pi-webapp 0.1.7 → 0.1.8

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.
Files changed (127) hide show
  1. package/README.md +4 -0
  2. package/README.zh-CN.md +4 -0
  3. package/dist/extension.js +21 -8
  4. package/docs/sentry.md +54 -0
  5. package/package.json +17 -8
  6. package/web/dist/.vite/manifest.json +859 -0
  7. package/web/dist/assets/app-B2Ac56ic.js +544 -0
  8. package/web/dist/assets/app.js +9 -541
  9. package/web/dist/assets/asciidoc-fDuF7HNn.js +3 -0
  10. package/web/dist/assets/bat-CIKKTCO7.js +3 -0
  11. package/web/dist/assets/bibtex-D13O2Wvh.js +3 -0
  12. package/web/dist/assets/c-BxgHfdNM.js +3 -0
  13. package/web/dist/assets/clojure-CiHGeAtp.js +3 -0
  14. package/web/dist/assets/cmake-DmzJtVCe.js +3 -0
  15. package/web/dist/assets/cpp-WTsyTmWk.js +3 -0
  16. package/web/dist/assets/csharp-BusYHIEz.js +3 -0
  17. package/web/dist/assets/css-D-q0lhfR.js +3 -0
  18. package/web/dist/assets/csv-DFLln536.js +3 -0
  19. package/web/dist/assets/dart-CafiI-9_.js +3 -0
  20. package/web/dist/assets/diff-Br1ISN9_.js +3 -0
  21. package/web/dist/assets/dotenv-CIz2XDph.js +3 -0
  22. package/web/dist/assets/elixir-DRaGIFOe.js +3 -0
  23. package/web/dist/assets/erlang-NGps-vi9.js +3 -0
  24. package/web/dist/assets/fish-ByHW6pZw.js +3 -0
  25. package/web/dist/assets/fsharp-BOBx9XdV.js +3 -0
  26. package/web/dist/assets/go-BeHf35-M.js +3 -0
  27. package/web/dist/assets/graphql-DvPK7yuL.js +3 -0
  28. package/web/dist/assets/groovy-zjY2ZfG0.js +3 -0
  29. package/web/dist/assets/haskell-CMvfT32Y.js +3 -0
  30. package/web/dist/assets/hcl-RKiXyu-a.js +3 -0
  31. package/web/dist/assets/html-DsaiN7Ee.js +3 -0
  32. package/web/dist/assets/html-derivative-CADUTaWI.js +3 -0
  33. package/web/dist/assets/http-B5WHvjtS.js +3 -0
  34. package/web/dist/assets/ini-DuzuNcum.js +3 -0
  35. package/web/dist/assets/java-K8yEFi64.js +3 -0
  36. package/web/dist/assets/javascript-D_ijBMSX.js +3 -0
  37. package/web/dist/assets/julia-BCSipsbD.js +3 -0
  38. package/web/dist/assets/kotlin-BSbocnsc.js +3 -0
  39. package/web/dist/assets/latex-B2rh6wcV.js +3 -0
  40. package/web/dist/assets/less-DrDudO82.js +3 -0
  41. package/web/dist/assets/log-ljR8DmTe.js +3 -0
  42. package/web/dist/assets/lua-DyIUvKwX.js +3 -0
  43. package/web/dist/assets/make-D75dUjYA.js +3 -0
  44. package/web/dist/assets/markdown-CW047eNb.js +3 -0
  45. package/web/dist/assets/mdx-XsqTTZB4.js +3 -0
  46. package/web/dist/assets/nix-CipIrdNI.js +3 -0
  47. package/web/dist/assets/perl-D7RI67n_.js +3 -0
  48. package/web/dist/assets/php-s52DiJil.js +3 -0
  49. package/web/dist/assets/powershell-jgDnaG9I.js +3 -0
  50. package/web/dist/assets/proto-BIjSd36w.js +3 -0
  51. package/web/dist/assets/python-D7_Ztkaq.js +3 -0
  52. package/web/dist/assets/r-CJzV5ecV.js +3 -0
  53. package/web/dist/assets/rst-CN3AX0Wt.js +3 -0
  54. package/web/dist/assets/ruby-TeaxAh4o.js +3 -0
  55. package/web/dist/assets/rust-DSBpfBj6.js +3 -0
  56. package/web/dist/assets/scala-C5J7wQ_u.js +3 -0
  57. package/web/dist/assets/scss-Ce0Xtdy1.js +3 -0
  58. package/web/dist/assets/sql-B8q9hRYB.js +3 -0
  59. package/web/dist/assets/svelte-D-qO2kbs.js +3 -0
  60. package/web/dist/assets/swift-BYyWkiAC.js +3 -0
  61. package/web/dist/assets/system-verilog-DeQRavVp.js +3 -0
  62. package/web/dist/assets/telemetry-client-BUyFe34_.js +7 -0
  63. package/web/dist/assets/toml-D4Tpftfr.js +3 -0
  64. package/web/dist/assets/vb-CT8kYl35.js +3 -0
  65. package/web/dist/assets/verilog-CRrcH6Pt.js +3 -0
  66. package/web/dist/assets/vue-xQhdtb6A.js +3 -0
  67. package/web/dist/assets/xml-DCBoxqhY.js +3 -0
  68. package/web/dist/assets/yaml-jmrW97Mk.js +3 -0
  69. package/web/dist/assets/asciidoc.js +0 -1
  70. package/web/dist/assets/bat.js +0 -1
  71. package/web/dist/assets/bibtex.js +0 -1
  72. package/web/dist/assets/c.js +0 -1
  73. package/web/dist/assets/clojure.js +0 -1
  74. package/web/dist/assets/cmake.js +0 -1
  75. package/web/dist/assets/cpp.js +0 -1
  76. package/web/dist/assets/csharp.js +0 -1
  77. package/web/dist/assets/css.js +0 -1
  78. package/web/dist/assets/csv.js +0 -1
  79. package/web/dist/assets/dart.js +0 -1
  80. package/web/dist/assets/diff.js +0 -1
  81. package/web/dist/assets/dotenv.js +0 -1
  82. package/web/dist/assets/elixir.js +0 -1
  83. package/web/dist/assets/erlang.js +0 -1
  84. package/web/dist/assets/fish.js +0 -1
  85. package/web/dist/assets/fsharp.js +0 -1
  86. package/web/dist/assets/go.js +0 -1
  87. package/web/dist/assets/graphql.js +0 -1
  88. package/web/dist/assets/groovy.js +0 -1
  89. package/web/dist/assets/haskell.js +0 -1
  90. package/web/dist/assets/hcl.js +0 -1
  91. package/web/dist/assets/html-derivative.js +0 -1
  92. package/web/dist/assets/html.js +0 -1
  93. package/web/dist/assets/http.js +0 -1
  94. package/web/dist/assets/ini.js +0 -1
  95. package/web/dist/assets/java.js +0 -1
  96. package/web/dist/assets/javascript.js +0 -1
  97. package/web/dist/assets/julia.js +0 -1
  98. package/web/dist/assets/kotlin.js +0 -1
  99. package/web/dist/assets/latex.js +0 -1
  100. package/web/dist/assets/less.js +0 -1
  101. package/web/dist/assets/log.js +0 -1
  102. package/web/dist/assets/lua.js +0 -1
  103. package/web/dist/assets/make.js +0 -1
  104. package/web/dist/assets/markdown.js +0 -1
  105. package/web/dist/assets/mdx.js +0 -1
  106. package/web/dist/assets/nix.js +0 -1
  107. package/web/dist/assets/perl.js +0 -1
  108. package/web/dist/assets/php.js +0 -1
  109. package/web/dist/assets/powershell.js +0 -1
  110. package/web/dist/assets/proto.js +0 -1
  111. package/web/dist/assets/python.js +0 -1
  112. package/web/dist/assets/r.js +0 -1
  113. package/web/dist/assets/rst.js +0 -1
  114. package/web/dist/assets/ruby.js +0 -1
  115. package/web/dist/assets/rust.js +0 -1
  116. package/web/dist/assets/scala.js +0 -1
  117. package/web/dist/assets/scss.js +0 -1
  118. package/web/dist/assets/sql.js +0 -1
  119. package/web/dist/assets/svelte.js +0 -1
  120. package/web/dist/assets/swift.js +0 -1
  121. package/web/dist/assets/system-verilog.js +0 -1
  122. package/web/dist/assets/toml.js +0 -1
  123. package/web/dist/assets/vb.js +0 -1
  124. package/web/dist/assets/verilog.js +0 -1
  125. package/web/dist/assets/vue.js +0 -1
  126. package/web/dist/assets/xml.js +0 -1
  127. package/web/dist/assets/yaml.js +0 -1
package/docs/sentry.md ADDED
@@ -0,0 +1,54 @@
1
+ # Sentry error collection
2
+
3
+ Browser and extension error reporting are enabled by default with this built-in public DSN:
4
+
5
+ ```text
6
+ https://070c0b7c5ac18d940c294e63ecfa0793@o4506663318716416.ingest.us.sentry.io/4512191040716800
7
+ ```
8
+
9
+ Start Pi and run `/web`; no environment configuration is needed. To override the default destination, set `PI_WEB_SENTRY_DSN` in the **Pi process environment**. Pi does not automatically read `.env`; `.env.example` is a configuration reference.
10
+
11
+ ```sh
12
+ PI_WEB_SENTRY_DSN='https://PUBLIC_KEY@o123.ingest.sentry.io/123' pi
13
+ ```
14
+
15
+ Replace the example with your project's public DSN. `PI_WEB_SENTRY_BROWSER_DSN` and `PI_WEB_SENTRY_NODE_DSN` override the common destination; an explicitly empty override disables that side. An explicitly empty common DSN disables both sides unless a per-side DSN overrides it. Use `PI_WEB_SENTRY_ENABLED=false` to disable both regardless of DSN overrides; disabled SDKs are not loaded and no events are sent. `PI_WEB_SENTRY_ENVIRONMENT` defaults to `production`. Restart Pi after changing runtime configuration. The host's `SENTRY_DSN` is deliberately ignored.
16
+
17
+ ## What is collected
18
+
19
+ - Browser errors, unhandled rejections, React render failures, HTTP/response parsing failures, invalid NDJSON/protocol events and unexpected connection failures.
20
+ - Extension request/workspace/configuration failures, asynchronous Agent and tool failures, and provider-login failures. Fatal exceptions attributable to this extension are best effort; process exit can prevent delivery.
21
+ - Sanitized stack locations and causes, build/release versions, runtime/platform, model and session-state summaries, anonymous session identifiers, request/operation IDs and up to 100 semantic breadcrumbs (64 KiB total).
22
+
23
+ User cancellation, stopping an Agent, normal shutdown, known validation failures and stale-session conflicts are excluded. No conversation, source contents, attachments, login values, request/response bodies, console output or DOM recordings are deliberately collected. Agent/provider error messages are replaced with generic diagnostic labels. Other exception text is scrubbed for credentials, URLs, quoted values, email addresses and absolute paths. Arbitrary free-form exception messages cannot be classified perfectly; do not put private data in exceptions.
24
+
25
+ Browser events go directly to the configured Sentry host with no Pi authorization header, cookies or referrer. The authenticated configuration endpoint returns only the public DSN and build metadata. Node reporting uses a private client and explicit scopes without initializing a global SDK or changing Pi's uncaught-error/async-context handling; inherited SDK attachments are discarded before sending.
26
+
27
+ ## Performance and reliability
28
+
29
+ Each side sends at most 20 events/minute and one event per fingerprint/minute. Repetition counts appear on the next retained event. Startup and transport queues are bounded to 20 events. Transport requests time out after 3 seconds, do not persist offline, and do not retry indefinitely. Rate-limited/dropped events are intentionally lossy. Browser configuration has a 1-second timeout and never gates rendering; SDKs load only when reporting is enabled. No tracing, profiling, automatic console/DOM instrumentation or token-by-token logging is enabled.
30
+
31
+ Request failures and asynchronous error events include additive `errorId`, `requestId`, `operationId`, `errorCode` and `errorReported` metadata. `errorReported` prevents the browser from bypassing server-side deduplication/rate limits. Protocol version 7 is retained. A `shutdown` event stops reconnection on normal exit; controlled launcher upgrades mark it with `reconnect: true` so the browser reconnects without reporting the expected interruption. A changed build ID replaces a retained bridge on `/web` after `/reload` so its static manifest matches the new assets.
32
+
33
+ ## Private source maps and releases
34
+
35
+ `npm run build` produces matching browser/extension release IDs and debug IDs. It archives bundles/maps in `.sentry-artifacts/<buildId>/` and removes `.map` files from `web/dist` and `dist`. Archive directories are git-ignored and excluded from the npm package. These private files contain application source; store them as access-controlled CI artifacts. Ordinary local builds do not upload or contact Sentry.
36
+
37
+ For an upload-required release build, provide these **CI-only** variables:
38
+
39
+ ```sh
40
+ export SENTRY_AUTH_TOKEN='YOUR_CI_TOKEN'
41
+ export SENTRY_ORG='YOUR_ORGANIZATION'
42
+ export SENTRY_PROJECT='YOUR_PROJECT'
43
+ npm run build:sentry
44
+ ```
45
+
46
+ Use `SENTRY_BROWSER_PROJECT` / `SENTRY_NODE_PROJECT` for separate projects. The upload-required command fails on missing credentials or upload failure, and still removes maps from public output. Do not publish after a failed command. Auth tokens are never part of runtime configuration. The ordinary npm `prepack` rebuilds locally without uploading; use `npm pack --ignore-scripts` or `npm publish --ignore-scripts` only after checks and a successful `build:sentry` to package the exact uploaded artifacts.
47
+
48
+ ## Verification and finding an error
49
+
50
+ Run `npm run check`, `npm run test`, `npm run build`, then `npm run test:browser`. Install test Chromium with `npx playwright install chromium`; on a machine with Chrome use `PI_WEB_TEST_CHROME=true npm run test:browser`. Browser tests intercept a synthetic Sentry destination and do not send to a real project. Optional performance comparison: `PI_WEB_TEST_CHROME=true PI_WEB_BENCHMARK=true npm run test:browser -- --grep 'streaming frame budget'`.
51
+
52
+ In Sentry, filter by `release`, `environment` and the `side` tag. Use `contexts.diagnostic.requestId` / `operationId` to follow a browser action into its asynchronous Agent result. Confirm a production-build exception has a `debug_meta` ID matching an uploaded map and resolves to original TypeScript.
53
+
54
+ The included tests verify default reporting through a mock transport, local delivery, correlation, privacy, bounded buffering, render fallback, reconnection and build debug IDs. Real ingestion must be checked in the configured Sentry project; Sentry-side source-map restoration additionally requires CI upload credentials. Context describes the failure path; it does not deterministically replay model responses, tool side effects or private content.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-webapp",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "type": "module",
5
5
  "description": "A browser interface for Pi with live chat, workspaces, models, and attachments",
6
6
  "repository": {
@@ -15,7 +15,7 @@
15
15
  "pi-webapp": "./bin/pi-webapp.mjs"
16
16
  },
17
17
  "pi": {
18
- "image": "https://cdn.jsdelivr.net/npm/pi-webapp@0.1.7/assets/cover-webapp.png",
18
+ "image": "https://cdn.jsdelivr.net/npm/pi-webapp@0.1.8/assets/cover-webapp.png",
19
19
  "extensions": [
20
20
  "./dist/extension.js"
21
21
  ]
@@ -28,19 +28,22 @@
28
28
  "README.md",
29
29
  "README.zh-CN.md",
30
30
  "LICENSE",
31
- "THIRD_PARTY_LICENSE.txt"
31
+ "THIRD_PARTY_LICENSE.txt",
32
+ "docs/sentry.md"
32
33
  ],
33
34
  "scripts": {
34
35
  "start": "npm run build && node bin/pi-webapp.mjs",
35
36
  "status": "node bin/pi-webapp.mjs status",
36
37
  "stop": "node bin/pi-webapp.mjs stop",
37
38
  "check": "tsc --noEmit && tsc -p web/tsconfig.json",
38
- "test": "node --experimental-strip-types --test test/*.test.ts",
39
- "build": "npm run build:web && npm run build:extension",
40
- "build:web": "vite build",
41
- "build:extension": "node scripts/build-extension.mjs",
39
+ "test": "node --import ./test/setup-env.mjs --experimental-strip-types --test test/*.test.ts",
40
+ "build": "node scripts/build.mjs",
41
+ "build:web": "node scripts/build.mjs browser",
42
+ "build:extension": "node scripts/build.mjs node",
42
43
  "prepack": "npm run build",
43
- "prepublishOnly": "npm run check && npm run build && npm run test"
44
+ "prepublishOnly": "npm run check && npm run build && npm run test",
45
+ "build:sentry": "node scripts/build.mjs all --sentry",
46
+ "test:browser": "playwright test"
44
47
  },
45
48
  "publishConfig": {
46
49
  "access": "public"
@@ -53,6 +56,9 @@
53
56
  "@chengzhiyi/pi-web-protocol": "0.1.0",
54
57
  "@earendil-works/pi-ai": "0.87.1",
55
58
  "@earendil-works/pi-coding-agent": "0.87.1",
59
+ "@playwright/test": "1.63.0",
60
+ "@sentry/esbuild-plugin": "5.4.0",
61
+ "@sentry/vite-plugin": "5.4.0",
56
62
  "@types/katex": "^0.16.7",
57
63
  "@types/mdast": "^4.0.4",
58
64
  "@types/node": "22.19.19",
@@ -69,6 +75,9 @@
69
75
  "dependencies": {
70
76
  "@lexical/history": "0.49.0",
71
77
  "@lexical/plain-text": "0.49.0",
78
+ "@sentry/core": "11.4.0",
79
+ "@sentry/node": "11.4.0",
80
+ "@sentry/react": "11.4.0",
72
81
  "@shikijs/langs": "^4.3.1",
73
82
  "anser": "^2.3.5",
74
83
  "clsx": "^2.1.1",