@opencode-ai/client
Advanced tools
+10
-1
@@ -1,2 +0,2 @@ | ||
| import type { OpenCodeClient, PtyConnectTokenInput } from "../promise"; | ||
| import type { ExperimentalPersistentPtyConnectTokenInput, OpenCodeClient, PtyConnectTokenInput } from "../promise"; | ||
| export type PtyClientOptions = { | ||
@@ -11,4 +11,13 @@ readonly url: string; | ||
| }; | ||
| export type PersistentPtyConnectInput = { | ||
| readonly ptyID: ExperimentalPersistentPtyConnectTokenInput["ptyID"]; | ||
| readonly cursor: number; | ||
| readonly attachmentID: string; | ||
| readonly takeover?: boolean; | ||
| }; | ||
| export declare function createPtyClient(api: OpenCodeClient, options: PtyClientOptions): { | ||
| connect(input: PtyConnectInput): Promise<WebSocket>; | ||
| }; | ||
| export declare function createPersistentPtyClient(api: OpenCodeClient, options: PtyClientOptions): { | ||
| connect(input: PersistentPtyConnectInput): Promise<WebSocket>; | ||
| }; |
+20
-0
@@ -24,1 +24,21 @@ export function createPtyClient(api, options) { | ||
| } | ||
| export function createPersistentPtyClient(api, options) { | ||
| return { | ||
| async connect(input) { | ||
| const token = await api.experimental.persistentPty.connectToken({ | ||
| ptyID: input.ptyID, | ||
| "x-opencode-ticket": "1", | ||
| }); | ||
| const url = new URL(`/api/experimental/persistent-pty/${encodeURIComponent(input.ptyID)}/connect`, options.url); | ||
| url.searchParams.set("ticket", token.ticket); | ||
| url.searchParams.set("cursor", String(input.cursor)); | ||
| url.searchParams.set("attachment_id", input.attachmentID); | ||
| url.searchParams.set("takeover", String(input.takeover ?? false)); | ||
| url.searchParams.set("input_protocol", "1"); | ||
| url.protocol = url.protocol === "https:" ? "wss:" : "ws:"; | ||
| const socket = options.openSocket?.(url) ?? new WebSocket(url); | ||
| socket.binaryType = "arraybuffer"; | ||
| return socket; | ||
| }, | ||
| }; | ||
| } |
+4
-4
| { | ||
| "$schema": "https://json.schemastore.org/package.json", | ||
| "name": "@opencode-ai/client", | ||
| "version": "0.0.0-dev-18297", | ||
| "version": "0.0.0-dev-18298", | ||
| "type": "module", | ||
@@ -60,4 +60,4 @@ "license": "MIT", | ||
| "dependencies": { | ||
| "@opencode-ai/schema": "0.0.0-dev-18297", | ||
| "@opencode-ai/protocol": "0.0.0-dev-18297" | ||
| "@opencode-ai/schema": "0.0.0-dev-18298", | ||
| "@opencode-ai/protocol": "0.0.0-dev-18298" | ||
| }, | ||
@@ -78,3 +78,3 @@ "peerDependencies": { | ||
| "@effect/platform-node": "4.0.0-rc.111", | ||
| "@opencode-ai/httpapi-codegen": "0.0.0-dev-18297", | ||
| "@opencode-ai/httpapi-codegen": "0.0.0-dev-18298", | ||
| "@tsconfig/bun": "1.0.9", | ||
@@ -81,0 +81,0 @@ "@types/bun": "1.3.13", |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
782068
0.18%18811
0.15%+ Added
+ Added
- Removed
- Removed