opencode-ahp 0.1.4 → 0.1.6
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 +91 -37
- package/options.example.jsonc +25 -8
- package/package.json +1 -1
- package/src/bridge.ts +335 -127
- package/src/channels.ts +74 -32
- package/src/client-tools.ts +127 -0
- package/src/handshake.ts +2 -3
- package/src/host-base.ts +335 -0
- package/src/host-changesets.ts +381 -0
- package/src/host-chats.ts +300 -0
- package/src/host-client-tools.ts +205 -0
- package/src/host-dispatch.ts +593 -0
- package/src/host-errors.ts +29 -0
- package/src/host-events.ts +386 -0
- package/src/host-rpc.ts +435 -0
- package/src/host-sessions.ts +558 -0
- package/src/host-terminals.ts +654 -0
- package/src/host-turns.ts +82 -0
- package/src/host-types.ts +225 -0
- package/src/host-util.ts +194 -0
- package/src/host.ts +23 -2299
- package/src/index.ts +265 -33
- package/src/keep-alive.ts +3 -3
- package/src/options.ts +23 -9
- package/src/seq.ts +4 -5
- package/src/state.ts +40 -6
- package/src/transport.ts +6 -6
package/src/transport.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* AHP transport
|
|
2
|
+
* AHP transport.
|
|
3
3
|
*
|
|
4
4
|
* Two layers:
|
|
5
5
|
*
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* policy, path routing, loopback check. Unit-tested without a runtime.
|
|
8
8
|
* 2. **A thin listener** behind the `Listener` interface. The reference
|
|
9
9
|
* implementation uses `Bun.serve` (opencode v2 is Bun-based, so the
|
|
10
|
-
* in-process plugin runtime has it
|
|
11
|
-
*
|
|
10
|
+
* in-process plugin runtime has it). If the plugin context ever
|
|
11
|
+
* forbids raw listeners, a `ws`-
|
|
12
12
|
* package implementation drops in here with no changes to the
|
|
13
13
|
* protocol layer.
|
|
14
14
|
*
|
|
@@ -71,7 +71,7 @@ export function tokenValid(expected: string, presented: string | null): boolean
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
* Origin policy
|
|
74
|
+
* Origin policy. The token is the only credential; this only
|
|
75
75
|
* filters *which* browser origins may attempt a connection. A null Origin
|
|
76
76
|
* (non-browser clients: VS Code's own connection, CLI clients) always
|
|
77
77
|
* passes — browser-origin filtering is the real attack surface.
|
|
@@ -183,7 +183,7 @@ const textDecoder = new TextDecoder();
|
|
|
183
183
|
/**
|
|
184
184
|
* Start the AHP listener. Throws before binding when a non-loopback
|
|
185
185
|
* address is given without a token (R4) or when the runtime lacks
|
|
186
|
-
* `Bun.serve` (
|
|
186
|
+
* `Bun.serve` (the fallback implementation would be added here).
|
|
187
187
|
*/
|
|
188
188
|
export function createListener(opts: ListenerOptions, callbacks: TransportCallbacks): Listener {
|
|
189
189
|
if (!isLoopback(opts.host) && !opts.token) {
|
|
@@ -194,7 +194,7 @@ export function createListener(opts: ListenerOptions, callbacks: TransportCallba
|
|
|
194
194
|
const bun = bunOf();
|
|
195
195
|
if (!bun) {
|
|
196
196
|
throw new Error(
|
|
197
|
-
"Bun.serve is not available in this runtime
|
|
197
|
+
"Bun.serve is not available in this runtime; expected inside the " +
|
|
198
198
|
"Bun-based opencode v2 server — a `ws`-package fallback would go here",
|
|
199
199
|
);
|
|
200
200
|
}
|