@proteos/sdk 0.18.1
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/LICENSE +40 -0
- package/dist/chunk-7RGN4E22.cjs +1185 -0
- package/dist/chunk-7RGN4E22.cjs.map +1 -0
- package/dist/chunk-XJP5WCRZ.js +1125 -0
- package/dist/chunk-XJP5WCRZ.js.map +1 -0
- package/dist/index.cjs +2384 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +5225 -0
- package/dist/index.d.ts +5225 -0
- package/dist/index.js +2146 -0
- package/dist/index.js.map +1 -0
- package/dist/meta/index.cjs +204 -0
- package/dist/meta/index.cjs.map +1 -0
- package/dist/meta/index.d.cts +2 -0
- package/dist/meta/index.d.ts +2 -0
- package/dist/meta/index.js +3 -0
- package/dist/meta/index.js.map +1 -0
- package/dist/types-BNsjfU8N.d.cts +3299 -0
- package/dist/types-BNsjfU8N.d.ts +3299 -0
- package/package.json +86 -0
- package/src/agent/agents.ts +53 -0
- package/src/agent/index.ts +134 -0
- package/src/agent/mcp-servers.ts +102 -0
- package/src/agent/prompts.ts +80 -0
- package/src/agent/session-types.ts +397 -0
- package/src/agent/sessions.ts +197 -0
- package/src/agent/skills.ts +89 -0
- package/src/agent/tools.ts +53 -0
- package/src/agent/types.ts +362 -0
- package/src/auth/index.ts +111 -0
- package/src/auth/me.ts +46 -0
- package/src/auth/organizations.ts +128 -0
- package/src/auth/platform-entities.ts +78 -0
- package/src/auth/roles.ts +213 -0
- package/src/auth/types.ts +294 -0
- package/src/auth/users.ts +226 -0
- package/src/client.ts +441 -0
- package/src/connector/index.ts +120 -0
- package/src/connector/types.ts +150 -0
- package/src/conversation/index.ts +297 -0
- package/src/conversation/types.ts +590 -0
- package/src/conversation/voice.ts +123 -0
- package/src/data/index.ts +53 -0
- package/src/data/queries.ts +66 -0
- package/src/data/records.ts +122 -0
- package/src/data/types.ts +89 -0
- package/src/errors.ts +148 -0
- package/src/events/index.ts +172 -0
- package/src/events/types.ts +77 -0
- package/src/functions/actions.ts +95 -0
- package/src/functions/index.ts +32 -0
- package/src/functions/types.ts +71 -0
- package/src/http/index.ts +2 -0
- package/src/http/query-params.ts +106 -0
- package/src/index.ts +598 -0
- package/src/iterator.ts +183 -0
- package/src/knowledge/graph.ts +35 -0
- package/src/knowledge/index.ts +104 -0
- package/src/knowledge/labels.ts +70 -0
- package/src/knowledge/links.ts +65 -0
- package/src/knowledge/nodes.ts +198 -0
- package/src/knowledge/record-links.ts +66 -0
- package/src/knowledge/types.ts +569 -0
- package/src/meta/apps.ts +107 -0
- package/src/meta/components.ts +124 -0
- package/src/meta/currency/index.ts +202 -0
- package/src/meta/entities.ts +193 -0
- package/src/meta/filters.ts +76 -0
- package/src/meta/index.ts +227 -0
- package/src/meta/layout/common-props.ts +93 -0
- package/src/meta/layout/control-registry.json +70 -0
- package/src/meta/layout/control-registry.ts +92 -0
- package/src/meta/layout/elements.ts +203 -0
- package/src/meta/layout/index.ts +41 -0
- package/src/meta/layout/page-layout.ts +35 -0
- package/src/meta/layout/size-value.ts +27 -0
- package/src/meta/list-views.ts +109 -0
- package/src/meta/lists.ts +104 -0
- package/src/meta/menu-configurations.ts +128 -0
- package/src/meta/modules.ts +159 -0
- package/src/meta/pages.ts +106 -0
- package/src/meta/types.ts +1115 -0
- package/src/meta/variables.ts +98 -0
- package/src/storage/files.ts +183 -0
- package/src/storage/index.ts +33 -0
- package/src/storage/types.ts +70 -0
- package/src/types/common.ts +143 -0
- package/src/types/index.ts +28 -0
- package/src/types/options.ts +95 -0
- package/src/workflow/executions.ts +99 -0
- package/src/workflow/index.ts +109 -0
- package/src/workflow/node-types.ts +50 -0
- package/src/workflow/types.ts +658 -0
- package/src/workflow/workflows.ts +152 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { ProteosClient } from '../client.js'
|
|
2
|
+
import type {
|
|
3
|
+
Connector,
|
|
4
|
+
ConnectorConnection,
|
|
5
|
+
ConnectorMethod,
|
|
6
|
+
ConnectionTokenResponse,
|
|
7
|
+
CreateConnectorConnectionRequest,
|
|
8
|
+
InstallConnectorConnectionResponse,
|
|
9
|
+
InvokeMethodResponse,
|
|
10
|
+
ListConnectorConnectionsQuery,
|
|
11
|
+
ListConnectorsQuery,
|
|
12
|
+
ListResponse,
|
|
13
|
+
UpdateConnectorConnectionRequest,
|
|
14
|
+
} from './types.js'
|
|
15
|
+
|
|
16
|
+
export * from './types.js'
|
|
17
|
+
|
|
18
|
+
const CONNECTOR_BASE_PATH = '/connectors/v1'
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Facade for connector-service: the connector manifest catalog and
|
|
22
|
+
* connections (install flow, token release, connector-method invocation).
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* const connector = new ConnectorClient(client)
|
|
26
|
+
* const catalog = await connector.connectors.list()
|
|
27
|
+
* const { authorization_url } = await connector.connections.install(id)
|
|
28
|
+
* const events = await connector.connections.invokeMethod(id, 'list_events', {})
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export class ConnectorClient {
|
|
32
|
+
readonly connectors: ConnectorCatalogService
|
|
33
|
+
readonly connections: ConnectorConnectionService
|
|
34
|
+
|
|
35
|
+
constructor(client: ProteosClient) {
|
|
36
|
+
this.connectors = new ConnectorCatalogServiceImpl(client)
|
|
37
|
+
this.connections = new ConnectorConnectionServiceImpl(client)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The connector manifest catalog (pre-built + org-custom). */
|
|
42
|
+
export interface ConnectorCatalogService {
|
|
43
|
+
list(query?: ListConnectorsQuery): Promise<ListResponse<Connector>>
|
|
44
|
+
get(key: string): Promise<Connector>
|
|
45
|
+
/** A connector's callable methods (sugar over get().methods). */
|
|
46
|
+
listMethods(key: string): Promise<ConnectorMethod[]>
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
class ConnectorCatalogServiceImpl implements ConnectorCatalogService {
|
|
50
|
+
constructor(private readonly client: ProteosClient) {}
|
|
51
|
+
|
|
52
|
+
list(query: ListConnectorsQuery = {}): Promise<ListResponse<Connector>> {
|
|
53
|
+
return this.client.requestWithQuery('GET', `${CONNECTOR_BASE_PATH}/connectors`, query)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get(key: string): Promise<Connector> {
|
|
57
|
+
return this.client.request('GET', `${CONNECTOR_BASE_PATH}/connectors/${encodeURIComponent(key)}`)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async listMethods(key: string): Promise<ConnectorMethod[]> {
|
|
61
|
+
const connector = await this.get(key)
|
|
62
|
+
return connector.methods ?? []
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Configured integration instances + method invocation. */
|
|
67
|
+
export interface ConnectorConnectionService {
|
|
68
|
+
list(query?: ListConnectorConnectionsQuery): Promise<ListResponse<ConnectorConnection>>
|
|
69
|
+
get(id: string): Promise<ConnectorConnection>
|
|
70
|
+
create(request: CreateConnectorConnectionRequest): Promise<ConnectorConnection>
|
|
71
|
+
update(id: string, request: UpdateConnectorConnectionRequest): Promise<ConnectorConnection>
|
|
72
|
+
delete(id: string): Promise<void>
|
|
73
|
+
/** Begin the OAuth install flow; open the returned URL in a popup. */
|
|
74
|
+
install(id: string): Promise<InstallConnectorConnectionResponse>
|
|
75
|
+
/** Release the connection's usable token material (requires connections write). */
|
|
76
|
+
token(id: string): Promise<ConnectionTokenResponse>
|
|
77
|
+
/** Invoke a connector method; returns the unwrapped result. */
|
|
78
|
+
invokeMethod<T = unknown>(id: string, method: string, params?: unknown): Promise<T>
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
class ConnectorConnectionServiceImpl implements ConnectorConnectionService {
|
|
82
|
+
constructor(private readonly client: ProteosClient) {}
|
|
83
|
+
|
|
84
|
+
list(query: ListConnectorConnectionsQuery = {}): Promise<ListResponse<ConnectorConnection>> {
|
|
85
|
+
return this.client.requestWithQuery('GET', `${CONNECTOR_BASE_PATH}/connections`, query)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get(id: string): Promise<ConnectorConnection> {
|
|
89
|
+
return this.client.request('GET', `${CONNECTOR_BASE_PATH}/connections/${encodeURIComponent(id)}`)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
create(request: CreateConnectorConnectionRequest): Promise<ConnectorConnection> {
|
|
93
|
+
return this.client.request('POST', `${CONNECTOR_BASE_PATH}/connections`, request)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
update(id: string, request: UpdateConnectorConnectionRequest): Promise<ConnectorConnection> {
|
|
97
|
+
return this.client.request('PATCH', `${CONNECTOR_BASE_PATH}/connections/${encodeURIComponent(id)}`, request)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async delete(id: string): Promise<void> {
|
|
101
|
+
await this.client.request('DELETE', `${CONNECTOR_BASE_PATH}/connections/${encodeURIComponent(id)}`)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
install(id: string): Promise<InstallConnectorConnectionResponse> {
|
|
105
|
+
return this.client.request('POST', `${CONNECTOR_BASE_PATH}/connections/${encodeURIComponent(id)}/install`)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
token(id: string): Promise<ConnectionTokenResponse> {
|
|
109
|
+
return this.client.request('POST', `${CONNECTOR_BASE_PATH}/connections/${encodeURIComponent(id)}/token`)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async invokeMethod<T = unknown>(id: string, method: string, params: unknown = {}): Promise<T> {
|
|
113
|
+
const response = await this.client.request<InvokeMethodResponse<T>>(
|
|
114
|
+
'POST',
|
|
115
|
+
`${CONNECTOR_BASE_PATH}/connections/${encodeURIComponent(id)}/methods/${encodeURIComponent(method)}/invoke`,
|
|
116
|
+
params,
|
|
117
|
+
)
|
|
118
|
+
return response.result
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import type { Attribute } from '../meta/types.js'
|
|
2
|
+
|
|
3
|
+
/** Connection lifecycle status. */
|
|
4
|
+
export type ConnectionStatus = 'pending' | 'active' | 'error' | 'revoked'
|
|
5
|
+
|
|
6
|
+
/** org-wide integration vs a single user's grant. */
|
|
7
|
+
export type ConnectionScope = 'org' | 'user'
|
|
8
|
+
|
|
9
|
+
/** How a connector authenticates. */
|
|
10
|
+
export type CredentialKind = 'oauth' | 'api_key' | 'basic' | 'bot_token'
|
|
11
|
+
|
|
12
|
+
export interface UserRef {
|
|
13
|
+
type: string
|
|
14
|
+
id: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* One callable operation a connector exposes (get_event, update_event, …).
|
|
19
|
+
* Params/Returns use the platform attribute language — the same shape actions
|
|
20
|
+
* use — so pickers and validation work identically for pre-built and custom
|
|
21
|
+
* connectors.
|
|
22
|
+
*/
|
|
23
|
+
export interface ConnectorMethod {
|
|
24
|
+
key: string
|
|
25
|
+
title: string
|
|
26
|
+
description?: string
|
|
27
|
+
access: 'read' | 'write'
|
|
28
|
+
/** function-service action implementing this method (custom connectors only). */
|
|
29
|
+
action_slug?: string
|
|
30
|
+
params: Attribute[]
|
|
31
|
+
returns: Attribute[]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The provider config of an oauth connector. Carries no secrets — the OAuth
|
|
36
|
+
* APP credentials are org VARIABLES referenced by the two *_variable_key
|
|
37
|
+
* fields (app credentials are variables, tokens are connections).
|
|
38
|
+
*/
|
|
39
|
+
export interface ConnectorOAuthConfig {
|
|
40
|
+
auth_url: string
|
|
41
|
+
token_url: string
|
|
42
|
+
scopes: string[]
|
|
43
|
+
is_pkce_enabled?: boolean
|
|
44
|
+
client_id_variable_key: string
|
|
45
|
+
client_secret_variable_key: string
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** A connector TYPE (google-calendar, a customer's vertex-tax, …). */
|
|
49
|
+
export interface Connector {
|
|
50
|
+
key: string
|
|
51
|
+
org_id: string
|
|
52
|
+
title: string
|
|
53
|
+
description?: string
|
|
54
|
+
icon?: string
|
|
55
|
+
credential_kind: CredentialKind
|
|
56
|
+
oauth?: ConnectorOAuthConfig
|
|
57
|
+
/**
|
|
58
|
+
* COMPUTED: the broker's per-environment OAuth callback — register it as an
|
|
59
|
+
* authorized redirect URI on the provider app.
|
|
60
|
+
*/
|
|
61
|
+
oauth_redirect_uri?: string
|
|
62
|
+
config_schema?: Attribute[]
|
|
63
|
+
methods: ConnectorMethod[]
|
|
64
|
+
origin: 'pre_built' | 'custom'
|
|
65
|
+
module_slug?: string
|
|
66
|
+
status: 'active' | 'inactive'
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* One configured integration instance. `Connection` collides with the
|
|
71
|
+
* conversation module's export, so connector types are prefixed
|
|
72
|
+
* `ConnectorConnection`.
|
|
73
|
+
*/
|
|
74
|
+
export interface ConnectorConnection {
|
|
75
|
+
id: string
|
|
76
|
+
org_id: string
|
|
77
|
+
connector_key: string
|
|
78
|
+
display_name: string
|
|
79
|
+
scope: ConnectionScope
|
|
80
|
+
owner?: UserRef
|
|
81
|
+
external_account_id: string
|
|
82
|
+
settings: Record<string, unknown>
|
|
83
|
+
status: ConnectionStatus
|
|
84
|
+
status_detail?: string
|
|
85
|
+
created_at: string
|
|
86
|
+
updated_at: string
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface WriteCredentialsRequest {
|
|
90
|
+
kind: CredentialKind
|
|
91
|
+
api_key?: string
|
|
92
|
+
username?: string
|
|
93
|
+
password?: string
|
|
94
|
+
bot_token?: string
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface CreateConnectorConnectionRequest {
|
|
98
|
+
connector_key: string
|
|
99
|
+
display_name: string
|
|
100
|
+
scope: ConnectionScope
|
|
101
|
+
settings?: Record<string, unknown>
|
|
102
|
+
credentials?: WriteCredentialsRequest
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface UpdateConnectorConnectionRequest {
|
|
106
|
+
display_name?: string
|
|
107
|
+
settings?: Record<string, unknown>
|
|
108
|
+
credentials?: WriteCredentialsRequest
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface InstallConnectorConnectionResponse {
|
|
112
|
+
authorization_url: string
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface ConnectionTokenResponse {
|
|
116
|
+
kind: CredentialKind
|
|
117
|
+
access_token?: string
|
|
118
|
+
expires_at?: string
|
|
119
|
+
api_key?: string
|
|
120
|
+
username?: string
|
|
121
|
+
password?: string
|
|
122
|
+
bot_token?: string
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface InvokeMethodResponse<T = unknown> {
|
|
126
|
+
result: T
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface ListConnectorsQuery {
|
|
130
|
+
page?: number
|
|
131
|
+
page_size?: number
|
|
132
|
+
status?: string
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface ListConnectorConnectionsQuery {
|
|
136
|
+
page?: number
|
|
137
|
+
page_size?: number
|
|
138
|
+
connector_key?: string
|
|
139
|
+
scope?: ConnectionScope
|
|
140
|
+
status?: ConnectionStatus
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface ListResponse<T> {
|
|
144
|
+
data: T[]
|
|
145
|
+
meta: {
|
|
146
|
+
pagination: { page: number; page_size: number }
|
|
147
|
+
items_total: number
|
|
148
|
+
pages_total: number
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import type { ProteosClient } from '../client.js'
|
|
2
|
+
import { type VoiceService, VoiceServiceImpl } from './voice.js'
|
|
3
|
+
import type {
|
|
4
|
+
AgentListener,
|
|
5
|
+
CreateTranscriptionRequest,
|
|
6
|
+
ListTranscriptionsQuery,
|
|
7
|
+
MaterializeTranscriptionRequest,
|
|
8
|
+
Transcription,
|
|
9
|
+
Connection,
|
|
10
|
+
Conversation,
|
|
11
|
+
CreateAgentListenerRequest,
|
|
12
|
+
CreateConnectionRequest,
|
|
13
|
+
InstallConnectionResponse,
|
|
14
|
+
ListAgentListenersQuery,
|
|
15
|
+
ListConnectionsQuery,
|
|
16
|
+
ListConversationsQuery,
|
|
17
|
+
ListMessagesQuery,
|
|
18
|
+
ListParticipantsQuery,
|
|
19
|
+
ListReactionsResponse,
|
|
20
|
+
ListResponse,
|
|
21
|
+
ListRoomsQuery,
|
|
22
|
+
Message,
|
|
23
|
+
Participant,
|
|
24
|
+
Reaction,
|
|
25
|
+
Room,
|
|
26
|
+
SendMessageRequest,
|
|
27
|
+
UnreadCounts,
|
|
28
|
+
UpdateAgentListenerRequest,
|
|
29
|
+
UpdateConnectionRequest,
|
|
30
|
+
} from './types.js'
|
|
31
|
+
|
|
32
|
+
const CONVERSATION_BASE_PATH = '/conversations/v1'
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Facade for conversation-service: connections (channel-connector instances),
|
|
36
|
+
* conversations + messages (THE platform Message), and agent listeners.
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* const conversation = new ConversationClient(client)
|
|
40
|
+
* const { authorization_url } = await conversation.connections.install(id)
|
|
41
|
+
* const inbox = await conversation.conversations.list({ channel: 'slack' })
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export class ConversationClient {
|
|
45
|
+
readonly connections: ConnectionService
|
|
46
|
+
readonly conversations: ConversationService
|
|
47
|
+
readonly messages: MessageService
|
|
48
|
+
readonly agentListeners: AgentListenerService
|
|
49
|
+
readonly transcriptions: TranscriptionService
|
|
50
|
+
/** Realtime speech-to-text (dictation) — moved here from agent-service. */
|
|
51
|
+
readonly voice: VoiceService
|
|
52
|
+
|
|
53
|
+
constructor(client: ProteosClient) {
|
|
54
|
+
this.connections = new ConnectionServiceImpl(client)
|
|
55
|
+
this.conversations = new ConversationServiceImpl(client)
|
|
56
|
+
this.messages = new MessageServiceImpl(client)
|
|
57
|
+
this.agentListeners = new AgentListenerServiceImpl(client)
|
|
58
|
+
this.transcriptions = new TranscriptionServiceImpl(client)
|
|
59
|
+
this.voice = new VoiceServiceImpl(client)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Configured integration instances (Slack workspace, Gmail grant, …). */
|
|
64
|
+
export interface ConnectionService {
|
|
65
|
+
list(query?: ListConnectionsQuery): Promise<ListResponse<Connection>>
|
|
66
|
+
get(id: string): Promise<Connection>
|
|
67
|
+
create(request: CreateConnectionRequest): Promise<Connection>
|
|
68
|
+
update(id: string, request: UpdateConnectionRequest): Promise<Connection>
|
|
69
|
+
delete(id: string): Promise<void>
|
|
70
|
+
/** Begin the connector's install flow; open the returned URL in a popup. */
|
|
71
|
+
install(id: string): Promise<InstallConnectionResponse>
|
|
72
|
+
/** Search a connection's known PEOPLE (workspace members, correspondents) for the compose picker. */
|
|
73
|
+
listParticipants(connectionId: string, query?: ListParticipantsQuery): Promise<ListResponse<Participant>>
|
|
74
|
+
/** Search a connection's addressable VENUES (Slack channels) for the compose picker. */
|
|
75
|
+
listRooms(connectionId: string, query?: ListRoomsQuery): Promise<ListResponse<Room>>
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
class ConnectionServiceImpl implements ConnectionService {
|
|
79
|
+
constructor(private readonly client: ProteosClient) {}
|
|
80
|
+
|
|
81
|
+
list(query: ListConnectionsQuery = {}): Promise<ListResponse<Connection>> {
|
|
82
|
+
return this.client.requestWithQuery('GET', `${CONVERSATION_BASE_PATH}/connections`, query)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
get(id: string): Promise<Connection> {
|
|
86
|
+
return this.client.request('GET', `${CONVERSATION_BASE_PATH}/connections/${encodeURIComponent(id)}`)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
create(request: CreateConnectionRequest): Promise<Connection> {
|
|
90
|
+
return this.client.request('POST', `${CONVERSATION_BASE_PATH}/connections`, request)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
update(id: string, request: UpdateConnectionRequest): Promise<Connection> {
|
|
94
|
+
return this.client.request('PATCH', `${CONVERSATION_BASE_PATH}/connections/${encodeURIComponent(id)}`, request)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async delete(id: string): Promise<void> {
|
|
98
|
+
await this.client.request('DELETE', `${CONVERSATION_BASE_PATH}/connections/${encodeURIComponent(id)}`)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
install(id: string): Promise<InstallConnectionResponse> {
|
|
102
|
+
return this.client.request('POST', `${CONVERSATION_BASE_PATH}/connections/${encodeURIComponent(id)}/install`)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
listParticipants(connectionId: string, query: ListParticipantsQuery = {}): Promise<ListResponse<Participant>> {
|
|
106
|
+
return this.client.requestWithQuery(
|
|
107
|
+
'GET',
|
|
108
|
+
`${CONVERSATION_BASE_PATH}/connections/${encodeURIComponent(connectionId)}/participants`,
|
|
109
|
+
query,
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
listRooms(connectionId: string, query: ListRoomsQuery = {}): Promise<ListResponse<Room>> {
|
|
114
|
+
return this.client.requestWithQuery(
|
|
115
|
+
'GET',
|
|
116
|
+
`${CONVERSATION_BASE_PATH}/connections/${encodeURIComponent(connectionId)}/rooms`,
|
|
117
|
+
query,
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Conversation threads across every channel (inbox order: last_message_at). */
|
|
123
|
+
export interface ConversationService {
|
|
124
|
+
list(query?: ListConversationsQuery): Promise<ListResponse<Conversation>>
|
|
125
|
+
get(id: string): Promise<Conversation>
|
|
126
|
+
end(id: string): Promise<Conversation>
|
|
127
|
+
/** Upsert the requesting user's read marker to now (open a conversation). */
|
|
128
|
+
markRead(id: string): Promise<void>
|
|
129
|
+
/** Remove the marker — the conversation reads as unread again. */
|
|
130
|
+
markUnread(id: string): Promise<void>
|
|
131
|
+
/** Unread-conversation counts for the requesting user (envelope + badges). */
|
|
132
|
+
unreadCounts(): Promise<UnreadCounts>
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
class ConversationServiceImpl implements ConversationService {
|
|
136
|
+
constructor(private readonly client: ProteosClient) {}
|
|
137
|
+
|
|
138
|
+
list(query: ListConversationsQuery = {}): Promise<ListResponse<Conversation>> {
|
|
139
|
+
return this.client.requestWithQuery('GET', `${CONVERSATION_BASE_PATH}/conversations`, query)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
get(id: string): Promise<Conversation> {
|
|
143
|
+
return this.client.request('GET', `${CONVERSATION_BASE_PATH}/conversations/${encodeURIComponent(id)}`)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
end(id: string): Promise<Conversation> {
|
|
147
|
+
return this.client.request('POST', `${CONVERSATION_BASE_PATH}/conversations/${encodeURIComponent(id)}/end`)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
markRead(id: string): Promise<void> {
|
|
151
|
+
return this.client.request('POST', `${CONVERSATION_BASE_PATH}/conversations/${encodeURIComponent(id)}/read`)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
markUnread(id: string): Promise<void> {
|
|
155
|
+
return this.client.request('DELETE', `${CONVERSATION_BASE_PATH}/conversations/${encodeURIComponent(id)}/read`)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
unreadCounts(): Promise<UnreadCounts> {
|
|
159
|
+
return this.client.request('GET', `${CONVERSATION_BASE_PATH}/conversations/unread-counts`)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Messages within a conversation (ordered by occurred_at) + outbound send + reactions. */
|
|
164
|
+
export interface MessageService {
|
|
165
|
+
listByConversation(conversationId: string, query?: ListMessagesQuery): Promise<ListResponse<Message>>
|
|
166
|
+
send(request: SendMessageRequest): Promise<Message>
|
|
167
|
+
/** Aggregated reactions on one message (also rides on Message.reactions). */
|
|
168
|
+
getReactions(messageId: string): Promise<Reaction[]>
|
|
169
|
+
/**
|
|
170
|
+
* Place an emoji (connector-native token) via the message's connector.
|
|
171
|
+
* Rejected with `reactions_not_supported` on reaction-less channels — gate
|
|
172
|
+
* the affordance on the connection's `supports_reactions` / `reactions`.
|
|
173
|
+
*/
|
|
174
|
+
addReaction(messageId: string, emoji: string): Promise<Reaction[]>
|
|
175
|
+
removeReaction(messageId: string, emoji: string): Promise<Reaction[]>
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
class MessageServiceImpl implements MessageService {
|
|
179
|
+
constructor(private readonly client: ProteosClient) {}
|
|
180
|
+
|
|
181
|
+
listByConversation(conversationId: string, query: ListMessagesQuery = {}): Promise<ListResponse<Message>> {
|
|
182
|
+
return this.client.requestWithQuery(
|
|
183
|
+
'GET',
|
|
184
|
+
`${CONVERSATION_BASE_PATH}/conversations/${encodeURIComponent(conversationId)}/messages`,
|
|
185
|
+
query,
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
send(request: SendMessageRequest): Promise<Message> {
|
|
190
|
+
return this.client.request('POST', `${CONVERSATION_BASE_PATH}/messages/send`, request)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
async getReactions(messageId: string): Promise<Reaction[]> {
|
|
194
|
+
const response: ListReactionsResponse = await this.client.request(
|
|
195
|
+
'GET',
|
|
196
|
+
`${CONVERSATION_BASE_PATH}/messages/${encodeURIComponent(messageId)}/reactions`,
|
|
197
|
+
)
|
|
198
|
+
return response.data
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
async addReaction(messageId: string, emoji: string): Promise<Reaction[]> {
|
|
202
|
+
const response: ListReactionsResponse = await this.client.request(
|
|
203
|
+
'POST',
|
|
204
|
+
`${CONVERSATION_BASE_PATH}/messages/${encodeURIComponent(messageId)}/reactions`,
|
|
205
|
+
{ emoji },
|
|
206
|
+
)
|
|
207
|
+
return response.data
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
async removeReaction(messageId: string, emoji: string): Promise<Reaction[]> {
|
|
211
|
+
const response: ListReactionsResponse = await this.client.request(
|
|
212
|
+
'DELETE',
|
|
213
|
+
`${CONVERSATION_BASE_PATH}/messages/${encodeURIComponent(messageId)}/reactions/${encodeURIComponent(emoji)}`,
|
|
214
|
+
)
|
|
215
|
+
return response.data
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** Rules binding inbound messages to agents. */
|
|
220
|
+
export interface AgentListenerService {
|
|
221
|
+
list(query?: ListAgentListenersQuery): Promise<ListResponse<AgentListener>>
|
|
222
|
+
get(id: string): Promise<AgentListener>
|
|
223
|
+
create(request: CreateAgentListenerRequest): Promise<AgentListener>
|
|
224
|
+
update(id: string, request: UpdateAgentListenerRequest): Promise<AgentListener>
|
|
225
|
+
delete(id: string): Promise<void>
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
class AgentListenerServiceImpl implements AgentListenerService {
|
|
229
|
+
constructor(private readonly client: ProteosClient) {}
|
|
230
|
+
|
|
231
|
+
list(query: ListAgentListenersQuery = {}): Promise<ListResponse<AgentListener>> {
|
|
232
|
+
return this.client.requestWithQuery('GET', `${CONVERSATION_BASE_PATH}/agent-listeners`, query)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
get(id: string): Promise<AgentListener> {
|
|
236
|
+
return this.client.request('GET', `${CONVERSATION_BASE_PATH}/agent-listeners/${encodeURIComponent(id)}`)
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
create(request: CreateAgentListenerRequest): Promise<AgentListener> {
|
|
240
|
+
return this.client.request('POST', `${CONVERSATION_BASE_PATH}/agent-listeners`, request)
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
update(id: string, request: UpdateAgentListenerRequest): Promise<AgentListener> {
|
|
244
|
+
return this.client.request('PATCH', `${CONVERSATION_BASE_PATH}/agent-listeners/${encodeURIComponent(id)}`, request)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
async delete(id: string): Promise<void> {
|
|
248
|
+
await this.client.request('DELETE', `${CONVERSATION_BASE_PATH}/agent-listeners/${encodeURIComponent(id)}`)
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** Batch transcription of stored audio files + materialization. */
|
|
253
|
+
export interface TranscriptionService {
|
|
254
|
+
/**
|
|
255
|
+
* Kicks off transcription asynchronously — resolves immediately with a
|
|
256
|
+
* PROCESSING entity; the provider runs off-request. Poll `get(id)` until the
|
|
257
|
+
* status is `completed` (or `failed`), then `materialize`.
|
|
258
|
+
*/
|
|
259
|
+
createFromFile(request: CreateTranscriptionRequest): Promise<Transcription>
|
|
260
|
+
list(query?: ListTranscriptionsQuery): Promise<ListResponse<Transcription>>
|
|
261
|
+
get(id: string): Promise<Transcription>
|
|
262
|
+
/** Turns a completed transcription into an adhoc/meeting conversation. */
|
|
263
|
+
materialize(id: string, request?: MaterializeTranscriptionRequest): Promise<Conversation>
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
class TranscriptionServiceImpl implements TranscriptionService {
|
|
267
|
+
constructor(private readonly client: ProteosClient) {}
|
|
268
|
+
|
|
269
|
+
createFromFile(request: CreateTranscriptionRequest): Promise<Transcription> {
|
|
270
|
+
return this.client.request('POST', `${CONVERSATION_BASE_PATH}/transcriptions`, request)
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
list(query: ListTranscriptionsQuery = {}): Promise<ListResponse<Transcription>> {
|
|
274
|
+
return this.client.requestWithQuery('GET', `${CONVERSATION_BASE_PATH}/transcriptions`, query)
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
get(id: string): Promise<Transcription> {
|
|
278
|
+
return this.client.request('GET', `${CONVERSATION_BASE_PATH}/transcriptions/${encodeURIComponent(id)}`)
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
materialize(id: string, request: MaterializeTranscriptionRequest = {}): Promise<Conversation> {
|
|
282
|
+
return this.client.request(
|
|
283
|
+
'POST',
|
|
284
|
+
`${CONVERSATION_BASE_PATH}/transcriptions/${encodeURIComponent(id)}/materialize`,
|
|
285
|
+
request,
|
|
286
|
+
)
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export type * from './types.js'
|
|
291
|
+
// Re-export voice types (the live dictation stream lives on this service now)
|
|
292
|
+
export type {
|
|
293
|
+
TranscribeStreamOptions,
|
|
294
|
+
TranscriptResult,
|
|
295
|
+
VoiceService,
|
|
296
|
+
VoiceTranscriptionStream,
|
|
297
|
+
} from './voice.js'
|