@proteos/sdk 0.89.0 → 0.91.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proteos/sdk",
3
- "version": "0.89.0",
3
+ "version": "0.91.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "TypeScript SDK for the Proteos platform",
6
6
  "repository": {
@@ -153,6 +153,8 @@ export type {
153
153
  ToolUseDeltaPayload,
154
154
  ToolUsePayload,
155
155
  ToolUseStartPayload,
156
+ TransferVoiceRequest,
157
+ TransferVoiceResponse,
156
158
  Turn,
157
159
  UserMessagePayload,
158
160
  VoiceEndedPayload,
@@ -172,6 +174,7 @@ export type {
172
174
  Agent,
173
175
  AgentResourceListOptions,
174
176
  AgentRuntime,
177
+ AgentVoiceStyle,
175
178
  CreateAgentRequest,
176
179
  CreateMcpServerRequest,
177
180
  CreatePromptRequest,
@@ -31,6 +31,8 @@ export interface ModelInfo {
31
31
  runtimes: AgentRuntime[]
32
32
  /** Tokens one request can hold, input and output together. Absent when unknown. */
33
33
  context_window?: number
34
+ /** Whether the model reads images and PDFs sent with the conversation. */
35
+ supports_images: boolean
34
36
  }
35
37
 
36
38
  // ---------------------------------------------------------------------------
@@ -14,7 +14,7 @@
14
14
  */
15
15
 
16
16
  import type { AuditFields, ListOptions, UserRef } from '../types/common.js'
17
- import type { AgentRuntime, ToolKind } from './types.js'
17
+ import type { AgentRuntime, AgentVoiceStyle, ToolKind } from './types.js'
18
18
 
19
19
  export type { ToolKind } from './types.js'
20
20
 
@@ -76,6 +76,11 @@ export interface Session extends AuditFields {
76
76
  ended_at: string | null
77
77
  /** Who ended it; null unless `status` is `ended` (and on sessions ended by the platform). */
78
78
  ended_by: UserRef | null
79
+ /**
80
+ * Whether the voice provider records the voice sessions of this session (see
81
+ * {@link CreateSessionRequest.is_voice_recorded}). Set at create, never changed.
82
+ */
83
+ is_voice_recorded: boolean
79
84
  }
80
85
 
81
86
  /**
@@ -136,6 +141,7 @@ export type EventType =
136
141
  | 'session.updated'
137
142
  | 'session.voice_started'
138
143
  | 'session.voice_ended'
144
+ // The service asking the agent to open the conversation; shows nothing.
139
145
  // A report on a session this one delegated to.
140
146
  | 'delegated_session.updated'
141
147
  // Span (observability).
@@ -188,9 +194,12 @@ export interface ContentBlock extends FileBlock {
188
194
  * under `image`; `json` carries an arbitrary raw object.
189
195
  */
190
196
  export interface ResultBlock {
191
- type: 'text' | 'image' | 'json'
197
+ type: 'text' | 'image' | 'file' | 'json'
192
198
  text?: string
199
+ /** A stored image (type `image`). The model sees it when it reads images. */
193
200
  image?: FileBlock
201
+ /** Any other stored file, such as a PDF (type `file`). */
202
+ file?: FileBlock
194
203
  json?: unknown
195
204
  }
196
205
 
@@ -385,12 +394,22 @@ export interface VoiceRequestPayload {
385
394
  context?: string
386
395
  }
387
396
 
388
- /** Voice was entered on the session. */
397
+ /**
398
+ * Voice was entered on the session. `transferred_from_session_id` is set when
399
+ * it was not entered here but came with the person: the session they were
400
+ * handed over from, or handed back from.
401
+ */
389
402
  export interface VoiceStartedPayload {
390
403
  voice_session_id: string
404
+ transferred_from_session_id?: string
391
405
  }
392
406
 
393
- /** Why a voice session ended. `superseded` is never reported by a page. */
407
+ /**
408
+ * Why a voice session ended. `superseded` and `transferred` are never reported
409
+ * by a page. `transferred` is the reason of the `session.voice_ended` in the log
410
+ * of a session the person was handed over from: the voice session itself goes on
411
+ * in the session they were handed to.
412
+ */
394
413
  export type VoiceEndReason =
395
414
  | 'user'
396
415
  | 'idle'
@@ -399,16 +418,19 @@ export type VoiceEndReason =
399
418
  | 'browser_left'
400
419
  | 'provider_closed'
401
420
  | 'superseded'
421
+ | 'transferred'
402
422
 
403
423
  /**
404
424
  * Voice was left: why, and how long the voice session lasted: what the voice
405
425
  * provider says, or the time since voice was entered when the page went away
406
- * without it (null when nobody learned it).
426
+ * without it (null when nobody learned it). With `transferred` the voice session
427
+ * goes on in `transferred_to_session_id`, and no duration is known yet.
407
428
  */
408
429
  export interface VoiceEndedPayload {
409
430
  voice_session_id: string
410
431
  end_reason: VoiceEndReason
411
432
  duration_seconds: number | null
433
+ transferred_to_session_id?: string
412
434
  }
413
435
 
414
436
  /** Opens a model-request span. */
@@ -539,6 +561,18 @@ export interface CreateSessionRequest {
539
561
  agent_key: string
540
562
  title?: string
541
563
  client_tools?: ClientToolSchema[]
564
+ /**
565
+ * Replaces the voice assistant's instructions in the voice sessions of this
566
+ * session, at most 40,000 characters. `{{delegate}}` and `{{do_not_delegate}}` in them stand
567
+ * for the words the voice model in use is told to hand a request over with, and
568
+ * not to; the service fills them in. No response or event returns them.
569
+ */
570
+ voice_instructions?: string
571
+ /**
572
+ * The voice provider records the voice sessions of this session; a recording
573
+ * is read with `sessions.getVoiceRecording`.
574
+ */
575
+ is_voice_recorded?: boolean
542
576
  }
543
577
 
544
578
  /**
@@ -579,11 +613,13 @@ export interface AppendEventRequest {
579
613
  * One time a person talked to a session's agent through the voice assistant. The
580
614
  * assistant listens and speaks; what was said is in the session's event log
581
615
  * (`user.speech`, `agent.speech`) and everything asked for runs as turns of the
582
- * session. A session has at most one active voice session.
616
+ * session. A session has at most one active voice session. A hand-over moves the
617
+ * voice session to the session the person is handed to, and back.
583
618
  */
584
619
  export interface VoiceSession {
585
620
  id: string
586
621
  org_id: string
622
+ /** The session the person talks to. */
587
623
  session_id: string
588
624
  status: 'active' | 'ended'
589
625
  /** Null while it is active. */
@@ -591,6 +627,10 @@ export interface VoiceSession {
591
627
  /** How long it lasted: what the voice provider says, or the time since voice
592
628
  * was entered when the page went away without it. Null when not known. */
593
629
  duration_seconds: number | null
630
+ /** How much of `duration_seconds` the voice model was paused (standby):
631
+ * nobody spoke, and the provider bills that time at its lower rate. Null when
632
+ * not known. */
633
+ standby_seconds: number | null
594
634
  created_by: UserRef
595
635
  created_at: string
596
636
  ended_at: string | null
@@ -608,10 +648,20 @@ export interface StartVoiceRequest {
608
648
  export interface StartVoiceResponse {
609
649
  voice_session: VoiceSession
610
650
  sdp_answer: string
611
- /** How long nobody may speak before the page leaves voice. */
651
+ /** How long nobody may speak, while the voice model listens, before the page
652
+ * leaves voice. */
612
653
  idle_timeout_seconds: number
613
654
  /** How long a voice session may last at most. */
614
655
  max_duration_seconds: number
656
+ /** How long nobody speaks before the voice provider pauses the voice model
657
+ * (standby); speech wakes it. 0: it never pauses. */
658
+ standby_after_seconds: number
659
+ /** How long the voice model may stay paused in one stretch before the page
660
+ * leaves voice. */
661
+ max_standby_seconds: number
662
+ /** When the voice of the session's agent speaks: the page tells a
663
+ * moderator's voice model when the conversation has gone quiet. */
664
+ voice_style: AgentVoiceStyle
615
665
  }
616
666
 
617
667
  /** One finished utterance as the page heard it from the voice provider. */
@@ -653,13 +703,43 @@ export interface AppendSpeechRequest {
653
703
  */
654
704
  export interface EndVoiceRequest {
655
705
  voice_session_id: string
656
- end_reason: Exclude<VoiceEndReason, 'superseded'>
706
+ end_reason: Exclude<VoiceEndReason, 'superseded' | 'transferred'>
657
707
  duration_seconds?: number | null
708
+ /** How much of `duration_seconds` the voice model was paused, as the voice
709
+ * provider says. */
710
+ standby_seconds?: number | null
658
711
  /** What was said since the last speech report: a page that is being closed
659
712
  * has one request left to send. */
660
713
  segments?: SpeechSegment[]
661
714
  }
662
715
 
716
+ /**
717
+ * Moves the session's active voice session to another session, when the person
718
+ * is handed over to it or handed back. The connection to the voice provider
719
+ * stays as it is; what the person asks for next runs as turns of the target.
720
+ */
721
+ export interface TransferVoiceRequest {
722
+ /** The voice session the page started (see {@link AppendSpeechRequest}). */
723
+ voice_session_id: string
724
+ /** A session the session delegated to, or the one that delegated to it. */
725
+ target_session_id: string
726
+ }
727
+
728
+ /**
729
+ * The voice session on its new session, and the `session.voice_started` written
730
+ * to that session's log: what the log holds up to it was not said to the voice
731
+ * model.
732
+ */
733
+ export interface TransferVoiceResponse {
734
+ voice_session: VoiceSession
735
+ started: SessionEvent
736
+ /** The voice style of the agent the voice speaks for now. */
737
+ voice_style: AgentVoiceStyle
738
+ /** Whether a turn of that session runs, as its log says up to `started`.
739
+ * The page follows the log from `started` on. */
740
+ is_turn_running: boolean
741
+ }
742
+
663
743
  /** List filter for sessions (in addition to pagination/sorting). */
664
744
  export interface ListSessionsOptions extends ListOptions {
665
745
  /** Filter by the agent the session runs. */
@@ -21,6 +21,8 @@ import type {
21
21
  SessionStreamOptions,
22
22
  StartVoiceRequest,
23
23
  StartVoiceResponse,
24
+ TransferVoiceRequest,
25
+ TransferVoiceResponse,
24
26
  Turn,
25
27
  VoiceSession,
26
28
  } from './session-types.js'
@@ -140,6 +142,16 @@ export interface SessionService {
140
142
  * talked to by voice; 501 `voice_disabled`; 502 `voice_provider_failed`.
141
143
  */
142
144
  startVoice(id: string, request: StartVoiceRequest): Promise<StartVoiceResponse>
145
+ /**
146
+ * Moves the session's active voice session to a session it delegated to, or
147
+ * to the one that delegated to it: the person was handed over and talks to
148
+ * that session's agent from here on. The page keeps its connection to the
149
+ * voice provider and reports to the target session from then on.
150
+ * @throws {ProteosError} 400 `invalid_voice_request` when the target is
151
+ * neither; 409 `voice_not_supported` when the target is over; 409
152
+ * `voice_session_not_active`.
153
+ */
154
+ transferVoice(id: string, request: TransferVoiceRequest): Promise<TransferVoiceResponse>
143
155
  /**
144
156
  * Reports what was said in the session's active voice session and returns the
145
157
  * events written. With `starts_turn` the last of them is the
@@ -162,6 +174,23 @@ export interface SessionService {
162
174
  request: EndVoiceRequest,
163
175
  requestOptions?: RequestOptions,
164
176
  ): Promise<VoiceSession>
177
+ /**
178
+ * The voice provider's recording of an ended voice session of the session, for
179
+ * a session created with `is_voice_recorded`: a WAV file (16-bit PCM, stereo,
180
+ * the person on the left channel and the voice assistant on the right). The
181
+ * ids of a session's voice sessions are in its `session.voice_started` and
182
+ * `session.voice_ended` events. `options.timeout` covers reading the whole
183
+ * file, so raise it for a long recording.
184
+ * @throws {ProteosError} 404 `voice_recording_not_found` when the voice session
185
+ * is not one of this session or was not recorded; 409
186
+ * `voice_recording_not_ready` while the voice session is active or the provider
187
+ * does not have the recording yet (ask again).
188
+ */
189
+ getVoiceRecording(
190
+ id: string,
191
+ voiceSessionId: string,
192
+ requestOptions?: RequestOptions,
193
+ ): Promise<Blob>
165
194
  }
166
195
 
167
196
  export class SessionServiceImpl implements SessionService {
@@ -309,6 +338,14 @@ export class SessionServiceImpl implements SessionService {
309
338
  )
310
339
  }
311
340
 
341
+ async transferVoice(id: string, request: TransferVoiceRequest): Promise<TransferVoiceResponse> {
342
+ return this.client.request<TransferVoiceResponse>(
343
+ 'POST',
344
+ `${SESSIONS_BASE_PATH}/${id}/voice/transfer`,
345
+ request,
346
+ )
347
+ }
348
+
312
349
  async appendSpeech(
313
350
  id: string,
314
351
  request: AppendSpeechRequest,
@@ -335,6 +372,20 @@ export class SessionServiceImpl implements SessionService {
335
372
  requestOptions,
336
373
  )
337
374
  }
375
+
376
+ async getVoiceRecording(
377
+ id: string,
378
+ voiceSessionId: string,
379
+ requestOptions?: RequestOptions,
380
+ ): Promise<Blob> {
381
+ const { response } = await this.client.requestRaw(
382
+ 'GET',
383
+ `${SESSIONS_BASE_PATH}/${id}/voice/${voiceSessionId}/recording`,
384
+ undefined,
385
+ requestOptions,
386
+ )
387
+ return await response.blob()
388
+ }
338
389
  }
339
390
 
340
391
  /**
@@ -57,6 +57,14 @@ export interface ModelConfig {
57
57
  */
58
58
  export type AgentRuntime = 'durable' | 'embedded' | 'sandbox'
59
59
 
60
+ /**
61
+ * When an agent's voice speaks in a voice session. `conversational` answers
62
+ * everything the person says. `listener` sits in on people who talk to each
63
+ * other and speaks only when addressed by the agent's name. `moderator` does
64
+ * the same and also speaks up when the conversation has gone quiet.
65
+ */
66
+ export type AgentVoiceStyle = 'conversational' | 'listener' | 'moderator'
67
+
60
68
  /**
61
69
  * A configured persona: a system prompt + model config + the skills, tools,
62
70
  * sub-agents and MCP servers it can use. All references are by key (immutable):
@@ -94,6 +102,9 @@ export interface Agent extends AuditFields {
94
102
  * (personal) knowledge space.
95
103
  */
96
104
  has_memory: boolean
105
+ /** When the agent's voice speaks in a voice session. A change applies to the
106
+ * next voice session. */
107
+ voice_style: AgentVoiceStyle
97
108
  /** What runs this agent's sessions. A session keeps the runtime it was created with. */
98
109
  runtime: AgentRuntime
99
110
  version: number
@@ -116,6 +127,8 @@ export interface CreateAgentRequest {
116
127
  has_memory?: boolean
117
128
  /** Defaults to `durable`. */
118
129
  runtime?: AgentRuntime
130
+ /** Defaults to `conversational`. */
131
+ voice_style?: AgentVoiceStyle
119
132
  }
120
133
 
121
134
  export interface UpdateAgentRequest {
@@ -133,6 +146,7 @@ export interface UpdateAgentRequest {
133
146
  has_workspace?: boolean
134
147
  has_memory?: boolean
135
148
  runtime?: AgentRuntime
149
+ voice_style?: AgentVoiceStyle
136
150
  }
137
151
 
138
152
  export type ListAgentsOptions = AgentResourceListOptions
@@ -142,6 +142,9 @@ export const PLATFORM_ENTITIES: readonly PlatformEntity[] = [
142
142
  // Discovery (discovery-service): what users send Proteos to show how they
143
143
  // work — screenshots, recordings, written feedback. Mass noun, no plural.
144
144
  { slug: 'discovery-evidence', name: 'Discovery Evidence' },
145
+ // Interview guides an admin writes; whoever reads a definition reads its
146
+ // interviews, and whoever writes it invites people.
147
+ { slug: 'discovery-interview-definitions', name: 'Discovery Interview Definitions' },
145
148
  ] as const
146
149
 
147
150
  /** Just the platform entity slugs, in canonical order. */
@@ -178,6 +181,9 @@ export const SCOPED_PLATFORM_ENTITY_SLUGS: readonly string[] = [
178
181
  // grant at all is treated as scoped (own rows), so every org member can
179
182
  // send feedback and see what they sent.
180
183
  'discovery-evidence',
184
+ // discovery-service: an interview definition is owned by its creator; its
185
+ // interviews follow it.
186
+ 'discovery-interview-definitions',
181
187
  ]
182
188
 
183
189
  /** True when `slug` belongs to a platform entity (reserved; can't be user-created). */
@@ -1,4 +1,5 @@
1
1
  import type { ProteosClient } from '../client.js'
2
+ import { INVOKE_TIMEOUT_MS } from '../types/options.js'
2
3
  import type {
3
4
  ConnectionTokenResponse,
4
5
  Connector,
@@ -133,6 +134,7 @@ class ConnectorConnectionServiceImpl implements ConnectorConnectionService {
133
134
  'POST',
134
135
  `${CONNECTOR_BASE_PATH}/connections/${encodeURIComponent(id)}/methods/${encodeURIComponent(method)}/invoke`,
135
136
  params,
137
+ { timeout: INVOKE_TIMEOUT_MS },
136
138
  )
137
139
  return response.result
138
140
  }
@@ -63,6 +63,8 @@ export interface Connector {
63
63
  title: string
64
64
  description?: string
65
65
  icon?: string
66
+ /** Brand logo: an https URL or an app-relative path; `icon` is the fallback. */
67
+ logo_url?: string
66
68
  credential_kind: CredentialKind
67
69
  /** Every kind a connection may use; absent/empty = exactly [credential_kind]. */
68
70
  supported_credential_kinds?: CredentialKind[]
@@ -2,15 +2,24 @@ import type { ProteosClient } from '../client.js'
2
2
  import type {
3
3
  CreateDiscoveryEvidenceNarrationRequest,
4
4
  CreateDiscoveryEvidenceRequest,
5
+ CreateDiscoveryInterviewDefinitionRequest,
5
6
  DiscoveryEvidence,
6
7
  DiscoveryEvidenceDownloadUrl,
7
8
  DiscoveryEvidenceNarration,
8
9
  DiscoveryEvidenceOrgSummary,
10
+ DiscoveryInterview,
11
+ DiscoveryInterviewDefinition,
12
+ DiscoveryInterviewParticipation,
13
+ InviteDiscoveryInterviewParticipantsRequest,
9
14
  ListDiscoveryEvidenceQuery,
15
+ ListDiscoveryInterviewDefinitionsQuery,
16
+ ListDiscoveryInterviewsQuery,
10
17
  ListPlatformDiscoveryEvidenceQuery,
11
18
  ListResponse,
19
+ StartDiscoveryInterviewParticipationRequest,
12
20
  UpdateDiscoveryEvidenceRequest,
13
21
  UpdateDiscoveryEvidenceStatusRequest,
22
+ UpdateDiscoveryInterviewDefinitionRequest,
14
23
  } from './types.js'
15
24
 
16
25
  export * from './types.js'
@@ -28,6 +37,11 @@ const encode = encodeURIComponent
28
37
  * from what was said in a recording. `platform` is the Proteos-side view
29
38
  * across every org; it answers only to platform admins.
30
39
  *
40
+ * `interviewDefinitions` are the interview guides an admin writes and
41
+ * `interviews` what each participant's interview came to. Both also carry the
42
+ * participant's own calls (`getParticipation`, `startParticipation`,
43
+ * `complete`), which answer to the person interviewed, not to a grant.
44
+ *
31
45
  * ```ts
32
46
  * const discovery = new DiscoveryClient(client)
33
47
  * const sent = await discovery.evidence.create({ kind: 'feedback', source: 'web', notes, context })
@@ -39,11 +53,15 @@ export class DiscoveryClient {
39
53
  readonly evidence: DiscoveryEvidenceService
40
54
  readonly narrations: DiscoveryEvidenceNarrationService
41
55
  readonly platform: PlatformDiscoveryEvidenceService
56
+ readonly interviewDefinitions: DiscoveryInterviewDefinitionService
57
+ readonly interviews: DiscoveryInterviewService
42
58
 
43
59
  constructor(client: ProteosClient) {
44
60
  this.evidence = new DiscoveryEvidenceServiceImpl(client)
45
61
  this.narrations = new DiscoveryEvidenceNarrationServiceImpl(client)
46
62
  this.platform = new PlatformDiscoveryEvidenceServiceImpl(client)
63
+ this.interviewDefinitions = new DiscoveryInterviewDefinitionServiceImpl(client)
64
+ this.interviews = new DiscoveryInterviewServiceImpl(client)
47
65
  }
48
66
  }
49
67
 
@@ -84,6 +102,60 @@ export interface PlatformDiscoveryEvidenceService {
84
102
  createDownloadUrl(id: string, fileId: string): Promise<DiscoveryEvidenceDownloadUrl>
85
103
  }
86
104
 
105
+ /**
106
+ * Interview definitions: the guide (objective, questions, agent) and who it is
107
+ * for. The last two methods are the participant's: what their page shows
108
+ * before the interview, and starting or resuming their own interview.
109
+ */
110
+ export interface DiscoveryInterviewDefinitionService {
111
+ create(request: CreateDiscoveryInterviewDefinitionRequest): Promise<DiscoveryInterviewDefinition>
112
+ list(
113
+ query?: ListDiscoveryInterviewDefinitionsQuery,
114
+ ): Promise<ListResponse<DiscoveryInterviewDefinition>>
115
+ /** The detail read; carries `guide_findings`. */
116
+ get(id: string): Promise<DiscoveryInterviewDefinition>
117
+ update(
118
+ id: string,
119
+ request: UpdateDiscoveryInterviewDefinitionRequest,
120
+ ): Promise<DiscoveryInterviewDefinition>
121
+ /** Deletes the definition with its interviews and their recordings. */
122
+ delete(id: string): Promise<void>
123
+ publish(id: string): Promise<DiscoveryInterviewDefinition>
124
+ /** Nobody can start or continue; results stay readable. */
125
+ close(id: string): Promise<DiscoveryInterviewDefinition>
126
+ reopen(id: string): Promise<DiscoveryInterviewDefinition>
127
+ /** Assigns users; people already assigned are returned unchanged. */
128
+ invite(
129
+ id: string,
130
+ request: InviteDiscoveryInterviewParticipantsRequest,
131
+ ): Promise<DiscoveryInterview[]>
132
+ getParticipation(id: string): Promise<DiscoveryInterviewParticipation>
133
+ startParticipation(
134
+ id: string,
135
+ request: StartDiscoveryInterviewParticipationRequest,
136
+ ): Promise<DiscoveryInterviewParticipation>
137
+ }
138
+
139
+ /**
140
+ * Interviews of a definition, for whoever can read it. `complete` and
141
+ * `getParticipation` are the participant's.
142
+ */
143
+ export interface DiscoveryInterviewService {
144
+ list(query: ListDiscoveryInterviewsQuery): Promise<ListResponse<DiscoveryInterview>>
145
+ /** The detail read; carries the guide snapshot and the transcript. */
146
+ get(id: string): Promise<DiscoveryInterview>
147
+ /** Sends the invitation again. */
148
+ remind(id: string): Promise<void>
149
+ /** Reruns a synthesis that failed. */
150
+ synthesize(id: string): Promise<DiscoveryInterview>
151
+ /** Withdraws an invitation or deletes a result with its recordings. */
152
+ delete(id: string): Promise<void>
153
+ createDownloadUrl(id: string, fileId: string): Promise<DiscoveryEvidenceDownloadUrl>
154
+ /** Ends the caller's interview and starts the synthesis. Safe to repeat. */
155
+ complete(id: string): Promise<DiscoveryInterviewParticipation>
156
+ getParticipation(id: string): Promise<DiscoveryInterviewParticipation>
157
+ }
158
+
87
159
  class DiscoveryEvidenceServiceImpl implements DiscoveryEvidenceService {
88
160
  constructor(private readonly client: ProteosClient) {}
89
161
 
@@ -168,3 +240,114 @@ class PlatformDiscoveryEvidenceServiceImpl implements PlatformDiscoveryEvidenceS
168
240
  )
169
241
  }
170
242
  }
243
+
244
+ class DiscoveryInterviewDefinitionServiceImpl implements DiscoveryInterviewDefinitionService {
245
+ constructor(private readonly client: ProteosClient) {}
246
+
247
+ private path(id?: string, suffix = ''): string {
248
+ const base = `${DISCOVERY_BASE_PATH}/interview-definitions`
249
+ return id === undefined ? base : `${base}/${encode(id)}${suffix}`
250
+ }
251
+
252
+ create(
253
+ request: CreateDiscoveryInterviewDefinitionRequest,
254
+ ): Promise<DiscoveryInterviewDefinition> {
255
+ return this.client.request('POST', this.path(), request)
256
+ }
257
+
258
+ list(
259
+ query: ListDiscoveryInterviewDefinitionsQuery = {},
260
+ ): Promise<ListResponse<DiscoveryInterviewDefinition>> {
261
+ return this.client.requestWithQuery('GET', this.path(), query)
262
+ }
263
+
264
+ get(id: string): Promise<DiscoveryInterviewDefinition> {
265
+ return this.client.request('GET', this.path(id))
266
+ }
267
+
268
+ update(
269
+ id: string,
270
+ request: UpdateDiscoveryInterviewDefinitionRequest,
271
+ ): Promise<DiscoveryInterviewDefinition> {
272
+ return this.client.request('PATCH', this.path(id), request)
273
+ }
274
+
275
+ async delete(id: string): Promise<void> {
276
+ await this.client.request('DELETE', this.path(id))
277
+ }
278
+
279
+ publish(id: string): Promise<DiscoveryInterviewDefinition> {
280
+ return this.client.request('POST', this.path(id, '/publish'))
281
+ }
282
+
283
+ close(id: string): Promise<DiscoveryInterviewDefinition> {
284
+ return this.client.request('POST', this.path(id, '/close'))
285
+ }
286
+
287
+ reopen(id: string): Promise<DiscoveryInterviewDefinition> {
288
+ return this.client.request('POST', this.path(id, '/reopen'))
289
+ }
290
+
291
+ async invite(
292
+ id: string,
293
+ request: InviteDiscoveryInterviewParticipantsRequest,
294
+ ): Promise<DiscoveryInterview[]> {
295
+ const response = await this.client.request<{ data: DiscoveryInterview[] }>(
296
+ 'POST',
297
+ this.path(id, '/interviews'),
298
+ request,
299
+ )
300
+ return response.data
301
+ }
302
+
303
+ getParticipation(id: string): Promise<DiscoveryInterviewParticipation> {
304
+ return this.client.request('GET', this.path(id, '/participation'))
305
+ }
306
+
307
+ startParticipation(
308
+ id: string,
309
+ request: StartDiscoveryInterviewParticipationRequest,
310
+ ): Promise<DiscoveryInterviewParticipation> {
311
+ return this.client.request('POST', this.path(id, '/participation/start'), request)
312
+ }
313
+ }
314
+
315
+ class DiscoveryInterviewServiceImpl implements DiscoveryInterviewService {
316
+ constructor(private readonly client: ProteosClient) {}
317
+
318
+ private path(id: string, suffix = ''): string {
319
+ return `${DISCOVERY_BASE_PATH}/interviews/${encode(id)}${suffix}`
320
+ }
321
+
322
+ list(query: ListDiscoveryInterviewsQuery): Promise<ListResponse<DiscoveryInterview>> {
323
+ return this.client.requestWithQuery('GET', `${DISCOVERY_BASE_PATH}/interviews`, query)
324
+ }
325
+
326
+ get(id: string): Promise<DiscoveryInterview> {
327
+ return this.client.request('GET', this.path(id))
328
+ }
329
+
330
+ async remind(id: string): Promise<void> {
331
+ await this.client.request('POST', this.path(id, '/remind'))
332
+ }
333
+
334
+ synthesize(id: string): Promise<DiscoveryInterview> {
335
+ return this.client.request('POST', this.path(id, '/synthesize'))
336
+ }
337
+
338
+ async delete(id: string): Promise<void> {
339
+ await this.client.request('DELETE', this.path(id))
340
+ }
341
+
342
+ createDownloadUrl(id: string, fileId: string): Promise<DiscoveryEvidenceDownloadUrl> {
343
+ return this.client.request('POST', this.path(id, `/files/${encode(fileId)}/download-url`))
344
+ }
345
+
346
+ complete(id: string): Promise<DiscoveryInterviewParticipation> {
347
+ return this.client.request('POST', this.path(id, '/complete'), {})
348
+ }
349
+
350
+ getParticipation(id: string): Promise<DiscoveryInterviewParticipation> {
351
+ return this.client.request('GET', this.path(id, '/participation'))
352
+ }
353
+ }