@vybestack/llxprt-code-zed-acp 0.0.0-bootstrap.0 → 0.12.0-nightly.261005.bdbb230dd
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/.last_build +0 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/src/acp-terminal-shell-host.d.ts +45 -0
- package/dist/src/acp-terminal-shell-host.js +80 -0
- package/dist/src/acp-terminal-shell-host.js.map +1 -0
- package/dist/src/acp-types.d.ts +26 -0
- package/dist/src/acp-types.js +7 -0
- package/dist/src/acp-types.js.map +1 -0
- package/dist/src/fileSystemService.d.ts +19 -0
- package/dist/src/fileSystemService.js +42 -0
- package/dist/src/fileSystemService.js.map +1 -0
- package/dist/src/runZedIntegration.d.ts +60 -0
- package/dist/src/runZedIntegration.js +123 -0
- package/dist/src/runZedIntegration.js.map +1 -0
- package/dist/src/terminalOutputDelta.d.ts +53 -0
- package/dist/src/terminalOutputDelta.js +155 -0
- package/dist/src/terminalOutputDelta.js.map +1 -0
- package/dist/src/utils/version.d.ts +14 -0
- package/dist/src/utils/version.js +52 -0
- package/dist/src/utils/version.js.map +1 -0
- package/dist/src/zed-agent-event-handler.d.ts +20 -0
- package/dist/src/zed-agent-event-handler.js +112 -0
- package/dist/src/zed-agent-event-handler.js.map +1 -0
- package/dist/src/zed-agent-setup.d.ts +8 -0
- package/dist/src/zed-agent-setup.js +38 -0
- package/dist/src/zed-agent-setup.js.map +1 -0
- package/dist/src/zed-command-registry.d.ts +20 -0
- package/dist/src/zed-command-registry.js +131 -0
- package/dist/src/zed-command-registry.js.map +1 -0
- package/dist/src/zed-config-options.d.ts +22 -0
- package/dist/src/zed-config-options.js +172 -0
- package/dist/src/zed-config-options.js.map +1 -0
- package/dist/src/zed-content-utils.d.ts +20 -0
- package/dist/src/zed-content-utils.js +117 -0
- package/dist/src/zed-content-utils.js.map +1 -0
- package/dist/src/zed-helpers.d.ts +88 -0
- package/dist/src/zed-helpers.js +272 -0
- package/dist/src/zed-helpers.js.map +1 -0
- package/dist/src/zed-initialize.d.ts +9 -0
- package/dist/src/zed-initialize.js +56 -0
- package/dist/src/zed-initialize.js.map +1 -0
- package/dist/src/zed-path-resolver.d.ts +36 -0
- package/dist/src/zed-path-resolver.js +429 -0
- package/dist/src/zed-path-resolver.js.map +1 -0
- package/dist/src/zed-plan-update.d.ts +8 -0
- package/dist/src/zed-plan-update.js +17 -0
- package/dist/src/zed-plan-update.js.map +1 -0
- package/dist/src/zed-prompt-command.d.ts +32 -0
- package/dist/src/zed-prompt-command.js +62 -0
- package/dist/src/zed-prompt-command.js.map +1 -0
- package/dist/src/zed-session-config.d.ts +32 -0
- package/dist/src/zed-session-config.js +101 -0
- package/dist/src/zed-session-config.js.map +1 -0
- package/dist/src/zed-session-errors.d.ts +96 -0
- package/dist/src/zed-session-errors.js +264 -0
- package/dist/src/zed-session-errors.js.map +1 -0
- package/dist/src/zed-session-events.d.ts +40 -0
- package/dist/src/zed-session-events.js +131 -0
- package/dist/src/zed-session-events.js.map +1 -0
- package/dist/src/zed-session-info.d.ts +134 -0
- package/dist/src/zed-session-info.js +190 -0
- package/dist/src/zed-session-info.js.map +1 -0
- package/dist/src/zed-session-lifecycle.d.ts +37 -0
- package/dist/src/zed-session-lifecycle.js +136 -0
- package/dist/src/zed-session-lifecycle.js.map +1 -0
- package/dist/src/zed-session-listing.d.ts +8 -0
- package/dist/src/zed-session-listing.js +107 -0
- package/dist/src/zed-session-listing.js.map +1 -0
- package/dist/src/zed-session-loader.d.ts +75 -0
- package/dist/src/zed-session-loader.js +141 -0
- package/dist/src/zed-session-loader.js.map +1 -0
- package/dist/src/zed-session-pagination.d.ts +26 -0
- package/dist/src/zed-session-pagination.js +142 -0
- package/dist/src/zed-session-pagination.js.map +1 -0
- package/dist/src/zed-session-replay.d.ts +59 -0
- package/dist/src/zed-session-replay.js +476 -0
- package/dist/src/zed-session-replay.js.map +1 -0
- package/dist/src/zed-stream-batcher.d.ts +57 -0
- package/dist/src/zed-stream-batcher.js +197 -0
- package/dist/src/zed-stream-batcher.js.map +1 -0
- package/dist/src/zed-terminal-manager.d.ts +44 -0
- package/dist/src/zed-terminal-manager.js +457 -0
- package/dist/src/zed-terminal-manager.js.map +1 -0
- package/dist/src/zed-terminal-setup.d.ts +14 -0
- package/dist/src/zed-terminal-setup.js +32 -0
- package/dist/src/zed-terminal-setup.js.map +1 -0
- package/dist/src/zed-tool-handler.d.ts +25 -0
- package/dist/src/zed-tool-handler.js +321 -0
- package/dist/src/zed-tool-handler.js.map +1 -0
- package/dist/src/zedIntegration.d.ts +90 -0
- package/dist/src/zedIntegration.js +566 -0
- package/dist/src/zedIntegration.js.map +1 -0
- package/index.ts +21 -0
- package/package.json +55 -3
- package/src/acp-terminal-shell-host.ts +130 -0
- package/src/acp-types.ts +35 -0
- package/src/fileSystemService.ts +46 -0
- package/src/runZedIntegration.ts +159 -0
- package/src/terminalOutputDelta.ts +179 -0
- package/src/utils/version.ts +59 -0
- package/src/zed-agent-event-handler.ts +179 -0
- package/src/zed-agent-setup.ts +43 -0
- package/src/zed-command-registry.ts +171 -0
- package/src/zed-config-options.ts +280 -0
- package/src/zed-content-utils.ts +164 -0
- package/src/zed-helpers.ts +352 -0
- package/src/zed-initialize.ts +69 -0
- package/src/zed-path-resolver.ts +681 -0
- package/src/zed-plan-update.ts +20 -0
- package/src/zed-prompt-command.ts +77 -0
- package/src/zed-session-config.ts +119 -0
- package/src/zed-session-errors.ts +337 -0
- package/src/zed-session-events.ts +216 -0
- package/src/zed-session-info.ts +255 -0
- package/src/zed-session-lifecycle.ts +194 -0
- package/src/zed-session-listing.ts +153 -0
- package/src/zed-session-loader.ts +193 -0
- package/src/zed-session-pagination.ts +240 -0
- package/src/zed-session-replay.ts +596 -0
- package/src/zed-stream-batcher.ts +236 -0
- package/src/zed-terminal-manager.ts +608 -0
- package/src/zed-terminal-setup.ts +74 -0
- package/src/zed-tool-handler.ts +420 -0
- package/src/zedIntegration.ts +813 -0
package/dist/.last_build
ADDED
|
File without changes
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Public surface of the ACP (Agent Client Protocol) client.
|
|
8
|
+
*
|
|
9
|
+
* This package is a peer client of the Agent API, not part of the CLI. A host
|
|
10
|
+
* launches it with a `Config` and, optionally, its own process-exit cleanup;
|
|
11
|
+
* everything else — the ndjson transport over stdio, session lifecycle, and
|
|
12
|
+
* runtime registration under {@link ZED_ACP_RUNTIME_ID} — is owned here.
|
|
13
|
+
*/
|
|
14
|
+
export { runZedIntegration, ZED_ACP_RUNTIME_ID, type ExitCleanupCallback, } from './src/runZedIntegration.js';
|
|
15
|
+
export { ZedAgent } from './src/zedIntegration.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Public surface of the ACP (Agent Client Protocol) client.
|
|
8
|
+
*
|
|
9
|
+
* This package is a peer client of the Agent API, not part of the CLI. A host
|
|
10
|
+
* launches it with a `Config` and, optionally, its own process-exit cleanup;
|
|
11
|
+
* everything else — the ndjson transport over stdio, session lifecycle, and
|
|
12
|
+
* runtime registration under {@link ZED_ACP_RUNTIME_ID} — is owned here.
|
|
13
|
+
*/
|
|
14
|
+
export { runZedIntegration, ZED_ACP_RUNTIME_ID, } from './src/runZedIntegration.js';
|
|
15
|
+
export { ZedAgent } from './src/zedIntegration.js';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AAEH,OAAO,EACL,iBAAiB,EACjB,kBAAkB,GAEnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { IShellToolHost, ShellExecutionResult, ShellOutputEvent, HostShellJobInfo, HostShellJobTailResult, BackgroundPromotionResult } from '@vybestack/llxprt-code-tools';
|
|
7
|
+
import type { TerminalManager } from './zed-terminal-manager.js';
|
|
8
|
+
export declare class AcpTerminalShellHost implements IShellToolHost {
|
|
9
|
+
private readonly delegate;
|
|
10
|
+
private readonly terminals;
|
|
11
|
+
constructor(delegate: IShellToolHost, terminals: TerminalManager);
|
|
12
|
+
getTargetDir(): string;
|
|
13
|
+
getWorkspaceContext(): {
|
|
14
|
+
getDirectories(): string[];
|
|
15
|
+
isPathWithinWorkspace(resolvedPath: string): boolean;
|
|
16
|
+
};
|
|
17
|
+
isCommandAllowed(command: string): import("@vybestack/llxprt-code-tools").CommandPolicyResult;
|
|
18
|
+
isShellInvocationAllowlisted(command: string, toolName: string): boolean;
|
|
19
|
+
isInteractive(): boolean;
|
|
20
|
+
isYoloMode(): boolean;
|
|
21
|
+
getDebugMode(): boolean;
|
|
22
|
+
getShellExecutionConfig(): import("@vybestack/llxprt-code-tools").ShellExecutionConfig;
|
|
23
|
+
getTimeoutConfig(): import("@vybestack/llxprt-code-tools").ShellTimeoutConfig;
|
|
24
|
+
getOutputLimits(): import("@vybestack/llxprt-code-tools").OutputLimits;
|
|
25
|
+
executeShellCommand(command: string, cwd: string, onOutput: (event: ShellOutputEvent) => void, signal: AbortSignal): Promise<ShellExecutionResult>;
|
|
26
|
+
getCommandRoots(command: string): string[];
|
|
27
|
+
stripShellWrapper(command: string): string;
|
|
28
|
+
validatePathWithinWorkspace(workspaceContext: ReturnType<IShellToolHost['getWorkspaceContext']>, dirPath: string, label: string): string | null;
|
|
29
|
+
isPtyActive(pid: number): boolean;
|
|
30
|
+
formatMemoryUsage(bytes: number): string;
|
|
31
|
+
trySummarizeOutput(content: string, signal: AbortSignal, tokenBudget?: number): Promise<string>;
|
|
32
|
+
getSummarizeConfig(): {
|
|
33
|
+
tokenBudget?: number;
|
|
34
|
+
} | undefined;
|
|
35
|
+
limitOutputTokens(content: string): {
|
|
36
|
+
content: string;
|
|
37
|
+
wasTruncated: boolean;
|
|
38
|
+
};
|
|
39
|
+
launchBackgroundJob(input: {
|
|
40
|
+
command: string;
|
|
41
|
+
cwd: string;
|
|
42
|
+
}): HostShellJobInfo;
|
|
43
|
+
tailBackgroundJob(id: string): HostShellJobTailResult;
|
|
44
|
+
detectTrailingBackground(command: string): BackgroundPromotionResult;
|
|
45
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export class AcpTerminalShellHost {
|
|
7
|
+
delegate;
|
|
8
|
+
terminals;
|
|
9
|
+
constructor(delegate, terminals) {
|
|
10
|
+
this.delegate = delegate;
|
|
11
|
+
this.terminals = terminals;
|
|
12
|
+
}
|
|
13
|
+
getTargetDir() {
|
|
14
|
+
return this.delegate.getTargetDir();
|
|
15
|
+
}
|
|
16
|
+
getWorkspaceContext() {
|
|
17
|
+
return this.delegate.getWorkspaceContext();
|
|
18
|
+
}
|
|
19
|
+
isCommandAllowed(command) {
|
|
20
|
+
return this.delegate.isCommandAllowed(command);
|
|
21
|
+
}
|
|
22
|
+
isShellInvocationAllowlisted(command, toolName) {
|
|
23
|
+
return this.delegate.isShellInvocationAllowlisted(command, toolName);
|
|
24
|
+
}
|
|
25
|
+
isInteractive() {
|
|
26
|
+
return this.delegate.isInteractive();
|
|
27
|
+
}
|
|
28
|
+
isYoloMode() {
|
|
29
|
+
return this.delegate.isYoloMode();
|
|
30
|
+
}
|
|
31
|
+
getDebugMode() {
|
|
32
|
+
return this.delegate.getDebugMode();
|
|
33
|
+
}
|
|
34
|
+
getShellExecutionConfig() {
|
|
35
|
+
return this.delegate.getShellExecutionConfig();
|
|
36
|
+
}
|
|
37
|
+
getTimeoutConfig() {
|
|
38
|
+
return this.delegate.getTimeoutConfig();
|
|
39
|
+
}
|
|
40
|
+
getOutputLimits() {
|
|
41
|
+
return this.delegate.getOutputLimits();
|
|
42
|
+
}
|
|
43
|
+
executeShellCommand(command, cwd, onOutput, signal) {
|
|
44
|
+
return this.terminals.executeShellCommand(command, cwd, onOutput, signal);
|
|
45
|
+
}
|
|
46
|
+
getCommandRoots(command) {
|
|
47
|
+
return this.delegate.getCommandRoots(command);
|
|
48
|
+
}
|
|
49
|
+
stripShellWrapper(command) {
|
|
50
|
+
return this.delegate.stripShellWrapper(command);
|
|
51
|
+
}
|
|
52
|
+
validatePathWithinWorkspace(workspaceContext, dirPath, label) {
|
|
53
|
+
return this.delegate.validatePathWithinWorkspace(workspaceContext, dirPath, label);
|
|
54
|
+
}
|
|
55
|
+
isPtyActive(pid) {
|
|
56
|
+
return this.delegate.isPtyActive(pid);
|
|
57
|
+
}
|
|
58
|
+
formatMemoryUsage(bytes) {
|
|
59
|
+
return this.delegate.formatMemoryUsage(bytes);
|
|
60
|
+
}
|
|
61
|
+
trySummarizeOutput(content, signal, tokenBudget) {
|
|
62
|
+
return this.delegate.trySummarizeOutput(content, signal, tokenBudget);
|
|
63
|
+
}
|
|
64
|
+
getSummarizeConfig() {
|
|
65
|
+
return this.delegate.getSummarizeConfig();
|
|
66
|
+
}
|
|
67
|
+
limitOutputTokens(content) {
|
|
68
|
+
return this.delegate.limitOutputTokens(content);
|
|
69
|
+
}
|
|
70
|
+
launchBackgroundJob(input) {
|
|
71
|
+
return this.delegate.launchBackgroundJob(input);
|
|
72
|
+
}
|
|
73
|
+
tailBackgroundJob(id) {
|
|
74
|
+
return this.delegate.tailBackgroundJob(id);
|
|
75
|
+
}
|
|
76
|
+
detectTrailingBackground(command) {
|
|
77
|
+
return this.delegate.detectTrailingBackground(command);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=acp-terminal-shell-host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acp-terminal-shell-host.js","sourceRoot":"","sources":["../../src/acp-terminal-shell-host.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,MAAM,OAAO,oBAAoB;IAEZ;IACA;IAFnB,YACmB,QAAwB,EACxB,SAA0B;QAD1B,aAAQ,GAAR,QAAQ,CAAgB;QACxB,cAAS,GAAT,SAAS,CAAiB;IAC1C,CAAC;IAEJ,YAAY;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC;IACtC,CAAC;IAED,mBAAmB;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,mBAAmB,EAAE,CAAC;IAC7C,CAAC;IAED,gBAAgB,CAAC,OAAe;QAC9B,OAAO,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;IAED,4BAA4B,CAAC,OAAe,EAAE,QAAgB;QAC5D,OAAO,IAAI,CAAC,QAAQ,CAAC,4BAA4B,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACvE,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC;IACvC,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACpC,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC;IACtC,CAAC;I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;IAC5C,CAAC;IAED,iBAAiB,CAAC,OAAe;QAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;IAED,mBAAmB,CAAC,KAGnB;QACC,OAAO,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC;IAED,iBAAiB,CAAC,EAAU;QAC1B,OAAO,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED,wBAAwB,CAAC,OAAe;QACtC,OAAO,IAAI,CAAC,QAAQ,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type * as acp from '@agentclientprotocol/sdk';
|
|
7
|
+
/**
|
|
8
|
+
* The pinned ACP SDK (0.14.1) does not yet export `CloseSessionRequest`,
|
|
9
|
+
* `DeleteSessionRequest`, or their responses, nor does its
|
|
10
|
+
* `ClientCapabilities` type include the `session` field used for
|
|
11
|
+
* config-option gating. These local type aliases keep the integration
|
|
12
|
+
* strongly-typed without resorting to `any`.
|
|
13
|
+
*/
|
|
14
|
+
export interface CloseSessionRequest {
|
|
15
|
+
readonly sessionId: acp.SessionId;
|
|
16
|
+
}
|
|
17
|
+
export type CloseSessionResponse = Record<string, never>;
|
|
18
|
+
export interface DeleteSessionRequest {
|
|
19
|
+
readonly sessionId: acp.SessionId;
|
|
20
|
+
}
|
|
21
|
+
export type DeleteSessionResponse = Record<string, never>;
|
|
22
|
+
export type ClientCapabilitiesWithSession = NonNullable<acp.InitializeRequest['clientCapabilities']> & {
|
|
23
|
+
readonly session?: {
|
|
24
|
+
readonly configOptions?: boolean;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acp-types.js","sourceRoot":"","sources":["../../src/acp-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { FileSystemService } from '@vybestack/llxprt-code-storage';
|
|
7
|
+
import type * as acp from '@agentclientprotocol/sdk';
|
|
8
|
+
/**
|
|
9
|
+
* ACP connection-based implementation of FileSystemService
|
|
10
|
+
*/
|
|
11
|
+
export declare class AcpFileSystemService implements FileSystemService {
|
|
12
|
+
private readonly connection;
|
|
13
|
+
private readonly sessionId;
|
|
14
|
+
private readonly capabilities;
|
|
15
|
+
private readonly fallback;
|
|
16
|
+
constructor(connection: acp.AgentSideConnection, sessionId: string, capabilities: acp.FileSystemCapabilities, fallback: FileSystemService);
|
|
17
|
+
readTextFile(filePath: string): Promise<string>;
|
|
18
|
+
writeTextFile(filePath: string, content: string): Promise<void>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* ACP connection-based implementation of FileSystemService
|
|
8
|
+
*/
|
|
9
|
+
export class AcpFileSystemService {
|
|
10
|
+
connection;
|
|
11
|
+
sessionId;
|
|
12
|
+
capabilities;
|
|
13
|
+
fallback;
|
|
14
|
+
constructor(connection, sessionId, capabilities, fallback) {
|
|
15
|
+
this.connection = connection;
|
|
16
|
+
this.sessionId = sessionId;
|
|
17
|
+
this.capabilities = capabilities;
|
|
18
|
+
this.fallback = fallback;
|
|
19
|
+
}
|
|
20
|
+
async readTextFile(filePath) {
|
|
21
|
+
if (this.capabilities.readTextFile !== true) {
|
|
22
|
+
return this.fallback.readTextFile(filePath);
|
|
23
|
+
}
|
|
24
|
+
const response = await this.connection.readTextFile({
|
|
25
|
+
path: filePath,
|
|
26
|
+
sessionId: this.sessionId,
|
|
27
|
+
});
|
|
28
|
+
return response.content;
|
|
29
|
+
}
|
|
30
|
+
async writeTextFile(filePath, content) {
|
|
31
|
+
if (this.capabilities.writeTextFile !== true) {
|
|
32
|
+
return this.fallback.writeTextFile(filePath, content);
|
|
33
|
+
}
|
|
34
|
+
await this.connection.writeTextFile({
|
|
35
|
+
path: filePath,
|
|
36
|
+
content,
|
|
37
|
+
sessionId: this.sessionId,
|
|
38
|
+
});
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=fileSystemService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileSystemService.js","sourceRoot":"","sources":["../../src/fileSystemService.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAEZ;IACA;IACA;IACA;IAJnB,YACmB,UAAmC,EACnC,SAAiB,EACjB,YAAwC,EACxC,QAA2B;QAH3B,eAAU,GAAV,UAAU,CAAyB;QACnC,cAAS,GAAT,SAAS,CAAQ;QACjB,iBAAY,GAAZ,YAAY,CAA4B;QACxC,aAAQ,GAAR,QAAQ,CAAmB;IAC3C,CAAC;IAEJ,KAAK,CAAC,YAAY,CAAC,QAAgB;QACjC,IAAI,IAAI,CAAC,YAAY,CAAC,YAAY,KAAK,IAAI,EAAE,CAAC;YAC5C,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC9C,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC;YAClD,IAAI,EAAE,QAAQ;YACd,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC,OAAO,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,QAAgB,EAAE,OAAe;QACnD,IAAI,IAAI,CAAC,YAAY,CAAC,aAAa,KAAK,IAAI,EAAE,CAAC;YAC7C,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACxD,CAAC;QAED,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;YAClC,IAAI,EAAE,QAAQ;YACd,OAAO;YACP,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { type Config } from '@vybestack/llxprt-code-core';
|
|
7
|
+
import { DebugLogger } from '@vybestack/llxprt-code-telemetry';
|
|
8
|
+
import { Readable } from 'node:stream';
|
|
9
|
+
import { ZedAgent } from './zedIntegration.js';
|
|
10
|
+
/**
|
|
11
|
+
* The package-owned runtime id registered by the ACP client when it claims the
|
|
12
|
+
* foreground runtime slot. Replaces the historical CLI-scoped
|
|
13
|
+
* `'cli.runtime.zed'`.
|
|
14
|
+
*/
|
|
15
|
+
export declare const ZED_ACP_RUNTIME_ID = "zed-acp.runtime";
|
|
16
|
+
/**
|
|
17
|
+
* Listener target for process-signal-driven disposal. Injectable so tests can
|
|
18
|
+
* drive the disposal path without sending real OS signals.
|
|
19
|
+
*/
|
|
20
|
+
export type SignalListenerTarget = {
|
|
21
|
+
on(signal: NodeJS.Signals, listener: () => void): unknown;
|
|
22
|
+
off(signal: NodeJS.Signals, listener: () => void): unknown;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Builds the disposal action performed when a disposal signal fires.
|
|
26
|
+
*
|
|
27
|
+
* The transport-ownership rule: {@link ndJsonStream} calls
|
|
28
|
+
* `input.getReader()` on the web stream, which **locks** it. Calling
|
|
29
|
+
* `.cancel()` on a locked `ReadableStream` rejects with `TypeError: Cannot
|
|
30
|
+
* cancel a readable stream that is locked`, so disposal silently no-ops and
|
|
31
|
+
* `connection.closed` never resolves — the process hangs.
|
|
32
|
+
*
|
|
33
|
+
* Instead, we destroy the **owned** Node.js `Readable` source that
|
|
34
|
+
* `Readable.toWeb` wraps. Destroying the source propagates an abort/EOF into
|
|
35
|
+
* the web stream's active reader, which the SDK's `ndJsonStream` read loop
|
|
36
|
+
* detects (either a stream-end `{ done: true }` chunk or an underlying error).
|
|
37
|
+
* That causes the SDK to call `controller.close()` / `controller.error()`,
|
|
38
|
+
* resolving `connection.closed` naturally so the `finally` cleanup runs.
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildSignalDisposalHandler(source: Readable, logger: Pick<DebugLogger, 'debug'>): () => void;
|
|
41
|
+
/**
|
|
42
|
+
* Installs process-signal listeners that trigger graceful disposal. Returns a
|
|
43
|
+
* disposer that removes the listeners.
|
|
44
|
+
*
|
|
45
|
+
* Registers listeners so Node's default SIGINT/SIGTERM behavior (immediate
|
|
46
|
+
* process termination) is suppressed long enough for the `finally` cleanup in
|
|
47
|
+
* {@link runZedIntegration} to run.
|
|
48
|
+
*/
|
|
49
|
+
export declare function installDisposalSignalHandlers(onSignal: () => void, signals?: readonly NodeJS.Signals[], target?: SignalListenerTarget): () => void;
|
|
50
|
+
export type ExitCleanupCallback = () => void | Promise<void>;
|
|
51
|
+
export declare function cleanupAgents(agents: readonly ZedAgent[], logger: DebugLogger, onExitCleanup?: ExitCleanupCallback | undefined): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Registers the ACP client as a foreground runtime in the providers runtime
|
|
54
|
+
* registry, handing off the default CLI runtime pointer. Extracted and exported
|
|
55
|
+
* so tests can assert the registration against the real registry.
|
|
56
|
+
*/
|
|
57
|
+
export declare function registerZedAcpRuntime(config: Config): void;
|
|
58
|
+
export declare function runZedIntegration(config: Config, options?: {
|
|
59
|
+
onExitCleanup?: ExitCleanupCallback;
|
|
60
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { createInkStdio } from '@vybestack/llxprt-code-core';
|
|
7
|
+
import { DebugLogger } from '@vybestack/llxprt-code-telemetry';
|
|
8
|
+
import * as acp from '@agentclientprotocol/sdk';
|
|
9
|
+
import { Readable, Writable } from 'node:stream';
|
|
10
|
+
import * as process from 'node:process';
|
|
11
|
+
import { setCliRuntimeContext } from '@vybestack/llxprt-code-providers/runtime.js';
|
|
12
|
+
import { ZedAgent } from './zedIntegration.js';
|
|
13
|
+
/**
|
|
14
|
+
* The package-owned runtime id registered by the ACP client when it claims the
|
|
15
|
+
* foreground runtime slot. Replaces the historical CLI-scoped
|
|
16
|
+
* `'cli.runtime.zed'`.
|
|
17
|
+
*/
|
|
18
|
+
export const ZED_ACP_RUNTIME_ID = 'zed-acp.runtime';
|
|
19
|
+
const DISPOSAL_SIGNALS = ['SIGINT', 'SIGTERM'];
|
|
20
|
+
/**
|
|
21
|
+
* Builds the disposal action performed when a disposal signal fires.
|
|
22
|
+
*
|
|
23
|
+
* The transport-ownership rule: {@link ndJsonStream} calls
|
|
24
|
+
* `input.getReader()` on the web stream, which **locks** it. Calling
|
|
25
|
+
* `.cancel()` on a locked `ReadableStream` rejects with `TypeError: Cannot
|
|
26
|
+
* cancel a readable stream that is locked`, so disposal silently no-ops and
|
|
27
|
+
* `connection.closed` never resolves — the process hangs.
|
|
28
|
+
*
|
|
29
|
+
* Instead, we destroy the **owned** Node.js `Readable` source that
|
|
30
|
+
* `Readable.toWeb` wraps. Destroying the source propagates an abort/EOF into
|
|
31
|
+
* the web stream's active reader, which the SDK's `ndJsonStream` read loop
|
|
32
|
+
* detects (either a stream-end `{ done: true }` chunk or an underlying error).
|
|
33
|
+
* That causes the SDK to call `controller.close()` / `controller.error()`,
|
|
34
|
+
* resolving `connection.closed` naturally so the `finally` cleanup runs.
|
|
35
|
+
*/
|
|
36
|
+
export function buildSignalDisposalHandler(source, logger) {
|
|
37
|
+
return () => {
|
|
38
|
+
try {
|
|
39
|
+
// destroy() is idempotent and safe to call on an already-ended stream.
|
|
40
|
+
// It propagates to the web stream via Readable.toWeb's adapter, causing
|
|
41
|
+
// the SDK's locked reader to observe the end/error.
|
|
42
|
+
source.destroy();
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
logger.debug(() => `Signal-driven transport destroy failed: ${String(error)}`);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Installs process-signal listeners that trigger graceful disposal. Returns a
|
|
51
|
+
* disposer that removes the listeners.
|
|
52
|
+
*
|
|
53
|
+
* Registers listeners so Node's default SIGINT/SIGTERM behavior (immediate
|
|
54
|
+
* process termination) is suppressed long enough for the `finally` cleanup in
|
|
55
|
+
* {@link runZedIntegration} to run.
|
|
56
|
+
*/
|
|
57
|
+
export function installDisposalSignalHandlers(onSignal, signals = DISPOSAL_SIGNALS, target = process) {
|
|
58
|
+
for (const signal of signals) {
|
|
59
|
+
target.on(signal, onSignal);
|
|
60
|
+
}
|
|
61
|
+
return () => {
|
|
62
|
+
for (const signal of signals) {
|
|
63
|
+
target.off(signal, onSignal);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export async function cleanupAgents(agents, logger, onExitCleanup = undefined) {
|
|
68
|
+
const disposalResults = await Promise.allSettled(agents.map((agent) => agent.disposeAll()));
|
|
69
|
+
const rejected = disposalResults.filter((result) => result.status === 'rejected');
|
|
70
|
+
for (const result of rejected) {
|
|
71
|
+
logger.warn(() => `Zed agent cleanup failed: ${String(result.reason)}`);
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
await onExitCleanup?.();
|
|
75
|
+
}
|
|
76
|
+
catch (cleanupError) {
|
|
77
|
+
logger.debug(() => `Exit cleanup failed: ${String(cleanupError)}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Registers the ACP client as a foreground runtime in the providers runtime
|
|
82
|
+
* registry, handing off the default CLI runtime pointer. Extracted and exported
|
|
83
|
+
* so tests can assert the registration against the real registry.
|
|
84
|
+
*/
|
|
85
|
+
export function registerZedAcpRuntime(config) {
|
|
86
|
+
setCliRuntimeContext(config.getSettingsService(), config, {
|
|
87
|
+
runtimeId: ZED_ACP_RUNTIME_ID,
|
|
88
|
+
metadata: { source: 'zed-integration', stage: 'bootstrap' },
|
|
89
|
+
allowDefaultHandoff: true,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
export async function runZedIntegration(config, options = {}) {
|
|
93
|
+
const logger = new DebugLogger('llxprt:zed-integration');
|
|
94
|
+
logger.debug(() => 'Starting Zed integration');
|
|
95
|
+
const { stdout: workingStdout } = createInkStdio();
|
|
96
|
+
const stdout = Writable.toWeb(workingStdout);
|
|
97
|
+
// Keep the owned Node.js Readable reference. Destroying this source (not the
|
|
98
|
+
// locked web stream) is the only way to make the ACP ndJsonStream reader
|
|
99
|
+
// observe EOF/abort so connection.closed settles.
|
|
100
|
+
const stdinSource = process.stdin;
|
|
101
|
+
const stdin = Readable.toWeb(stdinSource);
|
|
102
|
+
registerZedAcpRuntime(config);
|
|
103
|
+
const agents = [];
|
|
104
|
+
const removeSignalHandlers = installDisposalSignalHandlers(buildSignalDisposalHandler(stdinSource, logger));
|
|
105
|
+
try {
|
|
106
|
+
const stream = acp.ndJsonStream(stdout, stdin);
|
|
107
|
+
const connection = new acp.AgentSideConnection((conn) => {
|
|
108
|
+
const agent = new ZedAgent(config, conn);
|
|
109
|
+
agents.push(agent);
|
|
110
|
+
return agent;
|
|
111
|
+
}, stream);
|
|
112
|
+
await connection.closed;
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
logger.warn(() => `Zed agent connection error: ${error}`);
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
finally {
|
|
119
|
+
removeSignalHandlers();
|
|
120
|
+
await cleanupAgents(agents, logger, options.onExitCleanup);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=runZedIntegration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runZedIntegration.js","sourceRoot":"","sources":["../../src/runZedIntegration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAe,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,KAAK,GAAG,MAAM,0BAA0B,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AAEpD,MAAM,gBAAgB,GAA8B,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;AAW1E;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,0BAA0B,CACxC,MAAgB,EAChB,MAAkC;IAElC,OAAO,GAAG,EAAE;QACV,IAAI,CAAC;YACH,uEAAuE;YACvE,wEAAwE;YACxE,oDAAoD;YACpD,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CACV,GAAG,EAAE,CAAC,2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K,CAAC,CAAC;YACnB,OAAO,KAAK,CAAC;QACf,CAAC,EAAE,MAAM,CAAC,CAAC;QACX,MAAM,UAAU,CAAC,MAAM,CAAC;IAC1B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,+BAA+B,KAAK,EAAE,CAAC,CAAC;QAC1D,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,oBAAoB,EAAE,CAAC;QACvB,MAAM,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Maximum number of bytes/code units to scan when searching for an overlap
|
|
8
|
+
* between the previous and current terminal snapshots after the peer reports
|
|
9
|
+
* truncation. Keeps the search bounded (issue #3200 finding 6) so a hostile or
|
|
10
|
+
* pathological peer cannot cause super-linear work.
|
|
11
|
+
*/
|
|
12
|
+
export declare const OVERLAP_SEARCH_BOUND = 8192;
|
|
13
|
+
/**
|
|
14
|
+
* Marker inserted into the output delta when the terminal peer evicts
|
|
15
|
+
* scrollback content and no bounded overlap is found, so the model sees an
|
|
16
|
+
* explicit discontinuity rather than a silent replay or data loss.
|
|
17
|
+
*/
|
|
18
|
+
export declare const TERMINAL_DISCONTINUITY_NOTICE = "[... terminal output truncated/evicted by peer ...]\n";
|
|
19
|
+
export interface DeltaResult {
|
|
20
|
+
/** The incremental chunk to emit (may include a discontinuity notice). */
|
|
21
|
+
readonly delta: string;
|
|
22
|
+
/** True when peer eviction left some prior content unmatched or lost. */
|
|
23
|
+
readonly discontinuity: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Compute the incremental delta between two terminal output snapshots using a
|
|
27
|
+
* bounded, truly-linear (KMP) overlap search (issue #3200 finding 6).
|
|
28
|
+
*
|
|
29
|
+
* - **Clean append** (current starts with previous): O(previous.length) slice.
|
|
30
|
+
* - **Non-prefix snapshot**: a bounded overlap search (capped at
|
|
31
|
+
* {@link OVERLAP_SEARCH_BOUND}) finds the longest suffix of `previous` that
|
|
32
|
+
* is a prefix of `current` in O(bound) time via the KMP prefix function. If
|
|
33
|
+
* found, the delta skips the overlap. For truncated snapshots with no overlap,
|
|
34
|
+
* a {@link TERMINAL_DISCONTINUITY_NOTICE} is emitted instead of silently
|
|
35
|
+
* replaying the entire window. If the true overlap extends beyond the bounded
|
|
36
|
+
* search operands, content outside the detected overlap may be replayed; the
|
|
37
|
+
* discontinuity flag makes that uncertainty explicit for truncated output.
|
|
38
|
+
* A non-truncated snapshot with no overlap is treated as a reset.
|
|
39
|
+
*/
|
|
40
|
+
export declare function computeBoundedDelta(previous: string, current: string, truncated: boolean): DeltaResult;
|
|
41
|
+
/**
|
|
42
|
+
* Bound a snapshot string to its tail by UTF-8 byte budget, never splitting a
|
|
43
|
+
* multibyte character. Used to keep retained polling state bounded to the
|
|
44
|
+
* configured acquisition budget rather than a fixed character cap (issue #3200
|
|
45
|
+
* finding 4).
|
|
46
|
+
*/
|
|
47
|
+
export declare function boundSnapshotBytes(text: string, maxBytes: number): string;
|
|
48
|
+
/**
|
|
49
|
+
* Legacy character-cap snapshot bounding. Prefer {@link boundSnapshotBytes} with
|
|
50
|
+
* the configured byte budget. Retained for existing callers/tests.
|
|
51
|
+
*/
|
|
52
|
+
export declare const MAX_RETAINED_SNAPSHOT_CHARS: number;
|
|
53
|
+
export declare function boundSnapshot(text: string): string;
|