@celljs/ta 4.16.0 → 4.17.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/README.en.md +1 -0
- package/README.md +1 -0
- package/dist/cli.mjs +2224 -203
- package/dist/gateway.mjs +2011 -528
- package/dist/pi/CHANGELOG.md +12 -0
- package/dist/pi/package.json +1 -1
- package/dist/pi/packages/ta-3d/extension/index.mjs +1 -0
- package/dist/pi/packages/ta-3d/package.json +2 -1
- package/dist/pi/packages/ta-agents/README.en.md +14 -2
- package/dist/pi/packages/ta-agents/README.md +14 -2
- package/dist/pi/packages/ta-agents/extension/index.mjs +278 -105
- package/dist/pi/packages/ta-agents/host/index.mjs +662 -0
- package/dist/pi/packages/ta-agents/lib/agent-catalog.d.ts +36 -2
- package/dist/pi/packages/ta-agents/lib/agent-catalog.js +76 -6
- package/dist/pi/packages/ta-agents/lib/agent-installer.d.ts +55 -0
- package/dist/pi/packages/ta-agents/lib/agent-installer.js +140 -0
- package/dist/pi/packages/ta-agents/lib/agent-installs.d.ts +25 -0
- package/dist/pi/packages/ta-agents/lib/agent-installs.js +64 -0
- package/dist/pi/packages/ta-agents/lib/agent-prompt.d.ts +6 -0
- package/dist/pi/packages/ta-agents/lib/agent-prompt.js +9 -0
- package/dist/pi/packages/ta-agents/lib/agent-refresh.d.ts +11 -0
- package/dist/pi/packages/ta-agents/lib/agent-refresh.js +37 -0
- package/dist/pi/packages/ta-agents/lib/agent-session.js +2 -1
- package/dist/pi/packages/ta-agents/lib/agents-protocol.d.ts +26 -0
- package/dist/pi/packages/ta-agents/lib/agents-protocol.js +11 -0
- package/dist/pi/packages/ta-agents/lib/agents-settings.d.ts +10 -0
- package/dist/pi/packages/ta-agents/lib/agents-settings.js +165 -0
- package/dist/pi/packages/ta-agents/lib/extension.d.ts +3 -1
- package/dist/pi/packages/ta-agents/lib/extension.js +17 -4
- package/dist/pi/packages/ta-agents/lib/host.d.ts +35 -0
- package/dist/pi/packages/ta-agents/lib/host.js +96 -0
- package/dist/pi/packages/ta-agents/lib/react.d.ts +8 -0
- package/dist/pi/packages/ta-agents/lib/react.js +8 -0
- package/dist/pi/packages/ta-agents/lib/style.d.ts +4 -0
- package/dist/pi/packages/ta-agents/lib/style.js +30 -0
- package/dist/pi/packages/ta-agents/lib/texts.d.ts +18 -0
- package/dist/pi/packages/ta-agents/lib/texts.js +18 -0
- package/dist/pi/packages/ta-agents/lib/web-words.d.ts +30 -0
- package/dist/pi/packages/ta-agents/lib/web-words.js +98 -0
- package/dist/pi/packages/ta-agents/lib/web.d.ts +4 -0
- package/dist/pi/packages/ta-agents/lib/web.js +14 -0
- package/dist/pi/packages/ta-agents/package.json +21 -5
- package/dist/pi/packages/ta-agents/web/index.js +385 -0
- package/dist/pi/packages/ta-app-use/README.en.md +28 -0
- package/dist/pi/packages/ta-app-use/README.md +28 -0
- package/dist/pi/packages/ta-app-use/extension/index.mjs +534 -0
- package/dist/pi/packages/ta-app-use/host/index.mjs +136 -0
- package/dist/pi/packages/ta-app-use/lib/app-host.d.ts +32 -0
- package/dist/pi/packages/ta-app-use/lib/app-host.js +79 -0
- package/dist/pi/packages/ta-app-use/lib/app-protocol.d.ts +23 -0
- package/dist/pi/packages/ta-app-use/lib/app-protocol.js +9 -0
- package/dist/pi/packages/ta-app-use/lib/app-util.d.ts +18 -0
- package/dist/pi/packages/ta-app-use/lib/app-util.js +71 -0
- package/dist/pi/packages/ta-app-use/lib/extension.d.ts +80 -0
- package/dist/pi/packages/ta-app-use/lib/extension.js +125 -0
- package/dist/pi/packages/ta-app-use/lib/host.d.ts +7 -0
- package/dist/pi/packages/ta-app-use/lib/host.js +16 -0
- package/dist/pi/packages/ta-app-use/lib/i18n.d.ts +38 -0
- package/dist/pi/packages/ta-app-use/lib/i18n.js +130 -0
- package/dist/pi/packages/ta-app-use/lib/index.d.ts +9 -0
- package/dist/pi/packages/ta-app-use/lib/index.js +93 -0
- package/dist/pi/packages/ta-app-use/lib/screen-cursor.d.ts +33 -0
- package/dist/pi/packages/ta-app-use/lib/screen-cursor.js +134 -0
- package/dist/pi/packages/ta-app-use/lib/screen-dom.d.ts +19 -0
- package/dist/pi/packages/ta-app-use/lib/screen-dom.js +184 -0
- package/dist/pi/packages/ta-app-use/lib/screen-driver.d.ts +46 -0
- package/dist/pi/packages/ta-app-use/lib/screen-driver.js +174 -0
- package/dist/pi/packages/ta-app-use/lib/screen-protocol.d.ts +67 -0
- package/dist/pi/packages/ta-app-use/lib/screen-protocol.js +8 -0
- package/dist/pi/packages/ta-app-use/lib/screen-text.d.ts +13 -0
- package/dist/pi/packages/ta-app-use/lib/screen-text.js +69 -0
- package/dist/pi/packages/ta-app-use/lib/screen-window.d.ts +68 -0
- package/dist/pi/packages/ta-app-use/lib/screen-window.js +376 -0
- package/dist/pi/packages/ta-app-use/lib/tool-line.d.ts +11 -0
- package/dist/pi/packages/ta-app-use/lib/tool-line.js +69 -0
- package/dist/pi/packages/ta-app-use/package.json +63 -0
- package/dist/pi/packages/ta-app-use/web/index.js +1520 -0
- package/dist/pi/packages/ta-bots/README.en.md +1 -0
- package/dist/pi/packages/ta-bots/README.md +1 -0
- package/dist/pi/packages/ta-bots/extension/index.mjs +25 -22
- package/dist/pi/packages/ta-bots/host/index.mjs +688 -148
- package/dist/pi/packages/ta-bots/lib/bot-service.d.ts +9 -1
- package/dist/pi/packages/ta-bots/lib/bot-service.js +49 -8
- package/dist/pi/packages/ta-bots/lib/channel-protocol.d.ts +2 -0
- package/dist/pi/packages/ta-bots/lib/extension.d.ts +2 -2
- package/dist/pi/packages/ta-bots/lib/extension.js +28 -24
- package/dist/pi/packages/ta-bots/lib/index.js +4 -0
- package/dist/pi/packages/ta-bots/lib/page.d.ts +7 -1
- package/dist/pi/packages/ta-bots/lib/page.js +17 -0
- package/dist/pi/packages/ta-bots/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-bots/lib/style.js +1 -1
- package/dist/pi/packages/ta-bots/lib/wecom-channel.js +1 -1
- package/dist/pi/packages/ta-bots/lib/weixin-api.d.ts +1 -0
- package/dist/pi/packages/ta-bots/lib/weixin-channel.js +2 -1
- package/dist/pi/packages/ta-bots/package.json +1 -1
- package/dist/pi/packages/ta-bots/web/index.js +13 -2
- package/dist/pi/packages/ta-call/README.en.md +9 -0
- package/dist/pi/packages/ta-call/README.md +9 -0
- package/dist/pi/packages/ta-call/extension/index.mjs +474 -0
- package/dist/pi/packages/ta-call/host/index.mjs +899 -0
- package/dist/pi/packages/ta-call/lib/call-host.d.ts +127 -0
- package/dist/pi/packages/ta-call/lib/call-host.js +377 -0
- package/dist/pi/packages/ta-call/lib/call-protocol.d.ts +33 -0
- package/dist/pi/packages/ta-call/lib/call-protocol.js +10 -0
- package/dist/pi/packages/ta-call/lib/call-util.d.ts +50 -0
- package/dist/pi/packages/ta-call/lib/call-util.js +250 -0
- package/dist/pi/packages/ta-call/lib/extension.d.ts +20 -0
- package/dist/pi/packages/ta-call/lib/extension.js +114 -0
- package/dist/pi/packages/ta-call/lib/host.d.ts +7 -0
- package/dist/pi/packages/ta-call/lib/host.js +20 -0
- package/dist/pi/packages/ta-call/lib/i18n.d.ts +16 -0
- package/dist/pi/packages/ta-call/lib/i18n.js +38 -0
- package/dist/pi/packages/ta-call/lib/index.d.ts +7 -0
- package/dist/pi/packages/ta-call/lib/index.js +60 -0
- package/dist/pi/packages/ta-call/lib/react.d.ts +8 -0
- package/dist/pi/packages/ta-call/lib/react.js +8 -0
- package/dist/pi/packages/ta-call/package.json +64 -0
- package/dist/pi/packages/ta-call/web/index.js +552 -0
- package/dist/pi/packages/ta-changes/extension/index.mjs +1 -0
- package/dist/pi/packages/ta-changes/lib/card.js +4 -1
- package/dist/pi/packages/ta-changes/package.json +1 -1
- package/dist/pi/packages/ta-changes/web/index.js +2 -0
- package/dist/pi/packages/ta-channels/extension/index.mjs +155 -194
- package/dist/pi/packages/ta-channels/host/index.mjs +2035 -1534
- package/dist/pi/packages/ta-channels/lib/agent-menu.js +2 -1
- package/dist/pi/packages/ta-channels/lib/channel-menu.d.ts +1 -1
- package/dist/pi/packages/ta-channels/lib/channel-menu.js +2 -2
- package/dist/pi/packages/ta-channels/lib/channels-text.d.ts +38 -0
- package/dist/pi/packages/ta-channels/lib/channels-text.js +173 -0
- package/dist/pi/packages/ta-channels/lib/channels-util.d.ts +0 -48
- package/dist/pi/packages/ta-channels/lib/channels-util.js +1 -223
- package/dist/pi/packages/ta-channels/lib/create.js +5 -1
- package/dist/pi/packages/ta-channels/lib/i18n-ja.d.ts +3 -0
- package/dist/pi/packages/ta-channels/lib/i18n-ja.js +182 -0
- package/dist/pi/packages/ta-channels/lib/i18n-zh-tw.d.ts +3 -0
- package/dist/pi/packages/ta-channels/lib/i18n-zh-tw.js +182 -0
- package/dist/pi/packages/ta-channels/lib/i18n-zh.d.ts +3 -0
- package/dist/pi/packages/ta-channels/lib/i18n-zh.js +182 -0
- package/dist/pi/packages/ta-channels/lib/i18n.js +4 -535
- package/dist/pi/packages/ta-channels/lib/index.js +2 -1
- package/dist/pi/packages/ta-channels/lib/notice-util.d.ts +15 -0
- package/dist/pi/packages/ta-channels/lib/notice-util.js +61 -0
- package/dist/pi/packages/ta-channels/lib/notice.d.ts +1 -1
- package/dist/pi/packages/ta-channels/lib/notice.js +5 -4
- package/dist/pi/packages/ta-channels/lib/room.js +4 -3
- package/dist/pi/packages/ta-channels/lib/sidebar-head.d.ts +6 -0
- package/dist/pi/packages/ta-channels/lib/sidebar-head.js +67 -0
- package/dist/pi/packages/ta-channels/lib/sidebar-hooks.d.ts +51 -0
- package/dist/pi/packages/ta-channels/lib/sidebar-hooks.js +230 -0
- package/dist/pi/packages/ta-channels/lib/sidebar-rows.d.ts +71 -0
- package/dist/pi/packages/ta-channels/lib/sidebar-rows.js +105 -0
- package/dist/pi/packages/ta-channels/lib/sidebar.d.ts +0 -4
- package/dist/pi/packages/ta-channels/lib/sidebar.js +35 -396
- package/dist/pi/packages/ta-channels/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-channels/lib/style.js +0 -1
- package/dist/pi/packages/ta-channels/lib/tasks.js +2 -1
- package/dist/pi/packages/ta-channels/lib/team-store.d.ts +78 -0
- package/dist/pi/packages/ta-channels/lib/team-store.js +261 -0
- package/dist/pi/packages/ta-channels/lib/team-tools.js +3 -2
- package/dist/pi/packages/ta-channels/lib/team.d.ts +3 -76
- package/dist/pi/packages/ta-channels/lib/team.js +5 -254
- package/dist/pi/packages/ta-channels/package.json +1 -1
- package/dist/pi/packages/ta-channels/web/index.js +889 -809
- package/dist/pi/packages/ta-computer-use/package.json +1 -1
- package/dist/pi/packages/ta-cron/README.en.md +19 -3
- package/dist/pi/packages/ta-cron/README.md +19 -3
- package/dist/pi/packages/ta-cron/extension/index.mjs +396 -111
- package/dist/pi/packages/ta-cron/host/index.mjs +633 -49
- package/dist/pi/packages/ta-cron/lib/chat-task.d.ts +5 -3
- package/dist/pi/packages/ta-cron/lib/chat-task.js +15 -10
- package/dist/pi/packages/ta-cron/lib/commands.d.ts +7 -4
- package/dist/pi/packages/ta-cron/lib/commands.js +26 -47
- package/dist/pi/packages/ta-cron/lib/cron-expression.d.ts +8 -0
- package/dist/pi/packages/ta-cron/lib/cron-expression.js +43 -1
- package/dist/pi/packages/ta-cron/lib/cron-protocol.d.ts +54 -7
- package/dist/pi/packages/ta-cron/lib/cron-protocol.js +16 -2
- package/dist/pi/packages/ta-cron/lib/editor.d.ts +3 -0
- package/dist/pi/packages/ta-cron/lib/editor.js +106 -36
- package/dist/pi/packages/ta-cron/lib/extension.js +1 -1
- package/dist/pi/packages/ta-cron/lib/form-util.d.ts +16 -6
- package/dist/pi/packages/ta-cron/lib/form-util.js +40 -28
- package/dist/pi/packages/ta-cron/lib/host.js +17 -1
- package/dist/pi/packages/ta-cron/lib/i18n.d.ts +39 -5
- package/dist/pi/packages/ta-cron/lib/i18n.js +160 -24
- package/dist/pi/packages/ta-cron/lib/index.js +4 -0
- package/dist/pi/packages/ta-cron/lib/page.d.ts +3 -2
- package/dist/pi/packages/ta-cron/lib/page.js +13 -2
- package/dist/pi/packages/ta-cron/lib/schedule-util.d.ts +4 -0
- package/dist/pi/packages/ta-cron/lib/schedule-util.js +52 -4
- package/dist/pi/packages/ta-cron/lib/scheduler.d.ts +56 -6
- package/dist/pi/packages/ta-cron/lib/scheduler.js +209 -27
- package/dist/pi/packages/ta-cron/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-cron/lib/style.js +50 -21
- package/dist/pi/packages/ta-cron/lib/task-list.d.ts +23 -0
- package/dist/pi/packages/ta-cron/lib/task-list.js +70 -0
- package/dist/pi/packages/ta-cron/lib/task-row.d.ts +19 -0
- package/dist/pi/packages/ta-cron/lib/task-row.js +246 -0
- package/dist/pi/packages/ta-cron/lib/task-util.d.ts +10 -6
- package/dist/pi/packages/ta-cron/lib/task-util.js +53 -19
- package/dist/pi/packages/ta-cron/lib/task-watchers.d.ts +30 -0
- package/dist/pi/packages/ta-cron/lib/task-watchers.js +90 -0
- package/dist/pi/packages/ta-cron/lib/tasks-view.d.ts +3 -2
- package/dist/pi/packages/ta-cron/lib/tasks-view.js +48 -193
- package/dist/pi/packages/ta-cron/lib/tool-line.js +4 -0
- package/dist/pi/packages/ta-cron/lib/tool.d.ts +7 -0
- package/dist/pi/packages/ta-cron/lib/tool.js +18 -8
- package/dist/pi/packages/ta-cron/lib/when.d.ts +39 -0
- package/dist/pi/packages/ta-cron/lib/when.js +231 -0
- package/dist/pi/packages/ta-cron/package.json +2 -1
- package/dist/pi/packages/ta-cron/web/index.js +1091 -340
- package/dist/pi/packages/ta-extensions/lib/market-detail.js +9 -5
- package/dist/pi/packages/ta-extensions/lib/page.js +1 -1
- package/dist/pi/packages/ta-extensions/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-extensions/lib/style.js +1 -1
- package/dist/pi/packages/ta-extensions/package.json +1 -1
- package/dist/pi/packages/ta-extensions/skills/ta-package/SKILL.md +9 -7
- package/dist/pi/packages/ta-extensions/web/index.js +739 -234
- package/dist/pi/packages/ta-feedback/README.en.md +10 -0
- package/dist/pi/packages/ta-feedback/README.md +10 -0
- package/dist/pi/packages/ta-feedback/extension/index.mjs +451 -0
- package/dist/pi/packages/ta-feedback/host/index.mjs +1187 -0
- package/dist/pi/packages/ta-feedback/lib/extension.d.ts +31 -0
- package/dist/pi/packages/ta-feedback/lib/extension.js +160 -0
- package/dist/pi/packages/ta-feedback/lib/feedback-git.d.ts +25 -0
- package/dist/pi/packages/ta-feedback/lib/feedback-git.js +44 -0
- package/dist/pi/packages/ta-feedback/lib/feedback-host.d.ts +133 -0
- package/dist/pi/packages/ta-feedback/lib/feedback-host.js +668 -0
- package/dist/pi/packages/ta-feedback/lib/feedback-protocol.d.ts +127 -0
- package/dist/pi/packages/ta-feedback/lib/feedback-protocol.js +41 -0
- package/dist/pi/packages/ta-feedback/lib/feedback-util.d.ts +79 -0
- package/dist/pi/packages/ta-feedback/lib/feedback-util.js +252 -0
- package/dist/pi/packages/ta-feedback/lib/feedback-view.d.ts +11 -0
- package/dist/pi/packages/ta-feedback/lib/feedback-view.js +244 -0
- package/dist/pi/packages/ta-feedback/lib/host.d.ts +8 -0
- package/dist/pi/packages/ta-feedback/lib/host.js +19 -0
- package/dist/pi/packages/ta-feedback/lib/i18n.d.ts +69 -0
- package/dist/pi/packages/ta-feedback/lib/i18n.js +250 -0
- package/dist/pi/packages/ta-feedback/lib/index.d.ts +8 -0
- package/dist/pi/packages/ta-feedback/lib/index.js +88 -0
- package/dist/pi/packages/ta-feedback/lib/page.d.ts +35 -0
- package/dist/pi/packages/ta-feedback/lib/page.js +135 -0
- package/dist/pi/packages/ta-feedback/lib/react.d.ts +8 -0
- package/dist/pi/packages/ta-feedback/lib/react.js +8 -0
- package/dist/pi/packages/ta-feedback/lib/style.d.ts +4 -0
- package/dist/pi/packages/ta-feedback/lib/style.js +71 -0
- package/dist/pi/packages/ta-feedback/package.json +65 -0
- package/dist/pi/packages/ta-feedback/web/index.js +939 -0
- package/dist/pi/packages/ta-games/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-games/lib/style.js +1 -1
- package/dist/pi/packages/ta-games/package.json +1 -1
- package/dist/pi/packages/ta-games/web/index.js +1 -1
- package/dist/pi/packages/ta-glance/extension/index.mjs +27 -8
- package/dist/pi/packages/ta-glance/lib/card.js +67 -27
- package/dist/pi/packages/ta-glance/lib/glance-json.d.ts +1 -1
- package/dist/pi/packages/ta-glance/lib/glance-json.js +8 -1
- package/dist/pi/packages/ta-glance/lib/glance-prompt.js +3 -3
- package/dist/pi/packages/ta-glance/lib/glance-protocol.d.ts +9 -2
- package/dist/pi/packages/ta-glance/lib/glance-spec.js +33 -5
- package/dist/pi/packages/ta-glance/lib/glance-speech.d.ts +13 -0
- package/dist/pi/packages/ta-glance/lib/glance-speech.js +45 -0
- package/dist/pi/packages/ta-glance/lib/i18n.d.ts +5 -0
- package/dist/pi/packages/ta-glance/lib/i18n.js +20 -0
- package/dist/pi/packages/ta-glance/lib/index.js +11 -1
- package/dist/pi/packages/ta-glance/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-glance/lib/style.js +17 -3
- package/dist/pi/packages/ta-glance/package.json +2 -1
- package/dist/pi/packages/ta-glance/web/index.js +180 -30
- package/dist/pi/packages/ta-initiative/extension/index.mjs +3 -2
- package/dist/pi/packages/ta-initiative/host/index.mjs +1 -1
- package/dist/pi/packages/ta-initiative/lib/chat-proposals.js +1 -1
- package/dist/pi/packages/ta-initiative/lib/index.js +1 -0
- package/dist/pi/packages/ta-initiative/lib/material-util.js +1 -1
- package/dist/pi/packages/ta-initiative/lib/settings.js +2 -1
- package/dist/pi/packages/ta-initiative/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-initiative/lib/style.js +1 -1
- package/dist/pi/packages/ta-initiative/package.json +1 -1
- package/dist/pi/packages/ta-initiative/web/index.js +5 -3
- package/dist/pi/packages/ta-launcher/package.json +1 -1
- package/dist/pi/packages/ta-manual/lib/manual-util.d.ts +1 -1
- package/dist/pi/packages/ta-manual/lib/pictures-c.js +15 -0
- package/dist/pi/packages/ta-manual/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-manual/lib/style.js +1 -1
- package/dist/pi/packages/ta-manual/lib/topics-a.d.ts +3 -0
- package/dist/pi/packages/ta-manual/lib/topics-a.js +295 -0
- package/dist/pi/packages/ta-manual/lib/topics-model.d.ts +46 -0
- package/dist/pi/packages/ta-manual/lib/topics-model.js +21 -0
- package/dist/pi/packages/ta-manual/lib/topics.d.ts +1 -44
- package/dist/pi/packages/ta-manual/lib/topics.js +28 -318
- package/dist/pi/packages/ta-manual/package.json +1 -1
- package/dist/pi/packages/ta-manual/skills/ta-manual/SKILL.md +12 -10
- package/dist/pi/packages/ta-manual/web/index.js +97 -24
- package/dist/pi/packages/ta-moments/extension/index.mjs +702 -191
- package/dist/pi/packages/ta-moments/host/index.mjs +1361 -837
- package/dist/pi/packages/ta-moments/lib/index.js +3 -1
- package/dist/pi/packages/ta-moments/lib/moments-host-base.d.ts +96 -0
- package/dist/pi/packages/ta-moments/lib/moments-host-base.js +276 -0
- package/dist/pi/packages/ta-moments/lib/moments-host-pictures.d.ts +22 -0
- package/dist/pi/packages/ta-moments/lib/moments-host-pictures.js +167 -0
- package/dist/pi/packages/ta-moments/lib/moments-host.d.ts +4 -84
- package/dist/pi/packages/ta-moments/lib/moments-host.js +13 -426
- package/dist/pi/packages/ta-moments/lib/page.js +3 -3
- package/dist/pi/packages/ta-moments/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-moments/lib/style.js +1 -1
- package/dist/pi/packages/ta-moments/lib/talk-host-base.d.ts +71 -0
- package/dist/pi/packages/ta-moments/lib/talk-host-base.js +171 -0
- package/dist/pi/packages/ta-moments/lib/talk-host.d.ts +3 -62
- package/dist/pi/packages/ta-moments/lib/talk-host.js +14 -169
- package/dist/pi/packages/ta-moments/package.json +1 -1
- package/dist/pi/packages/ta-moments/web/index.js +648 -144
- package/dist/pi/packages/ta-nearby/extension/index.mjs +9 -0
- package/dist/pi/packages/ta-nearby/host/index.mjs +1073 -1018
- package/dist/pi/packages/ta-nearby/lib/index.js +8 -5
- package/dist/pi/packages/ta-nearby/lib/nearby-home.d.ts +13 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-home.js +91 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-meet-view.d.ts +12 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-meet-view.js +113 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-page.d.ts +6 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-page.js +157 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-service-base.d.ts +161 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-service-base.js +343 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-service-meet.d.ts +41 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-service-meet.js +297 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-service.d.ts +6 -167
- package/dist/pi/packages/ta-nearby/lib/nearby-service.js +38 -638
- package/dist/pi/packages/ta-nearby/lib/nearby-show-view.d.ts +6 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-show-view.js +88 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-spot.d.ts +6 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-spot.js +25 -3
- package/dist/pi/packages/ta-nearby/lib/page.d.ts +27 -20
- package/dist/pi/packages/ta-nearby/lib/page.js +15 -417
- package/dist/pi/packages/ta-nearby/lib/server-texts.d.ts +1 -1
- package/dist/pi/packages/ta-nearby/lib/server-texts.js +9 -1
- package/dist/pi/packages/ta-nearby/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-nearby/lib/style.js +1 -1
- package/dist/pi/packages/ta-nearby/package.json +1 -1
- package/dist/pi/packages/ta-nearby/web/index.js +370 -362
- package/dist/pi/packages/ta-notify/extension/index.mjs +1 -0
- package/dist/pi/packages/ta-notify/lib/settings.js +1 -0
- package/dist/pi/packages/ta-notify/package.json +1 -1
- package/dist/pi/packages/ta-notify/web/index.js +1 -0
- package/dist/pi/packages/ta-plot/extension/index.mjs +1 -0
- package/dist/pi/packages/ta-plot/package.json +2 -1
- package/dist/pi/packages/ta-recall/extension/index.mjs +1 -0
- package/dist/pi/packages/ta-recall/host/index.mjs +1 -0
- package/dist/pi/packages/ta-recall/lib/settings.js +1 -0
- package/dist/pi/packages/ta-recall/package.json +1 -1
- package/dist/pi/packages/ta-recall/web/index.js +2 -0
- package/dist/pi/packages/ta-rooms/extension/index.mjs +1 -0
- package/dist/pi/packages/ta-rooms/host/index.mjs +497 -492
- package/dist/pi/packages/ta-rooms/lib/double-agents.js +6 -6
- package/dist/pi/packages/ta-rooms/lib/double-grants.js +10 -10
- package/dist/pi/packages/ta-rooms/lib/double-host.js +6 -5
- package/dist/pi/packages/ta-rooms/lib/double-tasks-base.d.ts +55 -0
- package/dist/pi/packages/ta-rooms/lib/double-tasks-base.js +279 -0
- package/dist/pi/packages/ta-rooms/lib/double-tasks.d.ts +3 -45
- package/dist/pi/packages/ta-rooms/lib/double-tasks.js +14 -282
- package/dist/pi/packages/ta-rooms/lib/double-user.js +2 -2
- package/dist/pi/packages/ta-rooms/lib/friend-notices.js +2 -2
- package/dist/pi/packages/ta-rooms/lib/i18n.d.ts +1 -0
- package/dist/pi/packages/ta-rooms/lib/i18n.js +8 -4
- package/dist/pi/packages/ta-rooms/lib/index.js +18 -2
- package/dist/pi/packages/ta-rooms/lib/members-view.js +37 -3
- package/dist/pi/packages/ta-rooms/lib/page.d.ts +36 -1
- package/dist/pi/packages/ta-rooms/lib/page.js +76 -1
- package/dist/pi/packages/ta-rooms/lib/room-view.js +22 -17
- package/dist/pi/packages/ta-rooms/lib/rooms-home.js +1 -0
- package/dist/pi/packages/ta-rooms/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-rooms/lib/style.js +32 -6
- package/dist/pi/packages/ta-rooms/package.json +1 -1
- package/dist/pi/packages/ta-rooms/web/index.js +223 -38
- package/dist/pi/packages/ta-secrets/README.en.md +22 -0
- package/dist/pi/packages/ta-secrets/README.md +22 -0
- package/dist/pi/packages/ta-secrets/extension/index.mjs +462 -0
- package/dist/pi/packages/ta-secrets/host/index.mjs +1341 -0
- package/dist/pi/packages/ta-secrets/lib/command-prelude.d.ts +36 -0
- package/dist/pi/packages/ta-secrets/lib/command-prelude.js +66 -0
- package/dist/pi/packages/ta-secrets/lib/extension.d.ts +28 -0
- package/dist/pi/packages/ta-secrets/lib/extension.js +156 -0
- package/dist/pi/packages/ta-secrets/lib/host.d.ts +4 -0
- package/dist/pi/packages/ta-secrets/lib/host.js +15 -0
- package/dist/pi/packages/ta-secrets/lib/i18n.d.ts +47 -0
- package/dist/pi/packages/ta-secrets/lib/i18n.js +166 -0
- package/dist/pi/packages/ta-secrets/lib/index.d.ts +8 -0
- package/dist/pi/packages/ta-secrets/lib/index.js +28 -0
- package/dist/pi/packages/ta-secrets/lib/personal-info.d.ts +26 -0
- package/dist/pi/packages/ta-secrets/lib/personal-info.js +108 -0
- package/dist/pi/packages/ta-secrets/lib/proxy-certs.d.ts +40 -0
- package/dist/pi/packages/ta-secrets/lib/proxy-certs.js +200 -0
- package/dist/pi/packages/ta-secrets/lib/proxy-scenario.d.ts +6 -0
- package/dist/pi/packages/ta-secrets/lib/proxy-scenario.js +91 -0
- package/dist/pi/packages/ta-secrets/lib/react.d.ts +8 -0
- package/dist/pi/packages/ta-secrets/lib/react.js +8 -0
- package/dist/pi/packages/ta-secrets/lib/scrubber.d.ts +20 -0
- package/dist/pi/packages/ta-secrets/lib/scrubber.js +70 -0
- package/dist/pi/packages/ta-secrets/lib/secrets-protocol.d.ts +106 -0
- package/dist/pi/packages/ta-secrets/lib/secrets-protocol.js +134 -0
- package/dist/pi/packages/ta-secrets/lib/server-texts.d.ts +14 -0
- package/dist/pi/packages/ta-secrets/lib/server-texts.js +62 -0
- package/dist/pi/packages/ta-secrets/lib/settings.d.ts +4 -0
- package/dist/pi/packages/ta-secrets/lib/settings.js +179 -0
- package/dist/pi/packages/ta-secrets/lib/style.d.ts +4 -0
- package/dist/pi/packages/ta-secrets/lib/style.js +32 -0
- package/dist/pi/packages/ta-secrets/lib/vault-fixture.d.ts +8 -0
- package/dist/pi/packages/ta-secrets/lib/vault-fixture.js +22 -0
- package/dist/pi/packages/ta-secrets/lib/vault-proxy.d.ts +94 -0
- package/dist/pi/packages/ta-secrets/lib/vault-proxy.js +357 -0
- package/dist/pi/packages/ta-secrets/lib/vault-service.d.ts +111 -0
- package/dist/pi/packages/ta-secrets/lib/vault-service.js +429 -0
- package/dist/pi/packages/ta-secrets/lib/vault-store.d.ts +48 -0
- package/dist/pi/packages/ta-secrets/lib/vault-store.js +107 -0
- package/dist/pi/packages/ta-secrets/package.json +67 -0
- package/dist/pi/packages/ta-secrets/web/index.js +579 -0
- package/dist/pi/packages/ta-share/extension/index.mjs +1 -0
- package/dist/pi/packages/ta-share/host/index.mjs +172 -21
- package/dist/pi/packages/ta-share/lib/i18n.d.ts +1 -0
- package/dist/pi/packages/ta-share/lib/i18n.js +4 -0
- package/dist/pi/packages/ta-share/lib/index.js +1 -1
- package/dist/pi/packages/ta-share/lib/share-dialog.js +1 -0
- package/dist/pi/packages/ta-share/lib/share-protocol.d.ts +2 -0
- package/dist/pi/packages/ta-share/lib/share-service.d.ts +11 -1
- package/dist/pi/packages/ta-share/lib/share-service.js +62 -4
- package/dist/pi/packages/ta-share/lib/snapshot.d.ts +8 -2
- package/dist/pi/packages/ta-share/lib/snapshot.js +93 -7
- package/dist/pi/packages/ta-share/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-share/lib/style.js +1 -1
- package/dist/pi/packages/ta-share/package.json +1 -1
- package/dist/pi/packages/ta-share/web/index.js +7 -2
- package/dist/pi/packages/ta-sync/host/index.mjs +1154 -755
- package/dist/pi/packages/ta-sync/lib/host.js +3 -0
- package/dist/pi/packages/ta-sync/lib/index.js +6 -2
- package/dist/pi/packages/ta-sync/lib/migrate-archive.d.ts +8 -6
- package/dist/pi/packages/ta-sync/lib/migrate-archive.js +24 -28
- package/dist/pi/packages/ta-sync/lib/migrate-i18n.d.ts +10 -0
- package/dist/pi/packages/ta-sync/lib/migrate-i18n.js +40 -0
- package/dist/pi/packages/ta-sync/lib/migrate-paths.d.ts +24 -0
- package/dist/pi/packages/ta-sync/lib/migrate-paths.js +230 -0
- package/dist/pi/packages/ta-sync/lib/migrate-protocol.d.ts +18 -0
- package/dist/pi/packages/ta-sync/lib/migrate-service.d.ts +11 -1
- package/dist/pi/packages/ta-sync/lib/migrate-service.js +28 -1
- package/dist/pi/packages/ta-sync/lib/move-panel.d.ts +9 -1
- package/dist/pi/packages/ta-sync/lib/move-panel.js +69 -5
- package/dist/pi/packages/ta-sync/lib/server-texts.d.ts +1 -0
- package/dist/pi/packages/ta-sync/lib/server-texts.js +9 -0
- package/dist/pi/packages/ta-sync/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-sync/lib/style.js +8 -1
- package/dist/pi/packages/ta-sync/lib/sync-service-base.d.ts +78 -0
- package/dist/pi/packages/ta-sync/lib/sync-service-base.js +224 -0
- package/dist/pi/packages/ta-sync/lib/sync-service-space.d.ts +36 -0
- package/dist/pi/packages/ta-sync/lib/sync-service-space.js +210 -0
- package/dist/pi/packages/ta-sync/lib/sync-service.d.ts +3 -99
- package/dist/pi/packages/ta-sync/lib/sync-service.js +2 -412
- package/dist/pi/packages/ta-sync/package.json +1 -1
- package/dist/pi/packages/ta-sync/web/index.js +138 -5
- package/dist/pi/packages/ta-sync-cloud/package.json +1 -1
- package/dist/pi/packages/ta-team/extension/index.mjs +1 -0
- package/dist/pi/packages/ta-team/host/index.mjs +1 -0
- package/dist/pi/packages/ta-team/lib/dialogs.d.ts +0 -2
- package/dist/pi/packages/ta-team/lib/dialogs.js +0 -227
- package/dist/pi/packages/ta-team/lib/i18n-ja.d.ts +3 -0
- package/dist/pi/packages/ta-team/lib/i18n-ja.js +211 -0
- package/dist/pi/packages/ta-team/lib/i18n-zh-tw.d.ts +3 -0
- package/dist/pi/packages/ta-team/lib/i18n-zh-tw.js +211 -0
- package/dist/pi/packages/ta-team/lib/i18n-zh.d.ts +3 -0
- package/dist/pi/packages/ta-team/lib/i18n-zh.js +211 -0
- package/dist/pi/packages/ta-team/lib/i18n.d.ts +1 -2
- package/dist/pi/packages/ta-team/lib/i18n.js +6 -624
- package/dist/pi/packages/ta-team/lib/index.js +3 -1
- package/dist/pi/packages/ta-team/lib/join-dialog.d.ts +3 -0
- package/dist/pi/packages/ta-team/lib/join-dialog.js +234 -0
- package/dist/pi/packages/ta-team/lib/members-tab.js +2 -1
- package/dist/pi/packages/ta-team/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-team/lib/style.js +1 -1
- package/dist/pi/packages/ta-team/package.json +1 -1
- package/dist/pi/packages/ta-team/web/index.js +2095 -2086
- package/dist/pi/packages/ta-usage/README.en.md +6 -0
- package/dist/pi/packages/ta-usage/README.md +6 -0
- package/dist/pi/packages/ta-usage/host/index.mjs +220 -0
- package/dist/pi/packages/ta-usage/lib/host.d.ts +4 -0
- package/dist/pi/packages/ta-usage/lib/host.js +9 -0
- package/dist/pi/packages/ta-usage/lib/i18n.d.ts +30 -0
- package/dist/pi/packages/ta-usage/lib/i18n.js +98 -0
- package/dist/pi/packages/ta-usage/lib/index.d.ts +4 -0
- package/dist/pi/packages/ta-usage/lib/index.js +20 -0
- package/dist/pi/packages/ta-usage/lib/react.d.ts +8 -0
- package/dist/pi/packages/ta-usage/lib/react.js +8 -0
- package/dist/pi/packages/ta-usage/lib/style.d.ts +4 -0
- package/dist/pi/packages/ta-usage/lib/style.js +53 -0
- package/dist/pi/packages/ta-usage/lib/usage-host.d.ts +25 -0
- package/dist/pi/packages/ta-usage/lib/usage-host.js +70 -0
- package/dist/pi/packages/ta-usage/lib/usage-protocol.d.ts +55 -0
- package/dist/pi/packages/ta-usage/lib/usage-protocol.js +7 -0
- package/dist/pi/packages/ta-usage/lib/usage-util.d.ts +18 -0
- package/dist/pi/packages/ta-usage/lib/usage-util.js +159 -0
- package/dist/pi/packages/ta-usage/lib/usage-view.d.ts +9 -0
- package/dist/pi/packages/ta-usage/lib/usage-view.js +91 -0
- package/dist/pi/packages/ta-usage/package.json +61 -0
- package/dist/pi/packages/ta-usage/web/index.js +471 -0
- package/dist/pi/packages/ta-voice/README.en.md +8 -0
- package/dist/pi/packages/ta-voice/README.md +8 -0
- package/dist/pi/packages/ta-voice/host/index.mjs +662 -0
- package/dist/pi/packages/ta-voice/lib/doubao-frames.d.ts +44 -0
- package/dist/pi/packages/ta-voice/lib/doubao-frames.js +116 -0
- package/dist/pi/packages/ta-voice/lib/doubao-realtime.d.ts +35 -0
- package/dist/pi/packages/ta-voice/lib/doubao-realtime.js +172 -0
- package/dist/pi/packages/ta-voice/lib/host.d.ts +20 -0
- package/dist/pi/packages/ta-voice/lib/host.js +120 -0
- package/dist/pi/packages/ta-voice/lib/openai-realtime.d.ts +73 -0
- package/dist/pi/packages/ta-voice/lib/openai-realtime.js +257 -0
- package/dist/pi/packages/ta-voice/lib/realtime-socket.d.ts +23 -0
- package/dist/pi/packages/ta-voice/lib/realtime-socket.js +80 -0
- package/dist/pi/packages/ta-voice/package.json +67 -0
- package/dist/pi/packages/ta-workspace/README.md +1 -1
- package/dist/pi/packages/ta-workspace/README.zh-cn.md +1 -1
- package/dist/pi/packages/ta-workspace/lib/browser-common.d.ts +4 -0
- package/dist/pi/packages/ta-workspace/lib/browser-common.js +1 -0
- package/dist/pi/packages/ta-workspace/lib/browser-pick.d.ts +49 -0
- package/dist/pi/packages/ta-workspace/lib/browser-pick.js +166 -0
- package/dist/pi/packages/ta-workspace/lib/browser-webview.js +16 -1
- package/dist/pi/packages/ta-workspace/lib/i18n-en.d.ts +3 -0
- package/dist/pi/packages/ta-workspace/lib/i18n-en.js +215 -0
- package/dist/pi/packages/ta-workspace/lib/i18n-ja.d.ts +3 -0
- package/dist/pi/packages/ta-workspace/lib/i18n-ja.js +215 -0
- package/dist/pi/packages/ta-workspace/lib/i18n-zh-tw.d.ts +3 -0
- package/dist/pi/packages/ta-workspace/lib/i18n-zh-tw.js +215 -0
- package/dist/pi/packages/ta-workspace/lib/i18n.d.ts +7 -3
- package/dist/pi/packages/ta-workspace/lib/i18n.js +11 -621
- package/dist/pi/packages/ta-workspace/package.json +1 -1
- package/dist/pi/packages/ta-workspace/web/index.js +1464 -765
- package/dist/public/assets/{abnfDiagram-S7VZAUFO-FSEuUCgT.js → abnfDiagram-S7VZAUFO-w8qXXVn-.js} +1 -1
- package/dist/public/assets/{architecture-WOLXFQ4H-Do_DyWCg.js → architecture-WOLXFQ4H-B-FHaYwY.js} +1 -1
- package/dist/public/assets/{architectureDiagram-YGSQEFNW-D-N2qDs4.js → architectureDiagram-YGSQEFNW-DTnoGaaX.js} +1 -1
- package/dist/public/assets/{blockDiagram-APKKGZFW-Ds6DzHNZ.js → blockDiagram-APKKGZFW-CyeBzv-v.js} +1 -1
- package/dist/public/assets/{browser-D2BcOPKG.js → browser-Cb38iiEE.js} +1 -1
- package/dist/public/assets/{browser-KlrZxPbE.js → browser-DXexCqIh.js} +2 -2
- package/dist/public/assets/{c4Diagram-KJ2TOQU5-D5ZdqxrP.js → c4Diagram-KJ2TOQU5-CJJqDqyQ.js} +1 -1
- package/dist/public/assets/{chunk-6MUBBAK2-CWOwhB3b.js → chunk-6MUBBAK2-DbvUMdNm.js} +1 -1
- package/dist/public/assets/{chunk-AXFCVDMN-Dr6p2RGg.js → chunk-AXFCVDMN-D4hlZGtj.js} +1 -1
- package/dist/public/assets/{chunk-BG4553SI-DUCV_pmW.js → chunk-BG4553SI-VNa9Q9On.js} +1 -1
- package/dist/public/assets/{chunk-DQASFODM-Yxd3jIXM.js → chunk-DQASFODM-BtlEbc_V.js} +1 -1
- package/dist/public/assets/{chunk-HFQBQIA3-C24I15MF.js → chunk-HFQBQIA3-CAYSo4CJ.js} +1 -1
- package/dist/public/assets/{chunk-KQLB2F66-Dxk-aejD.js → chunk-KQLB2F66-CyKdg6hW.js} +1 -1
- package/dist/public/assets/{chunk-KS47KZWR-DPyr7gb8.js → chunk-KS47KZWR-BMogCB2r.js} +1 -1
- package/dist/public/assets/{chunk-LEVMRMFU-D_mEFJGR.js → chunk-LEVMRMFU-Y9wr-8qB.js} +1 -1
- package/dist/public/assets/{chunk-M57EVK23-DfMFxQib.js → chunk-M57EVK23-DL3IAQKR.js} +1 -1
- package/dist/public/assets/{chunk-OY52VR5R-O9W83Laa.js → chunk-OY52VR5R-CJBFHdg6.js} +1 -1
- package/dist/public/assets/{chunk-QB3YPZ4I-IdikGcw1.js → chunk-QB3YPZ4I-CyuWKZZv.js} +1 -1
- package/dist/public/assets/{chunk-R3KSYZAL-DLpaFCvz.js → chunk-R3KSYZAL-DxvGhfpm.js} +1 -1
- package/dist/public/assets/{chunk-STOXU5M4-Lx-CZ4Ql.js → chunk-STOXU5M4-Cpdl6bfz.js} +1 -1
- package/dist/public/assets/{chunk-TU62E6Q5-DCnr5NsA.js → chunk-TU62E6Q5-CIxOg6QF.js} +1 -1
- package/dist/public/assets/{chunk-X4PVCEUW-Ct7aUJFY.js → chunk-X4PVCEUW-DCFSCRBh.js} +1 -1
- package/dist/public/assets/{chunk-XXDRQBXY-CQhxfoYw.js → chunk-XXDRQBXY-B2R8Cxf7.js} +1 -1
- package/dist/public/assets/{classDiagram-v2-L25IHNXF-DPSu5qYq.js → classDiagram-v2-L25IHNXF-B7W9HSbj.js} +1 -1
- package/dist/public/assets/{client-C8gi9Fk2.js → client-D75LfyFa.js} +1 -1
- package/dist/public/assets/{common-DrZR0tgm.js → common-CjqTomRQ.js} +1 -1
- package/dist/public/assets/{cose-bilkent-JH36ORCC-CFimsFsN.js → cose-bilkent-JH36ORCC-CXSLFyCH.js} +1 -1
- package/dist/public/assets/cynefin-EF2NZ3EQ-BIcbDns7.js +1 -0
- package/dist/public/assets/{cynefinDiagram-L36ESFBY-CiAWhkVp.js → cynefinDiagram-L36ESFBY-DTv0Kn1r.js} +1 -1
- package/dist/public/assets/{d3-selection-C8RIDfkO.js → d3-selection-g4Hl3_NH.js} +1 -1
- package/dist/public/assets/{dagre-SPEB5RXH-l1nRD1Fx.js → dagre-SPEB5RXH-BujVqk5R.js} +1 -1
- package/dist/public/assets/{diagram-3B7GL73J-ipqtnhoX.js → diagram-3B7GL73J-Ds-VnLzP.js} +1 -1
- package/dist/public/assets/{diagram-DNEMPZML-VpIcHRUP.js → diagram-DNEMPZML-BBoIIK-a.js} +1 -1
- package/dist/public/assets/{diagram-L3MUGCDN-8VdVmcS6.js → diagram-L3MUGCDN-Glgd5N_n.js} +1 -1
- package/dist/public/assets/{diagram-LA4NIPWU-Bej-aiF0.js → diagram-LA4NIPWU-B4EODdUU.js} +1 -1
- package/dist/public/assets/{diagram-MHCOC4E2-D8gW4bVQ.js → diagram-MHCOC4E2-pzDDXO2J.js} +1 -1
- package/dist/public/assets/{diagram-XPFHEONP-BMevAJ1M.js → diagram-XPFHEONP-l--gwSuK.js} +1 -1
- package/dist/public/assets/{dist-DBKJcjvW.js → dist-C0u3lAFR.js} +1 -1
- package/dist/public/assets/{ebnfDiagram-UZSYDL2S-C3HDTOzn.js → ebnfDiagram-UZSYDL2S-BVfPeaVX.js} +1 -1
- package/dist/public/assets/{editor.api-BMWdjwhK.js → editor.api-BMcewI3C.js} +1 -1
- package/dist/public/assets/{elk-XV6XMXQE-XOOPrVin.js → elk-XV6XMXQE-BFJtUnG9.js} +1 -1
- package/dist/public/assets/{erDiagram-EYBAPDEH-Cr-vwx1l.js → erDiagram-EYBAPDEH-BWxMtfIc.js} +1 -1
- package/dist/public/assets/{eventmodeling-K75KTNOO-DbPhpfxn.js → eventmodeling-K75KTNOO-YwYgBgCX.js} +1 -1
- package/dist/public/assets/flowDiagram-MALGAFMO-Dah4--NW.js +1 -0
- package/dist/public/assets/{freemarker2-6h_1-8qB.js → freemarker2-B8HquI7K.js} +1 -1
- package/dist/public/assets/{ganttDiagram-23REXITY-C7kNPXx3.js → ganttDiagram-23REXITY-CBqv7wbi.js} +1 -1
- package/dist/public/assets/gitGraph-VSP46ZUC-BwDfrSZS.js +1 -0
- package/dist/public/assets/{gitGraphDiagram-STJD7YCW-CVnEJEZr.js → gitGraphDiagram-STJD7YCW-BLSf23f_.js} +1 -1
- package/dist/public/assets/{handlebars-F4lp3oLr.js → handlebars-P1qmNq4N.js} +1 -1
- package/dist/public/assets/{html-Dj6f8B_g.js → html-Ceswbytr.js} +1 -1
- package/dist/public/assets/{index-DnNrrk68.js → index-10isUUN4.js} +2 -2
- package/dist/public/assets/info-OHQRW6UA-Ch8aMV1p.js +1 -0
- package/dist/public/assets/{infoDiagram-KBXO4MBG-DcttQWdp.js → infoDiagram-KBXO4MBG-LvOtgUlm.js} +1 -1
- package/dist/public/assets/{ishikawaDiagram-M35NCXHK-BSUYTZf6.js → ishikawaDiagram-M35NCXHK-CwUZOvcm.js} +1 -1
- package/dist/public/assets/{javascript-b_BkOE5Y.js → javascript-B3FXC8qR.js} +1 -1
- package/dist/public/assets/{journeyDiagram-OPLOXDXO-BCfd5-6n.js → journeyDiagram-OPLOXDXO-5j1KtwTt.js} +1 -1
- package/dist/public/assets/{jsonMode-Cq5QJbVZ.js → jsonMode-CrCyxNQI.js} +1 -1
- package/dist/public/assets/{kanban-definition-BZKZHSQY-B3nenaw_.js → kanban-definition-BZKZHSQY-BKAB5id1.js} +1 -1
- package/dist/public/assets/{liquid-CGuZI_Aa.js → liquid-CXZRIgp2.js} +1 -1
- package/dist/public/assets/{mdx-Dt9yTqnf.js → mdx-Dm3uNczM.js} +1 -1
- package/dist/public/assets/{mermaid-parser.core-CquzROwT.js → mermaid-parser.core-C755A-rX.js} +3 -3
- package/dist/public/assets/{mermaid.core-Bx-e_Scq.js → mermaid.core-CQrYmFAR.js} +4 -4
- package/dist/public/assets/{mindmap-definition-I2QAS2VK-DyeewbnH.js → mindmap-definition-I2QAS2VK-DNJQKYbK.js} +1 -1
- package/dist/public/assets/module-9otB6_kX.js +1 -0
- package/dist/public/assets/{module-Cm_mLwAQ.js → module-C3jC5acf.js} +1 -1
- package/dist/public/assets/module-C_MyFORb.js +1 -0
- package/dist/public/assets/module-Cjpl4gva.js +1 -0
- package/dist/public/assets/{module-DUYj4E8T.js → module-D8yH9xCl.js} +1 -1
- package/dist/public/assets/module-DlHjBjOg.js +1 -0
- package/dist/public/assets/module-QsLiJaR6.js +1 -0
- package/dist/public/assets/module-aaW5Ri2L.js +2771 -0
- package/dist/public/assets/module-gSy9fKBo.js +1 -0
- package/dist/public/assets/{monaco-nvIdDTWu.js → monaco-BS7JBNW4.js} +3 -3
- package/dist/public/assets/packet-JDAUHWVQ-LqMrrc60.js +1 -0
- package/dist/public/assets/{pegDiagram-FD4XPPHP-B884_KoR.js → pegDiagram-FD4XPPHP-BzbBCWht.js} +1 -1
- package/dist/public/assets/pie-XZMESJXO-BWzABXQU.js +1 -0
- package/dist/public/assets/{pieDiagram-J4AKIIQI-I40wRwyy.js → pieDiagram-J4AKIIQI-Bf_LDukL.js} +1 -1
- package/dist/public/assets/{python-Djw4wvG9.js → python-jgOUhB-F.js} +1 -1
- package/dist/public/assets/{quadrantDiagram-XTYBLID2-DyNOImfk.js → quadrantDiagram-XTYBLID2-CdMHWnKX.js} +1 -1
- package/dist/public/assets/radar-ABXABTNO-CR4kNiUj.js +1 -0
- package/dist/public/assets/railroad-I3PHUGI6-BAkWtkGC.js +1 -0
- package/dist/public/assets/{railroad-abnf-LNEFI6M7-3G0zWzgf.js → railroad-abnf-LNEFI6M7-DQGYaRbc.js} +1 -1
- package/dist/public/assets/{railroad-ebnf-DWYD2UWJ-B5XRDRWS.js → railroad-ebnf-DWYD2UWJ-D6Ljza0U.js} +1 -1
- package/dist/public/assets/{railroad-peg-JR7BVNR7-rcIioIyH.js → railroad-peg-JR7BVNR7-Du9hL1Gf.js} +1 -1
- package/dist/public/assets/{railroadDiagram-MRQ6NCDL-CDM2ahQM.js → railroadDiagram-MRQ6NCDL-CS_JnlGN.js} +1 -1
- package/dist/public/assets/{razor-CStezNUn.js → razor-BWj90God.js} +1 -1
- package/dist/public/assets/{requirementDiagram-Y7LWUY3S-hbb6WtfM.js → requirementDiagram-Y7LWUY3S-Cq8rRz2y.js} +1 -1
- package/dist/public/assets/{resolver-0zC31mg5.js → resolver-BPuspqws.js} +1 -1
- package/dist/public/assets/{sankeyDiagram-WGJFYUXA-DLV3Aoae.js → sankeyDiagram-WGJFYUXA-aK7jRBVK.js} +1 -1
- package/dist/public/assets/{sequenceDiagram-5NDRBG5M-BWxOV5U9.js → sequenceDiagram-5NDRBG5M-BxcIyc38.js} +1 -1
- package/dist/public/assets/{stateDiagram-v2-FJ4FJNEA-C-TaUPaQ.js → stateDiagram-v2-FJ4FJNEA-Ctletlj4.js} +1 -1
- package/dist/public/assets/{swimlanes-UMQ2AFYF-CJY0BFmc.js → swimlanes-UMQ2AFYF-DaD55xd2.js} +1 -1
- package/dist/public/assets/swimlanesDiagram-OMPLPG4O-CytCT4x3.js +8 -0
- package/dist/public/assets/{timeline-definition-SEUHKTQE-CUfQb8Gv.js → timeline-definition-SEUHKTQE-Ce19CDiJ.js} +1 -1
- package/dist/public/assets/treeView-D4JQ5SDB-DvzNkX4G.js +1 -0
- package/dist/public/assets/treemap-SAJKECNS-BuUeBmMd.js +1 -0
- package/dist/public/assets/{typescript-B7kmi8MF.js → typescript-RgyfxmPQ.js} +1 -1
- package/dist/public/assets/{usecaseDiagram-AFA6YXN4-BKTVAp-G.js → usecaseDiagram-AFA6YXN4-CAVEBKQS.js} +1 -1
- package/dist/public/assets/{vennDiagram-NNMJR3RB-CN1RxNTS.js → vennDiagram-NNMJR3RB-DHyJxlHv.js} +1 -1
- package/dist/public/assets/wardley-7MLQ67FV-DSfdKACG.js +1 -0
- package/dist/public/assets/{wardleyDiagram-S7YFUSEH-JJ6qcpu1.js → wardleyDiagram-S7YFUSEH-C-FCHxR7.js} +1 -1
- package/dist/public/assets/{xml-DVamlHEU.js → xml-DiA1T3iN.js} +1 -1
- package/dist/public/assets/{xychartDiagram-GGNKY7IX-BNakYgUZ.js → xychartDiagram-GGNKY7IX-BlnHU6Gz.js} +1 -1
- package/dist/public/assets/{yaml-BihGeFrM.js → yaml-dnCcfJBR.js} +1 -1
- package/dist/public/ext/index.json +1 -0
- package/dist/public/ext/ta-3d.js +660 -0
- package/dist/public/ext/ta-glance.js +1611 -0
- package/dist/public/ext/ta-plot.js +1320 -0
- package/dist/public/index.html +2 -2
- package/dist/serve/index.mjs +10558 -7361
- package/package.json +45 -39
- package/dist/public/assets/cynefin-EF2NZ3EQ-Dcc0sCHf.js +0 -1
- package/dist/public/assets/flowDiagram-MALGAFMO-CDXqnHAQ.js +0 -1
- package/dist/public/assets/gitGraph-VSP46ZUC-KPsoB6Z1.js +0 -1
- package/dist/public/assets/info-OHQRW6UA-CtM6s0SQ.js +0 -1
- package/dist/public/assets/module-C-ofp7U4.js +0 -1
- package/dist/public/assets/module-DDH-aU6z.js +0 -1
- package/dist/public/assets/module-DRofmFJn.js +0 -1
- package/dist/public/assets/module-MaD4hvv4.js +0 -1
- package/dist/public/assets/module-ZDJutm0b.js +0 -1
- package/dist/public/assets/module-dnDlIzeV.js +0 -2616
- package/dist/public/assets/module-qoBVcE5h.js +0 -1
- package/dist/public/assets/packet-JDAUHWVQ-XKjiwdar.js +0 -1
- package/dist/public/assets/pie-XZMESJXO-MuCMavHL.js +0 -1
- package/dist/public/assets/radar-ABXABTNO-Cq12GHJS.js +0 -1
- package/dist/public/assets/railroad-I3PHUGI6-CfeMswZU.js +0 -1
- package/dist/public/assets/swimlanesDiagram-OMPLPG4O-DdFDl6aK.js +0 -8
- package/dist/public/assets/treeView-D4JQ5SDB-BQ4uUy4s.js +0 -1
- package/dist/public/assets/treemap-SAJKECNS-BFTTkjF9.js +0 -1
- package/dist/public/assets/wardley-7MLQ67FV-BbyzsA8S.js +0 -1
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
// ../ta-protocol/esm/common/access-protocol.js
|
|
2
|
-
var TaAccessServer = Symbol("TaAccessServer");
|
|
3
|
-
// ../ta-protocol/esm/common/auth-protocol.js
|
|
4
|
-
var TaAuthServer = Symbol("TaAuthServer");
|
|
5
|
-
// ../ta-protocol/esm/common/gateway-protocol.js
|
|
6
|
-
var TaGatewayServer = Symbol("TaGatewayServer");
|
|
7
1
|
// ../ta-protocol/esm/common/language.js
|
|
8
2
|
var TaLanguageUtil;
|
|
9
3
|
(function(TaLanguageUtil2) {
|
|
@@ -42,503 +36,954 @@ var TaLanguageUtil;
|
|
|
42
36
|
}
|
|
43
37
|
TaLanguageUtil2.list = list;
|
|
44
38
|
})(TaLanguageUtil || (TaLanguageUtil = {}));
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
39
|
+
|
|
40
|
+
// ../ta-protocol/esm/common/team-protocol.js
|
|
41
|
+
var TA_OWNER = "owner";
|
|
42
|
+
var TA_UNDECLARED = "extensions.install";
|
|
43
|
+
var TaPermissionUtil;
|
|
44
|
+
(function(TaPermissionUtil2) {
|
|
45
|
+
function read(pi) {
|
|
46
|
+
const given = pi === null || pi === undefined ? undefined : pi.permissions;
|
|
47
|
+
const map = (value) => value && typeof value === "object" && !Array.isArray(value) ? Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === "string")) : undefined;
|
|
48
|
+
const host2 = map(given === null || given === undefined ? undefined : given.host);
|
|
49
|
+
const tools = map(given === null || given === undefined ? undefined : given.tools);
|
|
50
|
+
return { ...host2 ? { host: host2 } : {}, ...tools ? { tools } : {} };
|
|
54
51
|
}
|
|
55
|
-
|
|
56
|
-
function
|
|
57
|
-
|
|
52
|
+
TaPermissionUtil2.read = read;
|
|
53
|
+
function host(manifest, method, kind) {
|
|
54
|
+
var _a, _b, _c, _d;
|
|
55
|
+
const host2 = (_a = manifest === null || manifest === undefined ? undefined : manifest.host) !== null && _a !== undefined ? _a : {};
|
|
56
|
+
const own = (key) => Object.prototype.hasOwnProperty.call(host2, key) ? host2[key] : undefined;
|
|
57
|
+
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;
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
TaPermissionUtil2.host = host;
|
|
60
|
+
})(TaPermissionUtil || (TaPermissionUtil = {}));
|
|
61
|
+
var action = (id, en, zh, tw, ja, more = {}) => ({
|
|
62
|
+
id,
|
|
63
|
+
area: id.split(".")[0],
|
|
64
|
+
title: { en, "zh-CN": zh, ...tw ? { "zh-TW": tw } : {}, ...ja ? { "ja-JP": ja } : {} },
|
|
65
|
+
...more
|
|
66
|
+
});
|
|
67
|
+
var TA_ACTIONS = [
|
|
68
|
+
action("chat.view", "See conversations", "查看对话", "檢視對話", "会話を確認"),
|
|
69
|
+
action("chat.send", "Send in conversations", "在对话里发消息", "在對話裡發訊息", "会話にメッセージを送信"),
|
|
70
|
+
action("chat.create", "Start conversations", "新建对话", "新建對話", "新しい会話を開始"),
|
|
71
|
+
action("chat.stop", "Stop a reply", "停止回复", "停止回覆", "返信を停止"),
|
|
72
|
+
action("chat.manage", "Rename, archive and close conversations", "改名、归档、关闭对话", "改名、歸檔、關閉對話", "会話の名前変更、アーカイブ、クローズ"),
|
|
73
|
+
action("chat.share", "Share by a link", "生成分享链接", "生成分享連結", "共有リンクで共有"),
|
|
74
|
+
action("agent.view", "See agents", "查看智能体", "檢視智慧體", "エージェントを確認"),
|
|
75
|
+
action("agent.use", "Talk with agents", "和智能体对话", "和智慧體對話", "エージェントと対話"),
|
|
76
|
+
action("agent.edit", "Create, change and remove agents", "新建、修改、删除智能体", "新建、修改、刪除智慧體", "エージェントを作成・変更・削除"),
|
|
77
|
+
action("channel.view", "See channels", "查看频道", "檢視頻道", "チャネルを確認"),
|
|
78
|
+
action("channel.post", "Post in channels", "在频道里发言", "在頻道里發言", "チャネルに投稿"),
|
|
79
|
+
action("channel.manage", "Create and change channels", "新建、管理频道", "新建、管理頻道", "チャネルを作成・管理"),
|
|
80
|
+
action("task.view", "See tasks", "查看任务", "檢視任務", "タスクを確認"),
|
|
81
|
+
action("task.create", "Hand out tasks", "派任务", "派任務", "タスクを割り当て"),
|
|
82
|
+
action("task.manage", "Take over and stop tasks", "接管、停止任务", "接管、停止任務", "タスクを引き継ぎ・停止"),
|
|
83
|
+
action("files.read", "Read files", "读文件", "讀檔案", "ファイルを読取", { scoped: true }),
|
|
84
|
+
action("files.write", "Change files", "改文件", "改檔案", "ファイルを変更", { scoped: true }),
|
|
85
|
+
action("commands.run", "Let Ta run commands", "让 Ta 运行命令", "讓 Ta 執行命令", "Ta にコマンド実行を許可", { scoped: true, risky: true }),
|
|
86
|
+
action("commands.terminal", "Open terminals", "打开终端", "開啟終端機", "ターミナルを開く", { scoped: true, risky: true }),
|
|
87
|
+
action("hosts.use", "Use remote hosts", "使用远程主机", "使用遠端主機", "リモートホストを使用", { risky: true }),
|
|
88
|
+
action("models.use", "Use the models", "使用模型", "使用模型", "モデルを使用"),
|
|
89
|
+
action("models.manage", "Sign in to models", "登录和更换模型账号", "登入和更換模型帳號", "モデルアカウントにサインイン・変更"),
|
|
90
|
+
action("cron.view", "See scheduled tasks", "查看定时任务", "檢視定時任務", "スケジュールタスクを確認"),
|
|
91
|
+
action("cron.manage", "Change scheduled tasks", "管理定时任务", "管理定時任務", "スケジュールタスクを管理"),
|
|
92
|
+
action("extensions.use", "Use extensions", "使用扩展", "使用擴充功能", "拡張機能を使用"),
|
|
93
|
+
action("extensions.install", "Install and turn off extensions", "安装、停用扩展", "安裝、停用擴充功能", "拡張機能をインストール・無効化"),
|
|
94
|
+
action("settings.view", "See settings", "查看设置", "檢視設定", "設定を確認"),
|
|
95
|
+
action("settings.manage", "Change settings", "修改设置", "修改設定", "設定を変更"),
|
|
96
|
+
action("members.view", "See members", "查看成员", "檢視成員", "メンバーを確認"),
|
|
97
|
+
action("members.invite", "Invite people", "邀请别人", "邀請別人", "メンバーを招待"),
|
|
98
|
+
action("members.approve", "Answer requests", "处理申请", "處理申請", "リクエストに対応"),
|
|
99
|
+
action("members.roles", "Change roles and members", "管理角色和成员", "管理角色和成員", "ロールとメンバーを管理"),
|
|
100
|
+
action("audit.view", "See the record", "查看记录", "檢視記錄", "レコードを確認")
|
|
101
|
+
];
|
|
102
|
+
var TaActionUtil;
|
|
103
|
+
(function(TaActionUtil2) {
|
|
104
|
+
const byId = new Map(TA_ACTIONS.map((one) => [one.id, one]));
|
|
105
|
+
function info(id) {
|
|
106
|
+
return byId.get(id);
|
|
62
107
|
}
|
|
63
|
-
|
|
64
|
-
function
|
|
65
|
-
|
|
108
|
+
TaActionUtil2.info = info;
|
|
109
|
+
function title(id, language) {
|
|
110
|
+
var _a;
|
|
111
|
+
var _b, _c;
|
|
112
|
+
const title2 = (_a = byId.get(id)) === null || _a === undefined ? undefined : _a.title;
|
|
113
|
+
if (!title2) {
|
|
114
|
+
return id;
|
|
115
|
+
}
|
|
116
|
+
return TaLanguageUtil.pick(language, {
|
|
117
|
+
"zh-CN": title2["zh-CN"],
|
|
118
|
+
"zh-TW": (_b = title2["zh-TW"]) !== null && _b !== undefined ? _b : title2["zh-CN"],
|
|
119
|
+
"en-US": title2.en,
|
|
120
|
+
"ja-JP": (_c = title2["ja-JP"]) !== null && _c !== undefined ? _c : title2.en
|
|
121
|
+
});
|
|
66
122
|
}
|
|
67
|
-
|
|
68
|
-
function
|
|
69
|
-
|
|
70
|
-
|
|
123
|
+
TaActionUtil2.title = title;
|
|
124
|
+
function inside(dir, path) {
|
|
125
|
+
const base = dir.replace(/\/+$/, "");
|
|
126
|
+
return path === base || path.startsWith(`${base}/`) || base === "";
|
|
127
|
+
}
|
|
128
|
+
TaActionUtil2.inside = inside;
|
|
129
|
+
})(TaActionUtil || (TaActionUtil = {}));
|
|
130
|
+
|
|
131
|
+
// ../ta-protocol/esm/common/redactor.js
|
|
132
|
+
var REDACTED = "[redacted]";
|
|
133
|
+
var WHOLE = [
|
|
134
|
+
["PRIVATE_KEY", /-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z0-9 ]*PRIVATE KEY-----/g],
|
|
135
|
+
["API_KEY", /\bsk-(?:ant-|proj-)?[A-Za-z0-9_-]{20,}/g],
|
|
136
|
+
["GITHUB_TOKEN", /\bgh[pousr]_[A-Za-z0-9]{30,}\b/g],
|
|
137
|
+
["GITHUB_TOKEN", /\bgithub_pat_[A-Za-z0-9_]{40,}\b/g],
|
|
138
|
+
["GITLAB_TOKEN", /\bglpat-[A-Za-z0-9_-]{20,}\b/g],
|
|
139
|
+
["SLACK_TOKEN", /\bxox[abprs]-[A-Za-z0-9-]{10,}\b/g],
|
|
140
|
+
["AWS_ACCESS_KEY_ID", /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g],
|
|
141
|
+
["GOOGLE_API_KEY", /\bAIza[0-9A-Za-z_-]{35}\b/g],
|
|
142
|
+
["JWT", /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}/g]
|
|
143
|
+
];
|
|
144
|
+
var NAMED = [
|
|
145
|
+
/(\bBearer\s+)[A-Za-z0-9._~+/-]{16,}=*/gi,
|
|
146
|
+
/(\b[A-Za-z0-9_.-]*(?:password|passwd|pwd|secret|token|api[_-]?key|access[_-]?key|private[_-]?key)[A-Za-z0-9_.-]*["']?\s*[:=]\s*["']?)([^\s"'`,;]{6,})/gi,
|
|
147
|
+
/(:\/\/[^\s:/@]+:)([^\s@/]{3,})(@)/g
|
|
148
|
+
];
|
|
149
|
+
|
|
150
|
+
class Redactor {
|
|
151
|
+
constructor() {
|
|
152
|
+
this.count = 0;
|
|
153
|
+
}
|
|
154
|
+
text(text) {
|
|
155
|
+
let out = text;
|
|
156
|
+
for (const [, pattern] of WHOLE) {
|
|
157
|
+
out = out.replace(pattern, () => this.hide());
|
|
71
158
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
159
|
+
out = out.replace(NAMED[0], (_match, before) => before + this.hide());
|
|
160
|
+
out = out.replace(NAMED[1], (match, before, value) => Redactor.placeholder(value) ? match : before + this.hide());
|
|
161
|
+
out = out.replace(NAMED[2], (_match, before, _value, after) => before + this.hide() + after);
|
|
162
|
+
return out;
|
|
75
163
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (!isRemote(location)) {
|
|
80
|
-
return;
|
|
164
|
+
value(value, max) {
|
|
165
|
+
if (typeof value === "string") {
|
|
166
|
+
return Redactor.cut(this.text(value), max);
|
|
81
167
|
}
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
if (!isCloudName(name)) {
|
|
85
|
-
throw new Error(`${JSON.stringify(location)} names no cloud workspace: write ta://<name>/<path>.`);
|
|
86
|
-
}
|
|
87
|
-
const path3 = location.slice(TaLocation2.CLOUD.length + name.length);
|
|
88
|
-
return { host: `${TaLocation2.CLOUD}${name}`, path: path3 ? normalize(path3) : "" };
|
|
168
|
+
if (Array.isArray(value)) {
|
|
169
|
+
return value.map((item) => this.value(item, max));
|
|
89
170
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const host2 = slash < 0 ? rest : rest.slice(0, slash);
|
|
93
|
-
const path2 = slash < 0 ? "" : normalize(rest.slice(slash));
|
|
94
|
-
if (!isHost(host2)) {
|
|
95
|
-
throw new Error(`${JSON.stringify(location)} names no host: write ssh://<host>/<path>, the host as ssh takes it.`);
|
|
171
|
+
if (value && typeof value === "object") {
|
|
172
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, this.value(item, max)]));
|
|
96
173
|
}
|
|
97
|
-
return
|
|
98
|
-
}
|
|
99
|
-
TaLocation2.parse = parse;
|
|
100
|
-
function isHost(host2) {
|
|
101
|
-
return isCloud(host2) ? isCloudName(host2.slice(TaLocation2.CLOUD.length)) : HOST.test(host2);
|
|
174
|
+
return value;
|
|
102
175
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
let destination;
|
|
111
|
-
let port;
|
|
112
|
-
let user;
|
|
113
|
-
const options = [];
|
|
114
|
-
for (let i = 0;i < words.length; i++) {
|
|
115
|
-
const word = words[i];
|
|
116
|
-
const glued = /^-([pl])(.+)$/.exec(word);
|
|
117
|
-
if (word === "-p" || word === "-l" || glued) {
|
|
118
|
-
const value = glued ? glued[2] : words[++i];
|
|
119
|
-
if (value === undefined) {
|
|
120
|
-
return { error: "invalid" };
|
|
121
|
-
}
|
|
122
|
-
if ((glued ? glued[1] : word[1]) === "p") {
|
|
123
|
-
port = value;
|
|
124
|
-
} else {
|
|
125
|
-
user = value;
|
|
126
|
-
}
|
|
127
|
-
} else if (word === "-o" || word.startsWith("-o")) {
|
|
128
|
-
const value = word === "-o" ? words[++i] : word.slice(2);
|
|
129
|
-
const option = /^(port|user)\s*=?\s*(.+)$/i.exec(value !== null && value !== undefined ? value : "");
|
|
130
|
-
if (!option) {
|
|
131
|
-
options.push(`-o ${value !== null && value !== undefined ? value : ""}`.trim());
|
|
132
|
-
} else if (option[1].toLowerCase() === "port") {
|
|
133
|
-
port = option[2];
|
|
134
|
-
} else {
|
|
135
|
-
user = option[2];
|
|
136
|
-
}
|
|
137
|
-
} else if (FLAGS.test(word)) {} else if (word.startsWith("-")) {
|
|
138
|
-
options.push(/^-[bBcDeEFiIJLmOQRSwW]$/.test(word) && words[i + 1] !== undefined ? `${word} ${words[++i]}` : word);
|
|
139
|
-
} else if (destination === undefined) {
|
|
140
|
-
destination = word;
|
|
141
|
-
} else {
|
|
142
|
-
return { error: "invalid" };
|
|
176
|
+
static spans(text) {
|
|
177
|
+
var _a;
|
|
178
|
+
var _b;
|
|
179
|
+
const found = [];
|
|
180
|
+
for (const [kind, pattern] of WHOLE) {
|
|
181
|
+
for (const match of text.matchAll(pattern)) {
|
|
182
|
+
found.push({ start: match.index, end: match.index + match[0].length, kind });
|
|
143
183
|
}
|
|
144
184
|
}
|
|
145
|
-
|
|
146
|
-
|
|
185
|
+
for (const match of text.matchAll(NAMED[0])) {
|
|
186
|
+
found.push({ start: match.index + match[1].length, end: match.index + match[0].length, kind: "BEARER_TOKEN" });
|
|
147
187
|
}
|
|
148
|
-
|
|
149
|
-
|
|
188
|
+
for (const match of text.matchAll(NAMED[1])) {
|
|
189
|
+
if (!Redactor.placeholder(match[2])) {
|
|
190
|
+
const start = match.index + match[1].length;
|
|
191
|
+
const name = (_b = (_a = /[A-Za-z0-9_.-]+/.exec(match[1])) === null || _a === undefined ? undefined : _a[0]) !== null && _b !== undefined ? _b : "SECRET";
|
|
192
|
+
found.push({ start, end: start + match[2].length, kind: name.replace(/[^A-Za-z0-9]+/g, "_").toUpperCase() });
|
|
193
|
+
}
|
|
150
194
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
195
|
+
for (const match of text.matchAll(NAMED[2])) {
|
|
196
|
+
const start = match.index + match[1].length;
|
|
197
|
+
found.push({ start, end: start + match[2].length, kind: "URL_PASSWORD" });
|
|
154
198
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
199
|
+
found.sort((a, b) => a.start - b.start || b.end - a.end);
|
|
200
|
+
const spans = [];
|
|
201
|
+
for (const span of found) {
|
|
202
|
+
const last = spans.at(-1);
|
|
203
|
+
if (!last || span.start >= last.end) {
|
|
204
|
+
spans.push(span);
|
|
158
205
|
}
|
|
159
|
-
host2 = port === "22" ? host2 : `${host2}:${port}`;
|
|
160
|
-
}
|
|
161
|
-
return isHost(host2) ? { host: host2 } : { error: "invalid" };
|
|
162
|
-
}
|
|
163
|
-
TaLocation2.readHost = readHost;
|
|
164
|
-
function ssh(host2, path2 = "") {
|
|
165
|
-
return isCloud(host2) ? `${host2}${path2 ? normalize(path2) : ""}` : `${TaLocation2.SSH}${host2}${path2 ? normalize(path2) : ""}`;
|
|
166
|
-
}
|
|
167
|
-
TaLocation2.ssh = ssh;
|
|
168
|
-
function hostLabel(host2) {
|
|
169
|
-
if (isCloud(host2)) {
|
|
170
|
-
return host2.slice(TaLocation2.CLOUD.length);
|
|
171
206
|
}
|
|
172
|
-
|
|
173
|
-
return /^[\d.]+$/.test(name) || name.includes(":") ? name : name.split(".")[0] || name;
|
|
207
|
+
return spans;
|
|
174
208
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
var _a;
|
|
178
|
-
return isRemote(location) ? (_a = parse(location)) === null || _a === undefined ? undefined : _a.host : undefined;
|
|
209
|
+
static cut(text, max) {
|
|
210
|
+
return text.length > max ? `${text.slice(0, max)}…` : text;
|
|
179
211
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
var _b;
|
|
184
|
-
return (_b = (_a = parse(location)) === null || _a === undefined ? undefined : _a.path) !== null && _b !== undefined ? _b : location;
|
|
212
|
+
hide() {
|
|
213
|
+
this.count++;
|
|
214
|
+
return REDACTED;
|
|
185
215
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const remote = parse(location);
|
|
189
|
-
if (remote) {
|
|
190
|
-
const above = remote.path ? parentPath(remote.path) : undefined;
|
|
191
|
-
return above === undefined ? undefined : ssh(remote.host, above);
|
|
192
|
-
}
|
|
193
|
-
return parentPath(location);
|
|
216
|
+
static placeholder(value) {
|
|
217
|
+
return /^(?:\$|<|\{|\[redacted|process\.env|os\.environ|xxx|\*{3})/i.test(value) || /^(?:true|false|null|undefined|none|string|number)$/i.test(value);
|
|
194
218
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// ../ta-relay/esm/common/relay-card.js
|
|
222
|
+
var RELAY_AGENT_KIND = "ta-agent";
|
|
223
|
+
var RelayAgentCards;
|
|
224
|
+
(function(RelayAgentCards2) {
|
|
225
|
+
const MAX_ROLE = 8000;
|
|
226
|
+
function parse(data) {
|
|
227
|
+
try {
|
|
228
|
+
const card = JSON.parse(typeof data === "string" ? data : new TextDecoder().decode(data));
|
|
229
|
+
if ((card === null || card === undefined ? undefined : card.v) !== 1 || typeof card.name !== "string" || !card.name.trim() || typeof card.role !== "string" || !card.role.trim()) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
const color = typeof card.color === "string" && /^#[0-9a-fA-F]{6}$/.test(card.color) ? card.color : undefined;
|
|
233
|
+
return {
|
|
234
|
+
v: 1,
|
|
235
|
+
name: card.name.trim().slice(0, 32),
|
|
236
|
+
role: card.role.trim().slice(0, MAX_ROLE),
|
|
237
|
+
mark: typeof card.mark === "string" && card.mark.trim() ? card.mark.trim().slice(0, 2) : card.name.trim().slice(0, 1).toUpperCase(),
|
|
238
|
+
...Number.isInteger(card.face) ? { face: card.face } : {},
|
|
239
|
+
...color ? { color } : {},
|
|
240
|
+
...typeof card.redacted === "number" && card.redacted > 0 ? { redacted: card.redacted } : {}
|
|
241
|
+
};
|
|
242
|
+
} catch (_a) {
|
|
243
|
+
return;
|
|
200
244
|
}
|
|
201
|
-
return childPath(location, name);
|
|
202
245
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
246
|
+
RelayAgentCards2.parse = parse;
|
|
247
|
+
})(RelayAgentCards || (RelayAgentCards = {}));
|
|
248
|
+
|
|
249
|
+
// web-src/channels-model.ts
|
|
250
|
+
var NAME = "@celljs/ta-channels";
|
|
251
|
+
var AGENT_MARK = "one of the agents of Ta";
|
|
252
|
+
var MEMBER_CHANGES = ["lead", "remove", "mute", "unmute"];
|
|
253
|
+
var Keys;
|
|
254
|
+
((Keys) => {
|
|
255
|
+
Keys.TEAM = "team";
|
|
256
|
+
Keys.QUEUE = "queue";
|
|
257
|
+
Keys.WORKING = "working";
|
|
258
|
+
Keys.FOCUS = "focus";
|
|
259
|
+
Keys.ANSWERED = "answered";
|
|
260
|
+
Keys.CARDS = "cards";
|
|
261
|
+
Keys.MESSAGES = "messages/";
|
|
262
|
+
Keys.messages = (channelId) => `${Keys.MESSAGES}${channelId}`;
|
|
263
|
+
})(Keys ||= {});
|
|
264
|
+
var USER = "user";
|
|
265
|
+
var TA = "ta";
|
|
266
|
+
var SYSTEM = "system";
|
|
267
|
+
var MAX_HOPS = 3;
|
|
268
|
+
var MAX_REPLIES = 8;
|
|
269
|
+
var MAX_AGENT_REPLIES = 2;
|
|
270
|
+
var STOP_NOTE = "The agents stopped handing on here, at the limit of a round; it is your turn.";
|
|
271
|
+
var MAX_MESSAGES = 200;
|
|
272
|
+
var FACES = 16;
|
|
273
|
+
var MAX_MEMBERS = 12;
|
|
274
|
+
var CONTEXT_MESSAGES = 12;
|
|
275
|
+
var MAX_NAME = 32;
|
|
276
|
+
var MAX_NOTICE = 2000;
|
|
277
|
+
var NOTICE_HEADINGS = { zh: ["决定", "约定", "待办"], en: ["Decisions", "Conventions", "To do"] };
|
|
278
|
+
var CARD_DAYS = 30;
|
|
279
|
+
|
|
280
|
+
// web-src/channels-util.ts
|
|
281
|
+
var ChannelsUtil;
|
|
282
|
+
((ChannelsUtil) => {
|
|
283
|
+
function newRound() {
|
|
284
|
+
return { total: 0, byAgent: {}, stopped: false };
|
|
209
285
|
}
|
|
210
|
-
|
|
211
|
-
function
|
|
212
|
-
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
|
|
286
|
+
ChannelsUtil.newRound = newRound;
|
|
287
|
+
function limit(round, targets, hops) {
|
|
288
|
+
const allowed = [];
|
|
289
|
+
const byAgent = { ...round.byAgent };
|
|
290
|
+
let total = round.total;
|
|
291
|
+
for (const id of targets) {
|
|
292
|
+
if (hops < MAX_HOPS && total < MAX_REPLIES && (byAgent[id] ?? 0) < MAX_AGENT_REPLIES) {
|
|
293
|
+
allowed.push(id);
|
|
294
|
+
byAgent[id] = (byAgent[id] ?? 0) + 1;
|
|
295
|
+
total++;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
const cut = allowed.length < targets.length;
|
|
299
|
+
const note = cut && !round.stopped;
|
|
300
|
+
return { allowed, round: { total, byAgent, stopped: round.stopped || cut }, cut, note };
|
|
217
301
|
}
|
|
218
|
-
|
|
219
|
-
function
|
|
220
|
-
|
|
221
|
-
|
|
302
|
+
ChannelsUtil.limit = limit;
|
|
303
|
+
function emptyTeam() {
|
|
304
|
+
return { agents: [], channels: [] };
|
|
305
|
+
}
|
|
306
|
+
ChannelsUtil.emptyTeam = emptyTeam;
|
|
307
|
+
function newId(prefix) {
|
|
308
|
+
return `${prefix}-${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
|
|
309
|
+
}
|
|
310
|
+
ChannelsUtil.newId = newId;
|
|
311
|
+
function checkName(value, what) {
|
|
312
|
+
const name = typeof value === "string" ? value.trim().replace(/^[@#]+/, "").replace(/\s+/g, "-") : "";
|
|
313
|
+
if (!name || name.length > MAX_NAME || /[@#,]/.test(name)) {
|
|
314
|
+
throw new Error(`The name of the ${what} must be 1 to ${MAX_NAME} characters, without @, # or commas.`);
|
|
222
315
|
}
|
|
223
|
-
return
|
|
316
|
+
return name;
|
|
224
317
|
}
|
|
225
|
-
|
|
226
|
-
function
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
return;
|
|
318
|
+
ChannelsUtil.checkName = checkName;
|
|
319
|
+
function mark(name) {
|
|
320
|
+
const first = Array.from(name)[0] ?? "?";
|
|
321
|
+
if (!/[A-Za-z0-9]/.test(first)) {
|
|
322
|
+
return first;
|
|
231
323
|
}
|
|
232
|
-
const
|
|
233
|
-
return
|
|
324
|
+
const words = name.split(/[-_.\s]+|(?<=[a-z])(?=[A-Z])/).filter(Boolean);
|
|
325
|
+
return words.length > 1 ? (words[0][0] + words[1][0]).toUpperCase() : first.toUpperCase();
|
|
234
326
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
327
|
+
ChannelsUtil.mark = mark;
|
|
328
|
+
function faces(agents) {
|
|
329
|
+
const result = new Map;
|
|
330
|
+
const taken = new Set;
|
|
331
|
+
for (const agent of agents) {
|
|
332
|
+
if (isFace(agent.face)) {
|
|
333
|
+
result.set(agent.id, agent.face);
|
|
334
|
+
taken.add(agent.face);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
for (const agent of agents) {
|
|
338
|
+
if (!result.has(agent.id)) {
|
|
339
|
+
const face = freeFace(hash(agent.id), taken);
|
|
340
|
+
result.set(agent.id, face);
|
|
341
|
+
taken.add(face);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return result;
|
|
345
|
+
}
|
|
346
|
+
ChannelsUtil.faces = faces;
|
|
347
|
+
function isFace(face) {
|
|
348
|
+
return typeof face === "number" && Number.isInteger(face) && face >= 0 && face < FACES;
|
|
349
|
+
}
|
|
350
|
+
ChannelsUtil.isFace = isFace;
|
|
351
|
+
function freeFaceFor(agents, seed) {
|
|
352
|
+
return freeFace(hash(seed), new Set(faces(agents).values()));
|
|
353
|
+
}
|
|
354
|
+
ChannelsUtil.freeFaceFor = freeFaceFor;
|
|
355
|
+
function freeName(team, base) {
|
|
356
|
+
let name = base;
|
|
357
|
+
for (let count = 2;findAgent(team, name); count++) {
|
|
358
|
+
name = `${base}-${count}`;
|
|
359
|
+
}
|
|
360
|
+
return name;
|
|
361
|
+
}
|
|
362
|
+
ChannelsUtil.freeName = freeName;
|
|
363
|
+
function freeFace(start, taken) {
|
|
364
|
+
for (let step = 0;step < FACES; step++) {
|
|
365
|
+
const face = (start + step) % FACES;
|
|
366
|
+
if (!taken.has(face)) {
|
|
367
|
+
return face;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return start % FACES;
|
|
371
|
+
}
|
|
372
|
+
function hash(text) {
|
|
373
|
+
let value = 2166136261;
|
|
374
|
+
for (let index = 0;index < text.length; index++) {
|
|
375
|
+
value = Math.imul(value ^ text.charCodeAt(index), 16777619);
|
|
376
|
+
}
|
|
377
|
+
return value >>> 0;
|
|
378
|
+
}
|
|
379
|
+
ChannelsUtil.hash = hash;
|
|
380
|
+
function findAgent(team, ref) {
|
|
381
|
+
const key = ref.trim().replace(/^@/, "").toLowerCase();
|
|
382
|
+
return team.agents.find((agent) => agent.id === ref) ?? team.agents.find((agent) => agent.name.toLowerCase() === key);
|
|
383
|
+
}
|
|
384
|
+
ChannelsUtil.findAgent = findAgent;
|
|
385
|
+
function findChannel(team, ref) {
|
|
386
|
+
const key = ref.trim().replace(/^#/, "").toLowerCase();
|
|
387
|
+
return team.channels.find((channel) => channel.id === ref) ?? team.channels.find((channel) => channel.name.toLowerCase() === key);
|
|
388
|
+
}
|
|
389
|
+
ChannelsUtil.findChannel = findChannel;
|
|
390
|
+
function directory(value) {
|
|
391
|
+
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
392
|
+
}
|
|
393
|
+
ChannelsUtil.directory = directory;
|
|
394
|
+
function addAgent(team, input) {
|
|
395
|
+
const name = checkName(input.name, "agent");
|
|
396
|
+
if (findAgent(team, name)) {
|
|
397
|
+
throw new Error(`There is an agent named ${name} already.`);
|
|
398
|
+
}
|
|
399
|
+
const role = typeof input.role === "string" ? input.role.trim() : "";
|
|
400
|
+
if (!role) {
|
|
401
|
+
throw new Error(`Say what ${name} does: its role.`);
|
|
402
|
+
}
|
|
403
|
+
const cwd = directory(input.cwd);
|
|
404
|
+
const id = newId("agent");
|
|
405
|
+
const face = isFace(input.face) ? input.face : freeFace(hash(id), new Set(faces(team.agents).values()));
|
|
406
|
+
const agent = { id, name, role, mark: mark(name), face, cwd, ...input.temporary ? { temporary: true } : {}, createdAt: Date.now() };
|
|
407
|
+
return { team: { ...team, agents: [...team.agents, agent] }, agent };
|
|
408
|
+
}
|
|
409
|
+
ChannelsUtil.addAgent = addAgent;
|
|
410
|
+
function addChannel(team, input) {
|
|
411
|
+
const name = checkName(input.name, "channel");
|
|
412
|
+
if (findChannel(team, name)) {
|
|
413
|
+
throw new Error(`There is a channel named ${name} already.`);
|
|
414
|
+
}
|
|
415
|
+
const members = agentIds(team, input.members);
|
|
416
|
+
if (members.length === 0) {
|
|
417
|
+
throw new Error("A channel needs at least one agent.");
|
|
418
|
+
}
|
|
419
|
+
if (members.length > MAX_MEMBERS) {
|
|
420
|
+
throw new Error(`A channel holds at most ${MAX_MEMBERS} agents.`);
|
|
421
|
+
}
|
|
422
|
+
const topic = typeof input.topic === "string" && input.topic.trim() ? input.topic.trim() : undefined;
|
|
423
|
+
const channel = {
|
|
424
|
+
id: newId("channel"),
|
|
425
|
+
name,
|
|
426
|
+
topic,
|
|
427
|
+
members,
|
|
428
|
+
...input.by ? { by: input.by } : {},
|
|
429
|
+
...input.origin ? { origin: input.origin } : {},
|
|
430
|
+
createdAt: Date.now()
|
|
431
|
+
};
|
|
432
|
+
return { team: { ...team, channels: [...team.channels, channel] }, channel };
|
|
433
|
+
}
|
|
434
|
+
ChannelsUtil.addChannel = addChannel;
|
|
435
|
+
function addMembers(team, input) {
|
|
436
|
+
const found = channelOf(team, input.channel);
|
|
437
|
+
const ids = agentIds(team, input.members);
|
|
438
|
+
if (ids.length === 0) {
|
|
439
|
+
throw new Error("Name at least one agent to add.");
|
|
440
|
+
}
|
|
441
|
+
const added = ids.filter((id) => !found.members.includes(id)).map((id) => team.agents.find((agent) => agent.id === id));
|
|
442
|
+
if (found.members.length + added.length > MAX_MEMBERS) {
|
|
443
|
+
throw new Error(`A channel holds at most ${MAX_MEMBERS} agents; #${found.name} has ${found.members.length}.`);
|
|
444
|
+
}
|
|
445
|
+
const channel = { ...found, members: [...found.members, ...added.map((agent) => agent.id)] };
|
|
446
|
+
return { team: { ...team, channels: team.channels.map((other) => other.id === channel.id ? channel : other) }, channel, added };
|
|
447
|
+
}
|
|
448
|
+
ChannelsUtil.addMembers = addMembers;
|
|
449
|
+
function channelOf(team, ref) {
|
|
450
|
+
const key = typeof ref === "string" ? ref : "";
|
|
451
|
+
const found = findChannel(team, key);
|
|
452
|
+
if (!found) {
|
|
453
|
+
const known = team.channels.map((other) => `#${other.name}`).join(", ") || "none yet";
|
|
454
|
+
throw new Error(`No channel is named ${key}. The channels: ${known}.`);
|
|
455
|
+
}
|
|
456
|
+
return found;
|
|
457
|
+
}
|
|
458
|
+
ChannelsUtil.channelOf = channelOf;
|
|
459
|
+
function changeMember(team, input) {
|
|
460
|
+
const found = channelOf(team, input.channel);
|
|
461
|
+
const agent = findAgent(team, typeof input.agent === "string" ? input.agent : "");
|
|
462
|
+
if (!agent || !found.members.includes(agent.id)) {
|
|
463
|
+
throw new Error(`${agent?.name ?? String(input.agent)} is not a member of #${found.name}.`);
|
|
464
|
+
}
|
|
465
|
+
if (typeof input.change !== "string" || !MEMBER_CHANGES.includes(input.change)) {
|
|
466
|
+
throw new Error(`A member is changed with one of ${MEMBER_CHANGES.join(", ")}.`);
|
|
467
|
+
}
|
|
468
|
+
const others = found.members.filter((id) => id !== agent.id);
|
|
469
|
+
const muted = (found.muted ?? []).filter((id) => id !== agent.id);
|
|
470
|
+
let channel;
|
|
471
|
+
switch (input.change) {
|
|
472
|
+
case "lead":
|
|
473
|
+
channel = { ...found, members: [agent.id, ...others] };
|
|
474
|
+
break;
|
|
475
|
+
case "remove":
|
|
476
|
+
if (others.length === 0) {
|
|
477
|
+
throw new Error(`${agent.name} is the only member of #${found.name}: delete the channel instead.`);
|
|
478
|
+
}
|
|
479
|
+
channel = { ...found, members: others, muted };
|
|
480
|
+
break;
|
|
481
|
+
case "mute":
|
|
482
|
+
channel = { ...found, muted: [...muted, agent.id] };
|
|
483
|
+
break;
|
|
484
|
+
default:
|
|
485
|
+
channel = { ...found, muted };
|
|
486
|
+
}
|
|
487
|
+
if (channel.muted?.length === 0) {
|
|
488
|
+
delete channel.muted;
|
|
489
|
+
}
|
|
490
|
+
return { team: { ...team, channels: team.channels.map((other) => other.id === channel.id ? channel : other) }, channel };
|
|
491
|
+
}
|
|
492
|
+
ChannelsUtil.changeMember = changeMember;
|
|
493
|
+
function updateChannel(team, input) {
|
|
494
|
+
const before = channelOf(team, input.channel);
|
|
495
|
+
const channel = { ...before };
|
|
496
|
+
if (input.name !== undefined) {
|
|
497
|
+
const name = checkName(input.name, "channel");
|
|
498
|
+
const other = findChannel(team, name);
|
|
499
|
+
if (other && other.id !== channel.id) {
|
|
500
|
+
throw new Error(`There is a channel named ${name} already.`);
|
|
501
|
+
}
|
|
502
|
+
channel.name = name;
|
|
503
|
+
}
|
|
504
|
+
if (input.topic !== undefined) {
|
|
505
|
+
const topic = typeof input.topic === "string" ? input.topic.trim() : "";
|
|
506
|
+
if (topic) {
|
|
507
|
+
channel.topic = topic;
|
|
508
|
+
} else {
|
|
509
|
+
delete channel.topic;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
if (input.pinned !== undefined) {
|
|
513
|
+
if (input.pinned === true) {
|
|
514
|
+
channel.pinned = true;
|
|
515
|
+
} else {
|
|
516
|
+
delete channel.pinned;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
return { team: { ...team, channels: team.channels.map((other) => other.id === channel.id ? channel : other) }, channel, before };
|
|
520
|
+
}
|
|
521
|
+
ChannelsUtil.updateChannel = updateChannel;
|
|
522
|
+
function standing(team) {
|
|
523
|
+
const inChannel = new Set(team.channels.flatMap((channel) => channel.members));
|
|
524
|
+
return team.agents.filter((agent) => !agent.temporary || !inChannel.has(agent.id));
|
|
525
|
+
}
|
|
526
|
+
ChannelsUtil.standing = standing;
|
|
527
|
+
function taskChannels(team) {
|
|
528
|
+
return team.channels.filter((channel) => channel.by === "ta");
|
|
529
|
+
}
|
|
530
|
+
ChannelsUtil.taskChannels = taskChannels;
|
|
531
|
+
function ownChannels(team) {
|
|
532
|
+
return team.channels.filter((channel) => channel.by !== "ta");
|
|
533
|
+
}
|
|
534
|
+
ChannelsUtil.ownChannels = ownChannels;
|
|
535
|
+
function pinnedFirst(items) {
|
|
536
|
+
return [...items.filter((item) => item.pinned), ...items.filter((item) => !item.pinned)];
|
|
537
|
+
}
|
|
538
|
+
ChannelsUtil.pinnedFirst = pinnedFirst;
|
|
539
|
+
function removeChannel(team, ref) {
|
|
540
|
+
const channel = channelOf(team, ref);
|
|
541
|
+
return { team: { ...team, channels: team.channels.filter((other) => other.id !== channel.id) }, channel };
|
|
542
|
+
}
|
|
543
|
+
ChannelsUtil.removeChannel = removeChannel;
|
|
544
|
+
function resetAgent(team, ref) {
|
|
545
|
+
const found = findAgent(team, typeof ref === "string" ? ref : "");
|
|
546
|
+
if (!found) {
|
|
547
|
+
throw new Error(`No agent is ${String(ref)}.`);
|
|
548
|
+
}
|
|
549
|
+
const { sessionFile: _gone, ...agent } = found;
|
|
550
|
+
return { team: { ...team, agents: team.agents.map((other) => other.id === agent.id ? agent : other) }, agent };
|
|
551
|
+
}
|
|
552
|
+
ChannelsUtil.resetAgent = resetAgent;
|
|
553
|
+
function updateAgent(team, input) {
|
|
554
|
+
const before = findAgent(team, typeof input.agent === "string" ? input.agent : "");
|
|
555
|
+
if (!before) {
|
|
556
|
+
throw new Error(`No agent is ${String(input.agent)}.`);
|
|
557
|
+
}
|
|
558
|
+
const agent = { ...before };
|
|
559
|
+
if (input.name !== undefined) {
|
|
560
|
+
const name = checkName(input.name, "agent");
|
|
561
|
+
const other = findAgent(team, name);
|
|
562
|
+
if (other && other.id !== agent.id) {
|
|
563
|
+
throw new Error(`There is an agent named ${name} already.`);
|
|
564
|
+
}
|
|
565
|
+
agent.name = name;
|
|
566
|
+
agent.mark = mark(name);
|
|
567
|
+
}
|
|
568
|
+
if (input.role !== undefined) {
|
|
569
|
+
const role = typeof input.role === "string" ? input.role.trim() : "";
|
|
570
|
+
if (!role) {
|
|
571
|
+
throw new Error(`Say what ${agent.name} does: its role.`);
|
|
572
|
+
}
|
|
573
|
+
agent.role = role;
|
|
574
|
+
}
|
|
575
|
+
if (input.face !== undefined) {
|
|
576
|
+
if (!isFace(input.face)) {
|
|
577
|
+
throw new Error(`A face is a number from 0 to ${FACES - 1}.`);
|
|
578
|
+
}
|
|
579
|
+
agent.face = input.face;
|
|
580
|
+
}
|
|
581
|
+
if (input.keep === true) {
|
|
582
|
+
delete agent.temporary;
|
|
583
|
+
}
|
|
584
|
+
if (input.pinned === true) {
|
|
585
|
+
agent.pinned = true;
|
|
586
|
+
} else if (input.pinned !== undefined) {
|
|
587
|
+
delete agent.pinned;
|
|
588
|
+
}
|
|
589
|
+
if (input.cwd !== undefined) {
|
|
590
|
+
const cwd = typeof input.cwd === "string" && input.cwd.trim() ? input.cwd.trim() : undefined;
|
|
591
|
+
if (cwd !== before.cwd) {
|
|
592
|
+
agent.cwd = cwd;
|
|
593
|
+
delete agent.sessionFile;
|
|
594
|
+
}
|
|
595
|
+
if (!cwd) {
|
|
596
|
+
delete agent.cwd;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
return { team: { ...team, agents: team.agents.map((other) => other.id === agent.id ? agent : other) }, agent, before };
|
|
600
|
+
}
|
|
601
|
+
ChannelsUtil.updateAgent = updateAgent;
|
|
602
|
+
function removeAgent(team, ref) {
|
|
603
|
+
const agent = findAgent(team, typeof ref === "string" ? ref : "");
|
|
604
|
+
if (!agent) {
|
|
605
|
+
throw new Error(`No agent is ${String(ref)}.`);
|
|
606
|
+
}
|
|
607
|
+
const gone = [];
|
|
608
|
+
const channels = [];
|
|
609
|
+
for (const channel of team.channels) {
|
|
610
|
+
if (!channel.members.includes(agent.id)) {
|
|
611
|
+
channels.push(channel);
|
|
612
|
+
continue;
|
|
613
|
+
}
|
|
614
|
+
const members = channel.members.filter((id) => id !== agent.id);
|
|
615
|
+
if (members.length === 0) {
|
|
616
|
+
gone.push(channel);
|
|
617
|
+
continue;
|
|
618
|
+
}
|
|
619
|
+
const muted = channel.muted?.filter((id) => id !== agent.id);
|
|
620
|
+
const next = { ...channel, members, muted };
|
|
621
|
+
if (!muted?.length) {
|
|
622
|
+
delete next.muted;
|
|
623
|
+
}
|
|
624
|
+
channels.push(next);
|
|
625
|
+
}
|
|
626
|
+
return { team: { agents: team.agents.filter((other) => other.id !== agent.id), channels }, agent, channels: gone };
|
|
627
|
+
}
|
|
628
|
+
ChannelsUtil.removeAgent = removeAgent;
|
|
629
|
+
function agentIds(team, refs) {
|
|
630
|
+
const ids = [];
|
|
631
|
+
for (const ref of Array.isArray(refs) ? refs.filter((item) => typeof item === "string") : []) {
|
|
632
|
+
const agent = findAgent(team, ref);
|
|
633
|
+
if (!agent) {
|
|
634
|
+
const known = team.agents.map((other) => other.name).join(", ") || "none yet";
|
|
635
|
+
throw new Error(`No agent is named ${ref}. The agents: ${known}.`);
|
|
636
|
+
}
|
|
637
|
+
if (!ids.includes(agent.id)) {
|
|
638
|
+
ids.push(agent.id);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
return ids;
|
|
642
|
+
}
|
|
643
|
+
function setNotice(team, input) {
|
|
644
|
+
const before = channelOf(team, input.channel);
|
|
645
|
+
const text = typeof input.text === "string" ? input.text.replace(/\r\n/g, `
|
|
646
|
+
`).trim() : "";
|
|
647
|
+
if (text.length > MAX_NOTICE) {
|
|
648
|
+
throw new Error(`The notice is too long (${text.length} characters, ${MAX_NOTICE} at most): keep it short, and drop to-dos done long ago.`);
|
|
649
|
+
}
|
|
650
|
+
if (text === (before.notice?.text ?? "")) {
|
|
651
|
+
return { team, channel: before, before, changed: false };
|
|
652
|
+
}
|
|
653
|
+
const channel = { ...before };
|
|
654
|
+
if (text) {
|
|
655
|
+
channel.notice = { text, at: input.at ?? Date.now(), by: input.by };
|
|
656
|
+
} else {
|
|
657
|
+
delete channel.notice;
|
|
658
|
+
}
|
|
659
|
+
return { team: { ...team, channels: team.channels.map((other) => other.id === channel.id ? channel : other) }, channel, before, changed: true };
|
|
238
660
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
661
|
+
ChannelsUtil.setNotice = setNotice;
|
|
662
|
+
function append(messages, message) {
|
|
663
|
+
const next = [...messages, message];
|
|
664
|
+
return next.length > MAX_MESSAGES ? next.slice(next.length - MAX_MESSAGES) : next;
|
|
242
665
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
|
|
666
|
+
ChannelsUtil.append = append;
|
|
667
|
+
})(ChannelsUtil ||= {});
|
|
668
|
+
|
|
669
|
+
// web-src/agent-cards.ts
|
|
670
|
+
var AgentCards;
|
|
671
|
+
((AgentCards) => {
|
|
672
|
+
AgentCards.KIND = RELAY_AGENT_KIND;
|
|
673
|
+
AgentCards.MARK = "[ta-channels:card]";
|
|
674
|
+
function card(agent, color) {
|
|
675
|
+
const redactor = new Redactor;
|
|
676
|
+
const role = redactor.text(agent.role);
|
|
677
|
+
return {
|
|
678
|
+
v: 1,
|
|
679
|
+
name: agent.name,
|
|
680
|
+
role,
|
|
681
|
+
mark: agent.mark,
|
|
682
|
+
...agent.face !== undefined ? { face: agent.face } : {},
|
|
683
|
+
...color && /^#[0-9a-fA-F]{6}$/.test(color) ? { color } : {},
|
|
684
|
+
...redactor.count ? { redacted: redactor.count } : {}
|
|
685
|
+
};
|
|
256
686
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
var TaServer = Symbol("TaServer");
|
|
261
|
-
var TaClient = Symbol("TaClient");
|
|
262
|
-
var TaErrorCode = {
|
|
263
|
-
SESSION_NOT_FOUND: "CELL_TA_SESSION_NOT_FOUND",
|
|
264
|
-
SESSION_LOCKED: "CELL_TA_SESSION_LOCKED",
|
|
265
|
-
TOO_MANY_SESSIONS: "CELL_TA_TOO_MANY_SESSIONS",
|
|
266
|
-
MESSAGE_CONFLICT: "CELL_TA_MESSAGE_CONFLICT",
|
|
267
|
-
MODEL_NOT_FOUND: "CELL_TA_MODEL_NOT_FOUND",
|
|
268
|
-
INVALID_ARGUMENT: "CELL_TA_INVALID_ARGUMENT",
|
|
269
|
-
COMMAND_FAILED: "CELL_TA_COMMAND_FAILED",
|
|
270
|
-
NOTHING_TO_COMPACT: "CELL_TA_NOTHING_TO_COMPACT",
|
|
271
|
-
ALREADY_COMPACTED: "CELL_TA_ALREADY_COMPACTED",
|
|
272
|
-
SESSION_BUSY: "CELL_TA_SESSION_BUSY",
|
|
273
|
-
CANCELLED: "CELL_TA_CANCELLED",
|
|
274
|
-
NOT_SIGNED_IN: "CELL_TA_NOT_SIGNED_IN",
|
|
275
|
-
ENVIRONMENT_FAILED: "CELL_TA_ENVIRONMENT_FAILED",
|
|
276
|
-
RATE_LIMITED: "CELL_TA_RATE_LIMITED",
|
|
277
|
-
FORBIDDEN: "CELL_TA_FORBIDDEN",
|
|
278
|
-
LIMIT: "CELL_TA_LIMIT",
|
|
279
|
-
CONNECTION_LOST: "CELL_TA_CONNECTION_LOST"
|
|
280
|
-
};
|
|
281
|
-
var TaErrorUtil;
|
|
282
|
-
(function(TaErrorUtil2) {
|
|
283
|
-
function code(error) {
|
|
284
|
-
var _a;
|
|
285
|
-
var _b;
|
|
286
|
-
const failure = error;
|
|
287
|
-
const code2 = (_b = failure === null || failure === undefined ? undefined : failure.code) !== null && _b !== undefined ? _b : (_a = failure === null || failure === undefined ? undefined : failure.data) === null || _a === undefined ? undefined : _a.code;
|
|
288
|
-
return typeof code2 === "string" ? code2 : undefined;
|
|
687
|
+
AgentCards.card = card;
|
|
688
|
+
function parse(data) {
|
|
689
|
+
return RelayAgentCards.parse(data);
|
|
289
690
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
(
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
691
|
+
AgentCards.parse = parse;
|
|
692
|
+
function freeName(team, name) {
|
|
693
|
+
const base = (name.trim().replace(/\s+/g, "-") || "agent").slice(0, MAX_NAME - 3);
|
|
694
|
+
if (!ChannelsUtil.findAgent(team, base)) {
|
|
695
|
+
return base;
|
|
696
|
+
}
|
|
697
|
+
for (let n = 2;; n++) {
|
|
698
|
+
if (!ChannelsUtil.findAgent(team, `${base}-${n}`)) {
|
|
699
|
+
return `${base}-${n}`;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
298
702
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
703
|
+
AgentCards.freeName = freeName;
|
|
704
|
+
function adapt(cwd, language) {
|
|
705
|
+
const context = [
|
|
706
|
+
AgentCards.MARK,
|
|
707
|
+
`You were just added to this Ta from a card someone shared: the role in your instructions is theirs, written for their own work. Fit it to the project of your directory (${cwd}): look at it first (its README, manifests such as package.json, its layout, how it builds and tests), then rewrite your role for it, keeping what you are for, and save it with update_my_role. Then tell the user in a few sentences, in ${TaLanguageUtil.pick(language, { "zh-CN": "Chinese", "zh-TW": "Traditional Chinese", "en-US": "English", "ja-JP": "Japanese" })}, what you changed and what you can do here. Change no files.`
|
|
708
|
+
].join(`
|
|
709
|
+
`);
|
|
305
710
|
return `<context>
|
|
306
711
|
${context}
|
|
307
712
|
</context>
|
|
308
|
-
${
|
|
309
|
-
}
|
|
310
|
-
TaMessageContext2.wrap = wrap;
|
|
311
|
-
function strip(message) {
|
|
312
|
-
return message.replace(BLOCK, "");
|
|
313
|
-
}
|
|
314
|
-
TaMessageContext2.strip = strip;
|
|
315
|
-
function read(message) {
|
|
316
|
-
var _a;
|
|
317
|
-
const block = (_a = BLOCK.exec(message)) === null || _a === undefined ? undefined : _a[0];
|
|
318
|
-
return block === null || block === undefined ? undefined : block.replace(/^<context>\n?/, "").replace(/\n?<\/context>\n?$/, "");
|
|
319
|
-
}
|
|
320
|
-
TaMessageContext2.read = read;
|
|
321
|
-
})(TaMessageContext || (TaMessageContext = {}));
|
|
322
|
-
var TaMessageSource;
|
|
323
|
-
(function(TaMessageSource2) {
|
|
324
|
-
TaMessageSource2.DOUBLE = "ta:double";
|
|
325
|
-
const LINE = /^\[ta:from ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
|
|
326
|
-
function mark(message, from, detail) {
|
|
327
|
-
if (/^[/!]/.test(message) || of(message)) {
|
|
328
|
-
return message;
|
|
329
|
-
}
|
|
330
|
-
const line = `[ta:from ${from}${detail ? ` ${detail.replace(/[\]\n]/g, " ")}` : ""}]`;
|
|
331
|
-
const context = TaMessageContext.read(message);
|
|
332
|
-
return TaMessageContext.wrap(context === undefined ? line : `${context}
|
|
333
|
-
${line}`, TaMessageContext.strip(message));
|
|
713
|
+
${TaLanguageUtil.pick(language, { "zh-CN": "看看这个项目,把你的职责调整得贴合这里", "zh-TW": "看看這個專案,把你的職責調整得貼合這裡", "en-US": "Look at this project and fit your role to it", "ja-JP": "このプロジェクトを見て、ロールをそれに適応させてください" })}`;
|
|
334
714
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
var TaImageNote;
|
|
344
|
-
(function(TaImageNote2) {
|
|
345
|
-
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 [^\]]+\.\]$/;
|
|
346
|
-
function strip(text) {
|
|
347
|
-
const lines = text.split(`
|
|
348
|
-
`);
|
|
349
|
-
const kept = lines.filter((line) => !NOTE.test(line.trim()));
|
|
350
|
-
if (kept.length === lines.length) {
|
|
715
|
+
AgentCards.adapt = adapt;
|
|
716
|
+
})(AgentCards ||= {});
|
|
717
|
+
|
|
718
|
+
// web-src/channels-text.ts
|
|
719
|
+
var ChannelsText;
|
|
720
|
+
((ChannelsText) => {
|
|
721
|
+
function markMentions(text, agents) {
|
|
722
|
+
if (agents.length === 0) {
|
|
351
723
|
return text;
|
|
352
724
|
}
|
|
353
|
-
|
|
354
|
-
`).
|
|
725
|
+
const names = [...agents].sort((a, b) => b.name.length - a.name.length).map((agent) => agent.name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
|
|
726
|
+
const pattern = new RegExp(`(?<![*A-Za-z0-9_])@(${names.join("|")})(?![A-Za-z0-9_-])`, "gi");
|
|
727
|
+
return text.split(/(```[\s\S]*?(?:```|$)|`[^`\n]*`)/).map((part, index) => index % 2 === 1 ? part : part.replace(pattern, "**$&**")).join("");
|
|
355
728
|
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
const JPEG_BYTES = 256 * 1024;
|
|
361
|
-
function of(base64) {
|
|
362
|
-
var _a, _b, _c;
|
|
363
|
-
let bytes;
|
|
364
|
-
try {
|
|
365
|
-
const binary = atob(base64.slice(0, Math.ceil(JPEG_BYTES * 4 / 3 / 4) * 4));
|
|
366
|
-
bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
367
|
-
} catch (_d) {
|
|
368
|
-
return;
|
|
729
|
+
ChannelsText.markMentions = markMentions;
|
|
730
|
+
function mentions(text, agents) {
|
|
731
|
+
if (agents.length === 0) {
|
|
732
|
+
return [];
|
|
369
733
|
}
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
function u24le(bytes, at) {
|
|
381
|
-
return bytes[at] | bytes[at + 1] << 8 | bytes[at + 2] << 16;
|
|
382
|
-
}
|
|
383
|
-
function u32be(bytes, at) {
|
|
384
|
-
return (bytes[at] << 24 | bytes[at + 1] << 16 | bytes[at + 2] << 8 | bytes[at + 3]) >>> 0;
|
|
385
|
-
}
|
|
386
|
-
function text(bytes, at, length) {
|
|
387
|
-
return String.fromCharCode(...bytes.subarray(at, at + length));
|
|
388
|
-
}
|
|
389
|
-
function png(bytes) {
|
|
390
|
-
return bytes.length >= 24 && bytes[0] === 137 && text(bytes, 1, 3) === "PNG" ? { width: u32be(bytes, 16), height: u32be(bytes, 20) } : undefined;
|
|
734
|
+
const names = [...agents].sort((a, b) => b.name.length - a.name.length).map((agent) => agent.name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
|
|
735
|
+
const pattern = new RegExp(`@(${names.join("|")})(?![A-Za-z0-9_-])`, "gi");
|
|
736
|
+
const found = [];
|
|
737
|
+
for (const match of text.matchAll(pattern)) {
|
|
738
|
+
const agent = agents.find((candidate) => candidate.name.toLowerCase() === match[1].toLowerCase());
|
|
739
|
+
if (agent && !found.includes(agent.id)) {
|
|
740
|
+
found.push(agent.id);
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
return found;
|
|
391
744
|
}
|
|
392
|
-
|
|
393
|
-
|
|
745
|
+
ChannelsText.mentions = mentions;
|
|
746
|
+
function targets(team, channel, message) {
|
|
747
|
+
const muted = channel.muted ?? [];
|
|
748
|
+
const members = channel.members.filter((id) => !muted.includes(id)).map((id) => team.agents.find((agent) => agent.id === id)).filter((agent) => !!agent);
|
|
749
|
+
const named = mentions(message.text, members).filter((id) => id !== message.author);
|
|
750
|
+
if (message.author === SYSTEM) {
|
|
751
|
+
return [];
|
|
752
|
+
}
|
|
753
|
+
if (named.length > 0 || message.author !== USER && message.author !== TA) {
|
|
754
|
+
return named;
|
|
755
|
+
}
|
|
756
|
+
return members.length > 0 ? [members[0].id] : [];
|
|
394
757
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
758
|
+
ChannelsText.targets = targets;
|
|
759
|
+
function authorName(team, author, labels) {
|
|
760
|
+
if (author === SYSTEM) {
|
|
761
|
+
return "channel";
|
|
398
762
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
763
|
+
if (author === USER) {
|
|
764
|
+
return labels.user;
|
|
765
|
+
}
|
|
766
|
+
if (author === TA) {
|
|
767
|
+
return labels.ta;
|
|
768
|
+
}
|
|
769
|
+
return team.agents.find((agent) => agent.id === author)?.name ?? author;
|
|
770
|
+
}
|
|
771
|
+
ChannelsText.authorName = authorName;
|
|
772
|
+
function systemPrompt(agent) {
|
|
773
|
+
return [
|
|
774
|
+
`You are ${agent.name}, ${AGENT_MARK}. Your role: ${agent.role}`,
|
|
775
|
+
"You work with the user, Ta and other agents in channels. A message for you starts with a <context> block: the channel, its members, the recent messages and who speaks to you; answer what follows the block.",
|
|
776
|
+
"Do the part of the work your role covers with your tools, then answer in a few sentences: your answer is posted to the channel as it is.",
|
|
777
|
+
"To hand work to another member, write @ and their name in your answer; name nobody when the work is done or you need the user.",
|
|
778
|
+
NOTICE_RULE
|
|
779
|
+
].join(`
|
|
780
|
+
`);
|
|
781
|
+
}
|
|
782
|
+
ChannelsText.systemPrompt = systemPrompt;
|
|
783
|
+
function prompt(team, channel, history, message, agent) {
|
|
784
|
+
const labels = { user: "user", ta: "Ta" };
|
|
785
|
+
const members = channel.members.map((id) => team.agents.find((other) => other.id === id)).filter((other) => !!other).map((other) => `@${other.name}${other.id === agent.id ? " (you)" : ""}: ${firstLine(other.role)}`);
|
|
786
|
+
const before = history.filter((item) => item.id !== message.id && !item.failed && !item.notice).slice(-CONTEXT_MESSAGES);
|
|
787
|
+
const lines = [`[#${channel.name}]${channel.topic ? ` ${channel.topic}` : ""}`, "Members:", ...members.map((line) => `- ${line}`)];
|
|
788
|
+
if (channel.notice) {
|
|
789
|
+
lines.push("", "Notice of the channel (follow it; keep it with update_channel_notice):", channel.notice.text);
|
|
410
790
|
}
|
|
791
|
+
if (before.length > 0) {
|
|
792
|
+
lines.push("", "Recent messages:", ...before.map((item) => `${authorName(team, item.author, labels)}: ${item.text}`));
|
|
793
|
+
}
|
|
794
|
+
lines.push("", `${authorName(team, message.author, labels)} to you:`);
|
|
795
|
+
const speaker = message.author === USER ? "" : ` · ${authorName(team, message.author, labels).replace(/[\]\n]/g, " ")}`;
|
|
796
|
+
lines.push(`[ta:from ${NAME} #${channel.name}${speaker}]`);
|
|
797
|
+
return `<context>
|
|
798
|
+
${lines.join(`
|
|
799
|
+
`)}
|
|
800
|
+
</context>
|
|
801
|
+
${message.text}`;
|
|
411
802
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
803
|
+
ChannelsText.prompt = prompt;
|
|
804
|
+
function summary(team) {
|
|
805
|
+
if (team.agents.length === 0) {
|
|
806
|
+
return "No agents and no channels yet.";
|
|
415
807
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
808
|
+
const name = (id) => team.agents.find((agent) => agent.id === id)?.name ?? id;
|
|
809
|
+
const agents = team.agents.map((agent) => `- @${agent.name}: ${firstLine(agent.role)}`);
|
|
810
|
+
const channels = team.channels.map((channel) => `- #${channel.name}${channel.topic ? ` (${channel.topic})` : ""}: ${channel.members.map((id) => `@${name(id)}`).join(", ")}${channel.muted?.length ? `; muted by the user, answering nothing: ${channel.muted.map((id) => `@${name(id)}`).join(", ")}` : ""}${channel.notice ? `
|
|
811
|
+
notice: ${channel.notice.text.replace(/\s+/g, " ").slice(0, 300)}` : ""}`);
|
|
812
|
+
return ["Agents:", ...agents, "", "Channels:", ...channels.length > 0 ? channels : ["none yet"]].join(`
|
|
813
|
+
`);
|
|
814
|
+
}
|
|
815
|
+
ChannelsText.summary = summary;
|
|
816
|
+
function transcript(team, messages) {
|
|
817
|
+
const labels = { user: "user", ta: "Ta" };
|
|
818
|
+
return messages.map((item) => `${authorName(team, item.author, labels)}${item.failed ? " (failed)" : ""}: ${item.text}`).join(`
|
|
819
|
+
|
|
820
|
+
`);
|
|
821
|
+
}
|
|
822
|
+
ChannelsText.transcript = transcript;
|
|
823
|
+
function markdown(agent, messages, labels) {
|
|
824
|
+
const parts = [`# ${agent.name}`, "", `> ${firstLine(agent.role)}`];
|
|
825
|
+
for (const message of messages) {
|
|
826
|
+
const { role, content } = message ?? {};
|
|
827
|
+
if (role !== "user" && role !== "assistant") {
|
|
828
|
+
continue;
|
|
420
829
|
}
|
|
421
|
-
const
|
|
422
|
-
if (
|
|
423
|
-
|
|
830
|
+
const text = (typeof content === "string" ? content : Array.isArray(content) ? content.map((block) => block?.type === "text" ? String(block.text ?? "") : "").join("") : "").replace(/^<context>\n?[\s\S]*?\n?<\/context>\n?/, "").trim();
|
|
831
|
+
if (text) {
|
|
832
|
+
parts.push("", `## ${role === "user" ? labels.user : agent.name}`, "", text);
|
|
424
833
|
}
|
|
425
|
-
at += 2 + u16be(bytes, at + 2);
|
|
426
834
|
}
|
|
427
|
-
return
|
|
835
|
+
return `${parts.join(`
|
|
836
|
+
`)}
|
|
837
|
+
`;
|
|
428
838
|
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
function read(text) {
|
|
435
|
-
if (!START.test(text)) {
|
|
436
|
-
return;
|
|
839
|
+
ChannelsText.markdown = markdown;
|
|
840
|
+
function channelMarkdown(team, channel, messages, labels) {
|
|
841
|
+
const parts = [`# #${channel.name}`];
|
|
842
|
+
if (channel.topic) {
|
|
843
|
+
parts.push("", `> ${firstLine(channel.topic)}`);
|
|
437
844
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
}
|
|
444
|
-
TaAgentSummary2.strip = strip;
|
|
445
|
-
})(TaAgentSummary || (TaAgentSummary = {}));
|
|
446
|
-
var TaSkillUse;
|
|
447
|
-
(function(TaSkillUse2) {
|
|
448
|
-
const BLOCK = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
|
|
449
|
-
function parse(message) {
|
|
450
|
-
var _a;
|
|
451
|
-
const match = BLOCK.exec(message);
|
|
452
|
-
if (!match) {
|
|
453
|
-
return;
|
|
845
|
+
for (const message of messages) {
|
|
846
|
+
const text = message.text.trim();
|
|
847
|
+
if (text && message.author !== SYSTEM) {
|
|
848
|
+
parts.push("", `## ${authorName(team, message.author, labels)}${message.failed ? " (failed)" : ""}`, "", text);
|
|
849
|
+
}
|
|
454
850
|
}
|
|
455
|
-
return {
|
|
851
|
+
return `${parts.join(`
|
|
852
|
+
`)}
|
|
853
|
+
`;
|
|
456
854
|
}
|
|
457
|
-
|
|
458
|
-
function
|
|
459
|
-
return
|
|
855
|
+
ChannelsText.channelMarkdown = channelMarkdown;
|
|
856
|
+
function firstLine(text) {
|
|
857
|
+
return text.split(`
|
|
858
|
+
`)[0];
|
|
460
859
|
}
|
|
461
|
-
|
|
462
|
-
|
|
860
|
+
})(ChannelsText ||= {});
|
|
861
|
+
var NOTICE_RULE = [
|
|
862
|
+
"A channel may have a notice, in the <context> block: what its members decided, agreed and are to do. Follow it.",
|
|
863
|
+
`When the talk settles a decision or a convention, or adds, assigns or finishes a to-do, update it with update_channel_notice: the whole notice, short, under the headings ### ${NOTICE_HEADINGS.zh.join(" / ")} (### ${NOTICE_HEADINGS.en.join(" / ")} in English), in the language of the channel, to-dos as - [ ] or - [x] with who does them. The lead keeps it most; leave it for small talk.`
|
|
864
|
+
].join(`
|
|
865
|
+
`);
|
|
463
866
|
|
|
464
|
-
//
|
|
465
|
-
var
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
return plain;
|
|
867
|
+
// web-src/handoff.ts
|
|
868
|
+
var HandOff;
|
|
869
|
+
((HandOff) => {
|
|
870
|
+
HandOff.TOOL = "hand_off";
|
|
871
|
+
HandOff.CARD = "ta-channels-handoff";
|
|
872
|
+
HandOff.BLOCK = "ta-handoff";
|
|
873
|
+
const MARK = /\[ta-handoff:([^\]\s]+)\]/;
|
|
874
|
+
HandOff.DEFINITION = {
|
|
875
|
+
name: HandOff.TOOL,
|
|
876
|
+
label: "Hand off",
|
|
877
|
+
description: "Hands the work of this conversation over to one of the user's agents (@name) or channels (#name), when the user says so (hand it to, give it to, 交给, 转给). The other side does not see this conversation: write the brief it needs to go on, in the user's language: the goal, what is done and decided, what is left or blocks, the files, branches, commands and links that matter. It works on it in its own conversation, which the user follows; you stop working on it here. list_channels lists the team. After the call, say in one line to whom it went.",
|
|
878
|
+
promptSnippet: "Hand the work over to one of the user's agents or channels",
|
|
879
|
+
parameters: {
|
|
880
|
+
type: "object",
|
|
881
|
+
properties: {
|
|
882
|
+
to: { type: "string", description: "@name of an agent or #name of a channel." },
|
|
883
|
+
brief: { type: "string", description: "Complete in itself: the receiver sees only this." }
|
|
884
|
+
},
|
|
885
|
+
required: ["to", "brief"]
|
|
484
886
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
return
|
|
488
|
-
${line}`, TaMessageContext.strip(plain));
|
|
887
|
+
};
|
|
888
|
+
function ref(target) {
|
|
889
|
+
return `${target.kind === "agent" ? "@" : "#"}${target.name}`;
|
|
489
890
|
}
|
|
490
|
-
|
|
491
|
-
function
|
|
492
|
-
|
|
493
|
-
const context =
|
|
494
|
-
|
|
495
|
-
|
|
891
|
+
HandOff.ref = ref;
|
|
892
|
+
function ask(language, to) {
|
|
893
|
+
const fence = "```";
|
|
894
|
+
const context = [
|
|
895
|
+
`[ta-handoff:${to}]`,
|
|
896
|
+
`The user hands the work of this conversation over to ${to}, which does not see this conversation.`,
|
|
897
|
+
`- Write the brief it needs to go on: the goal, what is done and decided, what is left or blocks, the files, branches, commands and links that matter, in the user's language. Leave out what was only tried and dropped.`,
|
|
898
|
+
`- With the tool ${HandOff.TOOL}, call it with to "${to}" and the brief, then say in one line that it went.`,
|
|
899
|
+
`- Without it, say in one line what you hand over, then end your answer with the brief in a fenced block of the language ${HandOff.BLOCK}, which Ta reads to hand it over (a longer fence when the brief has one of its own):`,
|
|
900
|
+
`${fence}${HandOff.BLOCK}`,
|
|
901
|
+
"<the brief>",
|
|
902
|
+
fence,
|
|
903
|
+
`- When the conversation holds nothing to hand over yet, say so and ask what ${to} should do.`
|
|
904
|
+
].join(`
|
|
905
|
+
`);
|
|
906
|
+
const line = TaLanguageUtil.pick(language, {
|
|
907
|
+
"zh-CN": `把这件事交给 ${to}`,
|
|
908
|
+
"zh-TW": `把這件事交給 ${to}`,
|
|
909
|
+
"en-US": `Hand this over to ${to}`,
|
|
910
|
+
"ja-JP": `これを ${to} に引き継ぐ`
|
|
911
|
+
});
|
|
912
|
+
return `<context>
|
|
913
|
+
${context}
|
|
914
|
+
</context>
|
|
915
|
+
${line}`;
|
|
496
916
|
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
var TaRelayServer = Symbol("TaRelayServer");
|
|
501
|
-
// ../ta-protocol/esm/common/remote-protocol.js
|
|
502
|
-
var TaRemoteServer = Symbol("TaRemoteServer");
|
|
503
|
-
// ../ta-protocol/esm/common/room-protocol.js
|
|
504
|
-
var TaRoomServer = Symbol("TaRoomServer");
|
|
505
|
-
var TaRoomWatchUtil;
|
|
506
|
-
(function(TaRoomWatchUtil2) {
|
|
507
|
-
function of(messages, state) {
|
|
508
|
-
const prefixes = Array.isArray(state) ? state.filter((prefix) => typeof prefix === "string" && prefix.length > 0) : [];
|
|
509
|
-
return { messages: messages !== false, state: [...new Set(prefixes)].sort() };
|
|
917
|
+
HandOff.ask = ask;
|
|
918
|
+
function asked(text) {
|
|
919
|
+
return MARK.exec(text)?.[1];
|
|
510
920
|
}
|
|
511
|
-
|
|
512
|
-
function
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
for (
|
|
516
|
-
|
|
517
|
-
|
|
921
|
+
HandOff.asked = asked;
|
|
922
|
+
function find(text) {
|
|
923
|
+
const lines = text.split(/\r?\n/);
|
|
924
|
+
let found;
|
|
925
|
+
for (let index = 0;index < lines.length; index++) {
|
|
926
|
+
const open = /^\s*(`{3,})\s*([\w-]+)\s*$/.exec(lines[index]);
|
|
927
|
+
if (open?.[2] !== HandOff.BLOCK) {
|
|
928
|
+
continue;
|
|
929
|
+
}
|
|
930
|
+
const close = new RegExp(`^\\s*${open[1]}\`*\\s*$`);
|
|
931
|
+
const end = lines.findIndex((line, at) => at > index && close.test(line));
|
|
932
|
+
found = lines.slice(index + 1, end < 0 ? lines.length : end);
|
|
933
|
+
index = end < 0 ? lines.length : end;
|
|
518
934
|
}
|
|
519
|
-
|
|
935
|
+
const brief = found?.join(`
|
|
936
|
+
`).trim();
|
|
937
|
+
return brief || undefined;
|
|
520
938
|
}
|
|
521
|
-
|
|
522
|
-
function
|
|
523
|
-
|
|
524
|
-
|
|
939
|
+
HandOff.find = find;
|
|
940
|
+
function message(origin, brief, language) {
|
|
941
|
+
const title = origin.title?.trim() || TaLanguageUtil.pick(language, { "zh-CN": "一个对话", "zh-TW": "一個對話", "en-US": "a conversation", "ja-JP": "ある会話" });
|
|
942
|
+
const head = TaLanguageUtil.pick(language, {
|
|
943
|
+
"zh-CN": `(交接自“${title}”)`,
|
|
944
|
+
"zh-TW": `(交接自「${title}」)`,
|
|
945
|
+
"en-US": `(Handed over from “${title}”)`,
|
|
946
|
+
"ja-JP": `(“${title}” から引き継ぎました)`
|
|
947
|
+
});
|
|
948
|
+
const context = [
|
|
949
|
+
"The user handed you this work from another conversation of theirs, which you do not see; the brief below is all it says. Go on from there in this conversation, which the user follows; ask them when the brief leaves out something you need.",
|
|
950
|
+
origin.sessionFile ? `That conversation is pi's session file ${origin.sessionFile}${origin.cwd ? `, working in ${origin.cwd}` : ""}: read it only when the brief is not enough.` : ""
|
|
951
|
+
].filter(Boolean).join(`
|
|
525
952
|
`);
|
|
953
|
+
return `<context>
|
|
954
|
+
${context}
|
|
955
|
+
</context>
|
|
956
|
+
${head}
|
|
957
|
+
|
|
958
|
+
${brief.trim()}`;
|
|
959
|
+
}
|
|
960
|
+
HandOff.message = message;
|
|
961
|
+
function channelText(origin, brief, language) {
|
|
962
|
+
const title = origin.title?.trim() || TaLanguageUtil.pick(language, { "zh-CN": "一个对话", "zh-TW": "一個對話", "en-US": "a conversation", "ja-JP": "ある会話" });
|
|
963
|
+
return `${TaLanguageUtil.pick(language, {
|
|
964
|
+
"zh-CN": `(交接自“${title}”)`,
|
|
965
|
+
"zh-TW": `(交接自「${title}」)`,
|
|
966
|
+
"en-US": `(Handed over from “${title}”)`,
|
|
967
|
+
"ja-JP": `(“${title}” から引き継ぎました)`
|
|
968
|
+
})}
|
|
969
|
+
|
|
970
|
+
${brief.trim()}`;
|
|
971
|
+
}
|
|
972
|
+
HandOff.channelText = channelText;
|
|
973
|
+
function serverLanguage(env = typeof process === "undefined" ? {} : process.env) {
|
|
974
|
+
return TaLanguageUtil.of(env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG || "");
|
|
526
975
|
}
|
|
527
|
-
|
|
528
|
-
function
|
|
529
|
-
|
|
530
|
-
return watch.messages;
|
|
531
|
-
}
|
|
532
|
-
if (event.type === "state") {
|
|
533
|
-
return watch.messages || watch.state.some((prefix) => event.key.startsWith(prefix));
|
|
534
|
-
}
|
|
535
|
-
return true;
|
|
976
|
+
HandOff.serverLanguage = serverLanguage;
|
|
977
|
+
function result(target) {
|
|
978
|
+
return `Handed over to ${ref(target)}; it works on it in its own conversation, which the user follows. Do not go on with it here.`;
|
|
536
979
|
}
|
|
537
|
-
|
|
538
|
-
})(
|
|
539
|
-
|
|
540
|
-
|
|
980
|
+
HandOff.result = result;
|
|
981
|
+
})(HandOff ||= {});
|
|
982
|
+
|
|
983
|
+
// ../ta-protocol/esm/common/access-protocol.js
|
|
984
|
+
var TaAccessServer = Symbol("TaAccessServer");
|
|
541
985
|
// ../ta-protocol/esm/common/ta-extension-host.js
|
|
986
|
+
var TA_WEBHOOK_MAX_BYTES = 256 * 1024;
|
|
542
987
|
var TA_HOST_EVENT = "ta:host";
|
|
543
988
|
var TaHostUtil;
|
|
544
989
|
(function(TaHostUtil2) {
|
|
@@ -630,1032 +1075,1284 @@ var TaAskUtil;
|
|
|
630
1075
|
return { question: entry(question).question, at: Number.isNaN(at) ? 0 : at };
|
|
631
1076
|
}
|
|
632
1077
|
})(TaAskUtil || (TaAskUtil = {}));
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
var
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
1078
|
+
|
|
1079
|
+
// ../ta-protocol/esm/common/delegate-protocol.js
|
|
1080
|
+
var TaDelegateUtil;
|
|
1081
|
+
(function(TaDelegateUtil2) {
|
|
1082
|
+
TaDelegateUtil2.LEVELS = ["less", "balanced", "more"];
|
|
1083
|
+
TaDelegateUtil2.DEFAULT = "balanced";
|
|
1084
|
+
TaDelegateUtil2.WORK_TOOLS = ["read", "bash", "powershell", "edit", "write", "grep", "find", "ls"];
|
|
1085
|
+
TaDelegateUtil2.CHANGE_TOOLS = ["edit", "write"];
|
|
1086
|
+
const LIMITS = {
|
|
1087
|
+
less: { noChanges: false },
|
|
1088
|
+
balanced: { noChanges: true, steps: 6 },
|
|
1089
|
+
more: { noChanges: true, steps: 2 }
|
|
1090
|
+
};
|
|
1091
|
+
function parse(value) {
|
|
1092
|
+
return TaDelegateUtil2.LEVELS.includes(value) ? value : TaDelegateUtil2.DEFAULT;
|
|
644
1093
|
}
|
|
645
|
-
|
|
646
|
-
function
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
1094
|
+
TaDelegateUtil2.parse = parse;
|
|
1095
|
+
function mark(level) {
|
|
1096
|
+
return `(delegate=${level})`;
|
|
1097
|
+
}
|
|
1098
|
+
TaDelegateUtil2.mark = mark;
|
|
1099
|
+
function levelOf(systemPrompt) {
|
|
1100
|
+
const role = TaHostUtil.role(systemPrompt);
|
|
1101
|
+
return TaDelegateUtil2.LEVELS.find((level) => role.includes(mark(level)));
|
|
1102
|
+
}
|
|
1103
|
+
TaDelegateUtil2.levelOf = levelOf;
|
|
1104
|
+
function limits(level) {
|
|
1105
|
+
return LIMITS[level];
|
|
1106
|
+
}
|
|
1107
|
+
TaDelegateUtil2.limits = limits;
|
|
1108
|
+
function refusal(level, tool, steps) {
|
|
1109
|
+
if (!TaDelegateUtil2.WORK_TOOLS.includes(tool)) {
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1112
|
+
const limit = LIMITS[level];
|
|
1113
|
+
if (limit.noChanges && TaDelegateUtil2.CHANGE_TOOLS.includes(tool)) {
|
|
1114
|
+
return "You do not change files yourself: hand this to a task with start_task, with instructions complete enough to do it. The user set how much you hand out in the settings of the double.";
|
|
1115
|
+
}
|
|
1116
|
+
if (limit.steps !== undefined && steps >= limit.steps) {
|
|
1117
|
+
return "You have looked enough for this: hand the work to a task with start_task now, with what you found in its instructions, and tell the user what you started.";
|
|
1118
|
+
}
|
|
1119
|
+
return;
|
|
1120
|
+
}
|
|
1121
|
+
TaDelegateUtil2.refusal = refusal;
|
|
1122
|
+
})(TaDelegateUtil || (TaDelegateUtil = {}));
|
|
1123
|
+
|
|
1124
|
+
// ../ta-protocol/esm/common/app-protocol.js
|
|
1125
|
+
var FONT_SIZES = ["small", "standard", "large", "xlarge"];
|
|
1126
|
+
var words = (en, zh, tw, ja) => ({ "en-US": en, "zh-CN": zh, "zh-TW": tw, "ja-JP": ja });
|
|
1127
|
+
var SYSTEM2 = words("as the system", "跟随系统", "跟隨系統", "システムに合わせる");
|
|
1128
|
+
var FONT_SHOWN = {
|
|
1129
|
+
small: words("small", "小", "小", "小"),
|
|
1130
|
+
standard: words("standard", "标准", "標準", "標準"),
|
|
1131
|
+
large: words("large", "大", "大", "大"),
|
|
1132
|
+
xlarge: words("extra large", "特大", "特大", "特大")
|
|
1133
|
+
};
|
|
1134
|
+
var TA_WEB_SETTINGS = [
|
|
1135
|
+
{
|
|
1136
|
+
key: "theme",
|
|
1137
|
+
type: "enum",
|
|
1138
|
+
values: ["system", "light", "dark"],
|
|
1139
|
+
default: "system",
|
|
1140
|
+
what: "Light or dark look; system follows the device.",
|
|
1141
|
+
title: words("Theme", "外观", "外觀", "外観"),
|
|
1142
|
+
shown: { system: SYSTEM2, light: words("light", "浅色", "淺色", "ライト"), dark: words("dark", "深色", "深色", "ダーク") }
|
|
1143
|
+
},
|
|
1144
|
+
{
|
|
1145
|
+
key: "language",
|
|
1146
|
+
type: "enum",
|
|
1147
|
+
values: ["system", ...TaLanguageUtil.ALL],
|
|
1148
|
+
default: "system",
|
|
1149
|
+
what: "The language of Ta's pages and of what Ta says; system follows the device.",
|
|
1150
|
+
title: words("Language", "语言", "語言", "言語"),
|
|
1151
|
+
shown: {
|
|
1152
|
+
system: SYSTEM2,
|
|
1153
|
+
...Object.fromEntries(TaLanguageUtil.ALL.map((language) => [
|
|
1154
|
+
language,
|
|
1155
|
+
words(TaLanguageUtil.NAMES[language], TaLanguageUtil.NAMES[language], TaLanguageUtil.NAMES[language], TaLanguageUtil.NAMES[language])
|
|
1156
|
+
]))
|
|
1157
|
+
}
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
key: "fontSize",
|
|
1161
|
+
type: "enum",
|
|
1162
|
+
values: FONT_SIZES,
|
|
1163
|
+
default: "standard",
|
|
1164
|
+
what: "The size of the text of the whole page.",
|
|
1165
|
+
title: words("Text size", "字体大小", "字型大小", "文字サイズ"),
|
|
1166
|
+
shown: FONT_SHOWN
|
|
1167
|
+
},
|
|
1168
|
+
{
|
|
1169
|
+
key: "chatFontSize",
|
|
1170
|
+
type: "enum",
|
|
1171
|
+
values: FONT_SIZES,
|
|
1172
|
+
default: "standard",
|
|
1173
|
+
what: "The size of the text of conversations, on top of fontSize.",
|
|
1174
|
+
title: words("Text size of conversations", "对话字体大小", "對話字型大小", "会話の文字サイズ"),
|
|
1175
|
+
shown: FONT_SHOWN
|
|
1176
|
+
},
|
|
1177
|
+
{
|
|
1178
|
+
key: "speak",
|
|
1179
|
+
type: "boolean",
|
|
1180
|
+
default: false,
|
|
1181
|
+
what: "Read every reply aloud.",
|
|
1182
|
+
title: words("Read replies aloud", "朗读回复", "朗讀回覆", "返信を読み上げ")
|
|
1183
|
+
},
|
|
1184
|
+
{
|
|
1185
|
+
key: "speakTalk",
|
|
1186
|
+
type: "boolean",
|
|
1187
|
+
default: false,
|
|
1188
|
+
what: "Read the reply aloud when the user spoke to the double by voice.",
|
|
1189
|
+
title: words("Read aloud what was asked by voice", "语音提问时朗读回复", "語音提問時朗讀回覆", "音声で聞いたら読み上げ")
|
|
1190
|
+
},
|
|
1191
|
+
{
|
|
1192
|
+
key: "callCaptions",
|
|
1193
|
+
type: "boolean",
|
|
1194
|
+
default: false,
|
|
1195
|
+
what: "Show captions in a call: what the user says and what Ta reads.",
|
|
1196
|
+
title: words("Call captions", "通话字幕", "通話字幕", "通話の字幕")
|
|
1197
|
+
},
|
|
1198
|
+
{
|
|
1199
|
+
key: "voice",
|
|
1200
|
+
type: "string",
|
|
1201
|
+
default: "",
|
|
1202
|
+
what: "The voice replies are read with (a voiceURI of the device's voices); empty for the most natural one.",
|
|
1203
|
+
title: words("Voice", "朗读声音", "朗讀聲音", "読み上げの声")
|
|
1204
|
+
},
|
|
1205
|
+
{
|
|
1206
|
+
key: "confirmTasks",
|
|
1207
|
+
type: "boolean",
|
|
1208
|
+
default: false,
|
|
1209
|
+
what: "The double asks before it hands out work.",
|
|
1210
|
+
title: words("Ask before handing out work", "派任务前先问我", "派任務前先問我", "作業を割り当てる前に確認")
|
|
1211
|
+
},
|
|
1212
|
+
{
|
|
1213
|
+
key: "maxTasks",
|
|
1214
|
+
type: "number",
|
|
1215
|
+
values: [0, 2, 4, 8],
|
|
1216
|
+
default: 0,
|
|
1217
|
+
what: "How many of the double's tasks run at once; 0 for as many as it starts.",
|
|
1218
|
+
title: words("Tasks at once", "同时运行的任务", "同時執行的任務", "同時に実行するタスク")
|
|
1219
|
+
},
|
|
1220
|
+
{
|
|
1221
|
+
key: "delegate",
|
|
1222
|
+
type: "enum",
|
|
1223
|
+
values: TaDelegateUtil.LEVELS,
|
|
1224
|
+
default: TaDelegateUtil.DEFAULT,
|
|
1225
|
+
what: "How much of the work the double hands out to tasks rather than doing it itself.",
|
|
1226
|
+
title: words("Hand out work", "派活多少", "派活多少", "作業の割り当て"),
|
|
1227
|
+
shown: { less: words("less", "少", "少", "少なめ"), balanced: words("balanced", "适中", "適中", "ふつう"), more: words("more", "多", "多", "多め") }
|
|
1228
|
+
},
|
|
1229
|
+
{
|
|
1230
|
+
key: "assistantModel",
|
|
1231
|
+
type: "model",
|
|
1232
|
+
default: "",
|
|
1233
|
+
what: "The model of the double, <provider>/<model id>; empty for the default model.",
|
|
1234
|
+
title: words("Model of the double", "分身的模型", "分身的模型", "分身のモデル")
|
|
1235
|
+
},
|
|
1236
|
+
{
|
|
1237
|
+
key: "taskModel",
|
|
1238
|
+
type: "model",
|
|
1239
|
+
default: "",
|
|
1240
|
+
what: "The model of the tasks the double starts; empty for the default model.",
|
|
1241
|
+
title: words("Model of tasks", "任务的模型", "任務的模型", "タスクのモデル")
|
|
1242
|
+
},
|
|
1243
|
+
{ key: "reduceMotion", type: "boolean", default: false, what: "Fewer animations.", title: words("Reduce motion", "减少动画", "減少動畫", "動きを減らす") },
|
|
1244
|
+
{
|
|
1245
|
+
key: "keepAliveMinutes",
|
|
1246
|
+
type: "number",
|
|
1247
|
+
values: [1, 5, 15, 30],
|
|
1248
|
+
default: 5,
|
|
1249
|
+
what: "How long an extension started on open keeps running once left, in minutes.",
|
|
1250
|
+
title: words("Keep extensions running", "扩展离开后保留", "擴充功能離開後保留", "拡張機能を保持")
|
|
1251
|
+
},
|
|
1252
|
+
{
|
|
1253
|
+
key: "chatFoldDays",
|
|
1254
|
+
type: "number",
|
|
1255
|
+
values: [3, 7, 30, 0],
|
|
1256
|
+
default: 7,
|
|
1257
|
+
what: "Conversations not updated for these days fold at the end of the list; 0 for none.",
|
|
1258
|
+
title: words("Fold old conversations", "折叠旧对话", "摺疊舊對話", "古い会話を折りたたむ")
|
|
1259
|
+
},
|
|
1260
|
+
{
|
|
1261
|
+
key: "chatArchiveDays",
|
|
1262
|
+
type: "number",
|
|
1263
|
+
values: [30, 90, 365, 0],
|
|
1264
|
+
default: 30,
|
|
1265
|
+
what: "Conversations not updated for these days are archived (out of the list, found by search); 0 for none.",
|
|
1266
|
+
title: words("Archive old conversations", "归档旧对话", "歸檔舊對話", "古い会話をアーカイブ")
|
|
1267
|
+
},
|
|
1268
|
+
{
|
|
1269
|
+
key: "recentShots",
|
|
1270
|
+
type: "boolean",
|
|
1271
|
+
default: true,
|
|
1272
|
+
what: "The screenshot just taken is offered above the message box, once.",
|
|
1273
|
+
title: words("Offer recent screenshots", "提示刚截的图", "提示剛截的圖", "撮ったばかりのスクリーンショットを提案")
|
|
651
1274
|
}
|
|
652
|
-
TaPermissionUtil2.host = host;
|
|
653
|
-
})(TaPermissionUtil || (TaPermissionUtil = {}));
|
|
654
|
-
var action = (id, en, zh, tw, ja, more = {}) => ({
|
|
655
|
-
id,
|
|
656
|
-
area: id.split(".")[0],
|
|
657
|
-
title: { en, "zh-CN": zh, ...tw ? { "zh-TW": tw } : {}, ...ja ? { "ja-JP": ja } : {} },
|
|
658
|
-
...more
|
|
659
|
-
});
|
|
660
|
-
var TA_ACTIONS = [
|
|
661
|
-
action("chat.view", "See conversations", "查看对话", "檢視對話", "会話を確認"),
|
|
662
|
-
action("chat.send", "Send in conversations", "在对话里发消息", "在對話裡發訊息", "会話にメッセージを送信"),
|
|
663
|
-
action("chat.create", "Start conversations", "新建对话", "新建對話", "新しい会話を開始"),
|
|
664
|
-
action("chat.stop", "Stop a reply", "停止回复", "停止回覆", "返信を停止"),
|
|
665
|
-
action("chat.manage", "Rename, archive and close conversations", "改名、归档、关闭对话", "改名、歸檔、關閉對話", "会話の名前変更、アーカイブ、クローズ"),
|
|
666
|
-
action("chat.share", "Share by a link", "生成分享链接", "生成分享連結", "共有リンクで共有"),
|
|
667
|
-
action("agent.view", "See agents", "查看智能体", "檢視智慧體", "エージェントを確認"),
|
|
668
|
-
action("agent.use", "Talk with agents", "和智能体对话", "和智慧體對話", "エージェントと対話"),
|
|
669
|
-
action("agent.edit", "Create, change and remove agents", "新建、修改、删除智能体", "新建、修改、刪除智慧體", "エージェントを作成・変更・削除"),
|
|
670
|
-
action("channel.view", "See channels", "查看频道", "檢視頻道", "チャネルを確認"),
|
|
671
|
-
action("channel.post", "Post in channels", "在频道里发言", "在頻道里發言", "チャネルに投稿"),
|
|
672
|
-
action("channel.manage", "Create and change channels", "新建、管理频道", "新建、管理頻道", "チャネルを作成・管理"),
|
|
673
|
-
action("task.view", "See tasks", "查看任务", "檢視任務", "タスクを確認"),
|
|
674
|
-
action("task.create", "Hand out tasks", "派任务", "派任務", "タスクを割り当て"),
|
|
675
|
-
action("task.manage", "Take over and stop tasks", "接管、停止任务", "接管、停止任務", "タスクを引き継ぎ・停止"),
|
|
676
|
-
action("files.read", "Read files", "读文件", "讀檔案", "ファイルを読取", { scoped: true }),
|
|
677
|
-
action("files.write", "Change files", "改文件", "改檔案", "ファイルを変更", { scoped: true }),
|
|
678
|
-
action("commands.run", "Let Ta run commands", "让 Ta 运行命令", "讓 Ta 執行命令", "Ta にコマンド実行を許可", { scoped: true, risky: true }),
|
|
679
|
-
action("commands.terminal", "Open terminals", "打开终端", "開啟終端機", "ターミナルを開く", { scoped: true, risky: true }),
|
|
680
|
-
action("hosts.use", "Use remote hosts", "使用远程主机", "使用遠端主機", "リモートホストを使用", { risky: true }),
|
|
681
|
-
action("models.use", "Use the models", "使用模型", "使用模型", "モデルを使用"),
|
|
682
|
-
action("models.manage", "Sign in to models", "登录和更换模型账号", "登入和更換模型帳號", "モデルアカウントにサインイン・変更"),
|
|
683
|
-
action("cron.view", "See scheduled tasks", "查看定时任务", "檢視定時任務", "スケジュールタスクを確認"),
|
|
684
|
-
action("cron.manage", "Change scheduled tasks", "管理定时任务", "管理定時任務", "スケジュールタスクを管理"),
|
|
685
|
-
action("extensions.use", "Use extensions", "使用扩展", "使用擴充功能", "拡張機能を使用"),
|
|
686
|
-
action("extensions.install", "Install and turn off extensions", "安装、停用扩展", "安裝、停用擴充功能", "拡張機能をインストール・無効化"),
|
|
687
|
-
action("settings.view", "See settings", "查看设置", "檢視設定", "設定を確認"),
|
|
688
|
-
action("settings.manage", "Change settings", "修改设置", "修改設定", "設定を変更"),
|
|
689
|
-
action("members.view", "See members", "查看成员", "檢視成員", "メンバーを確認"),
|
|
690
|
-
action("members.invite", "Invite people", "邀请别人", "邀請別人", "メンバーを招待"),
|
|
691
|
-
action("members.approve", "Answer requests", "处理申请", "處理申請", "リクエストに対応"),
|
|
692
|
-
action("members.roles", "Change roles and members", "管理角色和成员", "管理角色和成員", "ロールとメンバーを管理"),
|
|
693
|
-
action("audit.view", "See the record", "查看记录", "檢視記錄", "レコードを確認")
|
|
694
1275
|
];
|
|
695
|
-
var
|
|
696
|
-
(function(
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
1276
|
+
var TaAppUtil;
|
|
1277
|
+
(function(TaAppUtil2) {
|
|
1278
|
+
function check(spec, value) {
|
|
1279
|
+
var _a, _b;
|
|
1280
|
+
switch (spec.type) {
|
|
1281
|
+
case "boolean":
|
|
1282
|
+
return typeof value === "boolean" ? undefined : "true or false";
|
|
1283
|
+
case "string":
|
|
1284
|
+
return typeof value === "string" ? undefined : "a string";
|
|
1285
|
+
case "model":
|
|
1286
|
+
return value === "" || typeof value === "string" && /^[^/\s]+\/\S+$/.test(value) ? undefined : "<provider>/<model id>, or empty";
|
|
1287
|
+
default:
|
|
1288
|
+
return ((_a = spec.values) === null || _a === undefined ? undefined : _a.includes(value)) ? undefined : `one of ${(_b = spec.values) === null || _b === undefined ? undefined : _b.map((one) => JSON.stringify(one)).join(", ")}`;
|
|
1289
|
+
}
|
|
700
1290
|
}
|
|
701
|
-
|
|
702
|
-
function
|
|
1291
|
+
TaAppUtil2.check = check;
|
|
1292
|
+
function shown(value, language, spec) {
|
|
703
1293
|
var _a;
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
return id;
|
|
1294
|
+
const named = (_a = spec === null || spec === undefined ? undefined : spec.shown) === null || _a === undefined ? undefined : _a[String(value)];
|
|
1295
|
+
if (named) {
|
|
1296
|
+
return TaLanguageUtil.pick(language, named);
|
|
708
1297
|
}
|
|
709
|
-
|
|
710
|
-
"
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
"
|
|
714
|
-
}
|
|
1298
|
+
if (typeof value === "boolean") {
|
|
1299
|
+
return TaLanguageUtil.pick(language, value ? words("on", "开", "開", "オン") : words("off", "关", "關", "オフ"));
|
|
1300
|
+
}
|
|
1301
|
+
if (value === "" || value === undefined || value === null) {
|
|
1302
|
+
return TaLanguageUtil.pick(language, words("default", "默认", "預設", "デフォルト"));
|
|
1303
|
+
}
|
|
1304
|
+
return String(value);
|
|
715
1305
|
}
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
1306
|
+
TaAppUtil2.shown = shown;
|
|
1307
|
+
})(TaAppUtil || (TaAppUtil = {}));
|
|
1308
|
+
// ../ta-protocol/esm/common/auth-protocol.js
|
|
1309
|
+
var TaAuthServer = Symbol("TaAuthServer");
|
|
1310
|
+
// ../ta-protocol/esm/common/deployment-protocol.js
|
|
1311
|
+
var TA_WELL_KNOWN_PATH = "/.well-known/ta";
|
|
1312
|
+
|
|
1313
|
+
class TaDeploymentError extends Error {
|
|
1314
|
+
}
|
|
1315
|
+
var TaDeploymentUtil;
|
|
1316
|
+
(function(TaDeploymentUtil2) {
|
|
1317
|
+
TaDeploymentUtil2.DISTRIBUTION_FILE = "distribution.json";
|
|
1318
|
+
function url(value) {
|
|
1319
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
1320
|
+
return;
|
|
1321
|
+
}
|
|
1322
|
+
try {
|
|
1323
|
+
const parsed = new URL(value.trim());
|
|
1324
|
+
if (!/^https?:$/.test(parsed.protocol) || parsed.search || parsed.hash || parsed.username || parsed.password) {
|
|
1325
|
+
return;
|
|
1326
|
+
}
|
|
1327
|
+
return `${parsed.origin}${parsed.pathname}`.replace(/\/+$/, "");
|
|
1328
|
+
} catch (_a) {
|
|
1329
|
+
return;
|
|
1330
|
+
}
|
|
720
1331
|
}
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
var TaUsageServer = Symbol("TaUsageServer");
|
|
725
|
-
// ../ta-protocol/esm/common/workspace-protocol.js
|
|
726
|
-
var TaWorkspaceServer = Symbol("TaWorkspaceServer");
|
|
727
|
-
var TaTerminalServer = Symbol("TaTerminalServer");
|
|
728
|
-
var TaExcludedFiles;
|
|
729
|
-
(function(TaExcludedFiles2) {
|
|
730
|
-
TaExcludedFiles2.NAMES = [".git", ".svn", ".hg", ".DS_Store", "Thumbs.db"];
|
|
731
|
-
function has(name) {
|
|
732
|
-
return TaExcludedFiles2.NAMES.includes(name);
|
|
1332
|
+
TaDeploymentUtil2.url = url;
|
|
1333
|
+
function name(value) {
|
|
1334
|
+
return typeof value === "string" && value.trim() ? value.trim().slice(0, 80) : undefined;
|
|
733
1335
|
}
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
1336
|
+
function describe(env, own, version) {
|
|
1337
|
+
var _a, _b;
|
|
1338
|
+
const gateway = (_a = url(own.gateway)) !== null && _a !== undefined ? _a : url(env.TA_GATEWAY_URL);
|
|
1339
|
+
const relay = (_b = url(own.relay)) !== null && _b !== undefined ? _b : url(env.TA_RELAY_URL);
|
|
1340
|
+
const called = name(env.TA_DEPLOYMENT_NAME);
|
|
1341
|
+
return { v: 1, ...called ? { name: called } : {}, ...gateway ? { gateway } : {}, ...relay ? { relay } : {}, ...version ? { version } : {} };
|
|
1342
|
+
}
|
|
1343
|
+
TaDeploymentUtil2.describe = describe;
|
|
1344
|
+
TaDeploymentUtil2.HEADERS = {
|
|
1345
|
+
"content-type": "application/json",
|
|
1346
|
+
"access-control-allow-origin": "*",
|
|
1347
|
+
"cache-control": "no-store"
|
|
1348
|
+
};
|
|
1349
|
+
function parse(value) {
|
|
1350
|
+
const given = value;
|
|
1351
|
+
if (!given || typeof given !== "object" || given.v !== 1) {
|
|
1352
|
+
return;
|
|
1353
|
+
}
|
|
1354
|
+
const deployment = describe({ TA_DEPLOYMENT_NAME: given.name, TA_GATEWAY_URL: given.gateway, TA_RELAY_URL: given.relay }, {});
|
|
1355
|
+
const version = name(given.version);
|
|
1356
|
+
return version ? { ...deployment, version } : deployment;
|
|
737
1357
|
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
1358
|
+
TaDeploymentUtil2.parse = parse;
|
|
1359
|
+
async function discover(address, timeoutMs = 6000) {
|
|
1360
|
+
const base = url(address);
|
|
1361
|
+
if (!base) {
|
|
1362
|
+
throw new TaDeploymentError(`${address} is not an address of http or https.`);
|
|
1363
|
+
}
|
|
1364
|
+
const controller = new AbortController;
|
|
1365
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
1366
|
+
try {
|
|
1367
|
+
const response = await fetch(`${base}${TA_WELL_KNOWN_PATH}`, { signal: controller.signal, redirect: "follow" });
|
|
1368
|
+
if (!response.ok) {
|
|
1369
|
+
throw new TaDeploymentError(`${base} is not a deployment of Ta (${response.status}).`);
|
|
1370
|
+
}
|
|
1371
|
+
const deployment = parse(await response.json().catch(() => {
|
|
1372
|
+
return;
|
|
1373
|
+
}));
|
|
1374
|
+
if (!deployment || !deployment.gateway && !deployment.relay) {
|
|
1375
|
+
throw new TaDeploymentError(`${base} is not a deployment of Ta.`);
|
|
1376
|
+
}
|
|
1377
|
+
return deployment;
|
|
1378
|
+
} catch (error) {
|
|
1379
|
+
if ((error === null || error === undefined ? undefined : error.name) === "AbortError") {
|
|
1380
|
+
throw new TaDeploymentError(`${base} did not answer in time.`);
|
|
1381
|
+
}
|
|
1382
|
+
throw error;
|
|
1383
|
+
} finally {
|
|
1384
|
+
clearTimeout(timer);
|
|
1385
|
+
}
|
|
763
1386
|
}
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
1387
|
+
TaDeploymentUtil2.discover = discover;
|
|
1388
|
+
function distribution(value) {
|
|
1389
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
1390
|
+
throw new TaDeploymentError(`${TaDeploymentUtil2.DISTRIBUTION_FILE} holds a JSON object.`);
|
|
1391
|
+
}
|
|
1392
|
+
const given = value;
|
|
1393
|
+
const result = {};
|
|
1394
|
+
if (given.name !== undefined) {
|
|
1395
|
+
result.name = name(given.name);
|
|
1396
|
+
}
|
|
1397
|
+
for (const key of ["relay", "gateway"]) {
|
|
1398
|
+
if (given[key] !== undefined) {
|
|
1399
|
+
const address = url(given[key]);
|
|
1400
|
+
if (!address) {
|
|
1401
|
+
throw new TaDeploymentError(`"${key}" of ${TaDeploymentUtil2.DISTRIBUTION_FILE} is not an address of http or https.`);
|
|
1402
|
+
}
|
|
1403
|
+
result[key] = address;
|
|
1404
|
+
}
|
|
768
1405
|
}
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
1406
|
+
if (given.updates !== undefined) {
|
|
1407
|
+
const updates = given.updates;
|
|
1408
|
+
const base = url(updates === null || updates === undefined ? undefined : updates.base);
|
|
1409
|
+
if (!base && (updates === null || updates === undefined ? undefined : updates.base) !== undefined) {
|
|
1410
|
+
throw new TaDeploymentError(`"updates.base" of ${TaDeploymentUtil2.DISTRIBUTION_FILE} is not an address of http or https.`);
|
|
1411
|
+
}
|
|
1412
|
+
const key = typeof (updates === null || updates === undefined ? undefined : updates.key) === "string" && updates.key.includes("PUBLIC KEY") ? updates.key : undefined;
|
|
1413
|
+
if ((updates === null || updates === undefined ? undefined : updates.key) !== undefined && !key) {
|
|
1414
|
+
throw new TaDeploymentError(`"updates.key" of ${TaDeploymentUtil2.DISTRIBUTION_FILE} is a public key in PEM.`);
|
|
1415
|
+
}
|
|
1416
|
+
result.updates = { ...base ? { base } : {}, ...key ? { key } : {} };
|
|
1417
|
+
}
|
|
1418
|
+
return result;
|
|
1419
|
+
}
|
|
1420
|
+
TaDeploymentUtil2.distribution = distribution;
|
|
1421
|
+
function apply(distribution2, env) {
|
|
1422
|
+
const defaults = { TA_DEPLOYMENT_NAME: distribution2.name, TA_RELAY_URL: distribution2.relay, TA_GATEWAY_URL: distribution2.gateway };
|
|
1423
|
+
for (const [key, value] of Object.entries(defaults)) {
|
|
1424
|
+
if (value && !env[key]) {
|
|
1425
|
+
env[key] = value;
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
TaDeploymentUtil2.apply = apply;
|
|
1430
|
+
})(TaDeploymentUtil || (TaDeploymentUtil = {}));
|
|
1431
|
+
// ../ta-protocol/esm/common/error-protocol.js
|
|
1432
|
+
var TaErrorCode = {
|
|
1433
|
+
SESSION_NOT_FOUND: "CELL_TA_SESSION_NOT_FOUND",
|
|
1434
|
+
SESSION_LOCKED: "CELL_TA_SESSION_LOCKED",
|
|
1435
|
+
TOO_MANY_SESSIONS: "CELL_TA_TOO_MANY_SESSIONS",
|
|
1436
|
+
MESSAGE_CONFLICT: "CELL_TA_MESSAGE_CONFLICT",
|
|
1437
|
+
MODEL_NOT_FOUND: "CELL_TA_MODEL_NOT_FOUND",
|
|
1438
|
+
INVALID_ARGUMENT: "CELL_TA_INVALID_ARGUMENT",
|
|
1439
|
+
COMMAND_FAILED: "CELL_TA_COMMAND_FAILED",
|
|
1440
|
+
NOTHING_TO_COMPACT: "CELL_TA_NOTHING_TO_COMPACT",
|
|
1441
|
+
ALREADY_COMPACTED: "CELL_TA_ALREADY_COMPACTED",
|
|
1442
|
+
SESSION_BUSY: "CELL_TA_SESSION_BUSY",
|
|
1443
|
+
CANCELLED: "CELL_TA_CANCELLED",
|
|
1444
|
+
NOT_SIGNED_IN: "CELL_TA_NOT_SIGNED_IN",
|
|
1445
|
+
ENVIRONMENT_FAILED: "CELL_TA_ENVIRONMENT_FAILED",
|
|
1446
|
+
RATE_LIMITED: "CELL_TA_RATE_LIMITED",
|
|
1447
|
+
FORBIDDEN: "CELL_TA_FORBIDDEN",
|
|
1448
|
+
LIMIT: "CELL_TA_LIMIT",
|
|
1449
|
+
CONNECTION_LOST: "CELL_TA_CONNECTION_LOST"
|
|
1450
|
+
};
|
|
1451
|
+
var TaErrorUtil;
|
|
1452
|
+
(function(TaErrorUtil2) {
|
|
1453
|
+
function code(error) {
|
|
1454
|
+
var _a;
|
|
1455
|
+
var _b;
|
|
1456
|
+
const failure = error;
|
|
1457
|
+
const code2 = (_b = failure === null || failure === undefined ? undefined : failure.code) !== null && _b !== undefined ? _b : (_a = failure === null || failure === undefined ? undefined : failure.data) === null || _a === undefined ? undefined : _a.code;
|
|
1458
|
+
return typeof code2 === "string" ? code2 : undefined;
|
|
1459
|
+
}
|
|
1460
|
+
TaErrorUtil2.code = code;
|
|
1461
|
+
})(TaErrorUtil || (TaErrorUtil = {}));
|
|
1462
|
+
// ../ta-protocol/esm/common/gateway-protocol.js
|
|
1463
|
+
var TaGatewayServer = Symbol("TaGatewayServer");
|
|
1464
|
+
// ../ta-protocol/esm/common/location.js
|
|
1465
|
+
var TaLocation;
|
|
1466
|
+
(function(TaLocation2) {
|
|
1467
|
+
TaLocation2.SSH = "ssh://";
|
|
1468
|
+
TaLocation2.CLOUD = "ta://";
|
|
1469
|
+
const CLOUD_NAME = /^[a-z0-9][a-z0-9-]{0,39}$/;
|
|
1470
|
+
const HOST = /^(?!-)[\w.@:%+[\]-]+$/;
|
|
1471
|
+
function isRemote(location) {
|
|
1472
|
+
return location.startsWith(TaLocation2.SSH) || location.startsWith(TaLocation2.CLOUD);
|
|
1473
|
+
}
|
|
1474
|
+
TaLocation2.isRemote = isRemote;
|
|
1475
|
+
function isCloud(host2) {
|
|
1476
|
+
return !!host2 && host2.startsWith(TaLocation2.CLOUD);
|
|
1477
|
+
}
|
|
1478
|
+
TaLocation2.isCloud = isCloud;
|
|
1479
|
+
function isCloudName(name) {
|
|
1480
|
+
return CLOUD_NAME.test(name);
|
|
1481
|
+
}
|
|
1482
|
+
TaLocation2.isCloudName = isCloudName;
|
|
1483
|
+
function cloud(name, path2 = "") {
|
|
1484
|
+
return `${TaLocation2.CLOUD}${name}${path2 ? normalize(path2) : ""}`;
|
|
1485
|
+
}
|
|
1486
|
+
TaLocation2.cloud = cloud;
|
|
1487
|
+
function cloudName(hostOrLocation) {
|
|
1488
|
+
if (!hostOrLocation.startsWith(TaLocation2.CLOUD)) {
|
|
1489
|
+
return;
|
|
1490
|
+
}
|
|
1491
|
+
const rest = hostOrLocation.slice(TaLocation2.CLOUD.length);
|
|
1492
|
+
const slash = rest.indexOf("/");
|
|
1493
|
+
return slash < 0 ? rest : rest.slice(0, slash);
|
|
773
1494
|
}
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
1495
|
+
TaLocation2.cloudName = cloudName;
|
|
1496
|
+
function parse(location) {
|
|
1497
|
+
var _a;
|
|
1498
|
+
if (!isRemote(location)) {
|
|
1499
|
+
return;
|
|
777
1500
|
}
|
|
778
|
-
if (
|
|
779
|
-
|
|
1501
|
+
if (location.startsWith(TaLocation2.CLOUD)) {
|
|
1502
|
+
const name = (_a = cloudName(location)) !== null && _a !== undefined ? _a : "";
|
|
1503
|
+
if (!isCloudName(name)) {
|
|
1504
|
+
throw new Error(`${JSON.stringify(location)} names no cloud workspace: write ta://<name>/<path>.`);
|
|
1505
|
+
}
|
|
1506
|
+
const path3 = location.slice(TaLocation2.CLOUD.length + name.length);
|
|
1507
|
+
return { host: `${TaLocation2.CLOUD}${name}`, path: path3 ? normalize(path3) : "" };
|
|
780
1508
|
}
|
|
781
|
-
|
|
782
|
-
|
|
1509
|
+
const rest = location.slice(TaLocation2.SSH.length);
|
|
1510
|
+
const slash = rest.indexOf("/");
|
|
1511
|
+
const host2 = slash < 0 ? rest : rest.slice(0, slash);
|
|
1512
|
+
const path2 = slash < 0 ? "" : normalize(rest.slice(slash));
|
|
1513
|
+
if (!isHost(host2)) {
|
|
1514
|
+
throw new Error(`${JSON.stringify(location)} names no host: write ssh://<host>/<path>, the host as ssh takes it.`);
|
|
783
1515
|
}
|
|
784
|
-
return
|
|
785
|
-
}
|
|
786
|
-
static cut(text, max) {
|
|
787
|
-
return text.length > max ? `${text.slice(0, max)}…` : text;
|
|
788
|
-
}
|
|
789
|
-
hide() {
|
|
790
|
-
this.count++;
|
|
791
|
-
return REDACTED;
|
|
1516
|
+
return { host: host2, path: path2 };
|
|
792
1517
|
}
|
|
793
|
-
|
|
794
|
-
|
|
1518
|
+
TaLocation2.parse = parse;
|
|
1519
|
+
function isHost(host2) {
|
|
1520
|
+
return isCloud(host2) ? isCloudName(host2.slice(TaLocation2.CLOUD.length)) : HOST.test(host2);
|
|
795
1521
|
}
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
(
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
1522
|
+
TaLocation2.isHost = isHost;
|
|
1523
|
+
const FLAGS = /^-[46AaCfGgKkMNnqsTtVvXxYy]+$/;
|
|
1524
|
+
function readHost(input) {
|
|
1525
|
+
const words2 = input.trim().split(/\s+/).filter(Boolean);
|
|
1526
|
+
if (words2[0] === "ssh") {
|
|
1527
|
+
words2.shift();
|
|
1528
|
+
}
|
|
1529
|
+
let destination;
|
|
1530
|
+
let port;
|
|
1531
|
+
let user;
|
|
1532
|
+
const options = [];
|
|
1533
|
+
for (let i = 0;i < words2.length; i++) {
|
|
1534
|
+
const word = words2[i];
|
|
1535
|
+
const glued = /^-([pl])(.+)$/.exec(word);
|
|
1536
|
+
if (word === "-p" || word === "-l" || glued) {
|
|
1537
|
+
const value = glued ? glued[2] : words2[++i];
|
|
1538
|
+
if (value === undefined) {
|
|
1539
|
+
return { error: "invalid" };
|
|
1540
|
+
}
|
|
1541
|
+
if ((glued ? glued[1] : word[1]) === "p") {
|
|
1542
|
+
port = value;
|
|
1543
|
+
} else {
|
|
1544
|
+
user = value;
|
|
1545
|
+
}
|
|
1546
|
+
} else if (word === "-o" || word.startsWith("-o")) {
|
|
1547
|
+
const value = word === "-o" ? words2[++i] : word.slice(2);
|
|
1548
|
+
const option = /^(port|user)\s*=?\s*(.+)$/i.exec(value !== null && value !== undefined ? value : "");
|
|
1549
|
+
if (!option) {
|
|
1550
|
+
options.push(`-o ${value !== null && value !== undefined ? value : ""}`.trim());
|
|
1551
|
+
} else if (option[1].toLowerCase() === "port") {
|
|
1552
|
+
port = option[2];
|
|
1553
|
+
} else {
|
|
1554
|
+
user = option[2];
|
|
1555
|
+
}
|
|
1556
|
+
} else if (FLAGS.test(word)) {} else if (word.startsWith("-")) {
|
|
1557
|
+
options.push(/^-[bBcDeEFiIJLmOQRSwW]$/.test(word) && words2[i + 1] !== undefined ? `${word} ${words2[++i]}` : word);
|
|
1558
|
+
} else if (destination === undefined) {
|
|
1559
|
+
destination = word;
|
|
1560
|
+
} else {
|
|
1561
|
+
return { error: "invalid" };
|
|
808
1562
|
}
|
|
809
|
-
const color = typeof card.color === "string" && /^#[0-9a-fA-F]{6}$/.test(card.color) ? card.color : undefined;
|
|
810
|
-
return {
|
|
811
|
-
v: 1,
|
|
812
|
-
name: card.name.trim().slice(0, 32),
|
|
813
|
-
role: card.role.trim().slice(0, MAX_ROLE),
|
|
814
|
-
mark: typeof card.mark === "string" && card.mark.trim() ? card.mark.trim().slice(0, 2) : card.name.trim().slice(0, 1).toUpperCase(),
|
|
815
|
-
...Number.isInteger(card.face) ? { face: card.face } : {},
|
|
816
|
-
...color ? { color } : {},
|
|
817
|
-
...typeof card.redacted === "number" && card.redacted > 0 ? { redacted: card.redacted } : {}
|
|
818
|
-
};
|
|
819
|
-
} catch (_a) {
|
|
820
|
-
return;
|
|
821
1563
|
}
|
|
1564
|
+
if (options.length > 0) {
|
|
1565
|
+
return { error: "options", options };
|
|
1566
|
+
}
|
|
1567
|
+
if (!destination) {
|
|
1568
|
+
return { error: "empty" };
|
|
1569
|
+
}
|
|
1570
|
+
let host2 = destination.replace(/^ssh:\/\//, "").replace(/\/.*$/, "");
|
|
1571
|
+
if (user && !host2.includes("@")) {
|
|
1572
|
+
host2 = `${user}@${host2}`;
|
|
1573
|
+
}
|
|
1574
|
+
if (port) {
|
|
1575
|
+
if (!/^\d{1,5}$/.test(port) || /:\d+$/.test(host2)) {
|
|
1576
|
+
return { error: "invalid" };
|
|
1577
|
+
}
|
|
1578
|
+
host2 = port === "22" ? host2 : `${host2}:${port}`;
|
|
1579
|
+
}
|
|
1580
|
+
return isHost(host2) ? { host: host2 } : { error: "invalid" };
|
|
822
1581
|
}
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
// web-src/channels-model.ts
|
|
827
|
-
var NAME = "@celljs/ta-channels";
|
|
828
|
-
var AGENT_MARK = "one of the agents of Ta";
|
|
829
|
-
var MEMBER_CHANGES = ["lead", "remove", "mute", "unmute"];
|
|
830
|
-
var Keys;
|
|
831
|
-
((Keys) => {
|
|
832
|
-
Keys.TEAM = "team";
|
|
833
|
-
Keys.QUEUE = "queue";
|
|
834
|
-
Keys.WORKING = "working";
|
|
835
|
-
Keys.FOCUS = "focus";
|
|
836
|
-
Keys.ANSWERED = "answered";
|
|
837
|
-
Keys.CARDS = "cards";
|
|
838
|
-
Keys.MESSAGES = "messages/";
|
|
839
|
-
Keys.messages = (channelId) => `${Keys.MESSAGES}${channelId}`;
|
|
840
|
-
})(Keys ||= {});
|
|
841
|
-
var USER = "user";
|
|
842
|
-
var TA = "ta";
|
|
843
|
-
var SYSTEM = "system";
|
|
844
|
-
var MAX_HOPS = 3;
|
|
845
|
-
var MAX_REPLIES = 8;
|
|
846
|
-
var MAX_AGENT_REPLIES = 2;
|
|
847
|
-
var STOP_NOTE = "The agents stopped handing on here, at the limit of a round; it is your turn.";
|
|
848
|
-
var MAX_MESSAGES = 200;
|
|
849
|
-
var FACES = 16;
|
|
850
|
-
var MAX_MEMBERS = 12;
|
|
851
|
-
var CONTEXT_MESSAGES = 12;
|
|
852
|
-
var MAX_NAME = 32;
|
|
853
|
-
var MAX_NOTICE = 2000;
|
|
854
|
-
var NOTICE_HEADINGS = { zh: ["决定", "约定", "待办"], en: ["Decisions", "Conventions", "To do"] };
|
|
855
|
-
var CARD_DAYS = 30;
|
|
856
|
-
|
|
857
|
-
// web-src/channels-util.ts
|
|
858
|
-
var ChannelsUtil;
|
|
859
|
-
((ChannelsUtil) => {
|
|
860
|
-
function newRound() {
|
|
861
|
-
return { total: 0, byAgent: {}, stopped: false };
|
|
1582
|
+
TaLocation2.readHost = readHost;
|
|
1583
|
+
function ssh(host2, path2 = "") {
|
|
1584
|
+
return isCloud(host2) ? `${host2}${path2 ? normalize(path2) : ""}` : `${TaLocation2.SSH}${host2}${path2 ? normalize(path2) : ""}`;
|
|
862
1585
|
}
|
|
863
|
-
|
|
864
|
-
function
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
let total = round.total;
|
|
868
|
-
for (const id of targets2) {
|
|
869
|
-
if (hops < MAX_HOPS && total < MAX_REPLIES && (byAgent[id] ?? 0) < MAX_AGENT_REPLIES) {
|
|
870
|
-
allowed.push(id);
|
|
871
|
-
byAgent[id] = (byAgent[id] ?? 0) + 1;
|
|
872
|
-
total++;
|
|
873
|
-
}
|
|
1586
|
+
TaLocation2.ssh = ssh;
|
|
1587
|
+
function hostLabel(host2) {
|
|
1588
|
+
if (isCloud(host2)) {
|
|
1589
|
+
return host2.slice(TaLocation2.CLOUD.length);
|
|
874
1590
|
}
|
|
875
|
-
const
|
|
876
|
-
|
|
877
|
-
return { allowed, round: { total, byAgent, stopped: round.stopped || cut }, cut, note };
|
|
1591
|
+
const name = host2.replace(/^[^@]*@/, "").replace(/^\[(.*)\](?::\d+)?$/, "$1").replace(/^([^:]*):\d+$/, "$1");
|
|
1592
|
+
return /^[\d.]+$/.test(name) || name.includes(":") ? name : name.split(".")[0] || name;
|
|
878
1593
|
}
|
|
879
|
-
|
|
880
|
-
function
|
|
881
|
-
|
|
1594
|
+
TaLocation2.hostLabel = hostLabel;
|
|
1595
|
+
function host(location) {
|
|
1596
|
+
var _a;
|
|
1597
|
+
return isRemote(location) ? (_a = parse(location)) === null || _a === undefined ? undefined : _a.host : undefined;
|
|
882
1598
|
}
|
|
883
|
-
|
|
884
|
-
function
|
|
885
|
-
|
|
1599
|
+
TaLocation2.host = host;
|
|
1600
|
+
function path(location) {
|
|
1601
|
+
var _a;
|
|
1602
|
+
var _b;
|
|
1603
|
+
return (_b = (_a = parse(location)) === null || _a === undefined ? undefined : _a.path) !== null && _b !== undefined ? _b : location;
|
|
886
1604
|
}
|
|
887
|
-
|
|
888
|
-
function
|
|
889
|
-
const
|
|
890
|
-
if (
|
|
891
|
-
|
|
1605
|
+
TaLocation2.path = path;
|
|
1606
|
+
function parent(location) {
|
|
1607
|
+
const remote = parse(location);
|
|
1608
|
+
if (remote) {
|
|
1609
|
+
const above = remote.path ? parentPath(remote.path) : undefined;
|
|
1610
|
+
return above === undefined ? undefined : ssh(remote.host, above);
|
|
892
1611
|
}
|
|
893
|
-
return
|
|
1612
|
+
return parentPath(location);
|
|
894
1613
|
}
|
|
895
|
-
|
|
896
|
-
function
|
|
897
|
-
const
|
|
898
|
-
if (
|
|
899
|
-
return
|
|
1614
|
+
TaLocation2.parent = parent;
|
|
1615
|
+
function child(location, name) {
|
|
1616
|
+
const remote = parse(location);
|
|
1617
|
+
if (remote) {
|
|
1618
|
+
return ssh(remote.host, childPath(remote.path || "/", name));
|
|
900
1619
|
}
|
|
901
|
-
|
|
902
|
-
return words.length > 1 ? (words[0][0] + words[1][0]).toUpperCase() : first.toUpperCase();
|
|
1620
|
+
return childPath(location, name);
|
|
903
1621
|
}
|
|
904
|
-
|
|
905
|
-
function
|
|
906
|
-
const
|
|
907
|
-
const
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
1622
|
+
TaLocation2.child = child;
|
|
1623
|
+
function basename(location) {
|
|
1624
|
+
const remote = parse(location);
|
|
1625
|
+
const path2 = (remote ? remote.path : location).replace(/[\\/]+$/, "");
|
|
1626
|
+
const name = path2.slice(Math.max(path2.lastIndexOf("/"), path2.lastIndexOf("\\")) + 1);
|
|
1627
|
+
return name || (remote === null || remote === undefined ? undefined : remote.host) || location;
|
|
1628
|
+
}
|
|
1629
|
+
TaLocation2.basename = basename;
|
|
1630
|
+
function homeRelative(location) {
|
|
1631
|
+
var _a;
|
|
1632
|
+
const remote = parse(location);
|
|
1633
|
+
const path2 = remote ? remote.path ? remote.path.slice(1) : "~" : location;
|
|
1634
|
+
const match = /^~(?:[\\/]+(.*))?$/.exec(path2);
|
|
1635
|
+
return match ? ((_a = match[1]) !== null && _a !== undefined ? _a : "").replace(/[\\/]+$/, "") : undefined;
|
|
1636
|
+
}
|
|
1637
|
+
TaLocation2.homeRelative = homeRelative;
|
|
1638
|
+
function isAbsolute(location) {
|
|
1639
|
+
if (homeRelative(location) !== undefined) {
|
|
1640
|
+
return false;
|
|
913
1641
|
}
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
1642
|
+
return isRemote(location) || /^([\\/]|[A-Za-z]:)/.test(location);
|
|
1643
|
+
}
|
|
1644
|
+
TaLocation2.isAbsolute = isAbsolute;
|
|
1645
|
+
function parentPath(path2) {
|
|
1646
|
+
const trimmed = path2.replace(/[\\/]+$/, "");
|
|
1647
|
+
const at = Math.max(trimmed.lastIndexOf("/"), trimmed.lastIndexOf("\\"));
|
|
1648
|
+
if (at < 0) {
|
|
1649
|
+
return;
|
|
920
1650
|
}
|
|
921
|
-
|
|
1651
|
+
const head = trimmed.slice(0, at);
|
|
1652
|
+
return head === "" || /^[A-Za-z]:$/.test(head) ? head + trimmed[at] : head;
|
|
922
1653
|
}
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
return
|
|
1654
|
+
function childPath(path2, name) {
|
|
1655
|
+
const separator = path2.includes("/") || !path2.includes("\\") ? "/" : "\\";
|
|
1656
|
+
return path2.endsWith(separator) ? path2 + name : path2 + separator + name;
|
|
926
1657
|
}
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
return
|
|
1658
|
+
function normalize(path2) {
|
|
1659
|
+
const squeezed = `/${path2}`.replace(/\/+/g, "/");
|
|
1660
|
+
return squeezed.length > 1 ? squeezed.replace(/\/$/, "") : squeezed;
|
|
930
1661
|
}
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
1662
|
+
})(TaLocation || (TaLocation = {}));
|
|
1663
|
+
// ../ta-protocol/esm/common/message-protocol.js
|
|
1664
|
+
var TaMessageContext;
|
|
1665
|
+
(function(TaMessageContext2) {
|
|
1666
|
+
const BLOCK = /^<context>\n?[\s\S]*?\n?<\/context>\n?/;
|
|
1667
|
+
function wrap(context, message) {
|
|
1668
|
+
return `<context>
|
|
1669
|
+
${context}
|
|
1670
|
+
</context>
|
|
1671
|
+
${message}`;
|
|
1672
|
+
}
|
|
1673
|
+
TaMessageContext2.wrap = wrap;
|
|
1674
|
+
function strip(message) {
|
|
1675
|
+
return message.replace(BLOCK, "");
|
|
1676
|
+
}
|
|
1677
|
+
TaMessageContext2.strip = strip;
|
|
1678
|
+
function read(message) {
|
|
1679
|
+
var _a;
|
|
1680
|
+
const block = (_a = BLOCK.exec(message)) === null || _a === undefined ? undefined : _a[0];
|
|
1681
|
+
return block === null || block === undefined ? undefined : block.replace(/^<context>\n?/, "").replace(/\n?<\/context>\n?$/, "");
|
|
1682
|
+
}
|
|
1683
|
+
TaMessageContext2.read = read;
|
|
1684
|
+
})(TaMessageContext || (TaMessageContext = {}));
|
|
1685
|
+
var TaMessageSource;
|
|
1686
|
+
(function(TaMessageSource2) {
|
|
1687
|
+
TaMessageSource2.DOUBLE = "ta:double";
|
|
1688
|
+
const LINE = /^\[ta:from ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
|
|
1689
|
+
function mark(message, from, detail) {
|
|
1690
|
+
if (/^[/!]/.test(message) || of(message)) {
|
|
1691
|
+
return message;
|
|
936
1692
|
}
|
|
937
|
-
|
|
1693
|
+
const line = `[ta:from ${from}${detail ? ` ${detail.replace(/[\]\n]/g, " ")}` : ""}]`;
|
|
1694
|
+
const context = TaMessageContext.read(message);
|
|
1695
|
+
return TaMessageContext.wrap(context === undefined ? line : `${context}
|
|
1696
|
+
${line}`, TaMessageContext.strip(message));
|
|
938
1697
|
}
|
|
939
|
-
|
|
940
|
-
function
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
1698
|
+
TaMessageSource2.mark = mark;
|
|
1699
|
+
function of(message) {
|
|
1700
|
+
const context = TaMessageContext.read(message);
|
|
1701
|
+
const match = context === undefined ? null : LINE.exec(context);
|
|
1702
|
+
return match ? { from: match[1], ...match[2] ? { detail: match[2].trim() } : {} } : undefined;
|
|
1703
|
+
}
|
|
1704
|
+
TaMessageSource2.of = of;
|
|
1705
|
+
})(TaMessageSource || (TaMessageSource = {}));
|
|
1706
|
+
var TaImageNote;
|
|
1707
|
+
(function(TaImageNote2) {
|
|
1708
|
+
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 [^\]]+\.\]$/;
|
|
1709
|
+
function strip(text) {
|
|
1710
|
+
const lines = text.split(`
|
|
1711
|
+
`);
|
|
1712
|
+
const kept = lines.filter((line) => !NOTE.test(line.trim()));
|
|
1713
|
+
if (kept.length === lines.length) {
|
|
1714
|
+
return text;
|
|
946
1715
|
}
|
|
947
|
-
return
|
|
1716
|
+
return kept.join(`
|
|
1717
|
+
`).replace(/\n+$/, "").replace(/^\n+/, "");
|
|
948
1718
|
}
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
1719
|
+
TaImageNote2.strip = strip;
|
|
1720
|
+
})(TaImageNote || (TaImageNote = {}));
|
|
1721
|
+
var TaImageSize;
|
|
1722
|
+
(function(TaImageSize2) {
|
|
1723
|
+
const JPEG_BYTES = 256 * 1024;
|
|
1724
|
+
function of(base64) {
|
|
1725
|
+
var _a, _b, _c;
|
|
1726
|
+
let bytes;
|
|
1727
|
+
try {
|
|
1728
|
+
const binary = atob(base64.slice(0, Math.ceil(JPEG_BYTES * 4 / 3 / 4) * 4));
|
|
1729
|
+
bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
1730
|
+
} catch (_d) {
|
|
1731
|
+
return;
|
|
953
1732
|
}
|
|
954
|
-
|
|
1733
|
+
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);
|
|
1734
|
+
return size && size.width > 0 && size.height > 0 ? size : undefined;
|
|
955
1735
|
}
|
|
956
|
-
|
|
957
|
-
function
|
|
958
|
-
|
|
959
|
-
return team.agents.find((agent) => agent.id === ref) ?? team.agents.find((agent) => agent.name.toLowerCase() === key);
|
|
1736
|
+
TaImageSize2.of = of;
|
|
1737
|
+
function u16be(bytes, at) {
|
|
1738
|
+
return bytes[at] << 8 | bytes[at + 1];
|
|
960
1739
|
}
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
const key = ref.trim().replace(/^#/, "").toLowerCase();
|
|
964
|
-
return team.channels.find((channel) => channel.id === ref) ?? team.channels.find((channel) => channel.name.toLowerCase() === key);
|
|
1740
|
+
function u16le(bytes, at) {
|
|
1741
|
+
return bytes[at] | bytes[at + 1] << 8;
|
|
965
1742
|
}
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
1743
|
+
function u24le(bytes, at) {
|
|
1744
|
+
return bytes[at] | bytes[at + 1] << 8 | bytes[at + 2] << 16;
|
|
969
1745
|
}
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
const name = checkName(input.name, "agent");
|
|
973
|
-
if (findAgent(team, name)) {
|
|
974
|
-
throw new Error(`There is an agent named ${name} already.`);
|
|
975
|
-
}
|
|
976
|
-
const role = typeof input.role === "string" ? input.role.trim() : "";
|
|
977
|
-
if (!role) {
|
|
978
|
-
throw new Error(`Say what ${name} does: its role.`);
|
|
979
|
-
}
|
|
980
|
-
const cwd = directory(input.cwd);
|
|
981
|
-
const id = newId("agent");
|
|
982
|
-
const face = isFace(input.face) ? input.face : freeFace(hash(id), new Set(faces(team.agents).values()));
|
|
983
|
-
const agent = { id, name, role, mark: mark(name), face, cwd, ...input.temporary ? { temporary: true } : {}, createdAt: Date.now() };
|
|
984
|
-
return { team: { ...team, agents: [...team.agents, agent] }, agent };
|
|
1746
|
+
function u32be(bytes, at) {
|
|
1747
|
+
return (bytes[at] << 24 | bytes[at + 1] << 16 | bytes[at + 2] << 8 | bytes[at + 3]) >>> 0;
|
|
985
1748
|
}
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
const name = checkName(input.name, "channel");
|
|
989
|
-
if (findChannel(team, name)) {
|
|
990
|
-
throw new Error(`There is a channel named ${name} already.`);
|
|
991
|
-
}
|
|
992
|
-
const members = agentIds(team, input.members);
|
|
993
|
-
if (members.length === 0) {
|
|
994
|
-
throw new Error("A channel needs at least one agent.");
|
|
995
|
-
}
|
|
996
|
-
if (members.length > MAX_MEMBERS) {
|
|
997
|
-
throw new Error(`A channel holds at most ${MAX_MEMBERS} agents.`);
|
|
998
|
-
}
|
|
999
|
-
const topic = typeof input.topic === "string" && input.topic.trim() ? input.topic.trim() : undefined;
|
|
1000
|
-
const channel = {
|
|
1001
|
-
id: newId("channel"),
|
|
1002
|
-
name,
|
|
1003
|
-
topic,
|
|
1004
|
-
members,
|
|
1005
|
-
...input.by ? { by: input.by } : {},
|
|
1006
|
-
...input.origin ? { origin: input.origin } : {},
|
|
1007
|
-
createdAt: Date.now()
|
|
1008
|
-
};
|
|
1009
|
-
return { team: { ...team, channels: [...team.channels, channel] }, channel };
|
|
1749
|
+
function text(bytes, at, length) {
|
|
1750
|
+
return String.fromCharCode(...bytes.subarray(at, at + length));
|
|
1010
1751
|
}
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
const found = channelOf(team, input.channel);
|
|
1014
|
-
const ids = agentIds(team, input.members);
|
|
1015
|
-
if (ids.length === 0) {
|
|
1016
|
-
throw new Error("Name at least one agent to add.");
|
|
1017
|
-
}
|
|
1018
|
-
const added = ids.filter((id) => !found.members.includes(id)).map((id) => team.agents.find((agent) => agent.id === id));
|
|
1019
|
-
if (found.members.length + added.length > MAX_MEMBERS) {
|
|
1020
|
-
throw new Error(`A channel holds at most ${MAX_MEMBERS} agents; #${found.name} has ${found.members.length}.`);
|
|
1021
|
-
}
|
|
1022
|
-
const channel = { ...found, members: [...found.members, ...added.map((agent) => agent.id)] };
|
|
1023
|
-
return { team: { ...team, channels: team.channels.map((other) => other.id === channel.id ? channel : other) }, channel, added };
|
|
1752
|
+
function png(bytes) {
|
|
1753
|
+
return bytes.length >= 24 && bytes[0] === 137 && text(bytes, 1, 3) === "PNG" ? { width: u32be(bytes, 16), height: u32be(bytes, 20) } : undefined;
|
|
1024
1754
|
}
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
const key = typeof ref === "string" ? ref : "";
|
|
1028
|
-
const found = findChannel(team, key);
|
|
1029
|
-
if (!found) {
|
|
1030
|
-
const known = team.channels.map((other) => `#${other.name}`).join(", ") || "none yet";
|
|
1031
|
-
throw new Error(`No channel is named ${key}. The channels: ${known}.`);
|
|
1032
|
-
}
|
|
1033
|
-
return found;
|
|
1755
|
+
function gif(bytes) {
|
|
1756
|
+
return bytes.length >= 10 && text(bytes, 0, 3) === "GIF" ? { width: u16le(bytes, 6), height: u16le(bytes, 8) } : undefined;
|
|
1034
1757
|
}
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
const agent = findAgent(team, typeof input.agent === "string" ? input.agent : "");
|
|
1039
|
-
if (!agent || !found.members.includes(agent.id)) {
|
|
1040
|
-
throw new Error(`${agent?.name ?? String(input.agent)} is not a member of #${found.name}.`);
|
|
1041
|
-
}
|
|
1042
|
-
if (typeof input.change !== "string" || !MEMBER_CHANGES.includes(input.change)) {
|
|
1043
|
-
throw new Error(`A member is changed with one of ${MEMBER_CHANGES.join(", ")}.`);
|
|
1758
|
+
function webp(bytes) {
|
|
1759
|
+
if (bytes.length < 30 || text(bytes, 0, 4) !== "RIFF" || text(bytes, 8, 4) !== "WEBP") {
|
|
1760
|
+
return;
|
|
1044
1761
|
}
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
case "
|
|
1053
|
-
|
|
1054
|
-
throw new Error(`${agent.name} is the only member of #${found.name}: delete the channel instead.`);
|
|
1055
|
-
}
|
|
1056
|
-
channel = { ...found, members: others, muted };
|
|
1057
|
-
break;
|
|
1058
|
-
case "mute":
|
|
1059
|
-
channel = { ...found, muted: [...muted, agent.id] };
|
|
1060
|
-
break;
|
|
1762
|
+
switch (text(bytes, 12, 4)) {
|
|
1763
|
+
case "VP8 ":
|
|
1764
|
+
return { width: u16le(bytes, 26) & 16383, height: u16le(bytes, 28) & 16383 };
|
|
1765
|
+
case "VP8L": {
|
|
1766
|
+
const bits = bytes[21] | bytes[22] << 8 | bytes[23] << 16 | bytes[24] << 24;
|
|
1767
|
+
return { width: (bits & 16383) + 1, height: (bits >> 14 & 16383) + 1 };
|
|
1768
|
+
}
|
|
1769
|
+
case "VP8X":
|
|
1770
|
+
return { width: u24le(bytes, 24) + 1, height: u24le(bytes, 27) + 1 };
|
|
1061
1771
|
default:
|
|
1062
|
-
|
|
1063
|
-
}
|
|
1064
|
-
if (channel.muted?.length === 0) {
|
|
1065
|
-
delete channel.muted;
|
|
1772
|
+
return;
|
|
1066
1773
|
}
|
|
1067
|
-
return { team: { ...team, channels: team.channels.map((other) => other.id === channel.id ? channel : other) }, channel };
|
|
1068
1774
|
}
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
const channel = { ...before };
|
|
1073
|
-
if (input.name !== undefined) {
|
|
1074
|
-
const name = checkName(input.name, "channel");
|
|
1075
|
-
const other = findChannel(team, name);
|
|
1076
|
-
if (other && other.id !== channel.id) {
|
|
1077
|
-
throw new Error(`There is a channel named ${name} already.`);
|
|
1078
|
-
}
|
|
1079
|
-
channel.name = name;
|
|
1775
|
+
function jpeg(bytes) {
|
|
1776
|
+
if (bytes[0] !== 255 || bytes[1] !== 216) {
|
|
1777
|
+
return;
|
|
1080
1778
|
}
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
if (
|
|
1084
|
-
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1779
|
+
let at = 2;
|
|
1780
|
+
while (at + 9 < bytes.length) {
|
|
1781
|
+
if (bytes[at] !== 255) {
|
|
1782
|
+
return;
|
|
1783
|
+
}
|
|
1784
|
+
const marker = bytes[at + 1];
|
|
1785
|
+
if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) {
|
|
1786
|
+
return { width: u16be(bytes, at + 7), height: u16be(bytes, at + 5) };
|
|
1087
1787
|
}
|
|
1788
|
+
at += 2 + u16be(bytes, at + 2);
|
|
1088
1789
|
}
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1790
|
+
return;
|
|
1791
|
+
}
|
|
1792
|
+
})(TaImageSize || (TaImageSize = {}));
|
|
1793
|
+
var TaAgentSummary;
|
|
1794
|
+
(function(TaAgentSummary2) {
|
|
1795
|
+
const START = /^\s*<conversation_history_summary>/;
|
|
1796
|
+
const BLOCK = /^\s*<conversation_history_summary>[\s\S]*?(?:<\/conversation_history_summary>\s*|$)/;
|
|
1797
|
+
function read(text) {
|
|
1798
|
+
if (!START.test(text)) {
|
|
1799
|
+
return;
|
|
1095
1800
|
}
|
|
1096
|
-
return
|
|
1801
|
+
return text.replace(/<\/?(?:conversation_history_summary|summary)>/g, "").replace(/<\/?\w*$/, "").trim();
|
|
1097
1802
|
}
|
|
1098
|
-
|
|
1099
|
-
function
|
|
1100
|
-
|
|
1101
|
-
return team.agents.filter((agent) => !agent.temporary || !inChannel.has(agent.id));
|
|
1803
|
+
TaAgentSummary2.read = read;
|
|
1804
|
+
function strip(text) {
|
|
1805
|
+
return text.replace(BLOCK, "");
|
|
1102
1806
|
}
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1807
|
+
TaAgentSummary2.strip = strip;
|
|
1808
|
+
})(TaAgentSummary || (TaAgentSummary = {}));
|
|
1809
|
+
var TaSkillUse;
|
|
1810
|
+
(function(TaSkillUse2) {
|
|
1811
|
+
const BLOCK = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
|
|
1812
|
+
function parse(message) {
|
|
1813
|
+
var _a;
|
|
1814
|
+
const match = BLOCK.exec(message);
|
|
1815
|
+
if (!match) {
|
|
1816
|
+
return;
|
|
1817
|
+
}
|
|
1818
|
+
return { name: match[1], location: match[2], content: match[3], message: ((_a = match[4]) === null || _a === undefined ? undefined : _a.trim()) || undefined };
|
|
1106
1819
|
}
|
|
1107
|
-
|
|
1108
|
-
function
|
|
1109
|
-
return
|
|
1820
|
+
TaSkillUse2.parse = parse;
|
|
1821
|
+
function command(use) {
|
|
1822
|
+
return use.message ? `/skill:${use.name} ${use.message}` : `/skill:${use.name}`;
|
|
1110
1823
|
}
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1824
|
+
TaSkillUse2.command = command;
|
|
1825
|
+
})(TaSkillUse || (TaSkillUse = {}));
|
|
1826
|
+
var TaTaskNote;
|
|
1827
|
+
(function(TaTaskNote2) {
|
|
1828
|
+
const NOTE = /^<task_(update|adopted|renamed) ((?:[^>"\n]|"[^"]*")*)>\n?([\s\S]*?)\n?<\/task_\1>$/;
|
|
1829
|
+
const ATTRIBUTE = /(\w+)="([^"]*)"/g;
|
|
1830
|
+
function write(note) {
|
|
1831
|
+
const attributes = [`id="${quote(note.id)}"`];
|
|
1832
|
+
if (note.was !== undefined) {
|
|
1833
|
+
attributes.push(`was="${quote(note.was)}"`);
|
|
1834
|
+
}
|
|
1835
|
+
attributes.push(`title="${quote(note.title)}"`);
|
|
1836
|
+
if (note.status !== undefined) {
|
|
1837
|
+
attributes.push(`status="${quote(note.status)}"`);
|
|
1838
|
+
}
|
|
1839
|
+
return `<task_${note.kind} ${attributes.join(" ")}>
|
|
1840
|
+
${note.body}
|
|
1841
|
+
</task_${note.kind}>`;
|
|
1842
|
+
}
|
|
1843
|
+
TaTaskNote2.write = write;
|
|
1844
|
+
function parse(text) {
|
|
1845
|
+
const match = NOTE.exec(text.trim());
|
|
1846
|
+
if (!match) {
|
|
1847
|
+
return;
|
|
1848
|
+
}
|
|
1849
|
+
const attributes = {};
|
|
1850
|
+
for (const [, name, value] of match[2].matchAll(ATTRIBUTE)) {
|
|
1851
|
+
attributes[name] = unquote(value);
|
|
1852
|
+
}
|
|
1853
|
+
if (!attributes.id || attributes.title === undefined) {
|
|
1854
|
+
return;
|
|
1855
|
+
}
|
|
1856
|
+
const { id, title, status, was } = attributes;
|
|
1857
|
+
return { kind: match[1], id, title, ...status ? { status } : {}, ...was ? { was } : {}, body: match[3] };
|
|
1114
1858
|
}
|
|
1115
|
-
|
|
1116
|
-
function
|
|
1117
|
-
|
|
1118
|
-
return { team: { ...team, channels: team.channels.filter((other) => other.id !== channel.id) }, channel };
|
|
1859
|
+
TaTaskNote2.parse = parse;
|
|
1860
|
+
function quote(text) {
|
|
1861
|
+
return text.replace(/&/g, "&").replace(/"/g, """).replace(/\n/g, " ");
|
|
1119
1862
|
}
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1863
|
+
function unquote(text) {
|
|
1864
|
+
return text.replace(/"/g, '"').replace(/&/g, "&");
|
|
1865
|
+
}
|
|
1866
|
+
})(TaTaskNote || (TaTaskNote = {}));
|
|
1867
|
+
// ../ta-protocol/esm/common/package-protocol.js
|
|
1868
|
+
var TaPackageServer = Symbol("TaPackageServer");
|
|
1869
|
+
var TaPackageTextUtil;
|
|
1870
|
+
(function(TaPackageTextUtil2) {
|
|
1871
|
+
function pick(text, language) {
|
|
1872
|
+
var _a, _b, _c, _d, _e;
|
|
1873
|
+
if (text === undefined || typeof text === "string") {
|
|
1874
|
+
return text;
|
|
1125
1875
|
}
|
|
1126
|
-
const
|
|
1127
|
-
|
|
1876
|
+
const base = language.split("-")[0];
|
|
1877
|
+
const kin = Object.keys(text).find((key) => key.split("-")[0] === base);
|
|
1878
|
+
return (_e = (_d = (_c = (_b = (_a = text[language]) !== null && _a !== undefined ? _a : text[base]) !== null && _b !== undefined ? _b : kin === undefined ? undefined : text[kin]) !== null && _c !== undefined ? _c : text.en) !== null && _d !== undefined ? _d : text["en-US"]) !== null && _e !== undefined ? _e : Object.values(text)[0];
|
|
1128
1879
|
}
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1880
|
+
TaPackageTextUtil2.pick = pick;
|
|
1881
|
+
})(TaPackageTextUtil || (TaPackageTextUtil = {}));
|
|
1882
|
+
// ../ta-protocol/esm/common/page-protocol.js
|
|
1883
|
+
var TaPageServer = Symbol("TaPageServer");
|
|
1884
|
+
// ../ta-protocol/esm/common/path-map.js
|
|
1885
|
+
var TaPathMap;
|
|
1886
|
+
(function(TaPathMap2) {
|
|
1887
|
+
function isWindows(path2) {
|
|
1888
|
+
return /^[a-zA-Z]:([\\/]|$)/.test(path2) || /^\\\\[^\\]/.test(path2);
|
|
1889
|
+
}
|
|
1890
|
+
TaPathMap2.isWindows = isWindows;
|
|
1891
|
+
function rest(path2, base) {
|
|
1892
|
+
const windows = isWindows(base);
|
|
1893
|
+
if (windows ? !isWindows(path2) : !base.startsWith("/") || !path2.startsWith("/")) {
|
|
1894
|
+
return;
|
|
1134
1895
|
}
|
|
1135
|
-
const
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
if (other && other.id !== agent.id) {
|
|
1140
|
-
throw new Error(`There is an agent named ${name} already.`);
|
|
1141
|
-
}
|
|
1142
|
-
agent.name = name;
|
|
1143
|
-
agent.mark = mark(name);
|
|
1896
|
+
const within = parts(base, windows);
|
|
1897
|
+
const all = parts(path2, windows);
|
|
1898
|
+
if (!within.length || all.length < within.length) {
|
|
1899
|
+
return;
|
|
1144
1900
|
}
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1901
|
+
const same = (a, b) => windows ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
1902
|
+
return within.every((part, i) => same(part, all[i])) ? all.slice(within.length) : undefined;
|
|
1903
|
+
}
|
|
1904
|
+
TaPathMap2.rest = rest;
|
|
1905
|
+
function under(path2, base) {
|
|
1906
|
+
return rest(path2, base) !== undefined;
|
|
1907
|
+
}
|
|
1908
|
+
TaPathMap2.under = under;
|
|
1909
|
+
function join(base, parts2) {
|
|
1910
|
+
if (!parts2.length) {
|
|
1911
|
+
return base;
|
|
1151
1912
|
}
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1913
|
+
const sep = isWindows(base) ? "\\" : "/";
|
|
1914
|
+
return `${base.replace(/[\\/]+$/, "")}${sep}${parts2.join(sep)}`;
|
|
1915
|
+
}
|
|
1916
|
+
TaPathMap2.join = join;
|
|
1917
|
+
function basename(path2) {
|
|
1918
|
+
var _a;
|
|
1919
|
+
return (_a = path2.split(/[\\/]+/).filter(Boolean).pop()) !== null && _a !== undefined ? _a : "";
|
|
1920
|
+
}
|
|
1921
|
+
TaPathMap2.basename = basename;
|
|
1922
|
+
function path(value, pairs) {
|
|
1923
|
+
for (const [from, to] of deepest(pairs)) {
|
|
1924
|
+
const found = rest(value, from);
|
|
1925
|
+
if (found) {
|
|
1926
|
+
return join(to, found);
|
|
1155
1927
|
}
|
|
1156
|
-
agent.face = input.face;
|
|
1157
1928
|
}
|
|
1158
|
-
|
|
1159
|
-
|
|
1929
|
+
return value;
|
|
1930
|
+
}
|
|
1931
|
+
TaPathMap2.path = path;
|
|
1932
|
+
function text(value, pairs) {
|
|
1933
|
+
const order = deepest(pairs);
|
|
1934
|
+
if (!order.length) {
|
|
1935
|
+
return value;
|
|
1160
1936
|
}
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1937
|
+
const end = String.raw`\s"'<>|*?:;,`;
|
|
1938
|
+
const pattern = new RegExp(String.raw`(^|[^\w.~-])(?:${order.map(([from]) => `(${source(from)})`).join("|")})((?:[\\/][^\\/${end}]*)*)(?=$|[\\/${end})\]}])`, "g");
|
|
1939
|
+
return value.replace(pattern, (...match) => {
|
|
1940
|
+
var _a;
|
|
1941
|
+
const before = match[1];
|
|
1942
|
+
const found = order.findIndex((_, i) => match[i + 2] !== undefined);
|
|
1943
|
+
const tail = (_a = match[order.length + 2]) !== null && _a !== undefined ? _a : "";
|
|
1944
|
+
return `${before}${join(order[found][1], tail.split(/[\\/]+/).filter(Boolean))}`;
|
|
1945
|
+
});
|
|
1946
|
+
}
|
|
1947
|
+
TaPathMap2.text = text;
|
|
1948
|
+
function json(value, pairs) {
|
|
1949
|
+
const order = deepest(pairs);
|
|
1950
|
+
if (!order.length) {
|
|
1951
|
+
return value;
|
|
1165
1952
|
}
|
|
1166
|
-
|
|
1167
|
-
const
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1953
|
+
const one = (each) => {
|
|
1954
|
+
const whole = path(each, order);
|
|
1955
|
+
return whole !== each ? whole : text(each, order);
|
|
1956
|
+
};
|
|
1957
|
+
const walk = (each) => {
|
|
1958
|
+
if (typeof each === "string") {
|
|
1959
|
+
return one(each);
|
|
1171
1960
|
}
|
|
1172
|
-
if (
|
|
1173
|
-
|
|
1961
|
+
if (Array.isArray(each)) {
|
|
1962
|
+
return each.map(walk);
|
|
1174
1963
|
}
|
|
1964
|
+
if (each && typeof each === "object") {
|
|
1965
|
+
return Object.fromEntries(Object.entries(each).map(([key, inner]) => [one(key), walk(inner)]));
|
|
1966
|
+
}
|
|
1967
|
+
return each;
|
|
1968
|
+
};
|
|
1969
|
+
return walk(value);
|
|
1970
|
+
}
|
|
1971
|
+
TaPathMap2.json = json;
|
|
1972
|
+
function parts(path2, windows) {
|
|
1973
|
+
return path2.split(windows ? /[\\/]+/ : /\/+/).filter(Boolean);
|
|
1974
|
+
}
|
|
1975
|
+
function deepest(pairs) {
|
|
1976
|
+
return pairs.filter(([from, to]) => from && to && from !== to && parts(from, isWindows(from)).length > 0).sort(([a], [b]) => parts(b, isWindows(b)).length - parts(a, isWindows(a)).length);
|
|
1977
|
+
}
|
|
1978
|
+
function source(base) {
|
|
1979
|
+
const windows = isWindows(base);
|
|
1980
|
+
const quote = (part) => [...part].map((char) => windows && char.toLowerCase() !== char.toUpperCase() ? `[${char.toLowerCase()}${char.toUpperCase()}]` : char.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("");
|
|
1981
|
+
const each = parts(base, windows).map(quote);
|
|
1982
|
+
if (!windows) {
|
|
1983
|
+
return `/${each.join("/+")}`;
|
|
1175
1984
|
}
|
|
1176
|
-
return {
|
|
1985
|
+
return `${base.startsWith("\\\\") ? String.raw`\\\\` : ""}${each.join(String.raw`[\\/]+`)}`;
|
|
1177
1986
|
}
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1987
|
+
})(TaPathMap || (TaPathMap = {}));
|
|
1988
|
+
// ../ta-protocol/esm/common/presence-protocol.js
|
|
1989
|
+
var TaPresenceServer = Symbol("TaPresenceServer");
|
|
1990
|
+
var TaMessageAuthor;
|
|
1991
|
+
(function(TaMessageAuthor2) {
|
|
1992
|
+
const LINE = /^\[ta:by ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
|
|
1993
|
+
const LINES = /^\[ta:by [^\]\n]*\]$\n?/gm;
|
|
1994
|
+
function strip(message) {
|
|
1995
|
+
const context = TaMessageContext.read(message);
|
|
1996
|
+
if (context === undefined || !LINE.test(context)) {
|
|
1997
|
+
return message;
|
|
1183
1998
|
}
|
|
1184
|
-
const
|
|
1185
|
-
const
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
gone.push(channel);
|
|
1194
|
-
continue;
|
|
1195
|
-
}
|
|
1196
|
-
const muted = channel.muted?.filter((id) => id !== agent.id);
|
|
1197
|
-
const next = { ...channel, members, muted };
|
|
1198
|
-
if (!muted?.length) {
|
|
1199
|
-
delete next.muted;
|
|
1200
|
-
}
|
|
1201
|
-
channels.push(next);
|
|
1999
|
+
const kept = context.replace(LINES, "").replace(/\n+$/, "");
|
|
2000
|
+
const body = TaMessageContext.strip(message);
|
|
2001
|
+
return kept.trim() ? TaMessageContext.wrap(kept, body) : body;
|
|
2002
|
+
}
|
|
2003
|
+
TaMessageAuthor2.strip = strip;
|
|
2004
|
+
function mark(message, id, name) {
|
|
2005
|
+
const plain = strip(message);
|
|
2006
|
+
if (/^[/!]/.test(plain)) {
|
|
2007
|
+
return plain;
|
|
1202
2008
|
}
|
|
1203
|
-
|
|
2009
|
+
const line = `[ta:by ${id.replace(/[\s\]]/g, "")} ${name.replace(/[\]\n]/g, " ").trim() || id}]`;
|
|
2010
|
+
const context = TaMessageContext.read(plain);
|
|
2011
|
+
return TaMessageContext.wrap(context === undefined ? line : `${context}
|
|
2012
|
+
${line}`, TaMessageContext.strip(plain));
|
|
1204
2013
|
}
|
|
1205
|
-
|
|
1206
|
-
function
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
2014
|
+
TaMessageAuthor2.mark = mark;
|
|
2015
|
+
function of(message) {
|
|
2016
|
+
var _a;
|
|
2017
|
+
const context = TaMessageContext.read(message);
|
|
2018
|
+
const match = context === undefined ? null : LINE.exec(context);
|
|
2019
|
+
return match ? { id: match[1], name: ((_a = match[2]) !== null && _a !== undefined ? _a : match[1]).trim() } : undefined;
|
|
2020
|
+
}
|
|
2021
|
+
TaMessageAuthor2.of = of;
|
|
2022
|
+
})(TaMessageAuthor || (TaMessageAuthor = {}));
|
|
2023
|
+
// ../ta-protocol/esm/common/relay-protocol.js
|
|
2024
|
+
var TaRelayServer = Symbol("TaRelayServer");
|
|
2025
|
+
// ../ta-protocol/esm/common/remote-protocol.js
|
|
2026
|
+
var TaRemoteServer = Symbol("TaRemoteServer");
|
|
2027
|
+
// ../ta-protocol/esm/common/room-protocol.js
|
|
2028
|
+
var TaRoomServer = Symbol("TaRoomServer");
|
|
2029
|
+
var TaRoomWatchUtil;
|
|
2030
|
+
(function(TaRoomWatchUtil2) {
|
|
2031
|
+
function of(messages, state) {
|
|
2032
|
+
const prefixes = Array.isArray(state) ? state.filter((prefix) => typeof prefix === "string" && prefix.length > 0) : [];
|
|
2033
|
+
return { messages: messages !== false, state: [...new Set(prefixes)].sort() };
|
|
2034
|
+
}
|
|
2035
|
+
TaRoomWatchUtil2.of = of;
|
|
2036
|
+
function union(watches) {
|
|
2037
|
+
let messages = false;
|
|
2038
|
+
const state = [];
|
|
2039
|
+
for (const watch of watches) {
|
|
2040
|
+
messages || (messages = watch.messages);
|
|
2041
|
+
state.push(...watch.state);
|
|
1217
2042
|
}
|
|
1218
|
-
return
|
|
2043
|
+
return of(messages, messages ? [] : state);
|
|
2044
|
+
}
|
|
2045
|
+
TaRoomWatchUtil2.union = union;
|
|
2046
|
+
function same(a, b) {
|
|
2047
|
+
return a === b || !!a && !!b && a.messages === b.messages && a.state.join(`
|
|
2048
|
+
`) === b.state.join(`
|
|
2049
|
+
`);
|
|
2050
|
+
}
|
|
2051
|
+
TaRoomWatchUtil2.same = same;
|
|
2052
|
+
function hears(watch, event) {
|
|
2053
|
+
if (event.type === "message") {
|
|
2054
|
+
return watch.messages;
|
|
2055
|
+
}
|
|
2056
|
+
if (event.type === "state") {
|
|
2057
|
+
return watch.messages || watch.state.some((prefix) => event.key.startsWith(prefix));
|
|
2058
|
+
}
|
|
2059
|
+
return true;
|
|
2060
|
+
}
|
|
2061
|
+
TaRoomWatchUtil2.hears = hears;
|
|
2062
|
+
})(TaRoomWatchUtil || (TaRoomWatchUtil = {}));
|
|
2063
|
+
// ../ta-protocol/esm/common/settings-protocol.js
|
|
2064
|
+
var TaSettingsServer = Symbol("TaSettingsServer");
|
|
2065
|
+
// ../ta-protocol/esm/common/ta-protocol.js
|
|
2066
|
+
var TaServer = Symbol("TaServer");
|
|
2067
|
+
var TaClient = Symbol("TaClient");
|
|
2068
|
+
var TaSlashCommandUtil;
|
|
2069
|
+
(function(TaSlashCommandUtil2) {
|
|
2070
|
+
function description(command, language) {
|
|
2071
|
+
var _a, _b;
|
|
2072
|
+
const { descriptions } = command;
|
|
2073
|
+
return (_b = (_a = descriptions === null || descriptions === undefined ? undefined : descriptions[language]) !== null && _a !== undefined ? _a : descriptions === null || descriptions === undefined ? undefined : descriptions[language.split("-")[0]]) !== null && _b !== undefined ? _b : command.description;
|
|
1219
2074
|
}
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
2075
|
+
TaSlashCommandUtil2.description = description;
|
|
2076
|
+
})(TaSlashCommandUtil || (TaSlashCommandUtil = {}));
|
|
2077
|
+
// ../ta-protocol/esm/common/usage-protocol.js
|
|
2078
|
+
var TaUsageServer = Symbol("TaUsageServer");
|
|
2079
|
+
// ../ta-protocol/esm/common/voice-protocol.js
|
|
2080
|
+
var TaVoiceServer = Symbol("TaVoiceServer");
|
|
2081
|
+
// ../ta-protocol/esm/common/workspace-protocol.js
|
|
2082
|
+
var TaWorkspaceServer = Symbol("TaWorkspaceServer");
|
|
2083
|
+
var TaTerminalServer = Symbol("TaTerminalServer");
|
|
2084
|
+
var TaExcludedFiles;
|
|
2085
|
+
(function(TaExcludedFiles2) {
|
|
2086
|
+
TaExcludedFiles2.NAMES = [".git", ".svn", ".hg", ".DS_Store", "Thumbs.db"];
|
|
2087
|
+
function has(name) {
|
|
2088
|
+
return TaExcludedFiles2.NAMES.includes(name);
|
|
1227
2089
|
}
|
|
1228
|
-
|
|
1229
|
-
function
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
2090
|
+
TaExcludedFiles2.has = has;
|
|
2091
|
+
function filter(entries) {
|
|
2092
|
+
return entries.filter((entry) => !has(entry.name));
|
|
2093
|
+
}
|
|
2094
|
+
TaExcludedFiles2.filter = filter;
|
|
2095
|
+
})(TaExcludedFiles || (TaExcludedFiles = {}));
|
|
2096
|
+
var TA_UPLOAD_PART_BYTES = 4 * 1024 * 1024;
|
|
2097
|
+
// web-src/team-view.ts
|
|
2098
|
+
var TeamViewUtil;
|
|
2099
|
+
((TeamViewUtil) => {
|
|
2100
|
+
function visible(team2, can) {
|
|
2101
|
+
const channels = new Set(team2.channels.filter((channel) => can("channel", channel.id)).map((channel) => channel.id));
|
|
2102
|
+
const agents = new Set(team2.agents.filter((agent) => can("agent", agent.id)).map((agent) => agent.id));
|
|
2103
|
+
for (const channel of team2.channels) {
|
|
2104
|
+
if (channels.has(channel.id)) {
|
|
2105
|
+
for (const member of channel.members) {
|
|
2106
|
+
agents.add(member);
|
|
2107
|
+
}
|
|
1240
2108
|
}
|
|
1241
2109
|
}
|
|
1242
|
-
return
|
|
2110
|
+
return { agents, channels };
|
|
1243
2111
|
}
|
|
1244
|
-
|
|
1245
|
-
function
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
const named = mentions(message.text, members).filter((id) => id !== message.author);
|
|
1249
|
-
if (message.author === SYSTEM) {
|
|
1250
|
-
return [];
|
|
1251
|
-
}
|
|
1252
|
-
if (named.length > 0 || message.author !== USER && message.author !== TA) {
|
|
1253
|
-
return named;
|
|
2112
|
+
TeamViewUtil.visible = visible;
|
|
2113
|
+
function team(value, visible2) {
|
|
2114
|
+
if (!value) {
|
|
2115
|
+
return value;
|
|
1254
2116
|
}
|
|
1255
|
-
return
|
|
2117
|
+
return {
|
|
2118
|
+
...value,
|
|
2119
|
+
agents: value.agents.filter((agent) => visible2.agents.has(agent.id)),
|
|
2120
|
+
channels: value.channels.filter((channel) => visible2.channels.has(channel.id))
|
|
2121
|
+
};
|
|
1256
2122
|
}
|
|
1257
|
-
|
|
1258
|
-
function
|
|
1259
|
-
if (
|
|
1260
|
-
return
|
|
1261
|
-
}
|
|
1262
|
-
if (author === USER) {
|
|
1263
|
-
return labels.user;
|
|
1264
|
-
}
|
|
1265
|
-
if (author === TA) {
|
|
1266
|
-
return labels.ta;
|
|
2123
|
+
TeamViewUtil.team = team;
|
|
2124
|
+
function byId(value, seen) {
|
|
2125
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
2126
|
+
return value;
|
|
1267
2127
|
}
|
|
1268
|
-
return
|
|
2128
|
+
return Object.fromEntries(Object.entries(value).filter(([id]) => seen.has(id)));
|
|
1269
2129
|
}
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
2130
|
+
TeamViewUtil.byId = byId;
|
|
2131
|
+
})(TeamViewUtil ||= {});
|
|
2132
|
+
|
|
2133
|
+
// web-src/team-store.ts
|
|
2134
|
+
class TeamStore {
|
|
2135
|
+
host;
|
|
2136
|
+
team = ChannelsUtil.emptyTeam();
|
|
2137
|
+
queue = { jobs: [], rounds: {} };
|
|
2138
|
+
working = {};
|
|
2139
|
+
answered;
|
|
2140
|
+
messages = new Map;
|
|
2141
|
+
reading = new Map;
|
|
2142
|
+
agents = new Map;
|
|
2143
|
+
started = new Set;
|
|
2144
|
+
waiting = new Map;
|
|
2145
|
+
opening = new Map;
|
|
2146
|
+
settling = new Set;
|
|
2147
|
+
options;
|
|
2148
|
+
disposed = false;
|
|
2149
|
+
constructor(host, options = {}) {
|
|
2150
|
+
this.host = host;
|
|
2151
|
+
this.options = { pollMs: 300, timeoutMs: 15 * 60 * 1000, ...options };
|
|
1280
2152
|
}
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
if (
|
|
1287
|
-
throw new Error(`
|
|
2153
|
+
get state() {
|
|
2154
|
+
return this.team;
|
|
2155
|
+
}
|
|
2156
|
+
async shareAgent(ref, color) {
|
|
2157
|
+
const agent = ChannelsUtil.findAgent(this.team, String(ref ?? ""));
|
|
2158
|
+
if (!agent) {
|
|
2159
|
+
throw new Error(`No agent is ${String(ref)}.`);
|
|
1288
2160
|
}
|
|
1289
|
-
|
|
1290
|
-
|
|
2161
|
+
const card = JSON.stringify(AgentCards.card(agent, typeof color === "string" ? color : undefined));
|
|
2162
|
+
const cards = await this.get(Keys.CARDS) ?? {};
|
|
2163
|
+
const kept = cards[agent.id];
|
|
2164
|
+
const live = kept ? (await this.host.shares.list()).find((share2) => share2.id === kept.share) : undefined;
|
|
2165
|
+
if (live && kept?.card === card) {
|
|
2166
|
+
return live;
|
|
1291
2167
|
}
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
channel.notice = { text, at: input.at ?? Date.now(), by: input.by };
|
|
1295
|
-
} else {
|
|
1296
|
-
delete channel.notice;
|
|
2168
|
+
if (live) {
|
|
2169
|
+
await this.host.shares.remove(live.id);
|
|
1297
2170
|
}
|
|
1298
|
-
|
|
2171
|
+
const share = await this.host.shares.create({
|
|
2172
|
+
kind: AgentCards.KIND,
|
|
2173
|
+
title: `@${agent.name}`,
|
|
2174
|
+
type: "application/json",
|
|
2175
|
+
data: new TextEncoder().encode(card),
|
|
2176
|
+
access: "link",
|
|
2177
|
+
days: CARD_DAYS,
|
|
2178
|
+
offline: true
|
|
2179
|
+
});
|
|
2180
|
+
await this.set(Keys.CARDS, { ...this.liveCards(cards), [agent.id]: { share: share.id, card } });
|
|
2181
|
+
return share;
|
|
1299
2182
|
}
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
const
|
|
1303
|
-
const
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
if (channel.notice) {
|
|
1307
|
-
lines.push("", "Notice of the channel (follow it; keep it with update_channel_notice):", channel.notice.text);
|
|
1308
|
-
}
|
|
1309
|
-
if (before.length > 0) {
|
|
1310
|
-
lines.push("", "Recent messages:", ...before.map((item) => `${authorName(team, item.author, labels)}: ${item.text}`));
|
|
2183
|
+
async stopCard(ref) {
|
|
2184
|
+
const agent = ChannelsUtil.findAgent(this.team, String(ref ?? ""));
|
|
2185
|
+
const cards = await this.get(Keys.CARDS) ?? {};
|
|
2186
|
+
const kept = agent && cards[agent.id];
|
|
2187
|
+
if (!agent || !kept) {
|
|
2188
|
+
return false;
|
|
1311
2189
|
}
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
return `<context>
|
|
1316
|
-
${lines.join(`
|
|
1317
|
-
`)}
|
|
1318
|
-
</context>
|
|
1319
|
-
${message.text}`;
|
|
2190
|
+
const { [agent.id]: _gone, ...rest } = cards;
|
|
2191
|
+
await this.set(Keys.CARDS, this.liveCards(rest));
|
|
2192
|
+
return this.host.shares.remove(kept.share);
|
|
1320
2193
|
}
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
const next = [...messages, message];
|
|
1324
|
-
return next.length > MAX_MESSAGES ? next.slice(next.length - MAX_MESSAGES) : next;
|
|
2194
|
+
liveCards(cards) {
|
|
2195
|
+
return Object.fromEntries(Object.entries(cards).filter(([id]) => this.team.agents.some((agent) => agent.id === id)));
|
|
1325
2196
|
}
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
2197
|
+
async openCard(link, password) {
|
|
2198
|
+
const content = await this.host.shares.open(String(link ?? ""), typeof password === "string" && password ? password : undefined);
|
|
2199
|
+
const card = content.kind === AgentCards.KIND ? AgentCards.parse(content.data) : undefined;
|
|
2200
|
+
if (!card) {
|
|
2201
|
+
throw new Error("This link shares no card of an agent.");
|
|
1330
2202
|
}
|
|
1331
|
-
|
|
1332
|
-
const agents = team.agents.map((agent) => `- @${agent.name}: ${firstLine(agent.role)}`);
|
|
1333
|
-
const channels = team.channels.map((channel) => `- #${channel.name}${channel.topic ? ` (${channel.topic})` : ""}: ${channel.members.map((id) => `@${name(id)}`).join(", ")}${channel.muted?.length ? `; muted by the user, answering nothing: ${channel.muted.map((id) => `@${name(id)}`).join(", ")}` : ""}${channel.notice ? `
|
|
1334
|
-
notice: ${channel.notice.text.replace(/\s+/g, " ").slice(0, 300)}` : ""}`);
|
|
1335
|
-
return ["Agents:", ...agents, "", "Channels:", ...channels.length > 0 ? channels : ["none yet"]].join(`
|
|
1336
|
-
`);
|
|
1337
|
-
}
|
|
1338
|
-
ChannelsUtil.summary = summary;
|
|
1339
|
-
function transcript(team, messages) {
|
|
1340
|
-
const labels = { user: "user", ta: "Ta" };
|
|
1341
|
-
return messages.map((item) => `${authorName(team, item.author, labels)}${item.failed ? " (failed)" : ""}: ${item.text}`).join(`
|
|
1342
|
-
|
|
1343
|
-
`);
|
|
2203
|
+
return card;
|
|
1344
2204
|
}
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
if (role !== "user" && role !== "assistant") {
|
|
1351
|
-
continue;
|
|
1352
|
-
}
|
|
1353
|
-
const text = (typeof content === "string" ? content : Array.isArray(content) ? content.map((block) => block?.type === "text" ? String(block.text ?? "") : "").join("") : "").replace(/^<context>\n?[\s\S]*?\n?<\/context>\n?/, "").trim();
|
|
1354
|
-
if (text) {
|
|
1355
|
-
parts.push("", `## ${role === "user" ? labels.user : agent.name}`, "", text);
|
|
1356
|
-
}
|
|
2205
|
+
waitingFor(round) {
|
|
2206
|
+
let waiting = this.waiting.get(round);
|
|
2207
|
+
if (!waiting) {
|
|
2208
|
+
waiting = { replies: [], waiters: [] };
|
|
2209
|
+
this.waiting.set(round, waiting);
|
|
1357
2210
|
}
|
|
1358
|
-
return
|
|
1359
|
-
`)}
|
|
1360
|
-
`;
|
|
2211
|
+
return waiting;
|
|
1361
2212
|
}
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
const
|
|
1365
|
-
|
|
1366
|
-
|
|
2213
|
+
async setAnswered(agentId, at) {
|
|
2214
|
+
this.answered ??= await this.get(Keys.ANSWERED) ?? {};
|
|
2215
|
+
const known = new Set(this.team.agents.map((agent) => agent.id));
|
|
2216
|
+
const kept = Object.fromEntries(Object.entries(this.answered).filter(([id]) => known.has(id)));
|
|
2217
|
+
this.answered = { ...kept, [agentId]: at };
|
|
2218
|
+
await this.set(Keys.ANSWERED, this.answered);
|
|
2219
|
+
}
|
|
2220
|
+
async pinDirectories() {
|
|
2221
|
+
const loose = this.team.agents.filter((agent) => !agent.cwd);
|
|
2222
|
+
if (loose.length === 0) {
|
|
2223
|
+
return;
|
|
1367
2224
|
}
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
}
|
|
2225
|
+
const serverCwd = (await this.host.getServerInfo()).cwd;
|
|
2226
|
+
const pinned = new Map;
|
|
2227
|
+
for (const agent of loose) {
|
|
2228
|
+
pinned.set(agent.id, agent.sessionFile && await this.host.sessionCwd(agent.sessionFile) || serverCwd);
|
|
1373
2229
|
}
|
|
1374
|
-
|
|
1375
|
-
`)}
|
|
1376
|
-
`;
|
|
2230
|
+
await this.saveTeam({ ...this.team, agents: this.team.agents.map((agent) => pinned.has(agent.id) ? { ...agent, cwd: pinned.get(agent.id) } : agent) });
|
|
1377
2231
|
}
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
2232
|
+
session(agent) {
|
|
2233
|
+
let opening = this.opening.get(agent.id);
|
|
2234
|
+
if (!opening) {
|
|
2235
|
+
opening = this.openSession(agent).finally(() => this.opening.delete(agent.id));
|
|
2236
|
+
this.opening.set(agent.id, opening);
|
|
2237
|
+
}
|
|
2238
|
+
return opening;
|
|
1382
2239
|
}
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
`);
|
|
1389
|
-
var NoticeUtil;
|
|
1390
|
-
((NoticeUtil) => {
|
|
1391
|
-
const PARTS = {
|
|
1392
|
-
决定: "decisions",
|
|
1393
|
-
decisions: "decisions",
|
|
1394
|
-
约定: "conventions",
|
|
1395
|
-
conventions: "conventions",
|
|
1396
|
-
待办: "todo",
|
|
1397
|
-
"to do": "todo",
|
|
1398
|
-
todo: "todo",
|
|
1399
|
-
"to-do": "todo"
|
|
1400
|
-
};
|
|
1401
|
-
function counts(text) {
|
|
1402
|
-
const counts2 = { decisions: 0, conventions: 0, todo: 0, done: 0 };
|
|
1403
|
-
let part;
|
|
1404
|
-
for (const line of text.split(/\r?\n/)) {
|
|
1405
|
-
const heading = /^\s*#{1,6}\s+(.+?)\s*#*\s*$/.exec(line) ?? /^\s*\*\*(.+?)\*\*\s*[::]?\s*$/.exec(line);
|
|
1406
|
-
if (heading) {
|
|
1407
|
-
part = PARTS[heading[1].replace(/[::]$/, "").trim().toLowerCase()];
|
|
1408
|
-
continue;
|
|
1409
|
-
}
|
|
1410
|
-
const item = /^\s*(?:[-*+]|\d+[.)])\s+(\[( |x|X)\]\s+)?\S/.exec(line);
|
|
1411
|
-
if (!part || !item) {
|
|
1412
|
-
continue;
|
|
2240
|
+
async openSession(agent) {
|
|
2241
|
+
if (agent.sessionFile) {
|
|
2242
|
+
const open = (await this.host.listSessions()).find((session) => session.sessionFile === agent.sessionFile);
|
|
2243
|
+
if (open) {
|
|
2244
|
+
return open.sessionId;
|
|
1413
2245
|
}
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
2246
|
+
}
|
|
2247
|
+
const cwd = agent.cwd ?? (await this.host.getServerInfo()).cwd;
|
|
2248
|
+
const options = { cwd, appendSystemPrompt: ChannelsText.systemPrompt(agent), group: NAME };
|
|
2249
|
+
if (agent.sessionFile) {
|
|
2250
|
+
try {
|
|
2251
|
+
return (await this.host.openSession({ ...options, sessionFile: agent.sessionFile })).sessionId;
|
|
2252
|
+
} catch (error) {
|
|
2253
|
+
if (TaErrorUtil.code(error) !== TaErrorCode.INVALID_ARGUMENT) {
|
|
2254
|
+
throw error;
|
|
2255
|
+
}
|
|
1418
2256
|
}
|
|
1419
2257
|
}
|
|
1420
|
-
|
|
2258
|
+
const { sessionId } = await this.host.openSession(options);
|
|
2259
|
+
await this.host.setSessionName(sessionId, agent.name);
|
|
2260
|
+
const { sessionFile } = await this.host.getState(sessionId);
|
|
2261
|
+
if (sessionFile) {
|
|
2262
|
+
await this.saveTeam({ ...this.team, agents: this.team.agents.map((other) => other.id === agent.id ? { ...other, sessionFile } : other) });
|
|
2263
|
+
}
|
|
2264
|
+
return sessionId;
|
|
1421
2265
|
}
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
for (
|
|
1425
|
-
const
|
|
1426
|
-
if (
|
|
1427
|
-
return
|
|
2266
|
+
async settled(sessionId, before) {
|
|
2267
|
+
const start = Date.now();
|
|
2268
|
+
for (;; ) {
|
|
2269
|
+
const state = await this.host.getState(sessionId);
|
|
2270
|
+
if (!state.isStreaming && state.pendingMessageCount === 0 && state.messageCount > before) {
|
|
2271
|
+
return;
|
|
2272
|
+
}
|
|
2273
|
+
if (Date.now() - start > this.options.timeoutMs) {
|
|
2274
|
+
throw new Error("No answer in time; the agent may still be working in its session.");
|
|
1428
2275
|
}
|
|
2276
|
+
await new Promise((resolve) => setTimeout(resolve, this.options.pollMs));
|
|
1429
2277
|
}
|
|
1430
|
-
return text.split(/\r?\n/).find((line) => line.trim() && !/^\s*#/.test(line))?.trim() ?? "";
|
|
1431
|
-
}
|
|
1432
|
-
NoticeUtil.firstLine = firstLine;
|
|
1433
|
-
})(NoticeUtil ||= {});
|
|
1434
|
-
|
|
1435
|
-
// web-src/agent-cards.ts
|
|
1436
|
-
var AgentCards;
|
|
1437
|
-
((AgentCards) => {
|
|
1438
|
-
AgentCards.KIND = RELAY_AGENT_KIND;
|
|
1439
|
-
AgentCards.MARK = "[ta-channels:card]";
|
|
1440
|
-
function card(agent, color) {
|
|
1441
|
-
const redactor = new Redactor;
|
|
1442
|
-
const role = redactor.text(agent.role);
|
|
1443
|
-
return {
|
|
1444
|
-
v: 1,
|
|
1445
|
-
name: agent.name,
|
|
1446
|
-
role,
|
|
1447
|
-
mark: agent.mark,
|
|
1448
|
-
...agent.face !== undefined ? { face: agent.face } : {},
|
|
1449
|
-
...color && /^#[0-9a-fA-F]{6}$/.test(color) ? { color } : {},
|
|
1450
|
-
...redactor.count ? { redacted: redactor.count } : {}
|
|
1451
|
-
};
|
|
1452
|
-
}
|
|
1453
|
-
AgentCards.card = card;
|
|
1454
|
-
function parse(data) {
|
|
1455
|
-
return RelayAgentCards.parse(data);
|
|
1456
2278
|
}
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
return base;
|
|
2279
|
+
messagesOf(channelId) {
|
|
2280
|
+
const known = this.messages.get(channelId);
|
|
2281
|
+
if (known) {
|
|
2282
|
+
return Promise.resolve(known);
|
|
1462
2283
|
}
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
2284
|
+
let reading = this.reading.get(channelId);
|
|
2285
|
+
if (!reading) {
|
|
2286
|
+
reading = this.get(Keys.messages(channelId)).then((stored) => {
|
|
2287
|
+
const messages = this.messages.get(channelId) ?? stored ?? [];
|
|
2288
|
+
this.messages.set(channelId, messages);
|
|
2289
|
+
return messages;
|
|
2290
|
+
});
|
|
2291
|
+
this.reading.set(channelId, reading);
|
|
1467
2292
|
}
|
|
2293
|
+
return reading;
|
|
1468
2294
|
}
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
AgentCards.MARK,
|
|
1473
|
-
`You were just added to this Ta from a card someone shared: the role in your instructions is theirs, written for their own work. Fit it to the project of your directory (${cwd}): look at it first (its README, manifests such as package.json, its layout, how it builds and tests), then rewrite your role for it, keeping what you are for, and save it with update_my_role. Then tell the user in a few sentences, in ${TaLanguageUtil.pick(language2, { "zh-CN": "Chinese", "zh-TW": "Traditional Chinese", "en-US": "English", "ja-JP": "Japanese" })}, what you changed and what you can do here. Change no files.`
|
|
1474
|
-
].join(`
|
|
1475
|
-
`);
|
|
1476
|
-
return `<context>
|
|
1477
|
-
${context}
|
|
1478
|
-
</context>
|
|
1479
|
-
${TaLanguageUtil.pick(language2, { "zh-CN": "看看这个项目,把你的职责调整得贴合这里", "zh-TW": "看看這個專案,把你的職責調整得貼合這裡", "en-US": "Look at this project and fit your role to it", "ja-JP": "このプロジェクトを見て、ロールをそれに適応させてください" })}`;
|
|
1480
|
-
}
|
|
1481
|
-
AgentCards.adapt = adapt;
|
|
1482
|
-
})(AgentCards ||= {});
|
|
1483
|
-
|
|
1484
|
-
// web-src/handoff.ts
|
|
1485
|
-
var HandOff;
|
|
1486
|
-
((HandOff) => {
|
|
1487
|
-
HandOff.TOOL = "hand_off";
|
|
1488
|
-
HandOff.CARD = "ta-channels-handoff";
|
|
1489
|
-
HandOff.BLOCK = "ta-handoff";
|
|
1490
|
-
const MARK = /\[ta-handoff:([^\]\s]+)\]/;
|
|
1491
|
-
HandOff.DEFINITION = {
|
|
1492
|
-
name: HandOff.TOOL,
|
|
1493
|
-
label: "Hand off",
|
|
1494
|
-
description: "Hands the work of this conversation over to one of the user's agents (@name) or channels (#name), when the user says so (hand it to, give it to, 交给, 转给). The other side does not see this conversation: write the brief it needs to go on, in the user's language: the goal, what is done and decided, what is left or blocks, the files, branches, commands and links that matter. It works on it in its own conversation, which the user follows; you stop working on it here. list_channels lists the team. After the call, say in one line to whom it went.",
|
|
1495
|
-
promptSnippet: "Hand the work over to one of the user's agents or channels",
|
|
1496
|
-
parameters: {
|
|
1497
|
-
type: "object",
|
|
1498
|
-
properties: {
|
|
1499
|
-
to: { type: "string", description: "@name of an agent or #name of a channel." },
|
|
1500
|
-
brief: { type: "string", description: "Complete in itself: the receiver sees only this." }
|
|
1501
|
-
},
|
|
1502
|
-
required: ["to", "brief"]
|
|
2295
|
+
async append(channelId, message) {
|
|
2296
|
+
if (!this.team.channels.some((channel) => channel.id === channelId)) {
|
|
2297
|
+
return message;
|
|
1503
2298
|
}
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
function ask(language2, to) {
|
|
1510
|
-
const fence = "```";
|
|
1511
|
-
const context = [
|
|
1512
|
-
`[ta-handoff:${to}]`,
|
|
1513
|
-
`The user hands the work of this conversation over to ${to}, which does not see this conversation.`,
|
|
1514
|
-
`- Write the brief it needs to go on: the goal, what is done and decided, what is left or blocks, the files, branches, commands and links that matter, in the user's language. Leave out what was only tried and dropped.`,
|
|
1515
|
-
`- With the tool ${HandOff.TOOL}, call it with to "${to}" and the brief, then say in one line that it went.`,
|
|
1516
|
-
`- Without it, say in one line what you hand over, then end your answer with the brief in a fenced block of the language ${HandOff.BLOCK}, which Ta reads to hand it over (a longer fence when the brief has one of its own):`,
|
|
1517
|
-
`${fence}${HandOff.BLOCK}`,
|
|
1518
|
-
"<the brief>",
|
|
1519
|
-
fence,
|
|
1520
|
-
`- When the conversation holds nothing to hand over yet, say so and ask what ${to} should do.`
|
|
1521
|
-
].join(`
|
|
1522
|
-
`);
|
|
1523
|
-
const line = TaLanguageUtil.pick(language2, {
|
|
1524
|
-
"zh-CN": `把这件事交给 ${to}`,
|
|
1525
|
-
"zh-TW": `把這件事交給 ${to}`,
|
|
1526
|
-
"en-US": `Hand this over to ${to}`,
|
|
1527
|
-
"ja-JP": `これを ${to} に引き継ぐ`
|
|
1528
|
-
});
|
|
1529
|
-
return `<context>
|
|
1530
|
-
${context}
|
|
1531
|
-
</context>
|
|
1532
|
-
${line}`;
|
|
2299
|
+
await this.messagesOf(channelId);
|
|
2300
|
+
const messages = ChannelsUtil.append(this.messages.get(channelId) ?? [], message);
|
|
2301
|
+
this.messages.set(channelId, messages);
|
|
2302
|
+
await this.set(Keys.messages(channelId), messages);
|
|
2303
|
+
return message;
|
|
1533
2304
|
}
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
2305
|
+
async saveTeam(team) {
|
|
2306
|
+
this.team = team;
|
|
2307
|
+
this.linkSessions();
|
|
2308
|
+
await this.set(Keys.TEAM, team);
|
|
1537
2309
|
}
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
for (let index = 0;index < lines.length; index++) {
|
|
1543
|
-
const open = /^\s*(`{3,})\s*([\w-]+)\s*$/.exec(lines[index]);
|
|
1544
|
-
if (open?.[2] !== HandOff.BLOCK) {
|
|
1545
|
-
continue;
|
|
1546
|
-
}
|
|
1547
|
-
const close = new RegExp(`^\\s*${open[1]}\`*\\s*$`);
|
|
1548
|
-
const end = lines.findIndex((line, at) => at > index && close.test(line));
|
|
1549
|
-
found = lines.slice(index + 1, end < 0 ? lines.length : end);
|
|
1550
|
-
index = end < 0 ? lines.length : end;
|
|
2310
|
+
shareWithMembers() {
|
|
2311
|
+
const team = this.host.team;
|
|
2312
|
+
if (!team) {
|
|
2313
|
+
return;
|
|
1551
2314
|
}
|
|
1552
|
-
const
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
const context = [
|
|
1566
|
-
"The user handed you this work from another conversation of theirs, which you do not see; the brief below is all it says. Go on from there in this conversation, which the user follows; ask them when the brief leaves out something you need.",
|
|
1567
|
-
origin.sessionFile ? `That conversation is pi's session file ${origin.sessionFile}${origin.cwd ? `, working in ${origin.cwd}` : ""}: read it only when the brief is not enough.` : ""
|
|
1568
|
-
].filter(Boolean).join(`
|
|
1569
|
-
`);
|
|
1570
|
-
return `<context>
|
|
1571
|
-
${context}
|
|
1572
|
-
</context>
|
|
1573
|
-
${head}
|
|
1574
|
-
|
|
1575
|
-
${brief.trim()}`;
|
|
1576
|
-
}
|
|
1577
|
-
HandOff.message = message;
|
|
1578
|
-
function channelText(origin, brief, language2) {
|
|
1579
|
-
const title = origin.title?.trim() || TaLanguageUtil.pick(language2, { "zh-CN": "一个对话", "zh-TW": "一個對話", "en-US": "a conversation", "ja-JP": "ある会話" });
|
|
1580
|
-
return `${TaLanguageUtil.pick(language2, {
|
|
1581
|
-
"zh-CN": `(交接自“${title}”)`,
|
|
1582
|
-
"zh-TW": `(交接自「${title}」)`,
|
|
1583
|
-
"en-US": `(Handed over from “${title}”)`,
|
|
1584
|
-
"ja-JP": `(“${title}” から引き継ぎました)`
|
|
1585
|
-
})}
|
|
1586
|
-
|
|
1587
|
-
${brief.trim()}`;
|
|
1588
|
-
}
|
|
1589
|
-
HandOff.channelText = channelText;
|
|
1590
|
-
function serverLanguage(env = typeof process === "undefined" ? {} : process.env) {
|
|
1591
|
-
return TaLanguageUtil.of(env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG || "");
|
|
1592
|
-
}
|
|
1593
|
-
HandOff.serverLanguage = serverLanguage;
|
|
1594
|
-
function result(target) {
|
|
1595
|
-
return `Handed over to ${ref(target)}; it works on it in its own conversation, which the user follows. Do not go on with it here.`;
|
|
1596
|
-
}
|
|
1597
|
-
HandOff.result = result;
|
|
1598
|
-
})(HandOff ||= {});
|
|
1599
|
-
|
|
1600
|
-
// web-src/team-view.ts
|
|
1601
|
-
var TeamViewUtil;
|
|
1602
|
-
((TeamViewUtil) => {
|
|
1603
|
-
function visible(team2, can) {
|
|
1604
|
-
const channels = new Set(team2.channels.filter((channel) => can("channel", channel.id)).map((channel) => channel.id));
|
|
1605
|
-
const agents = new Set(team2.agents.filter((agent) => can("agent", agent.id)).map((agent) => agent.id));
|
|
1606
|
-
for (const channel of team2.channels) {
|
|
1607
|
-
if (channels.has(channel.id)) {
|
|
1608
|
-
for (const member of channel.members) {
|
|
1609
|
-
agents.add(member);
|
|
2315
|
+
const can = (principal, kind, id) => team.can(principal, kind === "agent" ? "agent.view" : "channel.view", { kind, id });
|
|
2316
|
+
team.shareData(NAME, {
|
|
2317
|
+
keys: [Keys.TEAM, Keys.WORKING, Keys.ANSWERED, Keys.FOCUS, Keys.MESSAGES],
|
|
2318
|
+
view: (principal, key, value) => {
|
|
2319
|
+
const visible = TeamViewUtil.visible(this.team, (kind, id) => can(principal, kind, id));
|
|
2320
|
+
if (key === Keys.TEAM) {
|
|
2321
|
+
return TeamViewUtil.team(value, visible);
|
|
2322
|
+
}
|
|
2323
|
+
if (key.startsWith(Keys.MESSAGES)) {
|
|
2324
|
+
return visible.channels.has(key.slice(Keys.MESSAGES.length)) ? value : undefined;
|
|
2325
|
+
}
|
|
2326
|
+
if (key === Keys.FOCUS) {
|
|
2327
|
+
return visible.channels.has(value?.channelId ?? "") ? value : undefined;
|
|
1610
2328
|
}
|
|
2329
|
+
return TeamViewUtil.byId(value, key === Keys.WORKING ? visible.channels : visible.agents);
|
|
1611
2330
|
}
|
|
1612
|
-
}
|
|
1613
|
-
|
|
2331
|
+
});
|
|
2332
|
+
this.linkSessions();
|
|
1614
2333
|
}
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
2334
|
+
linkSessions() {
|
|
2335
|
+
for (const agent of this.team.agents) {
|
|
2336
|
+
if (agent.sessionFile) {
|
|
2337
|
+
this.host.team?.link(agent.sessionFile, { kind: "agent", id: agent.id });
|
|
2338
|
+
}
|
|
1619
2339
|
}
|
|
1620
|
-
return {
|
|
1621
|
-
...value,
|
|
1622
|
-
agents: value.agents.filter((agent) => visible2.agents.has(agent.id)),
|
|
1623
|
-
channels: value.channels.filter((channel) => visible2.channels.has(channel.id))
|
|
1624
|
-
};
|
|
1625
2340
|
}
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
}
|
|
1631
|
-
return Object.fromEntries(Object.entries(value).filter(([id]) => seen.has(id)));
|
|
2341
|
+
async setWorking(channelId, agentId, on) {
|
|
2342
|
+
const others = (this.working[channelId] ?? []).filter((id) => id !== agentId);
|
|
2343
|
+
this.working = { ...this.working, [channelId]: on ? [...others, agentId] : others };
|
|
2344
|
+
await this.set(Keys.WORKING, this.working);
|
|
1632
2345
|
}
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
// web-src/team.ts
|
|
1637
|
-
class TeamService {
|
|
1638
|
-
host;
|
|
1639
|
-
team = ChannelsUtil.emptyTeam();
|
|
1640
|
-
queue = { jobs: [], rounds: {} };
|
|
1641
|
-
working = {};
|
|
1642
|
-
answered;
|
|
1643
|
-
messages = new Map;
|
|
1644
|
-
reading = new Map;
|
|
1645
|
-
agents = new Map;
|
|
1646
|
-
started = new Set;
|
|
1647
|
-
waiting = new Map;
|
|
1648
|
-
opening = new Map;
|
|
1649
|
-
settling = new Set;
|
|
1650
|
-
options;
|
|
1651
|
-
disposed = false;
|
|
1652
|
-
constructor(host, options = {}) {
|
|
1653
|
-
this.host = host;
|
|
1654
|
-
this.options = { pollMs: 300, timeoutMs: 15 * 60 * 1000, ...options };
|
|
2346
|
+
async get(key) {
|
|
2347
|
+
return await this.host.getExtensionData(NAME, key) ?? undefined;
|
|
1655
2348
|
}
|
|
1656
|
-
|
|
1657
|
-
return this.
|
|
2349
|
+
set(key, value) {
|
|
2350
|
+
return this.host.setExtensionData(NAME, key, value);
|
|
1658
2351
|
}
|
|
2352
|
+
}
|
|
2353
|
+
|
|
2354
|
+
// web-src/team.ts
|
|
2355
|
+
class TeamService extends TeamStore {
|
|
1659
2356
|
async start() {
|
|
1660
2357
|
this.team = await this.get(Keys.TEAM) ?? ChannelsUtil.emptyTeam();
|
|
1661
2358
|
this.shareWithMembers();
|
|
@@ -1740,55 +2437,6 @@ class TeamService {
|
|
|
1740
2437
|
agentOf(sessionFile) {
|
|
1741
2438
|
return sessionFile ? this.team.agents.find((agent) => agent.sessionFile === sessionFile) : undefined;
|
|
1742
2439
|
}
|
|
1743
|
-
async shareAgent(ref, color) {
|
|
1744
|
-
const agent = ChannelsUtil.findAgent(this.team, String(ref ?? ""));
|
|
1745
|
-
if (!agent) {
|
|
1746
|
-
throw new Error(`No agent is ${String(ref)}.`);
|
|
1747
|
-
}
|
|
1748
|
-
const card = JSON.stringify(AgentCards.card(agent, typeof color === "string" ? color : undefined));
|
|
1749
|
-
const cards = await this.get(Keys.CARDS) ?? {};
|
|
1750
|
-
const kept = cards[agent.id];
|
|
1751
|
-
const live = kept ? (await this.host.shares.list()).find((share2) => share2.id === kept.share) : undefined;
|
|
1752
|
-
if (live && kept?.card === card) {
|
|
1753
|
-
return live;
|
|
1754
|
-
}
|
|
1755
|
-
if (live) {
|
|
1756
|
-
await this.host.shares.remove(live.id);
|
|
1757
|
-
}
|
|
1758
|
-
const share = await this.host.shares.create({
|
|
1759
|
-
kind: AgentCards.KIND,
|
|
1760
|
-
title: `@${agent.name}`,
|
|
1761
|
-
type: "application/json",
|
|
1762
|
-
data: new TextEncoder().encode(card),
|
|
1763
|
-
access: "link",
|
|
1764
|
-
days: CARD_DAYS,
|
|
1765
|
-
offline: true
|
|
1766
|
-
});
|
|
1767
|
-
await this.set(Keys.CARDS, { ...this.liveCards(cards), [agent.id]: { share: share.id, card } });
|
|
1768
|
-
return share;
|
|
1769
|
-
}
|
|
1770
|
-
async stopCard(ref) {
|
|
1771
|
-
const agent = ChannelsUtil.findAgent(this.team, String(ref ?? ""));
|
|
1772
|
-
const cards = await this.get(Keys.CARDS) ?? {};
|
|
1773
|
-
const kept = agent && cards[agent.id];
|
|
1774
|
-
if (!agent || !kept) {
|
|
1775
|
-
return false;
|
|
1776
|
-
}
|
|
1777
|
-
const { [agent.id]: _gone, ...rest } = cards;
|
|
1778
|
-
await this.set(Keys.CARDS, this.liveCards(rest));
|
|
1779
|
-
return this.host.shares.remove(kept.share);
|
|
1780
|
-
}
|
|
1781
|
-
liveCards(cards) {
|
|
1782
|
-
return Object.fromEntries(Object.entries(cards).filter(([id]) => this.team.agents.some((agent) => agent.id === id)));
|
|
1783
|
-
}
|
|
1784
|
-
async openCard(link, password) {
|
|
1785
|
-
const content = await this.host.shares.open(String(link ?? ""), typeof password === "string" && password ? password : undefined);
|
|
1786
|
-
const card = content.kind === AgentCards.KIND ? AgentCards.parse(content.data) : undefined;
|
|
1787
|
-
if (!card) {
|
|
1788
|
-
throw new Error("This link shares no card of an agent.");
|
|
1789
|
-
}
|
|
1790
|
-
return card;
|
|
1791
|
-
}
|
|
1792
2440
|
async addFromCard(input, language2 = HandOff.serverLanguage()) {
|
|
1793
2441
|
const card = await this.openCard(input.link, input.password);
|
|
1794
2442
|
const agent = await this.createAgent({ name: AgentCards.freeName(this.team, card.name), role: card.role, cwd: input.cwd, face: card.face });
|
|
@@ -1944,7 +2592,7 @@ class TeamService {
|
|
|
1944
2592
|
async handOn(channel, message, hops, round) {
|
|
1945
2593
|
const current = this.queue.rounds[round]?.round ?? ChannelsUtil.newRound();
|
|
1946
2594
|
const messages = await this.messagesOf(channel.id);
|
|
1947
|
-
const targets =
|
|
2595
|
+
const targets = ChannelsText.targets(this.team, channel, message).filter((agentId) => !this.queue.jobs.some((job) => job.messageId === message.id && job.agentId === agentId) && !messages.some((item) => item.replyTo === message.id && item.author === agentId));
|
|
1948
2596
|
const limited = ChannelsUtil.limit(current, targets, hops);
|
|
1949
2597
|
const jobs = limited.allowed.map((agentId) => ({
|
|
1950
2598
|
id: ChannelsUtil.newId("job"),
|
|
@@ -2030,14 +2678,6 @@ class TeamService {
|
|
|
2030
2678
|
resolve(waiting.replies);
|
|
2031
2679
|
}
|
|
2032
2680
|
}
|
|
2033
|
-
waitingFor(round) {
|
|
2034
|
-
let waiting = this.waiting.get(round);
|
|
2035
|
-
if (!waiting) {
|
|
2036
|
-
waiting = { replies: [], waiters: [] };
|
|
2037
|
-
this.waiting.set(round, waiting);
|
|
2038
|
-
}
|
|
2039
|
-
return waiting;
|
|
2040
|
-
}
|
|
2041
2681
|
async answer(channel, message, agentId, by) {
|
|
2042
2682
|
await this.setWorking(channel.id, agentId, true);
|
|
2043
2683
|
let text;
|
|
@@ -2054,13 +2694,6 @@ class TeamService {
|
|
|
2054
2694
|
}
|
|
2055
2695
|
return this.append(channel.id, { id: ChannelsUtil.newId("message"), author: agentId, text, at: Date.now(), replyTo: message.id, failed });
|
|
2056
2696
|
}
|
|
2057
|
-
async setAnswered(agentId, at) {
|
|
2058
|
-
this.answered ??= await this.get(Keys.ANSWERED) ?? {};
|
|
2059
|
-
const known = new Set(this.team.agents.map((agent) => agent.id));
|
|
2060
|
-
const kept = Object.fromEntries(Object.entries(this.answered).filter(([id]) => known.has(id)));
|
|
2061
|
-
this.answered = { ...kept, [agentId]: at };
|
|
2062
|
-
await this.set(Keys.ANSWERED, this.answered);
|
|
2063
|
-
}
|
|
2064
2697
|
async ask(channel, message, agentId) {
|
|
2065
2698
|
const agent = this.team.agents.find((candidate) => candidate.id === agentId);
|
|
2066
2699
|
if (!agent) {
|
|
@@ -2069,7 +2702,7 @@ class TeamService {
|
|
|
2069
2702
|
const sessionId = await this.session(agent);
|
|
2070
2703
|
const before = await this.host.getState(sessionId);
|
|
2071
2704
|
const history = await this.messagesOf(channel.id);
|
|
2072
|
-
const input = { clientMessageId: `${message.id}:${agent.id}`, message:
|
|
2705
|
+
const input = { clientMessageId: `${message.id}:${agent.id}`, message: ChannelsText.prompt(this.team, channel, history, message, agent) };
|
|
2073
2706
|
await this.host.prompt(sessionId, input);
|
|
2074
2707
|
await this.settled(sessionId, before.messageCount);
|
|
2075
2708
|
const { text } = await this.host.getLastAssistantText(sessionId);
|
|
@@ -2078,127 +2711,6 @@ class TeamService {
|
|
|
2078
2711
|
}
|
|
2079
2712
|
return text.trim();
|
|
2080
2713
|
}
|
|
2081
|
-
async pinDirectories() {
|
|
2082
|
-
const loose = this.team.agents.filter((agent) => !agent.cwd);
|
|
2083
|
-
if (loose.length === 0) {
|
|
2084
|
-
return;
|
|
2085
|
-
}
|
|
2086
|
-
const serverCwd = (await this.host.getServerInfo()).cwd;
|
|
2087
|
-
const pinned = new Map;
|
|
2088
|
-
for (const agent of loose) {
|
|
2089
|
-
pinned.set(agent.id, agent.sessionFile && await this.host.sessionCwd(agent.sessionFile) || serverCwd);
|
|
2090
|
-
}
|
|
2091
|
-
await this.saveTeam({ ...this.team, agents: this.team.agents.map((agent) => pinned.has(agent.id) ? { ...agent, cwd: pinned.get(agent.id) } : agent) });
|
|
2092
|
-
}
|
|
2093
|
-
session(agent) {
|
|
2094
|
-
let opening = this.opening.get(agent.id);
|
|
2095
|
-
if (!opening) {
|
|
2096
|
-
opening = this.openSession(agent).finally(() => this.opening.delete(agent.id));
|
|
2097
|
-
this.opening.set(agent.id, opening);
|
|
2098
|
-
}
|
|
2099
|
-
return opening;
|
|
2100
|
-
}
|
|
2101
|
-
async openSession(agent) {
|
|
2102
|
-
if (agent.sessionFile) {
|
|
2103
|
-
const open = (await this.host.listSessions()).find((session) => session.sessionFile === agent.sessionFile);
|
|
2104
|
-
if (open) {
|
|
2105
|
-
return open.sessionId;
|
|
2106
|
-
}
|
|
2107
|
-
}
|
|
2108
|
-
const cwd = agent.cwd ?? (await this.host.getServerInfo()).cwd;
|
|
2109
|
-
const options = { cwd, appendSystemPrompt: ChannelsUtil.systemPrompt(agent), group: NAME };
|
|
2110
|
-
if (agent.sessionFile) {
|
|
2111
|
-
try {
|
|
2112
|
-
return (await this.host.openSession({ ...options, sessionFile: agent.sessionFile })).sessionId;
|
|
2113
|
-
} catch (error) {
|
|
2114
|
-
if (TaErrorUtil.code(error) !== TaErrorCode.INVALID_ARGUMENT) {
|
|
2115
|
-
throw error;
|
|
2116
|
-
}
|
|
2117
|
-
}
|
|
2118
|
-
}
|
|
2119
|
-
const { sessionId } = await this.host.openSession(options);
|
|
2120
|
-
await this.host.setSessionName(sessionId, agent.name);
|
|
2121
|
-
const { sessionFile } = await this.host.getState(sessionId);
|
|
2122
|
-
if (sessionFile) {
|
|
2123
|
-
await this.saveTeam({ ...this.team, agents: this.team.agents.map((other) => other.id === agent.id ? { ...other, sessionFile } : other) });
|
|
2124
|
-
}
|
|
2125
|
-
return sessionId;
|
|
2126
|
-
}
|
|
2127
|
-
async settled(sessionId, before) {
|
|
2128
|
-
const start = Date.now();
|
|
2129
|
-
for (;; ) {
|
|
2130
|
-
const state = await this.host.getState(sessionId);
|
|
2131
|
-
if (!state.isStreaming && state.pendingMessageCount === 0 && state.messageCount > before) {
|
|
2132
|
-
return;
|
|
2133
|
-
}
|
|
2134
|
-
if (Date.now() - start > this.options.timeoutMs) {
|
|
2135
|
-
throw new Error("No answer in time; the agent may still be working in its session.");
|
|
2136
|
-
}
|
|
2137
|
-
await new Promise((resolve) => setTimeout(resolve, this.options.pollMs));
|
|
2138
|
-
}
|
|
2139
|
-
}
|
|
2140
|
-
messagesOf(channelId) {
|
|
2141
|
-
const known = this.messages.get(channelId);
|
|
2142
|
-
if (known) {
|
|
2143
|
-
return Promise.resolve(known);
|
|
2144
|
-
}
|
|
2145
|
-
let reading = this.reading.get(channelId);
|
|
2146
|
-
if (!reading) {
|
|
2147
|
-
reading = this.get(Keys.messages(channelId)).then((stored) => {
|
|
2148
|
-
const messages = this.messages.get(channelId) ?? stored ?? [];
|
|
2149
|
-
this.messages.set(channelId, messages);
|
|
2150
|
-
return messages;
|
|
2151
|
-
});
|
|
2152
|
-
this.reading.set(channelId, reading);
|
|
2153
|
-
}
|
|
2154
|
-
return reading;
|
|
2155
|
-
}
|
|
2156
|
-
async append(channelId, message) {
|
|
2157
|
-
if (!this.team.channels.some((channel) => channel.id === channelId)) {
|
|
2158
|
-
return message;
|
|
2159
|
-
}
|
|
2160
|
-
await this.messagesOf(channelId);
|
|
2161
|
-
const messages = ChannelsUtil.append(this.messages.get(channelId) ?? [], message);
|
|
2162
|
-
this.messages.set(channelId, messages);
|
|
2163
|
-
await this.set(Keys.messages(channelId), messages);
|
|
2164
|
-
return message;
|
|
2165
|
-
}
|
|
2166
|
-
async saveTeam(team) {
|
|
2167
|
-
this.team = team;
|
|
2168
|
-
this.linkSessions();
|
|
2169
|
-
await this.set(Keys.TEAM, team);
|
|
2170
|
-
}
|
|
2171
|
-
shareWithMembers() {
|
|
2172
|
-
const team = this.host.team;
|
|
2173
|
-
if (!team) {
|
|
2174
|
-
return;
|
|
2175
|
-
}
|
|
2176
|
-
const can = (principal, kind, id) => team.can(principal, kind === "agent" ? "agent.view" : "channel.view", { kind, id });
|
|
2177
|
-
team.shareData(NAME, {
|
|
2178
|
-
keys: [Keys.TEAM, Keys.WORKING, Keys.ANSWERED, Keys.FOCUS, Keys.MESSAGES],
|
|
2179
|
-
view: (principal, key, value) => {
|
|
2180
|
-
const visible = TeamViewUtil.visible(this.team, (kind, id) => can(principal, kind, id));
|
|
2181
|
-
if (key === Keys.TEAM) {
|
|
2182
|
-
return TeamViewUtil.team(value, visible);
|
|
2183
|
-
}
|
|
2184
|
-
if (key.startsWith(Keys.MESSAGES)) {
|
|
2185
|
-
return visible.channels.has(key.slice(Keys.MESSAGES.length)) ? value : undefined;
|
|
2186
|
-
}
|
|
2187
|
-
if (key === Keys.FOCUS) {
|
|
2188
|
-
return visible.channels.has(value?.channelId ?? "") ? value : undefined;
|
|
2189
|
-
}
|
|
2190
|
-
return TeamViewUtil.byId(value, key === Keys.WORKING ? visible.channels : visible.agents);
|
|
2191
|
-
}
|
|
2192
|
-
});
|
|
2193
|
-
this.linkSessions();
|
|
2194
|
-
}
|
|
2195
|
-
linkSessions() {
|
|
2196
|
-
for (const agent of this.team.agents) {
|
|
2197
|
-
if (agent.sessionFile) {
|
|
2198
|
-
this.host.team?.link(agent.sessionFile, { kind: "agent", id: agent.id });
|
|
2199
|
-
}
|
|
2200
|
-
}
|
|
2201
|
-
}
|
|
2202
2714
|
listChannels() {
|
|
2203
2715
|
return this.team.channels.map((channel) => ({
|
|
2204
2716
|
id: channel.id,
|
|
@@ -2207,17 +2719,6 @@ class TeamService {
|
|
|
2207
2719
|
members: channel.members
|
|
2208
2720
|
}));
|
|
2209
2721
|
}
|
|
2210
|
-
async setWorking(channelId, agentId, on) {
|
|
2211
|
-
const others = (this.working[channelId] ?? []).filter((id) => id !== agentId);
|
|
2212
|
-
this.working = { ...this.working, [channelId]: on ? [...others, agentId] : others };
|
|
2213
|
-
await this.set(Keys.WORKING, this.working);
|
|
2214
|
-
}
|
|
2215
|
-
async get(key) {
|
|
2216
|
-
return await this.host.getExtensionData(NAME, key) ?? undefined;
|
|
2217
|
-
}
|
|
2218
|
-
set(key, value) {
|
|
2219
|
-
return this.host.setExtensionData(NAME, key, value);
|
|
2220
|
-
}
|
|
2221
2722
|
}
|
|
2222
2723
|
|
|
2223
2724
|
// web-src/host.ts
|