@agentclientprotocol/claude-agent-acp 0.24.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/LICENSE +191 -0
- package/README.md +25 -0
- package/dist/acp-agent.d.ts +171 -0
- package/dist/acp-agent.d.ts.map +1 -0
- package/dist/acp-agent.js +1633 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/lib.d.ts +6 -0
- package/dist/lib.d.ts.map +1 -0
- package/dist/lib.js +5 -0
- package/dist/settings.d.ts +106 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +222 -0
- package/dist/static-entry.d.ts +2 -0
- package/dist/static-entry.d.ts.map +1 -0
- package/dist/static-entry.js +9 -0
- package/dist/tools.d.ts +64 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +569 -0
- package/dist/utils.d.ts +19 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +100 -0
- package/package.json +81 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Load managed settings and apply environment variables
|
|
3
|
+
import { loadManagedSettings, applyEnvironmentSettings } from "./utils.js";
|
|
4
|
+
import { claudeCliPath, runAcp } from "./acp-agent.js";
|
|
5
|
+
if (process.argv.includes("--cli")) {
|
|
6
|
+
process.argv = process.argv.filter((arg) => arg !== "--cli");
|
|
7
|
+
await import(await claudeCliPath());
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
const managedSettings = loadManagedSettings();
|
|
11
|
+
if (managedSettings) {
|
|
12
|
+
applyEnvironmentSettings(managedSettings);
|
|
13
|
+
}
|
|
14
|
+
// stdout is used to send messages to the client
|
|
15
|
+
// we redirect everything else to stderr to make sure it doesn't interfere with ACP
|
|
16
|
+
console.log = console.error;
|
|
17
|
+
console.info = console.error;
|
|
18
|
+
console.warn = console.error;
|
|
19
|
+
console.debug = console.error;
|
|
20
|
+
process.on("unhandledRejection", (reason, promise) => {
|
|
21
|
+
console.error("Unhandled Rejection at:", promise, "reason:", reason);
|
|
22
|
+
});
|
|
23
|
+
runAcp();
|
|
24
|
+
// Keep process alive
|
|
25
|
+
process.stdin.resume();
|
|
26
|
+
}
|
package/dist/lib.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { ClaudeAcpAgent, runAcp, toAcpNotifications, streamEventToAcpNotifications, type ToolUpdateMeta, type NewSessionMeta, } from "./acp-agent.js";
|
|
2
|
+
export { loadManagedSettings, applyEnvironmentSettings, nodeToWebReadable, nodeToWebWritable, Pushable, unreachable, } from "./utils.js";
|
|
3
|
+
export { toolInfoFromToolUse, toDisplayPath, planEntries, toolUpdateFromToolResult, } from "./tools.js";
|
|
4
|
+
export { SettingsManager, type ClaudeCodeSettings, type SettingsManagerOptions, } from "./settings.js";
|
|
5
|
+
export type { ClaudePlanEntry } from "./tools.js";
|
|
6
|
+
//# sourceMappingURL=lib.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,MAAM,EACN,kBAAkB,EAClB,6BAA6B,EAC7B,KAAK,cAAc,EACnB,KAAK,cAAc,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,QAAQ,EACR,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,eAAe,EACf,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,GAC5B,MAAM,eAAe,CAAC;AAGvB,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/lib.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Export the main agent class and utilities for library usage
|
|
2
|
+
export { ClaudeAcpAgent, runAcp, toAcpNotifications, streamEventToAcpNotifications, } from "./acp-agent.js";
|
|
3
|
+
export { loadManagedSettings, applyEnvironmentSettings, nodeToWebReadable, nodeToWebWritable, Pushable, unreachable, } from "./utils.js";
|
|
4
|
+
export { toolInfoFromToolUse, toDisplayPath, planEntries, toolUpdateFromToolResult, } from "./tools.js";
|
|
5
|
+
export { SettingsManager, } from "./settings.js";
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Permission rule format examples:
|
|
3
|
+
* - "Read" - matches all Read tool calls
|
|
4
|
+
* - "Read(./.env)" - matches specific path
|
|
5
|
+
* - "Read(./.env.*)" - glob pattern
|
|
6
|
+
* - "Read(./secrets/**)" - recursive glob
|
|
7
|
+
* - "Bash(npm run lint)" - exact command prefix
|
|
8
|
+
* - "Bash(npm run:*)" - command prefix with wildcard
|
|
9
|
+
*
|
|
10
|
+
* Docs: https://code.claude.com/docs/en/iam#tool-specific-permission-rules
|
|
11
|
+
*/
|
|
12
|
+
export interface PermissionSettings {
|
|
13
|
+
defaultMode?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ClaudeCodeSettings {
|
|
16
|
+
permissions?: PermissionSettings;
|
|
17
|
+
env?: Record<string, string>;
|
|
18
|
+
model?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Gets the enterprise settings path based on the current platform
|
|
22
|
+
*/
|
|
23
|
+
export declare function getManagedSettingsPath(): string;
|
|
24
|
+
export interface SettingsManagerOptions {
|
|
25
|
+
onChange?: () => void;
|
|
26
|
+
logger?: {
|
|
27
|
+
log: (...args: any[]) => void;
|
|
28
|
+
error: (...args: any[]) => void;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Manages Claude Code settings from multiple sources with proper precedence.
|
|
33
|
+
*
|
|
34
|
+
* Settings are loaded from (in order of increasing precedence):
|
|
35
|
+
* 1. User settings (~/.claude/settings.json)
|
|
36
|
+
* 2. Project settings (<cwd>/.claude/settings.json)
|
|
37
|
+
* 3. Local project settings (<cwd>/.claude/settings.local.json)
|
|
38
|
+
* 4. Enterprise managed settings (platform-specific path)
|
|
39
|
+
*
|
|
40
|
+
* The manager watches all settings files for changes and automatically reloads.
|
|
41
|
+
*/
|
|
42
|
+
export declare class SettingsManager {
|
|
43
|
+
private cwd;
|
|
44
|
+
private userSettings;
|
|
45
|
+
private projectSettings;
|
|
46
|
+
private localSettings;
|
|
47
|
+
private enterpriseSettings;
|
|
48
|
+
private mergedSettings;
|
|
49
|
+
private watchers;
|
|
50
|
+
private onChange?;
|
|
51
|
+
private logger;
|
|
52
|
+
private initialized;
|
|
53
|
+
private debounceTimer;
|
|
54
|
+
constructor(cwd: string, options?: SettingsManagerOptions);
|
|
55
|
+
/**
|
|
56
|
+
* Initialize the settings manager by loading all settings and setting up file watchers
|
|
57
|
+
*/
|
|
58
|
+
initialize(): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Returns the path to the user settings file
|
|
61
|
+
*/
|
|
62
|
+
private getUserSettingsPath;
|
|
63
|
+
/**
|
|
64
|
+
* Returns the path to the project settings file
|
|
65
|
+
*/
|
|
66
|
+
private getProjectSettingsPath;
|
|
67
|
+
/**
|
|
68
|
+
* Returns the path to the local project settings file
|
|
69
|
+
*/
|
|
70
|
+
private getLocalSettingsPath;
|
|
71
|
+
/**
|
|
72
|
+
* Loads settings from all sources
|
|
73
|
+
*/
|
|
74
|
+
private loadAllSettings;
|
|
75
|
+
/**
|
|
76
|
+
* Merges all settings sources with proper precedence.
|
|
77
|
+
* For permissions, rules from all sources are combined.
|
|
78
|
+
* Deny rules always take precedence during permission checks.
|
|
79
|
+
*/
|
|
80
|
+
private mergeSettings;
|
|
81
|
+
/**
|
|
82
|
+
* Sets up file watchers for all settings files
|
|
83
|
+
*/
|
|
84
|
+
private setupWatchers;
|
|
85
|
+
/**
|
|
86
|
+
* Handles settings file changes with debouncing to avoid rapid reloads
|
|
87
|
+
*/
|
|
88
|
+
private handleSettingsChange;
|
|
89
|
+
/**
|
|
90
|
+
* Returns the current merged settings
|
|
91
|
+
*/
|
|
92
|
+
getSettings(): ClaudeCodeSettings;
|
|
93
|
+
/**
|
|
94
|
+
* Returns the current working directory
|
|
95
|
+
*/
|
|
96
|
+
getCwd(): string;
|
|
97
|
+
/**
|
|
98
|
+
* Updates the working directory and reloads project-specific settings
|
|
99
|
+
*/
|
|
100
|
+
setCwd(cwd: string): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Disposes of file watchers and cleans up resources
|
|
103
|
+
*/
|
|
104
|
+
dispose(): void;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,kBAAkB;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAkBD;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAW/C;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE;QAAE,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;QAAC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;KAAE,CAAC;CAC7E;AAED;;;;;;;;;;GAUG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,YAAY,CAA0B;IAC9C,OAAO,CAAC,eAAe,CAA0B;IACjD,OAAO,CAAC,aAAa,CAA0B;IAC/C,OAAO,CAAC,kBAAkB,CAA0B;IACpD,OAAO,CAAC,cAAc,CAA0B;IAChD,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,QAAQ,CAAC,CAAa;IAC9B,OAAO,CAAC,MAAM,CAAqE;IACnF,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,aAAa,CAA8C;gBAEvD,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,sBAAsB;IAMzD;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAUjC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAI3B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAI9B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAI5B;;OAEG;YACW,eAAe;IAgB7B;;;;OAIG;IACH,OAAO,CAAC,aAAa;IA8BrB;;OAEG;IACH,OAAO,CAAC,aAAa;IAkCrB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAgB5B;;OAEG;IACH,WAAW,IAAI,kBAAkB;IAIjC;;OAEG;IACH,MAAM,IAAI,MAAM;IAIhB;;OAEG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWxC;;OAEG;IACH,OAAO,IAAI,IAAI;CAYhB"}
|
package/dist/settings.js
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { CLAUDE_CONFIG_DIR } from "./acp-agent.js";
|
|
4
|
+
/**
|
|
5
|
+
* Reads and parses a JSON settings file, returning an empty object if not found or invalid
|
|
6
|
+
*/
|
|
7
|
+
async function loadSettingsFile(filePath) {
|
|
8
|
+
if (!filePath) {
|
|
9
|
+
return {};
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
const content = await fs.promises.readFile(filePath, "utf-8");
|
|
13
|
+
return JSON.parse(content);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Gets the enterprise settings path based on the current platform
|
|
21
|
+
*/
|
|
22
|
+
export function getManagedSettingsPath() {
|
|
23
|
+
switch (process.platform) {
|
|
24
|
+
case "darwin":
|
|
25
|
+
return "/Library/Application Support/ClaudeCode/managed-settings.json";
|
|
26
|
+
case "linux":
|
|
27
|
+
return "/etc/claude-code/managed-settings.json";
|
|
28
|
+
case "win32":
|
|
29
|
+
return "C:\\Program Files\\ClaudeCode\\managed-settings.json";
|
|
30
|
+
default:
|
|
31
|
+
return "/etc/claude-code/managed-settings.json";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Manages Claude Code settings from multiple sources with proper precedence.
|
|
36
|
+
*
|
|
37
|
+
* Settings are loaded from (in order of increasing precedence):
|
|
38
|
+
* 1. User settings (~/.claude/settings.json)
|
|
39
|
+
* 2. Project settings (<cwd>/.claude/settings.json)
|
|
40
|
+
* 3. Local project settings (<cwd>/.claude/settings.local.json)
|
|
41
|
+
* 4. Enterprise managed settings (platform-specific path)
|
|
42
|
+
*
|
|
43
|
+
* The manager watches all settings files for changes and automatically reloads.
|
|
44
|
+
*/
|
|
45
|
+
export class SettingsManager {
|
|
46
|
+
constructor(cwd, options) {
|
|
47
|
+
this.userSettings = {};
|
|
48
|
+
this.projectSettings = {};
|
|
49
|
+
this.localSettings = {};
|
|
50
|
+
this.enterpriseSettings = {};
|
|
51
|
+
this.mergedSettings = {};
|
|
52
|
+
this.watchers = [];
|
|
53
|
+
this.initialized = false;
|
|
54
|
+
this.debounceTimer = null;
|
|
55
|
+
this.cwd = cwd;
|
|
56
|
+
this.onChange = options?.onChange;
|
|
57
|
+
this.logger = options?.logger ?? console;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Initialize the settings manager by loading all settings and setting up file watchers
|
|
61
|
+
*/
|
|
62
|
+
async initialize() {
|
|
63
|
+
if (this.initialized) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
await this.loadAllSettings();
|
|
67
|
+
this.setupWatchers();
|
|
68
|
+
this.initialized = true;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Returns the path to the user settings file
|
|
72
|
+
*/
|
|
73
|
+
getUserSettingsPath() {
|
|
74
|
+
return path.join(CLAUDE_CONFIG_DIR, "settings.json");
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Returns the path to the project settings file
|
|
78
|
+
*/
|
|
79
|
+
getProjectSettingsPath() {
|
|
80
|
+
return path.join(this.cwd, ".claude", "settings.json");
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Returns the path to the local project settings file
|
|
84
|
+
*/
|
|
85
|
+
getLocalSettingsPath() {
|
|
86
|
+
return path.join(this.cwd, ".claude", "settings.local.json");
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Loads settings from all sources
|
|
90
|
+
*/
|
|
91
|
+
async loadAllSettings() {
|
|
92
|
+
const [userSettings, projectSettings, localSettings, enterpriseSettings] = await Promise.all([
|
|
93
|
+
loadSettingsFile(this.getUserSettingsPath()),
|
|
94
|
+
loadSettingsFile(this.getProjectSettingsPath()),
|
|
95
|
+
loadSettingsFile(this.getLocalSettingsPath()),
|
|
96
|
+
loadSettingsFile(getManagedSettingsPath()),
|
|
97
|
+
]);
|
|
98
|
+
this.userSettings = userSettings;
|
|
99
|
+
this.projectSettings = projectSettings;
|
|
100
|
+
this.localSettings = localSettings;
|
|
101
|
+
this.enterpriseSettings = enterpriseSettings;
|
|
102
|
+
this.mergeSettings();
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Merges all settings sources with proper precedence.
|
|
106
|
+
* For permissions, rules from all sources are combined.
|
|
107
|
+
* Deny rules always take precedence during permission checks.
|
|
108
|
+
*/
|
|
109
|
+
mergeSettings() {
|
|
110
|
+
const allSettings = [
|
|
111
|
+
this.userSettings,
|
|
112
|
+
this.projectSettings,
|
|
113
|
+
this.localSettings,
|
|
114
|
+
this.enterpriseSettings,
|
|
115
|
+
];
|
|
116
|
+
const merged = {};
|
|
117
|
+
for (const settings of allSettings) {
|
|
118
|
+
if (settings.env) {
|
|
119
|
+
merged.env = { ...merged.env, ...settings.env };
|
|
120
|
+
}
|
|
121
|
+
if (settings.model) {
|
|
122
|
+
merged.model = settings.model;
|
|
123
|
+
}
|
|
124
|
+
if (settings.permissions?.defaultMode !== undefined) {
|
|
125
|
+
merged.permissions = {
|
|
126
|
+
...merged.permissions,
|
|
127
|
+
defaultMode: settings.permissions.defaultMode,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
this.mergedSettings = merged;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Sets up file watchers for all settings files
|
|
135
|
+
*/
|
|
136
|
+
setupWatchers() {
|
|
137
|
+
const paths = [
|
|
138
|
+
this.getUserSettingsPath(),
|
|
139
|
+
this.getProjectSettingsPath(),
|
|
140
|
+
this.getLocalSettingsPath(),
|
|
141
|
+
getManagedSettingsPath(),
|
|
142
|
+
];
|
|
143
|
+
for (const filePath of paths) {
|
|
144
|
+
if (!filePath)
|
|
145
|
+
continue;
|
|
146
|
+
try {
|
|
147
|
+
const dir = path.dirname(filePath);
|
|
148
|
+
const filename = path.basename(filePath);
|
|
149
|
+
if (fs.existsSync(dir)) {
|
|
150
|
+
const watcher = fs.watch(dir, (eventType, changedFilename) => {
|
|
151
|
+
if (changedFilename === filename) {
|
|
152
|
+
this.handleSettingsChange();
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
watcher.on("error", (error) => {
|
|
156
|
+
this.logger.error(`Settings watcher error for ${filePath}:`, error);
|
|
157
|
+
});
|
|
158
|
+
this.watchers.push(watcher);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
this.logger.error(`Failed to set up watcher for ${filePath}:`, error);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Handles settings file changes with debouncing to avoid rapid reloads
|
|
168
|
+
*/
|
|
169
|
+
handleSettingsChange() {
|
|
170
|
+
if (this.debounceTimer) {
|
|
171
|
+
clearTimeout(this.debounceTimer);
|
|
172
|
+
}
|
|
173
|
+
this.debounceTimer = setTimeout(async () => {
|
|
174
|
+
this.debounceTimer = null;
|
|
175
|
+
try {
|
|
176
|
+
await this.loadAllSettings();
|
|
177
|
+
this.onChange?.();
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
this.logger.error("Failed to reload settings:", error);
|
|
181
|
+
}
|
|
182
|
+
}, 100);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Returns the current merged settings
|
|
186
|
+
*/
|
|
187
|
+
getSettings() {
|
|
188
|
+
return this.mergedSettings;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Returns the current working directory
|
|
192
|
+
*/
|
|
193
|
+
getCwd() {
|
|
194
|
+
return this.cwd;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Updates the working directory and reloads project-specific settings
|
|
198
|
+
*/
|
|
199
|
+
async setCwd(cwd) {
|
|
200
|
+
if (this.cwd === cwd) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
this.dispose();
|
|
204
|
+
this.cwd = cwd;
|
|
205
|
+
this.initialized = false;
|
|
206
|
+
await this.initialize();
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Disposes of file watchers and cleans up resources
|
|
210
|
+
*/
|
|
211
|
+
dispose() {
|
|
212
|
+
if (this.debounceTimer) {
|
|
213
|
+
clearTimeout(this.debounceTimer);
|
|
214
|
+
this.debounceTimer = null;
|
|
215
|
+
}
|
|
216
|
+
for (const watcher of this.watchers) {
|
|
217
|
+
watcher.close();
|
|
218
|
+
}
|
|
219
|
+
this.watchers = [];
|
|
220
|
+
this.initialized = false;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static-entry.d.ts","sourceRoot":"","sources":["../src/static-entry.ts"],"names":[],"mappings":""}
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { PlanEntry, ToolCallContent, ToolCallLocation, ToolKind } from "@agentclientprotocol/sdk";
|
|
2
|
+
import { HookCallback } from "@anthropic-ai/claude-agent-sdk";
|
|
3
|
+
import { ToolResultBlockParam, WebSearchToolResultBlockParam } from "@anthropic-ai/sdk/resources";
|
|
4
|
+
import { BetaBashCodeExecutionToolResultBlockParam, BetaCodeExecutionToolResultBlockParam, BetaRequestMCPToolResultBlockParam, BetaTextEditorCodeExecutionToolResultBlockParam, BetaToolResultBlockParam, BetaToolSearchToolResultBlockParam, BetaWebFetchToolResultBlockParam, BetaWebSearchToolResultBlockParam } from "@anthropic-ai/sdk/resources/beta.mjs";
|
|
5
|
+
import { Logger } from "./acp-agent.js";
|
|
6
|
+
interface ToolInfo {
|
|
7
|
+
title: string;
|
|
8
|
+
kind: ToolKind;
|
|
9
|
+
content: ToolCallContent[];
|
|
10
|
+
locations?: ToolCallLocation[];
|
|
11
|
+
}
|
|
12
|
+
interface ToolUpdate {
|
|
13
|
+
title?: string;
|
|
14
|
+
content?: ToolCallContent[];
|
|
15
|
+
locations?: ToolCallLocation[];
|
|
16
|
+
_meta?: {
|
|
17
|
+
terminal_info?: {
|
|
18
|
+
terminal_id: string;
|
|
19
|
+
};
|
|
20
|
+
terminal_output?: {
|
|
21
|
+
terminal_id: string;
|
|
22
|
+
data: string;
|
|
23
|
+
};
|
|
24
|
+
terminal_exit?: {
|
|
25
|
+
terminal_id: string;
|
|
26
|
+
exit_code: number;
|
|
27
|
+
signal: string | null;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Convert an absolute file path to a project-relative path for display.
|
|
33
|
+
* Returns the original path if it's outside the project directory or if no cwd is provided.
|
|
34
|
+
*/
|
|
35
|
+
export declare function toDisplayPath(filePath: string, cwd?: string): string;
|
|
36
|
+
export declare function toolInfoFromToolUse(toolUse: any, supportsTerminalOutput?: boolean, cwd?: string): ToolInfo;
|
|
37
|
+
export declare function toolUpdateFromToolResult(toolResult: ToolResultBlockParam | BetaToolResultBlockParam | BetaWebSearchToolResultBlockParam | BetaWebFetchToolResultBlockParam | WebSearchToolResultBlockParam | BetaCodeExecutionToolResultBlockParam | BetaBashCodeExecutionToolResultBlockParam | BetaTextEditorCodeExecutionToolResultBlockParam | BetaRequestMCPToolResultBlockParam | BetaToolSearchToolResultBlockParam, toolUse: any | undefined, supportsTerminalOutput?: boolean): ToolUpdate;
|
|
38
|
+
export type ClaudePlanEntry = {
|
|
39
|
+
content: string;
|
|
40
|
+
status: "pending" | "in_progress" | "completed";
|
|
41
|
+
activeForm: string;
|
|
42
|
+
};
|
|
43
|
+
export declare function planEntries(input: {
|
|
44
|
+
todos: ClaudePlanEntry[];
|
|
45
|
+
}): PlanEntry[];
|
|
46
|
+
export declare function markdownEscape(text: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* Builds diff ToolUpdate content from the structured Edit toolResponse provided
|
|
49
|
+
* by the PostToolUse hook. Unlike parsing the plain unified diff string, this uses
|
|
50
|
+
* the pre-parsed structuredPatch which supports multiple replacement sites (replaceAll)
|
|
51
|
+
* and always includes context lines for better readability.
|
|
52
|
+
*/
|
|
53
|
+
export declare function toolUpdateFromEditToolResponse(toolResponse: unknown): {
|
|
54
|
+
content?: ToolCallContent[];
|
|
55
|
+
locations?: ToolCallLocation[];
|
|
56
|
+
};
|
|
57
|
+
export declare const registerHookCallback: (toolUseID: string, { onPostToolUseHook, }: {
|
|
58
|
+
onPostToolUseHook?: (toolUseID: string, toolInput: unknown, toolResponse: unknown) => Promise<void>;
|
|
59
|
+
}) => void;
|
|
60
|
+
export declare const createPostToolUseHook: (logger?: Logger, options?: {
|
|
61
|
+
onEnterPlanMode?: () => Promise<void>;
|
|
62
|
+
}) => HookCallback;
|
|
63
|
+
export {};
|
|
64
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"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"}
|