@celljs/ta 4.12.0 → 4.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +2 -2
- package/README.md +2 -2
- package/dist/cli.mjs +1006 -164
- package/dist/gateway.mjs +182 -2
- package/dist/pi/CHANGELOG.md +15 -0
- package/dist/pi/package.json +1 -1
- package/dist/pi/packages/ta-agents/README.en.md +1 -1
- package/dist/pi/packages/ta-agents/README.md +1 -1
- package/dist/pi/packages/ta-agents/extension/index.mjs +75 -11
- package/dist/pi/packages/ta-agents/lib/acp-protocol.d.ts +2 -2
- package/dist/pi/packages/ta-agents/lib/acp-protocol.js +5 -2
- package/dist/pi/packages/ta-agents/lib/agent-prompt.d.ts +6 -4
- package/dist/pi/packages/ta-agents/lib/agent-prompt.js +7 -5
- package/dist/pi/packages/ta-agents/lib/agent-session.d.ts +2 -0
- package/dist/pi/packages/ta-agents/lib/agent-session.js +7 -0
- package/dist/pi/packages/ta-agents/lib/agent-tool.d.ts +2 -0
- package/dist/pi/packages/ta-agents/lib/agent-tool.js +44 -3
- package/dist/pi/packages/ta-agents/lib/agent-turn.d.ts +12 -2
- package/dist/pi/packages/ta-agents/lib/agent-turn.js +29 -4
- package/dist/pi/packages/ta-agents/package.json +1 -1
- package/dist/pi/packages/ta-bots/extension/index.mjs +72 -0
- package/dist/pi/packages/ta-bots/host/index.mjs +178 -0
- package/dist/pi/packages/ta-bots/package.json +7 -2
- package/dist/pi/packages/ta-changes/extension/index.mjs +72 -0
- package/dist/pi/packages/ta-changes/package.json +8 -2
- package/dist/pi/packages/ta-channels/README.en.md +3 -1
- package/dist/pi/packages/ta-channels/README.md +3 -1
- package/dist/pi/packages/ta-channels/extension/index.mjs +78 -4
- package/dist/pi/packages/ta-channels/host/index.mjs +289 -8
- package/dist/pi/packages/ta-channels/lib/channels-model.d.ts +25 -0
- package/dist/pi/packages/ta-channels/lib/channels-util.js +8 -2
- package/dist/pi/packages/ta-channels/lib/extension.js +2 -2
- package/dist/pi/packages/ta-channels/lib/i18n.d.ts +1 -0
- package/dist/pi/packages/ta-channels/lib/i18n.js +2 -0
- package/dist/pi/packages/ta-channels/lib/room.d.ts +0 -4
- package/dist/pi/packages/ta-channels/lib/room.js +31 -5
- package/dist/pi/packages/ta-channels/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-channels/lib/style.js +7 -13
- package/dist/pi/packages/ta-channels/lib/team-view.d.ts +19 -0
- package/dist/pi/packages/ta-channels/lib/team-view.js +45 -0
- package/dist/pi/packages/ta-channels/lib/team.d.ts +20 -4
- package/dist/pi/packages/ta-channels/lib/team.js +87 -6
- package/dist/pi/packages/ta-channels/package.json +26 -2
- package/dist/pi/packages/ta-channels/web/index.js +137 -27
- package/dist/pi/packages/ta-computer-use/package.json +1 -1
- package/dist/pi/packages/ta-cron/README.en.md +2 -2
- package/dist/pi/packages/ta-cron/README.md +2 -2
- package/dist/pi/packages/ta-cron/extension/index.mjs +113 -258
- package/dist/pi/packages/ta-cron/host/index.mjs +9 -0
- package/dist/pi/packages/ta-cron/lib/chat-task.d.ts +16 -15
- package/dist/pi/packages/ta-cron/lib/chat-task.js +45 -36
- package/dist/pi/packages/ta-cron/lib/extension.js +12 -8
- package/dist/pi/packages/ta-cron/lib/i18n.d.ts +5 -7
- package/dist/pi/packages/ta-cron/lib/i18n.js +10 -14
- package/dist/pi/packages/ta-cron/lib/index.js +0 -2
- package/dist/pi/packages/ta-cron/lib/page.d.ts +5 -0
- package/dist/pi/packages/ta-cron/lib/page.js +24 -0
- package/dist/pi/packages/ta-cron/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-cron/lib/style.js +8 -0
- package/dist/pi/packages/ta-cron/lib/task-change.d.ts +11 -0
- package/dist/pi/packages/ta-cron/lib/task-change.js +43 -0
- package/dist/pi/packages/ta-cron/lib/task-extension.d.ts +3 -0
- package/dist/pi/packages/ta-cron/lib/task-extension.js +2 -0
- package/dist/pi/packages/ta-cron/lib/task-util.d.ts +5 -0
- package/dist/pi/packages/ta-cron/lib/task-util.js +13 -0
- package/dist/pi/packages/ta-cron/lib/tasks-view.js +26 -2
- package/dist/pi/packages/ta-cron/package.json +10 -2
- package/dist/pi/packages/ta-cron/web/index.js +607 -784
- package/dist/pi/packages/ta-extensions/README.en.md +1 -2
- package/dist/pi/packages/ta-extensions/README.md +1 -2
- package/dist/pi/packages/ta-extensions/lib/i18n.d.ts +0 -4
- package/dist/pi/packages/ta-extensions/lib/i18n.js +2 -10
- package/dist/pi/packages/ta-extensions/lib/index.js +0 -2
- package/dist/pi/packages/ta-extensions/package.json +10 -2
- package/dist/pi/packages/ta-extensions/skills/ta-package/SKILL.md +15 -11
- package/dist/pi/packages/ta-extensions/web/index.js +197 -97
- package/dist/pi/packages/ta-games/package.json +8 -2
- package/dist/pi/packages/ta-glance/README.en.md +1 -0
- package/dist/pi/packages/ta-glance/README.md +1 -0
- package/dist/pi/packages/ta-glance/extension/index.mjs +446 -3
- package/dist/pi/packages/ta-glance/lib/card.js +38 -12
- package/dist/pi/packages/ta-glance/lib/extension.d.ts +3 -0
- package/dist/pi/packages/ta-glance/lib/extension.js +10 -0
- package/dist/pi/packages/ta-glance/lib/glance-ask.d.ts +15 -0
- package/dist/pi/packages/ta-glance/lib/glance-ask.js +97 -0
- package/dist/pi/packages/ta-glance/lib/glance-prompt.d.ts +1 -1
- package/dist/pi/packages/ta-glance/lib/glance-prompt.js +3 -3
- package/dist/pi/packages/ta-glance/lib/glance-protocol.d.ts +2 -0
- package/dist/pi/packages/ta-glance/lib/glance-protocol.js +3 -1
- package/dist/pi/packages/ta-glance/lib/glance-spec.d.ts +6 -1
- package/dist/pi/packages/ta-glance/lib/glance-spec.js +41 -7
- package/dist/pi/packages/ta-glance/lib/i18n.d.ts +5 -0
- package/dist/pi/packages/ta-glance/lib/i18n.js +9 -0
- package/dist/pi/packages/ta-glance/lib/index.js +4 -1
- package/dist/pi/packages/ta-glance/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-glance/lib/style.js +9 -1
- package/dist/pi/packages/ta-glance/package.json +1 -1
- package/dist/pi/packages/ta-glance/web/index.js +87 -19
- package/dist/pi/packages/ta-initiative/README.en.md +66 -0
- package/dist/pi/packages/ta-initiative/README.md +66 -0
- package/dist/pi/packages/ta-initiative/extension/index.mjs +741 -0
- package/dist/pi/packages/ta-initiative/host/index.mjs +1169 -0
- package/dist/pi/packages/ta-initiative/lib/chat-kinds.d.ts +4 -0
- package/dist/pi/packages/ta-initiative/lib/chat-kinds.js +17 -0
- package/dist/pi/packages/ta-initiative/lib/chat-proposals.d.ts +28 -0
- package/dist/pi/packages/ta-initiative/lib/chat-proposals.js +79 -0
- package/dist/pi/packages/ta-initiative/lib/conversation.d.ts +4 -0
- package/dist/pi/packages/ta-initiative/lib/conversation.js +27 -0
- package/dist/pi/packages/ta-initiative/lib/cron-proposals.d.ts +23 -0
- package/dist/pi/packages/ta-initiative/lib/cron-proposals.js +94 -0
- package/dist/pi/packages/ta-initiative/lib/event-proposals.d.ts +13 -0
- package/dist/pi/packages/ta-initiative/lib/event-proposals.js +76 -0
- package/dist/pi/packages/ta-initiative/lib/extension.d.ts +30 -0
- package/dist/pi/packages/ta-initiative/lib/extension.js +237 -0
- package/dist/pi/packages/ta-initiative/lib/host.d.ts +4 -0
- package/dist/pi/packages/ta-initiative/lib/host.js +11 -0
- package/dist/pi/packages/ta-initiative/lib/i18n.d.ts +79 -0
- package/dist/pi/packages/ta-initiative/lib/i18n.js +159 -0
- package/dist/pi/packages/ta-initiative/lib/inbox-util.d.ts +19 -0
- package/dist/pi/packages/ta-initiative/lib/inbox-util.js +45 -0
- package/dist/pi/packages/ta-initiative/lib/inbox.d.ts +23 -0
- package/dist/pi/packages/ta-initiative/lib/inbox.js +142 -0
- package/dist/pi/packages/ta-initiative/lib/index.d.ts +10 -0
- package/dist/pi/packages/ta-initiative/lib/index.js +121 -0
- package/dist/pi/packages/ta-initiative/lib/initiative-protocol.d.ts +320 -0
- package/dist/pi/packages/ta-initiative/lib/initiative-protocol.js +96 -0
- package/dist/pi/packages/ta-initiative/lib/initiative-service.d.ts +37 -0
- package/dist/pi/packages/ta-initiative/lib/initiative-service.js +104 -0
- package/dist/pi/packages/ta-initiative/lib/initiative-store.d.ts +44 -0
- package/dist/pi/packages/ta-initiative/lib/initiative-store.js +112 -0
- package/dist/pi/packages/ta-initiative/lib/level-util.d.ts +22 -0
- package/dist/pi/packages/ta-initiative/lib/level-util.js +86 -0
- package/dist/pi/packages/ta-initiative/lib/material-util.d.ts +34 -0
- package/dist/pi/packages/ta-initiative/lib/material-util.js +155 -0
- package/dist/pi/packages/ta-initiative/lib/notices.d.ts +13 -0
- package/dist/pi/packages/ta-initiative/lib/notices.js +65 -0
- package/dist/pi/packages/ta-initiative/lib/notify-util.d.ts +25 -0
- package/dist/pi/packages/ta-initiative/lib/notify-util.js +60 -0
- package/dist/pi/packages/ta-initiative/lib/pace-util.d.ts +21 -0
- package/dist/pi/packages/ta-initiative/lib/pace-util.js +60 -0
- package/dist/pi/packages/ta-initiative/lib/page-initiative.d.ts +9 -0
- package/dist/pi/packages/ta-initiative/lib/page-initiative.js +40 -0
- package/dist/pi/packages/ta-initiative/lib/proposal-book.d.ts +61 -0
- package/dist/pi/packages/ta-initiative/lib/proposal-book.js +397 -0
- package/dist/pi/packages/ta-initiative/lib/react.d.ts +11 -0
- package/dist/pi/packages/ta-initiative/lib/react.js +16 -0
- package/dist/pi/packages/ta-initiative/lib/review-service.d.ts +32 -0
- package/dist/pi/packages/ta-initiative/lib/review-service.js +155 -0
- package/dist/pi/packages/ta-initiative/lib/server-texts.d.ts +7 -0
- package/dist/pi/packages/ta-initiative/lib/server-texts.js +17 -0
- package/dist/pi/packages/ta-initiative/lib/settings.d.ts +10 -0
- package/dist/pi/packages/ta-initiative/lib/settings.js +226 -0
- package/dist/pi/packages/ta-initiative/lib/style.d.ts +4 -0
- package/dist/pi/packages/ta-initiative/lib/style.js +56 -0
- package/dist/pi/packages/ta-initiative/lib/tool.d.ts +106 -0
- package/dist/pi/packages/ta-initiative/lib/tool.js +98 -0
- package/dist/pi/packages/ta-initiative/package.json +63 -0
- package/dist/pi/packages/ta-initiative/web/index.js +1226 -0
- package/dist/pi/packages/ta-launcher/README.en.md +2 -1
- package/dist/pi/packages/ta-launcher/README.md +2 -1
- package/dist/pi/packages/ta-launcher/lib/i18n.d.ts +2 -0
- package/dist/pi/packages/ta-launcher/lib/i18n.js +4 -0
- package/dist/pi/packages/ta-launcher/lib/launcher-view.js +32 -0
- package/dist/pi/packages/ta-launcher/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-launcher/lib/style.js +11 -0
- package/dist/pi/packages/ta-launcher/package.json +1 -1
- package/dist/pi/packages/ta-launcher/web/index.js +58 -1
- package/dist/pi/packages/ta-manual/lib/pictures-b.js +29 -0
- package/dist/pi/packages/ta-manual/lib/pictures-c.js +109 -2
- package/dist/pi/packages/ta-manual/lib/topics.d.ts +4 -0
- package/dist/pi/packages/ta-manual/lib/topics.js +123 -11
- package/dist/pi/packages/ta-manual/package.json +1 -1
- package/dist/pi/packages/ta-manual/skills/ta-manual/SKILL.md +45 -10
- package/dist/pi/packages/ta-manual/web/index.js +567 -12
- package/dist/pi/packages/ta-moments/README.en.md +29 -0
- package/dist/pi/packages/ta-moments/README.md +29 -0
- package/dist/pi/packages/ta-moments/extension/index.mjs +1787 -0
- package/dist/pi/packages/ta-moments/host/index.mjs +2415 -0
- package/dist/pi/packages/ta-moments/lib/brief-util.d.ts +30 -0
- package/dist/pi/packages/ta-moments/lib/brief-util.js +92 -0
- package/dist/pi/packages/ta-moments/lib/context.d.ts +18 -0
- package/dist/pi/packages/ta-moments/lib/context.js +35 -0
- package/dist/pi/packages/ta-moments/lib/draft-card.d.ts +6 -0
- package/dist/pi/packages/ta-moments/lib/draft-card.js +60 -0
- package/dist/pi/packages/ta-moments/lib/editor.d.ts +16 -0
- package/dist/pi/packages/ta-moments/lib/editor.js +126 -0
- package/dist/pi/packages/ta-moments/lib/extension.d.ts +24 -0
- package/dist/pi/packages/ta-moments/lib/extension.js +136 -0
- package/dist/pi/packages/ta-moments/lib/friends.d.ts +13 -0
- package/dist/pi/packages/ta-moments/lib/friends.js +27 -0
- package/dist/pi/packages/ta-moments/lib/host.d.ts +4 -0
- package/dist/pi/packages/ta-moments/lib/host.js +11 -0
- package/dist/pi/packages/ta-moments/lib/i18n.d.ts +92 -0
- package/dist/pi/packages/ta-moments/lib/i18n.js +201 -0
- package/dist/pi/packages/ta-moments/lib/image-util.d.ts +18 -0
- package/dist/pi/packages/ta-moments/lib/image-util.js +71 -0
- package/dist/pi/packages/ta-moments/lib/index.d.ts +8 -0
- package/dist/pi/packages/ta-moments/lib/index.js +50 -0
- package/dist/pi/packages/ta-moments/lib/moments-host.d.ts +133 -0
- package/dist/pi/packages/ta-moments/lib/moments-host.js +821 -0
- package/dist/pi/packages/ta-moments/lib/moments-protocol.d.ts +334 -0
- package/dist/pi/packages/ta-moments/lib/moments-protocol.js +99 -0
- package/dist/pi/packages/ta-moments/lib/page.d.ts +7 -0
- package/dist/pi/packages/ta-moments/lib/page.js +307 -0
- package/dist/pi/packages/ta-moments/lib/post-util.d.ts +31 -0
- package/dist/pi/packages/ta-moments/lib/post-util.js +205 -0
- package/dist/pi/packages/ta-moments/lib/server-texts.d.ts +29 -0
- package/dist/pi/packages/ta-moments/lib/server-texts.js +104 -0
- package/dist/pi/packages/ta-moments/lib/store.d.ts +33 -0
- package/dist/pi/packages/ta-moments/lib/store.js +108 -0
- package/dist/pi/packages/ta-moments/lib/style.d.ts +4 -0
- package/dist/pi/packages/ta-moments/lib/style.js +155 -0
- package/dist/pi/packages/ta-moments/lib/talk-host.d.ts +112 -0
- package/dist/pi/packages/ta-moments/lib/talk-host.js +582 -0
- package/dist/pi/packages/ta-moments/lib/talk-util.d.ts +26 -0
- package/dist/pi/packages/ta-moments/lib/talk-util.js +145 -0
- package/dist/pi/packages/ta-moments/lib/tool.d.ts +48 -0
- package/dist/pi/packages/ta-moments/lib/tool.js +56 -0
- package/dist/pi/packages/ta-moments/package.json +61 -0
- package/dist/pi/packages/ta-moments/web/index.js +2008 -0
- package/dist/pi/packages/ta-nearby/README.en.md +33 -0
- package/dist/pi/packages/ta-nearby/README.md +33 -0
- package/dist/pi/packages/ta-nearby/extension/index.mjs +410 -0
- package/dist/pi/packages/ta-nearby/host/index.mjs +1859 -0
- package/dist/pi/packages/ta-nearby/lib/extension.d.ts +27 -0
- package/dist/pi/packages/ta-nearby/lib/extension.js +190 -0
- package/dist/pi/packages/ta-nearby/lib/host.d.ts +7 -0
- package/dist/pi/packages/ta-nearby/lib/host.js +20 -0
- package/dist/pi/packages/ta-nearby/lib/i18n.d.ts +92 -0
- package/dist/pi/packages/ta-nearby/lib/i18n.js +183 -0
- package/dist/pi/packages/ta-nearby/lib/index.d.ts +8 -0
- package/dist/pi/packages/ta-nearby/lib/index.js +38 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-crypto.d.ts +31 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-crypto.js +59 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-meet.d.ts +35 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-meet.js +93 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-net.d.ts +59 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-net.js +253 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-protocol.d.ts +274 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-protocol.js +31 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-service.d.ts +199 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-service.js +1012 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-spot.d.ts +50 -0
- package/dist/pi/packages/ta-nearby/lib/nearby-spot.js +167 -0
- package/dist/pi/packages/ta-nearby/lib/page.d.ts +52 -0
- package/dist/pi/packages/ta-nearby/lib/page.js +588 -0
- package/dist/pi/packages/ta-nearby/lib/react.d.ts +8 -0
- package/dist/pi/packages/ta-nearby/lib/react.js +8 -0
- package/dist/pi/packages/ta-nearby/lib/server-texts.d.ts +45 -0
- package/dist/pi/packages/ta-nearby/lib/server-texts.js +148 -0
- package/dist/pi/packages/ta-nearby/lib/style.d.ts +4 -0
- package/dist/pi/packages/ta-nearby/lib/style.js +92 -0
- package/dist/pi/packages/ta-nearby/package.json +65 -0
- package/dist/pi/packages/ta-nearby/web/index.js +1055 -0
- package/dist/pi/packages/ta-notify/README.en.md +3 -1
- package/dist/pi/packages/ta-notify/README.md +3 -1
- package/dist/pi/packages/ta-notify/extension/index.mjs +85 -0
- package/dist/pi/packages/ta-notify/host/index.mjs +24 -1
- package/dist/pi/packages/ta-notify/lib/extension.d.ts +4 -1
- package/dist/pi/packages/ta-notify/lib/extension.js +20 -1
- package/dist/pi/packages/ta-notify/lib/notify-protocol.d.ts +23 -3
- package/dist/pi/packages/ta-notify/lib/notify-service.d.ts +4 -2
- package/dist/pi/packages/ta-notify/lib/notify-service.js +27 -2
- package/dist/pi/packages/ta-notify/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-notify/lib/style.js +1 -1
- package/dist/pi/packages/ta-notify/lib/watcher.js +2 -1
- package/dist/pi/packages/ta-notify/package.json +7 -2
- package/dist/pi/packages/ta-notify/web/index.js +3 -2
- package/dist/pi/packages/ta-recall/README.en.md +15 -6
- package/dist/pi/packages/ta-recall/README.md +15 -6
- package/dist/pi/packages/ta-recall/extension/index.mjs +311 -134
- package/dist/pi/packages/ta-recall/host/index.mjs +472 -116
- package/dist/pi/packages/ta-recall/lib/block-util.d.ts +11 -0
- package/dist/pi/packages/ta-recall/lib/block-util.js +43 -0
- package/dist/pi/packages/ta-recall/lib/brief-util.d.ts +25 -0
- package/dist/pi/packages/ta-recall/lib/brief-util.js +38 -1
- package/dist/pi/packages/ta-recall/lib/composer.d.ts +3 -2
- package/dist/pi/packages/ta-recall/lib/composer.js +9 -8
- package/dist/pi/packages/ta-recall/lib/extension-util.d.ts +21 -0
- package/dist/pi/packages/ta-recall/lib/extension-util.js +104 -0
- package/dist/pi/packages/ta-recall/lib/extension.d.ts +3 -3
- package/dist/pi/packages/ta-recall/lib/extension.js +31 -23
- package/dist/pi/packages/ta-recall/lib/i18n.d.ts +18 -10
- package/dist/pi/packages/ta-recall/lib/i18n.js +40 -24
- package/dist/pi/packages/ta-recall/lib/index.d.ts +2 -2
- package/dist/pi/packages/ta-recall/lib/index.js +5 -4
- package/dist/pi/packages/ta-recall/lib/keep-card.d.ts +10 -0
- package/dist/pi/packages/ta-recall/lib/keep-card.js +83 -0
- package/dist/pi/packages/ta-recall/lib/keep-util.d.ts +15 -0
- package/dist/pi/packages/ta-recall/lib/keep-util.js +55 -0
- package/dist/pi/packages/ta-recall/lib/recall-protocol.d.ts +92 -18
- package/dist/pi/packages/ta-recall/lib/recall-protocol.js +19 -9
- package/dist/pi/packages/ta-recall/lib/recall-service.d.ts +16 -6
- package/dist/pi/packages/ta-recall/lib/recall-service.js +101 -11
- package/dist/pi/packages/ta-recall/lib/requests-util.d.ts +6 -0
- package/dist/pi/packages/ta-recall/lib/requests-util.js +37 -0
- package/dist/pi/packages/ta-recall/lib/server-texts.d.ts +2 -0
- package/dist/pi/packages/ta-recall/lib/server-texts.js +5 -0
- package/dist/pi/packages/ta-recall/lib/settings.d.ts +1 -1
- package/dist/pi/packages/ta-recall/lib/settings.js +1 -1
- package/dist/pi/packages/ta-recall/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-recall/lib/style.js +2 -2
- package/dist/pi/packages/ta-recall/lib/tool-line.d.ts +2 -2
- package/dist/pi/packages/ta-recall/lib/tool-line.js +10 -5
- package/dist/pi/packages/ta-recall/lib/tool.d.ts +14 -5
- package/dist/pi/packages/ta-recall/lib/tool.js +29 -17
- package/dist/pi/packages/ta-recall/package.json +13 -5
- package/dist/pi/packages/ta-recall/web/index.js +414 -153
- package/dist/pi/packages/ta-rooms/README.en.md +6 -3
- package/dist/pi/packages/ta-rooms/README.md +6 -3
- package/dist/pi/packages/ta-rooms/extension/index.mjs +194 -9
- package/dist/pi/packages/ta-rooms/host/index.mjs +1023 -234
- package/dist/pi/packages/ta-rooms/lib/dialogs.js +5 -0
- package/dist/pi/packages/ta-rooms/lib/double-agents.d.ts +26 -0
- package/dist/pi/packages/ta-rooms/lib/double-agents.js +84 -0
- package/dist/pi/packages/ta-rooms/lib/double-grants.d.ts +22 -0
- package/dist/pi/packages/ta-rooms/lib/double-grants.js +140 -0
- package/dist/pi/packages/ta-rooms/lib/double-host.d.ts +43 -40
- package/dist/pi/packages/ta-rooms/lib/double-host.js +142 -311
- package/dist/pi/packages/ta-rooms/lib/double-i18n.d.ts +20 -0
- package/dist/pi/packages/ta-rooms/lib/double-i18n.js +40 -0
- package/dist/pi/packages/ta-rooms/lib/double-protocol.d.ts +96 -3
- package/dist/pi/packages/ta-rooms/lib/double-protocol.js +58 -3
- package/dist/pi/packages/ta-rooms/lib/double-tasks.d.ts +82 -0
- package/dist/pi/packages/ta-rooms/lib/double-tasks.js +527 -0
- package/dist/pi/packages/ta-rooms/lib/double-user.d.ts +19 -0
- package/dist/pi/packages/ta-rooms/lib/double-user.js +124 -0
- package/dist/pi/packages/ta-rooms/lib/double-util.d.ts +34 -2
- package/dist/pi/packages/ta-rooms/lib/double-util.js +60 -2
- package/dist/pi/packages/ta-rooms/lib/doubles-store.d.ts +4 -1
- package/dist/pi/packages/ta-rooms/lib/doubles-store.js +8 -2
- package/dist/pi/packages/ta-rooms/lib/doubles-view.js +7 -2
- package/dist/pi/packages/ta-rooms/lib/extension.d.ts +9 -0
- package/dist/pi/packages/ta-rooms/lib/extension.js +35 -8
- package/dist/pi/packages/ta-rooms/lib/friend-notices.d.ts +12 -0
- package/dist/pi/packages/ta-rooms/lib/friend-notices.js +47 -0
- package/dist/pi/packages/ta-rooms/lib/friends-view.d.ts +20 -0
- package/dist/pi/packages/ta-rooms/lib/friends-view.js +224 -0
- package/dist/pi/packages/ta-rooms/lib/host.d.ts +2 -1
- package/dist/pi/packages/ta-rooms/lib/host.js +9 -2
- package/dist/pi/packages/ta-rooms/lib/i18n.d.ts +23 -2
- package/dist/pi/packages/ta-rooms/lib/i18n.js +60 -18
- package/dist/pi/packages/ta-rooms/lib/index.js +18 -1
- package/dist/pi/packages/ta-rooms/lib/members-view.js +12 -1
- package/dist/pi/packages/ta-rooms/lib/page.d.ts +42 -4
- package/dist/pi/packages/ta-rooms/lib/page.js +108 -24
- package/dist/pi/packages/ta-rooms/lib/room-view.js +7 -3
- package/dist/pi/packages/ta-rooms/lib/rooms-page.js +6 -17
- package/dist/pi/packages/ta-rooms/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-rooms/lib/style.js +31 -6
- package/dist/pi/packages/ta-rooms/lib/tasks-view.d.ts +41 -0
- package/dist/pi/packages/ta-rooms/lib/tasks-view.js +228 -0
- package/dist/pi/packages/ta-rooms/package.json +11 -2
- package/dist/pi/packages/ta-rooms/web/index.js +1633 -751
- package/dist/pi/packages/ta-share/README.en.md +1 -1
- package/dist/pi/packages/ta-share/README.md +1 -1
- package/dist/pi/packages/ta-share/extension/index.mjs +72 -0
- package/dist/pi/packages/ta-share/lib/i18n.js +6 -6
- package/dist/pi/packages/ta-share/lib/share-dialog.js +1 -1
- package/dist/pi/packages/ta-share/lib/style.d.ts +1 -1
- package/dist/pi/packages/ta-share/lib/style.js +4 -6
- package/dist/pi/packages/ta-share/package.json +10 -2
- package/dist/pi/packages/ta-share/web/index.js +12 -14
- package/dist/pi/packages/ta-sync/README.en.md +55 -0
- package/dist/pi/packages/ta-sync/README.md +55 -0
- package/dist/pi/packages/ta-sync/host/index.mjs +3763 -0
- package/dist/pi/packages/ta-sync/lib/host.d.ts +10 -0
- package/dist/pi/packages/ta-sync/lib/host.js +94 -0
- package/dist/pi/packages/ta-sync/lib/i18n.d.ts +98 -0
- package/dist/pi/packages/ta-sync/lib/i18n.js +202 -0
- package/dist/pi/packages/ta-sync/lib/index.d.ts +7 -0
- package/dist/pi/packages/ta-sync/lib/index.js +115 -0
- package/dist/pi/packages/ta-sync/lib/migrate-archive.d.ts +88 -0
- package/dist/pi/packages/ta-sync/lib/migrate-archive.js +439 -0
- package/dist/pi/packages/ta-sync/lib/migrate-frames.d.ts +77 -0
- package/dist/pi/packages/ta-sync/lib/migrate-frames.js +210 -0
- package/dist/pi/packages/ta-sync/lib/migrate-i18n.d.ts +99 -0
- package/dist/pi/packages/ta-sync/lib/migrate-i18n.js +210 -0
- package/dist/pi/packages/ta-sync/lib/migrate-net.d.ts +51 -0
- package/dist/pi/packages/ta-sync/lib/migrate-net.js +170 -0
- package/dist/pi/packages/ta-sync/lib/migrate-protocol.d.ts +126 -0
- package/dist/pi/packages/ta-sync/lib/migrate-protocol.js +43 -0
- package/dist/pi/packages/ta-sync/lib/migrate-service.d.ts +86 -0
- package/dist/pi/packages/ta-sync/lib/migrate-service.js +521 -0
- package/dist/pi/packages/ta-sync/lib/move-panel.d.ts +16 -0
- package/dist/pi/packages/ta-sync/lib/move-panel.js +320 -0
- package/dist/pi/packages/ta-sync/lib/move-store.d.ts +15 -0
- package/dist/pi/packages/ta-sync/lib/move-store.js +42 -0
- package/dist/pi/packages/ta-sync/lib/panel.d.ts +28 -0
- package/dist/pi/packages/ta-sync/lib/panel.js +305 -0
- package/dist/pi/packages/ta-sync/lib/pictures.d.ts +22 -0
- package/dist/pi/packages/ta-sync/lib/pictures.js +92 -0
- package/dist/pi/packages/ta-sync/lib/react.d.ts +11 -0
- package/dist/pi/packages/ta-sync/lib/react.js +16 -0
- package/dist/pi/packages/ta-sync/lib/server-texts.d.ts +29 -0
- package/dist/pi/packages/ta-sync/lib/server-texts.js +111 -0
- package/dist/pi/packages/ta-sync/lib/style.d.ts +4 -0
- package/dist/pi/packages/ta-sync/lib/style.js +108 -0
- package/dist/pi/packages/ta-sync/lib/sync-codec.d.ts +16 -0
- package/dist/pi/packages/ta-sync/lib/sync-codec.js +61 -0
- package/dist/pi/packages/ta-sync/lib/sync-engine.d.ts +57 -0
- package/dist/pi/packages/ta-sync/lib/sync-engine.js +203 -0
- package/dist/pi/packages/ta-sync/lib/sync-folder.d.ts +156 -0
- package/dist/pi/packages/ta-sync/lib/sync-folder.js +385 -0
- package/dist/pi/packages/ta-sync/lib/sync-identity.d.ts +60 -0
- package/dist/pi/packages/ta-sync/lib/sync-identity.js +201 -0
- package/dist/pi/packages/ta-sync/lib/sync-items.d.ts +104 -0
- package/dist/pi/packages/ta-sync/lib/sync-items.js +426 -0
- package/dist/pi/packages/ta-sync/lib/sync-merge.d.ts +42 -0
- package/dist/pi/packages/ta-sync/lib/sync-merge.js +109 -0
- package/dist/pi/packages/ta-sync/lib/sync-protocol.d.ts +134 -0
- package/dist/pi/packages/ta-sync/lib/sync-protocol.js +72 -0
- package/dist/pi/packages/ta-sync/lib/sync-service.d.ts +128 -0
- package/dist/pi/packages/ta-sync/lib/sync-service.js +679 -0
- package/dist/pi/packages/ta-sync/lib/sync-store.d.ts +15 -0
- package/dist/pi/packages/ta-sync/lib/sync-store.js +41 -0
- package/dist/pi/packages/ta-sync/package.json +57 -0
- package/dist/pi/packages/ta-sync/web/index.js +2018 -0
- package/dist/pi/packages/ta-sync-cloud/README.en.md +31 -0
- package/dist/pi/packages/ta-sync-cloud/README.md +31 -0
- package/dist/pi/packages/ta-sync-cloud/host/index.mjs +810 -0
- package/dist/pi/packages/ta-sync-cloud/lib/git-store.d.ts +90 -0
- package/dist/pi/packages/ta-sync-cloud/lib/git-store.js +393 -0
- package/dist/pi/packages/ta-sync-cloud/lib/host.d.ts +13 -0
- package/dist/pi/packages/ta-sync-cloud/lib/host.js +112 -0
- package/dist/pi/packages/ta-sync-cloud/lib/s3-store.d.ts +72 -0
- package/dist/pi/packages/ta-sync-cloud/lib/s3-store.js +206 -0
- package/dist/pi/packages/ta-sync-cloud/lib/store-util.d.ts +17 -0
- package/dist/pi/packages/ta-sync-cloud/lib/store-util.js +69 -0
- package/dist/pi/packages/ta-sync-cloud/lib/webdav-store.d.ts +40 -0
- package/dist/pi/packages/ta-sync-cloud/lib/webdav-store.js +144 -0
- package/dist/pi/packages/ta-sync-cloud/package.json +63 -0
- package/dist/pi/packages/ta-team/README.en.md +28 -0
- package/dist/pi/packages/ta-team/README.md +28 -0
- package/dist/pi/packages/ta-team/extension/index.mjs +285 -0
- package/dist/pi/packages/ta-team/host/index.mjs +2121 -0
- package/dist/pi/packages/ta-team/lib/dialogs.d.ts +13 -0
- package/dist/pi/packages/ta-team/lib/dialogs.js +335 -0
- package/dist/pi/packages/ta-team/lib/extension.d.ts +21 -0
- package/dist/pi/packages/ta-team/lib/extension.js +123 -0
- package/dist/pi/packages/ta-team/lib/host.d.ts +13 -0
- package/dist/pi/packages/ta-team/lib/host.js +45 -0
- package/dist/pi/packages/ta-team/lib/i18n.d.ts +200 -0
- package/dist/pi/packages/ta-team/lib/i18n.js +401 -0
- package/dist/pi/packages/ta-team/lib/index.d.ts +8 -0
- package/dist/pi/packages/ta-team/lib/index.js +67 -0
- package/dist/pi/packages/ta-team/lib/join.d.ts +28 -0
- package/dist/pi/packages/ta-team/lib/join.js +48 -0
- package/dist/pi/packages/ta-team/lib/member-dialog.d.ts +2 -0
- package/dist/pi/packages/ta-team/lib/member-dialog.js +121 -0
- package/dist/pi/packages/ta-team/lib/members-tab.d.ts +11 -0
- package/dist/pi/packages/ta-team/lib/members-tab.js +133 -0
- package/dist/pi/packages/ta-team/lib/page.d.ts +42 -0
- package/dist/pi/packages/ta-team/lib/page.js +142 -0
- package/dist/pi/packages/ta-team/lib/parts.d.ts +39 -0
- package/dist/pi/packages/ta-team/lib/parts.js +47 -0
- package/dist/pi/packages/ta-team/lib/policy.d.ts +37 -0
- package/dist/pi/packages/ta-team/lib/policy.js +215 -0
- package/dist/pi/packages/ta-team/lib/protocol.d.ts +285 -0
- package/dist/pi/packages/ta-team/lib/protocol.js +119 -0
- package/dist/pi/packages/ta-team/lib/react.d.ts +8 -0
- package/dist/pi/packages/ta-team/lib/react.js +8 -0
- package/dist/pi/packages/ta-team/lib/record-tab.d.ts +8 -0
- package/dist/pi/packages/ta-team/lib/record-tab.js +90 -0
- package/dist/pi/packages/ta-team/lib/remote.d.ts +31 -0
- package/dist/pi/packages/ta-team/lib/remote.js +128 -0
- package/dist/pi/packages/ta-team/lib/roles-tab.d.ts +9 -0
- package/dist/pi/packages/ta-team/lib/roles-tab.js +76 -0
- package/dist/pi/packages/ta-team/lib/seal.d.ts +28 -0
- package/dist/pi/packages/ta-team/lib/seal.js +75 -0
- package/dist/pi/packages/ta-team/lib/shared-home.d.ts +23 -0
- package/dist/pi/packages/ta-team/lib/shared-home.js +123 -0
- package/dist/pi/packages/ta-team/lib/style.d.ts +4 -0
- package/dist/pi/packages/ta-team/lib/style.js +99 -0
- package/dist/pi/packages/ta-team/lib/team-admin.d.ts +31 -0
- package/dist/pi/packages/ta-team/lib/team-admin.js +140 -0
- package/dist/pi/packages/ta-team/lib/team-audit.d.ts +35 -0
- package/dist/pi/packages/ta-team/lib/team-audit.js +152 -0
- package/dist/pi/packages/ta-team/lib/team-core.d.ts +58 -0
- package/dist/pi/packages/ta-team/lib/team-core.js +115 -0
- package/dist/pi/packages/ta-team/lib/team-error.d.ts +4 -0
- package/dist/pi/packages/ta-team/lib/team-error.js +8 -0
- package/dist/pi/packages/ta-team/lib/team-expiry.d.ts +15 -0
- package/dist/pi/packages/ta-team/lib/team-expiry.js +67 -0
- package/dist/pi/packages/ta-team/lib/team-files.d.ts +21 -0
- package/dist/pi/packages/ta-team/lib/team-files.js +119 -0
- package/dist/pi/packages/ta-team/lib/team-inbox.d.ts +8 -0
- package/dist/pi/packages/ta-team/lib/team-inbox.js +32 -0
- package/dist/pi/packages/ta-team/lib/team-invites.d.ts +46 -0
- package/dist/pi/packages/ta-team/lib/team-invites.js +204 -0
- package/dist/pi/packages/ta-team/lib/team-page.d.ts +6 -0
- package/dist/pi/packages/ta-team/lib/team-page.js +41 -0
- package/dist/pi/packages/ta-team/lib/team-paths.d.ts +15 -0
- package/dist/pi/packages/ta-team/lib/team-paths.js +70 -0
- package/dist/pi/packages/ta-team/lib/team-people.d.ts +28 -0
- package/dist/pi/packages/ta-team/lib/team-people.js +106 -0
- package/dist/pi/packages/ta-team/lib/team-requests.d.ts +24 -0
- package/dist/pi/packages/ta-team/lib/team-requests.js +126 -0
- package/dist/pi/packages/ta-team/lib/team-runs.d.ts +38 -0
- package/dist/pi/packages/ta-team/lib/team-runs.js +136 -0
- package/dist/pi/packages/ta-team/lib/team-service.d.ts +32 -0
- package/dist/pi/packages/ta-team/lib/team-service.js +58 -0
- package/dist/pi/packages/ta-team/lib/team-shares.d.ts +52 -0
- package/dist/pi/packages/ta-team/lib/team-shares.js +145 -0
- package/dist/pi/packages/ta-team/lib/team-waits.d.ts +8 -0
- package/dist/pi/packages/ta-team/lib/team-waits.js +42 -0
- package/dist/pi/packages/ta-team/lib/team-watch.d.ts +28 -0
- package/dist/pi/packages/ta-team/lib/team-watch.js +136 -0
- package/dist/pi/packages/ta-team/package.json +68 -0
- package/dist/pi/packages/ta-team/web/index.js +2741 -0
- package/dist/pi/packages/ta-workspace/package.json +1 -1
- package/dist/pi/packages/ta-workspace/web/index.js +178 -0
- package/dist/public/assets/{abnfDiagram-S7VZAUFO-BnqtcbpZ.js → abnfDiagram-S7VZAUFO-C30pzFN3.js} +1 -1
- package/dist/public/assets/{architecture-WOLXFQ4H-BzPq1Ioe.js → architecture-WOLXFQ4H-wfYFQl2u.js} +1 -1
- package/dist/public/assets/{architectureDiagram-YGSQEFNW-BsquO3a7.js → architectureDiagram-YGSQEFNW-B05zgxyT.js} +1 -1
- package/dist/public/assets/{blockDiagram-APKKGZFW-BQNYOEP4.js → blockDiagram-APKKGZFW-BhN8Bsu0.js} +1 -1
- package/dist/public/assets/{browser-DS711n7Y.js → browser-DteLjv_-.js} +1 -1
- package/dist/public/assets/{c4Diagram-KJ2TOQU5-D6e79Ycq.js → c4Diagram-KJ2TOQU5-DvdF3qCV.js} +1 -1
- package/dist/public/assets/{chunk-6MUBBAK2-B-sgaPoU.js → chunk-6MUBBAK2-DNavkrnr.js} +1 -1
- package/dist/public/assets/{chunk-AXFCVDMN-D8pJKIg2.js → chunk-AXFCVDMN-DplVEqp_.js} +1 -1
- package/dist/public/assets/{chunk-BG4553SI-86TL-vCz.js → chunk-BG4553SI-BazOaHvw.js} +1 -1
- package/dist/public/assets/{chunk-DQASFODM-CfUVuGjc.js → chunk-DQASFODM-DmoQWa8b.js} +1 -1
- package/dist/public/assets/{chunk-HFQBQIA3-Drm0FEYk.js → chunk-HFQBQIA3-Cj1m9ccz.js} +1 -1
- package/dist/public/assets/{chunk-KQLB2F66-BVFRADlC.js → chunk-KQLB2F66-_jbilrLX.js} +1 -1
- package/dist/public/assets/{chunk-KS47KZWR-DfyALEmP.js → chunk-KS47KZWR-CWU16Lut.js} +1 -1
- package/dist/public/assets/{chunk-LEVMRMFU-DtJVzk2c.js → chunk-LEVMRMFU-wsbxWEZE.js} +1 -1
- package/dist/public/assets/{chunk-M57EVK23-DTy27PHQ.js → chunk-M57EVK23-BGvmwwTv.js} +1 -1
- package/dist/public/assets/{chunk-OY52VR5R-nSgn7jZg.js → chunk-OY52VR5R-Bp3hJ4kT.js} +1 -1
- package/dist/public/assets/{chunk-QB3YPZ4I-CkSxO_X6.js → chunk-QB3YPZ4I-C1rQVxsJ.js} +1 -1
- package/dist/public/assets/{chunk-R3KSYZAL-Ck6iAjAL.js → chunk-R3KSYZAL-CEy0dKWn.js} +1 -1
- package/dist/public/assets/{chunk-STOXU5M4-DQPHdSTh.js → chunk-STOXU5M4-akqvafwH.js} +1 -1
- package/dist/public/assets/{chunk-TU62E6Q5-Bc2AbV2Y.js → chunk-TU62E6Q5-CVXAS4DS.js} +1 -1
- package/dist/public/assets/{chunk-X4PVCEUW-Cgpm0IXm.js → chunk-X4PVCEUW-DT_bEMvQ.js} +1 -1
- package/dist/public/assets/{chunk-XXDRQBXY-CGE4eLpg.js → chunk-XXDRQBXY-Bgv_n5Qh.js} +1 -1
- package/dist/public/assets/{classDiagram-v2-L25IHNXF-4eQuDPEo.js → classDiagram-v2-L25IHNXF-BtjQChpS.js} +1 -1
- package/dist/public/assets/{cose-bilkent-JH36ORCC-tDLCWq07.js → cose-bilkent-JH36ORCC-DSrOY8Uk.js} +1 -1
- package/dist/public/assets/cynefin-EF2NZ3EQ-DYlwwGUb.js +1 -0
- package/dist/public/assets/{cynefinDiagram-L36ESFBY-ByqcZ8x9.js → cynefinDiagram-L36ESFBY-DTy7FNFS.js} +1 -1
- package/dist/public/assets/{d3-selection-Bgn1374-.js → d3-selection-ip6rDUzY.js} +1 -1
- package/dist/public/assets/{dagre-SPEB5RXH-mCgr71mV.js → dagre-SPEB5RXH-CHrks7Jb.js} +1 -1
- package/dist/public/assets/{diagram-3B7GL73J-DpYSwpQ0.js → diagram-3B7GL73J-eUJ7STAr.js} +1 -1
- package/dist/public/assets/{diagram-DNEMPZML-DMozUQzi.js → diagram-DNEMPZML-B_fptNkg.js} +1 -1
- package/dist/public/assets/{diagram-L3MUGCDN-Bk5Uf8PD.js → diagram-L3MUGCDN-C15owCSG.js} +1 -1
- package/dist/public/assets/{diagram-LA4NIPWU-DFt5cPVK.js → diagram-LA4NIPWU-Bfa1qEgY.js} +1 -1
- package/dist/public/assets/{diagram-MHCOC4E2-BkZZcKqK.js → diagram-MHCOC4E2-Bwxsih_Q.js} +1 -1
- package/dist/public/assets/{diagram-XPFHEONP-HEY6kyyN.js → diagram-XPFHEONP-DKZ_lwah.js} +1 -1
- package/dist/public/assets/{dist-Bj2CrKn7.js → dist-VHGBaby6.js} +1 -1
- package/dist/public/assets/{ebnfDiagram-UZSYDL2S-D4JvYyVb.js → ebnfDiagram-UZSYDL2S-CCkttvYi.js} +1 -1
- package/dist/public/assets/{editor.api-BpJFzYbl.js → editor.api-a2gC0dVD.js} +1 -1
- package/dist/public/assets/{elk-XV6XMXQE-CT6qLJkF.js → elk-XV6XMXQE-DcikW39e.js} +1 -1
- package/dist/public/assets/{erDiagram-EYBAPDEH-BGng1goR.js → erDiagram-EYBAPDEH-BE3TV5lU.js} +1 -1
- package/dist/public/assets/{eventmodeling-K75KTNOO-Tt8O-Q1Z.js → eventmodeling-K75KTNOO-C2s1kutf.js} +1 -1
- package/dist/public/assets/flowDiagram-MALGAFMO-Bufgn1OL.js +1 -0
- package/dist/public/assets/{freemarker2-Dd5ksoRn.js → freemarker2-2e8pZojb.js} +1 -1
- package/dist/public/assets/{ganttDiagram-23REXITY-Jl8VO_g2.js → ganttDiagram-23REXITY-rGnJptii.js} +1 -1
- package/dist/public/assets/gitGraph-VSP46ZUC-D_tzR9z9.js +1 -0
- package/dist/public/assets/{gitGraphDiagram-STJD7YCW-Be4qXALb.js → gitGraphDiagram-STJD7YCW-CNnsDjQA.js} +1 -1
- package/dist/public/assets/{handlebars-4xabgUi4.js → handlebars-CMKN6E37.js} +1 -1
- package/dist/public/assets/{html-Dk3kt2w_.js → html-0AjXQhkQ.js} +1 -1
- package/dist/public/assets/{index-Bx0c7eoh.js → index-TUtoc8CW.js} +2 -2
- package/dist/public/assets/info-OHQRW6UA-C5Pwv-6e.js +1 -0
- package/dist/public/assets/{infoDiagram-KBXO4MBG-Coc0tdwb.js → infoDiagram-KBXO4MBG-DMKs8cuE.js} +1 -1
- package/dist/public/assets/{ishikawaDiagram-M35NCXHK-CE_1VQCg.js → ishikawaDiagram-M35NCXHK-Dg_IbA0G.js} +1 -1
- package/dist/public/assets/{javascript-DKLGqy6v.js → javascript-CqYOqPjw.js} +1 -1
- package/dist/public/assets/{journeyDiagram-OPLOXDXO-CrolRZ_7.js → journeyDiagram-OPLOXDXO-ohAOfoEY.js} +1 -1
- package/dist/public/assets/{jsonMode-Chcs19_y.js → jsonMode-D-gI-S5H.js} +1 -1
- package/dist/public/assets/{kanban-definition-BZKZHSQY-CjJj47De.js → kanban-definition-BZKZHSQY-w-aKZS_U.js} +1 -1
- package/dist/public/assets/{liquid-jff3p-Ji.js → liquid-oBN7c8NZ.js} +1 -1
- package/dist/public/assets/{mdx-DW4uRDfJ.js → mdx-CnwhgGjX.js} +1 -1
- package/dist/public/assets/{mermaid-parser.core-XhQj6FvH.js → mermaid-parser.core-CfFkSR0t.js} +3 -3
- package/dist/public/assets/{mermaid.core-OD4Atimg.js → mermaid.core-apiVCSBY.js} +4 -4
- package/dist/public/assets/{mindmap-definition-I2QAS2VK-DpGelVY7.js → mindmap-definition-I2QAS2VK-E7vqVWB0.js} +1 -1
- package/dist/public/assets/module-C2jtFD0v.js +2365 -0
- package/dist/public/assets/module-xT4L5yYw.js +1 -0
- package/dist/public/assets/{monaco-BTVZP-tU.js → monaco-C0ByxW3l.js} +3 -3
- package/dist/public/assets/packet-JDAUHWVQ-xozI7a9T.js +1 -0
- package/dist/public/assets/{pegDiagram-FD4XPPHP-CqcBmPfB.js → pegDiagram-FD4XPPHP--RpwCE7x.js} +1 -1
- package/dist/public/assets/pie-XZMESJXO-BkHXIzDi.js +1 -0
- package/dist/public/assets/{pieDiagram-J4AKIIQI-CRir3beB.js → pieDiagram-J4AKIIQI-DxSbPaRZ.js} +1 -1
- package/dist/public/assets/{python-BwW_0207.js → python-vNPe_Fao.js} +1 -1
- package/dist/public/assets/{quadrantDiagram-XTYBLID2-DIY6gdcf.js → quadrantDiagram-XTYBLID2-CR_eeYXi.js} +1 -1
- package/dist/public/assets/radar-ABXABTNO-CaUh9zV3.js +1 -0
- package/dist/public/assets/railroad-I3PHUGI6-DckPvlDe.js +1 -0
- package/dist/public/assets/{railroad-abnf-LNEFI6M7-XWNOzunl.js → railroad-abnf-LNEFI6M7-D6I2HxIC.js} +1 -1
- package/dist/public/assets/{railroad-ebnf-DWYD2UWJ-CI0-j1Jz.js → railroad-ebnf-DWYD2UWJ-BuhDRGo3.js} +1 -1
- package/dist/public/assets/{railroad-peg-JR7BVNR7-BVB_IaIG.js → railroad-peg-JR7BVNR7-n15PB7Sb.js} +1 -1
- package/dist/public/assets/{railroadDiagram-MRQ6NCDL-CudwT6q2.js → railroadDiagram-MRQ6NCDL-Bbe5bNap.js} +1 -1
- package/dist/public/assets/{razor-DrjCyQqB.js → razor-CnKbF0Yz.js} +1 -1
- package/dist/public/assets/{requirementDiagram-Y7LWUY3S-CvRMeRqj.js → requirementDiagram-Y7LWUY3S-Beuygh9j.js} +1 -1
- package/dist/public/assets/{sankeyDiagram-WGJFYUXA-adxYCJKr.js → sankeyDiagram-WGJFYUXA-jwWPgnrS.js} +1 -1
- package/dist/public/assets/{sequenceDiagram-5NDRBG5M-lCRsoLUp.js → sequenceDiagram-5NDRBG5M-CmU-HYQI.js} +1 -1
- package/dist/public/assets/{stateDiagram-v2-FJ4FJNEA-DNst1BLg.js → stateDiagram-v2-FJ4FJNEA-Bo7BEi-m.js} +1 -1
- package/dist/public/assets/{swimlanes-UMQ2AFYF-S_omrdvA.js → swimlanes-UMQ2AFYF-PSKyZN_b.js} +1 -1
- package/dist/public/assets/swimlanesDiagram-OMPLPG4O-z_0ABNQq.js +8 -0
- package/dist/public/assets/{timeline-definition-SEUHKTQE-_pMGrTE-.js → timeline-definition-SEUHKTQE-BuRxLScZ.js} +1 -1
- package/dist/public/assets/treeView-D4JQ5SDB-BN38Jg9j.js +1 -0
- package/dist/public/assets/treemap-SAJKECNS-CKdz7u7W.js +1 -0
- package/dist/public/assets/{typescript-0-z_OYCU.js → typescript-C00ztMLg.js} +1 -1
- package/dist/public/assets/{usecaseDiagram-AFA6YXN4-B2oJKi5Q.js → usecaseDiagram-AFA6YXN4-Dlvyos8r.js} +1 -1
- package/dist/public/assets/{vennDiagram-NNMJR3RB-inPs2Kkr.js → vennDiagram-NNMJR3RB-CuLZubJH.js} +1 -1
- package/dist/public/assets/wardley-7MLQ67FV-B0cvM1zV.js +1 -0
- package/dist/public/assets/{wardleyDiagram-S7YFUSEH-DNhNHM7b.js → wardleyDiagram-S7YFUSEH-WOGGTs4y.js} +1 -1
- package/dist/public/assets/{xml-BXPxQzKF.js → xml-CHBFuf5n.js} +1 -1
- package/dist/public/assets/{xychartDiagram-GGNKY7IX-DJc93dNT.js → xychartDiagram-GGNKY7IX-DwW9eifP.js} +1 -1
- package/dist/public/assets/{yaml-CGmD9Rya.js → yaml-C4qkqzcL.js} +1 -1
- package/dist/public/index.html +1 -1
- package/dist/serve/index.mjs +7738 -3839
- package/package.json +37 -31
- package/dist/pi/packages/ta-cron/lib/composer.d.ts +0 -11
- package/dist/pi/packages/ta-cron/lib/composer.js +0 -58
- package/dist/pi/packages/ta-extensions/lib/composer.d.ts +0 -17
- package/dist/pi/packages/ta-extensions/lib/composer.js +0 -84
- package/dist/pi/packages/ta-recall/lib/skill-card.d.ts +0 -9
- package/dist/pi/packages/ta-recall/lib/skill-card.js +0 -51
- package/dist/pi/packages/ta-recall/lib/skill-util.d.ts +0 -19
- package/dist/pi/packages/ta-recall/lib/skill-util.js +0 -110
- package/dist/public/assets/cynefin-EF2NZ3EQ-Dd40W2Jh.js +0 -1
- package/dist/public/assets/flowDiagram-MALGAFMO-uFzenfA3.js +0 -1
- package/dist/public/assets/gitGraph-VSP46ZUC-D28I_jUc.js +0 -1
- package/dist/public/assets/info-OHQRW6UA-5vIGEIq7.js +0 -1
- package/dist/public/assets/module-CrD0OHQp.js +0 -1
- package/dist/public/assets/module-DEBMgdtf.js +0 -2273
- package/dist/public/assets/packet-JDAUHWVQ-CBxQ5Mzy.js +0 -1
- package/dist/public/assets/pie-XZMESJXO-DT5V3581.js +0 -1
- package/dist/public/assets/radar-ABXABTNO-BAOovYEa.js +0 -1
- package/dist/public/assets/railroad-I3PHUGI6-RZ2Rnwzh.js +0 -1
- package/dist/public/assets/swimlanesDiagram-OMPLPG4O-By5lnz4u.js +0 -8
- package/dist/public/assets/treeView-D4JQ5SDB-Cyb9N8KY.js +0 -1
- package/dist/public/assets/treemap-SAJKECNS-BkMo57pG.js +0 -1
- package/dist/public/assets/wardley-7MLQ67FV-CSt-uQ-Y.js +0 -1
|
@@ -0,0 +1,1169 @@
|
|
|
1
|
+
// web-src/initiative-protocol.ts
|
|
2
|
+
var NAME = "@celljs/ta-initiative";
|
|
3
|
+
var FORMER_NAME = "@celljs/ta-evolve";
|
|
4
|
+
var CRON = "@celljs/ta-cron";
|
|
5
|
+
var REVIEW_MARK = "[ta-evolve:review";
|
|
6
|
+
var SECTION = "ta-evolve";
|
|
7
|
+
var PACE_TOOL = "evolve_pace";
|
|
8
|
+
var PROFILE_TOOL = "evolve_profile";
|
|
9
|
+
var PROPOSE_TOOL = "propose";
|
|
10
|
+
var PROFILE_SECTION = "ta-user";
|
|
11
|
+
var LEVELS = ["off", "digest", "ask", "act"];
|
|
12
|
+
var MODES = ["quiet", "balanced", "active"];
|
|
13
|
+
var RESULT_ID = "$result.id";
|
|
14
|
+
var Keys;
|
|
15
|
+
((Keys) => {
|
|
16
|
+
Keys.SETTINGS = "settings";
|
|
17
|
+
Keys.FILE = "file";
|
|
18
|
+
Keys.LAST = "last";
|
|
19
|
+
Keys.NOTE = "note";
|
|
20
|
+
Keys.PROFILE = "profile";
|
|
21
|
+
Keys.MODE = "mode";
|
|
22
|
+
Keys.LOCKS = "locks";
|
|
23
|
+
Keys.PROPOSALS = "proposals";
|
|
24
|
+
Keys.SEEN = "seen";
|
|
25
|
+
Keys.QUIET = "quiet";
|
|
26
|
+
Keys.MIGRATED = "migrated";
|
|
27
|
+
})(Keys ||= {});
|
|
28
|
+
var Limits;
|
|
29
|
+
((Limits) => {
|
|
30
|
+
Limits.MIN_DAYS = 1;
|
|
31
|
+
Limits.MAX_DAYS = 30;
|
|
32
|
+
Limits.LOOK_BACK_DAYS = 7;
|
|
33
|
+
Limits.MATERIAL_CHARS = 48000;
|
|
34
|
+
Limits.RUNS = 5;
|
|
35
|
+
Limits.PROMPT_CHARS = 400;
|
|
36
|
+
Limits.SUMMARY_CHARS = 240;
|
|
37
|
+
Limits.NEW_TASKS = 3;
|
|
38
|
+
Limits.PROFILE_CHARS = 3000;
|
|
39
|
+
Limits.PROPOSALS_KEPT = 200;
|
|
40
|
+
Limits.OUTCOMES = 20;
|
|
41
|
+
Limits.UP_AFTER = 3;
|
|
42
|
+
Limits.DOWN_AFTER = 2;
|
|
43
|
+
Limits.EXPIRE_DAYS = 14;
|
|
44
|
+
Limits.UNDO_DAYS = 7;
|
|
45
|
+
Limits.BUDGET = { quiet: 1, balanced: 3, active: Number.POSITIVE_INFINITY };
|
|
46
|
+
Limits.NOTICE_MS = 2 * 60000;
|
|
47
|
+
})(Limits ||= {});
|
|
48
|
+
|
|
49
|
+
// web-src/chat-kinds.ts
|
|
50
|
+
var CHAT_KINDS = [
|
|
51
|
+
{
|
|
52
|
+
id: "chat.next-step",
|
|
53
|
+
owner: NAME,
|
|
54
|
+
title: { en: "Take the next step you usually want", zh: "接着做你通常要的下一步" },
|
|
55
|
+
reversible: true,
|
|
56
|
+
level: "ask"
|
|
57
|
+
},
|
|
58
|
+
{ id: "git.commit", owner: NAME, title: { en: "Commit the changes", zh: "提交改动" }, reversible: true, level: "ask" },
|
|
59
|
+
{ id: "git.push", owner: NAME, title: { en: "Push to the remote", zh: "推送到远端" }, reversible: false, level: "ask" }
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
// web-src/cron-proposals.ts
|
|
63
|
+
var CRON_KINDS = [
|
|
64
|
+
{
|
|
65
|
+
id: "cron.add",
|
|
66
|
+
owner: NAME,
|
|
67
|
+
title: { en: "Schedule work you ask for again and again", zh: "把反复交代的事建成定时任务" },
|
|
68
|
+
reversible: true,
|
|
69
|
+
level: "ask"
|
|
70
|
+
},
|
|
71
|
+
{ id: "cron.update", owner: NAME, title: { en: "Fix a scheduled task gone out of date", zh: "修改过时的定时任务" }, reversible: true, level: "ask" },
|
|
72
|
+
{ id: "cron.disable", owner: NAME, title: { en: "Turn off a stale or failing task", zh: "停用过时或常失败的任务" }, reversible: true, level: "act" }
|
|
73
|
+
];
|
|
74
|
+
var FIELDS = ["name", "prompt", "schedule", "cwd", "model", "thinking", "notify", "timeout", "enabled"];
|
|
75
|
+
var CLEARED = { model: "", thinking: "", notify: "", timeout: "" };
|
|
76
|
+
var CronProposals;
|
|
77
|
+
((CronProposals) => {
|
|
78
|
+
function isCron(kind) {
|
|
79
|
+
return CRON_KINDS.some((one) => one.id === kind);
|
|
80
|
+
}
|
|
81
|
+
CronProposals.isCron = isCron;
|
|
82
|
+
function build(params, current) {
|
|
83
|
+
const base = {
|
|
84
|
+
kind: params.kind,
|
|
85
|
+
title: params.title,
|
|
86
|
+
why: params.why,
|
|
87
|
+
...Array.isArray(params.evidence) ? { evidence: params.evidence.filter((file) => typeof file === "string").slice(0, 10) } : {}
|
|
88
|
+
};
|
|
89
|
+
switch (params.kind) {
|
|
90
|
+
case "cron.add": {
|
|
91
|
+
const task = params.task;
|
|
92
|
+
if (!task || typeof task.prompt !== "string" || !task.schedule) {
|
|
93
|
+
throw new Error("cron.add needs task with at least prompt and schedule, as schedule_task adds one.");
|
|
94
|
+
}
|
|
95
|
+
const cwd = typeof task.cwd === "string" ? task.cwd : undefined;
|
|
96
|
+
return {
|
|
97
|
+
...base,
|
|
98
|
+
...cwd ? { cwd } : {},
|
|
99
|
+
key: `cron.add:${typeof task.name === "string" ? task.name : task.prompt.slice(0, 80)}`,
|
|
100
|
+
action: { type: "call", package: CRON, method: "add", params: [task] },
|
|
101
|
+
undo: { package: CRON, method: "remove", params: [RESULT_ID] }
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
case "cron.disable": {
|
|
105
|
+
const id = taskId(params);
|
|
106
|
+
return {
|
|
107
|
+
...base,
|
|
108
|
+
key: `cron.disable:${id}`,
|
|
109
|
+
action: { type: "call", package: CRON, method: "setEnabled", params: [id, false] },
|
|
110
|
+
undo: { package: CRON, method: "setEnabled", params: [id, true] }
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
case "cron.update": {
|
|
114
|
+
const id = taskId(params);
|
|
115
|
+
const patch = params.patch && typeof params.patch === "object" ? params.patch : undefined;
|
|
116
|
+
if (!patch || Object.keys(patch).length === 0) {
|
|
117
|
+
throw new Error("cron.update needs patch, the fields to change.");
|
|
118
|
+
}
|
|
119
|
+
if (!current) {
|
|
120
|
+
throw new Error(`No scheduled task ${id}.`);
|
|
121
|
+
}
|
|
122
|
+
const before = {};
|
|
123
|
+
for (const field of FIELDS) {
|
|
124
|
+
if (field in patch) {
|
|
125
|
+
before[field] = current[field] ?? CLEARED[field] ?? null;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
...base,
|
|
130
|
+
key: `cron.update:${current.id}`,
|
|
131
|
+
action: { type: "call", package: CRON, method: "update", params: [current.id, patch] },
|
|
132
|
+
undo: { package: CRON, method: "update", params: [current.id, before] }
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
default:
|
|
136
|
+
throw new Error(`A review proposes ${CRON_KINDS.map((one) => one.id).join(", ")}.`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
CronProposals.build = build;
|
|
140
|
+
function taskId(params) {
|
|
141
|
+
if (typeof params.id !== "string" || !params.id) {
|
|
142
|
+
throw new Error(`${params.kind} needs id, the task.`);
|
|
143
|
+
}
|
|
144
|
+
return params.id;
|
|
145
|
+
}
|
|
146
|
+
})(CronProposals ||= {});
|
|
147
|
+
|
|
148
|
+
// web-src/event-proposals.ts
|
|
149
|
+
var EVENT_KINDS = [
|
|
150
|
+
{
|
|
151
|
+
id: "chat.fix-failure",
|
|
152
|
+
owner: NAME,
|
|
153
|
+
title: { en: "Look into a turn that failed and try again", zh: "排查失败的这一轮并重试" },
|
|
154
|
+
reversible: false,
|
|
155
|
+
level: "ask"
|
|
156
|
+
}
|
|
157
|
+
];
|
|
158
|
+
var ERROR_CHARS = 200;
|
|
159
|
+
function readable(error) {
|
|
160
|
+
const json = /\{[\s\S]*\}/.exec(error)?.[0];
|
|
161
|
+
let text = error;
|
|
162
|
+
if (json) {
|
|
163
|
+
try {
|
|
164
|
+
const parsed = JSON.parse(json);
|
|
165
|
+
const message = parsed.message ?? parsed.error?.message;
|
|
166
|
+
if (typeof message === "string" && message.trim()) {
|
|
167
|
+
const status = /^(\d{3})\b/.exec(error.trim())?.[1];
|
|
168
|
+
text = status ? `${status}: ${message}` : message;
|
|
169
|
+
}
|
|
170
|
+
} catch {}
|
|
171
|
+
}
|
|
172
|
+
return text.replace(/\s+/g, " ").trim().slice(0, ERROR_CHARS);
|
|
173
|
+
}
|
|
174
|
+
var EventProposals;
|
|
175
|
+
((EventProposals) => {
|
|
176
|
+
function key(sessionFile) {
|
|
177
|
+
return `chat.fix-failure:${sessionFile}`;
|
|
178
|
+
}
|
|
179
|
+
EventProposals.key = key;
|
|
180
|
+
function failed(event, zh) {
|
|
181
|
+
if (event.type !== "turn_end" || !event.error || event.group || !event.sessionFile) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const error = readable(event.error);
|
|
185
|
+
return {
|
|
186
|
+
kind: "chat.fix-failure",
|
|
187
|
+
title: zh ? "排查失败的原因并重试" : "Find out why it failed and try again",
|
|
188
|
+
why: error,
|
|
189
|
+
cwd: event.cwd,
|
|
190
|
+
evidence: [event.sessionFile],
|
|
191
|
+
key: key(event.sessionFile),
|
|
192
|
+
source: "host",
|
|
193
|
+
urgency: "today",
|
|
194
|
+
action: {
|
|
195
|
+
type: "session",
|
|
196
|
+
sessionFile: event.sessionFile,
|
|
197
|
+
prompt: zh ? "上一轮失败了,查一下原因,能修的先修好,再把刚才要做的事做完。" : "The last turn failed. Find out why, fix what you can, and do what was asked again."
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
EventProposals.failed = failed;
|
|
202
|
+
function settled(event) {
|
|
203
|
+
return event.type === "turn_end" && !event.error && !event.aborted && event.sessionFile ? key(event.sessionFile) : undefined;
|
|
204
|
+
}
|
|
205
|
+
EventProposals.settled = settled;
|
|
206
|
+
})(EventProposals ||= {});
|
|
207
|
+
|
|
208
|
+
// web-src/proposal-book.ts
|
|
209
|
+
import { randomBytes } from "node:crypto";
|
|
210
|
+
|
|
211
|
+
// web-src/inbox-util.ts
|
|
212
|
+
var DAY_MS = 24 * 60 * 60000;
|
|
213
|
+
function waits(proposal) {
|
|
214
|
+
return proposal.state === "pending" || proposal.state === "digest";
|
|
215
|
+
}
|
|
216
|
+
var InboxUtil;
|
|
217
|
+
((InboxUtil) => {
|
|
218
|
+
function waiting(proposals) {
|
|
219
|
+
return proposals.filter(waits).sort((a, b) => a.state === b.state ? b.at - a.at : a.state === "pending" ? -1 : 1);
|
|
220
|
+
}
|
|
221
|
+
InboxUtil.waiting = waiting;
|
|
222
|
+
function done(proposals, now) {
|
|
223
|
+
return proposals.filter((proposal) => proposal.auto && ["done", "undone", "failed"].includes(proposal.state) && now - (proposal.decidedAt ?? proposal.at) <= Limits.UNDO_DAYS * DAY_MS).sort((a, b) => (b.decidedAt ?? b.at) - (a.decidedAt ?? a.at));
|
|
224
|
+
}
|
|
225
|
+
InboxUtil.done = done;
|
|
226
|
+
function canUndo(proposal, now) {
|
|
227
|
+
return proposal.state === "done" && !!proposal.undo && now - (proposal.decidedAt ?? proposal.at) <= Limits.UNDO_DAYS * DAY_MS;
|
|
228
|
+
}
|
|
229
|
+
InboxUtil.canUndo = canUndo;
|
|
230
|
+
function home(proposals, seen, now) {
|
|
231
|
+
const open = waiting(proposals);
|
|
232
|
+
const did = done(proposals, now).filter((proposal) => proposal.state === "done");
|
|
233
|
+
if (open.length === 0 && did.length === 0) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
const at = Math.max(...[...open, ...did].map((proposal) => Math.max(proposal.at, proposal.decidedAt ?? 0)));
|
|
237
|
+
return { waiting: open.length, done: did.length, at, unseen: at > seen };
|
|
238
|
+
}
|
|
239
|
+
InboxUtil.home = home;
|
|
240
|
+
})(InboxUtil ||= {});
|
|
241
|
+
|
|
242
|
+
// web-src/level-util.ts
|
|
243
|
+
var LevelUtil;
|
|
244
|
+
((LevelUtil) => {
|
|
245
|
+
function index(level2) {
|
|
246
|
+
return Math.max(0, LEVELS.indexOf(level2));
|
|
247
|
+
}
|
|
248
|
+
LevelUtil.index = index;
|
|
249
|
+
function at(index2) {
|
|
250
|
+
return LEVELS[Math.min(LEVELS.length - 1, Math.max(0, index2))];
|
|
251
|
+
}
|
|
252
|
+
function cap(kind, mode) {
|
|
253
|
+
return kind.reversible && mode !== "quiet" ? "act" : "ask";
|
|
254
|
+
}
|
|
255
|
+
LevelUtil.cap = cap;
|
|
256
|
+
function start(kind, mode) {
|
|
257
|
+
const own = index(kind.level);
|
|
258
|
+
const moved = mode === "quiet" ? Math.max(own === 0 ? 0 : 1, own - 1) : mode === "active" ? own + 1 : own;
|
|
259
|
+
return at(Math.min(moved, index(cap(kind, mode))));
|
|
260
|
+
}
|
|
261
|
+
LevelUtil.start = start;
|
|
262
|
+
function outcome(proposal) {
|
|
263
|
+
switch (proposal.state) {
|
|
264
|
+
case "done":
|
|
265
|
+
return "accepted";
|
|
266
|
+
case "declined":
|
|
267
|
+
return "declined";
|
|
268
|
+
case "undone":
|
|
269
|
+
return "undone";
|
|
270
|
+
default:
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
LevelUtil.outcome = outcome;
|
|
275
|
+
function level(kind, mode, proposals, locked) {
|
|
276
|
+
if (locked) {
|
|
277
|
+
return { level: kind.reversible ? locked : at(Math.min(index(locked), index("ask"))), reason: { cause: "locked" } };
|
|
278
|
+
}
|
|
279
|
+
const top = index(cap(kind, mode));
|
|
280
|
+
let current = index(start(kind, mode));
|
|
281
|
+
let reason = { cause: "start" };
|
|
282
|
+
let accepted = 0;
|
|
283
|
+
let declined = 0;
|
|
284
|
+
const decided = proposals.flatMap((proposal) => {
|
|
285
|
+
const result = outcome(proposal);
|
|
286
|
+
return result ? [{ result, at: proposal.decidedAt ?? proposal.at }] : [];
|
|
287
|
+
}).sort((a, b) => a.at - b.at).slice(-Limits.OUTCOMES);
|
|
288
|
+
for (const { result, at: when } of decided) {
|
|
289
|
+
if (result === "accepted") {
|
|
290
|
+
declined = 0;
|
|
291
|
+
if (++accepted >= Limits.UP_AFTER && current < top) {
|
|
292
|
+
current++;
|
|
293
|
+
accepted = 0;
|
|
294
|
+
reason = { cause: "up", at: when };
|
|
295
|
+
}
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
accepted = 0;
|
|
299
|
+
declined = result === "declined" ? declined + 1 : Limits.DOWN_AFTER;
|
|
300
|
+
if (declined >= Limits.DOWN_AFTER) {
|
|
301
|
+
declined = 0;
|
|
302
|
+
if (current > index("digest")) {
|
|
303
|
+
current--;
|
|
304
|
+
reason = { cause: "down", at: when };
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return { level: at(current), reason };
|
|
309
|
+
}
|
|
310
|
+
LevelUtil.level = level;
|
|
311
|
+
})(LevelUtil ||= {});
|
|
312
|
+
|
|
313
|
+
// web-src/notify-util.ts
|
|
314
|
+
var NotifyUtil;
|
|
315
|
+
((NotifyUtil) => {
|
|
316
|
+
NotifyUtil.QUIET = { enabled: true, start: "22:00", end: "08:00" };
|
|
317
|
+
function quiet(value) {
|
|
318
|
+
const stored = value && typeof value === "object" ? value : {};
|
|
319
|
+
return {
|
|
320
|
+
enabled: typeof stored.enabled === "boolean" ? stored.enabled : NotifyUtil.QUIET.enabled,
|
|
321
|
+
start: typeof stored.start === "string" && minutes(stored.start) !== undefined ? stored.start : NotifyUtil.QUIET.start,
|
|
322
|
+
end: typeof stored.end === "string" && minutes(stored.end) !== undefined ? stored.end : NotifyUtil.QUIET.end
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
NotifyUtil.quiet = quiet;
|
|
326
|
+
function minutes(text) {
|
|
327
|
+
const match = /^(\d{1,2}):(\d{2})$/.exec(text.trim());
|
|
328
|
+
const hours = Number(match?.[1]);
|
|
329
|
+
const mins = Number(match?.[2]);
|
|
330
|
+
return match && hours < 24 && mins < 60 ? hours * 60 + mins : undefined;
|
|
331
|
+
}
|
|
332
|
+
NotifyUtil.minutes = minutes;
|
|
333
|
+
function isQuiet(hours, now) {
|
|
334
|
+
const start = minutes(hours.start);
|
|
335
|
+
const end = minutes(hours.end);
|
|
336
|
+
if (!hours.enabled || start === undefined || end === undefined || start === end) {
|
|
337
|
+
return false;
|
|
338
|
+
}
|
|
339
|
+
const date = new Date(now);
|
|
340
|
+
const at = date.getHours() * 60 + date.getMinutes();
|
|
341
|
+
return start < end ? at >= start && at < end : at >= start || at < end;
|
|
342
|
+
}
|
|
343
|
+
NotifyUtil.isQuiet = isQuiet;
|
|
344
|
+
function toldToday(proposals, now) {
|
|
345
|
+
const day = new Date(now).toDateString();
|
|
346
|
+
return proposals.filter((proposal) => proposal.notifiedAt && new Date(proposal.notifiedAt).toDateString() === day).length;
|
|
347
|
+
}
|
|
348
|
+
NotifyUtil.toldToday = toldToday;
|
|
349
|
+
function tell(input) {
|
|
350
|
+
const { proposal } = input;
|
|
351
|
+
return proposal.state === "pending" && proposal.level === "ask" && proposal.urgency === "now" && proposal.source !== "turn" && input.pages > 0 && !isQuiet(input.quiet, input.now) && input.told < Limits.BUDGET[input.mode];
|
|
352
|
+
}
|
|
353
|
+
NotifyUtil.tell = tell;
|
|
354
|
+
})(NotifyUtil ||= {});
|
|
355
|
+
|
|
356
|
+
// web-src/proposal-book.ts
|
|
357
|
+
var DAY_MS2 = 24 * 60 * 60000;
|
|
358
|
+
|
|
359
|
+
class ProposalBook {
|
|
360
|
+
host;
|
|
361
|
+
now;
|
|
362
|
+
proposals = [];
|
|
363
|
+
defined = new Map;
|
|
364
|
+
queue = Promise.resolve();
|
|
365
|
+
telling = [];
|
|
366
|
+
constructor(host, kinds = [], now = Date.now) {
|
|
367
|
+
this.host = host;
|
|
368
|
+
this.now = now;
|
|
369
|
+
for (const kind of kinds) {
|
|
370
|
+
this.defined.set(kind.id, kind);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
async load() {
|
|
374
|
+
const stored = await this.read(Keys.PROPOSALS);
|
|
375
|
+
this.proposals = Array.isArray(stored) ? stored.filter(valid) : [];
|
|
376
|
+
}
|
|
377
|
+
defineKind(kind) {
|
|
378
|
+
return this.serial(async () => {
|
|
379
|
+
this.defined.set(checkKind(kind).id, kind);
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
kinds() {
|
|
383
|
+
return this.serial(async () => {
|
|
384
|
+
const [mode, locks] = await Promise.all([this.mode(), this.locks()]);
|
|
385
|
+
const ids = new Set([...this.defined.keys(), ...this.proposals.map((proposal) => proposal.kind)]);
|
|
386
|
+
return [...ids].map((id) => this.status(id, mode, locks));
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
level(kind) {
|
|
390
|
+
return this.serial(async () => this.status(String(kind), await this.mode(), await this.locks()).level);
|
|
391
|
+
}
|
|
392
|
+
offer(input) {
|
|
393
|
+
return this.serialThenTell(async () => {
|
|
394
|
+
const { inTurn, done, ...rest } = input ?? {};
|
|
395
|
+
const checked = checkInput(rest);
|
|
396
|
+
this.expire();
|
|
397
|
+
if (done) {
|
|
398
|
+
const { level: level2 } = this.status(checked.kind, await this.mode(), await this.locks());
|
|
399
|
+
const now = this.now();
|
|
400
|
+
const proposal2 = { ...checked, id: newId(), level: level2, state: "done", auto: true, at: now, decidedAt: now };
|
|
401
|
+
this.proposals.push(proposal2);
|
|
402
|
+
await this.save();
|
|
403
|
+
return { id: proposal2.id, delivered: "act", state: "done" };
|
|
404
|
+
}
|
|
405
|
+
const waiting = checked.key ? this.proposals.find((one) => one.key === checked.key && waits(one)) : undefined;
|
|
406
|
+
if (waiting) {
|
|
407
|
+
return { id: waiting.id, delivered: waiting.level, state: waiting.state };
|
|
408
|
+
}
|
|
409
|
+
let { level } = this.status(checked.kind, await this.mode(), await this.locks());
|
|
410
|
+
if (level === "off") {
|
|
411
|
+
return { delivered: "dropped" };
|
|
412
|
+
}
|
|
413
|
+
if (level === "act" && !checked.action) {
|
|
414
|
+
level = "ask";
|
|
415
|
+
}
|
|
416
|
+
const proposal = { ...checked, id: newId(), level, state: level === "digest" ? "digest" : "pending", at: this.now() };
|
|
417
|
+
if (await this.tellNow(proposal)) {
|
|
418
|
+
proposal.notifiedAt = proposal.at;
|
|
419
|
+
}
|
|
420
|
+
this.proposals.push(proposal);
|
|
421
|
+
if (level === "act" && inTurn && checked.action?.type === "session") {
|
|
422
|
+
proposal.state = "done";
|
|
423
|
+
proposal.auto = true;
|
|
424
|
+
proposal.decidedAt = proposal.at;
|
|
425
|
+
} else if (level === "act") {
|
|
426
|
+
await this.run(proposal, true);
|
|
427
|
+
}
|
|
428
|
+
await this.save();
|
|
429
|
+
return { id: proposal.id, delivered: level, state: proposal.state, ...proposal.error ? { error: proposal.error } : {} };
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
record(input) {
|
|
433
|
+
return this.serial(async () => {
|
|
434
|
+
const { outcome, ...rest } = input;
|
|
435
|
+
const checked = checkInput(rest);
|
|
436
|
+
const { level } = this.status(checked.kind, await this.mode(), await this.locks());
|
|
437
|
+
const now = this.now();
|
|
438
|
+
this.proposals.push({ ...checked, id: newId(), level, state: outcome === "accepted" ? "done" : "declined", at: now, decidedAt: now });
|
|
439
|
+
await this.save();
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
decide(id, decision) {
|
|
443
|
+
return this.serialThenTell(async () => {
|
|
444
|
+
this.expire();
|
|
445
|
+
const proposal = this.find(id);
|
|
446
|
+
if (!waits(proposal)) {
|
|
447
|
+
throw new Error("It was decided already.");
|
|
448
|
+
}
|
|
449
|
+
if (decision === "always" || decision === "never") {
|
|
450
|
+
await this.lock(proposal.kind, decision === "always" ? "act" : "off");
|
|
451
|
+
}
|
|
452
|
+
if (decision === "accept" || decision === "always") {
|
|
453
|
+
await this.run(proposal, false);
|
|
454
|
+
} else if (decision === "decline" || decision === "never") {
|
|
455
|
+
proposal.state = "declined";
|
|
456
|
+
proposal.decidedAt = this.now();
|
|
457
|
+
} else {
|
|
458
|
+
throw new Error("Decide with accept, decline, always or never.");
|
|
459
|
+
}
|
|
460
|
+
await this.save();
|
|
461
|
+
return { ...proposal };
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
undo(id) {
|
|
465
|
+
return this.serialThenTell(async () => {
|
|
466
|
+
const proposal = this.find(id);
|
|
467
|
+
if (proposal.state !== "done" || !proposal.undo) {
|
|
468
|
+
throw new Error("This cannot be undone.");
|
|
469
|
+
}
|
|
470
|
+
if (this.now() - (proposal.decidedAt ?? proposal.at) > Limits.UNDO_DAYS * DAY_MS2) {
|
|
471
|
+
throw new Error(`It was done more than ${Limits.UNDO_DAYS} days ago.`);
|
|
472
|
+
}
|
|
473
|
+
const undo = proposal.undo;
|
|
474
|
+
if ("type" in undo && undo.type === "session") {
|
|
475
|
+
await this.tell(undo.sessionFile, `ta-initiative-undo:${proposal.id}`, `The user undoes what you did on your own: ${proposal.title}. Undo it, and say in a line that it is undone.`, undo.prompt);
|
|
476
|
+
} else {
|
|
477
|
+
const { package: name, method, params } = undo;
|
|
478
|
+
await this.host.callPackageHost(name, method, params);
|
|
479
|
+
}
|
|
480
|
+
proposal.state = "undone";
|
|
481
|
+
proposal.decidedAt = this.now();
|
|
482
|
+
await this.save();
|
|
483
|
+
return { ...proposal };
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
setLevel(kind, level) {
|
|
487
|
+
return this.serial(async () => {
|
|
488
|
+
if (level !== null && !LEVELS.includes(level)) {
|
|
489
|
+
throw new Error(`A level is one of ${LEVELS.join(", ")}.`);
|
|
490
|
+
}
|
|
491
|
+
await this.lock(String(kind), level);
|
|
492
|
+
return this.status(String(kind), await this.mode(), await this.locks());
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
setMode(mode) {
|
|
496
|
+
return this.serial(async () => {
|
|
497
|
+
if (!MODES.includes(mode)) {
|
|
498
|
+
throw new Error(`A mode is one of ${MODES.join(", ")}.`);
|
|
499
|
+
}
|
|
500
|
+
await this.host.setExtensionData(NAME, Keys.MODE, mode);
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
list() {
|
|
504
|
+
return this.proposals.map((proposal) => ({ ...proposal }));
|
|
505
|
+
}
|
|
506
|
+
status(id, mode, locks) {
|
|
507
|
+
const kind = this.kind(id);
|
|
508
|
+
const own = this.proposals.filter((proposal) => proposal.kind === id);
|
|
509
|
+
const { level, reason } = LevelUtil.level(kind, mode, own, locks[id]);
|
|
510
|
+
return { kind, level, ...locks[id] ? { locked: locks[id] } : {}, reason, waiting: own.filter(waits).length };
|
|
511
|
+
}
|
|
512
|
+
kind(id) {
|
|
513
|
+
const defined = this.defined.get(id);
|
|
514
|
+
if (defined) {
|
|
515
|
+
return defined;
|
|
516
|
+
}
|
|
517
|
+
const title = [...this.proposals].reverse().find((proposal) => proposal.kind === id && proposal.kindTitle)?.kindTitle ?? id;
|
|
518
|
+
return { id, owner: "", title: { en: title, zh: title }, reversible: false, level: "ask" };
|
|
519
|
+
}
|
|
520
|
+
async run(proposal, auto) {
|
|
521
|
+
proposal.decidedAt = this.now();
|
|
522
|
+
proposal.auto = auto || undefined;
|
|
523
|
+
try {
|
|
524
|
+
const action = proposal.action;
|
|
525
|
+
if (action?.type === "call") {
|
|
526
|
+
const result = await this.host.callPackageHost(action.package, action.method, action.params);
|
|
527
|
+
if (proposal.undo) {
|
|
528
|
+
proposal.undo = resolveUndo(proposal.undo, result);
|
|
529
|
+
}
|
|
530
|
+
} else if (action?.type === "prompt") {
|
|
531
|
+
proposal.sessionFile = await this.prompt(proposal, action.prompt, action.cwd ?? proposal.cwd);
|
|
532
|
+
} else if (action?.type === "session") {
|
|
533
|
+
const why = auto ? "You may do this on your own now" : "The user accepted what you proposed";
|
|
534
|
+
this.later(proposal, action.sessionFile, `ta-initiative:${proposal.id}`, `${why}: ${proposal.title}. Do it now.`, action.prompt);
|
|
535
|
+
}
|
|
536
|
+
proposal.state = "done";
|
|
537
|
+
} catch (error) {
|
|
538
|
+
proposal.state = "failed";
|
|
539
|
+
proposal.error = error instanceof Error ? error.message : String(error);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
async prompt(proposal, prompt, cwd) {
|
|
543
|
+
const session = await this.host.openSession({ cwd: cwd ?? (await this.host.getServerInfo()).cwd });
|
|
544
|
+
await this.host.setSessionName(session.sessionId, proposal.title).catch(() => {
|
|
545
|
+
return;
|
|
546
|
+
});
|
|
547
|
+
await this.host.prompt(session.sessionId, { clientMessageId: `ta-initiative:${proposal.id}`, message: prompt });
|
|
548
|
+
return session.sessionFile ?? (await this.host.listSessions()).find((info) => info.sessionId === session.sessionId)?.sessionFile;
|
|
549
|
+
}
|
|
550
|
+
later(proposal, sessionFile, clientMessageId, context, prompt) {
|
|
551
|
+
this.telling.push(() => this.tell(sessionFile, clientMessageId, context, prompt).catch((error) => this.serial(async () => {
|
|
552
|
+
const failed = this.proposals.find((one) => one.id === proposal.id);
|
|
553
|
+
if (failed) {
|
|
554
|
+
failed.state = "failed";
|
|
555
|
+
failed.error = error instanceof Error ? error.message : String(error);
|
|
556
|
+
await this.save();
|
|
557
|
+
}
|
|
558
|
+
})));
|
|
559
|
+
}
|
|
560
|
+
async serialThenTell(work) {
|
|
561
|
+
const result = await this.serial(work);
|
|
562
|
+
for (const tell of this.telling.splice(0)) {
|
|
563
|
+
await tell();
|
|
564
|
+
}
|
|
565
|
+
return result;
|
|
566
|
+
}
|
|
567
|
+
async tell(sessionFile, clientMessageId, context, prompt) {
|
|
568
|
+
let session = (await this.host.listSessions()).find((info) => info.sessionFile === sessionFile);
|
|
569
|
+
if (!session) {
|
|
570
|
+
const cwd = await this.host.sessionCwd(sessionFile) ?? (await this.host.getServerInfo()).cwd;
|
|
571
|
+
session = await this.host.openSession({ cwd, sessionFile });
|
|
572
|
+
}
|
|
573
|
+
await this.host.prompt(session.sessionId, { clientMessageId, message: `<context>
|
|
574
|
+
${context}
|
|
575
|
+
</context>
|
|
576
|
+
${prompt}`, streamingBehavior: "followUp" });
|
|
577
|
+
}
|
|
578
|
+
async tellNow(proposal) {
|
|
579
|
+
const now = this.now();
|
|
580
|
+
return NotifyUtil.tell({
|
|
581
|
+
proposal,
|
|
582
|
+
pages: this.host.presence?.().pages ?? 0,
|
|
583
|
+
quiet: NotifyUtil.quiet(await this.read(Keys.QUIET)),
|
|
584
|
+
mode: await this.mode(),
|
|
585
|
+
told: NotifyUtil.toldToday(this.proposals, now),
|
|
586
|
+
now
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
expireKey(key) {
|
|
590
|
+
return this.serial(async () => {
|
|
591
|
+
const waiting = this.proposals.filter((proposal) => proposal.key === key && waits(proposal));
|
|
592
|
+
for (const proposal of waiting) {
|
|
593
|
+
proposal.state = "expired";
|
|
594
|
+
}
|
|
595
|
+
if (waiting.length > 0) {
|
|
596
|
+
await this.save();
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
expire() {
|
|
601
|
+
const now = this.now();
|
|
602
|
+
for (const proposal of this.proposals) {
|
|
603
|
+
if (waits(proposal) && now > (proposal.expiresAt ?? proposal.at + Limits.EXPIRE_DAYS * DAY_MS2)) {
|
|
604
|
+
proposal.state = "expired";
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
find(id) {
|
|
609
|
+
const proposal = this.proposals.find((one) => one.id === id);
|
|
610
|
+
if (!proposal) {
|
|
611
|
+
throw new Error(`No proposal ${id}.`);
|
|
612
|
+
}
|
|
613
|
+
return proposal;
|
|
614
|
+
}
|
|
615
|
+
async lock(kind, level) {
|
|
616
|
+
const locks = { ...await this.locks() };
|
|
617
|
+
if (level === null) {
|
|
618
|
+
delete locks[kind];
|
|
619
|
+
} else {
|
|
620
|
+
locks[kind] = level;
|
|
621
|
+
}
|
|
622
|
+
await this.host.setExtensionData(NAME, Keys.LOCKS, locks);
|
|
623
|
+
}
|
|
624
|
+
async mode() {
|
|
625
|
+
const mode = await this.read(Keys.MODE);
|
|
626
|
+
return MODES.includes(mode) ? mode : "balanced";
|
|
627
|
+
}
|
|
628
|
+
async locks() {
|
|
629
|
+
const stored = await this.read(Keys.LOCKS);
|
|
630
|
+
const locks = {};
|
|
631
|
+
if (stored && typeof stored === "object") {
|
|
632
|
+
for (const [kind, level] of Object.entries(stored)) {
|
|
633
|
+
if (LEVELS.includes(level)) {
|
|
634
|
+
locks[kind] = level;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
return locks;
|
|
639
|
+
}
|
|
640
|
+
async save() {
|
|
641
|
+
this.proposals = this.proposals.slice(-Limits.PROPOSALS_KEPT);
|
|
642
|
+
await this.host.setExtensionData(NAME, Keys.PROPOSALS, this.proposals);
|
|
643
|
+
}
|
|
644
|
+
read(key) {
|
|
645
|
+
return this.host.getExtensionData(NAME, key).catch(() => {
|
|
646
|
+
return;
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
serial(work) {
|
|
650
|
+
const next = this.queue.then(work, work);
|
|
651
|
+
this.queue = next.catch(() => {
|
|
652
|
+
return;
|
|
653
|
+
});
|
|
654
|
+
return next;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
function resolveUndo(undo, result) {
|
|
658
|
+
if ("type" in undo && undo.type === "session") {
|
|
659
|
+
return undo;
|
|
660
|
+
}
|
|
661
|
+
const call = undo;
|
|
662
|
+
const id = result && typeof result === "object" ? result.id : undefined;
|
|
663
|
+
return { ...call, params: call.params.map((param) => param === RESULT_ID ? id : param) };
|
|
664
|
+
}
|
|
665
|
+
function newId() {
|
|
666
|
+
return `prop_${randomBytes(4).toString("hex")}`;
|
|
667
|
+
}
|
|
668
|
+
function valid(value) {
|
|
669
|
+
const proposal = value;
|
|
670
|
+
return !!proposal && typeof proposal.id === "string" && typeof proposal.kind === "string" && typeof proposal.state === "string";
|
|
671
|
+
}
|
|
672
|
+
function checkKind(kind) {
|
|
673
|
+
if (!kind || typeof kind.id !== "string" || !/^[\w-]+\.[\w.-]+$/.test(kind.id)) {
|
|
674
|
+
throw new Error("A kind needs an id as <area>.<verb>, such as cron.add.");
|
|
675
|
+
}
|
|
676
|
+
if (!LEVELS.includes(kind.level) || typeof kind.reversible !== "boolean" || typeof kind.title?.en !== "string") {
|
|
677
|
+
throw new Error("A kind needs a title { en, zh }, reversible and a level.");
|
|
678
|
+
}
|
|
679
|
+
return kind;
|
|
680
|
+
}
|
|
681
|
+
function checkInput(input) {
|
|
682
|
+
if (!input || typeof input.kind !== "string" || !input.kind || typeof input.title !== "string" || !input.title.trim() || typeof input.why !== "string") {
|
|
683
|
+
throw new Error("A proposal needs a kind, a title and why.");
|
|
684
|
+
}
|
|
685
|
+
if (input.action && !validAction(input.action)) {
|
|
686
|
+
throw new Error('An action is { type: "call", package, method, params }, { type: "prompt", prompt, cwd? } or { type: "session", sessionFile, prompt }.');
|
|
687
|
+
}
|
|
688
|
+
if (input.undo && !validUndo(input.undo)) {
|
|
689
|
+
throw new Error('An undo is { package, method, params } or { type: "session", sessionFile, prompt }.');
|
|
690
|
+
}
|
|
691
|
+
return {
|
|
692
|
+
...input,
|
|
693
|
+
title: input.title.trim().slice(0, 200),
|
|
694
|
+
why: input.why.trim().slice(0, 400),
|
|
695
|
+
...typeof input.kindTitle === "string" ? { kindTitle: input.kindTitle.trim().slice(0, 80) } : {}
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
function validAction(action) {
|
|
699
|
+
switch (action.type) {
|
|
700
|
+
case "call":
|
|
701
|
+
return typeof action.package === "string" && typeof action.method === "string" && Array.isArray(action.params);
|
|
702
|
+
case "prompt":
|
|
703
|
+
return typeof action.prompt === "string";
|
|
704
|
+
case "session":
|
|
705
|
+
return typeof action.sessionFile === "string" && typeof action.prompt === "string";
|
|
706
|
+
default:
|
|
707
|
+
return false;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
function validUndo(undo) {
|
|
711
|
+
return "type" in undo && undo.type === "session" ? typeof undo.sessionFile === "string" && typeof undo.prompt === "string" : typeof undo.package === "string" && typeof undo.method === "string" && Array.isArray(undo.params);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
// web-src/review-service.ts
|
|
715
|
+
import { existsSync } from "node:fs";
|
|
716
|
+
|
|
717
|
+
// web-src/material-util.ts
|
|
718
|
+
var LEVEL_MEANS = {
|
|
719
|
+
act: "done at once, the user told and able to undo it",
|
|
720
|
+
ask: "asked of the user with a card",
|
|
721
|
+
digest: "only a line of the daily brief",
|
|
722
|
+
off: "dropped: the user wants none of these"
|
|
723
|
+
};
|
|
724
|
+
var MaterialUtil;
|
|
725
|
+
((MaterialUtil) => {
|
|
726
|
+
function message(since2, zh) {
|
|
727
|
+
const context = [
|
|
728
|
+
`${REVIEW_MARK} since=${since2}]`,
|
|
729
|
+
`Review the scheduled tasks of the user now, from the <${SECTION}> section of your system prompt. Nobody is watching: ask nothing, decide and report; the user reads it later and may answer here. Write the report in ${zh ? "Chinese" : "English"}.`
|
|
730
|
+
].join(`
|
|
731
|
+
`);
|
|
732
|
+
return `<context>
|
|
733
|
+
${context}
|
|
734
|
+
</context>
|
|
735
|
+
${zh ? "回顾一下最近的工作,整理定时任务" : "Look back at the recent work and tidy the scheduled tasks"}`;
|
|
736
|
+
}
|
|
737
|
+
MaterialUtil.message = message;
|
|
738
|
+
function since(prompt) {
|
|
739
|
+
const at = prompt.indexOf(REVIEW_MARK);
|
|
740
|
+
if (at < 0) {
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
const match = /^ since=(\d+)\]/.exec(prompt.slice(at + REVIEW_MARK.length));
|
|
744
|
+
return match ? Number(match[1]) : undefined;
|
|
745
|
+
}
|
|
746
|
+
MaterialUtil.since = since;
|
|
747
|
+
function section(input) {
|
|
748
|
+
const lines = [
|
|
749
|
+
`<${SECTION}>`,
|
|
750
|
+
`You keep the scheduled tasks of the user (those of ta-cron) in step with their work, so that what they ask for again and again gets done without them asking, and what no longer matters stops. You change them only with ${PROPOSE_TOOL}, never with schedule_task: each kind goes as far as the user lets it, which grows as they accept what you propose.`,
|
|
751
|
+
"",
|
|
752
|
+
"How to review:",
|
|
753
|
+
`1. Find the work asked again and again in the requests below: the same kind of request on two days or more, or in two conversations or more, or the user saying "every day", "each week", "again". Group the requests by the work they ask for, not by their words.`,
|
|
754
|
+
"2. Schedule it when it repeats, can be done with nobody watching, has a way to check it (tests, a build, a benchmark, a log, a report) and fits the timeout of a run (30 minutes unless the task sets more, up to 4h). Do not schedule work that needs the user: their taste, a phone or a device in hand, a release they start, a one-off.",
|
|
755
|
+
`3. Propose it (${PROPOSE_TOOL}, kind cron.add), at most ${Limits.NEW_TASKS} in a review, the surest first, with \`why\` naming how often it was asked and \`evidence\` the session files of those conversations. The task: a short name; a prompt complete in itself (the run sees no conversation) that says what to do, from where (since its last run, the past week), how to check it, what it may change on its own and what it only lists for the user, and the report it ends with, written the way the user asks for such work; the directory (cwd) of the conversations it comes from; a schedule at a minute that is not 0 and not the time of another task; notify "error".`,
|
|
756
|
+
`4. Look at every task below: one that keeps failing or timing out, repeats another, is about something gone (a feature removed, a date passed, a module renamed), or was asked for once and is done, is stale: propose turning it off (kind cron.disable, its id) and say why; never delete one. A prompt or a schedule that went out of date (a fixed date, a file that moved, a run that needs more time) may be changed (kind cron.update, its id and the fields to change). A task that runs fine and still matches the work stays as it is.`,
|
|
757
|
+
"5. Earlier reviews and the answers of the user are above in this conversation: do not propose again what the user turned off, deleted, declined or undid, keep doing what they approved, and learn from what they said.",
|
|
758
|
+
...input.levels?.length ? [` What a proposal of each kind does now: ${input.levels.map(({ kind, level }) => `${kind} ${LEVEL_MEANS[level]}`).join("; ")}.`] : [],
|
|
759
|
+
...input.learn ? [
|
|
760
|
+
`5b. Learn the user, so that every conversation of Ta knows them: rewrite with ${PROFILE_TOOL} the whole of what you know of them (below), from the requests: who they are and what they work on; how they want things done (what they corrected, what they said "always", "never", "next time" about, what they approved that was not obvious); what they usually want next after a kind of work (test, commit, push, a screenshot, a report), so that Ta does it without being asked; and what Ta should do on its own and what it must ask first. Markdown, short lines under a few headings, at most ${Limits.PROFILE_CHARS} characters, in the language of the user; keep what still holds, drop what turned out wrong, never a secret (keys, tokens, passwords) or a private matter. Leave it as it is when you learned nothing new.`
|
|
761
|
+
] : [],
|
|
762
|
+
input.auto ? `6. Reviews come every ${input.every} days, and the user lets you choose: call ${PACE_TOOL} once with the days to the next review (1 to 30) and why: sooner while the work changes and you found much to do, later when nothing changed.` : `6. Reviews come every ${input.every} days, as the user set; do not change it.`,
|
|
763
|
+
`7. End with a short report: what was done on its own, what waits for the user in their suggestions (on the double's home), what went to the brief, each with why in a few words, as ${PROPOSE_TOOL} answered;${input.learn ? " what you newly learned of the user, in a line or two;" : ""} nothing more. On a card, the tasks go in a table or steps, not in changes (which are files). When nothing needed doing, say so in one line.`,
|
|
764
|
+
"Use the tools only for what you change and what you must check (a file, git log); the material is below.",
|
|
765
|
+
"",
|
|
766
|
+
`Requests of the user since ${day(input.since)} (by conversation, latest first):`
|
|
767
|
+
];
|
|
768
|
+
let size = lines.join(`
|
|
769
|
+
`).length;
|
|
770
|
+
if (!input.requests) {
|
|
771
|
+
lines.push(`- Not available: the package Recall is off. Read the user messages of the session files under ${input.agentDir ? `${input.agentDir}/sessions` : "the sessions directory of the agent"} with a script, not one by one.`);
|
|
772
|
+
} else if (input.requests.length === 0) {
|
|
773
|
+
lines.push("- None.");
|
|
774
|
+
}
|
|
775
|
+
const tasks = taskLines(input.tasks, input.now);
|
|
776
|
+
size += tasks.join(`
|
|
777
|
+
`).length;
|
|
778
|
+
let left = 0;
|
|
779
|
+
for (const conversation of input.requests ?? []) {
|
|
780
|
+
const block = [
|
|
781
|
+
`- [${conversation.title || "Untitled"}](${conversation.file}) · ${conversation.cwd}${conversation.group ? ` · of ${conversation.group}` : ""}`,
|
|
782
|
+
...conversation.asks.map((ask) => ` - ${day(ask.at)} ${clock(ask.at)}: ${ask.text}`)
|
|
783
|
+
];
|
|
784
|
+
const length = block.join(`
|
|
785
|
+
`).length + 1;
|
|
786
|
+
if (size + length > Limits.MATERIAL_CHARS) {
|
|
787
|
+
left++;
|
|
788
|
+
continue;
|
|
789
|
+
}
|
|
790
|
+
size += length;
|
|
791
|
+
lines.push(...block);
|
|
792
|
+
}
|
|
793
|
+
if (left > 0) {
|
|
794
|
+
lines.push(`- And ${left} more conversations, left out for length: search_conversations finds them.`);
|
|
795
|
+
}
|
|
796
|
+
lines.push("", ...tasks);
|
|
797
|
+
if (input.learn) {
|
|
798
|
+
lines.push("", input.profile ? `What you know of the user so far:
|
|
799
|
+
${input.profile}` : "What you know of the user so far: nothing yet.");
|
|
800
|
+
}
|
|
801
|
+
lines.push(`</${SECTION}>`);
|
|
802
|
+
return lines.join(`
|
|
803
|
+
`);
|
|
804
|
+
}
|
|
805
|
+
MaterialUtil.section = section;
|
|
806
|
+
function profileSection(profile) {
|
|
807
|
+
return [
|
|
808
|
+
`<${PROFILE_SECTION}>`,
|
|
809
|
+
"What Ta learned of the user over time from working with them (they see and edit it in Settings → Initiative). Work the way it says without being told again, and do on your own what it says they usually want next; what they say now comes first.",
|
|
810
|
+
"",
|
|
811
|
+
profile.trim(),
|
|
812
|
+
`</${PROFILE_SECTION}>`
|
|
813
|
+
].join(`
|
|
814
|
+
`);
|
|
815
|
+
}
|
|
816
|
+
MaterialUtil.profileSection = profileSection;
|
|
817
|
+
function taskLines(tasks, now) {
|
|
818
|
+
if (!tasks) {
|
|
819
|
+
return ["Scheduled tasks: not available, the package Scheduled tasks is off; add nothing, and say so."];
|
|
820
|
+
}
|
|
821
|
+
if (tasks.length === 0) {
|
|
822
|
+
return ["Scheduled tasks: none yet."];
|
|
823
|
+
}
|
|
824
|
+
const lines = [`Scheduled tasks (${tasks.length}), at ${day(now)} ${clock(now)}:`];
|
|
825
|
+
for (const { task, runs } of tasks) {
|
|
826
|
+
const stats = `runs ${task.runCount}, failed ${task.failCount}${task.timeout ? `, timeout ${task.timeout}` : ""}`;
|
|
827
|
+
lines.push(`- ${task.enabled ? "on" : "off"} · ${task.name} · id ${task.id} · ${schedule(task.schedule)} · ${task.cwd} · ${stats} · created ${day(Date.parse(task.createdAt))}`, ` prompt: ${flat(task.prompt, Limits.PROMPT_CHARS)}`);
|
|
828
|
+
if (runs.length > 0) {
|
|
829
|
+
lines.push(` last runs: ${runs.map((run) => runLine(run)).join("; ")}`);
|
|
830
|
+
const last = runs[0];
|
|
831
|
+
const said = last.summary ?? last.error;
|
|
832
|
+
if (said) {
|
|
833
|
+
lines.push(` last said: ${flat(said, Limits.SUMMARY_CHARS)}`);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
return lines;
|
|
838
|
+
}
|
|
839
|
+
function runLine(run) {
|
|
840
|
+
const took = run.endedAt ? Math.round((Date.parse(run.endedAt) - Date.parse(run.startedAt)) / 60000) : undefined;
|
|
841
|
+
return `${day(Date.parse(run.startedAt))} ${run.status}${run.reason ? ` (${run.reason})` : ""}${took !== undefined && Number.isFinite(took) ? ` ${took}m` : ""}`;
|
|
842
|
+
}
|
|
843
|
+
function schedule(value) {
|
|
844
|
+
return value.expression ?? (value.every ? `every ${value.every}` : value.at ? `once at ${value.at}` : value.kind);
|
|
845
|
+
}
|
|
846
|
+
function flat(text, chars) {
|
|
847
|
+
const line = text.replace(/\s+/g, " ").trim();
|
|
848
|
+
return line.length > chars ? `${line.slice(0, chars - 1)}…` : line;
|
|
849
|
+
}
|
|
850
|
+
function day(at) {
|
|
851
|
+
const date = new Date(at);
|
|
852
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
|
853
|
+
}
|
|
854
|
+
function clock(at) {
|
|
855
|
+
const date = new Date(at);
|
|
856
|
+
return `${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
|
857
|
+
}
|
|
858
|
+
function pad(value) {
|
|
859
|
+
return String(value).padStart(2, "0");
|
|
860
|
+
}
|
|
861
|
+
})(MaterialUtil ||= {});
|
|
862
|
+
|
|
863
|
+
// web-src/pace-util.ts
|
|
864
|
+
var DAY_MS3 = 24 * 60 * 60000;
|
|
865
|
+
var PaceUtil;
|
|
866
|
+
((PaceUtil) => {
|
|
867
|
+
PaceUtil.DEFAULT = { enabled: true, every: 7, time: "20:00", auto: false, learn: true };
|
|
868
|
+
PaceUtil.CHOICES = [1, 7, 14, 30];
|
|
869
|
+
function settings(value) {
|
|
870
|
+
const stored = value && typeof value === "object" ? value : {};
|
|
871
|
+
return {
|
|
872
|
+
enabled: typeof stored.enabled === "boolean" ? stored.enabled : PaceUtil.DEFAULT.enabled,
|
|
873
|
+
every: typeof stored.every === "number" && Number.isFinite(stored.every) ? days(stored.every) : PaceUtil.DEFAULT.every,
|
|
874
|
+
time: typeof stored.time === "string" && parseTime(stored.time) ? stored.time : PaceUtil.DEFAULT.time,
|
|
875
|
+
auto: typeof stored.auto === "boolean" ? stored.auto : PaceUtil.DEFAULT.auto,
|
|
876
|
+
learn: typeof stored.learn === "boolean" ? stored.learn : PaceUtil.DEFAULT.learn
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
PaceUtil.settings = settings;
|
|
880
|
+
function days(value) {
|
|
881
|
+
return Math.min(Limits.MAX_DAYS, Math.max(Limits.MIN_DAYS, Math.round(value)));
|
|
882
|
+
}
|
|
883
|
+
PaceUtil.days = days;
|
|
884
|
+
function parseTime(text) {
|
|
885
|
+
const match = /^(\d{1,2}):(\d{2})$/.exec(text.trim());
|
|
886
|
+
if (!match) {
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
889
|
+
const hours = Number(match[1]);
|
|
890
|
+
const minutes = Number(match[2]);
|
|
891
|
+
return hours < 24 && minutes < 60 ? { hours, minutes } : undefined;
|
|
892
|
+
}
|
|
893
|
+
PaceUtil.parseTime = parseTime;
|
|
894
|
+
function next(settings2, last) {
|
|
895
|
+
const { hours, minutes } = parseTime(settings2.time) ?? { hours: 20, minutes: 0 };
|
|
896
|
+
const day = new Date(last + settings2.every * DAY_MS3);
|
|
897
|
+
day.setHours(hours, minutes, 0, 0);
|
|
898
|
+
return day.getTime();
|
|
899
|
+
}
|
|
900
|
+
PaceUtil.next = next;
|
|
901
|
+
function due(settings2, last, now) {
|
|
902
|
+
return settings2.enabled && last !== undefined && now >= next(settings2, last);
|
|
903
|
+
}
|
|
904
|
+
PaceUtil.due = due;
|
|
905
|
+
function since(last, now) {
|
|
906
|
+
const earliest = now - Limits.MAX_DAYS * DAY_MS3;
|
|
907
|
+
const latest = now - Limits.LOOK_BACK_DAYS * DAY_MS3;
|
|
908
|
+
return Math.max(earliest, Math.min(latest, last ?? latest));
|
|
909
|
+
}
|
|
910
|
+
PaceUtil.since = since;
|
|
911
|
+
})(PaceUtil ||= {});
|
|
912
|
+
|
|
913
|
+
// web-src/server-texts.ts
|
|
914
|
+
var InitiativeServerTexts;
|
|
915
|
+
((InitiativeServerTexts) => {
|
|
916
|
+
function zh(env = process.env) {
|
|
917
|
+
return /^zh/i.test(env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG || "");
|
|
918
|
+
}
|
|
919
|
+
InitiativeServerTexts.zh = zh;
|
|
920
|
+
function title() {
|
|
921
|
+
return zh() ? "自我进化" : "Evolve";
|
|
922
|
+
}
|
|
923
|
+
InitiativeServerTexts.title = title;
|
|
924
|
+
})(InitiativeServerTexts ||= {});
|
|
925
|
+
|
|
926
|
+
// web-src/review-service.ts
|
|
927
|
+
var CHECK_MS = 60000;
|
|
928
|
+
var FIRST_CHECK_MS = 30000;
|
|
929
|
+
|
|
930
|
+
class ReviewHost {
|
|
931
|
+
host;
|
|
932
|
+
now;
|
|
933
|
+
timers = [];
|
|
934
|
+
reviewing;
|
|
935
|
+
queue = Promise.resolve();
|
|
936
|
+
constructor(host, now = Date.now) {
|
|
937
|
+
this.host = host;
|
|
938
|
+
this.now = now;
|
|
939
|
+
}
|
|
940
|
+
start() {
|
|
941
|
+
const first = setTimeout(() => void this.check(), FIRST_CHECK_MS);
|
|
942
|
+
const every = setInterval(() => void this.check(), CHECK_MS);
|
|
943
|
+
first.unref?.();
|
|
944
|
+
every.unref?.();
|
|
945
|
+
this.timers.push(first, every);
|
|
946
|
+
}
|
|
947
|
+
dispose() {
|
|
948
|
+
for (const timer of this.timers) {
|
|
949
|
+
clearTimeout(timer);
|
|
950
|
+
clearInterval(timer);
|
|
951
|
+
}
|
|
952
|
+
this.timers = [];
|
|
953
|
+
}
|
|
954
|
+
async reviewStatus() {
|
|
955
|
+
const [stored, last, file, note, profile] = await Promise.all([Keys.SETTINGS, Keys.LAST, Keys.FILE, Keys.NOTE, Keys.PROFILE].map((key) => this.read(key)));
|
|
956
|
+
const settings = PaceUtil.settings(stored);
|
|
957
|
+
const at = typeof last === "number" ? last : undefined;
|
|
958
|
+
return {
|
|
959
|
+
settings,
|
|
960
|
+
...at !== undefined ? { last: at } : {},
|
|
961
|
+
...settings.enabled && at !== undefined ? { next: PaceUtil.next(settings, at) } : {},
|
|
962
|
+
...typeof file === "string" && file ? { file } : {},
|
|
963
|
+
...typeof note === "string" && note ? { note } : {},
|
|
964
|
+
...typeof profile === "string" && profile.trim() ? { profile } : {}
|
|
965
|
+
};
|
|
966
|
+
}
|
|
967
|
+
reviewNow() {
|
|
968
|
+
return this.review();
|
|
969
|
+
}
|
|
970
|
+
setPace(days, reason) {
|
|
971
|
+
return this.serial(async () => {
|
|
972
|
+
const settings = PaceUtil.settings(await this.read(Keys.SETTINGS));
|
|
973
|
+
if (!settings.auto) {
|
|
974
|
+
throw new Error("The user set how often reviews come; leave it as it is.");
|
|
975
|
+
}
|
|
976
|
+
if (typeof days !== "number" || !Number.isFinite(days)) {
|
|
977
|
+
throw new Error("Say the days to the next review, 1 to 30.");
|
|
978
|
+
}
|
|
979
|
+
const every = PaceUtil.days(days);
|
|
980
|
+
await this.host.setExtensionData(NAME, Keys.SETTINGS, { ...settings, every });
|
|
981
|
+
await this.host.setExtensionData(NAME, Keys.NOTE, typeof reason === "string" ? reason.trim().slice(0, 300) : "");
|
|
982
|
+
return every;
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
setProfile(profile) {
|
|
986
|
+
return this.serial(async () => {
|
|
987
|
+
if (typeof profile !== "string") {
|
|
988
|
+
throw new Error("Write the whole profile as Markdown.");
|
|
989
|
+
}
|
|
990
|
+
const text = profile.trim();
|
|
991
|
+
const kept = text.length > Limits.PROFILE_CHARS ? text.slice(0, Limits.PROFILE_CHARS) : text;
|
|
992
|
+
await this.host.setExtensionData(NAME, Keys.PROFILE, kept);
|
|
993
|
+
return kept;
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
async check() {
|
|
997
|
+
try {
|
|
998
|
+
const [settings, last] = await Promise.all([this.read(Keys.SETTINGS), this.read(Keys.LAST)]);
|
|
999
|
+
if (typeof last !== "number") {
|
|
1000
|
+
await this.host.setExtensionData(NAME, Keys.LAST, this.now());
|
|
1001
|
+
return;
|
|
1002
|
+
}
|
|
1003
|
+
if (PaceUtil.due(PaceUtil.settings(settings), last, this.now())) {
|
|
1004
|
+
await this.review();
|
|
1005
|
+
}
|
|
1006
|
+
} catch (error) {
|
|
1007
|
+
console.error("ta-evolve could not start the review:", error);
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
review() {
|
|
1011
|
+
this.reviewing ??= this.startReview().finally(() => {
|
|
1012
|
+
this.reviewing = undefined;
|
|
1013
|
+
});
|
|
1014
|
+
return this.reviewing;
|
|
1015
|
+
}
|
|
1016
|
+
async startReview() {
|
|
1017
|
+
const now = this.now();
|
|
1018
|
+
const [last, stored] = await Promise.all([this.read(Keys.LAST), this.read(Keys.FILE)]);
|
|
1019
|
+
const file = typeof stored === "string" && stored ? stored : undefined;
|
|
1020
|
+
const session = await this.session(await this.host.listSessions(), file);
|
|
1021
|
+
await this.host.setExtensionData(NAME, Keys.LAST, now);
|
|
1022
|
+
await this.host.prompt(session.sessionId, {
|
|
1023
|
+
message: MaterialUtil.message(PaceUtil.since(typeof last === "number" ? last : undefined, now), InitiativeServerTexts.zh()),
|
|
1024
|
+
clientMessageId: `ta-evolve-review:${now}`,
|
|
1025
|
+
streamingBehavior: "followUp"
|
|
1026
|
+
});
|
|
1027
|
+
const opened = session.sessionFile ?? (await this.host.listSessions()).find((info) => info.sessionId === session.sessionId)?.sessionFile;
|
|
1028
|
+
if (opened && opened !== file) {
|
|
1029
|
+
await this.host.setExtensionData(NAME, Keys.FILE, opened);
|
|
1030
|
+
}
|
|
1031
|
+
return opened;
|
|
1032
|
+
}
|
|
1033
|
+
async session(sessions, file) {
|
|
1034
|
+
const open = file ? sessions.find((info) => info.sessionFile === file) : undefined;
|
|
1035
|
+
if (open) {
|
|
1036
|
+
return open;
|
|
1037
|
+
}
|
|
1038
|
+
const { cwd } = await this.host.getServerInfo();
|
|
1039
|
+
if (file && existsSync(file)) {
|
|
1040
|
+
return this.host.openSession({ cwd: await this.host.sessionCwd(file) ?? cwd, sessionFile: file });
|
|
1041
|
+
}
|
|
1042
|
+
const created = await this.host.openSession({ cwd });
|
|
1043
|
+
await this.host.setSessionName(created.sessionId, InitiativeServerTexts.title()).catch(() => {
|
|
1044
|
+
return;
|
|
1045
|
+
});
|
|
1046
|
+
if (created.sessionFile) {
|
|
1047
|
+
await this.host.setExtensionData(NAME, Keys.FILE, created.sessionFile);
|
|
1048
|
+
}
|
|
1049
|
+
return created;
|
|
1050
|
+
}
|
|
1051
|
+
read(key) {
|
|
1052
|
+
return this.host.getExtensionData(NAME, key).catch(() => {
|
|
1053
|
+
return;
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
serial(work) {
|
|
1057
|
+
const next = this.queue.then(work, work);
|
|
1058
|
+
this.queue = next.catch(() => {
|
|
1059
|
+
return;
|
|
1060
|
+
});
|
|
1061
|
+
return next;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
// web-src/initiative-service.ts
|
|
1066
|
+
var FORMER_KEYS = [Keys.SETTINGS, Keys.FILE, Keys.LAST, Keys.NOTE, Keys.PROFILE];
|
|
1067
|
+
|
|
1068
|
+
class InitiativeHost {
|
|
1069
|
+
host;
|
|
1070
|
+
book;
|
|
1071
|
+
review;
|
|
1072
|
+
stopEvents;
|
|
1073
|
+
constructor(host, now = Date.now) {
|
|
1074
|
+
this.host = host;
|
|
1075
|
+
this.book = new ProposalBook(host, [...CRON_KINDS, ...CHAT_KINDS, ...EVENT_KINDS], now);
|
|
1076
|
+
this.review = new ReviewHost(host, now);
|
|
1077
|
+
}
|
|
1078
|
+
async start() {
|
|
1079
|
+
await this.migrate().catch((error) => console.error("ta-initiative could not take over the data of Evolve:", error));
|
|
1080
|
+
await this.book.load();
|
|
1081
|
+
this.review.start();
|
|
1082
|
+
this.stopEvents = this.host.onSessionEvent?.((event) => void this.onTurn(event).catch((error) => console.error("ta-initiative:", error)));
|
|
1083
|
+
}
|
|
1084
|
+
dispose() {
|
|
1085
|
+
this.stopEvents?.();
|
|
1086
|
+
this.review.dispose();
|
|
1087
|
+
}
|
|
1088
|
+
async onTurn(event) {
|
|
1089
|
+
const failed = EventProposals.failed(event, InitiativeServerTexts.zh());
|
|
1090
|
+
if (failed) {
|
|
1091
|
+
await this.book.offer(failed);
|
|
1092
|
+
return;
|
|
1093
|
+
}
|
|
1094
|
+
const settled = EventProposals.settled(event);
|
|
1095
|
+
if (settled) {
|
|
1096
|
+
await this.book.expireKey(settled);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
defineKind(kind) {
|
|
1100
|
+
return this.book.defineKind(kind);
|
|
1101
|
+
}
|
|
1102
|
+
kinds() {
|
|
1103
|
+
return this.book.kinds();
|
|
1104
|
+
}
|
|
1105
|
+
level(kind) {
|
|
1106
|
+
return this.book.level(kind);
|
|
1107
|
+
}
|
|
1108
|
+
offer(input) {
|
|
1109
|
+
return this.book.offer(input);
|
|
1110
|
+
}
|
|
1111
|
+
record(input) {
|
|
1112
|
+
return this.book.record(input);
|
|
1113
|
+
}
|
|
1114
|
+
decide(id, decision) {
|
|
1115
|
+
return this.book.decide(id, decision);
|
|
1116
|
+
}
|
|
1117
|
+
undo(id) {
|
|
1118
|
+
return this.book.undo(id);
|
|
1119
|
+
}
|
|
1120
|
+
setLevel(kind, level) {
|
|
1121
|
+
return this.book.setLevel(kind, level);
|
|
1122
|
+
}
|
|
1123
|
+
setMode(mode) {
|
|
1124
|
+
return this.book.setMode(mode);
|
|
1125
|
+
}
|
|
1126
|
+
reviewStatus() {
|
|
1127
|
+
return this.review.reviewStatus();
|
|
1128
|
+
}
|
|
1129
|
+
reviewNow() {
|
|
1130
|
+
return this.review.reviewNow();
|
|
1131
|
+
}
|
|
1132
|
+
setPace(days, reason) {
|
|
1133
|
+
return this.review.setPace(days, reason);
|
|
1134
|
+
}
|
|
1135
|
+
setProfile(profile) {
|
|
1136
|
+
return this.review.setProfile(profile);
|
|
1137
|
+
}
|
|
1138
|
+
async migrate() {
|
|
1139
|
+
if (await this.host.getExtensionData(NAME, Keys.MIGRATED).catch(() => {
|
|
1140
|
+
return;
|
|
1141
|
+
}) === true) {
|
|
1142
|
+
return;
|
|
1143
|
+
}
|
|
1144
|
+
for (const key of FORMER_KEYS) {
|
|
1145
|
+
const [own, former] = await Promise.all([
|
|
1146
|
+
this.host.getExtensionData(NAME, key).catch(() => {
|
|
1147
|
+
return;
|
|
1148
|
+
}),
|
|
1149
|
+
this.host.getExtensionData(FORMER_NAME, key).catch(() => {
|
|
1150
|
+
return;
|
|
1151
|
+
})
|
|
1152
|
+
]);
|
|
1153
|
+
if (own === undefined && former !== undefined) {
|
|
1154
|
+
await this.host.setExtensionData(NAME, key, former);
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
await this.host.setExtensionData(NAME, Keys.MIGRATED, true);
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
// web-src/host.ts
|
|
1162
|
+
async function activate(host) {
|
|
1163
|
+
const initiative = new InitiativeHost(host);
|
|
1164
|
+
await initiative.start();
|
|
1165
|
+
return initiative;
|
|
1166
|
+
}
|
|
1167
|
+
export {
|
|
1168
|
+
activate as default
|
|
1169
|
+
};
|