@jmfederico/pi-web 1.202606.6 → 1.202606.7

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 (55) hide show
  1. package/README.md +84 -296
  2. package/dist/cli.js +25 -7
  3. package/dist/cli.js.map +1 -1
  4. package/dist/client/assets/CodeViewer-CQU9mJ74.js +4 -0
  5. package/dist/client/assets/{TerminalPanel-BZKsaE9s.js → TerminalPanel-DtfVBsqI.js} +1 -1
  6. package/dist/client/assets/UnifiedDiffViewer-BZQQK99S.js +34 -0
  7. package/dist/client/assets/index-CbE7df66.js +2742 -0
  8. package/dist/client/assets/{vendor-editor-core-Bc1A7SO7.js → vendor-editor-core-C7aWiQy0.js} +2 -2
  9. package/dist/client/assets/{vendor-editor-languages-D0CnB2js.js → vendor-editor-languages-EW34FfVy.js} +1 -1
  10. package/dist/client/index.html +3 -3
  11. package/dist/config.js +33 -1
  12. package/dist/config.js.map +1 -1
  13. package/dist/plugin-api.d.ts +30 -2
  14. package/dist/server/app.js +16 -4
  15. package/dist/server/app.js.map +1 -1
  16. package/dist/server/configRoutes.js +4 -1
  17. package/dist/server/configRoutes.js.map +1 -1
  18. package/dist/server/machines/machineClient.js +33 -5
  19. package/dist/server/machines/machineClient.js.map +1 -1
  20. package/dist/server/machines/machineProxyRoutes.js +18 -3
  21. package/dist/server/machines/machineProxyRoutes.js.map +1 -1
  22. package/dist/server/sessions/attachmentService.js +69 -11
  23. package/dist/server/sessions/attachmentService.js.map +1 -1
  24. package/dist/server/sessions/piSessionManagerGateway.js +20 -2
  25. package/dist/server/sessions/piSessionManagerGateway.js.map +1 -1
  26. package/dist/server/sessions/piSessionService.js +466 -33
  27. package/dist/server/sessions/piSessionService.js.map +1 -1
  28. package/dist/server/sessions/sessionCleanup.js +157 -0
  29. package/dist/server/sessions/sessionCleanup.js.map +1 -0
  30. package/dist/server/sessions/sessionRoutes.js +17 -0
  31. package/dist/server/sessions/sessionRoutes.js.map +1 -1
  32. package/dist/server/sessions/spawnSubsessionTool.js +6 -3
  33. package/dist/server/sessions/spawnSubsessionTool.js.map +1 -1
  34. package/dist/server/workspaceExplorerRoutes.js +55 -3
  35. package/dist/server/workspaceExplorerRoutes.js.map +1 -1
  36. package/dist/server/workspaces/fileContentService.js +112 -1
  37. package/dist/server/workspaces/fileContentService.js.map +1 -1
  38. package/dist/server/workspaces/pathSafety.js +16 -1
  39. package/dist/server/workspaces/pathSafety.js.map +1 -1
  40. package/dist/server/workspaces/projectPiWebConfig.js +6 -1
  41. package/dist/server/workspaces/projectPiWebConfig.js.map +1 -1
  42. package/dist/shared/apiTypes.d.ts +83 -6
  43. package/dist/shared/apiTypes.js +1 -0
  44. package/dist/shared/apiTypes.js.map +1 -1
  45. package/dist/shared/capabilities.js +3 -2
  46. package/dist/shared/capabilities.js.map +1 -1
  47. package/dist/shared/federatedRoutes.js +5 -0
  48. package/dist/shared/federatedRoutes.js.map +1 -1
  49. package/dist/shared/promptAttachments.js +30 -11
  50. package/dist/shared/promptAttachments.js.map +1 -1
  51. package/docs/config.md +40 -3
  52. package/docs/plugins.md +127 -3
  53. package/package.json +1 -1
  54. package/dist/client/assets/CodeViewer-Bv8l_MFi.js +0 -4
  55. package/dist/client/assets/index-C9oPLpm7.js +0 -2408
@@ -1,5 +1,6 @@
1
1
  export const PI_WEB_CAPABILITIES = {
2
2
  sessionsDeleteArchived: "sessions.deleteArchived",
3
+ sessionsCleanup: "sessions.cleanup",
3
4
  sessionsReload: "sessions.reload",
4
5
  promptAttachments: "prompt.attachments",
5
6
  workspaceFileSuggestions: "workspace.fileSuggestions",
@@ -1 +1 @@
1
- {"version":3,"file":"apiTypes.js","sourceRoot":"","sources":["../../src/shared/apiTypes.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,sBAAsB,EAAE,yBAAyB;IACjD,cAAc,EAAE,iBAAiB;IACjC,iBAAiB,EAAE,oBAAoB;IACvC,wBAAwB,EAAE,2BAA2B;CAC7C,CAAC"}
1
+ {"version":3,"file":"apiTypes.js","sourceRoot":"","sources":["../../src/shared/apiTypes.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,sBAAsB,EAAE,yBAAyB;IACjD,eAAe,EAAE,kBAAkB;IACnC,cAAc,EAAE,iBAAiB;IACjC,iBAAiB,EAAE,oBAAoB;IACvC,wBAAwB,EAAE,2BAA2B;CAC7C,CAAC"}
@@ -2,10 +2,11 @@ import { PI_WEB_CAPABILITIES } from "./apiTypes.js";
2
2
  export { PI_WEB_CAPABILITIES };
3
3
  export const KNOWN_PI_WEB_CAPABILITIES = Object.values(PI_WEB_CAPABILITIES);
4
4
  const knownPiWebCapabilities = new Set(KNOWN_PI_WEB_CAPABILITIES);
5
- export const WEB_RUNTIME_CAPABILITIES = [PI_WEB_CAPABILITIES.sessionsDeleteArchived, PI_WEB_CAPABILITIES.sessionsReload, PI_WEB_CAPABILITIES.promptAttachments, PI_WEB_CAPABILITIES.workspaceFileSuggestions];
6
- export const SESSIOND_RUNTIME_CAPABILITIES = [PI_WEB_CAPABILITIES.sessionsDeleteArchived, PI_WEB_CAPABILITIES.sessionsReload, PI_WEB_CAPABILITIES.promptAttachments];
5
+ export const WEB_RUNTIME_CAPABILITIES = [PI_WEB_CAPABILITIES.sessionsDeleteArchived, PI_WEB_CAPABILITIES.sessionsCleanup, PI_WEB_CAPABILITIES.sessionsReload, PI_WEB_CAPABILITIES.promptAttachments, PI_WEB_CAPABILITIES.workspaceFileSuggestions];
6
+ export const SESSIOND_RUNTIME_CAPABILITIES = [PI_WEB_CAPABILITIES.sessionsDeleteArchived, PI_WEB_CAPABILITIES.sessionsCleanup, PI_WEB_CAPABILITIES.sessionsReload, PI_WEB_CAPABILITIES.promptAttachments];
7
7
  const EFFECTIVE_CAPABILITY_REQUIREMENTS = {
8
8
  [PI_WEB_CAPABILITIES.sessionsDeleteArchived]: ["web", "sessiond"],
9
+ [PI_WEB_CAPABILITIES.sessionsCleanup]: ["web", "sessiond"],
9
10
  [PI_WEB_CAPABILITIES.sessionsReload]: ["web", "sessiond"],
10
11
  [PI_WEB_CAPABILITIES.promptAttachments]: ["web", "sessiond"],
11
12
  [PI_WEB_CAPABILITIES.workspaceFileSuggestions]: ["web"],
@@ -1 +1 @@
1
- {"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../../src/shared/capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAgF,MAAM,eAAe,CAAC;AAElI,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAG/B,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAC5E,MAAM,sBAAsB,GAAwB,IAAI,GAAG,CAAC,yBAAyB,CAAC,CAAC;AAEvF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,mBAAmB,CAAC,sBAAsB,EAAE,mBAAmB,CAAC,cAAc,EAAE,mBAAmB,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,wBAAwB,CAA+C,CAAC;AAC5P,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,mBAAmB,CAAC,sBAAsB,EAAE,mBAAmB,CAAC,cAAc,EAAE,mBAAmB,CAAC,iBAAiB,CAA+C,CAAC;AAEnN,MAAM,iCAAiC,GAAG;IACxC,CAAC,mBAAmB,CAAC,sBAAsB,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC;IACjE,CAAC,mBAAmB,CAAC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC;IACzD,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC;IAC5D,CAAC,mBAAmB,CAAC,wBAAwB,CAAC,EAAE,CAAC,KAAK,CAAC;CACqB,CAAC;AAE/E,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI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P_ROUTES = [
8
8
  { method: "DELETE", path: "/projects/:projectId/workspaces/:workspaceId" },
9
9
  { method: "GET", path: "/projects/:projectId/workspaces/:workspaceId/tree" },
10
10
  { method: "GET", path: "/projects/:projectId/workspaces/:workspaceId/file" },
11
+ { method: "PUT", path: "/projects/:projectId/workspaces/:workspaceId/file" },
12
+ { method: "DELETE", path: "/projects/:projectId/workspaces/:workspaceId/file" },
13
+ { method: "POST", path: "/projects/:projectId/workspaces/:workspaceId/file/move" },
11
14
  { method: "GET", path: "/projects/:projectId/workspaces/:workspaceId/file/preview" },
12
15
  { method: "GET", path: "/projects/:projectId/workspaces/:workspaceId/files" },
13
16
  { method: "GET", path: "/projects/:projectId/workspaces/:workspaceId/git/status" },
@@ -25,6 +28,8 @@ export const FEDERATED_HTTP_ROUTES = [
25
28
  { method: "GET", path: "/activity" },
26
29
  { method: "GET", path: "/sessions" },
27
30
  { method: "POST", path: "/sessions" },
31
+ { method: "POST", path: "/sessions/cleanup/preview" },
32
+ { method: "POST", path: "/sessions/cleanup" },
28
33
  { method: "GET", path: "/sessions/:sessionId/messages" },
29
34
  { method: "GET", path: "/sessions/:sessionId/status" },
30
35
  { method: "GET", path: "/sessions/:sessionId/models" },
@@ -1 +1 @@
1
- {"version":3,"file":"federatedRoutes.js","sourceRoot":"","sources":["../../src/shared/federatedRoutes.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE;IACzC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE;IACpC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE;IACrC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,sBAAsB,EAAE;IAClD,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,sBAAsB,EAAE;IAC/C,EAAE,MAAM,EAAE,KAAK,EAAE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EAAE;IACjE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,4BAA4B,EAAE;IACtD,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,2BAA2B,EAAE;IACrD,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,8BAA8B,EAAE;IACxD,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,mCAAmC,EAAE;IAC7D,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,8BAA8B,EAAE;IACxD,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,sBAAsB,EAAE;IAClD,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,6BAA6B,EAAE;IACvD,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,oCAAoC,EAAE;IAC9D,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE;IAC1C,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE;IACzC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE;IACxC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE;IACvC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,qBAAqB,EAAE;IAC9C,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,6BAA6B,EAAE;IACvD,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,4BAA4B,EAAE;CACF,CAAC;AAEvD,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,SAAS;IACT,kBAAkB;IAClB,6BAA6B;IAC7B,2EAA2E;CACvC,CAAC"}
@@ -29,10 +29,6 @@ export function base64ByteLength(data) {
29
29
  const padding = data.endsWith("==") ? 2 : data.endsWith("=") ? 1 : 0;
30
30
  return Math.max(0, Math.floor((data.length * 3) / 4) - padding);
31
31
  }
32
- /**
33
- * Validate and normalize untrusted prompt attachments. Throws on malformed,
34
- * unsupported, or oversized input so routes can return a 400.
35
- */
36
32
  export function parsePromptAttachments(value, options = {}) {
37
33
  if (value === undefined)
38
34
  return [];
@@ -51,23 +47,46 @@ function parsePromptAttachment(value, index, options) {
51
47
  throw new Error(`attachment ${String(index)} must be an object`);
52
48
  const record = value;
53
49
  const kind = record["kind"];
54
- if (kind !== "image")
55
- throw new Error(`attachment ${String(index)} has unsupported kind`);
50
+ if (kind === "image")
51
+ return parseImageAttachment(record, index, options);
52
+ if (kind === "file" && options.allowFileAttachments === true)
53
+ return parseFileAttachment(record, index);
54
+ throw new Error(`attachment ${String(index)} has unsupported kind`);
55
+ }
56
+ function parseImageAttachment(record, index, options) {
56
57
  const mimeType = record["mimeType"];
57
58
  if (!isSupportedImageMimeType(mimeType))
58
59
  throw new Error(`attachment ${String(index)} has unsupported image type`);
59
- const data = record["data"];
60
- if (typeof data !== "string" || data === "" || !base64Pattern.test(data))
61
- throw new Error(`attachment ${String(index)} has invalid base64 data`);
60
+ const data = requireBase64Data(record["data"], index, { allowEmpty: false });
62
61
  if (options.enforceInlineSizeLimit === true && base64ByteLength(data) > MAX_INLINE_IMAGE_BASE64_BYTES) {
63
62
  throw new Error(`attachment ${String(index)} exceeds the inline image size limit`);
64
63
  }
65
- const name = record["name"];
66
64
  return {
67
65
  kind: "image",
68
66
  mimeType,
69
67
  data,
70
- ...(typeof name === "string" && name !== "" ? { name } : {}),
68
+ ...attachmentName(record),
69
+ };
70
+ }
71
+ function parseFileAttachment(record, index) {
72
+ const mimeType = record["mimeType"];
73
+ if (typeof mimeType !== "string" || mimeType.trim() === "")
74
+ throw new Error(`attachment ${String(index)} has invalid file type`);
75
+ return {
76
+ kind: "file",
77
+ mimeType: mimeType.trim(),
78
+ data: requireBase64Data(record["data"], index, { allowEmpty: true }),
79
+ ...attachmentName(record),
71
80
  };
72
81
  }
82
+ function requireBase64Data(value, index, options) {
83
+ if (typeof value !== "string" || (!options.allowEmpty && value === "") || !base64Pattern.test(value)) {
84
+ throw new Error(`attachment ${String(index)} has invalid base64 data`);
85
+ }
86
+ return value;
87
+ }
88
+ function attachmentName(record) {
89
+ const name = record["name"];
90
+ return typeof name === "string" && name !== "" ? { name } : {};
91
+ }
73
92
  //# sourceMappingURL=promptAttachments.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"promptAttachments.js","sourceRoot":"","sources":["../../src/shared/promptAttachments.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,CAAU,CAAC;AAI1G,MAAM,uBAAuB,GAAwB,IAAI,GAAG,CAAC,0BAA0B,CAAC,CAAC;AAEzF;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;AAE3E,gEAAgE;AAChE,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAEzC,MAAM,UAAU,wBAAwB,CAAC,KAAc;IACrD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,uBAAuB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,QAAgB;IACxD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,YAAY,CAAC,CAAC,OAAO,KAAK,CAAC;QAChC,KAAK,WAAW,CAAC,CAAC,OAAO,KAAK,CAAC;QAC/B,KAAK,WAAW,CAAC,CAAC,OAAO,KAAK,CAAC;QAC/B,KAAK,YAAY,CAAC,CAAC,OAAO,MAAM,CAAC;QACjC,OAAO,CAAC,CAAC,OAAO,KAAK,CAAC;IACxB,CAAC;AACH,CAAC;AAED,MAAM,aAAa,GAAG,wBAAwB,CAAC;AAE/C,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,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C1B,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc,EAAE,KAAa,EAAE,OAAgC;IACxF,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,OAAO,CAAC,UAAU,IAAI,KAAK,KAAK,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACrG,MAAM,IAAI,KAAK,CAAC,cAAc,MAAM,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,cAAc,CAAC,MAA+B;IACrD,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5B,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACjE,CAAC"}
package/docs/config.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # PI WEB configuration reference
2
2
 
3
- PI WEB configuration covers the machine-local and project-local settings you usually need: the web/API bind address, trusted development-host settings, UI preferences, plugin enablement, file-explorer path access, upload limits, and session-daemon tools.
3
+ PI WEB configuration covers the machine-local and project-local settings you usually need: the web/API bind address, trusted development-host settings, UI preferences, plugin enablement, file-explorer path access, manual upload defaults, upload limits, and session-daemon tools.
4
4
 
5
5
  This file is the markdown reference for agents and package consumers. The website page is <https://pi-web.dev/config>.
6
6
 
@@ -17,12 +17,14 @@ If you installed services with a custom config path, rerun `pi-web install --con
17
17
 
18
18
  ## Precedence and reloads
19
19
 
20
- Runtime values are resolved as:
20
+ Machine-global runtime values are resolved as:
21
21
 
22
22
  ```text
23
- defaults → config file → environment overrides
23
+ defaults → global config file → environment overrides
24
24
  ```
25
25
 
26
+ Supported project-local settings are then applied for that project's workspaces. For upload defaults, `<project>/.pi-web/config.json` overrides the global value.
27
+
26
28
  Environment overrides include `PI_WEB_HOST`, `PI_WEB_PORT` / `PORT`, `PI_WEB_ALLOWED_HOSTS`, `PI_WEB_MAX_UPLOAD_BYTES`, `PI_WEB_SPAWN_SESSIONS`, and `PI_WEB_SUBSESSIONS`.
27
29
 
28
30
  Process restarts depend on the key:
@@ -31,6 +33,7 @@ Process restarts depend on the key:
31
33
  - `maxUploadBytes`: restart both the web/API process and the session daemon.
32
34
  - `spawnSessions` / `subsessions`: restart the session daemon.
33
35
  - `pathAccess`: applies on the next request; existing file views may need a browser refresh.
36
+ - `uploads.defaultFolder`: applies to newly opened Files upload dialogs and new direct drag/drop batches after config/workspace refresh.
34
37
  - `plugins`: reload the browser tab after changing plugin enablement.
35
38
  - `shortcuts`: saved settings apply in the browser after config refresh/save.
36
39
 
@@ -43,6 +46,9 @@ Process restarts depend on the key:
43
46
  "pathAccess": {
44
47
  "allowedPaths": ["~/SDKs", "/opt/reference"]
45
48
  },
49
+ "uploads": {
50
+ "defaultFolder": ".pi-web/uploads"
51
+ },
46
52
  "maxUploadBytes": 67108864,
47
53
  "spawnSessions": true,
48
54
  "subsessions": false,
@@ -67,12 +73,17 @@ Project-local config lives at `<project>/.pi-web/config.json`. Use it for settin
67
73
  "version": 1,
68
74
  "pathAccess": {
69
75
  "allowedPaths": ["~/SDKs", "/opt/reference"]
76
+ },
77
+ "uploads": {
78
+ "defaultFolder": "manual/uploads"
70
79
  }
71
80
  }
72
81
  ```
73
82
 
74
83
  Project-local `pathAccess.allowedPaths` entries are merged after the global list and deduplicated. Paths must still be host-absolute or `~`-prefixed; relative roots are not supported.
75
84
 
85
+ Project-local `uploads.defaultFolder` overrides the global upload destination for workspaces in that project. Current PI WEB servers include this workspace-effective value on the existing workspace responses used locally and through machine federation. Older remote servers may omit the optional field; the browser falls back to the global/default upload folder.
86
+
76
87
  Plugins may own separate project files, such as `.pi-web/tasks.json` for the built-in Workspace Tasks plugin.
77
88
 
78
89
  ## Configuration matrix
@@ -86,6 +97,7 @@ Rows with JSON key `—` are runtime-only environment variables, not config-file
86
97
  | Web/API port | `port` | `PI_WEB_PORT`, `PORT` | Global | Not supported locally | Restart web/API |
87
98
  | Dev-server allowed hosts | `allowedHosts` | `PI_WEB_ALLOWED_HOSTS` | Global | Not supported locally | Restart dev web/UI |
88
99
  | External filesystem roots | `pathAccess.allowedPaths` | — | Global + project | **Merges**: global roots first, then project roots; duplicates removed | Next file request; refresh existing views if needed |
100
+ | Manual file upload default folder | `uploads.defaultFolder` | — | Global + project | **Overrides**: project value wins for workspaces in that project; otherwise global/default applies | New Upload dialogs and direct drag/drop batches after config/workspace refresh |
89
101
  | Upload/body limit | `maxUploadBytes` | `PI_WEB_MAX_UPLOAD_BYTES` | Global | Not supported locally | Restart web/API and session daemon |
90
102
  | Agent can spawn sessions | `spawnSessions` | `PI_WEB_SPAWN_SESSIONS` | Global/session daemon | Not supported locally | Restart session daemon |
91
103
  | Tracked subsessions (beta) | `subsessions` | `PI_WEB_SUBSESSIONS` | Global/session daemon | Not supported locally; also requires `spawnSessions` | Restart session daemon |
@@ -123,6 +135,31 @@ When an absolute request is served, PI WEB expands `~`, canonicalizes the config
123
135
 
124
136
  This is not a sandbox for the underlying Pi Coding Agent or your OS user. It only controls PI WEB UI/API file exposure outside a workspace.
125
137
 
138
+ ### Manual upload defaults
139
+
140
+ The Files panel can upload one or more files in two ways:
141
+
142
+ - Drop files onto the Files panel to upload immediately to the workspace-effective default folder.
143
+ - Use the toolbar **Upload** button to open the review dialog, edit the destination, and opt into upload options.
144
+
145
+ `uploads.defaultFolder` sets the workspace-effective default destination. The built-in default is `.pi-web/uploads`; a global config value applies to every project unless `<project>/.pi-web/config.json` sets a project-local override.
146
+
147
+ ```json
148
+ {
149
+ "uploads": {
150
+ "defaultFolder": "manual/uploads"
151
+ }
152
+ }
153
+ ```
154
+
155
+ The value must be a non-empty workspace-relative folder. PI WEB normalizes repeated separators and backslashes to `/`, and rejects absolute paths or `..` traversal. In the upload dialog only, clearing the destination field uploads that batch to the workspace root.
156
+
157
+ Manual uploads use the workspace file-write path: paths stay workspace-relative, parent folder creation is enabled by default, and overwrite is disabled by default. Direct drag/drop always keeps `overwrite` off; the review dialog lets you explicitly enable overwrite when needed. Browser-owned XHR progress is shown per batch/file, conflicts and errors stay visible in the upload progress UI, and the final file-write response is the source of truth.
158
+
159
+ For machine federation, current remote PI WEB servers return `workspace.effectiveConfig.uploads.defaultFolder` on the existing workspace-list response. Older remote servers can omit that optional field without breaking clients; the Files panel falls back to the global/default upload folder.
160
+
161
+ The per-request size limit is still controlled by `maxUploadBytes` / `PI_WEB_MAX_UPLOAD_BYTES`.
162
+
126
163
  ### Session daemon tools
127
164
 
128
165
  `spawnSessions` controls whether agents receive the `spawn_session` tool. It defaults to `true`; set it to `false` if you do not want an agent to start independent PI WEB sessions.
package/docs/plugins.md CHANGED
@@ -426,10 +426,13 @@ interface PluginAction {
426
426
  shortcut?: string;
427
427
  group?: string;
428
428
  enabled?: (context: PluginRuntimeContext) => boolean;
429
+ disabledReason?: (context: PluginRuntimeContext) => string | undefined;
429
430
  run: (context: PluginRuntimeContext) => void | Promise<void>;
430
431
  }
431
432
  ```
432
433
 
434
+ If an action is disabled and returns `disabledReason`, PI WEB can keep it visible in the action palette with that explanation instead of hiding it.
435
+
433
436
  Stable runtime context fields:
434
437
 
435
438
  ```ts
@@ -439,6 +442,7 @@ interface PluginRuntimeContext {
439
442
  selectedSession?: unknown;
440
443
  piWebStatus?: PiWebStatusResponse;
441
444
  };
445
+ prompt: PluginPromptEditor;
442
446
  openActionPalette: () => void;
443
447
  focusPrompt: () => void;
444
448
  addProject: () => void | Promise<void>;
@@ -464,6 +468,29 @@ Notes:
464
468
  - `openTerminal()` switches to the built-in terminal panel. Pass `{ terminalId }` to deep-link to a specific terminal.
465
469
  - Only fields documented here and declared in `plugin-api.d.ts` are stable public plugin API. Anything else is experimental: it may become public API later, change shape, or disappear.
466
470
 
471
+ ### Prompt editor API
472
+
473
+ The `prompt` helper on `PluginRuntimeContext` and `WorkspacePanelContext` provides stable access to the chat prompt editor:
474
+
475
+ | Method | Description |
476
+ | --- | --- |
477
+ | `insertText(text)` | Insert text at cursor position. When text is selected, replaces the selection. Focuses the editor first if not focused. |
478
+ | `getText()` | Returns the full prompt text. |
479
+ | `getSelection()` | Returns `{ start, end, text }` if text is selected, or `null`. |
480
+
481
+ Usage:
482
+
483
+ ```js
484
+ // Insert text at the cursor (e.g. a file mention)
485
+ context.prompt.insertText("@file.txt");
486
+
487
+ // Read the current prompt and selection
488
+ const text = context.prompt.getText();
489
+ const selection = context.prompt.getSelection(); // { start, end, text } | null
490
+ ```
491
+
492
+ Use `focusPrompt()` on `PluginRuntimeContext` to move focus to the prompt editor. Workspace panels can call `context.prompt.insertText()` from explicit user interactions such as button clicks; panel contexts target the currently selected session's mounted prompt editor.
493
+
467
494
  #### Keyboard shortcuts
468
495
 
469
496
  - App-level keyboard shortcuts must be attached to actions. PI WEB does not support standalone plugin keyboard commands; contribute an action first, then add a `shortcut` if it needs a keybinding.
@@ -521,7 +548,11 @@ interface WorkspacePanelContext {
521
548
  state?: PluginRuntimeState;
522
549
  files: {
523
550
  readFile(path: string): Promise<FileContentResponse>;
551
+ writeFile(path: string, content: string | Uint8Array, options?: WriteWorkspaceFileOptions): Promise<WriteWorkspaceFileResponse>;
552
+ deleteFile(path: string): Promise<DeleteWorkspaceFileResponse>;
553
+ moveFile(fromPath: string, toPath: string, options?: MoveWorkspaceFileOptions): Promise<MoveWorkspaceFileResponse>;
524
554
  };
555
+ prompt: PluginPromptEditor;
525
556
  terminal: {
526
557
  open(options?: { terminalId?: string }): void;
527
558
  runCommand(input: {
@@ -539,7 +570,7 @@ interface WorkspacePanelContext {
539
570
 
540
571
  `icon` is optional and is used in the compact mobile tab bar. Prefer an SVG rendered with the `svg` helper from `PluginActivationContext`; use `currentColor` so PI WEB themes can style it. If `icon` is omitted, mobile tabs fall back to initials from the panel title, or to the full title when initials collide.
541
572
 
542
- `machine`, `workspace`, `files`, `terminal`, and `host` are documented as stable for panel callbacks. Use `terminal.open()` to switch to the built-in terminal panel; pass `{ terminalId }` to deep-link to a specific terminal. Call `host.requestRender()` when async plugin-owned state changes should make PI WEB re-evaluate panel callbacks such as `badge`, `visible`, or `render`.
573
+ `machine`, `workspace`, `files`, `prompt`, `terminal`, and `host` are documented as stable for panel callbacks. The `files` helper supports `readFile`, `writeFile`, `deleteFile`, and `moveFile` — see [Reading workspace files](#reading-workspace-files) and [Writing workspace files](#writing-workspace-files). The `prompt` helper supports panel interactions that insert workspace context into the current prompt — see [Prompt editor API](#prompt-editor-api). Use `terminal.open()` to switch to the built-in terminal panel; pass `{ terminalId }` to deep-link to a specific terminal. Call `host.requestRender()` when async plugin-owned state changes should make PI WEB re-evaluate panel callbacks such as `badge`, `visible`, or `render`.
543
574
 
544
575
  For compatibility, PI WEB still provides the old `context.openTerminal()` workspace-panel helper at runtime. It is deprecated, intentionally omitted from the public TypeScript declarations, and planned for removal in v2. Existing JavaScript plugins keep working, while typed plugins should migrate to `context.terminal.open()`.
545
576
 
@@ -607,6 +638,9 @@ interface WorkspaceLabelContext {
607
638
  state?: PluginRuntimeState;
608
639
  files: {
609
640
  readFile(path: string): Promise<FileContentResponse>;
641
+ writeFile(path: string, content: string | Uint8Array, options?: WriteWorkspaceFileOptions): Promise<WriteWorkspaceFileResponse>;
642
+ deleteFile(path: string): Promise<DeleteWorkspaceFileResponse>;
643
+ moveFile(fromPath: string, toPath: string, options?: MoveWorkspaceFileOptions): Promise<MoveWorkspaceFileResponse>;
610
644
  };
611
645
  host: {
612
646
  requestRender(): void;
@@ -614,7 +648,7 @@ interface WorkspaceLabelContext {
614
648
  }
615
649
  ```
616
650
 
617
- `machine`, `workspace`, `files`, and `host` are documented as stable for label callbacks. Include `machine.id` in any label caches that depend on workspace data. Call `host.requestRender()` when async plugin-owned state changes should make PI WEB re-evaluate label `visible` or `items` callbacks.
651
+ `machine`, `workspace`, `files`, and `host` are documented as stable for label callbacks. The `files` helper supports `readFile`, `writeFile`, `deleteFile`, and `moveFile` — see [Reading workspace files](#reading-workspace-files) and [Writing workspace files](#writing-workspace-files). Include `machine.id` in any label caches that depend on workspace data. Call `host.requestRender()` when async plugin-owned state changes should make PI WEB re-evaluate label `visible` or `items` callbacks.
618
652
 
619
653
  Items are sorted by `order` and then id. Return an empty array to render nothing. Keep callbacks synchronous and lightweight; start async work from the callback, return cached items, then call `host.requestRender()` when the cache changes.
620
654
 
@@ -753,6 +787,96 @@ workspaceLabels: [
753
787
 
754
788
  The file response includes fields such as `path`, `content`, `truncated`, and `binary`. Be careful with sensitive files such as `.env`: plugins are trusted browser code, and file contents are exposed to the plugin.
755
789
 
790
+ ## Writing, deleting, and moving workspace files
791
+
792
+ Workspace panels and workspace labels can write, delete, and move files through the documented `files` helper. Like `readFile`, PI WEB binds these helpers to the callback's machine and workspace, so they work the same for local and federated machines.
793
+
794
+ ### Writing files
795
+
796
+ ```js
797
+ workspacePanels: [
798
+ {
799
+ id: "workspace.generate",
800
+ title: "Generate",
801
+ render: ({ files }) => html`
802
+ <button @click=${async () => {
803
+ const result = await files.writeFile("output/result.txt", "Generated content\n");
804
+ console.log("Wrote", result.path, result.size, "bytes");
805
+ }}>Generate</button>
806
+ `,
807
+ },
808
+ ]
809
+ ```
810
+
811
+ ### Binary writes
812
+
813
+ Pass a `Uint8Array` for binary content such as images:
814
+
815
+ ```js
816
+ const png = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a]);
817
+ await files.writeFile("screenshots/thumb.png", png);
818
+ ```
819
+
820
+ ### Options
821
+
822
+ `files.writeFile` accepts an optional third argument:
823
+
824
+ - `createDirs` (default `true`): create intermediate directories, like `mkdir -p`.
825
+ - `overwrite` (default `true`): overwrite existing files. Set to `false` to throw if the file already exists.
826
+
827
+ ```js
828
+ // Create only — throw if the file already exists
829
+ await files.writeFile("config/new-config.json", jsonContent, { overwrite: false });
830
+ ```
831
+
832
+ ### Deleting files
833
+
834
+ `files.deleteFile` removes a workspace file. It is idempotent: deleting a file that does not exist returns `{ existed: false }` instead of throwing.
835
+
836
+ ```js
837
+ const result = await files.deleteFile("temp/cache.json");
838
+ console.log(result.existed ? "File deleted" : "File did not exist");
839
+ ```
840
+
841
+ ### Moving files
842
+
843
+ `files.moveFile` renames or moves a file within the workspace, like `mv`. The default is safe: it will not overwrite an existing target file.
844
+
845
+ ```js
846
+ // Rename a file
847
+ await files.moveFile("old-name.txt", "new-name.txt");
848
+
849
+ // Move into a subdirectory (creates intermediate dirs by default)
850
+ await files.moveFile("file.txt", "archive/file.txt");
851
+
852
+ // Overwrite an existing target
853
+ await files.moveFile("incoming.txt", "current.txt", { overwrite: true });
854
+
855
+ // Move without creating intermediate directories
856
+ await files.moveFile("file.txt", "deep/nested/file.txt", { createDirs: false }); // throws if dirs don't exist
857
+ ```
858
+
859
+ `files.moveFile` accepts an optional third argument:
860
+
861
+ - `createDirs` (default `true`): create intermediate directories for the target path.
862
+ - `overwrite` (default `false`): overwrite the target file if it exists. The default is safer than `writeFile` because moving is a more destructive operation.
863
+
864
+ ### Error handling
865
+
866
+ All file mutations share the same safety layer:
867
+
868
+ - `overwrite: false` on `writeFile` or existing target on `moveFile` (default) throws if the file already exists.
869
+ - Path traversal (e.g., `../../etc/passwd`) is blocked by the workspace safety layer.
870
+ - Writing to or moving to a path that is a directory returns an error.
871
+ - Deleting a directory returns an error.
872
+ - Intermediate directory creation with `createDirs: false` fails if the parent directory does not exist.
873
+
874
+ After any mutation (`writeFile`, `deleteFile`, or `moveFile`), the File Explorer updates automatically. No explicit `refreshFiles()` call is needed from plugin code. For label and badge updates, call `context.host.requestRender()` if the UI should reflect the change.
875
+
876
+ ### Security
877
+
878
+ Plugins are trusted browser code. File writes go through the same path safety validation as reads — paths are resolved and checked to stay inside the workspace root.
879
+
756
880
  ## Running workspace terminal commands
757
881
 
758
882
  Workspace panels can start terminal commands through the documented `terminal` helper. Commands run in the current workspace on the panel's machine.
@@ -801,7 +925,7 @@ If you are an AI agent building or editing a PI WEB plugin, follow this checklis
801
925
  9. Add workspace panels for larger workspace UI.
802
926
  10. Add workspace labels for compact inline metadata.
803
927
  11. Return arrays from workspace label `items()`; return an empty array to render nothing.
804
- 12. Use documented context helpers first: `files`, `terminal`, `host.requestRender`, `workspace`, `machine`, `state.selectedWorkspace`, `state.selectedSession`, and `state.piWebStatus`.
928
+ 12. Use documented context helpers first: `files`, `terminal`, `host.requestRender`, `workspace`, `machine`, `state.selectedWorkspace`, `state.selectedSession`, `state.piWebStatus`, and `prompt`.
805
929
  13. Do not fetch PI WEB `/api/...` endpoints directly unless you intentionally accept private API churn; prefer documented helpers.
806
930
  14. Treat plugins as trusted code and avoid reading or displaying secrets unless intentional.
807
931
  15. After local edits, tell the user to hard reload the browser and check the console for plugin errors.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jmfederico/pi-web",
3
- "version": "1.202606.6",
3
+ "version": "1.202606.7",
4
4
  "description": "Web UI for persistent Pi Coding Agent sessions in real workspaces.",
5
5
  "license": "MIT",
6
6
  "author": "Federico Jaramillo Martinez",
@@ -1,4 +0,0 @@
1
- import{w as a,J as p,$ as h,A as m,X as g,U as f,_ as v,a0 as b}from"./vendor-editor-core-Bc1A7SO7.js";import{g as y,r as w,p as C,h as x,c as j,m as _,j as k,a as u}from"./vendor-editor-languages-D0CnB2js.js";import{d as E}from"./vendor-editor-legacy-B4QLsWF8.js";import{i as H,b as O,a as S,n as d,e as P,t as L}from"./index-C9oPLpm7.js";var D=Object.defineProperty,F=Object.getOwnPropertyDescriptor,i=(e,o,n,s)=>{for(var t=s>1?void 0:s?F(o,n):o,c=e.length-1,l;c>=0;c--)(l=e[c])&&(t=(s?l(o,n,t):l(t))||t);return s&&t&&D(o,n,t),t};let r=class extends H{constructor(){super(...arguments),this.content=""}firstUpdated(){this.recreateEditor()}updated(e){(e.has("content")||e.has("language"))&&this.recreateEditor()}disconnectedCallback(){this.view?.destroy(),this.view=void 0,super.disconnectedCallback()}render(){return O`<div class="host"></div>`}recreateEditor(){this.editorHost&&(this.view?.destroy(),this.view=new a({parent:this.editorHost,state:p.create({doc:this.content,extensions:[h(),m.of(g),f(v,{fallback:!0}),p.readOnly.of(!0),a.editable.of(!1),a.lineWrapping,M,...R(this.language)]})}))}};r.styles=S`
2
- :host { display: block; min-height: 0; height: 100%; }
3
- .host { height: 100%; min-height: 0; overflow: auto; }
4
- `;i([d()],r.prototype,"content",2);i([d()],r.prototype,"language",2);i([P(".host")],r.prototype,"editorHost",2);r=i([L("code-viewer")],r);const M=a.theme({"&":{height:"100%",color:"var(--pi-text)",backgroundColor:"var(--pi-bg)",fontSize:"12px"},".cm-scroller":{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",lineHeight:"1.45"},".cm-gutters":{backgroundColor:"var(--pi-bg)",color:"var(--pi-dim)",borderRight:"1px solid var(--pi-border-muted)"},".cm-activeLineGutter":{backgroundColor:"transparent"},".cm-activeLine":{backgroundColor:"transparent"},".cm-content":{caretColor:"transparent"},"&.cm-focused":{outline:"none"}});function R(e){if(e===void 0)return[];switch(e){case"typescript":return[u({typescript:!0})];case"javascript":return[u()];case"json":return[k()];case"markdown":return[_()];case"css":return[j()];case"html":return[x()];case"python":return[C()];case"rust":return[w()];case"go":return[y()];case"diff":return[b.define(E)];default:return[]}}export{r as CodeViewer};