@opencode/plugin-browser 0.0.0-dev-20327 → 0.0.0-dev-20328

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.
@@ -4,7 +4,7 @@ import { Tool } from "@opencode/schema/tool";
4
4
  import { Effect } from "effect";
5
5
  import { Browser } from "./rpc.js";
6
6
  export type Connection = Effect.Success<ReturnType<typeof make>>;
7
- export declare const make: (ctx: Pick<Context, "location" | "rpc" | "event" | "session">) => Effect.Effect<{
7
+ export declare const make: (ctx: Pick<Context, "location" | "rpc" | "agent" | "event" | "session">) => Effect.Effect<{
8
8
  target: (sessionID: string & import("effect/Brand").Brand<"SessionID">, action: {
9
9
  readonly type: "tabs.list";
10
10
  } | {
@@ -5,6 +5,19 @@ import { Browser } from "./rpc.js";
5
5
  import { BrowserTunnel } from "./tunnel.js";
6
6
  export const make = Effect.fn("BrowserConnection.make")(function* (ctx) {
7
7
  const browsers = new Map();
8
+ // Appended after config, so every agent hides the browser until an attachment allows it.
9
+ yield* ctx.agent.transform((editor) => editor.list().forEach((agent) => agent.permissions.push({ action: "browser", resource: "*", effect: "deny" })));
10
+ // Each attachment adds and removes its own allow, so a replaced attachment keeps the new one's.
11
+ const grant = (sessionID) => Effect.acquireRelease(ctx.session.get({ sessionID }).pipe(Effect.flatMap((session) => ctx.session.update({
12
+ sessionID,
13
+ permissions: [...(session.permissions ?? []), { action: "browser", resource: "*", effect: "allow" }],
14
+ })), Effect.orDie), () => ctx.session.get({ sessionID }).pipe(Effect.flatMap((session) => {
15
+ const permissions = session.permissions ?? [];
16
+ const index = permissions.findIndex((rule) => rule.action === "browser" && rule.resource === "*" && rule.effect === "allow");
17
+ if (index === -1)
18
+ return Effect.void;
19
+ return ctx.session.update({ sessionID, permissions: permissions.toSpliced(index, 1) });
20
+ }), Effect.ignore));
8
21
  let active = true;
9
22
  const close = (sessionID, reason = "closed") => Effect.gen(function* () {
10
23
  const browser = browsers.get(sessionID);
@@ -46,6 +59,7 @@ export const make = Effect.fn("BrowserConnection.make")(function* (ctx) {
46
59
  browsers.set(input.sessionID, browser);
47
60
  return browser;
48
61
  }), (browser) => (browsers.get(input.sessionID) === browser ? close(input.sessionID) : Effect.void));
62
+ yield* grant(input.sessionID);
49
63
  yield* rpc.events
50
64
  .emit("control", { type: "attached", connectionID: input.connectionID, version: 4 })
51
65
  .pipe(Effect.orDie);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@opencode/plugin-browser",
4
- "version": "0.0.0-dev-20327",
4
+ "version": "0.0.0-dev-20328",
5
5
  "description": "OpenCode's desktop browser plugin",
6
6
  "type": "module",
7
7
  "license": "MIT",
@@ -36,8 +36,8 @@
36
36
  "test": "bun test"
37
37
  },
38
38
  "dependencies": {
39
- "@opencode/plugin": "0.0.0-dev-20327",
40
- "@opencode/schema": "0.0.0-dev-20327",
39
+ "@opencode/plugin": "0.0.0-dev-20328",
40
+ "@opencode/schema": "0.0.0-dev-20328",
41
41
  "effect": "4.0.0-rc.112"
42
42
  },
43
43
  "devDependencies": {