@celljs/ta-extensions 4.13.1 → 4.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -6
- package/skills/ta-package/SKILL.md +1 -1
- package/web/index.js +170 -134
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-extensions",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.14.0",
|
|
4
4
|
"description": "A pi package for Ta: the page of extensions, where the user makes one by saying what it should do, and hands extensions on or takes them in as one file",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
7
7
|
],
|
|
8
|
-
"homepage": "https://github.com/cellbang/
|
|
8
|
+
"homepage": "https://github.com/cellbang/ta",
|
|
9
9
|
"bugs": {
|
|
10
|
-
"url": "https://github.com/cellbang/
|
|
10
|
+
"url": "https://github.com/cellbang/ta/issues"
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@celljs/ta-harness": "4.
|
|
31
|
-
"@celljs/ta-protocol": "4.
|
|
32
|
-
"@celljs/ta-web": "4.
|
|
30
|
+
"@celljs/ta-harness": "4.14.0",
|
|
31
|
+
"@celljs/ta-protocol": "4.14.0",
|
|
32
|
+
"@celljs/ta-web": "4.14.0",
|
|
33
33
|
"@types/react": "^19.3.0"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
@@ -78,7 +78,7 @@ export default function (pi) {
|
|
|
78
78
|
- `ui.Composer`: the message box of every conversation, with its microphone and its hold to talk, `{ placeholder?, onSend(text), mentions?, mentionLabel?, actions?, voiceSends?, onTalkSent?(), onListening?(listening), working?, onStop?(), after? }`: `mentions` (`{ name, detail? }[]`) is what `@` lists; `actions` are sections of its + menu, entries `{ key, label, icon?, detail?, setting?, toggle?, checked?, insert? | run() }` (`insert` puts text at the caret; tiles, `setting` and `toggle` as above). As the double's box: `voiceSends` sends what the microphone hears at once, `onTalkSent` says a message was said by voice (read its answer aloud with `ui.voice`), `onListening` says the user talks now, `working` makes the send button stop (`onStop`) while nothing is typed, `after` are buttons of the page before the microphone. Use it for any conversation an extension shows, rather than a box of its own. `ui.HoldToTalk` (`{ onSend(text), onEdit?(text), hints?, title?, className?, children }`) is a button held to talk, as the bar of the message box: the page dims and listens with its own recognizer (the app's on iOS), 取消 and 编辑 to slide onto; it renders nothing where the page cannot listen. `ui.voice` (`canListen()`, `canSpeak()`, `speak(text, onEnd?)`, `hush()`) reads aloud in the voice of the settings. Never a `SpeechRecognition` or `speechSynthesis` of your own. A page that is a conversation may take a message from another extension: `ui.useView(id).send?.(text)` (the double's page, `assistant/assistant`, has it; its answer comes as the view's `preview`). `ui.Markdown` (`{ text }`) renders messages as the conversations do. `ui.Empty` (`{ title, hint?, compact?, tone?, picture?, children? }`) is what an empty list or view shows, as Ta's own lists: a short title without a full stop, at most one quieter hint, centered in its parent (a column of flex); `compact` in a menu, picker or dialog; `picture` above it where seeing what will be there helps (a first page, a list the user fills). Use it rather than text of your own. `ui.Picture` (`{ width?, height?, frame?, className?, children }`, 160 by 96 in a rounded frame unless told) is a small picture as Ta's own: draw a few `rect`, `circle`, `path` and `text` in it with the classes `ta-pic-pane` (a surface), `ta-pic-line` (a bar of text), `ta-pic-box` (an outline), `ta-pic-accent` (what it is about), `ta-pic-mark` (green), `ta-pic-soft` (half of it), `ta-pic-dot`, `ta-pic-bad` (red), `ta-pic-path` (a dashed way), `ta-pic-stroke` (a green line), `ta-pic-tick` (a line on green) and `ta-pic-text` (code), never colors of your own, so it follows the theme. `ui.PictureCards` (`{ cards, columns?, compactColumns? }`, cards `{ key, picture, label, hint?, title?, disabled?, onPick() }`) is a row of them to pick from, as the suggestions of an empty conversation. `ui.Dialog` (`{ title, onClose, children }`) is a dialog over the whole page, as Ta's own: use it to make or change things rather than a form in a sidebar.
|
|
79
79
|
- `ui.usePages()`: a React hook, every page there is (`{ id, extension, title, icon?, state, onOpen, place, usedAt?, source?, temporary? }`), what Quick open lists; `ui.stopExtension(name)` stops one that started on open, `ui.forgetPage(id)` takes one out of Recent. `openTemporary(source, 'link')` opens a package of npm or Git without installing it and shows its first page: ask the user first. `ui.useContextMenu()`: a React hook, `[menu, open]`: render `menu`, and call `open(event, sections)` from `onContextMenu` (a long press on a touch screen is one), sections of `{ key, label, icon?, disabled?, danger?, run }`. `ui.shareExtension({ title, source?, packageId? })` opens Ta's dialog that shares an extension (a link and its QR code), `ui.openShared(text)` opens such a link after asking, and `registerSearch({ key, title, order?, remote?, search(query, offset), subscribe? })` adds a section to the search of Quick open (entries `{ key, title, detail?, icon?, tint?, action?, open(), menu? }`). `ui.QrCode` (`{ text }`) draws a QR code; `ui.ImageViewer` (`{ src, alt?, className?, onLoad?, onBackground?, onPrevious?, onNext?, autoFocus? }`) shows a picture to zoom and drag, as the previews of the workbench do (it fills a column of flex; `onPrevious` / `onNext` go to the pictures beside it, by side buttons and ← →); `ui.scanCode?.(instructions)`, only in the Ta app, scans one with the camera; `ui.scan?.()` is the Scan of the page itself (Discover, the + of the first list), which opens what the code carries (a computer, a link of an extension, a page, text to copy).
|
|
80
80
|
- What waits on ta serve says so, so that the user sees the click took: `ui.useBusy()`, a React hook, `[busy, run]`; `run(action)` stays busy until what `action` returns settles and runs nothing else meanwhile (a second click). Mark what waits with the page's classes, which show it only once it took a moment: `ta-busy` on a button with `<span className="ta-spinner ta-busy-mark" />` in it (add `ta-on-brand` on a button of the brand's color), `ta-pending` on a row being taken away, `<span className="ta-spinner ta-later" />` for a spinner of its own. `ui.Switch` (`{ checked, onChange, label, disabled? }`) is the page's switch: an `onChange` that returns a promise moves it at once, its knob turning until done. Both are newer than some Ta apps: `(pi.ui.useBusy ?? fallback)()`, `pi.ui.Switch ?? fallback`.
|
|
81
|
-
- Lists drawn as the page's: `ui.useSessions()` and `ui.useSavedSessions()`, React hooks, the open sessions of ta serve and the conversations saved lately, as the lists of the page have them (never a poll of `server.listSessions()` of your own); `ui.Face` (`{ face?, seed?, size, working?, online? }`, the same for the same `seed` on every device) and `ui.GroupFace` (`{ members, size }`) for who is not Ta; `ui.SwipeRow` for a row a finger swipes for its actions, `ui.SelectCheck` and `ui.SelectBar` for several chosen at once; `ui.Stack` (`{ base, top, open, onClose }`) for what a tap in a list pushes over it. Work the package does for the user is a task: `registerTasks(source)`, listed with the double's by `ui.useTasks()`, removed after asking with `ui.removeTasks(tasks)`. Newer than some Ta apps: `pi.ui.Face ?? fallback`.
|
|
81
|
+
- Lists drawn as the page's: `ui.useSessions()` and `ui.useSavedSessions()`, React hooks, the open sessions of ta serve and the conversations saved lately, as the lists of the page have them (never a poll of `server.listSessions()` of your own); `ui.useAsks()` the conversations waiting for the user to decide, as the top of the list of chats has them (`pi.ui.useAsks?.() ?? []`); `ui.Face` (`{ face?, seed?, size, working?, online? }`, the same for the same `seed` on every device) and `ui.GroupFace` (`{ members, size }`) for who is not Ta; `ui.SwipeRow` for a row a finger swipes for its actions, `ui.SelectCheck` and `ui.SelectBar` for several chosen at once; `ui.Stack` (`{ base, top, open, onClose }`) for what a tap in a list pushes over it. Work the package does for the user is a task: `registerTasks(source)`, listed with the double's by `ui.useTasks()`, removed after asking with `ui.removeTasks(tasks)`. Newer than some Ta apps: `pi.ui.Face ?? fallback`.
|
|
82
82
|
- `ui.Avatar`: Ta's avatar, the Cell logo, as a component `{ size?, mood?, mark? }`; `mark`, one or two characters, tells agents apart. Use it wherever Ta speaks, and draw Ta no other way.
|
|
83
83
|
- `ui.icons`: the lucide icons of the page by name (`Plus`, `Hash`, `Search`, `Files`, ...): a web extension cannot import them. Check for one before using it: the list only grows.
|
|
84
84
|
- `storage.get(key)` and `storage.set(key, value)`: small JSON values kept on the server for the package, so they stay across browsers and devices; setting `null` removes a key. A package keeps at most 4 MB there. `storage.onChange(keys => ...)` hears keys changed by other pages or the server. `storage.directory(cwd)` has the same methods for values of one directory (use `ui.useCwd()`), such as the folders open in a tree: keep there what belongs to a directory, and in `storage` what belongs to the user. Keys of `storage` that should go to the user's other computers (a best score, preferences) are listed in `"pi": { "sync": ["best"] }` of package.json; the built-in Sync (@celljs/ta-sync) carries them, when the user turned it on. The pages of people the user let into their Ta (the built-in Members, @celljs/ta-team) keep values of their own in `storage`: theirs are not the user's. A call the person may not make fails with the code `CELL_TA_FORBIDDEN` and a message that says what it needs.
|
package/web/index.js
CHANGED
|
@@ -771,140 +771,6 @@ var TaPackageTextUtil;
|
|
|
771
771
|
}
|
|
772
772
|
TaPackageTextUtil2.pick = pick;
|
|
773
773
|
})(TaPackageTextUtil || (TaPackageTextUtil = {}));
|
|
774
|
-
// ../ta-protocol/esm/common/relay-protocol.js
|
|
775
|
-
var TaRelayServer = Symbol("TaRelayServer");
|
|
776
|
-
// ../ta-protocol/esm/common/remote-protocol.js
|
|
777
|
-
var TaRemoteServer = Symbol("TaRemoteServer");
|
|
778
|
-
// ../ta-protocol/esm/common/room-protocol.js
|
|
779
|
-
var TaRoomServer = Symbol("TaRoomServer");
|
|
780
|
-
var TaRoomWatchUtil;
|
|
781
|
-
(function(TaRoomWatchUtil2) {
|
|
782
|
-
function of(messages, state) {
|
|
783
|
-
const prefixes = Array.isArray(state) ? state.filter((prefix) => typeof prefix === "string" && prefix.length > 0) : [];
|
|
784
|
-
return { messages: messages !== false, state: [...new Set(prefixes)].sort() };
|
|
785
|
-
}
|
|
786
|
-
TaRoomWatchUtil2.of = of;
|
|
787
|
-
function union(watches) {
|
|
788
|
-
let messages = false;
|
|
789
|
-
const state = [];
|
|
790
|
-
for (const watch of watches) {
|
|
791
|
-
messages || (messages = watch.messages);
|
|
792
|
-
state.push(...watch.state);
|
|
793
|
-
}
|
|
794
|
-
return of(messages, messages ? [] : state);
|
|
795
|
-
}
|
|
796
|
-
TaRoomWatchUtil2.union = union;
|
|
797
|
-
function same(a, b) {
|
|
798
|
-
return a === b || !!a && !!b && a.messages === b.messages && a.state.join(`
|
|
799
|
-
`) === b.state.join(`
|
|
800
|
-
`);
|
|
801
|
-
}
|
|
802
|
-
TaRoomWatchUtil2.same = same;
|
|
803
|
-
function hears(watch, event) {
|
|
804
|
-
if (event.type === "message") {
|
|
805
|
-
return watch.messages;
|
|
806
|
-
}
|
|
807
|
-
if (event.type === "state") {
|
|
808
|
-
return watch.messages || watch.state.some((prefix) => event.key.startsWith(prefix));
|
|
809
|
-
}
|
|
810
|
-
return true;
|
|
811
|
-
}
|
|
812
|
-
TaRoomWatchUtil2.hears = hears;
|
|
813
|
-
})(TaRoomWatchUtil || (TaRoomWatchUtil = {}));
|
|
814
|
-
// ../ta-protocol/esm/common/settings-protocol.js
|
|
815
|
-
var TaSettingsServer = Symbol("TaSettingsServer");
|
|
816
|
-
// ../ta-protocol/esm/common/ta-extension-host.js
|
|
817
|
-
var TA_HOST_EVENT = "ta:host";
|
|
818
|
-
var TaHostUtil;
|
|
819
|
-
(function(TaHostUtil2) {
|
|
820
|
-
TaHostUtil2.WAIT_MS = 1000;
|
|
821
|
-
function reach(events, name, waitMs = TaHostUtil2.WAIT_MS) {
|
|
822
|
-
return new Promise((resolve) => {
|
|
823
|
-
let heard = false;
|
|
824
|
-
let answered = false;
|
|
825
|
-
const timer = setTimeout(() => resolve(undefined), waitMs);
|
|
826
|
-
const request = {
|
|
827
|
-
name,
|
|
828
|
-
heard: () => {
|
|
829
|
-
heard = true;
|
|
830
|
-
},
|
|
831
|
-
resolve: (answer) => {
|
|
832
|
-
answered = true;
|
|
833
|
-
clearTimeout(timer);
|
|
834
|
-
resolve(answer);
|
|
835
|
-
}
|
|
836
|
-
};
|
|
837
|
-
events.emit(TA_HOST_EVENT, request);
|
|
838
|
-
if (!heard && !answered) {
|
|
839
|
-
clearTimeout(timer);
|
|
840
|
-
resolve(undefined);
|
|
841
|
-
}
|
|
842
|
-
});
|
|
843
|
-
}
|
|
844
|
-
TaHostUtil2.reach = reach;
|
|
845
|
-
function marked(systemPrompt, mark) {
|
|
846
|
-
return role(systemPrompt).includes(mark);
|
|
847
|
-
}
|
|
848
|
-
TaHostUtil2.marked = marked;
|
|
849
|
-
function role(systemPrompt) {
|
|
850
|
-
if (!systemPrompt) {
|
|
851
|
-
return "";
|
|
852
|
-
}
|
|
853
|
-
const open = `<addendum>
|
|
854
|
-
`;
|
|
855
|
-
const start = systemPrompt.indexOf(open);
|
|
856
|
-
const context = systemPrompt.indexOf(`<project_context>
|
|
857
|
-
`);
|
|
858
|
-
if (start < 0 || context >= 0 && context < start) {
|
|
859
|
-
return "";
|
|
860
|
-
}
|
|
861
|
-
const end = systemPrompt.indexOf(`
|
|
862
|
-
</addendum>`, start);
|
|
863
|
-
return systemPrompt.slice(start + open.length, end < 0 ? undefined : end);
|
|
864
|
-
}
|
|
865
|
-
TaHostUtil2.role = role;
|
|
866
|
-
})(TaHostUtil || (TaHostUtil = {}));
|
|
867
|
-
var TA_ASK_ENTRY = "ta-ask";
|
|
868
|
-
var TaAskUtil;
|
|
869
|
-
(function(TaAskUtil2) {
|
|
870
|
-
const LENGTH = 120;
|
|
871
|
-
function entry(question) {
|
|
872
|
-
const line = question.replace(/\s+/g, " ").trim();
|
|
873
|
-
return { question: line.length > LENGTH ? `${line.slice(0, LENGTH - 1)}…` : line };
|
|
874
|
-
}
|
|
875
|
-
TaAskUtil2.entry = entry;
|
|
876
|
-
function asking(entries) {
|
|
877
|
-
var _a;
|
|
878
|
-
for (let i = entries.length - 1;i >= 0; i--) {
|
|
879
|
-
const entry2 = entries[i];
|
|
880
|
-
if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
|
|
881
|
-
return;
|
|
882
|
-
}
|
|
883
|
-
if (entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY) {
|
|
884
|
-
return read(entry2);
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
return;
|
|
888
|
-
}
|
|
889
|
-
TaAskUtil2.asking = asking;
|
|
890
|
-
function next(asked, entry2) {
|
|
891
|
-
var _a;
|
|
892
|
-
if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
|
|
893
|
-
return;
|
|
894
|
-
}
|
|
895
|
-
return entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY ? read(entry2) : asked;
|
|
896
|
-
}
|
|
897
|
-
TaAskUtil2.next = next;
|
|
898
|
-
function read(found) {
|
|
899
|
-
var _a;
|
|
900
|
-
const question = (_a = found.data) === null || _a === undefined ? undefined : _a.question;
|
|
901
|
-
if (typeof question !== "string" || !question.trim()) {
|
|
902
|
-
return;
|
|
903
|
-
}
|
|
904
|
-
const at = found.timestamp ? Date.parse(found.timestamp) : Number.NaN;
|
|
905
|
-
return { question: entry(question).question, at: Number.isNaN(at) ? 0 : at };
|
|
906
|
-
}
|
|
907
|
-
})(TaAskUtil || (TaAskUtil = {}));
|
|
908
774
|
// ../ta-protocol/esm/common/ta-protocol.js
|
|
909
775
|
var TaServer = Symbol("TaServer");
|
|
910
776
|
var TaClient = Symbol("TaClient");
|
|
@@ -1090,6 +956,176 @@ var TaSkillUse;
|
|
|
1090
956
|
}
|
|
1091
957
|
TaSkillUse2.command = command;
|
|
1092
958
|
})(TaSkillUse || (TaSkillUse = {}));
|
|
959
|
+
|
|
960
|
+
// ../ta-protocol/esm/common/presence-protocol.js
|
|
961
|
+
var TaPresenceServer = Symbol("TaPresenceServer");
|
|
962
|
+
var TaMessageAuthor;
|
|
963
|
+
(function(TaMessageAuthor2) {
|
|
964
|
+
const LINE = /^\[ta:by ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
|
|
965
|
+
const LINES = /^\[ta:by [^\]\n]*\]$\n?/gm;
|
|
966
|
+
function strip(message) {
|
|
967
|
+
const context = TaMessageContext.read(message);
|
|
968
|
+
if (context === undefined || !LINE.test(context)) {
|
|
969
|
+
return message;
|
|
970
|
+
}
|
|
971
|
+
const kept = context.replace(LINES, "").replace(/\n+$/, "");
|
|
972
|
+
const body = TaMessageContext.strip(message);
|
|
973
|
+
return kept.trim() ? TaMessageContext.wrap(kept, body) : body;
|
|
974
|
+
}
|
|
975
|
+
TaMessageAuthor2.strip = strip;
|
|
976
|
+
function mark(message, id, name) {
|
|
977
|
+
const plain = strip(message);
|
|
978
|
+
if (/^[/!]/.test(plain)) {
|
|
979
|
+
return plain;
|
|
980
|
+
}
|
|
981
|
+
const line = `[ta:by ${id.replace(/[\s\]]/g, "")} ${name.replace(/[\]\n]/g, " ").trim() || id}]`;
|
|
982
|
+
const context = TaMessageContext.read(plain);
|
|
983
|
+
return TaMessageContext.wrap(context === undefined ? line : `${context}
|
|
984
|
+
${line}`, TaMessageContext.strip(plain));
|
|
985
|
+
}
|
|
986
|
+
TaMessageAuthor2.mark = mark;
|
|
987
|
+
function of(message) {
|
|
988
|
+
var _a;
|
|
989
|
+
const context = TaMessageContext.read(message);
|
|
990
|
+
const match = context === undefined ? null : LINE.exec(context);
|
|
991
|
+
return match ? { id: match[1], name: ((_a = match[2]) !== null && _a !== undefined ? _a : match[1]).trim() } : undefined;
|
|
992
|
+
}
|
|
993
|
+
TaMessageAuthor2.of = of;
|
|
994
|
+
})(TaMessageAuthor || (TaMessageAuthor = {}));
|
|
995
|
+
// ../ta-protocol/esm/common/relay-protocol.js
|
|
996
|
+
var TaRelayServer = Symbol("TaRelayServer");
|
|
997
|
+
// ../ta-protocol/esm/common/remote-protocol.js
|
|
998
|
+
var TaRemoteServer = Symbol("TaRemoteServer");
|
|
999
|
+
// ../ta-protocol/esm/common/room-protocol.js
|
|
1000
|
+
var TaRoomServer = Symbol("TaRoomServer");
|
|
1001
|
+
var TaRoomWatchUtil;
|
|
1002
|
+
(function(TaRoomWatchUtil2) {
|
|
1003
|
+
function of(messages, state) {
|
|
1004
|
+
const prefixes = Array.isArray(state) ? state.filter((prefix) => typeof prefix === "string" && prefix.length > 0) : [];
|
|
1005
|
+
return { messages: messages !== false, state: [...new Set(prefixes)].sort() };
|
|
1006
|
+
}
|
|
1007
|
+
TaRoomWatchUtil2.of = of;
|
|
1008
|
+
function union(watches) {
|
|
1009
|
+
let messages = false;
|
|
1010
|
+
const state = [];
|
|
1011
|
+
for (const watch of watches) {
|
|
1012
|
+
messages || (messages = watch.messages);
|
|
1013
|
+
state.push(...watch.state);
|
|
1014
|
+
}
|
|
1015
|
+
return of(messages, messages ? [] : state);
|
|
1016
|
+
}
|
|
1017
|
+
TaRoomWatchUtil2.union = union;
|
|
1018
|
+
function same(a, b) {
|
|
1019
|
+
return a === b || !!a && !!b && a.messages === b.messages && a.state.join(`
|
|
1020
|
+
`) === b.state.join(`
|
|
1021
|
+
`);
|
|
1022
|
+
}
|
|
1023
|
+
TaRoomWatchUtil2.same = same;
|
|
1024
|
+
function hears(watch, event) {
|
|
1025
|
+
if (event.type === "message") {
|
|
1026
|
+
return watch.messages;
|
|
1027
|
+
}
|
|
1028
|
+
if (event.type === "state") {
|
|
1029
|
+
return watch.messages || watch.state.some((prefix) => event.key.startsWith(prefix));
|
|
1030
|
+
}
|
|
1031
|
+
return true;
|
|
1032
|
+
}
|
|
1033
|
+
TaRoomWatchUtil2.hears = hears;
|
|
1034
|
+
})(TaRoomWatchUtil || (TaRoomWatchUtil = {}));
|
|
1035
|
+
// ../ta-protocol/esm/common/settings-protocol.js
|
|
1036
|
+
var TaSettingsServer = Symbol("TaSettingsServer");
|
|
1037
|
+
// ../ta-protocol/esm/common/ta-extension-host.js
|
|
1038
|
+
var TA_HOST_EVENT = "ta:host";
|
|
1039
|
+
var TaHostUtil;
|
|
1040
|
+
(function(TaHostUtil2) {
|
|
1041
|
+
TaHostUtil2.WAIT_MS = 1000;
|
|
1042
|
+
function reach(events, name, waitMs = TaHostUtil2.WAIT_MS) {
|
|
1043
|
+
return new Promise((resolve) => {
|
|
1044
|
+
let heard = false;
|
|
1045
|
+
let answered = false;
|
|
1046
|
+
const timer = setTimeout(() => resolve(undefined), waitMs);
|
|
1047
|
+
const request = {
|
|
1048
|
+
name,
|
|
1049
|
+
heard: () => {
|
|
1050
|
+
heard = true;
|
|
1051
|
+
},
|
|
1052
|
+
resolve: (answer) => {
|
|
1053
|
+
answered = true;
|
|
1054
|
+
clearTimeout(timer);
|
|
1055
|
+
resolve(answer);
|
|
1056
|
+
}
|
|
1057
|
+
};
|
|
1058
|
+
events.emit(TA_HOST_EVENT, request);
|
|
1059
|
+
if (!heard && !answered) {
|
|
1060
|
+
clearTimeout(timer);
|
|
1061
|
+
resolve(undefined);
|
|
1062
|
+
}
|
|
1063
|
+
});
|
|
1064
|
+
}
|
|
1065
|
+
TaHostUtil2.reach = reach;
|
|
1066
|
+
function marked(systemPrompt, mark) {
|
|
1067
|
+
return role(systemPrompt).includes(mark);
|
|
1068
|
+
}
|
|
1069
|
+
TaHostUtil2.marked = marked;
|
|
1070
|
+
function role(systemPrompt) {
|
|
1071
|
+
if (!systemPrompt) {
|
|
1072
|
+
return "";
|
|
1073
|
+
}
|
|
1074
|
+
const open = `<addendum>
|
|
1075
|
+
`;
|
|
1076
|
+
const start = systemPrompt.indexOf(open);
|
|
1077
|
+
const context = systemPrompt.indexOf(`<project_context>
|
|
1078
|
+
`);
|
|
1079
|
+
if (start < 0 || context >= 0 && context < start) {
|
|
1080
|
+
return "";
|
|
1081
|
+
}
|
|
1082
|
+
const end = systemPrompt.indexOf(`
|
|
1083
|
+
</addendum>`, start);
|
|
1084
|
+
return systemPrompt.slice(start + open.length, end < 0 ? undefined : end);
|
|
1085
|
+
}
|
|
1086
|
+
TaHostUtil2.role = role;
|
|
1087
|
+
})(TaHostUtil || (TaHostUtil = {}));
|
|
1088
|
+
var TA_ASK_ENTRY = "ta-ask";
|
|
1089
|
+
var TaAskUtil;
|
|
1090
|
+
(function(TaAskUtil2) {
|
|
1091
|
+
const LENGTH = 120;
|
|
1092
|
+
function entry(question) {
|
|
1093
|
+
const line = question.replace(/\s+/g, " ").trim();
|
|
1094
|
+
return { question: line.length > LENGTH ? `${line.slice(0, LENGTH - 1)}…` : line };
|
|
1095
|
+
}
|
|
1096
|
+
TaAskUtil2.entry = entry;
|
|
1097
|
+
function asking(entries) {
|
|
1098
|
+
var _a;
|
|
1099
|
+
for (let i = entries.length - 1;i >= 0; i--) {
|
|
1100
|
+
const entry2 = entries[i];
|
|
1101
|
+
if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
|
|
1102
|
+
return;
|
|
1103
|
+
}
|
|
1104
|
+
if (entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY) {
|
|
1105
|
+
return read(entry2);
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
return;
|
|
1109
|
+
}
|
|
1110
|
+
TaAskUtil2.asking = asking;
|
|
1111
|
+
function next(asked, entry2) {
|
|
1112
|
+
var _a;
|
|
1113
|
+
if (entry2.type === "message" && ((_a = entry2.message) === null || _a === undefined ? undefined : _a.role) === "user") {
|
|
1114
|
+
return;
|
|
1115
|
+
}
|
|
1116
|
+
return entry2.type === "custom" && entry2.customType === TA_ASK_ENTRY ? read(entry2) : asked;
|
|
1117
|
+
}
|
|
1118
|
+
TaAskUtil2.next = next;
|
|
1119
|
+
function read(found) {
|
|
1120
|
+
var _a;
|
|
1121
|
+
const question = (_a = found.data) === null || _a === undefined ? undefined : _a.question;
|
|
1122
|
+
if (typeof question !== "string" || !question.trim()) {
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
const at = found.timestamp ? Date.parse(found.timestamp) : Number.NaN;
|
|
1126
|
+
return { question: entry(question).question, at: Number.isNaN(at) ? 0 : at };
|
|
1127
|
+
}
|
|
1128
|
+
})(TaAskUtil || (TaAskUtil = {}));
|
|
1093
1129
|
// ../ta-protocol/esm/common/team-protocol.js
|
|
1094
1130
|
var TA_UNDECLARED = "extensions.install";
|
|
1095
1131
|
var TaPermissionUtil;
|