@aramisfa/openclaw-a2a-outbound 0.1.1 → 0.2.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/README.md +261 -16
- package/dist/config.d.ts +17 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +214 -8
- package/dist/config.js.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/errors.d.ts +4 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +37 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +44 -20
- package/dist/index.js.map +1 -1
- package/dist/request-normalization.d.ts +23 -0
- package/dist/request-normalization.d.ts.map +1 -0
- package/dist/request-normalization.js +109 -0
- package/dist/request-normalization.js.map +1 -0
- package/dist/result-shape.d.ts +68 -25
- package/dist/result-shape.d.ts.map +1 -1
- package/dist/result-shape.js +192 -59
- package/dist/result-shape.js.map +1 -1
- package/dist/schemas.d.ts +81 -779
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +308 -275
- package/dist/schemas.js.map +1 -1
- package/dist/sdk-client-pool.d.ts +8 -4
- package/dist/sdk-client-pool.d.ts.map +1 -1
- package/dist/sdk-client-pool.js +21 -1
- package/dist/sdk-client-pool.js.map +1 -1
- package/dist/service.d.ts +33 -4
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +381 -60
- package/dist/service.js.map +1 -1
- package/dist/target-catalog.d.ts +66 -0
- package/dist/target-catalog.d.ts.map +1 -0
- package/dist/target-catalog.js +309 -0
- package/dist/target-catalog.js.map +1 -0
- package/dist/task-handle-registry.d.ts +29 -0
- package/dist/task-handle-registry.d.ts.map +1 -0
- package/dist/task-handle-registry.js +141 -0
- package/dist/task-handle-registry.js.map +1 -0
- package/openclaw.plugin.json +68 -1
- package/package.json +9 -5
- package/skills/remote-agent/SKILL.md +93 -0
package/dist/schemas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"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"}
|
package/dist/schemas.js
CHANGED
|
@@ -1,315 +1,348 @@
|
|
|
1
1
|
import { ALL_TRANSPORTS } from "./constants.js";
|
|
2
|
-
import { createA2AOutboundAjv, toValidationError } from "./ajv-validator.js";
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
type: "string",
|
|
17
|
-
minLength: 1,
|
|
18
|
-
description: "Optional override for the target agent-card path. Defaults from plugin config when omitted.",
|
|
19
|
-
},
|
|
20
|
-
preferredTransports: {
|
|
21
|
-
type: "array",
|
|
22
|
-
items: {
|
|
23
|
-
type: "string",
|
|
24
|
-
enum: ALL_TRANSPORTS,
|
|
25
|
-
},
|
|
26
|
-
description: "Optional transport preference override for this call. Defaults from plugin config when omitted.",
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
required: ["baseUrl"],
|
|
2
|
+
import { createA2AOutboundAjv, toValidationError, } from "./ajv-validator.js";
|
|
3
|
+
export const REMOTE_AGENT_TOOL_NAME = "remote_agent";
|
|
4
|
+
export const REMOTE_AGENT_ACTIONS = [
|
|
5
|
+
"list_targets",
|
|
6
|
+
"send",
|
|
7
|
+
"watch",
|
|
8
|
+
"status",
|
|
9
|
+
"cancel",
|
|
10
|
+
];
|
|
11
|
+
const TASK_HANDLE_SCHEMA = {
|
|
12
|
+
type: "string",
|
|
13
|
+
minLength: 1,
|
|
14
|
+
pattern: "^rah_[A-Za-z0-9-]+$",
|
|
15
|
+
description: "Opaque task handle issued by this plugin. Handles are process-local and invalidated by restarts.",
|
|
30
16
|
};
|
|
31
|
-
const
|
|
17
|
+
const ATTACHMENT_METADATA_SCHEMA = {
|
|
32
18
|
type: "object",
|
|
33
19
|
additionalProperties: true,
|
|
34
20
|
};
|
|
35
|
-
const
|
|
36
|
-
type: "object",
|
|
37
|
-
additionalProperties: false,
|
|
38
|
-
properties: {
|
|
39
|
-
kind: { type: "string", enum: ["text"] },
|
|
40
|
-
text: { type: "string" },
|
|
41
|
-
metadata: MESSAGE_PART_METADATA_SCHEMA,
|
|
42
|
-
},
|
|
43
|
-
required: ["kind", "text"],
|
|
44
|
-
};
|
|
45
|
-
const FILE_PART_FILE_SCHEMA = {
|
|
46
|
-
type: "object",
|
|
47
|
-
additionalProperties: false,
|
|
48
|
-
properties: {
|
|
49
|
-
uri: { type: "string", minLength: 1 },
|
|
50
|
-
bytes: { type: "string", minLength: 1 },
|
|
51
|
-
name: { type: "string" },
|
|
52
|
-
mimeType: { type: "string" },
|
|
53
|
-
},
|
|
54
|
-
anyOf: [{ required: ["uri"] }, { required: ["bytes"] }],
|
|
55
|
-
};
|
|
56
|
-
const FILE_PART_SCHEMA = {
|
|
21
|
+
const FILE_ATTACHMENT_SCHEMA = {
|
|
57
22
|
type: "object",
|
|
58
23
|
additionalProperties: false,
|
|
59
24
|
properties: {
|
|
60
25
|
kind: { type: "string", enum: ["file"] },
|
|
61
|
-
|
|
62
|
-
metadata: MESSAGE_PART_METADATA_SCHEMA,
|
|
63
|
-
},
|
|
64
|
-
required: ["kind", "file"],
|
|
65
|
-
};
|
|
66
|
-
const DATA_PART_SCHEMA = {
|
|
67
|
-
type: "object",
|
|
68
|
-
additionalProperties: false,
|
|
69
|
-
properties: {
|
|
70
|
-
kind: { type: "string", enum: ["data"] },
|
|
71
|
-
data: { type: "object", additionalProperties: true },
|
|
72
|
-
metadata: MESSAGE_PART_METADATA_SCHEMA,
|
|
73
|
-
},
|
|
74
|
-
required: ["kind", "data"],
|
|
75
|
-
};
|
|
76
|
-
const PUSH_NOTIFICATION_AUTHENTICATION_SCHEMA = {
|
|
77
|
-
type: "object",
|
|
78
|
-
additionalProperties: false,
|
|
79
|
-
properties: {
|
|
80
|
-
schemes: {
|
|
81
|
-
type: "array",
|
|
82
|
-
items: { type: "string" },
|
|
83
|
-
description: "Authentication schemes for MessageSendParams.configuration.pushNotificationConfig.authentication.schemes.",
|
|
84
|
-
},
|
|
85
|
-
credentials: {
|
|
26
|
+
uri: {
|
|
86
27
|
type: "string",
|
|
87
|
-
|
|
28
|
+
minLength: 1,
|
|
29
|
+
description: "Remote file URI for the attachment.",
|
|
88
30
|
},
|
|
89
|
-
|
|
90
|
-
required: ["schemes"],
|
|
91
|
-
};
|
|
92
|
-
const PUSH_NOTIFICATION_CONFIG_SCHEMA = {
|
|
93
|
-
type: "object",
|
|
94
|
-
additionalProperties: false,
|
|
95
|
-
properties: {
|
|
96
|
-
url: {
|
|
31
|
+
bytes: {
|
|
97
32
|
type: "string",
|
|
98
33
|
minLength: 1,
|
|
99
|
-
description: "
|
|
34
|
+
description: "Base64-encoded inline file content.",
|
|
100
35
|
},
|
|
101
|
-
|
|
36
|
+
name: {
|
|
102
37
|
type: "string",
|
|
103
|
-
|
|
38
|
+
minLength: 1,
|
|
39
|
+
description: "Optional filename.",
|
|
104
40
|
},
|
|
105
|
-
|
|
41
|
+
mime_type: {
|
|
106
42
|
type: "string",
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
authentication: {
|
|
110
|
-
...PUSH_NOTIFICATION_AUTHENTICATION_SCHEMA,
|
|
111
|
-
description: "Optional MessageSendParams.configuration.pushNotificationConfig.authentication payload.",
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
required: ["url"],
|
|
115
|
-
};
|
|
116
|
-
const MESSAGE_SEND_CONFIGURATION_SCHEMA = {
|
|
117
|
-
type: "object",
|
|
118
|
-
additionalProperties: false,
|
|
119
|
-
properties: {
|
|
120
|
-
blocking: {
|
|
121
|
-
type: "boolean",
|
|
122
|
-
description: "Optional MessageSendParams.configuration.blocking passthrough.",
|
|
123
|
-
},
|
|
124
|
-
acceptedOutputModes: {
|
|
125
|
-
type: "array",
|
|
126
|
-
items: { type: "string" },
|
|
127
|
-
description: "Optional MessageSendParams.configuration.acceptedOutputModes passthrough.",
|
|
128
|
-
},
|
|
129
|
-
historyLength: {
|
|
130
|
-
type: "integer",
|
|
131
|
-
minimum: 0,
|
|
132
|
-
description: "Optional MessageSendParams.configuration.historyLength passthrough.",
|
|
133
|
-
},
|
|
134
|
-
pushNotificationConfig: {
|
|
135
|
-
...PUSH_NOTIFICATION_CONFIG_SCHEMA,
|
|
136
|
-
description: "Optional MessageSendParams.configuration.pushNotificationConfig passthrough.",
|
|
43
|
+
minLength: 1,
|
|
44
|
+
description: "Optional MIME type.",
|
|
137
45
|
},
|
|
46
|
+
metadata: ATTACHMENT_METADATA_SCHEMA,
|
|
138
47
|
},
|
|
48
|
+
required: ["kind"],
|
|
49
|
+
anyOf: [{ required: ["uri"] }, { required: ["bytes"] }],
|
|
139
50
|
};
|
|
140
|
-
const
|
|
51
|
+
const DATA_ATTACHMENT_SCHEMA = {
|
|
141
52
|
type: "object",
|
|
142
53
|
additionalProperties: false,
|
|
143
54
|
properties: {
|
|
144
|
-
kind: { type: "string", enum: ["
|
|
145
|
-
|
|
146
|
-
role: { type: "string", enum: MESSAGE_ROLES },
|
|
147
|
-
parts: {
|
|
148
|
-
type: "array",
|
|
149
|
-
items: {
|
|
150
|
-
oneOf: [TEXT_PART_SCHEMA, FILE_PART_SCHEMA, DATA_PART_SCHEMA],
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
contextId: { type: "string", minLength: 1 },
|
|
154
|
-
taskId: { type: "string", minLength: 1 },
|
|
155
|
-
extensions: {
|
|
156
|
-
type: "array",
|
|
157
|
-
items: { type: "string" },
|
|
158
|
-
},
|
|
159
|
-
referenceTaskIds: {
|
|
160
|
-
type: "array",
|
|
161
|
-
items: { type: "string" },
|
|
162
|
-
},
|
|
163
|
-
metadata: {
|
|
55
|
+
kind: { type: "string", enum: ["data"] },
|
|
56
|
+
data: {
|
|
164
57
|
type: "object",
|
|
165
58
|
additionalProperties: true,
|
|
59
|
+
description: "Structured attachment payload.",
|
|
166
60
|
},
|
|
61
|
+
metadata: ATTACHMENT_METADATA_SCHEMA,
|
|
167
62
|
},
|
|
168
|
-
required: ["kind", "
|
|
63
|
+
required: ["kind", "data"],
|
|
169
64
|
};
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
65
|
+
const ACTION_ALLOWED_FIELDS = Object.freeze({
|
|
66
|
+
list_targets: new Set(["action"]),
|
|
67
|
+
send: new Set([
|
|
68
|
+
"action",
|
|
69
|
+
"target_alias",
|
|
70
|
+
"target_url",
|
|
71
|
+
"input",
|
|
72
|
+
"attachments",
|
|
73
|
+
"follow_updates",
|
|
74
|
+
"history_length",
|
|
75
|
+
"timeout_ms",
|
|
76
|
+
"service_parameters",
|
|
77
|
+
"metadata",
|
|
78
|
+
]),
|
|
79
|
+
watch: new Set([
|
|
80
|
+
"action",
|
|
81
|
+
"target_alias",
|
|
82
|
+
"target_url",
|
|
83
|
+
"task_handle",
|
|
84
|
+
"task_id",
|
|
85
|
+
"timeout_ms",
|
|
86
|
+
"service_parameters",
|
|
87
|
+
]),
|
|
88
|
+
status: new Set([
|
|
89
|
+
"action",
|
|
90
|
+
"target_alias",
|
|
91
|
+
"target_url",
|
|
92
|
+
"task_handle",
|
|
93
|
+
"task_id",
|
|
94
|
+
"history_length",
|
|
95
|
+
"timeout_ms",
|
|
96
|
+
"service_parameters",
|
|
97
|
+
]),
|
|
98
|
+
cancel: new Set([
|
|
99
|
+
"action",
|
|
100
|
+
"target_alias",
|
|
101
|
+
"target_url",
|
|
102
|
+
"task_handle",
|
|
103
|
+
"task_id",
|
|
104
|
+
"timeout_ms",
|
|
105
|
+
"service_parameters",
|
|
106
|
+
]),
|
|
107
|
+
});
|
|
108
|
+
function normalizeConfiguredBaseUrl(baseUrl, config) {
|
|
109
|
+
return config.policy.normalizeBaseUrl ? new URL(baseUrl).toString() : baseUrl;
|
|
110
|
+
}
|
|
111
|
+
function summarizeTargets(config) {
|
|
112
|
+
return {
|
|
113
|
+
aliases: config.targets.map((target) => target.alias),
|
|
114
|
+
configuredBaseUrls: new Set(config.targets.map((target) => normalizeConfiguredBaseUrl(target.baseUrl, config))),
|
|
115
|
+
hasDefaultTarget: config.targets.some((target) => target.default),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function configuredTargetSummaryText(config) {
|
|
119
|
+
const aliases = config.targets.map((target) => target.alias);
|
|
120
|
+
const defaultTarget = config.targets.find((target) => target.default);
|
|
121
|
+
if (aliases.length === 0) {
|
|
122
|
+
return config.policy.allowTargetUrlOverride
|
|
123
|
+
? "No configured targets. Use target_url for explicit routing."
|
|
124
|
+
: "No configured targets. Add a default target or enable target_url overrides to route send/status/watch/cancel actions.";
|
|
125
|
+
}
|
|
126
|
+
const configured = `Configured targets: ${aliases.join(", ")}.`;
|
|
127
|
+
const defaultDescription = defaultTarget
|
|
128
|
+
? ` Default target: ${defaultTarget.alias}.`
|
|
129
|
+
: " No default target is configured.";
|
|
130
|
+
const urlPolicy = config.policy.allowTargetUrlOverride
|
|
131
|
+
? " Explicit target_url overrides are enabled."
|
|
132
|
+
: " Explicit target_url values must match configured targets.";
|
|
133
|
+
return `${configured}${defaultDescription}${urlPolicy}`;
|
|
134
|
+
}
|
|
135
|
+
function targetAliasSchema(config) {
|
|
136
|
+
const aliases = config.targets.map((target) => target.alias);
|
|
137
|
+
const defaultTarget = config.targets.find((target) => target.default);
|
|
138
|
+
return {
|
|
139
|
+
type: "string",
|
|
140
|
+
minLength: 1,
|
|
141
|
+
...(aliases.length > 0 ? { enum: aliases } : {}),
|
|
142
|
+
description: defaultTarget
|
|
143
|
+
? `Configured target alias. When omitted, the default target "${defaultTarget.alias}" is used when the action allows it.`
|
|
144
|
+
: "Configured target alias.",
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
export function buildRemoteAgentParametersSchema(config) {
|
|
148
|
+
return {
|
|
149
|
+
type: "object",
|
|
150
|
+
additionalProperties: false,
|
|
151
|
+
properties: {
|
|
152
|
+
action: {
|
|
153
|
+
type: "string",
|
|
154
|
+
enum: REMOTE_AGENT_ACTIONS,
|
|
155
|
+
description: "Action to perform: list_targets, send, watch, status, or cancel.",
|
|
202
156
|
},
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
additionalProperties: false,
|
|
211
|
-
properties: {
|
|
212
|
-
target: TARGET_SCHEMA,
|
|
213
|
-
request: {
|
|
214
|
-
type: "object",
|
|
215
|
-
additionalProperties: false,
|
|
216
|
-
properties: {
|
|
217
|
-
taskId: {
|
|
218
|
-
type: "string",
|
|
219
|
-
minLength: 1,
|
|
220
|
-
description: "Remote task id to query.",
|
|
221
|
-
},
|
|
222
|
-
historyLength: {
|
|
223
|
-
type: "integer",
|
|
224
|
-
minimum: 0,
|
|
225
|
-
description: "Optional history window length.",
|
|
226
|
-
},
|
|
227
|
-
timeoutMs: {
|
|
228
|
-
type: "integer",
|
|
229
|
-
minimum: 1,
|
|
230
|
-
description: "Optional timeout override for this operation.",
|
|
231
|
-
},
|
|
232
|
-
serviceParameters: {
|
|
233
|
-
type: "object",
|
|
234
|
-
additionalProperties: { type: "string" },
|
|
235
|
-
description: "Optional service parameters for this operation.",
|
|
236
|
-
},
|
|
157
|
+
target_alias: targetAliasSchema(config),
|
|
158
|
+
target_url: {
|
|
159
|
+
type: "string",
|
|
160
|
+
minLength: 1,
|
|
161
|
+
format: "uri",
|
|
162
|
+
pattern: "^https?://",
|
|
163
|
+
description: "Explicit remote target base URL. When target URL overrides are disabled, the URL must match a configured target.",
|
|
237
164
|
},
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
request: {
|
|
249
|
-
type: "object",
|
|
250
|
-
additionalProperties: false,
|
|
251
|
-
properties: {
|
|
252
|
-
taskId: {
|
|
253
|
-
type: "string",
|
|
254
|
-
minLength: 1,
|
|
255
|
-
description: "Remote task id to cancel.",
|
|
256
|
-
},
|
|
257
|
-
timeoutMs: {
|
|
258
|
-
type: "integer",
|
|
259
|
-
minimum: 1,
|
|
260
|
-
description: "Optional timeout override for this operation.",
|
|
261
|
-
},
|
|
262
|
-
serviceParameters: {
|
|
263
|
-
type: "object",
|
|
264
|
-
additionalProperties: { type: "string" },
|
|
265
|
-
description: "Optional service parameters for this operation.",
|
|
165
|
+
input: {
|
|
166
|
+
type: "string",
|
|
167
|
+
minLength: 1,
|
|
168
|
+
description: "User text input for action=send. This becomes the single user text part.",
|
|
169
|
+
},
|
|
170
|
+
attachments: {
|
|
171
|
+
type: "array",
|
|
172
|
+
description: "Optional file/data attachments for action=send. Inline text attachments are not supported in phase 4; use input instead.",
|
|
173
|
+
items: {
|
|
174
|
+
oneOf: [FILE_ATTACHMENT_SCHEMA, DATA_ATTACHMENT_SCHEMA],
|
|
266
175
|
},
|
|
267
176
|
},
|
|
268
|
-
|
|
177
|
+
task_handle: TASK_HANDLE_SCHEMA,
|
|
178
|
+
task_id: {
|
|
179
|
+
type: "string",
|
|
180
|
+
minLength: 1,
|
|
181
|
+
description: "Remote task id for watch/status/cancel when no task_handle is available.",
|
|
182
|
+
},
|
|
183
|
+
follow_updates: {
|
|
184
|
+
type: "boolean",
|
|
185
|
+
description: "When true, action=send streams updates and returns the full event log.",
|
|
186
|
+
},
|
|
187
|
+
history_length: {
|
|
188
|
+
type: "integer",
|
|
189
|
+
minimum: 0,
|
|
190
|
+
description: "Optional history window for action=send and action=status.",
|
|
191
|
+
},
|
|
192
|
+
timeout_ms: {
|
|
193
|
+
type: "integer",
|
|
194
|
+
minimum: 1,
|
|
195
|
+
description: "Optional timeout override for the remote request.",
|
|
196
|
+
},
|
|
197
|
+
service_parameters: {
|
|
198
|
+
type: "object",
|
|
199
|
+
additionalProperties: { type: "string" },
|
|
200
|
+
description: "Optional request service parameters.",
|
|
201
|
+
},
|
|
202
|
+
metadata: {
|
|
203
|
+
type: "object",
|
|
204
|
+
additionalProperties: true,
|
|
205
|
+
description: "Optional metadata payload for action=send.",
|
|
206
|
+
},
|
|
269
207
|
},
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
273
|
-
export
|
|
274
|
-
|
|
275
|
-
name:
|
|
276
|
-
label: "
|
|
277
|
-
description:
|
|
278
|
-
parameters:
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
208
|
+
required: ["action"],
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
export function buildRemoteAgentToolDefinition(config) {
|
|
212
|
+
return {
|
|
213
|
+
name: REMOTE_AGENT_TOOL_NAME,
|
|
214
|
+
label: "Remote Agent",
|
|
215
|
+
description: `Route requests to remote A2A agents and manage delegated tasks. ${configuredTargetSummaryText(config)}`,
|
|
216
|
+
parameters: buildRemoteAgentParametersSchema(config),
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
function makeError(instancePath, keyword, message, params = {}) {
|
|
220
|
+
return {
|
|
221
|
+
instancePath,
|
|
222
|
+
schemaPath: `#/runtime/${keyword}`,
|
|
223
|
+
keyword,
|
|
224
|
+
params,
|
|
225
|
+
message,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
function disallowedFieldErrors(action, input) {
|
|
229
|
+
const allowedFields = ACTION_ALLOWED_FIELDS[action];
|
|
230
|
+
const errors = [];
|
|
231
|
+
for (const property of Object.keys(input)) {
|
|
232
|
+
if (!allowedFields.has(property)) {
|
|
233
|
+
errors.push(makeError("", "not", `"${property}" is not supported for action=${action}`, {
|
|
234
|
+
property,
|
|
235
|
+
action,
|
|
236
|
+
}));
|
|
237
|
+
}
|
|
300
238
|
}
|
|
301
|
-
return
|
|
239
|
+
return errors;
|
|
302
240
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
241
|
+
function validateExplicitTargetFields(input, summary, config) {
|
|
242
|
+
const errors = [];
|
|
243
|
+
if (input.target_alias !== undefined && !summary.aliases.includes(input.target_alias)) {
|
|
244
|
+
errors.push(makeError("/target_alias", "enum", "must match a configured target alias", {
|
|
245
|
+
allowedValues: summary.aliases,
|
|
246
|
+
}));
|
|
247
|
+
}
|
|
248
|
+
if (input.target_url !== undefined) {
|
|
249
|
+
const normalized = normalizeConfiguredBaseUrl(input.target_url, config);
|
|
250
|
+
const isResolvable = config.policy.allowTargetUrlOverride ||
|
|
251
|
+
summary.configuredBaseUrls.has(normalized);
|
|
252
|
+
if (!isResolvable) {
|
|
253
|
+
errors.push(makeError("/target_url", "anyOf", "must resolve to a configured target or be allowed by policy", {
|
|
254
|
+
allowTargetUrlOverride: config.policy.allowTargetUrlOverride,
|
|
255
|
+
configuredTargetAliases: summary.aliases,
|
|
256
|
+
}));
|
|
257
|
+
}
|
|
306
258
|
}
|
|
307
|
-
return
|
|
259
|
+
return errors;
|
|
308
260
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
261
|
+
function validateSendInput(input, summary, config) {
|
|
262
|
+
const errors = validateExplicitTargetFields(input, summary, config);
|
|
263
|
+
if (input.input === undefined) {
|
|
264
|
+
errors.push(makeError("", "required", "send requires input", {
|
|
265
|
+
missingProperty: "input",
|
|
266
|
+
}));
|
|
312
267
|
}
|
|
313
|
-
|
|
268
|
+
const hasExplicitTarget = input.target_alias !== undefined || input.target_url !== undefined;
|
|
269
|
+
if (!hasExplicitTarget && !summary.hasDefaultTarget) {
|
|
270
|
+
errors.push(makeError("", "anyOf", "send requires target_alias, target_url, or a configured default target"));
|
|
271
|
+
}
|
|
272
|
+
return errors;
|
|
314
273
|
}
|
|
274
|
+
function validateFollowUpInput(input, summary, config) {
|
|
275
|
+
const errors = validateExplicitTargetFields(input, summary, config);
|
|
276
|
+
const hasTaskHandle = input.task_handle !== undefined;
|
|
277
|
+
const hasTaskId = input.task_id !== undefined;
|
|
278
|
+
if (!hasTaskHandle && !hasTaskId) {
|
|
279
|
+
errors.push(makeError("", "anyOf", `${input.action} requires task_handle or task_id`));
|
|
280
|
+
}
|
|
281
|
+
if (!hasTaskHandle &&
|
|
282
|
+
hasTaskId &&
|
|
283
|
+
input.target_alias === undefined &&
|
|
284
|
+
input.target_url === undefined &&
|
|
285
|
+
!summary.hasDefaultTarget) {
|
|
286
|
+
errors.push(makeError("", "anyOf", `${input.action} requires target_alias, target_url, or a configured default target when task_id is used without task_handle`));
|
|
287
|
+
}
|
|
288
|
+
return errors;
|
|
289
|
+
}
|
|
290
|
+
function validateActionSpecificRules(input, summary, config) {
|
|
291
|
+
const recordInput = input;
|
|
292
|
+
const errors = disallowedFieldErrors(input.action, recordInput);
|
|
293
|
+
switch (input.action) {
|
|
294
|
+
case "list_targets":
|
|
295
|
+
return errors;
|
|
296
|
+
case "send":
|
|
297
|
+
return [...errors, ...validateSendInput(input, summary, config)];
|
|
298
|
+
case "watch":
|
|
299
|
+
case "status":
|
|
300
|
+
case "cancel":
|
|
301
|
+
return [...errors, ...validateFollowUpInput(input, summary, config)];
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
export function createRemoteAgentInputValidator(config) {
|
|
305
|
+
const ajv = createA2AOutboundAjv();
|
|
306
|
+
const schema = buildRemoteAgentParametersSchema(config);
|
|
307
|
+
const validateSchema = ajv.compile(schema);
|
|
308
|
+
const targetSummary = summarizeTargets(config);
|
|
309
|
+
return (input) => {
|
|
310
|
+
if (!validateSchema(input)) {
|
|
311
|
+
toValidationError(REMOTE_AGENT_TOOL_NAME, [...validateSchema.errors]);
|
|
312
|
+
}
|
|
313
|
+
const validated = input;
|
|
314
|
+
const customErrors = validateActionSpecificRules(validated, targetSummary, config);
|
|
315
|
+
if (customErrors.length > 0) {
|
|
316
|
+
toValidationError(REMOTE_AGENT_TOOL_NAME, customErrors);
|
|
317
|
+
}
|
|
318
|
+
return validated;
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
export const PUBLIC_TARGET_SCHEMA = {
|
|
322
|
+
type: "object",
|
|
323
|
+
additionalProperties: false,
|
|
324
|
+
properties: {
|
|
325
|
+
baseUrl: {
|
|
326
|
+
type: "string",
|
|
327
|
+
minLength: 1,
|
|
328
|
+
format: "uri",
|
|
329
|
+
pattern: "^https?://",
|
|
330
|
+
description: "Target agent base URL.",
|
|
331
|
+
},
|
|
332
|
+
cardPath: {
|
|
333
|
+
type: "string",
|
|
334
|
+
minLength: 1,
|
|
335
|
+
description: "Optional override for the target agent-card path. Defaults from plugin config when omitted.",
|
|
336
|
+
},
|
|
337
|
+
preferredTransports: {
|
|
338
|
+
type: "array",
|
|
339
|
+
items: {
|
|
340
|
+
type: "string",
|
|
341
|
+
enum: ALL_TRANSPORTS,
|
|
342
|
+
},
|
|
343
|
+
description: "Optional transport preference override for this call. Defaults from plugin config when omitted.",
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
required: ["baseUrl"],
|
|
347
|
+
};
|
|
315
348
|
//# sourceMappingURL=schemas.js.map
|