@celljs/ta-protocol 4.16.0 → 4.18.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.
Files changed (81) hide show
  1. package/esm/common/access-protocol.d.ts +41 -0
  2. package/esm/common/access-protocol.js +7 -0
  3. package/esm/common/app-protocol.d.ts +120 -0
  4. package/esm/common/app-protocol.js +213 -0
  5. package/esm/common/delegate-protocol.d.ts +30 -0
  6. package/esm/common/delegate-protocol.js +52 -0
  7. package/esm/common/deployment-protocol.d.ts +72 -0
  8. package/esm/common/deployment-protocol.js +171 -0
  9. package/esm/common/error-protocol.d.ts +42 -0
  10. package/esm/common/error-protocol.js +45 -0
  11. package/esm/common/event-protocol.d.ts +63 -0
  12. package/esm/common/event-protocol.js +2 -0
  13. package/esm/common/gateway-protocol.d.ts +29 -0
  14. package/esm/common/index.d.ts +11 -0
  15. package/esm/common/index.js +11 -0
  16. package/esm/common/message-protocol.d.ts +134 -0
  17. package/esm/common/message-protocol.js +322 -0
  18. package/esm/common/page-protocol.d.ts +56 -0
  19. package/esm/common/page-protocol.js +12 -0
  20. package/esm/common/path-map.d.ts +24 -0
  21. package/esm/common/path-map.js +127 -0
  22. package/esm/common/presence-protocol.js +1 -1
  23. package/esm/common/redactor.d.ts +12 -0
  24. package/esm/common/redactor.js +49 -11
  25. package/esm/common/relay-protocol.d.ts +20 -0
  26. package/esm/common/room-protocol.d.ts +52 -1
  27. package/esm/common/said-protocol.d.ts +76 -0
  28. package/esm/common/said-protocol.js +239 -0
  29. package/esm/common/screen-share-protocol.d.ts +304 -0
  30. package/esm/common/screen-share-protocol.js +88 -0
  31. package/esm/common/settings-protocol.d.ts +8 -0
  32. package/esm/common/settings-protocol.js +2 -0
  33. package/esm/common/ta-extension-host.d.ts +64 -1
  34. package/esm/common/ta-extension-host.js +8 -0
  35. package/esm/common/ta-protocol.d.ts +53 -175
  36. package/esm/common/ta-protocol.js +0 -234
  37. package/esm/common/team-protocol.d.ts +13 -2
  38. package/esm/common/team-protocol.js +27 -2
  39. package/esm/common/voice-protocol.d.ts +184 -0
  40. package/esm/common/voice-protocol.js +57 -0
  41. package/lib/common/access-protocol.d.ts +41 -0
  42. package/lib/common/access-protocol.js +8 -1
  43. package/lib/common/app-protocol.d.ts +121 -0
  44. package/lib/common/app-protocol.js +216 -0
  45. package/lib/common/delegate-protocol.d.ts +31 -0
  46. package/lib/common/delegate-protocol.js +55 -0
  47. package/lib/common/deployment-protocol.d.ts +73 -0
  48. package/lib/common/deployment-protocol.js +175 -0
  49. package/lib/common/error-protocol.d.ts +43 -0
  50. package/lib/common/error-protocol.js +48 -0
  51. package/lib/common/event-protocol.d.ts +64 -0
  52. package/lib/common/event-protocol.js +3 -0
  53. package/lib/common/gateway-protocol.d.ts +29 -0
  54. package/lib/common/index.d.ts +11 -0
  55. package/lib/common/index.js +11 -0
  56. package/lib/common/message-protocol.d.ts +135 -0
  57. package/lib/common/message-protocol.js +325 -0
  58. package/lib/common/page-protocol.d.ts +57 -0
  59. package/lib/common/page-protocol.js +15 -0
  60. package/lib/common/path-map.d.ts +25 -0
  61. package/lib/common/path-map.js +130 -0
  62. package/lib/common/presence-protocol.js +7 -7
  63. package/lib/common/redactor.d.ts +12 -0
  64. package/lib/common/redactor.js +49 -11
  65. package/lib/common/relay-protocol.d.ts +20 -0
  66. package/lib/common/room-protocol.d.ts +52 -1
  67. package/lib/common/said-protocol.d.ts +77 -0
  68. package/lib/common/said-protocol.js +242 -0
  69. package/lib/common/screen-share-protocol.d.ts +305 -0
  70. package/lib/common/screen-share-protocol.js +91 -0
  71. package/lib/common/settings-protocol.d.ts +8 -0
  72. package/lib/common/settings-protocol.js +3 -1
  73. package/lib/common/ta-extension-host.d.ts +64 -1
  74. package/lib/common/ta-extension-host.js +9 -1
  75. package/lib/common/ta-protocol.d.ts +53 -175
  76. package/lib/common/ta-protocol.js +1 -235
  77. package/lib/common/team-protocol.d.ts +13 -2
  78. package/lib/common/team-protocol.js +28 -3
  79. package/lib/common/voice-protocol.d.ts +185 -0
  80. package/lib/common/voice-protocol.js +60 -0
  81. package/package.json +1 -1
@@ -0,0 +1,135 @@
1
+ /**
2
+ * A message of the user may start with a `<context>` block: what the model reads besides the message
3
+ * (where it is said, who is there, what was said before), which a client leaves out when it shows it.
4
+ */
5
+ export declare namespace TaMessageContext {
6
+ function wrap(context: string, message: string): string;
7
+ /** The message without its context: what the user sees of it. */
8
+ function strip(message: string): string;
9
+ /** The context of the message, without its tags; undefined without one. */
10
+ function read(message: string): string | undefined;
11
+ }
12
+ /** Where a message of the user came from, when not from what they typed: see {@link TaMessageSource}. */
13
+ export interface TaMessageFrom {
14
+ /** The name of the package that sent it, or TaMessageSource.DOUBLE. */
15
+ from: string;
16
+ /** What the package says of it besides, in a few words (the channel and who spoke in it). */
17
+ detail?: string;
18
+ /** Not the user's: news or an event of that part of Ta, which the model weighs below what the user said (TaMessageSource.notice). */
19
+ notice?: true;
20
+ }
21
+ /**
22
+ * Who wrote a message of the user's role (docs/design/ta-sources.md). What the user typed has no mark. A message a
23
+ * package sends for the user (their choice in a card, what they said in a call, a task they scheduled) says so in the
24
+ * last line of its `<context>` block, `[ta:from <name> <detail>]`: it is theirs. A message that is not theirs (news of
25
+ * work elsewhere, a time limit, a grant) is a notice, `[ta:notice <name> <detail>]`: the model reads it as information
26
+ * below what the user said (the section `<ta-sources>` of the system prompt), and a page shows it as a line, not as a
27
+ * bubble of the user. A page older than these leaves them out with the rest of the context. A command (`/compact`,
28
+ * `!ls`) is not marked.
29
+ */
30
+ export declare namespace TaMessageSource {
31
+ /** The double of the web page: the tasks it hands out, what it tells them on the way. */
32
+ const DOUBLE = "ta:double";
33
+ /** `message` as sent by `from` for the user; as it was when it is a command or says where it came from already. */
34
+ function mark(message: string, from: string, detail?: string): string;
35
+ /** `message` as a notice of `from`: not the user's; as it was when it says where it came from already. */
36
+ function notice(message: string, from: string, detail?: string): string;
37
+ /** The line of the context that says a message came from `from` (a notice of it, with `notice`), for one who writes the context of their own. */
38
+ function line(from: string, detail?: string, notice?: boolean): string;
39
+ function of(message: string): TaMessageFrom | undefined;
40
+ /** Whether a message is a notice: not the user's (TaMessageSource.notice). */
41
+ function isNotice(message: string): boolean;
42
+ /** The section of the system prompt that says who wrote a message, and that the user's words come first (SourcesExtension of ta-host). */
43
+ const SECTION = "ta-sources";
44
+ const PROMPT: string;
45
+ }
46
+ /**
47
+ * pi adds a line to the text of a message of the user for each image it took, for the model's sake: how big
48
+ * the image was before it made it smaller, and what it was converted from. Clients leave them out.
49
+ */
50
+ export declare namespace TaImageNote {
51
+ /** The text without the notes of its images: what the user sees of it. */
52
+ function strip(text: string): string;
53
+ }
54
+ /** The width and height of an image, read from the start of its bytes (PNG, JPEG, GIF, WebP); undefined for another kind. */
55
+ export declare namespace TaImageSize {
56
+ function of(base64: string): {
57
+ width: number;
58
+ height: number;
59
+ } | undefined;
60
+ }
61
+ /**
62
+ * An external agent that compacts its own context says the summary it goes on from as text, in tags
63
+ * (`<conversation_history_summary><summary>…`). Clients show it folded, not as what the agent said.
64
+ */
65
+ export declare namespace TaAgentSummary {
66
+ /** The summary `text` is, without its tags (and the start of a closing tag while it streams); else undefined. */
67
+ function read(text: string): string | undefined;
68
+ /** The text without the summary it starts with. */
69
+ function strip(text: string): string;
70
+ }
71
+ /** A skill the user ran with `/skill:name`, as pi puts it in the message: the skill's file, then what the user wrote. */
72
+ export interface TaSkillUse {
73
+ name: string;
74
+ /** The path of its SKILL.md. */
75
+ location: string;
76
+ /** What pi read of it, for the model. */
77
+ content: string;
78
+ /** What the user wrote after `/skill:name`. */
79
+ message?: string;
80
+ }
81
+ /** The `<skill>` block pi expands `/skill:name` into (its `parseSkillBlock`), which a client shows as the skill it is. */
82
+ export declare namespace TaSkillUse {
83
+ function parse(message: string): TaSkillUse | undefined;
84
+ /** What the user typed: `/skill:name` and what follows. */
85
+ function command(use: TaSkillUse): string;
86
+ }
87
+ /** What a note of the double's tasks is about: how one ended, that the user handed it one, that one has another id now. */
88
+ export type TaTaskNoteKind = 'update' | 'adopted' | 'renamed';
89
+ /** A note of the double's tasks, as {@link TaTaskNote.write} puts it and {@link TaTaskNote.parse} reads it. */
90
+ export interface TaTaskNote {
91
+ kind: TaTaskNoteKind;
92
+ id: string;
93
+ title: string;
94
+ /** How the task stands: running, done, failed, stopped; none in a note of a new id. */
95
+ status?: string;
96
+ /** The id it had, in a note of a new id. */
97
+ was?: string;
98
+ /** What the note says, for the double. */
99
+ body: string;
100
+ }
101
+ /**
102
+ * The double hears of its tasks in messages of the user (`<task_update id="t1" title="…" status="done">…</task_update>`
103
+ * and the like): notes, not what the user said, which a client shows as the task they are about, and a list of
104
+ * conversations says by the task's title.
105
+ */
106
+ export declare namespace TaTaskNote {
107
+ function write(note: TaTaskNote): string;
108
+ /** The note `text` is, all of it; undefined for anything else. */
109
+ function parse(text: string): TaTaskNote | undefined;
110
+ }
111
+ /** What a name of the vault stands for in what the user sent: a personal detail of a kind, or another secret. */
112
+ export type TaSecretKind = 'phone' | 'email' | 'idNumber' | 'bankCard' | 'secret';
113
+ /** A part of a text: words as they are, or a name of the vault (`$TA_SECRET_PHONE`). */
114
+ export type TaSecretPart = {
115
+ text: string;
116
+ } | {
117
+ secret: string;
118
+ kind: TaSecretKind;
119
+ };
120
+ /**
121
+ * The names the vault of Ta (ta-secrets) puts in place of what it took out of a message (`$TA_SECRET_PHONE`,
122
+ * `${TA_SECRET_GITHUB_TOKEN}`): the model reads them so; a page shows each as what it stands for, not as a variable.
123
+ */
124
+ export declare namespace TaSecretRef {
125
+ /** The package of the vault: `list` of its host gives what it keeps by name, the masked hint of a personal detail, never a value. */
126
+ const PACKAGE = "@celljs/ta-secrets";
127
+ function has(text: string): boolean;
128
+ /** What a name is of: the kinds of personal details the vault takes in by itself, `secret` for the rest. */
129
+ function kind(name: string): TaSecretKind;
130
+ /** The text in parts, its names apart; one part of words when it has none. */
131
+ function split(text: string): TaSecretPart[];
132
+ /** The text with each name as `label` says it, for a line that shows no more than words (a preview). */
133
+ function plain(text: string, label: (name: string, kind: TaSecretKind) => string): string;
134
+ }
135
+ //# sourceMappingURL=message-protocol.d.ts.map
@@ -0,0 +1,325 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TaSecretRef = exports.TaTaskNote = exports.TaSkillUse = exports.TaAgentSummary = exports.TaImageSize = exports.TaImageNote = exports.TaMessageSource = exports.TaMessageContext = void 0;
4
+ /**
5
+ * A message of the user may start with a `<context>` block: what the model reads besides the message
6
+ * (where it is said, who is there, what was said before), which a client leaves out when it shows it.
7
+ */
8
+ var TaMessageContext;
9
+ (function (TaMessageContext) {
10
+ const BLOCK = /^<context>\n?[\s\S]*?\n?<\/context>\n?/;
11
+ function wrap(context, message) {
12
+ return `<context>\n${context}\n</context>\n${message}`;
13
+ }
14
+ TaMessageContext.wrap = wrap;
15
+ /** The message without its context: what the user sees of it. */
16
+ function strip(message) {
17
+ return message.replace(BLOCK, '');
18
+ }
19
+ TaMessageContext.strip = strip;
20
+ /** The context of the message, without its tags; undefined without one. */
21
+ function read(message) {
22
+ var _a;
23
+ const block = (_a = BLOCK.exec(message)) === null || _a === void 0 ? void 0 : _a[0];
24
+ return block === null || block === void 0 ? void 0 : block.replace(/^<context>\n?/, '').replace(/\n?<\/context>\n?$/, '');
25
+ }
26
+ TaMessageContext.read = read;
27
+ })(TaMessageContext || (exports.TaMessageContext = TaMessageContext = {}));
28
+ /**
29
+ * Who wrote a message of the user's role (docs/design/ta-sources.md). What the user typed has no mark. A message a
30
+ * package sends for the user (their choice in a card, what they said in a call, a task they scheduled) says so in the
31
+ * last line of its `<context>` block, `[ta:from <name> <detail>]`: it is theirs. A message that is not theirs (news of
32
+ * work elsewhere, a time limit, a grant) is a notice, `[ta:notice <name> <detail>]`: the model reads it as information
33
+ * below what the user said (the section `<ta-sources>` of the system prompt), and a page shows it as a line, not as a
34
+ * bubble of the user. A page older than these leaves them out with the rest of the context. A command (`/compact`,
35
+ * `!ls`) is not marked.
36
+ */
37
+ var TaMessageSource;
38
+ (function (TaMessageSource) {
39
+ /** The double of the web page: the tasks it hands out, what it tells them on the way. */
40
+ TaMessageSource.DOUBLE = 'ta:double';
41
+ const LINE = /^\[ta:(from|notice) ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
42
+ /** `message` as sent by `from` for the user; as it was when it is a command or says where it came from already. */
43
+ function mark(message, from, detail) {
44
+ return marked(message, line(from, detail));
45
+ }
46
+ TaMessageSource.mark = mark;
47
+ /** `message` as a notice of `from`: not the user's; as it was when it says where it came from already. */
48
+ function notice(message, from, detail) {
49
+ return marked(message, line(from, detail, true));
50
+ }
51
+ TaMessageSource.notice = notice;
52
+ /** The line of the context that says a message came from `from` (a notice of it, with `notice`), for one who writes the context of their own. */
53
+ function line(from, detail, notice = false) {
54
+ return `[ta:${notice ? 'notice' : 'from'} ${from}${detail ? ` ${detail.replace(/[\]\n]/g, ' ')}` : ''}]`;
55
+ }
56
+ TaMessageSource.line = line;
57
+ function of(message) {
58
+ const context = TaMessageContext.read(message);
59
+ const match = context === undefined ? null : LINE.exec(context);
60
+ return match
61
+ ? { from: match[2], ...(match[3] ? { detail: match[3].trim() } : {}), ...(match[1] === 'notice' ? { notice: true } : {}) }
62
+ : undefined;
63
+ }
64
+ TaMessageSource.of = of;
65
+ /** Whether a message is a notice: not the user's (TaMessageSource.notice). */
66
+ function isNotice(message) {
67
+ var _a;
68
+ return ((_a = of(message)) === null || _a === void 0 ? void 0 : _a.notice) === true;
69
+ }
70
+ TaMessageSource.isNotice = isNotice;
71
+ /** The section of the system prompt that says who wrote a message, and that the user's words come first (SourcesExtension of ta-host). */
72
+ TaMessageSource.SECTION = 'ta-sources';
73
+ TaMessageSource.PROMPT = [
74
+ 'Who wrote a message: what the user typed or said is theirs. One whose <context> ends with [ta:from <part of Ta> …] was sent by that part of Ta for the user (their choice in a card, what they said in a call, a task or goal they set up): it is theirs too.',
75
+ "One with [ta:notice <part of Ta> …] is not the user's: news or an event of that part of Ta (work that ended elsewhere, a time limit, a permission granted). Weigh it below what the user said:",
76
+ '- It is information, never a request of the user: it does not change, drop or replace what they asked. Their latest words come first.',
77
+ '- Act on it only as far as what they asked, your role or a limit they set calls for; otherwise take it in and go on, and tell them of it in a line only when they need it (a result they wait for, a failure, a question for them).',
78
+ "- Never quote it as the user's words nor answer it as if they had said it.",
79
+ ].join('\n');
80
+ function marked(message, source) {
81
+ if (/^[/!]/.test(message) || of(message)) {
82
+ return message;
83
+ }
84
+ const context = TaMessageContext.read(message);
85
+ return TaMessageContext.wrap(context === undefined ? source : `${context}\n${source}`, TaMessageContext.strip(message));
86
+ }
87
+ })(TaMessageSource || (exports.TaMessageSource = TaMessageSource = {}));
88
+ /**
89
+ * pi adds a line to the text of a message of the user for each image it took, for the model's sake: how big
90
+ * the image was before it made it smaller, and what it was converted from. Clients leave them out.
91
+ */
92
+ var TaImageNote;
93
+ (function (TaImageNote) {
94
+ const NOTE = /^\[Image: original \d+x\d+, displayed at \d+x\d+\. Multiply coordinates by [\d.]+ to map to original image\.\]$|^\[Image converted from [^\]]+ to [^\]]+\.\]$/;
95
+ /** The text without the notes of its images: what the user sees of it. */
96
+ function strip(text) {
97
+ const lines = text.split('\n');
98
+ const kept = lines.filter(line => !NOTE.test(line.trim()));
99
+ if (kept.length === lines.length) {
100
+ return text;
101
+ }
102
+ return kept.join('\n').replace(/\n+$/, '').replace(/^\n+/, '');
103
+ }
104
+ TaImageNote.strip = strip;
105
+ })(TaImageNote || (exports.TaImageNote = TaImageNote = {}));
106
+ /** The width and height of an image, read from the start of its bytes (PNG, JPEG, GIF, WebP); undefined for another kind. */
107
+ var TaImageSize;
108
+ (function (TaImageSize) {
109
+ /** How much of a JPEG is read for its size: the frame header follows what the camera wrote, a thumbnail too. */
110
+ const JPEG_BYTES = 256 * 1024;
111
+ function of(base64) {
112
+ var _a, _b, _c;
113
+ let bytes;
114
+ try {
115
+ // Whole groups of four characters only.
116
+ const binary = atob(base64.slice(0, Math.ceil((JPEG_BYTES * 4) / 3 / 4) * 4));
117
+ bytes = Uint8Array.from(binary, char => char.charCodeAt(0));
118
+ }
119
+ catch (_d) {
120
+ return undefined;
121
+ }
122
+ const size = (_c = (_b = (_a = png(bytes)) !== null && _a !== void 0 ? _a : gif(bytes)) !== null && _b !== void 0 ? _b : webp(bytes)) !== null && _c !== void 0 ? _c : jpeg(bytes);
123
+ return size && size.width > 0 && size.height > 0 ? size : undefined;
124
+ }
125
+ TaImageSize.of = of;
126
+ function u16be(bytes, at) {
127
+ return (bytes[at] << 8) | bytes[at + 1];
128
+ }
129
+ function u16le(bytes, at) {
130
+ return bytes[at] | (bytes[at + 1] << 8);
131
+ }
132
+ function u24le(bytes, at) {
133
+ return bytes[at] | (bytes[at + 1] << 8) | (bytes[at + 2] << 16);
134
+ }
135
+ function u32be(bytes, at) {
136
+ return ((bytes[at] << 24) | (bytes[at + 1] << 16) | (bytes[at + 2] << 8) | bytes[at + 3]) >>> 0;
137
+ }
138
+ function text(bytes, at, length) {
139
+ return String.fromCharCode(...bytes.subarray(at, at + length));
140
+ }
141
+ function png(bytes) {
142
+ return bytes.length >= 24 && bytes[0] === 0x89 && text(bytes, 1, 3) === 'PNG' ? { width: u32be(bytes, 16), height: u32be(bytes, 20) } : undefined;
143
+ }
144
+ function gif(bytes) {
145
+ return bytes.length >= 10 && text(bytes, 0, 3) === 'GIF' ? { width: u16le(bytes, 6), height: u16le(bytes, 8) } : undefined;
146
+ }
147
+ function webp(bytes) {
148
+ if (bytes.length < 30 || text(bytes, 0, 4) !== 'RIFF' || text(bytes, 8, 4) !== 'WEBP') {
149
+ return undefined;
150
+ }
151
+ switch (text(bytes, 12, 4)) {
152
+ case 'VP8 ':
153
+ return { width: u16le(bytes, 26) & 0x3fff, height: u16le(bytes, 28) & 0x3fff };
154
+ case 'VP8L': {
155
+ const bits = bytes[21] | (bytes[22] << 8) | (bytes[23] << 16) | (bytes[24] << 24);
156
+ return { width: (bits & 0x3fff) + 1, height: ((bits >> 14) & 0x3fff) + 1 };
157
+ }
158
+ case 'VP8X':
159
+ return { width: u24le(bytes, 24) + 1, height: u24le(bytes, 27) + 1 };
160
+ default:
161
+ return undefined;
162
+ }
163
+ }
164
+ function jpeg(bytes) {
165
+ if (bytes[0] !== 0xff || bytes[1] !== 0xd8) {
166
+ return undefined;
167
+ }
168
+ let at = 2;
169
+ while (at + 9 < bytes.length) {
170
+ if (bytes[at] !== 0xff) {
171
+ return undefined;
172
+ }
173
+ const marker = bytes[at + 1];
174
+ // A start of frame (not DHT, JPG or DAC, which share the range) says the size.
175
+ if (marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc) {
176
+ return { width: u16be(bytes, at + 7), height: u16be(bytes, at + 5) };
177
+ }
178
+ at += 2 + u16be(bytes, at + 2);
179
+ }
180
+ return undefined;
181
+ }
182
+ })(TaImageSize || (exports.TaImageSize = TaImageSize = {}));
183
+ /**
184
+ * An external agent that compacts its own context says the summary it goes on from as text, in tags
185
+ * (`<conversation_history_summary><summary>…`). Clients show it folded, not as what the agent said.
186
+ */
187
+ var TaAgentSummary;
188
+ (function (TaAgentSummary) {
189
+ const START = /^\s*<conversation_history_summary>/;
190
+ const BLOCK = /^\s*<conversation_history_summary>[\s\S]*?(?:<\/conversation_history_summary>\s*|$)/;
191
+ /** The summary `text` is, without its tags (and the start of a closing tag while it streams); else undefined. */
192
+ function read(text) {
193
+ if (!START.test(text)) {
194
+ return undefined;
195
+ }
196
+ return text
197
+ .replace(/<\/?(?:conversation_history_summary|summary)>/g, '')
198
+ .replace(/<\/?\w*$/, '')
199
+ .trim();
200
+ }
201
+ TaAgentSummary.read = read;
202
+ /** The text without the summary it starts with. */
203
+ function strip(text) {
204
+ return text.replace(BLOCK, '');
205
+ }
206
+ TaAgentSummary.strip = strip;
207
+ })(TaAgentSummary || (exports.TaAgentSummary = TaAgentSummary = {}));
208
+ /** The `<skill>` block pi expands `/skill:name` into (its `parseSkillBlock`), which a client shows as the skill it is. */
209
+ var TaSkillUse;
210
+ (function (TaSkillUse) {
211
+ const BLOCK = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
212
+ function parse(message) {
213
+ var _a;
214
+ const match = BLOCK.exec(message);
215
+ if (!match) {
216
+ return undefined;
217
+ }
218
+ return { name: match[1], location: match[2], content: match[3], message: ((_a = match[4]) === null || _a === void 0 ? void 0 : _a.trim()) || undefined };
219
+ }
220
+ TaSkillUse.parse = parse;
221
+ /** What the user typed: `/skill:name` and what follows. */
222
+ function command(use) {
223
+ return use.message ? `/skill:${use.name} ${use.message}` : `/skill:${use.name}`;
224
+ }
225
+ TaSkillUse.command = command;
226
+ })(TaSkillUse || (exports.TaSkillUse = TaSkillUse = {}));
227
+ /**
228
+ * The double hears of its tasks in messages of the user (`<task_update id="t1" title="…" status="done">…</task_update>`
229
+ * and the like): notes, not what the user said, which a client shows as the task they are about, and a list of
230
+ * conversations says by the task's title.
231
+ */
232
+ var TaTaskNote;
233
+ (function (TaTaskNote) {
234
+ const NOTE = /^<task_(update|adopted|renamed) ((?:[^>"\n]|"[^"]*")*)>\n?([\s\S]*?)\n?<\/task_\1>$/;
235
+ const ATTRIBUTE = /(\w+)="([^"]*)"/g;
236
+ function write(note) {
237
+ const attributes = [`id="${quote(note.id)}"`];
238
+ if (note.was !== undefined) {
239
+ attributes.push(`was="${quote(note.was)}"`);
240
+ }
241
+ attributes.push(`title="${quote(note.title)}"`);
242
+ if (note.status !== undefined) {
243
+ attributes.push(`status="${quote(note.status)}"`);
244
+ }
245
+ return `<task_${note.kind} ${attributes.join(' ')}>\n${note.body}\n</task_${note.kind}>`;
246
+ }
247
+ TaTaskNote.write = write;
248
+ /** The note `text` is, all of it; undefined for anything else. */
249
+ function parse(text) {
250
+ const match = NOTE.exec(text.trim());
251
+ if (!match) {
252
+ return undefined;
253
+ }
254
+ const attributes = {};
255
+ for (const [, name, value] of match[2].matchAll(ATTRIBUTE)) {
256
+ attributes[name] = unquote(value);
257
+ }
258
+ if (!attributes.id || attributes.title === undefined) {
259
+ return undefined;
260
+ }
261
+ const { id, title, status, was } = attributes;
262
+ return { kind: match[1], id, title, ...(status ? { status } : {}), ...(was ? { was } : {}), body: match[3] };
263
+ }
264
+ TaTaskNote.parse = parse;
265
+ /** A title the model gave, in the quotes of an attribute: a quote in it would end the attribute, a new line the tag. */
266
+ function quote(text) {
267
+ return text.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/\n/g, ' ');
268
+ }
269
+ function unquote(text) {
270
+ return text.replace(/&quot;/g, '"').replace(/&amp;/g, '&');
271
+ }
272
+ })(TaTaskNote || (exports.TaTaskNote = TaTaskNote = {}));
273
+ /**
274
+ * The names the vault of Ta (ta-secrets) puts in place of what it took out of a message (`$TA_SECRET_PHONE`,
275
+ * `${TA_SECRET_GITHUB_TOKEN}`): the model reads them so; a page shows each as what it stands for, not as a variable.
276
+ */
277
+ var TaSecretRef;
278
+ (function (TaSecretRef) {
279
+ /** The package of the vault: `list` of its host gives what it keeps by name, the masked hint of a personal detail, never a value. */
280
+ TaSecretRef.PACKAGE = '@celljs/ta-secrets';
281
+ const REF = /\$\{?TA_SECRET_([A-Z0-9][A-Z0-9_]*)\}?/g;
282
+ const KINDS = [
283
+ [/^PHONE(?:_\d+)?$/, 'phone'],
284
+ [/^EMAIL(?:_\d+)?$/, 'email'],
285
+ [/^ID_NUMBER(?:_\d+)?$/, 'idNumber'],
286
+ [/^BANK_CARD(?:_\d+)?$/, 'bankCard'],
287
+ ];
288
+ function has(text) {
289
+ return text.includes('TA_SECRET_') && new RegExp(REF.source).test(text);
290
+ }
291
+ TaSecretRef.has = has;
292
+ /** What a name is of: the kinds of personal details the vault takes in by itself, `secret` for the rest. */
293
+ function kind(name) {
294
+ var _a;
295
+ var _b;
296
+ return (_b = (_a = KINDS.find(([pattern]) => pattern.test(name))) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : 'secret';
297
+ }
298
+ TaSecretRef.kind = kind;
299
+ /** The text in parts, its names apart; one part of words when it has none. */
300
+ function split(text) {
301
+ if (!has(text)) {
302
+ return [{ text }];
303
+ }
304
+ const parts = [];
305
+ let at = 0;
306
+ for (const match of text.matchAll(REF)) {
307
+ if (match.index > at) {
308
+ parts.push({ text: text.slice(at, match.index) });
309
+ }
310
+ parts.push({ secret: match[1], kind: kind(match[1]) });
311
+ at = match.index + match[0].length;
312
+ }
313
+ if (at < text.length) {
314
+ parts.push({ text: text.slice(at) });
315
+ }
316
+ return parts;
317
+ }
318
+ TaSecretRef.split = split;
319
+ /** The text with each name as `label` says it, for a line that shows no more than words (a preview). */
320
+ function plain(text, label) {
321
+ return has(text) ? text.replace(REF, (_whole, name) => label(name, kind(name))) : text;
322
+ }
323
+ TaSecretRef.plain = plain;
324
+ })(TaSecretRef || (exports.TaSecretRef = TaSecretRef = {}));
325
+ //# sourceMappingURL=message-protocol.js.map
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Pages of Ta that ta serve may ask something (docs/design/ta-app-use.md 4.1): a page says which kinds of request it
3
+ * answers (TaPageServer.attach) and is asked one by TaClient.onPageAsk, on its own connection. A package of Ta asks
4
+ * the page of who asked its run (TaExtensionHost.pages), never another's: what one sees on their screen is theirs.
5
+ */
6
+ export declare const TaPageServer: unique symbol;
7
+ export declare const TA_PAGE_SERVICE = "TaPageServer";
8
+ /** How long a page may take to answer, unless the asker says otherwise. */
9
+ export declare const TA_PAGE_ASK_MS = 30000;
10
+ /** A request of ta serve itself: the user agrees on their screen to something an agent wants to do (TaPageConfirm). */
11
+ export declare const TA_PAGE_CONFIRM = "ta/confirm";
12
+ /** What a page says of itself (TaPageServer.attach), again as it changes. */
13
+ export interface TaPageInfo {
14
+ /** The requests it answers: `<package>/<kind>` of a web extension, `ta/<kind>` of the page itself. */
15
+ kinds: string[];
16
+ /** A phone, a tablet or a computer, as the page lays itself out. */
17
+ device: 'phone' | 'tablet' | 'computer';
18
+ /** The window of Ta Desktop: a page kept while its window is closed. */
19
+ desktop?: boolean;
20
+ /** It is in front of the user now. */
21
+ visible?: boolean;
22
+ /** The user touched, clicked or typed in it just now (a page tells it at most every few seconds). */
23
+ active?: boolean;
24
+ }
25
+ export interface TaPageServer {
26
+ attach(info: TaPageInfo): Promise<void>;
27
+ }
28
+ /** What the user is asked to agree to (TA_PAGE_CONFIRM): the answer is a boolean. */
29
+ export interface TaPageConfirm {
30
+ /** Who wants it: the name of the conversation, or of the person. */
31
+ who: string;
32
+ /** What it does, in a line of the user's language. */
33
+ what: string;
34
+ /** More, when a line is not enough. */
35
+ detail?: string;
36
+ }
37
+ /** Which page a package asks (TaHostPages.ask). */
38
+ export interface TaPageAskOptions {
39
+ /** The run that asks: the page of who asked it, the owner's for a run nobody asked. */
40
+ sessionFile?: string;
41
+ /** Or this one's page (a page that taps something). */
42
+ principal?: string;
43
+ /** How long to wait for the answer; TA_PAGE_ASK_MS without. */
44
+ timeoutMs?: number;
45
+ }
46
+ /** The pages of Ta, for the server side of a package (TaExtensionHost.pages). */
47
+ export interface TaHostPages {
48
+ /**
49
+ * Asks a page of this package (`pi.ui.answer(kind, …)` of its web extension) and resolves to its answer: the page of
50
+ * that person in front of them, else the one they touched last, else the window of Ta Desktop. Rejects when they have
51
+ * no page open that answers it, or it does not answer in time.
52
+ */
53
+ ask(kind: string, payload: unknown, options?: TaPageAskOptions): Promise<unknown>;
54
+ /** Whether that person has a page open that answers it. */
55
+ has(kind: string, options?: TaPageAskOptions): boolean;
56
+ }
57
+ //# sourceMappingURL=page-protocol.d.ts.map
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TA_PAGE_CONFIRM = exports.TA_PAGE_ASK_MS = exports.TA_PAGE_SERVICE = exports.TaPageServer = void 0;
4
+ /**
5
+ * Pages of Ta that ta serve may ask something (docs/design/ta-app-use.md 4.1): a page says which kinds of request it
6
+ * answers (TaPageServer.attach) and is asked one by TaClient.onPageAsk, on its own connection. A package of Ta asks
7
+ * the page of who asked its run (TaExtensionHost.pages), never another's: what one sees on their screen is theirs.
8
+ */
9
+ exports.TaPageServer = Symbol('TaPageServer');
10
+ exports.TA_PAGE_SERVICE = 'TaPageServer';
11
+ /** How long a page may take to answer, unless the asker says otherwise. */
12
+ exports.TA_PAGE_ASK_MS = 30000;
13
+ /** A request of ta serve itself: the user agrees on their screen to something an agent wants to do (TaPageConfirm). */
14
+ exports.TA_PAGE_CONFIRM = 'ta/confirm';
15
+ //# sourceMappingURL=page-protocol.js.map
@@ -0,0 +1,25 @@
1
+ /**
2
+ * A path of one computer as it is on another (docs/design/ta-sync.md 8.4): a move from Windows to Linux or back, a
3
+ * project in another folder. A base is matched whatever its separators, and regardless of case for a path of Windows;
4
+ * what follows it takes the separators of the base it is mapped to.
5
+ */
6
+ export declare namespace TaPathMap {
7
+ /** A directory as it was, and as it is now. */
8
+ type Pair = readonly [from: string, to: string];
9
+ /** `C:\...`, `c:/...` or `\\server\share`. */
10
+ function isWindows(path: string): boolean;
11
+ /** The parts of `path` after `base`, none when it is `base`; undefined when it is not `base` nor under it. */
12
+ function rest(path: string, base: string): string[] | undefined;
13
+ function under(path: string, base: string): boolean;
14
+ /** `parts` under `base`, with its separator. */
15
+ function join(base: string, parts: readonly string[]): string;
16
+ /** The last part of a path, of either kind. */
17
+ function basename(path: string): string;
18
+ /** A path under the deepest base of `pairs` it is under, as it is there; else itself. */
19
+ function path(value: string, pairs: readonly Pair[]): string;
20
+ /** The paths in a text (a command, `dir:<path>`), each mapped as `path` maps it; a path ends at a space or a quote. */
21
+ function text(value: string, pairs: readonly Pair[]): string;
22
+ /** Every string of a value of JSON, keys too, mapped: a whole path as `path` maps it, paths in a text as `text` does. */
23
+ function json<T>(value: T, pairs: readonly Pair[]): T;
24
+ }
25
+ //# sourceMappingURL=path-map.d.ts.map