@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
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { rootSessionId } from "./session-store.js";
|
|
3
|
+
const INLINE_MESSAGE_PAYLOAD_THRESHOLD_BYTES = 16 * 1024;
|
|
4
|
+
const INLINE_JSON_PAYLOAD_THRESHOLD_BYTES = 16 * 1024;
|
|
5
|
+
export class ChatDataIngestService {
|
|
6
|
+
store;
|
|
7
|
+
constructor(store) {
|
|
8
|
+
this.store = store;
|
|
9
|
+
}
|
|
10
|
+
ingestUserMessageAccepted(input) {
|
|
11
|
+
const idempotencyKey = input.clientTxnId
|
|
12
|
+
? `chat:user.accepted:${input.roomId}:${input.actorId}:${input.clientTxnId}`
|
|
13
|
+
: undefined;
|
|
14
|
+
const messageId = idempotencyKey ? deterministicId("msg", idempotencyKey) : `msg_${randomUUID()}`;
|
|
15
|
+
const existingMessage = this.store.messages.getMessage(messageId);
|
|
16
|
+
if (existingMessage && idempotencyKey) {
|
|
17
|
+
const existingEvent = this.store.eventLog.findByIdempotencyKey(idempotencyKey);
|
|
18
|
+
return {
|
|
19
|
+
streamId: existingEvent?.streamId ?? existingMessage.sourceStreamId ?? 0,
|
|
20
|
+
messageId: existingMessage.id,
|
|
21
|
+
duplicate: true,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return this.store.transaction(() => {
|
|
25
|
+
const now = input.legacyEvent?.createdAt ?? new Date().toISOString();
|
|
26
|
+
this.store.sessions.upsertSession({ session: input.session, roomId: input.roomId, firstMessagePreview: input.text, lastActivityAt: now });
|
|
27
|
+
const payloadRef = this.writeTextPayloadIfLarge(input.text, now, "chat_message");
|
|
28
|
+
const event = this.store.eventLog.appendEvent({
|
|
29
|
+
sessionId: input.session.id,
|
|
30
|
+
sessionSequence: this.nextEventSequence(input.session.id),
|
|
31
|
+
roomId: input.roomId,
|
|
32
|
+
topic: "chat",
|
|
33
|
+
type: "user.message.accepted",
|
|
34
|
+
source: "user",
|
|
35
|
+
actorType: "user",
|
|
36
|
+
actorId: input.actorId,
|
|
37
|
+
eventId: input.legacyEvent?.eventId,
|
|
38
|
+
idempotencyKey,
|
|
39
|
+
retentionClass: "chat_message",
|
|
40
|
+
payloadRef,
|
|
41
|
+
previewText: previewText(input.text),
|
|
42
|
+
attributes: compactObject({
|
|
43
|
+
clientTxnId: input.clientTxnId,
|
|
44
|
+
legacyStreamId: input.legacyEvent?.streamId,
|
|
45
|
+
inlineText: payloadRef ? undefined : input.text,
|
|
46
|
+
}),
|
|
47
|
+
createdAt: now,
|
|
48
|
+
indexedAt: now,
|
|
49
|
+
});
|
|
50
|
+
const existingAfterEvent = this.store.messages.getMessage(messageId);
|
|
51
|
+
if (existingAfterEvent && idempotencyKey) {
|
|
52
|
+
return { streamId: event.streamId, messageId: existingAfterEvent.id, duplicate: true };
|
|
53
|
+
}
|
|
54
|
+
this.store.messages.insertMessage({
|
|
55
|
+
id: messageId,
|
|
56
|
+
sessionId: input.session.id,
|
|
57
|
+
roomId: input.roomId,
|
|
58
|
+
sequence: this.nextMessageSequence(input.session.id),
|
|
59
|
+
role: "user",
|
|
60
|
+
actorId: input.actorId,
|
|
61
|
+
status: "complete",
|
|
62
|
+
createdAt: now,
|
|
63
|
+
completedAt: now,
|
|
64
|
+
contentPreview: previewText(input.text),
|
|
65
|
+
contentPayloadRef: payloadRef,
|
|
66
|
+
sourceStreamId: event.streamId,
|
|
67
|
+
attributes: compactObject({
|
|
68
|
+
clientTxnId: input.clientTxnId,
|
|
69
|
+
inlineText: payloadRef ? undefined : input.text,
|
|
70
|
+
}),
|
|
71
|
+
});
|
|
72
|
+
this.upsertNavigation(input.session, input.roomId, previewText(input.text), now, "running");
|
|
73
|
+
return { streamId: event.streamId, messageId, duplicate: false };
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
ingestOutputEvent(input) {
|
|
77
|
+
const event = input.event;
|
|
78
|
+
const idempotencyKey = outputIdempotencyKey(event);
|
|
79
|
+
if (idempotencyKey) {
|
|
80
|
+
const existing = this.store.eventLog.findByIdempotencyKey(idempotencyKey);
|
|
81
|
+
if (existing) {
|
|
82
|
+
return {
|
|
83
|
+
streamId: existing.streamId,
|
|
84
|
+
duplicate: true,
|
|
85
|
+
messageId: messageIdForOutputEvent(event),
|
|
86
|
+
observationId: observationIdForOutputEvent(event),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return this.store.transaction(() => {
|
|
91
|
+
const now = input.createdAt ?? new Date().toISOString();
|
|
92
|
+
if (input.roomId) {
|
|
93
|
+
this.store.sessions.upsertSession({ session: input.session, roomId: input.roomId, lastActivityAt: now, status: outputSessionStatus(event) });
|
|
94
|
+
}
|
|
95
|
+
const payload = payloadForOutputEvent(event);
|
|
96
|
+
const payloadRef = payload ? this.writePayloadIfLarge(payload.value, payload.contentType, now, retentionClassForOutputEvent(event)) : undefined;
|
|
97
|
+
const storedEvent = this.store.eventLog.appendEvent({
|
|
98
|
+
sessionId: input.session.id,
|
|
99
|
+
sessionSequence: this.nextEventSequence(input.session.id),
|
|
100
|
+
roomId: input.roomId,
|
|
101
|
+
topic: "pibo.output",
|
|
102
|
+
type: event.type,
|
|
103
|
+
source: "actor",
|
|
104
|
+
actorType: actorTypeForOutputEvent(event),
|
|
105
|
+
actorId: input.actorId,
|
|
106
|
+
turnId: turnIdForOutputEvent(event),
|
|
107
|
+
eventId: eventIdForOutputEvent(event),
|
|
108
|
+
toolCallId: "toolCallId" in event ? event.toolCallId : undefined,
|
|
109
|
+
runId: eventIdForOutputEvent(event),
|
|
110
|
+
idempotencyKey,
|
|
111
|
+
retentionClass: retentionClassForOutputEvent(event),
|
|
112
|
+
payloadRef,
|
|
113
|
+
previewText: previewTextForOutputEvent(event),
|
|
114
|
+
attributes: compactObject({
|
|
115
|
+
legacyStreamId: input.legacyStreamId,
|
|
116
|
+
inlinePayload: payloadRef ? undefined : toPiboJsonValue(payload?.value),
|
|
117
|
+
...attributesForOutputEvent(event),
|
|
118
|
+
}),
|
|
119
|
+
createdAt: now,
|
|
120
|
+
indexedAt: now,
|
|
121
|
+
});
|
|
122
|
+
let messageId;
|
|
123
|
+
if (event.type === "assistant_message") {
|
|
124
|
+
messageId = messageIdForOutputEvent(event);
|
|
125
|
+
if (messageId && !this.store.messages.getMessage(messageId)) {
|
|
126
|
+
this.store.messages.insertMessage({
|
|
127
|
+
id: messageId,
|
|
128
|
+
sessionId: input.session.id,
|
|
129
|
+
roomId: input.roomId,
|
|
130
|
+
sequence: this.nextMessageSequence(input.session.id),
|
|
131
|
+
turnId: turnIdForOutputEvent(event),
|
|
132
|
+
role: "assistant",
|
|
133
|
+
actorId: input.actorId,
|
|
134
|
+
status: "complete",
|
|
135
|
+
createdAt: now,
|
|
136
|
+
completedAt: now,
|
|
137
|
+
contentPreview: previewText(event.text),
|
|
138
|
+
contentPayloadRef: payloadRef,
|
|
139
|
+
sourceStreamId: storedEvent.streamId,
|
|
140
|
+
attributes: compactObject({
|
|
141
|
+
eventId: event.eventId,
|
|
142
|
+
assistantIndex: event.assistantIndex,
|
|
143
|
+
contentIndex: event.contentIndex,
|
|
144
|
+
inlineText: payloadRef ? undefined : event.text,
|
|
145
|
+
}),
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const observationId = observationIdForOutputEvent(event);
|
|
150
|
+
this.store.observations.insertObservation({
|
|
151
|
+
id: observationId,
|
|
152
|
+
sessionId: input.session.id,
|
|
153
|
+
turnId: turnIdForOutputEvent(event),
|
|
154
|
+
eventStreamId: storedEvent.streamId,
|
|
155
|
+
kind: observationKindForOutputEvent(event),
|
|
156
|
+
role: observationRoleForOutputEvent(event),
|
|
157
|
+
name: observationNameForOutputEvent(event),
|
|
158
|
+
status: observationStatusForOutputEvent(event),
|
|
159
|
+
startedAt: now,
|
|
160
|
+
endedAt: isTerminalOutputEvent(event) ? now : undefined,
|
|
161
|
+
previewText: previewTextForOutputEvent(event),
|
|
162
|
+
payloadRef,
|
|
163
|
+
attributes: compactObject({ eventType: event.type, eventId: eventIdForOutputEvent(event), ...attributesForOutputEvent(event) }),
|
|
164
|
+
});
|
|
165
|
+
if (input.roomId && (event.type === "assistant_message" || event.type === "message_finished" || event.type === "session_error")) {
|
|
166
|
+
const navigationPreview = event.type === "message_finished" ? undefined : previewTextForOutputEvent(event);
|
|
167
|
+
this.upsertNavigation(input.session, input.roomId, navigationPreview, now, outputSessionStatus(event));
|
|
168
|
+
}
|
|
169
|
+
return { streamId: storedEvent.streamId, duplicate: false, messageId, observationId };
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
nextEventSequence(sessionId) {
|
|
173
|
+
const row = this.store.db.prepare("SELECT COALESCE(MAX(session_sequence), 0) + 1 AS next_sequence FROM event_log WHERE session_id = ?").get(sessionId);
|
|
174
|
+
return row.next_sequence;
|
|
175
|
+
}
|
|
176
|
+
nextMessageSequence(sessionId) {
|
|
177
|
+
const row = this.store.db.prepare("SELECT COALESCE(MAX(sequence), 0) + 1 AS next_sequence FROM chat_messages WHERE session_id = ?").get(sessionId);
|
|
178
|
+
return row.next_sequence;
|
|
179
|
+
}
|
|
180
|
+
writeTextPayloadIfLarge(text, createdAt, retentionClass) {
|
|
181
|
+
if (Buffer.byteLength(text, "utf8") <= INLINE_MESSAGE_PAYLOAD_THRESHOLD_BYTES)
|
|
182
|
+
return undefined;
|
|
183
|
+
return this.store.payloads.writePayload({
|
|
184
|
+
value: text,
|
|
185
|
+
contentType: "text/plain; charset=utf-8",
|
|
186
|
+
retentionClass,
|
|
187
|
+
createdAt,
|
|
188
|
+
}).id;
|
|
189
|
+
}
|
|
190
|
+
writePayloadIfLarge(value, contentType, createdAt, retentionClass) {
|
|
191
|
+
const bytes = Buffer.byteLength(typeof value === "string" ? value : JSON.stringify(value), "utf8");
|
|
192
|
+
const threshold = typeof value === "string" ? INLINE_MESSAGE_PAYLOAD_THRESHOLD_BYTES : INLINE_JSON_PAYLOAD_THRESHOLD_BYTES;
|
|
193
|
+
if (bytes <= threshold)
|
|
194
|
+
return undefined;
|
|
195
|
+
return this.store.payloads.writePayload({ value, contentType, retentionClass, createdAt }).id;
|
|
196
|
+
}
|
|
197
|
+
upsertNavigation(session, roomId, lastMessagePreview, now, status) {
|
|
198
|
+
this.store.navigation.upsertSession({
|
|
199
|
+
roomId,
|
|
200
|
+
sessionId: session.id,
|
|
201
|
+
rootSessionId: rootSessionId(session),
|
|
202
|
+
parentId: session.parentId,
|
|
203
|
+
originId: session.originId,
|
|
204
|
+
title: session.title || lastMessagePreview || "Untitled Session",
|
|
205
|
+
profile: session.profile,
|
|
206
|
+
status,
|
|
207
|
+
lastActivityAt: now,
|
|
208
|
+
lastMessagePreview,
|
|
209
|
+
sortKey: now,
|
|
210
|
+
updatedAt: now,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function deterministicId(prefix, value) {
|
|
215
|
+
return `${prefix}_${createHash("sha256").update(value).digest("hex").slice(0, 32)}`;
|
|
216
|
+
}
|
|
217
|
+
function hashJson(value) {
|
|
218
|
+
return createHash("sha256").update(JSON.stringify(value) ?? "null").digest("hex").slice(0, 16);
|
|
219
|
+
}
|
|
220
|
+
function previewText(text) {
|
|
221
|
+
const normalized = text.replace(/\s+/g, " ").trim();
|
|
222
|
+
return normalized ? normalized.slice(0, 512) : undefined;
|
|
223
|
+
}
|
|
224
|
+
function compactObject(value) {
|
|
225
|
+
return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== undefined));
|
|
226
|
+
}
|
|
227
|
+
function outputIdempotencyKey(event) {
|
|
228
|
+
const base = eventIdForOutputEvent(event) ?? ("toolCallId" in event ? event.toolCallId : undefined);
|
|
229
|
+
if (!base)
|
|
230
|
+
return undefined;
|
|
231
|
+
return `pibo.output:${event.piboSessionId}:${event.type}:${base}:${outputPartKey(event)}`;
|
|
232
|
+
}
|
|
233
|
+
function outputPartKey(event) {
|
|
234
|
+
if (event.type === "tool_call")
|
|
235
|
+
return `${event.toolCallId}:${event.argsComplete ? "complete" : "partial"}:${hashJson(event.args)}`;
|
|
236
|
+
if ("toolCallId" in event)
|
|
237
|
+
return event.toolCallId ?? "main";
|
|
238
|
+
if (event.type === "assistant_message")
|
|
239
|
+
return String(event.assistantIndex ?? event.contentIndex ?? 0);
|
|
240
|
+
if (event.type === "assistant_delta")
|
|
241
|
+
return String(event.assistantIndex ?? event.contentIndex ?? 0);
|
|
242
|
+
if (event.type === "thinking_started" || event.type === "thinking_delta" || event.type === "thinking_finished")
|
|
243
|
+
return String(event.thinkingIndex ?? event.contentIndex ?? 0);
|
|
244
|
+
if (event.type === "execution_result")
|
|
245
|
+
return event.action;
|
|
246
|
+
return "main";
|
|
247
|
+
}
|
|
248
|
+
function messageIdForOutputEvent(event) {
|
|
249
|
+
if (event.type !== "assistant_message")
|
|
250
|
+
return undefined;
|
|
251
|
+
return deterministicId("msg", outputIdempotencyKey(event) ?? JSON.stringify(event));
|
|
252
|
+
}
|
|
253
|
+
function observationIdForOutputEvent(event) {
|
|
254
|
+
return deterministicId("obs", outputIdempotencyKey(event) ?? JSON.stringify(event));
|
|
255
|
+
}
|
|
256
|
+
function turnIdForOutputEvent(event) {
|
|
257
|
+
return eventIdForOutputEvent(event) ?? ("toolCallId" in event ? event.toolCallId : undefined);
|
|
258
|
+
}
|
|
259
|
+
function eventIdForOutputEvent(event) {
|
|
260
|
+
return "eventId" in event ? event.eventId : undefined;
|
|
261
|
+
}
|
|
262
|
+
function retentionClassForOutputEvent(event) {
|
|
263
|
+
if (event.type === "assistant_message" || event.type === "message_started" || event.type === "message_finished")
|
|
264
|
+
return "chat_message";
|
|
265
|
+
if (event.type === "assistant_delta" || event.type === "thinking_delta" || event.type === "tool_execution_updated")
|
|
266
|
+
return "live_delta";
|
|
267
|
+
return "trace_event";
|
|
268
|
+
}
|
|
269
|
+
function actorTypeForOutputEvent(event) {
|
|
270
|
+
if (event.type === "assistant_message" || event.type === "assistant_delta" || event.type.startsWith("thinking_"))
|
|
271
|
+
return "assistant";
|
|
272
|
+
if (event.type.startsWith("tool_") || event.type === "subagent_session")
|
|
273
|
+
return "agent";
|
|
274
|
+
if (event.type === "session_error")
|
|
275
|
+
return "system";
|
|
276
|
+
return "agent";
|
|
277
|
+
}
|
|
278
|
+
function payloadForOutputEvent(event) {
|
|
279
|
+
if (event.type === "assistant_message" || event.type === "assistant_delta" || event.type === "thinking_delta" || event.type === "thinking_finished") {
|
|
280
|
+
return { value: event.text ?? "", contentType: "text/plain; charset=utf-8" };
|
|
281
|
+
}
|
|
282
|
+
if (event.type === "tool_call" || event.type === "tool_execution_started")
|
|
283
|
+
return { value: toPiboJsonValueOrNull(event.args), contentType: "application/json" };
|
|
284
|
+
if (event.type === "tool_execution_updated")
|
|
285
|
+
return { value: toPiboJsonValueOrNull(event.partialResult), contentType: "application/json" };
|
|
286
|
+
if (event.type === "tool_execution_finished")
|
|
287
|
+
return { value: toPiboJsonValueOrNull(event.result), contentType: "application/json" };
|
|
288
|
+
if (event.type === "execution_result")
|
|
289
|
+
return { value: toPiboJsonValueOrNull(event.result), contentType: "application/json" };
|
|
290
|
+
if (event.type === "pi_event")
|
|
291
|
+
return { value: toPiboJsonValueOrNull(event.event), contentType: "application/json" };
|
|
292
|
+
if (event.type === "compaction_end" && event.result !== undefined)
|
|
293
|
+
return { value: toPiboJsonValueOrNull(event.result), contentType: "application/json" };
|
|
294
|
+
return undefined;
|
|
295
|
+
}
|
|
296
|
+
function previewTextForOutputEvent(event) {
|
|
297
|
+
if (event.type === "assistant_message" || event.type === "assistant_delta" || event.type === "thinking_delta" || event.type === "thinking_finished")
|
|
298
|
+
return previewText(event.text ?? "");
|
|
299
|
+
if (event.type === "message_queued" || event.type === "message_started")
|
|
300
|
+
return previewText(event.text);
|
|
301
|
+
if (event.type === "tool_call" || event.type === "tool_execution_started" || event.type === "tool_execution_updated" || event.type === "tool_execution_finished")
|
|
302
|
+
return event.toolName;
|
|
303
|
+
if (event.type === "subagent_session")
|
|
304
|
+
return `${event.subagentName} via ${event.toolName}`;
|
|
305
|
+
if (event.type === "execution_result")
|
|
306
|
+
return event.action;
|
|
307
|
+
if (event.type === "session_error")
|
|
308
|
+
return previewText(event.error);
|
|
309
|
+
if (event.type === "compaction_start" || event.type === "compaction_end")
|
|
310
|
+
return event.reason;
|
|
311
|
+
return event.type;
|
|
312
|
+
}
|
|
313
|
+
function attributesForOutputEvent(event) {
|
|
314
|
+
if (event.type === "message_queued")
|
|
315
|
+
return { inlineText: event.text, source: event.source, queuedMessages: event.queuedMessages };
|
|
316
|
+
if (event.type === "assistant_message" || event.type === "assistant_delta")
|
|
317
|
+
return { assistantIndex: event.assistantIndex, contentIndex: event.contentIndex };
|
|
318
|
+
if (event.type === "thinking_started" || event.type === "thinking_delta" || event.type === "thinking_finished")
|
|
319
|
+
return { thinkingIndex: event.thinkingIndex, contentIndex: event.contentIndex };
|
|
320
|
+
if (event.type === "tool_call")
|
|
321
|
+
return { toolCallId: event.toolCallId, toolName: event.toolName, argsComplete: event.argsComplete };
|
|
322
|
+
if (event.type === "tool_execution_started" || event.type === "tool_execution_updated" || event.type === "tool_execution_finished")
|
|
323
|
+
return { toolCallId: event.toolCallId, toolName: event.toolName, isError: "isError" in event ? event.isError : undefined };
|
|
324
|
+
if (event.type === "subagent_session")
|
|
325
|
+
return { toolCallId: event.toolCallId, toolName: event.toolName, subagentName: event.subagentName, childPiboSessionId: event.childPiboSessionId, threadKey: event.threadKey };
|
|
326
|
+
if (event.type === "execution_result")
|
|
327
|
+
return { action: event.action };
|
|
328
|
+
if (event.type === "session_error")
|
|
329
|
+
return { error: event.error, ...(event.errorDetails ? { errorDetails: event.errorDetails } : {}) };
|
|
330
|
+
if (event.type === "compaction_start" || event.type === "compaction_end")
|
|
331
|
+
return { reason: event.reason, aborted: "aborted" in event ? event.aborted : undefined, errorMessage: "errorMessage" in event ? event.errorMessage : undefined };
|
|
332
|
+
return {};
|
|
333
|
+
}
|
|
334
|
+
function observationKindForOutputEvent(event) {
|
|
335
|
+
if (event.type === "assistant_message" || event.type === "assistant_delta")
|
|
336
|
+
return "message";
|
|
337
|
+
if (event.type.startsWith("thinking_"))
|
|
338
|
+
return "thinking";
|
|
339
|
+
if (event.type.startsWith("tool_") || event.type === "subagent_session")
|
|
340
|
+
return "tool";
|
|
341
|
+
if (event.type === "execution_result")
|
|
342
|
+
return "execution";
|
|
343
|
+
if (event.type === "session_error")
|
|
344
|
+
return "error";
|
|
345
|
+
if (event.type.startsWith("compaction_"))
|
|
346
|
+
return "compaction";
|
|
347
|
+
return "event";
|
|
348
|
+
}
|
|
349
|
+
function observationRoleForOutputEvent(event) {
|
|
350
|
+
if (event.type === "assistant_message" || event.type === "assistant_delta" || event.type.startsWith("thinking_"))
|
|
351
|
+
return "assistant";
|
|
352
|
+
if (event.type.startsWith("tool_"))
|
|
353
|
+
return "tool";
|
|
354
|
+
return undefined;
|
|
355
|
+
}
|
|
356
|
+
function observationNameForOutputEvent(event) {
|
|
357
|
+
if ("toolName" in event)
|
|
358
|
+
return event.toolName;
|
|
359
|
+
if (event.type === "execution_result")
|
|
360
|
+
return event.action;
|
|
361
|
+
return event.type;
|
|
362
|
+
}
|
|
363
|
+
function observationStatusForOutputEvent(event) {
|
|
364
|
+
if (event.type.endsWith("_started") || event.type === "tool_call" || event.type === "compaction_start")
|
|
365
|
+
return "running";
|
|
366
|
+
if (event.type === "session_error")
|
|
367
|
+
return "error";
|
|
368
|
+
if (event.type === "tool_execution_finished" && event.isError)
|
|
369
|
+
return "error";
|
|
370
|
+
return "completed";
|
|
371
|
+
}
|
|
372
|
+
function isTerminalOutputEvent(event) {
|
|
373
|
+
return !event.type.endsWith("_started") && event.type !== "tool_call" && event.type !== "assistant_delta" && event.type !== "thinking_delta" && event.type !== "tool_execution_updated";
|
|
374
|
+
}
|
|
375
|
+
function outputSessionStatus(event) {
|
|
376
|
+
if (event.type === "session_error")
|
|
377
|
+
return "error";
|
|
378
|
+
if (event.type === "message_finished")
|
|
379
|
+
return "idle";
|
|
380
|
+
return "running";
|
|
381
|
+
}
|
|
382
|
+
function toPiboJsonValue(value) {
|
|
383
|
+
if (value === undefined)
|
|
384
|
+
return undefined;
|
|
385
|
+
return JSON.parse(JSON.stringify(value));
|
|
386
|
+
}
|
|
387
|
+
function toPiboJsonValueOrNull(value) {
|
|
388
|
+
return toPiboJsonValue(value) ?? null;
|
|
389
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export class MessageStore {
|
|
2
|
+
db;
|
|
3
|
+
constructor(db) {
|
|
4
|
+
this.db = db;
|
|
5
|
+
}
|
|
6
|
+
insertMessage(input) {
|
|
7
|
+
this.db.prepare(`
|
|
8
|
+
INSERT INTO chat_messages (
|
|
9
|
+
id,
|
|
10
|
+
session_id,
|
|
11
|
+
room_id,
|
|
12
|
+
sequence,
|
|
13
|
+
turn_id,
|
|
14
|
+
role,
|
|
15
|
+
actor_id,
|
|
16
|
+
status,
|
|
17
|
+
created_at,
|
|
18
|
+
completed_at,
|
|
19
|
+
content_preview,
|
|
20
|
+
content_payload_ref,
|
|
21
|
+
source_stream_id,
|
|
22
|
+
input_tokens,
|
|
23
|
+
output_tokens,
|
|
24
|
+
cost_usd,
|
|
25
|
+
attributes_json
|
|
26
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
27
|
+
`).run(input.id, input.sessionId, input.roomId ?? null, input.sequence, input.turnId ?? null, input.role, input.actorId ?? null, input.status, input.createdAt, input.completedAt ?? null, input.contentPreview ?? null, input.contentPayloadRef ?? null, input.sourceStreamId ?? null, input.inputTokens ?? null, input.outputTokens ?? null, input.costUsd ?? null, JSON.stringify(input.attributes ?? {}));
|
|
28
|
+
const stored = this.getMessage(input.id);
|
|
29
|
+
if (!stored)
|
|
30
|
+
throw new Error(`Failed to insert chat message \"${input.id}\"`);
|
|
31
|
+
return stored;
|
|
32
|
+
}
|
|
33
|
+
getMessage(id) {
|
|
34
|
+
const row = this.db.prepare("SELECT * FROM chat_messages WHERE id = ?").get(id);
|
|
35
|
+
return row ? messageFromRow(row) : undefined;
|
|
36
|
+
}
|
|
37
|
+
listMessages(sessionId) {
|
|
38
|
+
const rows = this.db.prepare("SELECT * FROM chat_messages WHERE session_id = ? ORDER BY sequence ASC").all(sessionId);
|
|
39
|
+
return rows.map(messageFromRow);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function messageFromRow(row) {
|
|
43
|
+
return {
|
|
44
|
+
id: row.id,
|
|
45
|
+
sessionId: row.session_id,
|
|
46
|
+
roomId: row.room_id ?? undefined,
|
|
47
|
+
sequence: row.sequence,
|
|
48
|
+
turnId: row.turn_id ?? undefined,
|
|
49
|
+
role: row.role,
|
|
50
|
+
actorId: row.actor_id ?? undefined,
|
|
51
|
+
status: row.status,
|
|
52
|
+
createdAt: row.created_at,
|
|
53
|
+
completedAt: row.completed_at ?? undefined,
|
|
54
|
+
contentPreview: row.content_preview ?? undefined,
|
|
55
|
+
contentPayloadRef: row.content_payload_ref ?? undefined,
|
|
56
|
+
sourceStreamId: row.source_stream_id ?? undefined,
|
|
57
|
+
inputTokens: row.input_tokens ?? undefined,
|
|
58
|
+
outputTokens: row.output_tokens ?? undefined,
|
|
59
|
+
costUsd: row.cost_usd ?? undefined,
|
|
60
|
+
attributes: JSON.parse(row.attributes_json),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export class NavigationStore {
|
|
2
|
+
db;
|
|
3
|
+
constructor(db) {
|
|
4
|
+
this.db = db;
|
|
5
|
+
}
|
|
6
|
+
upsertSession(input) {
|
|
7
|
+
const insertColumns = [
|
|
8
|
+
"room_id", "session_id", "root_session_id", "parent_id", "origin_id", "title", "profile", "status", "archived_at", "last_activity_at", "last_message_preview", "child_count", "sort_key", "updated_at",
|
|
9
|
+
];
|
|
10
|
+
const assignments = [
|
|
11
|
+
"room_id = excluded.room_id",
|
|
12
|
+
"root_session_id = excluded.root_session_id",
|
|
13
|
+
"parent_id = excluded.parent_id",
|
|
14
|
+
"origin_id = excluded.origin_id",
|
|
15
|
+
"title = excluded.title",
|
|
16
|
+
"profile = excluded.profile",
|
|
17
|
+
"status = excluded.status",
|
|
18
|
+
"archived_at = excluded.archived_at",
|
|
19
|
+
"last_activity_at = excluded.last_activity_at",
|
|
20
|
+
"last_message_preview = COALESCE(excluded.last_message_preview, session_navigation.last_message_preview)",
|
|
21
|
+
"child_count = excluded.child_count",
|
|
22
|
+
"sort_key = excluded.sort_key",
|
|
23
|
+
"updated_at = excluded.updated_at",
|
|
24
|
+
];
|
|
25
|
+
this.db.prepare(`
|
|
26
|
+
INSERT INTO session_navigation (${insertColumns.join(", ")})
|
|
27
|
+
VALUES (${insertColumns.map(() => "?").join(", ")})
|
|
28
|
+
ON CONFLICT(session_id) DO UPDATE SET ${assignments.join(", ")}
|
|
29
|
+
`).run(input.roomId ?? null, input.sessionId, input.rootSessionId ?? null, input.parentId ?? null, input.originId ?? null, input.title, input.profile, input.status, input.archivedAt ?? null, input.lastActivityAt, input.lastMessagePreview ?? null, input.childCount ?? 0, input.sortKey, input.updatedAt);
|
|
30
|
+
const stored = this.getSession(input.sessionId);
|
|
31
|
+
if (!stored)
|
|
32
|
+
throw new Error(`Failed to upsert session navigation \"${input.sessionId}\"`);
|
|
33
|
+
return stored;
|
|
34
|
+
}
|
|
35
|
+
getSession(sessionId) {
|
|
36
|
+
const row = this.db.prepare("SELECT * FROM session_navigation WHERE session_id = ?").get(sessionId);
|
|
37
|
+
return row ? sessionNavigationFromRow(row) : undefined;
|
|
38
|
+
}
|
|
39
|
+
listSessions(input = {}) {
|
|
40
|
+
const clauses = [];
|
|
41
|
+
const values = [];
|
|
42
|
+
if (input.roomId !== undefined) {
|
|
43
|
+
clauses.push("room_id = ?");
|
|
44
|
+
values.push(input.roomId);
|
|
45
|
+
}
|
|
46
|
+
if (!input.includeArchived)
|
|
47
|
+
clauses.push("archived_at IS NULL");
|
|
48
|
+
const limit = Math.max(1, Math.min(input.limit ?? 100, 1000));
|
|
49
|
+
const rows = this.db.prepare(`
|
|
50
|
+
SELECT * FROM session_navigation
|
|
51
|
+
${clauses.length ? `WHERE ${clauses.join(" AND ")}` : ""}
|
|
52
|
+
ORDER BY sort_key DESC, updated_at DESC
|
|
53
|
+
LIMIT ?
|
|
54
|
+
`).all(...values, limit);
|
|
55
|
+
return rows.map(sessionNavigationFromRow);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function sessionNavigationFromRow(row) {
|
|
59
|
+
return {
|
|
60
|
+
roomId: row.room_id ?? undefined,
|
|
61
|
+
sessionId: row.session_id,
|
|
62
|
+
rootSessionId: row.root_session_id ?? undefined,
|
|
63
|
+
parentId: row.parent_id ?? undefined,
|
|
64
|
+
originId: row.origin_id ?? undefined,
|
|
65
|
+
title: row.title,
|
|
66
|
+
profile: row.profile,
|
|
67
|
+
status: row.status,
|
|
68
|
+
archivedAt: row.archived_at ?? undefined,
|
|
69
|
+
lastActivityAt: row.last_activity_at,
|
|
70
|
+
lastMessagePreview: row.last_message_preview ?? undefined,
|
|
71
|
+
childCount: row.child_count,
|
|
72
|
+
sortKey: row.sort_key,
|
|
73
|
+
updatedAt: row.updated_at,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
export class ObservationStore {
|
|
3
|
+
db;
|
|
4
|
+
constructor(db) {
|
|
5
|
+
this.db = db;
|
|
6
|
+
}
|
|
7
|
+
insertObservation(input) {
|
|
8
|
+
const sequence = input.sequence ?? this.nextSequence(input.sessionId);
|
|
9
|
+
const startedAt = input.startedAt ?? new Date().toISOString();
|
|
10
|
+
const id = input.id ?? `obs_${randomUUID()}`;
|
|
11
|
+
this.db.prepare(`INSERT OR IGNORE INTO observations (
|
|
12
|
+
id, session_id, sequence, trace_id, span_id, parent_span_id, parent_observation_id, turn_id, event_stream_id,
|
|
13
|
+
kind, role, name, status, started_at, ended_at, latency_ms, model_provider, model_id, input_tokens, output_tokens,
|
|
14
|
+
cost_usd, preview_text, payload_ref, attributes_json
|
|
15
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(id, input.sessionId, sequence, input.traceId ?? null, input.spanId ?? null, input.parentSpanId ?? null, input.parentObservationId ?? null, input.turnId ?? null, input.eventStreamId ?? null, input.kind, input.role ?? null, input.name ?? null, input.status ?? "completed", startedAt, input.endedAt ?? null, input.latencyMs ?? null, input.modelProvider ?? null, input.modelId ?? null, input.inputTokens ?? null, input.outputTokens ?? null, input.costUsd ?? null, input.previewText ?? null, input.payloadRef ?? null, JSON.stringify(input.attributes ?? {}));
|
|
16
|
+
return this.getObservation(id) ?? this.listObservations(input.sessionId).find((row) => row.sequence === sequence);
|
|
17
|
+
}
|
|
18
|
+
appendObservation(input) {
|
|
19
|
+
return this.insertObservation(input);
|
|
20
|
+
}
|
|
21
|
+
getObservation(id) {
|
|
22
|
+
const row = this.db.prepare("SELECT * FROM observations WHERE id = ?").get(id);
|
|
23
|
+
return row ? mapRow(row) : undefined;
|
|
24
|
+
}
|
|
25
|
+
listObservations(sessionId, limit = 200) {
|
|
26
|
+
return this.db.prepare("SELECT * FROM observations WHERE session_id = ? ORDER BY sequence ASC LIMIT ?").all(sessionId, limit).map(mapRow);
|
|
27
|
+
}
|
|
28
|
+
listSession(sessionId, limit = 200) {
|
|
29
|
+
return this.listObservations(sessionId, limit);
|
|
30
|
+
}
|
|
31
|
+
nextSequence(sessionId) {
|
|
32
|
+
const row = this.db.prepare("SELECT COALESCE(MAX(sequence), 0) + 1 AS next_sequence FROM observations WHERE session_id = ?").get(sessionId);
|
|
33
|
+
return row.next_sequence;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function mapRow(row) {
|
|
37
|
+
return {
|
|
38
|
+
id: row.id, sessionId: row.session_id, sequence: row.sequence, traceId: row.trace_id ?? undefined, spanId: row.span_id ?? undefined,
|
|
39
|
+
parentSpanId: row.parent_span_id ?? undefined, parentObservationId: row.parent_observation_id ?? undefined, turnId: row.turn_id ?? undefined,
|
|
40
|
+
eventStreamId: row.event_stream_id ?? undefined, kind: row.kind, role: row.role ?? undefined, name: row.name ?? undefined,
|
|
41
|
+
status: row.status, startedAt: row.started_at, endedAt: row.ended_at ?? undefined, latencyMs: row.latency_ms ?? undefined,
|
|
42
|
+
modelProvider: row.model_provider ?? undefined, modelId: row.model_id ?? undefined, inputTokens: row.input_tokens ?? undefined,
|
|
43
|
+
outputTokens: row.output_tokens ?? undefined, costUsd: row.cost_usd ?? undefined, previewText: row.preview_text ?? undefined,
|
|
44
|
+
payloadRef: row.payload_ref ?? undefined, attributes: JSON.parse(row.attributes_json),
|
|
45
|
+
};
|
|
46
|
+
}
|