@borgee/agents-host 0.2.35 → 0.2.56
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 +23 -27
- package/dist/agents-host.d.ts +28 -5
- package/dist/agents-host.js +274 -236
- package/dist/chat/chat-control-plane.d.ts +3 -0
- package/dist/chat/sdk-chat-control-plane.d.ts +4 -3
- package/dist/chat/sdk-chat-control-plane.js +6 -0
- package/dist/cli.js +1 -5
- package/dist/compatibility-gates.d.ts +4 -0
- package/dist/compatibility-gates.js +18 -1
- package/dist/context/claude-file-brief.d.ts +2 -0
- package/dist/context/claude-file-brief.js +83 -0
- package/dist/context/compaction.d.ts +20 -0
- package/dist/context/compaction.js +59 -0
- package/dist/context/injection.d.ts +44 -9
- package/dist/context/injection.js +360 -53
- package/dist/context/main-session-delegation.d.ts +1 -1
- package/dist/context/projection-strategy.d.ts +24 -0
- package/dist/context/projection-strategy.js +90 -0
- package/dist/context/prompt.d.ts +16 -1
- package/dist/context/prompt.js +475 -53
- package/dist/context/resolved-workspace.d.ts +2 -0
- package/dist/context/resolved-workspace.js +64 -0
- package/dist/context/skill-manual.d.ts +14 -0
- package/dist/context/skill-manual.js +21 -0
- package/dist/context/turn-preparation.d.ts +8 -2
- package/dist/context/turn-preparation.js +68 -17
- package/dist/gateway/localhost-gateway.js +18 -8
- package/dist/hosted-turn-content.d.ts +15 -0
- package/dist/hosted-turn-content.js +50 -0
- package/dist/managed-daemon.d.ts +3 -2
- package/dist/managed-daemon.js +198 -37
- package/dist/plugin-sdk.js +276 -359
- package/dist/plugin-sdk.js.map +4 -4
- package/dist/progress-to-activity.d.ts +16 -0
- package/dist/progress-to-activity.js +24 -0
- package/dist/projection-strategy-values.d.ts +4 -0
- package/dist/projection-strategy-values.js +28 -0
- package/dist/providers/acp-progress-collector.d.ts +44 -0
- package/dist/providers/acp-progress-collector.js +130 -0
- package/dist/providers/awaiting-user.d.ts +2 -3
- package/dist/providers/awaiting-user.js +5 -7
- package/dist/providers/claude/activity-metadata.d.ts +14 -0
- package/dist/providers/claude/activity-metadata.js +81 -0
- package/dist/providers/claude/adapter.d.ts +3 -1
- package/dist/providers/claude/adapter.js +10 -0
- package/dist/providers/claude/cli-client.d.ts +9 -1
- package/dist/providers/claude/cli-client.js +270 -126
- package/dist/providers/codex/adapter.d.ts +3 -1
- package/dist/providers/codex/adapter.js +10 -0
- package/dist/providers/codex/cli-client.d.ts +10 -2
- package/dist/providers/codex/cli-client.js +88 -104
- package/dist/providers/codex/project-doc.js +22 -37
- package/dist/providers/copilot/adapter.d.ts +3 -1
- package/dist/providers/copilot/adapter.js +10 -0
- package/dist/providers/copilot/cli-client.d.ts +9 -1
- package/dist/providers/copilot/cli-client.js +68 -85
- package/dist/providers/create-provider.d.ts +3 -1
- package/dist/providers/create-provider.js +36 -9
- package/dist/providers/provider-adapter.d.ts +35 -0
- package/dist/providers/provider-adapter.js +44 -1
- package/dist/state-paths.d.ts +10 -2
- package/dist/state-paths.js +25 -6
- package/dist/task-thread-resolution.d.ts +3 -2
- package/dist/types.d.ts +163 -8
- package/package.json +2 -2
- package/skills/borgee-agent/SKILL.md +127 -38
- package/skills/borgee-agent/references/errors.md +38 -0
- package/skills/borgee-agent/references/task-properties.md +33 -0
- package/skills/borgee-agent/scripts/borgee-agent.mjs +553 -0
- package/skills/borgee-agent/scripts/borgee-agent.py +547 -0
- package/dist/durable-cursor-store.d.ts +0 -5
- package/dist/durable-cursor-store.js +0 -7
- package/skills/borgee-agent/borgee-agent.mjs +0 -562
- package/skills/borgee-agent/borgee-agent.py +0 -469
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { DEFAULT_PROJECTION_STRATEGY, normalizeProjectionStrategy, } from '../projection-strategy-values.js';
|
|
2
|
+
import { findTaskForThread } from '../task-thread-resolution.js';
|
|
3
|
+
export class ServerProjectionStrategyResolver {
|
|
4
|
+
options;
|
|
5
|
+
strategyCache = new Map();
|
|
6
|
+
channelAliases = new Map();
|
|
7
|
+
fetchImpl;
|
|
8
|
+
fallback;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.options = options;
|
|
11
|
+
this.fetchImpl = options.fetch ?? fetch;
|
|
12
|
+
this.fallback = options.fallback ?? (() => DEFAULT_PROJECTION_STRATEGY);
|
|
13
|
+
}
|
|
14
|
+
async resolve(channelId) {
|
|
15
|
+
const baseUrl = this.options.baseUrl?.trim();
|
|
16
|
+
const agentApiKey = this.options.agentApiKey?.trim();
|
|
17
|
+
const agentId = this.options.resolveStableAgentId?.()?.trim();
|
|
18
|
+
if (!baseUrl || !agentApiKey || !agentId) {
|
|
19
|
+
return this.fallback();
|
|
20
|
+
}
|
|
21
|
+
const cacheKey = `${agentId}::${channelId}`;
|
|
22
|
+
const url = new URL(`/api/v1/agents/${encodeURIComponent(agentId)}/channels/${encodeURIComponent(channelId)}/projection-strategy`, baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`);
|
|
23
|
+
try {
|
|
24
|
+
const response = await this.fetchImpl(url.toString(), {
|
|
25
|
+
headers: {
|
|
26
|
+
Authorization: `Bearer ${agentApiKey}`,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
if (response.status === 404) {
|
|
30
|
+
const effectiveCacheKey = await this.resolveEffectiveCacheKey(agentId, channelId, cacheKey);
|
|
31
|
+
this.channelAliases.set(cacheKey, effectiveCacheKey);
|
|
32
|
+
this.strategyCache.set(effectiveCacheKey, DEFAULT_PROJECTION_STRATEGY);
|
|
33
|
+
return DEFAULT_PROJECTION_STRATEGY;
|
|
34
|
+
}
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
throw new Error(`server returned ${response.status} ${response.statusText}`.trim());
|
|
37
|
+
}
|
|
38
|
+
const body = await response.json();
|
|
39
|
+
const strategy = normalizeProjectionStrategy(typeof body.projection_strategy === 'string' ? body.projection_strategy : undefined);
|
|
40
|
+
if (!strategy) {
|
|
41
|
+
throw new Error('server returned an invalid projection strategy');
|
|
42
|
+
}
|
|
43
|
+
const effectiveChannelId = typeof body.channel_id === 'string' && body.channel_id.length > 0
|
|
44
|
+
? body.channel_id
|
|
45
|
+
: channelId;
|
|
46
|
+
const effectiveCacheKey = `${agentId}::${effectiveChannelId}`;
|
|
47
|
+
this.channelAliases.set(cacheKey, effectiveCacheKey);
|
|
48
|
+
this.strategyCache.set(effectiveCacheKey, strategy);
|
|
49
|
+
return strategy;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
const cached = await this.resolveCachedStrategy(agentId, channelId, cacheKey);
|
|
53
|
+
if (cached) {
|
|
54
|
+
return cached;
|
|
55
|
+
}
|
|
56
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
57
|
+
this.options.logger?.error('failed to resolve server-backed projection strategy; using fallback', {
|
|
58
|
+
agentId,
|
|
59
|
+
channelId,
|
|
60
|
+
error: message,
|
|
61
|
+
});
|
|
62
|
+
return DEFAULT_PROJECTION_STRATEGY;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async resolveCachedStrategy(agentId, channelId, cacheKey) {
|
|
66
|
+
const direct = this.strategyCache.get(this.channelAliases.get(cacheKey) ?? cacheKey);
|
|
67
|
+
if (direct) {
|
|
68
|
+
return direct;
|
|
69
|
+
}
|
|
70
|
+
if (!this.options.taskReader) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
const effectiveCacheKey = await this.resolveEffectiveCacheKey(agentId, channelId, cacheKey);
|
|
74
|
+
if (effectiveCacheKey === cacheKey) {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
this.channelAliases.set(cacheKey, effectiveCacheKey);
|
|
78
|
+
return this.strategyCache.get(effectiveCacheKey);
|
|
79
|
+
}
|
|
80
|
+
async resolveEffectiveCacheKey(agentId, channelId, cacheKey) {
|
|
81
|
+
if (!this.options.taskReader) {
|
|
82
|
+
return cacheKey;
|
|
83
|
+
}
|
|
84
|
+
const task = await findTaskForThread(this.options.taskReader, channelId);
|
|
85
|
+
if (!task?.channelId) {
|
|
86
|
+
return cacheKey;
|
|
87
|
+
}
|
|
88
|
+
return `${agentId}::${task.channelId}`;
|
|
89
|
+
}
|
|
90
|
+
}
|
package/dist/context/prompt.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PreparedPromptContext, ProviderKind } from '../types.js';
|
|
1
|
+
import type { ProjectionStrategy, PreparedPromptContext, ProviderKind } from '../types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Builds the per-turn prompt. Conversation memory is intentionally NOT
|
|
4
4
|
* assembled here: each provider's CLI client resumes a native per-channel
|
|
@@ -16,3 +16,18 @@ export declare function buildPrompt(params: {
|
|
|
16
16
|
incomingMessageType?: string;
|
|
17
17
|
promptContext?: PreparedPromptContext;
|
|
18
18
|
}): string;
|
|
19
|
+
export declare function buildClaudeSessionPromptAppend(params: {
|
|
20
|
+
agentName: string;
|
|
21
|
+
promptContext?: PreparedPromptContext;
|
|
22
|
+
promptStrategy?: ProjectionStrategy;
|
|
23
|
+
}): string | undefined;
|
|
24
|
+
export declare function buildClaudeTurnPrompt(params: {
|
|
25
|
+
agentName?: string;
|
|
26
|
+
channelId: string;
|
|
27
|
+
incomingAuthorId: string;
|
|
28
|
+
incomingContent: string;
|
|
29
|
+
incomingEventKind?: string;
|
|
30
|
+
incomingMessageType?: string;
|
|
31
|
+
promptContext?: PreparedPromptContext;
|
|
32
|
+
promptStrategy?: ProjectionStrategy;
|
|
33
|
+
}): string;
|