@celljs/ta-protocol 4.15.2 → 4.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/esm/common/app-protocol.d.ts +115 -0
  2. package/esm/common/app-protocol.js +199 -0
  3. package/esm/common/delegate-protocol.d.ts +30 -0
  4. package/esm/common/delegate-protocol.js +52 -0
  5. package/esm/common/deployment-protocol.d.ts +59 -0
  6. package/esm/common/deployment-protocol.js +135 -0
  7. package/esm/common/error-protocol.d.ts +42 -0
  8. package/esm/common/error-protocol.js +45 -0
  9. package/esm/common/event-protocol.d.ts +63 -0
  10. package/esm/common/event-protocol.js +2 -0
  11. package/esm/common/gateway-protocol.d.ts +54 -2
  12. package/esm/common/index.d.ts +9 -0
  13. package/esm/common/index.js +9 -0
  14. package/esm/common/location.d.ts +18 -1
  15. package/esm/common/location.js +51 -4
  16. package/esm/common/message-protocol.d.ts +95 -0
  17. package/esm/common/message-protocol.js +237 -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/remote-protocol.d.ts +12 -4
  27. package/esm/common/room-protocol.d.ts +7 -1
  28. package/esm/common/ta-extension-host.d.ts +31 -1
  29. package/esm/common/ta-extension-host.js +2 -0
  30. package/esm/common/ta-protocol.d.ts +50 -175
  31. package/esm/common/ta-protocol.js +0 -234
  32. package/esm/common/voice-protocol.d.ts +139 -0
  33. package/esm/common/voice-protocol.js +3 -0
  34. package/lib/common/app-protocol.d.ts +116 -0
  35. package/lib/common/app-protocol.js +202 -0
  36. package/lib/common/delegate-protocol.d.ts +31 -0
  37. package/lib/common/delegate-protocol.js +55 -0
  38. package/lib/common/deployment-protocol.d.ts +60 -0
  39. package/lib/common/deployment-protocol.js +139 -0
  40. package/lib/common/error-protocol.d.ts +43 -0
  41. package/lib/common/error-protocol.js +48 -0
  42. package/lib/common/event-protocol.d.ts +64 -0
  43. package/lib/common/event-protocol.js +3 -0
  44. package/lib/common/gateway-protocol.d.ts +54 -2
  45. package/lib/common/index.d.ts +9 -0
  46. package/lib/common/index.js +9 -0
  47. package/lib/common/location.d.ts +18 -1
  48. package/lib/common/location.js +51 -4
  49. package/lib/common/message-protocol.d.ts +96 -0
  50. package/lib/common/message-protocol.js +240 -0
  51. package/lib/common/page-protocol.d.ts +57 -0
  52. package/lib/common/page-protocol.js +15 -0
  53. package/lib/common/path-map.d.ts +25 -0
  54. package/lib/common/path-map.js +130 -0
  55. package/lib/common/presence-protocol.js +7 -7
  56. package/lib/common/redactor.d.ts +12 -0
  57. package/lib/common/redactor.js +49 -11
  58. package/lib/common/relay-protocol.d.ts +20 -0
  59. package/lib/common/remote-protocol.d.ts +12 -4
  60. package/lib/common/room-protocol.d.ts +7 -1
  61. package/lib/common/ta-extension-host.d.ts +31 -1
  62. package/lib/common/ta-extension-host.js +3 -1
  63. package/lib/common/ta-protocol.d.ts +50 -175
  64. package/lib/common/ta-protocol.js +1 -235
  65. package/lib/common/voice-protocol.d.ts +140 -0
  66. package/lib/common/voice-protocol.js +6 -0
  67. package/package.json +1 -1
@@ -0,0 +1,139 @@
1
+ import type { TaPackageText } from './package-protocol.js';
2
+ import type { TaRelayOption } from './relay-protocol.js';
3
+ export declare const TaVoiceServer: unique symbol;
4
+ export declare const TA_VOICE_SERVICE = "TaVoiceServer";
5
+ /** A field of the form to add a service of a type (docs/design/ta-voice.md): the same as those of relays. */
6
+ export type TaVoiceOption = TaRelayOption;
7
+ /** A type of voice service a package registered, as the page shows it to add one. */
8
+ export interface TaVoiceTypeInfo {
9
+ type: string;
10
+ title: TaPackageText;
11
+ hint?: TaPackageText;
12
+ /** The name of an icon of `pi.ui.icons`. */
13
+ icon?: string;
14
+ options: TaVoiceOption[];
15
+ /** It reads text given to it; without, Ta reads with the voice of the device and the service only listens. */
16
+ speaks: boolean;
17
+ }
18
+ /** A service of voices.json, as the page sees it: never a password or a key. */
19
+ export interface TaVoiceService {
20
+ id: string;
21
+ type: string;
22
+ name?: string;
23
+ /** Where it is, in a few words (a host). */
24
+ where?: string;
25
+ options?: Record<string, unknown>;
26
+ /** Its type is of a package that is off. */
27
+ unavailable?: boolean;
28
+ }
29
+ /** The services of calls and the one in use (TaVoiceServer.listVoices). */
30
+ export interface TaVoices {
31
+ services: TaVoiceService[];
32
+ /** The service calls use; undefined: the voice of the device. */
33
+ use?: string;
34
+ types: TaVoiceTypeInfo[];
35
+ /** voices.json in the agent directory, to edit by hand. */
36
+ file: string;
37
+ }
38
+ /** A voice opened for a call (TaVoiceServer.openVoice). */
39
+ export interface TaVoiceSession {
40
+ voiceId: string;
41
+ /** The rate of the PCM16 mono a page sends (sendVoice). */
42
+ inputRate: number;
43
+ /** The rate of the PCM16 mono of `audio` events. */
44
+ outputRate: number;
45
+ speaks: boolean;
46
+ }
47
+ /** What a voice opened by a connection tells it (TaClient.onVoiceEvent). */
48
+ export type TaVoiceEvent =
49
+ /** The user began to speak: Ta stops reading (barge-in). */
50
+ {
51
+ voiceId: string;
52
+ type: 'speech';
53
+ }
54
+ /** What the user said so far; `final` once a sentence ended. */
55
+ | {
56
+ voiceId: string;
57
+ type: 'text';
58
+ text: string;
59
+ final: boolean;
60
+ }
61
+ /** Audio of the reading `say`: base64 of PCM16 mono at `outputRate`. */
62
+ | {
63
+ voiceId: string;
64
+ type: 'audio';
65
+ say: number;
66
+ data: string;
67
+ }
68
+ /** The reading `say` has all its audio sent. */
69
+ | {
70
+ voiceId: string;
71
+ type: 'said';
72
+ say: number;
73
+ }
74
+ /** It closed, by itself (`error` then says why) or as asked. */
75
+ | {
76
+ voiceId: string;
77
+ type: 'closed';
78
+ error?: string;
79
+ };
80
+ /** The voices of calls for pages (docs/design/ta-voice.md). */
81
+ export interface TaVoiceServer {
82
+ listVoices(): Promise<TaVoices>;
83
+ /** Adds a service of a registered type after opening it once: a wrong key is said now. Its id. */
84
+ addVoice(type: string, options: Record<string, unknown>, name?: string): Promise<string>;
85
+ /**
86
+ * Changes a service after opening it once with what it would be: its fields (a secret left empty keeps the one
87
+ * kept) and its name; a wrong key is said now and nothing changes.
88
+ */
89
+ updateVoice(id: string, options: Record<string, unknown>, name?: string): Promise<void>;
90
+ removeVoice(id: string): Promise<void>;
91
+ /** The service calls use from now on; null for the voice of the device. */
92
+ chooseVoice(id: string | null): Promise<void>;
93
+ /** Opens the service in use for a call of this connection; it closes as the connection does. */
94
+ openVoice(options: {
95
+ language: string;
96
+ }): Promise<TaVoiceSession>;
97
+ /** PCM16 mono at `inputRate`, base64. */
98
+ sendVoice(voiceId: string, audio: string): Promise<void>;
99
+ /** Reads text: the id its audio and its `said` carry. */
100
+ sayVoice(voiceId: string, text: string): Promise<number>;
101
+ /** Stops what it reads. */
102
+ hushVoice(voiceId: string): Promise<void>;
103
+ closeVoice(voiceId: string): Promise<void>;
104
+ }
105
+ /** What a voice service tells Ta as it runs (TaVoiceType.open). */
106
+ export interface TaVoiceEngineEvents {
107
+ speech(): void;
108
+ text(text: string, final: boolean): void;
109
+ audio(pcm: Uint8Array, say: number): void;
110
+ said(say: number): void;
111
+ /** It closed by itself: the connection dropped, the service refused. */
112
+ closed(error?: string): void;
113
+ }
114
+ /** A voice service opened (TaVoiceType.open): what Ta sends it. */
115
+ export interface TaVoiceEngine {
116
+ readonly inputRate: number;
117
+ readonly outputRate: number;
118
+ /** PCM16 mono at `inputRate`. */
119
+ send(pcm: Uint8Array): void;
120
+ /** Reads text aloud, its audio told with `say`; only of a type that `speaks`. */
121
+ say?(text: string, say: number): void;
122
+ /** Stops what it reads; its audio coming late is dropped by Ta anyway. */
123
+ hush(): void;
124
+ close(): void;
125
+ }
126
+ /** A type of voice service a package adds (TaExtensionVoices.registerType): its form, and how it opens. */
127
+ export interface TaVoiceType extends Omit<TaVoiceTypeInfo, 'type'> {
128
+ /** Where it is, in a few words for the list: a host. */
129
+ where(options: Record<string, unknown>): string;
130
+ /** Connects; resolves once it is ready to hear, rejects with why it is not (a wrong key). */
131
+ open(options: Record<string, unknown>, call: {
132
+ language: string;
133
+ }, events: TaVoiceEngineEvents): Promise<TaVoiceEngine>;
134
+ }
135
+ /** voices.json for the server side of packages (TaExtensionHost.voices). */
136
+ export interface TaExtensionVoices {
137
+ /** A type of service: `"type": "<type>"` in voices.json and a form in Settings. Gone with what it returns, or when the package stops. */
138
+ registerType(type: string, definition: TaVoiceType): () => void;
139
+ }
@@ -0,0 +1,3 @@
1
+ export const TaVoiceServer = Symbol('TaVoiceServer');
2
+ export const TA_VOICE_SERVICE = 'TaVoiceServer';
3
+ //# sourceMappingURL=voice-protocol.js.map
@@ -0,0 +1,116 @@
1
+ import type { TaLanguage } from './language';
2
+ /**
3
+ * What an action of the catalog of Ta risks (docs/design/ta-app-use.md 7): `read` only looks, `act` changes what can
4
+ * be changed back (a setting, a pin), `danger` what cannot or should not without the user (remove, publish, grant):
5
+ * that one waits for a confirmation on the user's screen, which is not there yet, so the catalog refuses it.
6
+ */
7
+ export type TaAppRisk = 'read' | 'act' | 'danger';
8
+ /** An action of the catalog, as the model and the pages read it. */
9
+ export interface TaAppCommandInfo {
10
+ /** `<area>.<verb>`: `settings.set`. */
11
+ id: string;
12
+ /** For the user, in the notice of what Ta did. */
13
+ title: Readonly<Record<TaLanguage, string>>;
14
+ /** For the model, in English: what it does, when to use it, what it answers. */
15
+ description: string;
16
+ /** A JSON schema of an object; none: it takes nothing. */
17
+ input?: Record<string, unknown>;
18
+ risk: TaAppRisk;
19
+ /** What it needs of who asked the run, an action of TA_ACTIONS or one a package declares. */
20
+ action: string;
21
+ /** The package that added it; none for those of Ta itself. */
22
+ owner?: string;
23
+ }
24
+ /** What an action did. */
25
+ export interface TaAppCommandResult {
26
+ /** For the model, in English, short. */
27
+ text: string;
28
+ /** What it read or changed, as JSON. */
29
+ data?: unknown;
30
+ /** For the user, in their language, a few words of what Ta did (`修改了设置`): the head of the notice; none for no notice. */
31
+ notice?: string;
32
+ /** For the user, in their language: what changed, a row each under the head of the notice. */
33
+ changes?: TaAppChange[];
34
+ /** What changes it back: an action and its input. */
35
+ undo?: {
36
+ command: string;
37
+ input: Record<string, unknown>;
38
+ };
39
+ }
40
+ /** One thing an action changed, as the user reads it: `通话字幕 关 → 开`, or a name alone (`登录修复`). */
41
+ export interface TaAppChange {
42
+ label?: string;
43
+ before?: string;
44
+ after: string;
45
+ }
46
+ /** Who an action runs for. */
47
+ export interface TaAppCommandContext {
48
+ /** TA_OWNER, or one let in (ta-team). */
49
+ principal: string;
50
+ /** That of the pages (TaLanguageUtil.server). */
51
+ language: TaLanguage;
52
+ /** The conversation whose run asked for it. */
53
+ sessionFile?: string;
54
+ }
55
+ /** An action of the catalog and what runs it. */
56
+ export interface TaAppCommand extends Omit<TaAppCommandInfo, 'owner'> {
57
+ run(input: Record<string, unknown>, context: TaAppCommandContext): Promise<TaAppCommandResult>;
58
+ }
59
+ /** Who asks for an action: the run of a conversation (each who asked it), or one principal (a tap on a page). */
60
+ export interface TaAppRunOptions {
61
+ sessionFile?: string;
62
+ principal?: string;
63
+ }
64
+ /**
65
+ * The catalog of what can be done to Ta without its pages (docs/design/ta-app-use.md 2): change a setting, pin a
66
+ * conversation, turn an extension off. The buttons of the pages change the same data, so a page shows at once
67
+ * what an action did, and an agent does what the user can without moving a cursor.
68
+ */
69
+ export interface TaHostCommands {
70
+ list(): TaAppCommandInfo[];
71
+ /**
72
+ * Runs an action for who asked (TaAppRunOptions): each must be let to do its `action`. Throws with what is wrong:
73
+ * no such action, not let to, an input it does not take, a `danger` one the user did not agree to on their screen.
74
+ */
75
+ run(id: string, input?: Record<string, unknown>, options?: TaAppRunOptions): Promise<TaAppCommandResult>;
76
+ /** Adds an action, gone with the function returned or when the package stops. */
77
+ register(command: TaAppCommand): () => void;
78
+ }
79
+ /** The tools of ta-app-use, the catalog and the screen: a call's front has them too. */
80
+ export declare const TA_APP_TOOLS: readonly ['app_commands', 'app_run', 'app_look', 'app_go', 'app_do'];
81
+ /** Where the web client keeps its settings (TaState `user`): in the data of packages, under this name and key. */
82
+ export declare const TA_WEB_SETTINGS_DATA: {
83
+ readonly name: '@celljs/ta-web';
84
+ readonly key: 'settings';
85
+ };
86
+ /** Where the web client keeps the conversations pinned to the top of its lists: their session files, and keys of folders. */
87
+ export declare const TA_CHAT_PINNED: {
88
+ readonly name: '@celljs/ta-web';
89
+ readonly key: 'chat.pinned';
90
+ };
91
+ /** A setting of the web client an action may change (settings.set), as the settings page offers it. */
92
+ export interface TaWebSettingSpec {
93
+ key: string;
94
+ type: 'boolean' | 'enum' | 'number' | 'string' | 'model';
95
+ /** The values it may be, for `enum` and `number`. */
96
+ values?: readonly (string | number)[];
97
+ default: boolean | number | string;
98
+ /** For the model, in English. */
99
+ what: string;
100
+ title: Readonly<Record<TaLanguage, string>>;
101
+ /** What the user calls its values, by value, where the value itself is a word of the code. */
102
+ shown?: Readonly<Record<string, Readonly<Record<TaLanguage, string>>>>;
103
+ }
104
+ /**
105
+ * The settings of the web client (Settings of ta-web) an agent may change: those the settings page shows with a
106
+ * switch or a choice. Not `trustedDomains` (links open without asking), nor `navigation` and `builtinsOff`, which
107
+ * have pages and actions of their own. The tests of ta-web hold these to its defaults and choices.
108
+ */
109
+ export declare const TA_WEB_SETTINGS: readonly TaWebSettingSpec[];
110
+ export declare namespace TaAppUtil {
111
+ /** `value` for the setting, or why not: a value of its type and among its values. */
112
+ function check(spec: TaWebSettingSpec, value: unknown): string | undefined;
113
+ /** A value as the user reads it: on and off for a switch, the words of a choice (TaWebSettingSpec.shown). */
114
+ function shown(value: unknown, language: TaLanguage, spec?: TaWebSettingSpec): string;
115
+ }
116
+ //# sourceMappingURL=app-protocol.d.ts.map
@@ -0,0 +1,202 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TaAppUtil = exports.TA_WEB_SETTINGS = exports.TA_CHAT_PINNED = exports.TA_WEB_SETTINGS_DATA = exports.TA_APP_TOOLS = void 0;
4
+ const delegate_protocol_1 = require("./delegate-protocol");
5
+ const language_1 = require("./language");
6
+ /** The tools of ta-app-use, the catalog and the screen: a call's front has them too. */
7
+ exports.TA_APP_TOOLS = ['app_commands', 'app_run', 'app_look', 'app_go', 'app_do'];
8
+ /** Where the web client keeps its settings (TaState `user`): in the data of packages, under this name and key. */
9
+ exports.TA_WEB_SETTINGS_DATA = { name: '@celljs/ta-web', key: 'settings' };
10
+ /** Where the web client keeps the conversations pinned to the top of its lists: their session files, and keys of folders. */
11
+ exports.TA_CHAT_PINNED = { name: '@celljs/ta-web', key: 'chat.pinned' };
12
+ const FONT_SIZES = ['small', 'standard', 'large', 'xlarge'];
13
+ const words = (en, zh, tw, ja) => ({ 'en-US': en, 'zh-CN': zh, 'zh-TW': tw, 'ja-JP': ja });
14
+ const SYSTEM = words('as the system', '跟随系统', '跟隨系統', 'システムに合わせる');
15
+ const FONT_SHOWN = {
16
+ small: words('small', '小', '小', '小'),
17
+ standard: words('standard', '标准', '標準', '標準'),
18
+ large: words('large', '大', '大', '大'),
19
+ xlarge: words('extra large', '特大', '特大', '特大'),
20
+ };
21
+ /**
22
+ * The settings of the web client (Settings of ta-web) an agent may change: those the settings page shows with a
23
+ * switch or a choice. Not `trustedDomains` (links open without asking), nor `navigation` and `builtinsOff`, which
24
+ * have pages and actions of their own. The tests of ta-web hold these to its defaults and choices.
25
+ */
26
+ exports.TA_WEB_SETTINGS = [
27
+ {
28
+ key: 'theme',
29
+ type: 'enum',
30
+ values: ['system', 'light', 'dark'],
31
+ default: 'system',
32
+ what: 'Light or dark look; system follows the device.',
33
+ title: words('Theme', '外观', '外觀', '外観'),
34
+ shown: { system: SYSTEM, light: words('light', '浅色', '淺色', 'ライト'), dark: words('dark', '深色', '深色', 'ダーク') },
35
+ },
36
+ {
37
+ key: 'language',
38
+ type: 'enum',
39
+ values: ['system', ...language_1.TaLanguageUtil.ALL],
40
+ default: 'system',
41
+ what: "The language of Ta's pages and of what Ta says; system follows the device.",
42
+ title: words('Language', '语言', '語言', '言語'),
43
+ shown: {
44
+ system: SYSTEM,
45
+ ...Object.fromEntries(language_1.TaLanguageUtil.ALL.map(language => [
46
+ language,
47
+ words(language_1.TaLanguageUtil.NAMES[language], language_1.TaLanguageUtil.NAMES[language], language_1.TaLanguageUtil.NAMES[language], language_1.TaLanguageUtil.NAMES[language]),
48
+ ])),
49
+ },
50
+ },
51
+ {
52
+ key: 'fontSize',
53
+ type: 'enum',
54
+ values: FONT_SIZES,
55
+ default: 'standard',
56
+ what: 'The size of the text of the whole page.',
57
+ title: words('Text size', '字体大小', '字型大小', '文字サイズ'),
58
+ shown: FONT_SHOWN,
59
+ },
60
+ {
61
+ key: 'chatFontSize',
62
+ type: 'enum',
63
+ values: FONT_SIZES,
64
+ default: 'standard',
65
+ what: 'The size of the text of conversations, on top of fontSize.',
66
+ title: words('Text size of conversations', '对话字体大小', '對話字型大小', '会話の文字サイズ'),
67
+ shown: FONT_SHOWN,
68
+ },
69
+ {
70
+ key: 'speak',
71
+ type: 'boolean',
72
+ default: false,
73
+ what: 'Read every reply aloud.',
74
+ title: words('Read replies aloud', '朗读回复', '朗讀回覆', '返信を読み上げ'),
75
+ },
76
+ {
77
+ key: 'speakTalk',
78
+ type: 'boolean',
79
+ default: false,
80
+ what: 'Read the reply aloud when the user spoke to the double by voice.',
81
+ title: words('Read aloud what was asked by voice', '语音提问时朗读回复', '語音提問時朗讀回覆', '音声で聞いたら読み上げ'),
82
+ },
83
+ {
84
+ key: 'callCaptions',
85
+ type: 'boolean',
86
+ default: false,
87
+ what: 'Show captions in a call: what the user says and what Ta reads.',
88
+ title: words('Call captions', '通话字幕', '通話字幕', '通話の字幕'),
89
+ },
90
+ {
91
+ key: 'voice',
92
+ type: 'string',
93
+ default: '',
94
+ what: "The voice replies are read with (a voiceURI of the device's voices); empty for the most natural one.",
95
+ title: words('Voice', '朗读声音', '朗讀聲音', '読み上げの声'),
96
+ },
97
+ {
98
+ key: 'confirmTasks',
99
+ type: 'boolean',
100
+ default: false,
101
+ what: 'The double asks before it hands out work.',
102
+ title: words('Ask before handing out work', '派任务前先问我', '派任務前先問我', '作業を割り当てる前に確認'),
103
+ },
104
+ {
105
+ key: 'maxTasks',
106
+ type: 'number',
107
+ values: [0, 2, 4, 8],
108
+ default: 0,
109
+ what: "How many of the double's tasks run at once; 0 for as many as it starts.",
110
+ title: words('Tasks at once', '同时运行的任务', '同時執行的任務', '同時に実行するタスク'),
111
+ },
112
+ {
113
+ key: 'delegate',
114
+ type: 'enum',
115
+ values: delegate_protocol_1.TaDelegateUtil.LEVELS,
116
+ default: delegate_protocol_1.TaDelegateUtil.DEFAULT,
117
+ what: 'How much of the work the double hands out to tasks rather than doing it itself.',
118
+ title: words('Hand out work', '派活多少', '派活多少', '作業の割り当て'),
119
+ shown: { less: words('less', '少', '少', '少なめ'), balanced: words('balanced', '适中', '適中', 'ふつう'), more: words('more', '多', '多', '多め') },
120
+ },
121
+ {
122
+ key: 'assistantModel',
123
+ type: 'model',
124
+ default: '',
125
+ what: 'The model of the double, <provider>/<model id>; empty for the default model.',
126
+ title: words('Model of the double', '分身的模型', '分身的模型', '分身のモデル'),
127
+ },
128
+ {
129
+ key: 'taskModel',
130
+ type: 'model',
131
+ default: '',
132
+ what: 'The model of the tasks the double starts; empty for the default model.',
133
+ title: words('Model of tasks', '任务的模型', '任務的模型', 'タスクのモデル'),
134
+ },
135
+ { key: 'reduceMotion', type: 'boolean', default: false, what: 'Fewer animations.', title: words('Reduce motion', '减少动画', '減少動畫', '動きを減らす') },
136
+ {
137
+ key: 'keepAliveMinutes',
138
+ type: 'number',
139
+ values: [1, 5, 15, 30],
140
+ default: 5,
141
+ what: 'How long an extension started on open keeps running once left, in minutes.',
142
+ title: words('Keep extensions running', '扩展离开后保留', '擴充功能離開後保留', '拡張機能を保持'),
143
+ },
144
+ {
145
+ key: 'chatFoldDays',
146
+ type: 'number',
147
+ values: [3, 7, 30, 0],
148
+ default: 7,
149
+ what: 'Conversations not updated for these days fold at the end of the list; 0 for none.',
150
+ title: words('Fold old conversations', '折叠旧对话', '摺疊舊對話', '古い会話を折りたたむ'),
151
+ },
152
+ {
153
+ key: 'chatArchiveDays',
154
+ type: 'number',
155
+ values: [30, 90, 365, 0],
156
+ default: 30,
157
+ what: 'Conversations not updated for these days are archived (out of the list, found by search); 0 for none.',
158
+ title: words('Archive old conversations', '归档旧对话', '歸檔舊對話', '古い会話をアーカイブ'),
159
+ },
160
+ {
161
+ key: 'recentShots',
162
+ type: 'boolean',
163
+ default: true,
164
+ what: 'The screenshot just taken is offered above the message box, once.',
165
+ title: words('Offer recent screenshots', '提示刚截的图', '提示剛截的圖', '撮ったばかりのスクリーンショットを提案'),
166
+ },
167
+ ];
168
+ var TaAppUtil;
169
+ (function (TaAppUtil) {
170
+ /** `value` for the setting, or why not: a value of its type and among its values. */
171
+ function check(spec, value) {
172
+ var _a, _b;
173
+ switch (spec.type) {
174
+ case 'boolean':
175
+ return typeof value === 'boolean' ? undefined : 'true or false';
176
+ case 'string':
177
+ return typeof value === 'string' ? undefined : 'a string';
178
+ case 'model':
179
+ return value === '' || (typeof value === 'string' && /^[^/\s]+\/\S+$/.test(value)) ? undefined : '<provider>/<model id>, or empty';
180
+ default:
181
+ return ((_a = spec.values) === null || _a === void 0 ? void 0 : _a.includes(value)) ? undefined : `one of ${(_b = spec.values) === null || _b === void 0 ? void 0 : _b.map(one => JSON.stringify(one)).join(', ')}`;
182
+ }
183
+ }
184
+ TaAppUtil.check = check;
185
+ /** A value as the user reads it: on and off for a switch, the words of a choice (TaWebSettingSpec.shown). */
186
+ function shown(value, language, spec) {
187
+ var _a;
188
+ const named = (_a = spec === null || spec === void 0 ? void 0 : spec.shown) === null || _a === void 0 ? void 0 : _a[String(value)];
189
+ if (named) {
190
+ return language_1.TaLanguageUtil.pick(language, named);
191
+ }
192
+ if (typeof value === 'boolean') {
193
+ return language_1.TaLanguageUtil.pick(language, value ? words('on', '开', '開', 'オン') : words('off', '关', '關', 'オフ'));
194
+ }
195
+ if (value === '' || value === undefined || value === null) {
196
+ return language_1.TaLanguageUtil.pick(language, words('default', '默认', '預設', 'デフォルト'));
197
+ }
198
+ return String(value);
199
+ }
200
+ TaAppUtil.shown = shown;
201
+ })(TaAppUtil || (exports.TaAppUtil = TaAppUtil = {}));
202
+ //# sourceMappingURL=app-protocol.js.map
@@ -0,0 +1,31 @@
1
+ /**
2
+ * How much of the work the double hands out to tasks rather than doing it itself (Settings.delegate): the user's
3
+ * dial. Its role says it, and a guard of ta serve (DelegateExtension) holds it to it, by the mark of the level in
4
+ * the role: the tools that change files are off for it, and the others after a few steps of one run.
5
+ */
6
+ export type TaDelegateLevel = 'less' | 'balanced' | 'more';
7
+ export interface TaDelegateLimits {
8
+ /** Its tools that change files (edit, write) are off. */
9
+ noChanges: boolean;
10
+ /** Of its own tools (TaDelegateUtil.WORK_TOOLS), how many one run may call; undefined for as many as it likes. */
11
+ steps?: number;
12
+ }
13
+ export declare namespace TaDelegateUtil {
14
+ const LEVELS: readonly TaDelegateLevel[];
15
+ const DEFAULT: TaDelegateLevel;
16
+ /** pi's own tools, those with which a session works itself; the tools of extensions (start_task, the team's) are not. */
17
+ const WORK_TOOLS: readonly string[];
18
+ const CHANGE_TOOLS: readonly string[];
19
+ function parse(value: unknown): TaDelegateLevel;
20
+ /** In the role of the double: the guard reads which level it was opened with. */
21
+ function mark(level: TaDelegateLevel): string;
22
+ /** The level of a session's role, by its mark; undefined for a session that is not the double (a task, a chat). */
23
+ function levelOf(systemPrompt: string | undefined): TaDelegateLevel | undefined;
24
+ function limits(level: TaDelegateLevel): TaDelegateLimits;
25
+ /**
26
+ * Why a call of a tool is turned down, or undefined to let it run: `steps`, how many of its own tools the run
27
+ * called before it. What is turned down says what to do instead, for the model to read.
28
+ */
29
+ function refusal(level: TaDelegateLevel, tool: string, steps: number): string | undefined;
30
+ }
31
+ //# sourceMappingURL=delegate-protocol.d.ts.map
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TaDelegateUtil = void 0;
4
+ const ta_extension_host_1 = require("./ta-extension-host");
5
+ var TaDelegateUtil;
6
+ (function (TaDelegateUtil) {
7
+ TaDelegateUtil.LEVELS = ['less', 'balanced', 'more'];
8
+ TaDelegateUtil.DEFAULT = 'balanced';
9
+ /** pi's own tools, those with which a session works itself; the tools of extensions (start_task, the team's) are not. */
10
+ TaDelegateUtil.WORK_TOOLS = ['read', 'bash', 'powershell', 'edit', 'write', 'grep', 'find', 'ls'];
11
+ TaDelegateUtil.CHANGE_TOOLS = ['edit', 'write'];
12
+ const LIMITS = {
13
+ less: { noChanges: false },
14
+ balanced: { noChanges: true, steps: 6 },
15
+ more: { noChanges: true, steps: 2 },
16
+ };
17
+ function parse(value) {
18
+ return TaDelegateUtil.LEVELS.includes(value) ? value : TaDelegateUtil.DEFAULT;
19
+ }
20
+ TaDelegateUtil.parse = parse;
21
+ /** In the role of the double: the guard reads which level it was opened with. */
22
+ function mark(level) {
23
+ return `(delegate=${level})`;
24
+ }
25
+ TaDelegateUtil.mark = mark;
26
+ /** The level of a session's role, by its mark; undefined for a session that is not the double (a task, a chat). */
27
+ function levelOf(systemPrompt) {
28
+ const role = ta_extension_host_1.TaHostUtil.role(systemPrompt);
29
+ return TaDelegateUtil.LEVELS.find(level => role.includes(mark(level)));
30
+ }
31
+ TaDelegateUtil.levelOf = levelOf;
32
+ function limits(level) {
33
+ return LIMITS[level];
34
+ }
35
+ TaDelegateUtil.limits = limits;
36
+ /**
37
+ * Why a call of a tool is turned down, or undefined to let it run: `steps`, how many of its own tools the run
38
+ * called before it. What is turned down says what to do instead, for the model to read.
39
+ */
40
+ function refusal(level, tool, steps) {
41
+ if (!TaDelegateUtil.WORK_TOOLS.includes(tool)) {
42
+ return undefined;
43
+ }
44
+ const limit = LIMITS[level];
45
+ if (limit.noChanges && TaDelegateUtil.CHANGE_TOOLS.includes(tool)) {
46
+ return 'You do not change files yourself: hand this to a task with start_task, with instructions complete enough to do it. The user set how much you hand out in the settings of the double.';
47
+ }
48
+ if (limit.steps !== undefined && steps >= limit.steps) {
49
+ return 'You have looked enough for this: hand the work to a task with start_task now, with what you found in its instructions, and tell the user what you started.';
50
+ }
51
+ return undefined;
52
+ }
53
+ TaDelegateUtil.refusal = refusal;
54
+ })(TaDelegateUtil || (exports.TaDelegateUtil = TaDelegateUtil = {}));
55
+ //# sourceMappingURL=delegate-protocol.js.map
@@ -0,0 +1,60 @@
1
+ /**
2
+ * A deployment of Ta: its gateway, its relay, or both, for one group of people (docs/design/ta-deploy.md). Inside and
3
+ * outside a company each have one; nothing passes between them.
4
+ */
5
+ /** What every service of a deployment answers, to anyone (it holds nothing secret). */
6
+ export declare const TA_WELL_KNOWN_PATH = "/.well-known/ta";
7
+ /** What a deployment says of itself at TA_WELL_KNOWN_PATH: where its services are. */
8
+ export interface TaDeployment {
9
+ v: 1;
10
+ /** What its people call it: TA_DEPLOYMENT_NAME. */
11
+ name?: string;
12
+ /** Where its gateway is (cloud-hosted Ta), and its relay (devices, rooms, links). */
13
+ gateway?: string;
14
+ relay?: string;
15
+ version?: string;
16
+ }
17
+ /**
18
+ * What a build of Ta comes with (`distribution.json` beside its `dist/`, docs/design/ta-deploy.md 3): the addresses of the
19
+ * deployment it is for, as defaults of the environment; and where its desktop app updates from.
20
+ */
21
+ export interface TaDistribution {
22
+ name?: string;
23
+ relay?: string;
24
+ gateway?: string;
25
+ updates?: {
26
+ base?: string;
27
+ key?: string;
28
+ };
29
+ }
30
+ /** The environment a deployment is told by: the variables a distribution gives defaults of. */
31
+ export interface TaDeploymentEnv {
32
+ TA_DEPLOYMENT_NAME?: string;
33
+ TA_GATEWAY_URL?: string;
34
+ TA_RELAY_URL?: string;
35
+ }
36
+ export declare class TaDeploymentError extends Error {
37
+ }
38
+ export declare namespace TaDeploymentUtil {
39
+ const DISTRIBUTION_FILE = "distribution.json";
40
+ /** An address of a service as it is kept: http(s), its origin and path, no trailing slash; undefined for what is not one. */
41
+ function url(value: unknown): string | undefined;
42
+ /**
43
+ * What a service answers: `own` its own part (its address, TA_PUBLIC_URL or the origin it was reached at), the rest
44
+ * from the environment.
45
+ */
46
+ function describe(env: TaDeploymentEnv, own: {
47
+ gateway?: string;
48
+ relay?: string;
49
+ }, version?: string): TaDeployment;
50
+ const HEADERS: Readonly<Record<string, string>>;
51
+ /** What a deployment said, kept to what is known; undefined for what is not one. */
52
+ function parse(value: unknown): TaDeployment | undefined;
53
+ /** Asks a service of a deployment what it is part of: rejects with what went wrong. */
54
+ function discover(address: string, timeoutMs?: number): Promise<TaDeployment>;
55
+ /** A distribution as its file holds it: throws on what it cannot be, for a build not to ship a wrong one. */
56
+ function distribution(value: unknown): TaDistribution;
57
+ /** The environment a distribution gives: its defaults, for what `env` does not set already. */
58
+ function apply(distribution: TaDistribution, env: Record<string, string | undefined>): void;
59
+ }
60
+ //# sourceMappingURL=deployment-protocol.d.ts.map