@zengxingyuan/aamp-cli-bridge 0.1.7-dev.1
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 +326 -0
- package/dist/agent-bridge.d.ts +42 -0
- package/dist/agent-bridge.js +709 -0
- package/dist/agent-bridge.js.map +1 -0
- package/dist/bridge.d.ts +12 -0
- package/dist/bridge.js +58 -0
- package/dist/bridge.js.map +1 -0
- package/dist/cli/init.d.ts +9 -0
- package/dist/cli/init.js +656 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/profile-maker.d.ts +1 -0
- package/dist/cli/profile-maker.js +136 -0
- package/dist/cli/profile-maker.js.map +1 -0
- package/dist/cli-agent-client.d.ts +21 -0
- package/dist/cli-agent-client.js +150 -0
- package/dist/cli-agent-client.js.map +1 -0
- package/dist/cli-profiles.d.ts +10 -0
- package/dist/cli-profiles.js +97 -0
- package/dist/cli-profiles.js.map +1 -0
- package/dist/config.d.ts +639 -0
- package/dist/config.js +95 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +256 -0
- package/dist/index.js.map +1 -0
- package/dist/pairing.d.ts +39 -0
- package/dist/pairing.js +110 -0
- package/dist/pairing.js.map +1 -0
- package/dist/prompt-builder.d.ts +15 -0
- package/dist/prompt-builder.js +388 -0
- package/dist/prompt-builder.js.map +1 -0
- package/dist/storage.d.ts +7 -0
- package/dist/storage.js +65 -0
- package/dist/storage.js.map +1 -0
- package/dist/stream-parser.d.ts +26 -0
- package/dist/stream-parser.js +155 -0
- package/dist/stream-parser.js.map +1 -0
- package/package.json +32 -0
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
const STRUCTURED_RESULT_MARKER = 'AAMP_RESULT_JSON:';
|
|
2
|
+
function isConversationalTask(task) {
|
|
3
|
+
const source = task.dispatchContext?.source?.trim().toLowerCase();
|
|
4
|
+
return source === 'feishu' || source === 'wechat' || source === 'ios';
|
|
5
|
+
}
|
|
6
|
+
function displayAgentName(task, agentName) {
|
|
7
|
+
const trimmed = agentName?.trim();
|
|
8
|
+
if (trimmed)
|
|
9
|
+
return trimmed;
|
|
10
|
+
return task.to.split('@')[0] || 'the connected agent';
|
|
11
|
+
}
|
|
12
|
+
function isCliTranscriptHeader(line) {
|
|
13
|
+
return /^\[(acpx|client|tool|done|error|warning)\](?:\s|$)/i.test(line);
|
|
14
|
+
}
|
|
15
|
+
function buildStructuredResultInstructions() {
|
|
16
|
+
return [
|
|
17
|
+
`Structured result handoff:`,
|
|
18
|
+
`- If the task asks for structuredResult, field backfill, Meego field output, attachments, or aamp_send_result, include a final ${STRUCTURED_RESULT_MARKER} block.`,
|
|
19
|
+
`- The block must be valid JSON and may include output, structuredResult, and attachments.`,
|
|
20
|
+
`- Attachment entries should include filename, contentType, and path.`,
|
|
21
|
+
`- Use this shape:`,
|
|
22
|
+
`${STRUCTURED_RESULT_MARKER}`,
|
|
23
|
+
'```json',
|
|
24
|
+
'{"output":"Human-readable summary.","attachments":[{"filename":"file.zip","contentType":"application/zip","path":"/absolute/path/to/file.zip"}],"structuredResult":[{"fieldKey":"<fieldKey>","fieldTypeKey":"<fieldTypeKey>","value":"<field value>"}]}',
|
|
25
|
+
'```',
|
|
26
|
+
`- For attachment fields, also reference attached files with attachmentFilenames.`,
|
|
27
|
+
`- The bridge strips this block from the visible reply, sends structuredResult as X-AAMP-StructuredResult, and sends attachments as email attachments.`,
|
|
28
|
+
].join('\n');
|
|
29
|
+
}
|
|
30
|
+
function sanitizeAgentResponse(output) {
|
|
31
|
+
const trimmed = output.trim();
|
|
32
|
+
if (!trimmed)
|
|
33
|
+
return '';
|
|
34
|
+
if (!trimmed.split(/\r?\n/).some((line) => isCliTranscriptHeader(line))) {
|
|
35
|
+
return trimmed;
|
|
36
|
+
}
|
|
37
|
+
const lines = trimmed.replace(/\r\n/g, '\n').split('\n');
|
|
38
|
+
const textBlocks = [];
|
|
39
|
+
let currentBlock = [];
|
|
40
|
+
let skippingTranscriptDetails = false;
|
|
41
|
+
const flushBlock = () => {
|
|
42
|
+
const block = currentBlock.join('\n').trim();
|
|
43
|
+
if (block)
|
|
44
|
+
textBlocks.push(block);
|
|
45
|
+
currentBlock = [];
|
|
46
|
+
};
|
|
47
|
+
for (const line of lines) {
|
|
48
|
+
if (isCliTranscriptHeader(line)) {
|
|
49
|
+
flushBlock();
|
|
50
|
+
skippingTranscriptDetails = true;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (skippingTranscriptDetails) {
|
|
54
|
+
if (!line || /^[ \t]+/.test(line)) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
skippingTranscriptDetails = false;
|
|
58
|
+
}
|
|
59
|
+
currentBlock.push(line);
|
|
60
|
+
}
|
|
61
|
+
flushBlock();
|
|
62
|
+
return textBlocks.at(-1) ?? '';
|
|
63
|
+
}
|
|
64
|
+
function asRecord(value) {
|
|
65
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
66
|
+
return null;
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
function asString(value) {
|
|
70
|
+
return typeof value === 'string' && value.trim() ? value.trim() : undefined;
|
|
71
|
+
}
|
|
72
|
+
function normalizeStructuredResultField(value) {
|
|
73
|
+
const record = asRecord(value);
|
|
74
|
+
if (!record)
|
|
75
|
+
return null;
|
|
76
|
+
const fieldKey = asString(record.fieldKey);
|
|
77
|
+
const fieldTypeKey = asString(record.fieldTypeKey);
|
|
78
|
+
const fieldAlias = asString(record.fieldAlias);
|
|
79
|
+
const index = asString(record.index);
|
|
80
|
+
const attachmentFilenames = Array.isArray(record.attachmentFilenames)
|
|
81
|
+
&& record.attachmentFilenames.every((item) => typeof item === 'string')
|
|
82
|
+
? record.attachmentFilenames
|
|
83
|
+
: undefined;
|
|
84
|
+
const hasValue = Object.prototype.hasOwnProperty.call(record, 'value');
|
|
85
|
+
if (!fieldKey && !fieldTypeKey && !fieldAlias && !index && !attachmentFilenames?.length && !hasValue) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
...(fieldKey ? { fieldKey } : {}),
|
|
90
|
+
...(fieldTypeKey ? { fieldTypeKey } : {}),
|
|
91
|
+
...(hasValue ? { value: record.value } : {}),
|
|
92
|
+
...(fieldAlias ? { fieldAlias } : {}),
|
|
93
|
+
...(index ? { index } : {}),
|
|
94
|
+
...(attachmentFilenames ? { attachmentFilenames } : {}),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function normalizeStructuredResult(value) {
|
|
98
|
+
if (!Array.isArray(value))
|
|
99
|
+
return undefined;
|
|
100
|
+
const fields = value
|
|
101
|
+
.map((item) => normalizeStructuredResultField(item))
|
|
102
|
+
.filter((item) => item != null);
|
|
103
|
+
return fields.length ? fields : undefined;
|
|
104
|
+
}
|
|
105
|
+
function normalizeAttachmentRef(value) {
|
|
106
|
+
if (typeof value === 'string' && value.trim()) {
|
|
107
|
+
return { path: value.trim() };
|
|
108
|
+
}
|
|
109
|
+
const record = asRecord(value);
|
|
110
|
+
if (!record)
|
|
111
|
+
return null;
|
|
112
|
+
const path = asString(record.path ?? record.filePath ?? record.file);
|
|
113
|
+
if (!path)
|
|
114
|
+
return null;
|
|
115
|
+
const filename = asString(record.filename ?? record.name);
|
|
116
|
+
const contentType = asString(record.contentType ?? record.mimeType ?? record.type);
|
|
117
|
+
return {
|
|
118
|
+
path,
|
|
119
|
+
...(filename ? { filename } : {}),
|
|
120
|
+
...(contentType ? { contentType } : {}),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function normalizeAttachments(value) {
|
|
124
|
+
if (typeof value === 'string') {
|
|
125
|
+
const attachment = normalizeAttachmentRef(value);
|
|
126
|
+
return attachment ? [attachment] : undefined;
|
|
127
|
+
}
|
|
128
|
+
if (!Array.isArray(value))
|
|
129
|
+
return undefined;
|
|
130
|
+
const attachments = value
|
|
131
|
+
.map((item) => normalizeAttachmentRef(item))
|
|
132
|
+
.filter((item) => item != null);
|
|
133
|
+
return attachments.length ? attachments : undefined;
|
|
134
|
+
}
|
|
135
|
+
function parseStructuredPayload(value) {
|
|
136
|
+
const record = asRecord(value);
|
|
137
|
+
const structuredResult = Array.isArray(value)
|
|
138
|
+
? normalizeStructuredResult(value)
|
|
139
|
+
: normalizeStructuredResult(record?.structuredResult ?? record?.structured_result);
|
|
140
|
+
const attachments = normalizeAttachments(record?.attachments ?? record?.attachment);
|
|
141
|
+
if (!structuredResult?.length && !attachments?.length)
|
|
142
|
+
return null;
|
|
143
|
+
const output = asString(record?.output);
|
|
144
|
+
return {
|
|
145
|
+
...(output ? { output } : {}),
|
|
146
|
+
...(structuredResult ? { structuredResult } : {}),
|
|
147
|
+
...(attachments ? { attachments } : {}),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function extractBalancedJsonRange(source) {
|
|
151
|
+
const start = source.search(/[\[{]/);
|
|
152
|
+
if (start < 0)
|
|
153
|
+
return null;
|
|
154
|
+
const stack = [];
|
|
155
|
+
let inString = false;
|
|
156
|
+
let escaped = false;
|
|
157
|
+
for (let i = start; i < source.length; i += 1) {
|
|
158
|
+
const char = source[i];
|
|
159
|
+
if (inString) {
|
|
160
|
+
if (escaped) {
|
|
161
|
+
escaped = false;
|
|
162
|
+
}
|
|
163
|
+
else if (char === '\\') {
|
|
164
|
+
escaped = true;
|
|
165
|
+
}
|
|
166
|
+
else if (char === '"') {
|
|
167
|
+
inString = false;
|
|
168
|
+
}
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
if (char === '"') {
|
|
172
|
+
inString = true;
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
if (char === '{' || char === '[') {
|
|
176
|
+
stack.push(char);
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
if (char !== '}' && char !== ']')
|
|
180
|
+
continue;
|
|
181
|
+
const opener = stack.pop();
|
|
182
|
+
if ((char === '}' && opener !== '{') || (char === ']' && opener !== '[')) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
if (stack.length === 0) {
|
|
186
|
+
return {
|
|
187
|
+
jsonText: source.slice(start, i + 1),
|
|
188
|
+
start,
|
|
189
|
+
end: i + 1,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
function extractJsonFromMaybeFence(source) {
|
|
196
|
+
const trimmedStart = source.search(/\S/);
|
|
197
|
+
if (trimmedStart < 0)
|
|
198
|
+
return null;
|
|
199
|
+
const body = source.slice(trimmedStart);
|
|
200
|
+
const fenceMatch = /^```(?:json)?\s*\n?([\s\S]*?)\n?```/i.exec(body);
|
|
201
|
+
if (fenceMatch) {
|
|
202
|
+
const jsonText = fenceMatch[1].trim();
|
|
203
|
+
return {
|
|
204
|
+
jsonText,
|
|
205
|
+
start: trimmedStart,
|
|
206
|
+
end: trimmedStart + fenceMatch[0].length,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
return extractBalancedJsonRange(source);
|
|
210
|
+
}
|
|
211
|
+
function parsePayloadJson(jsonText) {
|
|
212
|
+
try {
|
|
213
|
+
return parseStructuredPayload(JSON.parse(jsonText));
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function extractMarkedStructuredPayload(text) {
|
|
220
|
+
const markerIndex = text.lastIndexOf(STRUCTURED_RESULT_MARKER);
|
|
221
|
+
if (markerIndex < 0)
|
|
222
|
+
return null;
|
|
223
|
+
const before = text.slice(0, markerIndex).trim();
|
|
224
|
+
const after = text.slice(markerIndex + STRUCTURED_RESULT_MARKER.length);
|
|
225
|
+
const jsonRange = extractJsonFromMaybeFence(after);
|
|
226
|
+
if (!jsonRange)
|
|
227
|
+
return null;
|
|
228
|
+
const payload = parsePayloadJson(jsonRange.jsonText);
|
|
229
|
+
if (!payload)
|
|
230
|
+
return null;
|
|
231
|
+
const trailing = after.slice(jsonRange.end).trim();
|
|
232
|
+
const visibleOutput = payload.output ?? [before, trailing].filter(Boolean).join('\n\n').trim();
|
|
233
|
+
return {
|
|
234
|
+
output: visibleOutput,
|
|
235
|
+
...(payload.structuredResult ? { structuredResult: payload.structuredResult } : {}),
|
|
236
|
+
...(payload.attachments ? { attachments: payload.attachments } : {}),
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function extractWholeJsonStructuredPayload(text) {
|
|
240
|
+
const trimmed = text.trim();
|
|
241
|
+
const range = extractJsonFromMaybeFence(trimmed);
|
|
242
|
+
if (!range || range.start !== 0 || range.end !== trimmed.length)
|
|
243
|
+
return null;
|
|
244
|
+
const payload = parsePayloadJson(range.jsonText);
|
|
245
|
+
if (!payload)
|
|
246
|
+
return null;
|
|
247
|
+
return {
|
|
248
|
+
output: payload.output ?? '',
|
|
249
|
+
...(payload.structuredResult ? { structuredResult: payload.structuredResult } : {}),
|
|
250
|
+
...(payload.attachments ? { attachments: payload.attachments } : {}),
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
function extractLooseStructuredResult(text) {
|
|
254
|
+
const match = /(?:^|\n)\s*structuredResult\s*:\s*/i.exec(text);
|
|
255
|
+
if (!match)
|
|
256
|
+
return null;
|
|
257
|
+
const valueStart = match.index + match[0].length;
|
|
258
|
+
const after = text.slice(valueStart);
|
|
259
|
+
const range = extractBalancedJsonRange(after);
|
|
260
|
+
if (!range)
|
|
261
|
+
return null;
|
|
262
|
+
const structuredResult = normalizeStructuredResult(JSON.parse(range.jsonText));
|
|
263
|
+
if (!structuredResult?.length)
|
|
264
|
+
return null;
|
|
265
|
+
const before = text.slice(0, match.index).trim();
|
|
266
|
+
const trailing = after.slice(range.end).trim();
|
|
267
|
+
return {
|
|
268
|
+
output: [before, trailing].filter(Boolean).join('\n\n').trim(),
|
|
269
|
+
structuredResult,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
function extractResultPayload(text) {
|
|
273
|
+
const marked = extractMarkedStructuredPayload(text);
|
|
274
|
+
if (marked)
|
|
275
|
+
return marked;
|
|
276
|
+
const wholeJson = extractWholeJsonStructuredPayload(text);
|
|
277
|
+
if (wholeJson)
|
|
278
|
+
return wholeJson;
|
|
279
|
+
try {
|
|
280
|
+
const loose = extractLooseStructuredResult(text);
|
|
281
|
+
if (loose)
|
|
282
|
+
return loose;
|
|
283
|
+
}
|
|
284
|
+
catch {
|
|
285
|
+
// Fall through to plain text if a loose structuredResult block is malformed.
|
|
286
|
+
}
|
|
287
|
+
return { output: text.trim() };
|
|
288
|
+
}
|
|
289
|
+
export function buildPrompt(task, threadContextText, agentName) {
|
|
290
|
+
const agentDisplayName = displayAgentName(task, agentName);
|
|
291
|
+
const dispatchContextLines = task.dispatchContext && Object.keys(task.dispatchContext).length > 0
|
|
292
|
+
? `Dispatch Context:\n${Object.entries(task.dispatchContext).map(([key, value]) => ` - ${key}: ${value}`).join('\n')}`
|
|
293
|
+
: '';
|
|
294
|
+
const parts = isConversationalTask(task)
|
|
295
|
+
? [
|
|
296
|
+
`## AAMP Conversation Turn`,
|
|
297
|
+
``,
|
|
298
|
+
`This task came from a chat surface (${task.dispatchContext?.source ?? 'unknown'}).`,
|
|
299
|
+
`You are ${agentDisplayName}. AAMP and AAMP App are only the transport/client channel, not your identity.`,
|
|
300
|
+
`Treat it as an ongoing conversation turn, not a ticket or work order.`,
|
|
301
|
+
`Reply naturally to the user's latest message and keep the conversation moving.`,
|
|
302
|
+
``,
|
|
303
|
+
`Identity rules:`,
|
|
304
|
+
`- Do not introduce yourself as AAMP, AAMP App, or an AAMP assistant.`,
|
|
305
|
+
`- If you mention who you are, identify as ${agentDisplayName}.`,
|
|
306
|
+
``,
|
|
307
|
+
`Task ID: ${task.taskId}`,
|
|
308
|
+
`From: ${task.from}`,
|
|
309
|
+
`Agent: ${agentDisplayName}`,
|
|
310
|
+
`Title: ${task.title}`,
|
|
311
|
+
`Priority: ${task.priority}`,
|
|
312
|
+
dispatchContextLines,
|
|
313
|
+
task.bodyText ? `Latest user message:\n${task.bodyText}` : '',
|
|
314
|
+
threadContextText?.trim() ? threadContextText : '',
|
|
315
|
+
task.expiresAt ? `Expires At: ${task.expiresAt}` : '',
|
|
316
|
+
``,
|
|
317
|
+
`Execution rules:`,
|
|
318
|
+
`- Treat the latest user message and prior thread context as the only conversation context.`,
|
|
319
|
+
`- Only start your response with "HELP:" when you are truly blocked and need specific missing information.`,
|
|
320
|
+
`- Keep your final reply limited to the final user-facing message.`,
|
|
321
|
+
`- Do not include tool logs or intermediate progress updates in the final reply.`,
|
|
322
|
+
``,
|
|
323
|
+
buildStructuredResultInstructions(),
|
|
324
|
+
``,
|
|
325
|
+
`If you create files, list each file path at the end in this exact format:`,
|
|
326
|
+
`FILE:/absolute/path/to/file`,
|
|
327
|
+
]
|
|
328
|
+
: [
|
|
329
|
+
`## AAMP Task`,
|
|
330
|
+
``,
|
|
331
|
+
`You are ${agentDisplayName}. AAMP and AAMP App are only the transport/client channel, not your identity.`,
|
|
332
|
+
`Do not introduce yourself as AAMP, AAMP App, or an AAMP assistant. If you mention who you are, identify as ${agentDisplayName}.`,
|
|
333
|
+
``,
|
|
334
|
+
`Task ID: ${task.taskId}`,
|
|
335
|
+
`From: ${task.from}`,
|
|
336
|
+
`Agent: ${agentDisplayName}`,
|
|
337
|
+
`Title: ${task.title}`,
|
|
338
|
+
`Priority: ${task.priority}`,
|
|
339
|
+
dispatchContextLines,
|
|
340
|
+
task.bodyText ? `Description:\n${task.bodyText}` : '',
|
|
341
|
+
threadContextText?.trim() ? threadContextText : '',
|
|
342
|
+
task.expiresAt ? `Expires At: ${task.expiresAt}` : '',
|
|
343
|
+
``,
|
|
344
|
+
`Execution rules:`,
|
|
345
|
+
`- Treat the Description section and prior thread context as the only task context.`,
|
|
346
|
+
`- If you need more information, start your response with "HELP:" followed by your question.`,
|
|
347
|
+
`- Keep your final reply limited to the final user-facing result.`,
|
|
348
|
+
`- Do not include tool logs or intermediate progress updates in the final reply.`,
|
|
349
|
+
``,
|
|
350
|
+
buildStructuredResultInstructions(),
|
|
351
|
+
``,
|
|
352
|
+
`If you create files, list each file path at the end in this exact format:`,
|
|
353
|
+
`FILE:/absolute/path/to/file`,
|
|
354
|
+
];
|
|
355
|
+
return parts.filter(Boolean).join('\n');
|
|
356
|
+
}
|
|
357
|
+
export function parseResponse(output) {
|
|
358
|
+
const trimmed = sanitizeAgentResponse(output);
|
|
359
|
+
if (trimmed.startsWith('HELP:')) {
|
|
360
|
+
return {
|
|
361
|
+
isHelp: true,
|
|
362
|
+
question: trimmed.slice(5).trim(),
|
|
363
|
+
output: '',
|
|
364
|
+
files: [],
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
const files = [];
|
|
368
|
+
const outputLines = [];
|
|
369
|
+
for (const line of trimmed.split('\n')) {
|
|
370
|
+
if (line.startsWith('FILE:')) {
|
|
371
|
+
const path = line.slice(5).trim();
|
|
372
|
+
if (path)
|
|
373
|
+
files.push(path);
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
outputLines.push(line);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
const structured = extractResultPayload(outputLines.join('\n').trim());
|
|
380
|
+
return {
|
|
381
|
+
isHelp: false,
|
|
382
|
+
output: structured.output,
|
|
383
|
+
files,
|
|
384
|
+
...(structured.structuredResult ? { structuredResult: structured.structuredResult } : {}),
|
|
385
|
+
...(structured.attachments ? { attachments: structured.attachments } : {}),
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
//# sourceMappingURL=prompt-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-builder.js","sourceRoot":"","sources":["../src/prompt-builder.ts"],"names":[],"mappings":"AAEA,MAAM,wBAAwB,GAAG,mBAAmB,CAAA;AAcpD,SAAS,oBAAoB,CAAC,IAAkB;IAC9C,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,WAAW,EA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EAAE,CAAC;QAChC,OAAO;YACL,MAAM,EAAE,IAAI;YACZ,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;YACjC,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,EAAE;SACV,CAAA;IACH,CAAC;IAED,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,MAAM,WAAW,GAAa,EAAE,CAAA;IAChC,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACvC,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;YACjC,IAAI,IAAI;gBAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC5B,CAAC;aAAM,CAAC;YACN,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACxB,CAAC;IACH,CAAC;IAED,MAAM,UAAU,GAAG,oBAAoB,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;IAEtE,OAAO;QACL,MAAM,EAAE,KAAK;QACb,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,KAAK;QACL,GAAG,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzF,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC3E,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function getBridgeHomeDir(): string;
|
|
2
|
+
export declare function getDefaultConfigPath(): string;
|
|
3
|
+
export declare function getDefaultCredentialsPath(agentName: string): string;
|
|
4
|
+
export declare function getDefaultProfilesDir(): string;
|
|
5
|
+
export declare function getDefaultProfilePath(profileName: string): string;
|
|
6
|
+
export declare function resolveConfigPath(pathValue?: string): string;
|
|
7
|
+
export declare function resolveCredentialsFile(pathValue: string | undefined, agentName: string): string;
|
package/dist/storage.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { dirname, join, resolve } from 'node:path';
|
|
4
|
+
const DEFAULT_CONFIG_FILENAME = 'config.json';
|
|
5
|
+
function expandHomePath(pathValue) {
|
|
6
|
+
if (pathValue === '~')
|
|
7
|
+
return homedir();
|
|
8
|
+
if (pathValue.startsWith('~/'))
|
|
9
|
+
return join(homedir(), pathValue.slice(2));
|
|
10
|
+
return pathValue;
|
|
11
|
+
}
|
|
12
|
+
function writeFileIfMissing(targetPath, content) {
|
|
13
|
+
if (existsSync(targetPath))
|
|
14
|
+
return;
|
|
15
|
+
mkdirSync(dirname(targetPath), { recursive: true });
|
|
16
|
+
writeFileSync(targetPath, content);
|
|
17
|
+
}
|
|
18
|
+
function getResolvedBridgeHomeDir() {
|
|
19
|
+
return join(homedir(), '.aamp', 'cli-bridge');
|
|
20
|
+
}
|
|
21
|
+
function migrateDraftCliBridgeConfigIfNeeded(targetPath) {
|
|
22
|
+
if (existsSync(targetPath))
|
|
23
|
+
return;
|
|
24
|
+
const draftPath = resolve(process.cwd(), 'cli-bridge.json');
|
|
25
|
+
if (!existsSync(draftPath))
|
|
26
|
+
return;
|
|
27
|
+
const raw = readFileSync(draftPath, 'utf8');
|
|
28
|
+
try {
|
|
29
|
+
const parsed = JSON.parse(raw);
|
|
30
|
+
writeFileIfMissing(targetPath, `${JSON.stringify(parsed, null, 2)}\n`);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
writeFileIfMissing(targetPath, raw);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function getBridgeHomeDir() {
|
|
37
|
+
return getResolvedBridgeHomeDir();
|
|
38
|
+
}
|
|
39
|
+
export function getDefaultConfigPath() {
|
|
40
|
+
return join(getBridgeHomeDir(), DEFAULT_CONFIG_FILENAME);
|
|
41
|
+
}
|
|
42
|
+
export function getDefaultCredentialsPath(agentName) {
|
|
43
|
+
return join(getBridgeHomeDir(), 'credentials', `${agentName}.json`);
|
|
44
|
+
}
|
|
45
|
+
export function getDefaultProfilesDir() {
|
|
46
|
+
return join(getBridgeHomeDir(), 'profiles');
|
|
47
|
+
}
|
|
48
|
+
export function getDefaultProfilePath(profileName) {
|
|
49
|
+
return join(getDefaultProfilesDir(), `${profileName}.json`);
|
|
50
|
+
}
|
|
51
|
+
export function resolveConfigPath(pathValue) {
|
|
52
|
+
const raw = pathValue?.trim();
|
|
53
|
+
if (raw)
|
|
54
|
+
return resolve(expandHomePath(raw));
|
|
55
|
+
const targetPath = getDefaultConfigPath();
|
|
56
|
+
migrateDraftCliBridgeConfigIfNeeded(targetPath);
|
|
57
|
+
return targetPath;
|
|
58
|
+
}
|
|
59
|
+
export function resolveCredentialsFile(pathValue, agentName) {
|
|
60
|
+
const raw = pathValue?.trim();
|
|
61
|
+
if (!raw)
|
|
62
|
+
return getDefaultCredentialsPath(agentName);
|
|
63
|
+
return expandHomePath(raw);
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGlD,MAAM,uBAA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|
|
7
|
+
event: CliStreamEvent;
|
|
8
|
+
textDelta?: string;
|
|
9
|
+
finalText?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function normalizeCliStreamEvent(event: CliStreamEvent): ParsedCliStreamUpdate;
|
|
12
|
+
export declare class SseStreamParser {
|
|
13
|
+
private buffer;
|
|
14
|
+
private eventName;
|
|
15
|
+
private dataLines;
|
|
16
|
+
push(chunk: string): ParsedCliStreamUpdate[];
|
|
17
|
+
flush(): ParsedCliStreamUpdate[];
|
|
18
|
+
private processLine;
|
|
19
|
+
private flushEvent;
|
|
20
|
+
}
|
|
21
|
+
export declare class NdjsonStreamParser {
|
|
22
|
+
private buffer;
|
|
23
|
+
push(chunk: string): ParsedCliStreamUpdate[];
|
|
24
|
+
flush(): ParsedCliStreamUpdate[];
|
|
25
|
+
private parseLine;
|
|
26
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
function parseJsonData(value) {
|
|
2
|
+
const trimmed = value.trim();
|
|
3
|
+
if (!trimmed)
|
|
4
|
+
return undefined;
|
|
5
|
+
try {
|
|
6
|
+
return JSON.parse(trimmed);
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return trimmed;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function asRecord(value) {
|
|
13
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
14
|
+
return undefined;
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
function firstString(record, keys) {
|
|
18
|
+
if (!record)
|
|
19
|
+
return undefined;
|
|
20
|
+
for (const key of keys) {
|
|
21
|
+
const value = record[key];
|
|
22
|
+
if (typeof value === 'string' && value.length > 0)
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
function normalizeEventType(value) {
|
|
28
|
+
return typeof value === 'string' && value.trim() ? value.trim() : undefined;
|
|
29
|
+
}
|
|
30
|
+
export function normalizeCliStreamEvent(event) {
|
|
31
|
+
const record = asRecord(event.data);
|
|
32
|
+
const type = event.type;
|
|
33
|
+
const textDelta = firstString(record, ['delta', 'text_delta', 'textDelta', 'content_delta'])
|
|
34
|
+
?? (['delta', 'text.delta'].includes(type) ? firstString(record, ['text', 'content', 'message']) : undefined)
|
|
35
|
+
?? (type === 'text' ? firstString(record, ['text', 'content', 'message']) : undefined);
|
|
36
|
+
const finalText = ['result', 'final', 'output', 'message'].includes(type)
|
|
37
|
+
? firstString(record, ['output', 'text', 'content', 'message'])
|
|
38
|
+
: undefined;
|
|
39
|
+
return {
|
|
40
|
+
event,
|
|
41
|
+
...(textDelta ? { textDelta } : {}),
|
|
42
|
+
...(finalText ? { finalText } : {}),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export class SseStreamParser {
|
|
46
|
+
buffer = '';
|
|
47
|
+
eventName = 'message';
|
|
48
|
+
dataLines = [];
|
|
49
|
+
push(chunk) {
|
|
50
|
+
this.buffer += chunk.replace(/\r\n/g, '\n');
|
|
51
|
+
const updates = [];
|
|
52
|
+
let newlineIndex = this.buffer.indexOf('\n');
|
|
53
|
+
while (newlineIndex >= 0) {
|
|
54
|
+
const line = this.buffer.slice(0, newlineIndex);
|
|
55
|
+
this.buffer = this.buffer.slice(newlineIndex + 1);
|
|
56
|
+
const update = this.processLine(line);
|
|
57
|
+
if (update)
|
|
58
|
+
updates.push(update);
|
|
59
|
+
newlineIndex = this.buffer.indexOf('\n');
|
|
60
|
+
}
|
|
61
|
+
return updates;
|
|
62
|
+
}
|
|
63
|
+
flush() {
|
|
64
|
+
const updates = [];
|
|
65
|
+
if (this.buffer.trim()) {
|
|
66
|
+
const update = this.processLine(this.buffer);
|
|
67
|
+
if (update)
|
|
68
|
+
updates.push(update);
|
|
69
|
+
}
|
|
70
|
+
this.buffer = '';
|
|
71
|
+
const finalUpdate = this.flushEvent();
|
|
72
|
+
if (finalUpdate)
|
|
73
|
+
updates.push(finalUpdate);
|
|
74
|
+
return updates;
|
|
75
|
+
}
|
|
76
|
+
processLine(line) {
|
|
77
|
+
if (!line.trim()) {
|
|
78
|
+
return this.flushEvent();
|
|
79
|
+
}
|
|
80
|
+
if (line.startsWith(':'))
|
|
81
|
+
return undefined;
|
|
82
|
+
const separatorIndex = line.indexOf(':');
|
|
83
|
+
if (separatorIndex < 0)
|
|
84
|
+
return undefined;
|
|
85
|
+
const field = line.slice(0, separatorIndex).trim();
|
|
86
|
+
const value = line.slice(separatorIndex + 1).replace(/^ /, '');
|
|
87
|
+
if (field === 'event') {
|
|
88
|
+
this.eventName = value || 'message';
|
|
89
|
+
}
|
|
90
|
+
else if (field === 'data') {
|
|
91
|
+
this.dataLines.push(value);
|
|
92
|
+
}
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
flushEvent() {
|
|
96
|
+
if (this.dataLines.length === 0) {
|
|
97
|
+
this.eventName = 'message';
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
const raw = this.dataLines.join('\n');
|
|
101
|
+
const event = {
|
|
102
|
+
type: this.eventName,
|
|
103
|
+
raw,
|
|
104
|
+
data: parseJsonData(raw),
|
|
105
|
+
};
|
|
106
|
+
this.eventName = 'message';
|
|
107
|
+
this.dataLines = [];
|
|
108
|
+
return normalizeCliStreamEvent(event);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
export class NdjsonStreamParser {
|
|
112
|
+
buffer = '';
|
|
113
|
+
push(chunk) {
|
|
114
|
+
this.buffer += chunk.replace(/\r\n/g, '\n');
|
|
115
|
+
const updates = [];
|
|
116
|
+
let newlineIndex = this.buffer.indexOf('\n');
|
|
117
|
+
while (newlineIndex >= 0) {
|
|
118
|
+
const line = this.buffer.slice(0, newlineIndex);
|
|
119
|
+
this.buffer = this.buffer.slice(newlineIndex + 1);
|
|
120
|
+
const update = this.parseLine(line);
|
|
121
|
+
if (update)
|
|
122
|
+
updates.push(update);
|
|
123
|
+
newlineIndex = this.buffer.indexOf('\n');
|
|
124
|
+
}
|
|
125
|
+
return updates;
|
|
126
|
+
}
|
|
127
|
+
flush() {
|
|
128
|
+
const update = this.parseLine(this.buffer);
|
|
129
|
+
this.buffer = '';
|
|
130
|
+
return update ? [update] : [];
|
|
131
|
+
}
|
|
132
|
+
parseLine(line) {
|
|
133
|
+
const trimmed = line.trim();
|
|
134
|
+
if (!trimmed)
|
|
135
|
+
return undefined;
|
|
136
|
+
let parsed;
|
|
137
|
+
try {
|
|
138
|
+
parsed = JSON.parse(trimmed);
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
const record = asRecord(parsed);
|
|
144
|
+
const type = normalizeEventType(record?.event)
|
|
145
|
+
?? normalizeEventType(record?.type)
|
|
146
|
+
?? normalizeEventType(record?.name)
|
|
147
|
+
?? 'message';
|
|
148
|
+
return normalizeCliStreamEvent({
|
|
149
|
+
type,
|
|
150
|
+
raw: trimmed,
|
|
151
|
+
data: parsed,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=stream-parser.js.map
|