@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,214 @@
|
|
|
1
|
+
const MINUTE_MS = 60_000;
|
|
2
|
+
const HOUR_MS = 60 * MINUTE_MS;
|
|
3
|
+
const DAY_MS = 24 * HOUR_MS;
|
|
4
|
+
export function validateSchedule(schedule) {
|
|
5
|
+
switch (schedule.kind) {
|
|
6
|
+
case "at": {
|
|
7
|
+
const date = new Date(schedule.at);
|
|
8
|
+
if (Number.isNaN(date.getTime()))
|
|
9
|
+
throw new Error("schedule.at must be a valid date");
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
case "every":
|
|
13
|
+
if (!Number.isFinite(schedule.everyMs) || schedule.everyMs < MINUTE_MS)
|
|
14
|
+
throw new Error("schedule.everyMs must be at least one minute");
|
|
15
|
+
if (schedule.anchorMs !== undefined && !Number.isFinite(schedule.anchorMs))
|
|
16
|
+
throw new Error("schedule.anchorMs must be finite");
|
|
17
|
+
return;
|
|
18
|
+
case "cron":
|
|
19
|
+
parseCron(schedule.expr);
|
|
20
|
+
if (schedule.tz)
|
|
21
|
+
validateTimeZone(schedule.tz);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function computeNextRunAt(schedule, now = new Date()) {
|
|
26
|
+
validateSchedule(schedule);
|
|
27
|
+
switch (schedule.kind) {
|
|
28
|
+
case "at": {
|
|
29
|
+
const at = new Date(schedule.at);
|
|
30
|
+
return at.getTime() > now.getTime() ? at : undefined;
|
|
31
|
+
}
|
|
32
|
+
case "every": {
|
|
33
|
+
const anchor = schedule.anchorMs ?? 0;
|
|
34
|
+
const elapsed = now.getTime() - anchor;
|
|
35
|
+
const steps = Math.floor(elapsed / schedule.everyMs) + 1;
|
|
36
|
+
return new Date(anchor + Math.max(1, steps) * schedule.everyMs);
|
|
37
|
+
}
|
|
38
|
+
case "cron":
|
|
39
|
+
return computeNextCronRunAt(schedule.expr, now, schedule.tz);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export function parseFriendlySchedule(input, now = new Date()) {
|
|
43
|
+
switch (input.kind) {
|
|
44
|
+
case "in": {
|
|
45
|
+
const everyMs = parseDurationMs(input.value);
|
|
46
|
+
const unit = uiUnit(everyMs);
|
|
47
|
+
const schedule = { kind: "at", at: new Date(now.getTime() + everyMs).toISOString() };
|
|
48
|
+
return { schedule, scheduleUi: { preset: "in", amount: amountForUnit(everyMs, unit), unit } };
|
|
49
|
+
}
|
|
50
|
+
case "at":
|
|
51
|
+
return { schedule: { kind: "at", at: new Date(input.value).toISOString() }, scheduleUi: { preset: "at", localDateTime: input.value, tz: input.tz } };
|
|
52
|
+
case "every": {
|
|
53
|
+
const everyMs = parseDurationMs(input.value);
|
|
54
|
+
const unit = uiUnit(everyMs);
|
|
55
|
+
return { schedule: { kind: "every", everyMs, anchorMs: now.getTime() }, scheduleUi: { preset: "every", amount: amountForUnit(everyMs, unit), unit } };
|
|
56
|
+
}
|
|
57
|
+
case "daily": {
|
|
58
|
+
const { hour, minute } = parseTime(input.time);
|
|
59
|
+
return { schedule: { kind: "cron", expr: `${minute} ${hour} * * *`, tz: input.tz }, scheduleUi: { preset: "daily", time: input.time, tz: input.tz } };
|
|
60
|
+
}
|
|
61
|
+
case "weekly": {
|
|
62
|
+
const { hour, minute } = parseTime(input.time);
|
|
63
|
+
const weekdays = Array.isArray(input.weekdays) ? input.weekdays : parseWeekdays(input.weekdays);
|
|
64
|
+
return { schedule: { kind: "cron", expr: `${minute} ${hour} * * ${weekdays.join(",")}`, tz: input.tz }, scheduleUi: { preset: "weekly", weekdays, time: input.time, tz: input.tz } };
|
|
65
|
+
}
|
|
66
|
+
case "monthly": {
|
|
67
|
+
const { hour, minute } = parseTime(input.time);
|
|
68
|
+
if (!Number.isInteger(input.dayOfMonth) || input.dayOfMonth < 1 || input.dayOfMonth > 31)
|
|
69
|
+
throw new Error("monthly day must be between 1 and 31");
|
|
70
|
+
return { schedule: { kind: "cron", expr: `${minute} ${hour} ${input.dayOfMonth} * *`, tz: input.tz }, scheduleUi: { preset: "monthly", dayOfMonth: input.dayOfMonth, time: input.time, tz: input.tz } };
|
|
71
|
+
}
|
|
72
|
+
case "cron":
|
|
73
|
+
return { schedule: { kind: "cron", expr: input.expr, tz: input.tz }, scheduleUi: { preset: "advanced", expr: input.expr, tz: input.tz } };
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export function formatSchedule(schedule, scheduleUi) {
|
|
77
|
+
if (scheduleUi) {
|
|
78
|
+
switch (scheduleUi.preset) {
|
|
79
|
+
case "in": return `in ${scheduleUi.amount} ${scheduleUi.unit}`;
|
|
80
|
+
case "at": return `at ${scheduleUi.localDateTime}`;
|
|
81
|
+
case "every": return `every ${scheduleUi.amount} ${scheduleUi.unit}`;
|
|
82
|
+
case "daily": return `daily at ${scheduleUi.time}`;
|
|
83
|
+
case "weekly": return `weekly ${scheduleUi.weekdays.join(",")} at ${scheduleUi.time}`;
|
|
84
|
+
case "monthly": return `monthly on day ${scheduleUi.dayOfMonth} at ${scheduleUi.time}`;
|
|
85
|
+
case "advanced": return `cron ${scheduleUi.expr}`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (schedule.kind === "at")
|
|
89
|
+
return `at ${schedule.at}`;
|
|
90
|
+
if (schedule.kind === "every")
|
|
91
|
+
return `every ${formatDuration(schedule.everyMs)}`;
|
|
92
|
+
return `cron ${schedule.expr}${schedule.tz ? ` (${schedule.tz})` : ""}`;
|
|
93
|
+
}
|
|
94
|
+
export function parseDurationMs(value) {
|
|
95
|
+
const match = value.trim().match(/^(\d+(?:\.\d+)?)\s*(m|min|minute|minutes|h|hr|hour|hours|d|day|days)$/i);
|
|
96
|
+
if (!match)
|
|
97
|
+
throw new Error("Duration must look like 20m, 2h, or 1d");
|
|
98
|
+
const amount = Number(match[1]);
|
|
99
|
+
const unit = match[2].toLowerCase();
|
|
100
|
+
const ms = unit.startsWith("m") ? amount * MINUTE_MS : unit.startsWith("h") ? amount * HOUR_MS : amount * DAY_MS;
|
|
101
|
+
if (!Number.isFinite(ms) || ms < MINUTE_MS)
|
|
102
|
+
throw new Error("Duration must be at least one minute");
|
|
103
|
+
return Math.round(ms);
|
|
104
|
+
}
|
|
105
|
+
function formatDuration(ms) {
|
|
106
|
+
if (ms % DAY_MS === 0)
|
|
107
|
+
return `${ms / DAY_MS}d`;
|
|
108
|
+
if (ms % HOUR_MS === 0)
|
|
109
|
+
return `${ms / HOUR_MS}h`;
|
|
110
|
+
return `${Math.round(ms / MINUTE_MS)}m`;
|
|
111
|
+
}
|
|
112
|
+
function uiUnit(ms) {
|
|
113
|
+
if (ms % DAY_MS === 0)
|
|
114
|
+
return "days";
|
|
115
|
+
if (ms % HOUR_MS === 0)
|
|
116
|
+
return "hours";
|
|
117
|
+
return "minutes";
|
|
118
|
+
}
|
|
119
|
+
function amountForUnit(ms, unit) {
|
|
120
|
+
return unit === "days" ? ms / DAY_MS : unit === "hours" ? ms / HOUR_MS : ms / MINUTE_MS;
|
|
121
|
+
}
|
|
122
|
+
function parseTime(value) {
|
|
123
|
+
const match = value.trim().match(/^(\d{1,2}):(\d{2})$/);
|
|
124
|
+
if (!match)
|
|
125
|
+
throw new Error("Time must use HH:MM");
|
|
126
|
+
const hour = Number(match[1]);
|
|
127
|
+
const minute = Number(match[2]);
|
|
128
|
+
if (hour < 0 || hour > 23 || minute < 0 || minute > 59)
|
|
129
|
+
throw new Error("Time is out of range");
|
|
130
|
+
return { hour, minute };
|
|
131
|
+
}
|
|
132
|
+
function parseWeekdays(value) {
|
|
133
|
+
const names = new Map([["sun", 0], ["mon", 1], ["tue", 2], ["wed", 3], ["thu", 4], ["fri", 5], ["sat", 6]]);
|
|
134
|
+
const days = value.split(",").map((part) => {
|
|
135
|
+
const text = part.trim().toLowerCase();
|
|
136
|
+
const numeric = Number(text);
|
|
137
|
+
const day = Number.isInteger(numeric) ? numeric : names.get(text.slice(0, 3));
|
|
138
|
+
if (day === undefined || day < 0 || day > 6)
|
|
139
|
+
throw new Error(`Invalid weekday: ${part}`);
|
|
140
|
+
return day;
|
|
141
|
+
});
|
|
142
|
+
if (days.length === 0)
|
|
143
|
+
throw new Error("At least one weekday is required");
|
|
144
|
+
return [...new Set(days)].sort();
|
|
145
|
+
}
|
|
146
|
+
function parseCron(expr) {
|
|
147
|
+
const fields = expr.trim().split(/\s+/);
|
|
148
|
+
if (fields.length !== 5)
|
|
149
|
+
throw new Error("Cron expression must have 5 fields: minute hour day month weekday");
|
|
150
|
+
return {
|
|
151
|
+
minutes: parseCronField(fields[0], 0, 59, "minute"),
|
|
152
|
+
hours: parseCronField(fields[1], 0, 23, "hour"),
|
|
153
|
+
days: parseCronField(fields[2], 1, 31, "day"),
|
|
154
|
+
months: parseCronField(fields[3], 1, 12, "month"),
|
|
155
|
+
weekdays: parseCronField(fields[4], 0, 7, "weekday", (value) => value === 7 ? 0 : value),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function parseCronField(field, min, max, label, mapValue = (value) => value) {
|
|
159
|
+
const values = new Set();
|
|
160
|
+
for (const part of field.split(",")) {
|
|
161
|
+
const [rangePart, stepPart] = part.split("/");
|
|
162
|
+
const step = stepPart === undefined ? 1 : Number(stepPart);
|
|
163
|
+
if (!Number.isInteger(step) || step < 1)
|
|
164
|
+
throw new Error(`Invalid ${label} step`);
|
|
165
|
+
let start;
|
|
166
|
+
let end;
|
|
167
|
+
if (rangePart === "*") {
|
|
168
|
+
start = min;
|
|
169
|
+
end = max;
|
|
170
|
+
}
|
|
171
|
+
else if (rangePart.includes("-")) {
|
|
172
|
+
const [left, right] = rangePart.split("-").map(Number);
|
|
173
|
+
start = left;
|
|
174
|
+
end = right;
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
start = Number(rangePart);
|
|
178
|
+
end = start;
|
|
179
|
+
}
|
|
180
|
+
if (!Number.isInteger(start) || !Number.isInteger(end) || start < min || end > max || start > end)
|
|
181
|
+
throw new Error(`Invalid ${label} field`);
|
|
182
|
+
for (let value = start; value <= end; value += step)
|
|
183
|
+
values.add(mapValue(value));
|
|
184
|
+
}
|
|
185
|
+
return values;
|
|
186
|
+
}
|
|
187
|
+
function computeNextCronRunAt(expr, now, tz) {
|
|
188
|
+
const spec = parseCron(expr);
|
|
189
|
+
const start = new Date(Math.floor(now.getTime() / MINUTE_MS) * MINUTE_MS + MINUTE_MS);
|
|
190
|
+
const max = start.getTime() + 5 * 366 * DAY_MS;
|
|
191
|
+
for (let time = start.getTime(); time <= max; time += MINUTE_MS) {
|
|
192
|
+
const date = new Date(time);
|
|
193
|
+
const parts = cronDateParts(date, tz);
|
|
194
|
+
if (spec.minutes.has(parts.minute) && spec.hours.has(parts.hour) && spec.days.has(parts.day) && spec.months.has(parts.month) && spec.weekdays.has(parts.weekday))
|
|
195
|
+
return date;
|
|
196
|
+
}
|
|
197
|
+
return undefined;
|
|
198
|
+
}
|
|
199
|
+
function cronDateParts(date, tz) {
|
|
200
|
+
if (!tz)
|
|
201
|
+
return { minute: date.getMinutes(), hour: date.getHours(), day: date.getDate(), month: date.getMonth() + 1, weekday: date.getDay() };
|
|
202
|
+
const parts = new Intl.DateTimeFormat("en-US", { timeZone: tz, minute: "numeric", hour: "numeric", day: "numeric", month: "numeric", weekday: "short", hour12: false }).formatToParts(date);
|
|
203
|
+
const get = (type) => Number(parts.find((part) => part.type === type)?.value);
|
|
204
|
+
const weekdays = new Map([["Sun", 0], ["Mon", 1], ["Tue", 2], ["Wed", 3], ["Thu", 4], ["Fri", 5], ["Sat", 6]]);
|
|
205
|
+
return { minute: get("minute"), hour: get("hour") % 24, day: get("day"), month: get("month"), weekday: weekdays.get(parts.find((part) => part.type === "weekday")?.value ?? "") ?? 0 };
|
|
206
|
+
}
|
|
207
|
+
function validateTimeZone(tz) {
|
|
208
|
+
try {
|
|
209
|
+
new Intl.DateTimeFormat("en-US", { timeZone: tz }).format(new Date());
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
throw new Error(`Invalid timezone: ${tz}`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { getDefaultPiboWorkspace } from "../core/workspace.js";
|
|
3
|
+
import { PiboDataStore } from "../data/pibo-store.js";
|
|
4
|
+
import { ChatRoomService } from "../apps/chat/data/room-service.js";
|
|
5
|
+
import { isPiboRoomArchived } from "../apps/chat/types/rooms.js";
|
|
6
|
+
import { formatSchedule } from "./schedule.js";
|
|
7
|
+
import { createDefaultPiboCronStore } from "./store.js";
|
|
8
|
+
const CHAT_WEB_CHANNEL = "pibo.chat-web";
|
|
9
|
+
function errorMessage(error) {
|
|
10
|
+
return error instanceof Error ? error.message : String(error);
|
|
11
|
+
}
|
|
12
|
+
function buildCronPrompt(job) {
|
|
13
|
+
return [
|
|
14
|
+
"You are running a scheduled Pibo job.",
|
|
15
|
+
`Job: ${job.name}`,
|
|
16
|
+
`Schedule: ${formatSchedule(job.schedule, job.scheduleUi)}`,
|
|
17
|
+
`Target: ${job.target.kind}`,
|
|
18
|
+
"",
|
|
19
|
+
"Complete the scheduled task below. Return the result in this session. Do not create another cron job unless the original task explicitly asks for it.",
|
|
20
|
+
"",
|
|
21
|
+
"Task:",
|
|
22
|
+
job.prompt,
|
|
23
|
+
].join("\n");
|
|
24
|
+
}
|
|
25
|
+
export class PiboCronService {
|
|
26
|
+
options;
|
|
27
|
+
store;
|
|
28
|
+
dataStore;
|
|
29
|
+
roomService;
|
|
30
|
+
intervalMs;
|
|
31
|
+
maxConcurrentRuns;
|
|
32
|
+
runTimeoutMs;
|
|
33
|
+
timer;
|
|
34
|
+
activeRuns = 0;
|
|
35
|
+
stopped = true;
|
|
36
|
+
constructor(options) {
|
|
37
|
+
this.options = options;
|
|
38
|
+
this.store = options.store ?? createDefaultPiboCronStore();
|
|
39
|
+
this.dataStore = new PiboDataStore(options.dataStorePath, { payloadRootDir: options.dataPayloadRootDir });
|
|
40
|
+
this.roomService = new ChatRoomService(this.dataStore);
|
|
41
|
+
this.intervalMs = options.intervalMs ?? 60_000;
|
|
42
|
+
this.maxConcurrentRuns = Math.max(1, options.maxConcurrentRuns ?? 2);
|
|
43
|
+
this.runTimeoutMs = options.runTimeoutMs ?? 30 * 60_000;
|
|
44
|
+
}
|
|
45
|
+
start() {
|
|
46
|
+
if (!this.stopped)
|
|
47
|
+
return;
|
|
48
|
+
this.stopped = false;
|
|
49
|
+
this.store.recoverInterruptedRuns();
|
|
50
|
+
this.arm(1000);
|
|
51
|
+
}
|
|
52
|
+
stop() {
|
|
53
|
+
this.stopped = true;
|
|
54
|
+
if (this.timer)
|
|
55
|
+
clearTimeout(this.timer);
|
|
56
|
+
this.timer = undefined;
|
|
57
|
+
this.dataStore.close();
|
|
58
|
+
this.store.close();
|
|
59
|
+
}
|
|
60
|
+
status() {
|
|
61
|
+
return { enabled: !this.stopped, ...this.store.status() };
|
|
62
|
+
}
|
|
63
|
+
async runJobNow(id) {
|
|
64
|
+
const reserved = this.store.reserveManualRun(id);
|
|
65
|
+
if (!reserved)
|
|
66
|
+
throw new Error("Cron job not found");
|
|
67
|
+
void this.executeReserved(reserved.job, reserved.run).finally(() => this.armSoon());
|
|
68
|
+
return reserved.run;
|
|
69
|
+
}
|
|
70
|
+
arm(delayMs) {
|
|
71
|
+
if (this.stopped)
|
|
72
|
+
return;
|
|
73
|
+
if (this.timer)
|
|
74
|
+
clearTimeout(this.timer);
|
|
75
|
+
const status = this.store.status();
|
|
76
|
+
const nextDelay = status.nextRunAt ? Math.max(1000, new Date(status.nextRunAt).getTime() - Date.now()) : this.intervalMs;
|
|
77
|
+
this.timer = setTimeout(() => void this.tick(), Math.min(delayMs ?? nextDelay, this.intervalMs));
|
|
78
|
+
}
|
|
79
|
+
armSoon() {
|
|
80
|
+
this.arm(1000);
|
|
81
|
+
}
|
|
82
|
+
async tick() {
|
|
83
|
+
if (this.stopped)
|
|
84
|
+
return;
|
|
85
|
+
try {
|
|
86
|
+
const capacity = this.maxConcurrentRuns - this.activeRuns;
|
|
87
|
+
if (capacity > 0) {
|
|
88
|
+
const due = this.store.reserveDueRuns(capacity);
|
|
89
|
+
for (const { job, run } of due)
|
|
90
|
+
void this.executeReserved(job, run).finally(() => this.armSoon());
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
console.error("[cron] scheduler tick failed", error);
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
this.arm();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async executeReserved(job, run) {
|
|
101
|
+
this.activeRuns += 1;
|
|
102
|
+
try {
|
|
103
|
+
const piboSessionId = await this.executeJob(job, run);
|
|
104
|
+
this.store.completeRun({ jobId: job.id, runId: run.id, status: "ok", piboSessionId });
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
this.store.completeRun({ jobId: job.id, runId: run.id, status: "error", error: errorMessage(error) });
|
|
108
|
+
console.error(`[cron] job ${job.id} failed`, error);
|
|
109
|
+
}
|
|
110
|
+
finally {
|
|
111
|
+
this.activeRuns -= 1;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async executeJob(job, run) {
|
|
115
|
+
const target = this.resolveTarget(job);
|
|
116
|
+
const session = this.options.context.createSession({
|
|
117
|
+
channel: CHAT_WEB_CHANNEL,
|
|
118
|
+
kind: "cron",
|
|
119
|
+
profile: job.profile,
|
|
120
|
+
workspace: target.workspace ?? getDefaultPiboWorkspace(),
|
|
121
|
+
title: job.name,
|
|
122
|
+
metadata: {
|
|
123
|
+
...(target.metadata ?? {}),
|
|
124
|
+
chatRoomId: target.roomId,
|
|
125
|
+
cronJobId: job.id,
|
|
126
|
+
cronRunId: run.id,
|
|
127
|
+
cronTargetKind: job.target.kind,
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
await this.emitMessageAndWait(session.id, buildCronPrompt(job));
|
|
131
|
+
return session.id;
|
|
132
|
+
}
|
|
133
|
+
resolveTarget(job) {
|
|
134
|
+
if (job.target.kind === "room") {
|
|
135
|
+
const room = this.roomService.getRoom(job.target.roomId);
|
|
136
|
+
if (!room)
|
|
137
|
+
throw new Error("Target room no longer exists");
|
|
138
|
+
if (isPiboRoomArchived(room))
|
|
139
|
+
throw new Error("Target room is archived");
|
|
140
|
+
return { roomId: room.id, workspace: room.workspace ?? getDefaultPiboWorkspace() };
|
|
141
|
+
}
|
|
142
|
+
const room = this.roomService.ensureDefaultRoom({ name: "Shared Chat" });
|
|
143
|
+
return { roomId: room.id, workspace: room.workspace ?? getDefaultPiboWorkspace() };
|
|
144
|
+
}
|
|
145
|
+
async emitMessageAndWait(piboSessionId, text) {
|
|
146
|
+
const eventId = `cron_msg_${randomUUID()}`;
|
|
147
|
+
await new Promise((resolve, reject) => {
|
|
148
|
+
let settled = false;
|
|
149
|
+
let unsubscribe;
|
|
150
|
+
const timeout = setTimeout(() => {
|
|
151
|
+
finish(new Error("Cron run timed out"));
|
|
152
|
+
}, this.runTimeoutMs);
|
|
153
|
+
const finish = (error) => {
|
|
154
|
+
if (settled)
|
|
155
|
+
return;
|
|
156
|
+
settled = true;
|
|
157
|
+
clearTimeout(timeout);
|
|
158
|
+
unsubscribe?.();
|
|
159
|
+
if (error)
|
|
160
|
+
reject(error);
|
|
161
|
+
else
|
|
162
|
+
resolve();
|
|
163
|
+
};
|
|
164
|
+
unsubscribe = this.options.context.subscribe((event) => {
|
|
165
|
+
if (event.piboSessionId !== piboSessionId)
|
|
166
|
+
return;
|
|
167
|
+
if ("eventId" in event && event.eventId !== eventId)
|
|
168
|
+
return;
|
|
169
|
+
if (event.type === "message_finished")
|
|
170
|
+
finish();
|
|
171
|
+
if (event.type === "session_error")
|
|
172
|
+
finish(new Error(event.error));
|
|
173
|
+
});
|
|
174
|
+
this.options.context.emit({ type: "message", piboSessionId, id: eventId, source: "service", text }).catch((error) => finish(error instanceof Error ? error : new Error(String(error))));
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|