@borgee/agents-host 0.2.65 → 0.2.68
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.
|
@@ -25,12 +25,14 @@ export type InternalPolicyMode = 'audit-only' | 'enforce';
|
|
|
25
25
|
export type InternalProviderImplementationPath = 'v1' | 'v2';
|
|
26
26
|
export type InternalProviderImplementationKey = 'claude' | 'copilot';
|
|
27
27
|
export type InternalProviderImplementationOverrides = Partial<Record<InternalProviderImplementationKey, InternalProviderImplementationPath>>;
|
|
28
|
+
export declare const CURRENT_AGENTS_HOST_PACKAGE_VERSION: string;
|
|
28
29
|
export interface ManagedRuntimeSettingsSnapshot {
|
|
29
30
|
schemaVersion: number;
|
|
30
31
|
compatibilityGates: string[];
|
|
31
32
|
providerImplementationOverrides: string[];
|
|
32
33
|
internalPolicyMode: InternalPolicyMode;
|
|
33
34
|
projectionStrategy: ProjectionStrategy;
|
|
35
|
+
packageVersion: string;
|
|
34
36
|
}
|
|
35
37
|
export declare const DEFAULT_INTERNAL_COMPATIBILITY_GATES: readonly string[];
|
|
36
38
|
export declare function resolveInternalProjectionStrategy(env?: NodeJS.ProcessEnv): ProjectionStrategy;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
2
5
|
import { DEFAULT_PROJECTION_STRATEGY, normalizeProjectionStrategy, } from './projection-strategy-values.js';
|
|
3
6
|
export const CLAUDE_PROVIDER_V2_COMPATIBILITY_GATE = 'claude-provider-v2';
|
|
4
7
|
export const COPILOT_PROVIDER_V2_COMPATIBILITY_GATE = 'copilot-provider-v2';
|
|
@@ -22,6 +25,15 @@ export const INTERNAL_POLICY_MODE_ENV = 'AGENTS_HOST_INTERNAL_POLICY_MODE';
|
|
|
22
25
|
export const INTERNAL_PROVIDER_IMPLEMENTATIONS_ENV = 'AGENTS_HOST_INTERNAL_PROVIDER_IMPLEMENTATIONS';
|
|
23
26
|
export const INTERNAL_CLAUDE_PROMPT_STRATEGY_ENV = 'AGENTS_HOST_INTERNAL_CLAUDE_PROMPT_STRATEGY';
|
|
24
27
|
export const MANAGED_RUNTIME_SETTINGS_SCHEMA_VERSION = 1;
|
|
28
|
+
function readCurrentAgentsHostPackageVersion() {
|
|
29
|
+
const packageManifestPath = join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json');
|
|
30
|
+
const manifest = JSON.parse(readFileSync(packageManifestPath, 'utf8'));
|
|
31
|
+
if (typeof manifest.version !== 'string' || manifest.version.length === 0) {
|
|
32
|
+
throw new Error(`Unable to resolve agents-host package version from ${packageManifestPath}`);
|
|
33
|
+
}
|
|
34
|
+
return manifest.version;
|
|
35
|
+
}
|
|
36
|
+
export const CURRENT_AGENTS_HOST_PACKAGE_VERSION = readCurrentAgentsHostPackageVersion();
|
|
25
37
|
const VALID_PROVIDER_IMPLEMENTATION_ENTRIES = '"claude:v1", "claude:v2", "copilot:v1", or "copilot:v2"';
|
|
26
38
|
export const DEFAULT_INTERNAL_COMPATIBILITY_GATES = Object.freeze([
|
|
27
39
|
ATTENTION_FOLLOW_SEMANTICS_COMPATIBILITY_GATE,
|
|
@@ -176,6 +188,7 @@ export function resolveManagedRuntimeSettingsSnapshot(env = process.env) {
|
|
|
176
188
|
providerImplementationOverrides: resolveManagedRuntimeProviderImplementationOverrides(env, compatibilityGates),
|
|
177
189
|
internalPolicyMode: resolveInternalPolicyMode(compatibilityGates.includes(POLICY_AUDIT_ENFORCEMENT_COMPATIBILITY_GATE), env),
|
|
178
190
|
projectionStrategy: resolveInternalProjectionStrategy(env),
|
|
191
|
+
packageVersion: CURRENT_AGENTS_HOST_PACKAGE_VERSION,
|
|
179
192
|
};
|
|
180
193
|
}
|
|
181
194
|
export function serializeManagedRuntimeSettingsSnapshot(snapshot) {
|
package/dist/context/prompt.js
CHANGED
|
@@ -565,9 +565,7 @@ function buildClaudeZeroTurnPrompt(params) {
|
|
|
565
565
|
}
|
|
566
566
|
const gatewayTaskLines = buildClaudeOrdinaryGatewayTaskLines(params.promptContext);
|
|
567
567
|
return [
|
|
568
|
-
'Do not claim to have performed actions you did not actually perform.',
|
|
569
568
|
...(gatewayTaskLines.length > 0 ? [...gatewayTaskLines, ''] : []),
|
|
570
|
-
`New message from ${params.incomingAuthorId}:`,
|
|
571
569
|
params.incomingContent,
|
|
572
570
|
].join('\n');
|
|
573
571
|
}
|
package/dist/managed-daemon.js
CHANGED
|
@@ -7,7 +7,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
7
7
|
import { AgentsHostSupervisor } from './agents-host-supervisor.js';
|
|
8
8
|
import { DEFAULT_PROJECTION_STRATEGY, normalizeProjectionStrategy, } from './projection-strategy-values.js';
|
|
9
9
|
import { resolveChannelWorkspaceDirectory, resolveChannelWorkspaceRootDirectory, resolveManagedWorkspaceCollectionRoot, resolveTaskThreadScratchWorkspaceDirectory, } from './context/injection.js';
|
|
10
|
-
import { CLAUDE_PROVIDER_V2_COMPATIBILITY_GATE, COMPATIBILITY_GATES_ENV, createManagedRuntimeSettingsFingerprint, INTERNAL_CLAUDE_PROMPT_STRATEGY_ENV, 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, serializeManagedRuntimeSettingsSnapshot, normalizeInternalProviderImplementationOverrides, } from './compatibility-gates.js';
|
|
10
|
+
import { CLAUDE_PROVIDER_V2_COMPATIBILITY_GATE, COMPATIBILITY_GATES_ENV, CURRENT_AGENTS_HOST_PACKAGE_VERSION, createManagedRuntimeSettingsFingerprint, INTERNAL_CLAUDE_PROMPT_STRATEGY_ENV, 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, serializeManagedRuntimeSettingsSnapshot, normalizeInternalProviderImplementationOverrides, } from './compatibility-gates.js';
|
|
11
11
|
import { DEFAULT_PROVIDER_COMMAND_CONFIG, hasLegacyClaudeOneShotArgs, loadConfigFromEnv, } from './config.js';
|
|
12
12
|
import { loadLocalConfigGenerateSpec, materializeLocalConfig, parseGenerateConfigSpec, resolveLocalConfigLayout, } from './local-config.js';
|
|
13
13
|
import { normalizeManagedRuntimeKey, resolveManagedBootstrapLockPath, resolveManagedDaemonEndpoint, resolveManagedDaemonLogPath, resolveManagedRuntimeRoot, resolveManagedStateRoot, resolveManagedRuntimeSettingsPath, } from './state-paths.js';
|
|
@@ -163,6 +163,7 @@ function normalizeManagedRuntimeSettingsSnapshot(snapshot) {
|
|
|
163
163
|
providerImplementationOverrides,
|
|
164
164
|
internalPolicyMode: snapshot.internalPolicyMode,
|
|
165
165
|
projectionStrategy: snapshot.projectionStrategy ?? DEFAULT_PROJECTION_STRATEGY,
|
|
166
|
+
packageVersion: CURRENT_AGENTS_HOST_PACKAGE_VERSION,
|
|
166
167
|
};
|
|
167
168
|
}
|
|
168
169
|
function parseManagedRuntimeSettingsSnapshotRecord(value, sourceLabel) {
|
|
@@ -197,6 +198,9 @@ function parseManagedRuntimeSettingsSnapshotRecord(value, sourceLabel) {
|
|
|
197
198
|
providerImplementationOverrides: [...record.providerImplementationOverrides],
|
|
198
199
|
internalPolicyMode: record.internalPolicyMode,
|
|
199
200
|
projectionStrategy: projectionStrategy ?? DEFAULT_PROJECTION_STRATEGY,
|
|
201
|
+
packageVersion: typeof record.packageVersion === 'string' && record.packageVersion.trim().length > 0
|
|
202
|
+
? record.packageVersion
|
|
203
|
+
: CURRENT_AGENTS_HOST_PACKAGE_VERSION,
|
|
200
204
|
});
|
|
201
205
|
}
|
|
202
206
|
async function loadManagedRuntimeSettingsSnapshot(rootPath) {
|
package/dist/plugin-sdk.js
CHANGED
|
@@ -3777,7 +3777,6 @@ var BppTransport = class {
|
|
|
3777
3777
|
// send issued during a reconnect never races ahead of the handshake.
|
|
3778
3778
|
online = false;
|
|
3779
3779
|
terminal = false;
|
|
3780
|
-
inboundFailed = false;
|
|
3781
3780
|
inboundChain = Promise.resolve();
|
|
3782
3781
|
configChain = Promise.resolve();
|
|
3783
3782
|
configAcks = /* @__PURE__ */ new Map();
|
|
@@ -3941,8 +3940,15 @@ var BppTransport = class {
|
|
|
3941
3940
|
}
|
|
3942
3941
|
});
|
|
3943
3942
|
ws.on("close", (code, reason) => {
|
|
3943
|
+
const closeReason = reason?.toString("utf8") ?? "";
|
|
3944
3944
|
connectionAbort.abort();
|
|
3945
3945
|
const wasCurrent = this.ws === ws;
|
|
3946
|
+
const closeSummary = `code=${code} reason=${closeReason || "<none>"} current=${wasCurrent}`;
|
|
3947
|
+
if (code === 1e3 || this.closed) {
|
|
3948
|
+
this.logger?.info("bpp.ws_closed", closeSummary);
|
|
3949
|
+
} else {
|
|
3950
|
+
this.logger?.warn("bpp.ws_closed", closeSummary);
|
|
3951
|
+
}
|
|
3946
3952
|
if (wasCurrent) {
|
|
3947
3953
|
this.online = false;
|
|
3948
3954
|
this.stopHeartbeat();
|
|
@@ -3952,7 +3958,7 @@ var BppTransport = class {
|
|
|
3952
3958
|
if (authFailed && wasCurrent) {
|
|
3953
3959
|
this.closed = true;
|
|
3954
3960
|
this.terminal = true;
|
|
3955
|
-
this.logger?.error("bpp.auth_failed", `server closed with ${WS_CLOSE_AUTH_FAILED} (authentication failed); not reconnecting. reason=${
|
|
3961
|
+
this.logger?.error("bpp.auth_failed", `server closed with ${WS_CLOSE_AUTH_FAILED} (authentication failed); not reconnecting. reason=${closeReason}`);
|
|
3956
3962
|
this.handlers?.onStateChange({ status: "error", reason: "api_key_invalid" });
|
|
3957
3963
|
}
|
|
3958
3964
|
if (wasCurrent) {
|
|
@@ -3998,6 +4004,7 @@ var BppTransport = class {
|
|
|
3998
4004
|
}
|
|
3999
4005
|
this.startHeartbeat();
|
|
4000
4006
|
this.goOnline(ws);
|
|
4007
|
+
this.logger?.info("bpp.connected");
|
|
4001
4008
|
resolve();
|
|
4002
4009
|
} catch (error) {
|
|
4003
4010
|
const failure = error instanceof BorgeeError ? error : new BorgeeError(`agent identity handshake failed: ${String(error)}`, "bpp.identity_unresolved");
|
|
@@ -4011,6 +4018,7 @@ var BppTransport = class {
|
|
|
4011
4018
|
this.reconnectAttempt += 1;
|
|
4012
4019
|
const delay = Math.min(this.reconnectBaseMs * 2 ** (this.reconnectAttempt - 1), this.reconnectMaxMs);
|
|
4013
4020
|
this.handlers?.onStateChange({ status: "reconnecting", attempt: this.reconnectAttempt });
|
|
4021
|
+
this.logger?.info("bpp.reconnect_scheduled", `attempt=${this.reconnectAttempt} delay_ms=${delay}`);
|
|
4014
4022
|
this.reconnectTimer = setTimeout(() => {
|
|
4015
4023
|
this.reconnectTimer = void 0;
|
|
4016
4024
|
if (this.closed)
|
|
@@ -4080,12 +4088,11 @@ var BppTransport = class {
|
|
|
4080
4088
|
}
|
|
4081
4089
|
handleInbound(frame) {
|
|
4082
4090
|
this.inboundChain = this.inboundChain.then(() => {
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
this.failTerminal(this.inboundFailure(error), this.ws);
|
|
4091
|
+
try {
|
|
4092
|
+
this.handlers?.onInbound(mapInbound(frame));
|
|
4093
|
+
} catch (error) {
|
|
4094
|
+
this.logger?.error("bpp.inbound_dispatch_failed", this.inboundFailure(error));
|
|
4095
|
+
}
|
|
4089
4096
|
});
|
|
4090
4097
|
}
|
|
4091
4098
|
handleActionResult(frame) {
|
|
@@ -4380,6 +4387,7 @@ var BppTransport = class {
|
|
|
4380
4387
|
failTerminal(error, ws) {
|
|
4381
4388
|
if (this.terminal)
|
|
4382
4389
|
return;
|
|
4390
|
+
this.logger?.error("bpp.terminal_failure", error);
|
|
4383
4391
|
this.terminal = true;
|
|
4384
4392
|
this.online = false;
|
|
4385
4393
|
this.handlers?.onStateChange({ status: "error", reason: "unknown", code: error.code });
|
|
@@ -5051,8 +5059,13 @@ var Client = class {
|
|
|
5051
5059
|
this.t.setStopTurnHandler?.(handler);
|
|
5052
5060
|
}
|
|
5053
5061
|
emit(event, payload) {
|
|
5054
|
-
for (const h of this.listeners[event])
|
|
5055
|
-
|
|
5062
|
+
for (const h of this.listeners[event]) {
|
|
5063
|
+
try {
|
|
5064
|
+
h(payload);
|
|
5065
|
+
} catch (error) {
|
|
5066
|
+
this.logger.error("client.observer_failed", { event, error });
|
|
5067
|
+
}
|
|
5068
|
+
}
|
|
5056
5069
|
}
|
|
5057
5070
|
handlers() {
|
|
5058
5071
|
return {
|