@celljs/ta-channels 4.13.0 → 4.14.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.
@@ -27,6 +27,27 @@ var TaHostUtil;
27
27
  });
28
28
  }
29
29
  TaHostUtil2.reach = reach;
30
+ function marked(systemPrompt, mark) {
31
+ return role(systemPrompt).includes(mark);
32
+ }
33
+ TaHostUtil2.marked = marked;
34
+ function role(systemPrompt) {
35
+ if (!systemPrompt) {
36
+ return "";
37
+ }
38
+ const open = `<addendum>
39
+ `;
40
+ const start = systemPrompt.indexOf(open);
41
+ const context = systemPrompt.indexOf(`<project_context>
42
+ `);
43
+ if (start < 0 || context >= 0 && context < start) {
44
+ return "";
45
+ }
46
+ const end = systemPrompt.indexOf(`
47
+ </addendum>`, start);
48
+ return systemPrompt.slice(start + open.length, end < 0 ? undefined : end);
49
+ }
50
+ TaHostUtil2.role = role;
30
51
  })(TaHostUtil || (TaHostUtil = {}));
31
52
  var TA_ASK_ENTRY = "ta-ask";
32
53
  var TaAskUtil;
@@ -984,7 +1005,7 @@ var ASK_FIRST_MARK = "Ask the user before you hand out work";
984
1005
  function activate(pi) {
985
1006
  let reached;
986
1007
  const reach = () => reached ??= TaHostUtil.reach(pi.events, NAME).then((answer) => ({ answered: !!answer, team: answer?.service }));
987
- const isAgent = (ctx) => ctx.getSystemPrompt().includes(AGENT_MARK);
1008
+ const isAgent = (ctx) => TaHostUtil.marked(ctx.getSystemPrompt(), AGENT_MARK);
988
1009
  const allowed = new Set;
989
1010
  pi.on("session_start", () => {
990
1011
  reach();
@@ -1027,7 +1048,7 @@ function activate(pi) {
1027
1048
  throw new Error(answered ? NO_TEAM : NO_SERVER);
1028
1049
  }
1029
1050
  const input = params ?? {};
1030
- if (ctx.getSystemPrompt().includes(ASK_FIRST_MARK)) {
1051
+ if (TaHostUtil.marked(ctx.getSystemPrompt(), ASK_FIRST_MARK)) {
1031
1052
  const question = TeamAsk.question(tool.name, input, team2.state, allowed);
1032
1053
  if (question && !await ask(ctx, question)) {
1033
1054
  return { content: [{ type: "text", text: TeamAsk.REFUSED }], details: undefined };
package/host/index.mjs CHANGED
@@ -181,119 +181,6 @@ var TaPackageTextUtil;
181
181
  }
182
182
  TaPackageTextUtil2.pick = pick;
183
183
  })(TaPackageTextUtil || (TaPackageTextUtil = {}));
184
- // ../ta-protocol/esm/common/relay-protocol.js
185
- var TaRelayServer = Symbol("TaRelayServer");
186
- // ../ta-protocol/esm/common/remote-protocol.js
187
- var TaRemoteServer = Symbol("TaRemoteServer");
188
- // ../ta-protocol/esm/common/room-protocol.js
189
- var TaRoomServer = Symbol("TaRoomServer");
190
- var TaRoomWatchUtil;
191
- (function(TaRoomWatchUtil2) {
192
- function of(messages, state) {
193
- const prefixes = Array.isArray(state) ? state.filter((prefix) => typeof prefix === "string" && prefix.length > 0) : [];
194
- return { messages: messages !== false, state: [...new Set(prefixes)].sort() };
195
- }
196
- TaRoomWatchUtil2.of = of;
197
- function union(watches) {
198
- let messages = false;
199
- const state = [];
200
- for (const watch of watches) {
201
- messages || (messages = watch.messages);
202
- state.push(...watch.state);
203
- }
204
- return of(messages, messages ? [] : state);
205
- }
206
- TaRoomWatchUtil2.union = union;
207
- function same(a, b) {
208
- return a === b || !!a && !!b && a.messages === b.messages && a.state.join(`
209
- `) === b.state.join(`
210
- `);
211
- }
212
- TaRoomWatchUtil2.same = same;
213
- function hears(watch, event) {
214
- if (event.type === "message") {
215
- return watch.messages;
216
- }
217
- if (event.type === "state") {
218
- return watch.messages || watch.state.some((prefix) => event.key.startsWith(prefix));
219
- }
220
- return true;
221
- }
222
- TaRoomWatchUtil2.hears = hears;
223
- })(TaRoomWatchUtil || (TaRoomWatchUtil = {}));
224
- // ../ta-protocol/esm/common/settings-protocol.js
225
- var TaSettingsServer = Symbol("TaSettingsServer");
226
- // ../ta-protocol/esm/common/ta-extension-host.js
227
- var TA_HOST_EVENT = "ta:host";
228
- var TaHostUtil;
229
- (function(TaHostUtil2) {
230
- TaHostUtil2.WAIT_MS = 1000;
231
- function reach(events, name, waitMs = TaHostUtil2.WAIT_MS) {
232
- return new Promise((resolve) => {
233
- let heard = false;
234
- let answered = false;
235
- const timer = setTimeout(() => resolve(undefined), waitMs);
236
- const request = {
237
- name,
238
- heard: () => {
239
- heard = true;
240
- },
241
- resolve: (answer) => {
242
- answered = true;
243
- clearTimeout(timer);
244
- resolve(answer);
245
- }
246
- };
247
- events.emit(TA_HOST_EVENT, request);
248
- if (!heard && !answered) {
249
- clearTimeout(timer);
250
- resolve(undefined);
251
- }
252
- });
253
- }
254
- TaHostUtil2.reach = reach;
255
- })(TaHostUtil || (TaHostUtil = {}));
256
- var TA_ASK_ENTRY = "ta-ask";
257
- var TaAskUtil;
258
- (function(TaAskUtil2) {
259
- const LENGTH = 120;
260
- function entry(question) {
261
- const line = question.replace(/\s+/g, " ").trim();
262
- return { question: line.length > LENGTH ? `${line.slice(0, LENGTH - 1)}…` : line };
263
- }
264
- TaAskUtil2.entry = entry;
265
- function asking(entries) {
266
- var _a;
267
- for (let i = entries.length - 1;i >= 0; i--) {
268
- const entry2 = entries[i];
269
- if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
270
- return;
271
- }
272
- if (entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY) {
273
- return read(entry2);
274
- }
275
- }
276
- return;
277
- }
278
- TaAskUtil2.asking = asking;
279
- function next(asked, entry2) {
280
- var _a;
281
- if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
282
- return;
283
- }
284
- return entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY ? read(entry2) : asked;
285
- }
286
- TaAskUtil2.next = next;
287
- function read(found) {
288
- var _a;
289
- const question = (_a = found.data) === null || _a === undefined ? undefined : _a.question;
290
- if (typeof question !== "string" || !question.trim()) {
291
- return;
292
- }
293
- const at = found.timestamp ? Date.parse(found.timestamp) : Number.NaN;
294
- return { question: entry(question).question, at: Number.isNaN(at) ? 0 : at };
295
- }
296
- })(TaAskUtil || (TaAskUtil = {}));
297
184
  // ../ta-protocol/esm/common/ta-protocol.js
298
185
  var TaServer = Symbol("TaServer");
299
186
  var TaClient = Symbol("TaClient");
@@ -497,6 +384,176 @@ var TaSkillUse;
497
384
  }
498
385
  TaSkillUse2.command = command;
499
386
  })(TaSkillUse || (TaSkillUse = {}));
387
+
388
+ // ../ta-protocol/esm/common/presence-protocol.js
389
+ var TaPresenceServer = Symbol("TaPresenceServer");
390
+ var TaMessageAuthor;
391
+ (function(TaMessageAuthor2) {
392
+ const LINE = /^\[ta:by ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
393
+ const LINES = /^\[ta:by [^\]\n]*\]$\n?/gm;
394
+ function strip(message) {
395
+ const context = TaMessageContext.read(message);
396
+ if (context === undefined || !LINE.test(context)) {
397
+ return message;
398
+ }
399
+ const kept = context.replace(LINES, "").replace(/\n+$/, "");
400
+ const body = TaMessageContext.strip(message);
401
+ return kept.trim() ? TaMessageContext.wrap(kept, body) : body;
402
+ }
403
+ TaMessageAuthor2.strip = strip;
404
+ function mark(message, id, name) {
405
+ const plain = strip(message);
406
+ if (/^[/!]/.test(plain)) {
407
+ return plain;
408
+ }
409
+ const line = `[ta:by ${id.replace(/[\s\]]/g, "")} ${name.replace(/[\]\n]/g, " ").trim() || id}]`;
410
+ const context = TaMessageContext.read(plain);
411
+ return TaMessageContext.wrap(context === undefined ? line : `${context}
412
+ ${line}`, TaMessageContext.strip(plain));
413
+ }
414
+ TaMessageAuthor2.mark = mark;
415
+ function of(message) {
416
+ var _a;
417
+ const context = TaMessageContext.read(message);
418
+ const match = context === undefined ? null : LINE.exec(context);
419
+ return match ? { id: match[1], name: ((_a = match[2]) !== null && _a !== undefined ? _a : match[1]).trim() } : undefined;
420
+ }
421
+ TaMessageAuthor2.of = of;
422
+ })(TaMessageAuthor || (TaMessageAuthor = {}));
423
+ // ../ta-protocol/esm/common/relay-protocol.js
424
+ var TaRelayServer = Symbol("TaRelayServer");
425
+ // ../ta-protocol/esm/common/remote-protocol.js
426
+ var TaRemoteServer = Symbol("TaRemoteServer");
427
+ // ../ta-protocol/esm/common/room-protocol.js
428
+ var TaRoomServer = Symbol("TaRoomServer");
429
+ var TaRoomWatchUtil;
430
+ (function(TaRoomWatchUtil2) {
431
+ function of(messages, state) {
432
+ const prefixes = Array.isArray(state) ? state.filter((prefix) => typeof prefix === "string" && prefix.length > 0) : [];
433
+ return { messages: messages !== false, state: [...new Set(prefixes)].sort() };
434
+ }
435
+ TaRoomWatchUtil2.of = of;
436
+ function union(watches) {
437
+ let messages = false;
438
+ const state = [];
439
+ for (const watch of watches) {
440
+ messages || (messages = watch.messages);
441
+ state.push(...watch.state);
442
+ }
443
+ return of(messages, messages ? [] : state);
444
+ }
445
+ TaRoomWatchUtil2.union = union;
446
+ function same(a, b) {
447
+ return a === b || !!a && !!b && a.messages === b.messages && a.state.join(`
448
+ `) === b.state.join(`
449
+ `);
450
+ }
451
+ TaRoomWatchUtil2.same = same;
452
+ function hears(watch, event) {
453
+ if (event.type === "message") {
454
+ return watch.messages;
455
+ }
456
+ if (event.type === "state") {
457
+ return watch.messages || watch.state.some((prefix) => event.key.startsWith(prefix));
458
+ }
459
+ return true;
460
+ }
461
+ TaRoomWatchUtil2.hears = hears;
462
+ })(TaRoomWatchUtil || (TaRoomWatchUtil = {}));
463
+ // ../ta-protocol/esm/common/settings-protocol.js
464
+ var TaSettingsServer = Symbol("TaSettingsServer");
465
+ // ../ta-protocol/esm/common/ta-extension-host.js
466
+ var TA_HOST_EVENT = "ta:host";
467
+ var TaHostUtil;
468
+ (function(TaHostUtil2) {
469
+ TaHostUtil2.WAIT_MS = 1000;
470
+ function reach(events, name, waitMs = TaHostUtil2.WAIT_MS) {
471
+ return new Promise((resolve) => {
472
+ let heard = false;
473
+ let answered = false;
474
+ const timer = setTimeout(() => resolve(undefined), waitMs);
475
+ const request = {
476
+ name,
477
+ heard: () => {
478
+ heard = true;
479
+ },
480
+ resolve: (answer) => {
481
+ answered = true;
482
+ clearTimeout(timer);
483
+ resolve(answer);
484
+ }
485
+ };
486
+ events.emit(TA_HOST_EVENT, request);
487
+ if (!heard && !answered) {
488
+ clearTimeout(timer);
489
+ resolve(undefined);
490
+ }
491
+ });
492
+ }
493
+ TaHostUtil2.reach = reach;
494
+ function marked(systemPrompt, mark) {
495
+ return role(systemPrompt).includes(mark);
496
+ }
497
+ TaHostUtil2.marked = marked;
498
+ function role(systemPrompt) {
499
+ if (!systemPrompt) {
500
+ return "";
501
+ }
502
+ const open = `<addendum>
503
+ `;
504
+ const start = systemPrompt.indexOf(open);
505
+ const context = systemPrompt.indexOf(`<project_context>
506
+ `);
507
+ if (start < 0 || context >= 0 && context < start) {
508
+ return "";
509
+ }
510
+ const end = systemPrompt.indexOf(`
511
+ </addendum>`, start);
512
+ return systemPrompt.slice(start + open.length, end < 0 ? undefined : end);
513
+ }
514
+ TaHostUtil2.role = role;
515
+ })(TaHostUtil || (TaHostUtil = {}));
516
+ var TA_ASK_ENTRY = "ta-ask";
517
+ var TaAskUtil;
518
+ (function(TaAskUtil2) {
519
+ const LENGTH = 120;
520
+ function entry(question) {
521
+ const line = question.replace(/\s+/g, " ").trim();
522
+ return { question: line.length > LENGTH ? `${line.slice(0, LENGTH - 1)}…` : line };
523
+ }
524
+ TaAskUtil2.entry = entry;
525
+ function asking(entries) {
526
+ var _a;
527
+ for (let i = entries.length - 1;i >= 0; i--) {
528
+ const entry2 = entries[i];
529
+ if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
530
+ return;
531
+ }
532
+ if (entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY) {
533
+ return read(entry2);
534
+ }
535
+ }
536
+ return;
537
+ }
538
+ TaAskUtil2.asking = asking;
539
+ function next(asked, entry2) {
540
+ var _a;
541
+ if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
542
+ return;
543
+ }
544
+ return entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY ? read(entry2) : asked;
545
+ }
546
+ TaAskUtil2.next = next;
547
+ function read(found) {
548
+ var _a;
549
+ const question = (_a = found.data) === null || _a === undefined ? undefined : _a.question;
550
+ if (typeof question !== "string" || !question.trim()) {
551
+ return;
552
+ }
553
+ const at = found.timestamp ? Date.parse(found.timestamp) : Number.NaN;
554
+ return { question: entry(question).question, at: Number.isNaN(at) ? 0 : at };
555
+ }
556
+ })(TaAskUtil || (TaAskUtil = {}));
500
557
  // ../ta-protocol/esm/common/team-protocol.js
501
558
  var TA_OWNER = "owner";
502
559
  var TA_UNDECLARED = "extensions.install";
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@celljs/ta-channels",
3
- "version": "4.13.0",
3
+ "version": "4.14.0",
4
4
  "description": "A pi package for Ta: agents with roles of their own and channels where the user, Ta and the agents talk; Ta builds the team for what the user wants",
5
5
  "keywords": [
6
6
  "pi-package"
7
7
  ],
8
- "homepage": "https://github.com/cellbang/cell",
8
+ "homepage": "https://github.com/cellbang/ta",
9
9
  "bugs": {
10
- "url": "https://github.com/cellbang/cell/issues"
10
+ "url": "https://github.com/cellbang/ta/issues"
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
@@ -27,9 +27,9 @@
27
27
  "watch": "tsc -b -w --preserveWatchOutput"
28
28
  },
29
29
  "devDependencies": {
30
- "@celljs/ta-protocol": "4.13.0",
31
- "@celljs/ta-relay": "4.13.0",
32
- "@celljs/ta-web": "4.13.0",
30
+ "@celljs/ta-protocol": "4.14.0",
31
+ "@celljs/ta-relay": "4.14.0",
32
+ "@celljs/ta-web": "4.14.0",
33
33
  "@types/react": "^19.3.0"
34
34
  },
35
35
  "publishConfig": {
package/web/index.js CHANGED
@@ -3383,6 +3383,7 @@ function ChannelRoom({ context, channelId: fixed }) {
3383
3383
  className: "tac-msg-face"
3384
3384
  }, first && pi.ui.Face && /* @__PURE__ */ React.createElement(pi.ui.Face, {
3385
3385
  seed: message.by ?? TA_OWNER,
3386
+ double: (message.by ?? TA_OWNER) === TA_OWNER,
3386
3387
  size: 28
3387
3388
  })), /* @__PURE__ */ React.createElement("div", {
3388
3389
  className: "tac-msg-col"