@parall/claude-agent 1.30.0 → 1.32.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/config.d.ts.map +1 -1
- package/dist/config.js +18 -18
- package/dist/dispatch.d.ts +9 -7
- package/dist/dispatch.d.ts.map +1 -1
- package/dist/dispatch.js +134 -88
- package/dist/index.js +185 -134
- package/dist/output-parser.d.ts +4 -4
- package/dist/output-parser.d.ts.map +1 -1
- package/dist/output-parser.js +41 -41
- package/dist/session-manager.d.ts +2 -2
- package/dist/session-manager.d.ts.map +1 -1
- package/dist/session-manager.js +12 -10
- package/dist/workspace.d.ts +1 -1
- package/dist/workspace.js +9 -9
- package/package.json +4 -4
- package/src/config.ts +27 -19
- package/src/dispatch.ts +182 -121
- package/src/index.ts +214 -142
- package/src/output-parser.ts +54 -49
- package/src/session-manager.ts +31 -28
- package/src/workspace.ts +10 -10
package/src/session-manager.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as fs from
|
|
2
|
-
import * as path from
|
|
3
|
-
import { randomUUID } from
|
|
4
|
-
import type { ChildProcessWithoutNullStreams } from
|
|
5
|
-
import type { ForkSessionHandle } from
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
import type { ChildProcessWithoutNullStreams } from 'node:child_process';
|
|
5
|
+
import type { ForkSessionHandle } from '@parall/agent-core';
|
|
6
6
|
|
|
7
7
|
type PersistedMainSession = {
|
|
8
8
|
runtimeKey: string;
|
|
@@ -38,10 +38,10 @@ export class ClaudeSessionManager {
|
|
|
38
38
|
|
|
39
39
|
getResumeArgs(sessionKey: string): string[] {
|
|
40
40
|
const existing = this.sessionIds.get(sessionKey);
|
|
41
|
-
if (existing) return [
|
|
41
|
+
if (existing) return ['--resume', existing];
|
|
42
42
|
|
|
43
43
|
const parent = this.pendingForkParents.get(sessionKey);
|
|
44
|
-
if (parent) return [
|
|
44
|
+
if (parent) return ['--resume', parent, '--fork-session'];
|
|
45
45
|
|
|
46
46
|
return [];
|
|
47
47
|
}
|
|
@@ -115,9 +115,7 @@ export class ClaudeSessionManager {
|
|
|
115
115
|
async shutdownAll(): Promise<void> {
|
|
116
116
|
const handles = [...this.processes.entries()];
|
|
117
117
|
this.processes.clear();
|
|
118
|
-
await Promise.all(
|
|
119
|
-
handles.map(([sessionKey, handle]) => this.shutdownOne(sessionKey, handle)),
|
|
120
|
-
);
|
|
118
|
+
await Promise.all(handles.map(([sessionKey, handle]) => this.shutdownOne(sessionKey, handle)));
|
|
121
119
|
}
|
|
122
120
|
|
|
123
121
|
private async shutdownOne(sessionKey: string, handle: ClaudeProcessHandle): Promise<void> {
|
|
@@ -133,15 +131,11 @@ export class ClaudeSessionManager {
|
|
|
133
131
|
if (!timedOut) return;
|
|
134
132
|
|
|
135
133
|
if (handle.proc.exitCode === null && handle.proc.signalCode === null) {
|
|
136
|
-
this.logger?.warn(
|
|
137
|
-
`claude-agent: SIGTERM timed out for ${sessionKey}, escalating to SIGKILL`,
|
|
138
|
-
);
|
|
134
|
+
this.logger?.warn(`claude-agent: SIGTERM timed out for ${sessionKey}, escalating to SIGKILL`);
|
|
139
135
|
try {
|
|
140
|
-
handle.proc.kill(
|
|
136
|
+
handle.proc.kill('SIGKILL');
|
|
141
137
|
} catch (error) {
|
|
142
|
-
this.logger?.warn(
|
|
143
|
-
`claude-agent: SIGKILL failed for ${sessionKey}: ${String(error)}`,
|
|
144
|
-
);
|
|
138
|
+
this.logger?.warn(`claude-agent: SIGKILL failed for ${sessionKey}: ${String(error)}`);
|
|
145
139
|
}
|
|
146
140
|
}
|
|
147
141
|
// Bound the post-SIGKILL wait too: on the rare kernel path where even
|
|
@@ -172,7 +166,7 @@ export class ClaudeSessionManager {
|
|
|
172
166
|
resolve(true);
|
|
173
167
|
}, ms);
|
|
174
168
|
// Don't keep the event loop alive purely on the timeout.
|
|
175
|
-
if (typeof timer.unref ===
|
|
169
|
+
if (typeof timer.unref === 'function') timer.unref();
|
|
176
170
|
promise
|
|
177
171
|
.catch(() => {
|
|
178
172
|
/* exitPromise does not reject; guard anyway */
|
|
@@ -192,13 +186,11 @@ export class ClaudeSessionManager {
|
|
|
192
186
|
handle.proc.stdin.end();
|
|
193
187
|
}
|
|
194
188
|
} catch (error) {
|
|
195
|
-
this.logger?.warn(
|
|
196
|
-
`claude-agent: failed to close stdin (${reason}): ${String(error)}`,
|
|
197
|
-
);
|
|
189
|
+
this.logger?.warn(`claude-agent: failed to close stdin (${reason}): ${String(error)}`);
|
|
198
190
|
}
|
|
199
191
|
if (handle.proc.exitCode === null && handle.proc.signalCode === null) {
|
|
200
192
|
try {
|
|
201
|
-
handle.proc.kill(
|
|
193
|
+
handle.proc.kill('SIGTERM');
|
|
202
194
|
} catch (error) {
|
|
203
195
|
this.logger?.warn(
|
|
204
196
|
`claude-agent: failed to SIGTERM claude subprocess (${reason}): ${String(error)}`,
|
|
@@ -218,9 +210,13 @@ export class ClaudeSessionManager {
|
|
|
218
210
|
|
|
219
211
|
private restore() {
|
|
220
212
|
try {
|
|
221
|
-
const raw = fs.readFileSync(this.stateFilePath,
|
|
213
|
+
const raw = fs.readFileSync(this.stateFilePath, 'utf8');
|
|
222
214
|
const parsed = JSON.parse(raw) as Partial<PersistedMainSession>;
|
|
223
|
-
if (
|
|
215
|
+
if (
|
|
216
|
+
parsed.runtimeKey === this.mainSessionKey &&
|
|
217
|
+
typeof parsed.sessionId === 'string' &&
|
|
218
|
+
parsed.sessionId.trim()
|
|
219
|
+
) {
|
|
224
220
|
this.sessionIds.set(this.mainSessionKey, parsed.sessionId.trim());
|
|
225
221
|
}
|
|
226
222
|
} catch {
|
|
@@ -231,10 +227,17 @@ export class ClaudeSessionManager {
|
|
|
231
227
|
private persist(sessionId: string) {
|
|
232
228
|
try {
|
|
233
229
|
fs.mkdirSync(path.dirname(this.stateFilePath), { recursive: true });
|
|
234
|
-
fs.writeFileSync(
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
230
|
+
fs.writeFileSync(
|
|
231
|
+
this.stateFilePath,
|
|
232
|
+
JSON.stringify(
|
|
233
|
+
{
|
|
234
|
+
runtimeKey: this.mainSessionKey,
|
|
235
|
+
sessionId,
|
|
236
|
+
},
|
|
237
|
+
null,
|
|
238
|
+
2,
|
|
239
|
+
),
|
|
240
|
+
);
|
|
238
241
|
} catch (error) {
|
|
239
242
|
this.logger?.warn(
|
|
240
243
|
`claude-agent: failed to persist main session state at ${this.stateFilePath}: ${String(error)}`,
|
package/src/workspace.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as fs from
|
|
2
|
-
import * as path from
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
3
|
import {
|
|
4
4
|
BRIDGE_WORKSPACE_INSTRUCTIONS,
|
|
5
5
|
PRLL_BEHAVIOR,
|
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
buildIdentity,
|
|
8
8
|
buildSkillReferences,
|
|
9
9
|
writeSkillFiles,
|
|
10
|
-
} from
|
|
11
|
-
import type { AgentIdentity } from
|
|
12
|
-
import { ensureLocalAttachmentGitExclude } from
|
|
10
|
+
} from '@parall/agent-core';
|
|
11
|
+
import type { AgentIdentity } from '@parall/agent-core';
|
|
12
|
+
import { ensureLocalAttachmentGitExclude } from '@parall/agent-core/internal/attachment-input';
|
|
13
13
|
|
|
14
14
|
export function ensureClaudeWorkspace(
|
|
15
15
|
workspaceDir: string,
|
|
@@ -22,15 +22,15 @@ export function ensureClaudeWorkspace(
|
|
|
22
22
|
PRLL_BEHAVIOR,
|
|
23
23
|
PRLL_REFERENCE_GUIDE,
|
|
24
24
|
buildSkillReferences(workspaceDir),
|
|
25
|
-
].join(
|
|
25
|
+
].join('\n\n');
|
|
26
26
|
|
|
27
27
|
fs.mkdirSync(workspaceDir, { recursive: true });
|
|
28
|
-
fs.mkdirSync(path.join(workspaceDir,
|
|
28
|
+
fs.mkdirSync(path.join(workspaceDir, '.claude'), { recursive: true });
|
|
29
29
|
|
|
30
|
-
const parallDir = path.join(workspaceDir,
|
|
30
|
+
const parallDir = path.join(workspaceDir, '.parall');
|
|
31
31
|
fs.mkdirSync(parallDir, { recursive: true });
|
|
32
|
-
fs.writeFileSync(path.join(parallDir,
|
|
32
|
+
fs.writeFileSync(path.join(parallDir, 'system-prompt.md'), systemPrompt, 'utf8');
|
|
33
33
|
|
|
34
|
-
writeSkillFiles(path.join(parallDir,
|
|
34
|
+
writeSkillFiles(path.join(parallDir, 'skills'));
|
|
35
35
|
ensureLocalAttachmentGitExclude(workspaceDir);
|
|
36
36
|
}
|