@abide/bridge 0.8.0 → 0.8.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @abide/bridge
2
2
 
3
+ ## 0.8.2
4
+
5
+ ### Patch Changes
6
+
7
+ - d8fef91: one withoutScheme; SITE_OPTIONS keyed by ClaudeCodeConfig; bridge() drops options nothing passes ([`4725199`](https://github.com/briancray/abide/commit/4725199666442d61d52758aec21615491d6a37c1))
8
+
9
+ ## 0.8.1
10
+
11
+ ### Patch Changes
12
+
13
+ - e5b48ef: a call of one MCP tool is made under the grant alone — no --allowedTools past it, since a turn's prompt is the site's to answer (44.83) and a call is already the site's own choice of tool and input; --disallowedTools still refuses — RULEBOOK 44.94 ([`ac0c77c`](https://github.com/briancray/abide/commit/ac0c77ceae8789bb726ba3aa41de8c2971cc19db))
14
+
3
15
  ## 0.8.0
4
16
 
5
17
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abide/bridge",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "type": "module",
5
5
  "description": "Connects the Claude Code on your machine to the assistant on an abide site",
6
6
  "license": "MIT",
@@ -3,7 +3,7 @@
3
3
  // holder `/__abide/bridge` named when the visitor allowed it — a code an attacker minted is minted for
4
4
  // the attacker, and is asked about. A visitor who allowed a site full access, or only its own tools
5
5
  // (44.86), is not asked again: it runs as they allowed it, whatever it asks for.
6
- import { siteOf } from './pairingLink.ts'
6
+ import { siteOf, withoutScheme } from './pairingLink.ts'
7
7
 
8
8
  /**
9
9
  * A site paired unasked, for one holder, while a link asks for none but `tools` — or whatever it asks
@@ -97,7 +97,3 @@ export async function forget(file: string, site?: string): Promise<number> {
97
97
  await Bun.write(file, JSON.stringify(kept, null, 4))
98
98
  return sites.length - kept.length
99
99
  }
100
-
101
- function withoutScheme(site: string): string {
102
- return site.slice(site.indexOf('://') + 3)
103
- }
package/src/bridge.ts CHANGED
@@ -35,11 +35,10 @@ type Report = TurnReport | { type: 'missing'; tools: string[] }
35
35
  export async function bridge(options: {
36
36
  site: string
37
37
  code: string
38
- claude?: string
38
+ claude: string
39
39
  claudeArgs?: string[]
40
40
  /** Everything `claude` has is the site's to use, prompts asked of its page. 44.82. */
41
41
  full?: boolean
42
- say?: (line: string) => void
43
42
  replyMilliseconds?: number
44
43
  silenceMilliseconds?: number
45
44
  }): Promise<void> {
@@ -48,7 +47,7 @@ export async function bridge(options: {
48
47
  // WHAT IS SAID IS READ AS A NOTIFICATION, where a link opened the bridge (`opened.ts`): one short
49
48
  // sentence naming the site by its host. The detail goes to Claude Code, in the failure it is answered.
50
49
  const host = new URL(site).host
51
- const say = options.say ?? ((line: string) => console.error(line))
50
+ const say = (line: string): void => console.error(line)
52
51
  const full = options.full ?? false
53
52
  const silenceMilliseconds =
54
53
  options.silenceMilliseconds ?? SILENCE_MILLISECONDS
@@ -159,7 +158,7 @@ export async function bridge(options: {
159
158
 
160
159
  const core = serveTurns({
161
160
  site,
162
- claude: options.claude ?? 'claude',
161
+ claude: options.claude,
163
162
  claudeArgs: () => options.claudeArgs ?? [],
164
163
  full,
165
164
  report,
package/src/claudeTurn.ts CHANGED
@@ -78,16 +78,20 @@ type CodeLine = {
78
78
  }
79
79
 
80
80
  // 44.16 — the options a site may set: each only shapes the answer, and reaches nothing of this machine.
81
- const SITE_OPTIONS = new Set([
82
- 'model',
83
- 'fallbackModel',
84
- 'systemPrompt',
85
- 'appendSystemPrompt',
86
- 'effort',
87
- 'maxBudgetUsd',
88
- 'betas',
89
- 'disallowedTools',
90
- ])
81
+ // Keyed by `ClaudeCodeConfig`'s own keys, so a key added on abide's side is a compile error here
82
+ // until it is decided whether a site may set it.
83
+ const SITE_OPTIONS = new Set(
84
+ Object.keys({
85
+ model: true,
86
+ fallbackModel: true,
87
+ systemPrompt: true,
88
+ appendSystemPrompt: true,
89
+ effort: true,
90
+ maxBudgetUsd: true,
91
+ betas: true,
92
+ disallowedTools: true,
93
+ } satisfies Record<keyof Omit<ClaudeCodeConfig, 'tools'>, true>),
94
+ )
91
95
 
92
96
  /** Claude Code's flag for an option named in camelCase: `fallbackModel` is `--fallback-model`. */
93
97
  function flagOf(option: string): string {
package/src/grant.ts CHANGED
@@ -236,8 +236,8 @@ function namesTool(
236
236
  /**
237
237
  * How a call of `tool` reaches this machine for a visitor who passed `claudeArgs` — the server it is
238
238
  * of, that server's configuration and the tool's name on it — or why it is refused: it is not an MCP
239
- * tool, a turn whose `tools` named it alone would not be given it (44.29), the visitor's
240
- * `--allowedTools` does not approve it, or their `--disallowedTools` names it. 44.94.
239
+ * tool, a turn whose `tools` named it alone would not be given it (44.29), or the visitor's
240
+ * `--disallowedTools` names it. 44.94.
241
241
  *
242
242
  * Throws where an `--mcp-config` they named cannot be read.
243
243
  */
@@ -269,17 +269,13 @@ export async function callGrant(
269
269
  return { refused: withheldNotices(grant).join(' ') }
270
270
  // 44.82 — a full bridge's options as the visitor gave them.
271
271
  const given = full ? [...claudeArgs] : args
272
- const allowed = takeFlag(given, ['--allowedTools', '--allowed-tools'])
273
272
  const denied = takeFlag(given, ['--disallowedTools', '--disallowed-tools'])
274
273
  if (namesTool(denied, tool, server))
275
274
  return {
276
275
  refused: `The site called ${tool}, which this bridge’s --disallowedTools names.`,
277
276
  }
278
- // A turn asks what auto mode would not approve; a call has no model to judge it, so it asks nothing.
279
- if (!namesTool(allowed, tool, server))
280
- return {
281
- refused: `The site called ${tool} directly, which this bridge does only for a tool you approved. Add \`-- --allowedTools ${tool}\` to allow it.`,
282
- }
277
+ // 44.94 — the grant is the visitor's consent, and nothing past it asks: a turn's prompt is the
278
+ // site's to answer (44.83), and a call is already the site's own choice of tool and input.
283
279
  return {
284
280
  server,
285
281
  configuration: grant.servers[server],
package/src/opened.ts CHANGED
@@ -21,7 +21,7 @@ import {
21
21
  import { BRIDGE_PATH } from './BRIDGE_PATH.ts'
22
22
  import { type Answer, ask, notify, type Question } from './desktop.ts'
23
23
  import { grantFor, serversNamed } from './grant.ts'
24
- import { type Pairing, pairingOf } from './pairingLink.ts'
24
+ import { type Pairing, pairingOf, withoutScheme } from './pairingLink.ts'
25
25
  import { readLines } from './readLines.ts'
26
26
  import { requestedLines } from './requestedLines.ts'
27
27
  import { siteTls } from './siteTls.ts'
@@ -42,11 +42,6 @@ export type HandlerSettings = {
42
42
  env: Record<string, string>
43
43
  }
44
44
 
45
- /** A site as the visitor reads it: what a link names, without its scheme. */
46
- function shownSite(site: string): string {
47
- return site.slice(site.indexOf('://') + 3)
48
- }
49
-
50
45
  /** Whether the visitor's options leave Claude Code in auto mode (44.81). */
51
46
  function inAutoMode(claudeArgs: readonly string[]): boolean {
52
47
  for (const arg of claudeArgs)
@@ -84,7 +79,7 @@ export function question(
84
79
  note,
85
80
  }: { name?: string | undefined; note?: string | undefined } = {},
86
81
  ): Question {
87
- const site = shownSite(pairing.site)
82
+ const site = withoutScheme(pairing.site)
88
83
  // The name is the site's to choose, so the site it is served from is always beside it.
89
84
  const asker = name === undefined ? site : `${name} (${site})`
90
85
  const owner = name ?? site
@@ -329,7 +324,7 @@ export async function consented(
329
324
  })
330
325
  if (before !== undefined) {
331
326
  say(
332
- `Pairing with ${asker.name ?? shownSite(pairing.site)}, which you always allow.`,
327
+ `Pairing with ${asker.name ?? withoutScheme(pairing.site)}, which you always allow.`,
333
328
  )
334
329
  return before.granted === 'siteTools' ? siteToolsOnly(pairing) : pairing
335
330
  }
@@ -78,3 +78,8 @@ export function pairingOf(link: string): Pairing | undefined {
78
78
  export function siteOf(url: URL): string {
79
79
  return `${url.origin}${url.pathname}`.replace(/\/+$/, '')
80
80
  }
81
+
82
+ /** A site as a person reads it: `siteOf`'s, with no scheme. */
83
+ export function withoutScheme(site: string): string {
84
+ return site.slice(site.indexOf('://') + 3)
85
+ }