@jmfederico/pi-web 1.202607.3 → 1.202608.1
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 +4 -4
- package/dist/cli.js +69 -7
- package/dist/cli.js.map +1 -1
- package/dist/client/assets/{CodeViewer-CDVbMiN9.js → CodeViewer-mEiBZFA5.js} +2 -2
- package/dist/client/assets/{TerminalPanel-CTS1CgqF.js → TerminalPanel-O9381Eme.js} +6 -6
- package/dist/client/assets/index-uI2AGFUy.js +4091 -0
- package/dist/client/index.html +1 -1
- package/dist/config.js +109 -73
- package/dist/config.js.map +1 -1
- package/dist/docker/piWebDockerCommandPlan.js +4 -3
- package/dist/docker/piWebDockerCommandPlan.js.map +1 -1
- package/dist/nativeServices/servicePlan.js +1 -1
- package/dist/nativeServices/servicePlan.js.map +1 -1
- package/dist/pi-web-plugins/git/browser/git-contract.js +108 -0
- package/dist/pi-web-plugins/git/browser/git-panel.js +609 -0
- package/dist/pi-web-plugins/git/browser/gitFileList.js +43 -0
- package/dist/pi-web-plugins/git/browser/gitFileShared.js +16 -0
- package/dist/pi-web-plugins/git/browser/gitFileTree.js +81 -0
- package/dist/pi-web-plugins/git/browser/gitFileViewPreference.js +35 -0
- package/dist/pi-web-plugins/git/browser/gitRoute.js +42 -0
- package/dist/pi-web-plugins/git/browser/pi-web-plugin.js +10 -0
- package/dist/pi-web-plugins/git/browser/unifiedDiff.js +301 -0
- package/dist/{server/git/gitService.js → pi-web-plugins/git/git-backend.js} +209 -60
- package/dist/pi-web-plugins/git/package.json +16 -0
- package/dist/pi-web-plugins/git/server-plugin.js +176 -0
- package/dist/pi-web-plugins/info/infoInternals.js +1 -2
- package/dist/pi-web-plugins/info/package.json +1 -1
- package/dist/pi-web-plugins/info/pi-web-plugin.js +2 -2
- package/dist/pi-web-plugins/relays/package.json +1 -1
- package/dist/pi-web-plugins/relays/pi-web-plugin.js +3 -3
- package/dist/pi-web-plugins/relays/relayDiscovery.js +159 -27
- package/dist/pi-web-plugins/relays/relaysPanelElement.js +173 -16
- package/dist/pi-web-plugins/updates/package.json +1 -1
- package/dist/pi-web-plugins/updates/pi-web-plugin.js +1 -1
- package/dist/pi-web-plugins/workspace-tasks/package.json +1 -1
- package/dist/pi-web-plugins/workspace-tasks/pi-web-plugin.js +3 -3
- package/dist/plugin-api.d.ts +33 -16
- package/dist/pluginRecoveryCli.js +172 -0
- package/dist/pluginRecoveryCli.js.map +1 -0
- package/dist/server/activity/workspaceActivityService.js +27 -19
- package/dist/server/activity/workspaceActivityService.js.map +1 -1
- package/dist/server/app.js +35 -37
- package/dist/server/app.js.map +1 -1
- package/dist/server/browserMessageProjection.js +0 -2
- package/dist/server/browserMessageProjection.js.map +1 -1
- package/dist/server/configRoutes.js +4 -31
- package/dist/server/configRoutes.js.map +1 -1
- package/dist/server/machines/machineClient.js +23 -4
- package/dist/server/machines/machineClient.js.map +1 -1
- package/dist/server/machines/machinePluginProxyRoutes.js +74 -17
- package/dist/server/machines/machinePluginProxyRoutes.js.map +1 -1
- package/dist/server/machines/machineProxyRoutes.js +167 -21
- package/dist/server/machines/machineProxyRoutes.js.map +1 -1
- package/dist/server/machines/machineService.js +22 -0
- package/dist/server/machines/machineService.js.map +1 -1
- package/dist/server/piWebPluginCatalog.js +584 -0
- package/dist/server/piWebPluginCatalog.js.map +1 -0
- package/dist/server/piWebPluginLifecycle.js +162 -0
- package/dist/server/piWebPluginLifecycle.js.map +1 -0
- package/dist/server/piWebPluginService.js +159 -261
- package/dist/server/piWebPluginService.js.map +1 -1
- package/dist/server/piWebStatus.js +40 -45
- package/dist/server/piWebStatus.js.map +1 -1
- package/dist/server/plugins/pluginBackendProxyRoutes.js +69 -0
- package/dist/server/plugins/pluginBackendProxyRoutes.js.map +1 -0
- package/dist/server/plugins/serverPluginExec.js +184 -0
- package/dist/server/plugins/serverPluginExec.js.map +1 -0
- package/dist/server/plugins/serverPluginRuntime.js +480 -0
- package/dist/server/plugins/serverPluginRuntime.js.map +1 -0
- package/dist/server/realtime/sessionEventHub.js +26 -11
- package/dist/server/realtime/sessionEventHub.js.map +1 -1
- package/dist/server/requestCancellation.js +32 -0
- package/dist/server/requestCancellation.js.map +1 -0
- package/dist/server/sessiond/agentHttpDispatcher.js +108 -0
- package/dist/server/sessiond/agentHttpDispatcher.js.map +1 -0
- package/dist/server/sessiond/agentProcessEnvironment.js +61 -0
- package/dist/server/sessiond/agentProcessEnvironment.js.map +1 -0
- package/dist/server/sessiond/pluginBackendRoutes.js +64 -0
- package/dist/server/sessiond/pluginBackendRoutes.js.map +1 -0
- package/dist/server/sessiond/sessionDaemonShutdown.js +24 -0
- package/dist/server/sessiond/sessionDaemonShutdown.js.map +1 -0
- package/dist/server/sessiond/sessionProxyRoutes.js +2 -2
- package/dist/server/sessiond/sessionProxyRoutes.js.map +1 -1
- package/dist/server/sessiond/sessionServiceDependencies.js +3 -1
- package/dist/server/sessiond/sessionServiceDependencies.js.map +1 -1
- package/dist/server/sessiond/sessiondStateOwnership.js +235 -0
- package/dist/server/sessiond/sessiondStateOwnership.js.map +1 -0
- package/dist/server/sessiond/workspaceCatalogRoutes.js +31 -0
- package/dist/server/sessiond/workspaceCatalogRoutes.js.map +1 -0
- package/dist/server/sessiond/workspaceRemovalRoutes.js +41 -0
- package/dist/server/sessiond/workspaceRemovalRoutes.js.map +1 -0
- package/dist/server/sessiond.js +283 -96
- package/dist/server/sessiond.js.map +1 -1
- package/dist/server/sessions/askUserTool.js +0 -3
- package/dist/server/sessions/askUserTool.js.map +1 -1
- package/dist/server/sessions/authRoutes.js +0 -10
- package/dist/server/sessions/authRoutes.js.map +1 -1
- package/dist/server/sessions/authService.js +15 -78
- package/dist/server/sessions/authService.js.map +1 -1
- package/dist/server/sessions/dockerEnvironmentFacts.js +254 -0
- package/dist/server/sessions/dockerEnvironmentFacts.js.map +1 -0
- package/dist/server/sessions/messagePaging.js +2 -2
- package/dist/server/sessions/messagePaging.js.map +1 -1
- package/dist/server/sessions/modelCatalogRefresher.js +4 -3
- package/dist/server/sessions/modelCatalogRefresher.js.map +1 -1
- package/dist/server/sessions/oauthLoginFlowService.js +2 -5
- package/dist/server/sessions/oauthLoginFlowService.js.map +1 -1
- package/dist/server/sessions/pendingAskStore.js +0 -3
- package/dist/server/sessions/pendingAskStore.js.map +1 -1
- package/dist/server/sessions/piSessionManagerGateway.js +134 -3
- package/dist/server/sessions/piSessionManagerGateway.js.map +1 -1
- package/dist/server/sessions/piSessionService.js +318 -253
- package/dist/server/sessions/piSessionService.js.map +1 -1
- package/dist/server/sessions/sessionCommandService.js +24 -1
- package/dist/server/sessions/sessionCommandService.js.map +1 -1
- package/dist/server/sessions/sessionEnvironmentFacts.js +48 -0
- package/dist/server/sessions/sessionEnvironmentFacts.js.map +1 -0
- package/dist/server/sessions/sessionFileFormat.js +27 -0
- package/dist/server/sessions/sessionFileFormat.js.map +1 -0
- package/dist/server/sessions/sessionFileHeader.js +82 -23
- package/dist/server/sessions/sessionFileHeader.js.map +1 -1
- package/dist/server/sessions/sessionRoutes.js +88 -56
- package/dist/server/sessions/sessionRoutes.js.map +1 -1
- package/dist/server/sessions/sessionSummaryScanner.js +491 -0
- package/dist/server/sessions/sessionSummaryScanner.js.map +1 -0
- package/dist/server/sessions/spawnSessionTool.js +8 -1
- package/dist/server/sessions/spawnSessionTool.js.map +1 -1
- package/dist/server/sessions/spawnSubsessionTool.js +11 -9
- package/dist/server/sessions/spawnSubsessionTool.js.map +1 -1
- package/dist/server/sessions/spawnTargetResolver.js +1 -1
- package/dist/server/status/machineStatusRoutes.js +8 -0
- package/dist/server/status/machineStatusRoutes.js.map +1 -0
- package/dist/server/status/machineStatusService.js +181 -0
- package/dist/server/status/machineStatusService.js.map +1 -0
- package/dist/server/status/workspaceAttribution.js +87 -0
- package/dist/server/status/workspaceAttribution.js.map +1 -0
- package/dist/server/terminalProxyRoutes.js +2 -1
- package/dist/server/terminalProxyRoutes.js.map +1 -1
- package/dist/server/workspaceExplorerRoutes.js +20 -13
- package/dist/server/workspaceExplorerRoutes.js.map +1 -1
- package/dist/server/workspaces/effectivePathAccess.js +0 -19
- package/dist/server/workspaces/effectivePathAccess.js.map +1 -1
- package/dist/server/workspaces/fileContentService.js +18 -9
- package/dist/server/workspaces/fileContentService.js.map +1 -1
- package/dist/server/workspaces/filePreviewResponseHeaders.js +18 -0
- package/dist/server/workspaces/filePreviewResponseHeaders.js.map +1 -0
- package/dist/server/workspaces/filePreviewResponsePolicy.js +55 -0
- package/dist/server/workspaces/filePreviewResponsePolicy.js.map +1 -0
- package/dist/server/workspaces/filePreviewService.js +81 -0
- package/dist/server/workspaces/filePreviewService.js.map +1 -0
- package/dist/server/workspaces/projectWorkspaceCwds.js +0 -5
- package/dist/server/workspaces/projectWorkspaceCwds.js.map +1 -1
- package/dist/server/workspaces/sessionDaemonWorkspaceCatalog.js +402 -0
- package/dist/server/workspaces/sessionDaemonWorkspaceCatalog.js.map +1 -0
- package/dist/server/workspaces/workspaceCatalog.js +47 -0
- package/dist/server/workspaces/workspaceCatalog.js.map +1 -0
- package/dist/server/workspaces/workspaceContext.js +1 -3
- package/dist/server/workspaces/workspaceContext.js.map +1 -1
- package/dist/server/workspaces/workspaceDeletionRoutes.js +39 -103
- package/dist/server/workspaces/workspaceDeletionRoutes.js.map +1 -1
- package/dist/server/workspaces/workspaceProviderRegistry.js +651 -0
- package/dist/server/workspaces/workspaceProviderRegistry.js.map +1 -0
- package/dist/server/workspaces/workspaceRemovalService.js +256 -0
- package/dist/server/workspaces/workspaceRemovalService.js.map +1 -0
- package/dist/server/workspaces/workspaceRouteErrors.js +7 -0
- package/dist/server/workspaces/workspaceRouteErrors.js.map +1 -0
- package/dist/server/workspaces/worktreePreRemoveHook.js +39 -0
- package/dist/server/workspaces/worktreePreRemoveHook.js.map +1 -0
- package/dist/server-plugin-api.d.ts +140 -0
- package/dist/server-plugin-api.js +2 -0
- package/dist/server-plugin-api.js.map +1 -0
- package/dist/serverPluginRecovery.js +138 -0
- package/dist/serverPluginRecovery.js.map +1 -0
- package/dist/sessiond/activeAgentProfile.js +3 -22
- package/dist/sessiond/activeAgentProfile.js.map +1 -1
- package/dist/sessiond/config.js +13 -2
- package/dist/sessiond/config.js.map +1 -1
- package/dist/sessiond/sessionDaemonClient.js +11 -9
- package/dist/sessiond/sessionDaemonClient.js.map +1 -1
- package/dist/shared/activeAgentProfile.js +2 -41
- package/dist/shared/activeAgentProfile.js.map +1 -1
- package/dist/shared/activity.js +0 -3
- package/dist/shared/activity.js.map +1 -1
- package/dist/shared/apiTypes.js +7 -14
- package/dist/shared/apiTypes.js.map +1 -1
- package/dist/shared/capabilities.js +8 -40
- package/dist/shared/capabilities.js.map +1 -1
- package/dist/shared/federatedRoutes.js +28 -8
- package/dist/shared/federatedRoutes.js.map +1 -1
- package/dist/shared/machinePluginIds.js +4 -2
- package/dist/shared/machinePluginIds.js.map +1 -1
- package/dist/shared/machineStatus.js +94 -0
- package/dist/shared/machineStatus.js.map +1 -0
- package/dist/shared/piWebStatusParsing.js +29 -0
- package/dist/shared/piWebStatusParsing.js.map +1 -1
- package/dist/shared/pluginApiTypes.d.ts +148 -0
- package/dist/shared/pluginApiTypes.js +3 -0
- package/dist/shared/pluginApiTypes.js.map +1 -0
- package/dist/shared/pluginBackendProtocol.js +110 -0
- package/dist/shared/pluginBackendProtocol.js.map +1 -0
- package/dist/shared/pluginIds.js +5 -0
- package/dist/shared/pluginIds.js.map +1 -1
- package/dist/shared/pluginRecoveryCommands.js +14 -0
- package/dist/shared/pluginRecoveryCommands.js.map +1 -0
- package/dist/shared/workspaceFiles.js +41 -2
- package/dist/shared/workspaceFiles.js.map +1 -1
- package/dist/shared/workspaceRemovalProtocol.js +24 -0
- package/dist/shared/workspaceRemovalProtocol.js.map +1 -0
- package/docs/config.md +140 -47
- package/docs/plugins.md +386 -137
- package/examples/workspace-provider-plugin/README.md +52 -0
- package/examples/workspace-provider-plugin/package.json +25 -0
- package/examples/workspace-provider-plugin/src/browser/index.ts +69 -0
- package/examples/workspace-provider-plugin/src/server.ts +64 -0
- package/examples/workspace-provider-plugin/tsconfig.json +21 -0
- package/package.json +32 -12
- package/server-plugin-api.d.ts +1 -0
- package/dist/client/assets/UnifiedDiffViewer-Cqke12ZX.js +0 -39
- package/dist/client/assets/index-LME0LfPb.js +0 -4068
- package/dist/plugin-api/unstable.d.ts +0 -22
- package/dist/server/activity/workspaceActivityRoutes.js +0 -4
- package/dist/server/activity/workspaceActivityRoutes.js.map +0 -1
- package/dist/server/git/gitService.js.map +0 -1
- package/dist/server/gitRoutes.js +0 -23
- package/dist/server/gitRoutes.js.map +0 -1
- package/dist/server/sessions/parentSessionLocator.js +0 -75
- package/dist/server/sessions/parentSessionLocator.js.map +0 -1
- package/dist/server/workspaces/gitWorktreeDiscovery.js +0 -43
- package/dist/server/workspaces/gitWorktreeDiscovery.js.map +0 -1
- package/dist/server/workspaces/imagePreviewService.js +0 -40
- package/dist/server/workspaces/imagePreviewService.js.map +0 -1
- package/dist/server/workspaces/workspaceService.js +0 -52
- package/dist/server/workspaces/workspaceService.js.map +0 -1
- package/dist/shared/apiTypes.d.ts +0 -1234
- package/dist/shared/thinkingLevels.d.ts +0 -27
- package/plugin-api/unstable.d.ts +0 -1
package/docs/plugins.md
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
# PI WEB plugin API
|
|
2
2
|
|
|
3
|
-
PI WEB plugins are trusted browser
|
|
3
|
+
PI WEB plugins are trusted packages that can extend the browser UI, provide workspace semantics in the session daemon, or pair both entries. They are intended for personal, team, and project-local customization, and simple enough for an LLM to create or modify directly.
|
|
4
4
|
|
|
5
5
|
Plugins can currently:
|
|
6
6
|
|
|
7
7
|
- add action-palette commands;
|
|
8
|
-
- add workspace tools/panels next to Files
|
|
8
|
+
- add workspace tools/panels next to Files and Terminal;
|
|
9
9
|
- add compact workspace-label items in the workspace list, panel header, and status bar;
|
|
10
10
|
- call browser APIs and documented PI WEB plugin context helpers;
|
|
11
11
|
- read workspace files and start workspace terminal commands through documented helpers;
|
|
12
|
-
- serve
|
|
12
|
+
- serve browser-public files from an explicitly declared `browserRoot`;
|
|
13
|
+
- contribute one server-side workspace provider, with optional JSON backend requests and workspace-removal planning.
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
Browser entries run in the PI WEB page through browser plugin API v2. Declared server entries run in the session daemon through the separate server-plugin API v1. Plugins do not get raw Fastify access, arbitrary routes, concrete core services, a generic event bus, Pi model-provider registration, or a general server-hook API. Neither entry is sandboxed.
|
|
15
16
|
|
|
16
17
|
## Pi packages, Pi extensions, and PI WEB plugins
|
|
17
18
|
|
|
18
|
-
**Pi packages** are distribution bundles managed by Pi (`pi install`, `pi remove`, `pi update`). A Pi package can provide Pi extensions, skills, prompt templates, themes, context/system prompt files, and/or PI WEB
|
|
19
|
+
**Pi packages** are distribution bundles managed by Pi (`pi install`, `pi remove`, `pi update`). A Pi package can provide Pi extensions, skills, prompt templates, themes, context/system prompt files, and/or PI WEB plugins. Many Pi packages do not include a PI WEB plugin.
|
|
19
20
|
|
|
20
|
-
**Pi extensions** are runtime modules loaded by the session daemon. They can register Pi tools, hooks, commands, and model providers. They are not PI WEB plugins.
|
|
21
|
+
**Pi extensions** are runtime modules loaded by the session daemon. They can register Pi tools, hooks, commands, and model providers. They are not PI WEB plugins and use a different API and lifecycle.
|
|
21
22
|
|
|
22
|
-
**PI WEB plugins** are
|
|
23
|
+
**PI WEB plugins** are packages discovered from bundled, local, dev, and installed Pi-package sources. A plugin can declare a browser `module`, a sessiond `serverModule`, or both. A server entry can participate only in the documented PI WEB plugin lifecycle and workspace-provider contract; it cannot register Pi model providers or arbitrary hooks.
|
|
23
24
|
|
|
24
25
|
Use **Settings → Pi packages** to view configured Pi packages or install/remove/update a package. Enter only the package source, such as `npm:@scope/package`, a git/URL source, or a local path. PI WEB uses Pi's default package location, equivalent to `pi install <source>`, and does not ask for an install location.
|
|
25
26
|
|
|
26
|
-
When machine federation is enabled, **Settings → Pi packages** targets the currently selected machine. The panel labels whether changes will run on the local/gateway machine or on a selected remote PI WEB machine.
|
|
27
|
+
When machine federation is enabled, **Settings → Pi packages** targets the currently selected machine. The panel labels whether changes will run on the local/gateway machine or on a selected remote PI WEB machine.
|
|
27
28
|
|
|
28
|
-
Use **Settings → PI WEB plugins** to
|
|
29
|
+
Use **Settings → PI WEB plugins** to edit the desired enablement of discovered plugins on the selected machine. Browser-only changes apply after a page reload. A server-backed change also requires a session-daemon restart before its paired browser module can load against the new active revision. If an older or unavailable remote PI WEB server does not support the versioned plugin lifecycle, PI WEB reports plugin settings as unsupported or unavailable instead of silently falling back to the gateway.
|
|
29
30
|
|
|
30
|
-
After installing, removing, or updating a Pi package, type `/reload` in each idle PI WEB session on the target machine to refresh ordinary Pi resources such as extensions, skills, prompt templates, themes, and context/system prompt files.
|
|
31
|
+
After installing, removing, or updating a Pi package, type `/reload` in each idle PI WEB session on the target machine to refresh ordinary Pi resources such as extensions, skills, prompt templates, themes, and context/system prompt files. For PI WEB plugins, manually restart the target session daemon when the package has a server entry, then reload the browser page. A provider-registering Pi extension follows a separate daemon-start policy; see [Pi extension provider baseline](https://pi-web.dev/config#pi-extension-provider-baseline).
|
|
31
32
|
|
|
32
33
|
## Pi extension dialogs in PI WEB
|
|
33
34
|
|
|
@@ -45,14 +46,27 @@ One browser-local caveat: reloading the browser while a new session is still bei
|
|
|
45
46
|
|
|
46
47
|
## Trust model
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
Treat every plugin package as trusted code:
|
|
49
50
|
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
51
|
+
- browser entries can call browser APIs, read workspace files, start terminal commands through helpers, and render arbitrary UI;
|
|
52
|
+
- server entries execute in-process inside sessiond with the PI WEB service user's filesystem, environment, and process permissions, and they share sessiond's event loop;
|
|
53
|
+
- a CPU-bound, blocking, or deadlocked callback can stall sessions, terminals, and health endpoints; abort/deadline signals bound only cooperative asynchronous code and cannot preempt code that ignores them;
|
|
54
|
+
- ordinary import, activation, start, health, and stop failures are attributed and quarantined where the host can catch them, but this is a stability boundary rather than a security boundary;
|
|
55
|
+
- plugins should not be installed from untrusted sources.
|
|
54
56
|
|
|
55
|
-
PI WEB's `/api/...` HTTP and WebSocket endpoints are internal implementation details.
|
|
57
|
+
PI WEB's `/api/...` HTTP and WebSocket endpoints are internal implementation details. Browser code should use documented context helpers, including `context.backend.request()` for a paired server entry. Server code should use only `@jmfederico/pi-web/server-plugin-api`. Private routes, runtime objects, and source-internal imports are experimental and may change or disappear.
|
|
58
|
+
|
|
59
|
+
## Workspace providers and replacement ownership
|
|
60
|
+
|
|
61
|
+
Sessiond is the single authority for project workspace discovery and spawned-session target validation. One active plugin exclusively owns a project's workspace semantics:
|
|
62
|
+
|
|
63
|
+
1. Healthy or degraded primary providers probe first.
|
|
64
|
+
2. If exactly one primary returns `"claim"`, it owns the project.
|
|
65
|
+
3. If no primary claims, fallback providers probe. Bundled Git is a fallback provider.
|
|
66
|
+
4. Multiple claimants in the winning tier produce a visible conflict; PI WEB does not select by plugin id or import order.
|
|
67
|
+
5. If no provider claims, PI WEB exposes the project folder as the kernel workspace. If a winner claims and then fails to list, PI WEB reports degraded state instead of silently switching owners.
|
|
68
|
+
|
|
69
|
+
PI WEB ships only the bundled Git production provider. Replacement integrations, including Jujutsu providers, are owned and distributed by third parties. An installed and enabled primary provider can claim its projects and suppress fallback Git without any PI WEB core changes; this documentation does not promise or ship a reference replacement.
|
|
56
70
|
|
|
57
71
|
## What to ask AI to build
|
|
58
72
|
|
|
@@ -89,7 +103,7 @@ Before coding, read the PI WEB plugin docs:
|
|
|
89
103
|
https://pi-web.dev/plugins
|
|
90
104
|
Full API reference:
|
|
91
105
|
https://pi-web.dev/plugins.md
|
|
92
|
-
Keep the
|
|
106
|
+
Keep the browser entry on API v2 and any server entry on API v1.
|
|
93
107
|
After editing, check the manifest endpoint and browser-console failure cases.
|
|
94
108
|
```
|
|
95
109
|
|
|
@@ -123,7 +137,7 @@ Package metadata:
|
|
|
123
137
|
"private": true,
|
|
124
138
|
"piWeb": {
|
|
125
139
|
"plugins": [
|
|
126
|
-
{ "id": "info", "module": "pi-web-plugin.js" }
|
|
140
|
+
{ "id": "info", "browserRoot": ".", "module": "pi-web-plugin.js" }
|
|
127
141
|
]
|
|
128
142
|
}
|
|
129
143
|
}
|
|
@@ -133,7 +147,7 @@ Module shape excerpt:
|
|
|
133
147
|
|
|
134
148
|
```js
|
|
135
149
|
export default {
|
|
136
|
-
apiVersion:
|
|
150
|
+
apiVersion: 2,
|
|
137
151
|
name: "Info Plugin",
|
|
138
152
|
activate: ({ html, svg }) => ({
|
|
139
153
|
contributions: {
|
|
@@ -151,9 +165,38 @@ The Info panel doubles as an always-available PI WEB status view: it renders the
|
|
|
151
165
|
|
|
152
166
|
PI WEB also ships an `updates` plugin that demonstrates dynamic `visible` and `badge` callbacks for tabs that only appear when the host has status messages or needs extra install visibility.
|
|
153
167
|
|
|
168
|
+
## Canonical dual-entry provider: bundled Git
|
|
169
|
+
|
|
170
|
+
The bundled `git` plugin is the production example for a paired browser module and workspace-provider server module. Both entries use the same public contracts available to an installed plugin:
|
|
171
|
+
|
|
172
|
+
```text
|
|
173
|
+
pi-web-plugins/git/package.json
|
|
174
|
+
pi-web-plugins/git/browser/pi-web-plugin.ts
|
|
175
|
+
pi-web-plugins/git/server-plugin.ts
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Its built `.js` server entry is a Node ES module, so its package declares `"type": "module"`. Do the same for an installed provider whose `serverModule` ends in `.js`, or emit `.mjs`; do not rely on Node's typeless-module reparsing.
|
|
179
|
+
|
|
180
|
+
Its TypeScript entries import declarations only from the published package subpaths:
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
import type { PiWebPlugin } from "@jmfederico/pi-web/plugin-api";
|
|
184
|
+
import type { PiWebServerPlugin, WorkspaceProvider } from "@jmfederico/pi-web/server-plugin-api";
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Git declares `machineSpecific: true`, contributes a fallback workspace provider, and implements its status/diff backend and removal plan through the public provider callbacks. It receives no raw routes or private PI WEB services. Use it to understand the demonstrated contract, not as a template for Git-specific fields: replacement providers define their own private data, public metadata, backend operations, and removal wording.
|
|
188
|
+
|
|
189
|
+
## Copyable standalone workspace-provider example
|
|
190
|
+
|
|
191
|
+
The repository and published npm package include [`examples/workspace-provider-plugin/`](https://github.com/jmfederico/pi-web/tree/main/examples/workspace-provider-plugin), a small standalone package you can copy without PI WEB source imports. It includes package metadata, a strict NodeNext TypeScript configuration, browser and server source, and build/install instructions.
|
|
192
|
+
|
|
193
|
+
The example uses browser API v2 and server API v1. Its browser entry compares `workspace.provider.pluginId` with the stable source `pluginId`, uses `runtimePluginId` only to open its qualified panel, displays non-secret `publicMetadata`, and calls the backend owned by the selected workspace. Its server provider conservatively claims only projects containing `.pi-web/example-workspace-provider`. The explicit `browserRoot: "dist/browser"` keeps `dist/server.js`, source, package metadata, and dependencies outside browser asset routes.
|
|
194
|
+
|
|
195
|
+
Copy the example from a checkout or from `node_modules/@jmfederico/pi-web/examples/workspace-provider-plugin`, then follow its README. It deliberately does not advertise removal; use the removal contract below when adding that capability.
|
|
196
|
+
|
|
154
197
|
## Local plugin usage
|
|
155
198
|
|
|
156
|
-
This works with the production native-service install. PI WEB discovers
|
|
199
|
+
This works with the production native-service install. PI WEB discovers packages from `~/.pi-web/plugins/<plugin-package>/`; if `PI_WEB_DATA_DIR` is set, use `$PI_WEB_DATA_DIR/plugins` instead. No PI WEB rebuild is required.
|
|
157
200
|
|
|
158
201
|
Symlink a plugin folder into PI WEB's local plugin directory:
|
|
159
202
|
|
|
@@ -162,46 +205,50 @@ mkdir -p ~/.pi-web/plugins
|
|
|
162
205
|
ln -s /path/to/plugin-folder ~/.pi-web/plugins/plugin-id
|
|
163
206
|
```
|
|
164
207
|
|
|
165
|
-
|
|
208
|
+
For a browser-only package, reload the PI WEB tab after installing or editing it. PI WEB uses a package-content revision in the module URL; hard reload if an already-open page still holds old JavaScript. For a package with `serverModule`, restart sessiond to activate the startup snapshot, then reload the browser. Editing files alone never hot-reloads or unloads server code.
|
|
166
209
|
|
|
167
210
|
## Remote machine plugins
|
|
168
211
|
|
|
169
|
-
When [machine federation](https://pi-web.dev/machines) is enabled, PI WEB
|
|
212
|
+
When [machine federation](https://pi-web.dev/machines) is enabled, PI WEB loads the selected remote machine's compatible browser plugins through the gateway and runs its server entries in that remote machine's session daemon. Contributions and helpers are machine-scoped:
|
|
213
|
+
|
|
214
|
+
- actions, workspace panels, and workspace labels appear only for the applicable selected machine;
|
|
215
|
+
- file and terminal helpers run against that machine;
|
|
216
|
+
- `context.backend.request()` is routed through the gateway to the current workspace owner on that machine;
|
|
217
|
+
- a server-backed browser module is published only when its package source, scope, settings fingerprint, browser revision, and backend revision match the active sessiond snapshot and the backend is not unhealthy;
|
|
218
|
+
- if gateway and remote packages share an original id, `machineSpecific` controls whether the portable gateway copy is reused or the selected machine's own copy is required;
|
|
219
|
+
- remote theme contributions are ignored for now because themes are app-wide.
|
|
170
220
|
|
|
171
|
-
|
|
172
|
-
- plugin file and terminal helpers run against that machine;
|
|
173
|
-
- plugin code is loaded best-effort through the current gateway and cached for the browser page lifetime;
|
|
174
|
-
- 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;
|
|
175
|
-
- remote theme contributions are ignored for now because themes are app-wide;
|
|
176
|
-
- mixed PI WEB versions across federated machines are best-effort and not guaranteed compatible.
|
|
221
|
+
The remote manifest and backend bridge use a versioned lifecycle contract. A future/unsupported lifecycle version, a missing backend route, or a mismatched frontend/backend revision produces an explicit compatibility error; PI WEB does not silently run an unpaired server-backed UI.
|
|
177
222
|
|
|
178
|
-
|
|
223
|
+
Plugin/provider compatibility is intentionally all-or-nothing during a mixed-version fleet rollout. A newer gateway rejects an older target's whole remote plugin manifest when the target lacks the current lifecycle contract, so even that target's browser-only plugin contributions and Git panel are unavailable. In the other upgrade order, an older gateway still calls the legacy core Git routes removed by an updated target, so remote Git status/diff requests return `404`. Upgrade the gateway and target together, restart their updated web/API processes and the target session daemon, then reload the gateway tab. Other machine features remain subject to their own capability negotiation.
|
|
224
|
+
|
|
225
|
+
Remote desired enablement is stored in the remote machine's PI WEB config. Select that machine in **Settings → PI WEB plugins** to edit it, or open the machine directly/edit its config. Browser-only changes need a page reload. Server-backed changes need a restart of that remote session daemon followed by a page reload.
|
|
179
226
|
|
|
180
227
|
Plugin package metadata may set `machineSpecific: true` when the plugin's meaning is tied to the selected PI WEB machine:
|
|
181
228
|
|
|
182
|
-
- Omitted or `false`: use the gateway copy when the same
|
|
183
|
-
- `true`: the gateway copy only
|
|
229
|
+
- Omitted or `false`: valid for browser-only plugins; use the gateway copy when the same id is present remotely.
|
|
230
|
+
- `true`: the gateway copy appears only for the local machine, and a selected remote machine uses only its own copy. Dual browser/server entries are always machine-specific; omitting the field defaults them to `true`, while explicitly setting `false` is invalid.
|
|
184
231
|
|
|
185
|
-
For portable plugin assets, prefer URLs relative to the plugin module
|
|
232
|
+
For portable plugin assets, prefer URLs relative to the plugin module:
|
|
186
233
|
|
|
187
234
|
```js
|
|
188
235
|
const url = new URL("./asset.json", import.meta.url);
|
|
189
236
|
```
|
|
190
237
|
|
|
191
|
-
|
|
238
|
+
In browser API v2, activation `pluginId` is always the stable package/source id, locally and through federation. Compare it directly with `workspace.provider.pluginId` for ownership. `runtimePluginId` is the separately named host-unique id for qualified contribution references such as `${runtimePluginId}:workspace.panel`; a remote host may machine-scope it.
|
|
192
239
|
|
|
193
|
-
|
|
240
|
+
Do not construct absolute plugin asset routes from either identity. Module-relative URLs keep the host-selected runtime scope and deployment base automatically; hard-coded `/pi-web-plugins/...` paths can point at the wrong machine or break nested deployments.
|
|
194
241
|
|
|
195
|
-
|
|
242
|
+
## Manage PI WEB plugins
|
|
196
243
|
|
|
197
|
-
|
|
244
|
+
Open **Settings → PI WEB plugins** to compare desired package/config state with the active sessiond startup snapshot on the selected machine. The list includes bundled, local, dev, and Pi-package-supplied plugins, disabled discovered entries, and entries known only to the still-active snapshot. It reports browser-only, active, failed, incompatible, disabled, not-active, unknown, conflict, stale-revision, health, safe-mode, and restart-required states. Settings and diagnostics expose fingerprints and revisions, not plugin setting values.
|
|
198
245
|
|
|
199
|
-
Plugin
|
|
246
|
+
Plugin enablement is separate from package installation. Use **Settings → Pi packages** to install, remove, or update a Pi package. The PI WEB plugin panel writes the selected machine's top-level `plugins` config key. It remains possible to edit desired config while sessiond is unavailable, although active state cannot then be verified.
|
|
200
247
|
|
|
201
248
|
```json
|
|
202
249
|
{
|
|
203
250
|
"plugins": {
|
|
204
|
-
"
|
|
251
|
+
"git": {
|
|
205
252
|
"enabled": true,
|
|
206
253
|
"settings": {}
|
|
207
254
|
},
|
|
@@ -212,16 +259,56 @@ Plugin preferences are stored under the top-level `plugins` config key in the PI
|
|
|
212
259
|
}
|
|
213
260
|
```
|
|
214
261
|
|
|
215
|
-
Plugins are enabled by default.
|
|
262
|
+
Plugins are enabled by default. `plugins.<id>.enabled: false` removes a browser-only entry on the next page load and prevents a server entry from loading on the next sessiond start. The optional `settings` object must be JSON-compatible and is captured for a server entry only at sessiond startup.
|
|
263
|
+
|
|
264
|
+
### Desired versus active state
|
|
265
|
+
|
|
266
|
+
Sessiond resolves one immutable enabled server-plugin snapshot at startup and remains the workspace authority for its lifetime. Saving config or replacing package files changes **desired** state only. The existing backend can remain active until sessiond restarts; conversely, its paired browser module is withheld when active and desired revisions no longer match. A web/API restart or browser reload does not change sessiond's active provider registry.
|
|
267
|
+
|
|
268
|
+
Use this sequence:
|
|
269
|
+
|
|
270
|
+
1. Install or update the package on the target machine.
|
|
271
|
+
2. Set the desired plugin enablement/settings.
|
|
272
|
+
3. For a browser-only plugin, reload the browser tab.
|
|
273
|
+
4. For a server-backed plugin, manually restart sessiond, wait for it to become available, then reload the browser tab.
|
|
216
274
|
|
|
217
|
-
|
|
275
|
+
> **Manual session-daemon restart:** for the native systemd user service, run `systemctl --user restart pi-web-sessiond` (the unit is `pi-web-sessiond.service`). Restarting sessiond may interrupt active sessions and runtime ownership. Web/UI autoreload, restarting only the web/API service, browser reload, and Pi's `/reload` command do not activate server-plugin changes.
|
|
276
|
+
|
|
277
|
+
### Offline disable and safe start
|
|
278
|
+
|
|
279
|
+
Recovery commands edit global PI WEB config without contacting sessiond, discovering packages, or importing plugin code. Run them on the affected target machine. Add `--config /path/to/config.json` when its services use a non-default `PI_WEB_CONFIG`.
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
pi-web plugins disable <plugin-id> --restart
|
|
283
|
+
pi-web plugins safe-start show
|
|
284
|
+
pi-web plugins safe-start set bundled-only --restart
|
|
285
|
+
pi-web plugins safe-start set none --restart
|
|
286
|
+
pi-web plugins safe-start clear --restart
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
- `disable` sets that plugin's desired `enabled` value to `false` while preserving unrelated config.
|
|
290
|
+
- `bundled-only` persists safe start and filters discovery before external local or Pi-package server modules are considered.
|
|
291
|
+
- `none` persists the emergency level and imports no server plugins; the kernel folder workspace remains available.
|
|
292
|
+
- `clear` returns the next startup to ordinary configured discovery.
|
|
293
|
+
- `--restart` requests an automatic restart only when PI WEB recognizes a safe installed-service action. Otherwise the command prints manual guidance.
|
|
294
|
+
|
|
295
|
+
An unsupported `serverPlugins.safeStart` shape or value in otherwise valid JSON fails closed as effective `none`: sessiond imports no server plugins and reports a diagnostic. Use `safe-start show`, then `set` or `clear`, to repair it offline. Recovery config is written before an automatic restart is attempted; if that service-manager command fails, restart sessiond manually.
|
|
296
|
+
|
|
297
|
+
Ordinary plugin failures are normally quarantined, but safe start provides a recovery path for code that blocks or terminates sessiond before normal containment can help. Any restart can interrupt active sessions/runtime ownership; inspect active work before using `--restart` or running the manual service command.
|
|
218
298
|
|
|
219
299
|
## Built-in plugins
|
|
220
300
|
|
|
221
|
-
PI WEB ships core, discoverable plugins in the main `@jmfederico/pi-web` npm package. No separate `pi install` step is required
|
|
301
|
+
PI WEB ships core, discoverable plugins in the main `@jmfederico/pi-web` npm package. No separate `pi install` step is required. After updating PI WEB, manually restart sessiond so bundled server entries use the installed revision, then reload the browser tab. Browser-only bundled entries need only the tab reload.
|
|
222
302
|
|
|
223
303
|
Built-in plugins can be managed from **Settings → PI WEB plugins** or with the top-level `plugins` config key.
|
|
224
304
|
|
|
305
|
+
### Git
|
|
306
|
+
|
|
307
|
+
**Plugin id:** `git`
|
|
308
|
+
**What it does:** claims Git projects as a fallback workspace provider, discovers worktrees, supplies provider-owned removal plans, and adds the Git status/diff workspace panel through its paired backend.
|
|
309
|
+
|
|
310
|
+
Git is enabled by default and is the only production workspace provider bundled with PI WEB. An enabled primary third-party provider can claim a project before Git. Disabling `git` and restarting sessiond leaves the kernel project-folder workspace available; reload the browser afterward so Git contributions disappear. The generic Files, Terminal, and Session features continue to work in that folder workspace.
|
|
311
|
+
|
|
225
312
|
### Updates
|
|
226
313
|
|
|
227
314
|
**Plugin id:** `updates`
|
|
@@ -301,6 +388,8 @@ Review task configs before running them, especially in shared projects. Workspac
|
|
|
301
388
|
|
|
302
389
|
A relay is a directory of markdown notes under `.pi-web/relays/<name>/` in the workspace root — the convention used by the Relay method for chaining agent sessions. The tab lists each relay's documents with `status.md`, `charter.md`, and `log.md` first (in that order), followed by any other files alphabetically, and opens `status.md` by default. Markdown documents render as sanitized HTML; other files render as preformatted text, and binary files have no preview. Truncated documents show a notice, and **Refresh** re-scans the workspace and reloads the open document.
|
|
303
390
|
|
|
391
|
+
Documents in subfolders are listed too. Folders appear as chips in the document strip, and expanding one inserts its files inline right after it — accordion-style, so expanding a folder collapses its siblings on the same level. An expanded folder wraps its chip and documents in a group bubble, so nested entries stay visually contained. Collapsing the folder that holds the open document keeps the selection and highlights the folder instead. Relay trees deeper than five levels, larger than 200 documents, or with more than 50 folders are listed partially, with a notice.
|
|
392
|
+
|
|
304
393
|
With several relays, a picker pre-selects the most recently modified one; a single relay opens directly. A workspace without `.pi-web/relays/` shows an empty state explaining the convention. The tab never creates, edits, or deletes relay files.
|
|
305
394
|
|
|
306
395
|
Relays is enabled by default. To hide it, disable `relays` in **Settings → PI WEB plugins** or set:
|
|
@@ -315,7 +404,7 @@ Relays is enabled by default. To hide it, disable `relays` in **Settings → PI
|
|
|
315
404
|
|
|
316
405
|
## Discovery and packaging
|
|
317
406
|
|
|
318
|
-
|
|
407
|
+
The web/API catalog and sessiond startup catalog use the same package sources. The browser manifest includes only compatible entries that declare `module`; sessiond considers enabled entries that declare `serverModule`:
|
|
319
408
|
|
|
320
409
|
1. Bundled plugins in the PI WEB package:
|
|
321
410
|
|
|
@@ -333,7 +422,7 @@ PI WEB builds the gateway `/pi-web-plugins/manifest.json` from these sources:
|
|
|
333
422
|
|
|
334
423
|
3. Installed Pi packages that expose PI WEB plugin metadata. Pi packages may be user or project scoped. Installing/removing/updating Pi packages is done from **Settings → Pi packages** (or Pi's package manager), not from the PI WEB plugin enable/disable list.
|
|
335
424
|
|
|
336
|
-
Remote machines expose their
|
|
425
|
+
Remote machines expose their versioned browser manifests through the gateway at `/api/machines/<machine-id>/pi-web-plugins/manifest.json`. Those plugin modules are rewritten to gateway-scoped asset URLs and registered under machine-scoped runtime ids so package copies on different machines do not collide.
|
|
337
426
|
|
|
338
427
|
Plugin package directory names and plugin ids must be valid identifiers:
|
|
339
428
|
|
|
@@ -341,15 +430,27 @@ Plugin package directory names and plugin ids must be valid identifiers:
|
|
|
341
430
|
^[a-z][a-z0-9.-]*$
|
|
342
431
|
```
|
|
343
432
|
|
|
344
|
-
A package can expose one or more PI WEB plugin
|
|
433
|
+
A package can expose one or more PI WEB plugin entries. There is exactly one supported `package.json` metadata shape:
|
|
345
434
|
|
|
346
435
|
```json
|
|
347
436
|
{
|
|
348
437
|
"private": true,
|
|
438
|
+
"type": "module",
|
|
349
439
|
"piWeb": {
|
|
350
440
|
"plugins": [
|
|
351
|
-
{
|
|
352
|
-
|
|
441
|
+
{
|
|
442
|
+
"id": "review",
|
|
443
|
+
"browserRoot": "dist/review",
|
|
444
|
+
"module": "dist/review/index.js"
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
"id": "workspaces",
|
|
448
|
+
"browserRoot": "dist/browser",
|
|
449
|
+
"module": "dist/browser/index.js",
|
|
450
|
+
"serverModule": "dist/server.js",
|
|
451
|
+
"machineSpecific": true
|
|
452
|
+
},
|
|
453
|
+
{ "id": "server-only", "serverModule": "dist/server-only.js" }
|
|
353
454
|
]
|
|
354
455
|
}
|
|
355
456
|
}
|
|
@@ -358,103 +459,212 @@ A package can expose one or more PI WEB plugin modules. There is exactly one sup
|
|
|
358
459
|
Rules:
|
|
359
460
|
|
|
360
461
|
- `piWeb.plugins` must be an array of objects.
|
|
361
|
-
- Each entry must have an explicit `id` and `module`.
|
|
362
|
-
- `id` must match `^[a-z][a-z0-9.-]*$`.
|
|
363
|
-
-
|
|
364
|
-
- `
|
|
365
|
-
-
|
|
462
|
+
- Each entry must have an explicit `id` and at least one of `module` or `serverModule`.
|
|
463
|
+
- `id` must match `^[a-z][a-z0-9.-]*$`. Externally declared ids `core`, `themes`, and every `machine.*` id are reserved for the host and rejected with an attributed package diagnostic.
|
|
464
|
+
- Both module paths must be safe canonical relative paths to existing files inside the package root. Backslashes, absolute or Windows drive-qualified paths, and empty, `.`, `..`, `.git`, or `node_modules` segments are rejected.
|
|
465
|
+
- Every browser entry must declare `browserRoot`; a server-only entry must not. The root is `.` or a safe canonical package-relative directory with no empty, `.`, `..`, `.git`, or `node_modules` segment; Windows drive-qualified roots are rejected. It must resolve inside the package, and the browser module must remain inside it both logically and after symlink resolution.
|
|
466
|
+
- Server entries are imported as Node ES modules. When a `serverModule` uses a `.js` path, declare `"type": "module"` in that plugin package; `.mjs` is the explicit-extension alternative.
|
|
467
|
+
- `machineSpecific` is optional and must be boolean. Browser-only and server-only entries default to `false`. Dual browser/server entries default to `true` and cannot explicitly set it to `false`.
|
|
468
|
+
- `plugins.<id>.settings` must be JSON-compatible for server entries; sessiond captures a private copy at startup and diagnostics expose only a fingerprint.
|
|
469
|
+
- A plugin id has one package owner across its browser and server capabilities. Duplicates are diagnosed and never merged or auto-renamed; later package records are skipped.
|
|
366
470
|
- Legacy shortcuts such as `piWeb.plugin`, string entries in `piWeb.plugins`, `piWeb.id` fallback ids, and no-`package.json` fallbacks are not supported.
|
|
367
471
|
|
|
472
|
+
Discovery hashes the package (without traversing `.git` or `node_modules`) to produce one package-wide revision and enforce one package-wide artifact budget. A package is rejected when the scan exceeds **4,096 directory entries** or **16 MiB of file content**. These limits include files outside `browserRoot`, even though those files are not served. Keep generated caches and unrelated large artifacts out of the installed plugin package.
|
|
473
|
+
|
|
368
474
|
### Manifest and assets
|
|
369
475
|
|
|
370
|
-
The manifest contains each
|
|
476
|
+
The manifest contains a lifecycle version and each publishable browser module. Current PI WEB releases emit `module` as a leading application-root reference and include `backendRevision` only for a paired active server entry:
|
|
371
477
|
|
|
372
478
|
```json
|
|
373
479
|
{
|
|
480
|
+
"lifecycleVersion": 1,
|
|
374
481
|
"plugins": [
|
|
375
482
|
{
|
|
376
|
-
"id": "
|
|
377
|
-
"module": "/pi-web-plugins/
|
|
483
|
+
"id": "workspaces",
|
|
484
|
+
"module": "/pi-web-plugins/workspaces/dist/browser/index.js?v=<content-revision>",
|
|
485
|
+
"backendRevision": "<active-server-revision>",
|
|
378
486
|
"source": "local",
|
|
379
487
|
"scope": "local",
|
|
380
|
-
"machineSpecific":
|
|
488
|
+
"machineSpecific": true
|
|
381
489
|
}
|
|
382
490
|
]
|
|
383
491
|
}
|
|
384
492
|
```
|
|
385
493
|
|
|
386
|
-
The browser maps leading application-root references into the current application base, so the same manifest works at the origin root or under a reverse-proxy path prefix.
|
|
494
|
+
The browser maps leading application-root references into the current application base, so the same manifest works at the origin root or under a reverse-proxy path prefix. Federated gateways additionally accept explicit manifest-relative references such as `./my-plugin/pi-web-plugin.js` and legacy plugin-root-relative references such as `nested/pi-web-plugin.js`; all accepted forms are rewritten to deployment-portable, gateway-relative references.
|
|
387
495
|
|
|
388
|
-
`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.
|
|
496
|
+
`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. A server-only entry has no browser manifest record. A dual entry is omitted unless sessiond reports the exact active, compatible, non-unhealthy package pairing.
|
|
389
497
|
|
|
390
|
-
At an origin-root deployment, a
|
|
498
|
+
At an origin-root deployment, a browser-public file is available under its package-relative path:
|
|
391
499
|
|
|
392
500
|
```text
|
|
393
|
-
/pi-web-plugins/<plugin-id>/<path-
|
|
501
|
+
/pi-web-plugins/<plugin-id>/<package-relative-path-under-browserRoot>
|
|
394
502
|
```
|
|
395
503
|
|
|
396
|
-
|
|
504
|
+
Only files logically inside `browserRoot` and canonically inside that same directory after symlink resolution are captured and served. Files elsewhere in the package—including a sibling server module, source, metadata, and dependencies—return not found through plugin asset routes. Declaring `browserRoot: "."` therefore makes almost the whole scanned package browser-public; prefer a narrow output directory and never place secrets inside it. Unsafe, missing, package-escaping, or module-excluding roots fail discovery with an attributed diagnostic.
|
|
505
|
+
|
|
506
|
+
Prefer module-relative asset URLs so they also work for remote machine plugins and nested deployments. For example, a built plugin module can reference an SVG shipped beside it:
|
|
397
507
|
|
|
398
508
|
```js
|
|
399
509
|
const iconUrl = new URL("./assets/icon.svg", import.meta.url);
|
|
400
510
|
```
|
|
401
511
|
|
|
402
|
-
The final installed plugin package must contain `assets/icon.svg` at that path relative to the final built module
|
|
512
|
+
The final installed plugin package must contain `assets/icon.svg` at that path relative to the final built module and inside `browserRoot`. PI WEB serves files that already exist in the package; it does not copy a source `public/` directory or apply Vite-style public-directory semantics. Configure the plugin build and package contents to emit or copy the asset into its final module-relative location.
|
|
403
513
|
|
|
404
|
-
PI WEB
|
|
514
|
+
PI WEB returns executable JavaScript MIME types for both `.js` and `.mjs`. JSON, CSS, HTML, and SVG receive their corresponding content types; unknown file types are served as octet-stream.
|
|
405
515
|
|
|
406
|
-
##
|
|
516
|
+
## Browser module shape and v2 migration
|
|
407
517
|
|
|
408
|
-
The
|
|
518
|
+
TypeScript browser entries should use a type-only import from the published declaration entrypoint. The built JavaScript must not import PI WEB source internals:
|
|
519
|
+
|
|
520
|
+
```ts
|
|
521
|
+
import type { PiWebPlugin } from "@jmfederico/pi-web/plugin-api";
|
|
522
|
+
|
|
523
|
+
const plugin: PiWebPlugin = {
|
|
524
|
+
apiVersion: 2,
|
|
525
|
+
name: "My Plugin",
|
|
526
|
+
activate: ({ pluginId, runtimePluginId, html }) => ({
|
|
527
|
+
contributions: {
|
|
528
|
+
actions: [{
|
|
529
|
+
id: "workspace.open",
|
|
530
|
+
title: "Open my panel",
|
|
531
|
+
run: ({ selectWorkspaceTool }) => {
|
|
532
|
+
selectWorkspaceTool(`${runtimePluginId}:workspace.my-panel`);
|
|
533
|
+
},
|
|
534
|
+
}],
|
|
535
|
+
workspacePanels: [{
|
|
536
|
+
id: "workspace.my-panel",
|
|
537
|
+
title: "My panel",
|
|
538
|
+
visible: ({ workspace }) => workspace.provider?.pluginId === pluginId,
|
|
539
|
+
render: ({ workspace }) => html`<p>${workspace.label}</p>`,
|
|
540
|
+
}],
|
|
541
|
+
},
|
|
542
|
+
}),
|
|
543
|
+
};
|
|
544
|
+
|
|
545
|
+
export default plugin;
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
The activation boundary is:
|
|
409
549
|
|
|
410
550
|
```ts
|
|
411
551
|
interface PiWebPlugin {
|
|
412
|
-
apiVersion:
|
|
552
|
+
apiVersion: 2;
|
|
413
553
|
name: string;
|
|
414
|
-
activate
|
|
554
|
+
activate(context: PluginActivationContext): PluginActivationResult;
|
|
415
555
|
}
|
|
416
556
|
|
|
417
557
|
interface PluginActivationContext {
|
|
418
|
-
apiVersion:
|
|
419
|
-
pluginId: string;
|
|
420
|
-
|
|
421
|
-
|
|
558
|
+
readonly apiVersion: 2;
|
|
559
|
+
readonly pluginId: string;
|
|
560
|
+
readonly runtimePluginId: string;
|
|
561
|
+
readonly html: HtmlTemplateTag;
|
|
562
|
+
readonly svg: SvgTemplateTag;
|
|
422
563
|
}
|
|
564
|
+
```
|
|
423
565
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
566
|
+
`activate()` is called once when the UI loads the plugin. Keep it cheap and synchronous: define contributions there, but move expensive or async work into actions, custom elements, or explicit user interactions.
|
|
567
|
+
|
|
568
|
+
Browser API v2 is a deliberate break: the host rejects browser v1 entries with the plugin/module identity and expected version; there is no v1 compatibility shim. Migrate a browser entry by setting `apiVersion: 2`, using stable `pluginId` for package/provider ownership, and using `runtimePluginId` when constructing a host-qualified contribution reference. Replace browser-v1 `refreshGit` with `refreshWorkspacePanels()` plus panel `onInvalidate()`. The browser-v1 `isGitRepo`, `isGitWorktree`, and top-level `workspace.branch` aliases were removed; use the provider-authored `workspace.label` for generic presentation, and keep provider-specific facts in `workspace.provider.metadata` or the owning backend. The former `@jmfederico/pi-web/plugin-api/unstable` type path is not part of v2 and is no longer exported.
|
|
569
|
+
|
|
570
|
+
Contribution ids authored in arrays remain local to the plugin. PI WEB qualifies them internally under the runtime identity:
|
|
571
|
+
|
|
572
|
+
```text
|
|
573
|
+
<runtime-plugin-id>:<local-contribution-id>
|
|
427
574
|
```
|
|
428
575
|
|
|
429
|
-
|
|
576
|
+
For a local plugin the runtime and source ids are normally equal. A federated registration may machine-scope `runtimePluginId`, while `pluginId` and `workspace.provider.pluginId` remain the same source id.
|
|
430
577
|
|
|
431
|
-
|
|
432
|
-
|
|
578
|
+
## Server module and workspace provider shape
|
|
579
|
+
|
|
580
|
+
TypeScript server entries import the separately published Node declarations with `import type`:
|
|
581
|
+
|
|
582
|
+
```ts
|
|
583
|
+
import type {
|
|
584
|
+
PiWebServerPlugin,
|
|
585
|
+
WorkspaceProvider,
|
|
586
|
+
} from "@jmfederico/pi-web/server-plugin-api";
|
|
587
|
+
|
|
588
|
+
const provider: WorkspaceProvider = {
|
|
589
|
+
async probe(project, signal) {
|
|
590
|
+
// Return "claim" only when this provider owns the project's semantics.
|
|
591
|
+
return await projectIsSupported(project, signal) ? "claim" : "pass";
|
|
592
|
+
},
|
|
593
|
+
async list(project, signal) {
|
|
594
|
+
return await listProviderWorkspaces(project, signal);
|
|
595
|
+
},
|
|
596
|
+
async request({ project, workspace, operation, input, signal }) {
|
|
597
|
+
return await handleProviderOperation({ project, workspace, operation, input, signal });
|
|
598
|
+
},
|
|
599
|
+
};
|
|
600
|
+
|
|
601
|
+
const plugin: PiWebServerPlugin = {
|
|
433
602
|
apiVersion: 1,
|
|
434
|
-
name: "My
|
|
435
|
-
activate
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
}
|
|
441
|
-
}
|
|
603
|
+
name: "My Workspace Provider",
|
|
604
|
+
activate(context) {
|
|
605
|
+
return {
|
|
606
|
+
workspaceProvider: provider,
|
|
607
|
+
health: async (signal) => ({ status: "healthy" }),
|
|
608
|
+
stop: async (signal) => { /* release plugin-owned resources */ },
|
|
609
|
+
};
|
|
610
|
+
},
|
|
442
611
|
};
|
|
612
|
+
|
|
613
|
+
export default plugin;
|
|
443
614
|
```
|
|
444
615
|
|
|
445
|
-
|
|
616
|
+
The default export has `apiVersion: 1`, a non-empty `name`, and `activate(context)`. The activation result can contain:
|
|
446
617
|
|
|
447
|
-
|
|
618
|
+
```ts
|
|
619
|
+
interface ServerPluginActivation {
|
|
620
|
+
workspaceProvider?: WorkspaceProvider;
|
|
621
|
+
start?(signal: AbortSignal): void | Promise<void>;
|
|
622
|
+
stop?(signal: AbortSignal): void | Promise<void>;
|
|
623
|
+
health?(signal: AbortSignal): ServerPluginHealth | Promise<ServerPluginHealth>;
|
|
624
|
+
}
|
|
625
|
+
```
|
|
448
626
|
|
|
449
|
-
|
|
450
|
-
|
|
627
|
+
A server plugin may contribute at most one `workspaceProvider`. The host-owned frozen activation context contains its `pluginId`, `packageRoot`, JSON settings snapshot, scoped logger, activation `AbortSignal`, and an argv-based `execFile()` helper. `execFile()` has host-owned timeout/output bounds; pass the current callback's signal into every command request. The API exposes no shell parser, Fastify instance, route registration, concrete service, event bus, or service locator.
|
|
628
|
+
|
|
629
|
+
Every activation, lifecycle, provider, and request signal is scoped to that one invocation. The host aborts it when the invocation times out or settles. Do not retain a signal as a plugin-lifetime shutdown notification; release plugin-owned resources in the explicit `stop()` callback. Deadlines remain cooperative, so plugins must observe each supplied signal.
|
|
630
|
+
|
|
631
|
+
Sessiond resolves the enabled catalog once per process start. It imports, validates, activates, and starts each server entry before publishing its contribution. A failed entry is attributed and skipped without aborting ordinary activation of other plugins; a failed `start` is rolled back with `stop` when available. Successful plugins stop in reverse activation order. Sessiond inspects each optional `health()` callback once while building the startup workspace authority; an unhealthy provider is excluded, a degraded provider remains eligible, and that inspection is not polled again during the process lifetime. Server entries are never hot-reloaded or unloaded after config/package edits.
|
|
632
|
+
|
|
633
|
+
### Workspace provider contract
|
|
634
|
+
|
|
635
|
+
```ts
|
|
636
|
+
interface WorkspaceProvider {
|
|
637
|
+
fallback?: boolean;
|
|
638
|
+
probe(project: ProjectInput, signal: AbortSignal): Promise<"claim" | "pass">;
|
|
639
|
+
list(project: ProjectInput, signal: AbortSignal): Promise<ProviderWorkspace[]>;
|
|
640
|
+
request?(context: ProviderRequestContext): Promise<JsonValue>;
|
|
641
|
+
prepareRemove?(context: ProviderRemoveContext): Promise<WorkspaceRemovePlan>;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
interface ProviderWorkspace {
|
|
645
|
+
key: string;
|
|
646
|
+
path: string;
|
|
647
|
+
label: string;
|
|
648
|
+
isMain: boolean;
|
|
649
|
+
data?: JsonValue;
|
|
650
|
+
publicMetadata?: JsonObject;
|
|
651
|
+
removal?: { actionLabel: string; confirmation: string };
|
|
652
|
+
}
|
|
451
653
|
```
|
|
452
654
|
|
|
453
|
-
|
|
655
|
+
- `probe()` must return only `"claim"` or `"pass"`. Leave `fallback` unset/false for a replacement that should run before bundled Git.
|
|
656
|
+
- `list()` runs only for the selected owner. Return stable provider-local keys, accessible absolute directory paths, unique paths/keys, non-empty labels, and exactly one main workspace.
|
|
657
|
+
- `data` is round-tripped privately to that provider during the current resolution. `publicMetadata` appears under `workspace.provider.metadata` and is visible to **all browser code and API consumers**. Never put secrets in `publicMetadata` or removal wording.
|
|
658
|
+
- `request()` is optional and receives a host-validated frozen current owner/workspace projection plus a bounded operation id, JSON input, and operation-scoped abort signal. It must return JSON.
|
|
659
|
+
- `removal` is display text only and requires `prepareRemove()`. It advertises removal for that specific workspace; browser `workspace.provider.capabilities.remove` is true only when that workspace advertises it and the owning provider implements removal.
|
|
660
|
+
- `prepareRemove()` returns a plan for a visible host-owned terminal run; returning the plan approves the operation but does **not** mean removal has completed. `command` is shell source interpreted by the host's login shell. The host chooses a safe current working directory outside the target, so the provider must use the supplied absolute `workspace.path`, shell-quote it, and keep removal in the foreground. The host records completion when the shell exits, with exit status 0 meaning success.
|
|
661
|
+
- Provider failures and conflicts are diagnostics. A claimant that fails `list()` does not permit fallback takeover for the same resolution.
|
|
662
|
+
|
|
663
|
+
The only supported plugin type entrypoints are the type-only package exports `@jmfederico/pi-web/plugin-api` and `@jmfederico/pi-web/server-plugin-api`. Use them with `import type`; there is no runtime JavaScript export. Private `dist/**` deep imports and any other plugin API subpath are not part of the package contract.
|
|
454
664
|
|
|
455
665
|
## Contributions
|
|
456
666
|
|
|
457
|
-
|
|
667
|
+
The workspace-related contribution arrays returned by `activate()` are:
|
|
458
668
|
|
|
459
669
|
```ts
|
|
460
670
|
interface PluginContributions {
|
|
@@ -491,6 +701,7 @@ interface PluginAction {
|
|
|
491
701
|
title: string;
|
|
492
702
|
description?: string;
|
|
493
703
|
shortcut?: string;
|
|
704
|
+
shortcutAliases?: QualifiedContributionId[];
|
|
494
705
|
group?: string;
|
|
495
706
|
enabled?: (context: PluginRuntimeContext) => boolean;
|
|
496
707
|
disabledReason?: (context: PluginRuntimeContext) => string | undefined;
|
|
@@ -508,6 +719,8 @@ interface PluginRuntimeContext {
|
|
|
508
719
|
selectedMachine?: PluginMachine;
|
|
509
720
|
selectedWorkspace?: Workspace;
|
|
510
721
|
selectedSession?: unknown;
|
|
722
|
+
workspaceTool?: string;
|
|
723
|
+
mainView?: string;
|
|
511
724
|
piWebStatus?: PiWebStatusResponse;
|
|
512
725
|
};
|
|
513
726
|
prompt: PluginPromptEditor;
|
|
@@ -516,11 +729,15 @@ interface PluginRuntimeContext {
|
|
|
516
729
|
addProject: () => void | Promise<void>;
|
|
517
730
|
configureAuth: () => void | Promise<void>;
|
|
518
731
|
logoutAuth: () => void | Promise<void>;
|
|
732
|
+
openThemePicker: () => void;
|
|
733
|
+
selectMainView: (view: string) => void;
|
|
519
734
|
selectWorkspaceTool: (tool: QualifiedContributionId) => void;
|
|
520
735
|
openTerminal: (options?: { terminalId?: string }) => void;
|
|
521
736
|
refreshFiles: () => void | Promise<void>;
|
|
522
|
-
|
|
737
|
+
refreshWorkspacePanels: (panelId?: QualifiedContributionId) => void | Promise<void>;
|
|
738
|
+
refreshAppData: () => void | Promise<void>;
|
|
523
739
|
checkForPiWebUpdates?: () => void | Promise<void>;
|
|
740
|
+
reloadPage: () => void;
|
|
524
741
|
startSession: () => void | Promise<void>;
|
|
525
742
|
archiveSession: () => void | Promise<void>;
|
|
526
743
|
stopActiveWork: () => void | Promise<void>;
|
|
@@ -530,13 +747,15 @@ interface PluginRuntimeContext {
|
|
|
530
747
|
Notes:
|
|
531
748
|
|
|
532
749
|
- `state` is a snapshot of current UI state when actions are built.
|
|
533
|
-
- The stable state fields are `state.selectedMachine`, `state.selectedWorkspace`, `state.selectedSession`, and `state.piWebStatus`. `state.selectedMachine` identifies the currently selected machine. `state.piWebStatus` describes the currently selected machine's PI WEB runtime, or the gateway/local runtime when the local machine is selected.
|
|
750
|
+
- The stable state fields are `state.selectedMachine`, `state.selectedWorkspace`, `state.selectedSession`, `state.workspaceTool`, `state.mainView`, and `state.piWebStatus`. `state.selectedMachine` identifies the currently selected machine. `state.piWebStatus` describes the currently selected machine's PI WEB runtime, or the gateway/local runtime when the local machine is selected.
|
|
534
751
|
- Other `state` fields may exist at runtime, but they are private PI WEB internals that may graduate into stable helpers, change shape, or disappear.
|
|
535
752
|
- `enabled` is evaluated when the action palette asks for actions.
|
|
753
|
+
- `shortcutAliases` is for migration only: list former fully qualified action ids whose saved shortcut preference should still apply to this action.
|
|
536
754
|
- `selectWorkspaceTool()` expects a qualified panel id such as `my-plugin:workspace.info`.
|
|
537
755
|
- `openTerminal()` switches to the built-in terminal panel. Pass `{ terminalId }` to deep-link to a specific terminal.
|
|
756
|
+
- `refreshWorkspacePanels()` invokes `onInvalidate` for the selected workspace, either for every plugin panel or for one qualified `panelId`. The callback owns its refresh and should request a render when its visible state changes.
|
|
538
757
|
- `checkForPiWebUpdates()` forces a fresh update check on the selected machine and refreshes `state.piWebStatus`. It is optional so plugins remain compatible with older PI WEB hosts.
|
|
539
|
-
- Only fields documented here and declared
|
|
758
|
+
- Only fields documented here and declared by `@jmfederico/pi-web/plugin-api` are stable public browser API. Anything else is experimental: it may become public API later, change shape, or disappear.
|
|
540
759
|
|
|
541
760
|
### Prompt editor API
|
|
542
761
|
|
|
@@ -587,7 +806,7 @@ workspacePanels: [
|
|
|
587
806
|
</svg>
|
|
588
807
|
`,
|
|
589
808
|
order: 100,
|
|
590
|
-
visible: ({ workspace }) => workspace.
|
|
809
|
+
visible: ({ workspace }) => workspace.isMain,
|
|
591
810
|
render: ({ workspace }) => html`
|
|
592
811
|
<section class="toolbar"><strong>Info</strong></section>
|
|
593
812
|
<section class="viewer">
|
|
@@ -607,8 +826,10 @@ interface WorkspacePanelContribution {
|
|
|
607
826
|
title: string;
|
|
608
827
|
icon?: TemplateResult;
|
|
609
828
|
order?: number;
|
|
829
|
+
routeAliases?: string[];
|
|
610
830
|
visible?: (context: WorkspacePanelContext) => boolean;
|
|
611
831
|
badge?: (context: WorkspacePanelContext) => string | number | TemplateResult | undefined;
|
|
832
|
+
onInvalidate?: (context: WorkspacePanelContext) => void | Promise<void>;
|
|
612
833
|
render: (context: WorkspacePanelContext) => TemplateResult;
|
|
613
834
|
}
|
|
614
835
|
|
|
@@ -623,6 +844,9 @@ interface WorkspacePanelContext {
|
|
|
623
844
|
deleteFile(path: string): Promise<DeleteWorkspaceFileResponse>;
|
|
624
845
|
moveFile(fromPath: string, toPath: string, options?: MoveWorkspaceFileOptions): Promise<MoveWorkspaceFileResponse>;
|
|
625
846
|
};
|
|
847
|
+
backend?: {
|
|
848
|
+
request(operation: string, input: JsonValue): Promise<JsonValue>;
|
|
849
|
+
};
|
|
626
850
|
prompt: PluginPromptEditor;
|
|
627
851
|
terminal: {
|
|
628
852
|
open(options?: { terminalId?: string }): void;
|
|
@@ -641,9 +865,7 @@ interface WorkspacePanelContext {
|
|
|
641
865
|
|
|
642
866
|
`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.
|
|
643
867
|
|
|
644
|
-
`machine`, `workspace`, `files`, `prompt`, `terminal`, and `host` are documented as stable for panel callbacks. The `files` helper supports `readFile`, `listFiles`, `writeFile`, `deleteFile`, and `moveFile` — see [Reading workspace files](#reading-workspace-files), [Listing workspace files](#listing-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.
|
|
645
|
-
|
|
646
|
-
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()`.
|
|
868
|
+
`machine`, `workspace`, `files`, optional `backend`, `prompt`, `terminal`, and `host` are documented as stable for panel callbacks. The `files` helper supports `readFile`, `listFiles`, `writeFile`, `deleteFile`, and `moveFile` — see [Reading workspace files](#reading-workspace-files), [Listing workspace files](#listing-workspace-files), and [Writing, deleting, and moving workspace files](#writing-deleting-and-moving-workspace-files). A browser entry with a paired active provider uses `backend.request()` instead of constructing API routes — see [Calling paired workspace backends](#calling-paired-workspace-backends). 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. `routeAliases` is only for migrating former URL tool/view values. Implement `onInvalidate()` to refresh plugin-owned panel data when an action or host refresh calls `refreshWorkspacePanels()`; call `host.requestRender()` when async state changes should make PI WEB re-evaluate `badge`, `visible`, or `render`.
|
|
647
869
|
|
|
648
870
|
Useful workspace and machine shapes:
|
|
649
871
|
|
|
@@ -655,18 +877,21 @@ interface PluginMachine {
|
|
|
655
877
|
}
|
|
656
878
|
|
|
657
879
|
interface Workspace {
|
|
658
|
-
id: string;
|
|
659
|
-
projectId: string;
|
|
660
|
-
path: string;
|
|
661
|
-
label: string;
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
880
|
+
readonly id: string;
|
|
881
|
+
readonly projectId: string;
|
|
882
|
+
readonly path: string;
|
|
883
|
+
readonly label: string;
|
|
884
|
+
readonly isMain: boolean;
|
|
885
|
+
readonly provider?: {
|
|
886
|
+
readonly pluginId: string;
|
|
887
|
+
readonly capabilities: { readonly request: boolean; readonly remove: boolean };
|
|
888
|
+
readonly metadata?: JsonObject;
|
|
889
|
+
};
|
|
890
|
+
readonly removal?: { readonly actionLabel: string; readonly confirmation: string };
|
|
666
891
|
}
|
|
667
892
|
```
|
|
668
893
|
|
|
669
|
-
`machine.id` is included in panel contexts so plugins can keep caches machine-scoped. Do not infer the selected machine from global browser state.
|
|
894
|
+
`machine.id` is included in panel contexts so plugins can keep caches machine-scoped. Do not infer the selected machine from global browser state. Use the provider-authored `workspace.label` for provider-neutral presentation. `workspace.provider.pluginId` is the stable source id, and provider-published details such as Git status live in `workspace.provider.metadata`, which the server provider fills from browser-public `publicMetadata`. Provider-specific browser code may interpret metadata it owns; PI WEB core does not assign branch semantics to the generic workspace shape. `capabilities.remove` describes only this workspace, not the provider in general. The browser-v1 `isGitRepo`, `isGitWorktree`, and top-level `branch` aliases were removed.
|
|
670
895
|
|
|
671
896
|
Use existing classes such as `toolbar`, `viewer`, `empty`, and `muted` for panel content when possible. Do not assume a panel owns the whole page; keep layout contained.
|
|
672
897
|
|
|
@@ -714,13 +939,16 @@ interface WorkspaceLabelContext {
|
|
|
714
939
|
deleteFile(path: string): Promise<DeleteWorkspaceFileResponse>;
|
|
715
940
|
moveFile(fromPath: string, toPath: string, options?: MoveWorkspaceFileOptions): Promise<MoveWorkspaceFileResponse>;
|
|
716
941
|
};
|
|
942
|
+
backend?: {
|
|
943
|
+
request(operation: string, input: JsonValue): Promise<JsonValue>;
|
|
944
|
+
};
|
|
717
945
|
host: {
|
|
718
946
|
requestRender(): void;
|
|
719
947
|
};
|
|
720
948
|
}
|
|
721
949
|
```
|
|
722
950
|
|
|
723
|
-
`machine`, `workspace`, `files`, and `host` are documented as stable for label callbacks. The `files` helper supports `readFile`, `listFiles`, `writeFile`, `deleteFile`, and `moveFile` — see [Reading workspace files](#reading-workspace-files), [Listing workspace files](#listing-workspace-files), and [Writing workspace files](#writing-workspace-files). Include `machine.id` in
|
|
951
|
+
`machine`, `workspace`, `files`, optional `backend`, and `host` are documented as stable for label callbacks. The `files` helper supports `readFile`, `listFiles`, `writeFile`, `deleteFile`, and `moveFile` — see [Reading workspace files](#reading-workspace-files), [Listing workspace files](#listing-workspace-files), and [Writing, deleting, and moving workspace files](#writing-deleting-and-moving-workspace-files). A browser entry with a paired active provider can call `backend.request()` from a label-owned async cache after checking that the optional helper is present. Include `machine.id` in 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.
|
|
724
952
|
|
|
725
953
|
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.
|
|
726
954
|
|
|
@@ -752,7 +980,7 @@ Use render items when a label contribution needs custom UI, async data, or cachi
|
|
|
752
980
|
class MyWorkspaceBadge extends HTMLElement {
|
|
753
981
|
set workspace(value) {
|
|
754
982
|
this._workspace = value;
|
|
755
|
-
this.textContent = value?.
|
|
983
|
+
this.textContent = value?.label ?? "workspace";
|
|
756
984
|
}
|
|
757
985
|
}
|
|
758
986
|
|
|
@@ -761,7 +989,7 @@ if (!customElements.get("my-workspace-badge")) {
|
|
|
761
989
|
}
|
|
762
990
|
|
|
763
991
|
export default {
|
|
764
|
-
apiVersion:
|
|
992
|
+
apiVersion: 2,
|
|
765
993
|
name: "My Plugin",
|
|
766
994
|
activate: ({ html }) => ({
|
|
767
995
|
contributions: {
|
|
@@ -780,6 +1008,23 @@ export default {
|
|
|
780
1008
|
};
|
|
781
1009
|
```
|
|
782
1010
|
|
|
1011
|
+
## Calling paired workspace backends
|
|
1012
|
+
|
|
1013
|
+
Workspace panel and label contexts include an optional JSON-only backend helper. It is present only for a browser entry paired with an active server backend:
|
|
1014
|
+
|
|
1015
|
+
```js
|
|
1016
|
+
if (context.backend === undefined) throw new Error("Workspace backend unavailable");
|
|
1017
|
+
const result = await context.backend.request("summary", {
|
|
1018
|
+
includeIgnored: false,
|
|
1019
|
+
});
|
|
1020
|
+
```
|
|
1021
|
+
|
|
1022
|
+
PI WEB binds the request to the browser module's original package id and active backend revision, plus the callback's selected machine, project, and workspace. The host resolves the current workspace owner again before dispatch. The call succeeds only when that same active plugin still owns the workspace and implements `WorkspaceProvider.request()`.
|
|
1023
|
+
|
|
1024
|
+
Operation ids must match `^[a-z][a-z0-9.-]*$` and be at most 128 characters. Inputs and results must contain only finite JSON values; functions, classes, `undefined`, cycles, and non-finite numbers are rejected. Requests, responses, owner resolution, and provider callbacks are size- and time-bounded.
|
|
1025
|
+
|
|
1026
|
+
The same helper works locally and through machine federation. It preserves machine scoping and active frontend/backend revision pairing, so browser plugins must not construct `/api/plugin-backends/...` or `/api/machines/...` URLs themselves. Missing/inactive backends, stale revisions/workspaces, ownership changes/conflicts, unsupported operations, invalid JSON, failures, and timeouts reject the promise with an attributed error.
|
|
1027
|
+
|
|
783
1028
|
## Reading workspace files
|
|
784
1029
|
|
|
785
1030
|
Workspace panels and workspace labels can read files through the documented `files` helper. PI WEB binds this helper to the callback's machine and workspace, so it works the same for local and federated machines.
|
|
@@ -857,7 +1102,7 @@ workspaceLabels: [
|
|
|
857
1102
|
]
|
|
858
1103
|
```
|
|
859
1104
|
|
|
860
|
-
The file response includes fields such as `path`, `content`, `truncated`, and `binary`. Be careful with sensitive files such as `.env`:
|
|
1105
|
+
The file response includes fields such as `path`, `content`, `truncated`, and `binary`. Be careful with sensitive files such as `.env`: browser entries are trusted code, and file contents are exposed to the plugin.
|
|
861
1106
|
|
|
862
1107
|
## Listing workspace files
|
|
863
1108
|
|
|
@@ -973,7 +1218,7 @@ After any mutation (`writeFile`, `deleteFile`, or `moveFile`), the File Explorer
|
|
|
973
1218
|
|
|
974
1219
|
### Security
|
|
975
1220
|
|
|
976
|
-
|
|
1221
|
+
Browser plugin entries are trusted code. File writes go through the same path safety validation as reads — paths are resolved and checked to stay inside the workspace root.
|
|
977
1222
|
|
|
978
1223
|
## Running workspace terminal commands
|
|
979
1224
|
|
|
@@ -994,9 +1239,9 @@ Review command strings carefully. They are trusted shell commands executed in th
|
|
|
994
1239
|
|
|
995
1240
|
## Private and experimental PI WEB APIs
|
|
996
1241
|
|
|
997
|
-
PI WEB's `/api/...` HTTP and WebSocket routes
|
|
1242
|
+
PI WEB's `/api/...` HTTP and WebSocket routes, runtime-only browser fields, source files, Fastify instance, and internal services are private implementation details. They are outside the supported browser-v2 and server-v1 package contracts and may change or disappear.
|
|
998
1243
|
|
|
999
|
-
|
|
1244
|
+
The stable browser API is the documented helpers and the type-only `@jmfederico/pi-web/plugin-api` export; the stable server API is the narrow type-only `@jmfederico/pi-web/server-plugin-api` export. Use `context.backend.request()` for paired browser/server work. If browser code intentionally relies on another private surface, keep that dependency local and expect to revisit it after PI WEB upgrades. A server plugin must not import PI WEB source internals or private `dist/**` declarations.
|
|
1000
1245
|
|
|
1001
1246
|
## Async data and caching
|
|
1002
1247
|
|
|
@@ -1012,21 +1257,21 @@ PI WEB does not provide a plugin cache/invalidation framework. Keep host callbac
|
|
|
1012
1257
|
|
|
1013
1258
|
If you are an AI agent building or editing a PI WEB plugin, follow this checklist:
|
|
1014
1259
|
|
|
1015
|
-
1. Create or update a
|
|
1016
|
-
2. Use
|
|
1017
|
-
3.
|
|
1018
|
-
4.
|
|
1019
|
-
5.
|
|
1020
|
-
6.
|
|
1021
|
-
7.
|
|
1022
|
-
8.
|
|
1023
|
-
9.
|
|
1024
|
-
10.
|
|
1025
|
-
11.
|
|
1026
|
-
12.
|
|
1027
|
-
13.
|
|
1028
|
-
14.
|
|
1029
|
-
15.
|
|
1260
|
+
1. Create or update a package folder with `package.json` and at least one built JavaScript entry. Declare `"type": "module"` when a `.js` server entry is present, or emit it as `.mjs`.
|
|
1261
|
+
2. Use `piWeb.plugins` entries shaped as `{ id, browserRoot?, module?, serverModule?, machineSpecific? }`; declare at least one module, give every browser entry a safe root containing its module, and use non-reserved ids matching `^[a-z][a-z0-9.-]*$`.
|
|
1262
|
+
3. Import browser types only from `@jmfederico/pi-web/plugin-api` and server types only from `@jmfederico/pi-web/server-plugin-api`, always with `import type`; do not use private subpaths or source internals.
|
|
1263
|
+
4. Default-export `{ apiVersion: 2, name, activate }` from a browser entry and `{ apiVersion: 1, name, activate }` from a server entry.
|
|
1264
|
+
5. In a browser entry, use source `pluginId` for ownership and `runtimePluginId` for qualified contribution references; return contributions synchronously and use the activation context's `html`/`svg` tags.
|
|
1265
|
+
6. Add actions for command-palette operations, panels for larger workspace UI, and labels for compact inline metadata.
|
|
1266
|
+
7. Return arrays synchronously from workspace label `items()`; return an empty array to render nothing.
|
|
1267
|
+
8. Use documented browser helpers first: `files`, `terminal`, `backend`, `host.requestRender`, `workspace`, `machine`, `state`, and `prompt`. Never construct PI WEB backend, federation, or absolute asset URLs.
|
|
1268
|
+
9. In a server entry, return only the demonstrated lifecycle callbacks and at most one `workspaceProvider`; treat every supplied `AbortSignal` as operation-scoped and forward it to bounded work.
|
|
1269
|
+
10. Make provider claims conservative. Return exactly one main workspace, stable keys, absolute accessible directories, JSON data/metadata, and optional request/removal capabilities.
|
|
1270
|
+
11. Keep backend operations JSON-only, bounded, and provider-owned. Put no secrets in `publicMetadata`, browser responses, removal wording, or diagnostics.
|
|
1271
|
+
12. Keep the installed package at or below 4,096 entries and 16 MiB, and keep every browser-public file inside a narrow `browserRoot`.
|
|
1272
|
+
13. Treat both entries as trusted code. A server module shares sessiond's process and user permissions.
|
|
1273
|
+
14. For browser-only edits, reload or hard-reload the page. For a server-backed edit, restart sessiond and then reload the page.
|
|
1274
|
+
15. Warn that restarting `pi-web-sessiond.service` may interrupt active sessions/runtime ownership.
|
|
1030
1275
|
|
|
1031
1276
|
## Troubleshooting
|
|
1032
1277
|
|
|
@@ -1044,13 +1289,17 @@ curl http://127.0.0.1:8504/pi-web-plugins/my-plugin/pi-web-plugin.js
|
|
|
1044
1289
|
|
|
1045
1290
|
Common issues:
|
|
1046
1291
|
|
|
1047
|
-
- invalid plugin
|
|
1048
|
-
- missing default export;
|
|
1049
|
-
- missing `
|
|
1050
|
-
- missing `package.json` or incorrect `piWeb.plugins` metadata;
|
|
1292
|
+
- invalid plugin or contribution id;
|
|
1293
|
+
- missing default export, browser `apiVersion: 2` or server `apiVersion: 1`, non-empty `name`, or `activate` function;
|
|
1294
|
+
- missing `package.json`, incorrect `piWeb.plugins` metadata, neither module declared, missing/unsafe `browserRoot`, a browser module outside its root, a `.js` server entry without `"type": "module"`, or a dual entry explicitly marked `machineSpecific: false`;
|
|
1051
1295
|
- legacy shortcuts such as `piWeb.plugin`, string plugin entries, or no-`package.json` fallback;
|
|
1052
|
-
- duplicate plugin ids;
|
|
1053
|
-
- entry
|
|
1054
|
-
-
|
|
1055
|
-
-
|
|
1056
|
-
-
|
|
1296
|
+
- duplicate plugin ids; records are diagnosed, skipped rather than merged, and never renamed;
|
|
1297
|
+
- entry/root path is unsafe, points outside the package, enters `.git`/`node_modules`, does not exist, or the package exceeds 4,096 entries/16 MiB;
|
|
1298
|
+
- package is not installed through Pi or under `$PI_WEB_DATA_DIR/plugins` (`~/.pi-web/plugins` by default);
|
|
1299
|
+
- browser import/activation/render failure; check the browser console;
|
|
1300
|
+
- server state is failed, incompatible, unhealthy, disabled, missing, stale, or conflicted; check **Settings → PI WEB plugins** and `pi-web logs` on the target machine;
|
|
1301
|
+
- a server-backed browser entry is absent because sessiond is unavailable or its active source/settings/revisions do not match desired package state; restart sessiond, then reload the tab;
|
|
1302
|
+
- a federated target lacks the lifecycle/backend capability; update and restart PI WEB on that target instead of falling back to the gateway;
|
|
1303
|
+
- recovery is needed before plugin discovery/import; use `pi-web plugins safe-start show`, offline disable, or one of the documented safe-start levels.
|
|
1304
|
+
|
|
1305
|
+
A manual restart of `pi-web-sessiond.service` may interrupt active sessions/runtime ownership. Inspect active work first and do not assume a web/UI restart is sufficient.
|