@agent-link/agent 0.1.337 → 0.1.339
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/backends/types.d.ts +58 -0
- package/dist/backends/types.js +15 -4
- package/dist/backends/types.js.map +1 -1
- package/dist/connection.js +231 -28
- package/dist/connection.js.map +1 -1
- package/dist/copilot-capabilities-offline.d.ts +254 -0
- package/dist/copilot-capabilities-offline.js +392 -0
- package/dist/copilot-capabilities-offline.js.map +1 -0
- package/dist/copilot-capabilities.d.ts +43 -0
- package/dist/copilot-capabilities.js +128 -0
- package/dist/copilot-capabilities.js.map +1 -0
- package/dist/copilot-capability-service.d.ts +24 -0
- package/dist/copilot-capability-service.js +116 -0
- package/dist/copilot-capability-service.js.map +1 -0
- package/dist/copilot-command-bridge.d.ts +184 -0
- package/dist/copilot-command-bridge.js +1800 -0
- package/dist/copilot-command-bridge.js.map +1 -0
- package/dist/copilot-compaction-barrier.d.ts +36 -0
- package/dist/copilot-compaction-barrier.js +152 -0
- package/dist/copilot-compaction-barrier.js.map +1 -0
- package/dist/copilot-compaction-lifecycle.d.ts +34 -0
- package/dist/copilot-compaction-lifecycle.js +88 -0
- package/dist/copilot-compaction-lifecycle.js.map +1 -0
- package/dist/copilot-compaction-policy.d.ts +5 -0
- package/dist/copilot-compaction-policy.js +7 -0
- package/dist/copilot-compaction-policy.js.map +1 -0
- package/dist/copilot-configuration.d.ts +63 -0
- package/dist/copilot-configuration.js +283 -0
- package/dist/copilot-configuration.js.map +1 -0
- package/dist/copilot-event-scope.d.ts +13 -0
- package/dist/copilot-event-scope.js +26 -0
- package/dist/copilot-event-scope.js.map +1 -0
- package/dist/copilot-fork-metadata.d.ts +9 -0
- package/dist/copilot-fork-metadata.js +86 -0
- package/dist/copilot-fork-metadata.js.map +1 -0
- package/dist/copilot-message-kind.d.ts +21 -0
- package/dist/copilot-message-kind.js +45 -0
- package/dist/copilot-message-kind.js.map +1 -0
- package/dist/copilot-plan-state.d.ts +19 -0
- package/dist/copilot-plan-state.js +180 -0
- package/dist/copilot-plan-state.js.map +1 -0
- package/dist/copilot-request-dispatch.d.ts +10 -0
- package/dist/copilot-request-dispatch.js +31 -0
- package/dist/copilot-request-dispatch.js.map +1 -0
- package/dist/copilot-review-documents.d.ts +17 -0
- package/dist/copilot-review-documents.js +162 -0
- package/dist/copilot-review-documents.js.map +1 -0
- package/dist/copilot-session-activity.d.ts +3 -0
- package/dist/copilot-session-activity.js +94 -0
- package/dist/copilot-session-activity.js.map +1 -0
- package/dist/copilot-sidecar.d.ts +2 -0
- package/dist/copilot-sidecar.js +17 -0
- package/dist/copilot-sidecar.js.map +1 -0
- package/dist/copilot-turn-journal.d.ts +36 -0
- package/dist/copilot-turn-journal.js +246 -0
- package/dist/copilot-turn-journal.js.map +1 -0
- package/dist/copilot-user-requests.d.ts +11 -0
- package/dist/copilot-user-requests.js +84 -0
- package/dist/copilot-user-requests.js.map +1 -0
- package/dist/copilot.d.ts +194 -9
- package/dist/copilot.js +5012 -240
- package/dist/copilot.js.map +1 -1
- package/dist/directory-handlers.js +36 -8
- package/dist/directory-handlers.js.map +1 -1
- package/dist/history-message-transform.d.ts +47 -1
- package/dist/history-message-transform.js +67 -0
- package/dist/history-message-transform.js.map +1 -1
- package/dist/history.d.ts +8 -0
- package/dist/history.js.map +1 -1
- package/dist/provider-command-discovery.d.ts +5 -0
- package/dist/provider-command-discovery.js +49 -1
- package/dist/provider-command-discovery.js.map +1 -1
- package/dist/provider-command-types.d.ts +5 -0
- package/dist/provider-command-types.js.map +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js +1 -1
- package/dist/runtime.js.map +1 -1
- package/dist/search-sessions.js +2 -1
- package/dist/search-sessions.js.map +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { createHash, randomUUID } from 'crypto';
|
|
2
|
+
import { existsSync, readFileSync } from 'fs';
|
|
3
|
+
import { atomicWriteCopilotSidecar } from './copilot-sidecar.js';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
import { isCopilotChildEvent } from './copilot-event-scope.js';
|
|
6
|
+
const FILE = '.agentlink-configuration.json';
|
|
7
|
+
const isRecord = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
8
|
+
const positive = (v) => typeof v === 'number' && Number.isFinite(v) && v > 0 ? v : undefined;
|
|
9
|
+
export function configurationKey(value) {
|
|
10
|
+
return JSON.stringify([value.model || '', value.context || 'default', value.effort || '']);
|
|
11
|
+
}
|
|
12
|
+
export function createCopilotConfiguration(providerId, transport, requested) {
|
|
13
|
+
return { version: 1, revision: randomUUID(), providerId, transport, requested: { ...requested }, effective: {},
|
|
14
|
+
sources: {}, windowEvidenceVersion: 1, status: 'pending', issues: [], updatedAt: new Date().toISOString() };
|
|
15
|
+
}
|
|
16
|
+
export function configurationIssue(config, field, code, message) {
|
|
17
|
+
config.issues = config.issues.filter(issue => !(issue.field === field && issue.code === code));
|
|
18
|
+
config.issues.push({ field, code, message });
|
|
19
|
+
}
|
|
20
|
+
export function confirmConfiguration(config, field, value, source, observedAt = Date.now()) {
|
|
21
|
+
if ((config.evidenceTimes?.[field] || 0) > observedAt)
|
|
22
|
+
return;
|
|
23
|
+
if (field === 'contextWindow') {
|
|
24
|
+
const size = positive(value);
|
|
25
|
+
if (size == null)
|
|
26
|
+
return;
|
|
27
|
+
config.effective.contextWindow = size;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
if (typeof value !== 'string' || !value)
|
|
31
|
+
return;
|
|
32
|
+
config.effective[field] = value;
|
|
33
|
+
}
|
|
34
|
+
config.sources[field] = source;
|
|
35
|
+
(config.evidenceTimes ||= {})[field] = observedAt;
|
|
36
|
+
if (source !== 'capability_declaration') {
|
|
37
|
+
config.issues = config.issues.filter(issue => issue.field !== field || issue.code !== 'unconfirmed');
|
|
38
|
+
}
|
|
39
|
+
config.updatedAt = new Date().toISOString();
|
|
40
|
+
}
|
|
41
|
+
export function finishConfiguration(config) {
|
|
42
|
+
if (config.status === 'failed')
|
|
43
|
+
return config;
|
|
44
|
+
if (config.effective.context === 'default' && config.effective.contextWindow
|
|
45
|
+
&& config.sources.contextWindow !== 'capability_declaration')
|
|
46
|
+
config.observedDefaultWindow = config.effective.contextWindow;
|
|
47
|
+
if (config.requested.context === 'long_context' && config.effective.context === 'long_context'
|
|
48
|
+
&& config.observedDefaultWindow && config.effective.contextWindow
|
|
49
|
+
&& config.effective.contextWindow <= config.observedDefaultWindow) {
|
|
50
|
+
configurationIssue(config, 'context', 'unsupported', 'Provider did not expand the observed context window for Long Context.');
|
|
51
|
+
}
|
|
52
|
+
const fields = ['model', 'context', 'effort'];
|
|
53
|
+
const verifiedSource = (field) => ['provider_config', 'provider_event'].includes(config.sources[field] || '');
|
|
54
|
+
const mismatch = fields.some(field => verifiedSource(field) && config.requested[field] && config.effective[field]
|
|
55
|
+
&& config.requested[field] !== config.effective[field]);
|
|
56
|
+
const missing = fields.some(field => config.requested[field] && (!config.effective[field] || !verifiedSource(field)))
|
|
57
|
+
|| !config.effective.contextWindow || !verifiedSource('contextWindow');
|
|
58
|
+
config.status = mismatch || config.issues.some(issue => issue.code === 'unsupported')
|
|
59
|
+
? 'fallback' : missing ? 'unverified' : 'confirmed';
|
|
60
|
+
return config;
|
|
61
|
+
}
|
|
62
|
+
// Catalogs describe capabilities, not an individual Session's effective budget.
|
|
63
|
+
export function applyModelCatalog(config, response, previous) {
|
|
64
|
+
const models = isRecord(response) && Array.isArray(response.models) ? response.models : null;
|
|
65
|
+
if (!models || !config.requested.model)
|
|
66
|
+
return { effort: config.requested.effort };
|
|
67
|
+
const model = models.find((m) => m.id === config.requested.model);
|
|
68
|
+
if (!model || model.policy?.state === 'disabled') {
|
|
69
|
+
config.status = 'failed';
|
|
70
|
+
throw new Error(`Copilot model ${config.requested.model} is unavailable for ${config.providerId}.`);
|
|
71
|
+
}
|
|
72
|
+
const efforts = model.supportedReasoningEfforts ?? model.capabilities?.supports?.reasoning_effort;
|
|
73
|
+
if (Array.isArray(efforts))
|
|
74
|
+
config.supportedEfforts = efforts.filter((v) => typeof v === 'string');
|
|
75
|
+
const prices = model.billing?.tokenPrices;
|
|
76
|
+
config.declaredWindows = {
|
|
77
|
+
default: positive(prices?.maxPromptTokens),
|
|
78
|
+
long_context: positive(prices?.longContext?.maxPromptTokens),
|
|
79
|
+
};
|
|
80
|
+
config.capabilityFingerprint = createHash('sha256').update(JSON.stringify([
|
|
81
|
+
model.id, model.policy?.state, config.supportedEfforts, model.defaultReasoningEffort, config.declaredWindows,
|
|
82
|
+
])).digest('hex');
|
|
83
|
+
if (config.requested.effort && config.supportedEfforts && !config.supportedEfforts.includes(config.requested.effort)) {
|
|
84
|
+
configurationIssue(config, 'effort', 'unsupported', `Requested effort ${config.requested.effort} is not supported by ${model.id}.`);
|
|
85
|
+
const current = previous?.effective.model === model.id
|
|
86
|
+
&& ['provider_config', 'provider_event'].includes(previous?.sources.effort || '') ? previous?.effective.effort : undefined;
|
|
87
|
+
const fallback = current && config.supportedEfforts.includes(current) ? current
|
|
88
|
+
: typeof model.defaultReasoningEffort === 'string' && config.supportedEfforts.includes(model.defaultReasoningEffort)
|
|
89
|
+
? model.defaultReasoningEffort : undefined;
|
|
90
|
+
return { effort: fallback }; // Omit when no Provider-confirmed default is known.
|
|
91
|
+
}
|
|
92
|
+
return { effort: config.requested.effort };
|
|
93
|
+
}
|
|
94
|
+
const observationScopes = new WeakMap();
|
|
95
|
+
export function resetCopilotConfigurationObservation(config) {
|
|
96
|
+
observationScopes.delete(config);
|
|
97
|
+
}
|
|
98
|
+
export function observeConfigurationEvent(config, event, replayScope) {
|
|
99
|
+
const scope = replayScope || observationScopes.get(config) || { compacting: false };
|
|
100
|
+
if (!replayScope)
|
|
101
|
+
observationScopes.set(config, scope);
|
|
102
|
+
const data = event.data;
|
|
103
|
+
if (isCopilotChildEvent(event))
|
|
104
|
+
return;
|
|
105
|
+
if (event.type === 'session.compaction_start') {
|
|
106
|
+
scope.compacting = true;
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (['session.compaction_complete', 'session.compaction_failed', 'abort', 'session.shutdown'].includes(event.type)) {
|
|
110
|
+
scope.compacting = false;
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
// A compactor can use the SAME model ID with different limits and effort.
|
|
114
|
+
// Model-name filtering alone cannot distinguish it from the main chat.
|
|
115
|
+
if (scope.compacting || !isRecord(data))
|
|
116
|
+
return;
|
|
117
|
+
const model = data.newModel ?? data.selectedModel ?? data.modelCall?.model ?? data.model;
|
|
118
|
+
const parsedTime = Date.parse(event.timestamp);
|
|
119
|
+
const observedAt = Number.isFinite(parsedTime) ? parsedTime : Date.now();
|
|
120
|
+
// Auxiliary classifiers/compactors may call another model within the parent journal.
|
|
121
|
+
if (typeof model === 'string' && config.requested.model && model !== config.requested.model) {
|
|
122
|
+
if (event.type === 'assistant.message') {
|
|
123
|
+
confirmConfiguration(config, 'model', model, 'provider_event', observedAt);
|
|
124
|
+
configurationIssue(config, 'model', 'rejected', `Provider replied with ${model}, not requested ${config.requested.model}.`);
|
|
125
|
+
config.status = 'failed';
|
|
126
|
+
}
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const set = (field, value) => {
|
|
130
|
+
confirmConfiguration(config, field, value, 'provider_event', observedAt);
|
|
131
|
+
};
|
|
132
|
+
if (['session.start', 'session.resume', 'session.model_change'].includes(event.type)) {
|
|
133
|
+
set('model', model);
|
|
134
|
+
set('effort', data.reasoningEffort);
|
|
135
|
+
set('context', data.contextTier === null ? 'default' : data.contextTier);
|
|
136
|
+
}
|
|
137
|
+
if (event.type === 'assistant.message')
|
|
138
|
+
set('model', data.model);
|
|
139
|
+
if (event.type === 'model.turn_started') {
|
|
140
|
+
set('model', data.model);
|
|
141
|
+
set('contextWindow', data.modelInfo?.capabilities?.limits?.max_prompt_tokens);
|
|
142
|
+
}
|
|
143
|
+
const mainCall = !!data.turnId || data.conversation === 'main' || event.main === true;
|
|
144
|
+
if (event.type === 'model.model_call_success' && model && mainCall)
|
|
145
|
+
set('effort', data.reasoningEffort);
|
|
146
|
+
if (event.type === 'session.usage_update')
|
|
147
|
+
set('contextWindow', data.size);
|
|
148
|
+
if (event.type === 'model.model_call_started' && model && mainCall) {
|
|
149
|
+
set('contextWindow', data.modelInfo?.capabilities?.limits?.max_prompt_tokens);
|
|
150
|
+
}
|
|
151
|
+
if (event.type === 'assistant.usage' || event.type === 'session.usage_info') {
|
|
152
|
+
set('model', data.model);
|
|
153
|
+
set('effort', data.reasoningEffort);
|
|
154
|
+
set('context', data.contextTier);
|
|
155
|
+
const inputWindow = positive(data.maxPromptTokens ?? data.contextWindow);
|
|
156
|
+
if (inputWindow != null) {
|
|
157
|
+
set('contextWindow', inputWindow);
|
|
158
|
+
}
|
|
159
|
+
// Bare tokenLimit can be a delayed compactor/buffer budget even AFTER its
|
|
160
|
+
// completion event. It cannot bootstrap an unknown chat input window.
|
|
161
|
+
}
|
|
162
|
+
if (event.type === 'session.usage_checkpoint') {
|
|
163
|
+
const states = Array.isArray(data.promptCacheBreakState) ? data.promptCacheBreakState : [];
|
|
164
|
+
const candidates = states.some((s) => s.conversation === 'main')
|
|
165
|
+
? states.filter((s) => s.conversation === 'main') : states;
|
|
166
|
+
const records = candidates.map((s) => s.models?.[config.requested.model || '']).filter(isRecord)
|
|
167
|
+
.sort((a, b) => Date.parse(a.completed_at || '') - Date.parse(b.completed_at || ''));
|
|
168
|
+
const latest = records.at(-1);
|
|
169
|
+
if (latest)
|
|
170
|
+
set('effort', latest.reasoning_effort);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
export function readConfigurationEvents(config, root, sessionId, since) {
|
|
174
|
+
if (!/^[\w-]+$/.test(sessionId))
|
|
175
|
+
return;
|
|
176
|
+
try {
|
|
177
|
+
const scope = { compacting: false };
|
|
178
|
+
for (const line of readFileSync(join(root, sessionId, 'events.jsonl'), 'utf8').split(/\r?\n/)) {
|
|
179
|
+
if (!line)
|
|
180
|
+
continue;
|
|
181
|
+
try {
|
|
182
|
+
const event = JSON.parse(line);
|
|
183
|
+
if (Date.parse(event.timestamp) >= since) {
|
|
184
|
+
// Replay must not inherit or replace the live notification scope.
|
|
185
|
+
observeConfigurationEvent(config, event, scope);
|
|
186
|
+
}
|
|
187
|
+
else if (!isCopilotChildEvent(event)) {
|
|
188
|
+
if (event.type === 'session.compaction_start')
|
|
189
|
+
scope.compacting = true;
|
|
190
|
+
if (['session.compaction_complete', 'session.compaction_failed', 'abort', 'session.shutdown'].includes(event.type))
|
|
191
|
+
scope.compacting = false;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
catch { /* A partially flushed final JSONL row is retried at the next boundary. */ }
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
catch { /* No journal is created solely for a configuration query. */ }
|
|
198
|
+
}
|
|
199
|
+
export function persistCopilotConfiguration(root, sessionId, config) {
|
|
200
|
+
if (!/^[\w-]+$/.test(sessionId) || !existsSync(join(root, sessionId)))
|
|
201
|
+
return;
|
|
202
|
+
try {
|
|
203
|
+
atomicWriteCopilotSidecar(join(root, sessionId, FILE), JSON.stringify(finishConfiguration(config), null, 2) + '\n', 'utf8');
|
|
204
|
+
}
|
|
205
|
+
catch { /* Configuration evidence must not prevent a completed reply. */ }
|
|
206
|
+
}
|
|
207
|
+
export function readStoredCopilotConfiguration(root, sessionId, providerId) {
|
|
208
|
+
if (!/^[\w-]+$/.test(sessionId))
|
|
209
|
+
return undefined;
|
|
210
|
+
try {
|
|
211
|
+
const value = JSON.parse(readFileSync(join(root, sessionId, FILE), 'utf8'));
|
|
212
|
+
if (value.version !== 1 || value.providerId !== providerId || !['sdk', 'acp'].includes(value.transport)
|
|
213
|
+
|| typeof value.revision !== 'string' || !isRecord(value.requested) || !isRecord(value.effective)
|
|
214
|
+
|| !isRecord(value.sources) || !Array.isArray(value.issues))
|
|
215
|
+
return undefined;
|
|
216
|
+
if (value.sessionId && value.sessionId !== sessionId)
|
|
217
|
+
return undefined;
|
|
218
|
+
for (const field of ['model', 'context', 'effort']) {
|
|
219
|
+
if (value.requested[field] != null && typeof value.requested[field] !== 'string')
|
|
220
|
+
return undefined;
|
|
221
|
+
if (value.effective[field] != null && typeof value.effective[field] !== 'string')
|
|
222
|
+
return undefined;
|
|
223
|
+
}
|
|
224
|
+
if (value.effective.contextWindow != null && positive(value.effective.contextWindow) == null)
|
|
225
|
+
return undefined;
|
|
226
|
+
if (value.windowEvidenceVersion !== 1)
|
|
227
|
+
repairCompactionWindowEvidence(value, root, sessionId);
|
|
228
|
+
return finishConfiguration(value);
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
// Read-only migration: never rewrite native history or fabricate a window from
|
|
235
|
+
// capability declarations. If the only evidence was a compactor, leave it unknown.
|
|
236
|
+
function repairCompactionWindowEvidence(config, root, sessionId) {
|
|
237
|
+
try {
|
|
238
|
+
const replay = createCopilotConfiguration(config.providerId, config.transport, config.requested);
|
|
239
|
+
let compacting = false;
|
|
240
|
+
let polluted = false;
|
|
241
|
+
for (const line of readFileSync(join(root, sessionId, 'events.jsonl'), 'utf8').split(/\r?\n/)) {
|
|
242
|
+
let event;
|
|
243
|
+
try {
|
|
244
|
+
event = JSON.parse(line);
|
|
245
|
+
}
|
|
246
|
+
catch {
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
if (isCopilotChildEvent(event))
|
|
250
|
+
continue;
|
|
251
|
+
if (event.type === 'session.compaction_start')
|
|
252
|
+
compacting = true;
|
|
253
|
+
if (compacting && Date.parse(event.timestamp) === config.evidenceTimes?.contextWindow)
|
|
254
|
+
polluted = true;
|
|
255
|
+
if (['session.compaction_complete', 'session.compaction_failed', 'abort', 'session.shutdown'].includes(event.type))
|
|
256
|
+
compacting = false;
|
|
257
|
+
const context = event.data?.contextTier;
|
|
258
|
+
const model = event.data?.newModel ?? event.data?.selectedModel;
|
|
259
|
+
if (!compacting && ['session.start', 'session.resume', 'session.model_change'].includes(event.type)
|
|
260
|
+
&& ((model && model !== replay.effective.model) || (context && context !== replay.effective.context))) {
|
|
261
|
+
delete replay.effective.contextWindow;
|
|
262
|
+
delete replay.sources.contextWindow;
|
|
263
|
+
if (replay.evidenceTimes)
|
|
264
|
+
delete replay.evidenceTimes.contextWindow;
|
|
265
|
+
}
|
|
266
|
+
observeConfigurationEvent(replay, event);
|
|
267
|
+
}
|
|
268
|
+
if (polluted) {
|
|
269
|
+
delete config.effective.contextWindow;
|
|
270
|
+
delete config.sources.contextWindow;
|
|
271
|
+
if (config.evidenceTimes)
|
|
272
|
+
delete config.evidenceTimes.contextWindow;
|
|
273
|
+
config.issues = config.issues.filter(issue => issue.message !== 'Provider did not expand the observed context window for Long Context.');
|
|
274
|
+
if (replay.effective.model === config.effective.model && replay.effective.context === config.effective.context
|
|
275
|
+
&& replay.effective.contextWindow) {
|
|
276
|
+
confirmConfiguration(config, 'contextWindow', replay.effective.contextWindow, 'provider_event', replay.evidenceTimes?.contextWindow);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
config.windowEvidenceVersion = 1;
|
|
280
|
+
}
|
|
281
|
+
catch { /* Keep old snapshots intact if the journal is unavailable. */ }
|
|
282
|
+
}
|
|
283
|
+
//# sourceMappingURL=copilot-configuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot-configuration.js","sourceRoot":"","sources":["../src/copilot-configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAkC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,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC,CAAC,8DAA8D,CAAC,CAAC;AAC5E,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** SDK events use agentId; older SDK/ACP events use parentToolCallId.
|
|
2
|
+
* parentId is journal ordering, not child ownership. Never use it here.
|
|
3
|
+
*/
|
|
4
|
+
export declare function copilotChildScope(event: {
|
|
5
|
+
agentId?: unknown;
|
|
6
|
+
parentToolCallId?: unknown;
|
|
7
|
+
data?: unknown;
|
|
8
|
+
}): string | undefined;
|
|
9
|
+
export declare function isCopilotChildEvent(event: Parameters<typeof copilotChildScope>[0]): boolean;
|
|
10
|
+
/** Associate agentId-only child text with its real task block, not the main reply. */
|
|
11
|
+
export declare function copilotParentToolCallId(event: Parameters<typeof copilotChildScope>[0] & {
|
|
12
|
+
type?: unknown;
|
|
13
|
+
}, agents: Map<string, string>): string | undefined;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** SDK events use agentId; older SDK/ACP events use parentToolCallId.
|
|
2
|
+
* parentId is journal ordering, not child ownership. Never use it here.
|
|
3
|
+
*/
|
|
4
|
+
export function copilotChildScope(event) {
|
|
5
|
+
const data = event.data && typeof event.data === 'object' ? event.data : {};
|
|
6
|
+
const id = (value) => typeof value === 'string' && value.trim() ? value : undefined;
|
|
7
|
+
const agent = id(event.agentId) ?? id(data.agentId);
|
|
8
|
+
if (agent)
|
|
9
|
+
return `agent:${agent}`;
|
|
10
|
+
const tool = id(data.parentToolCallId) ?? id(event.parentToolCallId);
|
|
11
|
+
return tool ? `tool:${tool}` : undefined;
|
|
12
|
+
}
|
|
13
|
+
export function isCopilotChildEvent(event) {
|
|
14
|
+
return copilotChildScope(event) !== undefined;
|
|
15
|
+
}
|
|
16
|
+
/** Associate agentId-only child text with its real task block, not the main reply. */
|
|
17
|
+
export function copilotParentToolCallId(event, agents) {
|
|
18
|
+
const data = event.data && typeof event.data === 'object' ? event.data : {};
|
|
19
|
+
const agent = typeof event.agentId === 'string' ? event.agentId : data.agentId;
|
|
20
|
+
if (event.type === 'subagent.started' && typeof agent === 'string' && typeof data.toolCallId === 'string') {
|
|
21
|
+
agents.set(agent, data.toolCallId);
|
|
22
|
+
}
|
|
23
|
+
const parent = data.parentToolCallId ?? event.parentToolCallId;
|
|
24
|
+
return typeof parent === 'string' && parent ? parent : typeof agent === 'string' ? agents.get(agent) : undefined;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=copilot-event-scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot-event-scope.js","sourceRoot":"","sources":["../src/copilot-event-scope.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAwE;IACxG,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAA+B,CAAC,CAAC,CAAC,EAAE,CAAC;IACvG,MAAM,EAAE,GAAG,CAAC,KAAc,EAAsB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IACjH,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpD,IAAI,KAAK;QAAE,OAAO,SAAS,KAAK,EAAE,CAAC;IACnC,MAAM,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACrE,OAAO,IAAI,CAAC,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAA8C;IAChF,OAAO,iBAAiB,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC;AAChD,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,uBAAuB,CAAC,KAAmE,EAAE,MAA2B;IACtI,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAA+B,CAAC,CAAC,CAAC,EAAE,CAAC;IACvG,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;IAC/E,IAAI,KAAK,CAAC,IAAI,KAAK,kBAAkB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ,EAAE,CAAC;QAC1G,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACrC,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,CAAC,gBAAgB,IAAI,KAAK,CAAC,gBAAgB,CAAC;IAC/D,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACnH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface CopilotForkMetadata {
|
|
2
|
+
version: 1;
|
|
3
|
+
sessionId: string;
|
|
4
|
+
sourceSessionId: string | null;
|
|
5
|
+
number: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function readCopilotForkMetadata(root: string, sessionId: string): CopilotForkMetadata | undefined;
|
|
8
|
+
/** Immutable reservations keep numbers stable across deletion, retries and Agents. */
|
|
9
|
+
export declare function ensureCopilotForkMetadata(root: string, sessionId: string, sourceSessionId?: string): CopilotForkMetadata | undefined;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { existsSync, linkSync, mkdirSync, readFileSync, readdirSync, unlinkSync, writeFileSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { randomUUID } from 'crypto';
|
|
4
|
+
const FILE = '.agentlink-fork.json';
|
|
5
|
+
const validId = (id) => typeof id === 'string' && /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/.test(id);
|
|
6
|
+
function readRecord(path) {
|
|
7
|
+
try {
|
|
8
|
+
const value = JSON.parse(readFileSync(path, 'utf8'));
|
|
9
|
+
return value.version === 1 && validId(value.sessionId)
|
|
10
|
+
&& (value.sourceSessionId === null || validId(value.sourceSessionId))
|
|
11
|
+
&& Number.isSafeInteger(value.number) && value.number > 0 ? value : undefined;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function readCopilotForkMetadata(root, sessionId) {
|
|
18
|
+
if (!validId(sessionId))
|
|
19
|
+
return undefined;
|
|
20
|
+
const record = readRecord(join(root, sessionId, FILE));
|
|
21
|
+
return record?.sessionId === sessionId ? record : undefined;
|
|
22
|
+
}
|
|
23
|
+
/** Immutable reservations keep numbers stable across deletion, retries and Agents. */
|
|
24
|
+
export function ensureCopilotForkMetadata(root, sessionId, sourceSessionId) {
|
|
25
|
+
if (!validId(sessionId) || (sourceSessionId !== undefined && (!validId(sourceSessionId) || sourceSessionId === sessionId))) {
|
|
26
|
+
throw new Error('Invalid Copilot fork identity');
|
|
27
|
+
}
|
|
28
|
+
// A numbering lookup must never create a Provider Session directory.
|
|
29
|
+
if (!existsSync(join(root, sessionId)))
|
|
30
|
+
return undefined;
|
|
31
|
+
const previous = readCopilotForkMetadata(root, sessionId);
|
|
32
|
+
if (previous)
|
|
33
|
+
return previous;
|
|
34
|
+
const destination = join(root, sessionId, FILE);
|
|
35
|
+
if (existsSync(destination))
|
|
36
|
+
throw new Error('Unreadable Copilot fork metadata');
|
|
37
|
+
const group = join(root, '.agentlink-fork-index', sourceSessionId ? `source-${sourceSessionId}` : 'legacy');
|
|
38
|
+
mkdirSync(group, { recursive: true });
|
|
39
|
+
const numbers = readdirSync(group).filter(name => /^[1-9]\d*\.json$/.test(name));
|
|
40
|
+
const publish = (reservation) => {
|
|
41
|
+
try {
|
|
42
|
+
linkSync(reservation, destination);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
if (error.code !== 'EEXIST')
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
const result = readCopilotForkMetadata(root, sessionId);
|
|
49
|
+
if (!result)
|
|
50
|
+
throw new Error('Unable to publish Copilot fork metadata');
|
|
51
|
+
return result;
|
|
52
|
+
};
|
|
53
|
+
// Recover a reservation made before a crash, without allocating a new number.
|
|
54
|
+
for (const name of numbers) {
|
|
55
|
+
const path = join(group, name);
|
|
56
|
+
const record = readRecord(path);
|
|
57
|
+
if (record?.sessionId === sessionId)
|
|
58
|
+
return publish(path);
|
|
59
|
+
}
|
|
60
|
+
let number = numbers.reduce((max, name) => Math.max(max, Number(name.slice(0, -5))), 0) + 1;
|
|
61
|
+
for (let attempt = 0; attempt < 1000 && Number.isSafeInteger(number); attempt++, number++) {
|
|
62
|
+
const record = { version: 1, sessionId, sourceSessionId: sourceSessionId || null, number };
|
|
63
|
+
const temporary = join(group, `${randomUUID()}.tmp`);
|
|
64
|
+
const reservation = join(group, `${number}.json`);
|
|
65
|
+
try {
|
|
66
|
+
writeFileSync(temporary, JSON.stringify(record), { flag: 'wx', mode: 0o600 });
|
|
67
|
+
// Linking a fully written record publishes atomically, including on NTFS.
|
|
68
|
+
// Concurrent Agents cannot reserve the same number or overwrite a child.
|
|
69
|
+
try {
|
|
70
|
+
linkSync(temporary, reservation);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
if (error.code === 'EEXIST')
|
|
74
|
+
continue;
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
return publish(reservation);
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
if (existsSync(temporary))
|
|
81
|
+
unlinkSync(temporary);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
throw new Error('Unable to reserve a Copilot fork number');
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=copilot-fork-metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot-fork-metadata.js","sourceRoot":"","sources":["../src/copilot-fork-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAC3G,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AASpC,MAAM,IAAI,GAAG,sBAAsB,CAAC;AACpC,MAAM,OAAO,GAAG,CAAC,EAAW,EAAgB,EAAE,CAAC,OAAO,EAAE,KAAK,QAAQ,IAAI,mCAAmC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAEtH,SAAS,UAAU,CAAC,IAAY;IAC9B,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;QACrD,OAAO,KAAK,CAAC,OAAO,KAAK,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC;eACjD,CAAC,KAAK,CAAC,eAAe,KAAK,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;eAClE,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAClF,CAAC;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M,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC;QAC1F,MAAM,MAAM,GAAwB,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,IAAI,IAAI,EAAE,MAAM,EAAE,CAAC;QAChH,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,EAAE,GAAG,UAAU,EAAE,MAAM,CAAC,CAAC;QACrD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,EAAE,GAAG,MAAM,OAAO,CAAC,CAAC;QAClD,IAAI,CAAC;YACH,aAAa,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;YAC9E,0EAA0E;YAC1E,yEAAyE;YACzE,IAAI,CAAC;gBAAC,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;YAAC,CAAC;YACzC,OAAO,KAAK,EAAE,CAAC;gBACb,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;oBAAE,SAAS;gBACjE,MAAM,KAAK,CAAC;YACd,CAAC;YACD,OAAO,OAAO,CAAC,WAAW,CAAC,CAAC;QAC9B,CAAC;gBAAS,CAAC;YACT,IAAI,UAAU,CAAC,SAAS,CAAC;gBAAE,UAAU,CAAC,SAAS,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Structural classification only: language and missing phase are not evidence. */
|
|
2
|
+
export declare function copilotMessageIsProgress(data: {
|
|
3
|
+
phase?: string;
|
|
4
|
+
toolRequests?: unknown[];
|
|
5
|
+
}): boolean;
|
|
6
|
+
/** A new main-model decision, not a late tool result or child output. */
|
|
7
|
+
export declare function copilotReplyContinues(event: {
|
|
8
|
+
type?: string;
|
|
9
|
+
id?: string;
|
|
10
|
+
data?: Record<string, any>;
|
|
11
|
+
}, candidateId: string, finalizedIds?: ReadonlySet<string>): boolean;
|
|
12
|
+
/** Keep replies after process blocks within each visible transcript section.
|
|
13
|
+
* User messages, inline questions and Plan snapshots remain fixed boundaries.
|
|
14
|
+
*/
|
|
15
|
+
export declare function orderCopilotHistoryReplies<T extends {
|
|
16
|
+
role: string;
|
|
17
|
+
content: string;
|
|
18
|
+
isThinking?: boolean;
|
|
19
|
+
isProgress?: boolean;
|
|
20
|
+
planId?: string;
|
|
21
|
+
}>(messages: T[], fixedRows?: ReadonlySet<T>): T[];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Structural classification only: language and missing phase are not evidence. */
|
|
2
|
+
export function copilotMessageIsProgress(data) {
|
|
3
|
+
return !!data.toolRequests?.length || ['commentary', 'progress'].includes(data.phase || '');
|
|
4
|
+
}
|
|
5
|
+
/** A new main-model decision, not a late tool result or child output. */
|
|
6
|
+
export function copilotReplyContinues(event, candidateId, finalizedIds = new Set()) {
|
|
7
|
+
const data = event.data || {};
|
|
8
|
+
if (event.type === 'user_input.requested')
|
|
9
|
+
return true;
|
|
10
|
+
if (event.type === 'assistant.message') {
|
|
11
|
+
const id = data.messageId || event.id;
|
|
12
|
+
if (!id && !data.content)
|
|
13
|
+
return false; // Unidentified legacy tool metadata is not a new-model decision.
|
|
14
|
+
if (id === candidateId || finalizedIds.has(id))
|
|
15
|
+
return false;
|
|
16
|
+
const tools = (data.toolRequests || []).filter((tool) => !['task_complete', 'report_intent'].includes(tool.name || ''));
|
|
17
|
+
if (data.toolRequests?.length && tools.length === 0)
|
|
18
|
+
return false;
|
|
19
|
+
return !!data.content?.trim() || tools.length > 0;
|
|
20
|
+
}
|
|
21
|
+
if (['assistant.message_delta', 'assistant.reasoning_delta'].includes(event.type || '')) {
|
|
22
|
+
return !!data.messageId && data.messageId !== candidateId && !finalizedIds.has(data.messageId) && !!data.deltaContent;
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
/** Keep replies after process blocks within each visible transcript section.
|
|
27
|
+
* User messages, inline questions and Plan snapshots remain fixed boundaries.
|
|
28
|
+
*/
|
|
29
|
+
export function orderCopilotHistoryReplies(messages, fixedRows = new Set()) {
|
|
30
|
+
let start = 0;
|
|
31
|
+
for (let end = 0; end <= messages.length; end++) {
|
|
32
|
+
const row = messages[end];
|
|
33
|
+
if (row && !fixedRows.has(row) && !row.planId && (row.role === 'assistant' || row.role === 'tool'))
|
|
34
|
+
continue;
|
|
35
|
+
const section = messages.slice(start, end);
|
|
36
|
+
const replies = section.filter(m => m.role === 'assistant' && !m.isThinking && !m.isProgress && !!m.content.trim());
|
|
37
|
+
if (replies.length) {
|
|
38
|
+
const replySet = new Set(replies);
|
|
39
|
+
messages.splice(start, section.length, ...section.filter(m => !replySet.has(m)), ...replies);
|
|
40
|
+
}
|
|
41
|
+
start = end + 1;
|
|
42
|
+
}
|
|
43
|
+
return messages;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=copilot-message-kind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot-message-kind.js","sourceRoot":"","sources":["../src/copilot-message-kind.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,MAAM,UAAU,wBAAwB,CAAC,IAGxC;IACC,OAAO,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;AAC9F,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,qBAAqB,CAAC,KAAiE,EAAE,WAAmB,EAC1H,eAAoC,IAAI,GAAG,EAAE;IAC7C,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;IAC9B,IAAI,KAAK,CAAC,IAAI,KAAK,sBAAsB;QAAE,OA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,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,IAAI,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC;QAChD,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,WAAW,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,CAAC;YAAE,SAAS;QAC7G,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,IAAI,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QACpH,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;YAClC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC;QAC/F,CAAC;QACD,KAAK,GAAG,GAAG,GAAG,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const COPILOT_PLAN_STATE_FILE = ".agentlink-plan-state.json";
|
|
2
|
+
export type CopilotPlanReadiness = 'awaiting_input' | 'ready';
|
|
3
|
+
export declare function beginCopilotPlanState(root: string, sessionId: string): string;
|
|
4
|
+
export declare function readCopilotPlanState(root: string, sessionId: string, revision: string): CopilotPlanReadiness | null;
|
|
5
|
+
export declare function readCopilotPlanRevision(root: string, sessionId: string): string | null;
|
|
6
|
+
/** Recover only the latest completed main Plan, never a draft or a child artifact. */
|
|
7
|
+
export declare function findRecoverableCopilotPlan(root: string, sessionId: string): {
|
|
8
|
+
content: string;
|
|
9
|
+
revision: string;
|
|
10
|
+
boundaryEventId: string;
|
|
11
|
+
turnId?: string;
|
|
12
|
+
} | null;
|
|
13
|
+
export declare function sealCopilotPlanState(root: string, sessionId: string, revision: string, plan: string, holdPlanMode?: boolean): void;
|
|
14
|
+
export declare function holdsRecoveredCopilotPlanMode(root: string, sessionId: string): boolean;
|
|
15
|
+
export declare function clearRecoveredCopilotPlanMode(root: string, sessionId: string): void;
|
|
16
|
+
export declare function copilotPlanStateAllowsImplementation(root: string, sessionId: string, plan: string): boolean;
|
|
17
|
+
export declare function copilotPlanControlPrompt(root: string, sessionId: string, revision: string, deferred?: string[], nativeUserInput?: boolean): string;
|
|
18
|
+
/** Strip only a well-formed, trailing AgentLink-owned control envelope. */
|
|
19
|
+
export declare function stripCopilotPlanControl(text: string): string;
|