@celljs/ta-workspace 4.12.0 → 4.13.1

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/web/index.js +178 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-workspace",
3
- "version": "4.12.0",
3
+ "version": "4.13.1",
4
4
  "description": "A pi package for Ta: the workspace beside the conversation, with an explorer, open files, search, source control, terminals and a browser",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -25,8 +25,8 @@
25
25
  "watch": "tsc -b -w --preserveWatchOutput"
26
26
  },
27
27
  "devDependencies": {
28
- "@celljs/ta-protocol": "4.12.0",
29
- "@celljs/ta-web": "4.12.0",
28
+ "@celljs/ta-protocol": "4.13.1",
29
+ "@celljs/ta-web": "4.13.1",
30
30
  "@types/react": "^19.3.0",
31
31
  "marked": "^14.0.0"
32
32
  },
package/web/index.js CHANGED
@@ -5977,19 +5977,91 @@ var TaHostUtil;
5977
5977
  TaHostUtil2.WAIT_MS = 1000;
5978
5978
  function reach(events, name, waitMs = TaHostUtil2.WAIT_MS) {
5979
5979
  return new Promise((resolve) => {
5980
+ let heard = false;
5981
+ let answered = false;
5980
5982
  const timer = setTimeout(() => resolve(undefined), waitMs);
5981
5983
  const request = {
5982
5984
  name,
5985
+ heard: () => {
5986
+ heard = true;
5987
+ },
5983
5988
  resolve: (answer) => {
5989
+ answered = true;
5984
5990
  clearTimeout(timer);
5985
5991
  resolve(answer);
5986
5992
  }
5987
5993
  };
5988
5994
  events.emit(TA_HOST_EVENT, request);
5995
+ if (!heard && !answered) {
5996
+ clearTimeout(timer);
5997
+ resolve(undefined);
5998
+ }
5989
5999
  });
5990
6000
  }
5991
6001
  TaHostUtil2.reach = reach;
6002
+ function marked2(systemPrompt, mark) {
6003
+ return role(systemPrompt).includes(mark);
6004
+ }
6005
+ TaHostUtil2.marked = marked2;
6006
+ function role(systemPrompt) {
6007
+ if (!systemPrompt) {
6008
+ return "";
6009
+ }
6010
+ const open = `<addendum>
6011
+ `;
6012
+ const start = systemPrompt.indexOf(open);
6013
+ const context = systemPrompt.indexOf(`<project_context>
6014
+ `);
6015
+ if (start < 0 || context >= 0 && context < start) {
6016
+ return "";
6017
+ }
6018
+ const end = systemPrompt.indexOf(`
6019
+ </addendum>`, start);
6020
+ return systemPrompt.slice(start + open.length, end < 0 ? undefined : end);
6021
+ }
6022
+ TaHostUtil2.role = role;
5992
6023
  })(TaHostUtil || (TaHostUtil = {}));
6024
+ var TA_ASK_ENTRY = "ta-ask";
6025
+ var TaAskUtil;
6026
+ (function(TaAskUtil2) {
6027
+ const LENGTH = 120;
6028
+ function entry(question) {
6029
+ const line = question.replace(/\s+/g, " ").trim();
6030
+ return { question: line.length > LENGTH ? `${line.slice(0, LENGTH - 1)}…` : line };
6031
+ }
6032
+ TaAskUtil2.entry = entry;
6033
+ function asking(entries) {
6034
+ var _a;
6035
+ for (let i = entries.length - 1;i >= 0; i--) {
6036
+ const entry2 = entries[i];
6037
+ if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
6038
+ return;
6039
+ }
6040
+ if (entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY) {
6041
+ return read(entry2);
6042
+ }
6043
+ }
6044
+ return;
6045
+ }
6046
+ TaAskUtil2.asking = asking;
6047
+ function next(asked, entry2) {
6048
+ var _a;
6049
+ if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
6050
+ return;
6051
+ }
6052
+ return entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY ? read(entry2) : asked;
6053
+ }
6054
+ TaAskUtil2.next = next;
6055
+ function read(found) {
6056
+ var _a;
6057
+ const question = (_a = found.data) === null || _a === undefined ? undefined : _a.question;
6058
+ if (typeof question !== "string" || !question.trim()) {
6059
+ return;
6060
+ }
6061
+ const at2 = found.timestamp ? Date.parse(found.timestamp) : Number.NaN;
6062
+ return { question: entry(question).question, at: Number.isNaN(at2) ? 0 : at2 };
6063
+ }
6064
+ })(TaAskUtil || (TaAskUtil = {}));
5993
6065
  // ../ta-protocol/esm/common/ta-protocol.js
5994
6066
  var TaServer = Symbol("TaServer");
5995
6067
  var TaClient = Symbol("TaClient");
@@ -6027,7 +6099,34 @@ ${message}`;
6027
6099
  return message.replace(BLOCK, "");
6028
6100
  }
6029
6101
  TaMessageContext2.strip = strip;
6102
+ function read(message) {
6103
+ var _a;
6104
+ const block2 = (_a = BLOCK.exec(message)) === null || _a === undefined ? undefined : _a[0];
6105
+ return block2 === null || block2 === undefined ? undefined : block2.replace(/^<context>\n?/, "").replace(/\n?<\/context>\n?$/, "");
6106
+ }
6107
+ TaMessageContext2.read = read;
6030
6108
  })(TaMessageContext || (TaMessageContext = {}));
6109
+ var TaMessageSource;
6110
+ (function(TaMessageSource2) {
6111
+ TaMessageSource2.DOUBLE = "ta:double";
6112
+ const LINE = /^\[ta:from ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
6113
+ function mark(message, from, detail) {
6114
+ if (/^[/!]/.test(message) || of(message)) {
6115
+ return message;
6116
+ }
6117
+ const line = `[ta:from ${from}${detail ? ` ${detail.replace(/[\]\n]/g, " ")}` : ""}]`;
6118
+ const context = TaMessageContext.read(message);
6119
+ return TaMessageContext.wrap(context === undefined ? line : `${context}
6120
+ ${line}`, TaMessageContext.strip(message));
6121
+ }
6122
+ TaMessageSource2.mark = mark;
6123
+ function of(message) {
6124
+ const context = TaMessageContext.read(message);
6125
+ const match = context === undefined ? null : LINE.exec(context);
6126
+ return match ? { from: match[1], ...match[2] ? { detail: match[2].trim() } : {} } : undefined;
6127
+ }
6128
+ TaMessageSource2.of = of;
6129
+ })(TaMessageSource || (TaMessageSource = {}));
6031
6130
  var TaImageNote;
6032
6131
  (function(TaImageNote2) {
6033
6132
  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 [^\]]+\.\]$/;
@@ -6148,6 +6247,85 @@ var TaSkillUse;
6148
6247
  }
6149
6248
  TaSkillUse2.command = command;
6150
6249
  })(TaSkillUse || (TaSkillUse = {}));
6250
+ // ../ta-protocol/esm/common/team-protocol.js
6251
+ var TA_UNDECLARED = "extensions.install";
6252
+ var TaPermissionUtil;
6253
+ (function(TaPermissionUtil2) {
6254
+ function read(pi2) {
6255
+ const given = pi2 === null || pi2 === undefined ? undefined : pi2.permissions;
6256
+ const map = (value) => value && typeof value === "object" && !Array.isArray(value) ? Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === "string")) : undefined;
6257
+ const host2 = map(given === null || given === undefined ? undefined : given.host);
6258
+ const tools = map(given === null || given === undefined ? undefined : given.tools);
6259
+ return { ...host2 ? { host: host2 } : {}, ...tools ? { tools } : {} };
6260
+ }
6261
+ TaPermissionUtil2.read = read;
6262
+ function host(manifest, method, kind) {
6263
+ var _a, _b, _c, _d;
6264
+ const host2 = (_a = manifest === null || manifest === undefined ? undefined : manifest.host) !== null && _a !== undefined ? _a : {};
6265
+ const own = (key) => Object.prototype.hasOwnProperty.call(host2, key) ? host2[key] : undefined;
6266
+ return (_d = (_c = (_b = kind ? own(`${method}:${kind}`) : undefined) !== null && _b !== undefined ? _b : own(method)) !== null && _c !== undefined ? _c : own("*")) !== null && _d !== undefined ? _d : TA_UNDECLARED;
6267
+ }
6268
+ TaPermissionUtil2.host = host;
6269
+ })(TaPermissionUtil || (TaPermissionUtil = {}));
6270
+ var action = (id, en, zh, more = {}) => ({
6271
+ id,
6272
+ area: id.split(".")[0],
6273
+ title: { en, "zh-CN": zh },
6274
+ ...more
6275
+ });
6276
+ var TA_ACTIONS = [
6277
+ action("chat.view", "See conversations", "查看对话"),
6278
+ action("chat.send", "Send in conversations", "在对话里发消息"),
6279
+ action("chat.create", "Start conversations", "新建对话"),
6280
+ action("chat.stop", "Stop a reply", "停止回复"),
6281
+ action("chat.manage", "Rename, archive and close conversations", "改名、归档、关闭对话"),
6282
+ action("chat.share", "Share by a link", "生成分享链接"),
6283
+ action("agent.view", "See agents", "查看智能体"),
6284
+ action("agent.use", "Talk with agents", "和智能体对话"),
6285
+ action("agent.edit", "Create, change and remove agents", "新建、修改、删除智能体"),
6286
+ action("channel.view", "See channels", "查看频道"),
6287
+ action("channel.post", "Post in channels", "在频道里发言"),
6288
+ action("channel.manage", "Create and change channels", "新建、管理频道"),
6289
+ action("task.view", "See tasks", "查看任务"),
6290
+ action("task.create", "Hand out tasks", "派任务"),
6291
+ action("task.manage", "Take over and stop tasks", "接管、停止任务"),
6292
+ action("files.read", "Read files", "读文件", { scoped: true }),
6293
+ action("files.write", "Change files", "改文件", { scoped: true }),
6294
+ action("commands.run", "Let Ta run commands", "让 Ta 运行命令", { scoped: true, risky: true }),
6295
+ action("commands.terminal", "Open terminals", "打开终端", { scoped: true, risky: true }),
6296
+ action("hosts.use", "Use remote hosts", "使用远程主机", { risky: true }),
6297
+ action("models.use", "Use the models", "使用模型"),
6298
+ action("models.manage", "Sign in to models", "登录和更换模型账号"),
6299
+ action("cron.view", "See scheduled tasks", "查看定时任务"),
6300
+ action("cron.manage", "Change scheduled tasks", "管理定时任务"),
6301
+ action("extensions.use", "Use extensions", "使用扩展"),
6302
+ action("extensions.install", "Install and turn off extensions", "安装、停用扩展"),
6303
+ action("settings.view", "See settings", "查看设置"),
6304
+ action("settings.manage", "Change settings", "修改设置"),
6305
+ action("members.view", "See members", "查看成员"),
6306
+ action("members.invite", "Invite people", "邀请别人"),
6307
+ action("members.approve", "Answer requests", "处理申请"),
6308
+ action("members.roles", "Change roles and members", "管理角色和成员"),
6309
+ action("audit.view", "See the record", "查看记录")
6310
+ ];
6311
+ var TaActionUtil;
6312
+ (function(TaActionUtil2) {
6313
+ const byId = new Map(TA_ACTIONS.map((one) => [one.id, one]));
6314
+ function info(id) {
6315
+ return byId.get(id);
6316
+ }
6317
+ TaActionUtil2.info = info;
6318
+ function title(id, language) {
6319
+ const found = byId.get(id);
6320
+ return found ? language.startsWith("zh") ? found.title["zh-CN"] : found.title.en : id;
6321
+ }
6322
+ TaActionUtil2.title = title;
6323
+ function inside(dir, path) {
6324
+ const base = dir.replace(/\/+$/, "");
6325
+ return path === base || path.startsWith(`${base}/`) || base === "";
6326
+ }
6327
+ TaActionUtil2.inside = inside;
6328
+ })(TaActionUtil || (TaActionUtil = {}));
6151
6329
  // ../ta-protocol/esm/common/workspace-protocol.js
6152
6330
  var TaWorkspaceServer = Symbol("TaWorkspaceServer");
6153
6331
  var TaTerminalServer = Symbol("TaTerminalServer");