orchestrator-client 5.7.3 → 5.7.10

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/dist/index.d.ts CHANGED
@@ -83,12 +83,15 @@ interface AttachmentMeta {
83
83
  interface ToolCall {
84
84
  id: string;
85
85
  type: string;
86
- function: Record<string, unknown>;
86
+ function: {
87
+ name: string;
88
+ arguments: string;
89
+ };
87
90
  }
88
91
  interface Message {
89
92
  id: number;
90
93
  role: string;
91
- content: string;
94
+ content: string | null;
92
95
  createdAt: string;
93
96
  kind: string | null;
94
97
  name: string | null;
@@ -233,7 +236,10 @@ interface SystemStatusSettings {
233
236
  translateModelId: string | null;
234
237
  maxConcurrentTasksPerReplica: number | null;
235
238
  subagentsEnabled: boolean | null;
236
- localizationTargets: Record<string, string>[] | null;
239
+ localizationTargets: {
240
+ locale: string;
241
+ language: string;
242
+ }[] | null;
237
243
  }
238
244
  interface SystemStatus {
239
245
  isConfigured: boolean;
@@ -242,15 +248,35 @@ interface SystemStatus {
242
248
  version: number;
243
249
  }
244
250
  interface LLMBackendInfo {
245
- host: string;
251
+ baseUrl: string;
246
252
  models: string[];
247
253
  }
254
+ interface LLMModelVisionInfo {
255
+ modelId: string;
256
+ visionCapable: boolean;
257
+ }
258
+ interface LLMModelContextInfo {
259
+ modelId: string;
260
+ contextLimit: number;
261
+ }
262
+ interface LLMBackendStatus {
263
+ backends: LLMBackendInfo[];
264
+ totalBackends: number;
265
+ allAvailableModels: string[];
266
+ modelsVision?: LLMModelVisionInfo[];
267
+ modelsContext?: LLMModelContextInfo[];
268
+ }
248
269
  interface MCPServerInfo {
249
270
  baseUrl: string;
250
271
  name: string;
251
272
  description: string;
252
273
  tools: string[];
253
274
  }
275
+ interface MCPServerStatus {
276
+ servers: MCPServerInfo[];
277
+ totalServers: number;
278
+ allAvailableTools: string[];
279
+ }
254
280
  interface TaskHandlerReplica {
255
281
  holderId: string;
256
282
  maxConcurrentTasksPerReplica: number;
@@ -554,6 +580,7 @@ declare class OrchestratorAsync {
554
580
  protected _insecure: boolean;
555
581
  close(): Promise<void>;
556
582
  protected _makeUrl(path: string): string;
583
+ protected _makeAbsoluteUrl(path: string): URL;
557
584
  protected _resolveHeaders(): Promise<Record<string, string>>;
558
585
  protected _request(method: string, path: string, opts?: {
559
586
  jsonBody?: unknown;
@@ -599,13 +626,15 @@ declare class OrchestratorAsync {
599
626
  excludeArchived?: boolean;
600
627
  locale?: string;
601
628
  }): Promise<ConversationResult>;
602
- getArchivedMessageContent(taskId: string, messageId: number): Promise<Record<string, unknown>>;
629
+ getArchivedMessageContent(taskId: string, messageId: number): Promise<ArchivedContent>;
603
630
  getTaskCompactions(taskId: string): Promise<CompactionEvent[]>;
604
631
  getTaskJournal(taskId: string): Promise<TaskJournal>;
605
632
  cancelTask(taskId: string): Promise<TaskCancelResponse>;
606
633
  deleteTask(taskId: string): Promise<TaskDeleteResult>;
607
634
  deleteTasks(taskIds: string[]): Promise<TaskDeleteResult>;
608
- uploadAttachment(file: File | Blob, filename?: string): Promise<AttachmentUploadResponse>;
635
+ uploadAttachment(file: File | Blob, filename?: string, options?: {
636
+ signal?: AbortSignal;
637
+ }): Promise<AttachmentUploadResponse>;
609
638
  downloadAttachment(attachmentId: string): Promise<Blob>;
610
639
  sendInteractiveMessage(taskId: string, message: string, attachmentIds?: string[]): Promise<SuccessResponse>;
611
640
  markInteractiveComplete(taskId: string): Promise<SuccessResponse>;
@@ -698,7 +727,7 @@ declare class OrchestratorAsync {
698
727
  }): Promise<ErrorEventListResult>;
699
728
  getErrorDetail(errorId: string): Promise<ErrorEventDetail>;
700
729
  getErrorStats(since?: string, topN?: number): Promise<ErrorStatsResult>;
701
- countErrors(since?: string): Promise<ErrorCountResult>;
730
+ countErrors(since?: string, severity?: string[]): Promise<ErrorCountResult>;
702
731
  purgeErrors(): Promise<ErrorPurgeResult>;
703
732
  health(): Promise<HealthStatus>;
704
733
  healthDetailed(): Promise<HealthDetail>;
@@ -706,14 +735,14 @@ declare class OrchestratorAsync {
706
735
  healthLeader(): Promise<LeaderStatus>;
707
736
  getMetrics(types?: string): Promise<MetricSnapshot>;
708
737
  getSystemStatus(): Promise<SystemStatus>;
709
- updateSettings(settings: Record<string, unknown>): Promise<SystemStatus>;
738
+ updateSettings(settings: Partial<SystemStatusSettings>): Promise<SystemStatus>;
710
739
  getConfigurationStatus(): Promise<ConfigurationStatus>;
711
740
  setAgentModel(model: string): Promise<SuccessResponse>;
712
741
  setOrchestratorModel(model: string): Promise<SuccessResponse>;
713
- getLLMBackendStatus(): Promise<Record<string, unknown>>;
742
+ getLLMBackendStatus(): Promise<LLMBackendStatus>;
714
743
  addLLMBackend(host: string, apiKey: string): Promise<SuccessResponse>;
715
744
  removeLLMBackend(host: string): Promise<SuccessResponse>;
716
- getMCPServerStatus(): Promise<Record<string, unknown>>;
745
+ getMCPServerStatus(): Promise<MCPServerStatus>;
717
746
  addMCPServer(host: string, apiKey: string): Promise<SuccessResponse>;
718
747
  removeMCPServer(host: string): Promise<SuccessResponse>;
719
748
  getTaskHandlerStatus(): Promise<TaskHandlerStatus>;
@@ -749,13 +778,15 @@ declare class Orchestrator {
749
778
  getTaskStatus(taskId: string, locale?: string): TaskDetail;
750
779
  setTaskStatus(taskId: string, status: string): SuccessResponse;
751
780
  getTaskConversation(taskId: string, params?: Parameters<OrchestratorAsync["getTaskConversation"]>[1]): ConversationResult;
752
- getArchivedMessageContent(taskId: string, messageId: number): Record<string, unknown>;
781
+ getArchivedMessageContent(taskId: string, messageId: number): ArchivedContent;
753
782
  getTaskCompactions(taskId: string): CompactionEvent[];
754
783
  getTaskJournal(taskId: string): TaskJournal;
755
784
  cancelTask(taskId: string): TaskCancelResponse;
756
785
  deleteTask(taskId: string): TaskDeleteResult;
757
786
  deleteTasks(taskIds: string[]): TaskDeleteResult;
758
- uploadAttachment(file: File | Blob, filename?: string): AttachmentUploadResponse;
787
+ uploadAttachment(file: File | Blob, filename?: string, options?: {
788
+ signal?: AbortSignal;
789
+ }): AttachmentUploadResponse;
759
790
  downloadAttachment(attachmentId: string): Blob;
760
791
  sendInteractiveMessage(taskId: string, message: string, attachmentIds?: string[]): SuccessResponse;
761
792
  markInteractiveComplete(taskId: string): SuccessResponse;
@@ -819,7 +850,7 @@ declare class Orchestrator {
819
850
  listErrors(params?: Parameters<OrchestratorAsync["listErrors"]>[0]): ErrorEventListResult;
820
851
  getErrorDetail(errorId: string): ErrorEventDetail;
821
852
  getErrorStats(since?: string): ErrorStatsResult;
822
- countErrors(since?: string): ErrorCountResult;
853
+ countErrors(since?: string, severity?: string[]): ErrorCountResult;
823
854
  purgeErrors(): ErrorPurgeResult;
824
855
  health(): HealthStatus;
825
856
  healthDetailed(): HealthDetail;
@@ -831,10 +862,10 @@ declare class Orchestrator {
831
862
  getConfigurationStatus(): ConfigurationStatus;
832
863
  setAgentModel(model: string): SuccessResponse;
833
864
  setOrchestratorModel(model: string): SuccessResponse;
834
- getLLMBackendStatus(): Record<string, unknown>;
865
+ getLLMBackendStatus(): LLMBackendStatus;
835
866
  addLLMBackend(host: string, apiKey: string): SuccessResponse;
836
867
  removeLLMBackend(host: string): SuccessResponse;
837
- getMCPServerStatus(): Record<string, unknown>;
868
+ getMCPServerStatus(): MCPServerStatus;
838
869
  addMCPServer(host: string, apiKey: string): SuccessResponse;
839
870
  removeMCPServer(host: string): SuccessResponse;
840
871
  getTaskHandlerStatus(): TaskHandlerStatus;
@@ -991,6 +1022,11 @@ declare class RealtimeClient {
991
1022
  /**
992
1023
  * Dispatch a message envelope to registered handlers and subscribers.
993
1024
  * The server sends: socket.emit("message", {type: "message", event: {..., event_type: "...", ...}})
1025
+ *
1026
+ * All event payloads are deep-converted from snake_case to camelCase so
1027
+ * consumers receive consistent camelCase objects (same convention as the
1028
+ * REST responses from _request). The raw event_type string is extracted
1029
+ * before conversion so the handler-map lookup still works.
994
1030
  */
995
1031
  private _dispatch;
996
1032
  /**
@@ -1119,7 +1155,7 @@ declare class OrchestratorConnectionError extends OrchestratorError {
1119
1155
  * Authentication or authorization failure (401/403).
1120
1156
  */
1121
1157
  declare class OrchestratorAuthError extends OrchestratorError {
1122
- constructor(message: string, statusCode?: number);
1158
+ constructor(message: string, statusCode?: number, errorCode?: string | null);
1123
1159
  }
1124
1160
  /**
1125
1161
  * Requested resource does not exist (404).
@@ -1145,6 +1181,185 @@ declare class OrchestratorConfigError extends OrchestratorError {
1145
1181
  constructor(message: string);
1146
1182
  }
1147
1183
 
1184
+ /**
1185
+ * Flow abstraction — reusable orchestrator workflow patterns.
1186
+ *
1187
+ * Every {@link Flow} subclass describes a complete orchestrator workflow
1188
+ * from trigger to parsed result. The base class handles task creation,
1189
+ * listening for completion via Socket.IO events, conversation retrieval,
1190
+ * and result parsing; subclasses only need to define the workflow
1191
+ * parameters and implement {@link Flow.parseResult}.
1192
+ *
1193
+ * Usage:
1194
+ *
1195
+ * ```ts
1196
+ * class MyFlow extends Flow<MyResult> {
1197
+ * get goalPrompt() { return "Do the thing"; }
1198
+ * parseResult(finalMessage: string): MyResult { ... }
1199
+ * }
1200
+ *
1201
+ * const result = await new MyFlow().run({ client: orchestrator });
1202
+ * ```
1203
+ *
1204
+ * @module
1205
+ */
1206
+
1207
+ /** Default timeout for Socket.IO-based completion waiting (10 minutes). */
1208
+ declare const DEFAULT_FLOW_TIMEOUT_MS = 600000;
1209
+ /**
1210
+ * Set the default {@link OrchestratorAsync} and optional
1211
+ * {@link RealtimeClient} for all flows in this process.
1212
+ *
1213
+ * Call once during application startup so that `flow.run()` can be
1214
+ * invoked without passing `client` explicitly.
1215
+ */
1216
+ declare function setupDefaultClient(client: OrchestratorAsync, realtime?: RealtimeClient): void;
1217
+ /** Raised when a flow execution fails. */
1218
+ declare class FlowError extends Error {
1219
+ constructor(message: string);
1220
+ }
1221
+ /** Raised when a flow's task does not reach a terminal state in time. */
1222
+ declare class FlowTimeoutError extends FlowError {
1223
+ constructor(message: string);
1224
+ }
1225
+ /** Raised when a flow's orchestrator task was explicitly cancelled. */
1226
+ declare class FlowCancelledError extends FlowError {
1227
+ /** The orchestrator task ID that was cancelled. */
1228
+ taskId: string;
1229
+ constructor(taskId: string);
1230
+ }
1231
+ /**
1232
+ * Extract the first JSON object from an LLM message body.
1233
+ *
1234
+ * Strategy (in order of preference):
1235
+ * 0. The entire trimmed message is parsed directly via `JSON.parse`.
1236
+ * 1. A fenced code block explicitly tagged `json`.
1237
+ * 2. Any fenced code block that parses as valid JSON.
1238
+ * 3. The first `{…}` block that parses as valid JSON.
1239
+ *
1240
+ * @throws {FlowError} If nothing parses.
1241
+ */
1242
+ declare function extractJsonFromMessage(content: string): Record<string, unknown>;
1243
+ /** Optional parameters for {@link Flow.run}. */
1244
+ interface FlowRunParams {
1245
+ /** Orchestrator async client. Falls back to the module-level default. */
1246
+ client?: OrchestratorAsync;
1247
+ /**
1248
+ * Optional realtime client for Socket.IO-based completion waiting.
1249
+ * Falls back to the module-level default. When neither is available
1250
+ * the flow uses polling instead.
1251
+ */
1252
+ realtime?: RealtimeClient;
1253
+ /**
1254
+ * Maximum milliseconds to wait for completion.
1255
+ * Defaults to {@link DEFAULT_FLOW_TIMEOUT_MS}.
1256
+ */
1257
+ timeoutMs?: number;
1258
+ }
1259
+ /**
1260
+ * Abstract base class for an orchestrator workflow flow.
1261
+ *
1262
+ * @typeParam T - The typed result produced by {@link parseResult}.
1263
+ */
1264
+ declare abstract class Flow<T> {
1265
+ /** Orchestrator workflow type — `"proactive"` by default. */
1266
+ workflowId: string;
1267
+ /** Maximum agent turns before the orchestrator forces a failure. */
1268
+ maxIterations: number;
1269
+ /** LLM reasoning budget: `"low"`, `"medium"`, or `"high"`. */
1270
+ reasoningEffort: string;
1271
+ /**
1272
+ * Maximum milliseconds to wait for the orchestrator task to reach a
1273
+ * terminal state. When exceeded, {@link FlowTimeoutError} is raised.
1274
+ */
1275
+ flowTimeoutMs: number;
1276
+ /**
1277
+ * The task description the orchestrator agent receives.
1278
+ * This is the primary instruction — it tells the agent *what* to do.
1279
+ */
1280
+ abstract get goalPrompt(): string;
1281
+ /**
1282
+ * Optional system-prompt override.
1283
+ * When set, this replaces the orchestrator's default system prompt.
1284
+ */
1285
+ get systemPrompt(): string | undefined;
1286
+ /**
1287
+ * Optional developer-prompt override appended after system prompt.
1288
+ */
1289
+ get developerPrompt(): string | undefined;
1290
+ /**
1291
+ * Restrict which MCP / built-in tools the agent may use.
1292
+ * `undefined` means *all* tools are available. An empty array means
1293
+ * *no* tools — text-only reasoning.
1294
+ */
1295
+ get availableTools(): string[] | undefined;
1296
+ /**
1297
+ * Per-task feature toggles sent in the creation request.
1298
+ * By default summaries and translation are disabled since flow
1299
+ * output is typically machine-consumed, not human-read.
1300
+ * Override in subclasses that produce human-facing content.
1301
+ */
1302
+ get taskOptions(): TaskOptions;
1303
+ /**
1304
+ * Override the agent model for this flow.
1305
+ */
1306
+ get agentModelId(): string | undefined;
1307
+ /**
1308
+ * Override the orchestrator (validation) model for this flow.
1309
+ */
1310
+ get orchestratorModelId(): string | undefined;
1311
+ /**
1312
+ * Parse the agent's final message into a typed result.
1313
+ *
1314
+ * Called *after* the task reaches `"completed"` and the final
1315
+ * assistant message has been retrieved.
1316
+ *
1317
+ * @param finalMessage - The text content of the last assistant message.
1318
+ * @throws {FlowError} If the message cannot be parsed as expected.
1319
+ */
1320
+ abstract parseResult(finalMessage: string): T;
1321
+ private _lastTaskId?;
1322
+ /**
1323
+ * Cancel the underlying orchestrator task, if one is running.
1324
+ *
1325
+ * Calling `cancel()` after `run()` has returned is a no-op.
1326
+ * The `run()` promise will reject with {@link FlowCancelledError}
1327
+ * after the orchestrator task transitions to `"cancelled"`.
1328
+ */
1329
+ cancel(client?: OrchestratorAsync): Promise<void>;
1330
+ /**
1331
+ * Execute the flow end-to-end.
1332
+ *
1333
+ * @returns The parsed result.
1334
+ * @throws {FlowError} If the task fails, times out, or cannot be parsed.
1335
+ */
1336
+ run(params?: FlowRunParams): Promise<T>;
1337
+ private _waitForTerminal;
1338
+ private _waitViaSocketIO;
1339
+ private _waitViaPolling;
1340
+ private _getFinalMessage;
1341
+ private _sleep;
1342
+ }
1343
+
1344
+ /**
1345
+ * Convert a snake_case string to camelCase.
1346
+ * Only converts single-underscore sequences followed by a lowercase letter.
1347
+ * Leading/double underscores and all-caps segments are preserved.
1348
+ */
1349
+ declare function snakeToCamel(str: string): string;
1350
+ /**
1351
+ * Convert a camelCase string to snake_case.
1352
+ * Inserts an underscore before each uppercase letter and lowercases it.
1353
+ */
1354
+ declare function camelToSnake(str: string): string;
1355
+ /**
1356
+ * Recursively convert all object keys from snake_case to camelCase.
1357
+ * Arrays are mapped element-by-element.
1358
+ * Primitive values (strings, numbers, booleans, null) are returned unchanged —
1359
+ * only the *keys* of plain objects are converted, never the *values*.
1360
+ */
1361
+ declare function deepCamelCase<T>(obj: T): T;
1362
+
1148
1363
  /**
1149
1364
  * orchestrator-client — TypeScript/JavaScript client for the DAMIT AIOps Orchestrator.
1150
1365
  *
@@ -1162,4 +1377,4 @@ declare class OrchestratorConfigError extends OrchestratorError {
1162
1377
  */
1163
1378
  declare const VERSION = "5.6.0";
1164
1379
 
1165
- export { type ArchivedContent, type AttachmentMeta, type AttachmentUploadResponse, type AuthConfig, type CompactionEvent, type ComponentHealth, type ConfigurationStatus, type ConversationResult, EVENT_ERROR_EVENT_RECORDED, EVENT_MESSAGE_ADDED, EVENT_MESSAGE_STREAMING, EVENT_MESSAGE_SUMMARY_GENERATED, EVENT_MESSAGE_TRANSLATION_READY, EVENT_TASK_CREATED, EVENT_TASK_DELETED, EVENT_TASK_INSIGHT_UPDATED, EVENT_TASK_ITERATION_CHANGED, EVENT_TASK_RESULT_UPDATED, EVENT_TASK_STATUS_CHANGED, type ErrorCountResult, type ErrorEvent, type ErrorEventDetail, type ErrorPurgeResult, type ErrorStatsResult, type EventHandler, type HealthDetail, type HealthStatus, type LLMBackendInfo, type LeaderStatus, type LockStatus, type MCPServerInfo, type MatrixConversationResult, type Message, type MessageTranslation, type MessageTranslationReadyEvent, type MessageTranslationsResult, type MetricSnapshot, type MioContext, Orchestrator, OrchestratorAPIError, OrchestratorAsync, OrchestratorAuthError, type OrchestratorClientOptions, type OrchestratorConfig, OrchestratorConfigError, OrchestratorConnectionError, OrchestratorError, OrchestratorNotFoundError, type Pagination$1 as Pagination, type ReadinessCheck, type ReadinessResult, RealtimeClient, type RealtimeClientOptions, type SlotInfo, type SlotsStatus, type SuccessResponse, type SummaryWorkerStatus, type SystemStatus, type SystemStatusSettings, type TaskCancelResponse, type TaskCreateResponse, type TaskDeleteResult, type TaskDetail, type TaskHandlerCluster, type TaskHandlerReplica, type TaskHandlerStatus, type TaskHandlerStatusLocal, type TaskJournal, type TaskListResult, type TaskOptions, type TaskSummary, type TokenWorkerStatus, type ToolCall, type ToolInfo, type ToolsListResult, VERSION, type VSATaskCreateResponse, type WebSocketClientInfo, type WebSocketStatus, type WorkflowStates, createInsecureFetch, loadConfig };
1380
+ export { type ArchivedContent, type AttachmentMeta, type AttachmentUploadResponse, type AuthConfig, type CompactionEvent, type ComponentHealth, type ConfigurationStatus, type ConversationResult, DEFAULT_FLOW_TIMEOUT_MS, EVENT_ERROR_EVENT_RECORDED, EVENT_MESSAGE_ADDED, EVENT_MESSAGE_STREAMING, EVENT_MESSAGE_SUMMARY_GENERATED, EVENT_MESSAGE_TRANSLATION_READY, EVENT_TASK_CREATED, EVENT_TASK_DELETED, EVENT_TASK_INSIGHT_UPDATED, EVENT_TASK_ITERATION_CHANGED, EVENT_TASK_RESULT_UPDATED, EVENT_TASK_STATUS_CHANGED, type ErrorCountResult, type ErrorEvent, type ErrorEventDetail, type ErrorEventListResult, type ErrorPurgeResult, type ErrorStatsResult, type EventHandler, Flow, FlowCancelledError, FlowError, type FlowRunParams, FlowTimeoutError, type HealthDetail, type HealthStatus, type LLMBackendInfo, type LLMBackendStatus, type LLMModelContextInfo, type LLMModelVisionInfo, type LeaderStatus, type LockStatus, type MCPServerInfo, type MCPServerStatus, type MatrixConversationResult, type Message, type MessageDeleteMultipleResult, type MessageTranslation, type MessageTranslationReadyEvent, type MessageTranslationsResult, type MetricSnapshot, type MioContext, type MioMemoriesResult, type MioMemoryItem, Orchestrator, OrchestratorAPIError, OrchestratorAsync, OrchestratorAuthError, type OrchestratorClientOptions, type OrchestratorConfig, OrchestratorConfigError, OrchestratorConnectionError, OrchestratorError, OrchestratorNotFoundError, type Pagination$1 as Pagination, type ReadinessCheck, type ReadinessResult, RealtimeClient, type RealtimeClientOptions, type ReloadServicesResult, type ReloadStatus, type SlotInfo, type SlotsStatus, type SubagentsStatus, type SuccessResponse, type SummaryWorkerStatus, type SystemStatus, type SystemStatusSettings, type TaskCancelResponse, type TaskCreateResponse, type TaskDeleteResult, type TaskDetail, type TaskHandlerCluster, type TaskHandlerReplica, type TaskHandlerStatus, type TaskHandlerStatusLocal, type TaskJournal, type TaskListResult, type TaskOptions, type TaskSummary, type TokenWorkerStatus, type ToolCall, type ToolInfo, type ToolsListResult, VERSION, type VSATaskCreateResponse, type WebSocketClientInfo, type WebSocketStatus, type WorkflowStates, camelToSnake, createInsecureFetch, deepCamelCase, extractJsonFromMessage, loadConfig, setupDefaultClient, snakeToCamel };