@mseep/obsidian-agent-client 0.10.6
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/.claude/hooks/gh-setup.sh +49 -0
- package/.claude/settings.json +15 -0
- package/.claude/skills/release-notes/SKILL.md +331 -0
- package/.editorconfig +10 -0
- package/.github/FUNDING.yml +2 -0
- package/.github/ISSUE_TEMPLATE/bug_report.yml +90 -0
- package/.github/ISSUE_TEMPLATE/config.yml +11 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +59 -0
- package/.github/copilot-instructions.md +45 -0
- package/.github/pull_request_template.md +32 -0
- package/.github/workflows/ci.yaml +25 -0
- package/.github/workflows/docs.yml +58 -0
- package/.github/workflows/relay_to_openclaw.yml +59 -0
- package/.github/workflows/release.yaml +45 -0
- package/.prettierignore +10 -0
- package/.prettierrc +13 -0
- package/.vscode/extensions.json +7 -0
- package/.vscode/settings.json +37 -0
- package/.zed/settings.json +42 -0
- package/AGENTS.md +330 -0
- package/ARCHITECTURE.md +390 -0
- package/CONTRIBUTING.md +216 -0
- package/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.ja.md +121 -0
- package/README.md +125 -0
- package/docs/.vitepress/config.mts +124 -0
- package/docs/.vitepress/theme/custom.css +111 -0
- package/docs/.vitepress/theme/index.ts +4 -0
- package/docs/agent-setup/claude-code.md +84 -0
- package/docs/agent-setup/codex.md +76 -0
- package/docs/agent-setup/custom-agents.md +67 -0
- package/docs/agent-setup/gemini-cli.md +99 -0
- package/docs/agent-setup/index.md +34 -0
- package/docs/announcements/gemini-cli-deprecation.md +73 -0
- package/docs/getting-started/index.md +78 -0
- package/docs/getting-started/quick-start.md +38 -0
- package/docs/help/faq.md +181 -0
- package/docs/help/troubleshooting.md +221 -0
- package/docs/index.md +63 -0
- package/docs/public/apple-touch-icon.png +0 -0
- package/docs/public/demo.mp4 +0 -0
- package/docs/public/favicon-16x16.png +0 -0
- package/docs/public/favicon-32x32.png +0 -0
- package/docs/public/favicon.ico +0 -0
- package/docs/public/images/editing.webp +0 -0
- package/docs/public/images/export.webp +0 -0
- package/docs/public/images/floating-chat-button.webp +0 -0
- package/docs/public/images/floating-chat-instance-menu.webp +0 -0
- package/docs/public/images/floating-chat-view.webp +0 -0
- package/docs/public/images/mode-selection.webp +0 -0
- package/docs/public/images/model-selection.webp +0 -0
- package/docs/public/images/multi-session.webp +0 -0
- package/docs/public/images/remove-image.webp +0 -0
- package/docs/public/images/ribbon-icon.webp +0 -0
- package/docs/public/images/selection-context.gif +0 -0
- package/docs/public/images/sending-images.webp +0 -0
- package/docs/public/images/sending-messages.webp +0 -0
- package/docs/public/images/session-history-button.webp +0 -0
- package/docs/public/images/slash-commands-1.webp +0 -0
- package/docs/public/images/slash-commands-2.webp +0 -0
- package/docs/public/images/switch-agent.webp +0 -0
- package/docs/public/images/switch-default-agent.webp +0 -0
- package/docs/public/images/temporary-disable.gif +0 -0
- package/docs/reference/acp-support.md +110 -0
- package/docs/usage/chat-export.md +80 -0
- package/docs/usage/commands.md +51 -0
- package/docs/usage/context-files.md +57 -0
- package/docs/usage/editing.md +69 -0
- package/docs/usage/floating-chat.md +84 -0
- package/docs/usage/index.md +97 -0
- package/docs/usage/mcp-tools.md +33 -0
- package/docs/usage/mentions.md +70 -0
- package/docs/usage/mode-selection.md +28 -0
- package/docs/usage/model-selection.md +32 -0
- package/docs/usage/multi-session.md +68 -0
- package/docs/usage/sending-images.md +64 -0
- package/docs/usage/session-history.md +91 -0
- package/docs/usage/slash-commands.md +44 -0
- package/esbuild.config.mjs +49 -0
- package/eslint.config.mjs +25 -0
- package/main.js +228 -0
- package/manifest.json +11 -0
- package/package.json +52 -0
- package/src/acp/acp-client.ts +921 -0
- package/src/acp/acp-handler.ts +252 -0
- package/src/acp/permission-handler.ts +282 -0
- package/src/acp/terminal-handler.ts +264 -0
- package/src/acp/type-converter.ts +272 -0
- package/src/hooks/useAgent.ts +250 -0
- package/src/hooks/useAgentMessages.ts +470 -0
- package/src/hooks/useAgentSession.ts +544 -0
- package/src/hooks/useChatActions.ts +400 -0
- package/src/hooks/useHistoryModal.ts +219 -0
- package/src/hooks/useSessionHistory.ts +863 -0
- package/src/hooks/useSettings.ts +19 -0
- package/src/hooks/useSuggestions.ts +342 -0
- package/src/main.ts +9 -0
- package/src/plugin.ts +1126 -0
- package/src/services/chat-exporter.ts +552 -0
- package/src/services/message-sender.ts +755 -0
- package/src/services/message-state.ts +375 -0
- package/src/services/session-helpers.ts +211 -0
- package/src/services/session-state.ts +130 -0
- package/src/services/session-storage.ts +267 -0
- package/src/services/settings-normalizer.ts +255 -0
- package/src/services/settings-service.ts +285 -0
- package/src/services/update-checker.ts +128 -0
- package/src/services/vault-service.ts +558 -0
- package/src/services/view-registry.ts +345 -0
- package/src/types/agent.ts +92 -0
- package/src/types/chat.ts +351 -0
- package/src/types/errors.ts +136 -0
- package/src/types/obsidian-internals.d.ts +14 -0
- package/src/types/session.ts +731 -0
- package/src/ui/ChangeDirectoryModal.ts +137 -0
- package/src/ui/ChatContext.ts +25 -0
- package/src/ui/ChatHeader.tsx +295 -0
- package/src/ui/ChatPanel.tsx +1162 -0
- package/src/ui/ChatView.tsx +348 -0
- package/src/ui/ErrorBanner.tsx +104 -0
- package/src/ui/FloatingButton.tsx +351 -0
- package/src/ui/FloatingChatView.tsx +531 -0
- package/src/ui/InputArea.tsx +1107 -0
- package/src/ui/InputToolbar.tsx +371 -0
- package/src/ui/MessageBubble.tsx +442 -0
- package/src/ui/MessageList.tsx +265 -0
- package/src/ui/PermissionBanner.tsx +61 -0
- package/src/ui/SessionHistoryModal.tsx +821 -0
- package/src/ui/SettingsTab.ts +1337 -0
- package/src/ui/SuggestionPopup.tsx +138 -0
- package/src/ui/TerminalBlock.tsx +107 -0
- package/src/ui/ToolCallBlock.tsx +456 -0
- package/src/ui/shared/AttachmentStrip.tsx +57 -0
- package/src/ui/shared/IconButton.tsx +55 -0
- package/src/ui/shared/MarkdownRenderer.tsx +103 -0
- package/src/ui/view-host.ts +56 -0
- package/src/utils/error-utils.ts +274 -0
- package/src/utils/logger.ts +44 -0
- package/src/utils/mention-parser.ts +129 -0
- package/src/utils/paths.ts +246 -0
- package/src/utils/platform.ts +425 -0
- package/styles.css +2322 -0
- package/tsconfig.json +18 -0
- package/version-bump.mjs +18 -0
- package/versions.json +3 -0
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain Models for Chat Messages
|
|
3
|
+
*
|
|
4
|
+
* These types are independent of the Agent Client Protocol (ACP) library.
|
|
5
|
+
* They represent the core domain concepts of this plugin and remain stable
|
|
6
|
+
* even if the underlying protocol changes. The Adapter layer handles conversion
|
|
7
|
+
* between these domain types and ACP protocol types.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Core Types
|
|
12
|
+
// ============================================================================
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Message role in a conversation.
|
|
16
|
+
* - assistant: AI agent's messages
|
|
17
|
+
* - user: User's messages
|
|
18
|
+
*/
|
|
19
|
+
export type Role = "assistant" | "user";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Status of a tool call execution.
|
|
23
|
+
*/
|
|
24
|
+
export type ToolCallStatus = "pending" | "in_progress" | "completed" | "failed";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Categories of tool operations.
|
|
28
|
+
*/
|
|
29
|
+
export type ToolKind =
|
|
30
|
+
| "read" // Reading files or data
|
|
31
|
+
| "edit" // Modifying existing content
|
|
32
|
+
| "delete" // Removing files or data
|
|
33
|
+
| "move" // Moving or renaming
|
|
34
|
+
| "search" // Searching through content
|
|
35
|
+
| "execute" // Running commands or scripts
|
|
36
|
+
| "think" // Agent reasoning/planning
|
|
37
|
+
| "fetch" // Fetching external resources
|
|
38
|
+
| "switch_mode" // Changing operation mode
|
|
39
|
+
| "other"; // Other operations
|
|
40
|
+
|
|
41
|
+
// ============================================================================
|
|
42
|
+
// Tool Call Content Types
|
|
43
|
+
// ============================================================================
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Content that can be included in a tool call result.
|
|
47
|
+
* Currently supports diffs and terminal output.
|
|
48
|
+
*/
|
|
49
|
+
export type ToolCallContent = DiffContent | TerminalContent;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Represents a file modification with before/after content.
|
|
53
|
+
*/
|
|
54
|
+
export interface DiffContent {
|
|
55
|
+
type: "diff";
|
|
56
|
+
path: string;
|
|
57
|
+
newText: string;
|
|
58
|
+
oldText?: string | null; // null or undefined for new files
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Reference to a terminal session created by a tool call.
|
|
63
|
+
*/
|
|
64
|
+
export interface TerminalContent {
|
|
65
|
+
type: "terminal";
|
|
66
|
+
terminalId: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ============================================================================
|
|
70
|
+
// Supporting Types
|
|
71
|
+
// ============================================================================
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Location information for tool operations (e.g., which file/line was affected).
|
|
75
|
+
*/
|
|
76
|
+
export interface ToolCallLocation {
|
|
77
|
+
path: string;
|
|
78
|
+
line?: number | null; // null if the entire file is affected
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* User's choice for permission requests.
|
|
83
|
+
*/
|
|
84
|
+
export interface PermissionOption {
|
|
85
|
+
optionId: string;
|
|
86
|
+
name: string;
|
|
87
|
+
kind: "allow_once" | "allow_always" | "reject_once" | "reject_always";
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Active permission request information.
|
|
92
|
+
* Derived from messages by scanning for tool_call content with isActive permission.
|
|
93
|
+
*/
|
|
94
|
+
export interface ActivePermission {
|
|
95
|
+
/** Permission request ID */
|
|
96
|
+
requestId: string;
|
|
97
|
+
/** Tool call ID that triggered the request */
|
|
98
|
+
toolCallId: string;
|
|
99
|
+
/** Available permission options */
|
|
100
|
+
options: PermissionOption[];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Entry in an agent's plan/task list.
|
|
105
|
+
*/
|
|
106
|
+
export interface PlanEntry {
|
|
107
|
+
content: string;
|
|
108
|
+
status: "pending" | "in_progress" | "completed";
|
|
109
|
+
priority: "high" | "medium" | "low";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Tool call information for permission requests.
|
|
114
|
+
* Contains details about the operation being requested for user approval.
|
|
115
|
+
*/
|
|
116
|
+
export interface ToolCallInfo {
|
|
117
|
+
toolCallId: string;
|
|
118
|
+
title?: string | null;
|
|
119
|
+
status?: ToolCallStatus | null;
|
|
120
|
+
kind?: ToolKind | null;
|
|
121
|
+
content?: ToolCallContent[] | null;
|
|
122
|
+
locations?: ToolCallLocation[] | null;
|
|
123
|
+
rawInput?: { [k: string]: unknown }; // Tool's input parameters
|
|
124
|
+
rawOutput?: { [k: string]: unknown }; // Tool's output data
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// ============================================================================
|
|
128
|
+
// Chat Message
|
|
129
|
+
// ============================================================================
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* A single message in the chat history.
|
|
133
|
+
*
|
|
134
|
+
* Messages can contain multiple content blocks of different types
|
|
135
|
+
* (text, images, tool calls, etc.) to represent rich conversations.
|
|
136
|
+
*/
|
|
137
|
+
export interface ChatMessage {
|
|
138
|
+
id: string;
|
|
139
|
+
role: Role;
|
|
140
|
+
content: MessageContent[];
|
|
141
|
+
timestamp: Date;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Different types of content that can appear in a message.
|
|
146
|
+
*
|
|
147
|
+
* This union type represents all possible content blocks:
|
|
148
|
+
* - text: Plain text from user or agent
|
|
149
|
+
* - agent_thought: Agent's internal reasoning (often collapsed in UI)
|
|
150
|
+
* - image: Visual content (base64 encoded)
|
|
151
|
+
* - resource_link: Reference to a file the agent can access (URI only)
|
|
152
|
+
* - tool_call: Agent's tool execution with results
|
|
153
|
+
* - plan: Agent's task breakdown
|
|
154
|
+
* - permission_request: Request for user approval
|
|
155
|
+
* - terminal: Reference to a terminal session
|
|
156
|
+
*/
|
|
157
|
+
export type MessageContent =
|
|
158
|
+
| {
|
|
159
|
+
type: "text";
|
|
160
|
+
text: string;
|
|
161
|
+
}
|
|
162
|
+
| {
|
|
163
|
+
type: "text_with_context";
|
|
164
|
+
text: string;
|
|
165
|
+
autoMentionContext?: {
|
|
166
|
+
noteName: string;
|
|
167
|
+
notePath: string;
|
|
168
|
+
selection?: {
|
|
169
|
+
fromLine: number;
|
|
170
|
+
toLine: number;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
| {
|
|
175
|
+
type: "agent_thought";
|
|
176
|
+
text: string;
|
|
177
|
+
}
|
|
178
|
+
| {
|
|
179
|
+
type: "image";
|
|
180
|
+
data: string; // Base64 encoded image data
|
|
181
|
+
mimeType: string; // e.g., "image/png"
|
|
182
|
+
uri?: string; // Optional source URI
|
|
183
|
+
}
|
|
184
|
+
| {
|
|
185
|
+
type: "resource_link";
|
|
186
|
+
uri: string; // Resource URI (e.g., "file:///path/to/file.pdf")
|
|
187
|
+
name: string; // Human-readable file name
|
|
188
|
+
mimeType?: string; // e.g., "application/pdf"
|
|
189
|
+
size?: number; // File size in bytes
|
|
190
|
+
}
|
|
191
|
+
| {
|
|
192
|
+
type: "tool_call";
|
|
193
|
+
toolCallId: string;
|
|
194
|
+
title?: string | null;
|
|
195
|
+
status: ToolCallStatus;
|
|
196
|
+
kind?: ToolKind;
|
|
197
|
+
content?: ToolCallContent[];
|
|
198
|
+
locations?: ToolCallLocation[];
|
|
199
|
+
rawInput?: { [k: string]: unknown };
|
|
200
|
+
rawOutput?: { [k: string]: unknown };
|
|
201
|
+
permissionRequest?: {
|
|
202
|
+
requestId: string;
|
|
203
|
+
options: PermissionOption[];
|
|
204
|
+
selectedOptionId?: string;
|
|
205
|
+
isCancelled?: boolean;
|
|
206
|
+
isActive?: boolean;
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
| {
|
|
210
|
+
type: "plan";
|
|
211
|
+
entries: PlanEntry[];
|
|
212
|
+
}
|
|
213
|
+
| {
|
|
214
|
+
type: "permission_request";
|
|
215
|
+
toolCall: ToolCallInfo;
|
|
216
|
+
options: PermissionOption[];
|
|
217
|
+
selectedOptionId?: string;
|
|
218
|
+
isCancelled?: boolean;
|
|
219
|
+
isActive?: boolean;
|
|
220
|
+
}
|
|
221
|
+
| {
|
|
222
|
+
type: "terminal";
|
|
223
|
+
terminalId: string;
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Attached file for ChatInput.
|
|
227
|
+
*
|
|
228
|
+
* Two kinds:
|
|
229
|
+
* - "image": Base64 embedded image (from paste or D&D with image capability)
|
|
230
|
+
* - "file": File reference by path (D&D non-image, or D&D image without capability)
|
|
231
|
+
*/
|
|
232
|
+
export interface AttachedFile {
|
|
233
|
+
id: string;
|
|
234
|
+
kind: "image" | "file";
|
|
235
|
+
mimeType: string;
|
|
236
|
+
|
|
237
|
+
/** Base64-encoded data (only for kind === "image") */
|
|
238
|
+
data?: string;
|
|
239
|
+
|
|
240
|
+
/** File name for display (only for kind === "file") */
|
|
241
|
+
name?: string;
|
|
242
|
+
|
|
243
|
+
/** Absolute file path (only for kind === "file") */
|
|
244
|
+
path?: string;
|
|
245
|
+
|
|
246
|
+
/** File size in bytes (only for kind === "file", for display + resource_link) */
|
|
247
|
+
size?: number;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* ChatInput component state that can be shared between views.
|
|
252
|
+
* Used for broadcast-prompt command.
|
|
253
|
+
*/
|
|
254
|
+
export interface ChatInputState {
|
|
255
|
+
/** Text content in the input field */
|
|
256
|
+
text: string;
|
|
257
|
+
/** Attached files (images and non-image files) */
|
|
258
|
+
files: AttachedFile[];
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Prompt Content Types
|
|
262
|
+
*
|
|
263
|
+
* Types representing content that can be included in a prompt sent to the agent.
|
|
264
|
+
* These correspond to ACP ContentBlock types but are defined independently
|
|
265
|
+
* to maintain domain layer isolation.
|
|
266
|
+
*/
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Text content in a prompt
|
|
270
|
+
*/
|
|
271
|
+
export interface TextPromptContent {
|
|
272
|
+
type: "text";
|
|
273
|
+
text: string;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Image content in a prompt
|
|
278
|
+
*
|
|
279
|
+
* Images are sent as Base64-encoded data with their MIME type.
|
|
280
|
+
* Supported MIME types: image/png, image/jpeg, image/gif, image/webp
|
|
281
|
+
*/
|
|
282
|
+
export interface ImagePromptContent {
|
|
283
|
+
type: "image";
|
|
284
|
+
/** Base64-encoded image data (without data: prefix) */
|
|
285
|
+
data: string;
|
|
286
|
+
/** MIME type of the image */
|
|
287
|
+
mimeType: string;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Annotations for resource content (ACP spec compliant)
|
|
292
|
+
*
|
|
293
|
+
* Provides hints to the agent about how to use or prioritize the resource.
|
|
294
|
+
*/
|
|
295
|
+
export interface ResourceAnnotations {
|
|
296
|
+
/** Intended audience(s) for this resource */
|
|
297
|
+
audience?: ("user" | "assistant")[];
|
|
298
|
+
/** Importance (0.0 = least important, 1.0 = most important) */
|
|
299
|
+
priority?: number;
|
|
300
|
+
/** Last modified timestamp (ISO 8601) */
|
|
301
|
+
lastModified?: string;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Embedded resource content in a prompt
|
|
306
|
+
*
|
|
307
|
+
* Used when agent supports embeddedContext capability.
|
|
308
|
+
* Contains file content with URI and metadata.
|
|
309
|
+
* This allows the agent to receive structured context about referenced files.
|
|
310
|
+
*/
|
|
311
|
+
export interface ResourcePromptContent {
|
|
312
|
+
type: "resource";
|
|
313
|
+
resource: {
|
|
314
|
+
/** Resource URI (e.g., "file:///path/to/note.md") */
|
|
315
|
+
uri: string;
|
|
316
|
+
/** MIME type of the resource */
|
|
317
|
+
mimeType: string;
|
|
318
|
+
/** Text content of the resource */
|
|
319
|
+
text: string;
|
|
320
|
+
};
|
|
321
|
+
/** Optional annotations for the resource */
|
|
322
|
+
annotations?: ResourceAnnotations;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Resource link content in a prompt
|
|
327
|
+
*
|
|
328
|
+
* References a file by URI without embedding its contents.
|
|
329
|
+
* The agent is expected to access the file itself.
|
|
330
|
+
* No prompt capability is required (unlike image/audio/resource).
|
|
331
|
+
*/
|
|
332
|
+
export interface ResourceLinkPromptContent {
|
|
333
|
+
type: "resource_link";
|
|
334
|
+
/** Resource URI (e.g., "file:///path/to/document.pdf") */
|
|
335
|
+
uri: string;
|
|
336
|
+
/** Human-readable file name */
|
|
337
|
+
name: string;
|
|
338
|
+
/** MIME type of the resource */
|
|
339
|
+
mimeType?: string;
|
|
340
|
+
/** File size in bytes */
|
|
341
|
+
size?: number;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Union type for all prompt content types
|
|
346
|
+
*/
|
|
347
|
+
export type PromptContent =
|
|
348
|
+
| TextPromptContent
|
|
349
|
+
| ImagePromptContent
|
|
350
|
+
| ResourcePromptContent
|
|
351
|
+
| ResourceLinkPromptContent;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain Models for Agent Errors
|
|
3
|
+
*
|
|
4
|
+
* This module defines error types for the Agent Client plugin:
|
|
5
|
+
* - AcpError: ACP protocol errors (JSON-RPC based)
|
|
6
|
+
* - ProcessError: Node.js process-level errors
|
|
7
|
+
*
|
|
8
|
+
* These types are based on the ACP (Agent Client Protocol) specification
|
|
9
|
+
* and JSON-RPC 2.0 error object specification.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// ACP Error Codes
|
|
14
|
+
// ============================================================================
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* ACP Error Codes based on JSON-RPC 2.0 and ACP protocol extensions.
|
|
18
|
+
* https://agentclientprotocol.com/
|
|
19
|
+
*
|
|
20
|
+
* Standard JSON-RPC 2.0 errors: -32700 to -32600
|
|
21
|
+
* ACP protocol-specific errors: -32000 to -32099 (reserved range)
|
|
22
|
+
*/
|
|
23
|
+
export const AcpErrorCode = {
|
|
24
|
+
// JSON-RPC 2.0 standard errors
|
|
25
|
+
PARSE_ERROR: -32700,
|
|
26
|
+
INVALID_REQUEST: -32600,
|
|
27
|
+
METHOD_NOT_FOUND: -32601,
|
|
28
|
+
INVALID_PARAMS: -32602,
|
|
29
|
+
INTERNAL_ERROR: -32603,
|
|
30
|
+
|
|
31
|
+
// ACP protocol-specific errors (reserved range -32000 to -32099)
|
|
32
|
+
AUTHENTICATION_REQUIRED: -32000,
|
|
33
|
+
RESOURCE_NOT_FOUND: -32002,
|
|
34
|
+
} as const;
|
|
35
|
+
|
|
36
|
+
export type AcpErrorCodeValue =
|
|
37
|
+
(typeof AcpErrorCode)[keyof typeof AcpErrorCode];
|
|
38
|
+
|
|
39
|
+
// ============================================================================
|
|
40
|
+
// User-Facing Error Information
|
|
41
|
+
// ============================================================================
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* User-facing error information for UI display.
|
|
45
|
+
*
|
|
46
|
+
* This is the common interface used by all error types to provide
|
|
47
|
+
* consistent error information to the user.
|
|
48
|
+
*/
|
|
49
|
+
export interface ErrorInfo {
|
|
50
|
+
/** Short, user-friendly error title */
|
|
51
|
+
title: string;
|
|
52
|
+
|
|
53
|
+
/** Detailed error message explaining what went wrong */
|
|
54
|
+
message: string;
|
|
55
|
+
|
|
56
|
+
/** Optional suggestion on how to resolve the error */
|
|
57
|
+
suggestion?: string;
|
|
58
|
+
|
|
59
|
+
/** Optional external link rendered as an actionable anchor (e.g. docs). */
|
|
60
|
+
link?: { text: string; url: string };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// ============================================================================
|
|
64
|
+
// ACP Error (Protocol-level)
|
|
65
|
+
// ============================================================================
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* ACP protocol error from agent communication.
|
|
69
|
+
*
|
|
70
|
+
* Based on JSON-RPC 2.0 error object specification with ACP extensions.
|
|
71
|
+
* The `message` field contains the agent's error message and should be
|
|
72
|
+
* displayed directly to the user for detailed error information.
|
|
73
|
+
*/
|
|
74
|
+
export interface AcpError extends ErrorInfo {
|
|
75
|
+
/** ACP/JSON-RPC error code */
|
|
76
|
+
code: number;
|
|
77
|
+
|
|
78
|
+
/** Additional error data from agent (for debugging) */
|
|
79
|
+
data?: unknown;
|
|
80
|
+
|
|
81
|
+
/** Session ID where the error occurred */
|
|
82
|
+
sessionId?: string | null;
|
|
83
|
+
|
|
84
|
+
/** Original error object for debugging */
|
|
85
|
+
originalError?: unknown;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ============================================================================
|
|
89
|
+
// Process Error (System-level)
|
|
90
|
+
// ============================================================================
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Process-level error types.
|
|
94
|
+
*
|
|
95
|
+
* These represent Node.js/system errors that occur during
|
|
96
|
+
* agent process management, not ACP protocol errors.
|
|
97
|
+
*/
|
|
98
|
+
export type ProcessErrorType =
|
|
99
|
+
| "spawn_failed" // Process spawn failed (ENOENT, etc.)
|
|
100
|
+
| "command_not_found" // Exit code 127
|
|
101
|
+
| "process_crashed" // Abnormal termination
|
|
102
|
+
| "process_timeout"; // Timeout
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Process-level error from agent process management.
|
|
106
|
+
*
|
|
107
|
+
* These are Node.js/system errors, not ACP protocol errors.
|
|
108
|
+
* Used for errors that occur before or outside of ACP communication.
|
|
109
|
+
*/
|
|
110
|
+
export interface ProcessError extends ErrorInfo {
|
|
111
|
+
/** Error type classification */
|
|
112
|
+
type: ProcessErrorType;
|
|
113
|
+
|
|
114
|
+
/** Agent ID where the error occurred */
|
|
115
|
+
agentId: string;
|
|
116
|
+
|
|
117
|
+
/** Exit code (if applicable) */
|
|
118
|
+
exitCode?: number;
|
|
119
|
+
|
|
120
|
+
/** Node.js error code (e.g., "ENOENT") */
|
|
121
|
+
errorCode?: string;
|
|
122
|
+
|
|
123
|
+
/** Original error object for debugging */
|
|
124
|
+
originalError?: unknown;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// ============================================================================
|
|
128
|
+
// UI Display Types
|
|
129
|
+
// ============================================================================
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Visual variant for error/notification banners.
|
|
133
|
+
* - "error": Red/critical styling
|
|
134
|
+
* - "info": Subtle/informational styling
|
|
135
|
+
*/
|
|
136
|
+
export type OverlayVariant = "error" | "info";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Type augmentation for unofficial Obsidian APIs.
|
|
5
|
+
*
|
|
6
|
+
* These methods exist at runtime but are not in the public type definitions.
|
|
7
|
+
* Only add methods that are widely used by the plugin community and unlikely
|
|
8
|
+
* to be removed without notice.
|
|
9
|
+
*/
|
|
10
|
+
declare module "obsidian" {
|
|
11
|
+
interface Vault {
|
|
12
|
+
getConfig(key: string): unknown;
|
|
13
|
+
}
|
|
14
|
+
}
|