@camerontaylor/paseo-client 0.8.0-fork.1
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 +44 -0
- package/dist/compat/normalize-provider-models.d.ts +11 -0
- package/dist/compat/normalize-provider-models.js +51 -0
- package/dist/connection/index.d.ts +42 -0
- package/dist/connection/index.js +111 -0
- package/dist/creation/index.d.ts +47 -0
- package/dist/creation/index.js +216 -0
- package/dist/daemon-client-relay-e2ee-transport.d.ts +8 -0
- package/dist/daemon-client-relay-e2ee-transport.js +161 -0
- package/dist/daemon-client-runtime-metrics.d.ts +39 -0
- package/dist/daemon-client-runtime-metrics.js +173 -0
- package/dist/daemon-client-transport-types.d.ts +36 -0
- package/dist/daemon-client-transport-types.js +2 -0
- package/dist/daemon-client-transport-utils.d.ts +13 -0
- package/dist/daemon-client-transport-utils.js +123 -0
- package/dist/daemon-client-transport.d.ts +5 -0
- package/dist/daemon-client-transport.js +4 -0
- package/dist/daemon-client-websocket-transport.d.ts +12 -0
- package/dist/daemon-client-websocket-transport.js +140 -0
- package/dist/daemon-client.d.ts +1245 -0
- package/dist/daemon-client.js +4783 -0
- package/dist/index.d.ts +383 -0
- package/dist/index.js +407 -0
- package/dist/provider-snapshots/index.d.ts +23 -0
- package/dist/provider-snapshots/index.js +60 -0
- package/dist/terminal-stream-router.d.ts +28 -0
- package/dist/terminal-stream-router.js +109 -0
- package/dist/terminals/index.d.ts +69 -0
- package/dist/terminals/index.js +103 -0
- package/package.json +51 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { DaemonClient } from "../daemon-client.js";
|
|
3
|
+
declare const TerminalSchema: z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
workspaceId: z.ZodString;
|
|
6
|
+
cwd: z.ZodString;
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export type PaseoTerminal = z.infer<typeof TerminalSchema>;
|
|
10
|
+
export interface PaseoTerminalCreateOptions {
|
|
11
|
+
workspaceId: string;
|
|
12
|
+
/** Process working directory; defaults to the workspace directory. */
|
|
13
|
+
cwd?: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
command?: string;
|
|
16
|
+
args?: string[];
|
|
17
|
+
size?: {
|
|
18
|
+
rows: number;
|
|
19
|
+
cols: number;
|
|
20
|
+
};
|
|
21
|
+
requestId?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface PaseoTerminalListOptions {
|
|
24
|
+
/** Ownership filter. When supplied, cwd does not restrict the results. */
|
|
25
|
+
workspaceId?: string;
|
|
26
|
+
/** Workspace root directory filter for unscoped listings. */
|
|
27
|
+
cwd?: string;
|
|
28
|
+
requestId?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface PaseoTerminalListResult {
|
|
31
|
+
entries: PaseoTerminal[];
|
|
32
|
+
requestId: string;
|
|
33
|
+
}
|
|
34
|
+
export interface PaseoTerminalCaptureOptions {
|
|
35
|
+
start?: number;
|
|
36
|
+
end?: number;
|
|
37
|
+
stripAnsi?: boolean;
|
|
38
|
+
requestId?: string;
|
|
39
|
+
}
|
|
40
|
+
export type PaseoTerminalCaptureResult = Awaited<ReturnType<DaemonClient["captureTerminal"]>>;
|
|
41
|
+
export interface PaseoTerminalHandle {
|
|
42
|
+
readonly id: string;
|
|
43
|
+
current(): PaseoTerminal | null;
|
|
44
|
+
refresh(options?: {
|
|
45
|
+
requestId?: string;
|
|
46
|
+
}): Promise<PaseoTerminal | null>;
|
|
47
|
+
/** Sends literal input and returns its UTF-16 length. Does not await command execution. */
|
|
48
|
+
write(data: string): number;
|
|
49
|
+
/** Expands CLI key tokens; other strings are literal. Returns the input's UTF-16 length. */
|
|
50
|
+
sendKeys(keys: readonly string[]): number;
|
|
51
|
+
capture(options?: PaseoTerminalCaptureOptions): Promise<PaseoTerminalCaptureResult>;
|
|
52
|
+
kill(requestId?: string): Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
export interface PaseoTerminalActions {
|
|
55
|
+
create(options: PaseoTerminalCreateOptions): Promise<PaseoTerminalHandle>;
|
|
56
|
+
list(options?: PaseoTerminalListOptions): Promise<PaseoTerminalListResult>;
|
|
57
|
+
ref(terminal: string | PaseoTerminal): PaseoTerminalHandle;
|
|
58
|
+
}
|
|
59
|
+
export interface PaseoWorkspaceTerminalActions {
|
|
60
|
+
create(options?: Omit<PaseoTerminalCreateOptions, "workspaceId">): Promise<PaseoTerminalHandle>;
|
|
61
|
+
list(options?: {
|
|
62
|
+
requestId?: string;
|
|
63
|
+
}): Promise<PaseoTerminalListResult>;
|
|
64
|
+
}
|
|
65
|
+
type TerminalClient = Pick<DaemonClient, "ensureConnected" | "getLastServerInfoMessage" | "createTerminal" | "listTerminals" | "sendTerminalInput" | "captureTerminal" | "killTerminal">;
|
|
66
|
+
/** @package */
|
|
67
|
+
export declare function createTerminalActions(daemonClient: TerminalClient, resolveWorkspaceDirectory: (workspaceId: string) => Promise<string>): PaseoTerminalActions;
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const TerminalSchema = z.object({
|
|
3
|
+
id: z.string(),
|
|
4
|
+
workspaceId: z.string(),
|
|
5
|
+
cwd: z.string(),
|
|
6
|
+
name: z.string(),
|
|
7
|
+
});
|
|
8
|
+
/** @package */
|
|
9
|
+
export function createTerminalActions(daemonClient, resolveWorkspaceDirectory) {
|
|
10
|
+
function client() {
|
|
11
|
+
daemonClient.ensureConnected();
|
|
12
|
+
// COMPAT(workspaceTerminals): added in v0.7.3, remove gate after 2027-09-05.
|
|
13
|
+
if (daemonClient.getLastServerInfoMessage()?.features?.workspaceTerminals !== true) {
|
|
14
|
+
throw new Error("Update the host to use workspace terminals through the SDK.");
|
|
15
|
+
}
|
|
16
|
+
return daemonClient;
|
|
17
|
+
}
|
|
18
|
+
const list = async (options = {}) => {
|
|
19
|
+
const result = await client().listTerminals(options.cwd, options.requestId, {
|
|
20
|
+
workspaceId: options.workspaceId,
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
entries: result.terminals.map((terminal) => TerminalSchema.parse(terminal)),
|
|
24
|
+
requestId: result.requestId,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const ref = (terminal) => {
|
|
28
|
+
const id = typeof terminal === "string" ? terminal : terminal.id;
|
|
29
|
+
let current = typeof terminal === "string" ? null : terminal;
|
|
30
|
+
const write = (data) => {
|
|
31
|
+
client().sendTerminalInput(id, { type: "input", data });
|
|
32
|
+
return data.length;
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
id,
|
|
36
|
+
current: () => current,
|
|
37
|
+
refresh: async (options) => {
|
|
38
|
+
const result = await list(options);
|
|
39
|
+
current = result.entries.find((entry) => entry.id === id) ?? null;
|
|
40
|
+
return current;
|
|
41
|
+
},
|
|
42
|
+
write,
|
|
43
|
+
sendKeys: (keys) => write(keys.map(resolveKeyToken).join("")),
|
|
44
|
+
capture: (options = {}) => {
|
|
45
|
+
const { requestId, ...captureOptions } = options;
|
|
46
|
+
return client().captureTerminal(id, captureOptions, requestId);
|
|
47
|
+
},
|
|
48
|
+
kill: async (requestId) => {
|
|
49
|
+
const result = await client().killTerminal(id, requestId);
|
|
50
|
+
if (!result.success)
|
|
51
|
+
throw new Error(`Failed to kill terminal ${id}`);
|
|
52
|
+
current = null;
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
create: async ({ workspaceId, cwd, name, requestId, ...options }) => {
|
|
58
|
+
const driver = client();
|
|
59
|
+
if (!workspaceId)
|
|
60
|
+
throw new Error("workspaceId is required");
|
|
61
|
+
const directory = cwd ?? (await resolveWorkspaceDirectory(workspaceId));
|
|
62
|
+
const result = await driver.createTerminal(directory, name, requestId, {
|
|
63
|
+
...options,
|
|
64
|
+
workspaceId,
|
|
65
|
+
});
|
|
66
|
+
if (result.error || !result.terminal) {
|
|
67
|
+
throw new Error(result.error ?? "The daemon did not create a terminal");
|
|
68
|
+
}
|
|
69
|
+
return ref(TerminalSchema.parse(result.terminal));
|
|
70
|
+
},
|
|
71
|
+
list,
|
|
72
|
+
ref,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function resolveKeyToken(key) {
|
|
76
|
+
switch (key) {
|
|
77
|
+
case "Enter":
|
|
78
|
+
return "\r";
|
|
79
|
+
case "Tab":
|
|
80
|
+
return "\t";
|
|
81
|
+
case "Escape":
|
|
82
|
+
return "\u001b";
|
|
83
|
+
case "Space":
|
|
84
|
+
return " ";
|
|
85
|
+
case "BSpace":
|
|
86
|
+
return "\u007f";
|
|
87
|
+
case "C-c":
|
|
88
|
+
return "\u0003";
|
|
89
|
+
case "C-d":
|
|
90
|
+
return "\u0004";
|
|
91
|
+
case "C-z":
|
|
92
|
+
return "\u001a";
|
|
93
|
+
case "C-l":
|
|
94
|
+
return "\u000c";
|
|
95
|
+
case "C-a":
|
|
96
|
+
return "\u0001";
|
|
97
|
+
case "C-e":
|
|
98
|
+
return "\u0005";
|
|
99
|
+
default:
|
|
100
|
+
return key;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@camerontaylor/paseo-client",
|
|
3
|
+
"version": "0.8.0-fork.1",
|
|
4
|
+
"description": "Paseo client SDK package",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist",
|
|
7
|
+
"!dist/**/*.map",
|
|
8
|
+
"README.md"
|
|
9
|
+
],
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./internal/daemon-client": {
|
|
17
|
+
"types": "./dist/daemon-client.d.ts",
|
|
18
|
+
"default": "./dist/daemon-client.js"
|
|
19
|
+
},
|
|
20
|
+
"./internal/daemon-client-transport-types": {
|
|
21
|
+
"types": "./dist/daemon-client-transport-types.d.ts",
|
|
22
|
+
"default": "./dist/daemon-client-transport-types.js"
|
|
23
|
+
},
|
|
24
|
+
"./internal/daemon-client-websocket-transport": {
|
|
25
|
+
"types": "./dist/daemon-client-websocket-transport.d.ts",
|
|
26
|
+
"default": "./dist/daemon-client-websocket-transport.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"clean": "node ../../scripts/clean-package-dist.mjs",
|
|
34
|
+
"build": "npm run build --workspace=@camerontaylor/paseo-protocol && tsc -p tsconfig.json --incremental false",
|
|
35
|
+
"build:clean": "npm run clean && npm run build",
|
|
36
|
+
"prepack": "npm run build:clean",
|
|
37
|
+
"typecheck": "tsgo --noEmit",
|
|
38
|
+
"typecheck:examples": "tsgo -p tsconfig.examples.json --noEmit",
|
|
39
|
+
"test": "vitest run"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@camerontaylor/paseo-protocol": "0.8.0-fork.1",
|
|
43
|
+
"@camerontaylor/paseo-relay": "0.8.0-fork.1",
|
|
44
|
+
"zod": "^4.4.3"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/node": "^20.9.0",
|
|
48
|
+
"typescript": "^5.2.2",
|
|
49
|
+
"vitest": "^4.1.6"
|
|
50
|
+
}
|
|
51
|
+
}
|