linkshell-cli 0.9.0 → 0.10.0
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 +11 -6
- package/dist/cli/src/commands/gateway.d.ts +2 -0
- package/dist/cli/src/commands/gateway.js +29 -0
- package/dist/cli/src/commands/gateway.js.map +1 -0
- package/dist/cli/src/commands/host.d.ts +2 -0
- package/dist/cli/src/commands/host.js +12 -2
- package/dist/cli/src/commands/host.js.map +1 -1
- package/dist/cli/src/commands/setup.js +4 -2
- package/dist/cli/src/commands/setup.js.map +1 -1
- package/dist/cli/src/index.js +12 -334
- package/dist/cli/src/index.js.map +1 -1
- package/dist/cli/src/utils/daemon.d.ts +0 -7
- package/dist/cli/src/utils/daemon.js +1 -18
- package/dist/cli/src/utils/daemon.js.map +1 -1
- package/dist/cli/tsconfig.tsbuildinfo +1 -1
- package/dist/gateway/src/accounts.d.ts +6 -0
- package/dist/gateway/src/accounts.js +32 -0
- package/dist/gateway/src/accounts.js.map +1 -0
- package/dist/gateway/src/index.d.ts +4 -0
- package/dist/gateway/src/index.js +5 -0
- package/dist/gateway/src/index.js.map +1 -0
- package/dist/gateway/src/main.d.ts +1 -0
- package/dist/gateway/src/main.js +57 -0
- package/dist/gateway/src/main.js.map +1 -0
- package/dist/gateway/src/rate-limit.d.ts +22 -0
- package/dist/gateway/src/rate-limit.js +66 -0
- package/dist/gateway/src/rate-limit.js.map +1 -0
- package/dist/gateway/src/relay.d.ts +84 -0
- package/dist/gateway/src/relay.js +434 -0
- package/dist/gateway/src/relay.js.map +1 -0
- package/dist/gateway/src/serve.d.ts +34 -0
- package/dist/gateway/src/serve.js +102 -0
- package/dist/gateway/src/serve.js.map +1 -0
- package/dist/gateway/src/store.d.ts +35 -0
- package/dist/gateway/src/store.js +109 -0
- package/dist/gateway/src/store.js.map +1 -0
- package/dist/gateway/src/subscription.d.ts +18 -0
- package/dist/gateway/src/subscription.js +46 -0
- package/dist/gateway/src/subscription.js.map +1 -0
- package/dist/host/src/drivers/claude/transcript.d.ts +23 -23
- package/dist/host/src/fs.d.ts +3 -3
- package/dist/host/src/input.d.ts +4 -4
- package/dist/host/src/terminals.d.ts +1 -1
- package/dist/wire/src/model.d.ts +6 -6
- package/dist/wire/src/relay.d.ts +8 -8
- package/dist/wire/src/rpc.d.ts +818 -818
- package/dist/wire/src/updates.d.ts +18 -18
- package/package.json +4 -13
- package/src/commands/gateway.ts +31 -0
- package/src/commands/host.ts +13 -2
- package/src/commands/setup.ts +4 -2
- package/src/index.ts +14 -429
- package/src/utils/daemon.ts +2 -27
- package/dist/cli/src/config.d.ts +0 -14
- package/dist/cli/src/config.js +0 -23
- package/dist/cli/src/config.js.map +0 -1
- package/dist/cli/src/machine-id.d.ts +0 -6
- package/dist/cli/src/machine-id.js +0 -50
- package/dist/cli/src/machine-id.js.map +0 -1
- package/dist/cli/src/providers.d.ts +0 -13
- package/dist/cli/src/providers.js +0 -77
- package/dist/cli/src/providers.js.map +0 -1
- package/dist/cli/src/runtime/acp/acp-client.d.ts +0 -128
- package/dist/cli/src/runtime/acp/acp-client.js +0 -430
- package/dist/cli/src/runtime/acp/acp-client.js.map +0 -1
- package/dist/cli/src/runtime/acp/agent-process-discovery.d.ts +0 -48
- package/dist/cli/src/runtime/acp/agent-process-discovery.js +0 -278
- package/dist/cli/src/runtime/acp/agent-process-discovery.js.map +0 -1
- package/dist/cli/src/runtime/acp/agent-session.d.ts +0 -62
- package/dist/cli/src/runtime/acp/agent-session.js +0 -1081
- package/dist/cli/src/runtime/acp/agent-session.js.map +0 -1
- package/dist/cli/src/runtime/acp/agent-workspace.d.ts +0 -311
- package/dist/cli/src/runtime/acp/agent-workspace.js +0 -6083
- package/dist/cli/src/runtime/acp/agent-workspace.js.map +0 -1
- package/dist/cli/src/runtime/acp/claude-sdk-client.d.ts +0 -121
- package/dist/cli/src/runtime/acp/claude-sdk-client.js +0 -1147
- package/dist/cli/src/runtime/acp/claude-sdk-client.js.map +0 -1
- package/dist/cli/src/runtime/acp/claude-stream-json-client.d.ts +0 -53
- package/dist/cli/src/runtime/acp/claude-stream-json-client.js +0 -552
- package/dist/cli/src/runtime/acp/claude-stream-json-client.js.map +0 -1
- package/dist/cli/src/runtime/acp/json-rpc.d.ts +0 -22
- package/dist/cli/src/runtime/acp/json-rpc.js +0 -160
- package/dist/cli/src/runtime/acp/json-rpc.js.map +0 -1
- package/dist/cli/src/runtime/acp/provider-resolver.d.ts +0 -16
- package/dist/cli/src/runtime/acp/provider-resolver.js +0 -132
- package/dist/cli/src/runtime/acp/provider-resolver.js.map +0 -1
- package/dist/cli/src/runtime/bridge-session.d.ts +0 -97
- package/dist/cli/src/runtime/bridge-session.js +0 -1364
- package/dist/cli/src/runtime/bridge-session.js.map +0 -1
- package/dist/cli/src/runtime/hook-command.d.ts +0 -9
- package/dist/cli/src/runtime/hook-command.js +0 -80
- package/dist/cli/src/runtime/hook-command.js.map +0 -1
- package/dist/cli/src/runtime/screen-fallback.d.ts +0 -22
- package/dist/cli/src/runtime/screen-fallback.js +0 -202
- package/dist/cli/src/runtime/screen-fallback.js.map +0 -1
- package/dist/cli/src/runtime/screen-share.d.ts +0 -34
- package/dist/cli/src/runtime/screen-share.js +0 -376
- package/dist/cli/src/runtime/screen-share.js.map +0 -1
- package/dist/cli/src/runtime/scrollback.d.ts +0 -11
- package/dist/cli/src/runtime/scrollback.js +0 -33
- package/dist/cli/src/runtime/scrollback.js.map +0 -1
- package/dist/cli/src/runtime/usage-report.d.ts +0 -34
- package/dist/cli/src/runtime/usage-report.js +0 -332
- package/dist/cli/src/runtime/usage-report.js.map +0 -1
- package/dist/cli/src/utils/keep-awake.d.ts +0 -6
- package/dist/cli/src/utils/keep-awake.js +0 -48
- package/dist/cli/src/utils/keep-awake.js.map +0 -1
- package/dist/cli/src/utils/lan-ip.d.ts +0 -9
- package/dist/cli/src/utils/lan-ip.js +0 -61
- package/dist/cli/src/utils/lan-ip.js.map +0 -1
- package/dist/host/src/input-helper.d.ts +0 -1
- package/dist/host/src/input-helper.js +0 -564
- package/dist/host/src/input-helper.js.map +0 -1
- package/dist/shared-protocol/src/index.d.ts +0 -17029
- package/dist/shared-protocol/src/index.js +0 -1064
- package/dist/shared-protocol/src/index.js.map +0 -1
- package/scripts/copy-web.mjs +0 -34
- package/src/config.ts +0 -36
- package/src/machine-id.ts +0 -61
- package/src/providers.ts +0 -97
- package/src/runtime/acp/acp-client.ts +0 -521
- package/src/runtime/acp/agent-process-discovery.ts +0 -308
- package/src/runtime/acp/agent-session.ts +0 -1186
- package/src/runtime/acp/agent-workspace.ts +0 -6590
- package/src/runtime/acp/claude-sdk-client.ts +0 -1221
- package/src/runtime/acp/claude-stream-json-client.ts +0 -633
- package/src/runtime/acp/json-rpc.ts +0 -184
- package/src/runtime/acp/provider-resolver.ts +0 -154
- package/src/runtime/bridge-session.ts +0 -1549
- package/src/runtime/hook-command.ts +0 -73
- package/src/runtime/screen-fallback.ts +0 -235
- package/src/runtime/screen-share.ts +0 -426
- package/src/runtime/scrollback.ts +0 -43
- package/src/runtime/usage-report.ts +0 -342
- package/src/utils/keep-awake.ts +0 -61
- package/src/utils/lan-ip.ts +0 -61
- package/web/assets/FileBrowser-wOAfY-xj.js +0 -2
- package/web/assets/PortPreview-Cbvv7yzA.js +0 -2
- package/web/assets/TerminalPanel-CTSklkct.js +0 -1
- package/web/assets/UsageDashboard-CJ1AsNmd.js +0 -1
- package/web/assets/index-BsnDaeCt.css +0 -33
- package/web/assets/index-q85psYZ5.js +0 -36
- package/web/assets/vendor-highlight-NXWAAyIv.js +0 -5
- package/web/assets/vendor-react-M7xG3qiw.js +0 -49
- package/web/assets/vendor-xterm-D15THcI4.js +0 -9
- package/web/index.html +0 -37
- package/web/logos/claude.png +0 -0
- package/web/logos/codex.png +0 -0
- package/web/logos/copilot.png +0 -0
- package/web/logos/gemini.png +0 -0
- package/web/logos/linkshell-1024.png +0 -0
- package/web/logos/linkshell-splash.png +0 -0
- package/web/logos/linkshell.png +0 -0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;IAC7D,MAAM,QAAQ,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IAC1C,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAG,oBAAoB,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;QACtE,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC;IAChC,CAAC;IAED,MAAM,QAAQ,GAAoB;QAChC,SAAS,EAAE,UAAU,EAAE;QACvB,QAAQ,EAAE,QAAQ,EAAE;QACpB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACpC,CAAC;IACF,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1E,aAAa,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;QAChE,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,KAAK;KACZ,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { TerminalProvider } from "@linkshell/protocol";
|
|
2
|
-
export type ProviderName = TerminalProvider;
|
|
3
|
-
export interface ProviderConfig {
|
|
4
|
-
provider: ProviderName;
|
|
5
|
-
command: string;
|
|
6
|
-
args: string[];
|
|
7
|
-
env: NodeJS.ProcessEnv;
|
|
8
|
-
}
|
|
9
|
-
export declare function resolveProviderConfig(input: {
|
|
10
|
-
provider?: ProviderName;
|
|
11
|
-
command?: string;
|
|
12
|
-
args: string[];
|
|
13
|
-
}): ProviderConfig;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { accessSync, constants, existsSync } from "node:fs";
|
|
2
|
-
import { delimiter, join } from "node:path";
|
|
3
|
-
function defaultShell() {
|
|
4
|
-
if (process.platform === "win32") {
|
|
5
|
-
return process.env.COMSPEC ?? "cmd.exe";
|
|
6
|
-
}
|
|
7
|
-
return process.env.SHELL ?? "/bin/bash";
|
|
8
|
-
}
|
|
9
|
-
function stripOuterQuotes(value) {
|
|
10
|
-
const trimmed = value.trim();
|
|
11
|
-
if ((trimmed.startsWith("\"") && trimmed.endsWith("\"")) ||
|
|
12
|
-
(trimmed.startsWith("'") && trimmed.endsWith("'"))) {
|
|
13
|
-
return trimmed.slice(1, -1);
|
|
14
|
-
}
|
|
15
|
-
return trimmed;
|
|
16
|
-
}
|
|
17
|
-
function canExecute(path) {
|
|
18
|
-
try {
|
|
19
|
-
accessSync(path, constants.X_OK);
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
return process.platform === "win32" && existsSync(path);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function executableExtensions(bin) {
|
|
27
|
-
if (process.platform !== "win32")
|
|
28
|
-
return [""];
|
|
29
|
-
if (/\.[^\\/]+$/.test(bin))
|
|
30
|
-
return [""];
|
|
31
|
-
const pathext = process.env.PATHEXT?.split(";").filter(Boolean) ?? [];
|
|
32
|
-
return ["", ...pathext.map((ext) => ext.toLowerCase()), ...pathext.map((ext) => ext.toUpperCase())];
|
|
33
|
-
}
|
|
34
|
-
function commandHasPathSeparator(command) {
|
|
35
|
-
return command.includes("/") || command.includes("\\");
|
|
36
|
-
}
|
|
37
|
-
function which(bin) {
|
|
38
|
-
const command = stripOuterQuotes(bin);
|
|
39
|
-
if (!command)
|
|
40
|
-
return undefined;
|
|
41
|
-
const extensions = executableExtensions(command);
|
|
42
|
-
if (commandHasPathSeparator(command)) {
|
|
43
|
-
for (const extension of extensions) {
|
|
44
|
-
const candidate = `${command}${extension}`;
|
|
45
|
-
if (canExecute(candidate))
|
|
46
|
-
return candidate;
|
|
47
|
-
}
|
|
48
|
-
return undefined;
|
|
49
|
-
}
|
|
50
|
-
const pathEntries = (process.env.PATH ?? "")
|
|
51
|
-
.split(delimiter)
|
|
52
|
-
.filter(Boolean);
|
|
53
|
-
for (const dir of pathEntries) {
|
|
54
|
-
for (const extension of extensions) {
|
|
55
|
-
const candidate = join(dir, `${command}${extension}`);
|
|
56
|
-
if (canExecute(candidate))
|
|
57
|
-
return candidate;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return undefined;
|
|
61
|
-
}
|
|
62
|
-
export function resolveProviderConfig(input) {
|
|
63
|
-
if (input.provider && input.provider !== "custom") {
|
|
64
|
-
process.stderr.write(`[warn] --provider=${input.provider} is no longer supported; falling back to a shell. ` +
|
|
65
|
-
`Launch your CLI manually inside the terminal (e.g. type "${input.provider}").\n`);
|
|
66
|
-
}
|
|
67
|
-
const requested = input.command?.trim();
|
|
68
|
-
const command = requested && requested.length > 0 ? requested : defaultShell();
|
|
69
|
-
const resolved = which(command) ?? command;
|
|
70
|
-
return {
|
|
71
|
-
provider: "custom",
|
|
72
|
-
command: resolved,
|
|
73
|
-
args: input.args,
|
|
74
|
-
env: { ...process.env },
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
//# sourceMappingURL=providers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../../../src/providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAY5C,SAAS,YAAY;IACnB,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,SAAS,CAAC;IAC1C,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,WAAW,CAAC;AAC1C,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAa;IACrC,MAAM,OAAO,GAAG,K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,CAAC,QAAQ,OAAO,CACpF,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;IACxC,MAAM,OAAO,GAAG,SAAS,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC;IAC/E,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC;IAE3C,OAAO;QACL,QAAQ,EAAE,QAAQ;QAClB,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE;KACxB,CAAC;AACJ,CAAC"}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import type { AgentFraming, AgentProtocol } from "./provider-resolver.js";
|
|
2
|
-
type AgentPermissionMode = "read_only" | "workspace_write" | "full_access";
|
|
3
|
-
type AgentCollaborationMode = "default" | "plan";
|
|
4
|
-
export interface AdvertisedAcpCapabilities {
|
|
5
|
-
protocolVersion?: number;
|
|
6
|
-
loadSession: boolean;
|
|
7
|
-
listSession: boolean;
|
|
8
|
-
forkSession: boolean;
|
|
9
|
-
setModel: boolean;
|
|
10
|
-
cancel: boolean;
|
|
11
|
-
images: boolean;
|
|
12
|
-
audio: boolean;
|
|
13
|
-
embeddedContext: boolean;
|
|
14
|
-
mcp: boolean;
|
|
15
|
-
methods: string[];
|
|
16
|
-
}
|
|
17
|
-
/** Parse ACP `initialize` result. Unadvertised optional methods stay false. */
|
|
18
|
-
export declare function parseAcpInitializeCapabilities(result: unknown): AdvertisedAcpCapabilities;
|
|
19
|
-
export declare class AcpClient {
|
|
20
|
-
private readonly transport;
|
|
21
|
-
private readonly protocol;
|
|
22
|
-
lastInitializeResult: unknown;
|
|
23
|
-
advertised: AdvertisedAcpCapabilities;
|
|
24
|
-
constructor(input: {
|
|
25
|
-
command: string;
|
|
26
|
-
protocol: AgentProtocol;
|
|
27
|
-
framing: AgentFraming;
|
|
28
|
-
cwd: string;
|
|
29
|
-
onNotification: (method: string, params: unknown) => void;
|
|
30
|
-
onRequest: (method: string, params: unknown) => Promise<unknown> | unknown;
|
|
31
|
-
onExit: (message: string) => void;
|
|
32
|
-
});
|
|
33
|
-
initialize(): Promise<unknown>;
|
|
34
|
-
newSession(input: {
|
|
35
|
-
cwd: string;
|
|
36
|
-
mcpServers?: unknown;
|
|
37
|
-
}): Promise<unknown>;
|
|
38
|
-
loadSession(input: {
|
|
39
|
-
sessionId: string;
|
|
40
|
-
cwd: string;
|
|
41
|
-
mcpServers?: unknown;
|
|
42
|
-
}): Promise<unknown>;
|
|
43
|
-
readSession(input: {
|
|
44
|
-
sessionId: string;
|
|
45
|
-
includeTurns?: boolean;
|
|
46
|
-
}): Promise<unknown>;
|
|
47
|
-
listTurns(input: {
|
|
48
|
-
sessionId: string;
|
|
49
|
-
limit?: number;
|
|
50
|
-
cursor?: string;
|
|
51
|
-
sortDirection?: "asc" | "desc";
|
|
52
|
-
itemsView?: "summary" | "full";
|
|
53
|
-
}): Promise<unknown>;
|
|
54
|
-
listSessions(): Promise<unknown>;
|
|
55
|
-
updateThreadSettings(input: {
|
|
56
|
-
sessionId: string;
|
|
57
|
-
model?: string;
|
|
58
|
-
reasoningEffort?: string;
|
|
59
|
-
permissionMode?: AgentPermissionMode;
|
|
60
|
-
collaborationMode?: AgentCollaborationMode;
|
|
61
|
-
cwd?: string;
|
|
62
|
-
}): Promise<unknown>;
|
|
63
|
-
setThreadName(input: {
|
|
64
|
-
sessionId: string;
|
|
65
|
-
name: string;
|
|
66
|
-
}): Promise<unknown>;
|
|
67
|
-
archiveThread(input: {
|
|
68
|
-
sessionId: string;
|
|
69
|
-
}): Promise<unknown>;
|
|
70
|
-
unarchiveThread(input: {
|
|
71
|
-
sessionId: string;
|
|
72
|
-
}): Promise<unknown>;
|
|
73
|
-
deleteThread(input: {
|
|
74
|
-
sessionId: string;
|
|
75
|
-
}): Promise<unknown>;
|
|
76
|
-
forkThread(input: {
|
|
77
|
-
sessionId: string;
|
|
78
|
-
lastTurnId?: string;
|
|
79
|
-
}): Promise<unknown>;
|
|
80
|
-
setSessionModel(input: {
|
|
81
|
-
sessionId: string;
|
|
82
|
-
modelId: string;
|
|
83
|
-
}): Promise<unknown>;
|
|
84
|
-
startReview(input: {
|
|
85
|
-
sessionId: string;
|
|
86
|
-
prompt?: string;
|
|
87
|
-
}): Promise<unknown>;
|
|
88
|
-
listSkills(input: {
|
|
89
|
-
cwd: string;
|
|
90
|
-
}): Promise<unknown>;
|
|
91
|
-
listMcpServers(input?: {
|
|
92
|
-
threadId?: string;
|
|
93
|
-
}): Promise<unknown>;
|
|
94
|
-
startMcpOAuth(input: {
|
|
95
|
-
serverName: string;
|
|
96
|
-
}): Promise<unknown>;
|
|
97
|
-
listModels(): Promise<unknown>;
|
|
98
|
-
prompt(input: {
|
|
99
|
-
sessionId: string;
|
|
100
|
-
content: unknown[];
|
|
101
|
-
clientMessageId: string;
|
|
102
|
-
model?: string;
|
|
103
|
-
reasoningEffort?: string;
|
|
104
|
-
permissionMode?: AgentPermissionMode;
|
|
105
|
-
collaborationMode?: AgentCollaborationMode;
|
|
106
|
-
cwd: string;
|
|
107
|
-
}): Promise<unknown>;
|
|
108
|
-
steer(input: {
|
|
109
|
-
sessionId: string;
|
|
110
|
-
turnId: string;
|
|
111
|
-
content: unknown[];
|
|
112
|
-
}): Promise<unknown>;
|
|
113
|
-
cancel(input: {
|
|
114
|
-
sessionId?: string;
|
|
115
|
-
turnId?: string;
|
|
116
|
-
}): void;
|
|
117
|
-
respondPermission(input: {
|
|
118
|
-
sessionId?: string;
|
|
119
|
-
requestId: string;
|
|
120
|
-
outcome: "allow" | "deny";
|
|
121
|
-
optionId?: string;
|
|
122
|
-
}): void;
|
|
123
|
-
compact(input: {
|
|
124
|
-
sessionId: string;
|
|
125
|
-
}): Promise<unknown>;
|
|
126
|
-
stop(): void;
|
|
127
|
-
}
|
|
128
|
-
export {};
|
|
@@ -1,430 +0,0 @@
|
|
|
1
|
-
import { JsonRpcStdioTransport } from "./json-rpc.js";
|
|
2
|
-
function asRecord(value) {
|
|
3
|
-
return value && typeof value === "object" && !Array.isArray(value)
|
|
4
|
-
? value
|
|
5
|
-
: undefined;
|
|
6
|
-
}
|
|
7
|
-
function truthy(value) {
|
|
8
|
-
return value === true || value === "true" || value === 1;
|
|
9
|
-
}
|
|
10
|
-
function collectAdvertisedMethods(...sources) {
|
|
11
|
-
const methods = new Set();
|
|
12
|
-
for (const source of sources) {
|
|
13
|
-
if (!source)
|
|
14
|
-
continue;
|
|
15
|
-
const lists = [source.methods, source.supportedMethods, source.sessionMethods];
|
|
16
|
-
for (const list of lists) {
|
|
17
|
-
if (!Array.isArray(list))
|
|
18
|
-
continue;
|
|
19
|
-
for (const item of list) {
|
|
20
|
-
if (typeof item === "string" && item.trim())
|
|
21
|
-
methods.add(item.trim());
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
for (const [key, value] of Object.entries(source)) {
|
|
25
|
-
if (key.includes("/") && truthy(value))
|
|
26
|
-
methods.add(key);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return [...methods];
|
|
30
|
-
}
|
|
31
|
-
/** Parse ACP `initialize` result. Unadvertised optional methods stay false. */
|
|
32
|
-
export function parseAcpInitializeCapabilities(result) {
|
|
33
|
-
const raw = asRecord(result) ?? {};
|
|
34
|
-
const agentCaps = asRecord(raw.agentCapabilities) ?? asRecord(raw.capabilities) ?? {};
|
|
35
|
-
const sessionCaps = asRecord(raw.sessionCapabilities) ?? asRecord(agentCaps.sessionCapabilities) ?? {};
|
|
36
|
-
const promptCaps = asRecord(agentCaps.promptCapabilities) ?? {};
|
|
37
|
-
const mcpCaps = asRecord(agentCaps.mcpCapabilities);
|
|
38
|
-
const methods = collectAdvertisedMethods(raw, agentCaps, sessionCaps);
|
|
39
|
-
const has = (...keys) => keys.some((key) => truthy(agentCaps[key]) || truthy(sessionCaps[key]) || methods.includes(key));
|
|
40
|
-
return {
|
|
41
|
-
protocolVersion: typeof raw.protocolVersion === "number" ? raw.protocolVersion : undefined,
|
|
42
|
-
loadSession: has("loadSession", "session/load"),
|
|
43
|
-
listSession: has("listSession", "listSessions", "session/list"),
|
|
44
|
-
forkSession: has("forkSession", "session/fork"),
|
|
45
|
-
setModel: has("setModel", "session/set_model"),
|
|
46
|
-
// ACP v1 MUST session/cancel. AgentCapabilities has no cancel flag, so a
|
|
47
|
-
// real-shaped initialize that omits it still supports cancel.
|
|
48
|
-
cancel: true,
|
|
49
|
-
images: truthy(promptCaps.image) || has("image", "images"),
|
|
50
|
-
audio: truthy(promptCaps.audio) || has("audio"),
|
|
51
|
-
embeddedContext: truthy(promptCaps.embeddedContext),
|
|
52
|
-
mcp: Boolean(mcpCaps && Object.keys(mcpCaps).length > 0) || has("mcp"),
|
|
53
|
-
methods,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function normalizeMcpServers(value) {
|
|
57
|
-
if (Array.isArray(value))
|
|
58
|
-
return value;
|
|
59
|
-
if (!value || typeof value !== "object")
|
|
60
|
-
return [];
|
|
61
|
-
return Object.entries(value).map(([name, config]) => {
|
|
62
|
-
if (config && typeof config === "object" && !Array.isArray(config)) {
|
|
63
|
-
return { name, ...config };
|
|
64
|
-
}
|
|
65
|
-
return { name, config };
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
// Codex prefers a named permission profile (`permissions: ":workspace"`) and
|
|
69
|
-
// rejects combining it with the legacy tagged `sandboxPolicy`. Map our three
|
|
70
|
-
// LinkShell modes onto official profile ids; keep sandboxPolicy only for
|
|
71
|
-
// full_access, which has no stable named profile in the public docs.
|
|
72
|
-
function permissionOverridesForMode(mode) {
|
|
73
|
-
if (!mode)
|
|
74
|
-
return {};
|
|
75
|
-
switch (mode) {
|
|
76
|
-
case "read_only":
|
|
77
|
-
return { permissions: ":read-only" };
|
|
78
|
-
case "workspace_write":
|
|
79
|
-
return { permissions: ":workspace" };
|
|
80
|
-
case "full_access":
|
|
81
|
-
return { sandboxPolicy: { type: "dangerFullAccess" } };
|
|
82
|
-
default:
|
|
83
|
-
return {};
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
function approvalPolicyForMode(mode) {
|
|
87
|
-
if (!mode)
|
|
88
|
-
return undefined;
|
|
89
|
-
switch (mode) {
|
|
90
|
-
case "read_only":
|
|
91
|
-
case "workspace_write":
|
|
92
|
-
// Ask before escaping the sandbox → triggers a permission request the
|
|
93
|
-
// host forwards to the client as agent.v2.permission.request.
|
|
94
|
-
return "on-request";
|
|
95
|
-
case "full_access":
|
|
96
|
-
return "never";
|
|
97
|
-
default:
|
|
98
|
-
return undefined;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
export class AcpClient {
|
|
102
|
-
transport;
|
|
103
|
-
protocol;
|
|
104
|
-
lastInitializeResult;
|
|
105
|
-
advertised = parseAcpInitializeCapabilities(undefined);
|
|
106
|
-
constructor(input) {
|
|
107
|
-
this.protocol = input.protocol;
|
|
108
|
-
this.transport = new JsonRpcStdioTransport(input.command, input.framing, input.onNotification, input.onRequest, input.onExit);
|
|
109
|
-
this.transport.start(input.cwd);
|
|
110
|
-
}
|
|
111
|
-
async initialize() {
|
|
112
|
-
if (this.protocol === "codex-app-server") {
|
|
113
|
-
const result = await this.transport.request("initialize", {
|
|
114
|
-
clientInfo: { name: "LinkShell", version: "0.1" },
|
|
115
|
-
capabilities: { experimentalApi: true },
|
|
116
|
-
});
|
|
117
|
-
this.transport.notify("initialized", {});
|
|
118
|
-
this.lastInitializeResult = result;
|
|
119
|
-
this.advertised = {
|
|
120
|
-
...parseAcpInitializeCapabilities(result),
|
|
121
|
-
loadSession: true,
|
|
122
|
-
listSession: true,
|
|
123
|
-
forkSession: true,
|
|
124
|
-
setModel: true,
|
|
125
|
-
cancel: true,
|
|
126
|
-
images: true,
|
|
127
|
-
mcp: true,
|
|
128
|
-
};
|
|
129
|
-
return result;
|
|
130
|
-
}
|
|
131
|
-
const result = await this.transport.request("initialize", {
|
|
132
|
-
protocolVersion: 1,
|
|
133
|
-
clientInfo: { name: "LinkShell", version: "0.1" },
|
|
134
|
-
clientCapabilities: {
|
|
135
|
-
fs: { readTextFile: false, writeTextFile: false },
|
|
136
|
-
terminal: false,
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
this.lastInitializeResult = result;
|
|
140
|
-
this.advertised = { ...parseAcpInitializeCapabilities(result), cancel: true };
|
|
141
|
-
return result;
|
|
142
|
-
}
|
|
143
|
-
newSession(input) {
|
|
144
|
-
if (this.protocol === "codex-app-server") {
|
|
145
|
-
return this.transport.request("thread/start", {
|
|
146
|
-
cwd: input.cwd,
|
|
147
|
-
sessionStartSource: "startup",
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
return this.transport.request("session/new", {
|
|
151
|
-
cwd: input.cwd,
|
|
152
|
-
mcpServers: normalizeMcpServers(input.mcpServers),
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
loadSession(input) {
|
|
156
|
-
if (this.protocol === "codex-app-server") {
|
|
157
|
-
return this.transport.request("thread/resume", {
|
|
158
|
-
threadId: input.sessionId,
|
|
159
|
-
cwd: input.cwd,
|
|
160
|
-
excludeTurns: false,
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
if (!this.advertised.loadSession) {
|
|
164
|
-
return Promise.reject(new Error("Provider did not advertise session/load."));
|
|
165
|
-
}
|
|
166
|
-
return this.transport.request("session/load", {
|
|
167
|
-
sessionId: input.sessionId,
|
|
168
|
-
cwd: input.cwd,
|
|
169
|
-
mcpServers: normalizeMcpServers(input.mcpServers),
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
readSession(input) {
|
|
173
|
-
if (this.protocol === "codex-app-server") {
|
|
174
|
-
return this.transport.request("thread/read", {
|
|
175
|
-
threadId: input.sessionId,
|
|
176
|
-
includeTurns: input.includeTurns ?? true,
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
return Promise.reject(new Error("Provider does not support readSession."));
|
|
180
|
-
}
|
|
181
|
-
listTurns(input) {
|
|
182
|
-
if (this.protocol === "codex-app-server") {
|
|
183
|
-
return this.transport.request("thread/turns/list", {
|
|
184
|
-
threadId: input.sessionId,
|
|
185
|
-
limit: input.limit ?? 50,
|
|
186
|
-
cursor: input.cursor,
|
|
187
|
-
sortDirection: input.sortDirection ?? "desc",
|
|
188
|
-
itemsView: input.itemsView ?? "full",
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
return Promise.reject(new Error("Provider does not support listTurns."));
|
|
192
|
-
}
|
|
193
|
-
async listSessions() {
|
|
194
|
-
if (this.protocol !== "codex-app-server") {
|
|
195
|
-
if (!this.advertised.listSession) {
|
|
196
|
-
return Promise.reject(new Error("Provider did not advertise session/list."));
|
|
197
|
-
}
|
|
198
|
-
return this.transport.request("session/list", {});
|
|
199
|
-
}
|
|
200
|
-
const allThreads = [];
|
|
201
|
-
let cursor;
|
|
202
|
-
for (let page = 0; page < 10; page++) {
|
|
203
|
-
const result = await this.transport.request("thread/list", {
|
|
204
|
-
limit: 100,
|
|
205
|
-
...(cursor ? { cursor } : {}),
|
|
206
|
-
});
|
|
207
|
-
const raw = result && typeof result === "object" ? result : undefined;
|
|
208
|
-
const threads = Array.isArray(result) ? result :
|
|
209
|
-
Array.isArray(raw?.data) ? raw.data :
|
|
210
|
-
Array.isArray(raw?.threads) ? raw.threads :
|
|
211
|
-
Array.isArray(raw?.sessions) ? raw.sessions :
|
|
212
|
-
Array.isArray(raw?.items) ? raw.items :
|
|
213
|
-
[];
|
|
214
|
-
allThreads.push(...threads);
|
|
215
|
-
const nextCursor = (typeof raw?.nextCursor === "string" && raw.nextCursor) ||
|
|
216
|
-
(typeof raw?.next_cursor === "string" && raw.next_cursor) ||
|
|
217
|
-
undefined;
|
|
218
|
-
if (!nextCursor || threads.length === 0)
|
|
219
|
-
break;
|
|
220
|
-
cursor = nextCursor;
|
|
221
|
-
}
|
|
222
|
-
return { data: allThreads };
|
|
223
|
-
}
|
|
224
|
-
updateThreadSettings(input) {
|
|
225
|
-
if (this.protocol !== "codex-app-server") {
|
|
226
|
-
return Promise.reject(new Error("Provider does not support updateThreadSettings."));
|
|
227
|
-
}
|
|
228
|
-
const model = input.model?.trim();
|
|
229
|
-
const collaborationMode = input.collaborationMode && input.collaborationMode !== "default"
|
|
230
|
-
? {
|
|
231
|
-
mode: input.collaborationMode,
|
|
232
|
-
settings: {
|
|
233
|
-
model: model || "default",
|
|
234
|
-
...(input.reasoningEffort ? { reasoning_effort: input.reasoningEffort } : {}),
|
|
235
|
-
},
|
|
236
|
-
}
|
|
237
|
-
: undefined;
|
|
238
|
-
const permission = permissionOverridesForMode(input.permissionMode);
|
|
239
|
-
const approvalPolicy = approvalPolicyForMode(input.permissionMode);
|
|
240
|
-
return this.transport.request("thread/settings/update", {
|
|
241
|
-
threadId: input.sessionId,
|
|
242
|
-
...(model ? { model } : {}),
|
|
243
|
-
...(input.reasoningEffort ? { effort: input.reasoningEffort } : {}),
|
|
244
|
-
...permission,
|
|
245
|
-
...(approvalPolicy ? { approvalPolicy } : {}),
|
|
246
|
-
...(collaborationMode ? { collaborationMode } : {}),
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
setThreadName(input) {
|
|
250
|
-
if (this.protocol !== "codex-app-server") {
|
|
251
|
-
return Promise.reject(new Error("Provider does not support setThreadName."));
|
|
252
|
-
}
|
|
253
|
-
return this.transport.request("thread/name/set", {
|
|
254
|
-
threadId: input.sessionId,
|
|
255
|
-
name: input.name,
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
archiveThread(input) {
|
|
259
|
-
if (this.protocol !== "codex-app-server") {
|
|
260
|
-
return Promise.reject(new Error("Provider does not support archiveThread."));
|
|
261
|
-
}
|
|
262
|
-
return this.transport.request("thread/archive", { threadId: input.sessionId });
|
|
263
|
-
}
|
|
264
|
-
unarchiveThread(input) {
|
|
265
|
-
if (this.protocol !== "codex-app-server") {
|
|
266
|
-
return Promise.reject(new Error("Provider does not support unarchiveThread."));
|
|
267
|
-
}
|
|
268
|
-
return this.transport.request("thread/unarchive", { threadId: input.sessionId });
|
|
269
|
-
}
|
|
270
|
-
deleteThread(input) {
|
|
271
|
-
if (this.protocol !== "codex-app-server") {
|
|
272
|
-
return Promise.reject(new Error("Provider does not support deleteThread."));
|
|
273
|
-
}
|
|
274
|
-
return this.transport.request("thread/delete", { threadId: input.sessionId });
|
|
275
|
-
}
|
|
276
|
-
forkThread(input) {
|
|
277
|
-
if (this.protocol === "codex-app-server") {
|
|
278
|
-
return this.transport.request("thread/fork", {
|
|
279
|
-
threadId: input.sessionId,
|
|
280
|
-
...(input.lastTurnId ? { lastTurnId: input.lastTurnId } : {}),
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
if (!this.advertised.forkSession) {
|
|
284
|
-
return Promise.reject(new Error("Provider did not advertise session/fork."));
|
|
285
|
-
}
|
|
286
|
-
return this.transport.request("session/fork", {
|
|
287
|
-
sessionId: input.sessionId,
|
|
288
|
-
...(input.lastTurnId ? { lastTurnId: input.lastTurnId } : {}),
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
setSessionModel(input) {
|
|
292
|
-
if (this.protocol === "codex-app-server") {
|
|
293
|
-
return this.updateThreadSettings({ sessionId: input.sessionId, model: input.modelId });
|
|
294
|
-
}
|
|
295
|
-
if (!this.advertised.setModel) {
|
|
296
|
-
return Promise.reject(new Error("Provider did not advertise session/set_model."));
|
|
297
|
-
}
|
|
298
|
-
return this.transport.request("session/set_model", {
|
|
299
|
-
sessionId: input.sessionId,
|
|
300
|
-
modelId: input.modelId,
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
startReview(input) {
|
|
304
|
-
if (this.protocol !== "codex-app-server") {
|
|
305
|
-
return Promise.reject(new Error("Provider does not support startReview."));
|
|
306
|
-
}
|
|
307
|
-
const prompt = input.prompt?.trim();
|
|
308
|
-
return this.transport.request("review/start", {
|
|
309
|
-
threadId: input.sessionId,
|
|
310
|
-
target: prompt
|
|
311
|
-
? { type: "custom", instructions: prompt }
|
|
312
|
-
: { type: "uncommittedChanges" },
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
listSkills(input) {
|
|
316
|
-
if (this.protocol !== "codex-app-server") {
|
|
317
|
-
return Promise.reject(new Error("Provider does not support listSkills."));
|
|
318
|
-
}
|
|
319
|
-
return this.transport.request("skills/list", { cwds: [input.cwd] });
|
|
320
|
-
}
|
|
321
|
-
listMcpServers(input) {
|
|
322
|
-
if (this.protocol !== "codex-app-server") {
|
|
323
|
-
return Promise.reject(new Error("Provider does not support listMcpServers."));
|
|
324
|
-
}
|
|
325
|
-
return this.transport.request("mcpServerStatus/list", {
|
|
326
|
-
detail: "full",
|
|
327
|
-
...(input?.threadId ? { threadId: input.threadId } : {}),
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
startMcpOAuth(input) {
|
|
331
|
-
if (this.protocol !== "codex-app-server") {
|
|
332
|
-
return Promise.reject(new Error("Provider does not support startMcpOAuth."));
|
|
333
|
-
}
|
|
334
|
-
return this.transport.request("mcpServer/oauth/login", { name: input.serverName });
|
|
335
|
-
}
|
|
336
|
-
listModels() {
|
|
337
|
-
if (this.protocol === "codex-app-server") {
|
|
338
|
-
return this.transport.request("model/list", {});
|
|
339
|
-
}
|
|
340
|
-
return Promise.resolve(undefined);
|
|
341
|
-
}
|
|
342
|
-
prompt(input) {
|
|
343
|
-
if (this.protocol === "codex-app-server") {
|
|
344
|
-
const model = input.model?.trim() || "default";
|
|
345
|
-
const collaborationSettings = {
|
|
346
|
-
model,
|
|
347
|
-
...(input.reasoningEffort ? { reasoning_effort: input.reasoningEffort } : {}),
|
|
348
|
-
};
|
|
349
|
-
const collaborationMode = input.collaborationMode && input.collaborationMode !== "default"
|
|
350
|
-
? {
|
|
351
|
-
mode: input.collaborationMode,
|
|
352
|
-
settings: collaborationSettings,
|
|
353
|
-
}
|
|
354
|
-
: undefined;
|
|
355
|
-
const permission = permissionOverridesForMode(input.permissionMode);
|
|
356
|
-
const approvalPolicy = approvalPolicyForMode(input.permissionMode);
|
|
357
|
-
const turnStartParams = {
|
|
358
|
-
threadId: input.sessionId,
|
|
359
|
-
model,
|
|
360
|
-
effort: input.reasoningEffort,
|
|
361
|
-
// Named profile when we have one; sandboxPolicy only for full_access.
|
|
362
|
-
// Omitted entirely when no mode is set so Codex uses config.toml.
|
|
363
|
-
...permission,
|
|
364
|
-
...(approvalPolicy ? { approvalPolicy } : {}),
|
|
365
|
-
collaborationMode,
|
|
366
|
-
input: input.content.map((block) => {
|
|
367
|
-
const raw = block;
|
|
368
|
-
if (raw.type === "image" && raw.data) {
|
|
369
|
-
return { type: "image", url: raw.data };
|
|
370
|
-
}
|
|
371
|
-
return { type: "text", text: raw.text ?? "" };
|
|
372
|
-
}),
|
|
373
|
-
};
|
|
374
|
-
return this.transport.request("turn/start", turnStartParams, null);
|
|
375
|
-
}
|
|
376
|
-
return this.transport.request("session/prompt", {
|
|
377
|
-
sessionId: input.sessionId,
|
|
378
|
-
prompt: input.content,
|
|
379
|
-
_meta: {
|
|
380
|
-
linkshellClientMessageId: input.clientMessageId,
|
|
381
|
-
model: input.model,
|
|
382
|
-
reasoningEffort: input.reasoningEffort,
|
|
383
|
-
permissionMode: input.permissionMode,
|
|
384
|
-
},
|
|
385
|
-
}, 60_000);
|
|
386
|
-
}
|
|
387
|
-
steer(input) {
|
|
388
|
-
if (this.protocol !== "codex-app-server") {
|
|
389
|
-
return Promise.reject(new Error("Active-turn steering is only supported by Codex app-server."));
|
|
390
|
-
}
|
|
391
|
-
return this.transport.request("turn/steer", {
|
|
392
|
-
threadId: input.sessionId,
|
|
393
|
-
expectedTurnId: input.turnId,
|
|
394
|
-
input: input.content.map((block) => {
|
|
395
|
-
const raw = block;
|
|
396
|
-
if (raw.type === "image" && raw.data) {
|
|
397
|
-
return { type: "image", url: raw.data };
|
|
398
|
-
}
|
|
399
|
-
return { type: "text", text: raw.text ?? "" };
|
|
400
|
-
}),
|
|
401
|
-
}, null);
|
|
402
|
-
}
|
|
403
|
-
cancel(input) {
|
|
404
|
-
if (this.protocol === "codex-app-server") {
|
|
405
|
-
if (!input.sessionId || !input.turnId)
|
|
406
|
-
return;
|
|
407
|
-
this.transport.request("turn/interrupt", {
|
|
408
|
-
threadId: input.sessionId,
|
|
409
|
-
turnId: input.turnId,
|
|
410
|
-
}).catch(() => { });
|
|
411
|
-
return;
|
|
412
|
-
}
|
|
413
|
-
if (!this.advertised.cancel)
|
|
414
|
-
return;
|
|
415
|
-
this.transport.notify("session/cancel", { sessionId: input.sessionId });
|
|
416
|
-
}
|
|
417
|
-
respondPermission(input) {
|
|
418
|
-
this.transport.notify("session/respond_permission", input);
|
|
419
|
-
}
|
|
420
|
-
compact(input) {
|
|
421
|
-
if (this.protocol === "codex-app-server") {
|
|
422
|
-
return this.transport.request("thread/compact/start", { threadId: input.sessionId });
|
|
423
|
-
}
|
|
424
|
-
return Promise.reject(new Error("Native compact is not supported by this provider."));
|
|
425
|
-
}
|
|
426
|
-
stop() {
|
|
427
|
-
this.transport.stop();
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
//# sourceMappingURL=acp-client.js.map
|