@chainingintention/pi-web-cn 1.202606.10 → 1.202606.12

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 (71) hide show
  1. package/README.md +12 -5
  2. package/dist/cli.js +14 -2
  3. package/dist/cli.js.map +1 -1
  4. package/dist/client/assets/{CodeViewer-YNyWxbqH.js → CodeViewer-BKljKDuK.js} +1 -1
  5. package/dist/client/assets/{TerminalPanel-B9UStXy9.js → TerminalPanel-DeDTQWls.js} +1 -1
  6. package/dist/client/assets/index-BuVYTYo8.js +2315 -0
  7. package/dist/client/index.html +1 -1
  8. package/dist/config.js +28 -3
  9. package/dist/config.js.map +1 -1
  10. package/dist/pi-web-plugins/updates/package.json +1 -1
  11. package/dist/pi-web-plugins/updates/pi-web-plugin.js +61 -71
  12. package/dist/pi-web-plugins/updates/updatesLogic.js +65 -0
  13. package/dist/server/app.js +14 -6
  14. package/dist/server/app.js.map +1 -1
  15. package/dist/server/index.js +2 -2
  16. package/dist/server/index.js.map +1 -1
  17. package/dist/server/machines/machinePluginProxyRoutes.js +8 -0
  18. package/dist/server/machines/machinePluginProxyRoutes.js.map +1 -1
  19. package/dist/server/machines/machineRoutes.js +6 -0
  20. package/dist/server/machines/machineRoutes.js.map +1 -1
  21. package/dist/server/machines/machineService.js +97 -5
  22. package/dist/server/machines/machineService.js.map +1 -1
  23. package/dist/server/piWebPluginService.js +24 -4
  24. package/dist/server/piWebPluginService.js.map +1 -1
  25. package/dist/server/piWebStatus.js +149 -45
  26. package/dist/server/piWebStatus.js.map +1 -1
  27. package/dist/server/piWebStatusCache.js +32 -0
  28. package/dist/server/piWebStatusCache.js.map +1 -0
  29. package/dist/server/sessiond/sessionProxyRoutes.js +15 -1
  30. package/dist/server/sessiond/sessionProxyRoutes.js.map +1 -1
  31. package/dist/server/sessiond.js +20 -8
  32. package/dist/server/sessiond.js.map +1 -1
  33. package/dist/server/sessions/attachmentService.js +61 -0
  34. package/dist/server/sessions/attachmentService.js.map +1 -0
  35. package/dist/server/sessions/oauthLoginFlowService.js +7 -0
  36. package/dist/server/sessions/oauthLoginFlowService.js.map +1 -1
  37. package/dist/server/sessions/piSessionManagerGateway.js +96 -0
  38. package/dist/server/sessions/piSessionManagerGateway.js.map +1 -0
  39. package/dist/server/sessions/piSessionService.js +211 -383
  40. package/dist/server/sessions/piSessionService.js.map +1 -1
  41. package/dist/server/sessions/sessionArchiveStore.js +16 -2
  42. package/dist/server/sessions/sessionArchiveStore.js.map +1 -1
  43. package/dist/server/sessions/sessionRoutes.js +156 -43
  44. package/dist/server/sessions/sessionRoutes.js.map +1 -1
  45. package/dist/server/terminals/terminalRoutes.js +10 -4
  46. package/dist/server/terminals/terminalRoutes.js.map +1 -1
  47. package/dist/server/workingDirectory.js +44 -0
  48. package/dist/server/workingDirectory.js.map +1 -0
  49. package/dist/server/workspaces/fileSuggestions.js +96 -16
  50. package/dist/server/workspaces/fileSuggestions.js.map +1 -1
  51. package/dist/shared/apiTypes.d.ts +81 -4
  52. package/dist/shared/apiTypes.js +5 -1
  53. package/dist/shared/apiTypes.js.map +1 -1
  54. package/dist/shared/capabilities.js +27 -0
  55. package/dist/shared/capabilities.js.map +1 -0
  56. package/dist/shared/federatedRoutes.js +3 -0
  57. package/dist/shared/federatedRoutes.js.map +1 -1
  58. package/dist/shared/piWebStatusParsing.js +28 -0
  59. package/dist/shared/piWebStatusParsing.js.map +1 -1
  60. package/dist/shared/promptAttachments.js +73 -0
  61. package/dist/shared/promptAttachments.js.map +1 -0
  62. package/dist/shared/thinkingLevels.d.ts +27 -0
  63. package/dist/shared/thinkingLevels.js +31 -0
  64. package/dist/shared/thinkingLevels.js.map +1 -0
  65. package/dist/shared/workspaceDeletion.js +1 -1
  66. package/dist/shared/workspaceDeletion.js.map +1 -1
  67. package/docs/plugins.md +14 -7
  68. package/package.json +23 -13
  69. package/dist/client/assets/index-BH7nkPuT.js +0 -2172
  70. package/dist/server/sessions/managementPermissionSystem.js +0 -94
  71. package/dist/server/sessions/managementPermissionSystem.js.map +0 -1
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Known levels in increasing intensity, derived from pi's `ThinkingLevel` union.
3
+ * The `satisfies` clause makes this fail to compile if pi removes or renames a
4
+ * level; thinkingLevels.test.ts adds a compile-time check for additions too. When
5
+ * either breaks, update this list and give the new level a label/description
6
+ * where thinking levels are presented.
7
+ */
8
+ export const KNOWN_THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh"];
9
+ export function isKnownThinkingLevel(value) {
10
+ return KNOWN_THINKING_LEVELS.some((level) => level === value);
11
+ }
12
+ export function thinkingLevelLabel(level) {
13
+ return level === undefined || level === "" ? "off" : level;
14
+ }
15
+ /**
16
+ * Describe a thinking-level gauge from the available set rather than a hardcoded
17
+ * table, so it stays correct even if pi changes the available levels at runtime.
18
+ *
19
+ * Convention: the first available level is treated as "no thinking". The gauge
20
+ * therefore renders one bar per remaining level, and fills up to the current
21
+ * level's rank. An unknown current level fills 0 bars instead of throwing.
22
+ */
23
+ export function thinkingGauge(level, available) {
24
+ const pool = available.length >= 2 ? available : KNOWN_THINKING_LEVELS;
25
+ const total = pool.length - 1;
26
+ const normalized = thinkingLevelLabel(level);
27
+ const index = pool.indexOf(normalized);
28
+ const filled = index <= 0 ? 0 : Math.min(index, total);
29
+ return { total, filled };
30
+ }
31
+ //# sourceMappingURL=thinkingLevels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thinkingLevels.js","sourceRoot":"","sources":["../../src/shared/thinkingLevels.ts"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAA6C,CAAC;AAEtI,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,OAAO,qBAAqB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAyB;IAC1D,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;AAC7D,CAAC;AASD;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,KAAyB,EAAE,SAA4B;IACnF,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,qBAAqB,CAAC;IACvE,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAC9B,MAAM,UAAU,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACvC,MAAM,MAAM,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACvD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC3B,CAAC"}
@@ -1,7 +1,7 @@
1
1
  export const workspaceDeleteOperation = "workspace.delete";
2
2
  export const workspaceDeleteOperationMetadataKey = "pi.operation";
3
3
  export const targetWorkspaceIdMetadataKey = "target.workspaceId";
4
- export const targetWorkspacePathMetadataKey = "target.workspacePath";
4
+ const targetWorkspacePathMetadataKey = "target.workspacePath";
5
5
  export function workspaceDeletionMetadata(workspace) {
6
6
  return {
7
7
  [workspaceDeleteOperationMetadataKey]: workspaceDeleteOperation,
@@ -1 +1 @@
1
- {"version":3,"file":"workspaceDeletion.js","sourceRoot":"","sources":["../../src/shared/workspaceDeletion.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,wBAAwB,GAAG,kBAAkB,CAAC;AAC3D,MAAM,CAAC,MAAM,mCAAmC,GAAG,cAAc,CAAC;AAClE,MAAM,CAAC,MAAM,4BAA4B,GAAG,oBAAoB,CAAC;AACjE,MAAM,CAAC,MAAM,8BAA8B,GAAG,sBAAsB,CAAC;AAOrE,MAAM,UAAU,yBAAyB,CAAC,SAAkC;IAC1E,OAAO;QACL,CAAC,mCAAmC,CAAC,EAAE,wBAAwB;QAC/D,CAAC,4BAA4B,CAAC,EAAE,SAAS,CAAC,EAAE;QAC5C,CAAC,8BAA8B,CAAC,EAAE,SAAS,CAAC,IAAI;KACjD,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"workspaceDeletion.js","sourceRoot":"","sources":["../../src/shared/workspaceDeletion.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,wBAAwB,GAAG,kBAAkB,CAAC;AAC3D,MAAM,CAAC,MAAM,mCAAmC,GAAG,cAAc,CAAC;AAClE,MAAM,CAAC,MAAM,4BAA4B,GAAG,oBAAoB,CAAC;AACjE,MAAM,8BAA8B,GAAG,sBAAsB,CAAC;AAO9D,MAAM,UAAU,yBAAyB,CAAC,SAAkC;IAC1E,OAAO;QACL,CAAC,mCAAmC,CAAC,EAAE,wBAAwB;QAC/D,CAAC,4BAA4B,CAAC,EAAE,SAAS,CAAC,EAAE;QAC5C,CAAC,8BAA8B,CAAC,EAAE,SAAS,CAAC,IAAI;KACjD,CAAC;AACJ,CAAC"}
package/docs/plugins.md CHANGED
@@ -136,12 +136,17 @@ When [machine federation](https://pi-web.dev/machines.html) is enabled, PI WEB a
136
136
  - actions, workspace panels, and workspace labels only appear while that machine is selected;
137
137
  - plugin file and terminal helpers run against that machine;
138
138
  - plugin code is loaded best-effort through the current gateway and cached for the browser page lifetime;
139
- - if the gateway already has an enabled plugin with the same original id, the gateway plugin wins and the remote duplicate stays hidden;
139
+ - if the gateway and remote machine both have an enabled plugin with the same original id, `machineSpecific` metadata decides whether the gateway copy is reused or only the selected machine's copy can appear;
140
140
  - remote theme contributions are ignored for now because themes are app-wide;
141
141
  - mixed PI WEB versions across federated machines are best-effort and not guaranteed compatible.
142
142
 
143
143
  Remote plugin enablement is controlled by the remote machine's PI WEB plugin config. To edit or disable a remote machine plugin, open that machine directly or update its config file.
144
144
 
145
+ Plugin package metadata may set `machineSpecific: true` when the plugin's meaning is tied to the selected PI WEB machine:
146
+
147
+ - Omitted or `false`: use the gateway copy when the same plugin id is also present on a remote machine. This is best for portable UI plugins whose helpers already route through the selected machine.
148
+ - `true`: the gateway copy only appears for the local machine. When a remote machine is selected, only that remote machine's copy can appear; if the remote machine does not expose the plugin, the plugin is hidden. This is best for plugins that report machine-local PI WEB status or depend on machine-local plugin code.
149
+
145
150
  For portable plugin assets, prefer URLs relative to the plugin module, for example:
146
151
 
147
152
  ```js
@@ -185,7 +190,7 @@ Built-in plugins can be managed from **Settings → Plugins** or with the top-le
185
190
  **Plugin id:** `updates`
186
191
  **What it does:** adds a conditional **Updates** workspace tab with PI WEB update, restart, and installed-service guidance.
187
192
 
188
- Updates is enabled by default. To hide it, disable `updates` in **Settings → Plugins** or set:
193
+ Updates is enabled by default. It declares `machineSpecific: true` so the gateway Updates tab only appears for the local machine; while a remote machine is selected, that remote machine's Updates plugin is used if available. To hide it, disable `updates` in **Settings → Plugins** or set:
189
194
 
190
195
  ```json
191
196
  {
@@ -286,7 +291,7 @@ A package can expose one or more PI WEB plugin modules. There is exactly one sup
286
291
  "piWeb": {
287
292
  "plugins": [
288
293
  { "id": "review", "module": "dist/review.js" },
289
- { "id": "dashboard", "module": "dist/dashboard.js" }
294
+ { "id": "dashboard", "module": "dist/dashboard.js", "machineSpecific": true }
290
295
  ]
291
296
  }
292
297
  }
@@ -298,6 +303,7 @@ Rules:
298
303
  - Each entry must have an explicit `id` and `module`.
299
304
  - `id` must match `^[a-z][a-z0-9.-]*$`.
300
305
  - `module` must be a safe relative path inside the plugin package root.
306
+ - `machineSpecific` is optional and must be a boolean; omit it for the default portable gateway behavior.
301
307
  - Duplicate plugin ids are not auto-renamed; later duplicates are skipped.
302
308
  - Legacy shortcuts such as `piWeb.plugin`, string entries in `piWeb.plugins`, `piWeb.id` fallback ids, and no-`package.json` fallbacks are not supported.
303
309
 
@@ -312,13 +318,14 @@ The manifest contains each discovered plugin module:
312
318
  "id": "my-plugin",
313
319
  "module": "/pi-web-plugins/my-plugin/pi-web-plugin.js?v=1234567890",
314
320
  "source": "local",
315
- "scope": "local"
321
+ "scope": "local",
322
+ "machineSpecific": false
316
323
  }
317
324
  ]
318
325
  }
319
326
  ```
320
327
 
321
- `source` describes where the plugin came from (`bundled`, `local`, or the Pi package source). `scope` is `bundled`, `local`, `user`, or `project`.
328
+ `source` describes where the plugin came from (`bundled`, `local`, or the Pi package source). `scope` is `bundled`, `local`, `user`, or `project`. `machineSpecific` controls whether the gateway copy is valid for remote machines or only each selected machine's own copy can appear.
322
329
 
323
330
  A plugin can fetch its own static assets with URLs under:
324
331
 
@@ -450,7 +457,7 @@ interface PluginRuntimeContext {
450
457
  Notes:
451
458
 
452
459
  - `state` is a snapshot of current UI state when actions are built.
453
- - The stable state fields are `state.selectedWorkspace`, `state.selectedSession`, and `state.piWebStatus`.
460
+ - The stable state fields are `state.selectedWorkspace`, `state.selectedSession`, and `state.piWebStatus`. `state.piWebStatus` describes the currently selected machine's PI WEB runtime, or the gateway/local runtime when the local machine is selected.
454
461
  - Other `state` fields may exist at runtime, but they are private PI WEB internals that may graduate into stable helpers, change shape, or disappear.
455
462
  - `enabled` is evaluated when the action palette asks for actions.
456
463
  - `selectWorkspaceTool()` expects a qualified panel id such as `my-plugin:workspace.info`.
@@ -795,7 +802,7 @@ PI WEB does not provide a plugin cache/invalidation framework. Keep host callbac
795
802
  If you are an AI agent building or editing a PI WEB plugin, follow this checklist:
796
803
 
797
804
  1. Create or update a plugin folder with `package.json` and a JavaScript module such as `pi-web-plugin.js`.
798
- 2. Use the single supported package metadata shape: `piWeb.plugins` array with `{ id, module }` entries.
805
+ 2. Use the single supported package metadata shape: `piWeb.plugins` array with `{ id, module, machineSpecific? }` entries.
799
806
  3. Default-export `{ apiVersion: 1, name, activate }` from the module.
800
807
  4. Return `{ contributions: { actions, workspacePanels, workspaceLabels } }` from `activate()`.
801
808
  5. Use ids matching `^[a-z][a-z0-9.-]*$`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainingintention/pi-web-cn",
3
- "version": "1.202606.10",
3
+ "version": "1.202606.12",
4
4
  "description": "Remote web UI and browser control plane for persistent Pi Coding Agent sessions.",
5
5
  "license": "MIT",
6
6
  "author": "Federico Jaramillo Martinez",
@@ -32,9 +32,10 @@
32
32
  "build:plugin-api": "tsc -p tsconfig.plugin-api.json",
33
33
  "build:plugins": "tsc -p tsconfig.plugins.json && node scripts/build-plugins.mjs",
34
34
  "typecheck": "tsc --noEmit",
35
+ "knip": "knip",
35
36
  "lint": "eslint \"src/**/*.ts\" \"extensions/**/*.ts\" \"pi-web-plugins/**/*.ts\" vite.config.ts vitest.config.ts",
36
37
  "test": "vitest run --config vitest.config.ts",
37
- "verify": "npm run typecheck && npm run lint && npm test",
38
+ "verify": "npm run typecheck && npm run lint && npm run knip && npm test",
38
39
  "start": "tsx src/server/index.ts",
39
40
  "start:sessiond": "tsx src/server/sessiond.ts",
40
41
  "clean": "rm -rf dist",
@@ -48,6 +49,7 @@
48
49
  "changelog:status": "changeset status"
49
50
  },
50
51
  "dependencies": {
52
+ "@codemirror/commands": "^6.10.3",
51
53
  "@codemirror/lang-css": "^6.3.1",
52
54
  "@codemirror/lang-go": "^6.0.1",
53
55
  "@codemirror/lang-html": "^6.4.11",
@@ -56,13 +58,15 @@
56
58
  "@codemirror/lang-markdown": "^6.5.0",
57
59
  "@codemirror/lang-python": "^6.2.1",
58
60
  "@codemirror/lang-rust": "^6.0.2",
61
+ "@codemirror/language": "^6.12.3",
59
62
  "@codemirror/legacy-modes": "^6.5.2",
63
+ "@codemirror/state": "^6.6.0",
64
+ "@codemirror/view": "^6.42.1",
60
65
  "@fastify/multipart": "^10.0.0",
61
66
  "@fastify/static": "^9.1.3",
62
67
  "@fastify/websocket": "^11.2.0",
63
68
  "@xterm/addon-fit": "^0.11.0",
64
69
  "@xterm/xterm": "^6.0.0",
65
- "codemirror": "^6.0.2",
66
70
  "diff": "^8.0.4",
67
71
  "fastify": "^5.6.1",
68
72
  "lit": "^3.3.1",
@@ -72,13 +76,15 @@
72
76
  },
73
77
  "devDependencies": {
74
78
  "@changesets/cli": "^2.31.0",
75
- "@earendil-works/pi-ai": "^0.74.0",
76
- "@earendil-works/pi-coding-agent": "^0.74.0",
79
+ "@earendil-works/pi-agent-core": "^0.79.1",
80
+ "@earendil-works/pi-ai": "^0.79.1",
81
+ "@earendil-works/pi-coding-agent": "^0.79.1",
77
82
  "@eslint/js": "^10.0.1",
78
83
  "@types/node": "^24.10.1",
79
84
  "@types/ws": "^8.18.1",
80
85
  "eslint": "^10.3.0",
81
86
  "globals": "^17.6.0",
87
+ "knip": "^6.16.1",
82
88
  "tsx": "^4.20.6",
83
89
  "typescript": "^5.9.3",
84
90
  "typescript-eslint": "^8.59.2",
@@ -101,22 +107,26 @@
101
107
  "homepage": "https://github.com/nayuto-wakusei/pi-web-ChineseTranslation#readme",
102
108
  "packageManager": "npm@11.11.0",
103
109
  "peerDependencies": {
104
- "@earendil-works/pi-ai": ">=0.74.0 <1",
105
- "@earendil-works/pi-coding-agent": ">=0.74.0 <1"
110
+ "@earendil-works/pi-agent-core": ">=0.78.0 <1",
111
+ "@earendil-works/pi-ai": ">=0.78.0 <1",
112
+ "@earendil-works/pi-coding-agent": ">=0.78.0 <1"
106
113
  },
107
114
  "keywords": [
108
115
  "pi-package",
109
116
  "pi",
117
+ "pi-web",
118
+ "pi-web-ui",
119
+ "pi-webui",
110
120
  "pi-coding-agent",
121
+ "pi-coding-agent-web-ui",
111
122
  "coding-agent",
112
- "agent",
113
- "web",
114
- "ui",
123
+ "ai-coding-agent",
124
+ "agentic-development",
125
+ "developer-tools",
115
126
  "web-ui",
116
127
  "webui",
117
- "remote",
118
- "browser",
119
- "control-plane",
128
+ "browser-ui",
129
+ "remote-development",
120
130
  "persistent-sessions"
121
131
  ],
122
132
  "pi": {