@parall/claude-agent 1.30.0 → 1.31.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.js +2 -2
- package/dist/dispatch.d.ts +1 -0
- package/dist/dispatch.d.ts.map +1 -1
- package/dist/dispatch.js +6 -2
- package/dist/index.js +27 -2
- package/package.json +4 -4
- package/src/config.ts +2 -2
- package/src/dispatch.ts +7 -2
- package/src/index.ts +25 -2
package/dist/config.js
CHANGED
|
@@ -23,8 +23,8 @@ export function resolveClaudeAgentConfig(env = process.env) {
|
|
|
23
23
|
const apiKey = requireEnv(env, "PRLL_API_KEY");
|
|
24
24
|
const orgId = requireEnv(env, "PRLL_ORG_ID");
|
|
25
25
|
const claudeHome = resolvePath(env.PRLL_CLAUDE_HOME?.trim() || env.HOME || os.homedir());
|
|
26
|
-
const stateDir = resolvePath(env.
|
|
27
|
-
const workspaceDir = resolvePath(env.
|
|
26
|
+
const stateDir = resolvePath(env.PRLL_STATE_DIR?.trim() || path.join(claudeHome, ".parall-agent"));
|
|
27
|
+
const workspaceDir = resolvePath(env.PRLL_WORKSPACE_DIR?.trim() || path.join(stateDir, "workspace"));
|
|
28
28
|
const additionalDirs = parseList(env.PRLL_CLAUDE_ADD_DIRS).map(resolvePath);
|
|
29
29
|
return {
|
|
30
30
|
apiUrl,
|
package/dist/dispatch.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export declare class ClaudeCodeAdapter implements DispatchAdapter {
|
|
|
35
35
|
getSessionHistoryPath(sessionKey: string): string | undefined;
|
|
36
36
|
forkSession({ sessionKey }: ForkOpts): import("@parall/agent-core").ForkSessionHandle | null;
|
|
37
37
|
cleanupFork({ fork }: CleanupForkOpts): void;
|
|
38
|
+
resetProcesses(): void;
|
|
38
39
|
shutdown(): Promise<void>;
|
|
39
40
|
private static readonly STEER_TURN_TIMEOUT_MS;
|
|
40
41
|
/**
|
package/dist/dispatch.d.ts.map
CHANGED
|
@@ -1 +1 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AQ,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,YAAY,GAAG,aAAa,CAAC,YAAY,CAAC;IAiCxG,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIvD,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAQ7D,WAAW,CAAC,EAAE,UAAU,EAAE,EAAE,QAAQ;IAIpC,WAAW,CAAC,EAAE,IAAI,EAAE,EAAE,eAAe;IAQrC,cAAc,IAAI,IAAI;IAQhB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAM/B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAAqB,CAAU;IAEvD;;;;;;;;;OASG;YACY,gBAAgB;YAsDhB,OAAO;IA2GtB,OAAO,CAAC,aAAa;IAyBrB,OAAO,CAAC,YAAY;IA+CpB,OAAO,CAAC,WAAW;IAkBnB,OAAO,CAAC,gBAAgB;IAWxB,OAAO,CAAC,SAAS;IAwCjB,OAAO,CAAC,uBAAuB;CAkBhC"}
|
package/dist/dispatch.js
CHANGED
|
@@ -139,12 +139,16 @@ export class ClaudeCodeAdapter {
|
|
|
139
139
|
}
|
|
140
140
|
this.opts.sessionManager.cleanupFork(fork.sessionKey);
|
|
141
141
|
}
|
|
142
|
-
|
|
143
|
-
this.shuttingDown = true;
|
|
142
|
+
resetProcesses() {
|
|
144
143
|
for (const [sessionKey, state] of this.processes) {
|
|
145
144
|
this.killProcess(sessionKey, state);
|
|
146
145
|
}
|
|
147
146
|
this.processes.clear();
|
|
147
|
+
this.pendingInjections.clear();
|
|
148
|
+
}
|
|
149
|
+
async shutdown() {
|
|
150
|
+
this.shuttingDown = true;
|
|
151
|
+
this.resetProcesses();
|
|
148
152
|
await this.opts.sessionManager.shutdownAll();
|
|
149
153
|
}
|
|
150
154
|
static STEER_TURN_TIMEOUT_MS = 10_000;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import * as os from "node:os";
|
|
3
|
-
import { ParallAgentGateway, createPlatformConfigManager, createLogger, childLogger, isPlatformManagedProfile, parseShutdownDeadlineMs } from "@parall/agent-core";
|
|
3
|
+
import { ParallAgentGateway, createPlatformConfigManager, createLogger, childLogger, isPlatformManagedProfile, parseShutdownDeadlineMs, parseProviderConfig, clearAllProviderCreds, llmSource } from "@parall/agent-core";
|
|
4
4
|
import { ApiError, ParallClient, ParallWs } from "@parall/sdk";
|
|
5
5
|
import { buildClaudeRuntimeKey, contextFilePathForSession, resolveClaudeAgentConfig, resolveWsUrl, sessionStateFilePathForRuntime, stepIdFilePathForSession, } from "./config.js";
|
|
6
6
|
import { ClaudeCodeAdapter } from "./dispatch.js";
|
|
@@ -20,7 +20,28 @@ async function getAgentMeWithLegacyFallback(client, orgId) {
|
|
|
20
20
|
return { ...user, agent_profile: null };
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
+
function resolveProviderEnv() {
|
|
24
|
+
const pc = parseProviderConfig(process.env);
|
|
25
|
+
if (!pc)
|
|
26
|
+
return;
|
|
27
|
+
clearAllProviderCreds(process.env);
|
|
28
|
+
const source = llmSource(pc);
|
|
29
|
+
if (source === "parall") {
|
|
30
|
+
process.env.ANTHROPIC_AUTH_TOKEN = process.env.PRLL_API_KEY;
|
|
31
|
+
process.env.ANTHROPIC_BASE_URL = `${process.env.PRLL_API_URL}/api/llm`;
|
|
32
|
+
process.env.PRLL_CLAUDE_ALLOW_API_KEY = "1";
|
|
33
|
+
}
|
|
34
|
+
else if (source === "custom") {
|
|
35
|
+
if (pc.anthropic_auth_token) {
|
|
36
|
+
process.env.ANTHROPIC_AUTH_TOKEN = pc.anthropic_auth_token;
|
|
37
|
+
process.env.PRLL_CLAUDE_ALLOW_API_KEY = "1";
|
|
38
|
+
}
|
|
39
|
+
if (pc.anthropic_base_url)
|
|
40
|
+
process.env.ANTHROPIC_BASE_URL = pc.anthropic_base_url;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
23
43
|
async function main() {
|
|
44
|
+
resolveProviderEnv();
|
|
24
45
|
const config = resolveClaudeAgentConfig(process.env);
|
|
25
46
|
if (config.allowApiKey &&
|
|
26
47
|
(process.env.ANTHROPIC_API_KEY || process.env.ANTHROPIC_AUTH_TOKEN)) {
|
|
@@ -137,7 +158,11 @@ async function main() {
|
|
|
137
158
|
onBeforeDisconnect: () => adapter.shutdown(),
|
|
138
159
|
onNewSession: async () => {
|
|
139
160
|
sessionManager.clearMainSession();
|
|
140
|
-
|
|
161
|
+
adapter.resetProcesses();
|
|
162
|
+
},
|
|
163
|
+
onSessionStale: () => {
|
|
164
|
+
sessionManager.clearMainSession();
|
|
165
|
+
adapter.resetProcesses();
|
|
141
166
|
},
|
|
142
167
|
});
|
|
143
168
|
const abortController = new AbortController();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parall/claude-agent",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.31.0",
|
|
4
4
|
"description": "Claude Code bridge runtime for self-hosted Parall agents",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"src"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@parall/
|
|
29
|
-
"@parall/cli": "1.
|
|
30
|
-
"@parall/
|
|
28
|
+
"@parall/sdk": "1.31.0",
|
|
29
|
+
"@parall/cli": "1.31.0",
|
|
30
|
+
"@parall/agent-core": "1.31.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^22.0.0",
|
package/src/config.ts
CHANGED
|
@@ -46,8 +46,8 @@ export function resolveClaudeAgentConfig(env: NodeJS.ProcessEnv = process.env):
|
|
|
46
46
|
const apiKey = requireEnv(env, "PRLL_API_KEY");
|
|
47
47
|
const orgId = requireEnv(env, "PRLL_ORG_ID");
|
|
48
48
|
const claudeHome = resolvePath(env.PRLL_CLAUDE_HOME?.trim() || env.HOME || os.homedir());
|
|
49
|
-
const stateDir = resolvePath(env.
|
|
50
|
-
const workspaceDir = resolvePath(env.
|
|
49
|
+
const stateDir = resolvePath(env.PRLL_STATE_DIR?.trim() || path.join(claudeHome, ".parall-agent"));
|
|
50
|
+
const workspaceDir = resolvePath(env.PRLL_WORKSPACE_DIR?.trim() || path.join(stateDir, "workspace"));
|
|
51
51
|
const additionalDirs = parseList(env.PRLL_CLAUDE_ADD_DIRS).map(resolvePath);
|
|
52
52
|
|
|
53
53
|
return {
|
package/src/dispatch.ts
CHANGED
|
@@ -203,12 +203,17 @@ export class ClaudeCodeAdapter implements DispatchAdapter {
|
|
|
203
203
|
this.opts.sessionManager.cleanupFork(fork.sessionKey);
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
|
|
207
|
-
this.shuttingDown = true;
|
|
206
|
+
resetProcesses(): void {
|
|
208
207
|
for (const [sessionKey, state] of this.processes) {
|
|
209
208
|
this.killProcess(sessionKey, state);
|
|
210
209
|
}
|
|
211
210
|
this.processes.clear();
|
|
211
|
+
this.pendingInjections.clear();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
async shutdown(): Promise<void> {
|
|
215
|
+
this.shuttingDown = true;
|
|
216
|
+
this.resetProcesses();
|
|
212
217
|
await this.opts.sessionManager.shutdownAll();
|
|
213
218
|
}
|
|
214
219
|
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import * as os from "node:os";
|
|
4
|
-
import { ParallAgentGateway, createPlatformConfigManager, createLogger, childLogger, isPlatformManagedProfile, parseShutdownDeadlineMs } from "@parall/agent-core";
|
|
4
|
+
import { ParallAgentGateway, createPlatformConfigManager, createLogger, childLogger, isPlatformManagedProfile, parseShutdownDeadlineMs, parseProviderConfig, clearAllProviderCreds, llmSource } from "@parall/agent-core";
|
|
5
5
|
import { ApiError, ParallClient, ParallWs } from "@parall/sdk";
|
|
6
6
|
import {
|
|
7
7
|
buildClaudeRuntimeKey,
|
|
@@ -30,7 +30,26 @@ async function getAgentMeWithLegacyFallback(client: ParallClient, orgId: string)
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
function resolveProviderEnv(): void {
|
|
34
|
+
const pc = parseProviderConfig(process.env);
|
|
35
|
+
if (!pc) return;
|
|
36
|
+
clearAllProviderCreds(process.env);
|
|
37
|
+
const source = llmSource(pc);
|
|
38
|
+
if (source === "parall") {
|
|
39
|
+
process.env.ANTHROPIC_AUTH_TOKEN = process.env.PRLL_API_KEY;
|
|
40
|
+
process.env.ANTHROPIC_BASE_URL = `${process.env.PRLL_API_URL}/api/llm`;
|
|
41
|
+
process.env.PRLL_CLAUDE_ALLOW_API_KEY = "1";
|
|
42
|
+
} else if (source === "custom") {
|
|
43
|
+
if (pc.anthropic_auth_token) {
|
|
44
|
+
process.env.ANTHROPIC_AUTH_TOKEN = pc.anthropic_auth_token;
|
|
45
|
+
process.env.PRLL_CLAUDE_ALLOW_API_KEY = "1";
|
|
46
|
+
}
|
|
47
|
+
if (pc.anthropic_base_url) process.env.ANTHROPIC_BASE_URL = pc.anthropic_base_url;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
33
51
|
async function main() {
|
|
52
|
+
resolveProviderEnv();
|
|
34
53
|
const config = resolveClaudeAgentConfig(process.env);
|
|
35
54
|
|
|
36
55
|
if (
|
|
@@ -160,7 +179,11 @@ async function main() {
|
|
|
160
179
|
onBeforeDisconnect: () => adapter.shutdown(),
|
|
161
180
|
onNewSession: async () => {
|
|
162
181
|
sessionManager.clearMainSession();
|
|
163
|
-
|
|
182
|
+
adapter.resetProcesses();
|
|
183
|
+
},
|
|
184
|
+
onSessionStale: () => {
|
|
185
|
+
sessionManager.clearMainSession();
|
|
186
|
+
adapter.resetProcesses();
|
|
164
187
|
},
|
|
165
188
|
});
|
|
166
189
|
|