@getmodus/sdk 0.2.1 → 0.2.3
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 +7 -3
- package/README.md +4 -0
- package/dist/{chunk-UOBVSNOW.js → chunk-ZFZQ2UMA.js} +159 -94
- package/dist/chunk-ZFZQ2UMA.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 +281 -126
- 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 +123 -34
- package/dist/index.js.map +1 -1
- package/dist/management/index.cjs +164 -94
- 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,14 @@ import {
|
|
|
29
29
|
validateChatModel,
|
|
30
30
|
validateId,
|
|
31
31
|
validatePageSize
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-ZFZQ2UMA.js";
|
|
33
|
+
|
|
34
|
+
// src/_agent_run_request.ts
|
|
35
|
+
import { randomUUID } from "crypto";
|
|
36
|
+
function resolveAgentRunSessionId(sessionId) {
|
|
37
|
+
if (typeof sessionId === "string" && sessionId.trim()) return sessionId.trim();
|
|
38
|
+
return randomUUID();
|
|
39
|
+
}
|
|
33
40
|
|
|
34
41
|
// src/_streaming.ts
|
|
35
42
|
var SILENTLY_IGNORED = /* @__PURE__ */ new Set([
|
|
@@ -121,28 +128,48 @@ function effectiveThreadId(threadId) {
|
|
|
121
128
|
if (!threadId.trim()) return void 0;
|
|
122
129
|
return threadId;
|
|
123
130
|
}
|
|
131
|
+
function resolveSessionId(threadId) {
|
|
132
|
+
return resolveAgentRunSessionId(effectiveThreadId(threadId));
|
|
133
|
+
}
|
|
124
134
|
function chatPath(resource, resourceId, options) {
|
|
125
135
|
const safeId = encodeURIComponent(String(resourceId));
|
|
126
|
-
const suffix = options.stream ? "/stream" : "";
|
|
127
136
|
const tid = effectiveThreadId(options.threadId);
|
|
128
137
|
if (tid !== void 0) {
|
|
129
138
|
const safeTid = encodeURIComponent(tid);
|
|
130
|
-
return `/api/v1/${resource}/${safeId}/conversations/${safeTid}/chat
|
|
139
|
+
return `/api/v1/${resource}/${safeId}/conversations/${safeTid}/chat`;
|
|
131
140
|
}
|
|
132
|
-
return `/api/v1/${resource}/${safeId}/chat
|
|
141
|
+
return `/api/v1/${resource}/${safeId}/chat`;
|
|
133
142
|
}
|
|
134
143
|
function modusChatPath(options) {
|
|
135
|
-
const suffix = options.stream ? "/stream" : "";
|
|
136
144
|
const tid = effectiveThreadId(options.threadId);
|
|
137
145
|
if (tid !== void 0) {
|
|
138
146
|
validateId(tid, "thread_id");
|
|
139
|
-
return `/api/v1/modus/conversations/${encodeURIComponent(tid)}/chat
|
|
147
|
+
return `/api/v1/modus/conversations/${encodeURIComponent(tid)}/chat`;
|
|
140
148
|
}
|
|
141
|
-
return `/api/v1/modus/chat
|
|
149
|
+
return `/api/v1/modus/chat`;
|
|
150
|
+
}
|
|
151
|
+
function agentHostRunsPath(resource, resourceId) {
|
|
152
|
+
if (resource === "modus") return "/agent/v1/modus/runs";
|
|
153
|
+
const safeId = encodeURIComponent(String(resourceId));
|
|
154
|
+
return `/agent/v1/${resource}/${safeId}/runs`;
|
|
142
155
|
}
|
|
143
156
|
function chatBody(message, model) {
|
|
144
157
|
return { message, model };
|
|
145
158
|
}
|
|
159
|
+
function agentRunsBody(message, model, options) {
|
|
160
|
+
const body = {
|
|
161
|
+
message,
|
|
162
|
+
config: { model },
|
|
163
|
+
sessionId: options.sessionId
|
|
164
|
+
};
|
|
165
|
+
if (options.organizationId !== void 0) {
|
|
166
|
+
body.organizationId = options.organizationId;
|
|
167
|
+
}
|
|
168
|
+
if (options.version !== void 0) {
|
|
169
|
+
body.version = options.version;
|
|
170
|
+
}
|
|
171
|
+
return body;
|
|
172
|
+
}
|
|
146
173
|
function raiseForEvent(event) {
|
|
147
174
|
if (event.type === "error") throw new ModusError(event.message);
|
|
148
175
|
if (event.type === "cancelled") throw new RunCancelledError();
|
|
@@ -150,10 +177,11 @@ function raiseForEvent(event) {
|
|
|
150
177
|
return event;
|
|
151
178
|
}
|
|
152
179
|
var ChatStream = class {
|
|
153
|
-
constructor(http, path, body) {
|
|
180
|
+
constructor(http, path, body, baseUrl) {
|
|
154
181
|
this.http = http;
|
|
155
182
|
this.path = path;
|
|
156
183
|
this.body = body;
|
|
184
|
+
this.baseUrl = baseUrl;
|
|
157
185
|
this.textParts = [];
|
|
158
186
|
}
|
|
159
187
|
async *textStream() {
|
|
@@ -166,7 +194,9 @@ var ChatStream = class {
|
|
|
166
194
|
}
|
|
167
195
|
async *events(supportsReset) {
|
|
168
196
|
const body = supportsReset ? { ...this.body, streamProtocolVersion: 2 } : this.body;
|
|
169
|
-
for await (const line of this.http.streamPost(this.path, body
|
|
197
|
+
for await (const line of this.http.streamPost(this.path, body, {
|
|
198
|
+
baseUrl: this.baseUrl
|
|
199
|
+
})) {
|
|
170
200
|
for (const event of parseSseStream([line])) {
|
|
171
201
|
const normalized = raiseForEvent(event);
|
|
172
202
|
if (normalized.type === "token") this.textParts.push(normalized.content);
|
|
@@ -200,39 +230,58 @@ async function chatBuffered(http, resource, resourceId, message, options) {
|
|
|
200
230
|
validateId(resourceId, `${resource}_id`);
|
|
201
231
|
validateChatModel(options.model);
|
|
202
232
|
const path = chatPath(resource, resourceId, {
|
|
203
|
-
threadId: options.threadId
|
|
204
|
-
stream: false
|
|
233
|
+
threadId: options.threadId
|
|
205
234
|
});
|
|
206
235
|
const data = await http.post(path, chatBody(message, options.model));
|
|
207
236
|
return data;
|
|
208
237
|
}
|
|
209
|
-
function chatStreamSession(http, resource, resourceId, message, options) {
|
|
238
|
+
function chatStreamSession(http, config, resource, resourceId, message, options) {
|
|
210
239
|
validateId(resourceId, `${resource}_id`);
|
|
211
240
|
validateChatModel(options.model);
|
|
212
|
-
const path =
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
241
|
+
const path = agentHostRunsPath(resource, resourceId);
|
|
242
|
+
return new ChatStream(
|
|
243
|
+
http,
|
|
244
|
+
path,
|
|
245
|
+
agentRunsBody(message, options.model, {
|
|
246
|
+
sessionId: resolveSessionId(options.threadId),
|
|
247
|
+
organizationId: config.organizationId,
|
|
248
|
+
version: options.version
|
|
249
|
+
}),
|
|
250
|
+
config.agentHost
|
|
251
|
+
);
|
|
217
252
|
}
|
|
218
253
|
async function modusChatBuffered(http, message, options) {
|
|
219
254
|
validateChatModel(options.model);
|
|
220
|
-
const path = modusChatPath({ threadId: options.threadId
|
|
255
|
+
const path = modusChatPath({ threadId: options.threadId });
|
|
221
256
|
const data = await http.post(path, chatBody(message, options.model));
|
|
222
257
|
return data;
|
|
223
258
|
}
|
|
224
|
-
function modusChatStreamSession(http, message, options) {
|
|
259
|
+
function modusChatStreamSession(http, config, message, options) {
|
|
225
260
|
validateChatModel(options.model);
|
|
226
|
-
|
|
227
|
-
|
|
261
|
+
return new ChatStream(
|
|
262
|
+
http,
|
|
263
|
+
agentHostRunsPath("modus"),
|
|
264
|
+
agentRunsBody(message, options.model, {
|
|
265
|
+
sessionId: resolveSessionId(options.threadId),
|
|
266
|
+
organizationId: config.organizationId
|
|
267
|
+
}),
|
|
268
|
+
config.agentHost
|
|
269
|
+
);
|
|
228
270
|
}
|
|
229
271
|
|
|
272
|
+
// src/types/agents.ts
|
|
273
|
+
var AgentType = {
|
|
274
|
+
task: "task",
|
|
275
|
+
workflow: "workflow"
|
|
276
|
+
};
|
|
277
|
+
|
|
230
278
|
// src/types/conversations.ts
|
|
231
279
|
function conversationSkillId(item) {
|
|
232
280
|
return item.skillId === 0 ? void 0 : item.skillId;
|
|
233
281
|
}
|
|
234
282
|
|
|
235
283
|
// src/resources/agents/runs.ts
|
|
284
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
236
285
|
var RUNS_MAX_PAGE_SIZE = 100;
|
|
237
286
|
function runsListParams(pageSize, pageToken, status, timeframe, approvalScope, search) {
|
|
238
287
|
const params = { pageSize };
|
|
@@ -280,7 +329,19 @@ function parseActiveRunsPage(raw, fetchPage) {
|
|
|
280
329
|
);
|
|
281
330
|
}
|
|
282
331
|
function randomRunId() {
|
|
283
|
-
return
|
|
332
|
+
return randomUUID2();
|
|
333
|
+
}
|
|
334
|
+
function sessionIdFromBody(body) {
|
|
335
|
+
return resolveAgentRunSessionId(body.sessionId);
|
|
336
|
+
}
|
|
337
|
+
function makeAgentRunStream(runId, events) {
|
|
338
|
+
return {
|
|
339
|
+
runId,
|
|
340
|
+
events,
|
|
341
|
+
[Symbol.asyncIterator]() {
|
|
342
|
+
return events[Symbol.asyncIterator]();
|
|
343
|
+
}
|
|
344
|
+
};
|
|
284
345
|
}
|
|
285
346
|
var WorkflowRunsResource = class {
|
|
286
347
|
constructor(http, config) {
|
|
@@ -331,18 +392,18 @@ var WorkflowRunsResource = class {
|
|
|
331
392
|
});
|
|
332
393
|
return parseRun(data);
|
|
333
394
|
}
|
|
334
|
-
|
|
395
|
+
create(workflowId, body, options = {}) {
|
|
335
396
|
validateId(workflowId, "workflow_id");
|
|
336
397
|
return this.createRun("WorkflowRunsController_create", body, { id: workflowId }, options);
|
|
337
398
|
}
|
|
338
|
-
|
|
399
|
+
createScope(scopeId, body, options = {}) {
|
|
339
400
|
validateId(scopeId, "scope_id");
|
|
340
401
|
return this.createRun("ScopeRunsController_create", body, { id: scopeId }, options);
|
|
341
402
|
}
|
|
342
|
-
|
|
403
|
+
createModus(body, options = {}) {
|
|
343
404
|
return this.createRun("ModusRunsController_create", body, {}, options);
|
|
344
405
|
}
|
|
345
|
-
|
|
406
|
+
resume(runId, body, options = {}) {
|
|
346
407
|
validateId(runId, "run_id");
|
|
347
408
|
return this.createRun("ResumeRunsController_create", body, { runId }, options);
|
|
348
409
|
}
|
|
@@ -405,20 +466,22 @@ var WorkflowRunsResource = class {
|
|
|
405
466
|
baseUrl: operationBaseUrl(this.http, op),
|
|
406
467
|
headers: options.lastEventId ? { "Last-Event-ID": options.lastEventId } : void 0
|
|
407
468
|
});
|
|
408
|
-
return
|
|
469
|
+
return makeAgentRunStream(runId, this.parseEvents(lines));
|
|
409
470
|
}
|
|
410
471
|
createRun(operationId, body, pathParams, options) {
|
|
411
472
|
const runId = options.idempotencyKey?.trim() || body.runId?.trim() || randomRunId();
|
|
473
|
+
const sessionId = sessionIdFromBody(body);
|
|
412
474
|
const op = getOperation(operationId);
|
|
413
475
|
const path = formatOperationPath(operationId, pathParams);
|
|
414
476
|
const lines = this.http.streamPost(path, {
|
|
415
477
|
...body,
|
|
478
|
+
sessionId,
|
|
416
479
|
streamProtocolVersion: 2
|
|
417
480
|
}, {
|
|
418
481
|
baseUrl: operationBaseUrl(this.http, op),
|
|
419
482
|
headers: { "Idempotency-Key": runId }
|
|
420
483
|
});
|
|
421
|
-
return
|
|
484
|
+
return makeAgentRunStream(runId, this.parseEvents(lines));
|
|
422
485
|
}
|
|
423
486
|
async *parseEvents(lines) {
|
|
424
487
|
yield* parseSseStream(lines);
|
|
@@ -426,15 +489,16 @@ var WorkflowRunsResource = class {
|
|
|
426
489
|
};
|
|
427
490
|
|
|
428
491
|
// src/resources/agents/workflow-actions.ts
|
|
492
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
429
493
|
function randomRunId2() {
|
|
430
|
-
return
|
|
494
|
+
return randomUUID3();
|
|
431
495
|
}
|
|
432
496
|
var AgentWorkflowActionsResource = class {
|
|
433
497
|
constructor(http, config) {
|
|
434
498
|
this.http = http;
|
|
435
499
|
this.config = config;
|
|
436
500
|
}
|
|
437
|
-
|
|
501
|
+
execute(body, options = {}) {
|
|
438
502
|
const runId = options.idempotencyKey?.trim() || body.runId?.trim() || randomRunId2();
|
|
439
503
|
const op = getOperation("WorkflowActionsController_execute");
|
|
440
504
|
const path = formatOperationPath("WorkflowActionsController_execute");
|
|
@@ -442,7 +506,7 @@ var AgentWorkflowActionsResource = class {
|
|
|
442
506
|
baseUrl: operationBaseUrl(this.http, op),
|
|
443
507
|
headers: { "Idempotency-Key": runId }
|
|
444
508
|
});
|
|
445
|
-
return
|
|
509
|
+
return makeAgentRunStream(runId, this.parseEvents(lines));
|
|
446
510
|
}
|
|
447
511
|
async cancel(runId) {
|
|
448
512
|
validateId(runId, "run_id");
|
|
@@ -520,6 +584,12 @@ var WorkflowsResource = class {
|
|
|
520
584
|
});
|
|
521
585
|
return parseWorkflow(data);
|
|
522
586
|
}
|
|
587
|
+
chat(workflowId, message, options) {
|
|
588
|
+
return chatBuffered(this.http, "workflows", workflowId, message, options);
|
|
589
|
+
}
|
|
590
|
+
chatStream(workflowId, message, options) {
|
|
591
|
+
return chatStreamSession(this.http, this.config, "workflows", workflowId, message, options);
|
|
592
|
+
}
|
|
523
593
|
};
|
|
524
594
|
|
|
525
595
|
// src/resources/connections.ts
|
|
@@ -736,7 +806,7 @@ var ModusResource = class {
|
|
|
736
806
|
return modusChatBuffered(this.http, message, options);
|
|
737
807
|
}
|
|
738
808
|
chatStream(message, options) {
|
|
739
|
-
return modusChatStreamSession(this.http, message, options);
|
|
809
|
+
return modusChatStreamSession(this.http, this.config, message, options);
|
|
740
810
|
}
|
|
741
811
|
};
|
|
742
812
|
|
|
@@ -804,10 +874,28 @@ var ScopesResource = class {
|
|
|
804
874
|
return chatBuffered(this.http, "scopes", scopeId, message, options);
|
|
805
875
|
}
|
|
806
876
|
chatStream(scopeId, message, options) {
|
|
807
|
-
return chatStreamSession(this.http, "scopes", scopeId, message, options);
|
|
877
|
+
return chatStreamSession(this.http, this.config, "scopes", scopeId, message, options);
|
|
808
878
|
}
|
|
809
879
|
};
|
|
810
880
|
|
|
881
|
+
// src/types/suggestions.ts
|
|
882
|
+
function normalizeRecordSuggestionEvent(event) {
|
|
883
|
+
const eventType = event.event_type ?? event.eventType;
|
|
884
|
+
if (eventType === void 0) {
|
|
885
|
+
throw new Error("recordEvent requires event_type (or eventType)");
|
|
886
|
+
}
|
|
887
|
+
const body = {
|
|
888
|
+
event_type: eventType,
|
|
889
|
+
source: event.source
|
|
890
|
+
};
|
|
891
|
+
const skillId = event.skill_id ?? event.skillId;
|
|
892
|
+
if (skillId !== void 0) body.skill_id = skillId;
|
|
893
|
+
const threadId = event.thread_id ?? event.threadId;
|
|
894
|
+
if (threadId !== void 0) body.thread_id = threadId;
|
|
895
|
+
if (event.metadata !== void 0) body.metadata = event.metadata;
|
|
896
|
+
return body;
|
|
897
|
+
}
|
|
898
|
+
|
|
811
899
|
// src/resources/suggestions.ts
|
|
812
900
|
var DEFAULT_SUGGESTIONS_PAGE_SIZE = 5;
|
|
813
901
|
var MAX_SUGGESTIONS_PAGE_SIZE = 12;
|
|
@@ -849,7 +937,7 @@ var SuggestionsResource = class {
|
|
|
849
937
|
validateId(id, "id");
|
|
850
938
|
await invokeWithRetry(this.config, this.http, "SuggestionsController_recordEvent", {
|
|
851
939
|
pathParams: { id },
|
|
852
|
-
jsonBody: event
|
|
940
|
+
jsonBody: normalizeRecordSuggestionEvent(event)
|
|
853
941
|
});
|
|
854
942
|
}
|
|
855
943
|
};
|
|
@@ -868,6 +956,7 @@ var Modus = class extends ModusClientBase {
|
|
|
868
956
|
};
|
|
869
957
|
export {
|
|
870
958
|
APIConnectionError,
|
|
959
|
+
AgentType,
|
|
871
960
|
AuthenticationError,
|
|
872
961
|
ChatStream,
|
|
873
962
|
ConflictError,
|