@pyric/cli 0.1.0-alpha.20 → 0.1.0-alpha.22
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 +64 -89
- package/dist/assurance/.generated/conformance-verdicts.d.ts +238 -1
- package/dist/assurance/.generated/conformance-verdicts.d.ts.map +1 -1
- package/dist/assurance/.generated/conformance-verdicts.js +238 -1
- package/dist/assurance/.generated/conformance-verdicts.js.map +1 -1
- package/dist/bridge/client/dispatch.d.ts +25 -19
- package/dist/bridge/client/dispatch.d.ts.map +1 -1
- package/dist/bridge/client/dispatch.js +41 -48
- package/dist/bridge/client/dispatch.js.map +1 -1
- package/dist/bridge/client/tool-family-factories.d.ts +26 -0
- package/dist/bridge/client/tool-family-factories.d.ts.map +1 -0
- package/dist/bridge/client/tool-family-factories.js +10 -0
- package/dist/bridge/client/tool-family-factories.js.map +1 -0
- package/dist/bridge/server/mcp-contract.d.ts +7 -6
- package/dist/bridge/server/mcp-contract.d.ts.map +1 -1
- package/dist/bridge/server/mcp-contract.js +9 -48
- package/dist/bridge/server/mcp-contract.js.map +1 -1
- package/dist/bridge/server/peer.d.ts +11 -1
- package/dist/bridge/server/peer.d.ts.map +1 -1
- package/dist/bridge/server/peer.js +22 -1
- package/dist/bridge/server/peer.js.map +1 -1
- package/dist/bridge/server/tool-family-factories.d.ts +30 -0
- package/dist/bridge/server/tool-family-factories.d.ts.map +1 -0
- package/dist/bridge/server/tool-family-factories.js +22 -0
- package/dist/bridge/server/tool-family-factories.js.map +1 -0
- package/dist/bridge/server/tool-metadata.d.ts +17 -18
- package/dist/bridge/server/tool-metadata.d.ts.map +1 -1
- package/dist/bridge/server/tool-metadata.js +24 -59
- package/dist/bridge/server/tool-metadata.js.map +1 -1
- package/dist/bridge/tool-families.d.ts +48 -0
- package/dist/bridge/tool-families.d.ts.map +1 -0
- package/dist/bridge/tool-families.generated.d.ts +32 -0
- package/dist/bridge/tool-families.generated.d.ts.map +1 -0
- package/dist/bridge/tool-families.generated.js +15 -0
- package/dist/bridge/tool-families.generated.js.map +1 -0
- package/dist/bridge/tool-families.js +51 -0
- package/dist/bridge/tool-families.js.map +1 -0
- package/dist/bridge/tool-family-records/conformance.d.ts +7 -0
- package/dist/bridge/tool-family-records/conformance.d.ts.map +1 -0
- package/dist/bridge/tool-family-records/conformance.js +6 -0
- package/dist/bridge/tool-family-records/conformance.js.map +1 -0
- package/dist/bridge/tool-family-records/firestore-data.d.ts +7 -0
- package/dist/bridge/tool-family-records/firestore-data.d.ts.map +1 -0
- package/dist/bridge/tool-family-records/firestore-data.js +15 -0
- package/dist/bridge/tool-family-records/firestore-data.js.map +1 -0
- package/dist/bridge/tool-family-records/firestore-inspect.d.ts +7 -0
- package/dist/bridge/tool-family-records/firestore-inspect.d.ts.map +1 -0
- package/dist/bridge/tool-family-records/firestore-inspect.js +6 -0
- package/dist/bridge/tool-family-records/firestore-inspect.js.map +1 -0
- package/dist/bridge/tool-family-records/firestore-rules.d.ts +7 -0
- package/dist/bridge/tool-family-records/firestore-rules.d.ts.map +1 -0
- package/dist/bridge/tool-family-records/firestore-rules.js +15 -0
- package/dist/bridge/tool-family-records/firestore-rules.js.map +1 -0
- package/dist/bridge/tool-family-records/firestore-simulator.d.ts +7 -0
- package/dist/bridge/tool-family-records/firestore-simulator.d.ts.map +1 -0
- package/dist/bridge/tool-family-records/firestore-simulator.js +16 -0
- package/dist/bridge/tool-family-records/firestore-simulator.js.map +1 -0
- package/dist/bridge/tool-family-records/rtdb-inspection.d.ts +7 -0
- package/dist/bridge/tool-family-records/rtdb-inspection.d.ts.map +1 -0
- package/dist/bridge/tool-family-records/rtdb-inspection.js +6 -0
- package/dist/bridge/tool-family-records/rtdb-inspection.js.map +1 -0
- package/dist/bundler/externals.d.ts +37 -0
- package/dist/bundler/externals.d.ts.map +1 -0
- package/dist/bundler/externals.js +52 -0
- package/dist/bundler/externals.js.map +1 -0
- package/dist/bundler/index.d.ts +17 -0
- package/dist/bundler/index.d.ts.map +1 -0
- package/dist/bundler/index.js +17 -0
- package/dist/bundler/index.js.map +1 -0
- package/dist/cli/inlined-sdk-scanner.d.ts +6 -0
- package/dist/cli/inlined-sdk-scanner.d.ts.map +1 -0
- package/dist/cli/inlined-sdk-scanner.js +82 -0
- package/dist/cli/inlined-sdk-scanner.js.map +1 -0
- package/dist/cli/sandbox-interlock.d.ts +97 -0
- package/dist/cli/sandbox-interlock.d.ts.map +1 -0
- package/dist/cli/sandbox-interlock.js +112 -0
- package/dist/cli/sandbox-interlock.js.map +1 -0
- package/dist/cli/sandbox-runner.d.ts +20 -12
- package/dist/cli/sandbox-runner.d.ts.map +1 -1
- package/dist/cli/sandbox-runner.js +24 -21
- package/dist/cli/sandbox-runner.js.map +1 -1
- package/dist/cli/serve.d.ts +6 -10
- package/dist/cli/serve.d.ts.map +1 -1
- package/dist/cli/serve.js +57 -77
- package/dist/cli/serve.js.map +1 -1
- package/dist/cli/unsupported-runtime.d.ts +27 -0
- package/dist/cli/unsupported-runtime.d.ts.map +1 -0
- package/dist/cli/unsupported-runtime.js +63 -0
- package/dist/cli/unsupported-runtime.js.map +1 -0
- package/dist/conformance/.generated/can-i-use-browser.d.ts +1 -1
- package/dist/conformance/.generated/can-i-use-browser.d.ts.map +1 -1
- package/dist/conformance/.generated/can-i-use-browser.js +1 -1
- package/dist/conformance/.generated/can-i-use-browser.js.map +1 -1
- package/dist/conformance/.generated/can-i-use.d.ts +1 -1
- package/dist/conformance/.generated/can-i-use.d.ts.map +1 -1
- package/dist/conformance/.generated/can-i-use.js +1 -1
- package/dist/conformance/.generated/can-i-use.js.map +1 -1
- package/dist/conformance/.generated/conformance-docs.d.ts.map +1 -1
- package/dist/conformance/.generated/conformance-docs.js +1 -1
- package/dist/conformance/.generated/conformance-docs.js.map +1 -1
- package/dist/functions-rtdb/child.d.ts +37 -0
- package/dist/functions-rtdb/child.d.ts.map +1 -1
- package/dist/functions-rtdb/child.js +90 -21
- package/dist/functions-rtdb/child.js.map +1 -1
- package/dist/functions-rtdb/development-runtime.d.ts +3 -0
- package/dist/functions-rtdb/development-runtime.d.ts.map +1 -1
- package/dist/functions-rtdb/development-runtime.js +1 -0
- package/dist/functions-rtdb/development-runtime.js.map +1 -1
- package/dist/google-endpoints.d.ts +67 -0
- package/dist/google-endpoints.d.ts.map +1 -0
- package/dist/google-endpoints.js +119 -0
- package/dist/google-endpoints.js.map +1 -0
- package/dist/next/runtime-env.d.ts.map +1 -1
- package/dist/next/runtime-env.js +5 -0
- package/dist/next/runtime-env.js.map +1 -1
- package/dist/next/with-pyric.d.ts +1 -1
- package/dist/next/with-pyric.js +1 -1
- package/dist/register/beacon.d.ts +69 -0
- package/dist/register/beacon.d.ts.map +1 -0
- package/dist/register/beacon.js +199 -0
- package/dist/register/beacon.js.map +1 -0
- package/dist/register/index.d.ts.map +1 -1
- package/dist/register/index.js +65 -6
- package/dist/register/index.js.map +1 -1
- package/dist/register/net-guard.d.ts +110 -0
- package/dist/register/net-guard.d.ts.map +1 -0
- package/dist/register/net-guard.js +462 -0
- package/dist/register/net-guard.js.map +1 -0
- package/dist/serve/ai-diagnostics-relay.d.ts +63 -0
- package/dist/serve/ai-diagnostics-relay.d.ts.map +1 -0
- package/dist/serve/ai-diagnostics-relay.js +125 -0
- package/dist/serve/ai-diagnostics-relay.js.map +1 -0
- package/dist/serve/ai-proxy.d.ts +92 -0
- package/dist/serve/ai-proxy.d.ts.map +1 -0
- package/dist/serve/ai-proxy.js +269 -0
- package/dist/serve/ai-proxy.js.map +1 -0
- package/dist/serve/ai-status.d.ts +44 -0
- package/dist/serve/ai-status.d.ts.map +1 -0
- package/dist/serve/ai-status.js +77 -0
- package/dist/serve/ai-status.js.map +1 -0
- package/dist/serve/ai-terminal-blocks.d.ts +97 -0
- package/dist/serve/ai-terminal-blocks.d.ts.map +1 -0
- package/dist/serve/ai-terminal-blocks.js +128 -0
- package/dist/serve/ai-terminal-blocks.js.map +1 -0
- package/dist/serve/ai-terminal-text.d.ts +36 -0
- package/dist/serve/ai-terminal-text.d.ts.map +1 -0
- package/dist/serve/ai-terminal-text.js +48 -0
- package/dist/serve/ai-terminal-text.js.map +1 -0
- package/dist/serve/beacon-route.d.ts +53 -0
- package/dist/serve/beacon-route.d.ts.map +1 -0
- package/dist/serve/beacon-route.js +101 -0
- package/dist/serve/beacon-route.js.map +1 -0
- package/dist/serve/entries/active-auth-registry.d.ts +16 -0
- package/dist/serve/entries/active-auth-registry.d.ts.map +1 -0
- package/dist/serve/entries/active-auth-registry.js +48 -0
- package/dist/serve/entries/active-auth-registry.js.map +1 -0
- package/dist/serve/entries/active-auth.d.ts +18 -0
- package/dist/serve/entries/active-auth.d.ts.map +1 -0
- package/dist/serve/entries/active-auth.js +84 -0
- package/dist/serve/entries/active-auth.js.map +1 -0
- package/dist/serve/entries/auth-helper-core.d.ts +1 -0
- package/dist/serve/entries/auth-helper-core.d.ts.map +1 -1
- package/dist/serve/entries/auth-helper-core.js +4 -0
- package/dist/serve/entries/auth-helper-core.js.map +1 -1
- package/dist/serve/entries/auth-helper-dom.d.ts.map +1 -1
- package/dist/serve/entries/auth-helper-dom.js +28 -2
- package/dist/serve/entries/auth-helper-dom.js.map +1 -1
- package/dist/serve/entries/auth.d.ts.map +1 -1
- package/dist/serve/entries/auth.js +8 -0
- package/dist/serve/entries/auth.js.map +1 -1
- package/dist/serve/entries/bridge-url.d.ts +1 -1
- package/dist/serve/entries/bridge-url.js +1 -1
- package/dist/serve/entries/init.d.ts.map +1 -1
- package/dist/serve/entries/init.js +70 -4
- package/dist/serve/entries/init.js.map +1 -1
- package/dist/serve/entries/runtime.d.ts.map +1 -1
- package/dist/serve/entries/runtime.js +9 -0
- package/dist/serve/entries/runtime.js.map +1 -1
- package/dist/serve/namespace.d.ts +14 -5
- package/dist/serve/namespace.d.ts.map +1 -1
- package/dist/serve/namespace.js +57 -124
- package/dist/serve/namespace.js.map +1 -1
- package/dist/serve/runtime/chip-config.d.ts.map +1 -1
- package/dist/serve/runtime/chip-config.js +16 -2
- package/dist/serve/runtime/chip-config.js.map +1 -1
- package/dist/serve/runtime/chip-dialog.d.ts +18 -0
- package/dist/serve/runtime/chip-dialog.d.ts.map +1 -0
- package/dist/serve/runtime/chip-dialog.js +315 -0
- package/dist/serve/runtime/chip-dialog.js.map +1 -0
- package/dist/serve/runtime/chip-install.d.ts +2 -0
- package/dist/serve/runtime/chip-install.d.ts.map +1 -1
- package/dist/serve/runtime/chip-install.js +9 -4
- package/dist/serve/runtime/chip-install.js.map +1 -1
- package/dist/serve/runtime/chip-user-search.d.ts +16 -0
- package/dist/serve/runtime/chip-user-search.d.ts.map +1 -0
- package/dist/serve/runtime/chip-user-search.js +354 -0
- package/dist/serve/runtime/chip-user-search.js.map +1 -0
- package/dist/serve/runtime/chip.d.ts +10 -0
- package/dist/serve/runtime/chip.d.ts.map +1 -1
- package/dist/serve/runtime/chip.js +118 -15
- package/dist/serve/runtime/chip.js.map +1 -1
- package/dist/serve/runtime/identity.d.ts +17 -0
- package/dist/serve/runtime/identity.d.ts.map +1 -0
- package/dist/serve/runtime/identity.js +10 -0
- package/dist/serve/runtime/identity.js.map +1 -0
- package/dist/serve/sandbox-session.d.ts +7 -0
- package/dist/serve/sandbox-session.d.ts.map +1 -1
- package/dist/serve/sandbox-session.js +2 -0
- package/dist/serve/sandbox-session.js.map +1 -1
- package/dist/serve/site-ui/_astro/{RulesCodeEditor.XtDmHOlN.js → RulesCodeEditor.DsTAsKIa.js} +1 -1
- package/dist/serve/site-ui/_astro/app.CMmTxyhL.js +1 -0
- package/dist/serve/site-ui/_astro/app.DhALsVii.js +115 -0
- package/dist/serve/site-ui/_astro/{chess-showcase.B72XYeoh.js → chess-showcase.Bn_pP6UJ.js} +2 -2
- package/dist/serve/site-ui/_astro/{example-runtime.C25_lx6Z.js → example-runtime.CXopTGv7.js} +1 -1
- package/dist/serve/site-ui/_astro/sandbox-controls.rOuZTOUG.js +510 -0
- package/dist/serve/site-ui/_astro/{seed.Co0yUJY5.js → seed.lywYbXZ0.js} +2 -2
- package/dist/serve/site-ui/_astro/writes.BsPBG3dp.js +653 -0
- package/dist/serve/site-ui/auth/index.html +1 -1
- package/dist/serve/site-ui/docs/_rhythm/index.html +1 -1
- package/dist/serve/site-ui/docs/agent/set-up-your-agent/index.html +1 -1
- package/dist/serve/site-ui/docs/agent/watch-and-review/index.html +1 -1
- package/dist/serve/site-ui/docs/agent/work-with-an-agent/index.html +1 -1
- package/dist/serve/site-ui/docs/ai-compat/index.html +1 -1
- package/dist/serve/site-ui/docs/api-reference/index.html +8 -1
- package/dist/serve/site-ui/docs/api-reference.md +7 -0
- package/dist/serve/site-ui/docs/app-compat/index.html +1 -1
- package/dist/serve/site-ui/docs/auth-compat/index.html +3 -3
- package/dist/serve/site-ui/docs/auth-compat.md +2 -2
- package/dist/serve/site-ui/docs/build/ai-logic/index.html +6 -1
- package/dist/serve/site-ui/docs/build/ai-logic.md +6 -0
- package/dist/serve/site-ui/docs/build/authentication/index.html +2 -2
- package/dist/serve/site-ui/docs/build/authentication.md +1 -1
- package/dist/serve/site-ui/docs/build/cloud-firestore/index.html +4 -2
- package/dist/serve/site-ui/docs/build/cloud-firestore.md +4 -0
- package/dist/serve/site-ui/docs/build/cloud-messaging/index.html +1 -1
- package/dist/serve/site-ui/docs/build/cloud-storage/index.html +1 -1
- package/dist/serve/site-ui/docs/build/realtime-database/index.html +1 -1
- package/dist/serve/site-ui/docs/conformance-scores/index.html +14 -2
- package/dist/serve/site-ui/docs/conformance-scores.md +13 -1
- package/dist/serve/site-ui/docs/create-pyric-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/database-compat/index.html +44 -44
- package/dist/serve/site-ui/docs/database-compat.md +43 -43
- package/dist/serve/site-ui/docs/examples/chess/index.html +1 -1
- package/dist/serve/site-ui/docs/examples/index.html +1 -1
- package/dist/serve/site-ui/docs/firestore-compat/index.html +4 -4
- package/dist/serve/site-ui/docs/firestore-compat.md +3 -3
- package/dist/serve/site-ui/docs/firestore-flutter-compat/index.html +319 -0
- package/dist/serve/site-ui/docs/firestore-flutter-compat.md +344 -0
- package/dist/serve/site-ui/docs/firestore-kotlin-compat/index.html +319 -0
- package/dist/serve/site-ui/docs/firestore-kotlin-compat.md +344 -0
- package/dist/serve/site-ui/docs/firestore-swift-compat/index.html +490 -0
- package/dist/serve/site-ui/docs/firestore-swift-compat.md +517 -0
- package/dist/serve/site-ui/docs/functions-rtdb-compat/index.html +1 -1
- package/dist/serve/site-ui/docs/get-started/backend-bundlers/index.html +105 -0
- package/dist/serve/site-ui/docs/get-started/backend-bundlers.md +165 -0
- package/dist/serve/site-ui/docs/get-started/flutter/index.html +98 -0
- package/dist/serve/site-ui/docs/get-started/flutter.md +105 -0
- package/dist/serve/site-ui/docs/get-started/how-the-swap-works/index.html +1 -1
- package/dist/serve/site-ui/docs/get-started/nextjs/index.html +1 -1
- package/dist/serve/site-ui/docs/get-started/start-building/index.html +1 -1
- package/dist/serve/site-ui/docs/get-started/vite/index.html +1 -1
- package/dist/serve/site-ui/docs/index.json +3211 -1471
- package/dist/serve/site-ui/docs/messaging-compat/index.html +1 -1
- package/dist/serve/site-ui/docs/observe/resolve-runtime-status/index.html +4 -3
- package/dist/serve/site-ui/docs/observe/resolve-runtime-status.md +3 -1
- package/dist/serve/site-ui/docs/observe/see-whats-happening/index.html +1 -1
- package/dist/serve/site-ui/docs/observe/shape-your-data/index.html +1 -1
- package/dist/serve/site-ui/docs/observe/switch-and-impersonate-identities/index.html +110 -0
- package/dist/serve/site-ui/docs/observe/switch-and-impersonate-identities.md +134 -0
- package/dist/serve/site-ui/docs/overview/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-admin-app-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-admin-auth-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-admin-database-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-admin-firestore-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-admin-messaging-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-admin-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-admin-storage-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-ai-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-ai-scripting-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-analytics-reference-api/index.html +124 -0
- package/dist/serve/site-ui/docs/pyric-analytics-reference-api.md +287 -0
- package/dist/serve/site-ui/docs/pyric-app-check-reference-api/index.html +87 -0
- package/dist/serve/site-ui/docs/pyric-app-check-reference-api.md +199 -0
- package/dist/serve/site-ui/docs/pyric-app-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-auth-reference-api/index.html +6 -2
- package/dist/serve/site-ui/docs/pyric-auth-reference-api.md +2 -1
- package/dist/serve/site-ui/docs/pyric-cli-assurance-browser-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-cli-assurance-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-cli-bridge-client-reference-api/index.html +2 -2
- package/dist/serve/site-ui/docs/pyric-cli-bridge-client-reference-api.md +1 -1
- package/dist/serve/site-ui/docs/pyric-cli-bridge-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-cli-bundler-reference-api/index.html +56 -0
- package/dist/serve/site-ui/docs/pyric-cli-bundler-reference-api.md +72 -0
- package/dist/serve/site-ui/docs/pyric-cli-conformance-browser-reference-api/index.html +4 -1
- package/dist/serve/site-ui/docs/pyric-cli-conformance-browser-reference-api.md +3 -0
- package/dist/serve/site-ui/docs/pyric-cli-conformance-docs-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-cli-conformance-reference-api/index.html +4 -1
- package/dist/serve/site-ui/docs/pyric-cli-conformance-reference-api.md +3 -0
- package/dist/serve/site-ui/docs/pyric-cli-credentials-node-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-cli-discover-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-cli-next-reference-api/index.html +2 -2
- package/dist/serve/site-ui/docs/pyric-cli-next-reference-api.md +1 -1
- package/dist/serve/site-ui/docs/pyric-cli-register-app-bridge-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-cli-register-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-cli-remote-reference-api/index.html +34 -9
- package/dist/serve/site-ui/docs/pyric-cli-remote-reference-api.md +16 -8
- package/dist/serve/site-ui/docs/pyric-cli-serve-worker-reference-api/index.html +133 -93
- package/dist/serve/site-ui/docs/pyric-cli-serve-worker-reference-api.md +61 -1
- package/dist/serve/site-ui/docs/pyric-cli-verify-reference-api/index.html +2 -2
- package/dist/serve/site-ui/docs/pyric-cli-verify-reference-api.md +1 -1
- package/dist/serve/site-ui/docs/pyric-cli-vite-reference-api/index.html +2 -2
- package/dist/serve/site-ui/docs/pyric-cli-vite-reference-api.md +2 -2
- package/dist/serve/site-ui/docs/pyric-database-reference-api/index.html +2 -2
- package/dist/serve/site-ui/docs/pyric-database-reference-api.md +1 -1
- package/dist/serve/site-ui/docs/pyric-firestore-lite-reference-api/index.html +559 -0
- package/dist/serve/site-ui/docs/pyric-firestore-lite-reference-api.md +1240 -0
- package/dist/serve/site-ui/docs/pyric-firestore-reference-api/index.html +40 -11
- package/dist/serve/site-ui/docs/pyric-firestore-reference-api.md +18 -8
- package/dist/serve/site-ui/docs/pyric-functions-reference-api/index.html +67 -0
- package/dist/serve/site-ui/docs/pyric-functions-reference-api.md +149 -0
- package/dist/serve/site-ui/docs/pyric-messaging-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-messaging-sw-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-performance-reference-api/index.html +35 -0
- package/dist/serve/site-ui/docs/pyric-performance-reference-api.md +69 -0
- package/dist/serve/site-ui/docs/pyric-remote-config-reference-api/index.html +132 -0
- package/dist/serve/site-ui/docs/pyric-remote-config-reference-api.md +307 -0
- package/dist/serve/site-ui/docs/pyric-rules-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-sandbox-database-reference-api/index.html +52 -17
- package/dist/serve/site-ui/docs/pyric-sandbox-database-reference-api.md +48 -9
- package/dist/serve/site-ui/docs/pyric-sandbox-firestore-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-sandbox-reference-api/index.html +239 -49
- package/dist/serve/site-ui/docs/pyric-sandbox-reference-api.md +148 -31
- package/dist/serve/site-ui/docs/pyric-storage-reference-api/index.html +22 -4
- package/dist/serve/site-ui/docs/pyric-storage-reference-api.md +25 -3
- package/dist/serve/site-ui/docs/pyric-ui-agents-reference-api/index.html +26 -96
- package/dist/serve/site-ui/docs/pyric-ui-agents-reference-api.md +20 -51
- package/dist/serve/site-ui/docs/pyric-ui-auth-hooks-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-ui-auth-reference-api/index.html +2 -2
- package/dist/serve/site-ui/docs/pyric-ui-auth-reference-api.md +1 -1
- package/dist/serve/site-ui/docs/pyric-ui-events-hooks-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-ui-events-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-ui-firestore-hooks-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-ui-firestore-reference-api/index.html +2 -2
- package/dist/serve/site-ui/docs/pyric-ui-firestore-reference-api.md +1 -1
- package/dist/serve/site-ui/docs/pyric-ui-primitives-reference-api/index.html +124 -26
- package/dist/serve/site-ui/docs/pyric-ui-primitives-reference-api.md +58 -5
- package/dist/serve/site-ui/docs/pyric-ui-rtdb-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-ui-rules-hooks-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-ui-rules-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-ui-storage-hooks-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-ui-storage-reference-api/index.html +4 -5
- package/dist/serve/site-ui/docs/pyric-ui-storage-reference-api.md +3 -4
- package/dist/serve/site-ui/docs/pyric-ui-traffic-hooks-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/pyric-ui-traffic-reference-api/index.html +1 -1
- package/dist/serve/site-ui/docs/reference/cli/index.html +6 -3
- package/dist/serve/site-ui/docs/reference/cli.md +8 -2
- package/dist/serve/site-ui/docs/rules-compat/index.html +10 -2
- package/dist/serve/site-ui/docs/rules-compat.md +9 -1
- package/dist/serve/site-ui/docs/secure/audit-your-rules/index.html +1 -1
- package/dist/serve/site-ui/docs/secure/firestore-rules-limits/index.html +1 -1
- package/dist/serve/site-ui/docs/secure/read-a-denial/index.html +1 -1
- package/dist/serve/site-ui/docs/secure/rtdb-rules-in-typescript/index.html +1 -1
- package/dist/serve/site-ui/docs/secure/rules-standard-library/index.html +1 -1
- package/dist/serve/site-ui/docs/secure/secure-it-with-rules/index.html +1 -1
- package/dist/serve/site-ui/docs/secure/simulate-and-lint/index.html +1 -1
- package/dist/serve/site-ui/docs/secure/write-a-rules-test-suite/index.html +1 -1
- package/dist/serve/site-ui/docs/ship/ship-to-production/index.html +1 -1
- package/dist/serve/site-ui/docs/ship/test-in-node/index.html +1 -1
- package/dist/serve/site-ui/docs/storage-compat/index.html +13 -13
- package/dist/serve/site-ui/docs/storage-compat.md +12 -12
- package/dist/serve/site-ui/docs/trust/how-we-know-it-matches-firebase/index.html +1 -1
- package/dist/serve/site-ui/docs/trust/rules-standard-library/index.html +1 -1
- package/dist/serve/site-ui/docs/trust/versioning-and-compatibility/index.html +1 -1
- package/dist/serve/site-ui/docs/tutorial/index.html +1 -1
- package/dist/serve/site-ui/examples/chess/index.html +1 -1
- package/dist/serve/site-ui/firestore/index.html +1 -1
- package/dist/serve/site-ui/llms.txt +13 -0
- package/dist/serve/site-ui/rtdb/index.html +1 -1
- package/dist/serve/site-ui/settings/index.html +1 -1
- package/dist/serve/site-ui/storage/index.html +1 -1
- package/dist/serve/site-ui/studio/index.html +1 -1
- package/dist/serve/site-ui/traffic/index.html +1 -1
- package/dist/serve/studio/disk-workspace.d.ts.map +1 -1
- package/dist/serve/studio/disk-workspace.js +64 -2
- package/dist/serve/studio/disk-workspace.js.map +1 -1
- package/dist/serve/vite-plugin.d.ts +7 -7
- package/dist/serve/vite-plugin.js +1 -1
- package/dist/serve/vite-plugin.js.map +1 -1
- package/dist/serve/vite-sandbox-generation.d.ts.map +1 -1
- package/dist/serve/vite-sandbox-generation.js +12 -0
- package/dist/serve/vite-sandbox-generation.js.map +1 -1
- package/dist/serve/worker/client/auth.js +1 -2
- package/dist/serve/worker/client/auth.js.map +1 -1
- package/dist/serve/worker/client/core.d.ts +21 -1
- package/dist/serve/worker/client/core.d.ts.map +1 -1
- package/dist/serve/worker/client/core.js +79 -3
- package/dist/serve/worker/client/core.js.map +1 -1
- package/dist/serve/worker/client.d.ts +1 -1
- package/dist/serve/worker/client.d.ts.map +1 -1
- package/dist/serve/worker/client.js +1 -1
- package/dist/serve/worker/client.js.map +1 -1
- package/dist/serve/worker/context-resolver.d.ts +30 -0
- package/dist/serve/worker/context-resolver.d.ts.map +1 -0
- package/dist/serve/worker/context-resolver.js +44 -0
- package/dist/serve/worker/context-resolver.js.map +1 -0
- package/dist/serve/worker/entry.js +23 -19
- package/dist/serve/worker/entry.js.map +1 -1
- package/dist/serve/worker/host/core.d.ts +1 -0
- package/dist/serve/worker/host/core.d.ts.map +1 -1
- package/dist/serve/worker/host/core.js +12 -6
- package/dist/serve/worker/host/core.js.map +1 -1
- package/dist/serve/worker/host/storage.js +2 -2
- package/dist/serve/worker/host-auth.js +1 -2
- package/dist/serve/worker/host-auth.js.map +1 -1
- package/dist/serve/worker/index.d.ts +1 -1
- package/dist/serve/worker/index.d.ts.map +1 -1
- package/dist/serve/worker/index.js +2 -2
- package/dist/serve/worker/index.js.map +1 -1
- package/dist/serve/worker/port-lifecycle.d.ts +18 -0
- package/dist/serve/worker/port-lifecycle.d.ts.map +1 -0
- package/dist/serve/worker/port-lifecycle.js +28 -0
- package/dist/serve/worker/port-lifecycle.js.map +1 -0
- package/dist/serve/worker/serve-init.d.ts.map +1 -1
- package/dist/serve/worker/serve-init.js +8 -2
- package/dist/serve/worker/serve-init.js.map +1 -1
- package/dist/verify/fixture.d.ts +1 -1
- package/package.json +16 -5
- package/src/assurance/.generated/conformance-verdicts.ts +238 -1
- package/src/bridge/client/dispatch.ts +52 -56
- package/src/bridge/client/tool-family-factories.ts +34 -0
- package/src/bridge/server/mcp-contract.ts +15 -59
- package/src/bridge/server/peer.ts +24 -1
- package/src/bridge/server/tool-family-factories.ts +40 -0
- package/src/bridge/server/tool-metadata.ts +29 -61
- package/src/bridge/tool-families.generated.ts +17 -0
- package/src/bridge/tool-families.ts +87 -0
- package/src/bridge/tool-family-records/conformance.ts +6 -0
- package/src/bridge/tool-family-records/firestore-data.ts +15 -0
- package/src/bridge/tool-family-records/firestore-inspect.ts +6 -0
- package/src/bridge/tool-family-records/firestore-rules.ts +15 -0
- package/src/bridge/tool-family-records/firestore-simulator.ts +16 -0
- package/src/bridge/tool-family-records/rtdb-inspection.ts +6 -0
- package/src/bundler/externals.ts +55 -0
- package/src/bundler/index.ts +21 -0
- package/src/cli/cli.test.ts +0 -44
- package/src/cli/inlined-sdk-scanner.ts +77 -0
- package/src/cli/sandbox-interlock.ts +167 -0
- package/src/cli/sandbox-runner.ts +37 -26
- package/src/cli/serve.ts +68 -69
- package/src/cli/unsupported-runtime.ts +68 -0
- package/src/conformance/.generated/can-i-use-browser.ts +2 -2
- package/src/conformance/.generated/can-i-use.ts +2 -2
- package/src/conformance/.generated/conformance-docs.ts +1 -1
- package/src/functions-rtdb/child.ts +115 -21
- package/src/functions-rtdb/development-runtime.ts +4 -0
- package/src/google-endpoints.ts +155 -0
- package/src/next/runtime-env.ts +5 -0
- package/src/next/with-pyric.ts +1 -1
- package/src/register/beacon.ts +232 -0
- package/src/register/index.ts +68 -6
- package/src/register/net-guard.ts +567 -0
- package/src/serve/ai-diagnostics-relay.ts +243 -0
- package/src/serve/ai-proxy.ts +327 -0
- package/src/serve/ai-status.ts +109 -0
- package/src/serve/ai-terminal-blocks.ts +210 -0
- package/src/serve/ai-terminal-text.ts +52 -0
- package/src/serve/beacon-route.ts +141 -0
- package/src/serve/entries/active-auth-registry.ts +56 -0
- package/src/serve/entries/active-auth.ts +100 -0
- package/src/serve/entries/auth-helper-core.ts +5 -0
- package/src/serve/entries/auth-helper-dom.ts +26 -2
- package/src/serve/entries/auth.ts +8 -0
- package/src/serve/entries/bridge-url.ts +1 -1
- package/src/serve/entries/init.ts +78 -3
- package/src/serve/entries/runtime.ts +10 -0
- package/src/serve/namespace.ts +73 -140
- package/src/serve/runtime/chip-config.ts +16 -2
- package/src/serve/runtime/chip-dialog.ts +366 -0
- package/src/serve/runtime/chip-install.ts +10 -4
- package/src/serve/runtime/chip-user-search.ts +391 -0
- package/src/serve/runtime/chip.ts +140 -15
- package/src/serve/runtime/identity.ts +26 -0
- package/src/serve/sandbox-session.ts +9 -0
- package/src/serve/studio/disk-workspace.ts +76 -2
- package/src/serve/vite-plugin.ts +8 -8
- package/src/serve/vite-sandbox-generation.ts +15 -0
- package/src/serve/worker/client/auth.ts +1 -1
- package/src/serve/worker/client/core.ts +80 -3
- package/src/serve/worker/client.ts +1 -1
- package/src/serve/worker/context-resolver.ts +60 -0
- package/src/serve/worker/entry.ts +22 -18
- package/src/serve/worker/host/core.ts +9 -7
- package/src/serve/worker/host/storage.ts +2 -2
- package/src/serve/worker/host-auth.ts +1 -1
- package/src/serve/worker/index.ts +4 -1
- package/src/serve/worker/port-lifecycle.ts +45 -0
- package/src/serve/worker/serve-init.ts +9 -2
- package/src/verify/fixture.ts +1 -1
- package/dist/serve/site-ui/_astro/app.B52xr-DK.js +0 -1
- package/dist/serve/site-ui/_astro/app.DWBraPUw.js +0 -12
- package/dist/serve/site-ui/_astro/sandbox-controls.DEpnKg-O.js +0 -1169
- package/dist/serve/site-ui/_astro/writes.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AC;QACvC,IAAI,OAAO,KAAK,IAAI;YAAE,OAAO;QAC7B,IAAI,CAAC;YACH,KAAK,OAAO,CAAC,kBAAkB,EAAE;gBAC/B,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;aAC9B,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;gBACZ,qEAAqE;YACvE,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACP,sEAAsE;QACxE,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/__pyric/ai-proxy`: the same-origin passthrough to an OpenAI-compatible
|
|
3
|
+
* upstream, plus the terminal diagnostics that make an upstream failure
|
|
4
|
+
* visible to a developer with no browser console open.
|
|
5
|
+
*
|
|
6
|
+
* The route is always mounted; it only touches the network when a request
|
|
7
|
+
* arrives. Everything about WHERE it forwards is resolved by
|
|
8
|
+
* {@link resolveAiProxyUpstream}, which the startup banner (`ai-status.ts`)
|
|
9
|
+
* shares so the two can never disagree.
|
|
10
|
+
*/
|
|
11
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
12
|
+
import type { ServeLogger } from './server.js';
|
|
13
|
+
/** The dev server's diagnostics throttle, as this module needs it: the
|
|
14
|
+
* denials route owns the instance, and the proxy shares it so a failing
|
|
15
|
+
* upstream cannot out-shout a denied listener. */
|
|
16
|
+
export interface AiDiagnosticThrottle {
|
|
17
|
+
shouldPrint(key: string, now: number): boolean;
|
|
18
|
+
}
|
|
19
|
+
/** Default upstream: local Ollama's OpenAI-compatible endpoint. */
|
|
20
|
+
export declare const AI_PROXY_DEFAULT_UPSTREAM = "http://localhost:11434/v1";
|
|
21
|
+
/** The route the dev server mounts for OpenAI-compatible traffic. */
|
|
22
|
+
export declare const AI_PROXY_ROUTE = "/__pyric/ai-proxy";
|
|
23
|
+
/** The upstream-failure shapes the proxy surfaces to the terminal. */
|
|
24
|
+
type AiProxyFailure = {
|
|
25
|
+
kind: 'unreachable';
|
|
26
|
+
target: string;
|
|
27
|
+
latencyMs: number;
|
|
28
|
+
cause: string;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'status';
|
|
31
|
+
target: string;
|
|
32
|
+
latencyMs: number;
|
|
33
|
+
status: number;
|
|
34
|
+
/** The upstream's raw `Retry-After` header, when it sent one. */
|
|
35
|
+
retryAfter?: string;
|
|
36
|
+
} | {
|
|
37
|
+
kind: 'stream-abort';
|
|
38
|
+
target: string;
|
|
39
|
+
latencyMs: number;
|
|
40
|
+
cause: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Format an upstream failure into the compact terminal block, the same
|
|
44
|
+
* ` [pyric] ...` idiom the denial relay prints, so ai-proxy trouble reads
|
|
45
|
+
* like every other dev-server diagnostic. Two lines: what went wrong, then
|
|
46
|
+
* the (redacted) upstream URL with the elapsed time. Exported for unit tests.
|
|
47
|
+
*
|
|
48
|
+
* A 429 says so in words (`rate limited`): the bare number reads as one more
|
|
49
|
+
* failed request, when it actually means the upstream is shedding load or the
|
|
50
|
+
* key is out of quota. When the upstream sent a `Retry-After`, a third line
|
|
51
|
+
* prints the wait it asked for, and states that NOTHING here waits on the
|
|
52
|
+
* developer's behalf. The proxy has no retry loop (the status rides straight
|
|
53
|
+
* through to the caller), so the backoff is the app's decision, not pyric's.
|
|
54
|
+
*/
|
|
55
|
+
export declare function formatAiProxyWarning(failure: AiProxyFailure): string;
|
|
56
|
+
/**
|
|
57
|
+
* Resolve the upstream `/__pyric/ai-proxy` forwards to, and say WHERE that
|
|
58
|
+
* value came from. One resolution shared by the proxy handler (which needs
|
|
59
|
+
* the target) and the startup line (which needs the provenance, so a
|
|
60
|
+
* developer can tell a deliberate `PYRIC_AI_PROXY_UPSTREAM` from the Ollama
|
|
61
|
+
* default nobody chose).
|
|
62
|
+
*/
|
|
63
|
+
export declare function resolveAiProxyUpstream(configured: string | undefined): {
|
|
64
|
+
target: string;
|
|
65
|
+
source: 'option' | 'env' | 'default';
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Handle `POST /__pyric/ai-proxy/<suffix>`: a same-origin passthrough to the
|
|
69
|
+
* configured OpenAI-compatible upstream, so the browser openai engine
|
|
70
|
+
* (running in the served page or the SharedWorker host) reaches a localhost
|
|
71
|
+
* upstream like Ollama with ZERO CORS setup (no `OLLAMA_ORIGINS`, ever).
|
|
72
|
+
*
|
|
73
|
+
* Behavior:
|
|
74
|
+
* - POST only (the OpenAI chat-completions surface is POST); 405 otherwise.
|
|
75
|
+
* - the path suffix + query ride through verbatim
|
|
76
|
+
* (`/__pyric/ai-proxy/chat/completions` becomes `<upstream>/chat/completions`).
|
|
77
|
+
* - the request body is forwarded verbatim; headers minus the
|
|
78
|
+
* origin-sensitive/hop-by-hop set above (`authorization` DOES forward,
|
|
79
|
+
* since upstreams may require a key).
|
|
80
|
+
* - the response body is STREAMED through chunk-by-chunk. SSE passthrough
|
|
81
|
+
* must never buffer, or `stream: true` completions would arrive all at
|
|
82
|
+
* once at the end.
|
|
83
|
+
* - an unreachable upstream answers 502 with a plain-text explanation.
|
|
84
|
+
* - every upstream failure (unreachable/timeout, non-2xx status, mid-stream
|
|
85
|
+
* abort) ALSO prints a structured warning on the dev server's terminal
|
|
86
|
+
* logger; a stopped Ollama used to fail in total silence. Diagnostics
|
|
87
|
+
* only: nothing here changes what the caller receives. No logger wired
|
|
88
|
+
* means dropped silently (same opt-out contract as the denial relay).
|
|
89
|
+
*/
|
|
90
|
+
export declare function handleAiProxy(configuredUpstream: string | undefined, throttle: AiDiagnosticThrottle, req: IncomingMessage, res: ServerResponse, url: URL, logger?: ServeLogger): Promise<void>;
|
|
91
|
+
export {};
|
|
92
|
+
//# sourceMappingURL=ai-proxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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sBG;AACH,wBAAsB,aAAa,CACjC,kBAAkB,EAAE,MAAM,GAAG,SAAS,EACtC,QAAQ,EAAE,oBAAoB,EAC9B,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,GAAG,EACR,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC,CAiHf"}
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { redactUrl } from 'pyric/ai/internal';
|
|
2
|
+
import { sanitizeForTerminal } from './ai-terminal-text.js';
|
|
3
|
+
/** Default upstream: local Ollama's OpenAI-compatible endpoint. */
|
|
4
|
+
export const AI_PROXY_DEFAULT_UPSTREAM = 'http://localhost:11434/v1';
|
|
5
|
+
/** The route the dev server mounts for OpenAI-compatible traffic. */
|
|
6
|
+
export const AI_PROXY_ROUTE = '/__pyric/ai-proxy';
|
|
7
|
+
/**
|
|
8
|
+
* Request headers that must NOT be forwarded upstream: origin-sensitive
|
|
9
|
+
* browser context (`origin`/`referer`/`cookie`, since the upstream is a
|
|
10
|
+
* different origin and must never see the page's), hop-by-hop headers, and
|
|
11
|
+
* the two the proxy re-derives (`host`, `content-length`). `accept-encoding`
|
|
12
|
+
* is dropped so fetch negotiates its own compression and the streamed body
|
|
13
|
+
* needs no length fixups.
|
|
14
|
+
*/
|
|
15
|
+
const AI_PROXY_STRIPPED_HEADERS = new Set([
|
|
16
|
+
'host',
|
|
17
|
+
'origin',
|
|
18
|
+
'referer',
|
|
19
|
+
'cookie',
|
|
20
|
+
'connection',
|
|
21
|
+
'content-length',
|
|
22
|
+
'accept-encoding',
|
|
23
|
+
'keep-alive',
|
|
24
|
+
'proxy-authorization',
|
|
25
|
+
'te',
|
|
26
|
+
'trailer',
|
|
27
|
+
'transfer-encoding',
|
|
28
|
+
'upgrade',
|
|
29
|
+
]);
|
|
30
|
+
/** Longest `Retry-After` value echoed to the terminal (delta-seconds and
|
|
31
|
+
* HTTP-dates are both far shorter; anything longer is upstream noise). */
|
|
32
|
+
const AI_PROXY_RETRY_AFTER_MAX = 64;
|
|
33
|
+
/**
|
|
34
|
+
* Render a `Retry-After` value for the terminal, or `null` when there is
|
|
35
|
+
* nothing worth printing.
|
|
36
|
+
*
|
|
37
|
+
* The header is remote-authored, so it is sanitized and length-capped like
|
|
38
|
+
* every other upstream string that reaches the terminal. Delta-seconds (the
|
|
39
|
+
* common form) get an `s` suffix so the wait reads as a duration; the
|
|
40
|
+
* HTTP-date form is echoed verbatim, since `Wed, 21 Oct 2026 07:28:00 GMTs`
|
|
41
|
+
* would be nonsense.
|
|
42
|
+
*/
|
|
43
|
+
function formatRetryAfter(raw) {
|
|
44
|
+
const clean = sanitizeForTerminal(raw).slice(0, AI_PROXY_RETRY_AFTER_MAX).trim();
|
|
45
|
+
if (clean === '')
|
|
46
|
+
return null;
|
|
47
|
+
if (/^\d+$/.test(clean))
|
|
48
|
+
return `${clean}s`;
|
|
49
|
+
return clean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Mask credentials, then flatten and cap, in that order. Both the target and
|
|
53
|
+
* a raw fetch error message are remote-influenced: the URL carries whatever
|
|
54
|
+
* the page put in the query string, and an error message can quote it back.
|
|
55
|
+
*/
|
|
56
|
+
function safeUpstreamText(text) {
|
|
57
|
+
return sanitizeForTerminal(redactUrl(text));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The throttle key for one upstream failure. A failing upstream fails on
|
|
61
|
+
* every request, so the key is the failure itself (kind, status, and the
|
|
62
|
+
* redacted target) rather than anything per-request: one line per window,
|
|
63
|
+
* exactly like a denied listener that re-fires.
|
|
64
|
+
*/
|
|
65
|
+
function aiProxyThrottleKey(failure) {
|
|
66
|
+
const target = redactUrl(failure.target);
|
|
67
|
+
if (failure.kind === 'status')
|
|
68
|
+
return `ai-proxy status ${failure.status} ${target}`;
|
|
69
|
+
return `ai-proxy ${failure.kind} ${target}`;
|
|
70
|
+
}
|
|
71
|
+
/** Print one upstream failure, unless the throttle already printed it. */
|
|
72
|
+
function noteAiProxyFailure(failure, throttle, logger) {
|
|
73
|
+
if (logger === undefined)
|
|
74
|
+
return;
|
|
75
|
+
if (!throttle.shouldPrint(aiProxyThrottleKey(failure), Date.now()))
|
|
76
|
+
return;
|
|
77
|
+
logger.note(formatAiProxyWarning(failure));
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Format an upstream failure into the compact terminal block, the same
|
|
81
|
+
* ` [pyric] ...` idiom the denial relay prints, so ai-proxy trouble reads
|
|
82
|
+
* like every other dev-server diagnostic. Two lines: what went wrong, then
|
|
83
|
+
* the (redacted) upstream URL with the elapsed time. Exported for unit tests.
|
|
84
|
+
*
|
|
85
|
+
* A 429 says so in words (`rate limited`): the bare number reads as one more
|
|
86
|
+
* failed request, when it actually means the upstream is shedding load or the
|
|
87
|
+
* key is out of quota. When the upstream sent a `Retry-After`, a third line
|
|
88
|
+
* prints the wait it asked for, and states that NOTHING here waits on the
|
|
89
|
+
* developer's behalf. The proxy has no retry loop (the status rides straight
|
|
90
|
+
* through to the caller), so the backoff is the app's decision, not pyric's.
|
|
91
|
+
*/
|
|
92
|
+
export function formatAiProxyWarning(failure) {
|
|
93
|
+
const target = safeUpstreamText(failure.target);
|
|
94
|
+
let headline;
|
|
95
|
+
if (failure.kind === 'unreachable') {
|
|
96
|
+
headline = `upstream unreachable: ${safeUpstreamText(failure.cause)}`;
|
|
97
|
+
}
|
|
98
|
+
else if (failure.kind === 'status') {
|
|
99
|
+
const rateLimited = failure.status === 429;
|
|
100
|
+
headline = `upstream returned ${failure.status}${rateLimited ? ' (rate limited / quota exhausted)' : ''}`;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
headline = `upstream stream aborted mid-response: ${safeUpstreamText(failure.cause)}`;
|
|
104
|
+
}
|
|
105
|
+
const lines = [
|
|
106
|
+
` ⚠ [pyric] ai-proxy: ${headline}`,
|
|
107
|
+
` POST ${target} (${failure.latencyMs}ms)`,
|
|
108
|
+
];
|
|
109
|
+
if (failure.kind === 'unreachable') {
|
|
110
|
+
lines.push(` set PYRIC_AI_PROXY_UPSTREAM to an OpenAI-compatible base URL (default ${AI_PROXY_DEFAULT_UPSTREAM})`);
|
|
111
|
+
}
|
|
112
|
+
if (failure.kind === 'status' && failure.retryAfter !== undefined) {
|
|
113
|
+
const wait = formatRetryAfter(failure.retryAfter);
|
|
114
|
+
if (wait !== null) {
|
|
115
|
+
lines.push(` Retry-After: ${wait}, no automatic retry; the status went to the caller`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return lines.join('\n');
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Resolve the upstream `/__pyric/ai-proxy` forwards to, and say WHERE that
|
|
122
|
+
* value came from. One resolution shared by the proxy handler (which needs
|
|
123
|
+
* the target) and the startup line (which needs the provenance, so a
|
|
124
|
+
* developer can tell a deliberate `PYRIC_AI_PROXY_UPSTREAM` from the Ollama
|
|
125
|
+
* default nobody chose).
|
|
126
|
+
*/
|
|
127
|
+
export function resolveAiProxyUpstream(configured) {
|
|
128
|
+
const envUpstream = process.env.PYRIC_AI_PROXY_UPSTREAM;
|
|
129
|
+
let raw = AI_PROXY_DEFAULT_UPSTREAM;
|
|
130
|
+
let source = 'default';
|
|
131
|
+
if (configured !== undefined) {
|
|
132
|
+
raw = configured;
|
|
133
|
+
source = 'option';
|
|
134
|
+
}
|
|
135
|
+
else if (envUpstream !== undefined) {
|
|
136
|
+
raw = envUpstream;
|
|
137
|
+
source = 'env';
|
|
138
|
+
}
|
|
139
|
+
return { target: raw.replace(/\/$/, ''), source };
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Handle `POST /__pyric/ai-proxy/<suffix>`: a same-origin passthrough to the
|
|
143
|
+
* configured OpenAI-compatible upstream, so the browser openai engine
|
|
144
|
+
* (running in the served page or the SharedWorker host) reaches a localhost
|
|
145
|
+
* upstream like Ollama with ZERO CORS setup (no `OLLAMA_ORIGINS`, ever).
|
|
146
|
+
*
|
|
147
|
+
* Behavior:
|
|
148
|
+
* - POST only (the OpenAI chat-completions surface is POST); 405 otherwise.
|
|
149
|
+
* - the path suffix + query ride through verbatim
|
|
150
|
+
* (`/__pyric/ai-proxy/chat/completions` becomes `<upstream>/chat/completions`).
|
|
151
|
+
* - the request body is forwarded verbatim; headers minus the
|
|
152
|
+
* origin-sensitive/hop-by-hop set above (`authorization` DOES forward,
|
|
153
|
+
* since upstreams may require a key).
|
|
154
|
+
* - the response body is STREAMED through chunk-by-chunk. SSE passthrough
|
|
155
|
+
* must never buffer, or `stream: true` completions would arrive all at
|
|
156
|
+
* once at the end.
|
|
157
|
+
* - an unreachable upstream answers 502 with a plain-text explanation.
|
|
158
|
+
* - every upstream failure (unreachable/timeout, non-2xx status, mid-stream
|
|
159
|
+
* abort) ALSO prints a structured warning on the dev server's terminal
|
|
160
|
+
* logger; a stopped Ollama used to fail in total silence. Diagnostics
|
|
161
|
+
* only: nothing here changes what the caller receives. No logger wired
|
|
162
|
+
* means dropped silently (same opt-out contract as the denial relay).
|
|
163
|
+
*/
|
|
164
|
+
export async function handleAiProxy(configuredUpstream, throttle, req, res, url, logger) {
|
|
165
|
+
if (req.method !== 'POST') {
|
|
166
|
+
res.writeHead(405, { allow: 'POST' }).end('method not allowed');
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const upstreamBase = resolveAiProxyUpstream(configuredUpstream).target;
|
|
170
|
+
const suffix = url.pathname.slice(AI_PROXY_ROUTE.length);
|
|
171
|
+
const target = `${upstreamBase}${suffix}${url.search}`;
|
|
172
|
+
// Buffer the REQUEST body (small JSON payloads); the RESPONSE streams.
|
|
173
|
+
const raw = await new Promise((resolve, reject) => {
|
|
174
|
+
const chunks = [];
|
|
175
|
+
req.on('data', (c) => chunks.push(c));
|
|
176
|
+
req.on('end', () => resolve(Buffer.concat(chunks)));
|
|
177
|
+
req.on('error', reject);
|
|
178
|
+
});
|
|
179
|
+
// Copy into a plain-ArrayBuffer view; fetch's BodyInit typing rejects
|
|
180
|
+
// Buffer's ArrayBufferLike backing.
|
|
181
|
+
const body = new Uint8Array(raw.byteLength);
|
|
182
|
+
body.set(raw);
|
|
183
|
+
const headers = {};
|
|
184
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
185
|
+
if (value === undefined)
|
|
186
|
+
continue;
|
|
187
|
+
if (AI_PROXY_STRIPPED_HEADERS.has(key.toLowerCase()))
|
|
188
|
+
continue;
|
|
189
|
+
headers[key] = Array.isArray(value) ? value.join(', ') : value;
|
|
190
|
+
}
|
|
191
|
+
const startedAt = Date.now();
|
|
192
|
+
let upstream;
|
|
193
|
+
try {
|
|
194
|
+
upstream = await fetch(target, { method: 'POST', headers, body });
|
|
195
|
+
}
|
|
196
|
+
catch (e) {
|
|
197
|
+
const cause = e instanceof Error ? e.message : String(e);
|
|
198
|
+
noteAiProxyFailure({ kind: 'unreachable', target, latencyMs: Date.now() - startedAt, cause }, throttle, logger);
|
|
199
|
+
// The 502 body quotes the same two strings the terminal block does, so it
|
|
200
|
+
// gets the same masking: the target carries the page's own query string,
|
|
201
|
+
// and a fetch error routinely echoes the URL back.
|
|
202
|
+
res.writeHead(502, { 'content-type': 'text/plain' });
|
|
203
|
+
res.end(`pyric dev ai-proxy: upstream ${redactUrl(target)} unreachable: ${redactUrl(cause)}\n` +
|
|
204
|
+
'Set PYRIC_AI_PROXY_UPSTREAM to an OpenAI-compatible base URL ' +
|
|
205
|
+
`(default ${AI_PROXY_DEFAULT_UPSTREAM}).`);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
// A refusal from a reachable upstream (bad model, missing key, rate limit)
|
|
209
|
+
// is just as invisible to a headless developer as a dead socket: the
|
|
210
|
+
// status rides through to the caller untouched, and is ALSO announced here.
|
|
211
|
+
// `Retry-After` rides along when the upstream sent one (429s and 503s carry
|
|
212
|
+
// it): it is the only place the requested backoff appears, since nothing in
|
|
213
|
+
// this path retries or sleeps.
|
|
214
|
+
if (!upstream.ok) {
|
|
215
|
+
const retryAfter = upstream.headers.get('retry-after');
|
|
216
|
+
const failure = {
|
|
217
|
+
kind: 'status',
|
|
218
|
+
target,
|
|
219
|
+
latencyMs: Date.now() - startedAt,
|
|
220
|
+
status: upstream.status,
|
|
221
|
+
};
|
|
222
|
+
if (retryAfter !== null)
|
|
223
|
+
failure.retryAfter = retryAfter;
|
|
224
|
+
noteAiProxyFailure(failure, throttle, logger);
|
|
225
|
+
}
|
|
226
|
+
const responseHeaders = { 'cache-control': 'no-store' };
|
|
227
|
+
const contentType = upstream.headers.get('content-type');
|
|
228
|
+
if (contentType)
|
|
229
|
+
responseHeaders['content-type'] = contentType;
|
|
230
|
+
res.writeHead(upstream.status, responseHeaders);
|
|
231
|
+
if (!upstream.body) {
|
|
232
|
+
res.end();
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
res.flushHeaders?.();
|
|
236
|
+
// Chunk-by-chunk passthrough. A dropped client cancels the upstream read
|
|
237
|
+
// so an abandoned SSE stream doesn't keep the upstream generating.
|
|
238
|
+
const reader = upstream.body.getReader();
|
|
239
|
+
let clientGone = false;
|
|
240
|
+
res.on('close', () => {
|
|
241
|
+
clientGone = true;
|
|
242
|
+
void reader.cancel().catch(() => { });
|
|
243
|
+
});
|
|
244
|
+
try {
|
|
245
|
+
for (;;) {
|
|
246
|
+
const { done, value } = await reader.read();
|
|
247
|
+
if (done)
|
|
248
|
+
break;
|
|
249
|
+
res.write(value);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
catch (e) {
|
|
253
|
+
// Nothing to salvage for the caller: the response is already committed
|
|
254
|
+
// with the upstream's status, so a truncated body is all it gets. But a
|
|
255
|
+
// half-delivered completion is exactly the failure that used to vanish,
|
|
256
|
+
// so announce it, unless the CLIENT is the one who walked away (a closed
|
|
257
|
+
// tab cancelling an SSE stream is normal, not a fault worth a warning).
|
|
258
|
+
if (!clientGone) {
|
|
259
|
+
noteAiProxyFailure({
|
|
260
|
+
kind: 'stream-abort',
|
|
261
|
+
target,
|
|
262
|
+
latencyMs: Date.now() - startedAt,
|
|
263
|
+
cause: e instanceof Error ? e.message : String(e),
|
|
264
|
+
}, throttle, logger);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
res.end();
|
|
268
|
+
}
|
|
269
|
+
//# sourceMappingURL=ai-proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-proxy.js","sourceRoot":"","sources":["../../src/serve/ai-proxy.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAS5D,mEAAmE;AACnE,MAAM,CAAC,MAAM,yBAAyB,GAAG,2BAA2B,CAAC;AAErE,qEAAqE;AACrE,MAAM,CAAC,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAC;IACxC,MAAM;IACN,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,YAAY;IACZ,gBAAgB;IAChB,iBAAiB;IACjB,YAAY;IACZ,qBAAqB;IACrB,IAAI;IACJ,SAAS;IACT,mBAAmB;IACnB,SAAS;CACV,CAAC,CAAC;AAeH;2EAC2E;AAC3E,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAEpC;;;;;;;;;GASG;AACH,SAAS,gBAAgB,CAAC,GAAW;IACnC,MAAM,KAAK,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,wBAAwB,CAAC,CAAC,IAAI,EAAE,CAAC;IACjF,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IAC9B,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,GAAG,KAAK,GAAG,CAAC;IAC5C,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,SAAS,gB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AU,GAAG,IAAI,CAAC;QAClB,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IACH,IAAI,CAAC;QACH,SAAS,CAAC;YACR,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YAC5C,IAAI,IAAI;gBAAE,MAAM;YAChB,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACnB,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,uEAAuE;QACvE,wEAAwE;QACxE,wEAAwE;QACxE,yEAAyE;QACzE,wEAAwE;QACxE,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,kBAAkB,CAChB;gBACE,IAAI,EAAE,cAAc;gBACpB,MAAM;gBACN,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;gBACjC,KAAK,EAAE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;aAClD,EACD,QAAQ,EACR,MAAM,CACP,CAAC;QACJ,CAAC;IACH,CAAC;IACD,GAAG,CAAC,GAAG,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The AI line in the dev server's startup banner.
|
|
3
|
+
*
|
|
4
|
+
* AI is the only live service that used to boot silently: hosting, sandbox
|
|
5
|
+
* bundles, rules, Studio, the bridge and persistence all announce themselves,
|
|
6
|
+
* so "nothing about AI" read as "AI isn't part of this server" rather than
|
|
7
|
+
* "AI is here, unconfigured". One description ({@link describeAiStatus}),
|
|
8
|
+
* rendered in the two dev-server flavors, so the `pyric dev` banner and the
|
|
9
|
+
* Vite plugin can never disagree about what AI resolved to.
|
|
10
|
+
*/
|
|
11
|
+
import type { AiEngineConfigWire } from './worker/protocol.js';
|
|
12
|
+
/**
|
|
13
|
+
* What the dev server itself knows about AI by the time it finishes booting.
|
|
14
|
+
*
|
|
15
|
+
* Everything here is resolved SYNCHRONOUSLY at bootstrap: the plugin's
|
|
16
|
+
* `ai.engine`/`ai.model` (already reduced to the worker wire shape) and the
|
|
17
|
+
* proxy upstream. Nothing in this shape forces a broker, a page, or an
|
|
18
|
+
* upstream connection into existence just to be reported. The engine is
|
|
19
|
+
* instantiated lazily, on the first `ai.*` op, in the page or the worker.
|
|
20
|
+
*/
|
|
21
|
+
export interface AiStartupStatus {
|
|
22
|
+
/** Engine resolved by the dev server (the Vite plugin's `ai.engine` /
|
|
23
|
+
* `ai.model`). Absent means nothing server-side: the served page's own
|
|
24
|
+
* `getAI(...)` chooses the engine at runtime, and the server cannot know
|
|
25
|
+
* which (there is no CLI surface for it under `pyric dev`). */
|
|
26
|
+
engine?: AiEngineConfigWire;
|
|
27
|
+
/** `ai.mode`: `production` passes through to Google AI instead of mirroring. */
|
|
28
|
+
mode?: 'sandbox' | 'production';
|
|
29
|
+
/** Configured OpenAI-compatible upstream (`ai.proxyUpstream`). Absent falls
|
|
30
|
+
* back to `PYRIC_AI_PROXY_UPSTREAM`, then the local-Ollama default. */
|
|
31
|
+
proxyUpstream?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The banner line for `pyric dev`'s aligned status column (`✔ hosting ...`).
|
|
35
|
+
* Exported for unit tests.
|
|
36
|
+
*/
|
|
37
|
+
export declare function formatAiStatusLine(status: AiStartupStatus): string;
|
|
38
|
+
/**
|
|
39
|
+
* The same report in the Vite dev server's flavor (` ✔ [pyric] ...`, the
|
|
40
|
+
* idiom `vite-functions-development.ts` prints). Same content, so the two
|
|
41
|
+
* dev-server front doors never disagree about what AI resolved to.
|
|
42
|
+
*/
|
|
43
|
+
export declare function formatAiStatusNote(status: AiStartupStatus): string;
|
|
44
|
+
//# sourceMappingURL=ai-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-status.d.ts","sourceRoot":"","sources":["../../src/serve/ai-status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAK/D;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAC9B;;;oEAGgE;IAChE,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,gFAAgF;IAChF,IAAI,CAAC,EAAE,SAAS,GAAG,YAAY,CAAC;IAChC;4EACwE;IACxE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAwDD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAGlE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAGlE"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { GEMINI_DEFAULT_BASE_URL, redactUrl } from 'pyric/ai/internal';
|
|
2
|
+
import { AI_PROXY_ROUTE, resolveAiProxyUpstream } from './ai-proxy.js';
|
|
3
|
+
import { sanitizeForTerminal } from './ai-terminal-text.js';
|
|
4
|
+
/** Where the resolved proxy upstream came from, in the terminal's words. The
|
|
5
|
+
* provenance is the point of the line: a developer has to be able to tell a
|
|
6
|
+
* deliberate upstream from the Ollama default nobody chose, so every source
|
|
7
|
+
* names the knob that set it. */
|
|
8
|
+
function describeUpstreamProvenance(source) {
|
|
9
|
+
if (source === 'option')
|
|
10
|
+
return ' (ai.proxyUpstream)';
|
|
11
|
+
if (source === 'env')
|
|
12
|
+
return ' (PYRIC_AI_PROXY_UPSTREAM)';
|
|
13
|
+
return ' (default)';
|
|
14
|
+
}
|
|
15
|
+
/** The openai engine's model binding, which may not be pinned at all. */
|
|
16
|
+
function describeOpenAiModel(model) {
|
|
17
|
+
if (model === undefined)
|
|
18
|
+
return 'no model pinned';
|
|
19
|
+
return `model ${sanitizeForTerminal(model)}`;
|
|
20
|
+
}
|
|
21
|
+
/** Mark + body for one AI status line, in both terminal flavors. */
|
|
22
|
+
function describeAiStatus(status) {
|
|
23
|
+
const upstream = resolveAiProxyUpstream(status.proxyUpstream);
|
|
24
|
+
const provenance = describeUpstreamProvenance(upstream.source);
|
|
25
|
+
const proxyChain = `${AI_PROXY_ROUTE} → ${redactUrl(upstream.target)}${provenance}`;
|
|
26
|
+
const engine = status.engine;
|
|
27
|
+
if (engine === undefined) {
|
|
28
|
+
// Visible absence, the `• rules no firestore.rules ...` idiom: AI
|
|
29
|
+
// silence used to be indistinguishable from AI-not-wired-up.
|
|
30
|
+
return {
|
|
31
|
+
mark: '•',
|
|
32
|
+
body: `no engine configured; the served page's getAI() picks one; ${proxyChain}`,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
if (engine.kind === 'openai') {
|
|
36
|
+
const model = describeOpenAiModel(engine.model);
|
|
37
|
+
const baseUrl = engine.baseUrl ?? AI_PROXY_ROUTE;
|
|
38
|
+
let endpoint = proxyChain;
|
|
39
|
+
if (baseUrl !== AI_PROXY_ROUTE) {
|
|
40
|
+
endpoint = `${redactUrl(baseUrl)} (direct, bypasses ${AI_PROXY_ROUTE})`;
|
|
41
|
+
}
|
|
42
|
+
return { mark: '✔', body: `openai (${model}) → ${endpoint}` };
|
|
43
|
+
}
|
|
44
|
+
if (engine.kind === 'gemini') {
|
|
45
|
+
let passthrough = '';
|
|
46
|
+
if (status.mode === 'production')
|
|
47
|
+
passthrough = 'production passthrough, ';
|
|
48
|
+
const hasKey = engine.apiKey !== undefined && engine.apiKey !== '';
|
|
49
|
+
let key = 'no API key; set GEMINI_API_KEY';
|
|
50
|
+
if (hasKey)
|
|
51
|
+
key = 'API key set';
|
|
52
|
+
let endpoint = GEMINI_DEFAULT_BASE_URL;
|
|
53
|
+
if (engine.baseUrl !== undefined)
|
|
54
|
+
endpoint = redactUrl(engine.baseUrl);
|
|
55
|
+
return { mark: '✔', body: `gemini (${passthrough}${key}) → ${endpoint}` };
|
|
56
|
+
}
|
|
57
|
+
const responses = engine.script?.length ?? 0;
|
|
58
|
+
return { mark: '✔', body: `scripted (${responses} canned response(s), no network)` };
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The banner line for `pyric dev`'s aligned status column (`✔ hosting ...`).
|
|
62
|
+
* Exported for unit tests.
|
|
63
|
+
*/
|
|
64
|
+
export function formatAiStatusLine(status) {
|
|
65
|
+
const { mark, body } = describeAiStatus(status);
|
|
66
|
+
return `${mark} ai ${body}`;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The same report in the Vite dev server's flavor (` ✔ [pyric] ...`, the
|
|
70
|
+
* idiom `vite-functions-development.ts` prints). Same content, so the two
|
|
71
|
+
* dev-server front doors never disagree about what AI resolved to.
|
|
72
|
+
*/
|
|
73
|
+
export function formatAiStatusNote(status) {
|
|
74
|
+
const { mark, body } = describeAiStatus(status);
|
|
75
|
+
return ` ${mark} [pyric] ai: ${body}`;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=ai-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-status.js","sourceRoot":"","sources":["../../src/serve/ai-status.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAwB5D;;;kCAGkC;AAClC,SAAS,0BAA0B,CAAC,MAAoC;IACtE,IAAI,MAAM,KAAK,QAAQ;QAAE,OAAO,qBAAqB,CAAC;IACtD,IAAI,MAAM,KAAK,KAAK;QAAE,OAAO,4BAA4B,CAAC;IAC1D,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,yEAAyE;AACzE,SAAS,mBAAmB,CAAC,KAAyB;IACpD,IAAI,KAAK,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AG,0BAA0B,CAAC;QAC3E,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,EAAE,CAAC;QACnE,IAAI,GAAG,GAAG,gCAAgC,CAAC;QAC3C,IAAI,MAAM;YAAE,GAAG,GAAG,aAAa,CAAC;QAChC,IAAI,QAAQ,GAAG,uBAAuB,CAAC;QACvC,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS;YAAE,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACvE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,WAAW,GAAG,GAAG,OAAO,QAAQ,EAAE,EAAE,CAAC;IAC5E,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,CAAC;IAC7C,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,aAAa,SAAS,kCAAkC,EAAE,CAAC;AACvF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAuB;IACxD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAChD,OAAO,GAAG,IAAI,aAAa,IAAI,EAAE,CAAC;AACpC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAuB;IACxD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAChD,OAAO,KAAK,IAAI,gBAAgB,IAAI,EAAE,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/** Loosely-typed mirror of the AI rejection payload POSTed by
|
|
2
|
+
* `ai-diagnostics-relay.ts` (the wire shape lives there). */
|
|
3
|
+
export interface AiRejectionPayload {
|
|
4
|
+
/** `'ai-rejection'`: what tells the route the body is NOT a rules denial. */
|
|
5
|
+
kind?: unknown;
|
|
6
|
+
/** Model resource the rejected op targeted. */
|
|
7
|
+
model?: unknown;
|
|
8
|
+
/** Resolved broker engine (`scripted` | `openai` | `gemini` | `custom`). */
|
|
9
|
+
engine?: unknown;
|
|
10
|
+
/** Wire error status (e.g. `INVALID_ARGUMENT`) and HTTP-ish code. */
|
|
11
|
+
status?: unknown;
|
|
12
|
+
code?: unknown;
|
|
13
|
+
/** The rejection reason: production's own message for shape errors. */
|
|
14
|
+
message?: unknown;
|
|
15
|
+
}
|
|
16
|
+
/** Loosely-typed mirror of the AI blocked-response payload. Unlike a
|
|
17
|
+
* rejection this carries no `message`: a filter block has no error envelope
|
|
18
|
+
* at all (HTTP 200, empty candidate), only the wire's reason enums, so the
|
|
19
|
+
* phrasing is this file's job. */
|
|
20
|
+
export interface AiBlockedPayload {
|
|
21
|
+
/** `'ai-blocked'`: what tells the route the body is a filter block. */
|
|
22
|
+
kind?: unknown;
|
|
23
|
+
/** Model resource the blocked op targeted. */
|
|
24
|
+
model?: unknown;
|
|
25
|
+
/** Resolved broker engine (`scripted` | `openai` | `gemini` | `custom`). */
|
|
26
|
+
engine?: unknown;
|
|
27
|
+
/** Candidate-level block: `SAFETY`, `RECITATION`, `BLOCKLIST`, and so on. */
|
|
28
|
+
finishReason?: unknown;
|
|
29
|
+
/** Production's own explanatory text for the block, when it sent one. */
|
|
30
|
+
finishMessage?: unknown;
|
|
31
|
+
/** Prompt-level block: `promptFeedback.blockReason`. */
|
|
32
|
+
blockReason?: unknown;
|
|
33
|
+
}
|
|
34
|
+
/** Loosely-typed mirror of the AI model-substitution payload. Not a refusal:
|
|
35
|
+
* the request SUCCEEDED, answered by a model the developer never named,
|
|
36
|
+
* which is why nothing else in the stack reports it. */
|
|
37
|
+
export interface AiModelSubstitutionPayload {
|
|
38
|
+
/** `'ai-model-substituted'`: what tells the route the body is a swap. */
|
|
39
|
+
kind?: unknown;
|
|
40
|
+
/** The model the request asked for. */
|
|
41
|
+
requestedModel?: unknown;
|
|
42
|
+
/** The model the engine actually calls. */
|
|
43
|
+
effectiveModel?: unknown;
|
|
44
|
+
/** Resolved broker engine (`openai` | `gemini` | ...). */
|
|
45
|
+
engine?: unknown;
|
|
46
|
+
/** Why it differs, e.g. `engine modelMap`, `experimental alias`. */
|
|
47
|
+
reason?: unknown;
|
|
48
|
+
}
|
|
49
|
+
/** What the route reads off a body before it knows which kind it holds. */
|
|
50
|
+
export type AiDiagnosticPayload = AiRejectionPayload & AiBlockedPayload & AiModelSubstitutionPayload;
|
|
51
|
+
/**
|
|
52
|
+
* Format a relayed AI broker rejection into the compact terminal block, the
|
|
53
|
+
* same ` [pyric] ...` idiom the denial relay and the ai-proxy warning print.
|
|
54
|
+
* Three lines at most: the reason production itself gives, then the model
|
|
55
|
+
* (with the resolved engine, since a rejection reads very differently for
|
|
56
|
+
* `scripted` than for a real upstream), then the wire status. Exported for
|
|
57
|
+
* unit tests.
|
|
58
|
+
*/
|
|
59
|
+
export declare function formatAiRejectionBlock(payload: AiRejectionPayload): string;
|
|
60
|
+
/**
|
|
61
|
+
* Format a relayed AI filter block, in the same three lines as
|
|
62
|
+
* {@link formatAiRejectionBlock}: the wire's own reason, the model + resolved
|
|
63
|
+
* engine, then WHY there is no content. That third line matters more here
|
|
64
|
+
* than for a rejection: a block throws nothing, so the only symptom a
|
|
65
|
+
* developer sees is an empty answer, and production's `finishMessage` (when
|
|
66
|
+
* it sent one) is the whole explanation. Exported for unit tests.
|
|
67
|
+
*/
|
|
68
|
+
export declare function formatAiBlockedBlock(payload: AiBlockedPayload): string;
|
|
69
|
+
/**
|
|
70
|
+
* Format a relayed AI model substitution into ONE terminal line, a single
|
|
71
|
+
* line on purpose: there is no error, no status, and no missing content to
|
|
72
|
+
* explain. The whole fact IS the arrow, and the parenthetical says which
|
|
73
|
+
* engine did it and why (`engine modelMap`, `experimental alias`, ...).
|
|
74
|
+
* Exported for unit tests.
|
|
75
|
+
*/
|
|
76
|
+
export declare function formatAiModelSubstitutionBlock(payload: AiModelSubstitutionPayload): string;
|
|
77
|
+
/**
|
|
78
|
+
* One record per AI diagnostic kind: how it prints, and the (target, reason)
|
|
79
|
+
* pair the denials route throttles it by.
|
|
80
|
+
*
|
|
81
|
+
* The prefixes on `throttleTarget` keep an AI key from colliding with a
|
|
82
|
+
* rules-denial key built from a Firestore path, or with each other: a
|
|
83
|
+
* rejection, a block, and a substitution on the same model are three
|
|
84
|
+
* different problems. `throttleReason` is each kind's identity: a block has
|
|
85
|
+
* no message of its own, so its reason enum is what collapses an agent's
|
|
86
|
+
* retry loop into one line, and a substitution's identity is the model it
|
|
87
|
+
* actually called, so a swap onto a DIFFERENT model still prints.
|
|
88
|
+
*/
|
|
89
|
+
export interface AiTerminalBlock {
|
|
90
|
+
format(payload: AiDiagnosticPayload): string;
|
|
91
|
+
throttleTarget(payload: AiDiagnosticPayload): string;
|
|
92
|
+
throttleReason(payload: AiDiagnosticPayload): string;
|
|
93
|
+
}
|
|
94
|
+
/** The record for a relayed body's `kind`, or `null` when the body is a rules
|
|
95
|
+
* denial (or anything else this route does not recognize). */
|
|
96
|
+
export declare function aiTerminalBlockFor(kind: unknown): AiTerminalBlock | null;
|
|
97
|
+
//# sourceMappingURL=ai-terminal-blocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-terminal-blocks.d.ts","sourceRoot":"","sources":["../../src/serve/ai-terminal-blocks.ts"],"names":[],"mappings":"AAkBA;8DAC8D;AAC9D,MAAM,WAAW,kBAAkB;IACjC,6EAA6E;IAC7E,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,+CAA+C;IAC/C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,qEAAqE;IACrE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,uEAAuE;IACvE,OAAO,CAAC,EAAE,OAAO,CAAC;C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