@getpaseo/client 0.2.2 → 0.2.4
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/dist/daemon-client-relay-e2ee-transport.js +4 -4
- package/dist/daemon-client-transport-types.d.ts +1 -1
- package/dist/daemon-client-transport-utils.d.ts +5 -1
- package/dist/daemon-client-transport-utils.js +8 -6
- package/dist/daemon-client-transport.d.ts +1 -1
- package/dist/daemon-client-transport.js +1 -1
- package/dist/daemon-client-websocket-transport.js +9 -1
- package/dist/daemon-client.d.ts +13 -0
- package/dist/daemon-client.js +41 -0
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createClientChannel, } from "@getpaseo/relay/e2ee";
|
|
2
|
-
import {
|
|
2
|
+
import { extractRelayMessage, normalizeTransportPayload } from "./daemon-client-transport-utils.js";
|
|
3
3
|
export function createRelayE2eeTransportFactory(args) {
|
|
4
4
|
return ({ url, headers }) => {
|
|
5
5
|
const base = args.baseFactory({ url, headers });
|
|
@@ -38,7 +38,7 @@ export function createEncryptedTransport(base, daemonPublicKeyB64, logger) {
|
|
|
38
38
|
if (closed) {
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
|
-
emitHandlers(messageHandlers, data);
|
|
41
|
+
emitHandlers(messageHandlers, data, data instanceof ArrayBuffer);
|
|
42
42
|
};
|
|
43
43
|
const relayTransport = {
|
|
44
44
|
send: (data) => {
|
|
@@ -81,8 +81,8 @@ export function createEncryptedTransport(base, daemonPublicKeyB64, logger) {
|
|
|
81
81
|
base.onOpen(() => {
|
|
82
82
|
void startHandshake();
|
|
83
83
|
});
|
|
84
|
-
base.onMessage((
|
|
85
|
-
relayTransport.onmessage?.(
|
|
84
|
+
base.onMessage((data, isBinary) => {
|
|
85
|
+
relayTransport.onmessage?.(extractRelayMessage(data, isBinary));
|
|
86
86
|
});
|
|
87
87
|
base.onClose((event) => {
|
|
88
88
|
const record = event;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export interface DaemonTransport {
|
|
2
2
|
send: (data: string | Uint8Array | ArrayBuffer) => void;
|
|
3
3
|
close: (code?: number, reason?: string) => void;
|
|
4
|
-
onMessage: (handler: (data: unknown) => void) => () => void;
|
|
4
|
+
onMessage: (handler: (data: unknown, isBinary: boolean) => void) => () => void;
|
|
5
5
|
onOpen: (handler: () => void) => () => void;
|
|
6
6
|
onClose: (handler: (event?: unknown) => void) => () => void;
|
|
7
7
|
onError: (handler: (event?: unknown) => void) => () => void;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export declare function copyArrayBufferViewToBuffer(data: ArrayBufferView): ArrayBuffer;
|
|
2
2
|
export declare function normalizeTransportPayload(data: string | Uint8Array | ArrayBuffer): string | ArrayBuffer;
|
|
3
|
-
export
|
|
3
|
+
export interface RelayTransportMessage {
|
|
4
|
+
data: string | ArrayBuffer;
|
|
5
|
+
isBinary: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function extractRelayMessage(event: unknown, nodeIsBinary?: boolean): RelayTransportMessage;
|
|
4
8
|
export declare function describeTransportClose(event?: unknown): string;
|
|
5
9
|
export declare function describeTransportError(event?: unknown): string;
|
|
6
10
|
export declare function safeRandomId(): string;
|
|
@@ -10,18 +10,20 @@ export function normalizeTransportPayload(data) {
|
|
|
10
10
|
}
|
|
11
11
|
return copyArrayBufferViewToBuffer(data);
|
|
12
12
|
}
|
|
13
|
-
export function
|
|
13
|
+
export function extractRelayMessage(event, nodeIsBinary) {
|
|
14
14
|
const raw = event && typeof event === "object" && "data" in event
|
|
15
15
|
? event.data
|
|
16
16
|
: event;
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const isBinary = nodeIsBinary ?? typeof raw !== "string";
|
|
18
|
+
if (!isBinary) {
|
|
19
|
+
return { data: decodeMessageData(raw) ?? String(raw ?? ""), isBinary: false };
|
|
20
|
+
}
|
|
19
21
|
if (raw instanceof ArrayBuffer)
|
|
20
|
-
return raw;
|
|
22
|
+
return { data: raw, isBinary: true };
|
|
21
23
|
if (ArrayBuffer.isView(raw)) {
|
|
22
|
-
return copyArrayBufferViewToBuffer(raw);
|
|
24
|
+
return { data: copyArrayBufferViewToBuffer(raw), isBinary: true };
|
|
23
25
|
}
|
|
24
|
-
return String(raw ?? "");
|
|
26
|
+
return { data: String(raw ?? ""), isBinary: true };
|
|
25
27
|
}
|
|
26
28
|
export function describeTransportClose(event) {
|
|
27
29
|
if (!event) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { DaemonTransport, DaemonTransportFactory, TransportLogger, WebSocketFactory, WebSocketLike, } from "./daemon-client-transport-types.js";
|
|
2
|
-
export { decodeMessageData, describeTransportClose, describeTransportError, encodeUtf8String,
|
|
2
|
+
export { decodeMessageData, describeTransportClose, describeTransportError, encodeUtf8String, extractRelayMessage, normalizeTransportPayload, safeRandomId, } from "./daemon-client-transport-utils.js";
|
|
3
3
|
export { createEncryptedTransport, createRelayE2eeTransportFactory, } from "./daemon-client-relay-e2ee-transport.js";
|
|
4
4
|
export { bindWsHandler, createWebSocketTransportFactory, defaultWebSocketFactory, } from "./daemon-client-websocket-transport.js";
|
|
5
5
|
//# sourceMappingURL=daemon-client-transport.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { decodeMessageData, describeTransportClose, describeTransportError, encodeUtf8String,
|
|
1
|
+
export { decodeMessageData, describeTransportClose, describeTransportError, encodeUtf8String, extractRelayMessage, normalizeTransportPayload, safeRandomId, } from "./daemon-client-transport-utils.js";
|
|
2
2
|
export { createEncryptedTransport, createRelayE2eeTransportFactory, } from "./daemon-client-relay-e2ee-transport.js";
|
|
3
3
|
export { bindWsHandler, createWebSocketTransportFactory, defaultWebSocketFactory, } from "./daemon-client-websocket-transport.js";
|
|
4
4
|
//# sourceMappingURL=daemon-client-transport.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { extractRelayMessage } from "./daemon-client-transport-utils.js";
|
|
1
2
|
export function defaultWebSocketFactory(url, options) {
|
|
2
3
|
const globalWs = globalThis.WebSocket;
|
|
3
4
|
if (!globalWs) {
|
|
@@ -40,10 +41,17 @@ export function createWebSocketTransportFactory(factory) {
|
|
|
40
41
|
onOpen: (handler) => bindWsHandler(ws, "open", handler),
|
|
41
42
|
onClose: (handler) => bindWsHandler(ws, "close", handler),
|
|
42
43
|
onError: (handler) => bindWsHandler(ws, "error", handler),
|
|
43
|
-
onMessage: (handler) =>
|
|
44
|
+
onMessage: (handler) => bindWsMessageHandler(ws, handler),
|
|
44
45
|
};
|
|
45
46
|
};
|
|
46
47
|
}
|
|
48
|
+
function bindWsMessageHandler(ws, handler) {
|
|
49
|
+
const listener = (...args) => {
|
|
50
|
+
const message = extractRelayMessage(args[0], typeof args[1] === "boolean" ? args[1] : undefined);
|
|
51
|
+
handler(message.data, message.isBinary);
|
|
52
|
+
};
|
|
53
|
+
return bindWsHandler(ws, "message", listener);
|
|
54
|
+
}
|
|
47
55
|
function bindTemporaryEarlyCloseErrorHandler(ws) {
|
|
48
56
|
const noop = () => { };
|
|
49
57
|
if (typeof ws.addEventListener === "function") {
|
package/dist/daemon-client.d.ts
CHANGED
|
@@ -424,6 +424,9 @@ export type FetchWorkspacesOptions = Omit<FetchWorkspacesRequest, "type" | "requ
|
|
|
424
424
|
};
|
|
425
425
|
export type FetchWorkspacesEntry = FetchWorkspacesPayload["entries"][number];
|
|
426
426
|
export type FetchWorkspacesPageInfo = FetchWorkspacesPayload["pageInfo"];
|
|
427
|
+
export type ProjectListPayload = Extract<SessionOutboundMessage, {
|
|
428
|
+
type: "project.list.response";
|
|
429
|
+
}>["payload"];
|
|
427
430
|
export interface CreateChatRoomOptions {
|
|
428
431
|
name: string;
|
|
429
432
|
purpose?: string | null;
|
|
@@ -701,6 +704,7 @@ export declare class DaemonClient {
|
|
|
701
704
|
fetchAgentHistory(options?: FetchAgentHistoryOptions): Promise<FetchAgentHistoryPayload>;
|
|
702
705
|
fetchRecentProviderSessions(options?: FetchRecentProviderSessionsOptions): Promise<FetchRecentProviderSessionsPayload>;
|
|
703
706
|
fetchWorkspaces(options?: FetchWorkspacesOptions): Promise<FetchWorkspacesPayload>;
|
|
707
|
+
listProjects(requestId?: string): Promise<ProjectListPayload>;
|
|
704
708
|
openProject(cwd: string, requestId?: string): Promise<OpenProjectPayload>;
|
|
705
709
|
addProject(cwd: string, requestId?: string): Promise<ProjectAddPayload>;
|
|
706
710
|
createProjectDirectory(input: {
|
|
@@ -719,6 +723,15 @@ export declare class DaemonClient {
|
|
|
719
723
|
startWorkspaceScript(workspaceId: string, scriptName: string, requestId?: string): Promise<Extract<SessionOutboundMessage, {
|
|
720
724
|
type: "start_workspace_script_response";
|
|
721
725
|
}>["payload"]>;
|
|
726
|
+
listWorkspaceScripts(workspaceId: string, requestId?: string): Promise<Extract<SessionOutboundMessage, {
|
|
727
|
+
type: "workspace.script.list.response";
|
|
728
|
+
}>["payload"]>;
|
|
729
|
+
startWorkspaceScriptWithStatus(workspaceId: string, scriptName: string, requestId?: string): Promise<Extract<SessionOutboundMessage, {
|
|
730
|
+
type: "workspace.script.start.response";
|
|
731
|
+
}>["payload"]>;
|
|
732
|
+
stopWorkspaceScript(workspaceId: string, scriptName: string, requestId?: string): Promise<Extract<SessionOutboundMessage, {
|
|
733
|
+
type: "workspace.script.stop.response";
|
|
734
|
+
}>["payload"]>;
|
|
722
735
|
archiveWorkspace(workspaceId: string, requestId?: string): Promise<ArchiveWorkspacePayload>;
|
|
723
736
|
fetchWorkspaceSetupStatus(workspaceId: string, requestId?: string): Promise<WorkspaceSetupStatusPayload>;
|
|
724
737
|
fetchAgent(options: FetchAgentOptions): Promise<FetchAgentResult | null>;
|
package/dist/daemon-client.js
CHANGED
|
@@ -1064,6 +1064,25 @@ export class DaemonClient {
|
|
|
1064
1064
|
},
|
|
1065
1065
|
});
|
|
1066
1066
|
}
|
|
1067
|
+
async listProjects(requestId) {
|
|
1068
|
+
const resolvedRequestId = this.createRequestId(requestId);
|
|
1069
|
+
const message = SessionInboundMessageSchema.parse({
|
|
1070
|
+
type: "project.list.request",
|
|
1071
|
+
requestId: resolvedRequestId,
|
|
1072
|
+
});
|
|
1073
|
+
return this.sendRequest({
|
|
1074
|
+
requestId: resolvedRequestId,
|
|
1075
|
+
message,
|
|
1076
|
+
options: { skipQueue: true },
|
|
1077
|
+
select: (msg) => {
|
|
1078
|
+
if (msg.type !== "project.list.response")
|
|
1079
|
+
return null;
|
|
1080
|
+
if (msg.payload.requestId !== resolvedRequestId)
|
|
1081
|
+
return null;
|
|
1082
|
+
return msg.payload;
|
|
1083
|
+
},
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1067
1086
|
async openProject(cwd, requestId) {
|
|
1068
1087
|
return this.sendCorrelatedSessionRequest({
|
|
1069
1088
|
requestId,
|
|
@@ -1128,6 +1147,27 @@ export class DaemonClient {
|
|
|
1128
1147
|
responseType: "start_workspace_script_response",
|
|
1129
1148
|
});
|
|
1130
1149
|
}
|
|
1150
|
+
async listWorkspaceScripts(workspaceId, requestId) {
|
|
1151
|
+
return this.sendCorrelatedSessionRequest({
|
|
1152
|
+
requestId,
|
|
1153
|
+
message: { type: "workspace.script.list.request", workspaceId },
|
|
1154
|
+
responseType: "workspace.script.list.response",
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
async startWorkspaceScriptWithStatus(workspaceId, scriptName, requestId) {
|
|
1158
|
+
return this.sendCorrelatedSessionRequest({
|
|
1159
|
+
requestId,
|
|
1160
|
+
message: { type: "workspace.script.start.request", workspaceId, scriptName },
|
|
1161
|
+
responseType: "workspace.script.start.response",
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
async stopWorkspaceScript(workspaceId, scriptName, requestId) {
|
|
1165
|
+
return this.sendCorrelatedSessionRequest({
|
|
1166
|
+
requestId,
|
|
1167
|
+
message: { type: "workspace.script.stop.request", workspaceId, scriptName },
|
|
1168
|
+
responseType: "workspace.script.stop.response",
|
|
1169
|
+
});
|
|
1170
|
+
}
|
|
1131
1171
|
async archiveWorkspace(workspaceId, requestId) {
|
|
1132
1172
|
return this.sendCorrelatedSessionRequest({
|
|
1133
1173
|
requestId,
|
|
@@ -2200,6 +2240,7 @@ export class DaemonClient {
|
|
|
2200
2240
|
cwd: payload.cwd,
|
|
2201
2241
|
files: payload.files,
|
|
2202
2242
|
error: payload.error,
|
|
2243
|
+
diffTooLarge: payload.diffTooLarge,
|
|
2203
2244
|
requestId: payload.requestId,
|
|
2204
2245
|
};
|
|
2205
2246
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpaseo/client",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Paseo client SDK package",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"test": "vitest run"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@getpaseo/protocol": "0.2.
|
|
39
|
-
"@getpaseo/relay": "0.2.
|
|
38
|
+
"@getpaseo/protocol": "0.2.4",
|
|
39
|
+
"@getpaseo/relay": "0.2.4",
|
|
40
40
|
"zod": "^4.4.3"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|