@borgee/agents-host 0.2.29 → 0.2.32
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/README.md +82 -27
- package/dist/agents-host.d.ts +1 -1
- package/dist/agents-host.js +45 -18
- package/dist/cli-args.d.ts +3 -1
- package/dist/cli-args.js +18 -2
- package/dist/cli.d.ts +4 -0
- package/dist/cli.js +12 -1
- package/dist/compatibility-gates.js +4 -1
- package/dist/config.d.ts +8 -0
- package/dist/config.js +51 -13
- package/dist/context/prompt.js +1 -1
- package/dist/gateway/localhost-gateway.js +34 -2
- package/dist/index.js +4 -1
- package/dist/local-config.js +20 -1
- package/dist/managed-daemon.js +20 -6
- package/dist/policy/authorization-audit.d.ts +1 -0
- package/dist/policy/gateway-authorization.d.ts +1 -1
- package/dist/policy/gateway-authorization.js +27 -4
- package/dist/providers/claude/cli-client.d.ts +55 -16
- package/dist/providers/claude/cli-client.js +811 -345
- package/dist/providers/create-provider.js +8 -13
- package/dist/state-paths.d.ts +5 -0
- package/dist/state-paths.js +12 -0
- package/dist/types.d.ts +1 -0
- package/dist/update/package-installation.d.ts +52 -0
- package/dist/update/package-installation.js +90 -0
- package/dist/update/package-manager.d.ts +33 -0
- package/dist/update/package-manager.js +137 -0
- package/dist/update/semantic-version.d.ts +7 -0
- package/dist/update/semantic-version.js +76 -0
- package/dist/update/update-command.d.ts +9 -0
- package/dist/update/update-command.js +55 -0
- package/dist/update/update-notice.d.ts +39 -0
- package/dist/update/update-notice.js +161 -0
- package/package.json +5 -2
- package/skills/borgee-agent/SKILL.md +5 -3
- package/skills/borgee-agent/borgee-agent.mjs +56 -22
- package/skills/borgee-agent/borgee-agent.py +56 -27
|
@@ -505,6 +505,33 @@ class LoopbackLocalhostGatewayController {
|
|
|
505
505
|
this.recordAudit('authorized', 200, decision.path, request.method ?? 'GET', decision.binding);
|
|
506
506
|
return;
|
|
507
507
|
}
|
|
508
|
+
case 'task-history': {
|
|
509
|
+
// The thread this reads is the one the server recorded on the task: thread_id is
|
|
510
|
+
// written once by task creation and is not part of the task update whitelist, so no
|
|
511
|
+
// client can repoint an in-scope task at another channel's messages after the check.
|
|
512
|
+
const task = await this.loadAuthorizedTask(binding.channelId, decision.route);
|
|
513
|
+
if (!task.threadId) {
|
|
514
|
+
this.sendJson(response, 404, { error: 'not_found' });
|
|
515
|
+
this.recordAudit('not-found', 404, decision.path, request.method ?? 'GET', decision.binding);
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
const url = new URL(request.url ?? '/', baseUrl);
|
|
519
|
+
const limit = clampHistoryLimit(url.searchParams.get('limit'));
|
|
520
|
+
const before = parseOptionalInteger(url.searchParams.get('before'));
|
|
521
|
+
const after = parseOptionalInteger(url.searchParams.get('after'));
|
|
522
|
+
const messages = await this.controlPlane.readChannelHistory({
|
|
523
|
+
channelId: task.threadId,
|
|
524
|
+
before,
|
|
525
|
+
after,
|
|
526
|
+
limit,
|
|
527
|
+
});
|
|
528
|
+
this.sendJson(response, 200, { messages });
|
|
529
|
+
// Presence of `readChannelId` is the cross-channel disclosure signal, so it is
|
|
530
|
+
// stamped only when the thread really is another channel; a task read from inside
|
|
531
|
+
// its own thread would otherwise imply a disclosure that never happened.
|
|
532
|
+
this.recordAudit('authorized', 200, decision.path, request.method ?? 'GET', decision.binding, task.threadId === binding.channelId ? undefined : { readChannelId: task.threadId });
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
508
535
|
case 'users': {
|
|
509
536
|
if (!binding.payload?.localhostGateway?.collaboration?.enabled) {
|
|
510
537
|
this.sendJson(response, 404, { error: 'not_found' });
|
|
@@ -604,7 +631,7 @@ class LoopbackLocalhostGatewayController {
|
|
|
604
631
|
response.setHeader('content-type', 'application/json; charset=utf-8');
|
|
605
632
|
response.end(`${JSON.stringify(payload)}\n`);
|
|
606
633
|
}
|
|
607
|
-
recordAudit(reason, status, path, method, binding) {
|
|
634
|
+
recordAudit(reason, status, path, method, binding, readTarget) {
|
|
608
635
|
if (!this.policyAuditGateEnabled) {
|
|
609
636
|
return;
|
|
610
637
|
}
|
|
@@ -616,6 +643,7 @@ class LoopbackLocalhostGatewayController {
|
|
|
616
643
|
reason,
|
|
617
644
|
agentId: binding?.agentId,
|
|
618
645
|
channelId: binding?.channelId,
|
|
646
|
+
...readTarget,
|
|
619
647
|
method,
|
|
620
648
|
path,
|
|
621
649
|
status,
|
|
@@ -778,8 +806,12 @@ function parseUpdateTaskInput(taskId, body) {
|
|
|
778
806
|
status: readOptionalString(body.status),
|
|
779
807
|
assigneeId: readOptionalString(body.assigneeId) ?? readOptionalString(body.assignee_id),
|
|
780
808
|
title: readOptionalString(body.title),
|
|
809
|
+
description: readOptionalString(body.description),
|
|
781
810
|
};
|
|
782
|
-
if (input.status === undefined &&
|
|
811
|
+
if (input.status === undefined &&
|
|
812
|
+
input.assigneeId === undefined &&
|
|
813
|
+
input.title === undefined &&
|
|
814
|
+
input.description === undefined) {
|
|
783
815
|
throw new GatewayHttpError(400, { error: 'no_updates' }, 'bad-request');
|
|
784
816
|
}
|
|
785
817
|
return input;
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { resolveAgentsHostDebugMode } from './debug.js';
|
|
2
2
|
import { runMain } from './run.js';
|
|
3
|
+
import { emitUpdateNotice } from './update/update-notice.js';
|
|
3
4
|
// Plain env-var entry point (`pnpm dev` / `pnpm start`) for the standalone
|
|
4
5
|
// single-agent process. For the CLI entry point that accepts foreground
|
|
5
6
|
// `agents-host start <serverUrl> <apiKey> ...` and opt-in
|
|
6
7
|
// `agents-host start-managed <serverUrl>` / `agents-host start-managed <serverUrl> <apiKey> ...`,
|
|
7
8
|
// see cli.ts.
|
|
8
|
-
|
|
9
|
+
emitUpdateNotice({ env: process.env })
|
|
10
|
+
.then(() => runMain({ debug: resolveAgentsHostDebugMode(false, process.env) }))
|
|
11
|
+
.catch((error) => {
|
|
9
12
|
console.error('[agents-host] fatal error:', error);
|
|
10
13
|
process.exitCode = 1;
|
|
11
14
|
});
|
package/dist/local-config.js
CHANGED
|
@@ -2,7 +2,7 @@ import { promises as fs } from 'node:fs';
|
|
|
2
2
|
import { randomUUID } from 'node:crypto';
|
|
3
3
|
import { dirname, extname, isAbsolute, join, relative, resolve } from 'node:path';
|
|
4
4
|
import { parseDocument, stringify } from 'yaml';
|
|
5
|
-
import { assertProviderCompatibility, optionalNonEmptyString, optionalStringArray, parseCopilotSessionTtlMinutesValue, requireNonEmptyString, resolveProvider, resolveProviderCommandConfig, } from './config.js';
|
|
5
|
+
import { assertProviderCompatibility, assertProviderCommandCompatibility, optionalNonEmptyString, optionalStringArray, parseCopilotSessionTtlMinutesValue, requireNonEmptyString, resolveProvider, resolveProviderCommandConfig, } from './config.js';
|
|
6
6
|
import { resolveLocalConfigAgentStateRoot } from './state-paths.js';
|
|
7
7
|
const SUPPORTED_CONFIG_EXTENSIONS = new Set(['.json', '.yaml', '.yml']);
|
|
8
8
|
export const DEFAULT_LOCAL_HOST_CONFIG_FILENAME = 'agents-host.yaml';
|
|
@@ -186,6 +186,8 @@ export function parseGenerateConfigSpec(value, sourceLabel, env = process.env) {
|
|
|
186
186
|
throw new Error(`Invalid generate-config agents[${index}] in ${sourceLabel}: expected an object`);
|
|
187
187
|
}
|
|
188
188
|
const agent = parseAgentConfigFile(`generate-config agents[${index}] in ${sourceLabel}`, entry, env);
|
|
189
|
+
const providerConfig = resolveAgentProviderCommandConfig(host.defaults, agent);
|
|
190
|
+
assertProviderCommandCompatibility(agent.provider, providerConfig, `generate-config agents[${index}] in ${sourceLabel}`);
|
|
189
191
|
const existingIndex = seenKeys.get(agent.key);
|
|
190
192
|
if (existingIndex !== undefined) {
|
|
191
193
|
throw new Error(`Duplicate generate-config agent key "${agent.key}" in ${sourceLabel} at indexes ${existingIndex} and ${index}`);
|
|
@@ -598,6 +600,7 @@ function buildManagedAgentSnapshot(host, stateRootBaseDir, sourcePath, agent) {
|
|
|
598
600
|
...host.defaults,
|
|
599
601
|
...parseProviderCommandOverrides(agent, `agent config ${sourcePath}`),
|
|
600
602
|
});
|
|
603
|
+
assertProviderCommandCompatibility(agent.provider, providerConfig, `agent config ${sourcePath}`);
|
|
601
604
|
const config = {
|
|
602
605
|
borgeeBaseUrl: host.borgeeBaseUrl,
|
|
603
606
|
stateRootDir: resolveLocalConfigAgentStateRoot(stateRootBaseDir, agent.key),
|
|
@@ -614,6 +617,20 @@ function buildManagedAgentSnapshot(host, stateRootBaseDir, sourcePath, agent) {
|
|
|
614
617
|
config,
|
|
615
618
|
};
|
|
616
619
|
}
|
|
620
|
+
function resolveAgentProviderCommandConfig(hostDefaults, agent) {
|
|
621
|
+
return resolveProviderCommandConfig({
|
|
622
|
+
...hostDefaults,
|
|
623
|
+
...(agent.claudeCommand !== undefined ? { claudeCommand: agent.claudeCommand } : {}),
|
|
624
|
+
...(agent.claudeArgs !== undefined ? { claudeArgs: agent.claudeArgs } : {}),
|
|
625
|
+
...(agent.codexCommand !== undefined ? { codexCommand: agent.codexCommand } : {}),
|
|
626
|
+
...(agent.codexArgs !== undefined ? { codexArgs: agent.codexArgs } : {}),
|
|
627
|
+
...(agent.copilotCommand !== undefined ? { copilotCommand: agent.copilotCommand } : {}),
|
|
628
|
+
...(agent.copilotArgs !== undefined ? { copilotArgs: agent.copilotArgs } : {}),
|
|
629
|
+
...(agent.copilotSessionTtlMinutes !== undefined
|
|
630
|
+
? { copilotSessionTtlMinutes: agent.copilotSessionTtlMinutes }
|
|
631
|
+
: {}),
|
|
632
|
+
});
|
|
633
|
+
}
|
|
617
634
|
export async function loadLocalConfigSnapshot(hostConfigPath, deps = {}) {
|
|
618
635
|
const fileSystem = deps.fileSystem ?? nodeFileSystem;
|
|
619
636
|
const absoluteHostConfigPath = resolve(hostConfigPath);
|
|
@@ -698,6 +715,8 @@ export async function loadLocalConfigGenerateSpec(hostConfigPath, deps = {}) {
|
|
|
698
715
|
}
|
|
699
716
|
const agentRecord = await loadParsedDocument(fileSystem, agentFilePath, 'agent config');
|
|
700
717
|
const agentConfig = parseAgentConfigFile(agentFilePath, agentRecord, deps.env);
|
|
718
|
+
const providerConfig = resolveAgentProviderCommandConfig(hostConfig.defaults, agentConfig);
|
|
719
|
+
assertProviderCommandCompatibility(agentConfig.provider, providerConfig, `agent config ${agentFilePath}`);
|
|
701
720
|
const existingPath = seenKeys.get(agentConfig.key);
|
|
702
721
|
if (existingPath) {
|
|
703
722
|
throw new Error(`Duplicate agent key "${agentConfig.key}" in ${existingPath} and ${agentFilePath}`);
|
package/dist/managed-daemon.js
CHANGED
|
@@ -5,8 +5,8 @@ import { createConnection, createServer } from 'node:net';
|
|
|
5
5
|
import { dirname, join, resolve } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
import { AgentsHostSupervisor } from './agents-host-supervisor.js';
|
|
8
|
-
import { COMPATIBILITY_GATES_ENV, createManagedRuntimeSettingsFingerprint, INTERNAL_DISABLED_COMPATIBILITY_GATES_ENV, INTERNAL_POLICY_MODE_ENV, INTERNAL_PROVIDER_IMPLEMENTATIONS_ENV, MANAGED_RUNTIME_CONVERGENCE_COMPATIBILITY_GATE, MANAGED_RUNTIME_SETTINGS_SCHEMA_VERSION, resolveDisabledDefaultCompatibilityGates, resolveManagedRuntimeSettingsSnapshot, normalizeInternalProviderImplementationOverrides, } from './compatibility-gates.js';
|
|
9
|
-
import { loadConfigFromEnv } from './config.js';
|
|
8
|
+
import { CLAUDE_PROVIDER_V2_COMPATIBILITY_GATE, COMPATIBILITY_GATES_ENV, createManagedRuntimeSettingsFingerprint, INTERNAL_DISABLED_COMPATIBILITY_GATES_ENV, INTERNAL_POLICY_MODE_ENV, INTERNAL_PROVIDER_IMPLEMENTATIONS_ENV, MANAGED_RUNTIME_CONVERGENCE_COMPATIBILITY_GATE, MANAGED_RUNTIME_SETTINGS_SCHEMA_VERSION, resolveDisabledDefaultCompatibilityGates, resolveManagedRuntimeSettingsSnapshot, normalizeInternalProviderImplementationOverrides, } from './compatibility-gates.js';
|
|
9
|
+
import { DEFAULT_PROVIDER_COMMAND_CONFIG, hasLegacyClaudeOneShotArgs, loadConfigFromEnv, } from './config.js';
|
|
10
10
|
import { loadLocalConfigGenerateSpec, materializeLocalConfig, parseGenerateConfigSpec, resolveLocalConfigLayout, } from './local-config.js';
|
|
11
11
|
import { normalizeManagedRuntimeKey, resolveManagedBootstrapLockPath, resolveManagedDaemonLogPath, resolveManagedDaemonSocketPath, resolveManagedRuntimeRoot, resolveManagedRuntimeSettingsPath, } from './state-paths.js';
|
|
12
12
|
const MANAGED_ROOT_MODE = 0o700;
|
|
@@ -149,8 +149,9 @@ function resolveDesiredManagedRuntimeSettings(env = process.env) {
|
|
|
149
149
|
function normalizeManagedRuntimeSettingsSnapshot(snapshot) {
|
|
150
150
|
const compatibilityGates = [...new Set(snapshot.compatibilityGates.map((gate) => gate.trim()))]
|
|
151
151
|
.filter((gate) => gate.length > 0)
|
|
152
|
+
.filter((gate) => gate !== CLAUDE_PROVIDER_V2_COMPATIBILITY_GATE)
|
|
152
153
|
.sort((left, right) => left.localeCompare(right));
|
|
153
|
-
const providerImplementationOverrides = normalizeInternalProviderImplementationOverrides(snapshot.providerImplementationOverrides.join(','));
|
|
154
|
+
const providerImplementationOverrides = normalizeInternalProviderImplementationOverrides(snapshot.providerImplementationOverrides.join(',')).filter((assignment) => !assignment.startsWith('claude:'));
|
|
154
155
|
return {
|
|
155
156
|
schemaVersion: MANAGED_RUNTIME_SETTINGS_SCHEMA_VERSION,
|
|
156
157
|
compatibilityGates,
|
|
@@ -341,9 +342,18 @@ export function buildManagedLocalAgentConfig(options) {
|
|
|
341
342
|
},
|
|
342
343
|
};
|
|
343
344
|
}
|
|
344
|
-
function mergeManagedLocalAgentConfig(existingAgent, generatedAgent, envOverrides) {
|
|
345
|
+
function mergeManagedLocalAgentConfig(hostDefaults, existingAgent, generatedAgent, envOverrides) {
|
|
345
346
|
const overrides = envOverrides ?? {};
|
|
346
347
|
const hasOverride = (key) => Object.prototype.hasOwnProperty.call(overrides, key);
|
|
348
|
+
const effectiveExistingClaudeCommand = existingAgent.claudeCommand ?? hostDefaults?.claudeCommand;
|
|
349
|
+
const effectiveExistingClaudeArgs = existingAgent.claudeArgs ?? hostDefaults?.claudeArgs ?? [];
|
|
350
|
+
const hasLegacyClaudeDefaults = effectiveExistingClaudeCommand === 'claude' && hasLegacyClaudeOneShotArgs(effectiveExistingClaudeArgs);
|
|
351
|
+
const shouldRefreshLegacyClaudeDefaults = hasLegacyClaudeDefaults
|
|
352
|
+
&& generatedAgent.claudeCommand === DEFAULT_PROVIDER_COMMAND_CONFIG.claudeCommand
|
|
353
|
+
&& JSON.stringify(generatedAgent.claudeArgs ?? []) === JSON.stringify(DEFAULT_PROVIDER_COMMAND_CONFIG.claudeArgs);
|
|
354
|
+
const shouldResetLegacyClaudeArgsForCommandOverride = hasLegacyClaudeDefaults
|
|
355
|
+
&& hasOverride('CLAUDE_COMMAND')
|
|
356
|
+
&& !hasOverride('CLAUDE_ARGS');
|
|
347
357
|
return {
|
|
348
358
|
...cloneLocalAgentConfig(existingAgent),
|
|
349
359
|
key: generatedAgent.key,
|
|
@@ -351,8 +361,12 @@ function mergeManagedLocalAgentConfig(existingAgent, generatedAgent, envOverride
|
|
|
351
361
|
enabled: true,
|
|
352
362
|
name: hasOverride('BORGEE_AGENT_NAME') ? generatedAgent.name : existingAgent.name,
|
|
353
363
|
provider: hasOverride('RUNTIME_PROVIDER') ? generatedAgent.provider : existingAgent.provider,
|
|
354
|
-
claudeCommand: hasOverride('CLAUDE_COMMAND')
|
|
364
|
+
claudeCommand: hasOverride('CLAUDE_COMMAND') || shouldRefreshLegacyClaudeDefaults
|
|
365
|
+
? generatedAgent.claudeCommand
|
|
366
|
+
: existingAgent.claudeCommand,
|
|
355
367
|
claudeArgs: hasOverride('CLAUDE_ARGS')
|
|
368
|
+
|| shouldRefreshLegacyClaudeDefaults
|
|
369
|
+
|| shouldResetLegacyClaudeArgsForCommandOverride
|
|
356
370
|
? [...(generatedAgent.claudeArgs ?? [])]
|
|
357
371
|
: [...(existingAgent.claudeArgs ?? [])],
|
|
358
372
|
codexCommand: hasOverride('CODEX_COMMAND') ? generatedAgent.codexCommand : existingAgent.codexCommand,
|
|
@@ -1005,7 +1019,7 @@ export async function bootstrapManagedDaemonStart(options, deps = {}) {
|
|
|
1005
1019
|
return existingAgent
|
|
1006
1020
|
? {
|
|
1007
1021
|
...generatedManagedAgent,
|
|
1008
|
-
agent: mergeManagedLocalAgentConfig(existingAgent, generatedManagedAgent.agent, explicitManagedAgentOverrides),
|
|
1022
|
+
agent: mergeManagedLocalAgentConfig(currentManagedSpec?.host.defaults, existingAgent, generatedManagedAgent.agent, explicitManagedAgentOverrides),
|
|
1009
1023
|
}
|
|
1010
1024
|
: generatedManagedAgent;
|
|
1011
1025
|
})();
|
|
@@ -16,6 +16,20 @@ export function parseBearerToken(value) {
|
|
|
16
16
|
const token = trimmed.slice(prefix.length);
|
|
17
17
|
return token.length > 0 && !/\s/.test(token) ? token : null;
|
|
18
18
|
}
|
|
19
|
+
// A segment carrying a malformed percent-escape names neither a channel nor a task, so it
|
|
20
|
+
// is not a route match. Decoding it unguarded would instead throw out of the routing step,
|
|
21
|
+
// which runs before the request handler's error mapping and would answer an unaudited 500.
|
|
22
|
+
function decodePathSegment(segment) {
|
|
23
|
+
if (segment == null) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
return decodeURIComponent(segment);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
19
33
|
export function matchChannelRoute(pathname, allowCollaborationRoutes = false) {
|
|
20
34
|
const resources = allowCollaborationRoutes
|
|
21
35
|
? '(bootstrap|me|history|draft|users|messages|tasks|current-task)'
|
|
@@ -24,19 +38,27 @@ export function matchChannelRoute(pathname, allowCollaborationRoutes = false) {
|
|
|
24
38
|
if (!match) {
|
|
25
39
|
return null;
|
|
26
40
|
}
|
|
41
|
+
const channelId = decodePathSegment(match[1]);
|
|
42
|
+
if (channelId == null) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
27
45
|
return {
|
|
28
|
-
channelId
|
|
46
|
+
channelId,
|
|
29
47
|
resource: match[2],
|
|
30
48
|
};
|
|
31
49
|
}
|
|
32
50
|
export function matchTaskRoute(pathname) {
|
|
33
|
-
const match = /^\/v1\/tasks\/([^/]+)
|
|
51
|
+
const match = /^\/v1\/tasks\/([^/]+)(\/history)?$/.exec(pathname);
|
|
34
52
|
if (!match) {
|
|
35
53
|
return null;
|
|
36
54
|
}
|
|
55
|
+
const taskId = decodePathSegment(match[1]);
|
|
56
|
+
if (taskId == null) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
37
59
|
return {
|
|
38
|
-
taskId
|
|
39
|
-
resource: 'task',
|
|
60
|
+
taskId,
|
|
61
|
+
resource: match[2] ? 'task-history' : 'task',
|
|
40
62
|
};
|
|
41
63
|
}
|
|
42
64
|
function allowedMethodsForRoute(route, collaborationRoutesEnabled) {
|
|
@@ -47,6 +69,7 @@ function allowedMethodsForRoute(route, collaborationRoutesEnabled) {
|
|
|
47
69
|
case 'history':
|
|
48
70
|
case 'draft':
|
|
49
71
|
case 'users':
|
|
72
|
+
case 'task-history':
|
|
50
73
|
return ['GET'];
|
|
51
74
|
case 'messages':
|
|
52
75
|
return collaborationRoutesEnabled ? ['POST'] : [];
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import spawn from 'cross-spawn';
|
|
2
|
+
import { PROTOCOL_VERSION, client, methods, ndJsonStream } from '@agentclientprotocol/sdk';
|
|
2
3
|
import { type DebugLogger } from '../../debug.js';
|
|
3
4
|
import type { PreparedProviderTurnInput, ProviderGenerateOptions } from '../../types.js';
|
|
4
5
|
import type { ClaudeChannelSessionStore } from './session-store.js';
|
|
5
|
-
interface
|
|
6
|
+
interface ClaudeAcpRuntime {
|
|
6
7
|
spawn: typeof spawn;
|
|
8
|
+
client: typeof client;
|
|
9
|
+
ndJsonStream: typeof ndJsonStream;
|
|
10
|
+
methods: typeof methods;
|
|
11
|
+
protocolVersion: typeof PROTOCOL_VERSION;
|
|
7
12
|
cwd: string;
|
|
13
|
+
shutdownGracePeriodMs: number;
|
|
14
|
+
shutdownForceKillWaitMs: number;
|
|
8
15
|
}
|
|
9
16
|
/**
|
|
10
|
-
*
|
|
11
|
-
* native provider-session continuity.
|
|
17
|
+
* Persistent ACP-backed client for the Claude ACP adapter.
|
|
12
18
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
19
|
+
* The public caller surface intentionally stays stable: callers still create a
|
|
20
|
+
* `ClaudeCliClient`, then call `generateReply()` and `dispose()`. Internally,
|
|
21
|
+
* the shipped runtime now runs one Claude ACP adapter process and reuses one
|
|
22
|
+
* ACP session per routed Borgee channel.
|
|
17
23
|
*/
|
|
18
24
|
export declare class ClaudeCliClient {
|
|
19
25
|
private readonly command;
|
|
@@ -24,28 +30,61 @@ export declare class ClaudeCliClient {
|
|
|
24
30
|
private readonly runtime;
|
|
25
31
|
private readonly channels;
|
|
26
32
|
private readonly persistedSessions;
|
|
33
|
+
private readonly closingSessions;
|
|
34
|
+
private readonly pendingSessionStarts;
|
|
35
|
+
private readonly pendingSessionCloses;
|
|
36
|
+
private readonly pendingSessionStoreOperations;
|
|
37
|
+
private readonly fatalPromise;
|
|
38
|
+
private rejectFatalPromise;
|
|
39
|
+
private child?;
|
|
40
|
+
private connection?;
|
|
41
|
+
private startPromise?;
|
|
42
|
+
private shutdownPromise?;
|
|
43
|
+
private childExitPromise?;
|
|
44
|
+
private resolveChildExit?;
|
|
45
|
+
private fatalError;
|
|
46
|
+
private disposing;
|
|
47
|
+
private backendClosed;
|
|
27
48
|
private loadedSessionStoreAgentId;
|
|
28
|
-
private stopped;
|
|
29
49
|
private sessionStoreLoadPromise;
|
|
30
50
|
private sessionStoreWriteQueue;
|
|
31
|
-
|
|
51
|
+
private sessionCapabilities;
|
|
52
|
+
private childStderr;
|
|
53
|
+
constructor(command: string, args?: string[], runtimeOverrides?: Partial<ClaudeAcpRuntime>, sessionStore?: ClaudeChannelSessionStore | undefined, resolveSessionStoreAgentId?: () => string | undefined, logger?: DebugLogger);
|
|
32
54
|
generateReply(turn: PreparedProviderTurnInput, options?: ProviderGenerateOptions): Promise<string>;
|
|
33
55
|
generateReply(channelId: string, prompt: string, options?: ProviderGenerateOptions): Promise<string>;
|
|
34
56
|
dispose(): Promise<void>;
|
|
57
|
+
private ensureStarted;
|
|
58
|
+
private startBackend;
|
|
35
59
|
private getOrCreateChannelState;
|
|
36
60
|
private processChannelQueue;
|
|
61
|
+
private getOrCreateSession;
|
|
62
|
+
private startFreshSession;
|
|
63
|
+
private restoreOrCreateSession;
|
|
64
|
+
private restoreSession;
|
|
65
|
+
private clearBufferedSessionReplay;
|
|
66
|
+
private resolveSessionCwd;
|
|
67
|
+
private recycleSessionIfScopeChanged;
|
|
37
68
|
private runTurn;
|
|
38
|
-
private
|
|
69
|
+
private raceWithFatal;
|
|
70
|
+
private failAll;
|
|
71
|
+
private handlePermissionRequest;
|
|
72
|
+
private invalidateSession;
|
|
73
|
+
private closeSession;
|
|
74
|
+
private rejectQueuedTurnsAfterSessionTaint;
|
|
75
|
+
private findChannelIdBySessionId;
|
|
39
76
|
private currentSessionStoreAgentId;
|
|
40
77
|
private ensureSessionStoreLoaded;
|
|
41
|
-
private
|
|
78
|
+
private readPersistedSessionId;
|
|
42
79
|
private persistSession;
|
|
43
80
|
private persistSessionBestEffort;
|
|
44
|
-
private
|
|
45
|
-
private
|
|
46
|
-
private resetSessionIfCwdChanged;
|
|
47
|
-
private resetPersistedSessionBestEffort;
|
|
81
|
+
private clearPersistedSession;
|
|
82
|
+
private clearPersistedSessionBestEffort;
|
|
48
83
|
private enqueueSessionStoreWrite;
|
|
49
|
-
private
|
|
84
|
+
private trackSessionStoreOperation;
|
|
85
|
+
private shutdownBackend;
|
|
86
|
+
private waitForPendingSessionStarts;
|
|
87
|
+
private waitForPendingSessionCloses;
|
|
88
|
+
private waitForChildExit;
|
|
50
89
|
}
|
|
51
90
|
export {};
|