@abide/bridge 0.8.1 → 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 +6 -0
- package/package.json +1 -1
- package/src/allowedSites.ts +1 -5
- package/src/bridge.ts +3 -4
- package/src/claudeTurn.ts +14 -10
- package/src/opened.ts +3 -8
- package/src/pairingLink.ts +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
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
|
+
|
|
3
9
|
## 0.8.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/package.json
CHANGED
package/src/allowedSites.ts
CHANGED
|
@@ -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
|
|
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 =
|
|
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
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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/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 =
|
|
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 ??
|
|
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
|
}
|
package/src/pairingLink.ts
CHANGED
|
@@ -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
|
+
}
|