Line data Source code
1 : // The messages between the page and the local agent server.
2 : // The types are generated from the JSON Schema in proto/json/dashql/agent_bridge.json, AgentServerMethods and
3 : // AgentClientMethods name the params and results of the methods.
4 :
5 : import type { AgentClientMethods, ClientSessionsParams } from '@ankoh/dashql-jsonschema/agent_bridge.js';
6 :
7 : export type * from '@ankoh/dashql-jsonschema/agent_bridge.js';
8 :
9 : /// The version of the protocol, the server turns away other versions
10 : export const AGENT_PROTOCOL_VERSION: ClientSessionsParams['protocol'] = 2;
11 :
12 : /// The features of this page, announced with client/sessions. The agent server picks the notes of its guide for the
13 : /// ones it knows (FEATURE_* in dashql-cli/src/agent/instructions.rs) and asks for a newer DashQL when one lacks.
14 : /// Identifiers only: the agent follows the text of the binary, never text of the page.
15 1 : export const AGENT_FEATURES: NonNullable<ClientSessionsParams['features']> = [
16 1 : 'connections',
17 1 : 'edit',
18 1 : 'vis',
19 1 : 'table-parameters',
20 1 : 'scalar-parameters',
21 1 : 'attachments',
22 1 : 'embedded-hyper',
23 1 : 'manual-scripts',
24 1 : 'result-caching',
25 1 : ];
26 :
27 : /// The path of the WebSocket endpoint
28 1 : export const AGENT_WEBSOCKET_PATH = '/v1/ws';
29 :
30 : /// A notification of the server, a method without a result
31 : export type AgentNotification = {
32 : [M in keyof AgentClientMethods]: AgentClientMethods[M] extends { result: unknown }
33 : ? never
34 : : { method: M; params: AgentClientMethods[M]['params'] };
35 : }[keyof AgentClientMethods];
|