@celljs/ta-team 4.17.0 → 4.19.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/extension/index.mjs +19 -2
- package/host/index.mjs +318 -42
- package/package.json +4 -4
- package/web/index.js +353 -67
package/extension/index.mjs
CHANGED
|
@@ -180,7 +180,7 @@ var TA_ACTIONS = [
|
|
|
180
180
|
action("commands.terminal", "Open terminals", "打开终端", "開啟終端機", "ターミナルを開く", { scoped: true, risky: true }),
|
|
181
181
|
action("hosts.use", "Use remote hosts", "使用远程主机", "使用遠端主機", "リモートホストを使用", { risky: true }),
|
|
182
182
|
action("models.use", "Use the models", "使用模型", "使用模型", "モデルを使用"),
|
|
183
|
-
action("models.manage", "Sign in to models", "登录和更换模型账号", "登入和更換模型帳號", "モデルアカウントにサインイン・変更"),
|
|
183
|
+
action("models.manage", "Sign in to models", "登录和更换模型账号", "登入和更換模型帳號", "モデルアカウントにサインイン・変更", { grant: "single" }),
|
|
184
184
|
action("cron.view", "See scheduled tasks", "查看定时任务", "檢視定時任務", "スケジュールタスクを確認"),
|
|
185
185
|
action("cron.manage", "Change scheduled tasks", "管理定时任务", "管理定時任務", "スケジュールタスクを管理"),
|
|
186
186
|
action("extensions.use", "Use extensions", "使用扩展", "使用擴充功能", "拡張機能を使用"),
|
|
@@ -193,9 +193,15 @@ var TA_ACTIONS = [
|
|
|
193
193
|
action("members.roles", "Change roles and members", "管理角色和成员", "管理角色和成員", "ロールとメンバーを管理"),
|
|
194
194
|
action("audit.view", "See the record", "查看记录", "檢視記錄", "レコードを確認")
|
|
195
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"];
|
|
196
201
|
var TaActionUtil;
|
|
197
202
|
(function(TaActionUtil2) {
|
|
198
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]));
|
|
199
205
|
function info(id) {
|
|
200
206
|
return byId.get(id);
|
|
201
207
|
}
|
|
@@ -203,7 +209,7 @@ var TaActionUtil;
|
|
|
203
209
|
function title(id, language) {
|
|
204
210
|
var _a;
|
|
205
211
|
var _b, _c;
|
|
206
|
-
const title2 = (_a =
|
|
212
|
+
const title2 = (_a = titled.get(id)) === null || _a === undefined ? undefined : _a.title;
|
|
207
213
|
if (!title2) {
|
|
208
214
|
return id;
|
|
209
215
|
}
|
|
@@ -215,6 +221,16 @@ var TaActionUtil;
|
|
|
215
221
|
});
|
|
216
222
|
}
|
|
217
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;
|
|
218
234
|
function inside(dir, path) {
|
|
219
235
|
const base = dir.replace(/\/+$/, "");
|
|
220
236
|
return path === base || path.startsWith(`${base}/`) || base === "";
|
|
@@ -224,6 +240,7 @@ var TaActionUtil;
|
|
|
224
240
|
|
|
225
241
|
// web-src/protocol.ts
|
|
226
242
|
var NAME = "@celljs/ta-team";
|
|
243
|
+
var ALL_ACTIONS = TA_ACTIONS.filter((action2) => TaActionUtil.inRoles(action2.id)).map((action2) => action2.id);
|
|
227
244
|
|
|
228
245
|
// web-src/extension.ts
|
|
229
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 =
|
|
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(
|
|
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.
|
|
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
|
|
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(" ");
|
|
@@ -1303,6 +1293,16 @@ var RELAY_CONNECT_PATH = "/v1/connect/";
|
|
|
1303
1293
|
var RELAY_PAIR_PATH = "/pair";
|
|
1304
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'";
|
|
1305
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>`;
|
|
1306
1306
|
var RELAY_SHARE_MAX_BYTES = 8 * 1024 * 1024;
|
|
1307
1307
|
var RELAY_SHARE_CHUNK_BYTES = 192 * 1024;
|
|
1308
1308
|
var RELAY_CONTENT_MAX_BYTES = 8 * 1024 * 1024;
|
|
@@ -2294,6 +2294,279 @@ class TeamPeople {
|
|
|
2294
2294
|
}
|
|
2295
2295
|
}
|
|
2296
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, "&").replace(/"/g, """).replace(/\n/g, " ");
|
|
2520
|
+
}
|
|
2521
|
+
function unquote(text) {
|
|
2522
|
+
return text.replace(/"/g, '"').replace(/&/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
|
+
|
|
2297
2570
|
// web-src/team-requests.ts
|
|
2298
2571
|
var DAY4 = 24 * 60 * 60 * 1000;
|
|
2299
2572
|
var DURATIONS2 = { "1h": 60 * 60 * 1000, "1d": DAY4, "7d": 7 * DAY4, always: undefined };
|
|
@@ -2312,7 +2585,7 @@ class TeamRequests {
|
|
|
2312
2585
|
throw new TeamError("Only someone let into this Ta asks for more.");
|
|
2313
2586
|
}
|
|
2314
2587
|
const action2 = String(input?.action ?? "");
|
|
2315
|
-
if (!TaActionUtil.
|
|
2588
|
+
if (!TaActionUtil.grantable(action2)) {
|
|
2316
2589
|
throw new TeamError("Name the action asked for, as the refusal named it.");
|
|
2317
2590
|
}
|
|
2318
2591
|
const resource = TeamInput.resource(input?.resource);
|
|
@@ -2366,6 +2639,9 @@ class TeamRequests {
|
|
|
2366
2639
|
team.save();
|
|
2367
2640
|
return request;
|
|
2368
2641
|
}
|
|
2642
|
+
if (!TaActionUtil.grantable(request.action)) {
|
|
2643
|
+
throw new TeamError("This is the owner's alone: it is given to no one.");
|
|
2644
|
+
}
|
|
2369
2645
|
if (by !== TA_OWNER && !team.may(by, request.action)) {
|
|
2370
2646
|
throw new TeamError("You cannot give what you may not do yourself.");
|
|
2371
2647
|
}
|
|
@@ -2386,7 +2662,7 @@ class TeamRequests {
|
|
|
2386
2662
|
async goOn(request) {
|
|
2387
2663
|
const { host } = this.team;
|
|
2388
2664
|
const file = request.sessionFile;
|
|
2389
|
-
const message = `
|
|
2665
|
+
const message = TaMessageSource.notice(`"${TaActionUtil.title(request.action, "en")}" was granted. Go on with what was refused before.`, NAME);
|
|
2390
2666
|
await host.team.actAs(request.member, async () => {
|
|
2391
2667
|
const open = (await host.listSessions()).find((session) => session.sessionFile === file);
|
|
2392
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.
|
|
3
|
+
"version": "4.19.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.
|
|
31
|
-
"@celljs/ta-relay": "4.
|
|
32
|
-
"@celljs/ta-web": "4.
|
|
30
|
+
"@celljs/ta-protocol": "4.19.0",
|
|
31
|
+
"@celljs/ta-relay": "4.19.0",
|
|
32
|
+
"@celljs/ta-web": "4.19.0",
|
|
33
33
|
"@types/react": "^19.3.0"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
package/web/index.js
CHANGED
|
@@ -39,6 +39,7 @@ var TaLanguageUtil;
|
|
|
39
39
|
|
|
40
40
|
// ../ta-protocol/esm/common/team-protocol.js
|
|
41
41
|
var TA_OWNER = "owner";
|
|
42
|
+
var TA_INVITE_PREFIX = "invite:";
|
|
42
43
|
var TA_UNDECLARED = "extensions.install";
|
|
43
44
|
var TaPermissionUtil;
|
|
44
45
|
(function(TaPermissionUtil2) {
|
|
@@ -87,7 +88,7 @@ var TA_ACTIONS = [
|
|
|
87
88
|
action("commands.terminal", "Open terminals", "打开终端", "開啟終端機", "ターミナルを開く", { scoped: true, risky: true }),
|
|
88
89
|
action("hosts.use", "Use remote hosts", "使用远程主机", "使用遠端主機", "リモートホストを使用", { risky: true }),
|
|
89
90
|
action("models.use", "Use the models", "使用模型", "使用模型", "モデルを使用"),
|
|
90
|
-
action("models.manage", "Sign in to models", "登录和更换模型账号", "登入和更換模型帳號", "モデルアカウントにサインイン・変更"),
|
|
91
|
+
action("models.manage", "Sign in to models", "登录和更换模型账号", "登入和更換模型帳號", "モデルアカウントにサインイン・変更", { grant: "single" }),
|
|
91
92
|
action("cron.view", "See scheduled tasks", "查看定时任务", "檢視定時任務", "スケジュールタスクを確認"),
|
|
92
93
|
action("cron.manage", "Change scheduled tasks", "管理定时任务", "管理定時任務", "スケジュールタスクを管理"),
|
|
93
94
|
action("extensions.use", "Use extensions", "使用扩展", "使用擴充功能", "拡張機能を使用"),
|
|
@@ -100,9 +101,15 @@ var TA_ACTIONS = [
|
|
|
100
101
|
action("members.roles", "Change roles and members", "管理角色和成员", "管理角色和成員", "ロールとメンバーを管理"),
|
|
101
102
|
action("audit.view", "See the record", "查看记录", "檢視記錄", "レコードを確認")
|
|
102
103
|
];
|
|
104
|
+
var TA_OWNER_ACTIONS = [
|
|
105
|
+
action("desktop.view", "See remote desktops", "查看远程桌面", "檢視遠端桌面", "リモートデスクトップを見る", { risky: true }),
|
|
106
|
+
action("desktop.control", "Work remote desktops", "操作远程桌面", "操作遠端桌面", "リモートデスクトップを操作", { risky: true })
|
|
107
|
+
];
|
|
108
|
+
var OWNER_AREAS = ["desktop"];
|
|
103
109
|
var TaActionUtil;
|
|
104
110
|
(function(TaActionUtil2) {
|
|
105
111
|
const byId = new Map(TA_ACTIONS.map((one) => [one.id, one]));
|
|
112
|
+
const titled = new Map([...TA_ACTIONS, ...TA_OWNER_ACTIONS].map((one) => [one.id, one]));
|
|
106
113
|
function info(id) {
|
|
107
114
|
return byId.get(id);
|
|
108
115
|
}
|
|
@@ -110,7 +117,7 @@ var TaActionUtil;
|
|
|
110
117
|
function title(id, language) {
|
|
111
118
|
var _a;
|
|
112
119
|
var _b, _c;
|
|
113
|
-
const title2 = (_a =
|
|
120
|
+
const title2 = (_a = titled.get(id)) === null || _a === undefined ? undefined : _a.title;
|
|
114
121
|
if (!title2) {
|
|
115
122
|
return id;
|
|
116
123
|
}
|
|
@@ -122,6 +129,16 @@ var TaActionUtil;
|
|
|
122
129
|
});
|
|
123
130
|
}
|
|
124
131
|
TaActionUtil2.title = title;
|
|
132
|
+
function grantable(id) {
|
|
133
|
+
const info2 = byId.get(id);
|
|
134
|
+
return !!info2 && !OWNER_AREAS.includes(info2.area);
|
|
135
|
+
}
|
|
136
|
+
TaActionUtil2.grantable = grantable;
|
|
137
|
+
function inRoles(id) {
|
|
138
|
+
var _a;
|
|
139
|
+
return grantable(id) && ((_a = byId.get(id)) === null || _a === undefined ? undefined : _a.grant) !== "single";
|
|
140
|
+
}
|
|
141
|
+
TaActionUtil2.inRoles = inRoles;
|
|
125
142
|
function inside(dir, path) {
|
|
126
143
|
const base = dir.replace(/\/+$/, "");
|
|
127
144
|
return path === base || path.startsWith(`${base}/`) || base === "";
|
|
@@ -129,10 +146,31 @@ var TaActionUtil;
|
|
|
129
146
|
TaActionUtil2.inside = inside;
|
|
130
147
|
})(TaActionUtil || (TaActionUtil = {}));
|
|
131
148
|
|
|
149
|
+
// ../ta-web/esm/browser/extension/share-sheet-compat.js
|
|
150
|
+
function ShareSheetCompat({ pi, ...props }) {
|
|
151
|
+
const h = pi.React.createElement;
|
|
152
|
+
if (pi.ui.ShareSheet) {
|
|
153
|
+
return h(pi.ui.ShareSheet, props);
|
|
154
|
+
}
|
|
155
|
+
const { title, link, error, name, gets, notes, password, own, onClose, children } = props;
|
|
156
|
+
const quiet = { margin: 0, opacity: 0.7, textAlign: "center" };
|
|
157
|
+
return h(pi.ui.Dialog, { title, onClose }, h("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", gap: 12 } }, error !== undefined ? h("p", { role: "alert" }, error) : [
|
|
158
|
+
name || gets ? h("p", { key: "who", style: { margin: 0, textAlign: "center" } }, [name, gets].filter(Boolean).join(" · ")) : null,
|
|
159
|
+
link && !own ? h(pi.ui.QrCode, { key: "qr", text: link, label: name || title }) : null,
|
|
160
|
+
h("code", { key: "link", style: { maxWidth: "100%", overflowWrap: "anywhere", userSelect: "all" } }, link !== null && link !== undefined ? link : "…"),
|
|
161
|
+
password ? h("code", { key: "password", style: { userSelect: "all" } }, password) : null,
|
|
162
|
+
link ? h("button", { key: "copy", type: "button", className: "ta-button ta-primary", onClick: () => {
|
|
163
|
+
var _a;
|
|
164
|
+
return void ((_a = navigator.clipboard) === null || _a === undefined ? undefined : _a.writeText(link));
|
|
165
|
+
} }, "Copy") : null,
|
|
166
|
+
children,
|
|
167
|
+
...(notes !== null && notes !== undefined ? notes : []).filter(Boolean).map((line) => h("p", { key: String(line), style: quiet }, line))
|
|
168
|
+
]));
|
|
169
|
+
}
|
|
170
|
+
|
|
132
171
|
// web-src/i18n-ja.ts
|
|
133
172
|
var JA = {
|
|
134
173
|
title: "メンバーと権限",
|
|
135
|
-
loading: "読込中…",
|
|
136
174
|
inviteTitle: "あなたの Ta に人を招待する",
|
|
137
175
|
inviteLine: "メンバーはあなたのエージェント、会話、タスクが見え、一緒に作業できます。各自ができることはロールで決まります",
|
|
138
176
|
invite: "招待",
|
|
@@ -173,9 +211,7 @@ var JA = {
|
|
|
173
211
|
linkApprove: "あなたの同意が必要",
|
|
174
212
|
linkOpen: "リンクを開くとすぐに参加",
|
|
175
213
|
copy: "コピー",
|
|
176
|
-
copied: "コピーしました",
|
|
177
214
|
stop: "無効化",
|
|
178
|
-
send: "送信",
|
|
179
215
|
roles: "ロール",
|
|
180
216
|
newRole: "新しいロール",
|
|
181
217
|
preset: "Ta が用意",
|
|
@@ -187,6 +223,7 @@ var JA = {
|
|
|
187
223
|
record: "レコード",
|
|
188
224
|
nothing: "まだなし",
|
|
189
225
|
inviteDialog: "あなたの Ta に招待",
|
|
226
|
+
inviteGets: "相手があなたの Ta への参加を申請し、許可すると参加します",
|
|
190
227
|
role: "ロール",
|
|
191
228
|
lasts: "リンクの有効期限",
|
|
192
229
|
days: "{n} 日",
|
|
@@ -341,7 +378,6 @@ var JA = {
|
|
|
341
378
|
// web-src/i18n-zh.ts
|
|
342
379
|
var ZH = {
|
|
343
380
|
title: "成员与权限",
|
|
344
|
-
loading: "正在读取…",
|
|
345
381
|
inviteTitle: "邀请别人一起用你的 Ta",
|
|
346
382
|
inviteLine: "他们能看到你的智能体、对话和任务,和你一起干活;每个人能做什么由角色决定",
|
|
347
383
|
invite: "邀请",
|
|
@@ -382,9 +418,7 @@ var ZH = {
|
|
|
382
418
|
linkApprove: "需要你同意",
|
|
383
419
|
linkOpen: "打开即加入",
|
|
384
420
|
copy: "复制",
|
|
385
|
-
copied: "已复制",
|
|
386
421
|
stop: "停用",
|
|
387
|
-
send: "发送",
|
|
388
422
|
roles: "角色",
|
|
389
423
|
newRole: "新建角色",
|
|
390
424
|
preset: "Ta 自带",
|
|
@@ -396,6 +430,7 @@ var ZH = {
|
|
|
396
430
|
record: "记录",
|
|
397
431
|
nothing: "暂时没有",
|
|
398
432
|
inviteDialog: "邀请加入你的 Ta",
|
|
433
|
+
inviteGets: "对方申请进入你的 Ta,你同意后加入",
|
|
399
434
|
role: "角色",
|
|
400
435
|
lasts: "链接有效期",
|
|
401
436
|
days: "{n} 天",
|
|
@@ -550,7 +585,6 @@ var ZH = {
|
|
|
550
585
|
// web-src/i18n-zh-tw.ts
|
|
551
586
|
var ZH_TW = {
|
|
552
587
|
title: "成員與權限",
|
|
553
|
-
loading: "正在讀取…",
|
|
554
588
|
inviteTitle: "邀請別人一起用你的 Ta",
|
|
555
589
|
inviteLine: "他們能看到你的智慧體、對話和任務,和你一起幹活;每個人能做什麼由角色決定",
|
|
556
590
|
invite: "邀請",
|
|
@@ -591,9 +625,7 @@ var ZH_TW = {
|
|
|
591
625
|
linkApprove: "需要你同意",
|
|
592
626
|
linkOpen: "開啟即加入",
|
|
593
627
|
copy: "複製",
|
|
594
|
-
copied: "已複製",
|
|
595
628
|
stop: "停用",
|
|
596
|
-
send: "傳送",
|
|
597
629
|
roles: "角色",
|
|
598
630
|
newRole: "新建角色",
|
|
599
631
|
preset: "Ta 自帶",
|
|
@@ -605,6 +637,7 @@ var ZH_TW = {
|
|
|
605
637
|
record: "記錄",
|
|
606
638
|
nothing: "暫時沒有",
|
|
607
639
|
inviteDialog: "邀請加入你的 Ta",
|
|
640
|
+
inviteGets: "對方申請進入你的 Ta,你同意後加入",
|
|
608
641
|
role: "角色",
|
|
609
642
|
lasts: "連結有效期",
|
|
610
643
|
days: "{n} 天",
|
|
@@ -759,7 +792,6 @@ var ZH_TW = {
|
|
|
759
792
|
// web-src/i18n.ts
|
|
760
793
|
var EN = {
|
|
761
794
|
title: "Members",
|
|
762
|
-
loading: "Loading…",
|
|
763
795
|
inviteTitle: "Invite people into your Ta",
|
|
764
796
|
inviteLine: "They see your agents, conversations and tasks, and work with you; what each may do is their role",
|
|
765
797
|
invite: "Invite",
|
|
@@ -800,9 +832,7 @@ var EN = {
|
|
|
800
832
|
linkApprove: "you let each in",
|
|
801
833
|
linkOpen: "in at once",
|
|
802
834
|
copy: "Copy",
|
|
803
|
-
copied: "Copied",
|
|
804
835
|
stop: "Stop",
|
|
805
|
-
send: "Send",
|
|
806
836
|
roles: "Roles",
|
|
807
837
|
newRole: "New role",
|
|
808
838
|
preset: "Comes with Ta",
|
|
@@ -814,6 +844,7 @@ var EN = {
|
|
|
814
844
|
record: "Record",
|
|
815
845
|
nothing: "Nothing yet",
|
|
816
846
|
inviteDialog: "Invite into your Ta",
|
|
847
|
+
inviteGets: "They ask to come into your Ta; you let them in",
|
|
817
848
|
role: "Role",
|
|
818
849
|
lasts: "The link works for",
|
|
819
850
|
days: "{n} days",
|
|
@@ -987,6 +1018,45 @@ var LIMIT_RANGE = {
|
|
|
987
1018
|
devices: [1, 20],
|
|
988
1019
|
running: [1, 50]
|
|
989
1020
|
};
|
|
1021
|
+
var ALL_ACTIONS = TA_ACTIONS.filter((action2) => TaActionUtil.inRoles(action2.id)).map((action2) => action2.id);
|
|
1022
|
+
var PRESET_ROLES = [
|
|
1023
|
+
{ id: "admin", name: "admin", preset: true, scope: "all", outside: "allow", dirs: ["/"], actions: ALL_ACTIONS },
|
|
1024
|
+
{
|
|
1025
|
+
id: "collaborator",
|
|
1026
|
+
name: "collaborator",
|
|
1027
|
+
preset: true,
|
|
1028
|
+
scope: "all",
|
|
1029
|
+
outside: "ask",
|
|
1030
|
+
actions: [
|
|
1031
|
+
"chat.view",
|
|
1032
|
+
"chat.send",
|
|
1033
|
+
"chat.create",
|
|
1034
|
+
"chat.stop",
|
|
1035
|
+
"chat.share",
|
|
1036
|
+
"agent.view",
|
|
1037
|
+
"agent.use",
|
|
1038
|
+
"channel.view",
|
|
1039
|
+
"channel.post",
|
|
1040
|
+
"task.view",
|
|
1041
|
+
"task.create",
|
|
1042
|
+
"files.read",
|
|
1043
|
+
"files.write",
|
|
1044
|
+
"models.use",
|
|
1045
|
+
"extensions.use",
|
|
1046
|
+
"settings.view",
|
|
1047
|
+
"members.view"
|
|
1048
|
+
]
|
|
1049
|
+
},
|
|
1050
|
+
{
|
|
1051
|
+
id: "viewer",
|
|
1052
|
+
name: "viewer",
|
|
1053
|
+
preset: true,
|
|
1054
|
+
scope: "all",
|
|
1055
|
+
outside: "deny",
|
|
1056
|
+
actions: ["chat.view", "agent.view", "channel.view", "task.view", "files.read", "extensions.use", "settings.view", "members.view"]
|
|
1057
|
+
},
|
|
1058
|
+
{ id: "guest", name: "guest", preset: true, scope: "shared", outside: "deny", actions: ["models.use", "extensions.use"] }
|
|
1059
|
+
];
|
|
990
1060
|
var DEFAULT_ROLE = "collaborator";
|
|
991
1061
|
|
|
992
1062
|
// web-src/react.ts
|
|
@@ -1188,6 +1258,223 @@ function Choices({
|
|
|
1188
1258
|
}), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", null, item.label), item.hint && /* @__PURE__ */ React.createElement("small", null, item.hint)))));
|
|
1189
1259
|
}
|
|
1190
1260
|
|
|
1261
|
+
// web-src/team-error.ts
|
|
1262
|
+
class TeamError extends Error {
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
// web-src/policy.ts
|
|
1266
|
+
var SCOPED = new Set(["files.read", "files.write", "commands.run", "commands.terminal"]);
|
|
1267
|
+
var IMPLIES = {
|
|
1268
|
+
"agent.edit": ["agent.use", "agent.view"],
|
|
1269
|
+
"agent.use": ["agent.view"],
|
|
1270
|
+
"channel.manage": ["channel.post", "channel.view"],
|
|
1271
|
+
"channel.post": ["channel.view"],
|
|
1272
|
+
"chat.manage": ["chat.send", "chat.view", "chat.stop"],
|
|
1273
|
+
"chat.send": ["chat.view", "chat.stop"],
|
|
1274
|
+
"files.write": ["files.read"]
|
|
1275
|
+
};
|
|
1276
|
+
function ofAction(action2, of) {
|
|
1277
|
+
const agent = of.kind === "agent";
|
|
1278
|
+
switch (action2) {
|
|
1279
|
+
case "chat.view":
|
|
1280
|
+
return agent ? "agent.view" : "channel.view";
|
|
1281
|
+
case "chat.send":
|
|
1282
|
+
case "chat.stop":
|
|
1283
|
+
return agent ? "agent.use" : "channel.post";
|
|
1284
|
+
case "chat.manage":
|
|
1285
|
+
case "chat.share":
|
|
1286
|
+
return agent ? "agent.edit" : "channel.manage";
|
|
1287
|
+
default:
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
var TeamPolicy;
|
|
1292
|
+
((TeamPolicy) => {
|
|
1293
|
+
TeamPolicy.MANAGING = ["members.invite", "members.approve", "members.roles"];
|
|
1294
|
+
function catalog() {
|
|
1295
|
+
return TA_ACTIONS.filter((action2) => TaActionUtil.inRoles(action2.id));
|
|
1296
|
+
}
|
|
1297
|
+
TeamPolicy.catalog = catalog;
|
|
1298
|
+
function manages(actions2) {
|
|
1299
|
+
return actions2.some((action2) => TeamPolicy.MANAGING.includes(action2));
|
|
1300
|
+
}
|
|
1301
|
+
TeamPolicy.manages = manages;
|
|
1302
|
+
function mayManage(member) {
|
|
1303
|
+
return !member.web || !!member.account;
|
|
1304
|
+
}
|
|
1305
|
+
TeamPolicy.mayManage = mayManage;
|
|
1306
|
+
function mayHold(member, role) {
|
|
1307
|
+
if (!mayManage(member) && manages(role.actions)) {
|
|
1308
|
+
throw new TeamError("Who came in from a browser without an account gets no role that manages members: they sign in with one, or join in the Ta app.");
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
TeamPolicy.mayHold = mayHold;
|
|
1312
|
+
function mayBeGiven(member, action2) {
|
|
1313
|
+
if (member && !mayManage(member) && TeamPolicy.MANAGING.includes(action2)) {
|
|
1314
|
+
throw new TeamError("Who came in from a browser without an account is given nothing that manages members: they sign in with one, or join in the Ta app.");
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
TeamPolicy.mayBeGiven = mayBeGiven;
|
|
1318
|
+
function roles(data) {
|
|
1319
|
+
return [...PRESET_ROLES, ...data.roles.filter((role) => !PRESET_ROLES.some((preset) => preset.id === role.id))];
|
|
1320
|
+
}
|
|
1321
|
+
TeamPolicy.roles = roles;
|
|
1322
|
+
function roleOf(data, id) {
|
|
1323
|
+
return roles(data).find((role) => role.id === id);
|
|
1324
|
+
}
|
|
1325
|
+
TeamPolicy.roleOf = roleOf;
|
|
1326
|
+
function valid(grant, now) {
|
|
1327
|
+
return grant.until === undefined || grant.until > now;
|
|
1328
|
+
}
|
|
1329
|
+
TeamPolicy.valid = valid;
|
|
1330
|
+
function gives(given, action2) {
|
|
1331
|
+
return given === action2 || (IMPLIES[given]?.includes(action2) ?? false);
|
|
1332
|
+
}
|
|
1333
|
+
TeamPolicy.gives = gives;
|
|
1334
|
+
function actions(data, principal, now) {
|
|
1335
|
+
const member = data.members.find((one) => one.id === principal);
|
|
1336
|
+
if (!member) {
|
|
1337
|
+
return [];
|
|
1338
|
+
}
|
|
1339
|
+
const role = roleOf(data, member.role);
|
|
1340
|
+
const granted = data.grants.filter((grant) => grant.member === principal && valid(grant, now) && !grant.resource).map((grant) => grant.action);
|
|
1341
|
+
return [...new Set([...role?.actions ?? [], ...granted])];
|
|
1342
|
+
}
|
|
1343
|
+
TeamPolicy.actions = actions;
|
|
1344
|
+
function isProtected(path, context) {
|
|
1345
|
+
return context.protectedDirs.some((dir) => TaActionUtil.inside(dir, path));
|
|
1346
|
+
}
|
|
1347
|
+
TeamPolicy.isProtected = isProtected;
|
|
1348
|
+
function check(data, principal, action2, resource, context) {
|
|
1349
|
+
const refuse = (reason, refused = action2, on2 = resource) => ({
|
|
1350
|
+
action: refused,
|
|
1351
|
+
...on2 ? { resource: on2 } : {},
|
|
1352
|
+
reason,
|
|
1353
|
+
...reason === "protected" || reason === "never" ? { askable: false } : {}
|
|
1354
|
+
});
|
|
1355
|
+
if (!TaActionUtil.grantable(action2)) {
|
|
1356
|
+
return refuse("never");
|
|
1357
|
+
}
|
|
1358
|
+
if (principal.startsWith(TA_INVITE_PREFIX)) {
|
|
1359
|
+
return refuse("never");
|
|
1360
|
+
}
|
|
1361
|
+
const member = data.members.find((one) => one.id === principal);
|
|
1362
|
+
if (!member) {
|
|
1363
|
+
return refuse("never");
|
|
1364
|
+
}
|
|
1365
|
+
const role = roleOf(data, member.role);
|
|
1366
|
+
const shared = role?.scope === "shared";
|
|
1367
|
+
const has = (role?.actions.includes(action2) ?? false) && TaActionUtil.inRoles(action2);
|
|
1368
|
+
const grants = data.grants.filter((grant) => grant.member === principal && valid(grant, context.now) && gives(grant.action, action2));
|
|
1369
|
+
const on = (kind, id) => grants.some((grant) => grant.resource?.kind === kind && grant.resource.id === id);
|
|
1370
|
+
const anywhere = grants.some((grant) => !grant.resource);
|
|
1371
|
+
switch (resource?.kind) {
|
|
1372
|
+
case "agent":
|
|
1373
|
+
case "channel":
|
|
1374
|
+
return on(resource.kind, resource.id) || !shared && (has || anywhere) || refuse(shared ? "hidden" : "role");
|
|
1375
|
+
case "session": {
|
|
1376
|
+
const author = data.authors[resource.id];
|
|
1377
|
+
if (author === principal && action2.startsWith("chat.")) {
|
|
1378
|
+
return true;
|
|
1379
|
+
}
|
|
1380
|
+
if (on("session", resource.id)) {
|
|
1381
|
+
return true;
|
|
1382
|
+
}
|
|
1383
|
+
if (data.private.includes(resource.id) && author !== principal) {
|
|
1384
|
+
return refuse("hidden");
|
|
1385
|
+
}
|
|
1386
|
+
const of = resource.of && ofAction(action2, resource.of);
|
|
1387
|
+
if (resource.of && of) {
|
|
1388
|
+
return check(data, principal, of, { kind: resource.of.kind, id: resource.of.id }, context) === true || refuse(shared ? "hidden" : "role");
|
|
1389
|
+
}
|
|
1390
|
+
if (SCOPED.has(action2)) {
|
|
1391
|
+
return checkPath(data, role, grants, action2, resource.cwd, context, refuse);
|
|
1392
|
+
}
|
|
1393
|
+
if (shared) {
|
|
1394
|
+
return refuse("hidden");
|
|
1395
|
+
}
|
|
1396
|
+
return has || anywhere || refuse("role");
|
|
1397
|
+
}
|
|
1398
|
+
default:
|
|
1399
|
+
if (SCOPED.has(action2)) {
|
|
1400
|
+
return checkPath(data, role, grants, action2, resource?.kind === "dir" ? resource.id : undefined, context, refuse);
|
|
1401
|
+
}
|
|
1402
|
+
return has || anywhere || refuse("role");
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
TeamPolicy.check = check;
|
|
1406
|
+
function checkPath(data, role, grants, action2, path, context, refuse) {
|
|
1407
|
+
const has = role?.actions.includes(action2) ?? false;
|
|
1408
|
+
if (path === undefined) {
|
|
1409
|
+
return has || grants.some((grant) => !grant.resource) || refuse("role");
|
|
1410
|
+
}
|
|
1411
|
+
if (isProtected(path, context)) {
|
|
1412
|
+
return refuse("protected");
|
|
1413
|
+
}
|
|
1414
|
+
const within = (dirs) => dirs.some((dir) => TaActionUtil.inside(dir, path));
|
|
1415
|
+
if (grants.some((grant) => !grant.resource || grant.resource.kind === "dir" && within([grant.resource.id]))) {
|
|
1416
|
+
return true;
|
|
1417
|
+
}
|
|
1418
|
+
if (within(role?.dirs ?? data.dirs)) {
|
|
1419
|
+
return has || refuse("role");
|
|
1420
|
+
}
|
|
1421
|
+
const outside = role?.outside ?? "deny";
|
|
1422
|
+
if (outside === "allow" && has) {
|
|
1423
|
+
return true;
|
|
1424
|
+
}
|
|
1425
|
+
if (outside === "read" && action2 === "files.read" && (role?.actions.includes("files.read") ?? false)) {
|
|
1426
|
+
return true;
|
|
1427
|
+
}
|
|
1428
|
+
return refuse(outside === "deny" ? "never" : "outside");
|
|
1429
|
+
}
|
|
1430
|
+
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);
|
|
1434
|
+
}
|
|
1435
|
+
if (given.startsWith("/") || /^[a-z][a-z0-9+.-]*:\/\//i.test(given)) {
|
|
1436
|
+
return normalize(given);
|
|
1437
|
+
}
|
|
1438
|
+
return normalize(`${cwd.replace(/\/+$/, "")}/${given}`);
|
|
1439
|
+
}
|
|
1440
|
+
TeamPolicy.resolve = resolve;
|
|
1441
|
+
function normalize(path) {
|
|
1442
|
+
const [, scheme = "", rest] = /^([a-z][a-z0-9+.-]*:\/\/[^/]*)?(.*)$/i.exec(path) ?? [];
|
|
1443
|
+
const parts = [];
|
|
1444
|
+
for (const part of (rest ?? "").split("/")) {
|
|
1445
|
+
if (part === "..") {
|
|
1446
|
+
parts.pop();
|
|
1447
|
+
} else if (part && part !== ".") {
|
|
1448
|
+
parts.push(part);
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
return `${scheme}/${parts.join("/")}`;
|
|
1452
|
+
}
|
|
1453
|
+
TeamPolicy.normalize = normalize;
|
|
1454
|
+
const READ_TOOLS = new Set(["read", "ls", "grep", "find"]);
|
|
1455
|
+
const WRITE_TOOLS = new Set(["edit", "write"]);
|
|
1456
|
+
const FREE_TOOLS = new Set(["codemode", "tool_search"]);
|
|
1457
|
+
function toolNeeds(tool, input, cwd, home, declared) {
|
|
1458
|
+
if (FREE_TOOLS.has(tool)) {
|
|
1459
|
+
return;
|
|
1460
|
+
}
|
|
1461
|
+
if (READ_TOOLS.has(tool)) {
|
|
1462
|
+
return { action: "files.read", resource: { kind: "dir", id: resolve(cwd, input?.path, home) } };
|
|
1463
|
+
}
|
|
1464
|
+
if (WRITE_TOOLS.has(tool)) {
|
|
1465
|
+
return { action: "files.write", resource: { kind: "dir", id: resolve(cwd, input?.path, home) } };
|
|
1466
|
+
}
|
|
1467
|
+
if (declared === "anyone") {
|
|
1468
|
+
return;
|
|
1469
|
+
}
|
|
1470
|
+
if (declared) {
|
|
1471
|
+
return { action: declared };
|
|
1472
|
+
}
|
|
1473
|
+
return { action: "commands.run", resource: { kind: "dir", id: resolve(cwd, ".") } };
|
|
1474
|
+
}
|
|
1475
|
+
TeamPolicy.toolNeeds = toolNeeds;
|
|
1476
|
+
})(TeamPolicy ||= {});
|
|
1477
|
+
|
|
1191
1478
|
// web-src/dialogs.tsx
|
|
1192
1479
|
function show(component) {
|
|
1193
1480
|
if (!pi.ui.custom) {
|
|
@@ -1196,33 +1483,23 @@ function show(component) {
|
|
|
1196
1483
|
}
|
|
1197
1484
|
return pi.ui.custom(component);
|
|
1198
1485
|
}
|
|
1199
|
-
function
|
|
1200
|
-
const
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
}, /* @__PURE__ */ React.createElement("button", {
|
|
1214
|
-
type: "button",
|
|
1215
|
-
className: "ta-button ta-primary",
|
|
1216
|
-
onClick: () => void navigator.clipboard?.writeText(link).then(() => setCopied(true))
|
|
1217
|
-
}, copied ? t("copied") : t("copy")), canSend && /* @__PURE__ */ React.createElement("button", {
|
|
1218
|
-
type: "button",
|
|
1219
|
-
className: "ta-button",
|
|
1220
|
-
onClick: () => void navigator.share({ title, url: link }).catch(() => {
|
|
1221
|
-
return;
|
|
1222
|
-
})
|
|
1223
|
-
}, t("send"))));
|
|
1486
|
+
function InviteSheet({ link, close }) {
|
|
1487
|
+
const Users = icon("Users");
|
|
1488
|
+
return /* @__PURE__ */ React.createElement(ShareSheetCompat, {
|
|
1489
|
+
pi,
|
|
1490
|
+
title: t("inviteDialog"),
|
|
1491
|
+
link,
|
|
1492
|
+
face: /* @__PURE__ */ React.createElement(Users, {
|
|
1493
|
+
size: 22
|
|
1494
|
+
}),
|
|
1495
|
+
name: t("inviteDialog"),
|
|
1496
|
+
gets: t("inviteGets"),
|
|
1497
|
+
notes: [t("inviteHint")],
|
|
1498
|
+
onClose: close
|
|
1499
|
+
});
|
|
1224
1500
|
}
|
|
1225
1501
|
function InviteDialog({ roles, close }) {
|
|
1502
|
+
const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
|
|
1226
1503
|
const [role, setRole] = React.useState(DEFAULT_ROLE);
|
|
1227
1504
|
const [what, setWhat] = React.useState("whole");
|
|
1228
1505
|
const [items, setItems] = React.useState();
|
|
@@ -1250,15 +1527,18 @@ function InviteDialog({ roles, close }) {
|
|
|
1250
1527
|
}
|
|
1251
1528
|
setBusy(false);
|
|
1252
1529
|
};
|
|
1530
|
+
if (invite) {
|
|
1531
|
+
return /* @__PURE__ */ React.createElement(InviteSheet, {
|
|
1532
|
+
link: invite.link,
|
|
1533
|
+
close
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1253
1536
|
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
1254
1537
|
title: t("inviteDialog"),
|
|
1255
1538
|
onClose: close
|
|
1256
1539
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
1257
1540
|
className: "ttm-dialog"
|
|
1258
|
-
},
|
|
1259
|
-
link: invite.link,
|
|
1260
|
-
title: t("inviteDialog")
|
|
1261
|
-
}) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
1541
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1262
1542
|
className: "ttm-field"
|
|
1263
1543
|
}, /* @__PURE__ */ React.createElement("span", null, t("inviteWhat")), /* @__PURE__ */ React.createElement(Choices, {
|
|
1264
1544
|
value: what,
|
|
@@ -1269,9 +1549,9 @@ function InviteDialog({ roles, close }) {
|
|
|
1269
1549
|
]
|
|
1270
1550
|
})), what === "only" && /* @__PURE__ */ React.createElement("div", {
|
|
1271
1551
|
className: "ttm-field"
|
|
1272
|
-
}, /* @__PURE__ */ React.createElement("span", null, t("pickShared")), !items ? /* @__PURE__ */ React.createElement(
|
|
1273
|
-
|
|
1274
|
-
}
|
|
1552
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("pickShared")), !items ? /* @__PURE__ */ React.createElement(Loading, {
|
|
1553
|
+
compact: true
|
|
1554
|
+
}) : items.length === 0 ? /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
1275
1555
|
title: t("nothingToShare"),
|
|
1276
1556
|
compact: true
|
|
1277
1557
|
}) : /* @__PURE__ */ React.createElement("ul", {
|
|
@@ -1342,7 +1622,7 @@ function InviteDialog({ roles, close }) {
|
|
|
1342
1622
|
className: `ta-button ta-primary${busy ? " ta-busy" : ""}`,
|
|
1343
1623
|
disabled: busy || what === "only" && picked.length === 0,
|
|
1344
1624
|
onClick: () => void make()
|
|
1345
|
-
}, busy ? t("making") : t("makeLink")))))
|
|
1625
|
+
}, busy ? t("making") : t("makeLink")))));
|
|
1346
1626
|
}
|
|
1347
1627
|
function openInvite(roles) {
|
|
1348
1628
|
show(({ close }) => /* @__PURE__ */ React.createElement(InviteDialog, {
|
|
@@ -1351,19 +1631,14 @@ function openInvite(roles) {
|
|
|
1351
1631
|
}));
|
|
1352
1632
|
}
|
|
1353
1633
|
function openLink(link) {
|
|
1354
|
-
show(({ close }) => /* @__PURE__ */ React.createElement(
|
|
1355
|
-
title: t("links"),
|
|
1356
|
-
onClose: close
|
|
1357
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
1358
|
-
className: "ttm-dialog"
|
|
1359
|
-
}, /* @__PURE__ */ React.createElement(LinkBox, {
|
|
1634
|
+
show(({ close }) => /* @__PURE__ */ React.createElement(InviteSheet, {
|
|
1360
1635
|
link,
|
|
1361
|
-
|
|
1362
|
-
}))
|
|
1636
|
+
close
|
|
1637
|
+
}));
|
|
1363
1638
|
}
|
|
1364
1639
|
function areas() {
|
|
1365
1640
|
const by = new Map;
|
|
1366
|
-
for (const action2 of
|
|
1641
|
+
for (const action2 of TeamPolicy.catalog()) {
|
|
1367
1642
|
by.set(action2.area, [...by.get(action2.area) ?? [], action2]);
|
|
1368
1643
|
}
|
|
1369
1644
|
return [...by];
|
|
@@ -1585,6 +1860,16 @@ var RELAY_CONNECT_PATH = "/v1/connect/";
|
|
|
1585
1860
|
var RELAY_PAIR_PATH = "/pair";
|
|
1586
1861
|
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'";
|
|
1587
1862
|
var RELAY_FRAME_HEADER_CSP = `${RELAY_FRAME_CSP}; frame-ancestors 'self'; sandbox allow-scripts allow-popups allow-popups-to-escape-sandbox`;
|
|
1863
|
+
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>
|
|
1864
|
+
<script>document.getElementById('open').href='ta://open?link='+encodeURIComponent(location.href)</script>`;
|
|
1865
|
+
var RELAY_PAIR_PAGE = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>Ta</title>
|
|
1866
|
+
<body style="font:16px system-ui;max-width:32em;margin:3em auto;padding:0 1em">
|
|
1867
|
+
<h1>Ta</h1><p>Open this link in the Ta app, or paste it there, to reach your Ta from this device.</p>
|
|
1868
|
+
<p>打开 Ta 应用,粘贴这个链接,就能从这台设备连到你的 Ta。</p>${OPEN_IN_TA}</body>`;
|
|
1869
|
+
var RELAY_SHARE_PAGE = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>Ta</title>
|
|
1870
|
+
<body style="font:16px system-ui;max-width:32em;margin:3em auto;padding:0 1em">
|
|
1871
|
+
<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>
|
|
1872
|
+
<p>有人分享了一个 Ta 扩展。在 Ta 应用里扫码,或把这个链接粘贴到“快捷打开”,就能打开它。</p>${OPEN_IN_TA}</body>`;
|
|
1588
1873
|
var RELAY_SHARE_MAX_BYTES = 8 * 1024 * 1024;
|
|
1589
1874
|
var RELAY_SHARE_CHUNK_BYTES = 192 * 1024;
|
|
1590
1875
|
var RELAY_CONTENT_MAX_BYTES = 8 * 1024 * 1024;
|
|
@@ -2649,6 +2934,7 @@ class TeamSharedHome {
|
|
|
2649
2934
|
// web-src/style.ts
|
|
2650
2935
|
var STYLE = `
|
|
2651
2936
|
.ttm-page { flex: 1; min-height: 0; height: 100%; overflow-y: auto; overscroll-behavior: none; }
|
|
2937
|
+
.ttm-page:has(> .ta-loading) { display: flex; flex-direction: column; }
|
|
2652
2938
|
.ttm-list { display: flex; flex-direction: column; gap: 12px; max-width: var(--ta-page-width); margin: 0 auto; padding: 8px 12px calc(24px + env(safe-area-inset-bottom)); box-sizing: border-box; }
|
|
2653
2939
|
.ttm-pad { padding: 16px; }
|
|
2654
2940
|
.ttm-hero { display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: 14px; background: var(--ta-raised); }
|
|
@@ -2706,7 +2992,6 @@ var STYLE = `
|
|
|
2706
2992
|
.ttm-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
|
|
2707
2993
|
.ttm-center { justify-content: center; }
|
|
2708
2994
|
.ttm-grow { flex: 1; }
|
|
2709
|
-
.ttm-qr { display: flex; justify-content: center; }
|
|
2710
2995
|
/* The tabs of the page are the page's segmented control (.ta-segmented); only what it lacks: they size to their labels and carry a count */
|
|
2711
2996
|
.ttm-segments { align-self: flex-start; max-width: 100%; overflow-x: auto; }
|
|
2712
2997
|
.ttm-segments button { position: relative; padding: 0 14px; white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
@@ -2742,7 +3027,6 @@ fieldset.ttm-plain:disabled .ttm-choice { cursor: default; opacity: .75; }
|
|
|
2742
3027
|
.ttm-seen { opacity: .6; }
|
|
2743
3028
|
[data-layout='compact'] .ttm-hero-row { flex-direction: column; align-items: stretch; }
|
|
2744
3029
|
[data-layout='compact'] .ttm-record { flex-direction: column; gap: 2px; }
|
|
2745
|
-
.ttm-link-box { padding: 8px 10px; border-radius: 8px; background: var(--ta-hover); font-family: var(--ta-mono, ui-monospace, monospace); font-size: calc(11.5px * var(--ta-font-scale)); word-break: break-all; user-select: all; }
|
|
2746
3030
|
`;
|
|
2747
3031
|
function injectStyle() {
|
|
2748
3032
|
const style = document.createElement("style");
|
|
@@ -2759,6 +3043,7 @@ function grantLine(grant) {
|
|
|
2759
3043
|
return `${actionTitle(grant.action)}${on} · ${until}`;
|
|
2760
3044
|
}
|
|
2761
3045
|
function ShareDialog({ member, name, close }) {
|
|
3046
|
+
const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
|
|
2762
3047
|
const [items, setItems] = React.useState();
|
|
2763
3048
|
const [picked, setPicked] = React.useState();
|
|
2764
3049
|
const [level, setLevel] = React.useState("use");
|
|
@@ -2779,9 +3064,11 @@ function ShareDialog({ member, name, close }) {
|
|
|
2779
3064
|
onClose: close
|
|
2780
3065
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
2781
3066
|
className: "ttm-dialog"
|
|
2782
|
-
}, !items ? /* @__PURE__ */ React.createElement("p", {
|
|
3067
|
+
}, !items ? error ? /* @__PURE__ */ React.createElement("p", {
|
|
2783
3068
|
className: "ttm-hint"
|
|
2784
|
-
}, error
|
|
3069
|
+
}, error) : /* @__PURE__ */ React.createElement(Loading, {
|
|
3070
|
+
compact: true
|
|
3071
|
+
}) : items.length === 0 ? /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
2785
3072
|
title: t("nothingToShare"),
|
|
2786
3073
|
compact: true
|
|
2787
3074
|
}) : /* @__PURE__ */ React.createElement("ul", {
|
|
@@ -3242,6 +3529,7 @@ function alertLine(alert, overview) {
|
|
|
3242
3529
|
return t(`rule.${alert.rule}`, { name, detail: alert.detail ?? alert.text });
|
|
3243
3530
|
}
|
|
3244
3531
|
function RecordTab({ overview }) {
|
|
3532
|
+
const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
|
|
3245
3533
|
const [filter, setFilter] = React.useState("notable");
|
|
3246
3534
|
const [who, setWho] = React.useState("");
|
|
3247
3535
|
const [text, setText] = React.useState("");
|
|
@@ -3326,9 +3614,9 @@ function RecordTab({ overview }) {
|
|
|
3326
3614
|
onChange: (event) => setText(event.target.value)
|
|
3327
3615
|
})), /* @__PURE__ */ React.createElement(Section, {
|
|
3328
3616
|
title: t("record")
|
|
3329
|
-
}, !entries ? /* @__PURE__ */ React.createElement("li", {
|
|
3330
|
-
|
|
3331
|
-
}
|
|
3617
|
+
}, !entries ? /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement(Loading, {
|
|
3618
|
+
compact: true
|
|
3619
|
+
})) : entries.length === 0 ? /* @__PURE__ */ React.createElement("li", {
|
|
3332
3620
|
className: "ttm-row ttm-quiet"
|
|
3333
3621
|
}, t("nothing")) : entries.map((entry, index) => /* @__PURE__ */ React.createElement("li", {
|
|
3334
3622
|
key: `${entry.at}:${index}`,
|
|
@@ -3456,6 +3744,7 @@ function RolesTab({ me, overview }) {
|
|
|
3456
3744
|
// web-src/team-page.tsx
|
|
3457
3745
|
function TeamPage() {
|
|
3458
3746
|
const { me, overview, error } = useBook();
|
|
3747
|
+
const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
|
|
3459
3748
|
const [tab, setTab] = React.useState("members");
|
|
3460
3749
|
React.useEffect(() => {
|
|
3461
3750
|
book.load();
|
|
@@ -3467,9 +3756,7 @@ function TeamPage() {
|
|
|
3467
3756
|
className: "ttm-page"
|
|
3468
3757
|
}, error ? /* @__PURE__ */ React.createElement("p", {
|
|
3469
3758
|
className: "ttm-error ttm-pad"
|
|
3470
|
-
}, error) : /* @__PURE__ */ React.createElement(
|
|
3471
|
-
className: "ttm-quiet ttm-pad"
|
|
3472
|
-
}, t("loading")));
|
|
3759
|
+
}, error) : /* @__PURE__ */ React.createElement(Loading, null));
|
|
3473
3760
|
}
|
|
3474
3761
|
if (!overview) {
|
|
3475
3762
|
return /* @__PURE__ */ React.createElement("div", {
|
|
@@ -3533,7 +3820,6 @@ function activate(pi2) {
|
|
|
3533
3820
|
title: () => t("title"),
|
|
3534
3821
|
icon: icon("ShieldCheck"),
|
|
3535
3822
|
render: TeamPage,
|
|
3536
|
-
discover: true,
|
|
3537
3823
|
group: "share",
|
|
3538
3824
|
order: 82
|
|
3539
3825
|
});
|