@codingame/monaco-vscode-xterm-common 30.0.0 → 31.0.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/package.json +4 -4
- package/vscode/src/vs/platform/agentHost/common/state/protocol/actions.d.ts +990 -0
- package/vscode/src/vs/platform/agentHost/common/state/protocol/actions.js +56 -0
- package/vscode/src/vs/platform/agentHost/common/state/protocol/notifications.d.ts +179 -0
- package/vscode/src/vs/platform/agentHost/common/state/protocol/notifications.js +16 -0
- package/vscode/src/vs/platform/agentHost/common/state/protocol/state.d.ts +1418 -0
- package/vscode/src/vs/platform/agentHost/common/state/protocol/state.js +118 -0
- package/vscode/src/vs/platform/agentHost/common/state/sessionState.d.ts +76 -0
- package/vscode/src/vs/platform/agentHost/common/state/sessionState.js +20 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/agentHostPty.d.ts +106 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/agentHostPty.js +276 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/agentHostTerminalService.d.ts +56 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/agentHostTerminalService.js +237 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/ahpTerminalCommandSource.d.ts +111 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/ahpTerminalCommandSource.js +138 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/environmentVariableInfo.js +5 -5
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalActions.js +61 -61
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalInstance.d.ts +9 -2
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalInstance.js +79 -40
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.js +8 -4
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalTabsList.js +5 -5
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalTooltip.js +3 -3
- package/vscode/src/vs/workbench/contrib/terminal/common/basePty.d.ts +38 -0
- package/vscode/src/vs/workbench/contrib/terminal/common/basePty.js +127 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollColorRegistry.js +3 -3
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollOverlay.js +3 -3
- package/vscode/src/vs/workbench/contrib/terminal/common/terminalEnvironment.d.ts +0 -38
- package/vscode/src/vs/workbench/contrib/terminal/common/terminalEnvironment.js +0 -321
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChat.d.ts +0 -59
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChat.js +0 -70
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
var PolicyState;
|
|
4
|
+
(function (PolicyState) {
|
|
5
|
+
PolicyState["Enabled"] = "enabled";
|
|
6
|
+
PolicyState["Disabled"] = "disabled";
|
|
7
|
+
PolicyState["Unconfigured"] = "unconfigured";
|
|
8
|
+
})(PolicyState || (PolicyState = {}));
|
|
9
|
+
var PendingMessageKind;
|
|
10
|
+
(function (PendingMessageKind) {
|
|
11
|
+
PendingMessageKind["Steering"] = "steering";
|
|
12
|
+
PendingMessageKind["Queued"] = "queued";
|
|
13
|
+
})(PendingMessageKind || (PendingMessageKind = {}));
|
|
14
|
+
var SessionLifecycle;
|
|
15
|
+
(function (SessionLifecycle) {
|
|
16
|
+
SessionLifecycle["Creating"] = "creating";
|
|
17
|
+
SessionLifecycle["Ready"] = "ready";
|
|
18
|
+
SessionLifecycle["CreationFailed"] = "creationFailed";
|
|
19
|
+
})(SessionLifecycle || (SessionLifecycle = {}));
|
|
20
|
+
var SessionStatus;
|
|
21
|
+
(function (SessionStatus) {
|
|
22
|
+
SessionStatus[SessionStatus["Idle"] = 1] = "Idle";
|
|
23
|
+
SessionStatus[SessionStatus["Error"] = 2] = "Error";
|
|
24
|
+
SessionStatus[SessionStatus["InProgress"] = 8] = "InProgress";
|
|
25
|
+
SessionStatus[SessionStatus["InputNeeded"] = 24] = "InputNeeded";
|
|
26
|
+
})(SessionStatus || (SessionStatus = {}));
|
|
27
|
+
var SessionInputResponseKind;
|
|
28
|
+
(function (SessionInputResponseKind) {
|
|
29
|
+
SessionInputResponseKind["Accept"] = "accept";
|
|
30
|
+
SessionInputResponseKind["Decline"] = "decline";
|
|
31
|
+
SessionInputResponseKind["Cancel"] = "cancel";
|
|
32
|
+
})(SessionInputResponseKind || (SessionInputResponseKind = {}));
|
|
33
|
+
var SessionInputQuestionKind;
|
|
34
|
+
(function (SessionInputQuestionKind) {
|
|
35
|
+
SessionInputQuestionKind["Text"] = "text";
|
|
36
|
+
SessionInputQuestionKind["Number"] = "number";
|
|
37
|
+
SessionInputQuestionKind["Integer"] = "integer";
|
|
38
|
+
SessionInputQuestionKind["Boolean"] = "boolean";
|
|
39
|
+
SessionInputQuestionKind["SingleSelect"] = "single-select";
|
|
40
|
+
SessionInputQuestionKind["MultiSelect"] = "multi-select";
|
|
41
|
+
})(SessionInputQuestionKind || (SessionInputQuestionKind = {}));
|
|
42
|
+
var SessionInputAnswerValueKind;
|
|
43
|
+
(function (SessionInputAnswerValueKind) {
|
|
44
|
+
SessionInputAnswerValueKind["Text"] = "text";
|
|
45
|
+
SessionInputAnswerValueKind["Number"] = "number";
|
|
46
|
+
SessionInputAnswerValueKind["Boolean"] = "boolean";
|
|
47
|
+
SessionInputAnswerValueKind["Selected"] = "selected";
|
|
48
|
+
SessionInputAnswerValueKind["SelectedMany"] = "selected-many";
|
|
49
|
+
})(SessionInputAnswerValueKind || (SessionInputAnswerValueKind = {}));
|
|
50
|
+
var SessionInputAnswerState;
|
|
51
|
+
(function (SessionInputAnswerState) {
|
|
52
|
+
SessionInputAnswerState["Draft"] = "draft";
|
|
53
|
+
SessionInputAnswerState["Submitted"] = "submitted";
|
|
54
|
+
SessionInputAnswerState["Skipped"] = "skipped";
|
|
55
|
+
})(SessionInputAnswerState || (SessionInputAnswerState = {}));
|
|
56
|
+
var TurnState;
|
|
57
|
+
(function (TurnState) {
|
|
58
|
+
TurnState["Complete"] = "complete";
|
|
59
|
+
TurnState["Cancelled"] = "cancelled";
|
|
60
|
+
TurnState["Error"] = "error";
|
|
61
|
+
})(TurnState || (TurnState = {}));
|
|
62
|
+
var AttachmentType;
|
|
63
|
+
(function (AttachmentType) {
|
|
64
|
+
AttachmentType["File"] = "file";
|
|
65
|
+
AttachmentType["Directory"] = "directory";
|
|
66
|
+
AttachmentType["Selection"] = "selection";
|
|
67
|
+
})(AttachmentType || (AttachmentType = {}));
|
|
68
|
+
var ResponsePartKind;
|
|
69
|
+
(function (ResponsePartKind) {
|
|
70
|
+
ResponsePartKind["Markdown"] = "markdown";
|
|
71
|
+
ResponsePartKind["ContentRef"] = "contentRef";
|
|
72
|
+
ResponsePartKind["ToolCall"] = "toolCall";
|
|
73
|
+
ResponsePartKind["Reasoning"] = "reasoning";
|
|
74
|
+
})(ResponsePartKind || (ResponsePartKind = {}));
|
|
75
|
+
var ToolCallStatus;
|
|
76
|
+
(function (ToolCallStatus) {
|
|
77
|
+
ToolCallStatus["Streaming"] = "streaming";
|
|
78
|
+
ToolCallStatus["PendingConfirmation"] = "pending-confirmation";
|
|
79
|
+
ToolCallStatus["Running"] = "running";
|
|
80
|
+
ToolCallStatus["PendingResultConfirmation"] = "pending-result-confirmation";
|
|
81
|
+
ToolCallStatus["Completed"] = "completed";
|
|
82
|
+
ToolCallStatus["Cancelled"] = "cancelled";
|
|
83
|
+
})(ToolCallStatus || (ToolCallStatus = {}));
|
|
84
|
+
var ToolCallConfirmationReason;
|
|
85
|
+
(function (ToolCallConfirmationReason) {
|
|
86
|
+
ToolCallConfirmationReason["NotNeeded"] = "not-needed";
|
|
87
|
+
ToolCallConfirmationReason["UserAction"] = "user-action";
|
|
88
|
+
ToolCallConfirmationReason["Setting"] = "setting";
|
|
89
|
+
})(ToolCallConfirmationReason || (ToolCallConfirmationReason = {}));
|
|
90
|
+
var ToolCallCancellationReason;
|
|
91
|
+
(function (ToolCallCancellationReason) {
|
|
92
|
+
ToolCallCancellationReason["Denied"] = "denied";
|
|
93
|
+
ToolCallCancellationReason["Skipped"] = "skipped";
|
|
94
|
+
ToolCallCancellationReason["ResultDenied"] = "result-denied";
|
|
95
|
+
})(ToolCallCancellationReason || (ToolCallCancellationReason = {}));
|
|
96
|
+
var ToolResultContentType;
|
|
97
|
+
(function (ToolResultContentType) {
|
|
98
|
+
ToolResultContentType["Text"] = "text";
|
|
99
|
+
ToolResultContentType["EmbeddedResource"] = "embeddedResource";
|
|
100
|
+
ToolResultContentType["Resource"] = "resource";
|
|
101
|
+
ToolResultContentType["FileEdit"] = "fileEdit";
|
|
102
|
+
ToolResultContentType["Terminal"] = "terminal";
|
|
103
|
+
ToolResultContentType["Subagent"] = "subagent";
|
|
104
|
+
})(ToolResultContentType || (ToolResultContentType = {}));
|
|
105
|
+
var CustomizationStatus;
|
|
106
|
+
(function (CustomizationStatus) {
|
|
107
|
+
CustomizationStatus["Loading"] = "loading";
|
|
108
|
+
CustomizationStatus["Loaded"] = "loaded";
|
|
109
|
+
CustomizationStatus["Degraded"] = "degraded";
|
|
110
|
+
CustomizationStatus["Error"] = "error";
|
|
111
|
+
})(CustomizationStatus || (CustomizationStatus = {}));
|
|
112
|
+
var TerminalClaimKind;
|
|
113
|
+
(function (TerminalClaimKind) {
|
|
114
|
+
TerminalClaimKind["Client"] = "client";
|
|
115
|
+
TerminalClaimKind["Session"] = "session";
|
|
116
|
+
})(TerminalClaimKind || (TerminalClaimKind = {}));
|
|
117
|
+
|
|
118
|
+
export { AttachmentType, CustomizationStatus, PendingMessageKind, PolicyState, ResponsePartKind, SessionInputAnswerState, SessionInputAnswerValueKind, SessionInputQuestionKind, SessionInputResponseKind, SessionLifecycle, SessionStatus, TerminalClaimKind, ToolCallCancellationReason, ToolCallConfirmationReason, ToolCallStatus, ToolResultContentType, TurnState };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { IToolResultFileEditContent, type IActiveTurn, type IRootState, type ISessionState, type ISessionSummary, type IToolCallCancelledState, type IToolCallCompletedState, type IToolCallResult, type IToolCallState, type IToolResultContent, type IToolResultSubagentContent, type IUserMessage, ITerminalState } from "./protocol/state.js";
|
|
2
|
+
export { type IActiveTurn, type IAgentInfo, type IConfigPropertySchema, type IConfigSchema, type IContentRef, type IErrorInfo, type IProjectInfo, type IMarkdownResponsePart, type IMessageAttachment, type IReasoningResponsePart, type IResponsePart, type IRootState, type ISessionActiveClient, type ISessionConfigState, type IFileEdit as ISessionFileDiff, type IModelSelection, type ISessionModelInfo, type ISessionState, type ISessionSummary, type ISnapshot, type ITerminalState, type IToolAnnotations, type IToolCallCancelledState, type IToolCallCompletedState, type IToolCallPendingConfirmationState, type IToolCallPendingResultConfirmationState, type IToolCallResponsePart, type IToolCallResult, type IToolCallRunningState, type IToolCallState, type IToolCallStreamingState, type IToolDefinition, type ICustomizationRef, type ISessionCustomization, type IToolResultEmbeddedResourceContent as IToolResultBinaryContent, type IToolResultContent, type IToolResultFileEditContent, type IToolResultSubagentContent, type IToolResultTextContent, type ITurn, type IUsageInfo, type IUserMessage, type IPendingMessage, type StringOrMarkdown, type URI, type ISessionInputRequest, type ISessionInputQuestion, type ISessionInputAnswer, type ISessionInputOption, AttachmentType, CustomizationStatus, PendingMessageKind, PolicyState, ResponsePartKind, SessionInputAnswerState, SessionInputAnswerValueKind, SessionInputQuestionKind, SessionInputResponseKind, SessionLifecycle, SessionStatus, ToolCallConfirmationReason, ToolCallCancellationReason, ToolCallStatus, ToolResultContentType, TurnState, } from "./protocol/state.js";
|
|
3
|
+
/**
|
|
4
|
+
* The kind of file edit operation. Derived from the presence/absence of
|
|
5
|
+
* `before`/`after` in {@link IToolResultFileEditContent}.
|
|
6
|
+
*/
|
|
7
|
+
export declare enum FileEditKind {
|
|
8
|
+
/** Content edit (same file URI, different content). */
|
|
9
|
+
Edit = "edit",
|
|
10
|
+
/** File creation (no before state). */
|
|
11
|
+
Create = "create",
|
|
12
|
+
/** File deletion (no after state). */
|
|
13
|
+
Delete = "delete",
|
|
14
|
+
/** File rename/move (different before and after URIs). */
|
|
15
|
+
Rename = "rename"
|
|
16
|
+
}
|
|
17
|
+
/** URI for the root state subscription. */
|
|
18
|
+
export declare const ROOT_STATE_URI = "agenthost:/root";
|
|
19
|
+
/**
|
|
20
|
+
* A tool call in a terminal state, stored in completed turns.
|
|
21
|
+
*/
|
|
22
|
+
export type ICompletedToolCall = IToolCallCompletedState | IToolCallCancelledState;
|
|
23
|
+
/**
|
|
24
|
+
* Derived status type for the tool call lifecycle.
|
|
25
|
+
*/
|
|
26
|
+
export type ToolCallStatusString = IToolCallState["status"];
|
|
27
|
+
/**
|
|
28
|
+
* Extracts a plain-text tool output string from a tool call result's `content`
|
|
29
|
+
* array. Joins all text-type content parts into a single string.
|
|
30
|
+
*
|
|
31
|
+
* Returns `undefined` if there are no text content parts.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getToolOutputText(result: IToolCallResult): string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Extracts file edit content entries from a tool call result's `content` array.
|
|
36
|
+
* Returns an empty array if there are no file edit content parts.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getToolFileEdits(result: IToolCallResult): IToolResultFileEditContent[];
|
|
39
|
+
/**
|
|
40
|
+
* Extracts the first subagent content entry from a tool call's `content` array.
|
|
41
|
+
* Works with both completed tool call results and running tool call states.
|
|
42
|
+
* Returns `undefined` if there are no subagent content parts.
|
|
43
|
+
*/
|
|
44
|
+
export declare function getToolSubagentContent(result: {
|
|
45
|
+
content?: readonly IToolResultContent[];
|
|
46
|
+
}): IToolResultSubagentContent | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Builds a subagent session URI from a parent session URI and tool call ID.
|
|
49
|
+
* Convention: `{parentSessionUri}/subagent/{toolCallId}`
|
|
50
|
+
*/
|
|
51
|
+
export declare function buildSubagentSessionUri(parentSession: string, toolCallId: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* Parses a subagent session URI into its parent session URI and tool call ID.
|
|
54
|
+
* Returns `undefined` if the URI does not follow the subagent convention.
|
|
55
|
+
*/
|
|
56
|
+
export declare function parseSubagentSessionUri(uri: string): {
|
|
57
|
+
parentSession: string;
|
|
58
|
+
toolCallId: string;
|
|
59
|
+
} | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Returns whether a session URI represents a subagent session.
|
|
62
|
+
*/
|
|
63
|
+
export declare function isSubagentSession(uri: string): boolean;
|
|
64
|
+
export declare function createRootState(): IRootState;
|
|
65
|
+
export declare function createSessionState(summary: ISessionSummary): ISessionState;
|
|
66
|
+
export declare function createActiveTurn(id: string, userMessage: IUserMessage): IActiveTurn;
|
|
67
|
+
export declare enum StateComponents {
|
|
68
|
+
Root = 0,
|
|
69
|
+
Session = 1,
|
|
70
|
+
Terminal = 2
|
|
71
|
+
}
|
|
72
|
+
export type ComponentToState = {
|
|
73
|
+
[StateComponents.Root]: IRootState;
|
|
74
|
+
[StateComponents.Session]: ISessionState;
|
|
75
|
+
[StateComponents.Terminal]: ITerminalState;
|
|
76
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
import '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
3
|
+
export { AttachmentType, CustomizationStatus, PendingMessageKind, PolicyState, ResponsePartKind, SessionInputAnswerState, SessionInputAnswerValueKind, SessionInputQuestionKind, SessionInputResponseKind, SessionLifecycle, SessionStatus, ToolCallCancellationReason, ToolCallConfirmationReason, ToolCallStatus, ToolResultContentType, TurnState } from './protocol/state.js';
|
|
4
|
+
|
|
5
|
+
var FileEditKind;
|
|
6
|
+
(function(FileEditKind) {
|
|
7
|
+
FileEditKind["Edit"] = "edit";
|
|
8
|
+
FileEditKind["Create"] = "create";
|
|
9
|
+
FileEditKind["Delete"] = "delete";
|
|
10
|
+
FileEditKind["Rename"] = "rename";
|
|
11
|
+
})(FileEditKind || (FileEditKind = {}));
|
|
12
|
+
const ROOT_STATE_URI = "agenthost:/root";
|
|
13
|
+
var StateComponents;
|
|
14
|
+
(function(StateComponents) {
|
|
15
|
+
StateComponents[StateComponents["Root"] = 0] = "Root";
|
|
16
|
+
StateComponents[StateComponents["Session"] = 1] = "Session";
|
|
17
|
+
StateComponents[StateComponents["Terminal"] = 2] = "Terminal";
|
|
18
|
+
})(StateComponents || (StateComponents = {}));
|
|
19
|
+
|
|
20
|
+
export { FileEditKind, ROOT_STATE_URI, StateComponents };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Event } from "@codingame/monaco-vscode-api/vscode/vs/base/common/event";
|
|
2
|
+
import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
|
|
3
|
+
import { IProcessPropertyMap, ITerminalChildProcess, ITerminalLaunchError, ITerminalLaunchResult, ProcessPropertyType } from "@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminal";
|
|
4
|
+
import { IAgentConnection } from "@codingame/monaco-vscode-chat-service-override/vscode/vs/platform/agentHost/common/agentService";
|
|
5
|
+
import { BasePty } from "../common/basePty.js";
|
|
6
|
+
/**
|
|
7
|
+
* Options for creating a new terminal on an agent host.
|
|
8
|
+
*/
|
|
9
|
+
export interface IAgentHostPtyOptions {
|
|
10
|
+
/** Human-readable terminal name. */
|
|
11
|
+
readonly name?: string;
|
|
12
|
+
/** Initial working directory URI. */
|
|
13
|
+
readonly cwd?: URI;
|
|
14
|
+
/**
|
|
15
|
+
* When true, attach to an existing terminal on the agent host instead of
|
|
16
|
+
* creating a new one. The terminal must already exist server-side (e.g.
|
|
17
|
+
* created by a tool). The pty will subscribe to its state and replay
|
|
18
|
+
* content without calling `createTerminal`.
|
|
19
|
+
*/
|
|
20
|
+
readonly attachOnly?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface IAgentHostPtyCommandExecutedEvent {
|
|
23
|
+
readonly commandId: string;
|
|
24
|
+
readonly commandLine: string;
|
|
25
|
+
readonly timestamp: number;
|
|
26
|
+
/** The stored VT output for this command (present during content replay). */
|
|
27
|
+
readonly storedOutput?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface IAgentHostPtyCommandFinishedEvent {
|
|
30
|
+
readonly commandId: string;
|
|
31
|
+
readonly exitCode?: number;
|
|
32
|
+
readonly durationMs?: number;
|
|
33
|
+
}
|
|
34
|
+
export declare enum AhpCommandMarkKind {
|
|
35
|
+
Executed = "s",
|
|
36
|
+
End = "e"
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Generates the mark ID used to correlate SetMark VT codes with xterm markers
|
|
40
|
+
* via {@link IBufferMarkCapability.getMark}.
|
|
41
|
+
*/
|
|
42
|
+
export declare function getAhpCommandMarkId(commandId: string, kind: AhpCommandMarkKind): string;
|
|
43
|
+
/**
|
|
44
|
+
* A pseudo-terminal backed by an Agent Host Protocol terminal subscription.
|
|
45
|
+
*
|
|
46
|
+
* Uses `customPtyImplementation` on `IShellLaunchConfig` so the
|
|
47
|
+
* `TerminalProcessManager` bypasses the pty host backend entirely.
|
|
48
|
+
*
|
|
49
|
+
* Data flow:
|
|
50
|
+
* terminal/data → onProcessData
|
|
51
|
+
* terminal/exited → onProcessExit
|
|
52
|
+
* input(data) → dispatch terminal/input
|
|
53
|
+
* resize(c,r) → dispatch terminal/resized
|
|
54
|
+
* shutdown() → disposeTerminal command
|
|
55
|
+
*/
|
|
56
|
+
export declare class AgentHostPty extends BasePty implements ITerminalChildProcess {
|
|
57
|
+
private readonly _connection;
|
|
58
|
+
private readonly _terminalUri;
|
|
59
|
+
private readonly _options?;
|
|
60
|
+
private readonly _startBarrier;
|
|
61
|
+
private readonly _subscriptionDisposables;
|
|
62
|
+
private _subscriptionRef;
|
|
63
|
+
private _initialCwd;
|
|
64
|
+
private readonly _onCommandExecuted;
|
|
65
|
+
readonly onCommandExecuted: Event<IAgentHostPtyCommandExecutedEvent>;
|
|
66
|
+
private readonly _onCommandFinished;
|
|
67
|
+
readonly onCommandFinished: Event<IAgentHostPtyCommandFinishedEvent>;
|
|
68
|
+
private readonly _onSupportsCommandDetection;
|
|
69
|
+
readonly onSupportsCommandDetection: Event<void>;
|
|
70
|
+
private _supportsCommandDetection;
|
|
71
|
+
get supportsCommandDetection(): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Command IDs for sentinel commands that should be suppressed from shell
|
|
74
|
+
* integration events. When the copilot shell tools fall back to sentinel-
|
|
75
|
+
* based exit code detection, shell integration may also detect the sentinel
|
|
76
|
+
* echo as a real command — we filter those out here.
|
|
77
|
+
*/
|
|
78
|
+
private readonly _suppressedCommandIds;
|
|
79
|
+
constructor(id: number, _connection: IAgentConnection, _terminalUri: URI, _options?: IAgentHostPtyOptions | undefined);
|
|
80
|
+
start(): Promise<ITerminalLaunchError | ITerminalLaunchResult | undefined>;
|
|
81
|
+
private _handleAction;
|
|
82
|
+
/**
|
|
83
|
+
* Replays structured terminal content parts from the initial state snapshot.
|
|
84
|
+
* Emits command lifecycle events for command parts so that consumers
|
|
85
|
+
* (e.g. {@link AhpTerminalCommandSource}) can reconstruct command history.
|
|
86
|
+
*/
|
|
87
|
+
private _replayContent;
|
|
88
|
+
/**
|
|
89
|
+
* Resolves a cwd URI for sending over the protocol. Agent-host URIs
|
|
90
|
+
* are unwrapped to their original URI via {@link fromAgentHostUri}.
|
|
91
|
+
*/
|
|
92
|
+
private _resolveCwdForProtocol;
|
|
93
|
+
input(data: string): void;
|
|
94
|
+
resize(cols: number, rows: number): void;
|
|
95
|
+
shutdown(_immediate: boolean): void;
|
|
96
|
+
getInitialCwd(): Promise<string>;
|
|
97
|
+
getCwd(): Promise<string>;
|
|
98
|
+
clearBuffer(): Promise<void>;
|
|
99
|
+
acknowledgeDataEvent(_charCount: number): void;
|
|
100
|
+
setUnicodeVersion(_version: "6" | "11"): Promise<void>;
|
|
101
|
+
processBinary(_data: string): Promise<void>;
|
|
102
|
+
sendSignal(_signal: string): void;
|
|
103
|
+
refreshProperty<T extends ProcessPropertyType>(type: T): Promise<IProcessPropertyMap[T]>;
|
|
104
|
+
updateProperty<T extends ProcessPropertyType>(_type: T, _value: IProcessPropertyMap[T]): Promise<void>;
|
|
105
|
+
dispose(): void;
|
|
106
|
+
}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
|
|
2
|
+
import { Barrier } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
|
3
|
+
import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
4
|
+
import { DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
5
|
+
import { ProcessPropertyType } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminal';
|
|
6
|
+
import { AGENT_HOST_SCHEME, fromAgentHostUri } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/agentHostUri';
|
|
7
|
+
import { ActionType } from '../../../../platform/agentHost/common/state/protocol/actions.js';
|
|
8
|
+
import '../../../../platform/agentHost/common/state/protocol/notifications.js';
|
|
9
|
+
import { TerminalClaimKind } from '../../../../platform/agentHost/common/state/protocol/state.js';
|
|
10
|
+
import { StateComponents } from '../../../../platform/agentHost/common/state/sessionState.js';
|
|
11
|
+
import { BasePty } from '../common/basePty.js';
|
|
12
|
+
|
|
13
|
+
var AhpCommandMarkKind;
|
|
14
|
+
(function(AhpCommandMarkKind) {
|
|
15
|
+
AhpCommandMarkKind["Executed"] = "s";
|
|
16
|
+
AhpCommandMarkKind["End"] = "e";
|
|
17
|
+
})(AhpCommandMarkKind || (AhpCommandMarkKind = {}));
|
|
18
|
+
function getAhpCommandMarkId(commandId, kind) {
|
|
19
|
+
return `ahp-${commandId}-${kind}`;
|
|
20
|
+
}
|
|
21
|
+
function getAhpCommandMarkCode(commandId, kind) {
|
|
22
|
+
return `\x1b]633;SetMark;Id=${getAhpCommandMarkId(commandId, kind)};Hidden\x07`;
|
|
23
|
+
}
|
|
24
|
+
const COPILOT_SENTINEL_PREFIX = "<<<COPILOT_SENTINEL_";
|
|
25
|
+
function isCopilotSentinelCommand(commandLine) {
|
|
26
|
+
return commandLine.includes(COPILOT_SENTINEL_PREFIX);
|
|
27
|
+
}
|
|
28
|
+
class AgentHostPty extends BasePty {
|
|
29
|
+
get supportsCommandDetection() {
|
|
30
|
+
return this._supportsCommandDetection;
|
|
31
|
+
}
|
|
32
|
+
constructor(id, _connection, _terminalUri, _options) {
|
|
33
|
+
super(id, false);
|
|
34
|
+
this._connection = _connection;
|
|
35
|
+
this._terminalUri = _terminalUri;
|
|
36
|
+
this._options = _options;
|
|
37
|
+
this._startBarrier = ( new Barrier());
|
|
38
|
+
this._subscriptionDisposables = this._register(( new DisposableStore()));
|
|
39
|
+
this._initialCwd = "";
|
|
40
|
+
this._onCommandExecuted = this._register(( new Emitter()));
|
|
41
|
+
this.onCommandExecuted = this._onCommandExecuted.event;
|
|
42
|
+
this._onCommandFinished = this._register(( new Emitter()));
|
|
43
|
+
this.onCommandFinished = this._onCommandFinished.event;
|
|
44
|
+
this._onSupportsCommandDetection = this._register(( new Emitter()));
|
|
45
|
+
this.onSupportsCommandDetection = this._onSupportsCommandDetection.event;
|
|
46
|
+
this._supportsCommandDetection = false;
|
|
47
|
+
this._suppressedCommandIds = ( new Set());
|
|
48
|
+
}
|
|
49
|
+
async start() {
|
|
50
|
+
try {
|
|
51
|
+
if (!this._options?.attachOnly) {
|
|
52
|
+
await this._connection.createTerminal({
|
|
53
|
+
terminal: ( this._terminalUri.toString()),
|
|
54
|
+
claim: {
|
|
55
|
+
kind: TerminalClaimKind.Client,
|
|
56
|
+
clientId: this._connection.clientId
|
|
57
|
+
},
|
|
58
|
+
name: this._options?.name,
|
|
59
|
+
cwd: this._resolveCwdForProtocol(this._options?.cwd),
|
|
60
|
+
cols: this._lastDimensions.cols > 0 ? this._lastDimensions.cols : undefined,
|
|
61
|
+
rows: this._lastDimensions.rows > 0 ? this._lastDimensions.rows : undefined
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
this._subscriptionRef = this._connection.getSubscription(StateComponents.Terminal, this._terminalUri);
|
|
65
|
+
const subscription = this._subscriptionRef.object;
|
|
66
|
+
if (subscription.value === undefined) {
|
|
67
|
+
await ( new Promise(resolve => {
|
|
68
|
+
const listener = subscription.onDidChange(() => {
|
|
69
|
+
listener.dispose();
|
|
70
|
+
resolve();
|
|
71
|
+
});
|
|
72
|
+
this._subscriptionDisposables.add(listener);
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
const state = subscription.value;
|
|
76
|
+
if (state.supportsCommandDetection) {
|
|
77
|
+
this._supportsCommandDetection = true;
|
|
78
|
+
this._onSupportsCommandDetection.fire();
|
|
79
|
+
}
|
|
80
|
+
this._replayContent(state.content);
|
|
81
|
+
this._initialCwd = state.cwd?.toString() ?? "";
|
|
82
|
+
this._properties.cwd = this._initialCwd;
|
|
83
|
+
this._properties.initialCwd = this._initialCwd;
|
|
84
|
+
if (state.title) {
|
|
85
|
+
this._properties.title = state.title;
|
|
86
|
+
}
|
|
87
|
+
this._subscriptionDisposables.add(subscription.onDidApplyAction(envelope => {
|
|
88
|
+
this._handleAction(envelope);
|
|
89
|
+
}));
|
|
90
|
+
this._startBarrier.open();
|
|
91
|
+
this.handleReady({
|
|
92
|
+
pid: -1,
|
|
93
|
+
cwd: this._initialCwd,
|
|
94
|
+
windowsPty: undefined
|
|
95
|
+
});
|
|
96
|
+
return undefined;
|
|
97
|
+
} catch (err) {
|
|
98
|
+
this._startBarrier.open();
|
|
99
|
+
return {
|
|
100
|
+
message: err instanceof Error ? err.message : String(err)
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
_handleAction(envelope) {
|
|
105
|
+
const action = envelope.action;
|
|
106
|
+
switch (action.type) {
|
|
107
|
+
case ActionType.TerminalData:
|
|
108
|
+
this.handleData(action.data);
|
|
109
|
+
break;
|
|
110
|
+
case ActionType.TerminalExited:
|
|
111
|
+
this.handleExit(action.exitCode);
|
|
112
|
+
break;
|
|
113
|
+
case ActionType.TerminalCwdChanged:
|
|
114
|
+
this._properties.cwd = ( action.cwd.toString());
|
|
115
|
+
this.handleDidChangeProperty({
|
|
116
|
+
type: ProcessPropertyType.Cwd,
|
|
117
|
+
value: ( action.cwd.toString())
|
|
118
|
+
});
|
|
119
|
+
break;
|
|
120
|
+
case ActionType.TerminalTitleChanged:
|
|
121
|
+
this._properties.title = action.title;
|
|
122
|
+
this.handleDidChangeProperty({
|
|
123
|
+
type: ProcessPropertyType.Title,
|
|
124
|
+
value: action.title
|
|
125
|
+
});
|
|
126
|
+
break;
|
|
127
|
+
case ActionType.TerminalResized:
|
|
128
|
+
if (envelope.origin?.clientId !== this._connection.clientId) {
|
|
129
|
+
this.handleDidChangeProperty({
|
|
130
|
+
type: ProcessPropertyType.OverrideDimensions,
|
|
131
|
+
value: {
|
|
132
|
+
cols: action.cols,
|
|
133
|
+
rows: action.rows
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
break;
|
|
138
|
+
case ActionType.TerminalCommandDetectionAvailable:
|
|
139
|
+
if (!this._supportsCommandDetection) {
|
|
140
|
+
this._supportsCommandDetection = true;
|
|
141
|
+
this._onSupportsCommandDetection.fire();
|
|
142
|
+
}
|
|
143
|
+
break;
|
|
144
|
+
case ActionType.TerminalCommandExecuted:
|
|
145
|
+
if (isCopilotSentinelCommand(action.commandLine)) {
|
|
146
|
+
this._suppressedCommandIds.add(action.commandId);
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
this.handleData(getAhpCommandMarkCode(action.commandId, AhpCommandMarkKind.Executed));
|
|
150
|
+
this._onCommandExecuted.fire({
|
|
151
|
+
commandId: action.commandId,
|
|
152
|
+
commandLine: action.commandLine,
|
|
153
|
+
timestamp: action.timestamp
|
|
154
|
+
});
|
|
155
|
+
break;
|
|
156
|
+
case ActionType.TerminalCommandFinished:
|
|
157
|
+
if (this._suppressedCommandIds.delete(action.commandId)) {
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
this.handleData(getAhpCommandMarkCode(action.commandId, AhpCommandMarkKind.End));
|
|
161
|
+
this._onCommandFinished.fire({
|
|
162
|
+
commandId: action.commandId,
|
|
163
|
+
exitCode: action.exitCode,
|
|
164
|
+
durationMs: action.durationMs
|
|
165
|
+
});
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
_replayContent(content) {
|
|
170
|
+
for (const part of content) {
|
|
171
|
+
if (part.type === "unclassified") {
|
|
172
|
+
if (part.value) {
|
|
173
|
+
this.handleData(part.value);
|
|
174
|
+
}
|
|
175
|
+
} else if (part.type === "command") {
|
|
176
|
+
if (isCopilotSentinelCommand(part.commandLine)) {
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
this.handleData(getAhpCommandMarkCode(part.commandId, AhpCommandMarkKind.Executed));
|
|
180
|
+
this._onCommandExecuted.fire({
|
|
181
|
+
commandId: part.commandId,
|
|
182
|
+
commandLine: part.commandLine,
|
|
183
|
+
timestamp: part.timestamp,
|
|
184
|
+
storedOutput: part.output
|
|
185
|
+
});
|
|
186
|
+
if (part.output) {
|
|
187
|
+
this.handleData(part.output);
|
|
188
|
+
}
|
|
189
|
+
if (part.isComplete) {
|
|
190
|
+
this.handleData(getAhpCommandMarkCode(part.commandId, AhpCommandMarkKind.End));
|
|
191
|
+
this._onCommandFinished.fire({
|
|
192
|
+
commandId: part.commandId,
|
|
193
|
+
exitCode: part.exitCode,
|
|
194
|
+
durationMs: part.durationMs
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
_resolveCwdForProtocol(cwd) {
|
|
201
|
+
if (!cwd) {
|
|
202
|
+
return undefined;
|
|
203
|
+
}
|
|
204
|
+
if (cwd.scheme === AGENT_HOST_SCHEME) {
|
|
205
|
+
return ( fromAgentHostUri(cwd).toString());
|
|
206
|
+
}
|
|
207
|
+
return ( cwd.toString());
|
|
208
|
+
}
|
|
209
|
+
input(data) {
|
|
210
|
+
if (this._inReplay) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
this._startBarrier.wait().then(() => {
|
|
214
|
+
this._connection.dispatch({
|
|
215
|
+
type: ActionType.TerminalInput,
|
|
216
|
+
terminal: ( this._terminalUri.toString()),
|
|
217
|
+
data
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
resize(cols, rows) {
|
|
222
|
+
if (this._inReplay || (this._lastDimensions.cols === cols && this._lastDimensions.rows === rows)) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
this._lastDimensions.cols = cols;
|
|
226
|
+
this._lastDimensions.rows = rows;
|
|
227
|
+
this._startBarrier.wait().then(() => {
|
|
228
|
+
this._connection.dispatch({
|
|
229
|
+
type: ActionType.TerminalResized,
|
|
230
|
+
terminal: ( this._terminalUri.toString()),
|
|
231
|
+
cols,
|
|
232
|
+
rows
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
shutdown(_immediate) {
|
|
237
|
+
this._startBarrier.wait().then(() => {
|
|
238
|
+
if (!this._options?.attachOnly) {
|
|
239
|
+
this._connection.disposeTerminal(this._terminalUri);
|
|
240
|
+
}
|
|
241
|
+
this._subscriptionRef?.dispose();
|
|
242
|
+
this._subscriptionRef = undefined;
|
|
243
|
+
this._subscriptionDisposables.clear();
|
|
244
|
+
this.handleExit(undefined);
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
async getInitialCwd() {
|
|
248
|
+
return this._initialCwd;
|
|
249
|
+
}
|
|
250
|
+
async getCwd() {
|
|
251
|
+
return this._properties.cwd || this._initialCwd;
|
|
252
|
+
}
|
|
253
|
+
async clearBuffer() {
|
|
254
|
+
this._connection.dispatch({
|
|
255
|
+
type: ActionType.TerminalCleared,
|
|
256
|
+
terminal: ( this._terminalUri.toString())
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
acknowledgeDataEvent(_charCount) {}
|
|
260
|
+
async setUnicodeVersion(_version) {}
|
|
261
|
+
processBinary(_data) {
|
|
262
|
+
return Promise.resolve();
|
|
263
|
+
}
|
|
264
|
+
sendSignal(_signal) {}
|
|
265
|
+
async refreshProperty(type) {
|
|
266
|
+
return this._properties[type];
|
|
267
|
+
}
|
|
268
|
+
async updateProperty(_type, _value) {}
|
|
269
|
+
dispose() {
|
|
270
|
+
this._subscriptionRef?.dispose();
|
|
271
|
+
this._subscriptionRef = undefined;
|
|
272
|
+
super.dispose();
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export { AgentHostPty, AhpCommandMarkKind, getAhpCommandMarkId };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Disposable, IDisposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
2
|
+
import { IObservable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/observable";
|
|
3
|
+
import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
|
|
4
|
+
import { IAgentConnection } from "@codingame/monaco-vscode-chat-service-override/vscode/vs/platform/agentHost/common/agentService";
|
|
5
|
+
import { IQuickInputService } from "@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service";
|
|
6
|
+
import { ITerminalInstance, ITerminalLocationOptions } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminal";
|
|
7
|
+
import { ITerminalChatService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminal.service";
|
|
8
|
+
import { ITerminalService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminal.service";
|
|
9
|
+
import { ITerminalProfileService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/common/terminal.service";
|
|
10
|
+
import { IAgentHostTerminalService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/agentHostTerminalService.service";
|
|
11
|
+
export interface IAgentHostTerminalCreateOptions {
|
|
12
|
+
/** Human-readable terminal name. */
|
|
13
|
+
readonly name?: string;
|
|
14
|
+
/** Initial working directory. */
|
|
15
|
+
readonly cwd?: URI;
|
|
16
|
+
/** Terminal location (panel, editor, split, etc.). */
|
|
17
|
+
readonly location?: ITerminalLocationOptions;
|
|
18
|
+
}
|
|
19
|
+
export interface IAgentHostEntry {
|
|
20
|
+
/** Display name for the profile. */
|
|
21
|
+
readonly name: string;
|
|
22
|
+
/** Address or identifier for the host. */
|
|
23
|
+
readonly address: string;
|
|
24
|
+
/** Getter for the connection (may be lazily resolved). */
|
|
25
|
+
readonly getConnection: () => IAgentConnection | undefined;
|
|
26
|
+
}
|
|
27
|
+
export interface IAgentHostTerminalProfileInfo {
|
|
28
|
+
readonly extensionIdentifier: string;
|
|
29
|
+
readonly profileId: string;
|
|
30
|
+
readonly title: string;
|
|
31
|
+
readonly address: string;
|
|
32
|
+
}
|
|
33
|
+
export declare class AgentHostTerminalService extends Disposable implements IAgentHostTerminalService {
|
|
34
|
+
private readonly _terminalService;
|
|
35
|
+
private readonly _terminalChatService;
|
|
36
|
+
private readonly _terminalProfileService;
|
|
37
|
+
private readonly _quickInputService;
|
|
38
|
+
readonly _serviceBrand: undefined;
|
|
39
|
+
private readonly _entries;
|
|
40
|
+
private readonly _usedHosts;
|
|
41
|
+
private readonly _profileRegistrations;
|
|
42
|
+
private readonly _profiles;
|
|
43
|
+
readonly profiles: IObservable<readonly IAgentHostTerminalProfileInfo[]>;
|
|
44
|
+
private _defaultCwd;
|
|
45
|
+
/** Revived terminal instances, keyed by terminal URI string. */
|
|
46
|
+
private readonly _revivedInstances;
|
|
47
|
+
constructor(_terminalService: ITerminalService, _terminalChatService: ITerminalChatService, _terminalProfileService: ITerminalProfileService, _quickInputService: IQuickInputService);
|
|
48
|
+
registerEntry(entry: IAgentHostEntry): IDisposable;
|
|
49
|
+
getProfileForConnection(address: string): IAgentHostTerminalProfileInfo | undefined;
|
|
50
|
+
setDefaultCwd(cwd: URI | undefined): void;
|
|
51
|
+
private _reconcile;
|
|
52
|
+
private _registerProfile;
|
|
53
|
+
createTerminalForEntry(address: string, options?: IAgentHostTerminalCreateOptions): Promise<ITerminalInstance | undefined>;
|
|
54
|
+
createTerminal(connection: IAgentConnection, options?: IAgentHostTerminalCreateOptions): Promise<ITerminalInstance>;
|
|
55
|
+
reviveTerminal(connection: IAgentConnection, terminalUri: URI, terminalToolSessionId: string): Promise<ITerminalInstance>;
|
|
56
|
+
}
|