@getmodus/sdk 0.2.1 → 0.2.2
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/CHANGELOG.md +5 -3
- package/README.md +4 -0
- package/dist/{chunk-UOBVSNOW.js → chunk-OUFN2O5C.js} +124 -93
- package/dist/chunk-OUFN2O5C.js.map +1 -0
- package/dist/{conversations-DoyTcWk6.d.cts → conversations-BP2sI3Q5.d.cts} +108 -90
- package/dist/{conversations-DoyTcWk6.d.ts → conversations-BP2sI3Q5.d.ts} +108 -90
- package/dist/index.cjs +237 -125
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -10
- package/dist/index.d.ts +26 -10
- package/dist/index.js +114 -34
- package/dist/index.js.map +1 -1
- package/dist/management/index.cjs +129 -93
- package/dist/management/index.cjs.map +1 -1
- package/dist/management/index.d.cts +1 -1
- package/dist/management/index.d.ts +1 -1
- package/dist/management/index.js +7 -2
- package/dist/management/index.js.map +1 -1
- package/package.json +2 -1
- package/dist/chunk-UOBVSNOW.js.map +0 -1
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-
|
|
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-
|
|
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';
|
|
3
3
|
|
|
4
4
|
declare class ModusError extends Error {
|
|
5
5
|
readonly statusCode?: number;
|
|
@@ -100,9 +100,10 @@ declare class ChatStream {
|
|
|
100
100
|
private readonly http;
|
|
101
101
|
private readonly path;
|
|
102
102
|
private readonly body;
|
|
103
|
+
private readonly baseUrl?;
|
|
103
104
|
private final?;
|
|
104
105
|
private readonly textParts;
|
|
105
|
-
constructor(http: HttpClient, path: string, body: Record<string, unknown
|
|
106
|
+
constructor(http: HttpClient, path: string, body: Record<string, unknown>, baseUrl?: string | undefined);
|
|
106
107
|
textStream(): AsyncGenerator<string>;
|
|
107
108
|
eventStream(): AsyncGenerator<RunEvent>;
|
|
108
109
|
private events;
|
|
@@ -124,7 +125,7 @@ type RunStatus = 'running' | 'awaiting_human' | 'completed' | 'error' | 'cancell
|
|
|
124
125
|
type RunTimeframe = 'last_hour' | 'last_day' | 'last_week' | (string & {});
|
|
125
126
|
type ApprovalScope = 'mine' | 'all' | (string & {});
|
|
126
127
|
|
|
127
|
-
interface AgentRunStream {
|
|
128
|
+
interface AgentRunStream extends AsyncIterable<RunEvent> {
|
|
128
129
|
readonly runId: string;
|
|
129
130
|
readonly events: AsyncIterable<RunEvent>;
|
|
130
131
|
}
|
|
@@ -146,16 +147,16 @@ declare class WorkflowRunsResource {
|
|
|
146
147
|
}): Promise<AgentRun>;
|
|
147
148
|
create(workflowId: number | string, body: CreateAgentRunRequest, options?: {
|
|
148
149
|
idempotencyKey?: string;
|
|
149
|
-
}):
|
|
150
|
+
}): AgentRunStream;
|
|
150
151
|
createScope(scopeId: number | string, body: SkillRunCreateRequest, options?: {
|
|
151
152
|
idempotencyKey?: string;
|
|
152
|
-
}):
|
|
153
|
+
}): AgentRunStream;
|
|
153
154
|
createModus(body: ModusRunCreateRequest, options?: {
|
|
154
155
|
idempotencyKey?: string;
|
|
155
|
-
}):
|
|
156
|
+
}): AgentRunStream;
|
|
156
157
|
resume(runId: string, body: ResumeRunRequest, options?: {
|
|
157
158
|
idempotencyKey?: string;
|
|
158
|
-
}):
|
|
159
|
+
}): AgentRunStream;
|
|
159
160
|
cancel(runId: string): Promise<void>;
|
|
160
161
|
events(runId: string): Promise<unknown>;
|
|
161
162
|
interrupt(runId: string): Promise<void>;
|
|
@@ -186,7 +187,12 @@ type ModusContextRequest = components['schemas']['ModusContextRequestDto'];
|
|
|
186
187
|
type SuggestionQuestion = components['schemas']['SuggestionQuestionDto'];
|
|
187
188
|
type SuggestionEventType = components['schemas']['SuggestionEventType'];
|
|
188
189
|
type SuggestionEventSource = components['schemas']['SuggestionEventSource'];
|
|
189
|
-
|
|
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
196
|
|
|
191
197
|
declare class AgentWorkflowActionsResource {
|
|
192
198
|
private readonly http;
|
|
@@ -194,7 +200,7 @@ declare class AgentWorkflowActionsResource {
|
|
|
194
200
|
constructor(http: HttpClient, config: ModusConfig);
|
|
195
201
|
execute(body: WorkflowActionRequest, options?: {
|
|
196
202
|
idempotencyKey?: string;
|
|
197
|
-
}):
|
|
203
|
+
}): AgentRunStream;
|
|
198
204
|
cancel(runId: string): Promise<void>;
|
|
199
205
|
private parseEvents;
|
|
200
206
|
}
|
|
@@ -219,6 +225,15 @@ declare class WorkflowsResource {
|
|
|
219
225
|
view?: VariationView;
|
|
220
226
|
includeVariation?: boolean;
|
|
221
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;
|
|
222
237
|
}
|
|
223
238
|
|
|
224
239
|
declare class ConnectionsResource {
|
|
@@ -334,6 +349,7 @@ declare class ScopesResource {
|
|
|
334
349
|
chatStream(scopeId: number | string, message: string, options: {
|
|
335
350
|
model: ChatModel;
|
|
336
351
|
threadId?: string;
|
|
352
|
+
version?: string;
|
|
337
353
|
}): ChatStream;
|
|
338
354
|
}
|
|
339
355
|
|
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-
|
|
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-
|
|
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';
|
|
3
3
|
|
|
4
4
|
declare class ModusError extends Error {
|
|
5
5
|
readonly statusCode?: number;
|
|
@@ -100,9 +100,10 @@ declare class ChatStream {
|
|
|
100
100
|
private readonly http;
|
|
101
101
|
private readonly path;
|
|
102
102
|
private readonly body;
|
|
103
|
+
private readonly baseUrl?;
|
|
103
104
|
private final?;
|
|
104
105
|
private readonly textParts;
|
|
105
|
-
constructor(http: HttpClient, path: string, body: Record<string, unknown
|
|
106
|
+
constructor(http: HttpClient, path: string, body: Record<string, unknown>, baseUrl?: string | undefined);
|
|
106
107
|
textStream(): AsyncGenerator<string>;
|
|
107
108
|
eventStream(): AsyncGenerator<RunEvent>;
|
|
108
109
|
private events;
|
|
@@ -124,7 +125,7 @@ type RunStatus = 'running' | 'awaiting_human' | 'completed' | 'error' | 'cancell
|
|
|
124
125
|
type RunTimeframe = 'last_hour' | 'last_day' | 'last_week' | (string & {});
|
|
125
126
|
type ApprovalScope = 'mine' | 'all' | (string & {});
|
|
126
127
|
|
|
127
|
-
interface AgentRunStream {
|
|
128
|
+
interface AgentRunStream extends AsyncIterable<RunEvent> {
|
|
128
129
|
readonly runId: string;
|
|
129
130
|
readonly events: AsyncIterable<RunEvent>;
|
|
130
131
|
}
|
|
@@ -146,16 +147,16 @@ declare class WorkflowRunsResource {
|
|
|
146
147
|
}): Promise<AgentRun>;
|
|
147
148
|
create(workflowId: number | string, body: CreateAgentRunRequest, options?: {
|
|
148
149
|
idempotencyKey?: string;
|
|
149
|
-
}):
|
|
150
|
+
}): AgentRunStream;
|
|
150
151
|
createScope(scopeId: number | string, body: SkillRunCreateRequest, options?: {
|
|
151
152
|
idempotencyKey?: string;
|
|
152
|
-
}):
|
|
153
|
+
}): AgentRunStream;
|
|
153
154
|
createModus(body: ModusRunCreateRequest, options?: {
|
|
154
155
|
idempotencyKey?: string;
|
|
155
|
-
}):
|
|
156
|
+
}): AgentRunStream;
|
|
156
157
|
resume(runId: string, body: ResumeRunRequest, options?: {
|
|
157
158
|
idempotencyKey?: string;
|
|
158
|
-
}):
|
|
159
|
+
}): AgentRunStream;
|
|
159
160
|
cancel(runId: string): Promise<void>;
|
|
160
161
|
events(runId: string): Promise<unknown>;
|
|
161
162
|
interrupt(runId: string): Promise<void>;
|
|
@@ -186,7 +187,12 @@ type ModusContextRequest = components['schemas']['ModusContextRequestDto'];
|
|
|
186
187
|
type SuggestionQuestion = components['schemas']['SuggestionQuestionDto'];
|
|
187
188
|
type SuggestionEventType = components['schemas']['SuggestionEventType'];
|
|
188
189
|
type SuggestionEventSource = components['schemas']['SuggestionEventSource'];
|
|
189
|
-
|
|
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
196
|
|
|
191
197
|
declare class AgentWorkflowActionsResource {
|
|
192
198
|
private readonly http;
|
|
@@ -194,7 +200,7 @@ declare class AgentWorkflowActionsResource {
|
|
|
194
200
|
constructor(http: HttpClient, config: ModusConfig);
|
|
195
201
|
execute(body: WorkflowActionRequest, options?: {
|
|
196
202
|
idempotencyKey?: string;
|
|
197
|
-
}):
|
|
203
|
+
}): AgentRunStream;
|
|
198
204
|
cancel(runId: string): Promise<void>;
|
|
199
205
|
private parseEvents;
|
|
200
206
|
}
|
|
@@ -219,6 +225,15 @@ declare class WorkflowsResource {
|
|
|
219
225
|
view?: VariationView;
|
|
220
226
|
includeVariation?: boolean;
|
|
221
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;
|
|
222
237
|
}
|
|
223
238
|
|
|
224
239
|
declare class ConnectionsResource {
|
|
@@ -334,6 +349,7 @@ declare class ScopesResource {
|
|
|
334
349
|
chatStream(scopeId: number | string, message: string, options: {
|
|
335
350
|
model: ChatModel;
|
|
336
351
|
threadId?: string;
|
|
352
|
+
version?: string;
|
|
337
353
|
}): ChatStream;
|
|
338
354
|
}
|
|
339
355
|
|
package/dist/index.js
CHANGED
|
@@ -29,7 +29,10 @@ import {
|
|
|
29
29
|
validateChatModel,
|
|
30
30
|
validateId,
|
|
31
31
|
validatePageSize
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-OUFN2O5C.js";
|
|
33
|
+
|
|
34
|
+
// src/_chat.ts
|
|
35
|
+
import { randomUUID } from "crypto";
|
|
33
36
|
|
|
34
37
|
// src/_streaming.ts
|
|
35
38
|
var SILENTLY_IGNORED = /* @__PURE__ */ new Set([
|
|
@@ -121,28 +124,48 @@ function effectiveThreadId(threadId) {
|
|
|
121
124
|
if (!threadId.trim()) return void 0;
|
|
122
125
|
return threadId;
|
|
123
126
|
}
|
|
127
|
+
function resolveSessionId(threadId) {
|
|
128
|
+
return effectiveThreadId(threadId) ?? randomUUID();
|
|
129
|
+
}
|
|
124
130
|
function chatPath(resource, resourceId, options) {
|
|
125
131
|
const safeId = encodeURIComponent(String(resourceId));
|
|
126
|
-
const suffix = options.stream ? "/stream" : "";
|
|
127
132
|
const tid = effectiveThreadId(options.threadId);
|
|
128
133
|
if (tid !== void 0) {
|
|
129
134
|
const safeTid = encodeURIComponent(tid);
|
|
130
|
-
return `/api/v1/${resource}/${safeId}/conversations/${safeTid}/chat
|
|
135
|
+
return `/api/v1/${resource}/${safeId}/conversations/${safeTid}/chat`;
|
|
131
136
|
}
|
|
132
|
-
return `/api/v1/${resource}/${safeId}/chat
|
|
137
|
+
return `/api/v1/${resource}/${safeId}/chat`;
|
|
133
138
|
}
|
|
134
139
|
function modusChatPath(options) {
|
|
135
|
-
const suffix = options.stream ? "/stream" : "";
|
|
136
140
|
const tid = effectiveThreadId(options.threadId);
|
|
137
141
|
if (tid !== void 0) {
|
|
138
142
|
validateId(tid, "thread_id");
|
|
139
|
-
return `/api/v1/modus/conversations/${encodeURIComponent(tid)}/chat
|
|
143
|
+
return `/api/v1/modus/conversations/${encodeURIComponent(tid)}/chat`;
|
|
140
144
|
}
|
|
141
|
-
return `/api/v1/modus/chat
|
|
145
|
+
return `/api/v1/modus/chat`;
|
|
146
|
+
}
|
|
147
|
+
function agentHostRunsPath(resource, resourceId) {
|
|
148
|
+
if (resource === "modus") return "/agent/v1/modus/runs";
|
|
149
|
+
const safeId = encodeURIComponent(String(resourceId));
|
|
150
|
+
return `/agent/v1/${resource}/${safeId}/runs`;
|
|
142
151
|
}
|
|
143
152
|
function chatBody(message, model) {
|
|
144
153
|
return { message, model };
|
|
145
154
|
}
|
|
155
|
+
function agentRunsBody(message, model, options) {
|
|
156
|
+
const body = {
|
|
157
|
+
message,
|
|
158
|
+
config: { model },
|
|
159
|
+
sessionId: options.sessionId
|
|
160
|
+
};
|
|
161
|
+
if (options.organizationId !== void 0) {
|
|
162
|
+
body.organizationId = options.organizationId;
|
|
163
|
+
}
|
|
164
|
+
if (options.version !== void 0) {
|
|
165
|
+
body.version = options.version;
|
|
166
|
+
}
|
|
167
|
+
return body;
|
|
168
|
+
}
|
|
146
169
|
function raiseForEvent(event) {
|
|
147
170
|
if (event.type === "error") throw new ModusError(event.message);
|
|
148
171
|
if (event.type === "cancelled") throw new RunCancelledError();
|
|
@@ -150,10 +173,11 @@ function raiseForEvent(event) {
|
|
|
150
173
|
return event;
|
|
151
174
|
}
|
|
152
175
|
var ChatStream = class {
|
|
153
|
-
constructor(http, path, body) {
|
|
176
|
+
constructor(http, path, body, baseUrl) {
|
|
154
177
|
this.http = http;
|
|
155
178
|
this.path = path;
|
|
156
179
|
this.body = body;
|
|
180
|
+
this.baseUrl = baseUrl;
|
|
157
181
|
this.textParts = [];
|
|
158
182
|
}
|
|
159
183
|
async *textStream() {
|
|
@@ -166,7 +190,9 @@ var ChatStream = class {
|
|
|
166
190
|
}
|
|
167
191
|
async *events(supportsReset) {
|
|
168
192
|
const body = supportsReset ? { ...this.body, streamProtocolVersion: 2 } : this.body;
|
|
169
|
-
for await (const line of this.http.streamPost(this.path, body
|
|
193
|
+
for await (const line of this.http.streamPost(this.path, body, {
|
|
194
|
+
baseUrl: this.baseUrl
|
|
195
|
+
})) {
|
|
170
196
|
for (const event of parseSseStream([line])) {
|
|
171
197
|
const normalized = raiseForEvent(event);
|
|
172
198
|
if (normalized.type === "token") this.textParts.push(normalized.content);
|
|
@@ -200,39 +226,58 @@ async function chatBuffered(http, resource, resourceId, message, options) {
|
|
|
200
226
|
validateId(resourceId, `${resource}_id`);
|
|
201
227
|
validateChatModel(options.model);
|
|
202
228
|
const path = chatPath(resource, resourceId, {
|
|
203
|
-
threadId: options.threadId
|
|
204
|
-
stream: false
|
|
229
|
+
threadId: options.threadId
|
|
205
230
|
});
|
|
206
231
|
const data = await http.post(path, chatBody(message, options.model));
|
|
207
232
|
return data;
|
|
208
233
|
}
|
|
209
|
-
function chatStreamSession(http, resource, resourceId, message, options) {
|
|
234
|
+
function chatStreamSession(http, config, resource, resourceId, message, options) {
|
|
210
235
|
validateId(resourceId, `${resource}_id`);
|
|
211
236
|
validateChatModel(options.model);
|
|
212
|
-
const path =
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
237
|
+
const path = agentHostRunsPath(resource, resourceId);
|
|
238
|
+
return new ChatStream(
|
|
239
|
+
http,
|
|
240
|
+
path,
|
|
241
|
+
agentRunsBody(message, options.model, {
|
|
242
|
+
sessionId: resolveSessionId(options.threadId),
|
|
243
|
+
organizationId: config.organizationId,
|
|
244
|
+
version: options.version
|
|
245
|
+
}),
|
|
246
|
+
config.agentHost
|
|
247
|
+
);
|
|
217
248
|
}
|
|
218
249
|
async function modusChatBuffered(http, message, options) {
|
|
219
250
|
validateChatModel(options.model);
|
|
220
|
-
const path = modusChatPath({ threadId: options.threadId
|
|
251
|
+
const path = modusChatPath({ threadId: options.threadId });
|
|
221
252
|
const data = await http.post(path, chatBody(message, options.model));
|
|
222
253
|
return data;
|
|
223
254
|
}
|
|
224
|
-
function modusChatStreamSession(http, message, options) {
|
|
255
|
+
function modusChatStreamSession(http, config, message, options) {
|
|
225
256
|
validateChatModel(options.model);
|
|
226
|
-
|
|
227
|
-
|
|
257
|
+
return new ChatStream(
|
|
258
|
+
http,
|
|
259
|
+
agentHostRunsPath("modus"),
|
|
260
|
+
agentRunsBody(message, options.model, {
|
|
261
|
+
sessionId: resolveSessionId(options.threadId),
|
|
262
|
+
organizationId: config.organizationId
|
|
263
|
+
}),
|
|
264
|
+
config.agentHost
|
|
265
|
+
);
|
|
228
266
|
}
|
|
229
267
|
|
|
268
|
+
// src/types/agents.ts
|
|
269
|
+
var AgentType = {
|
|
270
|
+
task: "task",
|
|
271
|
+
workflow: "workflow"
|
|
272
|
+
};
|
|
273
|
+
|
|
230
274
|
// src/types/conversations.ts
|
|
231
275
|
function conversationSkillId(item) {
|
|
232
276
|
return item.skillId === 0 ? void 0 : item.skillId;
|
|
233
277
|
}
|
|
234
278
|
|
|
235
279
|
// src/resources/agents/runs.ts
|
|
280
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
236
281
|
var RUNS_MAX_PAGE_SIZE = 100;
|
|
237
282
|
function runsListParams(pageSize, pageToken, status, timeframe, approvalScope, search) {
|
|
238
283
|
const params = { pageSize };
|
|
@@ -280,7 +325,16 @@ function parseActiveRunsPage(raw, fetchPage) {
|
|
|
280
325
|
);
|
|
281
326
|
}
|
|
282
327
|
function randomRunId() {
|
|
283
|
-
return
|
|
328
|
+
return randomUUID2();
|
|
329
|
+
}
|
|
330
|
+
function makeAgentRunStream(runId, events) {
|
|
331
|
+
return {
|
|
332
|
+
runId,
|
|
333
|
+
events,
|
|
334
|
+
[Symbol.asyncIterator]() {
|
|
335
|
+
return events[Symbol.asyncIterator]();
|
|
336
|
+
}
|
|
337
|
+
};
|
|
284
338
|
}
|
|
285
339
|
var WorkflowRunsResource = class {
|
|
286
340
|
constructor(http, config) {
|
|
@@ -331,18 +385,18 @@ var WorkflowRunsResource = class {
|
|
|
331
385
|
});
|
|
332
386
|
return parseRun(data);
|
|
333
387
|
}
|
|
334
|
-
|
|
388
|
+
create(workflowId, body, options = {}) {
|
|
335
389
|
validateId(workflowId, "workflow_id");
|
|
336
390
|
return this.createRun("WorkflowRunsController_create", body, { id: workflowId }, options);
|
|
337
391
|
}
|
|
338
|
-
|
|
392
|
+
createScope(scopeId, body, options = {}) {
|
|
339
393
|
validateId(scopeId, "scope_id");
|
|
340
394
|
return this.createRun("ScopeRunsController_create", body, { id: scopeId }, options);
|
|
341
395
|
}
|
|
342
|
-
|
|
396
|
+
createModus(body, options = {}) {
|
|
343
397
|
return this.createRun("ModusRunsController_create", body, {}, options);
|
|
344
398
|
}
|
|
345
|
-
|
|
399
|
+
resume(runId, body, options = {}) {
|
|
346
400
|
validateId(runId, "run_id");
|
|
347
401
|
return this.createRun("ResumeRunsController_create", body, { runId }, options);
|
|
348
402
|
}
|
|
@@ -405,7 +459,7 @@ var WorkflowRunsResource = class {
|
|
|
405
459
|
baseUrl: operationBaseUrl(this.http, op),
|
|
406
460
|
headers: options.lastEventId ? { "Last-Event-ID": options.lastEventId } : void 0
|
|
407
461
|
});
|
|
408
|
-
return
|
|
462
|
+
return makeAgentRunStream(runId, this.parseEvents(lines));
|
|
409
463
|
}
|
|
410
464
|
createRun(operationId, body, pathParams, options) {
|
|
411
465
|
const runId = options.idempotencyKey?.trim() || body.runId?.trim() || randomRunId();
|
|
@@ -418,7 +472,7 @@ var WorkflowRunsResource = class {
|
|
|
418
472
|
baseUrl: operationBaseUrl(this.http, op),
|
|
419
473
|
headers: { "Idempotency-Key": runId }
|
|
420
474
|
});
|
|
421
|
-
return
|
|
475
|
+
return makeAgentRunStream(runId, this.parseEvents(lines));
|
|
422
476
|
}
|
|
423
477
|
async *parseEvents(lines) {
|
|
424
478
|
yield* parseSseStream(lines);
|
|
@@ -426,15 +480,16 @@ var WorkflowRunsResource = class {
|
|
|
426
480
|
};
|
|
427
481
|
|
|
428
482
|
// src/resources/agents/workflow-actions.ts
|
|
483
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
429
484
|
function randomRunId2() {
|
|
430
|
-
return
|
|
485
|
+
return randomUUID3();
|
|
431
486
|
}
|
|
432
487
|
var AgentWorkflowActionsResource = class {
|
|
433
488
|
constructor(http, config) {
|
|
434
489
|
this.http = http;
|
|
435
490
|
this.config = config;
|
|
436
491
|
}
|
|
437
|
-
|
|
492
|
+
execute(body, options = {}) {
|
|
438
493
|
const runId = options.idempotencyKey?.trim() || body.runId?.trim() || randomRunId2();
|
|
439
494
|
const op = getOperation("WorkflowActionsController_execute");
|
|
440
495
|
const path = formatOperationPath("WorkflowActionsController_execute");
|
|
@@ -442,7 +497,7 @@ var AgentWorkflowActionsResource = class {
|
|
|
442
497
|
baseUrl: operationBaseUrl(this.http, op),
|
|
443
498
|
headers: { "Idempotency-Key": runId }
|
|
444
499
|
});
|
|
445
|
-
return
|
|
500
|
+
return makeAgentRunStream(runId, this.parseEvents(lines));
|
|
446
501
|
}
|
|
447
502
|
async cancel(runId) {
|
|
448
503
|
validateId(runId, "run_id");
|
|
@@ -520,6 +575,12 @@ var WorkflowsResource = class {
|
|
|
520
575
|
});
|
|
521
576
|
return parseWorkflow(data);
|
|
522
577
|
}
|
|
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
|
+
}
|
|
523
584
|
};
|
|
524
585
|
|
|
525
586
|
// src/resources/connections.ts
|
|
@@ -736,7 +797,7 @@ var ModusResource = class {
|
|
|
736
797
|
return modusChatBuffered(this.http, message, options);
|
|
737
798
|
}
|
|
738
799
|
chatStream(message, options) {
|
|
739
|
-
return modusChatStreamSession(this.http, message, options);
|
|
800
|
+
return modusChatStreamSession(this.http, this.config, message, options);
|
|
740
801
|
}
|
|
741
802
|
};
|
|
742
803
|
|
|
@@ -804,10 +865,28 @@ var ScopesResource = class {
|
|
|
804
865
|
return chatBuffered(this.http, "scopes", scopeId, message, options);
|
|
805
866
|
}
|
|
806
867
|
chatStream(scopeId, message, options) {
|
|
807
|
-
return chatStreamSession(this.http, "scopes", scopeId, message, options);
|
|
868
|
+
return chatStreamSession(this.http, this.config, "scopes", scopeId, message, options);
|
|
808
869
|
}
|
|
809
870
|
};
|
|
810
871
|
|
|
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
|
+
|
|
811
890
|
// src/resources/suggestions.ts
|
|
812
891
|
var DEFAULT_SUGGESTIONS_PAGE_SIZE = 5;
|
|
813
892
|
var MAX_SUGGESTIONS_PAGE_SIZE = 12;
|
|
@@ -849,7 +928,7 @@ var SuggestionsResource = class {
|
|
|
849
928
|
validateId(id, "id");
|
|
850
929
|
await invokeWithRetry(this.config, this.http, "SuggestionsController_recordEvent", {
|
|
851
930
|
pathParams: { id },
|
|
852
|
-
jsonBody: event
|
|
931
|
+
jsonBody: normalizeRecordSuggestionEvent(event)
|
|
853
932
|
});
|
|
854
933
|
}
|
|
855
934
|
};
|
|
@@ -868,6 +947,7 @@ var Modus = class extends ModusClientBase {
|
|
|
868
947
|
};
|
|
869
948
|
export {
|
|
870
949
|
APIConnectionError,
|
|
950
|
+
AgentType,
|
|
871
951
|
AuthenticationError,
|
|
872
952
|
ChatStream,
|
|
873
953
|
ConflictError,
|