@oh-my-pi/pi-utils 17.2.8 → 17.2.10
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/CHANGELOG.md +32 -0
- package/dist/types/acp/connection.d.ts +118 -0
- package/dist/types/acp/protocol.d.ts +526 -0
- package/dist/types/acp/schema.d.ts +41 -0
- package/dist/types/acp/stream.d.ts +8 -0
- package/dist/types/acp/transport.d.ts +81 -0
- package/dist/types/acp.d.ts +6 -0
- package/dist/types/browsers.d.ts +68 -0
- package/dist/types/chalk.d.ts +125 -0
- package/dist/types/dates.d.ts +7 -0
- package/dist/types/docx/converter.d.ts +46 -0
- package/dist/types/docx/xml.d.ts +26 -0
- package/dist/types/docx/zip.d.ts +6 -0
- package/dist/types/docx.d.ts +11 -0
- package/dist/types/dom/core.d.ts +431 -0
- package/dist/types/dom/parser.d.ts +7 -0
- package/dist/types/dom/selector.d.ts +5 -0
- package/dist/types/dom.d.ts +5 -0
- package/dist/types/headers.d.ts +34 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/logger/rotating-file.d.ts +18 -0
- package/dist/types/lru.d.ts +46 -0
- package/dist/types/marked/core.d.ts +445 -0
- package/dist/types/marked.d.ts +2 -0
- package/dist/types/postmortem.d.ts +14 -0
- package/dist/types/procmgr.d.ts +16 -0
- package/dist/types/prompt.d.ts +2 -2
- package/dist/types/readability/readability.d.ts +9 -0
- package/dist/types/readability/readerable.d.ts +10 -0
- package/dist/types/readability/types.d.ts +70 -0
- package/dist/types/readability.d.ts +4 -0
- package/dist/types/template.d.ts +62 -0
- package/dist/types/turndown/gfm.d.ts +11 -0
- package/dist/types/turndown/html.d.ts +5 -0
- package/dist/types/turndown/service.d.ts +21 -0
- package/dist/types/turndown/types.d.ts +70 -0
- package/dist/types/turndown.d.ts +4 -0
- package/dist/types/version.d.ts +18 -0
- package/dist/types/vterm/buffer.d.ts +99 -0
- package/dist/types/vterm/terminal.d.ts +44 -0
- package/dist/types/vterm.d.ts +8 -0
- package/dist/types/xml.d.ts +31 -0
- package/package.json +2 -5
- package/src/acp/connection.ts +344 -0
- package/src/acp/protocol.ts +466 -0
- package/src/acp/schema.ts +160 -0
- package/src/acp/stream.ts +82 -0
- package/src/acp/transport.ts +213 -0
- package/src/acp.ts +6 -0
- package/src/browsers.ts +501 -0
- package/src/chalk.ts +312 -0
- package/src/dates.ts +194 -0
- package/src/docx/converter.ts +681 -0
- package/src/docx/xml.ts +166 -0
- package/src/docx/zip.ts +87 -0
- package/src/docx.ts +20 -0
- package/src/dom/core.ts +1254 -0
- package/src/dom/parser.ts +370 -0
- package/src/dom/selector.ts +290 -0
- package/src/dom.ts +33 -0
- package/src/fetch-retry.ts +7 -1
- package/src/frontmatter.ts +1 -1
- package/src/headers.ts +167 -0
- package/src/index.ts +1 -0
- package/src/logger/rotating-file.ts +149 -0
- package/src/logger.ts +12 -28
- package/src/lru.ts +185 -0
- package/src/marked/core.ts +1576 -0
- package/src/marked.ts +2 -0
- package/src/postmortem.ts +44 -1
- package/src/procmgr.ts +21 -4
- package/src/prompt.ts +5 -22
- package/src/readability/readability.ts +533 -0
- package/src/readability/readerable.ts +51 -0
- package/src/readability/types.ts +72 -0
- package/src/readability.ts +11 -0
- package/src/template.ts +586 -0
- package/src/turndown/gfm.ts +106 -0
- package/src/turndown/html.ts +257 -0
- package/src/turndown/service.ts +334 -0
- package/src/turndown/types.ts +81 -0
- package/src/turndown.ts +5 -0
- package/src/version.ts +99 -0
- package/src/vterm/buffer.ts +218 -0
- package/src/vterm/terminal.ts +773 -0
- package/src/vterm.ts +8 -0
- package/src/which.ts +6 -4
- package/src/xml.ts +313 -0
- package/src/winston-daily-rotate-file.d.ts +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,38 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [17.2.10] - 2026-08-06
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Introduced zero-dependency in-house modules replacing external packages, importable via `@oh-my-pi/pi-utils/<module>`: `acp` (Agent Client Protocol), `browsers` (Chrome for Testing discovery/install), `chalk` (ANSI styling), `dates` (date formatting), `dom` (HTML parser, WHATWG DOM subset, and CSS selectors), `docx` (DOCX to HTML), `headers` (browser header generation), `lru` (LRU cache), `marked` (GFM markdown lexer/parser), `readability` (article extraction), `template` (Handlebars-compatible templating), `turndown` (HTML to Markdown), `vterm` (headless terminal emulator), and `xml` (XML parser).
|
|
10
|
+
- Added postmortem fatal recovery hint providers to allow applications to print actionable recovery commands before cleanup starts.
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Rewrote the logger file backend in-house, maintaining the identical line format, daily rotation, and pruning behavior without external dependencies.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- Fixed PowerShell (`powershell.exe` / `pwsh`) support when used as a custom `shellPath` by correctly passing `-NoLogo -Command` (and `-NoProfile` under `PI_BASH_NO_LOGIN`) instead of POSIX flags.
|
|
19
|
+
- Fixed the in-house `marked` list tokenizer consuming the trailing blank line into the list token when the next top-level line was a plain paragraph. The blank now always becomes a separate `space` token (matching real marked), so a list's token shape no longer depends on what follows it — restoring the TUI streaming lexer's freeze invariant — and a list followed by a paragraph is tight, not loose, per CommonMark.
|
|
20
|
+
- Added the missing Handlebars built-in `lookup` helper to the in-house `template` engine (`{{lookup obj key}}`, proto-safe property access; a user-registered `lookup` helper still takes precedence).
|
|
21
|
+
|
|
22
|
+
### Removed
|
|
23
|
+
|
|
24
|
+
- Removed external dependencies on `handlebars`, `winston`, and `winston-daily-rotate-file`.
|
|
25
|
+
|
|
26
|
+
## [17.2.9] - 2026-08-05
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
- Added a public `compareVersions` utility (`@oh-my-pi/pi-utils`) that compares two version strings with SemVer-2.0 prerelease ordering, build-metadata stripping, and numeric segment comparison without float overflow; never throws.
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
|
|
34
|
+
- Honor the current process `PATH` when caching executable lookups, preventing stale tool paths after environment reloads.
|
|
35
|
+
- Parsed account-cap reset windows such as “Your limit will reset in 13 minutes” so credential backoff honors the provider's full reset duration.
|
|
36
|
+
|
|
5
37
|
## [17.2.6] - 2026-08-03
|
|
6
38
|
|
|
7
39
|
### Added
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { Agent, AuthenticateRequest, AuthenticateResponse, CloseSessionRequest, CloseSessionResponse, CompleteElicitationNotification, CreateElicitationRequest, CreateElicitationResponse, CreateTerminalRequest, ForkSessionRequest, ForkSessionResponse, InitializeRequest, InitializeResponse, ListSessionsRequest, ListSessionsResponse, LoadSessionRequest, LoadSessionResponse, MaybePromise, NewSessionRequest, NewSessionResponse, PromptRequest, PromptResponse, ReadTextFileRequest, ReadTextFileResponse, RequestPermissionRequest, RequestPermissionResponse, ResumeSessionRequest, ResumeSessionResponse, SessionNotification, SetSessionConfigOptionRequest, SetSessionConfigOptionResponse, SetSessionModeRequest, SetSessionModeResponse, TerminalActionResponse, TerminalOutputResponse, WaitForTerminalExitResponse, WriteTextFileRequest, WriteTextFileResponse } from "./protocol.js";
|
|
2
|
+
import type { Stream } from "./stream.js";
|
|
3
|
+
import { RpcConnection } from "./transport.js";
|
|
4
|
+
/** Terminal creation response returned by a client. */
|
|
5
|
+
export interface CreateTerminalResponse {
|
|
6
|
+
terminalId: string;
|
|
7
|
+
}
|
|
8
|
+
/** Client callbacks handled by a client-side connection. */
|
|
9
|
+
export interface Client {
|
|
10
|
+
requestPermission(params: RequestPermissionRequest): MaybePromise<RequestPermissionResponse>;
|
|
11
|
+
sessionUpdate(params: SessionNotification): MaybePromise<void>;
|
|
12
|
+
readTextFile?(params: ReadTextFileRequest): MaybePromise<ReadTextFileResponse>;
|
|
13
|
+
writeTextFile?(params: WriteTextFileRequest): MaybePromise<WriteTextFileResponse | void>;
|
|
14
|
+
createTerminal?(params: CreateTerminalRequest): MaybePromise<CreateTerminalResponse>;
|
|
15
|
+
terminalOutput?(params: {
|
|
16
|
+
sessionId: string;
|
|
17
|
+
terminalId: string;
|
|
18
|
+
}): MaybePromise<TerminalOutputResponse>;
|
|
19
|
+
waitForTerminalExit?(params: {
|
|
20
|
+
sessionId: string;
|
|
21
|
+
terminalId: string;
|
|
22
|
+
}): MaybePromise<WaitForTerminalExitResponse>;
|
|
23
|
+
killTerminal?(params: {
|
|
24
|
+
sessionId: string;
|
|
25
|
+
terminalId: string;
|
|
26
|
+
}): MaybePromise<TerminalActionResponse | void>;
|
|
27
|
+
releaseTerminal?(params: {
|
|
28
|
+
sessionId: string;
|
|
29
|
+
terminalId: string;
|
|
30
|
+
}): MaybePromise<TerminalActionResponse | void>;
|
|
31
|
+
unstable_createElicitation?(params: CreateElicitationRequest): MaybePromise<CreateElicitationResponse>;
|
|
32
|
+
unstable_completeElicitation?(params: CompleteElicitationNotification): MaybePromise<void>;
|
|
33
|
+
extMethod?(method: string, params: Record<string, unknown>): MaybePromise<Record<string, unknown>>;
|
|
34
|
+
extNotification?(method: string, params: Record<string, unknown>): MaybePromise<void>;
|
|
35
|
+
}
|
|
36
|
+
/** Agent-side ACP connection. */
|
|
37
|
+
export declare class AgentSideConnection {
|
|
38
|
+
#private;
|
|
39
|
+
constructor(toAgent: (connection: AgentSideConnection) => Agent, stream: Stream);
|
|
40
|
+
/** Signal aborted when the transport closes. */
|
|
41
|
+
get signal(): AbortSignal;
|
|
42
|
+
/** Promise resolved when the transport closes. */
|
|
43
|
+
get closed(): Promise<void>;
|
|
44
|
+
/** Sends a session update notification. */
|
|
45
|
+
sessionUpdate(params: SessionNotification): Promise<void>;
|
|
46
|
+
/** Requests permission from the client. */
|
|
47
|
+
requestPermission(params: RequestPermissionRequest): Promise<RequestPermissionResponse>;
|
|
48
|
+
/** Reads a client-side text file. */
|
|
49
|
+
readTextFile(params: ReadTextFileRequest): Promise<ReadTextFileResponse>;
|
|
50
|
+
/** Writes a client-side text file. */
|
|
51
|
+
writeTextFile(params: WriteTextFileRequest): Promise<WriteTextFileResponse>;
|
|
52
|
+
/** Creates a client terminal and returns its control handle. */
|
|
53
|
+
createTerminal(params: CreateTerminalRequest): Promise<TerminalHandle>;
|
|
54
|
+
/** Creates an interactive elicitation on the client. */
|
|
55
|
+
unstable_createElicitation(params: CreateElicitationRequest): Promise<CreateElicitationResponse>;
|
|
56
|
+
/** Notifies a client that URL elicitation completed. */
|
|
57
|
+
unstable_completeElicitation(params: CompleteElicitationNotification): Promise<void>;
|
|
58
|
+
/** Sends a custom request. */
|
|
59
|
+
request<Response = unknown, Params = unknown>(method: string, params?: Params): Promise<Response>;
|
|
60
|
+
/** Sends a custom notification. */
|
|
61
|
+
notify<Params = unknown>(method: string, params?: Params): Promise<void>;
|
|
62
|
+
/** Sends a legacy extension request. */
|
|
63
|
+
extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
64
|
+
/** Sends a legacy extension notification. */
|
|
65
|
+
extNotification(method: string, params: Record<string, unknown>): Promise<void>;
|
|
66
|
+
}
|
|
67
|
+
/** Handle for controlling a client-owned terminal. */
|
|
68
|
+
export declare class TerminalHandle {
|
|
69
|
+
#private;
|
|
70
|
+
/** Client terminal identifier. */
|
|
71
|
+
readonly id: string;
|
|
72
|
+
constructor(id: string, sessionId: string, connection: RpcConnection);
|
|
73
|
+
/** Gets current terminal output. */
|
|
74
|
+
currentOutput(): Promise<TerminalOutputResponse>;
|
|
75
|
+
/** Waits for terminal exit. */
|
|
76
|
+
waitForExit(): Promise<WaitForTerminalExitResponse>;
|
|
77
|
+
/** Kills the terminal. */
|
|
78
|
+
kill(): Promise<TerminalActionResponse>;
|
|
79
|
+
/** Releases the terminal. */
|
|
80
|
+
release(): Promise<TerminalActionResponse | void>;
|
|
81
|
+
/** Releases the terminal during async disposal. */
|
|
82
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
83
|
+
}
|
|
84
|
+
/** Client-side ACP connection used to call an agent. */
|
|
85
|
+
export declare class ClientSideConnection {
|
|
86
|
+
#private;
|
|
87
|
+
constructor(toClient: (connection: ClientSideConnection) => Client, stream: Stream);
|
|
88
|
+
/** Signal aborted when the transport closes. */
|
|
89
|
+
get signal(): AbortSignal;
|
|
90
|
+
/** Promise resolved when the transport closes. */
|
|
91
|
+
get closed(): Promise<void>;
|
|
92
|
+
/** Initializes protocol capabilities. */
|
|
93
|
+
initialize(params: InitializeRequest): Promise<InitializeResponse>;
|
|
94
|
+
/** Authenticates with an agent. */
|
|
95
|
+
authenticate(params: AuthenticateRequest): Promise<AuthenticateResponse>;
|
|
96
|
+
/** Creates a session. */
|
|
97
|
+
newSession(params: NewSessionRequest): Promise<NewSessionResponse>;
|
|
98
|
+
/** Loads a session. */
|
|
99
|
+
loadSession(params: LoadSessionRequest): Promise<LoadSessionResponse>;
|
|
100
|
+
/** Lists sessions. */
|
|
101
|
+
listSessions(params: ListSessionsRequest): Promise<ListSessionsResponse>;
|
|
102
|
+
/** Resumes a session. */
|
|
103
|
+
resumeSession(params: ResumeSessionRequest): Promise<ResumeSessionResponse>;
|
|
104
|
+
/** Forks a session. */
|
|
105
|
+
unstable_forkSession(params: ForkSessionRequest): Promise<ForkSessionResponse>;
|
|
106
|
+
/** Closes a session. */
|
|
107
|
+
closeSession(params: CloseSessionRequest): Promise<CloseSessionResponse>;
|
|
108
|
+
/** Sets a session mode. */
|
|
109
|
+
setSessionMode(params: SetSessionModeRequest): Promise<SetSessionModeResponse>;
|
|
110
|
+
/** Sets a session config option. */
|
|
111
|
+
setSessionConfigOption(params: SetSessionConfigOptionRequest): Promise<SetSessionConfigOptionResponse>;
|
|
112
|
+
/** Sends a prompt. */
|
|
113
|
+
prompt(params: PromptRequest): Promise<PromptResponse>;
|
|
114
|
+
/** Cancels an active prompt. */
|
|
115
|
+
cancel(params: {
|
|
116
|
+
sessionId: string;
|
|
117
|
+
}): Promise<void>;
|
|
118
|
+
}
|
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
/** Behavior-compatible reimplementation of @agentclientprotocol/sdk's used protocol surface. */
|
|
2
|
+
/** Metadata reserved for protocol extensions. */
|
|
3
|
+
export interface Meta {
|
|
4
|
+
_meta?: Record<string, unknown> | null;
|
|
5
|
+
}
|
|
6
|
+
/** A value which may be produced asynchronously. */
|
|
7
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
8
|
+
/** ACP protocol version identifier. */
|
|
9
|
+
export type ProtocolVersion = number;
|
|
10
|
+
/** Current ACP protocol version. */
|
|
11
|
+
export declare const PROTOCOL_VERSION = 1;
|
|
12
|
+
/** Conversation session identifier. */
|
|
13
|
+
export type SessionId = string;
|
|
14
|
+
/** Tool call identifier. */
|
|
15
|
+
export type ToolCallId = string;
|
|
16
|
+
/** ACP tool category. */
|
|
17
|
+
export type ToolKind = "read" | "edit" | "delete" | "move" | "search" | "execute" | "think" | "fetch" | "switch_mode" | "other";
|
|
18
|
+
/** ACP tool execution state. */
|
|
19
|
+
export type ToolCallStatus = "pending" | "in_progress" | "completed" | "failed";
|
|
20
|
+
/** ACP prompt stop reason. */
|
|
21
|
+
export type StopReason = "end_turn" | "max_tokens" | "max_turn_requests" | "refusal" | "cancelled";
|
|
22
|
+
/** ACP permission choice kind. */
|
|
23
|
+
export type PermissionOptionKind = "allow_once" | "allow_always" | "reject_once" | "reject_always";
|
|
24
|
+
/** Text content block. */
|
|
25
|
+
export interface TextContent extends Meta {
|
|
26
|
+
type: "text";
|
|
27
|
+
text: string;
|
|
28
|
+
}
|
|
29
|
+
/** Image content block. */
|
|
30
|
+
export interface ImageContent extends Meta {
|
|
31
|
+
type: "image";
|
|
32
|
+
data: string;
|
|
33
|
+
mimeType: string;
|
|
34
|
+
}
|
|
35
|
+
/** Audio content block. */
|
|
36
|
+
export interface AudioContent extends Meta {
|
|
37
|
+
type: "audio";
|
|
38
|
+
data: string;
|
|
39
|
+
mimeType: string;
|
|
40
|
+
}
|
|
41
|
+
/** Resource link content block. */
|
|
42
|
+
export interface ResourceLink extends Meta {
|
|
43
|
+
type: "resource_link";
|
|
44
|
+
uri: string;
|
|
45
|
+
name?: string;
|
|
46
|
+
title?: string;
|
|
47
|
+
mimeType?: string | null;
|
|
48
|
+
description?: string | null;
|
|
49
|
+
size?: number | null;
|
|
50
|
+
}
|
|
51
|
+
/** Text or blob resource embedded in a prompt. */
|
|
52
|
+
export type EmbeddedResourceValue = ({
|
|
53
|
+
uri: string;
|
|
54
|
+
text: string;
|
|
55
|
+
mimeType?: string;
|
|
56
|
+
} | {
|
|
57
|
+
uri: string;
|
|
58
|
+
blob: string;
|
|
59
|
+
mimeType?: string;
|
|
60
|
+
}) & Meta;
|
|
61
|
+
/** Embedded resource content block. */
|
|
62
|
+
export interface EmbeddedResource extends Meta {
|
|
63
|
+
type: "resource";
|
|
64
|
+
resource: EmbeddedResourceValue;
|
|
65
|
+
}
|
|
66
|
+
/** Displayable ACP content. */
|
|
67
|
+
export type ContentBlock = TextContent | ImageContent | AudioContent | ResourceLink | EmbeddedResource;
|
|
68
|
+
/** Content wrapper used by tool calls. */
|
|
69
|
+
export interface ToolContent extends Meta {
|
|
70
|
+
type: "content";
|
|
71
|
+
content: ContentBlock;
|
|
72
|
+
}
|
|
73
|
+
/** File diff emitted by a tool call. */
|
|
74
|
+
export interface ToolDiff extends Meta {
|
|
75
|
+
type: "diff";
|
|
76
|
+
path: string;
|
|
77
|
+
oldText?: string | null;
|
|
78
|
+
newText: string;
|
|
79
|
+
}
|
|
80
|
+
/** Terminal reference emitted by a tool call. */
|
|
81
|
+
export interface ToolTerminal extends Meta {
|
|
82
|
+
type: "terminal";
|
|
83
|
+
terminalId: string;
|
|
84
|
+
}
|
|
85
|
+
/** Tool call output item. */
|
|
86
|
+
export type ToolCallContent = ToolContent | ToolDiff | ToolTerminal;
|
|
87
|
+
/** File location associated with a tool call. */
|
|
88
|
+
export interface ToolCallLocation extends Meta {
|
|
89
|
+
path: string;
|
|
90
|
+
line?: number | null;
|
|
91
|
+
}
|
|
92
|
+
/** Initial tool call notification. */
|
|
93
|
+
export interface ToolCall extends Meta {
|
|
94
|
+
toolCallId: ToolCallId;
|
|
95
|
+
title: string;
|
|
96
|
+
kind?: ToolKind | null;
|
|
97
|
+
status?: ToolCallStatus | null;
|
|
98
|
+
content?: ToolCallContent[] | null;
|
|
99
|
+
locations?: ToolCallLocation[] | null;
|
|
100
|
+
rawInput?: unknown;
|
|
101
|
+
rawOutput?: unknown;
|
|
102
|
+
}
|
|
103
|
+
/** Partial update to a tool call. */
|
|
104
|
+
export interface ToolCallUpdate extends Meta {
|
|
105
|
+
toolCallId: ToolCallId;
|
|
106
|
+
title?: string | null;
|
|
107
|
+
kind?: ToolKind | null;
|
|
108
|
+
status?: ToolCallStatus | null;
|
|
109
|
+
content?: ToolCallContent[] | null;
|
|
110
|
+
locations?: ToolCallLocation[] | null;
|
|
111
|
+
rawInput?: unknown;
|
|
112
|
+
rawOutput?: unknown;
|
|
113
|
+
}
|
|
114
|
+
/** Permission option presented by the client. */
|
|
115
|
+
export interface PermissionOption extends Meta {
|
|
116
|
+
optionId: string;
|
|
117
|
+
name: string;
|
|
118
|
+
kind: PermissionOptionKind;
|
|
119
|
+
}
|
|
120
|
+
/** Request for permission to execute a tool call. */
|
|
121
|
+
export interface RequestPermissionRequest extends Meta {
|
|
122
|
+
sessionId: SessionId;
|
|
123
|
+
toolCall: ToolCallUpdate;
|
|
124
|
+
options: PermissionOption[];
|
|
125
|
+
}
|
|
126
|
+
/** Permission request response. */
|
|
127
|
+
export interface RequestPermissionResponse extends Meta {
|
|
128
|
+
outcome: {
|
|
129
|
+
outcome: "cancelled";
|
|
130
|
+
} | {
|
|
131
|
+
outcome: "selected";
|
|
132
|
+
optionId: string;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/** Client filesystem capabilities. */
|
|
136
|
+
export interface FileSystemCapabilities {
|
|
137
|
+
readTextFile?: boolean;
|
|
138
|
+
writeTextFile?: boolean;
|
|
139
|
+
}
|
|
140
|
+
/** Capabilities advertised by an ACP client. */
|
|
141
|
+
export interface ClientCapabilities {
|
|
142
|
+
fs?: FileSystemCapabilities;
|
|
143
|
+
terminal?: boolean;
|
|
144
|
+
auth?: {
|
|
145
|
+
terminal?: boolean;
|
|
146
|
+
};
|
|
147
|
+
elicitation?: {
|
|
148
|
+
form?: Record<string, unknown>;
|
|
149
|
+
url?: Record<string, unknown>;
|
|
150
|
+
};
|
|
151
|
+
_meta?: Record<string, unknown>;
|
|
152
|
+
}
|
|
153
|
+
/** Implementation identity sent during initialization. */
|
|
154
|
+
export interface Implementation {
|
|
155
|
+
name: string;
|
|
156
|
+
version: string;
|
|
157
|
+
title?: string;
|
|
158
|
+
}
|
|
159
|
+
/** Initialization request. */
|
|
160
|
+
export interface InitializeRequest extends Meta {
|
|
161
|
+
protocolVersion: ProtocolVersion;
|
|
162
|
+
clientCapabilities?: ClientCapabilities;
|
|
163
|
+
clientInfo?: Implementation | null;
|
|
164
|
+
}
|
|
165
|
+
/** Authentication method using an environment variable. */
|
|
166
|
+
export interface AuthMethodEnvVar extends Meta {
|
|
167
|
+
type: "env_var";
|
|
168
|
+
id: string;
|
|
169
|
+
name: string;
|
|
170
|
+
description?: string | null;
|
|
171
|
+
variable: string;
|
|
172
|
+
}
|
|
173
|
+
/** Authentication method using a terminal command. */
|
|
174
|
+
export interface AuthMethodTerminal extends Meta {
|
|
175
|
+
type: "terminal";
|
|
176
|
+
id: string;
|
|
177
|
+
name: string;
|
|
178
|
+
description?: string | null;
|
|
179
|
+
command?: string;
|
|
180
|
+
args?: string[];
|
|
181
|
+
}
|
|
182
|
+
/** Authentication method handled by the agent. */
|
|
183
|
+
export interface AuthMethodAgent extends Meta {
|
|
184
|
+
type?: "agent";
|
|
185
|
+
id: string;
|
|
186
|
+
name: string;
|
|
187
|
+
description?: string | null;
|
|
188
|
+
}
|
|
189
|
+
/** Authentication method advertised by an agent. */
|
|
190
|
+
export type AuthMethod = AuthMethodEnvVar | AuthMethodTerminal | AuthMethodAgent;
|
|
191
|
+
/** Initialization response. */
|
|
192
|
+
export interface InitializeResponse extends Meta {
|
|
193
|
+
protocolVersion: ProtocolVersion;
|
|
194
|
+
agentCapabilities?: Record<string, unknown>;
|
|
195
|
+
authMethods?: AuthMethod[];
|
|
196
|
+
agentInfo?: Implementation | null;
|
|
197
|
+
}
|
|
198
|
+
/** Authentication request. */
|
|
199
|
+
export interface AuthenticateRequest extends Meta {
|
|
200
|
+
methodId: string;
|
|
201
|
+
}
|
|
202
|
+
/** Authentication response. */
|
|
203
|
+
export interface AuthenticateResponse extends Meta {
|
|
204
|
+
}
|
|
205
|
+
/** ACP MCP server configuration. */
|
|
206
|
+
export type McpServer = ({
|
|
207
|
+
type?: "stdio";
|
|
208
|
+
name: string;
|
|
209
|
+
command: string;
|
|
210
|
+
args?: string[];
|
|
211
|
+
env: Array<{
|
|
212
|
+
name: string;
|
|
213
|
+
value: string;
|
|
214
|
+
}>;
|
|
215
|
+
} | {
|
|
216
|
+
type: "http" | "sse" | "acp";
|
|
217
|
+
name: string;
|
|
218
|
+
url: string;
|
|
219
|
+
headers: Array<{
|
|
220
|
+
name: string;
|
|
221
|
+
value: string;
|
|
222
|
+
}>;
|
|
223
|
+
}) & Meta;
|
|
224
|
+
/** Session mode descriptor. */
|
|
225
|
+
export interface SessionMode extends Meta {
|
|
226
|
+
id: string;
|
|
227
|
+
name: string;
|
|
228
|
+
description?: string | null;
|
|
229
|
+
}
|
|
230
|
+
/** Current session mode and available choices. */
|
|
231
|
+
export interface SessionModeState extends Meta {
|
|
232
|
+
currentModeId: string;
|
|
233
|
+
availableModes: SessionMode[];
|
|
234
|
+
}
|
|
235
|
+
/** Select configuration value. */
|
|
236
|
+
export interface SessionConfigSelectOption extends Meta {
|
|
237
|
+
value: string;
|
|
238
|
+
name: string;
|
|
239
|
+
description?: string | null;
|
|
240
|
+
}
|
|
241
|
+
/** Session configuration option. */
|
|
242
|
+
export type SessionConfigOption = ({
|
|
243
|
+
type: "select";
|
|
244
|
+
currentValue: string;
|
|
245
|
+
options: SessionConfigSelectOption[];
|
|
246
|
+
} | {
|
|
247
|
+
type: "boolean";
|
|
248
|
+
currentValue: boolean;
|
|
249
|
+
}) & {
|
|
250
|
+
id: string;
|
|
251
|
+
name: string;
|
|
252
|
+
description?: string | null;
|
|
253
|
+
category?: string | null;
|
|
254
|
+
} & Meta;
|
|
255
|
+
/** Shared fields for creating or restoring a session. */
|
|
256
|
+
export interface SessionSetupRequest extends Meta {
|
|
257
|
+
cwd: string;
|
|
258
|
+
mcpServers: McpServer[];
|
|
259
|
+
additionalDirectories?: string[];
|
|
260
|
+
}
|
|
261
|
+
/** New-session request. */
|
|
262
|
+
export interface NewSessionRequest extends SessionSetupRequest {
|
|
263
|
+
}
|
|
264
|
+
/** New-session response. */
|
|
265
|
+
export interface NewSessionResponse extends Meta {
|
|
266
|
+
sessionId: SessionId;
|
|
267
|
+
modes?: SessionModeState | null;
|
|
268
|
+
configOptions?: SessionConfigOption[] | null;
|
|
269
|
+
}
|
|
270
|
+
/** Load-session request. */
|
|
271
|
+
export interface LoadSessionRequest extends SessionSetupRequest {
|
|
272
|
+
sessionId: SessionId;
|
|
273
|
+
}
|
|
274
|
+
/** Load-session response. */
|
|
275
|
+
export interface LoadSessionResponse extends Meta {
|
|
276
|
+
modes?: SessionModeState | null;
|
|
277
|
+
configOptions?: SessionConfigOption[] | null;
|
|
278
|
+
}
|
|
279
|
+
/** Resume-session request. */
|
|
280
|
+
export interface ResumeSessionRequest extends LoadSessionRequest {
|
|
281
|
+
}
|
|
282
|
+
/** Resume-session response. */
|
|
283
|
+
export interface ResumeSessionResponse extends LoadSessionResponse {
|
|
284
|
+
}
|
|
285
|
+
/** Fork-session request. */
|
|
286
|
+
export interface ForkSessionRequest extends LoadSessionRequest {
|
|
287
|
+
}
|
|
288
|
+
/** Fork-session response. */
|
|
289
|
+
export interface ForkSessionResponse extends NewSessionResponse {
|
|
290
|
+
}
|
|
291
|
+
/** Close-session request. */
|
|
292
|
+
export interface CloseSessionRequest extends Meta {
|
|
293
|
+
sessionId: SessionId;
|
|
294
|
+
}
|
|
295
|
+
/** Close-session response. */
|
|
296
|
+
export interface CloseSessionResponse extends Meta {
|
|
297
|
+
}
|
|
298
|
+
/** Session-list request. */
|
|
299
|
+
export interface ListSessionsRequest extends Meta {
|
|
300
|
+
cwd?: string | null;
|
|
301
|
+
cursor?: string | null;
|
|
302
|
+
additionalDirectories?: string[];
|
|
303
|
+
}
|
|
304
|
+
/** Session metadata. */
|
|
305
|
+
export interface SessionInfo extends Meta {
|
|
306
|
+
sessionId: SessionId;
|
|
307
|
+
cwd: string;
|
|
308
|
+
additionalDirectories?: string[];
|
|
309
|
+
title?: string | null;
|
|
310
|
+
updatedAt?: string | null;
|
|
311
|
+
}
|
|
312
|
+
/** Session-list response. */
|
|
313
|
+
export interface ListSessionsResponse extends Meta {
|
|
314
|
+
sessions: SessionInfo[];
|
|
315
|
+
nextCursor?: string | null;
|
|
316
|
+
}
|
|
317
|
+
/** Set-mode request. */
|
|
318
|
+
export interface SetSessionModeRequest extends Meta {
|
|
319
|
+
sessionId: SessionId;
|
|
320
|
+
modeId: string;
|
|
321
|
+
}
|
|
322
|
+
/** Set-mode response. */
|
|
323
|
+
export interface SetSessionModeResponse extends Meta {
|
|
324
|
+
}
|
|
325
|
+
/** Set-config request. */
|
|
326
|
+
export interface SetSessionConfigOptionRequest extends Meta {
|
|
327
|
+
sessionId: SessionId;
|
|
328
|
+
configId: string;
|
|
329
|
+
value: string | boolean;
|
|
330
|
+
}
|
|
331
|
+
/** Set-config response. */
|
|
332
|
+
export interface SetSessionConfigOptionResponse extends Meta {
|
|
333
|
+
configOptions: SessionConfigOption[];
|
|
334
|
+
}
|
|
335
|
+
/** Slash command advertised by an agent. */
|
|
336
|
+
export interface AvailableCommand extends Meta {
|
|
337
|
+
name: string;
|
|
338
|
+
description: string;
|
|
339
|
+
input?: {
|
|
340
|
+
hint: string;
|
|
341
|
+
} | null;
|
|
342
|
+
}
|
|
343
|
+
/** Session plan entry. */
|
|
344
|
+
export interface PlanEntry extends Meta {
|
|
345
|
+
content: string;
|
|
346
|
+
priority: "high" | "medium" | "low";
|
|
347
|
+
status: "pending" | "in_progress" | "completed";
|
|
348
|
+
}
|
|
349
|
+
/** Session update payload. */
|
|
350
|
+
export type SessionUpdate = ({
|
|
351
|
+
sessionUpdate: "agent_message_chunk" | "agent_thought_chunk" | "user_message_chunk";
|
|
352
|
+
content: ContentBlock;
|
|
353
|
+
messageId?: string;
|
|
354
|
+
} & Meta) | ({
|
|
355
|
+
sessionUpdate: "tool_call";
|
|
356
|
+
} & ToolCall) | ({
|
|
357
|
+
sessionUpdate: "tool_call_update";
|
|
358
|
+
} & ToolCallUpdate) | ({
|
|
359
|
+
sessionUpdate: "plan";
|
|
360
|
+
entries: PlanEntry[];
|
|
361
|
+
} & Meta) | ({
|
|
362
|
+
sessionUpdate: "current_mode_update";
|
|
363
|
+
currentModeId: string;
|
|
364
|
+
} & Meta) | ({
|
|
365
|
+
sessionUpdate: "config_option_update";
|
|
366
|
+
configOptions: SessionConfigOption[];
|
|
367
|
+
} & Meta) | ({
|
|
368
|
+
sessionUpdate: "available_commands_update";
|
|
369
|
+
availableCommands: AvailableCommand[];
|
|
370
|
+
} & Meta) | ({
|
|
371
|
+
sessionUpdate: "session_info_update";
|
|
372
|
+
title?: string | null;
|
|
373
|
+
updatedAt?: string | null;
|
|
374
|
+
} & Meta) | ({
|
|
375
|
+
sessionUpdate: "usage_update";
|
|
376
|
+
size: number;
|
|
377
|
+
used: number;
|
|
378
|
+
cost?: {
|
|
379
|
+
amount: number;
|
|
380
|
+
currency: string;
|
|
381
|
+
} | null;
|
|
382
|
+
} & Meta);
|
|
383
|
+
/** Notification containing a session update. */
|
|
384
|
+
export interface SessionNotification extends Meta {
|
|
385
|
+
sessionId: SessionId;
|
|
386
|
+
update: SessionUpdate;
|
|
387
|
+
}
|
|
388
|
+
/** Prompt request. */
|
|
389
|
+
export interface PromptRequest extends Meta {
|
|
390
|
+
sessionId: SessionId;
|
|
391
|
+
prompt: ContentBlock[];
|
|
392
|
+
}
|
|
393
|
+
/** Prompt token usage. */
|
|
394
|
+
export interface Usage extends Meta {
|
|
395
|
+
totalTokens: number;
|
|
396
|
+
inputTokens: number;
|
|
397
|
+
outputTokens: number;
|
|
398
|
+
cachedReadTokens?: number | null;
|
|
399
|
+
cachedWriteTokens?: number | null;
|
|
400
|
+
thoughtTokens?: number | null;
|
|
401
|
+
}
|
|
402
|
+
/** Prompt response. */
|
|
403
|
+
export interface PromptResponse extends Meta {
|
|
404
|
+
stopReason: StopReason;
|
|
405
|
+
usage?: Usage | null;
|
|
406
|
+
}
|
|
407
|
+
/** Read-file request. */
|
|
408
|
+
export interface ReadTextFileRequest extends Meta {
|
|
409
|
+
sessionId: string;
|
|
410
|
+
path: string;
|
|
411
|
+
line?: number | null;
|
|
412
|
+
limit?: number | null;
|
|
413
|
+
}
|
|
414
|
+
/** Read-file response. */
|
|
415
|
+
export interface ReadTextFileResponse extends Meta {
|
|
416
|
+
content: string;
|
|
417
|
+
}
|
|
418
|
+
/** Write-file request. */
|
|
419
|
+
export interface WriteTextFileRequest extends Meta {
|
|
420
|
+
sessionId: string;
|
|
421
|
+
path: string;
|
|
422
|
+
content: string;
|
|
423
|
+
}
|
|
424
|
+
/** Write-file response. */
|
|
425
|
+
export interface WriteTextFileResponse extends Meta {
|
|
426
|
+
}
|
|
427
|
+
/** Create-terminal request. */
|
|
428
|
+
export interface CreateTerminalRequest extends Meta {
|
|
429
|
+
sessionId: string;
|
|
430
|
+
command: string;
|
|
431
|
+
args?: string[];
|
|
432
|
+
env?: Array<{
|
|
433
|
+
name: string;
|
|
434
|
+
value: string;
|
|
435
|
+
}>;
|
|
436
|
+
cwd?: string;
|
|
437
|
+
outputByteLimit?: number;
|
|
438
|
+
}
|
|
439
|
+
/** Terminal output response. */
|
|
440
|
+
export interface TerminalOutputResponse extends Meta {
|
|
441
|
+
output: string;
|
|
442
|
+
truncated: boolean;
|
|
443
|
+
exitStatus?: {
|
|
444
|
+
exitCode?: number | null;
|
|
445
|
+
signal?: string | null;
|
|
446
|
+
} | null;
|
|
447
|
+
}
|
|
448
|
+
/** Terminal exit response. */
|
|
449
|
+
export interface WaitForTerminalExitResponse extends Meta {
|
|
450
|
+
exitCode?: number | null;
|
|
451
|
+
signal?: string | null;
|
|
452
|
+
}
|
|
453
|
+
/** Empty terminal response. */
|
|
454
|
+
export interface TerminalActionResponse extends Meta {
|
|
455
|
+
}
|
|
456
|
+
/** Elicitation scalar value. */
|
|
457
|
+
export type ElicitationContentValue = string | number | boolean | string[];
|
|
458
|
+
/** Elicitation property schema. */
|
|
459
|
+
export type ElicitationPropertySchema = Record<string, unknown> & {
|
|
460
|
+
type: string;
|
|
461
|
+
title?: string;
|
|
462
|
+
description?: string;
|
|
463
|
+
};
|
|
464
|
+
/** Elicitation creation request. */
|
|
465
|
+
export type CreateElicitationRequest = ({
|
|
466
|
+
mode: "form";
|
|
467
|
+
sessionId: string;
|
|
468
|
+
message: string;
|
|
469
|
+
requestedSchema: {
|
|
470
|
+
type: "object";
|
|
471
|
+
properties: Record<string, ElicitationPropertySchema>;
|
|
472
|
+
required?: string[];
|
|
473
|
+
};
|
|
474
|
+
} & Meta) | ({
|
|
475
|
+
mode: "url";
|
|
476
|
+
sessionId: string;
|
|
477
|
+
message: string;
|
|
478
|
+
url: string;
|
|
479
|
+
elicitationId: string;
|
|
480
|
+
} & Meta) | ({
|
|
481
|
+
mode: string;
|
|
482
|
+
sessionId: string;
|
|
483
|
+
message: string;
|
|
484
|
+
requestedSchema?: {
|
|
485
|
+
type: "object";
|
|
486
|
+
properties: Record<string, ElicitationPropertySchema>;
|
|
487
|
+
required?: string[];
|
|
488
|
+
};
|
|
489
|
+
url?: string;
|
|
490
|
+
elicitationId?: string;
|
|
491
|
+
} & Meta);
|
|
492
|
+
/** Elicitation creation response. */
|
|
493
|
+
export type CreateElicitationResponse = ({
|
|
494
|
+
action: "accept";
|
|
495
|
+
content: Record<string, ElicitationContentValue>;
|
|
496
|
+
} & Meta) | ({
|
|
497
|
+
action: "decline" | "cancel";
|
|
498
|
+
content?: never;
|
|
499
|
+
} & Meta) | ({
|
|
500
|
+
action: string;
|
|
501
|
+
content?: Record<string, ElicitationContentValue>;
|
|
502
|
+
} & Meta);
|
|
503
|
+
/** Completion notification for URL elicitation. */
|
|
504
|
+
export interface CompleteElicitationNotification extends Meta {
|
|
505
|
+
sessionId: string;
|
|
506
|
+
elicitationId: string;
|
|
507
|
+
}
|
|
508
|
+
/** Agent-side request handler contract. */
|
|
509
|
+
export interface Agent {
|
|
510
|
+
initialize(params: InitializeRequest): MaybePromise<InitializeResponse>;
|
|
511
|
+
newSession(params: NewSessionRequest): MaybePromise<NewSessionResponse>;
|
|
512
|
+
prompt(params: PromptRequest): MaybePromise<PromptResponse>;
|
|
513
|
+
cancel(params: {
|
|
514
|
+
sessionId: string;
|
|
515
|
+
}): MaybePromise<void>;
|
|
516
|
+
authenticate?(params: AuthenticateRequest): MaybePromise<AuthenticateResponse | void>;
|
|
517
|
+
loadSession?(params: LoadSessionRequest): MaybePromise<LoadSessionResponse | void>;
|
|
518
|
+
listSessions?(params: ListSessionsRequest): MaybePromise<ListSessionsResponse>;
|
|
519
|
+
resumeSession?(params: ResumeSessionRequest): MaybePromise<ResumeSessionResponse>;
|
|
520
|
+
unstable_forkSession?(params: ForkSessionRequest): MaybePromise<ForkSessionResponse>;
|
|
521
|
+
closeSession?(params: CloseSessionRequest): MaybePromise<CloseSessionResponse | void>;
|
|
522
|
+
setSessionMode?(params: SetSessionModeRequest): MaybePromise<SetSessionModeResponse | void>;
|
|
523
|
+
setSessionConfigOption?(params: SetSessionConfigOptionRequest): MaybePromise<SetSessionConfigOptionResponse>;
|
|
524
|
+
extMethod?(method: string, params: Record<string, unknown>): MaybePromise<Record<string, unknown>>;
|
|
525
|
+
extNotification?(method: string, params: Record<string, unknown>): MaybePromise<void>;
|
|
526
|
+
}
|