@getmodus/sdk 0.2.2 → 0.3.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/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { c as components, H as HttpClient, M as ModusConfig, P as Page, A as AgentType, V as VariationView, a as Agent, C as ContextItem, b as ContextItemLookupRow, d as CustomContextItemsResource, e as ConversationKind, f as ConversationListItem, g as Conversation, S as ScopeConversationsResource, h as Skill, i as ModusClientBase, j as ModusOptions } from './conversations-BP2sI3Q5.cjs';
2
- export { k as ContextType, l as Message, O as OPERATIONS, m as OperationId, n as OperationSpec, o as SkillStatus, p as SkillVariation, q as conversationSkillId, r as operations, s as paths } from './conversations-BP2sI3Q5.cjs';
1
+ import { c as components, H as HttpClient, M as ModusConfig, P as Page, W as WorkflowType, V as VariationView, a as Workflow, C as ContextItem, b as ContextItemLookupRow, d as CustomContextItemsResource, e as ConversationKind, f as ConversationListItem, g as Conversation, S as ScopeConversationsResource, h as Scope, i as ModusClientBase, j as ModusOptions } from './conversations-GNBMPpyr.cjs';
2
+ export { A as Agent, k as AgentType, l as ContextType, m as Message, O as OPERATIONS, n as OperationId, o as OperationSpec, p as ScopeStatus, q as ScopeVariation, r as Skill, s as SkillStatus, t as SkillVariation, u as conversationScopeId, v as conversationSkillId, w as operations, x as paths } from './conversations-GNBMPpyr.cjs';
3
3
 
4
4
  declare class ModusError extends Error {
5
5
  readonly statusCode?: number;
@@ -187,12 +187,8 @@ type ModusContextRequest = components['schemas']['ModusContextRequestDto'];
187
187
  type SuggestionQuestion = components['schemas']['SuggestionQuestionDto'];
188
188
  type SuggestionEventType = components['schemas']['SuggestionEventType'];
189
189
  type SuggestionEventSource = components['schemas']['SuggestionEventSource'];
190
- /** Wire format (snake_case) plus camelCase aliases for DX. */
191
- type RecordSuggestionEventRequest = components['schemas']['RecordSuggestionEventDto'] & {
192
- eventType?: components['schemas']['SuggestionEventType'];
193
- skillId?: number;
194
- threadId?: string;
195
- };
190
+ /** Request body for recording a suggestion event (camelCase, matches the wire). */
191
+ type RecordSuggestionEventRequest = components['schemas']['RecordSuggestionEventDto'];
196
192
 
197
193
  declare class AgentWorkflowActionsResource {
198
194
  private readonly http;
@@ -216,24 +212,15 @@ declare class WorkflowsResource {
216
212
  pageSize?: number;
217
213
  pageToken?: string;
218
214
  search?: string;
219
- type?: AgentType;
215
+ type?: WorkflowType;
220
216
  view?: VariationView;
221
217
  includeVariation?: boolean;
222
- }): Promise<Page<Agent>>;
218
+ }): Promise<Page<Workflow>>;
223
219
  private listPage;
224
220
  get(workflowId: number | string, options?: {
225
221
  view?: VariationView;
226
222
  includeVariation?: boolean;
227
- }): Promise<Agent>;
228
- chat(workflowId: number | string, message: string, options: {
229
- model: ChatModel;
230
- threadId?: string;
231
- }): Promise<ChatResult>;
232
- chatStream(workflowId: number | string, message: string, options: {
233
- model: ChatModel;
234
- threadId?: string;
235
- version?: string;
236
- }): ChatStream;
223
+ }): Promise<Workflow>;
237
224
  }
238
225
 
239
226
  declare class ConnectionsResource {
@@ -334,11 +321,11 @@ declare class ScopesResource {
334
321
  search?: string;
335
322
  view?: VariationView;
336
323
  managerId?: number;
337
- }): Promise<Page<Skill>>;
324
+ }): Promise<Page<Scope>>;
338
325
  private listPage;
339
326
  get(scopeId: number | string, options?: {
340
327
  view?: VariationView;
341
- }): Promise<Skill>;
328
+ }): Promise<Scope>;
342
329
  getContext(scopeId: number | string, message: string, options?: {
343
330
  limit?: number;
344
331
  }): Promise<SkillContextComposition>;
@@ -360,8 +347,8 @@ declare class SuggestionsResource {
360
347
  list(options?: {
361
348
  pageSize?: number;
362
349
  pageToken?: string;
363
- skillId?: number;
364
- skillIds?: readonly number[];
350
+ scopeId?: number;
351
+ scopeIds?: readonly number[];
365
352
  }): Promise<Page<SuggestionQuestion>>;
366
353
  private listPage;
367
354
  recordEvent(id: string, event: RecordSuggestionEventRequest): Promise<void>;
@@ -378,4 +365,4 @@ declare class Modus extends ModusClientBase {
378
365
  constructor(options?: ModusOptions);
379
366
  }
380
367
 
381
- export { APIConnectionError, Agent, type AgentRun, type AgentRunCreateRequest, type AgentRunListItem, type AgentRunStream, AgentType, type ApprovalScope, type AssistantContentResetEvent, AuthenticationError, type CancelRunRequest, type CancelledEvent, type ChatModel, type ChatRequest, type ChatResult, ChatStream, type ComposeSkillContextRequest, ConflictError, type Connection, ContextItem, ContextItemLookupRow, type ContextValueRow, Conversation, ConversationKind, ConversationListItem, type CreateAgentRunRequest, type DoneEvent, type EditQueuedRunRequest, type ErrorEvent, InternalServerError, type InterruptRunRequest, Modus, type ModusContextComposition, type ModusContextRequest, ModusError, ModusOptions, type ModusRunCreateRequest, NotFoundError, Page, PermissionDeniedError, RateLimitError, type RecordSuggestionEventRequest, type ResumeRunRequest, RunCancelledError, type RunEvent, type RunStatus, type RunTimeframe, Skill, type SkillContextComposition, type SkillRunCreateRequest, StreamTimeoutError, type StreamTimeoutEvent, type SuggestionEventSource, type SuggestionEventType, type SuggestionQuestion, type TokenEvent, UnprocessableError, ValidationError, VariationView, type WorkflowActionRequest, components };
368
+ export { APIConnectionError, type AgentRun, type AgentRunCreateRequest, type AgentRunListItem, type AgentRunStream, type ApprovalScope, type AssistantContentResetEvent, AuthenticationError, type CancelRunRequest, type CancelledEvent, type ChatModel, type ChatRequest, type ChatResult, ChatStream, type ComposeSkillContextRequest, ConflictError, type Connection, ContextItem, ContextItemLookupRow, type ContextValueRow, Conversation, ConversationKind, ConversationListItem, type CreateAgentRunRequest, type DoneEvent, type EditQueuedRunRequest, type ErrorEvent, InternalServerError, type InterruptRunRequest, Modus, type ModusContextComposition, type ModusContextRequest, ModusError, ModusOptions, type ModusRunCreateRequest, NotFoundError, Page, PermissionDeniedError, RateLimitError, type RecordSuggestionEventRequest, type ResumeRunRequest, RunCancelledError, type RunEvent, type RunStatus, type RunTimeframe, Scope, type SkillContextComposition, type SkillRunCreateRequest, StreamTimeoutError, type StreamTimeoutEvent, type SuggestionEventSource, type SuggestionEventType, type SuggestionQuestion, type TokenEvent, UnprocessableError, ValidationError, VariationView, Workflow, type WorkflowActionRequest, WorkflowType, components };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { c as components, H as HttpClient, M as ModusConfig, P as Page, A as AgentType, V as VariationView, a as Agent, C as ContextItem, b as ContextItemLookupRow, d as CustomContextItemsResource, e as ConversationKind, f as ConversationListItem, g as Conversation, S as ScopeConversationsResource, h as Skill, i as ModusClientBase, j as ModusOptions } from './conversations-BP2sI3Q5.js';
2
- export { k as ContextType, l as Message, O as OPERATIONS, m as OperationId, n as OperationSpec, o as SkillStatus, p as SkillVariation, q as conversationSkillId, r as operations, s as paths } from './conversations-BP2sI3Q5.js';
1
+ import { c as components, H as HttpClient, M as ModusConfig, P as Page, W as WorkflowType, V as VariationView, a as Workflow, C as ContextItem, b as ContextItemLookupRow, d as CustomContextItemsResource, e as ConversationKind, f as ConversationListItem, g as Conversation, S as ScopeConversationsResource, h as Scope, i as ModusClientBase, j as ModusOptions } from './conversations-GNBMPpyr.js';
2
+ export { A as Agent, k as AgentType, l as ContextType, m as Message, O as OPERATIONS, n as OperationId, o as OperationSpec, p as ScopeStatus, q as ScopeVariation, r as Skill, s as SkillStatus, t as SkillVariation, u as conversationScopeId, v as conversationSkillId, w as operations, x as paths } from './conversations-GNBMPpyr.js';
3
3
 
4
4
  declare class ModusError extends Error {
5
5
  readonly statusCode?: number;
@@ -187,12 +187,8 @@ type ModusContextRequest = components['schemas']['ModusContextRequestDto'];
187
187
  type SuggestionQuestion = components['schemas']['SuggestionQuestionDto'];
188
188
  type SuggestionEventType = components['schemas']['SuggestionEventType'];
189
189
  type SuggestionEventSource = components['schemas']['SuggestionEventSource'];
190
- /** Wire format (snake_case) plus camelCase aliases for DX. */
191
- type RecordSuggestionEventRequest = components['schemas']['RecordSuggestionEventDto'] & {
192
- eventType?: components['schemas']['SuggestionEventType'];
193
- skillId?: number;
194
- threadId?: string;
195
- };
190
+ /** Request body for recording a suggestion event (camelCase, matches the wire). */
191
+ type RecordSuggestionEventRequest = components['schemas']['RecordSuggestionEventDto'];
196
192
 
197
193
  declare class AgentWorkflowActionsResource {
198
194
  private readonly http;
@@ -216,24 +212,15 @@ declare class WorkflowsResource {
216
212
  pageSize?: number;
217
213
  pageToken?: string;
218
214
  search?: string;
219
- type?: AgentType;
215
+ type?: WorkflowType;
220
216
  view?: VariationView;
221
217
  includeVariation?: boolean;
222
- }): Promise<Page<Agent>>;
218
+ }): Promise<Page<Workflow>>;
223
219
  private listPage;
224
220
  get(workflowId: number | string, options?: {
225
221
  view?: VariationView;
226
222
  includeVariation?: boolean;
227
- }): Promise<Agent>;
228
- chat(workflowId: number | string, message: string, options: {
229
- model: ChatModel;
230
- threadId?: string;
231
- }): Promise<ChatResult>;
232
- chatStream(workflowId: number | string, message: string, options: {
233
- model: ChatModel;
234
- threadId?: string;
235
- version?: string;
236
- }): ChatStream;
223
+ }): Promise<Workflow>;
237
224
  }
238
225
 
239
226
  declare class ConnectionsResource {
@@ -334,11 +321,11 @@ declare class ScopesResource {
334
321
  search?: string;
335
322
  view?: VariationView;
336
323
  managerId?: number;
337
- }): Promise<Page<Skill>>;
324
+ }): Promise<Page<Scope>>;
338
325
  private listPage;
339
326
  get(scopeId: number | string, options?: {
340
327
  view?: VariationView;
341
- }): Promise<Skill>;
328
+ }): Promise<Scope>;
342
329
  getContext(scopeId: number | string, message: string, options?: {
343
330
  limit?: number;
344
331
  }): Promise<SkillContextComposition>;
@@ -360,8 +347,8 @@ declare class SuggestionsResource {
360
347
  list(options?: {
361
348
  pageSize?: number;
362
349
  pageToken?: string;
363
- skillId?: number;
364
- skillIds?: readonly number[];
350
+ scopeId?: number;
351
+ scopeIds?: readonly number[];
365
352
  }): Promise<Page<SuggestionQuestion>>;
366
353
  private listPage;
367
354
  recordEvent(id: string, event: RecordSuggestionEventRequest): Promise<void>;
@@ -378,4 +365,4 @@ declare class Modus extends ModusClientBase {
378
365
  constructor(options?: ModusOptions);
379
366
  }
380
367
 
381
- export { APIConnectionError, Agent, type AgentRun, type AgentRunCreateRequest, type AgentRunListItem, type AgentRunStream, AgentType, type ApprovalScope, type AssistantContentResetEvent, AuthenticationError, type CancelRunRequest, type CancelledEvent, type ChatModel, type ChatRequest, type ChatResult, ChatStream, type ComposeSkillContextRequest, ConflictError, type Connection, ContextItem, ContextItemLookupRow, type ContextValueRow, Conversation, ConversationKind, ConversationListItem, type CreateAgentRunRequest, type DoneEvent, type EditQueuedRunRequest, type ErrorEvent, InternalServerError, type InterruptRunRequest, Modus, type ModusContextComposition, type ModusContextRequest, ModusError, ModusOptions, type ModusRunCreateRequest, NotFoundError, Page, PermissionDeniedError, RateLimitError, type RecordSuggestionEventRequest, type ResumeRunRequest, RunCancelledError, type RunEvent, type RunStatus, type RunTimeframe, Skill, type SkillContextComposition, type SkillRunCreateRequest, StreamTimeoutError, type StreamTimeoutEvent, type SuggestionEventSource, type SuggestionEventType, type SuggestionQuestion, type TokenEvent, UnprocessableError, ValidationError, VariationView, type WorkflowActionRequest, components };
368
+ export { APIConnectionError, type AgentRun, type AgentRunCreateRequest, type AgentRunListItem, type AgentRunStream, type ApprovalScope, type AssistantContentResetEvent, AuthenticationError, type CancelRunRequest, type CancelledEvent, type ChatModel, type ChatRequest, type ChatResult, ChatStream, type ComposeSkillContextRequest, ConflictError, type Connection, ContextItem, ContextItemLookupRow, type ContextValueRow, Conversation, ConversationKind, ConversationListItem, type CreateAgentRunRequest, type DoneEvent, type EditQueuedRunRequest, type ErrorEvent, InternalServerError, type InterruptRunRequest, Modus, type ModusContextComposition, type ModusContextRequest, ModusError, ModusOptions, type ModusRunCreateRequest, NotFoundError, Page, PermissionDeniedError, RateLimitError, type RecordSuggestionEventRequest, type ResumeRunRequest, RunCancelledError, type RunEvent, type RunStatus, type RunTimeframe, Scope, type SkillContextComposition, type SkillRunCreateRequest, StreamTimeoutError, type StreamTimeoutEvent, type SuggestionEventSource, type SuggestionEventType, type SuggestionQuestion, type TokenEvent, UnprocessableError, ValidationError, VariationView, Workflow, type WorkflowActionRequest, WorkflowType, components };
package/dist/index.js CHANGED
@@ -29,10 +29,14 @@ import {
29
29
  validateChatModel,
30
30
  validateId,
31
31
  validatePageSize
32
- } from "./chunk-OUFN2O5C.js";
32
+ } from "./chunk-D3NU2M6B.js";
33
33
 
34
- // src/_chat.ts
34
+ // src/_agent_run_request.ts
35
35
  import { randomUUID } from "crypto";
36
+ function resolveAgentRunSessionId(sessionId) {
37
+ if (typeof sessionId === "string" && sessionId.trim()) return sessionId.trim();
38
+ return randomUUID();
39
+ }
36
40
 
37
41
  // src/_streaming.ts
38
42
  var SILENTLY_IGNORED = /* @__PURE__ */ new Set([
@@ -125,7 +129,7 @@ function effectiveThreadId(threadId) {
125
129
  return threadId;
126
130
  }
127
131
  function resolveSessionId(threadId) {
128
- return effectiveThreadId(threadId) ?? randomUUID();
132
+ return resolveAgentRunSessionId(effectiveThreadId(threadId));
129
133
  }
130
134
  function chatPath(resource, resourceId, options) {
131
135
  const safeId = encodeURIComponent(String(resourceId));
@@ -265,18 +269,22 @@ function modusChatStreamSession(http, config, message, options) {
265
269
  );
266
270
  }
267
271
 
268
- // src/types/agents.ts
269
- var AgentType = {
272
+ // src/types/workflows.ts
273
+ var WorkflowType = {
270
274
  task: "task",
271
275
  workflow: "workflow"
272
276
  };
277
+ var AgentType = WorkflowType;
273
278
 
274
279
  // src/types/conversations.ts
280
+ function conversationScopeId(item) {
281
+ return item.scopeId === 0 ? void 0 : item.scopeId;
282
+ }
275
283
  function conversationSkillId(item) {
276
- return item.skillId === 0 ? void 0 : item.skillId;
284
+ return item.scopeId;
277
285
  }
278
286
 
279
- // src/resources/agents/runs.ts
287
+ // src/resources/workflows/runs.ts
280
288
  import { randomUUID as randomUUID2 } from "crypto";
281
289
  var RUNS_MAX_PAGE_SIZE = 100;
282
290
  function runsListParams(pageSize, pageToken, status, timeframe, approvalScope, search) {
@@ -327,6 +335,9 @@ function parseActiveRunsPage(raw, fetchPage) {
327
335
  function randomRunId() {
328
336
  return randomUUID2();
329
337
  }
338
+ function sessionIdFromBody(body) {
339
+ return resolveAgentRunSessionId(body.sessionId);
340
+ }
330
341
  function makeAgentRunStream(runId, events) {
331
342
  return {
332
343
  runId,
@@ -463,10 +474,12 @@ var WorkflowRunsResource = class {
463
474
  }
464
475
  createRun(operationId, body, pathParams, options) {
465
476
  const runId = options.idempotencyKey?.trim() || body.runId?.trim() || randomRunId();
477
+ const sessionId = sessionIdFromBody(body);
466
478
  const op = getOperation(operationId);
467
479
  const path = formatOperationPath(operationId, pathParams);
468
480
  const lines = this.http.streamPost(path, {
469
481
  ...body,
482
+ sessionId,
470
483
  streamProtocolVersion: 2
471
484
  }, {
472
485
  baseUrl: operationBaseUrl(this.http, op),
@@ -479,7 +492,7 @@ var WorkflowRunsResource = class {
479
492
  }
480
493
  };
481
494
 
482
- // src/resources/agents/workflow-actions.ts
495
+ // src/resources/workflows/workflow-actions.ts
483
496
  import { randomUUID as randomUUID3 } from "crypto";
484
497
  function randomRunId2() {
485
498
  return randomUUID3();
@@ -511,7 +524,7 @@ var AgentWorkflowActionsResource = class {
511
524
  }
512
525
  };
513
526
 
514
- // src/resources/agents.ts
527
+ // src/resources/workflows.ts
515
528
  function workflowsListParams(pageSize, pageToken, search, type, view, includeVariation) {
516
529
  const extra = {};
517
530
  if (search !== void 0) extra.search = search;
@@ -557,7 +570,7 @@ var WorkflowsResource = class {
557
570
  );
558
571
  return buildAipPage(
559
572
  data,
560
- "agents",
573
+ "workflows",
561
574
  parseWorkflow,
562
575
  (token) => this.listPage(pageSize, token, search, type, view, includeVariation)
563
576
  );
@@ -575,12 +588,6 @@ var WorkflowsResource = class {
575
588
  });
576
589
  return parseWorkflow(data);
577
590
  }
578
- chat(workflowId, message, options) {
579
- return chatBuffered(this.http, "workflows", workflowId, message, options);
580
- }
581
- chatStream(workflowId, message, options) {
582
- return chatStreamSession(this.http, this.config, "workflows", workflowId, message, options);
583
- }
584
591
  };
585
592
 
586
593
  // src/resources/connections.ts
@@ -731,7 +738,7 @@ var ContextResource = class {
731
738
  };
732
739
 
733
740
  // src/resources/modus/conversations.ts
734
- var ALLOWED_KINDS = /* @__PURE__ */ new Set(["all", "modus", "skills"]);
741
+ var ALLOWED_KINDS = /* @__PURE__ */ new Set(["all", "modus", "scopes"]);
735
742
  function listParams(pageSize, pageToken, kind) {
736
743
  if (kind !== void 0 && !ALLOWED_KINDS.has(kind)) {
737
744
  throw new Error(
@@ -801,7 +808,7 @@ var ModusResource = class {
801
808
  }
802
809
  };
803
810
 
804
- // src/resources/skills.ts
811
+ // src/resources/scopes.ts
805
812
  function scopesListParams(pageSize, pageToken, search, view, managerId) {
806
813
  const extra = {};
807
814
  if (search !== void 0) extra.search = search;
@@ -839,7 +846,7 @@ var ScopesResource = class {
839
846
  );
840
847
  return buildAipPage(
841
848
  data,
842
- "skills",
849
+ "scopes",
843
850
  parseScope,
844
851
  (token) => this.listPage(pageSize, token, search, view, managerId)
845
852
  );
@@ -869,24 +876,6 @@ var ScopesResource = class {
869
876
  }
870
877
  };
871
878
 
872
- // src/types/suggestions.ts
873
- function normalizeRecordSuggestionEvent(event) {
874
- const eventType = event.event_type ?? event.eventType;
875
- if (eventType === void 0) {
876
- throw new Error("recordEvent requires event_type (or eventType)");
877
- }
878
- const body = {
879
- event_type: eventType,
880
- source: event.source
881
- };
882
- const skillId = event.skill_id ?? event.skillId;
883
- if (skillId !== void 0) body.skill_id = skillId;
884
- const threadId = event.thread_id ?? event.threadId;
885
- if (threadId !== void 0) body.thread_id = threadId;
886
- if (event.metadata !== void 0) body.metadata = event.metadata;
887
- return body;
888
- }
889
-
890
879
  // src/resources/suggestions.ts
891
880
  var DEFAULT_SUGGESTIONS_PAGE_SIZE = 5;
892
881
  var MAX_SUGGESTIONS_PAGE_SIZE = 12;
@@ -897,8 +886,8 @@ function suggestionListParams(options) {
897
886
  return {
898
887
  pageSize: options.pageSize,
899
888
  pageToken: options.pageToken,
900
- skill_id: options.skillId,
901
- skill_ids: options.skillIds?.join(",")
889
+ scopeId: options.scopeId,
890
+ scopeIds: options.scopeIds?.join(",")
902
891
  };
903
892
  }
904
893
  var SuggestionsResource = class {
@@ -909,26 +898,26 @@ var SuggestionsResource = class {
909
898
  list(options = {}) {
910
899
  const pageSize = options.pageSize ?? DEFAULT_SUGGESTIONS_PAGE_SIZE;
911
900
  validatePageSize(pageSize, MAX_SUGGESTIONS_PAGE_SIZE);
912
- return this.listPage(pageSize, options.pageToken, options.skillId, options.skillIds);
901
+ return this.listPage(pageSize, options.pageToken, options.scopeId, options.scopeIds);
913
902
  }
914
- async listPage(pageSize, pageToken, skillId, skillIds) {
903
+ async listPage(pageSize, pageToken, scopeId, scopeIds) {
915
904
  const data = asRecord(
916
905
  await invokeWithRetry(this.config, this.http, "SuggestionsController_listApproved", {
917
- query: suggestionListParams({ pageSize, pageToken, skillId, skillIds })
906
+ query: suggestionListParams({ pageSize, pageToken, scopeId, scopeIds })
918
907
  })
919
908
  );
920
909
  return buildAipPage(
921
910
  data,
922
911
  "suggestions",
923
912
  parseSuggestion,
924
- (token) => this.listPage(pageSize, token, skillId, skillIds)
913
+ (token) => this.listPage(pageSize, token, scopeId, scopeIds)
925
914
  );
926
915
  }
927
916
  async recordEvent(id, event) {
928
917
  validateId(id, "id");
929
918
  await invokeWithRetry(this.config, this.http, "SuggestionsController_recordEvent", {
930
919
  pathParams: { id },
931
- jsonBody: normalizeRecordSuggestionEvent(event)
920
+ jsonBody: event
932
921
  });
933
922
  }
934
923
  };
@@ -963,6 +952,8 @@ export {
963
952
  StreamTimeoutError,
964
953
  UnprocessableError,
965
954
  ValidationError,
955
+ WorkflowType,
956
+ conversationScopeId,
966
957
  conversationSkillId
967
958
  };
968
959
  //# sourceMappingURL=index.js.map