@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 ADDED
@@ -0,0 +1,9 @@
1
+ # @celljs/ta-call
2
+
3
+ The front of Ta's calls: a light session answers you at once in a call (chat, a poem, a question) while the work goes on in the conversation or the double called, which gets what is to be done; details of the work are looked up when asked. Design in `docs/design/ta-call.md`.
4
+
5
+ - Page: a partner of calls (`registerCallPartner`); Settings has the model of calls, a fast one of the same provider at first.
6
+ - Host: a front session per call, closed as it ends.
7
+ - pi extension: a front has `tell` (into the conversation called), `side` (a side conversation, same directory and role, as the caller), `stop`, `status` and `look` alone, none of the user's instructions or skills.
8
+ - A call begins knowing the conversation called: its role, name, how it goes and its last lines (about 1200 characters at most); details are looked up as asked.
9
+ - The conversations of calls fold into a folder Calls of the list, to look back at; archived as any other, the folder pinned stays once they all are, listing the archived when opened.
package/README.md CHANGED
@@ -1,3 +1,9 @@
1
- # Temporary Holding Version
1
+ # @celljs/ta-call
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Ta 的通话前台:通话时由一个轻量会话随时回应你(闲聊、念诗、回答问题),要做的事交给被通话的对话或分身,问到任务细节时按需去查。设计见 `docs/design/ta-call.md`。
4
+
5
+ - 页面:注册通话伙伴(`registerCallPartner`),设置里可选"通话用的模型",默认用同一提供商里快的那个。
6
+ - 服务端(host):每次通话开一个前台会话,通话结束就关掉。
7
+ - pi 扩展:前台只有 `tell`(插话进被通话的对话)、`side`(开旁路对话,同目录、同角色、按发起人的权限)、`stop`、`status`、`look` 五个工具,不读你的说明文件和技能。
8
+ - 通话开始时带上被通话对话的角色、名字、现在的状态和最近几轮(最多约 1200 字),之后的细节按需 `look`。
9
+ - 通话对话在对话列表里收进"通话"文件夹,可以回看;按对话列表的归档天数归档,置顶的文件夹全部归档后也一直在,点开连归档的一起列出。
@@ -0,0 +1,495 @@
1
+ // ../ta-protocol/esm/common/ta-extension-host.js
2
+ var TA_WEBHOOK_MAX_BYTES = 256 * 1024;
3
+ var TA_HOST_EVENT = "ta:host";
4
+ var TaHostUtil;
5
+ (function(TaHostUtil2) {
6
+ TaHostUtil2.WAIT_MS = 1000;
7
+ function reach(events, name, waitMs = TaHostUtil2.WAIT_MS) {
8
+ return new Promise((resolve) => {
9
+ let heard = false;
10
+ let answered = false;
11
+ const timer = setTimeout(() => resolve(undefined), waitMs);
12
+ const request = {
13
+ name,
14
+ heard: () => {
15
+ heard = true;
16
+ },
17
+ resolve: (answer) => {
18
+ answered = true;
19
+ clearTimeout(timer);
20
+ resolve(answer);
21
+ }
22
+ };
23
+ events.emit(TA_HOST_EVENT, request);
24
+ if (!heard && !answered) {
25
+ clearTimeout(timer);
26
+ resolve(undefined);
27
+ }
28
+ });
29
+ }
30
+ TaHostUtil2.reach = reach;
31
+ function marked(systemPrompt, mark) {
32
+ return role(systemPrompt).includes(mark);
33
+ }
34
+ TaHostUtil2.marked = marked;
35
+ function role(systemPrompt) {
36
+ if (!systemPrompt) {
37
+ return "";
38
+ }
39
+ const open = `<addendum>
40
+ `;
41
+ const start = systemPrompt.indexOf(open);
42
+ const context = systemPrompt.indexOf(`<project_context>
43
+ `);
44
+ if (start < 0 || context >= 0 && context < start) {
45
+ return "";
46
+ }
47
+ const end = systemPrompt.indexOf(`
48
+ </addendum>`, start);
49
+ return systemPrompt.slice(start + open.length, end < 0 ? undefined : end);
50
+ }
51
+ TaHostUtil2.role = role;
52
+ })(TaHostUtil || (TaHostUtil = {}));
53
+ var TA_ASK_ENTRY = "ta-ask";
54
+ var TaAskUtil;
55
+ (function(TaAskUtil2) {
56
+ const LENGTH = 120;
57
+ function entry(question) {
58
+ const line = question.replace(/\s+/g, " ").trim();
59
+ return { question: line.length > LENGTH ? `${line.slice(0, LENGTH - 1)}…` : line };
60
+ }
61
+ TaAskUtil2.entry = entry;
62
+ function asking(entries) {
63
+ var _a;
64
+ for (let i = entries.length - 1;i >= 0; i--) {
65
+ const entry2 = entries[i];
66
+ if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
67
+ return;
68
+ }
69
+ if (entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY) {
70
+ return read(entry2);
71
+ }
72
+ }
73
+ return;
74
+ }
75
+ TaAskUtil2.asking = asking;
76
+ function next(asked, entry2) {
77
+ var _a;
78
+ if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
79
+ return;
80
+ }
81
+ return entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY ? read(entry2) : asked;
82
+ }
83
+ TaAskUtil2.next = next;
84
+ function read(found) {
85
+ var _a;
86
+ const question = (_a = found.data) === null || _a === undefined ? undefined : _a.question;
87
+ if (typeof question !== "string" || !question.trim()) {
88
+ return;
89
+ }
90
+ const at = found.timestamp ? Date.parse(found.timestamp) : Number.NaN;
91
+ return { question: entry(question).question, at: Number.isNaN(at) ? 0 : at };
92
+ }
93
+ })(TaAskUtil || (TaAskUtil = {}));
94
+
95
+ // ../ta-protocol/esm/common/delegate-protocol.js
96
+ var TaDelegateUtil;
97
+ (function(TaDelegateUtil2) {
98
+ TaDelegateUtil2.LEVELS = ["less", "balanced", "more"];
99
+ TaDelegateUtil2.DEFAULT = "balanced";
100
+ TaDelegateUtil2.WORK_TOOLS = ["read", "bash", "powershell", "edit", "write", "grep", "find", "ls"];
101
+ TaDelegateUtil2.CHANGE_TOOLS = ["edit", "write"];
102
+ const LIMITS = {
103
+ less: { noChanges: false },
104
+ balanced: { noChanges: true, steps: 6 },
105
+ more: { noChanges: true, steps: 2 }
106
+ };
107
+ function parse(value) {
108
+ return TaDelegateUtil2.LEVELS.includes(value) ? value : TaDelegateUtil2.DEFAULT;
109
+ }
110
+ TaDelegateUtil2.parse = parse;
111
+ function mark(level) {
112
+ return `(delegate=${level})`;
113
+ }
114
+ TaDelegateUtil2.mark = mark;
115
+ function levelOf(systemPrompt) {
116
+ const role = TaHostUtil.role(systemPrompt);
117
+ return TaDelegateUtil2.LEVELS.find((level) => role.includes(mark(level)));
118
+ }
119
+ TaDelegateUtil2.levelOf = levelOf;
120
+ function limits(level) {
121
+ return LIMITS[level];
122
+ }
123
+ TaDelegateUtil2.limits = limits;
124
+ function refusal(level, tool, steps) {
125
+ if (!TaDelegateUtil2.WORK_TOOLS.includes(tool)) {
126
+ return;
127
+ }
128
+ const limit = LIMITS[level];
129
+ if (limit.noChanges && TaDelegateUtil2.CHANGE_TOOLS.includes(tool)) {
130
+ return "You do not change files yourself: hand this to a task with start_task, with instructions complete enough to do it. The user set how much you hand out in the settings of the double.";
131
+ }
132
+ if (limit.steps !== undefined && steps >= limit.steps) {
133
+ return "You have looked enough for this: hand the work to a task with start_task now, with what you found in its instructions, and tell the user what you started.";
134
+ }
135
+ return;
136
+ }
137
+ TaDelegateUtil2.refusal = refusal;
138
+ })(TaDelegateUtil || (TaDelegateUtil = {}));
139
+
140
+ // ../ta-protocol/esm/common/language.js
141
+ var TaLanguageUtil;
142
+ (function(TaLanguageUtil2) {
143
+ TaLanguageUtil2.ALL = ["zh-CN", "zh-TW", "en-US", "ja-JP"];
144
+ TaLanguageUtil2.NAMES = { "zh-CN": "简体中文", "zh-TW": "繁體中文", "en-US": "English", "ja-JP": "日本語" };
145
+ function of(tag) {
146
+ const said = (tag !== null && tag !== undefined ? tag : "").toLowerCase().replace(/_/g, "-");
147
+ if (/^zh(\b|-)/.test(said)) {
148
+ return /-hant\b/.test(said) || !/-hans\b/.test(said) && /-(tw|hk|mo)\b/.test(said) ? "zh-TW" : "zh-CN";
149
+ }
150
+ return /^ja(\b|-)/.test(said) ? "ja-JP" : "en-US";
151
+ }
152
+ TaLanguageUtil2.of = of;
153
+ function server(env = typeof process === "undefined" ? {} : process.env) {
154
+ return of(env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG);
155
+ }
156
+ TaLanguageUtil2.server = server;
157
+ function pick(language, words) {
158
+ return words[of(language)];
159
+ }
160
+ TaLanguageUtil2.pick = pick;
161
+ function say(words) {
162
+ return words[server()];
163
+ }
164
+ TaLanguageUtil2.say = say;
165
+ function chinese(language) {
166
+ return of(language).startsWith("zh");
167
+ }
168
+ TaLanguageUtil2.chinese = chinese;
169
+ function cjk(language) {
170
+ return of(language) !== "en-US";
171
+ }
172
+ TaLanguageUtil2.cjk = cjk;
173
+ function list(language, items) {
174
+ return items.join(cjk(language) ? "、" : ", ");
175
+ }
176
+ TaLanguageUtil2.list = list;
177
+ })(TaLanguageUtil || (TaLanguageUtil = {}));
178
+
179
+ // ../ta-protocol/esm/common/app-protocol.js
180
+ var TA_APP_TOOLS = ["app_commands", "app_run", "app_look", "app_go", "app_do"];
181
+ var FONT_SIZES = ["small", "standard", "large", "xlarge"];
182
+ var words = (en, zh, tw, ja) => ({ "en-US": en, "zh-CN": zh, "zh-TW": tw, "ja-JP": ja });
183
+ var SYSTEM = words("as the system", "跟随系统", "跟隨系統", "システムに合わせる");
184
+ var FONT_SHOWN = {
185
+ small: words("small", "小", "小", "小"),
186
+ standard: words("standard", "标准", "標準", "標準"),
187
+ large: words("large", "大", "大", "大"),
188
+ xlarge: words("extra large", "特大", "特大", "特大")
189
+ };
190
+ var TA_WEB_SETTINGS = [
191
+ {
192
+ key: "theme",
193
+ type: "enum",
194
+ values: ["system", "light", "dark"],
195
+ default: "system",
196
+ what: "Light or dark look; system follows the device.",
197
+ title: words("Theme", "外观", "外觀", "外観"),
198
+ shown: { system: SYSTEM, light: words("light", "浅色", "淺色", "ライト"), dark: words("dark", "深色", "深色", "ダーク") }
199
+ },
200
+ {
201
+ key: "language",
202
+ type: "enum",
203
+ values: ["system", ...TaLanguageUtil.ALL],
204
+ default: "system",
205
+ what: "The language of Ta's pages and of what Ta says; system follows the device.",
206
+ title: words("Language", "语言", "語言", "言語"),
207
+ shown: {
208
+ system: SYSTEM,
209
+ ...Object.fromEntries(TaLanguageUtil.ALL.map((language) => [
210
+ language,
211
+ words(TaLanguageUtil.NAMES[language], TaLanguageUtil.NAMES[language], TaLanguageUtil.NAMES[language], TaLanguageUtil.NAMES[language])
212
+ ]))
213
+ }
214
+ },
215
+ {
216
+ key: "fontSize",
217
+ type: "enum",
218
+ values: FONT_SIZES,
219
+ default: "standard",
220
+ what: "The size of the text of the whole page.",
221
+ title: words("Text size", "字体大小", "字型大小", "文字サイズ"),
222
+ shown: FONT_SHOWN
223
+ },
224
+ {
225
+ key: "chatFontSize",
226
+ type: "enum",
227
+ values: FONT_SIZES,
228
+ default: "standard",
229
+ what: "The size of the text of conversations, on top of fontSize.",
230
+ title: words("Text size of conversations", "对话字体大小", "對話字型大小", "会話の文字サイズ"),
231
+ shown: FONT_SHOWN
232
+ },
233
+ {
234
+ key: "speak",
235
+ type: "boolean",
236
+ default: false,
237
+ what: "Read every reply aloud.",
238
+ title: words("Read replies aloud", "朗读回复", "朗讀回覆", "返信を読み上げ")
239
+ },
240
+ {
241
+ key: "speakTalk",
242
+ type: "boolean",
243
+ default: false,
244
+ what: "Read the reply aloud when the user spoke to the double by voice.",
245
+ title: words("Read aloud what was asked by voice", "语音提问时朗读回复", "語音提問時朗讀回覆", "音声で聞いたら読み上げ")
246
+ },
247
+ {
248
+ key: "callCaptions",
249
+ type: "boolean",
250
+ default: false,
251
+ what: "Show captions in a call: what the user says and what Ta reads.",
252
+ title: words("Call captions", "通话字幕", "通話字幕", "通話の字幕")
253
+ },
254
+ {
255
+ key: "voice",
256
+ type: "string",
257
+ default: "",
258
+ what: "The voice replies are read with (a voiceURI of the device's voices); empty for the most natural one.",
259
+ title: words("Voice", "朗读声音", "朗讀聲音", "読み上げの声")
260
+ },
261
+ {
262
+ key: "confirmTasks",
263
+ type: "boolean",
264
+ default: false,
265
+ what: "The double asks before it hands out work.",
266
+ title: words("Ask before handing out work", "派任务前先问我", "派任務前先問我", "作業を割り当てる前に確認")
267
+ },
268
+ {
269
+ key: "maxTasks",
270
+ type: "number",
271
+ values: [0, 2, 4, 8],
272
+ default: 0,
273
+ what: "How many of the double's tasks run at once; 0 for as many as it starts.",
274
+ title: words("Tasks at once", "同时运行的任务", "同時執行的任務", "同時に実行するタスク")
275
+ },
276
+ {
277
+ key: "delegate",
278
+ type: "enum",
279
+ values: TaDelegateUtil.LEVELS,
280
+ default: TaDelegateUtil.DEFAULT,
281
+ what: "How much of the work the double hands out to tasks rather than doing it itself.",
282
+ title: words("Hand out work", "派活多少", "派活多少", "作業の割り当て"),
283
+ shown: { less: words("less", "少", "少", "少なめ"), balanced: words("balanced", "适中", "適中", "ふつう"), more: words("more", "多", "多", "多め") }
284
+ },
285
+ {
286
+ key: "assistantModel",
287
+ type: "model",
288
+ default: "",
289
+ what: "The model of the double, <provider>/<model id>; empty for the default model.",
290
+ title: words("Model of the double", "分身的模型", "分身的模型", "分身のモデル")
291
+ },
292
+ {
293
+ key: "taskModel",
294
+ type: "model",
295
+ default: "",
296
+ what: "The model of the tasks the double starts; empty for the default model.",
297
+ title: words("Model of tasks", "任务的模型", "任務的模型", "タスクのモデル")
298
+ },
299
+ { key: "reduceMotion", type: "boolean", default: false, what: "Fewer animations.", title: words("Reduce motion", "减少动画", "減少動畫", "動きを減らす") },
300
+ {
301
+ key: "diagramStyle",
302
+ type: "enum",
303
+ values: ["clean", "sketch", "colour", "motion"],
304
+ default: "clean",
305
+ what: "How diagrams in replies draw: in the colours of the page, as by hand, a colour to a node, or coming in with flowing lines.",
306
+ title: words("Diagram style", "图表风格", "圖表風格", "図のスタイル"),
307
+ shown: {
308
+ clean: words("clean", "简洁", "簡潔", "シンプル"),
309
+ sketch: words("sketch", "草图", "草圖", "スケッチ"),
310
+ colour: words("colour", "彩色", "彩色", "カラー"),
311
+ motion: words("motion", "动效", "動效", "モーション")
312
+ }
313
+ },
314
+ {
315
+ key: "keepAliveMinutes",
316
+ type: "number",
317
+ values: [1, 5, 15, 30],
318
+ default: 5,
319
+ what: "How long an extension started on open keeps running once left, in minutes.",
320
+ title: words("Keep extensions running", "扩展离开后保留", "擴充功能離開後保留", "拡張機能を保持")
321
+ },
322
+ {
323
+ key: "chatFoldDays",
324
+ type: "number",
325
+ values: [3, 7, 30, 0],
326
+ default: 7,
327
+ what: "Conversations not updated for these days fold at the end of the list; 0 for none.",
328
+ title: words("Fold old conversations", "折叠旧对话", "摺疊舊對話", "古い会話を折りたたむ")
329
+ },
330
+ {
331
+ key: "chatArchiveDays",
332
+ type: "number",
333
+ values: [30, 90, 365, 0],
334
+ default: 30,
335
+ what: "Conversations not updated for these days are archived (out of the list, found by search); 0 for none.",
336
+ title: words("Archive old conversations", "归档旧对话", "歸檔舊對話", "古い会話をアーカイブ")
337
+ },
338
+ {
339
+ key: "recentShots",
340
+ type: "boolean",
341
+ default: true,
342
+ what: "The screenshot just taken is offered above the message box, once.",
343
+ title: words("Offer recent screenshots", "提示刚截的图", "提示剛截的圖", "撮ったばかりのスクリーンショットを提案")
344
+ }
345
+ ];
346
+ var TaAppUtil;
347
+ (function(TaAppUtil2) {
348
+ function check(spec, value) {
349
+ var _a, _b;
350
+ switch (spec.type) {
351
+ case "boolean":
352
+ return typeof value === "boolean" ? undefined : "true or false";
353
+ case "string":
354
+ return typeof value === "string" ? undefined : "a string";
355
+ case "model":
356
+ return value === "" || typeof value === "string" && /^[^/\s]+\/\S+$/.test(value) ? undefined : "<provider>/<model id>, or empty";
357
+ default:
358
+ return ((_a = spec.values) === null || _a === undefined ? undefined : _a.includes(value)) ? undefined : `one of ${(_b = spec.values) === null || _b === undefined ? undefined : _b.map((one) => JSON.stringify(one)).join(", ")}`;
359
+ }
360
+ }
361
+ TaAppUtil2.check = check;
362
+ function shown(value, language, spec) {
363
+ var _a;
364
+ const named = (_a = spec === null || spec === undefined ? undefined : spec.shown) === null || _a === undefined ? undefined : _a[String(value)];
365
+ if (named) {
366
+ return TaLanguageUtil.pick(language, named);
367
+ }
368
+ if (typeof value === "boolean") {
369
+ return TaLanguageUtil.pick(language, value ? words("on", "开", "開", "オン") : words("off", "关", "關", "オフ"));
370
+ }
371
+ if (value === "" || value === undefined || value === null) {
372
+ return TaLanguageUtil.pick(language, words("default", "默认", "預設", "デフォルト"));
373
+ }
374
+ return String(value);
375
+ }
376
+ TaAppUtil2.shown = shown;
377
+ })(TaAppUtil || (TaAppUtil = {}));
378
+
379
+ // web-src/call-protocol.ts
380
+ var NAME = "@celljs/ta-call";
381
+ var CALL_MARK = "[ta-call]";
382
+ var CALL_TOOLS = ["tell", "side", "stop", "status", "look", "hang_up"];
383
+
384
+ // web-src/extension.ts
385
+ var NO_SERVER = "Calls need the Ta service: start it with `ta serve`.";
386
+ function activate(pi) {
387
+ let reached;
388
+ const reach = () => reached ??= TaHostUtil.reach(pi.events, NAME).then((answer) => ({
389
+ answered: !!answer,
390
+ calls: answer?.service?.service
391
+ }));
392
+ const front = (ctx) => TaHostUtil.marked(ctx.getSystemPrompt(), CALL_MARK);
393
+ const ours = (name) => CALL_TOOLS.includes(name);
394
+ const app = (name) => TA_APP_TOOLS.includes(name);
395
+ pi.on("before_agent_start", (event, ctx) => {
396
+ if (front(ctx)) {
397
+ const all = new Set(pi.getAllTools().map((tool) => tool.name));
398
+ pi.setActiveTools([...CALL_TOOLS, ...TA_APP_TOOLS].filter((name) => all.has(name)));
399
+ event.systemPromptOptions.contextFiles = [];
400
+ event.systemPromptOptions.skills = [];
401
+ return;
402
+ }
403
+ const active = pi.getActiveTools();
404
+ if (active.some(ours)) {
405
+ pi.setActiveTools(active.filter((name) => !ours(name)));
406
+ }
407
+ });
408
+ pi.on("tool_call", (event, ctx) => {
409
+ if (front(ctx) && !ours(event.toolName) && !app(event.toolName)) {
410
+ return { block: true, reason: "In a call you only talk: tell the work, or open a side conversation." };
411
+ }
412
+ if (!front(ctx) && ours(event.toolName)) {
413
+ return { block: true, reason: "Only in a call." };
414
+ }
415
+ return;
416
+ });
417
+ const tools = [
418
+ {
419
+ name: "tell",
420
+ label: "Tell the work",
421
+ description: "Tells the work (the conversation called) what the user wants done, in their words and complete: it reads nothing of this call. now: into what it does now (to change it); else after it.",
422
+ parameters: {
423
+ type: "object",
424
+ properties: { text: { type: "string" }, now: { type: "boolean" } },
425
+ required: ["text"]
426
+ },
427
+ run: (calls, call, params) => calls.tell(call, String(params.text ?? ""), params.now === true)
428
+ },
429
+ {
430
+ name: "side",
431
+ label: "Open a side conversation",
432
+ description: "Opens a side conversation for work apart from what the work does (look something up, try something, a task of its own): in the same directory, with the same role, as the user; it starts on text at once, which must say all it needs (it reads nothing of this call). title: a few words. Its end is news.",
433
+ parameters: {
434
+ type: "object",
435
+ properties: { text: { type: "string" }, title: { type: "string" } },
436
+ required: ["text"]
437
+ },
438
+ run: (calls, call, params) => calls.side(call, String(params.text ?? ""), typeof params.title === "string" ? params.title : undefined)
439
+ },
440
+ {
441
+ name: "stop",
442
+ label: "Stop",
443
+ description: "Stops what the work does now, or what another conversation does (within: its name, as status lists it), when the user wants it stopped.",
444
+ parameters: { type: "object", properties: { within: { type: "string" } } },
445
+ run: (calls, call, params) => calls.stop(call, typeof params.within === "string" ? params.within : undefined)
446
+ },
447
+ {
448
+ name: "hang_up",
449
+ label: "Hang up",
450
+ description: "Ends this call once your reply is said, when the user wants it ended: reply with a goodbye of a few words.",
451
+ parameters: { type: "object", properties: {} },
452
+ run: (calls, call) => calls.hangUp(call)
453
+ },
454
+ {
455
+ name: "status",
456
+ label: "How the work goes",
457
+ description: "How the work goes now: working or idle, what it said last, and the other tasks that run or wait for the user.",
458
+ parameters: { type: "object", properties: {} },
459
+ run: (calls, call) => calls.status(call)
460
+ },
461
+ {
462
+ name: "look",
463
+ label: "Look into the work",
464
+ description: "Looks up a detail of the work: the lines of its conversation (what was said, the tools it ran and what they returned) that answer question best, short; without a question, its last lines. within: another conversation that runs, by its name, as status lists them.",
465
+ parameters: {
466
+ type: "object",
467
+ properties: { question: { type: "string" }, within: { type: "string" } }
468
+ },
469
+ run: (calls, call, params) => calls.look(call, String(params.question ?? ""), typeof params.within === "string" ? params.within : undefined)
470
+ }
471
+ ];
472
+ for (const tool of tools) {
473
+ pi.registerTool({
474
+ name: tool.name,
475
+ label: tool.label,
476
+ description: tool.description,
477
+ parameters: tool.parameters,
478
+ execute: async (_id, params, _signal, _update, ctx) => {
479
+ const { answered, calls } = await reach();
480
+ if (!calls) {
481
+ throw new Error(answered ? "Calls did not start in the Ta service; its log says why." : NO_SERVER);
482
+ }
483
+ const call = calls.callOf(ctx.getSystemPrompt());
484
+ if (!call) {
485
+ throw new Error("Only in a call, and this call is over.");
486
+ }
487
+ const text = await tool.run(calls, call, params ?? {});
488
+ return { content: [{ type: "text", text }], details: undefined };
489
+ }
490
+ });
491
+ }
492
+ }
493
+ export {
494
+ activate as default
495
+ };