@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,126 @@
|
|
|
1
|
+
import { assistantOutputKey, isLiveOnlyOutputEvent, thinkingOutputKey, toolOutputKey } from "./output-event-policy.js";
|
|
2
|
+
export class OutputCompactor {
|
|
3
|
+
assistantBuffers = new Map();
|
|
4
|
+
thinkingBuffers = new Map();
|
|
5
|
+
toolSnapshots = new Map();
|
|
6
|
+
compact(event) {
|
|
7
|
+
const persistedEvents = [];
|
|
8
|
+
const snapshots = [];
|
|
9
|
+
switch (event.type) {
|
|
10
|
+
case "assistant_delta": {
|
|
11
|
+
const key = assistantOutputKey(event);
|
|
12
|
+
const previous = this.assistantBuffers.get(key);
|
|
13
|
+
const text = `${previous?.text ?? ""}${event.text}`;
|
|
14
|
+
this.assistantBuffers.set(key, { event, text });
|
|
15
|
+
snapshots.push({ ...event, text });
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
case "assistant_message": {
|
|
19
|
+
const key = assistantOutputKey(event);
|
|
20
|
+
const buffered = this.assistantBuffers.get(key);
|
|
21
|
+
this.assistantBuffers.delete(key);
|
|
22
|
+
persistedEvents.push({ ...event, text: event.text || buffered?.text || "" });
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
case "thinking_started": {
|
|
26
|
+
const key = thinkingOutputKey(event);
|
|
27
|
+
this.thinkingBuffers.set(key, { base: event, text: "" });
|
|
28
|
+
persistedEvents.push(event);
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
case "thinking_delta": {
|
|
32
|
+
const key = thinkingOutputKey(event);
|
|
33
|
+
const previous = this.thinkingBuffers.get(key);
|
|
34
|
+
const text = `${previous?.text ?? ""}${event.text}`;
|
|
35
|
+
this.thinkingBuffers.set(key, { base: previous?.base ?? event, text });
|
|
36
|
+
snapshots.push({ ...event, text });
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
case "thinking_finished": {
|
|
40
|
+
const key = thinkingOutputKey(event);
|
|
41
|
+
const buffered = this.thinkingBuffers.get(key);
|
|
42
|
+
this.thinkingBuffers.delete(key);
|
|
43
|
+
persistedEvents.push({ ...event, text: event.text || buffered?.text || "" });
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
case "tool_execution_updated": {
|
|
47
|
+
this.toolSnapshots.set(toolOutputKey(event), event);
|
|
48
|
+
snapshots.push(event);
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
case "tool_execution_finished": {
|
|
52
|
+
this.toolSnapshots.delete(toolOutputKey(event));
|
|
53
|
+
persistedEvents.push(event);
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
case "message_finished":
|
|
57
|
+
case "session_error": {
|
|
58
|
+
persistedEvents.push(...this.flushForBoundary(event));
|
|
59
|
+
persistedEvents.push(event);
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
default:
|
|
63
|
+
if (!isLiveOnlyOutputEvent(event))
|
|
64
|
+
persistedEvents.push(event);
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
return { liveEvents: [event], persistedEvents, snapshots };
|
|
68
|
+
}
|
|
69
|
+
snapshotsForSession(piboSessionId) {
|
|
70
|
+
const snapshots = [];
|
|
71
|
+
for (const buffer of this.assistantBuffers.values()) {
|
|
72
|
+
if (buffer.event.piboSessionId === piboSessionId)
|
|
73
|
+
snapshots.push({ ...buffer.event, text: buffer.text });
|
|
74
|
+
}
|
|
75
|
+
for (const buffer of this.thinkingBuffers.values()) {
|
|
76
|
+
if (buffer.base.piboSessionId !== piboSessionId)
|
|
77
|
+
continue;
|
|
78
|
+
if (buffer.base.type === "thinking_delta")
|
|
79
|
+
snapshots.push({ ...buffer.base, text: buffer.text });
|
|
80
|
+
else
|
|
81
|
+
snapshots.push({ ...buffer.base, type: "thinking_delta", text: buffer.text });
|
|
82
|
+
}
|
|
83
|
+
for (const event of this.toolSnapshots.values()) {
|
|
84
|
+
if (event.piboSessionId === piboSessionId)
|
|
85
|
+
snapshots.push(event);
|
|
86
|
+
}
|
|
87
|
+
return snapshots;
|
|
88
|
+
}
|
|
89
|
+
flushForBoundary(event) {
|
|
90
|
+
const flushed = [];
|
|
91
|
+
for (const [key, buffer] of Array.from(this.assistantBuffers.entries())) {
|
|
92
|
+
if (!matchesBoundary(buffer.event, event))
|
|
93
|
+
continue;
|
|
94
|
+
this.assistantBuffers.delete(key);
|
|
95
|
+
flushed.push({
|
|
96
|
+
type: "assistant_message",
|
|
97
|
+
piboSessionId: buffer.event.piboSessionId,
|
|
98
|
+
eventId: buffer.event.eventId,
|
|
99
|
+
assistantIndex: buffer.event.assistantIndex,
|
|
100
|
+
contentIndex: buffer.event.contentIndex,
|
|
101
|
+
text: buffer.text,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
for (const [key, buffer] of Array.from(this.thinkingBuffers.entries())) {
|
|
105
|
+
if (!matchesBoundary(buffer.base, event))
|
|
106
|
+
continue;
|
|
107
|
+
this.thinkingBuffers.delete(key);
|
|
108
|
+
flushed.push({
|
|
109
|
+
type: "thinking_finished",
|
|
110
|
+
piboSessionId: buffer.base.piboSessionId,
|
|
111
|
+
eventId: buffer.base.eventId,
|
|
112
|
+
thinkingIndex: "thinkingIndex" in buffer.base ? buffer.base.thinkingIndex : undefined,
|
|
113
|
+
contentIndex: buffer.base.contentIndex,
|
|
114
|
+
text: buffer.text,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return flushed;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function matchesBoundary(bufferEvent, boundary) {
|
|
121
|
+
if (bufferEvent.piboSessionId !== boundary.piboSessionId)
|
|
122
|
+
return false;
|
|
123
|
+
if (boundary.type === "session_error")
|
|
124
|
+
return !boundary.eventId || bufferEvent.eventId === boundary.eventId;
|
|
125
|
+
return bufferEvent.eventId === boundary.eventId;
|
|
126
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function isLiveOnlyOutputEvent(event) {
|
|
2
|
+
return event.type === "assistant_delta" || event.type === "thinking_delta" || event.type === "tool_execution_updated";
|
|
3
|
+
}
|
|
4
|
+
export function isPersistableOutputEvent(event) {
|
|
5
|
+
return !isLiveOnlyOutputEvent(event);
|
|
6
|
+
}
|
|
7
|
+
export function assistantOutputKey(event) {
|
|
8
|
+
const partIndex = event.assistantIndex ?? event.contentIndex ?? 0;
|
|
9
|
+
return [event.piboSessionId, event.eventId ?? "", partIndex].join(":");
|
|
10
|
+
}
|
|
11
|
+
export function thinkingOutputKey(event) {
|
|
12
|
+
const partIndex = event.thinkingIndex ?? event.contentIndex ?? 0;
|
|
13
|
+
return [event.piboSessionId, event.eventId ?? "", partIndex].join(":");
|
|
14
|
+
}
|
|
15
|
+
export function toolOutputKey(event) {
|
|
16
|
+
return [event.piboSessionId, event.eventId ?? "", event.toolCallId].join(":");
|
|
17
|
+
}
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import { responseJson } from "../../web/http.js";
|
|
2
|
+
import { sanitizeWorkflowDiagnostics } from "./workflow-persistence.js";
|
|
3
|
+
export function projectWorkflowPendingHumanActionFromToken(token, humanActionOptions) {
|
|
4
|
+
const diagnostics = [];
|
|
5
|
+
const availableActions = token.actions.map((action, index) => {
|
|
6
|
+
const registered = humanActionOptions.find((option) => option.id === action.id);
|
|
7
|
+
if (!registered) {
|
|
8
|
+
diagnostics.push({
|
|
9
|
+
code: "WorkflowGraphError.unknownHumanActionRef",
|
|
10
|
+
message: `Workflow wait token '${token.id}' references human action '${action.id}', but it is not registered in the Workflow Registry.`,
|
|
11
|
+
severity: "error",
|
|
12
|
+
path: `$.waitToken.actions.${index}.id`,
|
|
13
|
+
registryRef: action.id,
|
|
14
|
+
hint: "Resolve waits with registered approve/reject/resume/cancel action refs only.",
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
if (registered && action.kind && action.kind !== registered.kind) {
|
|
18
|
+
diagnostics.push({
|
|
19
|
+
code: "WorkflowGraphError.humanActionKindMismatch",
|
|
20
|
+
message: `Workflow wait token '${token.id}' action '${action.id}' declares kind '${action.kind}', but the registry defines kind '${registered.kind}'.`,
|
|
21
|
+
severity: "error",
|
|
22
|
+
path: `$.waitToken.actions.${index}.kind`,
|
|
23
|
+
registryRef: action.id,
|
|
24
|
+
hint: "Keep wait-token action refs aligned with their registered action definitions.",
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
id: action.id,
|
|
29
|
+
kind: action.kind ?? registered?.kind ?? "unknown",
|
|
30
|
+
displayName: registered?.displayName ?? action.id,
|
|
31
|
+
...(registered?.description ? { description: registered.description } : {}),
|
|
32
|
+
paramsSchema: registered?.paramsSchema ?? null,
|
|
33
|
+
registered: Boolean(registered),
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
waitTokenId: token.id,
|
|
38
|
+
workflowRunId: token.workflowRunId,
|
|
39
|
+
...(token.nodeAttemptId ? { nodeAttemptId: token.nodeAttemptId } : {}),
|
|
40
|
+
...(token.humanNodeId ? { humanNodeId: token.humanNodeId } : {}),
|
|
41
|
+
prompt: token.prompt,
|
|
42
|
+
...(token.schema ? { schema: token.schema } : {}),
|
|
43
|
+
status: "pending",
|
|
44
|
+
payloadRequirements: {
|
|
45
|
+
required: Boolean(token.schema),
|
|
46
|
+
...(token.schema ? { schema: token.schema } : {}),
|
|
47
|
+
description: token.schema
|
|
48
|
+
? "Resume requires a JSON payload that matches this wait token schema."
|
|
49
|
+
: "Approve, reject, resume, and cancel do not require a payload for this wait token.",
|
|
50
|
+
},
|
|
51
|
+
availableActions,
|
|
52
|
+
diagnostics,
|
|
53
|
+
createdAt: token.createdAt,
|
|
54
|
+
...(token.expiresAt ? { expiresAt: token.expiresAt } : {}),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export function projectWorkflowHumanActionLifecyclePayload(request) {
|
|
58
|
+
const payload = { waitTokenId: request.waitTokenId };
|
|
59
|
+
if (request.actionId)
|
|
60
|
+
payload.actionId = request.actionId;
|
|
61
|
+
if (request.kind)
|
|
62
|
+
payload.kind = request.kind;
|
|
63
|
+
return payload;
|
|
64
|
+
}
|
|
65
|
+
export function projectWorkflowHumanActionSubmittedLifecyclePayload(waitTokenId, action) {
|
|
66
|
+
const payload = {
|
|
67
|
+
waitTokenId,
|
|
68
|
+
kind: action.kind,
|
|
69
|
+
decision: action.kind === "cancel" ? "cancelled" : "resumed",
|
|
70
|
+
};
|
|
71
|
+
if (action.actionId)
|
|
72
|
+
payload.actionId = action.actionId;
|
|
73
|
+
return payload;
|
|
74
|
+
}
|
|
75
|
+
export function normalizeProjectWorkflowHumanActionBody(body) {
|
|
76
|
+
const diagnostics = [];
|
|
77
|
+
const waitTokenId = typeof body.waitTokenId === "string" && body.waitTokenId.trim() ? body.waitTokenId.trim() : undefined;
|
|
78
|
+
const actionId = typeof body.actionId === "string" && body.actionId.trim() ? body.actionId.trim() : undefined;
|
|
79
|
+
const kind = typeof body.kind === "string" && body.kind.trim() ? body.kind.trim() : undefined;
|
|
80
|
+
if (!waitTokenId) {
|
|
81
|
+
diagnostics.push({
|
|
82
|
+
code: "WorkflowRuntimeError.waitTokenIdRequired",
|
|
83
|
+
message: "Human action requests must include a waitTokenId.",
|
|
84
|
+
severity: "error",
|
|
85
|
+
path: "$.waitTokenId",
|
|
86
|
+
hint: "Submit a pending wait token returned by Project workflow inspection.",
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
if (!actionId && !kind) {
|
|
90
|
+
diagnostics.push({
|
|
91
|
+
code: "WorkflowRuntimeError.humanActionRequired",
|
|
92
|
+
message: "Human action requests must include an actionId or action kind.",
|
|
93
|
+
severity: "error",
|
|
94
|
+
path: "$.actionId",
|
|
95
|
+
hint: "Use one of the wait token's registered approve/reject/resume/cancel actions.",
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (body.payload !== undefined && !isJsonValue(body.payload)) {
|
|
99
|
+
diagnostics.push({
|
|
100
|
+
code: "WorkflowRuntimeError.invalidHumanActionPayload",
|
|
101
|
+
message: "Human action payload must be valid JSON data.",
|
|
102
|
+
severity: "error",
|
|
103
|
+
path: "$.payload",
|
|
104
|
+
hint: "Submit a JSON value that matches the wait token payload requirements.",
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
if (!waitTokenId)
|
|
108
|
+
return { diagnostics };
|
|
109
|
+
return {
|
|
110
|
+
request: {
|
|
111
|
+
waitTokenId,
|
|
112
|
+
...(actionId ? { actionId } : {}),
|
|
113
|
+
...(kind ? { kind } : {}),
|
|
114
|
+
...(body.payload !== undefined && isJsonValue(body.payload) ? { payload: body.payload } : {}),
|
|
115
|
+
},
|
|
116
|
+
diagnostics,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
export function validateProjectWorkflowHumanActionRequest(input) {
|
|
120
|
+
const checkedAt = new Date().toISOString();
|
|
121
|
+
const diagnostics = [];
|
|
122
|
+
if (!input.waitToken) {
|
|
123
|
+
diagnostics.push({
|
|
124
|
+
code: "WorkflowRuntimeError.unknownWaitToken",
|
|
125
|
+
message: `Workflow wait token '${input.request.waitTokenId}' does not exist.`,
|
|
126
|
+
severity: "error",
|
|
127
|
+
path: "$.waitTokenId",
|
|
128
|
+
hint: "Refresh the Project run view and submit one of its pending wait tokens.",
|
|
129
|
+
});
|
|
130
|
+
return { diagnostics, httpStatus: 404, checkedAt };
|
|
131
|
+
}
|
|
132
|
+
if (input.waitToken.projectId !== input.projectSession.projectId || input.waitToken.piboSessionId !== input.projectSession.piboSessionId || input.waitToken.workflowRunId !== input.projectSession.workflowRunId) {
|
|
133
|
+
diagnostics.push({
|
|
134
|
+
code: "WorkflowRuntimeError.waitTokenSessionMismatch",
|
|
135
|
+
message: `Workflow wait token '${input.waitToken.id}' does not belong to this Project workflow session.`,
|
|
136
|
+
severity: "error",
|
|
137
|
+
path: "$.waitTokenId",
|
|
138
|
+
registryRef: input.waitToken.id,
|
|
139
|
+
hint: "Use only wait tokens shown in the selected Project run view.",
|
|
140
|
+
});
|
|
141
|
+
return { diagnostics, httpStatus: 403, checkedAt };
|
|
142
|
+
}
|
|
143
|
+
if (input.waitToken.status !== "pending") {
|
|
144
|
+
diagnostics.push({
|
|
145
|
+
code: "WorkflowRuntimeError.waitTokenNotPending",
|
|
146
|
+
message: `Workflow wait token '${input.waitToken.id}' is '${input.waitToken.status}' and cannot accept another human action.`,
|
|
147
|
+
severity: "error",
|
|
148
|
+
path: "$.waitToken.status",
|
|
149
|
+
registryRef: input.waitToken.id,
|
|
150
|
+
hint: "Human wait tokens can only be resolved once while pending.",
|
|
151
|
+
});
|
|
152
|
+
return { diagnostics, httpStatus: 409, checkedAt };
|
|
153
|
+
}
|
|
154
|
+
if (input.waitToken.expiresAt && Date.parse(input.waitToken.expiresAt) <= Date.parse(checkedAt)) {
|
|
155
|
+
diagnostics.push({
|
|
156
|
+
code: "WorkflowRuntimeError.waitTokenExpired",
|
|
157
|
+
message: `Workflow wait token '${input.waitToken.id}' expired at ${input.waitToken.expiresAt}.`,
|
|
158
|
+
severity: "error",
|
|
159
|
+
path: "$.waitToken.expiresAt",
|
|
160
|
+
registryRef: input.waitToken.id,
|
|
161
|
+
hint: "Create a new human wait or handle the timeout before submitting an action.",
|
|
162
|
+
});
|
|
163
|
+
return { diagnostics, httpStatus: 409, checkedAt, expiredAt: input.waitToken.expiresAt };
|
|
164
|
+
}
|
|
165
|
+
const actionRef = input.request.actionId
|
|
166
|
+
? input.waitToken.actions.find((action) => action.id === input.request.actionId)
|
|
167
|
+
: input.waitToken.actions.find((action) => action.kind === input.request.kind);
|
|
168
|
+
if (!actionRef) {
|
|
169
|
+
diagnostics.push({
|
|
170
|
+
code: "WorkflowRuntimeError.humanActionUnavailable",
|
|
171
|
+
message: input.request.actionId
|
|
172
|
+
? `Workflow wait token '${input.waitToken.id}' does not offer human action '${input.request.actionId}'.`
|
|
173
|
+
: `Workflow wait token '${input.waitToken.id}' does not offer a human action of kind '${input.request.kind ?? "<missing>"}'.`,
|
|
174
|
+
severity: "error",
|
|
175
|
+
path: input.request.actionId ? "$.actionId" : "$.kind",
|
|
176
|
+
...(input.request.actionId ? { registryRef: input.request.actionId } : {}),
|
|
177
|
+
hint: "Use one of the wait token's available action refs.",
|
|
178
|
+
});
|
|
179
|
+
return { diagnostics, httpStatus: 422, checkedAt };
|
|
180
|
+
}
|
|
181
|
+
const registered = input.humanActionOptions.find((option) => option.id === actionRef.id);
|
|
182
|
+
if (!registered) {
|
|
183
|
+
diagnostics.push({
|
|
184
|
+
code: "WorkflowGraphError.unknownHumanActionRef",
|
|
185
|
+
message: `Workflow wait token '${input.waitToken.id}' references human action '${actionRef.id}', but it is not registered in the Workflow Registry.`,
|
|
186
|
+
severity: "error",
|
|
187
|
+
path: "$.waitToken.actions",
|
|
188
|
+
registryRef: actionRef.id,
|
|
189
|
+
hint: "Register or select a known approve/reject/resume/cancel human action before accepting it.",
|
|
190
|
+
});
|
|
191
|
+
return { diagnostics, httpStatus: 422, checkedAt, actionRef };
|
|
192
|
+
}
|
|
193
|
+
if (actionRef.kind && actionRef.kind !== registered.kind) {
|
|
194
|
+
diagnostics.push({
|
|
195
|
+
code: "WorkflowGraphError.humanActionKindMismatch",
|
|
196
|
+
message: `Workflow wait token '${input.waitToken.id}' action '${actionRef.id}' declares kind '${actionRef.kind}', but the registry defines kind '${registered.kind}'.`,
|
|
197
|
+
severity: "error",
|
|
198
|
+
path: "$.waitToken.actions",
|
|
199
|
+
registryRef: actionRef.id,
|
|
200
|
+
hint: "Keep wait-token action refs aligned with their registered action definitions.",
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
if (input.request.kind && input.request.kind !== registered.kind) {
|
|
204
|
+
diagnostics.push({
|
|
205
|
+
code: "WorkflowRuntimeError.humanActionKindMismatch",
|
|
206
|
+
message: `Requested human action kind '${input.request.kind}' does not match registered action '${registered.id}' kind '${registered.kind}'.`,
|
|
207
|
+
severity: "error",
|
|
208
|
+
path: "$.kind",
|
|
209
|
+
registryRef: registered.id,
|
|
210
|
+
hint: "Submit the kind returned by the wait token action list.",
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
if (registered.kind === "resume" && input.waitToken.schema) {
|
|
214
|
+
validateWorkflowHumanActionPayloadAgainstSchema(input.request.payload, input.waitToken.schema, "$.payload", diagnostics, {
|
|
215
|
+
registryRef: registered.id,
|
|
216
|
+
waitTokenId: input.waitToken.id,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
return {
|
|
220
|
+
diagnostics,
|
|
221
|
+
httpStatus: diagnostics.length ? 422 : 200,
|
|
222
|
+
checkedAt,
|
|
223
|
+
actionRef,
|
|
224
|
+
actionKind: registered.kind,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
export function projectWorkflowHumanActionRuntimeDiagnostic(error, waitTokenId) {
|
|
228
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
229
|
+
let code = "WorkflowRuntimeError.humanActionRejected";
|
|
230
|
+
if (/not found/i.test(message))
|
|
231
|
+
code = "WorkflowRuntimeError.unknownWaitToken";
|
|
232
|
+
else if (/does not belong/i.test(message))
|
|
233
|
+
code = "WorkflowRuntimeError.waitTokenSessionMismatch";
|
|
234
|
+
else if (/expired/i.test(message))
|
|
235
|
+
code = "WorkflowRuntimeError.waitTokenExpired";
|
|
236
|
+
else if (/cannot be resolved again|not pending/i.test(message))
|
|
237
|
+
code = "WorkflowRuntimeError.waitTokenNotPending";
|
|
238
|
+
else if (/does not offer/i.test(message))
|
|
239
|
+
code = "WorkflowRuntimeError.humanActionUnavailable";
|
|
240
|
+
return {
|
|
241
|
+
code,
|
|
242
|
+
message,
|
|
243
|
+
severity: "error",
|
|
244
|
+
path: "$.waitTokenId",
|
|
245
|
+
registryRef: waitTokenId,
|
|
246
|
+
hint: "Refresh the Project run view and retry with a currently pending wait token/action ref.",
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
export function projectWorkflowHumanActionDiagnosticResponse(message, diagnostics, status, waitToken, humanActionOptions) {
|
|
250
|
+
return responseJson({
|
|
251
|
+
error: message,
|
|
252
|
+
diagnostics: sanitizeWorkflowDiagnostics(diagnostics),
|
|
253
|
+
...(waitToken?.status === "pending" ? { waitToken: projectWorkflowPendingHumanActionFromToken(waitToken, humanActionOptions) } : {}),
|
|
254
|
+
}, { status });
|
|
255
|
+
}
|
|
256
|
+
function validateWorkflowHumanActionPayloadAgainstSchema(value, schema, path, diagnostics, context) {
|
|
257
|
+
const typeNames = readParamsSchemaTypes(schema.type);
|
|
258
|
+
if (typeNames.length && !typeNames.some((typeName) => workflowParamValueMatchesType(value, typeName))) {
|
|
259
|
+
diagnostics.push({
|
|
260
|
+
code: "WorkflowRuntimeError.invalidHumanActionPayload",
|
|
261
|
+
message: `Resume payload for wait token '${context.waitTokenId}' does not match schema type at '${path}'.`,
|
|
262
|
+
severity: "error",
|
|
263
|
+
path,
|
|
264
|
+
registryRef: context.registryRef,
|
|
265
|
+
hint: "Submit a resume payload matching the wait token schema before the action is accepted.",
|
|
266
|
+
});
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if (isJsonObject(value)) {
|
|
270
|
+
const required = Array.isArray(schema.required) ? schema.required.filter((entry) => typeof entry === "string") : [];
|
|
271
|
+
for (const requiredKey of required) {
|
|
272
|
+
if (Object.hasOwn(value, requiredKey))
|
|
273
|
+
continue;
|
|
274
|
+
diagnostics.push({
|
|
275
|
+
code: "WorkflowRuntimeError.invalidHumanActionPayload",
|
|
276
|
+
message: `Resume payload for wait token '${context.waitTokenId}' is missing required field '${requiredKey}'.`,
|
|
277
|
+
severity: "error",
|
|
278
|
+
path: workflowParamsChildPath(path, requiredKey),
|
|
279
|
+
registryRef: context.registryRef,
|
|
280
|
+
hint: "Add the required resume payload field before submitting the action.",
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
const properties = isJsonObject(schema.properties) ? schema.properties : {};
|
|
284
|
+
for (const [key, propertyValue] of Object.entries(value)) {
|
|
285
|
+
const propertySchema = properties[key];
|
|
286
|
+
if (isJsonObject(propertySchema)) {
|
|
287
|
+
validateWorkflowHumanActionPayloadAgainstSchema(propertyValue, propertySchema, workflowParamsChildPath(path, key), diagnostics, context);
|
|
288
|
+
}
|
|
289
|
+
else if (schema.additionalProperties === false) {
|
|
290
|
+
diagnostics.push({
|
|
291
|
+
code: "WorkflowRuntimeError.invalidHumanActionPayload",
|
|
292
|
+
message: `Resume payload for wait token '${context.waitTokenId}' includes field '${key}', which is not allowed by the wait token schema.`,
|
|
293
|
+
severity: "error",
|
|
294
|
+
path: workflowParamsChildPath(path, key),
|
|
295
|
+
registryRef: context.registryRef,
|
|
296
|
+
hint: "Remove fields not declared by the wait token payload schema.",
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
if (Array.isArray(value) && isJsonObject(schema.items)) {
|
|
302
|
+
value.forEach((item, index) => validateWorkflowHumanActionPayloadAgainstSchema(item, schema.items, `${path}.${index}`, diagnostics, context));
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
function isJsonValue(value) {
|
|
306
|
+
if (value === null ||
|
|
307
|
+
typeof value === "string" ||
|
|
308
|
+
typeof value === "boolean" ||
|
|
309
|
+
(typeof value === "number" && Number.isFinite(value))) {
|
|
310
|
+
return true;
|
|
311
|
+
}
|
|
312
|
+
if (Array.isArray(value))
|
|
313
|
+
return value.every(isJsonValue);
|
|
314
|
+
if (typeof value === "object")
|
|
315
|
+
return Object.values(value).every(isJsonValue);
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
function isJsonObject(value) {
|
|
319
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
320
|
+
}
|
|
321
|
+
function readParamsSchemaTypes(value) {
|
|
322
|
+
if (typeof value === "string")
|
|
323
|
+
return [value];
|
|
324
|
+
if (Array.isArray(value))
|
|
325
|
+
return value.filter((entry) => typeof entry === "string");
|
|
326
|
+
return [];
|
|
327
|
+
}
|
|
328
|
+
function workflowParamValueMatchesType(value, typeName) {
|
|
329
|
+
if (typeName === "string")
|
|
330
|
+
return typeof value === "string";
|
|
331
|
+
if (typeName === "number")
|
|
332
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
333
|
+
if (typeName === "integer")
|
|
334
|
+
return Number.isInteger(value);
|
|
335
|
+
if (typeName === "boolean")
|
|
336
|
+
return typeof value === "boolean";
|
|
337
|
+
if (typeName === "object")
|
|
338
|
+
return isJsonObject(value);
|
|
339
|
+
if (typeName === "array")
|
|
340
|
+
return Array.isArray(value);
|
|
341
|
+
if (typeName === "null")
|
|
342
|
+
return value === null;
|
|
343
|
+
return true;
|
|
344
|
+
}
|
|
345
|
+
function workflowParamsChildPath(path, key) {
|
|
346
|
+
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? `${path}.${key}` : `${path}[${JSON.stringify(key)}]`;
|
|
347
|
+
}
|