agent-orchestrator-mcp-server 0.7.14 → 0.7.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/shared/orchestrator-client/orchestrator-client.integration-mock.js +29 -16
- package/shared/orchestrator-client/orchestrator-client.js +6 -2
- package/shared/tools/action-session.js +24 -0
- package/shared/tools/action-trigger.js +3 -1
- package/shared/tools/search-triggers.d.ts +4 -4
- package/shared/tools/search-triggers.js +46 -13
- package/shared/types.d.ts +18 -9
package/package.json
CHANGED
|
@@ -611,18 +611,24 @@ export function createIntegrationMockOrchestratorClient(initialMockData) {
|
|
|
611
611
|
const trigger = {
|
|
612
612
|
id,
|
|
613
613
|
name: 'Test Trigger',
|
|
614
|
-
trigger_type: 'schedule',
|
|
615
614
|
status: 'enabled',
|
|
616
615
|
agent_root_name: 'mcp-servers',
|
|
617
616
|
prompt_template: 'Test prompt',
|
|
618
617
|
stop_condition: null,
|
|
619
618
|
reuse_session: false,
|
|
620
619
|
mcp_servers: [],
|
|
621
|
-
|
|
622
|
-
|
|
620
|
+
conditions: [
|
|
621
|
+
{
|
|
622
|
+
id: id * 10,
|
|
623
|
+
condition_type: 'schedule',
|
|
624
|
+
configuration: { interval: 1, unit: 'days', time: '09:00', timezone: 'UTC' },
|
|
625
|
+
description: 'Every day',
|
|
626
|
+
last_triggered_at: null,
|
|
627
|
+
last_polled_at: null,
|
|
628
|
+
},
|
|
629
|
+
],
|
|
623
630
|
last_session_id: null,
|
|
624
631
|
last_triggered_at: null,
|
|
625
|
-
last_polled_at: null,
|
|
626
632
|
sessions_created_count: 0,
|
|
627
633
|
created_at: new Date().toISOString(),
|
|
628
634
|
updated_at: new Date().toISOString(),
|
|
@@ -630,42 +636,52 @@ export function createIntegrationMockOrchestratorClient(initialMockData) {
|
|
|
630
636
|
return { trigger, recent_sessions: [] };
|
|
631
637
|
},
|
|
632
638
|
async createTrigger(data) {
|
|
639
|
+
const conditions = (data.trigger_conditions_attributes ?? []).map((c, i) => ({
|
|
640
|
+
id: i + 1,
|
|
641
|
+
condition_type: c.condition_type,
|
|
642
|
+
configuration: c.configuration,
|
|
643
|
+
description: `${c.condition_type} condition`,
|
|
644
|
+
last_triggered_at: null,
|
|
645
|
+
last_polled_at: null,
|
|
646
|
+
}));
|
|
633
647
|
return {
|
|
634
648
|
id: 1,
|
|
635
649
|
name: data.name,
|
|
636
|
-
trigger_type: data.trigger_type || 'schedule',
|
|
637
650
|
status: data.status || 'enabled',
|
|
638
651
|
agent_root_name: data.agent_root_name,
|
|
639
652
|
prompt_template: data.prompt_template,
|
|
640
653
|
stop_condition: data.stop_condition || null,
|
|
641
654
|
reuse_session: data.reuse_session || false,
|
|
642
655
|
mcp_servers: data.mcp_servers || [],
|
|
643
|
-
|
|
644
|
-
schedule_description: null,
|
|
656
|
+
conditions,
|
|
645
657
|
last_session_id: data.last_session_id ?? null,
|
|
646
658
|
last_triggered_at: null,
|
|
647
|
-
last_polled_at: null,
|
|
648
659
|
sessions_created_count: 0,
|
|
649
660
|
created_at: new Date().toISOString(),
|
|
650
661
|
updated_at: new Date().toISOString(),
|
|
651
662
|
};
|
|
652
663
|
},
|
|
653
664
|
async updateTrigger(id, data) {
|
|
665
|
+
const conditions = (data.trigger_conditions_attributes ?? []).map((c, i) => ({
|
|
666
|
+
id: i + 1,
|
|
667
|
+
condition_type: c.condition_type,
|
|
668
|
+
configuration: c.configuration,
|
|
669
|
+
description: `${c.condition_type} condition`,
|
|
670
|
+
last_triggered_at: null,
|
|
671
|
+
last_polled_at: null,
|
|
672
|
+
}));
|
|
654
673
|
return {
|
|
655
674
|
id,
|
|
656
675
|
name: data.name || 'Updated Trigger',
|
|
657
|
-
trigger_type: data.trigger_type || 'schedule',
|
|
658
676
|
status: data.status || 'enabled',
|
|
659
677
|
agent_root_name: data.agent_root_name || 'mcp-servers',
|
|
660
678
|
prompt_template: data.prompt_template || 'Test prompt',
|
|
661
679
|
stop_condition: data.stop_condition || null,
|
|
662
680
|
reuse_session: data.reuse_session || false,
|
|
663
681
|
mcp_servers: data.mcp_servers || [],
|
|
664
|
-
|
|
665
|
-
schedule_description: null,
|
|
682
|
+
conditions,
|
|
666
683
|
last_session_id: null,
|
|
667
684
|
last_triggered_at: null,
|
|
668
|
-
last_polled_at: null,
|
|
669
685
|
sessions_created_count: 0,
|
|
670
686
|
created_at: new Date().toISOString(),
|
|
671
687
|
updated_at: new Date().toISOString(),
|
|
@@ -678,18 +694,15 @@ export function createIntegrationMockOrchestratorClient(initialMockData) {
|
|
|
678
694
|
return {
|
|
679
695
|
id,
|
|
680
696
|
name: 'Toggled Trigger',
|
|
681
|
-
trigger_type: 'schedule',
|
|
682
697
|
status: 'disabled',
|
|
683
698
|
agent_root_name: 'mcp-servers',
|
|
684
699
|
prompt_template: 'Test prompt',
|
|
685
700
|
stop_condition: null,
|
|
686
701
|
reuse_session: false,
|
|
687
702
|
mcp_servers: [],
|
|
688
|
-
|
|
689
|
-
schedule_description: null,
|
|
703
|
+
conditions: [],
|
|
690
704
|
last_session_id: null,
|
|
691
705
|
last_triggered_at: null,
|
|
692
|
-
last_polled_at: null,
|
|
693
706
|
sessions_created_count: 0,
|
|
694
707
|
created_at: new Date().toISOString(),
|
|
695
708
|
updated_at: new Date().toISOString(),
|
|
@@ -222,7 +222,7 @@ export class AgentOrchestratorClient {
|
|
|
222
222
|
return this.request('POST', `/sessions/${id}/restart`);
|
|
223
223
|
}
|
|
224
224
|
async changeMcpServers(id, mcp_servers) {
|
|
225
|
-
const response = await this.request('PATCH', `/sessions/${id}`, {
|
|
225
|
+
const response = await this.request('PATCH', `/sessions/${id}/mcp_servers`, {
|
|
226
226
|
mcp_servers,
|
|
227
227
|
});
|
|
228
228
|
return response.session;
|
|
@@ -356,7 +356,11 @@ export class AgentOrchestratorClient {
|
|
|
356
356
|
}
|
|
357
357
|
// Triggers
|
|
358
358
|
async listTriggers(options) {
|
|
359
|
-
|
|
359
|
+
const { trigger_type, ...rest } = options ?? {};
|
|
360
|
+
return this.request('GET', '/triggers', undefined, {
|
|
361
|
+
...rest,
|
|
362
|
+
...(trigger_type !== undefined && { condition_type: trigger_type }),
|
|
363
|
+
});
|
|
360
364
|
}
|
|
361
365
|
async getTrigger(id) {
|
|
362
366
|
return this.request('GET', `/triggers/${id}`);
|
|
@@ -328,6 +328,30 @@ export function actionSessionTool(_server, clientFactory) {
|
|
|
328
328
|
}
|
|
329
329
|
case 'change_mcp_servers': {
|
|
330
330
|
const session = await client.changeMcpServers(session_id, mcp_servers);
|
|
331
|
+
const requested = [...mcp_servers].sort();
|
|
332
|
+
const actual = [...(session.mcp_servers ?? [])].sort();
|
|
333
|
+
const diverged = requested.length !== actual.length || requested.some((name, i) => name !== actual[i]);
|
|
334
|
+
if (diverged) {
|
|
335
|
+
const formatList = (list) => (list.length > 0 ? list.join(', ') : '(none)');
|
|
336
|
+
return {
|
|
337
|
+
content: [
|
|
338
|
+
{
|
|
339
|
+
type: 'text',
|
|
340
|
+
text: [
|
|
341
|
+
`## MCP Servers Update FAILED — server list unchanged`,
|
|
342
|
+
'',
|
|
343
|
+
`The API accepted the request but the session's MCP servers do not match what was requested. This usually indicates the request hit a backend endpoint that silently dropped the parameter.`,
|
|
344
|
+
'',
|
|
345
|
+
`- **Session ID:** ${session.id}`,
|
|
346
|
+
`- **Title:** ${session.title}`,
|
|
347
|
+
`- **Requested:** ${formatList(mcp_servers)}`,
|
|
348
|
+
`- **Actual:** ${formatList(session.mcp_servers ?? [])}`,
|
|
349
|
+
].join('\n'),
|
|
350
|
+
},
|
|
351
|
+
],
|
|
352
|
+
isError: true,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
331
355
|
const lines = [
|
|
332
356
|
`## MCP Servers Updated`,
|
|
333
357
|
'',
|
|
@@ -108,12 +108,14 @@ export function actionTriggerTool(_server, clientFactory) {
|
|
|
108
108
|
mcp_servers: validated.mcp_servers,
|
|
109
109
|
configuration: validated.configuration,
|
|
110
110
|
});
|
|
111
|
+
const conditionTypes = (trigger.conditions ?? []).map((c) => c.condition_type);
|
|
112
|
+
const typeSummary = conditionTypes.length > 0 ? Array.from(new Set(conditionTypes)).join(', ') : '(none)';
|
|
111
113
|
result = [
|
|
112
114
|
'## Trigger Created',
|
|
113
115
|
'',
|
|
114
116
|
`- **ID:** ${trigger.id}`,
|
|
115
117
|
`- **Name:** ${trigger.name}`,
|
|
116
|
-
`- **
|
|
118
|
+
`- **Conditions:** ${typeSummary}`,
|
|
117
119
|
`- **Status:** ${trigger.status}`,
|
|
118
120
|
`- **Agent Root:** ${trigger.agent_root_name}`,
|
|
119
121
|
].join('\n');
|
|
@@ -3,7 +3,7 @@ import { z } from 'zod';
|
|
|
3
3
|
import type { IAgentOrchestratorClient } from '../orchestrator-client/orchestrator-client.js';
|
|
4
4
|
export declare const SearchTriggersSchema: z.ZodObject<{
|
|
5
5
|
id: z.ZodOptional<z.ZodNumber>;
|
|
6
|
-
trigger_type: z.ZodOptional<z.ZodEnum<["slack", "schedule"]>>;
|
|
6
|
+
trigger_type: z.ZodOptional<z.ZodEnum<["slack", "schedule", "ao_event"]>>;
|
|
7
7
|
status: z.ZodOptional<z.ZodEnum<["enabled", "disabled"]>>;
|
|
8
8
|
include_channels: z.ZodOptional<z.ZodBoolean>;
|
|
9
9
|
page: z.ZodOptional<z.ZodNumber>;
|
|
@@ -12,14 +12,14 @@ export declare const SearchTriggersSchema: z.ZodObject<{
|
|
|
12
12
|
per_page?: number | undefined;
|
|
13
13
|
status?: "enabled" | "disabled" | undefined;
|
|
14
14
|
page?: number | undefined;
|
|
15
|
-
trigger_type?: "slack" | "schedule" | undefined;
|
|
15
|
+
trigger_type?: "slack" | "schedule" | "ao_event" | undefined;
|
|
16
16
|
id?: number | undefined;
|
|
17
17
|
include_channels?: boolean | undefined;
|
|
18
18
|
}, {
|
|
19
19
|
per_page?: number | undefined;
|
|
20
20
|
status?: "enabled" | "disabled" | undefined;
|
|
21
21
|
page?: number | undefined;
|
|
22
|
-
trigger_type?: "slack" | "schedule" | undefined;
|
|
22
|
+
trigger_type?: "slack" | "schedule" | "ao_event" | undefined;
|
|
23
23
|
id?: number | undefined;
|
|
24
24
|
include_channels?: boolean | undefined;
|
|
25
25
|
}>;
|
|
@@ -35,7 +35,7 @@ export declare function searchTriggersTool(_server: Server, clientFactory: () =>
|
|
|
35
35
|
};
|
|
36
36
|
trigger_type: {
|
|
37
37
|
type: string;
|
|
38
|
-
enum:
|
|
38
|
+
enum: readonly ["slack", "schedule", "ao_event"];
|
|
39
39
|
description: string;
|
|
40
40
|
};
|
|
41
41
|
status: {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
const TRIGGER_TYPE_VALUES = ['slack', 'schedule', 'ao_event'];
|
|
2
3
|
export const SearchTriggersSchema = z.object({
|
|
3
4
|
id: z.number().optional(),
|
|
4
|
-
trigger_type: z.enum(
|
|
5
|
+
trigger_type: z.enum(TRIGGER_TYPE_VALUES).optional(),
|
|
5
6
|
status: z.enum(['enabled', 'disabled']).optional(),
|
|
6
7
|
include_channels: z.boolean().optional(),
|
|
7
8
|
page: z.number().min(1).optional(),
|
|
@@ -14,10 +15,31 @@ const TOOL_DESCRIPTION = `Search and list automation triggers.
|
|
|
14
15
|
- **List**: List triggers with optional filters (trigger_type, status, pagination)
|
|
15
16
|
- **Include channels**: Set include_channels=true to also list available Slack channels (useful when creating Slack triggers)
|
|
16
17
|
|
|
18
|
+
**Filterable trigger types:**
|
|
19
|
+
- **slack**: Triggers fired by Slack messages
|
|
20
|
+
- **schedule**: Recurring or one-time scheduled triggers
|
|
21
|
+
- **ao_event**: Triggers fired by internal AO state transitions (e.g., a session entering needs_input or failed). These back the \`wake_me_up_when_session_changes_state\` tool.
|
|
22
|
+
|
|
23
|
+
A trigger may have multiple conditions (OR semantics) — filtering by trigger_type returns triggers that have at least one condition of that type.
|
|
24
|
+
|
|
17
25
|
**Use cases:**
|
|
18
|
-
- View configured automations (scheduled tasks, Slack integrations)
|
|
26
|
+
- View configured automations (scheduled tasks, Slack integrations, ao_event waiters)
|
|
19
27
|
- Check trigger status and execution history
|
|
20
28
|
- Discover available Slack channels for new triggers`;
|
|
29
|
+
// Returns a deduped, ordered list of condition types present on a trigger.
|
|
30
|
+
function summarizeConditionTypes(conditions) {
|
|
31
|
+
if (!conditions || conditions.length === 0)
|
|
32
|
+
return '(none)';
|
|
33
|
+
const seen = new Set();
|
|
34
|
+
const ordered = [];
|
|
35
|
+
for (const c of conditions) {
|
|
36
|
+
if (!seen.has(c.condition_type)) {
|
|
37
|
+
seen.add(c.condition_type);
|
|
38
|
+
ordered.push(c.condition_type);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return ordered.join(', ');
|
|
42
|
+
}
|
|
21
43
|
export function searchTriggersTool(_server, clientFactory) {
|
|
22
44
|
return {
|
|
23
45
|
name: 'search_triggers',
|
|
@@ -31,8 +53,8 @@ export function searchTriggersTool(_server, clientFactory) {
|
|
|
31
53
|
},
|
|
32
54
|
trigger_type: {
|
|
33
55
|
type: 'string',
|
|
34
|
-
enum:
|
|
35
|
-
description:
|
|
56
|
+
enum: TRIGGER_TYPE_VALUES,
|
|
57
|
+
description: "Filter to triggers having at least one condition of this type. Maps to the API's `condition_type` query parameter.",
|
|
36
58
|
},
|
|
37
59
|
status: {
|
|
38
60
|
type: 'string',
|
|
@@ -64,22 +86,30 @@ export function searchTriggersTool(_server, clientFactory) {
|
|
|
64
86
|
`## Trigger: ${t.name}`,
|
|
65
87
|
'',
|
|
66
88
|
`- **ID:** ${t.id}`,
|
|
67
|
-
`- **
|
|
89
|
+
`- **Conditions:** ${summarizeConditionTypes(t.conditions)}`,
|
|
68
90
|
`- **Status:** ${t.status}`,
|
|
69
91
|
`- **Agent Root:** ${t.agent_root_name}`,
|
|
70
92
|
`- **Reuse Session:** ${t.reuse_session ? 'Yes' : 'No'}`,
|
|
71
|
-
`- **MCP Servers:** ${t.mcp_servers.length > 0 ? t.mcp_servers.join(', ') : '(none)'}`,
|
|
93
|
+
`- **MCP Servers:** ${t.mcp_servers && t.mcp_servers.length > 0 ? t.mcp_servers.join(', ') : '(none)'}`,
|
|
72
94
|
];
|
|
73
95
|
if (t.stop_condition)
|
|
74
96
|
lines.push(`- **Stop Condition:** ${t.stop_condition}`);
|
|
75
|
-
if (t.schedule_description)
|
|
76
|
-
lines.push(`- **Schedule:** ${t.schedule_description}`);
|
|
77
97
|
lines.push(`- **Sessions Created:** ${t.sessions_created_count}`);
|
|
78
98
|
if (t.last_triggered_at)
|
|
79
99
|
lines.push(`- **Last Triggered:** ${t.last_triggered_at}`);
|
|
80
100
|
lines.push('', '### Prompt Template', '```', t.prompt_template, '```');
|
|
81
|
-
if (t.
|
|
82
|
-
lines.push('', '###
|
|
101
|
+
if (t.conditions && t.conditions.length > 0) {
|
|
102
|
+
lines.push('', '### Conditions');
|
|
103
|
+
t.conditions.forEach((c) => {
|
|
104
|
+
lines.push(`- **${c.condition_type}** — ${c.description}`);
|
|
105
|
+
if (c.configuration && Object.keys(c.configuration).length > 0) {
|
|
106
|
+
lines.push(' ```json');
|
|
107
|
+
JSON.stringify(c.configuration, null, 2)
|
|
108
|
+
.split('\n')
|
|
109
|
+
.forEach((line) => lines.push(` ${line}`));
|
|
110
|
+
lines.push(' ```');
|
|
111
|
+
}
|
|
112
|
+
});
|
|
83
113
|
}
|
|
84
114
|
if (response.recent_sessions && response.recent_sessions.length > 0) {
|
|
85
115
|
lines.push('', '### Recent Sessions');
|
|
@@ -104,9 +134,12 @@ export function searchTriggersTool(_server, clientFactory) {
|
|
|
104
134
|
lines.push(`## Triggers (${response.pagination.total_count} total, page ${response.pagination.page} of ${response.pagination.total_pages})`, '');
|
|
105
135
|
response.triggers.forEach((t) => {
|
|
106
136
|
lines.push(`### ${t.name} (ID: ${t.id})`);
|
|
107
|
-
lines.push(`- **
|
|
108
|
-
if (t.
|
|
109
|
-
|
|
137
|
+
lines.push(`- **Conditions:** ${summarizeConditionTypes(t.conditions)} | **Status:** ${t.status} | **Sessions:** ${t.sessions_created_count}`);
|
|
138
|
+
if (t.conditions && t.conditions.length > 0) {
|
|
139
|
+
t.conditions.forEach((c) => {
|
|
140
|
+
lines.push(` - ${c.description}`);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
110
143
|
lines.push('');
|
|
111
144
|
});
|
|
112
145
|
}
|
package/shared/types.d.ts
CHANGED
|
@@ -215,23 +215,31 @@ export interface EnqueuedMessageInterruptResponse {
|
|
|
215
215
|
session: Session;
|
|
216
216
|
message: string;
|
|
217
217
|
}
|
|
218
|
-
export type
|
|
218
|
+
export type TriggerConditionType = 'slack' | 'schedule' | 'ao_event';
|
|
219
|
+
export type TriggerType = TriggerConditionType;
|
|
219
220
|
export type TriggerStatus = 'enabled' | 'disabled';
|
|
221
|
+
export interface TriggerCondition {
|
|
222
|
+
id: number;
|
|
223
|
+
condition_type: TriggerConditionType;
|
|
224
|
+
configuration: Record<string, unknown>;
|
|
225
|
+
description: string;
|
|
226
|
+
last_triggered_at: string | null;
|
|
227
|
+
last_polled_at: string | null;
|
|
228
|
+
}
|
|
220
229
|
export interface Trigger {
|
|
221
230
|
id: number;
|
|
222
231
|
name: string;
|
|
223
|
-
trigger_type: TriggerType;
|
|
224
232
|
status: TriggerStatus;
|
|
225
233
|
agent_root_name: string;
|
|
226
234
|
prompt_template: string;
|
|
227
235
|
stop_condition: string | null;
|
|
228
236
|
reuse_session: boolean;
|
|
237
|
+
enqueue_messages?: boolean;
|
|
238
|
+
resuscitate_archived?: boolean;
|
|
229
239
|
mcp_servers: string[];
|
|
230
|
-
|
|
231
|
-
schedule_description: string | null;
|
|
240
|
+
conditions: TriggerCondition[];
|
|
232
241
|
last_session_id: number | null;
|
|
233
242
|
last_triggered_at: string | null;
|
|
234
|
-
last_polled_at: string | null;
|
|
235
243
|
sessions_created_count: number;
|
|
236
244
|
created_at: string;
|
|
237
245
|
updated_at: string;
|
|
@@ -253,31 +261,32 @@ export interface TriggerChannelsResponse {
|
|
|
253
261
|
}>;
|
|
254
262
|
}
|
|
255
263
|
export interface TriggerConditionAttributes {
|
|
256
|
-
condition_type:
|
|
264
|
+
condition_type: TriggerConditionType;
|
|
257
265
|
configuration: Record<string, unknown>;
|
|
258
266
|
}
|
|
259
267
|
export interface CreateTriggerRequest {
|
|
260
268
|
name: string;
|
|
261
|
-
trigger_type?: TriggerType;
|
|
262
269
|
agent_root_name: string;
|
|
263
270
|
prompt_template: string;
|
|
264
271
|
status?: TriggerStatus;
|
|
265
272
|
stop_condition?: string;
|
|
266
273
|
reuse_session?: boolean;
|
|
267
274
|
mcp_servers?: string[];
|
|
268
|
-
configuration?: Record<string, unknown>;
|
|
269
275
|
last_session_id?: number;
|
|
270
276
|
trigger_conditions_attributes?: TriggerConditionAttributes[];
|
|
277
|
+
trigger_type?: TriggerConditionType;
|
|
278
|
+
configuration?: Record<string, unknown>;
|
|
271
279
|
}
|
|
272
280
|
export interface UpdateTriggerRequest {
|
|
273
281
|
name?: string;
|
|
274
|
-
trigger_type?: TriggerType;
|
|
275
282
|
agent_root_name?: string;
|
|
276
283
|
prompt_template?: string;
|
|
277
284
|
status?: TriggerStatus;
|
|
278
285
|
stop_condition?: string;
|
|
279
286
|
reuse_session?: boolean;
|
|
280
287
|
mcp_servers?: string[];
|
|
288
|
+
trigger_conditions_attributes?: TriggerConditionAttributes[];
|
|
289
|
+
trigger_type?: TriggerConditionType;
|
|
281
290
|
configuration?: Record<string, unknown>;
|
|
282
291
|
}
|
|
283
292
|
export interface Notification {
|