@adecore/agents 0.39.0 → 0.40.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/async.d.ts +5 -0
- package/dist/async.js +13 -5
- package/dist/chat/acp-protocol.js +3 -5
- package/dist/chat/chat-core.js +0 -2
- package/dist/chat/chat-process.d.ts +1 -0
- package/dist/chat/chat-process.js +1 -1
- package/dist/chat/chat-session.js +6 -8
- package/dist/chat/claude-protocol.js +1 -6
- package/dist/chat/claude-transcript.js +1 -3
- package/dist/chat/codex-protocol.js +1 -6
- package/dist/chat/projector.js +1 -3
- package/dist/chat/request-summary.js +1 -3
- package/dist/coded-error.js +1 -5
- package/dist/context/argv.js +1 -2
- package/dist/context/verb.js +1 -3
- package/dist/error-text.d.ts +1 -0
- package/dist/error-text.js +4 -0
- package/dist/fields.d.ts +3 -0
- package/dist/fields.js +12 -0
- package/dist/fs.d.ts +1 -0
- package/dist/fs.js +8 -4
- package/dist/lineage.js +11 -5
- package/dist/messages/notice-store.js +3 -4
- package/dist/providers/accounts/acp-account.js +3 -20
- package/dist/providers/accounts/service.d.ts +1 -2
- package/dist/providers/accounts/service.js +5 -9
- package/dist/providers/accounts/status.js +1 -3
- package/dist/providers/acp-agent-state.js +1 -3
- package/dist/providers/claude.js +0 -1
- package/dist/providers/codex.js +0 -1
- package/dist/providers/detect.js +1 -1
- package/dist/providers/shell-commands.js +1 -2
- package/dist/run-process.js +1 -3
- package/dist/skills.d.ts +1 -1
- package/dist/skills.js +5 -8
- package/dist/tasks/background-limit.js +3 -2
- package/dist/tasks/task-coordinator.js +11 -17
- package/dist/testing/watch.js +0 -1
- package/dist/usage/limits/monitor.js +1 -2
- package/dist/usage/readers/claude.js +3 -10
- package/dist/usage/readers/codex.js +2 -9
- package/dist/usage/readers/grok.js +3 -10
- package/dist/usage/readers/host-log.js +3 -10
- package/dist/usage/record.d.ts +2 -0
- package/dist/usage/record.js +13 -0
- package/package.json +6 -6
- package/src/async.ts +23 -5
- package/src/chat/acp-backend.ts +121 -0
- package/src/chat/acp-protocol.ts +172 -6
- package/src/chat/attachment-store.ts +21 -0
- package/src/chat/backend.ts +0 -2
- package/src/chat/bookmark-store.ts +23 -0
- package/src/chat/chat-core.ts +208 -7
- package/src/chat/chat-log.ts +19 -0
- package/src/chat/chat-process.ts +52 -1
- package/src/chat/chat-session.ts +401 -10
- package/src/chat/chat-store.ts +50 -0
- package/src/chat/chat-title.ts +9 -0
- package/src/chat/claude-backend.ts +50 -0
- package/src/chat/claude-protocol.ts +155 -8
- package/src/chat/claude-title.ts +10 -0
- package/src/chat/claude-transcript.ts +47 -4
- package/src/chat/codex-backend.ts +131 -0
- package/src/chat/codex-protocol.ts +180 -8
- package/src/chat/codex-thread.ts +23 -0
- package/src/chat/composer-preferences.ts +6 -0
- package/src/chat/context-breakdown.ts +11 -0
- package/src/chat/delta-coalescer.ts +8 -0
- package/src/chat/external-sessions.ts +28 -0
- package/src/chat/generated-image.ts +25 -0
- package/src/chat/index.ts +5 -0
- package/src/chat/input.ts +13 -0
- package/src/chat/json-rpc-transport.ts +28 -0
- package/src/chat/limit-resume.ts +13 -0
- package/src/chat/projector.ts +160 -4
- package/src/chat/readable-text.ts +3 -0
- package/src/chat/request-summary.ts +18 -4
- package/src/chat/subagent-projection.ts +3 -0
- package/src/chat/subagent-reader.ts +76 -0
- package/src/chat/subagent-settlement.ts +24 -0
- package/src/chat/thread-search.ts +13 -0
- package/src/chat/thread.ts +31 -0
- package/src/chat/ui-queries.ts +122 -0
- package/src/chat/ui-replies.ts +34 -0
- package/src/chat/visual-store.ts +49 -0
- package/src/chat/wake-chat.ts +3 -0
- package/src/client-sinks.ts +2 -0
- package/src/coded-error.ts +1 -5
- package/src/context/argv.ts +18 -2
- package/src/context/index.ts +1 -0
- package/src/context/refusal.ts +3 -0
- package/src/context/verb.ts +32 -4
- package/src/coordination/index.ts +10 -0
- package/src/error-text.ts +7 -0
- package/src/fields.ts +14 -0
- package/src/fs.ts +20 -4
- package/src/host/agent-host.ts +20 -0
- package/src/host/environment.ts +6 -0
- package/src/host/handlers.ts +18 -0
- package/src/host/memory-port.ts +4 -0
- package/src/host/wiring.ts +10 -0
- package/src/index.ts +1 -0
- package/src/lineage.ts +24 -5
- package/src/messages/deliver-message.ts +6 -0
- package/src/messages/deliver-notice.ts +13 -0
- package/src/messages/notice-store.ts +16 -4
- package/src/modes.ts +1 -0
- package/src/outbox/outbox-worker.ts +31 -0
- package/src/outbox/outbox.ts +5 -0
- package/src/providers/accounts/accounts.ts +36 -0
- package/src/providers/accounts/acp-account.ts +22 -27
- package/src/providers/accounts/launch.ts +4 -0
- package/src/providers/accounts/service.ts +110 -12
- package/src/providers/accounts/shadow-home.ts +10 -0
- package/src/providers/accounts/status.ts +13 -4
- package/src/providers/accounts/store.ts +25 -0
- package/src/providers/accounts/variables.ts +11 -1
- package/src/providers/acp-agent-state.ts +24 -3
- package/src/providers/acp-provider.ts +5 -0
- package/src/providers/acp-usage-log.ts +2 -0
- package/src/providers/catalog.ts +17 -0
- package/src/providers/claude.ts +10 -1
- package/src/providers/codex-rules.ts +3 -0
- package/src/providers/codex.ts +2 -1
- package/src/providers/detect.ts +6 -1
- package/src/providers/provider.ts +1 -1
- package/src/providers/registry.ts +18 -2
- package/src/providers/shell-commands.ts +37 -2
- package/src/record-directory.ts +19 -0
- package/src/run-process.ts +24 -3
- package/src/serializer.ts +3 -0
- package/src/skills.ts +73 -10
- package/src/tasks/background-limit.ts +9 -2
- package/src/tasks/end-children.ts +9 -0
- package/src/tasks/give-task.ts +8 -0
- package/src/tasks/task-coordinator.ts +81 -17
- package/src/tasks/task-store.ts +28 -0
- package/src/tasks/waiting-child.ts +21 -0
- package/src/tasks/wake-parent.ts +26 -0
- package/src/tasks/wiring.ts +22 -0
- package/src/testing/accounts.ts +2 -0
- package/src/testing/fake-acp-capture.ts +16 -0
- package/src/testing/fake-acp.ts +66 -0
- package/src/testing/fake-claude.ts +177 -0
- package/src/testing/fake-cli.ts +29 -0
- package/src/testing/fake-codex.ts +122 -0
- package/src/testing/manual-clock.ts +2 -0
- package/src/testing/watch.ts +7 -1
- package/src/title-file.ts +12 -0
- package/src/usage/accounts.ts +6 -0
- package/src/usage/aggregate.ts +19 -0
- package/src/usage/exchange.ts +12 -0
- package/src/usage/index-file.ts +27 -0
- package/src/usage/limits/monitor.ts +31 -3
- package/src/usage/limits/normalize.ts +30 -0
- package/src/usage/limits/probe.ts +17 -0
- package/src/usage/pricing.ts +35 -0
- package/src/usage/projects.ts +8 -0
- package/src/usage/readers/claude.ts +12 -9
- package/src/usage/readers/codex.ts +40 -8
- package/src/usage/readers/grok.ts +17 -9
- package/src/usage/readers/host-log.ts +9 -9
- package/src/usage/record.ts +22 -0
- package/src/usage/roots.ts +6 -0
- package/src/usage/scanner.ts +61 -0
- package/src/usage/usage-service.ts +14 -0
- package/src/watch-seam.ts +8 -0
- package/src/windows-command.ts +12 -0
|
@@ -60,6 +60,7 @@ export class JsonRpcTransport {
|
|
|
60
60
|
|
|
61
61
|
constructor(options: JsonRpcTransportOptions) {
|
|
62
62
|
this.options = options;
|
|
63
|
+
|
|
63
64
|
this.child = new ChatChild({
|
|
64
65
|
command: options.command,
|
|
65
66
|
cwd: options.cwd,
|
|
@@ -68,6 +69,7 @@ export class JsonRpcTransport {
|
|
|
68
69
|
onError: (error) => this.broken(error),
|
|
69
70
|
onExit: (exitCode, stderr) => this.handleExit(exitCode, stderr)
|
|
70
71
|
});
|
|
72
|
+
|
|
71
73
|
void this.readLines();
|
|
72
74
|
}
|
|
73
75
|
|
|
@@ -82,27 +84,35 @@ export class JsonRpcTransport {
|
|
|
82
84
|
request(method: string, params: unknown, options: JsonRpcRequestOptions = {}): Promise<unknown> {
|
|
83
85
|
const label = this.options.label;
|
|
84
86
|
const timeoutMs = options.timeoutMs === undefined ? this.options.requestTimeoutMs : options.timeoutMs;
|
|
87
|
+
|
|
85
88
|
return new Promise((resolve, reject) => {
|
|
86
89
|
if (this.closed) {
|
|
87
90
|
reject(new Error(`${label} is not running`));
|
|
91
|
+
|
|
88
92
|
return;
|
|
89
93
|
}
|
|
94
|
+
|
|
90
95
|
const id = this.nextId++;
|
|
91
96
|
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
97
|
+
|
|
92
98
|
if (timeoutMs !== null) {
|
|
93
99
|
timer = setTimeout(() => {
|
|
94
100
|
this.pending.delete(id);
|
|
95
101
|
reject(new Error(`${method} failed: ${label} did not answer in ${timeoutMs / 1000} seconds`));
|
|
96
102
|
}, timeoutMs);
|
|
103
|
+
|
|
97
104
|
timer.unref?.();
|
|
98
105
|
}
|
|
106
|
+
|
|
99
107
|
this.pending.set(id, { resolve, reject, method, timer });
|
|
108
|
+
|
|
100
109
|
try {
|
|
101
110
|
this.write({ id, method, params });
|
|
102
111
|
} catch (error) {
|
|
103
112
|
if (timer !== null) {
|
|
104
113
|
clearTimeout(timer);
|
|
105
114
|
}
|
|
115
|
+
|
|
106
116
|
this.pending.delete(id);
|
|
107
117
|
reject(error);
|
|
108
118
|
}
|
|
@@ -124,6 +134,7 @@ export class JsonRpcTransport {
|
|
|
124
134
|
/* Closes stdin; the child ends on its own once it has nothing more to say. */
|
|
125
135
|
end(): void {
|
|
126
136
|
this.inputClosed = true;
|
|
137
|
+
|
|
127
138
|
try {
|
|
128
139
|
this.child.process.stdin.end();
|
|
129
140
|
} catch {
|
|
@@ -148,12 +159,14 @@ export class JsonRpcTransport {
|
|
|
148
159
|
if (this.closed || this.inputClosed) {
|
|
149
160
|
throw new Error(`${this.options.label} stdin is closed`);
|
|
150
161
|
}
|
|
162
|
+
|
|
151
163
|
try {
|
|
152
164
|
const framed = this.options.versionField ? { jsonrpc: '2.0', ...frame } : frame;
|
|
153
165
|
this.child.process.stdin.write(`${JSON.stringify(framed)}\n`);
|
|
154
166
|
this.child.process.stdin.flush();
|
|
155
167
|
} catch (error) {
|
|
156
168
|
this.inputClosed = true;
|
|
169
|
+
|
|
157
170
|
throw error;
|
|
158
171
|
}
|
|
159
172
|
}
|
|
@@ -167,6 +180,7 @@ export class JsonRpcTransport {
|
|
|
167
180
|
private failed(error: unknown): void {
|
|
168
181
|
const failure = new Error(`Lost the connection to ${this.options.label}: ${errorText(error)}`);
|
|
169
182
|
this.rejectPending(() => failure);
|
|
183
|
+
|
|
170
184
|
try {
|
|
171
185
|
this.options.onError?.(failure);
|
|
172
186
|
} catch (reportError) {
|
|
@@ -203,28 +217,39 @@ export class JsonRpcTransport {
|
|
|
203
217
|
if (this.closed || line.trim() === '') {
|
|
204
218
|
return;
|
|
205
219
|
}
|
|
220
|
+
|
|
206
221
|
let frame: unknown;
|
|
222
|
+
|
|
207
223
|
try {
|
|
208
224
|
frame = JSON.parse(line);
|
|
209
225
|
} catch {
|
|
210
226
|
return;
|
|
211
227
|
}
|
|
228
|
+
|
|
212
229
|
if (typeof frame !== 'object' || frame === null || Array.isArray(frame)) {
|
|
213
230
|
return;
|
|
214
231
|
}
|
|
232
|
+
|
|
215
233
|
const message = frame as JsonRpcFrame;
|
|
234
|
+
|
|
216
235
|
if (typeof message.method === 'string') {
|
|
217
236
|
this.options.onFrame(message);
|
|
237
|
+
|
|
218
238
|
return;
|
|
219
239
|
}
|
|
240
|
+
|
|
220
241
|
const settle = typeof message.id === 'number' ? this.pending.get(message.id) : undefined;
|
|
242
|
+
|
|
221
243
|
if (!settle) {
|
|
222
244
|
return;
|
|
223
245
|
}
|
|
246
|
+
|
|
224
247
|
this.pending.delete(message.id as number);
|
|
248
|
+
|
|
225
249
|
if (settle.timer !== null) {
|
|
226
250
|
clearTimeout(settle.timer);
|
|
227
251
|
}
|
|
252
|
+
|
|
228
253
|
if (message.error !== undefined) {
|
|
229
254
|
settle.reject(new JsonRpcError(this.options.errorName ?? 'JsonRpcError', settle.method, message.error));
|
|
230
255
|
} else {
|
|
@@ -236,6 +261,7 @@ export class JsonRpcTransport {
|
|
|
236
261
|
if (this.closed) {
|
|
237
262
|
return;
|
|
238
263
|
}
|
|
264
|
+
|
|
239
265
|
this.closed = true;
|
|
240
266
|
this.rejectPending((method) => new Error(`${method} failed: ${this.options.label} exited`));
|
|
241
267
|
this.options.onExit(exitCode, stderr);
|
|
@@ -246,8 +272,10 @@ export class JsonRpcTransport {
|
|
|
246
272
|
if (settle.timer !== null) {
|
|
247
273
|
clearTimeout(settle.timer);
|
|
248
274
|
}
|
|
275
|
+
|
|
249
276
|
settle.reject(reason(settle.method));
|
|
250
277
|
}
|
|
278
|
+
|
|
251
279
|
this.pending.clear();
|
|
252
280
|
}
|
|
253
281
|
}
|
package/src/chat/limit-resume.ts
CHANGED
|
@@ -6,6 +6,7 @@ export const LIMIT_RETRY_DELAYS_MS: readonly number[] = [60_000, 5 * 60_000, 15
|
|
|
6
6
|
/* The last turn of a thread, when it stopped on a limit. */
|
|
7
7
|
export function limitedTurn(items: readonly ChatItem[]): (ChatTurnItem & { limit: ChatTurnLimit }) | null {
|
|
8
8
|
const last = items.findLast((item) => item.kind === 'turn');
|
|
9
|
+
|
|
9
10
|
return last?.kind === 'turn' && last.state === 'error' && last.limit !== undefined ? (last as ChatTurnItem & { limit: ChatTurnLimit }) : null;
|
|
10
11
|
}
|
|
11
12
|
|
|
@@ -13,20 +14,27 @@ export function limitedTurn(items: readonly ChatItem[]): (ChatTurnItem & { limit
|
|
|
13
14
|
function limitedInARow(items: readonly ChatItem[], turn: ChatTurnItem): number {
|
|
14
15
|
let count = 0;
|
|
15
16
|
let seen = false;
|
|
17
|
+
|
|
16
18
|
for (let i = items.length - 1; i >= 0; i--) {
|
|
17
19
|
const item = items[i]!;
|
|
20
|
+
|
|
18
21
|
if (item.kind !== 'turn') {
|
|
19
22
|
continue;
|
|
20
23
|
}
|
|
24
|
+
|
|
21
25
|
seen ||= item.id === turn.id;
|
|
26
|
+
|
|
22
27
|
if (!seen) {
|
|
23
28
|
continue;
|
|
24
29
|
}
|
|
30
|
+
|
|
25
31
|
if (item.state !== 'error' || item.limit === undefined) {
|
|
26
32
|
break;
|
|
27
33
|
}
|
|
34
|
+
|
|
28
35
|
count += 1;
|
|
29
36
|
}
|
|
37
|
+
|
|
30
38
|
return count;
|
|
31
39
|
}
|
|
32
40
|
|
|
@@ -39,17 +47,22 @@ export function limitResumeAt(items: readonly ChatItem[], turn: ChatTurnItem, no
|
|
|
39
47
|
if (turn.state !== 'error' || turn.limit === undefined) {
|
|
40
48
|
return null;
|
|
41
49
|
}
|
|
50
|
+
|
|
42
51
|
const tries = limitedInARow(items, turn);
|
|
43
52
|
const delay = LIMIT_RETRY_DELAYS_MS[tries - 1];
|
|
53
|
+
|
|
44
54
|
if (delay === undefined) {
|
|
45
55
|
return null;
|
|
46
56
|
}
|
|
57
|
+
|
|
47
58
|
if (turn.limit.kind === 'overload') {
|
|
48
59
|
return now + delay;
|
|
49
60
|
}
|
|
61
|
+
|
|
50
62
|
if (turn.limit.resetsAt === undefined) {
|
|
51
63
|
return null;
|
|
52
64
|
}
|
|
65
|
+
|
|
53
66
|
return tries === 1 ? turn.limit.resetsAt : Math.max(turn.limit.resetsAt, now + delay);
|
|
54
67
|
}
|
|
55
68
|
|