@pasko70/pibo 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +106 -254
- package/context/codex-base-prompt.md +4 -0
- package/context/compute-worker.md +23 -0
- package/context/pibo-native-tooling.md +18 -0
- package/context/pibo-system-prompt.md +69 -8
- package/dist/api/simple-agent-api.js +136 -0
- package/dist/app-context.js +4 -0
- package/dist/apps/chat/agent-profiles.js +18 -3
- package/dist/apps/chat/agent-store.js +113 -16
- package/dist/apps/chat/chat-api-routes.js +311 -0
- package/dist/apps/chat/chat-capability-routes.js +90 -0
- package/dist/apps/chat/chat-files.js +178 -0
- package/dist/apps/chat/chat-request-normalizers.js +681 -0
- package/dist/apps/chat/chat-settings-routes.js +75 -0
- package/dist/apps/chat/chat-trace-helpers.js +94 -0
- package/dist/apps/chat/chat-user-skill-routes.js +149 -0
- package/dist/apps/chat/cron-api.js +213 -0
- package/dist/apps/chat/data/chat-data-mappers.js +74 -0
- package/dist/apps/chat/data/event-command-service.js +75 -0
- package/dist/apps/chat/data/navigation-query-service.js +11 -0
- package/dist/apps/chat/data/project-service.js +844 -0
- package/dist/apps/chat/data/read-state-service.js +42 -0
- package/dist/apps/chat/data/room-service.js +52 -0
- package/dist/apps/chat/data/session-query-service.js +63 -0
- package/dist/apps/chat/data/timeline-query-service.js +96 -0
- package/dist/apps/chat/event-log.js +1 -307
- package/dist/apps/chat/model-catalog.js +7 -2
- package/dist/apps/chat/output-compactor.js +126 -0
- package/dist/apps/chat/output-event-policy.js +17 -0
- package/dist/apps/chat/project-workflow-human-actions.js +347 -0
- package/dist/apps/chat/project-workflow-sessions.js +260 -0
- package/dist/apps/chat/provider-auth-actions.js +43 -0
- package/dist/apps/chat/ralph-api.js +156 -0
- package/dist/apps/chat/read-model.js +1 -218
- package/dist/apps/chat/rooms.js +1 -321
- package/dist/apps/chat/static-assets.js +996 -0
- package/dist/apps/chat/stream.js +29 -6
- package/dist/apps/chat/trace.js +179 -1003
- package/dist/apps/chat/types/event-store.js +1 -0
- package/dist/apps/chat/types/read-model.js +1 -0
- package/dist/apps/chat/types/rooms.js +36 -0
- package/dist/apps/chat/web-app.js +3131 -1959
- package/dist/apps/chat/workflow-catalog.js +572 -0
- package/dist/apps/chat/workflow-edge-compatibility.js +51 -0
- package/dist/apps/chat/workflow-json-schema-validation.js +335 -0
- package/dist/apps/chat/workflow-persistence-model.js +140 -0
- package/dist/apps/chat/workflow-persistence.js +633 -0
- package/dist/apps/chat/workflow-registered-ref-params.js +130 -0
- package/dist/apps/chat/workflow-registered-ref-pickers.js +179 -0
- package/dist/apps/chat/workflow-registered-ref-validation.js +210 -0
- package/dist/apps/chat/workflow-v2-security-validation.js +93 -0
- package/dist/apps/chat/workflow-validation-helpers.js +114 -0
- package/dist/apps/chat-ui/assets/{dist-CNLWH2qh.js → dist-B4lw9z4F.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-8e4L8ciw.js → dist-BbTaHWON.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-CMZOa5ik.js → dist-BcT_c1EJ.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-DNcnQRPF.js → dist-CGINd7XU.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-CqqUC8Ce.js → dist-CrBzZkUp.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-D2N4-LIc.js → dist-CyyISotB.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-CUqpST5w.js → dist-DFbnFNpX.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-CspjOeBj.js → dist-DGLWQLX8.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-B7bbI3Qz.js → dist-DfcIkFSN.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-v4pjHlB7.js → dist-sKDHTwaT.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-D9L4MSRF.js → dist-y9D6la48.js} +1 -1
- package/dist/apps/chat-ui/assets/index-C25VYnyb.css +1 -0
- package/dist/apps/chat-ui/assets/index-CUkuvI3v.js +165 -0
- package/dist/apps/chat-ui/assets/pwa-images/android/launchericon-144x144.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/android/launchericon-192x192.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/android/launchericon-48x48.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/android/launchericon-512x512.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/android/launchericon-72x72.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/android/launchericon-96x96.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/100.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/1024.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/114.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/120.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/128.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/144.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/152.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/16.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/167.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/180.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/192.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/20.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/256.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/29.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/32.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/40.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/50.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/512.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/57.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/58.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/60.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/64.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/72.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/76.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/80.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/ios/87.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/LargeTile.scale-100.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/LargeTile.scale-125.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/LargeTile.scale-150.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/LargeTile.scale-200.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/LargeTile.scale-400.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/SmallTile.scale-100.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/SmallTile.scale-125.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/SmallTile.scale-150.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/SmallTile.scale-200.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/SmallTile.scale-400.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/SplashScreen.scale-100.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/SplashScreen.scale-125.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/SplashScreen.scale-150.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/SplashScreen.scale-200.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/SplashScreen.scale-400.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square150x150Logo.scale-100.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square150x150Logo.scale-125.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square150x150Logo.scale-150.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square150x150Logo.scale-200.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square150x150Logo.scale-400.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-lightunplated_targetsize-16.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-lightunplated_targetsize-20.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-lightunplated_targetsize-24.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-lightunplated_targetsize-256.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-lightunplated_targetsize-30.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-lightunplated_targetsize-32.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-lightunplated_targetsize-36.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-lightunplated_targetsize-40.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-lightunplated_targetsize-44.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-lightunplated_targetsize-48.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-lightunplated_targetsize-60.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-lightunplated_targetsize-64.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-lightunplated_targetsize-72.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-lightunplated_targetsize-80.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-lightunplated_targetsize-96.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-unplated_targetsize-16.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-unplated_targetsize-20.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-unplated_targetsize-24.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-unplated_targetsize-256.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-unplated_targetsize-30.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-unplated_targetsize-32.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-unplated_targetsize-36.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-unplated_targetsize-40.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-unplated_targetsize-44.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-unplated_targetsize-48.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-unplated_targetsize-60.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-unplated_targetsize-64.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-unplated_targetsize-72.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-unplated_targetsize-80.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.altform-unplated_targetsize-96.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.scale-100.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.scale-125.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.scale-150.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.scale-200.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.scale-400.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.targetsize-16.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.targetsize-20.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.targetsize-24.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.targetsize-256.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.targetsize-30.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.targetsize-32.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.targetsize-36.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.targetsize-40.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.targetsize-44.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.targetsize-48.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.targetsize-60.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.targetsize-64.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.targetsize-72.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.targetsize-80.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Square44x44Logo.targetsize-96.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/StoreLogo.scale-100.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/StoreLogo.scale-125.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/StoreLogo.scale-150.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/StoreLogo.scale-200.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/StoreLogo.scale-400.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Wide310x150Logo.scale-100.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Wide310x150Logo.scale-125.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Wide310x150Logo.scale-150.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Wide310x150Logo.scale-200.png +0 -0
- package/dist/apps/chat-ui/assets/pwa-images/windows/Wide310x150Logo.scale-400.png +0 -0
- package/dist/apps/chat-ui/index.html +8 -3
- package/dist/apps/chat-ui/manifest.webmanifest +25 -0
- package/dist/apps/chat-ui/sw.js +41 -0
- package/dist/apps/cli-ui/InkSessionApp.js +1218 -0
- package/dist/apps/cli-ui/InkTerminalLine.js +53 -0
- package/dist/apps/cli-ui/InkTerminalRow.js +304 -0
- package/dist/apps/cli-ui/InkTerminalView.js +25 -0
- package/dist/apps/cli-ui/cliSessionsCommand.js +232 -0
- package/dist/apps/cli-ui/index.js +8 -0
- package/dist/apps/cli-ui/inkColors.js +67 -0
- package/dist/apps/cli-ui/inkJson.js +244 -0
- package/dist/apps/cli-ui/inkMarkdown.js +122 -0
- package/dist/apps/context-files-ui/assets/{dist-DFi2YGux.js → dist-BOiGdrG-.js} +1 -1
- package/dist/apps/context-files-ui/assets/{dist-DyfSeBMu.js → dist-DK01b7x4.js} +1 -1
- package/dist/apps/context-files-ui/assets/{dist-CwbH_3RN.js → dist-DPG9jOQ-.js} +1 -1
- package/dist/apps/context-files-ui/assets/{dist-dTBsFYAl.js → dist-Dp5AH00p.js} +1 -1
- package/dist/apps/context-files-ui/assets/{dist-CxRLRmMx.js → dist-DqYw0LH7.js} +1 -1
- package/dist/apps/context-files-ui/assets/{dist-MyZgX9K2.js → dist-TF5iO5ML.js} +1 -1
- package/dist/apps/context-files-ui/assets/{dist-DQXzt2Ng.js → dist-TbjAhles.js} +1 -1
- package/dist/apps/context-files-ui/assets/{dist-YwR9dpb-.js → dist-ZsBbt0uY.js} +1 -1
- package/dist/apps/context-files-ui/assets/{dist-CKQF1zEu.js → dist-kmsvtHkH.js} +1 -1
- package/dist/apps/context-files-ui/assets/{dist-BJW3917N.js → dist-vnd7PMu3.js} +1 -1
- package/dist/apps/context-files-ui/assets/{index-BwRDoHMC.css → index-B92tL3Pp.css} +1 -1
- package/dist/apps/context-files-ui/assets/{index-GwvjXytt.js → index-BhAWD3dv.js} +2 -2
- package/dist/apps/context-files-ui/index.html +2 -2
- package/dist/auth/better-auth.js +2 -1
- package/dist/auth/login-actions.js +251 -0
- package/dist/auth/openai-codex-usage.js +147 -0
- package/dist/bin/pibo.js +0 -0
- package/dist/bin/rg.js +15 -0
- package/dist/cli-session/fakeSessionSource.js +804 -0
- package/dist/cli-session/index.js +3 -0
- package/dist/cli-session/localSessionSource.js +1144 -0
- package/dist/cli-session/sessionSource.js +13 -0
- package/dist/cli.js +142 -14
- package/dist/compute/cli.js +415 -0
- package/dist/compute/docker.js +827 -0
- package/dist/compute/resource-health.js +333 -0
- package/dist/compute/resource-policy.js +98 -0
- package/dist/config/config.js +9 -5
- package/dist/core/context-build.js +677 -0
- package/dist/core/model-defaults.js +51 -9
- package/dist/core/pibo-home.js +8 -0
- package/dist/core/profiles.js +48 -0
- package/dist/core/provider-telemetry.js +222 -0
- package/dist/core/routed-session.js +441 -47
- package/dist/core/runtime-telemetry.js +853 -0
- package/dist/core/runtime.js +103 -15
- package/dist/core/session-errors.js +47 -0
- package/dist/core/session-model.js +39 -0
- package/dist/core/session-router.js +292 -62
- package/dist/core/shared-app.js +17 -0
- package/dist/core/skill-expansion.js +43 -0
- package/dist/core/system-prompt-template.js +9 -9
- package/dist/core/telemetry-staleness.js +128 -0
- package/dist/core/test-output-compaction.js +145 -0
- package/dist/core/user-settings.js +73 -0
- package/dist/cron/channel.js +28 -0
- package/dist/cron/cli.js +230 -0
- package/dist/cron/plugin.js +11 -0
- package/dist/cron/schedule.js +214 -0
- package/dist/cron/service.js +177 -0
- package/dist/cron/store.js +349 -0
- package/dist/cron/types.js +1 -0
- package/dist/data/cli.js +184 -0
- package/dist/data/event-log.js +106 -0
- package/dist/data/final-app-space-cutover-migration.js +728 -0
- package/dist/data/ingest-service.js +389 -0
- package/dist/data/message-store.js +62 -0
- package/dist/data/navigation-store.js +75 -0
- package/dist/data/observation-store.js +46 -0
- package/dist/data/payload-store.js +144 -0
- package/dist/data/pibo-store.js +59 -0
- package/dist/data/schema.js +434 -0
- package/dist/data/session-store.js +63 -0
- package/dist/data/shared-app-migration.js +757 -0
- package/dist/data/sqlite-schema.js +12 -0
- package/dist/data/telemetry-preview.js +65 -0
- package/dist/data/telemetry-queries.js +212 -0
- package/dist/data/telemetry-retention.js +50 -0
- package/dist/data/telemetry-rows.js +158 -0
- package/dist/data/telemetry.js +357 -0
- package/dist/debug/delta-compaction.js +99 -0
- package/dist/debug/detail-format.js +86 -0
- package/dist/debug/events.js +149 -29
- package/dist/debug/failures.js +162 -0
- package/dist/debug/index.js +655 -30
- package/dist/debug/messages.js +185 -0
- package/dist/debug/next-commands.js +6 -0
- package/dist/debug/payloads.js +123 -0
- package/dist/debug/pty.js +924 -0
- package/dist/debug/session.js +45 -15
- package/dist/debug/sql.js +1 -1
- package/dist/debug/stores.js +18 -13
- package/dist/debug/summary.js +72 -0
- package/dist/debug/telemetry.js +649 -0
- package/dist/debug/tools.js +168 -0
- package/dist/debug/trace-render-check.js +151 -0
- package/dist/debug/trace.js +152 -27
- package/dist/debug/web-artifacts.js +63 -0
- package/dist/debug/web-options.js +313 -0
- package/dist/debug/web-render-analysis.js +310 -0
- package/dist/debug/web-snapshot-browser-scripts.js +303 -0
- package/dist/debug/web-streaming-benchmark-analysis.js +605 -0
- package/dist/debug/web-streaming-browser-library.js +928 -0
- package/dist/debug/web-streaming-browser-scripts.js +242 -0
- package/dist/debug/web-streaming-provider-telemetry.js +194 -0
- package/dist/debug/web-streaming-report.js +493 -0
- package/dist/debug/web-streaming-types.js +1 -0
- package/dist/debug/web.js +574 -0
- package/dist/gateway/backup.js +83 -0
- package/dist/gateway/cli.js +511 -0
- package/dist/gateway/fallback.js +155 -0
- package/dist/gateway/pidfile.js +84 -0
- package/dist/gateway/protocol.js +16 -0
- package/dist/gateway/server.js +172 -17
- package/dist/gateway/tool.js +54 -51
- package/dist/gateway/web.js +74 -2
- package/dist/index.js +3 -1
- package/dist/local/client.js +3 -3
- package/dist/local/extension.js +8 -5
- package/dist/plugins/builtin.js +251 -49
- package/dist/plugins/chat-vscode-web.js +28 -0
- package/dist/plugins/codex-compat.js +0 -41
- package/dist/plugins/context-files.js +98 -18
- package/dist/plugins/dev-auth.js +124 -0
- package/dist/plugins/native-tooling.js +15 -0
- package/dist/plugins/registry.js +49 -1
- package/dist/plugins/web-annotations.js +27 -0
- package/dist/providers/minimax.js +70 -0
- package/dist/providers/openai-compat.js +48 -0
- package/dist/ralph/channel.js +8 -0
- package/dist/ralph/cli.js +152 -0
- package/dist/ralph/plugin.js +14 -0
- package/dist/ralph/service.js +271 -0
- package/dist/ralph/stopping.js +151 -0
- package/dist/ralph/store.js +450 -0
- package/dist/ralph/templates.js +200 -0
- package/dist/ralph/types.js +1 -0
- package/dist/reliability/store.js +42 -26
- package/dist/runs/registry.js +72 -35
- package/dist/session-ui/commandCatalog.js +193 -0
- package/dist/session-ui/commandResults.js +95 -0
- package/dist/session-ui/index.js +7 -0
- package/dist/session-ui/ownerViewModel.js +27 -0
- package/dist/session-ui/roomSessionViewModel.js +69 -0
- package/dist/session-ui/statusViewModel.js +127 -0
- package/dist/session-ui/terminalCards.js +210 -0
- package/dist/session-ui/terminalRows.js +937 -0
- package/dist/session-ui/terminalValue.js +45 -0
- package/dist/sessions/pibo-data-store.js +178 -0
- package/dist/sessions/sqlite-store.js +78 -12
- package/dist/sessions/store.js +11 -4
- package/dist/sessions/workflow-session-kind.js +20 -0
- package/dist/setup/cli.js +567 -0
- package/dist/shared/trace-async-agent-runs.js +127 -0
- package/dist/shared/trace-engine.js +96 -0
- package/dist/shared/trace-event-projection.js +679 -0
- package/dist/shared/trace-live-reducer.js +191 -0
- package/dist/shared/trace-nodes.js +76 -0
- package/dist/shared/trace-order.js +11 -10
- package/dist/shared/trace-patch-nodes.js +83 -0
- package/dist/shared/trace-run-notifications.js +69 -0
- package/dist/shared/trace-subagent-links.js +46 -0
- package/dist/shared/trace-transcript.js +303 -0
- package/dist/shared/trace-types.js +1 -0
- package/dist/shared-app.js +4 -0
- package/dist/signals/aggregate.js +65 -0
- package/dist/signals/events.js +1 -0
- package/dist/signals/projector.js +158 -0
- package/dist/signals/registry.js +513 -0
- package/dist/signals/store.js +1 -0
- package/dist/signals/types.js +1 -0
- package/dist/skills/cli.js +117 -0
- package/dist/tools/agent-browser-leases.js +219 -0
- package/dist/tools/agent-browser-wrapper.js +99 -0
- package/dist/tools/browser-pool.js +623 -0
- package/dist/tools/browser-use-cdp.js +56 -4
- package/dist/tools/browser-use-leases.js +215 -37
- package/dist/tools/browser-use-wrapper.js +508 -65
- package/dist/tools/cdp-client.js +189 -0
- package/dist/tools/guides.js +203 -4
- package/dist/tools/index.js +666 -16
- package/dist/tools/npm-runtime.js +136 -0
- package/dist/tools/registry.js +107 -8
- package/dist/tools/runtime/index.js +3 -0
- package/dist/tools/runtime/node-backend.js +225 -0
- package/dist/tools/runtime/node-worker-source.js +206 -0
- package/dist/tools/runtime/python-backend.js +227 -0
- package/dist/tools/runtime/python-worker-source.js +178 -0
- package/dist/tools/runtime/registry.js +255 -0
- package/dist/tools/runtime/tool.js +168 -0
- package/dist/tools/runtime/types.js +1 -0
- package/dist/tools/web-search.js +2 -1
- package/dist/user-skills/installer.js +39 -36
- package/dist/user-skills/store.js +50 -11
- package/dist/web/auth.js +5 -1
- package/dist/web/channel.js +86 -0
- package/dist/web/http.js +79 -14
- package/dist/web-annotations/api.js +348 -0
- package/dist/web-annotations/attachments.js +201 -0
- package/dist/web-annotations/cdp.js +1107 -0
- package/dist/web-annotations/index.js +7 -0
- package/dist/web-annotations/store.js +407 -0
- package/dist/web-annotations/tools.js +350 -0
- package/dist/web-annotations/types.js +34 -0
- package/dist/web-annotations/validation.js +288 -0
- package/docs/README.md +23 -0
- package/docs/ops/install-developer-host.md +112 -0
- package/docs/ops/install-user-host.md +76 -0
- package/docs/ops/upgrade-user-to-developer-host.md +69 -0
- package/package.json +24 -10
- package/skills/builtin/pi-agent-harness/SKILL.md +24 -24
- package/skills/builtin/pibo-docker-system/SKILL.md +170 -0
- package/skills/builtin/pibo-spec-writing/SKILL.md +330 -0
- package/skills/builtin/prd/SKILL.md +143 -0
- package/skills/builtin/ralph-loop/SKILL.md +359 -0
- package/skills/builtin/ralph-prd-json/SKILL.md +123 -0
- package/skills/builtin/skill-creator/LICENSE.txt +202 -0
- package/skills/builtin/skill-creator/SKILL.md +513 -0
- package/skills/builtin/skill-creator/agents/analyzer.md +274 -0
- package/skills/builtin/skill-creator/agents/comparator.md +202 -0
- package/skills/builtin/skill-creator/agents/grader.md +223 -0
- package/skills/builtin/skill-creator/assets/eval_review.html +146 -0
- package/skills/builtin/skill-creator/eval-viewer/generate_review.py +471 -0
- package/skills/builtin/skill-creator/eval-viewer/viewer.html +1325 -0
- package/skills/builtin/skill-creator/references/schemas.md +430 -0
- package/skills/builtin/skill-creator/scripts/__init__.py +0 -0
- package/skills/builtin/skill-creator/scripts/aggregate_benchmark.py +401 -0
- package/skills/builtin/skill-creator/scripts/generate_report.py +326 -0
- package/skills/builtin/skill-creator/scripts/improve_description.py +247 -0
- package/skills/builtin/skill-creator/scripts/package_skill.py +136 -0
- package/skills/builtin/skill-creator/scripts/quick_validate.py +103 -0
- package/skills/builtin/skill-creator/scripts/run_eval.py +310 -0
- package/skills/builtin/skill-creator/scripts/run_loop.py +328 -0
- package/skills/builtin/skill-creator/scripts/utils.py +47 -0
- package/skills/builtin/web-annotations/SKILL.md +93 -0
- package/dist/apps/chat-ui/assets/index-D2Qxambd.js +0 -151
- package/dist/apps/chat-ui/assets/index-DXx368XK.css +0 -1
- package/dist/env.js +0 -32
- package/dist/plugins/core-tools.js +0 -94
- package/dist/plugins/example.js +0 -67
- package/dist/plugins/remote-agent.js +0 -9
- package/dist/remote/channel.js +0 -176
- package/dist/remote/client.js +0 -92
- package/dist/remote/examples/tui-controller.js +0 -263
- package/dist/remote/protocol.js +0 -55
- package/dist/remote/session-client.js +0 -189
- package/dist/sessions/bindings.js +0 -41
|
@@ -1,7 +1,92 @@
|
|
|
1
|
-
import { SessionManager } from "@mariozechner/pi-coding-agent";
|
|
1
|
+
import { SessionManager, shouldCompact } from "@mariozechner/pi-coding-agent";
|
|
2
|
+
import { getOpenAiCodexProviderUsageForActiveModel } from "../auth/openai-codex-usage.js";
|
|
3
|
+
import { normalizeSessionErrorDetails, runtimeSessionErrorDetails } from "./session-errors.js";
|
|
4
|
+
import { expandInlineSkills } from "./skill-expansion.js";
|
|
5
|
+
const FAST_SERVICE_TIER = "priority";
|
|
6
|
+
function modelSupportsFastServiceTier(model) {
|
|
7
|
+
if (!model)
|
|
8
|
+
return false;
|
|
9
|
+
if (model.api === "openai-codex-responses")
|
|
10
|
+
return true;
|
|
11
|
+
return model.api === "openai-responses" && (model.provider === "openai" || model.provider === "openai-codex");
|
|
12
|
+
}
|
|
13
|
+
function withFastServiceTier(payload) {
|
|
14
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
15
|
+
return payload;
|
|
16
|
+
return { ...payload, service_tier: FAST_SERVICE_TIER };
|
|
17
|
+
}
|
|
18
|
+
function withFastServiceTierOption(options) {
|
|
19
|
+
return { ...(options ?? {}), serviceTier: FAST_SERVICE_TIER };
|
|
20
|
+
}
|
|
2
21
|
function errorMessage(error) {
|
|
3
22
|
return error instanceof Error ? error.message : String(error);
|
|
4
23
|
}
|
|
24
|
+
function numberValue(value) {
|
|
25
|
+
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
26
|
+
}
|
|
27
|
+
function stringValue(value) {
|
|
28
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
29
|
+
}
|
|
30
|
+
function parseEmbeddedProviderError(message) {
|
|
31
|
+
const jsonStart = message.indexOf("{");
|
|
32
|
+
if (jsonStart === -1)
|
|
33
|
+
return undefined;
|
|
34
|
+
try {
|
|
35
|
+
const parsed = JSON.parse(message.slice(jsonStart));
|
|
36
|
+
const error = parsed.error;
|
|
37
|
+
if (!error || typeof error !== "object")
|
|
38
|
+
return undefined;
|
|
39
|
+
return {
|
|
40
|
+
providerType: stringValue(error.type),
|
|
41
|
+
providerCode: stringValue(error.code),
|
|
42
|
+
providerParam: stringValue(error.param),
|
|
43
|
+
providerMessage: stringValue(error.message),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function assistantErrorDetails(message, context) {
|
|
51
|
+
const rawError = typeof message.errorMessage === "string" ? message.errorMessage : "";
|
|
52
|
+
const providerError = parseEmbeddedProviderError(rawError);
|
|
53
|
+
const usage = message.usage && typeof message.usage === "object" ? message.usage : undefined;
|
|
54
|
+
const contextTokens = numberValue(usage?.totalTokens);
|
|
55
|
+
const details = normalizeSessionErrorDetails(rawError, {
|
|
56
|
+
...(providerError?.providerCode === "context_length_exceeded" ? { category: "context_overflow", errorClass: "provider_context", code: "context_length_exceeded" } : {}),
|
|
57
|
+
...providerError,
|
|
58
|
+
api: stringValue(message.api),
|
|
59
|
+
provider: stringValue(message.provider),
|
|
60
|
+
model: stringValue(message.model),
|
|
61
|
+
contextWindow: context?.contextWindow,
|
|
62
|
+
contextTokens,
|
|
63
|
+
});
|
|
64
|
+
return Object.values(details).some((value) => value !== undefined) ? details : undefined;
|
|
65
|
+
}
|
|
66
|
+
function formatAssistantError(message, context) {
|
|
67
|
+
const rawError = typeof message.errorMessage === "string" && message.errorMessage.length > 0 ? message.errorMessage : "Assistant message failed.";
|
|
68
|
+
const details = assistantErrorDetails(message, context);
|
|
69
|
+
if (details?.category !== "context_overflow")
|
|
70
|
+
return rawError;
|
|
71
|
+
const lines = ["Context window exceeded while sending the model request."];
|
|
72
|
+
if (details.providerMessage)
|
|
73
|
+
lines.push(`Provider message: ${details.providerMessage}`);
|
|
74
|
+
if (details.providerCode)
|
|
75
|
+
lines.push(`Provider code: ${details.providerCode}`);
|
|
76
|
+
if (details.providerParam)
|
|
77
|
+
lines.push(`Provider param: ${details.providerParam}`);
|
|
78
|
+
if (details.api || details.provider || details.model) {
|
|
79
|
+
lines.push(`Model: ${[details.api, details.provider, details.model].filter(Boolean).join(" / ")}`);
|
|
80
|
+
}
|
|
81
|
+
if (details.contextTokens !== undefined || details.contextWindow !== undefined) {
|
|
82
|
+
const usage = details.contextWindow
|
|
83
|
+
? `${details.contextTokens ?? "unknown"} / ${details.contextWindow} tokens`
|
|
84
|
+
: `${details.contextTokens} tokens`;
|
|
85
|
+
lines.push(`Context usage: ${usage}`);
|
|
86
|
+
}
|
|
87
|
+
lines.push("Automatic overflow compaction will be attempted if auto-compaction is enabled.");
|
|
88
|
+
return lines.join("\n");
|
|
89
|
+
}
|
|
5
90
|
function messageContentIndex(candidate) {
|
|
6
91
|
return typeof candidate.assistantMessageEvent?.contentIndex === "number"
|
|
7
92
|
? candidate.assistantMessageEvent.contentIndex
|
|
@@ -102,7 +187,7 @@ function normalizeToolExecutionEvent(piboSessionId, candidate) {
|
|
|
102
187
|
}
|
|
103
188
|
return undefined;
|
|
104
189
|
}
|
|
105
|
-
function normalizePiEvent(piboSessionId, event) {
|
|
190
|
+
function normalizePiEvent(piboSessionId, event, context) {
|
|
106
191
|
if (!event || typeof event !== "object")
|
|
107
192
|
return undefined;
|
|
108
193
|
const candidate = event;
|
|
@@ -145,9 +230,8 @@ function normalizePiEvent(piboSessionId, event) {
|
|
|
145
230
|
return {
|
|
146
231
|
type: "session_error",
|
|
147
232
|
piboSessionId,
|
|
148
|
-
error:
|
|
149
|
-
|
|
150
|
-
: "Assistant message failed.",
|
|
233
|
+
error: formatAssistantError(message, context),
|
|
234
|
+
errorDetails: assistantErrorDetails(message, context),
|
|
151
235
|
};
|
|
152
236
|
}
|
|
153
237
|
const textPart = lastTextPartFromMessage(candidate.message);
|
|
@@ -163,49 +247,215 @@ function normalizePiEvent(piboSessionId, event) {
|
|
|
163
247
|
}
|
|
164
248
|
return undefined;
|
|
165
249
|
}
|
|
250
|
+
function estimateContextTokens(messages) {
|
|
251
|
+
let chars = 0;
|
|
252
|
+
for (const msg of messages) {
|
|
253
|
+
if (!msg || typeof msg !== "object")
|
|
254
|
+
continue;
|
|
255
|
+
const message = msg;
|
|
256
|
+
if (message.role === "user") {
|
|
257
|
+
const content = message.content;
|
|
258
|
+
if (typeof content === "string") {
|
|
259
|
+
chars += content.length;
|
|
260
|
+
}
|
|
261
|
+
else if (Array.isArray(content)) {
|
|
262
|
+
for (const block of content) {
|
|
263
|
+
if (block && typeof block === "object" && "type" in block && block.type === "text" && "text" in block && typeof block.text === "string") {
|
|
264
|
+
chars += block.text.length;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
else if (message.role === "assistant") {
|
|
270
|
+
const content = message.content;
|
|
271
|
+
if (Array.isArray(content)) {
|
|
272
|
+
for (const block of content) {
|
|
273
|
+
if (!block || typeof block !== "object")
|
|
274
|
+
continue;
|
|
275
|
+
if ("type" in block) {
|
|
276
|
+
if (block.type === "text" && "text" in block && typeof block.text === "string")
|
|
277
|
+
chars += block.text.length;
|
|
278
|
+
if (block.type === "thinking" && "thinking" in block && typeof block.thinking === "string")
|
|
279
|
+
chars += block.thinking.length;
|
|
280
|
+
if (block.type === "toolCall" && "name" in block && "arguments" in block) {
|
|
281
|
+
chars += String(block.name).length + JSON.stringify(block.arguments).length;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
else if (message.role === "toolResult" || message.role === "custom") {
|
|
288
|
+
const content = message.content;
|
|
289
|
+
if (typeof content === "string") {
|
|
290
|
+
chars += content.length;
|
|
291
|
+
}
|
|
292
|
+
else if (Array.isArray(content)) {
|
|
293
|
+
for (const block of content) {
|
|
294
|
+
if (block && typeof block === "object" && "type" in block && block.type === "text" && "text" in block && typeof block.text === "string") {
|
|
295
|
+
chars += block.text.length;
|
|
296
|
+
}
|
|
297
|
+
if (block && typeof block === "object" && "type" in block && block.type === "image") {
|
|
298
|
+
chars += 4800; // approximate image size
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return Math.ceil(chars / 4);
|
|
305
|
+
}
|
|
166
306
|
export class RoutedSession {
|
|
167
307
|
piboSessionId;
|
|
168
308
|
runtime;
|
|
169
309
|
emit;
|
|
170
310
|
pluginRegistry;
|
|
171
311
|
forwardPiEvents;
|
|
312
|
+
onPiEventTelemetry;
|
|
172
313
|
onSessionOperation;
|
|
314
|
+
onKillChildren;
|
|
315
|
+
onStateChange;
|
|
173
316
|
queue = [];
|
|
174
317
|
processing = false;
|
|
175
318
|
disposed = false;
|
|
319
|
+
fastMode = false;
|
|
320
|
+
fastModePatchedAgents = new WeakSet();
|
|
176
321
|
activeMessage;
|
|
177
322
|
activeAssistantIndex;
|
|
178
323
|
nextAssistantIndex = 0;
|
|
179
324
|
activeThinkingIndex;
|
|
180
325
|
nextThinkingIndex = 0;
|
|
181
326
|
unsubscribe;
|
|
182
|
-
|
|
327
|
+
isContinuePatched = false;
|
|
328
|
+
constructor(piboSessionId, runtime, emit, pluginRegistry, forwardPiEvents, onPiEventTelemetry, initialFastMode, onSessionOperation, onKillChildren, onStateChange) {
|
|
183
329
|
this.piboSessionId = piboSessionId;
|
|
184
330
|
this.runtime = runtime;
|
|
185
331
|
this.emit = emit;
|
|
186
332
|
this.pluginRegistry = pluginRegistry;
|
|
187
333
|
this.forwardPiEvents = forwardPiEvents;
|
|
334
|
+
this.onPiEventTelemetry = onPiEventTelemetry;
|
|
188
335
|
this.onSessionOperation = onSessionOperation;
|
|
336
|
+
this.onKillChildren = onKillChildren;
|
|
337
|
+
this.onStateChange = onStateChange;
|
|
338
|
+
this.fastMode = initialFastMode && this.fastModeSupported();
|
|
189
339
|
this.bindRuntimeSession();
|
|
340
|
+
this.patchFastModeProviderRequest();
|
|
341
|
+
this.patchAgentContinue();
|
|
190
342
|
this.runtime.setRebindSession(async () => {
|
|
191
343
|
this.bindRuntimeSession();
|
|
344
|
+
this.patchFastModeProviderRequest();
|
|
345
|
+
this.patchAgentContinue();
|
|
192
346
|
});
|
|
193
347
|
}
|
|
348
|
+
patchFastModeProviderRequest() {
|
|
349
|
+
const agent = this.runtime.session.agent;
|
|
350
|
+
if (!agent || typeof agent !== "object")
|
|
351
|
+
return;
|
|
352
|
+
if (this.fastModePatchedAgents.has(agent))
|
|
353
|
+
return;
|
|
354
|
+
this.fastModePatchedAgents.add(agent);
|
|
355
|
+
const originalStreamFn = typeof agent.streamFn === "function" ? agent.streamFn.bind(agent) : undefined;
|
|
356
|
+
if (originalStreamFn) {
|
|
357
|
+
agent.streamFn = (model, context, options) => {
|
|
358
|
+
const nextOptions = this.shouldUseFastServiceTier(model) ? withFastServiceTierOption(options) : options;
|
|
359
|
+
return originalStreamFn(model, context, nextOptions);
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
const originalOnPayload = agent.onPayload?.bind(agent);
|
|
363
|
+
agent.onPayload = async (payload, model) => {
|
|
364
|
+
const useFastTier = this.shouldUseFastServiceTier(model);
|
|
365
|
+
const payloadForHooks = useFastTier ? withFastServiceTier(payload) : payload;
|
|
366
|
+
const nextPayload = originalOnPayload ? await originalOnPayload(payloadForHooks, model) : payloadForHooks;
|
|
367
|
+
return useFastTier ? withFastServiceTier(nextPayload) : nextPayload;
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
shouldUseFastServiceTier(model) {
|
|
371
|
+
if (this.getFastModeResult().mode !== "fast")
|
|
372
|
+
return false;
|
|
373
|
+
return modelSupportsFastServiceTier(model) || modelSupportsFastServiceTier(this.runtime.session.model);
|
|
374
|
+
}
|
|
375
|
+
patchAgentContinue() {
|
|
376
|
+
if (this.isContinuePatched)
|
|
377
|
+
return;
|
|
378
|
+
this.isContinuePatched = true;
|
|
379
|
+
const agent = this.runtime.session.agent;
|
|
380
|
+
if (!agent)
|
|
381
|
+
return;
|
|
382
|
+
const originalContinue = agent.continue.bind(agent);
|
|
383
|
+
const session = this.runtime.session;
|
|
384
|
+
agent.continue = async () => {
|
|
385
|
+
const model = session.model;
|
|
386
|
+
if (!model)
|
|
387
|
+
return originalContinue();
|
|
388
|
+
const contextWindow = model.contextWindow ?? 0;
|
|
389
|
+
const settings = session.settingsManager.getCompactionSettings();
|
|
390
|
+
if (!settings.enabled)
|
|
391
|
+
return originalContinue();
|
|
392
|
+
let contextTokens = null;
|
|
393
|
+
const contextUsage = session.getContextUsage();
|
|
394
|
+
if (contextUsage && contextUsage.tokens !== null) {
|
|
395
|
+
contextTokens = contextUsage.tokens;
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
// Fallback: estimate tokens from current messages when no post-compaction
|
|
399
|
+
// assistant usage is available yet. This prevents context overflow between
|
|
400
|
+
// tool calls after a compaction.
|
|
401
|
+
contextTokens = estimateContextTokens(session.messages);
|
|
402
|
+
}
|
|
403
|
+
if (contextTokens === null)
|
|
404
|
+
return originalContinue();
|
|
405
|
+
if (shouldCompact(contextTokens, contextWindow, settings)) {
|
|
406
|
+
await session.compact();
|
|
407
|
+
}
|
|
408
|
+
return originalContinue();
|
|
409
|
+
};
|
|
410
|
+
}
|
|
194
411
|
bindRuntimeSession() {
|
|
195
412
|
this.unsubscribe?.();
|
|
196
413
|
this.unsubscribe = this.runtime.session.subscribe((event) => {
|
|
197
|
-
|
|
414
|
+
this.onPiEventTelemetry?.(this.piboSessionId, event, { status: this.getStatus(), activeEventId: this.activeMessage?.id });
|
|
415
|
+
const model = this.runtime.session.model;
|
|
416
|
+
const normalized = normalizePiEvent(this.piboSessionId, event, { contextWindow: numberValue(model?.contextWindow) });
|
|
198
417
|
if (normalized) {
|
|
199
418
|
this.emit(this.withActiveMessage(normalized));
|
|
200
419
|
}
|
|
201
420
|
if (this.forwardPiEvents) {
|
|
202
421
|
this.emit({ type: "pi_event", piboSessionId: this.piboSessionId, event });
|
|
203
422
|
}
|
|
423
|
+
this.handleCompactionEvent(event);
|
|
204
424
|
});
|
|
205
425
|
}
|
|
426
|
+
handleCompactionEvent(event) {
|
|
427
|
+
if (!event || typeof event !== "object")
|
|
428
|
+
return;
|
|
429
|
+
const candidate = event;
|
|
430
|
+
if (candidate.type === "compaction_start") {
|
|
431
|
+
this.emit({
|
|
432
|
+
type: "compaction_start",
|
|
433
|
+
piboSessionId: this.piboSessionId,
|
|
434
|
+
reason: typeof candidate.reason === "string" ? candidate.reason : "unknown",
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
if (candidate.type === "compaction_end") {
|
|
438
|
+
if (candidate.result && candidate.aborted !== true) {
|
|
439
|
+
// Reset assistant message indices so the next assistant response starts
|
|
440
|
+
// fresh after compaction, matching the reduced agent context.
|
|
441
|
+
this.activeAssistantIndex = undefined;
|
|
442
|
+
this.nextAssistantIndex = 0;
|
|
443
|
+
this.activeThinkingIndex = undefined;
|
|
444
|
+
this.nextThinkingIndex = 0;
|
|
445
|
+
}
|
|
446
|
+
this.emit({
|
|
447
|
+
type: "compaction_end",
|
|
448
|
+
piboSessionId: this.piboSessionId,
|
|
449
|
+
reason: typeof candidate.reason === "string" ? candidate.reason : "unknown",
|
|
450
|
+
result: candidate.result,
|
|
451
|
+
aborted: candidate.aborted === true,
|
|
452
|
+
errorMessage: typeof candidate.errorMessage === "string" ? candidate.errorMessage : undefined,
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
}
|
|
206
456
|
enqueueMessage(event) {
|
|
207
457
|
this.assertActive();
|
|
208
|
-
this.queue.push(event);
|
|
458
|
+
this.queue.push({ kind: "message", event });
|
|
209
459
|
const output = {
|
|
210
460
|
type: "message_queued",
|
|
211
461
|
piboSessionId: this.piboSessionId,
|
|
@@ -215,11 +465,15 @@ export class RoutedSession {
|
|
|
215
465
|
source: event.source,
|
|
216
466
|
};
|
|
217
467
|
this.emit(output);
|
|
468
|
+
this.onStateChange?.({ processing: this.processing, queuedMessages: this.queue.length, disposed: this.disposed });
|
|
218
469
|
void this.drain();
|
|
219
470
|
return output;
|
|
220
471
|
}
|
|
221
472
|
async executeAction(event) {
|
|
222
473
|
this.assertActive();
|
|
474
|
+
if (event.action === "compact") {
|
|
475
|
+
return this.enqueueCompactAction(event);
|
|
476
|
+
}
|
|
223
477
|
const result = await this.runAction(event);
|
|
224
478
|
if (isSessionOperationResult(result))
|
|
225
479
|
await this.onSessionOperation?.(result, event);
|
|
@@ -234,21 +488,42 @@ export class RoutedSession {
|
|
|
234
488
|
return output;
|
|
235
489
|
}
|
|
236
490
|
getStatus() {
|
|
491
|
+
const enabledTools = this.runtime.session.getActiveToolNames();
|
|
492
|
+
const thinkingLevel = this.runtime.session.thinkingLevel;
|
|
237
493
|
return {
|
|
238
494
|
piboSessionId: this.piboSessionId,
|
|
239
495
|
queuedMessages: this.queue.length,
|
|
240
496
|
processing: this.processing,
|
|
241
497
|
streaming: this.runtime.session.isStreaming,
|
|
242
|
-
activeTools:
|
|
498
|
+
activeTools: enabledTools,
|
|
499
|
+
enabledTools,
|
|
243
500
|
cwd: this.runtime.cwd,
|
|
244
501
|
disposed: this.disposed,
|
|
502
|
+
thinkingLevel,
|
|
503
|
+
fastMode: this.getFastModeResult().mode === "fast",
|
|
245
504
|
};
|
|
246
505
|
}
|
|
506
|
+
getContextUsage() {
|
|
507
|
+
return this.runtime.session.getContextUsage();
|
|
508
|
+
}
|
|
509
|
+
getActiveModel() {
|
|
510
|
+
const model = this.runtime.session.model;
|
|
511
|
+
return model ? { provider: model.provider, id: model.id } : undefined;
|
|
512
|
+
}
|
|
513
|
+
async getProviderUsage() {
|
|
514
|
+
try {
|
|
515
|
+
return await getOpenAiCodexProviderUsageForActiveModel(this.getActiveModel());
|
|
516
|
+
}
|
|
517
|
+
catch {
|
|
518
|
+
return undefined;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
247
521
|
removeQueuedMessages(predicate) {
|
|
248
522
|
this.assertActive();
|
|
249
523
|
let removed = 0;
|
|
250
524
|
for (let index = this.queue.length - 1; index >= 0; index -= 1) {
|
|
251
|
-
|
|
525
|
+
const item = this.queue[index];
|
|
526
|
+
if (item.kind !== "message" || !predicate(item.event))
|
|
252
527
|
continue;
|
|
253
528
|
this.queue.splice(index, 1);
|
|
254
529
|
removed += 1;
|
|
@@ -339,6 +614,14 @@ export class RoutedSession {
|
|
|
339
614
|
cancelled: result.cancelled,
|
|
340
615
|
};
|
|
341
616
|
}
|
|
617
|
+
async setModel(model) {
|
|
618
|
+
this.assertActive();
|
|
619
|
+
const resolved = this.runtime.session.modelRegistry.find(model.provider, model.id);
|
|
620
|
+
if (!resolved)
|
|
621
|
+
throw new Error(`Unknown model ${model.provider}/${model.id}`);
|
|
622
|
+
await this.runtime.session.setModel(resolved);
|
|
623
|
+
return { provider: resolved.provider, id: resolved.id };
|
|
624
|
+
}
|
|
342
625
|
setThinkingLevel(level) {
|
|
343
626
|
this.assertActive();
|
|
344
627
|
this.runtime.session.setThinkingLevel(level);
|
|
@@ -349,20 +632,44 @@ export class RoutedSession {
|
|
|
349
632
|
this.runtime.session.cycleThinkingLevel();
|
|
350
633
|
return this.getThinkingResult();
|
|
351
634
|
}
|
|
635
|
+
getFastMode() {
|
|
636
|
+
this.assertActive();
|
|
637
|
+
return this.getFastModeResult();
|
|
638
|
+
}
|
|
639
|
+
setFastMode(enabled) {
|
|
640
|
+
this.assertActive();
|
|
641
|
+
const before = this.getFastModeResult().mode;
|
|
642
|
+
if (this.fastModeSupported())
|
|
643
|
+
this.fastMode = enabled;
|
|
644
|
+
const current = this.getFastModeResult();
|
|
645
|
+
return { ...current, changed: before !== current.mode };
|
|
646
|
+
}
|
|
647
|
+
async compact(customInstructions) {
|
|
648
|
+
this.assertActive();
|
|
649
|
+
return await this.runtime.session.compact(customInstructions);
|
|
650
|
+
}
|
|
352
651
|
async dispose() {
|
|
353
652
|
if (this.disposed)
|
|
354
653
|
return;
|
|
355
654
|
this.queue.length = 0;
|
|
655
|
+
this.onStateChange?.({ processing: this.processing, queuedMessages: this.queue.length, disposed: true });
|
|
356
656
|
this.unsubscribe?.();
|
|
357
657
|
this.unsubscribe = undefined;
|
|
358
658
|
this.disposed = true;
|
|
359
659
|
await this.runtime.dispose();
|
|
360
660
|
}
|
|
661
|
+
async kill() {
|
|
662
|
+
this.queue.length = 0;
|
|
663
|
+
this.onStateChange?.({ processing: this.processing, queuedMessages: this.queue.length, disposed: this.disposed });
|
|
664
|
+
await this.runtime.session.abort();
|
|
665
|
+
return this.piboSessionId;
|
|
666
|
+
}
|
|
361
667
|
async cancelMessage(eventId) {
|
|
362
668
|
this.assertActive();
|
|
363
|
-
const queuedIndex = this.queue.findIndex((
|
|
669
|
+
const queuedIndex = this.queue.findIndex((item) => item.event.id === eventId);
|
|
364
670
|
if (queuedIndex >= 0) {
|
|
365
671
|
this.queue.splice(queuedIndex, 1);
|
|
672
|
+
this.onStateChange?.({ processing: this.processing, queuedMessages: this.queue.length, disposed: this.disposed });
|
|
366
673
|
return true;
|
|
367
674
|
}
|
|
368
675
|
if (this.activeMessage?.id === eventId) {
|
|
@@ -375,51 +682,101 @@ export class RoutedSession {
|
|
|
375
682
|
if (this.processing || this.disposed)
|
|
376
683
|
return;
|
|
377
684
|
this.processing = true;
|
|
685
|
+
this.onStateChange?.({ processing: this.processing, queuedMessages: this.queue.length, disposed: this.disposed });
|
|
378
686
|
try {
|
|
379
687
|
while (this.queue.length > 0 && !this.disposed) {
|
|
380
|
-
const
|
|
381
|
-
this.
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
eventId: event.id,
|
|
385
|
-
text: event.text,
|
|
386
|
-
source: event.source,
|
|
387
|
-
});
|
|
388
|
-
try {
|
|
389
|
-
this.activeMessage = event;
|
|
390
|
-
this.activeAssistantIndex = undefined;
|
|
391
|
-
this.nextAssistantIndex = 0;
|
|
392
|
-
this.activeThinkingIndex = undefined;
|
|
393
|
-
this.nextThinkingIndex = 0;
|
|
394
|
-
await this.runtime.session.prompt(event.text, { source: promptSource(event.source) });
|
|
395
|
-
this.emit({
|
|
396
|
-
type: "message_finished",
|
|
397
|
-
piboSessionId: this.piboSessionId,
|
|
398
|
-
eventId: event.id,
|
|
399
|
-
source: event.source,
|
|
400
|
-
});
|
|
688
|
+
const item = this.queue.shift();
|
|
689
|
+
this.onStateChange?.({ processing: this.processing, queuedMessages: this.queue.length, disposed: this.disposed });
|
|
690
|
+
if (item.kind === "compact") {
|
|
691
|
+
await this.processQueuedCompact(item.event);
|
|
401
692
|
}
|
|
402
|
-
|
|
403
|
-
this.
|
|
404
|
-
type: "session_error",
|
|
405
|
-
piboSessionId: this.piboSessionId,
|
|
406
|
-
eventId: event.id,
|
|
407
|
-
error: errorMessage(error),
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
finally {
|
|
411
|
-
this.activeMessage = undefined;
|
|
412
|
-
this.activeAssistantIndex = undefined;
|
|
413
|
-
this.nextAssistantIndex = 0;
|
|
414
|
-
this.activeThinkingIndex = undefined;
|
|
415
|
-
this.nextThinkingIndex = 0;
|
|
693
|
+
else {
|
|
694
|
+
await this.processQueuedMessage(item.event);
|
|
416
695
|
}
|
|
417
696
|
}
|
|
418
697
|
}
|
|
419
698
|
finally {
|
|
420
699
|
this.processing = false;
|
|
700
|
+
this.onStateChange?.({ processing: this.processing, queuedMessages: this.queue.length, disposed: this.disposed });
|
|
421
701
|
}
|
|
422
702
|
}
|
|
703
|
+
async processQueuedMessage(event) {
|
|
704
|
+
this.emit({
|
|
705
|
+
type: "message_started",
|
|
706
|
+
piboSessionId: this.piboSessionId,
|
|
707
|
+
eventId: event.id,
|
|
708
|
+
text: event.text,
|
|
709
|
+
source: event.source,
|
|
710
|
+
});
|
|
711
|
+
try {
|
|
712
|
+
this.activeMessage = event;
|
|
713
|
+
this.activeAssistantIndex = undefined;
|
|
714
|
+
this.nextAssistantIndex = 0;
|
|
715
|
+
this.activeThinkingIndex = undefined;
|
|
716
|
+
this.nextThinkingIndex = 0;
|
|
717
|
+
const expandedText = expandInlineSkills(event.text, this.runtime.session.resourceLoader.getSkills().skills);
|
|
718
|
+
await this.runtime.session.prompt(expandedText, { source: promptSource(event.source) });
|
|
719
|
+
this.emit({
|
|
720
|
+
type: "message_finished",
|
|
721
|
+
piboSessionId: this.piboSessionId,
|
|
722
|
+
eventId: event.id,
|
|
723
|
+
source: event.source,
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
catch (error) {
|
|
727
|
+
const message = errorMessage(error);
|
|
728
|
+
this.emit({
|
|
729
|
+
type: "session_error",
|
|
730
|
+
piboSessionId: this.piboSessionId,
|
|
731
|
+
eventId: event.id,
|
|
732
|
+
error: message,
|
|
733
|
+
errorDetails: runtimeSessionErrorDetails(message),
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
finally {
|
|
737
|
+
this.activeMessage = undefined;
|
|
738
|
+
this.activeAssistantIndex = undefined;
|
|
739
|
+
this.nextAssistantIndex = 0;
|
|
740
|
+
this.activeThinkingIndex = undefined;
|
|
741
|
+
this.nextThinkingIndex = 0;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
async processQueuedCompact(event) {
|
|
745
|
+
try {
|
|
746
|
+
const result = await this.runAction(event);
|
|
747
|
+
this.emit({
|
|
748
|
+
type: "execution_result",
|
|
749
|
+
piboSessionId: this.piboSessionId,
|
|
750
|
+
eventId: event.id,
|
|
751
|
+
action: event.action,
|
|
752
|
+
result,
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
catch (error) {
|
|
756
|
+
const message = errorMessage(error);
|
|
757
|
+
this.emit({
|
|
758
|
+
type: "session_error",
|
|
759
|
+
piboSessionId: this.piboSessionId,
|
|
760
|
+
eventId: event.id,
|
|
761
|
+
error: message,
|
|
762
|
+
errorDetails: runtimeSessionErrorDetails(message),
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
enqueueCompactAction(event) {
|
|
767
|
+
this.queue.push({ kind: "compact", event });
|
|
768
|
+
const output = {
|
|
769
|
+
type: "execution_result",
|
|
770
|
+
piboSessionId: this.piboSessionId,
|
|
771
|
+
eventId: event.id,
|
|
772
|
+
action: event.action,
|
|
773
|
+
result: { queued: true, queuedMessages: this.queue.length },
|
|
774
|
+
};
|
|
775
|
+
this.emit(output);
|
|
776
|
+
this.onStateChange?.({ processing: this.processing, queuedMessages: this.queue.length, disposed: this.disposed });
|
|
777
|
+
void this.drain();
|
|
778
|
+
return output;
|
|
779
|
+
}
|
|
423
780
|
async runAction(event) {
|
|
424
781
|
const action = event.action;
|
|
425
782
|
const gatewayAction = this.pluginRegistry.getGatewayAction(action);
|
|
@@ -429,6 +786,9 @@ export class RoutedSession {
|
|
|
429
786
|
return await gatewayAction.execute({
|
|
430
787
|
piboSessionId: this.piboSessionId,
|
|
431
788
|
getStatus: () => this.getStatus(),
|
|
789
|
+
getContextUsage: () => this.getContextUsage(),
|
|
790
|
+
getActiveModel: () => this.getActiveModel(),
|
|
791
|
+
getProviderUsage: () => this.getProviderUsage(),
|
|
432
792
|
clearQueue: () => this.clearQueue(),
|
|
433
793
|
abort: async () => {
|
|
434
794
|
await this.runtime.session.abort();
|
|
@@ -442,8 +802,33 @@ export class RoutedSession {
|
|
|
442
802
|
getSessionTree: () => this.getSessionTree(),
|
|
443
803
|
navigateSessionTree: (params) => this.navigateSessionTree(params),
|
|
444
804
|
switchSession: (params) => this.switchSession(params),
|
|
805
|
+
getThinkingLevel: () => this.getThinkingResult(),
|
|
445
806
|
setThinkingLevel: (level) => this.setThinkingLevel(level),
|
|
446
807
|
cycleThinkingLevel: () => this.cycleThinkingLevel(),
|
|
808
|
+
getFastMode: () => this.getFastMode(),
|
|
809
|
+
setFastMode: (enabled) => this.setFastMode(enabled),
|
|
810
|
+
setModel: (model) => this.setModel(model),
|
|
811
|
+
compact: (customInstructions) => this.compact(customInstructions),
|
|
812
|
+
kill: async () => {
|
|
813
|
+
const killed = [await this.kill()];
|
|
814
|
+
let cancelledRuns = [];
|
|
815
|
+
if (this.onKillChildren) {
|
|
816
|
+
const children = await this.onKillChildren(this.piboSessionId);
|
|
817
|
+
killed.push(...children.killed);
|
|
818
|
+
cancelledRuns = children.cancelledRuns;
|
|
819
|
+
}
|
|
820
|
+
return { killed, cancelledRuns };
|
|
821
|
+
},
|
|
822
|
+
killAll: async () => {
|
|
823
|
+
const killed = [await this.kill()];
|
|
824
|
+
let cancelledRuns = [];
|
|
825
|
+
if (this.onKillChildren) {
|
|
826
|
+
const children = await this.onKillChildren(this.piboSessionId, { includeRuns: true });
|
|
827
|
+
killed.push(...children.killed);
|
|
828
|
+
cancelledRuns = children.cancelledRuns;
|
|
829
|
+
}
|
|
830
|
+
return { killed, cancelledRuns };
|
|
831
|
+
},
|
|
447
832
|
}, event);
|
|
448
833
|
}
|
|
449
834
|
assertActive() {
|
|
@@ -458,9 +843,17 @@ export class RoutedSession {
|
|
|
458
843
|
supported: this.runtime.session.supportsThinking(),
|
|
459
844
|
};
|
|
460
845
|
}
|
|
846
|
+
getFastModeResult() {
|
|
847
|
+
const supported = this.fastModeSupported();
|
|
848
|
+
return { mode: supported && this.fastMode ? "fast" : "normal", supported };
|
|
849
|
+
}
|
|
850
|
+
fastModeSupported() {
|
|
851
|
+
return this.runtime.session.supportsThinking() && modelSupportsFastServiceTier(this.runtime.session.model);
|
|
852
|
+
}
|
|
461
853
|
clearQueue() {
|
|
462
854
|
const cleared = this.queue.length;
|
|
463
855
|
this.queue.length = 0;
|
|
856
|
+
this.onStateChange?.({ processing: this.processing, queuedMessages: this.queue.length, disposed: this.disposed });
|
|
464
857
|
return cleared;
|
|
465
858
|
}
|
|
466
859
|
createSessionSnapshot() {
|
|
@@ -514,7 +907,8 @@ export class RoutedSession {
|
|
|
514
907
|
event.type === "tool_execution_started" ||
|
|
515
908
|
event.type === "tool_execution_updated" ||
|
|
516
909
|
event.type === "tool_execution_finished" ||
|
|
517
|
-
event.type === "session_error"
|
|
910
|
+
event.type === "session_error" ||
|
|
911
|
+
event.type === "execution_result")) {
|
|
518
912
|
return { ...event, eventId: this.activeMessage.id };
|
|
519
913
|
}
|
|
520
914
|
return event;
|