paseo-plugin-genui 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/OVERVIEW.md CHANGED
@@ -11,11 +11,11 @@ When automatic instructions are enabled, new agents receive the Generative UI co
11
11
  ## Capabilities and data access
12
12
 
13
13
  - **86 components in 10 groups**: Layout, Content, Data, Media, Inputs, Widgets, Project, Dev, Manage, and Evidence.
14
- - **Confined file reading**: `Load(path)`, `Snippet(path, from, to)`, and `Image(path)` read JSON, CSV, TSV, logs, test reports (Vitest, Jest, JUnit), coverage (`lcov`, Istanbul, `coverage.py`, Go), lint and typecheck findings (ESLint, SARIF, `tsc`, Ruff), HAR traces, and benchmarks. Reads are strictly confined to the agent's workspace directory, its per-agent thread storage directory (`/tmp/opencode/genui-storage/<agentId>`), and `/tmp`.
14
+ - **Confined file reading**: `Load(path)`, `Snippet(path, from, to)`, and `Image(path)` read JSON, CSV, TSV, logs, test reports (Vitest, Jest, JUnit), coverage (`lcov`, Istanbul, `coverage.py`, Go), lint and typecheck findings (ESLint, SARIF, `tsc`, Ruff), HAR traces, and benchmarks. Reads are strictly confined to the agent's workspace directory, its per-agent thread storage directory (`/tmp/opencode/genui-storage/<agentId>`), `/tmp`, and any extra folders added in settings.
15
15
  - **Live workspace and git state**: `Changes()`, `Commits()`, `PullRequest()`, `Threads()`, and `Environments()` read the workspace's git diff, commits, pull request status, subagents, and worktrees on the daemon host.
16
16
  - **Sandboxed mini-apps**: `app` blocks run self-contained HTML and JavaScript inside a sandboxed iframe (`sandbox="allow-scripts"`) with a network-blocking Content Security Policy on desktop and web clients.
17
- - **Settings and web lookups**: Under **Settings -> Plugins -> Generative UI**, you can toggle automatic agent instructions for new sessions and toggle server-side web lookups. When web lookups are on, the daemon fetches photo searches from Wikimedia Commons (`commons.wikimedia.org` / `upload.wikimedia.org`), geocoding from Photon (`photon.komoot.io`), map tiles from OpenStreetMap (`tile.openstreetmap.org`), and HTTPS images through an address-checked proxy that rejects loopback, private, and link-local IP addresses. No cookies, credentials, or conversation text beyond the specific search query or place name are sent. Turning web lookups off disables all external network requests.
17
+ - **Settings and web lookups**: Under **Settings -> Plugins -> Generative UI**, you can toggle automatic agent instructions for new sessions and toggle server-side web lookups, and add extra folders (for example `~/dev/scratch`) that file reads may use. When web lookups are on, the daemon fetches photo searches from Wikimedia Commons (`commons.wikimedia.org` / `upload.wikimedia.org`), geocoding from Photon (`photon.komoot.io`), map tiles from OpenStreetMap (`tile.openstreetmap.org`), and HTTPS images through an address-checked proxy that rejects loopback, private, and link-local IP addresses. No cookies, credentials, or conversation text beyond the specific search query or place name are sent. Turning web lookups off disables all external network requests.
18
18
 
19
19
  ## Limits
20
20
 
21
- File reads outside the agent's workspace, thread storage, and `/tmp` are refused. Sandboxed `app` blocks require a desktop or browser client; mobile clients display the block's source code.
21
+ File reads outside the agent's workspace, thread storage, `/tmp`, and the extra folders in settings are refused; agents are told to copy other files into thread storage first. Sandboxed `app` blocks require a desktop or browser client; mobile clients display the block's source code.
@@ -1,11 +1,12 @@
1
1
  import { useSettings, type PluginSurfaceProps } from "@getpaseo/plugin/client";
2
- import { SettingsCard, SettingsSection, SettingsSwitch } from "@getpaseo/plugin/client/ui";
2
+ import { SettingsAction, SettingsCard, SettingsInput, SettingsSection, SettingsSwitch } from "@getpaseo/plugin/client/ui";
3
3
  import React from "react";
4
4
  import { Text, View } from "react-native";
5
5
  import { genuiSettings } from "../shared/settings";
6
6
 
7
7
  export function GenUiSettingsScreen({ theme }: PluginSurfaceProps) {
8
8
  const settings = useSettings(genuiSettings);
9
+ const [folders, setFolders] = React.useState<string | null>(null);
9
10
 
10
11
  if (settings.status === "loading") {
11
12
  return (
@@ -52,6 +53,26 @@ export function GenUiSettingsScreen({ theme }: PluginSurfaceProps) {
52
53
  />
53
54
  </SettingsCard>
54
55
  </SettingsSection>
56
+
57
+ <SettingsSection title="Files">
58
+ <SettingsCard>
59
+ <SettingsInput
60
+ label="Extra folders"
61
+ hint="Comma-separated folders, besides the workspace, thread storage and /tmp, that Load, Snippet and Image can read."
62
+ initialValue={values.extraFolders}
63
+ placeholder="~/dev/scratch"
64
+ onChangeText={setFolders}
65
+ />
66
+ <SettingsAction
67
+ label="Apply folder changes"
68
+ actionLabel="Save"
69
+ disabled={folders === null || folders === values.extraFolders}
70
+ onPress={() => {
71
+ if (folders !== null) void save({ ...values, extraFolders: folders }, revision);
72
+ }}
73
+ />
74
+ </SettingsCard>
75
+ </SettingsSection>
55
76
  </View>
56
77
  );
57
78
  }
package/index.server.ts CHANGED
@@ -29,7 +29,7 @@ import {
29
29
  webTileRpc,
30
30
  } from "./shared/rpc";
31
31
  import { GENUI_BLOCK_KIND } from "./shared/segment";
32
- import { genuiSettings } from "./shared/settings";
32
+ import { genuiSettings, parseFolders } from "./shared/settings";
33
33
  import {
34
34
  agentStorageDir,
35
35
  examplesReport,
@@ -41,6 +41,7 @@ import {
41
41
  loadGalleryFile,
42
42
  loadGalleryImage,
43
43
  readGallerySpec,
44
+ setExtraLoadFolders,
44
45
  sketchFontDataUrl,
45
46
  } from "./server/data-source";
46
47
  import {
@@ -69,10 +70,14 @@ export default function contribute(server: PluginServerContext) {
69
70
  let webLookupsEnabled = true;
70
71
 
71
72
  void settings.read().then((state) => {
72
- if (state.status === "ready") webLookupsEnabled = state.values.webLookups;
73
+ if (state.status !== "ready") return;
74
+ webLookupsEnabled = state.values.webLookups;
75
+ setExtraLoadFolders(parseFolders(state.values.extraFolders));
73
76
  });
74
77
  const unsubscribeSettings = settings.subscribe((state) => {
75
- if (state.status === "ready") webLookupsEnabled = state.values.webLookups;
78
+ if (state.status !== "ready") return;
79
+ webLookupsEnabled = state.values.webLookups;
80
+ setExtraLoadFolders(parseFolders(state.values.extraFolders));
76
81
  });
77
82
 
78
83
  const web = createWebLookups(
@@ -92,13 +97,14 @@ export default function contribute(server: PluginServerContext) {
92
97
  const current = await settings.read();
93
98
  if (current.status === "ready" && !current.values.autoInstructions) return;
94
99
  const webOn = current.status === "ready" ? current.values.webLookups : true;
100
+ const extraFolders = current.status === "ready" ? parseFolders(current.values.extraFolders) : [];
95
101
  const existing = request.config.systemPrompt ?? "";
96
102
  if (existing.includes(GENUI_MARKER)) return;
97
103
  return {
98
104
  ...request,
99
105
  config: {
100
106
  ...request.config,
101
- systemPrompt: [existing, buildFullInstructions(webOn)].filter(Boolean).join("\n\n"),
107
+ systemPrompt: [existing, buildFullInstructions(webOn, extraFolders)].filter(Boolean).join("\n\n"),
102
108
  },
103
109
  };
104
110
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paseo-plugin-genui",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Paseo plugin: agents answer with charts, diagrams, maps, plans and forms rendered inline in the chat.",
5
5
  "keywords": [
6
6
  "paseo",
@@ -3,10 +3,12 @@ import { mkdir, open, readdir, readFile, realpath } from "node:fs/promises";
3
3
  import os from "node:os";
4
4
  import path from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
- import type { PaseoApi } from "@getpaseo/client";
6
+ import type { PluginHandlerContext } from "@getpaseo/plugin/server";
7
7
  import { collectLoads, compile, parseDataFile, type LoadedData } from "../shared/core";
8
8
  import { COMPONENTS, componentSignature, type ComponentName } from "../shared/core/catalog";
9
9
 
10
+ type PaseoApi = PluginHandlerContext["paseo"];
11
+
10
12
  export const MAX_DATA_BYTES = 2 * 1024 * 1024;
11
13
  export const MAX_IMAGE_BYTES = 5 * 1024 * 1024;
12
14
  export const MAX_AUDIO_BYTES = 25 * 1024 * 1024;
@@ -47,7 +49,19 @@ type FileContent =
47
49
 
48
50
  type FileReader = (requested: string, maxBytes: number) => Promise<FileContent>;
49
51
 
50
- const AGENT_REFUSAL = "only files in this agent's workspace, its thread storage or /tmp can be loaded";
52
+ const AGENT_REFUSAL =
53
+ "only files in this agent's workspace, its thread storage, /tmp or a folder added in Generative UI settings can be loaded";
54
+
55
+ let extraRoots: readonly string[] = [];
56
+
57
+ /** Folders, besides the workspace, thread storage and /tmp, that agents may load files from. */
58
+ export function setExtraLoadFolders(folders: readonly string[]): void {
59
+ extraRoots = folders.map(expandHome).filter((folder) => path.isAbsolute(folder));
60
+ }
61
+
62
+ function expandHome(requested: string): string {
63
+ return requested === "~" || requested.startsWith("~/") ? path.join(os.homedir(), requested.slice(1)) : requested;
64
+ }
51
65
  const GALLERY_REFUSAL = "gallery specs can only load files in gallery/";
52
66
 
53
67
  function contains(root: string, target: string): boolean {
@@ -189,10 +203,11 @@ async function readAgentFile(
189
203
  } else if (requested.startsWith(PASEO_STORAGE_PREFIX)) {
190
204
  const rel = requested.slice(PASEO_STORAGE_PREFIX.length);
191
205
  attempts = inside(storageRoot, path.resolve(storageRoot, rel));
192
- } else if (path.isAbsolute(requested)) {
193
- const target = path.resolve(requested);
206
+ } else if (path.isAbsolute(expandHome(requested))) {
207
+ const target = path.resolve(expandHome(requested));
194
208
  attempts = [...inside(storageRoot, target), ...inside(workspaceCwd, target)].slice(0, 1);
195
209
  if (attempts.length === 0) attempts = tempAttempts(target);
210
+ if (attempts.length === 0) attempts = extraRoots.flatMap((root) => inside(root, target)).slice(0, 1);
196
211
  } else {
197
212
  attempts = [
198
213
  ...inside(workspaceCwd, workspaceCwd !== null ? path.resolve(workspaceCwd, requested) : ""),
package/server/project.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { execFile } from "node:child_process";
2
2
  import { promisify } from "node:util";
3
- import type { PaseoApi } from "@getpaseo/client";
3
+ import type { PluginHandlerContext } from "@getpaseo/plugin/server";
4
4
  import type {
5
5
  EnvironmentDetail,
6
6
  EnvironmentDetailResult,
@@ -34,6 +34,8 @@ import {
34
34
  import { lastMessage } from "../shared/core/thread-activity";
35
35
  import { resolveAgentCwd } from "./data-source";
36
36
 
37
+ type PaseoApi = PluginHandlerContext["paseo"];
38
+
37
39
  const execFileAsync = promisify(execFile);
38
40
 
39
41
  function failure(reason: ProjectFailure["reason"], message: string): ProjectFailure {
@@ -1,7 +1,8 @@
1
1
  import { mkdir, rm, symlink, writeFile } from "node:fs/promises";
2
+ import os from "node:os";
2
3
  import path from "node:path";
3
4
  import { describe, expect, it } from "vitest";
4
- import type { PaseoApi } from "@getpaseo/client";
5
+ import type { PluginHandlerContext } from "@getpaseo/plugin/server";
5
6
  import {
6
7
  collectLoads,
7
8
  compile,
@@ -26,8 +27,11 @@ import {
26
27
  loadAgentImage,
27
28
  loadGalleryFile,
28
29
  readGallerySpec,
30
+ setExtraLoadFolders,
29
31
  } from "../server/data-source";
30
32
 
33
+ type PaseoApi = PluginHandlerContext["paseo"];
34
+
31
35
  describe("paseo-plugin-genui core, instructions, and gallery", () => {
32
36
  it("compiles every example in the agent instructions cleanly", () => {
33
37
  for (const section of [
@@ -234,4 +238,26 @@ describe("paseo-plugin-genui core, instructions, and gallery", () => {
234
238
  await rm(testRoot, { recursive: true, force: true });
235
239
  }
236
240
  });
241
+ it("loads files from extra folders only once they are added in settings", async () => {
242
+ const folder = path.join(os.homedir(), `.genui-extra-folder-test-${Date.now()}`);
243
+ await mkdir(folder, { recursive: true });
244
+ try {
245
+ const file = path.join(folder, "notes.txt");
246
+ await writeFile(file, "scratch-line\n", "utf8");
247
+ const mockPaseo = {
248
+ agents: { ref: () => ({ current: () => ({ cwd: "/nonexistent-workspace" }), refresh: async () => null }) },
249
+ } as unknown as PaseoApi;
250
+ const tilde = `~/${path.basename(folder)}/notes.txt`;
251
+
252
+ expect((await loadAgentFile(mockPaseo, "agent_extra_test", file, { raw: true })).ok).toBe(false);
253
+
254
+ setExtraLoadFolders([`~/${path.basename(folder)}`]);
255
+ expect(await loadAgentFile(mockPaseo, "agent_extra_test", file, { raw: true })).toEqual({ ok: true, value: "scratch-line\n" });
256
+ expect(await loadAgentFile(mockPaseo, "agent_extra_test", tilde, { raw: true })).toEqual({ ok: true, value: "scratch-line\n" });
257
+ expect((await loadAgentFile(mockPaseo, "agent_extra_test", path.join(os.homedir(), ".bashrc"), { raw: true })).ok).toBe(false);
258
+ } finally {
259
+ setExtraLoadFolders([]);
260
+ await rm(folder, { recursive: true, force: true });
261
+ }
262
+ });
237
263
  });
@@ -28,7 +28,7 @@ Syntax: one statement per line. \`$x = 8\` is state inputs bind to; \`name = exp
28
28
  Components (? optional; tone: neutral|good|warn|bad|info if meaningful; more in the next section):
29
29
  ${componentLines(REFERENCE_GROUPS)}
30
30
  Actions: ${actionList}; a list runs in order; Send posts as the user.
31
- Data: Load("path") reads JSON/CSV/TSV/JSONL from the workspace, "$BB_THREAD_STORAGE/x.json" or /tmp into lists and objects, and other files (a log, tsc output) as text; never retype values a file or command output holds. Snippet and Image read files the same way.
31
+ Data: Load("path") reads JSON/CSV/TSV/JSONL from the workspace, "$BB_THREAD_STORAGE/x.json" or /tmp into lists and objects, and other files (a log, tsc output) as text; never retype values a file or command output holds. Snippet and Image read files the same way. Any other path fails to load: copy the file into $BB_THREAD_STORAGE first.
32
32
  Games, simulations, custom visuals: write \`\`\`app, a self-contained HTML page (inline CSS/JS, CSS vars --foreground --muted-foreground --border --primary --card; sandboxed, no network).`;
33
33
 
34
34
  export const UI_REFERENCE_MORE = `# Inline UI reference, continued
@@ -133,10 +133,11 @@ export const AGENT_INSTRUCTIONS_WEB_OFF = AGENT_INSTRUCTIONS.replace(MAP_EXAMPLE
133
133
 
134
134
  export const GENUI_MARKER = "[paseo-plugin-genui]";
135
135
 
136
- export function buildFullInstructions(webLookups: boolean): string {
136
+ export function buildFullInstructions(webLookups: boolean, extraFolders: readonly string[] = []): string {
137
137
  return [
138
138
  GENUI_MARKER,
139
139
  UI_REFERENCE,
140
+ ...(extraFolders.length > 0 ? [`Load, Snippet and Image also read absolute paths under: ${extraFolders.join(", ")}.`] : []),
140
141
  UI_REFERENCE_MORE,
141
142
  CODE_WORK_INSTRUCTIONS,
142
143
  webLookups ? AGENT_INSTRUCTIONS : AGENT_INSTRUCTIONS_WEB_OFF,
@@ -8,5 +8,13 @@ export const genuiSettings = defineSettings({
8
8
  schema: z.object({
9
9
  autoInstructions: z.boolean().default(true),
10
10
  webLookups: z.boolean().default(true),
11
+ extraFolders: z.string().default(""),
11
12
  }),
12
13
  });
14
+
15
+ export function parseFolders(value: string): string[] {
16
+ return value
17
+ .split(/[,\n]/)
18
+ .map((folder) => folder.trim())
19
+ .filter((folder) => folder !== "");
20
+ }