@celljs/ta-team 4.20.0 → 4.22.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/host/index.mjs CHANGED
@@ -225,6 +225,15 @@ class TeamError extends Error {
225
225
  }
226
226
 
227
227
  // web-src/policy.ts
228
+ var UNICODE_SPACES = /[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g;
229
+ function fileUrlPath(given) {
230
+ try {
231
+ const url = new URL(given);
232
+ return url.hostname && url.hostname !== "localhost" ? `/~${url.hostname}${url.pathname}` : decodeURIComponent(url.pathname);
233
+ } catch {
234
+ return "/~";
235
+ }
236
+ }
228
237
  var SCOPED = new Set(["files.read", "files.write", "commands.run", "commands.terminal"]);
229
238
  var IMPLIES = {
230
239
  "agent.edit": ["agent.use", "agent.view"],
@@ -390,9 +399,16 @@ var TeamPolicy;
390
399
  return refuse(outside === "deny" ? "never" : "outside");
391
400
  }
392
401
  function resolve(cwd, path, home) {
393
- let given = typeof path === "string" && path.trim() ? path.trim() : ".";
394
- if (home && (given === "~" || given.startsWith("~/"))) {
395
- given = home.replace(/\/+$/, "") + given.slice(1);
402
+ let given = typeof path === "string" && path.trim() ? path.trim().replace(UNICODE_SPACES, " ") : ".";
403
+ if (given.startsWith("@")) {
404
+ given = given.slice(1) || ".";
405
+ }
406
+ if (given === "~" || given.startsWith("~/")) {
407
+ given = (home ? home.replace(/\/+$/, "") : "/~") + given.slice(1);
408
+ }
409
+ const file = /^file:\/\//.test(given) ? fileUrlPath(given) : undefined;
410
+ if (file !== undefined) {
411
+ return normalize(file);
396
412
  }
397
413
  if (given.startsWith("/") || /^[a-z][a-z0-9+.-]*:\/\//i.test(given)) {
398
414
  return normalize(given);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-team",
3
- "version": "4.20.0",
3
+ "version": "4.22.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.20.0",
31
- "@celljs/ta-relay": "4.20.0",
32
- "@celljs/ta-web": "4.20.0",
30
+ "@celljs/ta-protocol": "4.22.0",
31
+ "@celljs/ta-relay": "4.22.0",
32
+ "@celljs/ta-web": "4.22.0",
33
33
  "@types/react": "^19.3.0"
34
34
  },
35
35
  "publishConfig": {
package/web/index.js CHANGED
@@ -1263,6 +1263,15 @@ class TeamError extends Error {
1263
1263
  }
1264
1264
 
1265
1265
  // web-src/policy.ts
1266
+ var UNICODE_SPACES = /[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g;
1267
+ function fileUrlPath(given) {
1268
+ try {
1269
+ const url = new URL(given);
1270
+ return url.hostname && url.hostname !== "localhost" ? `/~${url.hostname}${url.pathname}` : decodeURIComponent(url.pathname);
1271
+ } catch {
1272
+ return "/~";
1273
+ }
1274
+ }
1266
1275
  var SCOPED = new Set(["files.read", "files.write", "commands.run", "commands.terminal"]);
1267
1276
  var IMPLIES = {
1268
1277
  "agent.edit": ["agent.use", "agent.view"],
@@ -1428,9 +1437,16 @@ var TeamPolicy;
1428
1437
  return refuse(outside === "deny" ? "never" : "outside");
1429
1438
  }
1430
1439
  function resolve(cwd, path, home) {
1431
- let given = typeof path === "string" && path.trim() ? path.trim() : ".";
1432
- if (home && (given === "~" || given.startsWith("~/"))) {
1433
- given = home.replace(/\/+$/, "") + given.slice(1);
1440
+ let given = typeof path === "string" && path.trim() ? path.trim().replace(UNICODE_SPACES, " ") : ".";
1441
+ if (given.startsWith("@")) {
1442
+ given = given.slice(1) || ".";
1443
+ }
1444
+ if (given === "~" || given.startsWith("~/")) {
1445
+ given = (home ? home.replace(/\/+$/, "") : "/~") + given.slice(1);
1446
+ }
1447
+ const file = /^file:\/\//.test(given) ? fileUrlPath(given) : undefined;
1448
+ if (file !== undefined) {
1449
+ return normalize(file);
1434
1450
  }
1435
1451
  if (given.startsWith("/") || /^[a-z][a-z0-9+.-]*:\/\//i.test(given)) {
1436
1452
  return normalize(given);
@@ -2845,6 +2861,36 @@ class TeamSharedHome {
2845
2861
  listeners = new Set;
2846
2862
  timer;
2847
2863
  items = () => this.current;
2864
+ asPartners = () => {
2865
+ const made = new WeakMap;
2866
+ let list = [];
2867
+ let from;
2868
+ return {
2869
+ partners: () => {
2870
+ if (from !== this.current) {
2871
+ from = this.current;
2872
+ list = this.current.map((item) => {
2873
+ let partner = made.get(item);
2874
+ if (!partner) {
2875
+ partner = {
2876
+ id: item.id,
2877
+ kind: item.kind === "agent" ? "agent" : "group",
2878
+ name: item.title,
2879
+ about: item.detail,
2880
+ icon: item.icon,
2881
+ ...item.face ? { face: item.face } : {},
2882
+ open: item.open
2883
+ };
2884
+ made.set(item, partner);
2885
+ }
2886
+ return partner;
2887
+ });
2888
+ }
2889
+ return list;
2890
+ },
2891
+ subscribe: this.subscribe
2892
+ };
2893
+ };
2848
2894
  subscribe = (listener) => {
2849
2895
  this.listeners.add(listener);
2850
2896
  return () => this.listeners.delete(listener);
@@ -2884,6 +2930,7 @@ class TeamSharedHome {
2884
2930
  show(joined) {
2885
2931
  const items = joined.flatMap((one) => (one.shared ?? []).map((shared) => ({
2886
2932
  id: `${one.owner}:${shared.kind}:${shared.id}`,
2933
+ kind: shared.kind,
2887
2934
  title: shared.name,
2888
2935
  detail: t("fromTa", { owner: one.owner }),
2889
2936
  icon: icon(shared.kind === "agent" ? "Bot" : "Hash"),
@@ -3836,7 +3883,11 @@ function activate(pi2) {
3836
3883
  book.load();
3837
3884
  const home = new TeamSharedHome;
3838
3885
  const stopHome = home.start();
3839
- pi2.registerHomeItems?.(home);
3886
+ if (typeof pi2.registerPartners === "function") {
3887
+ pi2.registerPartners(home.asPartners());
3888
+ } else {
3889
+ pi2.registerHomeItems?.(home);
3890
+ }
3840
3891
  TeamSharedHome.openPending();
3841
3892
  return () => {
3842
3893
  removeStyle();