@agentclientprotocol/claude-agent-acp 0.24.2 → 0.25.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/dist/acp-agent.d.ts.map +1 -1
- package/dist/acp-agent.js +92 -15
- package/dist/settings.d.ts +2 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +36 -13
- package/package.json +9 -9
package/dist/acp-agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acp-agent.d.ts","sourceRoot":"","sources":["../src/acp-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,mBAAmB,EACnB,mBAAmB,EAGnB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EAEnB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EAEpB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,6BAA6B,EAC7B,8BAA8B,EAC9B,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EAEtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,UAAU,
|
|
1
|
+
{"version":3,"file":"acp-agent.d.ts","sourceRoot":"","sources":["../src/acp-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,mBAAmB,EACnB,mBAAmB,EAGnB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,kB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ED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,GAAG,iBAAiB,EAAE,GAAG,gBAAgB,EAAE,GAAG,wBAAwB,EAAE,EACvF,IAAI,EAAE,WAAW,GAAG,MAAM,EAC1B,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;IACR,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GACA,mBAAmB,EAAE,CAmPvB;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,0BAA0B,EACnC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;IACR,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GACA,mBAAmB,EAAE,CA0CvB;AAED,wBAAgB,MAAM,SAMrB"}
|
package/dist/acp-agent.js
CHANGED
|
@@ -39,6 +39,7 @@ const ALLOW_BYPASS = !IS_ROOT || !!process.env.IS_SANDBOX;
|
|
|
39
39
|
// message and without invoking the model.
|
|
40
40
|
const LOCAL_ONLY_COMMANDS = new Set(["/context", "/heapdump", "/extra-usage"]);
|
|
41
41
|
const PERMISSION_MODE_ALIASES = {
|
|
42
|
+
auto: "auto",
|
|
42
43
|
default: "default",
|
|
43
44
|
acceptedits: "acceptEdits",
|
|
44
45
|
dontask: "dontAsk",
|
|
@@ -90,24 +91,39 @@ export class ClaudeAcpAgent {
|
|
|
90
91
|
},
|
|
91
92
|
},
|
|
92
93
|
};
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
const supportsTerminalAuth = request.clientCapabilities?.auth?.terminal === true;
|
|
95
|
+
const supportsMetaTerminalAuth = request.clientCapabilities?._meta?.["terminal-auth"] === true;
|
|
96
|
+
const claudeLoginMethod = {
|
|
97
|
+
description: "Use Claude subscription ",
|
|
98
|
+
name: "Claude Subscription",
|
|
99
|
+
id: "claude-ai-login",
|
|
97
100
|
type: "terminal",
|
|
98
|
-
args: ["--cli"],
|
|
101
|
+
args: ["--cli", "auth", "login", "--claudeai"],
|
|
102
|
+
};
|
|
103
|
+
const consoleLoginMethod = {
|
|
104
|
+
description: "Use Anthropic Console (API usage billing)",
|
|
105
|
+
name: "Anthropic Console",
|
|
106
|
+
id: "console-login",
|
|
107
|
+
type: "terminal",
|
|
108
|
+
args: ["--cli", "auth", "login", "--console"],
|
|
99
109
|
};
|
|
100
|
-
const supportsTerminalAuth = request.clientCapabilities?.auth?.terminal === true;
|
|
101
110
|
// If client supports terminal-auth capability, use that instead.
|
|
102
|
-
const supportsMetaTerminalAuth = request.clientCapabilities?._meta?.["terminal-auth"] === true;
|
|
103
111
|
if (supportsMetaTerminalAuth) {
|
|
104
|
-
|
|
112
|
+
const baseArgs = process.argv.slice(1);
|
|
113
|
+
claudeLoginMethod._meta = {
|
|
105
114
|
"terminal-auth": {
|
|
106
115
|
command: process.execPath,
|
|
107
|
-
args: [...
|
|
116
|
+
args: [...baseArgs, "--cli", "auth", "login", "--claudeai"],
|
|
108
117
|
label: "Claude Login",
|
|
109
118
|
},
|
|
110
119
|
};
|
|
120
|
+
consoleLoginMethod._meta = {
|
|
121
|
+
"terminal-auth": {
|
|
122
|
+
command: process.execPath,
|
|
123
|
+
args: [...baseArgs, "--cli", "auth", "login", "--console"],
|
|
124
|
+
label: "Anthropic Console Login",
|
|
125
|
+
},
|
|
126
|
+
};
|
|
111
127
|
}
|
|
112
128
|
return {
|
|
113
129
|
protocolVersion: 1,
|
|
@@ -140,8 +156,9 @@ export class ClaudeAcpAgent {
|
|
|
140
156
|
},
|
|
141
157
|
authMethods: [
|
|
142
158
|
...(!shouldHideClaudeAuth() && (supportsTerminalAuth || supportsMetaTerminalAuth)
|
|
143
|
-
? [
|
|
159
|
+
? [claudeLoginMethod]
|
|
144
160
|
: []),
|
|
161
|
+
...(supportsTerminalAuth || supportsMetaTerminalAuth ? [consoleLoginMethod] : []),
|
|
145
162
|
...(supportsGatewayAuth ? [gatewayAuthMethod] : []),
|
|
146
163
|
],
|
|
147
164
|
};
|
|
@@ -231,6 +248,8 @@ export class ClaudeAcpAgent {
|
|
|
231
248
|
cachedWriteTokens: 0,
|
|
232
249
|
};
|
|
233
250
|
let lastAssistantTotalUsage = null;
|
|
251
|
+
let lastAssistantModel = null;
|
|
252
|
+
let lastContextWindowSize = 200000;
|
|
234
253
|
const userMessage = promptToClaude(params);
|
|
235
254
|
const promptUuid = randomUUID();
|
|
236
255
|
userMessage.uuid = promptUuid;
|
|
@@ -282,9 +301,26 @@ export class ClaudeAcpAgent {
|
|
|
282
301
|
break;
|
|
283
302
|
}
|
|
284
303
|
case "compact_boundary": {
|
|
285
|
-
//
|
|
286
|
-
//
|
|
304
|
+
// Send used:0 immediately so the client doesn't keep showing
|
|
305
|
+
// the stale pre-compaction context size until the next turn.
|
|
306
|
+
//
|
|
307
|
+
// This is a deliberate approximation: we don't know the exact
|
|
308
|
+
// post-compaction token count (only the SDK's next API call
|
|
309
|
+
// reveals that). But used:0 is directionally correct — context
|
|
310
|
+
// just dropped dramatically — and the real value replaces it
|
|
311
|
+
// within seconds when the next result message arrives.
|
|
312
|
+
// The alternative (no update) leaves the client showing e.g.
|
|
313
|
+
// "944k/1m" right after the user sees "Compacting completed",
|
|
314
|
+
// which is confusing and wrong.
|
|
287
315
|
lastAssistantTotalUsage = 0;
|
|
316
|
+
await this.client.sessionUpdate({
|
|
317
|
+
sessionId: message.session_id,
|
|
318
|
+
update: {
|
|
319
|
+
sessionUpdate: "usage_update",
|
|
320
|
+
used: 0,
|
|
321
|
+
size: lastContextWindowSize,
|
|
322
|
+
},
|
|
323
|
+
});
|
|
288
324
|
await this.client.sessionUpdate({
|
|
289
325
|
sessionId: message.session_id,
|
|
290
326
|
update: {
|
|
@@ -332,9 +368,11 @@ export class ClaudeAcpAgent {
|
|
|
332
368
|
session.accumulatedUsage.outputTokens += message.usage.output_tokens;
|
|
333
369
|
session.accumulatedUsage.cachedReadTokens += message.usage.cache_read_input_tokens;
|
|
334
370
|
session.accumulatedUsage.cachedWriteTokens += message.usage.cache_creation_input_tokens;
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
371
|
+
const matchingModelUsage = lastAssistantModel
|
|
372
|
+
? getMatchingModelUsage(message.modelUsage, lastAssistantModel)
|
|
373
|
+
: null;
|
|
374
|
+
const contextWindowSize = matchingModelUsage?.contextWindow ?? 200000;
|
|
375
|
+
lastContextWindowSize = contextWindowSize;
|
|
338
376
|
// Send usage_update notification
|
|
339
377
|
if (lastAssistantTotalUsage !== null) {
|
|
340
378
|
await this.client.sessionUpdate({
|
|
@@ -434,6 +472,11 @@ export class ClaudeAcpAgent {
|
|
|
434
472
|
}
|
|
435
473
|
}
|
|
436
474
|
// Store latest assistant usage (excluding subagents)
|
|
475
|
+
// Sum all token types as a proxy for post-turn context occupancy:
|
|
476
|
+
// current turn's output will become next turn's input.
|
|
477
|
+
// Note: per the Anthropic API, input_tokens excludes cache tokens —
|
|
478
|
+
// cache_read and cache_creation are reported separately, so summing
|
|
479
|
+
// all four fields is not double-counting.
|
|
437
480
|
if (message.message.usage && message.parent_tool_use_id === null) {
|
|
438
481
|
const messageWithUsage = message.message;
|
|
439
482
|
lastAssistantTotalUsage =
|
|
@@ -442,6 +485,14 @@ export class ClaudeAcpAgent {
|
|
|
442
485
|
messageWithUsage.usage.cache_read_input_tokens +
|
|
443
486
|
messageWithUsage.usage.cache_creation_input_tokens;
|
|
444
487
|
}
|
|
488
|
+
// Track the current top-level model for context window size lookup
|
|
489
|
+
// (exclude subagent messages to stay in sync with lastAssistantTotalUsage)
|
|
490
|
+
if (message.type === "assistant" &&
|
|
491
|
+
message.parent_tool_use_id === null &&
|
|
492
|
+
message.message.model &&
|
|
493
|
+
message.message.model !== "<synthetic>") {
|
|
494
|
+
lastAssistantModel = message.message.model;
|
|
495
|
+
}
|
|
445
496
|
// Slash commands like /compact can generate invalid output... doesn't match
|
|
446
497
|
// their own docs: https://docs.anthropic.com/en/docs/claude-code/sdk/sdk-slash-commands#%2Fcompact-compact-conversation-history
|
|
447
498
|
if (typeof message.message.content === "string" &&
|
|
@@ -1027,6 +1078,11 @@ export class ClaudeAcpAgent {
|
|
|
1027
1078
|
}
|
|
1028
1079
|
const models = await getAvailableModels(q, initializationResult.models, settingsManager);
|
|
1029
1080
|
const availableModes = [
|
|
1081
|
+
{
|
|
1082
|
+
id: "auto",
|
|
1083
|
+
name: "Auto",
|
|
1084
|
+
decription: "Use a model classifier to approve/deny permission prompts.",
|
|
1085
|
+
},
|
|
1030
1086
|
{
|
|
1031
1087
|
id: "default",
|
|
1032
1088
|
name: "Default",
|
|
@@ -1614,3 +1670,24 @@ export function runAcp() {
|
|
|
1614
1670
|
const stream = ndJsonStream(input, output);
|
|
1615
1671
|
new AgentSideConnection((client) => new ClaudeAcpAgent(client), stream);
|
|
1616
1672
|
}
|
|
1673
|
+
function commonPrefixLength(a, b) {
|
|
1674
|
+
let i = 0;
|
|
1675
|
+
while (i < a.length && i < b.length && a[i] === b[i]) {
|
|
1676
|
+
i++;
|
|
1677
|
+
}
|
|
1678
|
+
return i;
|
|
1679
|
+
}
|
|
1680
|
+
function getMatchingModelUsage(modelUsage, currentModel) {
|
|
1681
|
+
let bestKey = null;
|
|
1682
|
+
let bestLen = 0;
|
|
1683
|
+
for (const key of Object.keys(modelUsage)) {
|
|
1684
|
+
const len = commonPrefixLength(key, currentModel);
|
|
1685
|
+
if (len > bestLen) {
|
|
1686
|
+
bestLen = len;
|
|
1687
|
+
bestKey = key;
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
if (bestKey) {
|
|
1691
|
+
return modelUsage[bestKey];
|
|
1692
|
+
}
|
|
1693
|
+
}
|
package/dist/settings.d.ts
CHANGED
|
@@ -50,7 +50,9 @@ export declare class SettingsManager {
|
|
|
50
50
|
private onChange?;
|
|
51
51
|
private logger;
|
|
52
52
|
private initialized;
|
|
53
|
+
private disposed;
|
|
53
54
|
private debounceTimer;
|
|
55
|
+
private initPromise;
|
|
54
56
|
constructor(cwd: string, options?: SettingsManagerOptions);
|
|
55
57
|
/**
|
|
56
58
|
* Initialize the settings manager by loading all settings and setting up file watchers
|
package/dist/settings.d.ts.map
CHANGED
|
@@ -1 +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;
|
|
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;AA2BD;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAW/C;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,MAAM,CAAC,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
|
@@ -2,9 +2,11 @@ import * as fs from "node:fs";
|
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { CLAUDE_CONFIG_DIR } from "./acp-agent.js";
|
|
4
4
|
/**
|
|
5
|
-
* Reads and parses a JSON settings file, returning an empty object if not found or invalid
|
|
5
|
+
* Reads and parses a JSON settings file, returning an empty object if not found or invalid.
|
|
6
|
+
* Silently ignores missing files (ENOENT) but logs warnings for other errors
|
|
7
|
+
* (malformed JSON, permission errors, etc.) to aid debugging.
|
|
6
8
|
*/
|
|
7
|
-
async function loadSettingsFile(filePath) {
|
|
9
|
+
async function loadSettingsFile(filePath, logger) {
|
|
8
10
|
if (!filePath) {
|
|
9
11
|
return {};
|
|
10
12
|
}
|
|
@@ -12,7 +14,11 @@ async function loadSettingsFile(filePath) {
|
|
|
12
14
|
const content = await fs.promises.readFile(filePath, "utf-8");
|
|
13
15
|
return JSON.parse(content);
|
|
14
16
|
}
|
|
15
|
-
catch {
|
|
17
|
+
catch (error) {
|
|
18
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
19
|
+
return {};
|
|
20
|
+
}
|
|
21
|
+
logger?.error(`Failed to load settings from ${filePath}:`, error);
|
|
16
22
|
return {};
|
|
17
23
|
}
|
|
18
24
|
}
|
|
@@ -51,7 +57,9 @@ export class SettingsManager {
|
|
|
51
57
|
this.mergedSettings = {};
|
|
52
58
|
this.watchers = [];
|
|
53
59
|
this.initialized = false;
|
|
60
|
+
this.disposed = false;
|
|
54
61
|
this.debounceTimer = null;
|
|
62
|
+
this.initPromise = null;
|
|
55
63
|
this.cwd = cwd;
|
|
56
64
|
this.onChange = options?.onChange;
|
|
57
65
|
this.logger = options?.logger ?? console;
|
|
@@ -63,9 +71,18 @@ export class SettingsManager {
|
|
|
63
71
|
if (this.initialized) {
|
|
64
72
|
return;
|
|
65
73
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
74
|
+
if (this.initPromise) {
|
|
75
|
+
return this.initPromise;
|
|
76
|
+
}
|
|
77
|
+
this.disposed = false;
|
|
78
|
+
this.initPromise = this.loadAllSettings().then(() => {
|
|
79
|
+
if (!this.disposed) {
|
|
80
|
+
this.setupWatchers();
|
|
81
|
+
this.initialized = true;
|
|
82
|
+
}
|
|
83
|
+
this.initPromise = null;
|
|
84
|
+
});
|
|
85
|
+
return this.initPromise;
|
|
69
86
|
}
|
|
70
87
|
/**
|
|
71
88
|
* Returns the path to the user settings file
|
|
@@ -90,10 +107,10 @@ export class SettingsManager {
|
|
|
90
107
|
*/
|
|
91
108
|
async loadAllSettings() {
|
|
92
109
|
const [userSettings, projectSettings, localSettings, enterpriseSettings] = await Promise.all([
|
|
93
|
-
loadSettingsFile(this.getUserSettingsPath()),
|
|
94
|
-
loadSettingsFile(this.getProjectSettingsPath()),
|
|
95
|
-
loadSettingsFile(this.getLocalSettingsPath()),
|
|
96
|
-
loadSettingsFile(getManagedSettingsPath()),
|
|
110
|
+
loadSettingsFile(this.getUserSettingsPath(), this.logger),
|
|
111
|
+
loadSettingsFile(this.getProjectSettingsPath(), this.logger),
|
|
112
|
+
loadSettingsFile(this.getLocalSettingsPath(), this.logger),
|
|
113
|
+
loadSettingsFile(getManagedSettingsPath(), this.logger),
|
|
97
114
|
]);
|
|
98
115
|
this.userSettings = userSettings;
|
|
99
116
|
this.projectSettings = projectSettings;
|
|
@@ -172,9 +189,14 @@ export class SettingsManager {
|
|
|
172
189
|
}
|
|
173
190
|
this.debounceTimer = setTimeout(async () => {
|
|
174
191
|
this.debounceTimer = null;
|
|
192
|
+
if (this.disposed) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
175
195
|
try {
|
|
176
196
|
await this.loadAllSettings();
|
|
177
|
-
this.
|
|
197
|
+
if (!this.disposed) {
|
|
198
|
+
this.onChange?.();
|
|
199
|
+
}
|
|
178
200
|
}
|
|
179
201
|
catch (error) {
|
|
180
202
|
this.logger.error("Failed to reload settings:", error);
|
|
@@ -202,13 +224,15 @@ export class SettingsManager {
|
|
|
202
224
|
}
|
|
203
225
|
this.dispose();
|
|
204
226
|
this.cwd = cwd;
|
|
205
|
-
this.initialized = false;
|
|
206
227
|
await this.initialize();
|
|
207
228
|
}
|
|
208
229
|
/**
|
|
209
230
|
* Disposes of file watchers and cleans up resources
|
|
210
231
|
*/
|
|
211
232
|
dispose() {
|
|
233
|
+
this.disposed = true;
|
|
234
|
+
this.initialized = false;
|
|
235
|
+
this.initPromise = null;
|
|
212
236
|
if (this.debounceTimer) {
|
|
213
237
|
clearTimeout(this.debounceTimer);
|
|
214
238
|
this.debounceTimer = null;
|
|
@@ -217,6 +241,5 @@ export class SettingsManager {
|
|
|
217
241
|
watcher.close();
|
|
218
242
|
}
|
|
219
243
|
this.watchers = [];
|
|
220
|
-
this.initialized = false;
|
|
221
244
|
}
|
|
222
245
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.25.0",
|
|
7
7
|
"description": "An ACP-compatible coding agent powered by the Claude Agent SDK (TypeScript)",
|
|
8
8
|
"main": "dist/lib.js",
|
|
9
9
|
"types": "dist/lib.d.ts",
|
|
@@ -60,22 +60,22 @@
|
|
|
60
60
|
"author": "Zed Industries",
|
|
61
61
|
"license": "Apache-2.0",
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@agentclientprotocol/sdk": "0.
|
|
64
|
-
"@anthropic-ai/claude-agent-sdk": "0.2.
|
|
63
|
+
"@agentclientprotocol/sdk": "0.18.0",
|
|
64
|
+
"@anthropic-ai/claude-agent-sdk": "0.2.91",
|
|
65
65
|
"zod": "^3.25.0 || ^4.0.0"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@anthropic-ai/sdk": "0.
|
|
68
|
+
"@anthropic-ai/sdk": "0.82.0",
|
|
69
69
|
"@eslint/js": "10.0.1",
|
|
70
|
-
"@types/node": "25.5.
|
|
71
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
72
|
-
"@typescript-eslint/parser": "8.
|
|
70
|
+
"@types/node": "25.5.1",
|
|
71
|
+
"@typescript-eslint/eslint-plugin": "8.58.0",
|
|
72
|
+
"@typescript-eslint/parser": "8.58.0",
|
|
73
73
|
"eslint": "10.1.0",
|
|
74
74
|
"eslint-config-prettier": "10.1.8",
|
|
75
75
|
"globals": "17.4.0",
|
|
76
76
|
"prettier": "3.8.1",
|
|
77
77
|
"ts-node": "10.9.2",
|
|
78
|
-
"typescript": "
|
|
79
|
-
"vitest": "4.1.
|
|
78
|
+
"typescript": "6.0.2",
|
|
79
|
+
"vitest": "4.1.2"
|
|
80
80
|
}
|
|
81
81
|
}
|