@pasko70/pibo 1.1.0 → 1.3.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/chat-vscode-web/assets/index-B5QK07zO.css +2 -0
- package/dist/apps/chat-vscode-web/assets/index-C3GTPyDo.js +41 -0
- package/dist/apps/chat-vscode-web/index.html +14 -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/apps/vscode-artifacts/latest.vsix +0 -0
- package/dist/apps/vscode-artifacts/pibo-vscode-1.3.0.vsix +0 -0
- 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 +159 -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/vscode/cli.js +90 -0
- package/dist/vscode/code-cli.js +119 -0
- package/dist/vscode/install.js +177 -0
- package/dist/vscode/status.js +80 -0
- package/dist/vscode/types.js +14 -0
- package/dist/vscode/uninstall.js +49 -0
- package/dist/vscode/vsix-fetcher.js +131 -0
- 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/docs/ops/vscode-extension-release.md +138 -0
- package/package.json +24 -9
- 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,681 @@
|
|
|
1
|
+
import { existsSync, statSync } from "node:fs";
|
|
2
|
+
import { isAbsolute, resolve } from "node:path";
|
|
3
|
+
import { savePiboModelDefaults } from "../../core/model-defaults.js";
|
|
4
|
+
import { isPiboThinkingLevel } from "../../core/thinking.js";
|
|
5
|
+
import { PiboWebHttpError } from "../../web/http.js";
|
|
6
|
+
import { listPiPackages } from "../../pi-packages/store.js";
|
|
7
|
+
import { withChatWebArchived } from "./session-metadata.js";
|
|
8
|
+
import { isDefaultPiboRoom, withPiboRoomArchived, withPiboRoomWorkspace } from "./types/rooms.js";
|
|
9
|
+
import { isValidCustomAgentName } from "./agent-store.js";
|
|
10
|
+
export function normalizeRoomName(value, fallback = "New Chat") {
|
|
11
|
+
if (value === undefined)
|
|
12
|
+
return fallback;
|
|
13
|
+
if (typeof value !== "string")
|
|
14
|
+
throw new PiboWebHttpError("Room name must be a string", 400);
|
|
15
|
+
const name = value.replace(/\s+/g, " ").trim();
|
|
16
|
+
if (!name)
|
|
17
|
+
throw new PiboWebHttpError("Room name is required", 400);
|
|
18
|
+
if (name.length > 120)
|
|
19
|
+
throw new PiboWebHttpError("Room name is too long", 400);
|
|
20
|
+
return name;
|
|
21
|
+
}
|
|
22
|
+
export function normalizeRoomTopic(value) {
|
|
23
|
+
if (value === undefined || value === null)
|
|
24
|
+
return undefined;
|
|
25
|
+
if (typeof value !== "string")
|
|
26
|
+
throw new PiboWebHttpError("Room topic must be a string", 400);
|
|
27
|
+
const topic = value.replace(/\s+/g, " ").trim();
|
|
28
|
+
if (!topic)
|
|
29
|
+
return undefined;
|
|
30
|
+
if (topic.length > 500)
|
|
31
|
+
throw new PiboWebHttpError("Room topic is too long", 400);
|
|
32
|
+
return topic;
|
|
33
|
+
}
|
|
34
|
+
export function normalizeOptionalRoomTopic(value) {
|
|
35
|
+
if (value === undefined)
|
|
36
|
+
return undefined;
|
|
37
|
+
if (value === null)
|
|
38
|
+
return null;
|
|
39
|
+
return normalizeRoomTopic(value) ?? null;
|
|
40
|
+
}
|
|
41
|
+
export function normalizeRoomType(value) {
|
|
42
|
+
if (value === undefined)
|
|
43
|
+
return "chat";
|
|
44
|
+
if (value === "space" || value === "chat" || value === "agent")
|
|
45
|
+
return value;
|
|
46
|
+
throw new PiboWebHttpError("Room type is invalid", 400);
|
|
47
|
+
}
|
|
48
|
+
export function normalizeParentRoomId(value) {
|
|
49
|
+
if (value === undefined || value === null || value === "")
|
|
50
|
+
return undefined;
|
|
51
|
+
if (typeof value !== "string")
|
|
52
|
+
throw new PiboWebHttpError("Parent room id must be a string", 400);
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
export function normalizeOptionalParentRoomId(value) {
|
|
56
|
+
if (value === undefined)
|
|
57
|
+
return undefined;
|
|
58
|
+
if (value === null || value === "")
|
|
59
|
+
return null;
|
|
60
|
+
if (typeof value !== "string")
|
|
61
|
+
throw new PiboWebHttpError("Parent room id must be a string", 400);
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
export function normalizeRoomArchived(value) {
|
|
65
|
+
if (value === undefined)
|
|
66
|
+
return undefined;
|
|
67
|
+
if (typeof value !== "boolean")
|
|
68
|
+
throw new PiboWebHttpError("Room archived flag must be boolean", 400);
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
export function normalizeRoomWorkspace(value) {
|
|
72
|
+
if (value === undefined || value === null)
|
|
73
|
+
return undefined;
|
|
74
|
+
if (typeof value !== "string")
|
|
75
|
+
throw new PiboWebHttpError("Room workspace must be a string", 400);
|
|
76
|
+
const workspace = value.trim();
|
|
77
|
+
if (!workspace)
|
|
78
|
+
return undefined;
|
|
79
|
+
if (!isAbsolute(workspace)) {
|
|
80
|
+
throw new PiboWebHttpError("Room workspace must be an absolute path", 400);
|
|
81
|
+
}
|
|
82
|
+
if (!existsSync(workspace)) {
|
|
83
|
+
throw new PiboWebHttpError(`Room workspace does not exist: ${workspace}`, 400);
|
|
84
|
+
}
|
|
85
|
+
if (!statSync(workspace).isDirectory()) {
|
|
86
|
+
throw new PiboWebHttpError(`Room workspace is not a directory: ${workspace}`, 400);
|
|
87
|
+
}
|
|
88
|
+
return workspace;
|
|
89
|
+
}
|
|
90
|
+
export function normalizeOptionalRoomWorkspace(value) {
|
|
91
|
+
if (value === undefined)
|
|
92
|
+
return undefined;
|
|
93
|
+
if (value === null)
|
|
94
|
+
return null;
|
|
95
|
+
return normalizeRoomWorkspace(value) ?? null;
|
|
96
|
+
}
|
|
97
|
+
export function normalizeRoomDeleteConfirmation(value) {
|
|
98
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
99
|
+
throw new PiboWebHttpError("Type the room name to permanently delete it.", 400);
|
|
100
|
+
}
|
|
101
|
+
return value.trim();
|
|
102
|
+
}
|
|
103
|
+
export function normalizeAgentDisplayName(value, fallback = "new-agent") {
|
|
104
|
+
if (value === undefined)
|
|
105
|
+
return fallback;
|
|
106
|
+
if (typeof value !== "string")
|
|
107
|
+
throw new PiboWebHttpError("Agent name must be a string", 400);
|
|
108
|
+
const name = value.trim();
|
|
109
|
+
if (!name)
|
|
110
|
+
throw new PiboWebHttpError("Agent name is required", 400);
|
|
111
|
+
if (name.length > 120)
|
|
112
|
+
throw new PiboWebHttpError("Agent name is too long", 400);
|
|
113
|
+
if (!isValidCustomAgentName(name)) {
|
|
114
|
+
throw new PiboWebHttpError("Agent name must be lowercase kebab-case, for example test-agent", 400);
|
|
115
|
+
}
|
|
116
|
+
return name;
|
|
117
|
+
}
|
|
118
|
+
export function normalizeAgentDescription(value) {
|
|
119
|
+
if (value === undefined || value === null)
|
|
120
|
+
return undefined;
|
|
121
|
+
if (typeof value !== "string")
|
|
122
|
+
throw new PiboWebHttpError("Agent description must be a string", 400);
|
|
123
|
+
const description = value.trim();
|
|
124
|
+
if (!description)
|
|
125
|
+
return undefined;
|
|
126
|
+
if (description.length > 1000)
|
|
127
|
+
throw new PiboWebHttpError("Agent description is too long", 400);
|
|
128
|
+
return description;
|
|
129
|
+
}
|
|
130
|
+
export function normalizeNameArray(value, label) {
|
|
131
|
+
if (value === undefined)
|
|
132
|
+
return [];
|
|
133
|
+
if (!Array.isArray(value))
|
|
134
|
+
throw new PiboWebHttpError(`${label} must be an array`, 400);
|
|
135
|
+
const names = value.map((item) => {
|
|
136
|
+
if (typeof item !== "string" || item.trim().length === 0) {
|
|
137
|
+
throw new PiboWebHttpError(`${label} entries must be non-empty strings`, 400);
|
|
138
|
+
}
|
|
139
|
+
return item.trim();
|
|
140
|
+
});
|
|
141
|
+
return [...new Set(names)];
|
|
142
|
+
}
|
|
143
|
+
export function normalizeRegisteredPiPackages(value) {
|
|
144
|
+
const names = normalizeNameArray(value, "piPackages");
|
|
145
|
+
const packages = listPiPackages();
|
|
146
|
+
const registered = new Map(packages.flatMap((pkg) => [[pkg.id, pkg.id], [pkg.name, pkg.id]]));
|
|
147
|
+
for (const name of names) {
|
|
148
|
+
if (!registered.has(name))
|
|
149
|
+
throw new PiboWebHttpError(`Unknown Pi package "${name}"`, 400);
|
|
150
|
+
}
|
|
151
|
+
return [...new Set(names.map((name) => registered.get(name) ?? name))];
|
|
152
|
+
}
|
|
153
|
+
export function normalizePiPackageWebSource(value) {
|
|
154
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
155
|
+
throw new PiboWebHttpError("Pi package source is required", 400);
|
|
156
|
+
}
|
|
157
|
+
const source = value.trim();
|
|
158
|
+
let url;
|
|
159
|
+
try {
|
|
160
|
+
url = new URL(source);
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
throw new PiboWebHttpError("Pi package source must be a https://pi.dev/packages/... URL", 400);
|
|
164
|
+
}
|
|
165
|
+
if (url.origin !== "https://pi.dev" || !url.pathname.startsWith("/packages/") || url.pathname === "/packages/") {
|
|
166
|
+
throw new PiboWebHttpError("Pi package source must be a https://pi.dev/packages/... URL", 400);
|
|
167
|
+
}
|
|
168
|
+
return source;
|
|
169
|
+
}
|
|
170
|
+
export function normalizeBuiltinTools(value) {
|
|
171
|
+
if (value === undefined)
|
|
172
|
+
return "default";
|
|
173
|
+
if (value === "default" || value === "disabled")
|
|
174
|
+
return value;
|
|
175
|
+
throw new PiboWebHttpError("builtinTools must be default or disabled", 400);
|
|
176
|
+
}
|
|
177
|
+
export function normalizeBuiltinToolNames(value) {
|
|
178
|
+
if (value === undefined)
|
|
179
|
+
return undefined;
|
|
180
|
+
return normalizeNameArray(value, "builtinToolNames");
|
|
181
|
+
}
|
|
182
|
+
export function normalizeAutoContextFiles(value) {
|
|
183
|
+
if (value === undefined)
|
|
184
|
+
return true;
|
|
185
|
+
if (typeof value !== "boolean")
|
|
186
|
+
throw new PiboWebHttpError("autoContextFiles must be a boolean", 400);
|
|
187
|
+
return value;
|
|
188
|
+
}
|
|
189
|
+
export function normalizeRunControl(value) {
|
|
190
|
+
if (value === undefined)
|
|
191
|
+
return false;
|
|
192
|
+
if (typeof value !== "boolean")
|
|
193
|
+
throw new PiboWebHttpError("runControl must be a boolean", 400);
|
|
194
|
+
return value;
|
|
195
|
+
}
|
|
196
|
+
export function normalizeOptionalBoolean(value, fieldName) {
|
|
197
|
+
if (value === undefined || value === null)
|
|
198
|
+
return undefined;
|
|
199
|
+
if (typeof value !== "boolean")
|
|
200
|
+
throw new PiboWebHttpError(`${fieldName} must be a boolean`, 400);
|
|
201
|
+
return value;
|
|
202
|
+
}
|
|
203
|
+
export function normalizeThinkingLevel(value, fieldName) {
|
|
204
|
+
if (value === undefined || value === null)
|
|
205
|
+
return undefined;
|
|
206
|
+
if (typeof value !== "string" || !isPiboThinkingLevel(value)) {
|
|
207
|
+
throw new PiboWebHttpError(`${fieldName} must be one of off, minimal, low, medium, high, xhigh`, 400);
|
|
208
|
+
}
|
|
209
|
+
return value;
|
|
210
|
+
}
|
|
211
|
+
export function normalizeModelProfile(value, fieldName) {
|
|
212
|
+
if (value === undefined || value === null)
|
|
213
|
+
return undefined;
|
|
214
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
215
|
+
throw new PiboWebHttpError(`${fieldName} must be an object`, 400);
|
|
216
|
+
}
|
|
217
|
+
const raw = value;
|
|
218
|
+
if (typeof raw.provider !== "string" || typeof raw.id !== "string") {
|
|
219
|
+
throw new PiboWebHttpError(`${fieldName} must include provider and id`, 400);
|
|
220
|
+
}
|
|
221
|
+
const provider = raw.provider.trim();
|
|
222
|
+
const id = raw.id.trim();
|
|
223
|
+
if (!provider || !id) {
|
|
224
|
+
throw new PiboWebHttpError(`${fieldName} must include provider and id`, 400);
|
|
225
|
+
}
|
|
226
|
+
return { provider, id };
|
|
227
|
+
}
|
|
228
|
+
export function normalizeMcpServerDescriptionBody(value) {
|
|
229
|
+
if (typeof value !== "string")
|
|
230
|
+
throw new PiboWebHttpError("MCP server description must be a string", 400);
|
|
231
|
+
const description = value.replace(/\s+/g, " ").trim();
|
|
232
|
+
if (!description)
|
|
233
|
+
throw new PiboWebHttpError("MCP server description is required", 400);
|
|
234
|
+
if (description.length > 480)
|
|
235
|
+
throw new PiboWebHttpError("MCP server description is too long", 400);
|
|
236
|
+
return description;
|
|
237
|
+
}
|
|
238
|
+
export function normalizeBasePromptMode(value) {
|
|
239
|
+
if (value === "library" || value === "custom")
|
|
240
|
+
return value;
|
|
241
|
+
throw new PiboWebHttpError("mode must be library or custom", 400);
|
|
242
|
+
}
|
|
243
|
+
export function normalizeCompactionPromptMode(value) {
|
|
244
|
+
if (value === "library" || value === "custom")
|
|
245
|
+
return value;
|
|
246
|
+
throw new PiboWebHttpError("mode must be library or custom", 400);
|
|
247
|
+
}
|
|
248
|
+
export function normalizeBasePromptMarkdown(value) {
|
|
249
|
+
if (typeof value !== "string")
|
|
250
|
+
throw new PiboWebHttpError("markdown must be a string", 400);
|
|
251
|
+
return value;
|
|
252
|
+
}
|
|
253
|
+
export function normalizeCompactionPromptMarkdown(value) {
|
|
254
|
+
if (typeof value !== "string")
|
|
255
|
+
throw new PiboWebHttpError("markdown must be a string", 400);
|
|
256
|
+
return value;
|
|
257
|
+
}
|
|
258
|
+
export function normalizeUserSkillName(value) {
|
|
259
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
260
|
+
throw new PiboWebHttpError("Skill name is required", 400);
|
|
261
|
+
}
|
|
262
|
+
const name = value.trim();
|
|
263
|
+
if (name.length > 64)
|
|
264
|
+
throw new PiboWebHttpError("Skill name is too long", 400);
|
|
265
|
+
if (!/^[a-z][a-z0-9-]*$/.test(name)) {
|
|
266
|
+
throw new PiboWebHttpError("Skill name must be lowercase kebab-case, e.g. my-skill", 400);
|
|
267
|
+
}
|
|
268
|
+
return name;
|
|
269
|
+
}
|
|
270
|
+
export function normalizeUserSkillDescription(value) {
|
|
271
|
+
if (typeof value !== "string")
|
|
272
|
+
throw new PiboWebHttpError("Skill description must be a string", 400);
|
|
273
|
+
return value.trim();
|
|
274
|
+
}
|
|
275
|
+
export function normalizeUserSkillMarkdown(value) {
|
|
276
|
+
if (typeof value !== "string")
|
|
277
|
+
throw new PiboWebHttpError("Skill markdown must be a string", 400);
|
|
278
|
+
return value;
|
|
279
|
+
}
|
|
280
|
+
export function normalizeUserSkillEnabled(value) {
|
|
281
|
+
if (value === undefined)
|
|
282
|
+
return undefined;
|
|
283
|
+
if (typeof value !== "boolean")
|
|
284
|
+
throw new PiboWebHttpError("enabled must be a boolean", 400);
|
|
285
|
+
return value;
|
|
286
|
+
}
|
|
287
|
+
export function normalizeUserSkillUrl(value) {
|
|
288
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
289
|
+
throw new PiboWebHttpError("Skill URL is required", 400);
|
|
290
|
+
}
|
|
291
|
+
const url = value.trim();
|
|
292
|
+
if (!url.startsWith("http://") && !url.startsWith("https://") && !url.includes("/")) {
|
|
293
|
+
throw new PiboWebHttpError("Skill URL must be a valid URL or account/repo shorthand", 400);
|
|
294
|
+
}
|
|
295
|
+
return url;
|
|
296
|
+
}
|
|
297
|
+
export function normalizeAgentArchived(value) {
|
|
298
|
+
if (value === undefined)
|
|
299
|
+
return undefined;
|
|
300
|
+
if (typeof value !== "boolean")
|
|
301
|
+
throw new PiboWebHttpError("archived must be a boolean", 400);
|
|
302
|
+
return value;
|
|
303
|
+
}
|
|
304
|
+
export function normalizeAgentSubagents(value) {
|
|
305
|
+
if (value === undefined)
|
|
306
|
+
return [];
|
|
307
|
+
if (!Array.isArray(value))
|
|
308
|
+
throw new PiboWebHttpError("subagents must be an array", 400);
|
|
309
|
+
return value.map((item) => {
|
|
310
|
+
if (!item || typeof item !== "object" || Array.isArray(item)) {
|
|
311
|
+
throw new PiboWebHttpError("subagent entries must be objects", 400);
|
|
312
|
+
}
|
|
313
|
+
const raw = item;
|
|
314
|
+
const name = normalizeAgentDisplayName(raw.name, "");
|
|
315
|
+
if (typeof raw.targetProfile !== "string" || raw.targetProfile.trim().length === 0) {
|
|
316
|
+
throw new PiboWebHttpError("subagent targetProfile is required", 400);
|
|
317
|
+
}
|
|
318
|
+
const subagent = {
|
|
319
|
+
name,
|
|
320
|
+
targetProfile: raw.targetProfile.trim(),
|
|
321
|
+
};
|
|
322
|
+
const description = normalizeAgentDescription(raw.description);
|
|
323
|
+
if (description)
|
|
324
|
+
subagent.description = description;
|
|
325
|
+
if (raw.timeoutMs !== undefined) {
|
|
326
|
+
if (typeof raw.timeoutMs !== "number" || !Number.isFinite(raw.timeoutMs) || raw.timeoutMs <= 0) {
|
|
327
|
+
throw new PiboWebHttpError("subagent timeoutMs must be a positive number", 400);
|
|
328
|
+
}
|
|
329
|
+
subagent.timeoutMs = Math.round(raw.timeoutMs);
|
|
330
|
+
}
|
|
331
|
+
if (raw.maxDepth !== undefined) {
|
|
332
|
+
if (typeof raw.maxDepth !== "number" || !Number.isFinite(raw.maxDepth) || raw.maxDepth < 1) {
|
|
333
|
+
throw new PiboWebHttpError("subagent maxDepth must be a positive number", 400);
|
|
334
|
+
}
|
|
335
|
+
subagent.maxDepth = Math.round(raw.maxDepth);
|
|
336
|
+
}
|
|
337
|
+
return subagent;
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
export function normalizeClientTxnId(value) {
|
|
341
|
+
if (value === undefined)
|
|
342
|
+
return undefined;
|
|
343
|
+
if (typeof value !== "string")
|
|
344
|
+
throw new PiboWebHttpError("clientTxnId must be a string", 400);
|
|
345
|
+
const id = value.trim();
|
|
346
|
+
if (!id)
|
|
347
|
+
throw new PiboWebHttpError("clientTxnId must be a non-empty string", 400);
|
|
348
|
+
if (id.length > 160)
|
|
349
|
+
throw new PiboWebHttpError("clientTxnId is too long", 400);
|
|
350
|
+
return id;
|
|
351
|
+
}
|
|
352
|
+
export function normalizeSessionDeleteConfirmation(value) {
|
|
353
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
354
|
+
throw new PiboWebHttpError('Type "Delete this session" to permanently delete it.', 400);
|
|
355
|
+
}
|
|
356
|
+
return value.trim();
|
|
357
|
+
}
|
|
358
|
+
export function normalizeMessageText(value) {
|
|
359
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
360
|
+
throw new PiboWebHttpError("Message text is required", 400);
|
|
361
|
+
}
|
|
362
|
+
return value;
|
|
363
|
+
}
|
|
364
|
+
export function defaultStreamingFixtureDeltas(mix) {
|
|
365
|
+
if (mix === "markdown")
|
|
366
|
+
return [" **a**", " **b**", " **c**", " **d**", " **e**", " **f**", " **g**", " **h**", " **i**", " **j**", " **k**", " **l**"];
|
|
367
|
+
if (mix === "gfm-markdown")
|
|
368
|
+
return [" ~~a~~", " ~~b~~", " ~~c~~", " ~~d~~", " ~~e~~", " ~~f~~", " ~~g~~", " ~~h~~", " ~~i~~", " ~~j~~", " ~~k~~", " ~~l~~"];
|
|
369
|
+
if (mix === "gfm-task-markdown")
|
|
370
|
+
return ["- [ ] [_**a**_](https://e.co/a)", " [_**b**_](https://e.co/b)", " [_**c**_](https://e.co/c)", " [_**d**_](https://e.co/d)", " [_**e**_](https://e.co/e)", " [_**f**_](https://e.co/f)", " [_**g**_](https://e.co/g)", " [_**h**_](https://e.co/h)", " [_**i**_](https://e.co/i)", " [_**j**_](https://e.co/j)", " [_**k**_](https://e.co/k)", " [_**l**_](https://e.co/l)"];
|
|
371
|
+
if (mix === "gfm-full-markdown")
|
|
372
|
+
return ["- [ ] [_~~a~~_](https://e.co/a)", " [_~~b~~_](https://e.co/b)", " [_~~c~~_](https://e.co/c)", " [_~~d~~_](https://e.co/d)", " [_~~e~~_](https://e.co/e)", " [_~~f~~_](https://e.co/f)", " [_~~g~~_](https://e.co/g)", " [_~~h~~_](https://e.co/h)", " [_~~i~~_](https://e.co/i)", " [_~~j~~_](https://e.co/j)", " [_~~k~~_](https://e.co/k)", " [_~~l~~_](https://e.co/l)"];
|
|
373
|
+
return [" a", " b", " c", " d", " e", " f", " g", " h", " i", " j", " k", " l"];
|
|
374
|
+
}
|
|
375
|
+
export function normalizeStreamingFixtureDeltas(value, mix) {
|
|
376
|
+
if (value === undefined)
|
|
377
|
+
return defaultStreamingFixtureDeltas(mix);
|
|
378
|
+
if (!Array.isArray(value) || value.length === 0)
|
|
379
|
+
throw new PiboWebHttpError("deltas must be a non-empty string array", 400);
|
|
380
|
+
if (value.length > 100)
|
|
381
|
+
throw new PiboWebHttpError("deltas must contain at most 100 entries", 400);
|
|
382
|
+
return value.map((item) => {
|
|
383
|
+
if (typeof item !== "string" || item.length === 0)
|
|
384
|
+
throw new PiboWebHttpError("deltas entries must be non-empty strings", 400);
|
|
385
|
+
if (item.length > 200)
|
|
386
|
+
throw new PiboWebHttpError("deltas entries must be at most 200 characters", 400);
|
|
387
|
+
return item;
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
export function normalizeStreamingFixtureCadenceMs(value) {
|
|
391
|
+
if (value === undefined)
|
|
392
|
+
return 100;
|
|
393
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < 10 || value > 5_000) {
|
|
394
|
+
throw new PiboWebHttpError("cadenceMs must be a number between 10 and 5000", 400);
|
|
395
|
+
}
|
|
396
|
+
return Math.round(value);
|
|
397
|
+
}
|
|
398
|
+
export function normalizeStreamingFixtureProfile(value) {
|
|
399
|
+
if (value === undefined)
|
|
400
|
+
return "steady";
|
|
401
|
+
if (value === "steady" || value === "jitter" || value === "burst" || value === "batch")
|
|
402
|
+
return value;
|
|
403
|
+
throw new PiboWebHttpError("profile must be steady, jitter, burst, or batch", 400);
|
|
404
|
+
}
|
|
405
|
+
export function normalizeStreamingFixtureMix(value) {
|
|
406
|
+
if (value === undefined)
|
|
407
|
+
return "text";
|
|
408
|
+
if (value === "text" || value === "reasoning-text" || value === "markdown" || value === "gfm-markdown" || value === "gfm-task-markdown" || value === "gfm-full-markdown")
|
|
409
|
+
return value;
|
|
410
|
+
throw new PiboWebHttpError("mix must be text, reasoning-text, markdown, gfm-markdown, gfm-task-markdown, or gfm-full-markdown", 400);
|
|
411
|
+
}
|
|
412
|
+
export function normalizeStreamingFixturePreludeMessages(value) {
|
|
413
|
+
if (value === undefined)
|
|
414
|
+
return 0;
|
|
415
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < 0 || value > 2000) {
|
|
416
|
+
throw new PiboWebHttpError("preludeMessages must be an integer between 0 and 2000", 400);
|
|
417
|
+
}
|
|
418
|
+
return value;
|
|
419
|
+
}
|
|
420
|
+
export function normalizeStreamingFixturePreludeOnly(value) {
|
|
421
|
+
if (value === undefined)
|
|
422
|
+
return false;
|
|
423
|
+
if (typeof value === "boolean")
|
|
424
|
+
return value;
|
|
425
|
+
throw new PiboWebHttpError("preludeOnly must be a boolean", 400);
|
|
426
|
+
}
|
|
427
|
+
export function normalizeStreamingFixtureTraceSnapshots(value) {
|
|
428
|
+
if (value === undefined)
|
|
429
|
+
return false;
|
|
430
|
+
if (typeof value === "boolean")
|
|
431
|
+
return value;
|
|
432
|
+
throw new PiboWebHttpError("traceSnapshots must be a boolean", 400);
|
|
433
|
+
}
|
|
434
|
+
export function normalizeStreamingFixtureSuppressLiveDeltas(value) {
|
|
435
|
+
if (value === undefined)
|
|
436
|
+
return false;
|
|
437
|
+
if (typeof value === "boolean")
|
|
438
|
+
return value;
|
|
439
|
+
throw new PiboWebHttpError("suppressLiveDeltas must be a boolean", 400);
|
|
440
|
+
}
|
|
441
|
+
export function buildStreamingFixtureSchedule(deltaCount, cadenceMs, profile) {
|
|
442
|
+
const delays = [];
|
|
443
|
+
let elapsedMs = 0;
|
|
444
|
+
for (let index = 0; index < deltaCount; index += 1) {
|
|
445
|
+
let gapMs = cadenceMs;
|
|
446
|
+
if (profile === "jitter") {
|
|
447
|
+
const jitterMs = [-30, 50, -20, 30, -40, 60, -10, 40, -50, 70, -20, 30][index % 12];
|
|
448
|
+
gapMs = Math.max(10, cadenceMs + jitterMs);
|
|
449
|
+
}
|
|
450
|
+
else if (profile === "burst") {
|
|
451
|
+
gapMs = index > 0 && index % 3 !== 0 ? Math.max(10, Math.round(cadenceMs / 5)) : Math.max(cadenceMs, Math.round(cadenceMs * 2.5));
|
|
452
|
+
}
|
|
453
|
+
else if (profile === "batch") {
|
|
454
|
+
gapMs = index % 4 === 0 ? Math.max(cadenceMs, Math.round(cadenceMs * 3)) : 0;
|
|
455
|
+
}
|
|
456
|
+
elapsedMs += gapMs;
|
|
457
|
+
delays.push(elapsedMs);
|
|
458
|
+
}
|
|
459
|
+
return delays;
|
|
460
|
+
}
|
|
461
|
+
export function updateChatModelDefaults(body, cwd = process.cwd()) {
|
|
462
|
+
return savePiboModelDefaults({
|
|
463
|
+
main: normalizeModelProfile(body.main, "main"),
|
|
464
|
+
subagent: normalizeModelProfile(body.subagent, "subagent"),
|
|
465
|
+
thinking: normalizeThinkingLevel(body.thinking, "thinking"),
|
|
466
|
+
mainThinking: normalizeThinkingLevel(body.mainThinking, "mainThinking"),
|
|
467
|
+
subagentThinking: normalizeThinkingLevel(body.subagentThinking, "subagentThinking"),
|
|
468
|
+
fast: normalizeOptionalBoolean(body.fast, "fast"),
|
|
469
|
+
mainFast: normalizeOptionalBoolean(body.mainFast, "mainFast"),
|
|
470
|
+
subagentFast: normalizeOptionalBoolean(body.subagentFast, "subagentFast"),
|
|
471
|
+
}, cwd);
|
|
472
|
+
}
|
|
473
|
+
const PROJECT_SESSION_PATCH_FIELDS = new Set([
|
|
474
|
+
"title",
|
|
475
|
+
"archived",
|
|
476
|
+
]);
|
|
477
|
+
export function assertProjectSessionPatchFields(body) {
|
|
478
|
+
if (!body || typeof body !== "object" || Array.isArray(body))
|
|
479
|
+
throw new PiboWebHttpError("Invalid JSON body", 400);
|
|
480
|
+
for (const key of Object.keys(body)) {
|
|
481
|
+
if (!PROJECT_SESSION_PATCH_FIELDS.has(key)) {
|
|
482
|
+
throw new PiboWebHttpError(`Unsupported project session update field: ${key}. Project workflow selection and configuration are immutable; create a new configured session to change workflow, input, prompt, model, thinking, or fast-mode values.`, 400);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
export function normalizeProjectPath(value) {
|
|
487
|
+
if (typeof value !== "string" || !value.trim())
|
|
488
|
+
throw new PiboWebHttpError("Project folder is required", 400);
|
|
489
|
+
let projectPath = value.trim();
|
|
490
|
+
if (projectPath === "~")
|
|
491
|
+
projectPath = process.env.HOME ?? projectPath;
|
|
492
|
+
else if (projectPath.startsWith("~/"))
|
|
493
|
+
projectPath = `${process.env.HOME ?? ""}${projectPath.slice(1)}`;
|
|
494
|
+
if (!isAbsolute(projectPath))
|
|
495
|
+
throw new PiboWebHttpError("Project folder must be an absolute path, e.g. ~/code/my-project or /home/me/code/my-project", 400);
|
|
496
|
+
return resolve(projectPath);
|
|
497
|
+
}
|
|
498
|
+
export function normalizeProjectDescription(value) {
|
|
499
|
+
if (value === undefined || value === null)
|
|
500
|
+
return undefined;
|
|
501
|
+
if (typeof value !== "string")
|
|
502
|
+
throw new PiboWebHttpError("Project description must be a string", 400);
|
|
503
|
+
return value.trim() || undefined;
|
|
504
|
+
}
|
|
505
|
+
export function normalizeProjectArchived(value) {
|
|
506
|
+
if (value === undefined)
|
|
507
|
+
return undefined;
|
|
508
|
+
if (typeof value !== "boolean")
|
|
509
|
+
throw new PiboWebHttpError("Project archived flag must be boolean", 400);
|
|
510
|
+
return value;
|
|
511
|
+
}
|
|
512
|
+
export function normalizeProjectSessionArchived(value) {
|
|
513
|
+
if (value === undefined)
|
|
514
|
+
return undefined;
|
|
515
|
+
if (typeof value !== "boolean")
|
|
516
|
+
throw new PiboWebHttpError("Project session archived flag must be boolean", 400);
|
|
517
|
+
return value;
|
|
518
|
+
}
|
|
519
|
+
export function normalizeSessionTitle(value) {
|
|
520
|
+
if (value === undefined)
|
|
521
|
+
return undefined;
|
|
522
|
+
if (value === null)
|
|
523
|
+
return null;
|
|
524
|
+
if (typeof value !== "string") {
|
|
525
|
+
throw new PiboWebHttpError("Session title must be a string or null", 400);
|
|
526
|
+
}
|
|
527
|
+
const title = value.replace(/\s+/g, " ").trim();
|
|
528
|
+
if (!title)
|
|
529
|
+
return null;
|
|
530
|
+
if (title.length > 120) {
|
|
531
|
+
throw new PiboWebHttpError("Session title is too long", 400);
|
|
532
|
+
}
|
|
533
|
+
return title;
|
|
534
|
+
}
|
|
535
|
+
export function metadataWithArchiveState(session, archived) {
|
|
536
|
+
if (archived === undefined)
|
|
537
|
+
return undefined;
|
|
538
|
+
if (typeof archived !== "boolean") {
|
|
539
|
+
throw new PiboWebHttpError("Session archived flag must be boolean", 400);
|
|
540
|
+
}
|
|
541
|
+
return withChatWebArchived(session.metadata, archived);
|
|
542
|
+
}
|
|
543
|
+
export function createSessionUpdate(context, session, body) {
|
|
544
|
+
const update = {};
|
|
545
|
+
const title = normalizeSessionTitle(body.title);
|
|
546
|
+
if (title !== undefined)
|
|
547
|
+
update.title = title;
|
|
548
|
+
const metadata = metadataWithArchiveState(session, body.archived);
|
|
549
|
+
if (metadata)
|
|
550
|
+
update.metadata = metadata;
|
|
551
|
+
if (body.profile !== undefined) {
|
|
552
|
+
update.profile = resolveCreateSessionProfile(context, session.profile, body.profile);
|
|
553
|
+
}
|
|
554
|
+
if (body.activeModel !== undefined) {
|
|
555
|
+
update.activeModel = body.activeModel === null ? null : normalizeModelProfile(body.activeModel, "activeModel");
|
|
556
|
+
}
|
|
557
|
+
if (!("title" in update) && !("metadata" in update) && !("profile" in update) && !("activeModel" in update)) {
|
|
558
|
+
throw new PiboWebHttpError("No session update fields provided", 400);
|
|
559
|
+
}
|
|
560
|
+
return update;
|
|
561
|
+
}
|
|
562
|
+
export function createRoomUpdate(room, body) {
|
|
563
|
+
if (isDefaultPiboRoom(room)) {
|
|
564
|
+
throw new PiboWebHttpError("Shared Chat cannot be changed", 400);
|
|
565
|
+
}
|
|
566
|
+
const update = {};
|
|
567
|
+
if (body.name !== undefined)
|
|
568
|
+
update.name = normalizeRoomName(body.name);
|
|
569
|
+
if (body.topic !== undefined)
|
|
570
|
+
update.topic = normalizeOptionalRoomTopic(body.topic);
|
|
571
|
+
if (body.parentRoomId !== undefined)
|
|
572
|
+
update.parentRoomId = normalizeOptionalParentRoomId(body.parentRoomId);
|
|
573
|
+
const archived = normalizeRoomArchived(body.archived);
|
|
574
|
+
const workspace = normalizeOptionalRoomWorkspace(body.workspace);
|
|
575
|
+
let metadata = room.metadata;
|
|
576
|
+
let metadataChanged = false;
|
|
577
|
+
if (archived !== undefined) {
|
|
578
|
+
metadata = withPiboRoomArchived(metadata, archived);
|
|
579
|
+
metadataChanged = true;
|
|
580
|
+
}
|
|
581
|
+
if (workspace !== undefined) {
|
|
582
|
+
metadata = withPiboRoomWorkspace(metadata, workspace ?? undefined);
|
|
583
|
+
metadataChanged = true;
|
|
584
|
+
}
|
|
585
|
+
if (metadataChanged)
|
|
586
|
+
update.metadata = metadata;
|
|
587
|
+
if (Object.keys(update).length === 0) {
|
|
588
|
+
throw new PiboWebHttpError("No room update fields provided", 400);
|
|
589
|
+
}
|
|
590
|
+
return update;
|
|
591
|
+
}
|
|
592
|
+
export function createAgentInput(body) {
|
|
593
|
+
return {
|
|
594
|
+
displayName: normalizeAgentDisplayName(body.displayName),
|
|
595
|
+
description: normalizeAgentDescription(body.description),
|
|
596
|
+
nativeTools: normalizeNameArray(body.nativeTools, "nativeTools"),
|
|
597
|
+
skills: normalizeNameArray(body.skills, "skills"),
|
|
598
|
+
contextFiles: normalizeNameArray(body.contextFiles, "contextFiles"),
|
|
599
|
+
subagents: normalizeAgentSubagents(body.subagents),
|
|
600
|
+
mcpServers: normalizeNameArray(body.mcpServers, "mcpServers"),
|
|
601
|
+
piPackages: normalizeRegisteredPiPackages(body.piPackages),
|
|
602
|
+
mainModel: normalizeModelProfile(body.mainModel, "mainModel"),
|
|
603
|
+
subagentModel: normalizeModelProfile(body.subagentModel, "subagentModel"),
|
|
604
|
+
thinkingLevel: normalizeThinkingLevel(body.thinkingLevel, "thinkingLevel"),
|
|
605
|
+
mainThinkingLevel: normalizeThinkingLevel(body.mainThinkingLevel, "mainThinkingLevel"),
|
|
606
|
+
subagentThinkingLevel: normalizeThinkingLevel(body.subagentThinkingLevel, "subagentThinkingLevel"),
|
|
607
|
+
fast: normalizeOptionalBoolean(body.fast, "fast"),
|
|
608
|
+
mainFast: normalizeOptionalBoolean(body.mainFast, "mainFast"),
|
|
609
|
+
subagentFast: normalizeOptionalBoolean(body.subagentFast, "subagentFast"),
|
|
610
|
+
builtinTools: normalizeBuiltinTools(body.builtinTools),
|
|
611
|
+
builtinToolNames: normalizeBuiltinToolNames(body.builtinToolNames),
|
|
612
|
+
autoContextFiles: normalizeAutoContextFiles(body.autoContextFiles),
|
|
613
|
+
runControl: normalizeRunControl(body.runControl),
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
export function createAgentUpdate(body) {
|
|
617
|
+
const update = {};
|
|
618
|
+
if (body.displayName !== undefined)
|
|
619
|
+
update.displayName = normalizeAgentDisplayName(body.displayName);
|
|
620
|
+
if (body.description !== undefined)
|
|
621
|
+
update.description = normalizeAgentDescription(body.description);
|
|
622
|
+
if (body.nativeTools !== undefined)
|
|
623
|
+
update.nativeTools = normalizeNameArray(body.nativeTools, "nativeTools");
|
|
624
|
+
if (body.skills !== undefined)
|
|
625
|
+
update.skills = normalizeNameArray(body.skills, "skills");
|
|
626
|
+
if (body.contextFiles !== undefined)
|
|
627
|
+
update.contextFiles = normalizeNameArray(body.contextFiles, "contextFiles");
|
|
628
|
+
if (body.subagents !== undefined)
|
|
629
|
+
update.subagents = normalizeAgentSubagents(body.subagents);
|
|
630
|
+
if (body.mcpServers !== undefined)
|
|
631
|
+
update.mcpServers = normalizeNameArray(body.mcpServers, "mcpServers");
|
|
632
|
+
if (body.piPackages !== undefined)
|
|
633
|
+
update.piPackages = normalizeRegisteredPiPackages(body.piPackages);
|
|
634
|
+
if (body.mainModel !== undefined)
|
|
635
|
+
update.mainModel = normalizeModelProfile(body.mainModel, "mainModel");
|
|
636
|
+
if (body.subagentModel !== undefined)
|
|
637
|
+
update.subagentModel = normalizeModelProfile(body.subagentModel, "subagentModel");
|
|
638
|
+
if (body.thinkingLevel !== undefined)
|
|
639
|
+
update.thinkingLevel = normalizeThinkingLevel(body.thinkingLevel, "thinkingLevel");
|
|
640
|
+
if (body.mainThinkingLevel !== undefined)
|
|
641
|
+
update.mainThinkingLevel = normalizeThinkingLevel(body.mainThinkingLevel, "mainThinkingLevel");
|
|
642
|
+
if (body.subagentThinkingLevel !== undefined)
|
|
643
|
+
update.subagentThinkingLevel = normalizeThinkingLevel(body.subagentThinkingLevel, "subagentThinkingLevel");
|
|
644
|
+
if (body.fast !== undefined)
|
|
645
|
+
update.fast = normalizeOptionalBoolean(body.fast, "fast");
|
|
646
|
+
if (body.mainFast !== undefined)
|
|
647
|
+
update.mainFast = normalizeOptionalBoolean(body.mainFast, "mainFast");
|
|
648
|
+
if (body.subagentFast !== undefined)
|
|
649
|
+
update.subagentFast = normalizeOptionalBoolean(body.subagentFast, "subagentFast");
|
|
650
|
+
if (body.builtinTools !== undefined)
|
|
651
|
+
update.builtinTools = normalizeBuiltinTools(body.builtinTools);
|
|
652
|
+
if (body.builtinToolNames !== undefined)
|
|
653
|
+
update.builtinToolNames = normalizeBuiltinToolNames(body.builtinToolNames);
|
|
654
|
+
if (body.autoContextFiles !== undefined)
|
|
655
|
+
update.autoContextFiles = normalizeAutoContextFiles(body.autoContextFiles);
|
|
656
|
+
if (body.runControl !== undefined)
|
|
657
|
+
update.runControl = normalizeRunControl(body.runControl);
|
|
658
|
+
if (Object.keys(update).length === 0 && body.archived === undefined) {
|
|
659
|
+
throw new PiboWebHttpError("No agent update fields provided", 400);
|
|
660
|
+
}
|
|
661
|
+
return update;
|
|
662
|
+
}
|
|
663
|
+
export function resolveCreateSessionProfile(context, defaultProfile, requestedProfile) {
|
|
664
|
+
if (requestedProfile === undefined)
|
|
665
|
+
return defaultProfile;
|
|
666
|
+
if (typeof requestedProfile !== "string" || requestedProfile.trim().length === 0) {
|
|
667
|
+
throw new PiboWebHttpError("Profile must be a non-empty string", 400);
|
|
668
|
+
}
|
|
669
|
+
const profileName = requestedProfile.trim();
|
|
670
|
+
const profiles = context.channelContext.getProfiles?.() ?? [];
|
|
671
|
+
if (!profiles.length) {
|
|
672
|
+
if (profileName === defaultProfile)
|
|
673
|
+
return defaultProfile;
|
|
674
|
+
throw new PiboWebHttpError(`Unknown profile "${profileName}"`, 400);
|
|
675
|
+
}
|
|
676
|
+
const matched = profiles.find((profile) => profile.name === profileName || profile.aliases.includes(profileName));
|
|
677
|
+
if (!matched) {
|
|
678
|
+
throw new PiboWebHttpError(`Unknown profile "${profileName}"`, 400);
|
|
679
|
+
}
|
|
680
|
+
return matched.name;
|
|
681
|
+
}
|