@borgee/agents-host 0.2.65 → 0.2.73
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/compatibility-gates.d.ts +2 -0
- package/dist/compatibility-gates.js +13 -0
- package/dist/context/claude-file-brief.js +2 -1
- package/dist/context/prompt.js +4 -3
- package/dist/context/task-channel-boundary.d.ts +1 -0
- package/dist/context/task-channel-boundary.js +5 -0
- package/dist/managed-daemon.js +5 -1
- package/dist/plugin-sdk.js +113 -16
- package/dist/plugin-sdk.js.map +2 -2
- package/package.json +2 -2
- package/skills/borgee-agent/SKILL.md +2 -0
|
@@ -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) {
|
|
@@ -2,6 +2,7 @@ import { buildCollaborationCapabilityDeclarationSummaryLines, } from './collabor
|
|
|
2
2
|
import { MAIN_SESSION_DELEGATION_LINES } from './main-session-delegation.js';
|
|
3
3
|
import { buildResolvedWorkspaceGuidanceLines } from './resolved-workspace.js';
|
|
4
4
|
import { buildSkillManualLines, buildSkillManualReadLine } from './skill-manual.js';
|
|
5
|
+
import { PARENT_CHANNEL_TASK_BOUNDARY_LINES } from './task-channel-boundary.js';
|
|
5
6
|
function buildStableSkillLines(context) {
|
|
6
7
|
if (!context?.skillRuntime) {
|
|
7
8
|
return [];
|
|
@@ -16,7 +17,7 @@ function buildStableGatewayLines(context) {
|
|
|
16
17
|
}
|
|
17
18
|
const lines = [`Gateway credential file: ${context.gatewayCredentialPath}`];
|
|
18
19
|
if (context.runtimeSurface?.task.currentThread === 'parent-channel') {
|
|
19
|
-
lines.push('This channel is a parent channel, not a task thread.', 'For parent-channel task operations, use the packaged borgee-agent task rail through this gateway credential file.', 'Do not invent a bare task or bare borgee command.');
|
|
20
|
+
lines.push('This channel is a parent channel, not a task thread.', ...PARENT_CHANNEL_TASK_BOUNDARY_LINES, 'For parent-channel task operations, use the packaged borgee-agent task rail through this gateway credential file.', 'Do not invent a bare task or bare borgee command.');
|
|
20
21
|
if (context.runtimeSurface.task.currentTaskShorthand === 'requires-task-id') {
|
|
21
22
|
lines.push('In this parent channel, task get, task update, task history, and task property commands require an explicit task id.');
|
|
22
23
|
}
|
package/dist/context/prompt.js
CHANGED
|
@@ -6,6 +6,7 @@ import { buildCollaborationOutcomeSummaryLines } from './collaboration-outcome.j
|
|
|
6
6
|
import { MAIN_SESSION_DELEGATION_LINES } from './main-session-delegation.js';
|
|
7
7
|
import { buildResolvedWorkspaceGuidanceLines } from './resolved-workspace.js';
|
|
8
8
|
import { buildSkillManualLines, buildSkillManualReadLine } from './skill-manual.js';
|
|
9
|
+
import { PARENT_CHANNEL_TASK_BOUNDARY_LINES } from './task-channel-boundary.js';
|
|
9
10
|
import { buildTaskThreadCollaborationSummaryLines } from './task-thread-collaboration.js';
|
|
10
11
|
function providerLabel(provider) {
|
|
11
12
|
if (provider === 'copilot') {
|
|
@@ -46,6 +47,7 @@ function buildLocalhostGatewayPromptLines(context) {
|
|
|
46
47
|
: 'This turn runs in a parent channel, not a task thread.');
|
|
47
48
|
if (context.runtimeSurface?.task.currentThread === 'parent-channel'
|
|
48
49
|
&& (context.collaborationTurnMode ?? 'ordinary') === 'ordinary') {
|
|
50
|
+
lines.push(...PARENT_CHANNEL_TASK_BOUNDARY_LINES);
|
|
49
51
|
if (context.runtimeSurface.task.parentChannelTaskCollection === 'available') {
|
|
50
52
|
lines.push('Task list and task create are available in this parent channel.');
|
|
51
53
|
lines.push(`For parent-channel task operations on this turn, read the packaged borgee-agent manual at ${context.skillRuntime.skillMarkdownPath} and follow that command grammar exactly.`);
|
|
@@ -132,6 +134,7 @@ function buildClaudeOrdinaryGatewayTaskLines(context) {
|
|
|
132
134
|
const lines = [
|
|
133
135
|
`Gateway credential file for this turn: ${context.gatewayCredentialPath}`,
|
|
134
136
|
'This turn runs in a parent channel, not a task thread.',
|
|
137
|
+
...PARENT_CHANNEL_TASK_BOUNDARY_LINES,
|
|
135
138
|
'Task list and task create are available in this parent channel.',
|
|
136
139
|
`For parent-channel task operations on this turn, read the packaged borgee-agent manual at ${context.skillRuntime.skillMarkdownPath} and follow that command grammar exactly.`,
|
|
137
140
|
'For task creation and task updates in this parent channel, use the packaged borgee-agent task rail through this gateway credential file.',
|
|
@@ -169,7 +172,7 @@ function buildClaudeProjectedBriefTurnDeltaLines(context) {
|
|
|
169
172
|
lines.push(...taskLines);
|
|
170
173
|
}
|
|
171
174
|
else {
|
|
172
|
-
lines.push(`Gateway credential file for this turn: ${context.gatewayCredentialPath}`, 'This turn runs in a parent channel, not a task thread.');
|
|
175
|
+
lines.push(`Gateway credential file for this turn: ${context.gatewayCredentialPath}`, 'This turn runs in a parent channel, not a task thread.', ...PARENT_CHANNEL_TASK_BOUNDARY_LINES);
|
|
173
176
|
if (context.runtimeSurface.task.parentChannelTaskCollection === 'available') {
|
|
174
177
|
lines.push('Task list and task create are available in this parent channel.');
|
|
175
178
|
}
|
|
@@ -565,9 +568,7 @@ function buildClaudeZeroTurnPrompt(params) {
|
|
|
565
568
|
}
|
|
566
569
|
const gatewayTaskLines = buildClaudeOrdinaryGatewayTaskLines(params.promptContext);
|
|
567
570
|
return [
|
|
568
|
-
'Do not claim to have performed actions you did not actually perform.',
|
|
569
571
|
...(gatewayTaskLines.length > 0 ? [...gatewayTaskLines, ''] : []),
|
|
570
|
-
`New message from ${params.incomingAuthorId}:`,
|
|
571
572
|
params.incomingContent,
|
|
572
573
|
].join('\n');
|
|
573
574
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PARENT_CHANNEL_TASK_BOUNDARY_LINES: readonly ["This parent channel is limited to creating and assigning tasks, coordinating them, and giving brief confirmations.", "After a task is created and assigned, do not start or continue its implementation, tool calls, or work progress in this parent channel; leave that work to the assigned task thread.", "Never work on the same task in the parent channel and its task thread at the same time."];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export const PARENT_CHANNEL_TASK_BOUNDARY_LINES = [
|
|
2
|
+
'This parent channel is limited to creating and assigning tasks, coordinating them, and giving brief confirmations.',
|
|
3
|
+
'After a task is created and assigned, do not start or continue its implementation, tool calls, or work progress in this parent channel; leave that work to the assigned task thread.',
|
|
4
|
+
'Never work on the same task in the parent channel and its task thread at the same time.',
|
|
5
|
+
];
|
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();
|
|
@@ -3815,6 +3814,47 @@ var BppTransport = class {
|
|
|
3815
3814
|
getResolvedAgentId() {
|
|
3816
3815
|
return this.currentAgentId();
|
|
3817
3816
|
}
|
|
3817
|
+
/** Fire-and-forget metadata-only lifecycle rail. Callers durably retry until ACK. */
|
|
3818
|
+
sendExecutionTelemetry(frame) {
|
|
3819
|
+
const base = {
|
|
3820
|
+
agent_id: this.currentAgentId(),
|
|
3821
|
+
execution_id: frame.executionId,
|
|
3822
|
+
telemetry_context: frame.telemetryContext,
|
|
3823
|
+
event_id: frame.eventId
|
|
3824
|
+
};
|
|
3825
|
+
switch (frame.type) {
|
|
3826
|
+
case "execution_started":
|
|
3827
|
+
this.send({
|
|
3828
|
+
type: frame.type,
|
|
3829
|
+
...base,
|
|
3830
|
+
started_at: frame.startedAt
|
|
3831
|
+
});
|
|
3832
|
+
break;
|
|
3833
|
+
case "execution_usage":
|
|
3834
|
+
this.send({
|
|
3835
|
+
type: frame.type,
|
|
3836
|
+
...base,
|
|
3837
|
+
usage_granularity: frame.usageGranularity,
|
|
3838
|
+
...frame.callIndex === void 0 ? {} : { call_index: frame.callIndex },
|
|
3839
|
+
provider: frame.provider,
|
|
3840
|
+
model: frame.model,
|
|
3841
|
+
input_tokens: frame.inputTokens,
|
|
3842
|
+
output_tokens: frame.outputTokens,
|
|
3843
|
+
cache_read_tokens: frame.cacheReadTokens,
|
|
3844
|
+
cache_write_tokens: frame.cacheWriteTokens,
|
|
3845
|
+
observed_at: frame.observedAt
|
|
3846
|
+
});
|
|
3847
|
+
break;
|
|
3848
|
+
case "execution_finished":
|
|
3849
|
+
this.send({
|
|
3850
|
+
type: frame.type,
|
|
3851
|
+
...base,
|
|
3852
|
+
succeeded: frame.succeeded,
|
|
3853
|
+
ended_at: frame.endedAt
|
|
3854
|
+
});
|
|
3855
|
+
break;
|
|
3856
|
+
}
|
|
3857
|
+
}
|
|
3818
3858
|
async connect(ctx) {
|
|
3819
3859
|
this.ctx = ctx;
|
|
3820
3860
|
this.closed = false;
|
|
@@ -3941,8 +3981,15 @@ var BppTransport = class {
|
|
|
3941
3981
|
}
|
|
3942
3982
|
});
|
|
3943
3983
|
ws.on("close", (code, reason) => {
|
|
3984
|
+
const closeReason = reason?.toString("utf8") ?? "";
|
|
3944
3985
|
connectionAbort.abort();
|
|
3945
3986
|
const wasCurrent = this.ws === ws;
|
|
3987
|
+
const closeSummary = `code=${code} reason=${closeReason || "<none>"} current=${wasCurrent}`;
|
|
3988
|
+
if (code === 1e3 || this.closed) {
|
|
3989
|
+
this.logger?.info("bpp.ws_closed", closeSummary);
|
|
3990
|
+
} else {
|
|
3991
|
+
this.logger?.warn("bpp.ws_closed", closeSummary);
|
|
3992
|
+
}
|
|
3946
3993
|
if (wasCurrent) {
|
|
3947
3994
|
this.online = false;
|
|
3948
3995
|
this.stopHeartbeat();
|
|
@@ -3952,7 +3999,7 @@ var BppTransport = class {
|
|
|
3952
3999
|
if (authFailed && wasCurrent) {
|
|
3953
4000
|
this.closed = true;
|
|
3954
4001
|
this.terminal = true;
|
|
3955
|
-
this.logger?.error("bpp.auth_failed", `server closed with ${WS_CLOSE_AUTH_FAILED} (authentication failed); not reconnecting. reason=${
|
|
4002
|
+
this.logger?.error("bpp.auth_failed", `server closed with ${WS_CLOSE_AUTH_FAILED} (authentication failed); not reconnecting. reason=${closeReason}`);
|
|
3956
4003
|
this.handlers?.onStateChange({ status: "error", reason: "api_key_invalid" });
|
|
3957
4004
|
}
|
|
3958
4005
|
if (wasCurrent) {
|
|
@@ -3985,7 +4032,12 @@ var BppTransport = class {
|
|
|
3985
4032
|
plugin_id: ctx.pluginId ?? "",
|
|
3986
4033
|
token: "",
|
|
3987
4034
|
version: PROTOCOL_VERSION,
|
|
3988
|
-
capabilities: JSON.stringify([
|
|
4035
|
+
capabilities: JSON.stringify([
|
|
4036
|
+
"semantic_action",
|
|
4037
|
+
"inbound_message",
|
|
4038
|
+
"read_file",
|
|
4039
|
+
"execution_telemetry"
|
|
4040
|
+
])
|
|
3989
4041
|
};
|
|
3990
4042
|
this.sendTo(ws, connectFrame);
|
|
3991
4043
|
try {
|
|
@@ -3998,6 +4050,7 @@ var BppTransport = class {
|
|
|
3998
4050
|
}
|
|
3999
4051
|
this.startHeartbeat();
|
|
4000
4052
|
this.goOnline(ws);
|
|
4053
|
+
this.logger?.info("bpp.connected");
|
|
4001
4054
|
resolve();
|
|
4002
4055
|
} catch (error) {
|
|
4003
4056
|
const failure = error instanceof BorgeeError ? error : new BorgeeError(`agent identity handshake failed: ${String(error)}`, "bpp.identity_unresolved");
|
|
@@ -4011,6 +4064,7 @@ var BppTransport = class {
|
|
|
4011
4064
|
this.reconnectAttempt += 1;
|
|
4012
4065
|
const delay = Math.min(this.reconnectBaseMs * 2 ** (this.reconnectAttempt - 1), this.reconnectMaxMs);
|
|
4013
4066
|
this.handlers?.onStateChange({ status: "reconnecting", attempt: this.reconnectAttempt });
|
|
4067
|
+
this.logger?.info("bpp.reconnect_scheduled", `attempt=${this.reconnectAttempt} delay_ms=${delay}`);
|
|
4014
4068
|
this.reconnectTimer = setTimeout(() => {
|
|
4015
4069
|
this.reconnectTimer = void 0;
|
|
4016
4070
|
if (this.closed)
|
|
@@ -4061,6 +4115,11 @@ var BppTransport = class {
|
|
|
4061
4115
|
case "inbound_message":
|
|
4062
4116
|
this.handleInbound(env);
|
|
4063
4117
|
break;
|
|
4118
|
+
case "execution_telemetry_ack":
|
|
4119
|
+
this.handlers?.onExecutionTelemetryAck?.({
|
|
4120
|
+
eventId: env.event_id
|
|
4121
|
+
});
|
|
4122
|
+
break;
|
|
4064
4123
|
case "semantic_action_result":
|
|
4065
4124
|
this.handleActionResult(env);
|
|
4066
4125
|
break;
|
|
@@ -4080,12 +4139,11 @@ var BppTransport = class {
|
|
|
4080
4139
|
}
|
|
4081
4140
|
handleInbound(frame) {
|
|
4082
4141
|
this.inboundChain = this.inboundChain.then(() => {
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
this.failTerminal(this.inboundFailure(error), this.ws);
|
|
4142
|
+
try {
|
|
4143
|
+
this.handlers?.onInbound(mapInbound(frame));
|
|
4144
|
+
} catch (error) {
|
|
4145
|
+
this.logger?.error("bpp.inbound_dispatch_failed", this.inboundFailure(error));
|
|
4146
|
+
}
|
|
4089
4147
|
});
|
|
4090
4148
|
}
|
|
4091
4149
|
handleActionResult(frame) {
|
|
@@ -4253,7 +4311,12 @@ var BppTransport = class {
|
|
|
4253
4311
|
const specific = this.stopTurnHandler;
|
|
4254
4312
|
const generic = this.serverRequestHandler;
|
|
4255
4313
|
try {
|
|
4256
|
-
const answer = specific ? await specific(channelId) : generic ? await generic(STOP_TURN_ACTION, data) :
|
|
4314
|
+
const answer = specific ? await specific(channelId) : generic ? await generic(STOP_TURN_ACTION, data) : (
|
|
4315
|
+
// No handler is not the same as "unsupported": nothing was aborted,
|
|
4316
|
+
// which is what false already says, and the rail carries no third
|
|
4317
|
+
// value to draw that distinction with.
|
|
4318
|
+
{ aborted: false }
|
|
4319
|
+
);
|
|
4257
4320
|
this.send({ type: "response", id, data: this.asStopTurnResult(answer) });
|
|
4258
4321
|
} catch (err) {
|
|
4259
4322
|
this.logger?.warn("bpp.stop_turn_handler_failed", err);
|
|
@@ -4338,7 +4401,10 @@ var BppTransport = class {
|
|
|
4338
4401
|
frame.paths = action.activity.paths;
|
|
4339
4402
|
break;
|
|
4340
4403
|
case "plan":
|
|
4341
|
-
frame.plan = action.activity.entries.map((entry) => ({
|
|
4404
|
+
frame.plan = action.activity.entries.map((entry) => ({
|
|
4405
|
+
label: entry.label,
|
|
4406
|
+
status: entry.status
|
|
4407
|
+
}));
|
|
4342
4408
|
break;
|
|
4343
4409
|
case "output":
|
|
4344
4410
|
frame.stream = action.activity.stream;
|
|
@@ -4380,6 +4446,7 @@ var BppTransport = class {
|
|
|
4380
4446
|
failTerminal(error, ws) {
|
|
4381
4447
|
if (this.terminal)
|
|
4382
4448
|
return;
|
|
4449
|
+
this.logger?.error("bpp.terminal_failure", error);
|
|
4383
4450
|
this.terminal = true;
|
|
4384
4451
|
this.online = false;
|
|
4385
4452
|
this.handlers?.onStateChange({ status: "error", reason: "unknown", code: error.code });
|
|
@@ -4459,7 +4526,11 @@ function encodeActionPayload(action) {
|
|
|
4459
4526
|
case "delete_message":
|
|
4460
4527
|
return { message_id: action.messageId };
|
|
4461
4528
|
case "react":
|
|
4462
|
-
return {
|
|
4529
|
+
return {
|
|
4530
|
+
message_id: action.messageId,
|
|
4531
|
+
emoji: action.emoji,
|
|
4532
|
+
removed: action.removed ?? false
|
|
4533
|
+
};
|
|
4463
4534
|
case "create_dm":
|
|
4464
4535
|
return { user_id: action.userId };
|
|
4465
4536
|
case "get_me":
|
|
@@ -4476,6 +4547,7 @@ function encodeActionPayload(action) {
|
|
|
4476
4547
|
return {};
|
|
4477
4548
|
case "create_channel":
|
|
4478
4549
|
return {
|
|
4550
|
+
guild_id: action.guildId,
|
|
4479
4551
|
name: action.name,
|
|
4480
4552
|
topic: action.topic,
|
|
4481
4553
|
visibility: action.visibility,
|
|
@@ -4644,9 +4716,23 @@ function mapInbound(frame) {
|
|
|
4644
4716
|
kind,
|
|
4645
4717
|
channelId: frame.channel_id,
|
|
4646
4718
|
channelType: frame.channel_type,
|
|
4719
|
+
...frame.conversation_context ? {
|
|
4720
|
+
conversationContext: {
|
|
4721
|
+
guildId: frame.conversation_context.guild_id,
|
|
4722
|
+
topLevelChannelId: frame.conversation_context.top_level_channel_id,
|
|
4723
|
+
...frame.conversation_context.thread_id ? { threadId: frame.conversation_context.thread_id } : {},
|
|
4724
|
+
...frame.conversation_context.task_id ? { taskId: frame.conversation_context.task_id } : {}
|
|
4725
|
+
}
|
|
4726
|
+
} : {},
|
|
4647
4727
|
authorName: frame.author_name,
|
|
4648
4728
|
createdAt: frame.created_at
|
|
4649
4729
|
};
|
|
4730
|
+
if (frame.execution_id && frame.telemetry_context) {
|
|
4731
|
+
base.executionGrant = {
|
|
4732
|
+
executionId: frame.execution_id,
|
|
4733
|
+
telemetryContext: frame.telemetry_context
|
|
4734
|
+
};
|
|
4735
|
+
}
|
|
4650
4736
|
switch (kind) {
|
|
4651
4737
|
case "message":
|
|
4652
4738
|
case "mention": {
|
|
@@ -4834,7 +4920,8 @@ var Client = class {
|
|
|
4834
4920
|
message: /* @__PURE__ */ new Set(),
|
|
4835
4921
|
configUpdate: /* @__PURE__ */ new Set(),
|
|
4836
4922
|
permissionDenied: /* @__PURE__ */ new Set(),
|
|
4837
|
-
connectionState: /* @__PURE__ */ new Set()
|
|
4923
|
+
connectionState: /* @__PURE__ */ new Set(),
|
|
4924
|
+
executionTelemetryAck: /* @__PURE__ */ new Set()
|
|
4838
4925
|
};
|
|
4839
4926
|
constructor(opts, transport) {
|
|
4840
4927
|
this.opts = opts;
|
|
@@ -4906,6 +4993,7 @@ var Client = class {
|
|
|
4906
4993
|
async createChannel(input) {
|
|
4907
4994
|
return await this.t.perform({
|
|
4908
4995
|
op: "create_channel",
|
|
4996
|
+
guildId: input.guildId,
|
|
4909
4997
|
name: input.name,
|
|
4910
4998
|
topic: input.topic,
|
|
4911
4999
|
visibility: input.visibility,
|
|
@@ -4947,6 +5035,9 @@ var Client = class {
|
|
|
4947
5035
|
activity: input.activity
|
|
4948
5036
|
}).catch((err) => this.logger.warn("reportActivity failed", err));
|
|
4949
5037
|
}
|
|
5038
|
+
reportExecutionTelemetry(frame) {
|
|
5039
|
+
this.t.sendExecutionTelemetry?.(frame);
|
|
5040
|
+
}
|
|
4950
5041
|
reportTurnActivity(input) {
|
|
4951
5042
|
return new TurnActivityReporter({
|
|
4952
5043
|
...input,
|
|
@@ -5051,8 +5142,13 @@ var Client = class {
|
|
|
5051
5142
|
this.t.setStopTurnHandler?.(handler);
|
|
5052
5143
|
}
|
|
5053
5144
|
emit(event, payload) {
|
|
5054
|
-
for (const h of this.listeners[event])
|
|
5055
|
-
|
|
5145
|
+
for (const h of this.listeners[event]) {
|
|
5146
|
+
try {
|
|
5147
|
+
h(payload);
|
|
5148
|
+
} catch (error) {
|
|
5149
|
+
this.logger.error("client.observer_failed", { event, error });
|
|
5150
|
+
}
|
|
5151
|
+
}
|
|
5056
5152
|
}
|
|
5057
5153
|
handlers() {
|
|
5058
5154
|
return {
|
|
@@ -5063,7 +5159,8 @@ var Client = class {
|
|
|
5063
5159
|
onStateChange: (s) => {
|
|
5064
5160
|
this._state = s;
|
|
5065
5161
|
this.emit("connectionState", s);
|
|
5066
|
-
}
|
|
5162
|
+
},
|
|
5163
|
+
onExecutionTelemetryAck: (ack) => this.emit("executionTelemetryAck", ack)
|
|
5067
5164
|
};
|
|
5068
5165
|
}
|
|
5069
5166
|
context() {
|