@celljs/ta-team 4.16.0 → 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.
@@ -1,4 +1,5 @@
1
1
  // ../ta-protocol/esm/common/ta-extension-host.js
2
+ var TA_WEBHOOK_MAX_BYTES = 256 * 1024;
2
3
  var TA_HOST_EVENT = "ta:host";
3
4
  var TaHostUtil;
4
5
  (function(TaHostUtil2) {
@@ -179,7 +180,7 @@ var TA_ACTIONS = [
179
180
  action("commands.terminal", "Open terminals", "打开终端", "開啟終端機", "ターミナルを開く", { scoped: true, risky: true }),
180
181
  action("hosts.use", "Use remote hosts", "使用远程主机", "使用遠端主機", "リモートホストを使用", { risky: true }),
181
182
  action("models.use", "Use the models", "使用模型", "使用模型", "モデルを使用"),
182
- action("models.manage", "Sign in to models", "登录和更换模型账号", "登入和更換模型帳號", "モデルアカウントにサインイン・変更"),
183
+ action("models.manage", "Sign in to models", "登录和更换模型账号", "登入和更換模型帳號", "モデルアカウントにサインイン・変更", { grant: "single" }),
183
184
  action("cron.view", "See scheduled tasks", "查看定时任务", "檢視定時任務", "スケジュールタスクを確認"),
184
185
  action("cron.manage", "Change scheduled tasks", "管理定时任务", "管理定時任務", "スケジュールタスクを管理"),
185
186
  action("extensions.use", "Use extensions", "使用扩展", "使用擴充功能", "拡張機能を使用"),
@@ -192,9 +193,15 @@ var TA_ACTIONS = [
192
193
  action("members.roles", "Change roles and members", "管理角色和成员", "管理角色和成員", "ロールとメンバーを管理"),
193
194
  action("audit.view", "See the record", "查看记录", "檢視記錄", "レコードを確認")
194
195
  ];
196
+ var TA_OWNER_ACTIONS = [
197
+ action("desktop.view", "See remote desktops", "查看远程桌面", "檢視遠端桌面", "リモートデスクトップを見る", { risky: true }),
198
+ action("desktop.control", "Work remote desktops", "操作远程桌面", "操作遠端桌面", "リモートデスクトップを操作", { risky: true })
199
+ ];
200
+ var OWNER_AREAS = ["desktop"];
195
201
  var TaActionUtil;
196
202
  (function(TaActionUtil2) {
197
203
  const byId = new Map(TA_ACTIONS.map((one) => [one.id, one]));
204
+ const titled = new Map([...TA_ACTIONS, ...TA_OWNER_ACTIONS].map((one) => [one.id, one]));
198
205
  function info(id) {
199
206
  return byId.get(id);
200
207
  }
@@ -202,7 +209,7 @@ var TaActionUtil;
202
209
  function title(id, language) {
203
210
  var _a;
204
211
  var _b, _c;
205
- const title2 = (_a = byId.get(id)) === null || _a === undefined ? undefined : _a.title;
212
+ const title2 = (_a = titled.get(id)) === null || _a === undefined ? undefined : _a.title;
206
213
  if (!title2) {
207
214
  return id;
208
215
  }
@@ -214,6 +221,16 @@ var TaActionUtil;
214
221
  });
215
222
  }
216
223
  TaActionUtil2.title = title;
224
+ function grantable(id) {
225
+ const info2 = byId.get(id);
226
+ return !!info2 && !OWNER_AREAS.includes(info2.area);
227
+ }
228
+ TaActionUtil2.grantable = grantable;
229
+ function inRoles(id) {
230
+ var _a;
231
+ return grantable(id) && ((_a = byId.get(id)) === null || _a === undefined ? undefined : _a.grant) !== "single";
232
+ }
233
+ TaActionUtil2.inRoles = inRoles;
217
234
  function inside(dir, path) {
218
235
  const base = dir.replace(/\/+$/, "");
219
236
  return path === base || path.startsWith(`${base}/`) || base === "";
@@ -223,6 +240,7 @@ var TaActionUtil;
223
240
 
224
241
  // web-src/protocol.ts
225
242
  var NAME = "@celljs/ta-team";
243
+ var ALL_ACTIONS = TA_ACTIONS.filter((action2) => TaActionUtil.inRoles(action2.id)).map((action2) => action2.id);
226
244
 
227
245
  // web-src/extension.ts
228
246
  var MEMBER_TOOLS = ["my_permissions", "request_permission"];
package/host/index.mjs CHANGED
@@ -90,7 +90,7 @@ var TA_ACTIONS = [
90
90
  action("commands.terminal", "Open terminals", "打开终端", "開啟終端機", "ターミナルを開く", { scoped: true, risky: true }),
91
91
  action("hosts.use", "Use remote hosts", "使用远程主机", "使用遠端主機", "リモートホストを使用", { risky: true }),
92
92
  action("models.use", "Use the models", "使用模型", "使用模型", "モデルを使用"),
93
- action("models.manage", "Sign in to models", "登录和更换模型账号", "登入和更換模型帳號", "モデルアカウントにサインイン・変更"),
93
+ action("models.manage", "Sign in to models", "登录和更换模型账号", "登入和更換模型帳號", "モデルアカウントにサインイン・変更", { grant: "single" }),
94
94
  action("cron.view", "See scheduled tasks", "查看定时任务", "檢視定時任務", "スケジュールタスクを確認"),
95
95
  action("cron.manage", "Change scheduled tasks", "管理定时任务", "管理定時任務", "スケジュールタスクを管理"),
96
96
  action("extensions.use", "Use extensions", "使用扩展", "使用擴充功能", "拡張機能を使用"),
@@ -103,9 +103,15 @@ var TA_ACTIONS = [
103
103
  action("members.roles", "Change roles and members", "管理角色和成员", "管理角色和成員", "ロールとメンバーを管理"),
104
104
  action("audit.view", "See the record", "查看记录", "檢視記錄", "レコードを確認")
105
105
  ];
106
+ var TA_OWNER_ACTIONS = [
107
+ action("desktop.view", "See remote desktops", "查看远程桌面", "檢視遠端桌面", "リモートデスクトップを見る", { risky: true }),
108
+ action("desktop.control", "Work remote desktops", "操作远程桌面", "操作遠端桌面", "リモートデスクトップを操作", { risky: true })
109
+ ];
110
+ var OWNER_AREAS = ["desktop"];
106
111
  var TaActionUtil;
107
112
  (function(TaActionUtil2) {
108
113
  const byId = new Map(TA_ACTIONS.map((one) => [one.id, one]));
114
+ const titled = new Map([...TA_ACTIONS, ...TA_OWNER_ACTIONS].map((one) => [one.id, one]));
109
115
  function info(id) {
110
116
  return byId.get(id);
111
117
  }
@@ -113,7 +119,7 @@ var TaActionUtil;
113
119
  function title(id, language) {
114
120
  var _a;
115
121
  var _b, _c;
116
- const title2 = (_a = byId.get(id)) === null || _a === undefined ? undefined : _a.title;
122
+ const title2 = (_a = titled.get(id)) === null || _a === undefined ? undefined : _a.title;
117
123
  if (!title2) {
118
124
  return id;
119
125
  }
@@ -125,6 +131,16 @@ var TaActionUtil;
125
131
  });
126
132
  }
127
133
  TaActionUtil2.title = title;
134
+ function grantable(id) {
135
+ const info2 = byId.get(id);
136
+ return !!info2 && !OWNER_AREAS.includes(info2.area);
137
+ }
138
+ TaActionUtil2.grantable = grantable;
139
+ function inRoles(id) {
140
+ var _a;
141
+ return grantable(id) && ((_a = byId.get(id)) === null || _a === undefined ? undefined : _a.grant) !== "single";
142
+ }
143
+ TaActionUtil2.inRoles = inRoles;
128
144
  function inside(dir, path) {
129
145
  const base = dir.replace(/\/+$/, "");
130
146
  return path === base || path.startsWith(`${base}/`) || base === "";
@@ -159,40 +175,7 @@ var EMPTY_DATA = {
159
175
  limits: DEFAULT_LIMITS,
160
176
  alerts: []
161
177
  };
162
- var ALL_ACTIONS = [
163
- "chat.view",
164
- "chat.send",
165
- "chat.create",
166
- "chat.stop",
167
- "chat.manage",
168
- "chat.share",
169
- "agent.view",
170
- "agent.use",
171
- "agent.edit",
172
- "channel.view",
173
- "channel.post",
174
- "channel.manage",
175
- "task.view",
176
- "task.create",
177
- "task.manage",
178
- "files.read",
179
- "files.write",
180
- "commands.run",
181
- "commands.terminal",
182
- "hosts.use",
183
- "models.use",
184
- "cron.view",
185
- "cron.manage",
186
- "extensions.use",
187
- "extensions.install",
188
- "settings.view",
189
- "settings.manage",
190
- "members.view",
191
- "members.invite",
192
- "members.approve",
193
- "members.roles",
194
- "audit.view"
195
- ];
178
+ var ALL_ACTIONS = TA_ACTIONS.filter((action2) => TaActionUtil.inRoles(action2.id)).map((action2) => action2.id);
196
179
  var PRESET_ROLES = [
197
180
  { id: "admin", name: "admin", preset: true, scope: "all", outside: "allow", dirs: ["/"], actions: ALL_ACTIONS },
198
181
  {
@@ -270,6 +253,10 @@ function ofAction(action2, of) {
270
253
  var TeamPolicy;
271
254
  ((TeamPolicy) => {
272
255
  TeamPolicy.MANAGING = ["members.invite", "members.approve", "members.roles"];
256
+ function catalog() {
257
+ return TA_ACTIONS.filter((action2) => TaActionUtil.inRoles(action2.id));
258
+ }
259
+ TeamPolicy.catalog = catalog;
273
260
  function manages(actions2) {
274
261
  return actions2.some((action2) => TeamPolicy.MANAGING.includes(action2));
275
262
  }
@@ -327,6 +314,9 @@ var TeamPolicy;
327
314
  reason,
328
315
  ...reason === "protected" || reason === "never" ? { askable: false } : {}
329
316
  });
317
+ if (!TaActionUtil.grantable(action2)) {
318
+ return refuse("never");
319
+ }
330
320
  if (principal.startsWith(TA_INVITE_PREFIX)) {
331
321
  return refuse("never");
332
322
  }
@@ -336,7 +326,7 @@ var TeamPolicy;
336
326
  }
337
327
  const role = roleOf(data, member.role);
338
328
  const shared = role?.scope === "shared";
339
- const has = role?.actions.includes(action2) ?? false;
329
+ const has = (role?.actions.includes(action2) ?? false) && TaActionUtil.inRoles(action2);
340
330
  const grants = data.grants.filter((grant) => grant.member === principal && valid(grant, context.now) && gives(grant.action, action2));
341
331
  const on = (kind, id) => grants.some((grant) => grant.resource?.kind === kind && grant.resource.id === id);
342
332
  const anywhere = grants.some((grant) => !grant.resource);
@@ -660,7 +650,7 @@ class TeamAdmin {
660
650
  if (PRESET_ROLES.some((preset) => preset.id === input?.id)) {
661
651
  throw new TeamError("A role that comes with Ta is not changed: copy it.");
662
652
  }
663
- const known = new Set(PRESET_ROLES[0].actions);
653
+ const known = new Set(TeamPolicy.catalog().map((action2) => action2.id));
664
654
  const actions = [
665
655
  ...new Set(Array.isArray(input?.actions) ? input.actions.filter((one) => typeof one === "string" && known.has(one)) : [])
666
656
  ];
@@ -692,7 +682,7 @@ class TeamAdmin {
692
682
  const by = this.team.require("members.roles");
693
683
  const member = this.team.memberOf(input?.member);
694
684
  const action2 = String(input?.action ?? "");
695
- if (!TaActionUtil.info(action2)) {
685
+ if (!TaActionUtil.grantable(action2)) {
696
686
  throw new TeamError("No such action.");
697
687
  }
698
688
  if (by !== TA_OWNER && !this.team.may(by, action2)) {
@@ -845,7 +835,7 @@ ${rule}`;
845
835
  var ANALYZE_PROMPT = [
846
836
  "Look into what the people let into this Ta did lately, as a security reviewer would.",
847
837
  "Read the record with the tool team_audit (first with notable: true, then more of whom it shows), and the alerts.",
848
- "Tell me in a few lines: who did what that changes or runs something, anything that looks like an attack or a mistake",
838
+ "Tell me: who did what that changes or runs something, anything that looks like an attack or a mistake",
849
839
  "(probing what is refused, reaching for keys or folders Ta keeps, running what was downloaded, sending files away),",
850
840
  "and what I should do (take back a grant, change a role, remove someone). Name people by their names, with when."
851
841
  ].join(" ");
@@ -977,6 +967,7 @@ ${lines.join(`
977
967
  import { randomBytes as randomBytes3 } from "node:crypto";
978
968
 
979
969
  // ../ta-protocol/esm/common/ta-extension-host.js
970
+ var TA_WEBHOOK_MAX_BYTES = 256 * 1024;
980
971
  var TA_HOST_EVENT = "ta:host";
981
972
  var TaHostUtil;
982
973
  (function(TaHostUtil2) {
@@ -1302,6 +1293,16 @@ var RELAY_CONNECT_PATH = "/v1/connect/";
1302
1293
  var RELAY_PAIR_PATH = "/pair";
1303
1294
  var RELAY_FRAME_CSP = "default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' https: data: blob:; style-src 'unsafe-inline' https: data:; img-src https: data: blob:; font-src https: data:; media-src https: data: blob:; connect-src 'none'; form-action 'none'";
1304
1295
  var RELAY_FRAME_HEADER_CSP = `${RELAY_FRAME_CSP}; frame-ancestors 'self'; sandbox allow-scripts allow-popups allow-popups-to-escape-sandbox`;
1296
+ var OPEN_IN_TA = `<p><a id="open" style="display:inline-block;padding:10px 18px;border-radius:20px;background:#111;color:#fff;text-decoration:none;font-weight:600">Open in Ta · 在 Ta 中打开</a></p>
1297
+ <script>document.getElementById('open').href='ta://open?link='+encodeURIComponent(location.href)</script>`;
1298
+ var RELAY_PAIR_PAGE = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>Ta</title>
1299
+ <body style="font:16px system-ui;max-width:32em;margin:3em auto;padding:0 1em">
1300
+ <h1>Ta</h1><p>Open this link in the Ta app, or paste it there, to reach your Ta from this device.</p>
1301
+ <p>打开 Ta 应用,粘贴这个链接,就能从这台设备连到你的 Ta。</p>${OPEN_IN_TA}</body>`;
1302
+ var RELAY_SHARE_PAGE = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>Ta</title>
1303
+ <body style="font:16px system-ui;max-width:32em;margin:3em auto;padding:0 1em">
1304
+ <h1>Ta</h1><p>Someone shared an extension of Ta. Scan the code in the Ta app, or paste this link in its Quick open, to open it.</p>
1305
+ <p>有人分享了一个 Ta 扩展。在 Ta 应用里扫码,或把这个链接粘贴到“快捷打开”,就能打开它。</p>${OPEN_IN_TA}</body>`;
1305
1306
  var RELAY_SHARE_MAX_BYTES = 8 * 1024 * 1024;
1306
1307
  var RELAY_SHARE_CHUNK_BYTES = 192 * 1024;
1307
1308
  var RELAY_CONTENT_MAX_BYTES = 8 * 1024 * 1024;
@@ -2293,6 +2294,279 @@ class TeamPeople {
2293
2294
  }
2294
2295
  }
2295
2296
 
2297
+ // ../ta-protocol/esm/common/message-protocol.js
2298
+ var TaMessageContext;
2299
+ (function(TaMessageContext2) {
2300
+ const BLOCK = /^<context>\n?[\s\S]*?\n?<\/context>\n?/;
2301
+ function wrap(context, message) {
2302
+ return `<context>
2303
+ ${context}
2304
+ </context>
2305
+ ${message}`;
2306
+ }
2307
+ TaMessageContext2.wrap = wrap;
2308
+ function strip(message) {
2309
+ return message.replace(BLOCK, "");
2310
+ }
2311
+ TaMessageContext2.strip = strip;
2312
+ function read(message) {
2313
+ var _a;
2314
+ const block = (_a = BLOCK.exec(message)) === null || _a === undefined ? undefined : _a[0];
2315
+ return block === null || block === undefined ? undefined : block.replace(/^<context>\n?/, "").replace(/\n?<\/context>\n?$/, "");
2316
+ }
2317
+ TaMessageContext2.read = read;
2318
+ })(TaMessageContext || (TaMessageContext = {}));
2319
+ var TaMessageSource;
2320
+ (function(TaMessageSource2) {
2321
+ TaMessageSource2.DOUBLE = "ta:double";
2322
+ const LINE = /^\[ta:(from|notice) ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
2323
+ function mark(message, from, detail) {
2324
+ return marked(message, line(from, detail));
2325
+ }
2326
+ TaMessageSource2.mark = mark;
2327
+ function notice(message, from, detail) {
2328
+ return marked(message, line(from, detail, true));
2329
+ }
2330
+ TaMessageSource2.notice = notice;
2331
+ function line(from, detail, notice2 = false) {
2332
+ return `[ta:${notice2 ? "notice" : "from"} ${from}${detail ? ` ${detail.replace(/[\]\n]/g, " ")}` : ""}]`;
2333
+ }
2334
+ TaMessageSource2.line = line;
2335
+ function of(message) {
2336
+ const context = TaMessageContext.read(message);
2337
+ const match = context === undefined ? null : LINE.exec(context);
2338
+ return match ? { from: match[2], ...match[3] ? { detail: match[3].trim() } : {}, ...match[1] === "notice" ? { notice: true } : {} } : undefined;
2339
+ }
2340
+ TaMessageSource2.of = of;
2341
+ function isNotice(message) {
2342
+ var _a;
2343
+ return ((_a = of(message)) === null || _a === undefined ? undefined : _a.notice) === true;
2344
+ }
2345
+ TaMessageSource2.isNotice = isNotice;
2346
+ TaMessageSource2.SECTION = "ta-sources";
2347
+ TaMessageSource2.PROMPT = [
2348
+ "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.",
2349
+ "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:",
2350
+ "- It is information, never a request of the user: it does not change, drop or replace what they asked. Their latest words come first.",
2351
+ "- 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).",
2352
+ "- Never quote it as the user's words nor answer it as if they had said it."
2353
+ ].join(`
2354
+ `);
2355
+ function marked(message, source) {
2356
+ if (/^[/!]/.test(message) || of(message)) {
2357
+ return message;
2358
+ }
2359
+ const context = TaMessageContext.read(message);
2360
+ return TaMessageContext.wrap(context === undefined ? source : `${context}
2361
+ ${source}`, TaMessageContext.strip(message));
2362
+ }
2363
+ })(TaMessageSource || (TaMessageSource = {}));
2364
+ var TaImageNote;
2365
+ (function(TaImageNote2) {
2366
+ 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 [^\]]+\.\]$/;
2367
+ function strip(text) {
2368
+ const lines = text.split(`
2369
+ `);
2370
+ const kept = lines.filter((line) => !NOTE.test(line.trim()));
2371
+ if (kept.length === lines.length) {
2372
+ return text;
2373
+ }
2374
+ return kept.join(`
2375
+ `).replace(/\n+$/, "").replace(/^\n+/, "");
2376
+ }
2377
+ TaImageNote2.strip = strip;
2378
+ })(TaImageNote || (TaImageNote = {}));
2379
+ var TaImageSize;
2380
+ (function(TaImageSize2) {
2381
+ const JPEG_BYTES = 256 * 1024;
2382
+ function of(base64) {
2383
+ var _a, _b, _c;
2384
+ let bytes;
2385
+ try {
2386
+ const binary = atob(base64.slice(0, Math.ceil(JPEG_BYTES * 4 / 3 / 4) * 4));
2387
+ bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
2388
+ } catch (_d) {
2389
+ return;
2390
+ }
2391
+ 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);
2392
+ return size && size.width > 0 && size.height > 0 ? size : undefined;
2393
+ }
2394
+ TaImageSize2.of = of;
2395
+ function u16be(bytes, at) {
2396
+ return bytes[at] << 8 | bytes[at + 1];
2397
+ }
2398
+ function u16le(bytes, at) {
2399
+ return bytes[at] | bytes[at + 1] << 8;
2400
+ }
2401
+ function u24le(bytes, at) {
2402
+ return bytes[at] | bytes[at + 1] << 8 | bytes[at + 2] << 16;
2403
+ }
2404
+ function u32be(bytes, at) {
2405
+ return (bytes[at] << 24 | bytes[at + 1] << 16 | bytes[at + 2] << 8 | bytes[at + 3]) >>> 0;
2406
+ }
2407
+ function text(bytes, at, length) {
2408
+ return String.fromCharCode(...bytes.subarray(at, at + length));
2409
+ }
2410
+ function png(bytes) {
2411
+ return bytes.length >= 24 && bytes[0] === 137 && text(bytes, 1, 3) === "PNG" ? { width: u32be(bytes, 16), height: u32be(bytes, 20) } : undefined;
2412
+ }
2413
+ function gif(bytes) {
2414
+ return bytes.length >= 10 && text(bytes, 0, 3) === "GIF" ? { width: u16le(bytes, 6), height: u16le(bytes, 8) } : undefined;
2415
+ }
2416
+ function webp(bytes) {
2417
+ if (bytes.length < 30 || text(bytes, 0, 4) !== "RIFF" || text(bytes, 8, 4) !== "WEBP") {
2418
+ return;
2419
+ }
2420
+ switch (text(bytes, 12, 4)) {
2421
+ case "VP8 ":
2422
+ return { width: u16le(bytes, 26) & 16383, height: u16le(bytes, 28) & 16383 };
2423
+ case "VP8L": {
2424
+ const bits = bytes[21] | bytes[22] << 8 | bytes[23] << 16 | bytes[24] << 24;
2425
+ return { width: (bits & 16383) + 1, height: (bits >> 14 & 16383) + 1 };
2426
+ }
2427
+ case "VP8X":
2428
+ return { width: u24le(bytes, 24) + 1, height: u24le(bytes, 27) + 1 };
2429
+ default:
2430
+ return;
2431
+ }
2432
+ }
2433
+ function jpeg(bytes) {
2434
+ if (bytes[0] !== 255 || bytes[1] !== 216) {
2435
+ return;
2436
+ }
2437
+ let at = 2;
2438
+ while (at + 9 < bytes.length) {
2439
+ if (bytes[at] !== 255) {
2440
+ return;
2441
+ }
2442
+ const marker = bytes[at + 1];
2443
+ if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) {
2444
+ return { width: u16be(bytes, at + 7), height: u16be(bytes, at + 5) };
2445
+ }
2446
+ at += 2 + u16be(bytes, at + 2);
2447
+ }
2448
+ return;
2449
+ }
2450
+ })(TaImageSize || (TaImageSize = {}));
2451
+ var TaAgentSummary;
2452
+ (function(TaAgentSummary2) {
2453
+ const START = /^\s*<conversation_history_summary>/;
2454
+ const BLOCK = /^\s*<conversation_history_summary>[\s\S]*?(?:<\/conversation_history_summary>\s*|$)/;
2455
+ function read(text) {
2456
+ if (!START.test(text)) {
2457
+ return;
2458
+ }
2459
+ return text.replace(/<\/?(?:conversation_history_summary|summary)>/g, "").replace(/<\/?\w*$/, "").trim();
2460
+ }
2461
+ TaAgentSummary2.read = read;
2462
+ function strip(text) {
2463
+ return text.replace(BLOCK, "");
2464
+ }
2465
+ TaAgentSummary2.strip = strip;
2466
+ })(TaAgentSummary || (TaAgentSummary = {}));
2467
+ var TaSkillUse;
2468
+ (function(TaSkillUse2) {
2469
+ const BLOCK = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
2470
+ function parse(message) {
2471
+ var _a;
2472
+ const match = BLOCK.exec(message);
2473
+ if (!match) {
2474
+ return;
2475
+ }
2476
+ return { name: match[1], location: match[2], content: match[3], message: ((_a = match[4]) === null || _a === undefined ? undefined : _a.trim()) || undefined };
2477
+ }
2478
+ TaSkillUse2.parse = parse;
2479
+ function command(use) {
2480
+ return use.message ? `/skill:${use.name} ${use.message}` : `/skill:${use.name}`;
2481
+ }
2482
+ TaSkillUse2.command = command;
2483
+ })(TaSkillUse || (TaSkillUse = {}));
2484
+ var TaTaskNote;
2485
+ (function(TaTaskNote2) {
2486
+ const NOTE = /^<task_(update|adopted|renamed) ((?:[^>"\n]|"[^"]*")*)>\n?([\s\S]*?)\n?<\/task_\1>$/;
2487
+ const ATTRIBUTE = /(\w+)="([^"]*)"/g;
2488
+ function write(note) {
2489
+ const attributes = [`id="${quote(note.id)}"`];
2490
+ if (note.was !== undefined) {
2491
+ attributes.push(`was="${quote(note.was)}"`);
2492
+ }
2493
+ attributes.push(`title="${quote(note.title)}"`);
2494
+ if (note.status !== undefined) {
2495
+ attributes.push(`status="${quote(note.status)}"`);
2496
+ }
2497
+ return `<task_${note.kind} ${attributes.join(" ")}>
2498
+ ${note.body}
2499
+ </task_${note.kind}>`;
2500
+ }
2501
+ TaTaskNote2.write = write;
2502
+ function parse(text) {
2503
+ const match = NOTE.exec(text.trim());
2504
+ if (!match) {
2505
+ return;
2506
+ }
2507
+ const attributes = {};
2508
+ for (const [, name, value] of match[2].matchAll(ATTRIBUTE)) {
2509
+ attributes[name] = unquote(value);
2510
+ }
2511
+ if (!attributes.id || attributes.title === undefined) {
2512
+ return;
2513
+ }
2514
+ const { id: id2, title, status, was } = attributes;
2515
+ return { kind: match[1], id: id2, title, ...status ? { status } : {}, ...was ? { was } : {}, body: match[3] };
2516
+ }
2517
+ TaTaskNote2.parse = parse;
2518
+ function quote(text) {
2519
+ return text.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/\n/g, " ");
2520
+ }
2521
+ function unquote(text) {
2522
+ return text.replace(/&quot;/g, '"').replace(/&amp;/g, "&");
2523
+ }
2524
+ })(TaTaskNote || (TaTaskNote = {}));
2525
+ var TaSecretRef;
2526
+ (function(TaSecretRef2) {
2527
+ TaSecretRef2.PACKAGE = "@celljs/ta-secrets";
2528
+ const REF = /\$\{?TA_SECRET_([A-Z0-9][A-Z0-9_]*)\}?/g;
2529
+ const KINDS = [
2530
+ [/^PHONE(?:_\d+)?$/, "phone"],
2531
+ [/^EMAIL(?:_\d+)?$/, "email"],
2532
+ [/^ID_NUMBER(?:_\d+)?$/, "idNumber"],
2533
+ [/^BANK_CARD(?:_\d+)?$/, "bankCard"]
2534
+ ];
2535
+ function has(text) {
2536
+ return text.includes("TA_SECRET_") && new RegExp(REF.source).test(text);
2537
+ }
2538
+ TaSecretRef2.has = has;
2539
+ function kind(name) {
2540
+ var _a;
2541
+ var _b;
2542
+ return (_b = (_a = KINDS.find(([pattern]) => pattern.test(name))) === null || _a === undefined ? undefined : _a[1]) !== null && _b !== undefined ? _b : "secret";
2543
+ }
2544
+ TaSecretRef2.kind = kind;
2545
+ function split(text) {
2546
+ if (!has(text)) {
2547
+ return [{ text }];
2548
+ }
2549
+ const parts = [];
2550
+ let at = 0;
2551
+ for (const match of text.matchAll(REF)) {
2552
+ if (match.index > at) {
2553
+ parts.push({ text: text.slice(at, match.index) });
2554
+ }
2555
+ parts.push({ secret: match[1], kind: kind(match[1]) });
2556
+ at = match.index + match[0].length;
2557
+ }
2558
+ if (at < text.length) {
2559
+ parts.push({ text: text.slice(at) });
2560
+ }
2561
+ return parts;
2562
+ }
2563
+ TaSecretRef2.split = split;
2564
+ function plain(text, label) {
2565
+ return has(text) ? text.replace(REF, (_whole, name) => label(name, kind(name))) : text;
2566
+ }
2567
+ TaSecretRef2.plain = plain;
2568
+ })(TaSecretRef || (TaSecretRef = {}));
2569
+
2296
2570
  // web-src/team-requests.ts
2297
2571
  var DAY4 = 24 * 60 * 60 * 1000;
2298
2572
  var DURATIONS2 = { "1h": 60 * 60 * 1000, "1d": DAY4, "7d": 7 * DAY4, always: undefined };
@@ -2311,7 +2585,7 @@ class TeamRequests {
2311
2585
  throw new TeamError("Only someone let into this Ta asks for more.");
2312
2586
  }
2313
2587
  const action2 = String(input?.action ?? "");
2314
- if (!TaActionUtil.info(action2)) {
2588
+ if (!TaActionUtil.grantable(action2)) {
2315
2589
  throw new TeamError("Name the action asked for, as the refusal named it.");
2316
2590
  }
2317
2591
  const resource = TeamInput.resource(input?.resource);
@@ -2365,6 +2639,9 @@ class TeamRequests {
2365
2639
  team.save();
2366
2640
  return request;
2367
2641
  }
2642
+ if (!TaActionUtil.grantable(request.action)) {
2643
+ throw new TeamError("This is the owner's alone: it is given to no one.");
2644
+ }
2368
2645
  if (by !== TA_OWNER && !team.may(by, request.action)) {
2369
2646
  throw new TeamError("You cannot give what you may not do yourself.");
2370
2647
  }
@@ -2385,7 +2662,7 @@ class TeamRequests {
2385
2662
  async goOn(request) {
2386
2663
  const { host } = this.team;
2387
2664
  const file = request.sessionFile;
2388
- const message = `(Ta) "${TaActionUtil.title(request.action, "en")}" was granted. Go on with what was refused before.`;
2665
+ const message = TaMessageSource.notice(`"${TaActionUtil.title(request.action, "en")}" was granted. Go on with what was refused before.`, NAME);
2389
2666
  await host.team.actAs(request.member, async () => {
2390
2667
  const open = (await host.listSessions()).find((session) => session.sessionFile === file);
2391
2668
  const cwd = open?.cwd ?? await host.sessionCwd(file);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-team",
3
- "version": "4.16.0",
3
+ "version": "4.18.0",
4
4
  "description": "A pi package for Ta: people let into your Ta by a link, each with a role (admin, collaborator, viewer, guest, or one of your own), what they may do checked by the Ta service for every call and every tool, asking for more and the answers, and a record",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -27,9 +27,9 @@
27
27
  "watch": "tsc -b -w --preserveWatchOutput"
28
28
  },
29
29
  "devDependencies": {
30
- "@celljs/ta-protocol": "4.16.0",
31
- "@celljs/ta-relay": "4.16.0",
32
- "@celljs/ta-web": "4.16.0",
30
+ "@celljs/ta-protocol": "4.18.0",
31
+ "@celljs/ta-relay": "4.18.0",
32
+ "@celljs/ta-web": "4.18.0",
33
33
  "@types/react": "^19.3.0"
34
34
  },
35
35
  "publishConfig": {