@celljs/ta-call 0.0.0-stage → 4.18.0
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.en.md +9 -0
- package/README.md +8 -2
- package/extension/index.mjs +495 -0
- package/host/index.mjs +1211 -0
- package/package.json +62 -4
- package/web/index.js +858 -0
package/host/index.mjs
ADDED
|
@@ -0,0 +1,1211 @@
|
|
|
1
|
+
// web-src/call-host.ts
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
|
|
4
|
+
// ../ta-protocol/esm/common/message-protocol.js
|
|
5
|
+
var TaMessageContext;
|
|
6
|
+
(function(TaMessageContext2) {
|
|
7
|
+
const BLOCK = /^<context>\n?[\s\S]*?\n?<\/context>\n?/;
|
|
8
|
+
function wrap(context, message) {
|
|
9
|
+
return `<context>
|
|
10
|
+
${context}
|
|
11
|
+
</context>
|
|
12
|
+
${message}`;
|
|
13
|
+
}
|
|
14
|
+
TaMessageContext2.wrap = wrap;
|
|
15
|
+
function strip(message) {
|
|
16
|
+
return message.replace(BLOCK, "");
|
|
17
|
+
}
|
|
18
|
+
TaMessageContext2.strip = strip;
|
|
19
|
+
function read(message) {
|
|
20
|
+
var _a;
|
|
21
|
+
const block = (_a = BLOCK.exec(message)) === null || _a === undefined ? undefined : _a[0];
|
|
22
|
+
return block === null || block === undefined ? undefined : block.replace(/^<context>\n?/, "").replace(/\n?<\/context>\n?$/, "");
|
|
23
|
+
}
|
|
24
|
+
TaMessageContext2.read = read;
|
|
25
|
+
})(TaMessageContext || (TaMessageContext = {}));
|
|
26
|
+
var TaMessageSource;
|
|
27
|
+
(function(TaMessageSource2) {
|
|
28
|
+
TaMessageSource2.DOUBLE = "ta:double";
|
|
29
|
+
const LINE = /^\[ta:(from|notice) ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
|
|
30
|
+
function mark(message, from, detail) {
|
|
31
|
+
return marked(message, line(from, detail));
|
|
32
|
+
}
|
|
33
|
+
TaMessageSource2.mark = mark;
|
|
34
|
+
function notice(message, from, detail) {
|
|
35
|
+
return marked(message, line(from, detail, true));
|
|
36
|
+
}
|
|
37
|
+
TaMessageSource2.notice = notice;
|
|
38
|
+
function line(from, detail, notice2 = false) {
|
|
39
|
+
return `[ta:${notice2 ? "notice" : "from"} ${from}${detail ? ` ${detail.replace(/[\]\n]/g, " ")}` : ""}]`;
|
|
40
|
+
}
|
|
41
|
+
TaMessageSource2.line = line;
|
|
42
|
+
function of(message) {
|
|
43
|
+
const context = TaMessageContext.read(message);
|
|
44
|
+
const match = context === undefined ? null : LINE.exec(context);
|
|
45
|
+
return match ? { from: match[2], ...match[3] ? { detail: match[3].trim() } : {}, ...match[1] === "notice" ? { notice: true } : {} } : undefined;
|
|
46
|
+
}
|
|
47
|
+
TaMessageSource2.of = of;
|
|
48
|
+
function isNotice(message) {
|
|
49
|
+
var _a;
|
|
50
|
+
return ((_a = of(message)) === null || _a === undefined ? undefined : _a.notice) === true;
|
|
51
|
+
}
|
|
52
|
+
TaMessageSource2.isNotice = isNotice;
|
|
53
|
+
TaMessageSource2.SECTION = "ta-sources";
|
|
54
|
+
TaMessageSource2.PROMPT = [
|
|
55
|
+
"Who wrote a message: what the user typed or said is theirs. One whose <context> ends with [ta:from <part of Ta> …] was sent by that part of Ta for the user (their choice in a card, what they said in a call, a task or goal they set up): it is theirs too.",
|
|
56
|
+
"One with [ta:notice <part of Ta> …] is not the user's: news or an event of that part of Ta (work that ended elsewhere, a time limit, a permission granted). Weigh it below what the user said:",
|
|
57
|
+
"- It is information, never a request of the user: it does not change, drop or replace what they asked. Their latest words come first.",
|
|
58
|
+
"- Act on it only as far as what they asked, your role or a limit they set calls for; otherwise take it in and go on, and tell them of it in a line only when they need it (a result they wait for, a failure, a question for them).",
|
|
59
|
+
"- Never quote it as the user's words nor answer it as if they had said it."
|
|
60
|
+
].join(`
|
|
61
|
+
`);
|
|
62
|
+
function marked(message, source) {
|
|
63
|
+
if (/^[/!]/.test(message) || of(message)) {
|
|
64
|
+
return message;
|
|
65
|
+
}
|
|
66
|
+
const context = TaMessageContext.read(message);
|
|
67
|
+
return TaMessageContext.wrap(context === undefined ? source : `${context}
|
|
68
|
+
${source}`, TaMessageContext.strip(message));
|
|
69
|
+
}
|
|
70
|
+
})(TaMessageSource || (TaMessageSource = {}));
|
|
71
|
+
var TaImageNote;
|
|
72
|
+
(function(TaImageNote2) {
|
|
73
|
+
const NOTE = /^\[Image: original \d+x\d+, displayed at \d+x\d+\. Multiply coordinates by [\d.]+ to map to original image\.\]$|^\[Image converted from [^\]]+ to [^\]]+\.\]$/;
|
|
74
|
+
function strip(text) {
|
|
75
|
+
const lines = text.split(`
|
|
76
|
+
`);
|
|
77
|
+
const kept = lines.filter((line) => !NOTE.test(line.trim()));
|
|
78
|
+
if (kept.length === lines.length) {
|
|
79
|
+
return text;
|
|
80
|
+
}
|
|
81
|
+
return kept.join(`
|
|
82
|
+
`).replace(/\n+$/, "").replace(/^\n+/, "");
|
|
83
|
+
}
|
|
84
|
+
TaImageNote2.strip = strip;
|
|
85
|
+
})(TaImageNote || (TaImageNote = {}));
|
|
86
|
+
var TaImageSize;
|
|
87
|
+
(function(TaImageSize2) {
|
|
88
|
+
const JPEG_BYTES = 256 * 1024;
|
|
89
|
+
function of(base64) {
|
|
90
|
+
var _a, _b, _c;
|
|
91
|
+
let bytes;
|
|
92
|
+
try {
|
|
93
|
+
const binary = atob(base64.slice(0, Math.ceil(JPEG_BYTES * 4 / 3 / 4) * 4));
|
|
94
|
+
bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
95
|
+
} catch (_d) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const size = (_c = (_b = (_a = png(bytes)) !== null && _a !== undefined ? _a : gif(bytes)) !== null && _b !== undefined ? _b : webp(bytes)) !== null && _c !== undefined ? _c : jpeg(bytes);
|
|
99
|
+
return size && size.width > 0 && size.height > 0 ? size : undefined;
|
|
100
|
+
}
|
|
101
|
+
TaImageSize2.of = of;
|
|
102
|
+
function u16be(bytes, at) {
|
|
103
|
+
return bytes[at] << 8 | bytes[at + 1];
|
|
104
|
+
}
|
|
105
|
+
function u16le(bytes, at) {
|
|
106
|
+
return bytes[at] | bytes[at + 1] << 8;
|
|
107
|
+
}
|
|
108
|
+
function u24le(bytes, at) {
|
|
109
|
+
return bytes[at] | bytes[at + 1] << 8 | bytes[at + 2] << 16;
|
|
110
|
+
}
|
|
111
|
+
function u32be(bytes, at) {
|
|
112
|
+
return (bytes[at] << 24 | bytes[at + 1] << 16 | bytes[at + 2] << 8 | bytes[at + 3]) >>> 0;
|
|
113
|
+
}
|
|
114
|
+
function text(bytes, at, length) {
|
|
115
|
+
return String.fromCharCode(...bytes.subarray(at, at + length));
|
|
116
|
+
}
|
|
117
|
+
function png(bytes) {
|
|
118
|
+
return bytes.length >= 24 && bytes[0] === 137 && text(bytes, 1, 3) === "PNG" ? { width: u32be(bytes, 16), height: u32be(bytes, 20) } : undefined;
|
|
119
|
+
}
|
|
120
|
+
function gif(bytes) {
|
|
121
|
+
return bytes.length >= 10 && text(bytes, 0, 3) === "GIF" ? { width: u16le(bytes, 6), height: u16le(bytes, 8) } : undefined;
|
|
122
|
+
}
|
|
123
|
+
function webp(bytes) {
|
|
124
|
+
if (bytes.length < 30 || text(bytes, 0, 4) !== "RIFF" || text(bytes, 8, 4) !== "WEBP") {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
switch (text(bytes, 12, 4)) {
|
|
128
|
+
case "VP8 ":
|
|
129
|
+
return { width: u16le(bytes, 26) & 16383, height: u16le(bytes, 28) & 16383 };
|
|
130
|
+
case "VP8L": {
|
|
131
|
+
const bits = bytes[21] | bytes[22] << 8 | bytes[23] << 16 | bytes[24] << 24;
|
|
132
|
+
return { width: (bits & 16383) + 1, height: (bits >> 14 & 16383) + 1 };
|
|
133
|
+
}
|
|
134
|
+
case "VP8X":
|
|
135
|
+
return { width: u24le(bytes, 24) + 1, height: u24le(bytes, 27) + 1 };
|
|
136
|
+
default:
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function jpeg(bytes) {
|
|
141
|
+
if (bytes[0] !== 255 || bytes[1] !== 216) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
let at = 2;
|
|
145
|
+
while (at + 9 < bytes.length) {
|
|
146
|
+
if (bytes[at] !== 255) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const marker = bytes[at + 1];
|
|
150
|
+
if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) {
|
|
151
|
+
return { width: u16be(bytes, at + 7), height: u16be(bytes, at + 5) };
|
|
152
|
+
}
|
|
153
|
+
at += 2 + u16be(bytes, at + 2);
|
|
154
|
+
}
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
})(TaImageSize || (TaImageSize = {}));
|
|
158
|
+
var TaAgentSummary;
|
|
159
|
+
(function(TaAgentSummary2) {
|
|
160
|
+
const START = /^\s*<conversation_history_summary>/;
|
|
161
|
+
const BLOCK = /^\s*<conversation_history_summary>[\s\S]*?(?:<\/conversation_history_summary>\s*|$)/;
|
|
162
|
+
function read(text) {
|
|
163
|
+
if (!START.test(text)) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
return text.replace(/<\/?(?:conversation_history_summary|summary)>/g, "").replace(/<\/?\w*$/, "").trim();
|
|
167
|
+
}
|
|
168
|
+
TaAgentSummary2.read = read;
|
|
169
|
+
function strip(text) {
|
|
170
|
+
return text.replace(BLOCK, "");
|
|
171
|
+
}
|
|
172
|
+
TaAgentSummary2.strip = strip;
|
|
173
|
+
})(TaAgentSummary || (TaAgentSummary = {}));
|
|
174
|
+
var TaSkillUse;
|
|
175
|
+
(function(TaSkillUse2) {
|
|
176
|
+
const BLOCK = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
|
|
177
|
+
function parse(message) {
|
|
178
|
+
var _a;
|
|
179
|
+
const match = BLOCK.exec(message);
|
|
180
|
+
if (!match) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
return { name: match[1], location: match[2], content: match[3], message: ((_a = match[4]) === null || _a === undefined ? undefined : _a.trim()) || undefined };
|
|
184
|
+
}
|
|
185
|
+
TaSkillUse2.parse = parse;
|
|
186
|
+
function command(use) {
|
|
187
|
+
return use.message ? `/skill:${use.name} ${use.message}` : `/skill:${use.name}`;
|
|
188
|
+
}
|
|
189
|
+
TaSkillUse2.command = command;
|
|
190
|
+
})(TaSkillUse || (TaSkillUse = {}));
|
|
191
|
+
var TaTaskNote;
|
|
192
|
+
(function(TaTaskNote2) {
|
|
193
|
+
const NOTE = /^<task_(update|adopted|renamed) ((?:[^>"\n]|"[^"]*")*)>\n?([\s\S]*?)\n?<\/task_\1>$/;
|
|
194
|
+
const ATTRIBUTE = /(\w+)="([^"]*)"/g;
|
|
195
|
+
function write(note) {
|
|
196
|
+
const attributes = [`id="${quote(note.id)}"`];
|
|
197
|
+
if (note.was !== undefined) {
|
|
198
|
+
attributes.push(`was="${quote(note.was)}"`);
|
|
199
|
+
}
|
|
200
|
+
attributes.push(`title="${quote(note.title)}"`);
|
|
201
|
+
if (note.status !== undefined) {
|
|
202
|
+
attributes.push(`status="${quote(note.status)}"`);
|
|
203
|
+
}
|
|
204
|
+
return `<task_${note.kind} ${attributes.join(" ")}>
|
|
205
|
+
${note.body}
|
|
206
|
+
</task_${note.kind}>`;
|
|
207
|
+
}
|
|
208
|
+
TaTaskNote2.write = write;
|
|
209
|
+
function parse(text) {
|
|
210
|
+
const match = NOTE.exec(text.trim());
|
|
211
|
+
if (!match) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const attributes = {};
|
|
215
|
+
for (const [, name, value] of match[2].matchAll(ATTRIBUTE)) {
|
|
216
|
+
attributes[name] = unquote(value);
|
|
217
|
+
}
|
|
218
|
+
if (!attributes.id || attributes.title === undefined) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const { id, title, status, was } = attributes;
|
|
222
|
+
return { kind: match[1], id, title, ...status ? { status } : {}, ...was ? { was } : {}, body: match[3] };
|
|
223
|
+
}
|
|
224
|
+
TaTaskNote2.parse = parse;
|
|
225
|
+
function quote(text) {
|
|
226
|
+
return text.replace(/&/g, "&").replace(/"/g, """).replace(/\n/g, " ");
|
|
227
|
+
}
|
|
228
|
+
function unquote(text) {
|
|
229
|
+
return text.replace(/"/g, '"').replace(/&/g, "&");
|
|
230
|
+
}
|
|
231
|
+
})(TaTaskNote || (TaTaskNote = {}));
|
|
232
|
+
var TaSecretRef;
|
|
233
|
+
(function(TaSecretRef2) {
|
|
234
|
+
TaSecretRef2.PACKAGE = "@celljs/ta-secrets";
|
|
235
|
+
const REF = /\$\{?TA_SECRET_([A-Z0-9][A-Z0-9_]*)\}?/g;
|
|
236
|
+
const KINDS = [
|
|
237
|
+
[/^PHONE(?:_\d+)?$/, "phone"],
|
|
238
|
+
[/^EMAIL(?:_\d+)?$/, "email"],
|
|
239
|
+
[/^ID_NUMBER(?:_\d+)?$/, "idNumber"],
|
|
240
|
+
[/^BANK_CARD(?:_\d+)?$/, "bankCard"]
|
|
241
|
+
];
|
|
242
|
+
function has(text) {
|
|
243
|
+
return text.includes("TA_SECRET_") && new RegExp(REF.source).test(text);
|
|
244
|
+
}
|
|
245
|
+
TaSecretRef2.has = has;
|
|
246
|
+
function kind(name) {
|
|
247
|
+
var _a;
|
|
248
|
+
var _b;
|
|
249
|
+
return (_b = (_a = KINDS.find(([pattern]) => pattern.test(name))) === null || _a === undefined ? undefined : _a[1]) !== null && _b !== undefined ? _b : "secret";
|
|
250
|
+
}
|
|
251
|
+
TaSecretRef2.kind = kind;
|
|
252
|
+
function split(text) {
|
|
253
|
+
if (!has(text)) {
|
|
254
|
+
return [{ text }];
|
|
255
|
+
}
|
|
256
|
+
const parts = [];
|
|
257
|
+
let at = 0;
|
|
258
|
+
for (const match of text.matchAll(REF)) {
|
|
259
|
+
if (match.index > at) {
|
|
260
|
+
parts.push({ text: text.slice(at, match.index) });
|
|
261
|
+
}
|
|
262
|
+
parts.push({ secret: match[1], kind: kind(match[1]) });
|
|
263
|
+
at = match.index + match[0].length;
|
|
264
|
+
}
|
|
265
|
+
if (at < text.length) {
|
|
266
|
+
parts.push({ text: text.slice(at) });
|
|
267
|
+
}
|
|
268
|
+
return parts;
|
|
269
|
+
}
|
|
270
|
+
TaSecretRef2.split = split;
|
|
271
|
+
function plain(text, label) {
|
|
272
|
+
return has(text) ? text.replace(REF, (_whole, name) => label(name, kind(name))) : text;
|
|
273
|
+
}
|
|
274
|
+
TaSecretRef2.plain = plain;
|
|
275
|
+
})(TaSecretRef || (TaSecretRef = {}));
|
|
276
|
+
|
|
277
|
+
// ../ta-protocol/esm/common/ta-extension-host.js
|
|
278
|
+
var TA_WEBHOOK_MAX_BYTES = 256 * 1024;
|
|
279
|
+
var TA_HOST_EVENT = "ta:host";
|
|
280
|
+
var TaHostUtil;
|
|
281
|
+
(function(TaHostUtil2) {
|
|
282
|
+
TaHostUtil2.WAIT_MS = 1000;
|
|
283
|
+
function reach(events, name, waitMs = TaHostUtil2.WAIT_MS) {
|
|
284
|
+
return new Promise((resolve) => {
|
|
285
|
+
let heard = false;
|
|
286
|
+
let answered = false;
|
|
287
|
+
const timer = setTimeout(() => resolve(undefined), waitMs);
|
|
288
|
+
const request = {
|
|
289
|
+
name,
|
|
290
|
+
heard: () => {
|
|
291
|
+
heard = true;
|
|
292
|
+
},
|
|
293
|
+
resolve: (answer) => {
|
|
294
|
+
answered = true;
|
|
295
|
+
clearTimeout(timer);
|
|
296
|
+
resolve(answer);
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
events.emit(TA_HOST_EVENT, request);
|
|
300
|
+
if (!heard && !answered) {
|
|
301
|
+
clearTimeout(timer);
|
|
302
|
+
resolve(undefined);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
TaHostUtil2.reach = reach;
|
|
307
|
+
function marked(systemPrompt, mark) {
|
|
308
|
+
return role(systemPrompt).includes(mark);
|
|
309
|
+
}
|
|
310
|
+
TaHostUtil2.marked = marked;
|
|
311
|
+
function role(systemPrompt) {
|
|
312
|
+
if (!systemPrompt) {
|
|
313
|
+
return "";
|
|
314
|
+
}
|
|
315
|
+
const open = `<addendum>
|
|
316
|
+
`;
|
|
317
|
+
const start = systemPrompt.indexOf(open);
|
|
318
|
+
const context = systemPrompt.indexOf(`<project_context>
|
|
319
|
+
`);
|
|
320
|
+
if (start < 0 || context >= 0 && context < start) {
|
|
321
|
+
return "";
|
|
322
|
+
}
|
|
323
|
+
const end = systemPrompt.indexOf(`
|
|
324
|
+
</addendum>`, start);
|
|
325
|
+
return systemPrompt.slice(start + open.length, end < 0 ? undefined : end);
|
|
326
|
+
}
|
|
327
|
+
TaHostUtil2.role = role;
|
|
328
|
+
})(TaHostUtil || (TaHostUtil = {}));
|
|
329
|
+
var TA_ASK_ENTRY = "ta-ask";
|
|
330
|
+
var TaAskUtil;
|
|
331
|
+
(function(TaAskUtil2) {
|
|
332
|
+
const LENGTH = 120;
|
|
333
|
+
function entry(question) {
|
|
334
|
+
const line = question.replace(/\s+/g, " ").trim();
|
|
335
|
+
return { question: line.length > LENGTH ? `${line.slice(0, LENGTH - 1)}…` : line };
|
|
336
|
+
}
|
|
337
|
+
TaAskUtil2.entry = entry;
|
|
338
|
+
function asking(entries) {
|
|
339
|
+
var _a;
|
|
340
|
+
for (let i = entries.length - 1;i >= 0; i--) {
|
|
341
|
+
const entry2 = entries[i];
|
|
342
|
+
if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
if (entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY) {
|
|
346
|
+
return read(entry2);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
TaAskUtil2.asking = asking;
|
|
352
|
+
function next(asked, entry2) {
|
|
353
|
+
var _a;
|
|
354
|
+
if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
return entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY ? read(entry2) : asked;
|
|
358
|
+
}
|
|
359
|
+
TaAskUtil2.next = next;
|
|
360
|
+
function read(found) {
|
|
361
|
+
var _a;
|
|
362
|
+
const question = (_a = found.data) === null || _a === undefined ? undefined : _a.question;
|
|
363
|
+
if (typeof question !== "string" || !question.trim()) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
const at = found.timestamp ? Date.parse(found.timestamp) : Number.NaN;
|
|
367
|
+
return { question: entry(question).question, at: Number.isNaN(at) ? 0 : at };
|
|
368
|
+
}
|
|
369
|
+
})(TaAskUtil || (TaAskUtil = {}));
|
|
370
|
+
|
|
371
|
+
// web-src/call-protocol.ts
|
|
372
|
+
var NAME = "@celljs/ta-call";
|
|
373
|
+
var CALL_MARK = "[ta-call]";
|
|
374
|
+
|
|
375
|
+
// ../ta-protocol/esm/common/language.js
|
|
376
|
+
var TaLanguageUtil;
|
|
377
|
+
(function(TaLanguageUtil2) {
|
|
378
|
+
TaLanguageUtil2.ALL = ["zh-CN", "zh-TW", "en-US", "ja-JP"];
|
|
379
|
+
TaLanguageUtil2.NAMES = { "zh-CN": "简体中文", "zh-TW": "繁體中文", "en-US": "English", "ja-JP": "日本語" };
|
|
380
|
+
function of(tag) {
|
|
381
|
+
const said = (tag !== null && tag !== undefined ? tag : "").toLowerCase().replace(/_/g, "-");
|
|
382
|
+
if (/^zh(\b|-)/.test(said)) {
|
|
383
|
+
return /-hant\b/.test(said) || !/-hans\b/.test(said) && /-(tw|hk|mo)\b/.test(said) ? "zh-TW" : "zh-CN";
|
|
384
|
+
}
|
|
385
|
+
return /^ja(\b|-)/.test(said) ? "ja-JP" : "en-US";
|
|
386
|
+
}
|
|
387
|
+
TaLanguageUtil2.of = of;
|
|
388
|
+
function server(env = typeof process === "undefined" ? {} : process.env) {
|
|
389
|
+
return of(env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG);
|
|
390
|
+
}
|
|
391
|
+
TaLanguageUtil2.server = server;
|
|
392
|
+
function pick(language, words) {
|
|
393
|
+
return words[of(language)];
|
|
394
|
+
}
|
|
395
|
+
TaLanguageUtil2.pick = pick;
|
|
396
|
+
function say(words) {
|
|
397
|
+
return words[server()];
|
|
398
|
+
}
|
|
399
|
+
TaLanguageUtil2.say = say;
|
|
400
|
+
function chinese(language) {
|
|
401
|
+
return of(language).startsWith("zh");
|
|
402
|
+
}
|
|
403
|
+
TaLanguageUtil2.chinese = chinese;
|
|
404
|
+
function cjk(language) {
|
|
405
|
+
return of(language) !== "en-US";
|
|
406
|
+
}
|
|
407
|
+
TaLanguageUtil2.cjk = cjk;
|
|
408
|
+
function list(language, items) {
|
|
409
|
+
return items.join(cjk(language) ? "、" : ", ");
|
|
410
|
+
}
|
|
411
|
+
TaLanguageUtil2.list = list;
|
|
412
|
+
})(TaLanguageUtil || (TaLanguageUtil = {}));
|
|
413
|
+
|
|
414
|
+
// ../ta-protocol/esm/common/said-protocol.js
|
|
415
|
+
var TaSaid;
|
|
416
|
+
(function(TaSaid2) {
|
|
417
|
+
const CARD = /^ta-/i;
|
|
418
|
+
const READ = 4000;
|
|
419
|
+
const FENCE = /^\s*(`{3,}|~{3,})\s*([^\s`]*)/;
|
|
420
|
+
const TAG_LINE = /^<\/?[A-Za-z][\w:.-]*(?:\s[^<>]*)?\/?>$/;
|
|
421
|
+
const MARKS_ONLY = /^[-*_=|:+\s]+$/;
|
|
422
|
+
const MARKS = [
|
|
423
|
+
["context", /<\/?context>/],
|
|
424
|
+
["source", /\[ta:(?:from|notice|by) /],
|
|
425
|
+
["image note", /\[Image: original \d+x\d+|\[Image converted from /],
|
|
426
|
+
["skill", /<skill name="|<\/skill>/],
|
|
427
|
+
["task note", /<\/?task_(?:update|adopted|renamed)\b/],
|
|
428
|
+
["summary", /<\/?(?:conversation_history_summary|summary)>/]
|
|
429
|
+
];
|
|
430
|
+
function text(content, joiner = `
|
|
431
|
+
`) {
|
|
432
|
+
if (typeof content === "string") {
|
|
433
|
+
return content;
|
|
434
|
+
}
|
|
435
|
+
return Array.isArray(content) ? content.filter((part) => (part === null || part === undefined ? undefined : part.type) === "text" && typeof part.text === "string").map((part) => part.text).join(joiner) : "";
|
|
436
|
+
}
|
|
437
|
+
TaSaid2.text = text;
|
|
438
|
+
function words(role, text2, options = {}) {
|
|
439
|
+
const said = role === "user" ? userWords(text2) : TaAgentSummary.strip(text2);
|
|
440
|
+
return withoutFences(said, (language) => options.cards === false && CARD.test(language), true).trim();
|
|
441
|
+
}
|
|
442
|
+
TaSaid2.words = words;
|
|
443
|
+
function of(message, options) {
|
|
444
|
+
return message ? words(message.role, text(message.content), options) : "";
|
|
445
|
+
}
|
|
446
|
+
TaSaid2.of = of;
|
|
447
|
+
function notice(message) {
|
|
448
|
+
return (message === null || message === undefined ? undefined : message.role) === "user" && TaMessageSource.isNotice(text(message.content));
|
|
449
|
+
}
|
|
450
|
+
TaSaid2.notice = notice;
|
|
451
|
+
function marksOnly(role, text2) {
|
|
452
|
+
return !!text2.trim() && !line(words(role, text2), { chars: Number.POSITIVE_INFINITY });
|
|
453
|
+
}
|
|
454
|
+
TaSaid2.marksOnly = marksOnly;
|
|
455
|
+
function line(markdown, options) {
|
|
456
|
+
var _a;
|
|
457
|
+
const read = markdown.slice(0, READ);
|
|
458
|
+
const prose = withoutFences(read, () => true, true).trim();
|
|
459
|
+
const lines = plain(prose || codeOf(read)).split(`
|
|
460
|
+
`).map((part) => part.replace(/^\s*(?:#{1,6}\s+|>\s*|[-*+]\s+|\d+[.)]\s+)/, "").replace(/\*{1,3}|`+|~~|(?<![\p{L}\p{N}])_{1,3}|_{1,3}(?![\p{L}\p{N}])/gu, "").replace(/\s+/g, " ").trim()).filter((part) => part && !MARKS_ONLY.test(part) && !TAG_LINE.test(part));
|
|
461
|
+
const count = (_a = options.lines) !== null && _a !== undefined ? _a : 1;
|
|
462
|
+
const joined = count <= 1 ? lines.join(" ") : lines.slice(0, count).join(`
|
|
463
|
+
`);
|
|
464
|
+
return joined.length > options.chars ? `${joined.slice(0, Math.max(0, options.chars - 1)).trimEnd()}…` : joined;
|
|
465
|
+
}
|
|
466
|
+
TaSaid2.line = line;
|
|
467
|
+
function leaks(shown, options = {}) {
|
|
468
|
+
const found = MARKS.filter(([, mark]) => mark.test(shown)).map(([name]) => name);
|
|
469
|
+
const lines = shown.split(`
|
|
470
|
+
`);
|
|
471
|
+
if (options.cards !== true && lines.some((part) => {
|
|
472
|
+
var _a;
|
|
473
|
+
var _b;
|
|
474
|
+
return CARD.test((_b = (_a = FENCE.exec(part)) === null || _a === undefined ? undefined : _a[2]) !== null && _b !== undefined ? _b : "");
|
|
475
|
+
})) {
|
|
476
|
+
found.push("card");
|
|
477
|
+
}
|
|
478
|
+
if (lines.some((part) => TAG_LINE.test(part.trim()))) {
|
|
479
|
+
found.push("tag");
|
|
480
|
+
}
|
|
481
|
+
return found;
|
|
482
|
+
}
|
|
483
|
+
TaSaid2.leaks = leaks;
|
|
484
|
+
const SUMMARY = `<conversation_history_summary>
|
|
485
|
+
<summary>
|
|
486
|
+
1. Primary Request and Intent:
|
|
487
|
+
The user works on the relay.
|
|
488
|
+
</summary>
|
|
489
|
+
</conversation_history_summary>`;
|
|
490
|
+
TaSaid2.SAMPLES = [
|
|
491
|
+
{
|
|
492
|
+
mark: "context and where it came from",
|
|
493
|
+
role: "user",
|
|
494
|
+
text: `<context>
|
|
495
|
+
The channel #ops, its members.
|
|
496
|
+
[ta:from @celljs/ta-channels #ops]
|
|
497
|
+
</context>
|
|
498
|
+
Check the build`,
|
|
499
|
+
said: "Check the build"
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
mark: "a notice, not the user",
|
|
503
|
+
role: "user",
|
|
504
|
+
text: `<context>
|
|
505
|
+
[ta:notice @celljs/ta-call]
|
|
506
|
+
</context>
|
|
507
|
+
The work finished. Its last words: tests pass.`,
|
|
508
|
+
said: "The work finished. Its last words: tests pass."
|
|
509
|
+
},
|
|
510
|
+
{ mark: "one let in", role: "user", text: `<context>
|
|
511
|
+
[ta:by p-7 Alice]
|
|
512
|
+
</context>
|
|
513
|
+
Hello there`, said: "Hello there" },
|
|
514
|
+
{
|
|
515
|
+
mark: "notes of images",
|
|
516
|
+
role: "user",
|
|
517
|
+
text: `Look at this
|
|
518
|
+
[Image: original 3024x4032, displayed at 1512x2016. Multiply coordinates by 2.00 to map to original image.]
|
|
519
|
+
[Image converted from image/heic to image/png.]`,
|
|
520
|
+
said: "Look at this"
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
mark: "a skill run",
|
|
524
|
+
role: "user",
|
|
525
|
+
text: `<skill name="ta-package" location="/skills/ta-package/SKILL.md">
|
|
526
|
+
# Ta package
|
|
527
|
+
Steps.
|
|
528
|
+
</skill>
|
|
529
|
+
|
|
530
|
+
Make a card`,
|
|
531
|
+
said: "Make a card"
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
mark: "a note of a task",
|
|
535
|
+
role: "user",
|
|
536
|
+
text: `<task_update id="t1" title="Fix login" status="done">
|
|
537
|
+
All tests pass.
|
|
538
|
+
</task_update>`,
|
|
539
|
+
said: "Fix login"
|
|
540
|
+
},
|
|
541
|
+
{ mark: "a note of a new id", role: "user", text: `<task_renamed id="t2" was="t1" title="Fix login">
|
|
542
|
+
Now t2.
|
|
543
|
+
</task_renamed>` },
|
|
544
|
+
{ mark: "a summary, then the answer", role: "assistant", text: `${SUMMARY}
|
|
545
|
+
Switched to voice.`, said: "Switched to voice." },
|
|
546
|
+
{ mark: "a summary alone", role: "assistant", text: SUMMARY },
|
|
547
|
+
{ mark: "a summary as it streams", role: "assistant", text: `<conversation_history_summary>
|
|
548
|
+
<summary>` },
|
|
549
|
+
{
|
|
550
|
+
mark: "a card after the answer",
|
|
551
|
+
role: "assistant",
|
|
552
|
+
text: '**Done**: tests pass.\n\n```ta-glance\n{"status":"done","blocks":[]}\n```',
|
|
553
|
+
said: "tests pass"
|
|
554
|
+
},
|
|
555
|
+
{ mark: "a card alone", role: "assistant", text: '```ta-glance\n{"status":"done","blocks":[]}\n```' },
|
|
556
|
+
{ mark: "a proposal", role: "assistant", text: 'Committed.\n\n```ta-propose\n{"kind":"git.push","title":"Push"}\n```', said: "Committed." },
|
|
557
|
+
{ mark: "what a call says aloud", role: "assistant", text: "All fixed.\n\n```ta-say\nIt is fixed.\n```", said: "All fixed." },
|
|
558
|
+
{ mark: "a tag not known yet", role: "assistant", text: `<system-reminder>
|
|
559
|
+
</system-reminder>
|
|
560
|
+
Ready.`, said: "Ready." }
|
|
561
|
+
];
|
|
562
|
+
function userWords(text2) {
|
|
563
|
+
const said = TaImageNote.strip(TaMessageContext.strip(text2));
|
|
564
|
+
const skill = TaSkillUse.parse(said);
|
|
565
|
+
if (skill) {
|
|
566
|
+
return TaSkillUse.command(skill);
|
|
567
|
+
}
|
|
568
|
+
const note = TaTaskNote.parse(said);
|
|
569
|
+
if (!note) {
|
|
570
|
+
return said;
|
|
571
|
+
}
|
|
572
|
+
if (note.kind === "renamed") {
|
|
573
|
+
return "";
|
|
574
|
+
}
|
|
575
|
+
return note.kind === "update" && note.body.trim() ? `${note.title} · ${note.body}` : note.title;
|
|
576
|
+
}
|
|
577
|
+
function withoutFences(text2, drop, tags = false) {
|
|
578
|
+
const kept = [];
|
|
579
|
+
let fence;
|
|
580
|
+
let left = false;
|
|
581
|
+
for (const part of text2.split(`
|
|
582
|
+
`)) {
|
|
583
|
+
const open = FENCE.exec(part);
|
|
584
|
+
if (!fence && open) {
|
|
585
|
+
fence = { mark: open[1], dropped: drop(open[2]) };
|
|
586
|
+
} else if (fence && closes(part, fence.mark)) {
|
|
587
|
+
const dropped = fence.dropped;
|
|
588
|
+
fence = undefined;
|
|
589
|
+
if (dropped) {
|
|
590
|
+
continue;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
if ((fence === null || fence === undefined ? undefined : fence.dropped) || !fence && tags && TAG_LINE.test(part.trim())) {
|
|
594
|
+
left = true;
|
|
595
|
+
} else {
|
|
596
|
+
kept.push(part);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
return left ? kept.join(`
|
|
600
|
+
`).replace(/\n{3,}/g, `
|
|
601
|
+
|
|
602
|
+
`) : kept.join(`
|
|
603
|
+
`);
|
|
604
|
+
}
|
|
605
|
+
function codeOf(text2) {
|
|
606
|
+
const code = [];
|
|
607
|
+
let fence;
|
|
608
|
+
for (const part of text2.split(`
|
|
609
|
+
`)) {
|
|
610
|
+
const open = FENCE.exec(part);
|
|
611
|
+
if (!fence && open) {
|
|
612
|
+
fence = { mark: open[1], card: CARD.test(open[2]) };
|
|
613
|
+
} else if (fence && closes(part, fence.mark)) {
|
|
614
|
+
fence = undefined;
|
|
615
|
+
} else if (fence && !fence.card) {
|
|
616
|
+
code.push(part);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
return code.join(`
|
|
620
|
+
`);
|
|
621
|
+
}
|
|
622
|
+
function closes(part, mark) {
|
|
623
|
+
var _a;
|
|
624
|
+
const close = (_a = /^\s*(`{3,}|~{3,})\s*$/.exec(part)) === null || _a === undefined ? undefined : _a[1];
|
|
625
|
+
return !!close && close[0] === mark[0] && close.length >= mark.length;
|
|
626
|
+
}
|
|
627
|
+
function plain(text2) {
|
|
628
|
+
const linked = text2.replace(/(?<!!)\[([^\]\n]*)\]\([^)\n]*\)/g, "$1");
|
|
629
|
+
const words2 = linked.replace(/!\[[^\]\n]*\]\([^)\n]*\)/g, "").trim();
|
|
630
|
+
return words2 || linked.replace(/!\[([^\]\n]*)\]\([^)\n]*\)/g, "$1");
|
|
631
|
+
}
|
|
632
|
+
})(TaSaid || (TaSaid = {}));
|
|
633
|
+
|
|
634
|
+
// web-src/call-util.ts
|
|
635
|
+
var LOOK_CHARS = 1500;
|
|
636
|
+
var ENTRY_CHARS = 600;
|
|
637
|
+
var SEED_CHARS = 1200;
|
|
638
|
+
var ROLE_CHARS = 800;
|
|
639
|
+
var LAST_ENTRIES = 12;
|
|
640
|
+
var QUIET = "-";
|
|
641
|
+
var FAST = /(mini|flash|haiku|lite|nano|turbo|small|fast|air)\b/i;
|
|
642
|
+
var CallUtil;
|
|
643
|
+
((CallUtil) => {
|
|
644
|
+
function role(id, target, seed) {
|
|
645
|
+
const work = target.double ? "the user's double, which hands out tasks of its own" : `their conversation${target.cwd ? ` in ${target.cwd}` : ""}`;
|
|
646
|
+
return [
|
|
647
|
+
`${CALL_MARK} ${id}`,
|
|
648
|
+
`You are Ta, on a voice call with the user. You only talk: what you write is read aloud at once. The work goes on elsewhere, in ${work}, while you talk.`,
|
|
649
|
+
"- Answer in the language of the user, short, as on the phone: one to three sentences of plain words. No markdown, lists, tables, code, paths, links or cards.",
|
|
650
|
+
"- Chat, tell a poem, sing a song (say its words), answer what you know: do it yourself, never through the work.",
|
|
651
|
+
"- What needs files, commands, code, research or anything the work does: tell the work (into what it does now, or after it); for something apart from it, open a side conversation with side. Then say in a few words that you did. You cannot do it yourself.",
|
|
652
|
+
"- Asked how the work goes or about any detail of it: status, then look with a question for the detail; answer from what they return, never guess.",
|
|
653
|
+
"- When the user wants what the work or a side conversation does stopped: stop.",
|
|
654
|
+
"- When the user wants the call to end (hang up, bye): hang_up, then say goodbye in a few words; the call ends once it is said. Never tell them to hang up themselves.",
|
|
655
|
+
"- To change Ta itself (its settings, the captions of this call, pin a conversation, turn an extension on or off): app_run yourself, at once, then say in a few words it is done.",
|
|
656
|
+
"- When the work waits for the user to decide: read them the question (app_run asks.list), and answer it with what they say (app_run asks.answer: Ta asks them to agree on their screen, tell them so); never decide for them.",
|
|
657
|
+
"- What only the screen has, or what the user asks you to do on their screen (open a page, press a button, find something they look at): app_look, app_go, app_do on their own screen, the one in front of them, as their shadow; say in a few words what you do as you do it. The call goes on while their screen shows something else.",
|
|
658
|
+
"- A message that starts with [sent] went to the work already: acknowledge it in a few words.",
|
|
659
|
+
`- A message marked [ta:notice] is news of the work, not the user speaking: when the user should hear it (a result, a failure, a question for them), say it in one short sentence as you would on the phone, the answer first; else answer ${QUIET} alone. What the user says comes first: when they spoke after news, answer them, and add the news in a few words only if they should hear it and it was not said yet.`,
|
|
660
|
+
...seed ? ["", seedText(seed, target.double)] : []
|
|
661
|
+
].join(`
|
|
662
|
+
`);
|
|
663
|
+
}
|
|
664
|
+
CallUtil.role = role;
|
|
665
|
+
function seedText(seed, double) {
|
|
666
|
+
const lines = ["<called>"];
|
|
667
|
+
if (seed.name) {
|
|
668
|
+
lines.push(`Conversation: ${flat(seed.name).slice(0, 120)}${seed.cwd ? ` (in ${seed.cwd})` : ""}`);
|
|
669
|
+
}
|
|
670
|
+
const role2 = seed.role && !double ? flat(seed.role).slice(0, ROLE_CHARS) : "";
|
|
671
|
+
if (role2) {
|
|
672
|
+
lines.push(`Its role: speak as it would, with its focus. ${role2}`);
|
|
673
|
+
}
|
|
674
|
+
lines.push(`Now: ${seed.working ? "working" : "idle"}${seed.queued ? `, ${seed.queued} queued` : ""}${seed.waiting ? ", waiting for the user" : ""}.`);
|
|
675
|
+
const recent = [];
|
|
676
|
+
let length = 0;
|
|
677
|
+
const said2 = seed.entries.filter((entry) => entry.role !== "tool");
|
|
678
|
+
for (let i = said2.length - 1;i >= 0; i--) {
|
|
679
|
+
const line = `${said2[i].role}: ${said2[i].text.slice(0, 300)}`;
|
|
680
|
+
if (length + line.length > SEED_CHARS) {
|
|
681
|
+
break;
|
|
682
|
+
}
|
|
683
|
+
recent.unshift(line);
|
|
684
|
+
length += line.length + 1;
|
|
685
|
+
}
|
|
686
|
+
if (recent.length) {
|
|
687
|
+
lines.push("Its last lines (look for more):", ...recent);
|
|
688
|
+
}
|
|
689
|
+
lines.push("</called>");
|
|
690
|
+
return lines.join(`
|
|
691
|
+
`);
|
|
692
|
+
}
|
|
693
|
+
CallUtil.seedText = seedText;
|
|
694
|
+
function side(text, from) {
|
|
695
|
+
const about = from ? ` about the conversation "${flat(from).slice(0, 120)}"` : "";
|
|
696
|
+
return `<from_call>Opened from a call with the user${about}, as work apart from it: do it, then say in a few words how it went.</from_call>
|
|
697
|
+
${text}`;
|
|
698
|
+
}
|
|
699
|
+
CallUtil.side = side;
|
|
700
|
+
function sideOfDouble(text, title) {
|
|
701
|
+
const named = title ? ` ("${flat(title).slice(0, 80)}")` : "";
|
|
702
|
+
return `The user asked in a call for this as a task of its own${named}: start it with start_task, then go on.
|
|
703
|
+
${text}`;
|
|
704
|
+
}
|
|
705
|
+
CallUtil.sideOfDouble = sideOfDouble;
|
|
706
|
+
function callOf(role2) {
|
|
707
|
+
const at = role2.indexOf(CALL_MARK);
|
|
708
|
+
return at < 0 ? undefined : role2.slice(at + CALL_MARK.length).trim().split(/\s/)[0] || undefined;
|
|
709
|
+
}
|
|
710
|
+
CallUtil.callOf = callOf;
|
|
711
|
+
function name(language, called, said2) {
|
|
712
|
+
const call = TaLanguageUtil.pick(language, { "zh-CN": "通话", "zh-TW": "通話", "en-US": "Call", "ja-JP": "通話" });
|
|
713
|
+
const opening = said2 ? firstSentence(said2) : "";
|
|
714
|
+
const other = called ? flat(called).slice(0, opening ? 20 : 40) : "";
|
|
715
|
+
return [call, other, opening].filter(Boolean).join(" · ");
|
|
716
|
+
}
|
|
717
|
+
CallUtil.name = name;
|
|
718
|
+
function firstSentence(text) {
|
|
719
|
+
const [first = ""] = flat(text).split(/(?<=[。!?;!?;])|(?<=\.)\s/);
|
|
720
|
+
return first.replace(/[\s。!?;,、!?;,.]+$/, "").slice(0, 30);
|
|
721
|
+
}
|
|
722
|
+
function news(lines) {
|
|
723
|
+
return TaMessageSource.notice(lines.join(`
|
|
724
|
+
`), NAME);
|
|
725
|
+
}
|
|
726
|
+
CallUtil.news = news;
|
|
727
|
+
function toSay(reply) {
|
|
728
|
+
const said2 = reply?.trim();
|
|
729
|
+
return said2 && said2 !== QUIET ? said2 : undefined;
|
|
730
|
+
}
|
|
731
|
+
CallUtil.toSay = toSay;
|
|
732
|
+
function ended(name2, how) {
|
|
733
|
+
if (how.error) {
|
|
734
|
+
return `${name2} failed: ${how.error.replace(/\s+/g, " ").slice(0, 200)}`;
|
|
735
|
+
}
|
|
736
|
+
if (how.aborted) {
|
|
737
|
+
return `${name2} was stopped.`;
|
|
738
|
+
}
|
|
739
|
+
const last = how.last?.replace(/\s+/g, " ").trim();
|
|
740
|
+
return last ? `${name2} finished. Its last words: ${last.slice(0, 400)}` : `${name2} finished.`;
|
|
741
|
+
}
|
|
742
|
+
CallUtil.ended = ended;
|
|
743
|
+
function waits(name2) {
|
|
744
|
+
return `${name2} waits for the user to decide or confirm, on the screen.`;
|
|
745
|
+
}
|
|
746
|
+
CallUtil.waits = waits;
|
|
747
|
+
function said(text, sent) {
|
|
748
|
+
return sent ? `[sent] ${text}` : text;
|
|
749
|
+
}
|
|
750
|
+
CallUtil.said = said;
|
|
751
|
+
function model(models, chosen, current, agents = []) {
|
|
752
|
+
const own = models.filter((model2) => !agents.includes(model2));
|
|
753
|
+
if (chosen && own.includes(chosen)) {
|
|
754
|
+
return chosen;
|
|
755
|
+
}
|
|
756
|
+
const fast = own.filter((model2) => FAST.test(model2.split("/").slice(1).join("/")));
|
|
757
|
+
if (current && agents.includes(current)) {
|
|
758
|
+
return fast[0] ?? own[0];
|
|
759
|
+
}
|
|
760
|
+
const provider = current?.split("/")[0];
|
|
761
|
+
return fast.find((model2) => model2.split("/")[0] === provider) ?? current;
|
|
762
|
+
}
|
|
763
|
+
CallUtil.model = model;
|
|
764
|
+
function entries(messages) {
|
|
765
|
+
const lines = [];
|
|
766
|
+
for (const raw of messages) {
|
|
767
|
+
const message = raw;
|
|
768
|
+
const parts = typeof message.content === "string" ? [{ type: "text", text: message.content }] : message.content ?? [];
|
|
769
|
+
if (message.role === "user") {
|
|
770
|
+
const text = TaSaid.words("user", texts(parts));
|
|
771
|
+
if (text) {
|
|
772
|
+
lines.push({ role: "user", text: short(text) });
|
|
773
|
+
}
|
|
774
|
+
} else if (message.role === "assistant") {
|
|
775
|
+
const text = TaSaid.words("assistant", texts(parts));
|
|
776
|
+
if (text) {
|
|
777
|
+
lines.push({ role: "assistant", text: short(text) });
|
|
778
|
+
}
|
|
779
|
+
for (const call of parts.filter((part) => part.type === "toolCall")) {
|
|
780
|
+
lines.push({ role: "tool", text: short(`${call.name}(${JSON.stringify(call.arguments ?? {})})`) });
|
|
781
|
+
}
|
|
782
|
+
} else if (message.role === "toolResult") {
|
|
783
|
+
const text = texts(parts).trim();
|
|
784
|
+
lines.push({ role: "tool", text: short(`${message.toolName ?? "tool"} → ${text || "(nothing)"}`) });
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
return lines;
|
|
788
|
+
}
|
|
789
|
+
CallUtil.entries = entries;
|
|
790
|
+
function look(entries2, question) {
|
|
791
|
+
const words = terms(question);
|
|
792
|
+
let picked;
|
|
793
|
+
if (!words.length) {
|
|
794
|
+
picked = entries2.slice(-LAST_ENTRIES);
|
|
795
|
+
} else {
|
|
796
|
+
const scored = entries2.map((entry, index) => ({ entry, index, score: score(entry.text, words) })).filter((each) => each.score > 0);
|
|
797
|
+
scored.sort((a, b) => b.score - a.score || b.index - a.index);
|
|
798
|
+
picked = scored.slice(0, LAST_ENTRIES).sort((a, b) => a.index - b.index).map((each) => each.entry);
|
|
799
|
+
}
|
|
800
|
+
const lines = [];
|
|
801
|
+
let length = 0;
|
|
802
|
+
for (const entry of picked) {
|
|
803
|
+
const line = `${entry.role}: ${entry.text}`;
|
|
804
|
+
if (length + line.length > LOOK_CHARS) {
|
|
805
|
+
lines.push("…");
|
|
806
|
+
break;
|
|
807
|
+
}
|
|
808
|
+
lines.push(line);
|
|
809
|
+
length += line.length + 1;
|
|
810
|
+
}
|
|
811
|
+
return lines.join(`
|
|
812
|
+
`) || "Nothing about that in the work.";
|
|
813
|
+
}
|
|
814
|
+
CallUtil.look = look;
|
|
815
|
+
function terms(question) {
|
|
816
|
+
const found = new Set;
|
|
817
|
+
for (const word of question.toLowerCase().match(/[a-z0-9_.-]{2,}/g) ?? []) {
|
|
818
|
+
found.add(word);
|
|
819
|
+
}
|
|
820
|
+
for (const run of question.match(/[\u3040-\u30ff\u3400-\u9fff]+/g) ?? []) {
|
|
821
|
+
for (let i = 0;i + 1 < run.length; i++) {
|
|
822
|
+
found.add(run.slice(i, i + 2));
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
return [...found];
|
|
826
|
+
}
|
|
827
|
+
CallUtil.terms = terms;
|
|
828
|
+
function score(text, words) {
|
|
829
|
+
const lower = text.toLowerCase();
|
|
830
|
+
return words.filter((word) => lower.includes(word)).length;
|
|
831
|
+
}
|
|
832
|
+
function texts(parts) {
|
|
833
|
+
return parts.filter((part) => part.type === "text" && typeof part.text === "string").map((part) => part.text).join(`
|
|
834
|
+
`);
|
|
835
|
+
}
|
|
836
|
+
function short(text) {
|
|
837
|
+
const line = flat(text);
|
|
838
|
+
return line.length > ENTRY_CHARS ? `${line.slice(0, ENTRY_CHARS)}…` : line;
|
|
839
|
+
}
|
|
840
|
+
function flat(text) {
|
|
841
|
+
return text.replace(/\s+/g, " ").trim();
|
|
842
|
+
}
|
|
843
|
+
})(CallUtil ||= {});
|
|
844
|
+
|
|
845
|
+
// web-src/call-host.ts
|
|
846
|
+
var DEFAULTS = {
|
|
847
|
+
pollMs: 150,
|
|
848
|
+
answerMs: 90000,
|
|
849
|
+
idleMs: 15 * 60000,
|
|
850
|
+
newsMs: 1200,
|
|
851
|
+
watchMs: 2000,
|
|
852
|
+
nextMs: 25000,
|
|
853
|
+
now: () => Date.now()
|
|
854
|
+
};
|
|
855
|
+
|
|
856
|
+
class CallHost {
|
|
857
|
+
host;
|
|
858
|
+
calls = new Map;
|
|
859
|
+
options;
|
|
860
|
+
offEvents;
|
|
861
|
+
watchTimer;
|
|
862
|
+
constructor(host, options = {}) {
|
|
863
|
+
this.host = host;
|
|
864
|
+
this.options = { ...DEFAULTS, ...options };
|
|
865
|
+
}
|
|
866
|
+
async open(target, model) {
|
|
867
|
+
await this.sweep();
|
|
868
|
+
const id = randomUUID().slice(0, 8);
|
|
869
|
+
const caller = this.host.team?.current() ?? "";
|
|
870
|
+
const info = (await this.sessions()).find((session) => session.sessionId === target.sessionId);
|
|
871
|
+
const cwd = target.cwd || info?.cwd || (await this.host.getServerInfo()).cwd;
|
|
872
|
+
const seed = await this.seed(target, info, cwd);
|
|
873
|
+
const { sessionId } = await this.host.openSession({
|
|
874
|
+
cwd,
|
|
875
|
+
appendSystemPrompt: CallUtil.role(id, { ...target, cwd }, seed),
|
|
876
|
+
group: NAME,
|
|
877
|
+
thinkingLevel: "off",
|
|
878
|
+
...model ? { model } : {}
|
|
879
|
+
});
|
|
880
|
+
await this.host.setSessionName(sessionId, CallUtil.name(target.language, target.double ? undefined : seed.name)).catch(() => {
|
|
881
|
+
return;
|
|
882
|
+
});
|
|
883
|
+
this.calls.set(id, {
|
|
884
|
+
id,
|
|
885
|
+
front: sessionId,
|
|
886
|
+
target: { ...target, cwd },
|
|
887
|
+
caller,
|
|
888
|
+
seed,
|
|
889
|
+
...info?.model ? { model: info.model } : {},
|
|
890
|
+
sides: new Map,
|
|
891
|
+
used: this.options.now(),
|
|
892
|
+
watched: new Set([target.sessionId]),
|
|
893
|
+
waiting: new Set,
|
|
894
|
+
news: [],
|
|
895
|
+
outbox: [],
|
|
896
|
+
waiters: [],
|
|
897
|
+
turns: Promise.resolve(),
|
|
898
|
+
spoken: 0
|
|
899
|
+
});
|
|
900
|
+
this.watch();
|
|
901
|
+
return { callId: id };
|
|
902
|
+
}
|
|
903
|
+
async say(callId, text, sent = false) {
|
|
904
|
+
const call = this.call(callId);
|
|
905
|
+
call.used = this.options.now();
|
|
906
|
+
call.spoken++;
|
|
907
|
+
call.outbox.length = 0;
|
|
908
|
+
if (!call.titled && text.trim()) {
|
|
909
|
+
call.titled = true;
|
|
910
|
+
const name = CallUtil.name(call.target.language, call.target.double ? undefined : call.seed.name, text);
|
|
911
|
+
this.host.setSessionName(call.front, name).catch(() => {
|
|
912
|
+
return;
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
const reply = await this.turn(call, CallUtil.said(text, sent));
|
|
916
|
+
call.used = this.options.now();
|
|
917
|
+
return { ...reply ? { text: reply } : {}, ...call.ending ? { end: true } : {} };
|
|
918
|
+
}
|
|
919
|
+
next(callId) {
|
|
920
|
+
const call = this.calls.get(callId);
|
|
921
|
+
if (!call) {
|
|
922
|
+
return Promise.resolve(undefined);
|
|
923
|
+
}
|
|
924
|
+
const ready = call.outbox.shift();
|
|
925
|
+
if (ready) {
|
|
926
|
+
return Promise.resolve(ready);
|
|
927
|
+
}
|
|
928
|
+
return new Promise((resolve) => {
|
|
929
|
+
const done = (text) => {
|
|
930
|
+
clearTimeout(timer);
|
|
931
|
+
call.waiters = call.waiters.filter((waiter) => waiter !== done);
|
|
932
|
+
resolve(text);
|
|
933
|
+
};
|
|
934
|
+
const timer = setTimeout(() => done(undefined), this.options.nextMs);
|
|
935
|
+
call.waiters.push(done);
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
async close(callId) {
|
|
939
|
+
const call = this.calls.get(callId);
|
|
940
|
+
this.calls.delete(callId);
|
|
941
|
+
if (call) {
|
|
942
|
+
clearTimeout(call.newsTimer);
|
|
943
|
+
for (const waiter of [...call.waiters]) {
|
|
944
|
+
waiter(undefined);
|
|
945
|
+
}
|
|
946
|
+
await this.host.closeSession(call.front).catch(() => {
|
|
947
|
+
return;
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
if (!this.calls.size) {
|
|
951
|
+
this.unwatch();
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
callOf(systemPrompt) {
|
|
955
|
+
const id = CallUtil.callOf(TaHostUtil.role(systemPrompt));
|
|
956
|
+
return id ? this.calls.get(id) : undefined;
|
|
957
|
+
}
|
|
958
|
+
async tell(call, text, now) {
|
|
959
|
+
const { isStreaming } = await this.host.getState(call.target.sessionId);
|
|
960
|
+
await this.as(call, () => this.host.prompt(call.target.sessionId, {
|
|
961
|
+
clientMessageId: randomUUID(),
|
|
962
|
+
message: TaMessageSource.mark(text, NAME),
|
|
963
|
+
streamingBehavior: now ? "steer" : "followUp"
|
|
964
|
+
}));
|
|
965
|
+
return isStreaming ? now ? "Told the work as it goes." : "Queued after what the work does now." : "The work started on it.";
|
|
966
|
+
}
|
|
967
|
+
async side(call, text, title) {
|
|
968
|
+
if (call.target.double) {
|
|
969
|
+
await this.as(call, () => this.host.prompt(call.target.sessionId, {
|
|
970
|
+
clientMessageId: randomUUID(),
|
|
971
|
+
message: TaMessageSource.mark(CallUtil.sideOfDouble(text, title), NAME),
|
|
972
|
+
streamingBehavior: "followUp"
|
|
973
|
+
}));
|
|
974
|
+
return "Asked the double to start it as a task of its own: news comes when it ends.";
|
|
975
|
+
}
|
|
976
|
+
const name = title?.trim() || text.replace(/\s+/g, " ").trim().slice(0, 40);
|
|
977
|
+
const { sessionId } = await this.as(call, () => this.host.openSession({
|
|
978
|
+
cwd: call.target.cwd || ".",
|
|
979
|
+
...call.seed.role ? { appendSystemPrompt: call.seed.role } : {},
|
|
980
|
+
...call.model ? { model: call.model } : {}
|
|
981
|
+
}));
|
|
982
|
+
await this.host.setSessionName(sessionId, name).catch(() => {
|
|
983
|
+
return;
|
|
984
|
+
});
|
|
985
|
+
call.sides.set(sessionId, name);
|
|
986
|
+
call.watched.add(sessionId);
|
|
987
|
+
await this.as(call, () => this.host.prompt(sessionId, { clientMessageId: randomUUID(), message: TaMessageSource.mark(CallUtil.side(text, call.seed.name), NAME) }));
|
|
988
|
+
return `Opened the side conversation "${name}": it works on it now, news comes when it ends.`;
|
|
989
|
+
}
|
|
990
|
+
hangUp(call) {
|
|
991
|
+
call.ending = true;
|
|
992
|
+
return "The call ends once your reply is said: say goodbye in a few words.";
|
|
993
|
+
}
|
|
994
|
+
async stop(call, within) {
|
|
995
|
+
const sessionId = within ? (await this.named(call, within))?.sessionId : call.target.sessionId;
|
|
996
|
+
if (!sessionId) {
|
|
997
|
+
return `No conversation named "${within}".`;
|
|
998
|
+
}
|
|
999
|
+
if (!(await this.host.getState(sessionId)).isStreaming) {
|
|
1000
|
+
return "It does nothing now.";
|
|
1001
|
+
}
|
|
1002
|
+
await this.as(call, () => this.host.abort(sessionId));
|
|
1003
|
+
return "Stopped.";
|
|
1004
|
+
}
|
|
1005
|
+
async status(call) {
|
|
1006
|
+
const sessions = await this.host.listSessions();
|
|
1007
|
+
const state = await this.host.getState(call.target.sessionId);
|
|
1008
|
+
const last = (await this.host.getLastAssistantText(call.target.sessionId)).text?.trim();
|
|
1009
|
+
const lines = [
|
|
1010
|
+
`The work: ${state.isStreaming ? "working" : "idle"}${state.pendingMessageCount ? `, ${state.pendingMessageCount} queued` : ""}${sessions.find((session) => session.sessionId === call.target.sessionId)?.waiting ? ", waiting for the user" : ""}.`,
|
|
1011
|
+
...last ? [`Its last words: ${last.replace(/\s+/g, " ").slice(0, 300)}`] : []
|
|
1012
|
+
];
|
|
1013
|
+
for (const [sessionId, name] of call.sides) {
|
|
1014
|
+
const side = sessions.find((session) => session.sessionId === sessionId);
|
|
1015
|
+
lines.push(`${name} (a side conversation of this call): ${side?.waiting ? "waiting for the user" : side?.isStreaming ? "working" : "idle"}.`);
|
|
1016
|
+
}
|
|
1017
|
+
const others = sessions.filter((session) => session.sessionId !== call.target.sessionId && !call.sides.has(session.sessionId) && session.group !== NAME && (session.isStreaming || session.waiting)).slice(0, 8);
|
|
1018
|
+
for (const other of others) {
|
|
1019
|
+
lines.push(`${other.sessionName || other.firstMessage || other.cwd}: ${other.waiting ? "waiting for the user" : "working"}.`);
|
|
1020
|
+
}
|
|
1021
|
+
return lines.join(`
|
|
1022
|
+
`);
|
|
1023
|
+
}
|
|
1024
|
+
async look(call, question, within) {
|
|
1025
|
+
const file = within ? (await this.named(call, within))?.sessionFile : (await this.host.getState(call.target.sessionId)).sessionFile;
|
|
1026
|
+
if (!file) {
|
|
1027
|
+
return within ? `No conversation named "${within}".` : "The work has nothing written yet.";
|
|
1028
|
+
}
|
|
1029
|
+
return CallUtil.look(CallUtil.entries(await this.host.sessionMessages(file)), question);
|
|
1030
|
+
}
|
|
1031
|
+
dispose() {
|
|
1032
|
+
for (const id of [...this.calls.keys()]) {
|
|
1033
|
+
this.close(id);
|
|
1034
|
+
}
|
|
1035
|
+
this.unwatch();
|
|
1036
|
+
}
|
|
1037
|
+
async event(event) {
|
|
1038
|
+
if (event.group === NAME) {
|
|
1039
|
+
return;
|
|
1040
|
+
}
|
|
1041
|
+
for (const call of this.calls.values()) {
|
|
1042
|
+
if (event.type === "turn_start") {
|
|
1043
|
+
call.watched.add(event.sessionId);
|
|
1044
|
+
} else if (call.watched.has(event.sessionId)) {
|
|
1045
|
+
const name = await this.nameOf(call, event.sessionId);
|
|
1046
|
+
const last = event.error || event.aborted ? undefined : (await this.host.getLastAssistantText(event.sessionId).catch(() => {
|
|
1047
|
+
return;
|
|
1048
|
+
}))?.text;
|
|
1049
|
+
this.report(call, CallUtil.ended(name, { error: event.error, aborted: event.aborted, last: last ?? undefined }));
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
async lookWaiting() {
|
|
1054
|
+
const sessions = await this.sessions();
|
|
1055
|
+
for (const call of this.calls.values()) {
|
|
1056
|
+
for (const session of sessions) {
|
|
1057
|
+
if (!call.watched.has(session.sessionId)) {
|
|
1058
|
+
continue;
|
|
1059
|
+
}
|
|
1060
|
+
if (session.waiting && !call.waiting.has(session.sessionId)) {
|
|
1061
|
+
call.waiting.add(session.sessionId);
|
|
1062
|
+
this.report(call, CallUtil.waits(await this.nameOf(call, session.sessionId)));
|
|
1063
|
+
} else if (!session.waiting) {
|
|
1064
|
+
call.waiting.delete(session.sessionId);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
report(call, line) {
|
|
1070
|
+
call.news.push(line);
|
|
1071
|
+
clearTimeout(call.newsTimer);
|
|
1072
|
+
call.newsTimer = setTimeout(() => {
|
|
1073
|
+
const news = call.news.splice(0);
|
|
1074
|
+
if (!news.length || !this.calls.has(call.id)) {
|
|
1075
|
+
return;
|
|
1076
|
+
}
|
|
1077
|
+
const spoken = call.spoken;
|
|
1078
|
+
this.turn(call, CallUtil.news(news)).then((reply) => {
|
|
1079
|
+
const said = CallUtil.toSay(reply);
|
|
1080
|
+
if (!said || !this.calls.has(call.id) || call.spoken !== spoken) {
|
|
1081
|
+
return;
|
|
1082
|
+
}
|
|
1083
|
+
const waiter = call.waiters[0];
|
|
1084
|
+
if (waiter) {
|
|
1085
|
+
waiter(said);
|
|
1086
|
+
} else {
|
|
1087
|
+
call.outbox.push(said);
|
|
1088
|
+
}
|
|
1089
|
+
}, () => {
|
|
1090
|
+
return;
|
|
1091
|
+
});
|
|
1092
|
+
}, this.options.newsMs);
|
|
1093
|
+
}
|
|
1094
|
+
turn(call, message) {
|
|
1095
|
+
const next = call.turns.then(async () => {
|
|
1096
|
+
const before = await this.host.getState(call.front);
|
|
1097
|
+
await this.host.prompt(call.front, { clientMessageId: randomUUID(), message });
|
|
1098
|
+
await this.settled(call.front, before.messageCount);
|
|
1099
|
+
return (await this.host.getLastAssistantText(call.front)).text?.trim() || undefined;
|
|
1100
|
+
});
|
|
1101
|
+
call.turns = next.catch(() => {
|
|
1102
|
+
return;
|
|
1103
|
+
});
|
|
1104
|
+
return next;
|
|
1105
|
+
}
|
|
1106
|
+
sessions() {
|
|
1107
|
+
return this.host.listSessions().catch(() => []);
|
|
1108
|
+
}
|
|
1109
|
+
async nameOf(call, sessionId) {
|
|
1110
|
+
if (sessionId === call.target.sessionId) {
|
|
1111
|
+
return "The work";
|
|
1112
|
+
}
|
|
1113
|
+
const side = call.sides.get(sessionId);
|
|
1114
|
+
if (side) {
|
|
1115
|
+
return `The side conversation "${side}"`;
|
|
1116
|
+
}
|
|
1117
|
+
const session = (await this.sessions()).find((each) => each.sessionId === sessionId);
|
|
1118
|
+
return session?.sessionName || session?.firstMessage || "A task";
|
|
1119
|
+
}
|
|
1120
|
+
watch() {
|
|
1121
|
+
this.offEvents ??= this.host.onSessionEvent((event) => void this.event(event));
|
|
1122
|
+
this.watchTimer ??= setInterval(() => void this.lookWaiting(), this.options.watchMs);
|
|
1123
|
+
}
|
|
1124
|
+
unwatch() {
|
|
1125
|
+
this.offEvents?.();
|
|
1126
|
+
this.offEvents = undefined;
|
|
1127
|
+
clearInterval(this.watchTimer);
|
|
1128
|
+
this.watchTimer = undefined;
|
|
1129
|
+
}
|
|
1130
|
+
call(callId) {
|
|
1131
|
+
const call = this.calls.get(callId);
|
|
1132
|
+
if (!call) {
|
|
1133
|
+
throw new Error("This call is over.");
|
|
1134
|
+
}
|
|
1135
|
+
return call;
|
|
1136
|
+
}
|
|
1137
|
+
async named(call, name) {
|
|
1138
|
+
const wanted = name.trim().toLowerCase();
|
|
1139
|
+
const sessions = (await this.host.listSessions()).filter((session) => session.group !== NAME);
|
|
1140
|
+
for (const [sessionId, side] of call.sides) {
|
|
1141
|
+
if (side.toLowerCase().includes(wanted)) {
|
|
1142
|
+
const sessionFile = sessions.find((session) => session.sessionId === sessionId)?.sessionFile ?? (await this.host.getState(sessionId)).sessionFile;
|
|
1143
|
+
return { sessionId, ...sessionFile ? { sessionFile } : {} };
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
return sessions.find((session) => (session.sessionName ?? session.firstMessage ?? "").toLowerCase().includes(wanted));
|
|
1147
|
+
}
|
|
1148
|
+
async seed(target, info, cwd) {
|
|
1149
|
+
const state = await this.host.getState(target.sessionId).catch(() => {
|
|
1150
|
+
return;
|
|
1151
|
+
});
|
|
1152
|
+
const file = target.sessionFile || state?.sessionFile;
|
|
1153
|
+
const [messages, role] = file ? await Promise.all([
|
|
1154
|
+
this.host.sessionMessages(file).catch(() => []),
|
|
1155
|
+
target.double ? undefined : this.host.sessionRole?.(file).catch(() => {
|
|
1156
|
+
return;
|
|
1157
|
+
})
|
|
1158
|
+
]) : [[], undefined];
|
|
1159
|
+
const name = info?.sessionName || info?.firstMessage;
|
|
1160
|
+
return {
|
|
1161
|
+
...name ? { name } : {},
|
|
1162
|
+
cwd,
|
|
1163
|
+
...role ? { role } : {},
|
|
1164
|
+
entries: CallUtil.entries(messages),
|
|
1165
|
+
working: !!state?.isStreaming,
|
|
1166
|
+
queued: state?.pendingMessageCount ?? 0,
|
|
1167
|
+
waiting: !!info?.waiting
|
|
1168
|
+
};
|
|
1169
|
+
}
|
|
1170
|
+
as(call, run) {
|
|
1171
|
+
const team = this.host.team;
|
|
1172
|
+
return team && call.caller ? team.actAs(call.caller, run) : run();
|
|
1173
|
+
}
|
|
1174
|
+
async sweep() {
|
|
1175
|
+
const now = this.options.now();
|
|
1176
|
+
for (const call of [...this.calls.values()]) {
|
|
1177
|
+
if (now - call.used > this.options.idleMs) {
|
|
1178
|
+
await this.close(call.id);
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
async settled(sessionId, before) {
|
|
1183
|
+
const start = this.options.now();
|
|
1184
|
+
for (;; ) {
|
|
1185
|
+
const state = await this.host.getState(sessionId);
|
|
1186
|
+
if (!state.isStreaming && state.pendingMessageCount === 0 && state.messageCount > before) {
|
|
1187
|
+
return;
|
|
1188
|
+
}
|
|
1189
|
+
if (this.options.now() - start > this.options.answerMs) {
|
|
1190
|
+
throw new Error("No answer in time.");
|
|
1191
|
+
}
|
|
1192
|
+
await new Promise((resolve) => setTimeout(resolve, this.options.pollMs));
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
// web-src/host.ts
|
|
1198
|
+
async function activate(host) {
|
|
1199
|
+
const calls = new CallHost(host);
|
|
1200
|
+
return {
|
|
1201
|
+
dispose: () => calls.dispose(),
|
|
1202
|
+
open: (target, model) => calls.open(target, model),
|
|
1203
|
+
say: (callId, text, sent) => calls.say(callId, text, sent === true),
|
|
1204
|
+
next: (callId) => calls.next(callId),
|
|
1205
|
+
close: (callId) => calls.close(callId),
|
|
1206
|
+
service: calls
|
|
1207
|
+
};
|
|
1208
|
+
}
|
|
1209
|
+
export {
|
|
1210
|
+
activate as default
|
|
1211
|
+
};
|