@celljs/ta-host 4.16.0 → 4.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/node/app-commands.d.ts +111 -0
- package/esm/node/app-commands.js +629 -0
- package/esm/node/delegate-extension.d.ts +11 -0
- package/esm/node/delegate-extension.js +33 -0
- package/esm/node/directory-relocator.d.ts +49 -0
- package/esm/node/directory-relocator.js +267 -0
- package/esm/node/extension-providers.d.ts +16 -1
- package/esm/node/extension-providers.js +23 -3
- package/esm/node/index.d.ts +6 -0
- package/esm/node/index.js +6 -0
- package/esm/node/keep-awake.d.ts +5 -1
- package/esm/node/keep-awake.js +18 -2
- package/esm/node/message-page.d.ts +6 -1
- package/esm/node/message-page.js +50 -2
- package/esm/node/package-hosts.d.ts +6 -0
- package/esm/node/package-hosts.js +35 -0
- package/esm/node/package-webhooks.d.ts +26 -0
- package/esm/node/package-webhooks.js +101 -0
- package/esm/node/page-book.d.ts +48 -0
- package/esm/node/page-book.js +117 -0
- package/esm/node/relay-bridge.d.ts +2 -0
- package/esm/node/relay-bridge.js +35 -1
- package/esm/node/rooms-bridge.d.ts +3 -0
- package/esm/node/rooms-bridge.js +4 -0
- package/esm/node/session-info-util.d.ts +3 -1
- package/esm/node/session-info-util.js +32 -6
- package/esm/node/ta-server-impl.d.ts +5 -1
- package/esm/node/ta-server-impl.js +22 -0
- package/esm/node/ta-session-factory.d.ts +13 -1
- package/esm/node/ta-session-factory.js +39 -4
- package/esm/node/ta-session.d.ts +2 -0
- package/esm/node/ta-session.js +1 -0
- package/esm/node/team/team-calls.js +22 -0
- package/esm/node/voice-bridge.d.ts +68 -0
- package/esm/node/voice-bridge.js +273 -0
- package/esm/node/voices-file.d.ts +33 -0
- package/esm/node/voices-file.js +89 -0
- package/lib/node/app-commands.d.ts +112 -0
- package/lib/node/app-commands.js +633 -0
- package/lib/node/delegate-extension.d.ts +12 -0
- package/lib/node/delegate-extension.js +37 -0
- package/lib/node/directory-relocator.d.ts +50 -0
- package/lib/node/directory-relocator.js +270 -0
- package/lib/node/extension-providers.d.ts +16 -1
- package/lib/node/extension-providers.js +23 -3
- package/lib/node/index.d.ts +6 -0
- package/lib/node/index.js +6 -0
- package/lib/node/keep-awake.d.ts +5 -1
- package/lib/node/keep-awake.js +18 -2
- package/lib/node/message-page.d.ts +6 -1
- package/lib/node/message-page.js +50 -2
- package/lib/node/package-hosts.d.ts +6 -0
- package/lib/node/package-hosts.js +35 -0
- package/lib/node/package-webhooks.d.ts +27 -0
- package/lib/node/package-webhooks.js +104 -0
- package/lib/node/page-book.d.ts +49 -0
- package/lib/node/page-book.js +120 -0
- package/lib/node/relay-bridge.d.ts +2 -0
- package/lib/node/relay-bridge.js +34 -0
- package/lib/node/rooms-bridge.d.ts +3 -0
- package/lib/node/rooms-bridge.js +4 -0
- package/lib/node/session-info-util.d.ts +3 -1
- package/lib/node/session-info-util.js +31 -5
- package/lib/node/ta-server-impl.d.ts +5 -1
- package/lib/node/ta-server-impl.js +22 -0
- package/lib/node/ta-session-factory.d.ts +13 -1
- package/lib/node/ta-session-factory.js +38 -3
- package/lib/node/ta-session.d.ts +2 -0
- package/lib/node/ta-session.js +1 -0
- package/lib/node/team/team-calls.js +22 -0
- package/lib/node/voice-bridge.d.ts +69 -0
- package/lib/node/voice-bridge.js +274 -0
- package/lib/node/voices-file.d.ts +34 -0
- package/lib/node/voices-file.js +93 -0
- package/package.json +10 -10
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { chmodSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
/** voices.json of the agent directory (docs/design/ta-voice.md 3): its keys stay there, written 0600. */
|
|
4
|
+
export class VoicesFile {
|
|
5
|
+
constructor(agentDir) {
|
|
6
|
+
this.file = join(agentDir, 'voices.json');
|
|
7
|
+
}
|
|
8
|
+
read() {
|
|
9
|
+
let text;
|
|
10
|
+
try {
|
|
11
|
+
text = readFileSync(this.file, 'utf8');
|
|
12
|
+
}
|
|
13
|
+
catch (_a) {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
const config = JSON.parse(text);
|
|
17
|
+
const services = Array.isArray(config === null || config === void 0 ? void 0 : config.services)
|
|
18
|
+
? config.services.filter(service => service && typeof service.id === 'string' && typeof service.type === 'string' && typeof service.options === 'object')
|
|
19
|
+
: [];
|
|
20
|
+
return { services, ...(typeof (config === null || config === void 0 ? void 0 : config.use) === 'string' ? { use: config.use } : {}) };
|
|
21
|
+
}
|
|
22
|
+
/** What reads, or nothing with why it does not parse. */
|
|
23
|
+
safeRead() {
|
|
24
|
+
try {
|
|
25
|
+
return { config: this.read() };
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
return { config: {}, error: error instanceof Error ? error.message : String(error) };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
services() {
|
|
32
|
+
var _a;
|
|
33
|
+
return (_a = this.safeRead().config.services) !== null && _a !== void 0 ? _a : [];
|
|
34
|
+
}
|
|
35
|
+
/** The service in use, if it is still there. */
|
|
36
|
+
inUse() {
|
|
37
|
+
const { services = [], use } = this.safeRead().config;
|
|
38
|
+
return use ? services.find(service => service.id === use) : undefined;
|
|
39
|
+
}
|
|
40
|
+
/** Its id: the type with a number when there is one of it already. */
|
|
41
|
+
add(type, options, name) {
|
|
42
|
+
var _a;
|
|
43
|
+
const config = this.read();
|
|
44
|
+
const services = (_a = config.services) !== null && _a !== void 0 ? _a : [];
|
|
45
|
+
const stem = type.replace(/[^a-z0-9-]/gi, '').toLowerCase() || 'voice';
|
|
46
|
+
let id = stem;
|
|
47
|
+
for (let n = 2; services.some(service => service.id === id); n++) {
|
|
48
|
+
id = `${stem}-${n}`;
|
|
49
|
+
}
|
|
50
|
+
services.push({ id, type, ...(name ? { name } : {}), options });
|
|
51
|
+
this.write({ ...config, services });
|
|
52
|
+
return id;
|
|
53
|
+
}
|
|
54
|
+
/** Its options and name, the rest as it was; throws for one that is not there. */
|
|
55
|
+
update(id, options, name) {
|
|
56
|
+
var _a;
|
|
57
|
+
const config = this.read();
|
|
58
|
+
const services = (_a = config.services) !== null && _a !== void 0 ? _a : [];
|
|
59
|
+
const at = services.findIndex(service => service.id === id);
|
|
60
|
+
if (at < 0) {
|
|
61
|
+
throw new Error(`There is no voice service ${id} in voices.json.`);
|
|
62
|
+
}
|
|
63
|
+
const { name: _, ...kept } = services[at];
|
|
64
|
+
services[at] = { ...kept, ...(name ? { name } : {}), options };
|
|
65
|
+
this.write({ ...config, services });
|
|
66
|
+
}
|
|
67
|
+
remove(id) {
|
|
68
|
+
var _a;
|
|
69
|
+
const config = this.read();
|
|
70
|
+
const services = ((_a = config.services) !== null && _a !== void 0 ? _a : []).filter(service => service.id !== id);
|
|
71
|
+
this.write({ services, ...(config.use && config.use !== id ? { use: config.use } : {}) });
|
|
72
|
+
}
|
|
73
|
+
use(id) {
|
|
74
|
+
var _a, _b;
|
|
75
|
+
const config = this.read();
|
|
76
|
+
if (id !== undefined && !((_a = config.services) !== null && _a !== void 0 ? _a : []).some(service => service.id === id)) {
|
|
77
|
+
throw new Error(`There is no voice service ${id} in voices.json.`);
|
|
78
|
+
}
|
|
79
|
+
this.write({ services: (_b = config.services) !== null && _b !== void 0 ? _b : [], ...(id ? { use: id } : {}) });
|
|
80
|
+
}
|
|
81
|
+
write(config) {
|
|
82
|
+
mkdirSync(dirname(this.file), { recursive: true });
|
|
83
|
+
const temporary = `${this.file}.${process.pid}.tmp`;
|
|
84
|
+
writeFileSync(temporary, `${JSON.stringify(config, null, 2)}\n`, { mode: 0o600 });
|
|
85
|
+
chmodSync(temporary, 0o600);
|
|
86
|
+
renameSync(temporary, this.file);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=voices-file.js.map
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { ExecEnvironmentFactory } from '@celljs/ta-exec';
|
|
2
|
+
import { type RpcExtensionUIRequest, type RpcExtensionUIResponse, type TaAppCommand, type TaAppCommandInfo, type TaAppCommandResult, type TaAppRunOptions, type TaHostCommands, type TaLanguage, type TaPackageInfo, TaPackageServer, type TaSavedSessionInfo, TaServer, type TaSessionInfo, type TaSettingsSnapshot } from '@celljs/ta-protocol';
|
|
3
|
+
import { TaSessionRegistry } from './host-protocol';
|
|
4
|
+
import { TaPageBook } from './page-book';
|
|
5
|
+
import { TaSettingsStore } from './settings-store';
|
|
6
|
+
import { TaHostTeamProvider } from './team/team-protocol';
|
|
7
|
+
export declare const TaAppCommands: unique symbol;
|
|
8
|
+
/** The catalog of actions (TaHostCommands), and the actions of a package, gone when it stops. */
|
|
9
|
+
export interface TaAppCommands extends TaHostCommands {
|
|
10
|
+
/** Adds an action of a package. */
|
|
11
|
+
registerOf(owner: string, command: TaAppCommand): () => void;
|
|
12
|
+
/** The package stopped: its actions go. */
|
|
13
|
+
dropOwner(owner: string): void;
|
|
14
|
+
}
|
|
15
|
+
/** What the catalog asks of who runs an action (TaHostTeam). */
|
|
16
|
+
export interface AppCommandAccess {
|
|
17
|
+
can(principal: string, action: string): boolean;
|
|
18
|
+
actorsOf(sessionFile: string): string[];
|
|
19
|
+
current(): string;
|
|
20
|
+
/**
|
|
21
|
+
* Whether `principal` agrees, on a screen of theirs, to a danger action asked for by the run of `sessionFile`;
|
|
22
|
+
* undefined when they have no page open to ask on.
|
|
23
|
+
*/
|
|
24
|
+
confirm?(principal: string, what: string, sessionFile?: string): Promise<boolean | undefined>;
|
|
25
|
+
}
|
|
26
|
+
type Json = Record<string, unknown>;
|
|
27
|
+
/** The actions by id, and who may run them: pure, for TaAppCommandsImpl and its tests. */
|
|
28
|
+
export declare class AppCommandRegistry implements TaHostCommands {
|
|
29
|
+
protected readonly access: AppCommandAccess;
|
|
30
|
+
protected readonly language: () => TaLanguage;
|
|
31
|
+
protected readonly commands: Map<string, {
|
|
32
|
+
command: TaAppCommand;
|
|
33
|
+
owner?: string;
|
|
34
|
+
}>;
|
|
35
|
+
constructor(access: AppCommandAccess, language?: () => TaLanguage);
|
|
36
|
+
list(): TaAppCommandInfo[];
|
|
37
|
+
register(command: TaAppCommand, owner?: string): () => void;
|
|
38
|
+
dropOwner(owner: string): void;
|
|
39
|
+
run(id: string, input?: Json, options?: TaAppRunOptions): Promise<TaAppCommandResult>;
|
|
40
|
+
/** Each who asked: the principal given, or those of the run of the conversation; the owner for a run nobody asked. */
|
|
41
|
+
protected principals(options: TaAppRunOptions): string[];
|
|
42
|
+
}
|
|
43
|
+
/** What the actions of Ta itself read and change: the services the pages call. */
|
|
44
|
+
export interface CoreAppDeps {
|
|
45
|
+
getData(name: string, key: string): Promise<unknown>;
|
|
46
|
+
setData(name: string, key: string, value: unknown): Promise<void>;
|
|
47
|
+
agentSettings(): Promise<TaSettingsSnapshot>;
|
|
48
|
+
updateAgentSettings(changes: Json): Promise<void>;
|
|
49
|
+
sessions(): Promise<TaSessionInfo[]>;
|
|
50
|
+
saved(): Promise<TaSavedSessionInfo[]>;
|
|
51
|
+
abort(sessionId: string): Promise<void>;
|
|
52
|
+
packages(): Promise<TaPackageInfo[]>;
|
|
53
|
+
setPackageEnabled(name: string, enabled: boolean): Promise<void>;
|
|
54
|
+
/** The dialogs an open session waits on the user's answer of. */
|
|
55
|
+
pendingUi(sessionId: string): RpcExtensionUIRequest[];
|
|
56
|
+
respondUi(sessionId: string, response: RpcExtensionUIResponse): Promise<boolean>;
|
|
57
|
+
/** Says `text` in the conversation of a session file as the user, opening it if it is not. */
|
|
58
|
+
send(file: string, cwd: string, text: string): Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
/** What waits for the user, as asks.list gives it: a dialog of an extension, or a question the agent asked. */
|
|
61
|
+
export interface AppAsk {
|
|
62
|
+
file: string;
|
|
63
|
+
name: string;
|
|
64
|
+
kind: 'dialog' | 'question';
|
|
65
|
+
question: string;
|
|
66
|
+
/** How a dialog is answered: one of `choices` (select, confirm), or any text (input, editor). */
|
|
67
|
+
method?: 'select' | 'confirm' | 'input' | 'editor';
|
|
68
|
+
choices?: string[];
|
|
69
|
+
}
|
|
70
|
+
/** One conversation, as chats.list gives it. */
|
|
71
|
+
export interface AppChat {
|
|
72
|
+
file: string;
|
|
73
|
+
name: string;
|
|
74
|
+
cwd: string;
|
|
75
|
+
state: 'working' | 'waiting' | 'asking' | 'idle';
|
|
76
|
+
pinned: boolean;
|
|
77
|
+
updatedAt: string;
|
|
78
|
+
group?: string;
|
|
79
|
+
last?: string;
|
|
80
|
+
}
|
|
81
|
+
/** The actions of Ta itself (docs/design/ta-app-use.md 2.5). */
|
|
82
|
+
export declare namespace CoreAppCommands {
|
|
83
|
+
function all(deps: CoreAppDeps): TaAppCommand[];
|
|
84
|
+
/** What the user said, as the answer of a dialog: one of its choices, by its words or its number; yes or no. */
|
|
85
|
+
function answerOf(dialog: {
|
|
86
|
+
method: string;
|
|
87
|
+
options?: string[];
|
|
88
|
+
}, answer: unknown): {
|
|
89
|
+
value: string;
|
|
90
|
+
} | {
|
|
91
|
+
confirmed: boolean;
|
|
92
|
+
} | undefined;
|
|
93
|
+
}
|
|
94
|
+
/** The catalog of ta serve, with the actions of Ta itself; packages add theirs through their host (host.commands). */
|
|
95
|
+
export declare class TaAppCommandsImpl implements TaAppCommands {
|
|
96
|
+
protected readonly server: TaServer;
|
|
97
|
+
protected readonly packageServer: TaPackageServer;
|
|
98
|
+
protected readonly settings: TaSettingsStore;
|
|
99
|
+
protected readonly environments: ExecEnvironmentFactory;
|
|
100
|
+
protected readonly teamProvider: TaHostTeamProvider;
|
|
101
|
+
protected readonly pages: TaPageBook;
|
|
102
|
+
protected readonly sessions: TaSessionRegistry;
|
|
103
|
+
protected registry?: AppCommandRegistry;
|
|
104
|
+
list(): TaAppCommandInfo[];
|
|
105
|
+
run(id: string, input?: Json, options?: TaAppRunOptions): Promise<TaAppCommandResult>;
|
|
106
|
+
register(command: TaAppCommand): () => void;
|
|
107
|
+
registerOf(owner: string, command: TaAppCommand): () => void;
|
|
108
|
+
dropOwner(owner: string): void;
|
|
109
|
+
protected catalog(): AppCommandRegistry;
|
|
110
|
+
}
|
|
111
|
+
export {};
|
|
112
|
+
//# sourceMappingURL=app-commands.d.ts.map
|