@borgee/agents-host 0.2.74 → 0.2.94
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 +11 -24
- package/dist/agents-host.d.ts +6 -4
- package/dist/agents-host.js +127 -16
- package/dist/background-runs.d.ts +24 -0
- package/dist/background-runs.js +184 -0
- package/dist/chat/chat-control-plane.d.ts +7 -1
- package/dist/chat/sdk-chat-control-plane.d.ts +7 -2
- package/dist/chat/sdk-chat-control-plane.js +22 -0
- package/dist/context/claude-file-brief.js +3 -3
- package/dist/context/injection.d.ts +18 -12
- package/dist/context/injection.js +53 -53
- package/dist/context/prompt.js +10 -10
- package/dist/context/resolved-working-folder.d.ts +3 -0
- package/dist/context/resolved-working-folder.js +106 -0
- package/dist/context/turn-preparation.js +1 -1
- package/dist/managed-daemon.js +30 -30
- package/dist/plugin-sdk.js +315 -29
- package/dist/plugin-sdk.js.map +3 -3
- package/dist/policy/authorization-audit.d.ts +1 -1
- package/dist/policy/copilot-permission.d.ts +9 -0
- package/dist/policy/copilot-permission.js +120 -1
- package/dist/progress-to-activity.d.ts +1 -1
- package/dist/progress-to-activity.js +1 -0
- package/dist/providers/claude/adapter.d.ts +2 -1
- package/dist/providers/claude/adapter.js +36 -1
- package/dist/providers/claude/background-run-observer.d.ts +32 -0
- package/dist/providers/claude/background-run-observer.js +381 -0
- package/dist/providers/claude/cli-client.d.ts +12 -0
- package/dist/providers/claude/cli-client.js +453 -72
- package/dist/providers/claude/foreground-handoff.d.ts +4 -0
- package/dist/providers/claude/foreground-handoff.js +45 -0
- package/dist/providers/claude/task-cancellation-protocol.d.ts +14 -0
- package/dist/providers/claude/task-cancellation-protocol.js +21 -0
- package/dist/providers/codex/adapter.d.ts +1 -1
- package/dist/providers/codex/adapter.js +7 -0
- package/dist/providers/codex/cli-client.js +8 -7
- package/dist/providers/codex/project-doc.js +6 -6
- package/dist/providers/copilot/activity-metadata.d.ts +3 -0
- package/dist/providers/copilot/activity-metadata.js +19 -0
- package/dist/providers/copilot/adapter.d.ts +6 -2
- package/dist/providers/copilot/adapter.js +27 -1
- package/dist/providers/copilot/cli-client.d.ts +37 -10
- package/dist/providers/copilot/cli-client.js +756 -122
- package/dist/providers/copilot/sdk-session.d.ts +149 -0
- package/dist/providers/copilot/sdk-session.js +981 -0
- package/dist/providers/create-provider.js +33 -0
- package/dist/providers/provider-adapter.d.ts +24 -1
- package/dist/providers/provider-adapter.js +17 -0
- package/dist/types.d.ts +40 -11
- package/dist/vendor/claude-agent-acp/LICENSE +191 -0
- package/dist/vendor/claude-agent-acp/NOTICE +8 -0
- package/dist/vendor/claude-agent-acp/dist/acp-agent.d.ts +1017 -0
- package/dist/vendor/claude-agent-acp/dist/acp-agent.d.ts.map +1 -0
- package/dist/vendor/claude-agent-acp/dist/acp-agent.js +6305 -0
- package/dist/vendor/claude-agent-acp/dist/borgee-foreground-handoff-bridge.js +322 -0
- package/dist/vendor/claude-agent-acp/dist/borgee-task-cancellation-bridge.js +101 -0
- package/dist/vendor/claude-agent-acp/dist/borgee-task-lifecycle-bridge.js +58 -0
- package/dist/vendor/claude-agent-acp/dist/elicitation.d.ts +130 -0
- package/dist/vendor/claude-agent-acp/dist/elicitation.d.ts.map +1 -0
- package/dist/vendor/claude-agent-acp/dist/elicitation.js +304 -0
- package/dist/vendor/claude-agent-acp/dist/index.d.ts +3 -0
- package/dist/vendor/claude-agent-acp/dist/index.d.ts.map +1 -0
- package/dist/vendor/claude-agent-acp/dist/index.js +75 -0
- package/dist/vendor/claude-agent-acp/dist/lib.d.ts +6 -0
- package/dist/vendor/claude-agent-acp/dist/lib.d.ts.map +1 -0
- package/dist/vendor/claude-agent-acp/dist/lib.js +5 -0
- package/dist/vendor/claude-agent-acp/dist/settings.d.ts +68 -0
- package/dist/vendor/claude-agent-acp/dist/settings.d.ts.map +1 -0
- package/dist/vendor/claude-agent-acp/dist/settings.js +185 -0
- package/dist/vendor/claude-agent-acp/dist/tools.d.ts +102 -0
- package/dist/vendor/claude-agent-acp/dist/tools.d.ts.map +1 -0
- package/dist/vendor/claude-agent-acp/dist/tools.js +1000 -0
- package/dist/vendor/claude-agent-acp/dist/utils.d.ts +16 -0
- package/dist/vendor/claude-agent-acp/dist/utils.d.ts.map +1 -0
- package/dist/vendor/claude-agent-acp/dist/utils.js +81 -0
- package/dist/vendor/claude-agent-acp/package.json +85 -0
- package/package.json +15 -10
- package/skills/borgee-agent/references/task-properties.md +3 -3
- package/skills/borgee-agent/scripts/borgee-agent.mjs +1 -1
- package/skills/borgee-agent/scripts/borgee-agent.py +1 -1
- package/dist/context/resolved-workspace.d.ts +0 -3
- package/dist/context/resolved-workspace.js +0 -106
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
const STOP_UNSUPPORTED_REASON = 'This provider does not support targeted background-run cancellation';
|
|
3
|
+
const MAX_TRACKED_RUNS = 128;
|
|
4
|
+
export class BackgroundRunTracker {
|
|
5
|
+
report;
|
|
6
|
+
options;
|
|
7
|
+
now;
|
|
8
|
+
mintRunId;
|
|
9
|
+
runs = new Map();
|
|
10
|
+
runsById = new Map();
|
|
11
|
+
constructor(report, options, now = Date.now, mintRunId = stableRunId) {
|
|
12
|
+
this.report = report;
|
|
13
|
+
this.options = options;
|
|
14
|
+
this.now = now;
|
|
15
|
+
this.mintRunId = mintRunId;
|
|
16
|
+
}
|
|
17
|
+
observe(channelId, update) {
|
|
18
|
+
if (!this.options.lifecycleSupported || update.type !== 'background_run')
|
|
19
|
+
return;
|
|
20
|
+
const key = `${channelId}\0${update.run.providerRunId}`;
|
|
21
|
+
const held = this.runs.get(key);
|
|
22
|
+
const state = runState(update.run.state);
|
|
23
|
+
const refinesUnknown = held?.state === 'unknown' && state !== 'unknown';
|
|
24
|
+
const stopSupported = update.run.stopSupported &&
|
|
25
|
+
this.options.targetedCancellationSupported &&
|
|
26
|
+
this.options.cancel !== undefined;
|
|
27
|
+
const executionChanged = held !== undefined &&
|
|
28
|
+
((update.run.executionId !== undefined &&
|
|
29
|
+
update.run.executionId !== held.executionId) ||
|
|
30
|
+
(update.run.startedAt !== undefined &&
|
|
31
|
+
update.run.startedAt !== held.startedAt));
|
|
32
|
+
const startsNewExecution = !held ||
|
|
33
|
+
executionChanged ||
|
|
34
|
+
(held.state !== 'unknown' && isTerminal(held.state) && !isTerminal(state));
|
|
35
|
+
if (held &&
|
|
36
|
+
isTerminal(held.state) &&
|
|
37
|
+
isTerminal(state) &&
|
|
38
|
+
!startsNewExecution &&
|
|
39
|
+
held.state !== state &&
|
|
40
|
+
held.state !== 'unknown') {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const startedAt = startsNewExecution
|
|
44
|
+
? (update.run.startedAt ?? this.now())
|
|
45
|
+
: (update.run.startedAt ?? held.startedAt);
|
|
46
|
+
const run = startsNewExecution
|
|
47
|
+
? {
|
|
48
|
+
channelId,
|
|
49
|
+
providerRunId: update.run.providerRunId,
|
|
50
|
+
runId: this.mintRunId(channelId, update.run.providerRunId, startedAt, update.run.executionId),
|
|
51
|
+
executionId: update.run.executionId,
|
|
52
|
+
label: update.run.label,
|
|
53
|
+
state,
|
|
54
|
+
parentActivityId: update.run.parentActivityId,
|
|
55
|
+
startedAt,
|
|
56
|
+
finishedAt: update.run.finishedAt,
|
|
57
|
+
reason: update.run.reason,
|
|
58
|
+
stopSupported,
|
|
59
|
+
}
|
|
60
|
+
: {
|
|
61
|
+
...held,
|
|
62
|
+
label: update.run.label,
|
|
63
|
+
state,
|
|
64
|
+
parentActivityId: update.run.parentActivityId ?? held.parentActivityId,
|
|
65
|
+
startedAt,
|
|
66
|
+
finishedAt: refinesUnknown
|
|
67
|
+
? update.run.finishedAt
|
|
68
|
+
: (update.run.finishedAt ?? held.finishedAt),
|
|
69
|
+
reason: refinesUnknown ? update.run.reason : (update.run.reason ?? held.reason),
|
|
70
|
+
stopSupported,
|
|
71
|
+
};
|
|
72
|
+
if (isTerminal(state) && run.finishedAt === undefined) {
|
|
73
|
+
run.finishedAt = this.now();
|
|
74
|
+
}
|
|
75
|
+
if (held &&
|
|
76
|
+
held.runId === run.runId &&
|
|
77
|
+
held.label === run.label &&
|
|
78
|
+
held.state === run.state &&
|
|
79
|
+
held.parentActivityId === run.parentActivityId &&
|
|
80
|
+
held.finishedAt === run.finishedAt &&
|
|
81
|
+
held.reason === run.reason &&
|
|
82
|
+
held.stopSupported === run.stopSupported) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (held && held.runId !== run.runId) {
|
|
86
|
+
this.runsById.delete(held.runId);
|
|
87
|
+
}
|
|
88
|
+
this.runs.delete(key);
|
|
89
|
+
this.runs.set(key, run);
|
|
90
|
+
this.runsById.set(run.runId, run);
|
|
91
|
+
let historySize = [...this.runs.values()].filter((candidate) => isTerminal(candidate.state)).length;
|
|
92
|
+
while (historySize > MAX_TRACKED_RUNS) {
|
|
93
|
+
const oldest = [...this.runs].find(([, candidate]) => isTerminal(candidate.state));
|
|
94
|
+
if (!oldest) {
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
this.runs.delete(oldest[0]);
|
|
98
|
+
this.runsById.delete(oldest[1].runId);
|
|
99
|
+
historySize -= 1;
|
|
100
|
+
}
|
|
101
|
+
this.publish(run);
|
|
102
|
+
}
|
|
103
|
+
replay() {
|
|
104
|
+
for (const run of this.runs.values()) {
|
|
105
|
+
this.publish(run);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async stop(channelId, runId) {
|
|
109
|
+
if (!this.options.lifecycleSupported ||
|
|
110
|
+
!this.options.targetedCancellationSupported ||
|
|
111
|
+
!this.options.cancel) {
|
|
112
|
+
return {
|
|
113
|
+
outcome: 'unsupported',
|
|
114
|
+
reason: STOP_UNSUPPORTED_REASON,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
const run = this.runsById.get(runId);
|
|
118
|
+
if (!run || run.channelId !== channelId || isTerminal(run.state)) {
|
|
119
|
+
return { outcome: 'not_found' };
|
|
120
|
+
}
|
|
121
|
+
if (!run.stopSupported) {
|
|
122
|
+
return {
|
|
123
|
+
outcome: 'unsupported',
|
|
124
|
+
reason: STOP_UNSUPPORTED_REASON,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
if (!(await this.options.cancel(channelId, run.providerRunId))) {
|
|
128
|
+
return { outcome: 'not_found' };
|
|
129
|
+
}
|
|
130
|
+
const current = this.runsById.get(runId);
|
|
131
|
+
if (current && current.channelId === channelId && !isTerminal(current.state)) {
|
|
132
|
+
current.state = 'stopping';
|
|
133
|
+
this.publish(current);
|
|
134
|
+
}
|
|
135
|
+
return { outcome: 'stopped' };
|
|
136
|
+
}
|
|
137
|
+
publish(run) {
|
|
138
|
+
this.report(run.channelId, {
|
|
139
|
+
shape: 'background_run',
|
|
140
|
+
runId: run.runId,
|
|
141
|
+
label: run.label,
|
|
142
|
+
state: run.state,
|
|
143
|
+
...(run.parentActivityId ? { parentId: run.parentActivityId } : {}),
|
|
144
|
+
startedAt: run.startedAt,
|
|
145
|
+
...(run.finishedAt !== undefined ? { finishedAt: run.finishedAt } : {}),
|
|
146
|
+
...(run.reason ? { reason: run.reason } : {}),
|
|
147
|
+
stopSupported: run.stopSupported,
|
|
148
|
+
...(!run.stopSupported ? { stopUnsupportedReason: STOP_UNSUPPORTED_REASON } : {}),
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function runState(status) {
|
|
153
|
+
switch (status) {
|
|
154
|
+
case 'running':
|
|
155
|
+
return 'running';
|
|
156
|
+
case 'waiting':
|
|
157
|
+
return 'waiting';
|
|
158
|
+
case 'completed':
|
|
159
|
+
return 'completed';
|
|
160
|
+
case 'failed':
|
|
161
|
+
return 'failed';
|
|
162
|
+
case 'cancelled':
|
|
163
|
+
return 'cancelled';
|
|
164
|
+
case 'unknown':
|
|
165
|
+
return 'unknown';
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function isTerminal(state) {
|
|
169
|
+
return (state === 'completed' ||
|
|
170
|
+
state === 'failed' ||
|
|
171
|
+
state === 'cancelled' ||
|
|
172
|
+
state === 'unknown');
|
|
173
|
+
}
|
|
174
|
+
function stableRunId(channelId, providerRunId, startedAt, executionId) {
|
|
175
|
+
const digest = createHash('sha256')
|
|
176
|
+
.update(channelId)
|
|
177
|
+
.update('\0')
|
|
178
|
+
.update(providerRunId)
|
|
179
|
+
.update('\0')
|
|
180
|
+
.update(executionId ?? String(startedAt))
|
|
181
|
+
.digest('hex')
|
|
182
|
+
.slice(0, 32);
|
|
183
|
+
return `run_${digest}`;
|
|
184
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { ReportTurnActivityInput, StopTurnHandler, TurnActivityReporter } from '../plugin-sdk.js';
|
|
1
|
+
import type { AgentActivity, ReportTurnActivityInput, StopBackgroundRunHandler, StopTurnHandler, TurnActivityReporter } from '../plugin-sdk.js';
|
|
2
2
|
import type { ChannelSummary, ChannelHistoryEntry, ChannelMessageEvent, CreateTaskInput, DirectoryUser, MeResponseUser, PostMessageInput, PostedMessage, ReadChannelHistoryInput, Task, UpdateTaskInput } from '../types.js';
|
|
3
3
|
export interface ChatControlPlane {
|
|
4
4
|
onStopTurn?(handler: StopTurnHandler | undefined): void;
|
|
5
|
+
onStopBackgroundRun?(handler: StopBackgroundRunHandler | undefined): void;
|
|
6
|
+
onActivityTransportReady?(handler: (() => void) | undefined): void;
|
|
5
7
|
connect(onMessage: (message: ChannelMessageEvent) => void): Promise<void>;
|
|
6
8
|
close(): Promise<void>;
|
|
7
9
|
postMessage(input: PostMessageInput): Promise<PostedMessage>;
|
|
@@ -10,6 +12,10 @@ export interface ChatControlPlane {
|
|
|
10
12
|
startTyping(channelId: string): () => void;
|
|
11
13
|
/** Opens one turn's report on the activity rail. Fire-and-forget: nothing recovers what it sends. */
|
|
12
14
|
reportTurnActivity(input: ReportTurnActivityInput): TurnActivityReporter;
|
|
15
|
+
reportActivity?(input: {
|
|
16
|
+
channelId: string;
|
|
17
|
+
activity: AgentActivity;
|
|
18
|
+
}): void;
|
|
13
19
|
getMe(): Promise<MeResponseUser>;
|
|
14
20
|
listUsers(): Promise<DirectoryUser[]>;
|
|
15
21
|
listChannels(): Promise<ChannelSummary[]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type BorgeePluginClient, type BorgeePluginOptions, type InboundMessageEvent, type ReportTurnActivityInput, type StopTurnHandler, type TurnActivityReporter } from '../plugin-sdk.js';
|
|
1
|
+
import { type BorgeePluginClient, type BorgeePluginOptions, type InboundMessageEvent, type ReportTurnActivityInput, type StopTurnHandler, type StopBackgroundRunHandler, type TurnActivityReporter } from '../plugin-sdk.js';
|
|
2
2
|
import type { ChannelSummary, ChannelHistoryEntry, ChannelMessageEvent, CreateTaskInput, DirectoryUser, MeResponseUser, PostMessageInput, PostedMessage, ReadChannelHistoryInput, Task, UpdateTaskInput } from '../types.js';
|
|
3
3
|
import type { ChatControlPlane } from './chat-control-plane.js';
|
|
4
|
-
type PluginClientLike = Pick<BorgeePluginClient, 'agentId' | 'close' | 'connect' | 'createTask' | 'deleteMessage' | 'editMessage' | 'getMe' | 'getTask' | 'listChannels' | 'listTasks' | 'listUsers' | 'on' | 'onStopTurn' | 'readHistory' | 'reportTurnActivity' | 'sendMessage' | 'startTyping' | 'updateTask' | 'setTaskProperty' | 'deleteTaskProperty'>;
|
|
4
|
+
type PluginClientLike = Pick<BorgeePluginClient, 'agentId' | 'close' | 'connect' | 'createTask' | 'deleteMessage' | 'editMessage' | 'getMe' | 'getTask' | 'listChannels' | 'listTasks' | 'listUsers' | 'on' | 'onStopTurn' | 'onStopBackgroundRun' | 'reportActivity' | 'readHistory' | 'reportTurnActivity' | 'sendMessage' | 'startTyping' | 'updateTask' | 'setTaskProperty' | 'deleteTaskProperty'>;
|
|
5
5
|
type PluginClientFactory = (options: BorgeePluginOptions) => PluginClientLike;
|
|
6
6
|
type SdkChatControlPlaneOptions = Pick<BorgeePluginOptions, 'pluginId'>;
|
|
7
7
|
/**
|
|
@@ -13,13 +13,18 @@ export declare class SdkChatControlPlane implements ChatControlPlane {
|
|
|
13
13
|
private readonly client;
|
|
14
14
|
private pendingMessages;
|
|
15
15
|
private unsubscribe;
|
|
16
|
+
private stateUnsubscribe;
|
|
17
|
+
private activityTransportReady;
|
|
16
18
|
private connected;
|
|
17
19
|
private me;
|
|
18
20
|
constructor(baseUrl: string, apiKey: string, createClient?: PluginClientFactory, options?: SdkChatControlPlaneOptions);
|
|
19
21
|
onStopTurn(handler: StopTurnHandler | undefined): void;
|
|
22
|
+
onStopBackgroundRun(handler: StopBackgroundRunHandler | undefined): void;
|
|
23
|
+
onActivityTransportReady(handler: (() => void) | undefined): void;
|
|
20
24
|
connect(onMessage: (message: ChannelMessageEvent) => void): Promise<void>;
|
|
21
25
|
close(): Promise<void>;
|
|
22
26
|
postMessage(input: PostMessageInput): Promise<PostedMessage>;
|
|
27
|
+
reportActivity(input: Parameters<BorgeePluginClient['reportActivity']>[0]): void;
|
|
23
28
|
editMessage(messageId: string, content: string): Promise<void>;
|
|
24
29
|
deleteMessage(messageId: string): Promise<void>;
|
|
25
30
|
startTyping(channelId: string): () => void;
|
|
@@ -9,6 +9,8 @@ export class SdkChatControlPlane {
|
|
|
9
9
|
client;
|
|
10
10
|
pendingMessages = [];
|
|
11
11
|
unsubscribe = null;
|
|
12
|
+
stateUnsubscribe = null;
|
|
13
|
+
activityTransportReady;
|
|
12
14
|
connected = false;
|
|
13
15
|
me = null;
|
|
14
16
|
constructor(baseUrl, apiKey, createClient = createBorgeePlugin, options = {}) {
|
|
@@ -17,6 +19,12 @@ export class SdkChatControlPlane {
|
|
|
17
19
|
onStopTurn(handler) {
|
|
18
20
|
this.client.onStopTurn(handler);
|
|
19
21
|
}
|
|
22
|
+
onStopBackgroundRun(handler) {
|
|
23
|
+
this.client.onStopBackgroundRun?.(handler);
|
|
24
|
+
}
|
|
25
|
+
onActivityTransportReady(handler) {
|
|
26
|
+
this.activityTransportReady = handler;
|
|
27
|
+
}
|
|
20
28
|
async connect(onMessage) {
|
|
21
29
|
this.unsubscribe = this.client.on('message', (event) => {
|
|
22
30
|
const message = mapInboundToChannelMessage(event);
|
|
@@ -26,6 +34,11 @@ export class SdkChatControlPlane {
|
|
|
26
34
|
}
|
|
27
35
|
onMessage(message);
|
|
28
36
|
});
|
|
37
|
+
this.stateUnsubscribe = this.client.on('connectionState', (state) => {
|
|
38
|
+
if (state.status === 'online') {
|
|
39
|
+
this.activityTransportReady?.();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
29
42
|
try {
|
|
30
43
|
await this.client.connect();
|
|
31
44
|
this.connected = true;
|
|
@@ -40,6 +53,8 @@ export class SdkChatControlPlane {
|
|
|
40
53
|
catch (error) {
|
|
41
54
|
this.unsubscribe?.();
|
|
42
55
|
this.unsubscribe = null;
|
|
56
|
+
this.stateUnsubscribe?.();
|
|
57
|
+
this.stateUnsubscribe = null;
|
|
43
58
|
this.pendingMessages = [];
|
|
44
59
|
throw error;
|
|
45
60
|
}
|
|
@@ -49,7 +64,11 @@ export class SdkChatControlPlane {
|
|
|
49
64
|
this.pendingMessages = [];
|
|
50
65
|
this.unsubscribe?.();
|
|
51
66
|
this.unsubscribe = null;
|
|
67
|
+
this.stateUnsubscribe?.();
|
|
68
|
+
this.stateUnsubscribe = null;
|
|
69
|
+
this.activityTransportReady = undefined;
|
|
52
70
|
this.client.onStopTurn(undefined);
|
|
71
|
+
this.client.onStopBackgroundRun?.(undefined);
|
|
53
72
|
await this.client.close();
|
|
54
73
|
}
|
|
55
74
|
async postMessage(input) {
|
|
@@ -60,6 +79,9 @@ export class SdkChatControlPlane {
|
|
|
60
79
|
});
|
|
61
80
|
return { messageId: sent.messageId };
|
|
62
81
|
}
|
|
82
|
+
reportActivity(input) {
|
|
83
|
+
this.client.reportActivity(input);
|
|
84
|
+
}
|
|
63
85
|
async editMessage(messageId, content) {
|
|
64
86
|
await this.client.editMessage({ messageId, body: content });
|
|
65
87
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { buildCollaborationCapabilityDeclarationSummaryLines, } from './collaboration-capabilities-diagnostics.js';
|
|
2
2
|
import { MAIN_SESSION_DELEGATION_LINES } from './main-session-delegation.js';
|
|
3
|
-
import {
|
|
3
|
+
import { buildResolvedWorkingFolderGuidanceLines } from './resolved-working-folder.js';
|
|
4
4
|
import { buildSkillManualLines, buildSkillManualReadLine } from './skill-manual.js';
|
|
5
5
|
import { PARENT_CHANNEL_TASK_BOUNDARY_LINES } from './task-channel-boundary.js';
|
|
6
6
|
function buildStableSkillLines(context) {
|
|
@@ -60,8 +60,8 @@ export function buildClaudeFileBrief(context) {
|
|
|
60
60
|
'',
|
|
61
61
|
...sessionDelegationLines,
|
|
62
62
|
...(() => {
|
|
63
|
-
const
|
|
64
|
-
return
|
|
63
|
+
const workingFolderLines = buildResolvedWorkingFolderGuidanceLines(context);
|
|
64
|
+
return workingFolderLines.length > 0 ? ['', ...workingFolderLines] : [];
|
|
65
65
|
})(),
|
|
66
66
|
...(() => {
|
|
67
67
|
const capabilityLines = buildCollaborationCapabilityDeclarationSummaryLines(context?.collaborationCapabilities);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ChatControlPlane } from '../chat/chat-control-plane.js';
|
|
2
|
-
import type { AttentionSnapshot, ProjectionStrategy, CollaborationCapabilityDeclaration, CollaborationOutcomeSnapshot, CompactionSnapshot, LocalhostGatewayBootstrapMetadata, MissedCollaborationDiagnostic, ProviderKind, ProviderCollaborationContext,
|
|
2
|
+
import type { AttentionSnapshot, ProjectionStrategy, CollaborationCapabilityDeclaration, CollaborationOutcomeSnapshot, CompactionSnapshot, LocalhostGatewayBootstrapMetadata, MissedCollaborationDiagnostic, ProviderKind, ProviderCollaborationContext, ResolvedWorkingFolderContext, RuntimeSurface, SkillRuntimeBootstrapMetadata, TaskThreadCollaborationContract, TaskAssignmentThreadContext } from '../types.js';
|
|
3
3
|
export interface SkillRuntimeBootstrapPayload {
|
|
4
4
|
skillDirectoryPath: string;
|
|
5
5
|
nodeCliPath: string;
|
|
@@ -18,7 +18,13 @@ export interface ChannelContextPayload {
|
|
|
18
18
|
skillRuntime?: SkillRuntimeBootstrapPayload;
|
|
19
19
|
localhostGateway?: LocalhostGatewayBootstrapMetadata;
|
|
20
20
|
taskAssignmentContext?: TaskAssignmentThreadContext;
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Serialized into `context.json` and echoed by the gateway bootstrap response, so the key name is
|
|
23
|
+
* observable outside this process: `cleanup --purge` reads payloads written by whichever version
|
|
24
|
+
* happened to run last, and a payload whose key it does not recognize is skipped, silently leaving
|
|
25
|
+
* the directory it names on disk.
|
|
26
|
+
*/
|
|
27
|
+
resolvedWorkspace?: ResolvedWorkingFolderContext;
|
|
22
28
|
}
|
|
23
29
|
export interface PreparedChannelContext {
|
|
24
30
|
directoryPath: string;
|
|
@@ -29,7 +35,7 @@ export interface PreparedChannelContext {
|
|
|
29
35
|
gatewayCredentialPath?: string;
|
|
30
36
|
skillRuntime?: SkillRuntimeBootstrapMetadata;
|
|
31
37
|
localhostGateway?: LocalhostGatewayBootstrapMetadata;
|
|
32
|
-
|
|
38
|
+
resolvedWorkingFolder?: ResolvedWorkingFolderContext;
|
|
33
39
|
}
|
|
34
40
|
export declare class ChannelContextPreparationError extends Error {
|
|
35
41
|
readonly partialContext: PreparedChannelContext;
|
|
@@ -109,7 +115,7 @@ interface FileChannelContextStoreOptions {
|
|
|
109
115
|
skillRuntimeEnabled?: boolean;
|
|
110
116
|
skillAssetResolver?: SkillAssetResolver;
|
|
111
117
|
localhostGateway?: LocalhostGatewayContextPublisher;
|
|
112
|
-
|
|
118
|
+
workingFolderCollectionRootDir?: string;
|
|
113
119
|
taskReader?: Pick<ChatControlPlane, 'getTask' | 'listChannels' | 'listTasks' | 'listUsers'>;
|
|
114
120
|
taskResolutionTimeoutMs?: number;
|
|
115
121
|
allowCrossAgentIndependentWorkspaceHandoff?: boolean;
|
|
@@ -128,13 +134,13 @@ export declare function resolveChannelContextDirectory(stateRootDir: string, cha
|
|
|
128
134
|
export declare function resolveChannelContextPayloadPath(stateRootDir: string, channelId: string): string;
|
|
129
135
|
export declare function resolveTaskAssignmentStateDirectory(stateRootDir: string, channelId: string): string;
|
|
130
136
|
export declare function resolveTaskAssignmentStatePath(stateRootDir: string, channelId: string): string;
|
|
131
|
-
export declare function
|
|
132
|
-
export declare function
|
|
133
|
-
export declare function
|
|
134
|
-
export declare function
|
|
135
|
-
export declare function
|
|
136
|
-
export declare const
|
|
137
|
-
export declare function
|
|
137
|
+
export declare function resolveTaskWorkingFolderRootDirectory(channelRootDir: string): string;
|
|
138
|
+
export declare function resolveManagedWorkingFolderCollectionRoot(workingFolderCollectionRootDir: string | undefined, env?: NodeJS.ProcessEnv, resolvedHomeDir?: string): string;
|
|
139
|
+
export declare function resolveChannelWorkingFolderRootDirectory(workingFolderCollectionRootDir: string, channelId: string): string;
|
|
140
|
+
export declare function resolveChannelWorkingFolderDirectory(workingFolderCollectionRootDir: string, channelId: string): string;
|
|
141
|
+
export declare function resolveTaskIsolatedWorkingFolderDirectory(workingFolderCollectionRootDir: string, channelId: string, taskId: string): string;
|
|
142
|
+
export declare const resolveTaskWorkingFolderDirectory: typeof resolveTaskIsolatedWorkingFolderDirectory;
|
|
143
|
+
export declare function resolveTaskThreadScratchWorkingFolderDirectory(workingFolderCollectionRootDir: string, channelId: string): string;
|
|
138
144
|
export declare function resolveChannelGatewayCredentialPath(stateRootDir: string, channelId: string): string;
|
|
139
145
|
export declare function resolveGatewayCredentialPathFromPayloadPath(payloadPath: string): string;
|
|
140
146
|
export declare function resolveClaudeProjectedBriefPathFromPayloadPath(payloadPath: string): string;
|
|
@@ -146,7 +152,7 @@ export declare class FileChannelContextStore implements ChannelContextStore {
|
|
|
146
152
|
private readonly skillRuntimeEnabled;
|
|
147
153
|
private readonly skillAssetResolver;
|
|
148
154
|
private readonly localhostGateway?;
|
|
149
|
-
private readonly
|
|
155
|
+
private readonly workingFolderCollectionRootDir;
|
|
150
156
|
private readonly taskReader?;
|
|
151
157
|
private readonly taskResolutionTimeoutMs;
|
|
152
158
|
private readonly allowCrossAgentIndependentWorkspaceHandoff;
|