@evalops/maestro 0.10.31 → 0.10.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/transport/tool-execution.d.ts +1 -0
- package/dist/agent/transport/tool-execution.d.ts.map +1 -1
- package/dist/agent/transport/tool-execution.js +23 -3
- package/dist/agent/transport/tool-execution.js.map +1 -1
- package/dist/agent/transport/tool-phase-summary.d.ts +6 -0
- package/dist/agent/transport/tool-phase-summary.d.ts.map +1 -0
- package/dist/agent/transport/tool-phase-summary.js +99 -0
- package/dist/agent/transport/tool-phase-summary.js.map +1 -0
- package/dist/agent/transport/tool-safety-pipeline.d.ts +1 -0
- package/dist/agent/transport/tool-safety-pipeline.d.ts.map +1 -1
- package/dist/agent/transport/tool-safety-pipeline.js +9 -4
- package/dist/agent/transport/tool-safety-pipeline.js.map +1 -1
- package/dist/agent/transport.d.ts.map +1 -1
- package/dist/agent/transport.js +4 -99
- package/dist/agent/transport.js.map +1 -1
- package/dist/cli/commands/a2a/args.d.ts +13 -0
- package/dist/cli/commands/a2a/args.d.ts.map +1 -0
- package/dist/cli/commands/a2a/args.js +327 -0
- package/dist/cli/commands/a2a/args.js.map +1 -0
- package/dist/cli/commands/a2a/discovery.d.ts +40 -0
- package/dist/cli/commands/a2a/discovery.d.ts.map +1 -0
- package/dist/cli/commands/a2a/discovery.js +150 -0
- package/dist/cli/commands/a2a/discovery.js.map +1 -0
- package/dist/cli/commands/a2a.d.ts +2 -5
- package/dist/cli/commands/a2a.d.ts.map +1 -1
- package/dist/cli/commands/a2a.js +4 -474
- package/dist/cli/commands/a2a.js.map +1 -1
- package/dist/cli.js +1801 -1528
- package/dist/node_modules/@evalops/contracts/package.json +1 -1
- package/dist/node_modules/@evalops/tui/package.json +1 -1
- package/dist/server/app-context.d.ts +7 -0
- package/dist/server/app-context.d.ts.map +1 -1
- package/dist/server/app-context.js.map +1 -1
- package/dist/server/handlers/chat-ws.d.ts.map +1 -1
- package/dist/server/handlers/chat-ws.js +42 -24
- package/dist/server/handlers/chat-ws.js.map +1 -1
- package/dist/server/handlers/chat.d.ts.map +1 -1
- package/dist/server/handlers/chat.js +54 -35
- package/dist/server/handlers/chat.js.map +1 -1
- package/dist/server/handlers/hosted-runner-identity.d.ts +17 -0
- package/dist/server/handlers/hosted-runner-identity.d.ts.map +1 -1
- package/dist/server/handlers/hosted-runner-identity.js +7 -0
- package/dist/server/handlers/hosted-runner-identity.js.map +1 -1
- package/dist/server/handlers/platform-a2a-push.d.ts.map +1 -1
- package/dist/server/handlers/platform-a2a-push.js +134 -15
- package/dist/server/handlers/platform-a2a-push.js.map +1 -1
- package/dist/server/server-utils.d.ts.map +1 -1
- package/dist/server/server-utils.js +12 -0
- package/dist/server/server-utils.js.map +1 -1
- package/dist/server/session-timeline.d.ts.map +1 -1
- package/dist/server/session-timeline.js +13 -0
- package/dist/server/session-timeline.js.map +1 -1
- package/dist/telemetry/maestro-event-catalog.d.ts +30 -0
- package/dist/telemetry/maestro-event-catalog.d.ts.map +1 -1
- package/dist/telemetry/maestro-event-catalog.js +96 -5
- package/dist/telemetry/maestro-event-catalog.js.map +1 -1
- package/dist/tools/find.d.ts +2 -0
- package/dist/tools/find.d.ts.map +1 -1
- package/dist/tools/find.js +25 -12
- package/dist/tools/find.js.map +1 -1
- package/dist/version.json +2 -2
- package/package.json +6 -2
package/dist/cli/commands/a2a.js
CHANGED
|
@@ -7,166 +7,18 @@ import { buildA2ACockpit } from "../../platform/a2a-cockpit.js";
|
|
|
7
7
|
import { inspectA2AFleet } from "../../platform/a2a-fleet.js";
|
|
8
8
|
import { buildMaestroA2APeerProjection, defaultMaestroA2ACapabilities, } from "../../platform/a2a-maestro-peer.js";
|
|
9
9
|
import { createA2APeerPairingPayload, createA2APeerPairingPayloadFromAgentCard, decodeA2APeerPairingCode, encodeA2APeerPairingCode, resolveA2AAgentCardUrl, } from "../../platform/a2a-peer-pairing.js";
|
|
10
|
-
import { listA2APeers, loadA2APeerRegistry,
|
|
10
|
+
import { listA2APeers, loadA2APeerRegistry, resolveA2APeer, saveA2APeerRegistry, upsertA2APeerFromPairingPayload, } from "../../platform/a2a-peer-registry.js";
|
|
11
11
|
import { extractA2ATaskText, getA2ATaskLedgerPath, isActionRequiredA2AState, isFinalA2AState, isTerminalA2AState, listA2ATaskEntries, loadA2ATaskLedger, recordA2ATaskReply, recordA2ATaskStart, updateA2ATaskInLedger, } from "../../platform/a2a-task-ledger.js";
|
|
12
12
|
import { inspectA2ATelemetry, } from "../../platform/a2a-telemetry-inspect.js";
|
|
13
13
|
import { extractA2AWorkGraphMetadata, formatA2AWorkGraphCodexSubagents, formatA2AWorkGraphSummary, } from "../../platform/a2a-work-graph.js";
|
|
14
14
|
import { PlatformA2ADelegationTaskControlModeValue, PlatformAgentStatusValue, controlA2ADelegationTaskWithPlatform, delegateAgentWithPlatform, getA2ADelegationGraphWithPlatform, heartbeatAgentWithPlatform, isAgentAlreadyExistsError, listA2APeerCandidatesWithEvidenceWithPlatform, registerAgentWithPlatform, updateAgentWithPlatform, } from "../../platform/agent-registry-client.js";
|
|
15
15
|
import { getEnvValue } from "../../platform/client.js";
|
|
16
16
|
import { isAbortError } from "../../utils/abort-error.js";
|
|
17
|
+
import { booleanFlag, canonicalA2ASubcommand, minutesFlag, nonNegativeNumberFlag, numberFlag, parseA2AArgs, stringFlag, stringListFlag, } from "./a2a/args.js";
|
|
18
|
+
import { a2ADiscoveryEvidenceMetadata, a2ADiscoverySelectionPayload, a2APeerMetadataWithoutDiscoveryEvidence, compactA2APeerMetadata, discoveredPeerJson, discoveredPeerName, printA2ADiscoveryEvidence, uniqueDiscoveredPeerName, } from "./a2a/discovery.js";
|
|
19
|
+
export { parseA2AArgs } from "./a2a/args.js";
|
|
17
20
|
const DEFAULT_WAIT_MS = 300_000;
|
|
18
21
|
const DEFAULT_WAIT_INTERVAL_MS = 5_000;
|
|
19
|
-
const A2A_VALUE_FLAGS_BY_SUBCOMMAND = {
|
|
20
|
-
accept: [
|
|
21
|
-
"--name",
|
|
22
|
-
"--organization-id",
|
|
23
|
-
"--registry",
|
|
24
|
-
"--token-env",
|
|
25
|
-
"--token-file",
|
|
26
|
-
"--workspace-id",
|
|
27
|
-
],
|
|
28
|
-
card: ["--registry", "--timeout-ms"],
|
|
29
|
-
cockpit: ["--registry", "--tasks", "--timeout-ms", "--peer", "--limit"],
|
|
30
|
-
discover: [
|
|
31
|
-
"--capability",
|
|
32
|
-
"--limit",
|
|
33
|
-
"--offset",
|
|
34
|
-
"--registry",
|
|
35
|
-
"--skill",
|
|
36
|
-
"--status",
|
|
37
|
-
"--surface",
|
|
38
|
-
"--workspace-id",
|
|
39
|
-
],
|
|
40
|
-
delegate: [
|
|
41
|
-
"--capability",
|
|
42
|
-
"--cwd",
|
|
43
|
-
"--from-agent-id",
|
|
44
|
-
"--interval-ms",
|
|
45
|
-
"--limit",
|
|
46
|
-
"--max-wait-ms",
|
|
47
|
-
"--objective-id",
|
|
48
|
-
"--offset",
|
|
49
|
-
"--registry",
|
|
50
|
-
"--reason",
|
|
51
|
-
"--role",
|
|
52
|
-
"--skill",
|
|
53
|
-
"--status",
|
|
54
|
-
"--surface",
|
|
55
|
-
"--tasks",
|
|
56
|
-
"--timeout-ms",
|
|
57
|
-
"--to-agent-id",
|
|
58
|
-
"--workspace-id",
|
|
59
|
-
"--workflow-run-id",
|
|
60
|
-
"--workflow-step-id",
|
|
61
|
-
],
|
|
62
|
-
coordinate: [
|
|
63
|
-
"--interval-ms",
|
|
64
|
-
"--max-wait-ms",
|
|
65
|
-
"--registry",
|
|
66
|
-
"--reply",
|
|
67
|
-
"--tasks",
|
|
68
|
-
"--timeout-ms",
|
|
69
|
-
],
|
|
70
|
-
control: [
|
|
71
|
-
"--child-run-id",
|
|
72
|
-
"--delegation-id",
|
|
73
|
-
"--idempotency-key",
|
|
74
|
-
"--message",
|
|
75
|
-
"--mode",
|
|
76
|
-
"--subagent-lane-id",
|
|
77
|
-
"--target-run-id",
|
|
78
|
-
"--work-item-id",
|
|
79
|
-
"--workspace-id",
|
|
80
|
-
],
|
|
81
|
-
fleet: ["--registry", "--tasks", "--timeout-ms"],
|
|
82
|
-
graph: [
|
|
83
|
-
"--delegation-id",
|
|
84
|
-
"--limit",
|
|
85
|
-
"--max-depth",
|
|
86
|
-
"--root",
|
|
87
|
-
"--root-delegation-id",
|
|
88
|
-
"--workspace-id",
|
|
89
|
-
],
|
|
90
|
-
offer: [
|
|
91
|
-
"--agent-card-url",
|
|
92
|
-
"--base-url",
|
|
93
|
-
"--name",
|
|
94
|
-
"--peer-id",
|
|
95
|
-
"--ttl-minutes",
|
|
96
|
-
"--url",
|
|
97
|
-
],
|
|
98
|
-
peers: ["--registry"],
|
|
99
|
-
register: [
|
|
100
|
-
"--agent-card-etag",
|
|
101
|
-
"--agent-card-hash",
|
|
102
|
-
"--agent-card-url",
|
|
103
|
-
"--agent-id",
|
|
104
|
-
"--capabilities",
|
|
105
|
-
"--description",
|
|
106
|
-
"--internal-url",
|
|
107
|
-
"--name",
|
|
108
|
-
"--owner-id",
|
|
109
|
-
"--protocol-version",
|
|
110
|
-
"--public-url",
|
|
111
|
-
"--security-schemes",
|
|
112
|
-
"--status",
|
|
113
|
-
"--surface",
|
|
114
|
-
"--surface-types",
|
|
115
|
-
"--type",
|
|
116
|
-
"--url",
|
|
117
|
-
"--workspace-id",
|
|
118
|
-
],
|
|
119
|
-
reply: [
|
|
120
|
-
"--interval-ms",
|
|
121
|
-
"--max-wait-ms",
|
|
122
|
-
"--registry",
|
|
123
|
-
"--tasks",
|
|
124
|
-
"--timeout-ms",
|
|
125
|
-
],
|
|
126
|
-
send: [
|
|
127
|
-
"--interval-ms",
|
|
128
|
-
"--max-wait-ms",
|
|
129
|
-
"--registry",
|
|
130
|
-
"--tasks",
|
|
131
|
-
"--timeout-ms",
|
|
132
|
-
],
|
|
133
|
-
tasks: ["--registry", "--tasks", "--timeout-ms"],
|
|
134
|
-
telemetry: ["--events", "--swarm-id"],
|
|
135
|
-
wait: [
|
|
136
|
-
"--interval-ms",
|
|
137
|
-
"--max-wait-ms",
|
|
138
|
-
"--registry",
|
|
139
|
-
"--tasks",
|
|
140
|
-
"--timeout-ms",
|
|
141
|
-
],
|
|
142
|
-
};
|
|
143
|
-
const A2A_BOOLEAN_FLAGS_BY_SUBCOMMAND = {
|
|
144
|
-
accept: ["--default"],
|
|
145
|
-
cockpit: ["--json"],
|
|
146
|
-
coordinate: ["--json", "--refresh", "--wait", "--work-graph"],
|
|
147
|
-
delegate: [
|
|
148
|
-
"--discover",
|
|
149
|
-
"--platform",
|
|
150
|
-
"--prefer-internal",
|
|
151
|
-
"--wait",
|
|
152
|
-
"--work-graph",
|
|
153
|
-
],
|
|
154
|
-
discover: ["--default", "--import", "--json", "--prefer-internal"],
|
|
155
|
-
fleet: ["--json"],
|
|
156
|
-
graph: ["--json"],
|
|
157
|
-
register: ["--heartbeat-only", "--json", "--no-heartbeat", "--update-only"],
|
|
158
|
-
reply: ["--wait", "--work-graph"],
|
|
159
|
-
send: ["--wait", "--work-graph"],
|
|
160
|
-
tasks: ["--json", "--refresh", "--work-graph"],
|
|
161
|
-
telemetry: ["--json"],
|
|
162
|
-
wait: ["--work-graph"],
|
|
163
|
-
};
|
|
164
|
-
const A2A_COLLECT_VALUE_FLAGS_BY_SUBCOMMAND = {
|
|
165
|
-
coordinate: ["--reply"],
|
|
166
|
-
control: ["--message"],
|
|
167
|
-
};
|
|
168
|
-
const A2A_LEADING_VALUE_FLAGS = new Set(Object.values(A2A_VALUE_FLAGS_BY_SUBCOMMAND).flat());
|
|
169
|
-
const A2A_LEADING_BOOLEAN_FLAGS = new Set(Object.values(A2A_BOOLEAN_FLAGS_BY_SUBCOMMAND).flat());
|
|
170
22
|
export async function handleA2ACommand(args) {
|
|
171
23
|
const parsed = parseA2AArgs(args);
|
|
172
24
|
const subcommand = canonicalA2ASubcommand(parsed.positionals.shift());
|
|
@@ -232,137 +84,6 @@ export async function handleA2ACommand(args) {
|
|
|
232
84
|
printA2AHelp();
|
|
233
85
|
}
|
|
234
86
|
}
|
|
235
|
-
export function parseA2AArgs(args) {
|
|
236
|
-
const flags = new Map();
|
|
237
|
-
const positionals = [];
|
|
238
|
-
const subcommandIndex = findA2ASubcommandIndex(args);
|
|
239
|
-
const subcommand = subcommandIndex >= 0
|
|
240
|
-
? canonicalA2ASubcommand(args[subcommandIndex])
|
|
241
|
-
: "help";
|
|
242
|
-
const valueFlags = new Set(A2A_VALUE_FLAGS_BY_SUBCOMMAND[subcommand] ?? []);
|
|
243
|
-
const booleanFlags = new Set(A2A_BOOLEAN_FLAGS_BY_SUBCOMMAND[subcommand] ?? []);
|
|
244
|
-
if (subcommand === "delegate" && args.includes("--platform")) {
|
|
245
|
-
booleanFlags.add("--json");
|
|
246
|
-
}
|
|
247
|
-
const collectValueFlags = new Set(A2A_COLLECT_VALUE_FLAGS_BY_SUBCOMMAND[subcommand] ?? []);
|
|
248
|
-
for (let index = 0; index < args.length; index++) {
|
|
249
|
-
const arg = args[index];
|
|
250
|
-
if (!arg)
|
|
251
|
-
continue;
|
|
252
|
-
if (arg === "--") {
|
|
253
|
-
positionals.push(...args.slice(index + 1));
|
|
254
|
-
break;
|
|
255
|
-
}
|
|
256
|
-
if (arg.startsWith("--")) {
|
|
257
|
-
const [flag, inlineValue] = arg.split("=", 2);
|
|
258
|
-
if (!flag) {
|
|
259
|
-
continue;
|
|
260
|
-
}
|
|
261
|
-
if (index < subcommandIndex &&
|
|
262
|
-
!valueFlags.has(flag) &&
|
|
263
|
-
!booleanFlags.has(flag) &&
|
|
264
|
-
(A2A_LEADING_VALUE_FLAGS.has(flag) ||
|
|
265
|
-
A2A_LEADING_BOOLEAN_FLAGS.has(flag))) {
|
|
266
|
-
if (A2A_LEADING_VALUE_FLAGS.has(flag) && inlineValue === undefined) {
|
|
267
|
-
index++;
|
|
268
|
-
}
|
|
269
|
-
continue;
|
|
270
|
-
}
|
|
271
|
-
if (!valueFlags.has(flag) && !booleanFlags.has(flag)) {
|
|
272
|
-
positionals.push(arg);
|
|
273
|
-
continue;
|
|
274
|
-
}
|
|
275
|
-
if (inlineValue !== undefined) {
|
|
276
|
-
if (collectValueFlags.has(flag) && !inlineValue.trim()) {
|
|
277
|
-
throw new Error(collectValueFlagMissingTextMessage(flag, subcommand));
|
|
278
|
-
}
|
|
279
|
-
flags.set(flag, inlineValue);
|
|
280
|
-
continue;
|
|
281
|
-
}
|
|
282
|
-
if (booleanFlags.has(flag)) {
|
|
283
|
-
flags.set(flag, true);
|
|
284
|
-
continue;
|
|
285
|
-
}
|
|
286
|
-
if (collectValueFlags.has(flag)) {
|
|
287
|
-
const values = [];
|
|
288
|
-
while (args[index + 1] && args[index + 1] !== "--") {
|
|
289
|
-
const next = args[index + 1];
|
|
290
|
-
const [nextFlag] = next.split("=", 2);
|
|
291
|
-
if (next.startsWith("--") &&
|
|
292
|
-
nextFlag &&
|
|
293
|
-
(valueFlags.has(nextFlag) || booleanFlags.has(nextFlag))) {
|
|
294
|
-
break;
|
|
295
|
-
}
|
|
296
|
-
values.push(next);
|
|
297
|
-
index++;
|
|
298
|
-
}
|
|
299
|
-
const value = values.join(" ").trim();
|
|
300
|
-
if (!value) {
|
|
301
|
-
throw new Error(collectValueFlagMissingTextMessage(flag, subcommand));
|
|
302
|
-
}
|
|
303
|
-
flags.set(flag, value);
|
|
304
|
-
continue;
|
|
305
|
-
}
|
|
306
|
-
const next = args[index + 1];
|
|
307
|
-
if (next && next !== "--") {
|
|
308
|
-
flags.set(flag, next);
|
|
309
|
-
index++;
|
|
310
|
-
continue;
|
|
311
|
-
}
|
|
312
|
-
flags.set(flag, true);
|
|
313
|
-
continue;
|
|
314
|
-
}
|
|
315
|
-
positionals.push(arg);
|
|
316
|
-
}
|
|
317
|
-
return { flags, positionals };
|
|
318
|
-
}
|
|
319
|
-
function collectValueFlagMissingTextMessage(flag, subcommand) {
|
|
320
|
-
const usage = subcommand === "coordinate" && flag === "--reply"
|
|
321
|
-
? "\nUsage: maestro a2a coordinate [peer] --reply <text> [--wait]"
|
|
322
|
-
: "";
|
|
323
|
-
return `${flag} requires text${usage}`;
|
|
324
|
-
}
|
|
325
|
-
function findA2ASubcommandIndex(args) {
|
|
326
|
-
for (let index = 0; index < args.length; index++) {
|
|
327
|
-
const arg = args[index];
|
|
328
|
-
if (!arg || arg === "--") {
|
|
329
|
-
break;
|
|
330
|
-
}
|
|
331
|
-
if (!arg.startsWith("--")) {
|
|
332
|
-
return index;
|
|
333
|
-
}
|
|
334
|
-
const [flag = "", inlineValue] = arg.split("=", 2);
|
|
335
|
-
if (A2A_LEADING_VALUE_FLAGS.has(flag) && inlineValue === undefined) {
|
|
336
|
-
index++;
|
|
337
|
-
continue;
|
|
338
|
-
}
|
|
339
|
-
if (A2A_LEADING_VALUE_FLAGS.has(flag) ||
|
|
340
|
-
A2A_LEADING_BOOLEAN_FLAGS.has(flag)) {
|
|
341
|
-
continue;
|
|
342
|
-
}
|
|
343
|
-
break;
|
|
344
|
-
}
|
|
345
|
-
return -1;
|
|
346
|
-
}
|
|
347
|
-
function canonicalA2ASubcommand(input) {
|
|
348
|
-
switch (input?.toLowerCase()) {
|
|
349
|
-
case "pair":
|
|
350
|
-
case "create":
|
|
351
|
-
return "offer";
|
|
352
|
-
case "list":
|
|
353
|
-
return "peers";
|
|
354
|
-
case "dashboard":
|
|
355
|
-
return "cockpit";
|
|
356
|
-
case "delegation":
|
|
357
|
-
return "delegate";
|
|
358
|
-
case "continue":
|
|
359
|
-
return "reply";
|
|
360
|
-
case "publish":
|
|
361
|
-
return "register";
|
|
362
|
-
default:
|
|
363
|
-
return input?.toLowerCase() ?? "help";
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
87
|
async function handleA2AOffer(parsed) {
|
|
367
88
|
const baseUrl = stringFlag(parsed, "--url") ?? stringFlag(parsed, "--base-url");
|
|
368
89
|
const agentCardUrl = resolveA2AAgentCardUrl(stringFlag(parsed, "--agent-card-url") ??
|
|
@@ -1768,154 +1489,7 @@ function printWorkGraphLines(workGraph, includeDetails) {
|
|
|
1768
1489
|
console.log(chalk.dim(` Correlation: ${workGraph.correlationPath}`));
|
|
1769
1490
|
}
|
|
1770
1491
|
}
|
|
1771
|
-
function printA2ADiscoveryEvidence(evidence) {
|
|
1772
|
-
if (!evidence) {
|
|
1773
|
-
return;
|
|
1774
|
-
}
|
|
1775
|
-
const summary = [
|
|
1776
|
-
evidence.decision ? `decision=${evidence.decision}` : undefined,
|
|
1777
|
-
evidence.reason ? `reason=${evidence.reason}` : undefined,
|
|
1778
|
-
evidence.matchedCount !== undefined
|
|
1779
|
-
? `matched=${evidence.matchedCount}`
|
|
1780
|
-
: undefined,
|
|
1781
|
-
evidence.candidateCount !== undefined
|
|
1782
|
-
? `candidates=${evidence.candidateCount}`
|
|
1783
|
-
: undefined,
|
|
1784
|
-
evidence.a2aSkillId ? `skill=${evidence.a2aSkillId}` : undefined,
|
|
1785
|
-
evidence.capability ? `capability=${evidence.capability}` : undefined,
|
|
1786
|
-
]
|
|
1787
|
-
.filter(Boolean)
|
|
1788
|
-
.join(" ");
|
|
1789
|
-
if (summary) {
|
|
1790
|
-
console.log(chalk.dim(` discovery ${summary}`));
|
|
1791
|
-
}
|
|
1792
|
-
if (evidence.exclusions?.length) {
|
|
1793
|
-
const exclusions = evidence.exclusions
|
|
1794
|
-
.map((exclusion) => [
|
|
1795
|
-
exclusion.reason,
|
|
1796
|
-
exclusion.count !== undefined ? `count=${exclusion.count}` : "",
|
|
1797
|
-
]
|
|
1798
|
-
.filter(Boolean)
|
|
1799
|
-
.join(":"))
|
|
1800
|
-
.filter(Boolean)
|
|
1801
|
-
.join(", ");
|
|
1802
|
-
if (exclusions) {
|
|
1803
|
-
console.log(chalk.dim(` exclusions ${exclusions}`));
|
|
1804
|
-
}
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
1492
|
export const isA2AWaitCompletionState = isTerminalA2AState;
|
|
1808
|
-
function discoveredPeerJson(candidate) {
|
|
1809
|
-
return {
|
|
1810
|
-
...(candidate.agent.id ? { agentId: candidate.agent.id } : {}),
|
|
1811
|
-
...(candidate.agent.name ? { name: candidate.agent.name } : {}),
|
|
1812
|
-
...(candidate.agent.status ? { status: candidate.agent.status } : {}),
|
|
1813
|
-
endpointUrl: candidate.endpointUrl,
|
|
1814
|
-
...(candidate.endpointKind ? { endpointKind: candidate.endpointKind } : {}),
|
|
1815
|
-
...(candidate.agentCardUrl ? { agentCardUrl: candidate.agentCardUrl } : {}),
|
|
1816
|
-
...(candidate.protocolBinding
|
|
1817
|
-
? { protocolBinding: candidate.protocolBinding }
|
|
1818
|
-
: {}),
|
|
1819
|
-
...(candidate.protocolVersion
|
|
1820
|
-
? { protocolVersion: candidate.protocolVersion }
|
|
1821
|
-
: {}),
|
|
1822
|
-
skills: candidate.skills,
|
|
1823
|
-
...(candidate.supportedExtensions
|
|
1824
|
-
? { supportedExtensions: candidate.supportedExtensions }
|
|
1825
|
-
: {}),
|
|
1826
|
-
...(candidate.pushNotifications === undefined
|
|
1827
|
-
? {}
|
|
1828
|
-
: { pushNotifications: candidate.pushNotifications }),
|
|
1829
|
-
};
|
|
1830
|
-
}
|
|
1831
|
-
function discoveredPeerName(candidate, index) {
|
|
1832
|
-
const raw = candidate.agent.id ??
|
|
1833
|
-
candidate.agent.name ??
|
|
1834
|
-
`platform-a2a-peer-${index + 1}`;
|
|
1835
|
-
const sanitized = raw
|
|
1836
|
-
.trim()
|
|
1837
|
-
.replace(/[^A-Za-z0-9_.-]+/gu, "-")
|
|
1838
|
-
.replace(/^-+|-+$/gu, "")
|
|
1839
|
-
.slice(0, 80) || `platform-a2a-peer-${index + 1}`;
|
|
1840
|
-
return normalizePeerName(sanitized);
|
|
1841
|
-
}
|
|
1842
|
-
function uniqueDiscoveredPeerName(input) {
|
|
1843
|
-
for (let suffix = 1; suffix <= 100; suffix++) {
|
|
1844
|
-
const name = suffix === 1 ? input.baseName : suffixedPeerName(input.baseName, suffix);
|
|
1845
|
-
const existing = input.peers[name];
|
|
1846
|
-
const hasSameAgentId = Boolean(existing?.agentId &&
|
|
1847
|
-
input.candidate.agent.id &&
|
|
1848
|
-
existing.agentId === input.candidate.agent.id);
|
|
1849
|
-
const hasSameEndpoint = existing?.url === input.candidate.endpointUrl;
|
|
1850
|
-
if (!input.importedNames.has(name) &&
|
|
1851
|
-
(!existing || hasSameAgentId || hasSameEndpoint)) {
|
|
1852
|
-
input.importedNames.add(name);
|
|
1853
|
-
return name;
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
|
-
throw new Error(`Could not derive a unique A2A peer name for ${input.baseName}`);
|
|
1857
|
-
}
|
|
1858
|
-
function suffixedPeerName(baseName, suffix) {
|
|
1859
|
-
const suffixText = `-${suffix}`;
|
|
1860
|
-
return normalizePeerName(`${baseName.slice(0, 80 - suffixText.length)}${suffixText}`);
|
|
1861
|
-
}
|
|
1862
|
-
function a2ADiscoveryEvidenceMetadata(evidence) {
|
|
1863
|
-
if (!evidence) {
|
|
1864
|
-
return {};
|
|
1865
|
-
}
|
|
1866
|
-
return (compactA2APeerMetadata({
|
|
1867
|
-
platformDiscoverySchema: evidence.schema,
|
|
1868
|
-
platformDiscoveryDecision: evidence.decision,
|
|
1869
|
-
platformDiscoveryReason: evidence.reason,
|
|
1870
|
-
platformDiscoveryWorkspaceId: evidence.workspaceId,
|
|
1871
|
-
platformDiscoveryCapability: evidence.capability,
|
|
1872
|
-
platformDiscoveryAgentType: evidence.agentType,
|
|
1873
|
-
platformDiscoveryA2ASkillId: evidence.a2aSkillId,
|
|
1874
|
-
platformDiscoveryTaskClass: evidence.taskClass,
|
|
1875
|
-
platformDiscoveryRequireA2ADispatch: evidence.requireA2ADispatch,
|
|
1876
|
-
platformDiscoverySurface: evidence.surface,
|
|
1877
|
-
platformDiscoveryStatus: evidence.status,
|
|
1878
|
-
platformDiscoveryCandidateCount: evidence.candidateCount,
|
|
1879
|
-
platformDiscoveryMatchedCount: evidence.matchedCount,
|
|
1880
|
-
}) ?? {});
|
|
1881
|
-
}
|
|
1882
|
-
function a2APeerMetadataWithoutDiscoveryEvidence(metadata) {
|
|
1883
|
-
if (!metadata) {
|
|
1884
|
-
return undefined;
|
|
1885
|
-
}
|
|
1886
|
-
const entries = Object.entries(metadata).filter(([key]) => !key.startsWith("platformDiscovery"));
|
|
1887
|
-
return entries.length > 0 ? Object.fromEntries(entries) : undefined;
|
|
1888
|
-
}
|
|
1889
|
-
function a2ADiscoverySelectionPayload(selection) {
|
|
1890
|
-
if (!selection) {
|
|
1891
|
-
return undefined;
|
|
1892
|
-
}
|
|
1893
|
-
return compactA2AUnknownRecord({
|
|
1894
|
-
source: selection.source,
|
|
1895
|
-
...a2ADiscoveryEvidenceMetadata(selection.evidence),
|
|
1896
|
-
selectedAgentId: selection.selectedAgentId,
|
|
1897
|
-
selectedAgentName: selection.selectedAgentName,
|
|
1898
|
-
selectedEndpointUrl: selection.selectedEndpointUrl,
|
|
1899
|
-
selectedEndpointKind: selection.selectedEndpointKind,
|
|
1900
|
-
score: selection.score,
|
|
1901
|
-
reasons: selection.reasons,
|
|
1902
|
-
candidateCount: selection.candidateCount,
|
|
1903
|
-
matchedCount: selection.matchedCount,
|
|
1904
|
-
});
|
|
1905
|
-
}
|
|
1906
|
-
function compactA2AUnknownRecord(record) {
|
|
1907
|
-
const entries = Object.entries(record).filter(([, value]) => {
|
|
1908
|
-
if (value === undefined) {
|
|
1909
|
-
return false;
|
|
1910
|
-
}
|
|
1911
|
-
return !Array.isArray(value) || value.length > 0;
|
|
1912
|
-
});
|
|
1913
|
-
return entries.length > 0 ? Object.fromEntries(entries) : undefined;
|
|
1914
|
-
}
|
|
1915
|
-
function compactA2APeerMetadata(record) {
|
|
1916
|
-
const entries = Object.entries(record).filter((entry) => entry[1] !== undefined);
|
|
1917
|
-
return entries.length > 0 ? Object.fromEntries(entries) : undefined;
|
|
1918
|
-
}
|
|
1919
1493
|
function baseUrlFromAgentCardUrl(agentCardUrl) {
|
|
1920
1494
|
const parsed = new URL(agentCardUrl);
|
|
1921
1495
|
parsed.pathname = parsed.pathname.replace(/\/\.well-known\/agent-card\.json$/u, "");
|
|
@@ -1923,50 +1497,6 @@ function baseUrlFromAgentCardUrl(agentCardUrl) {
|
|
|
1923
1497
|
parsed.hash = "";
|
|
1924
1498
|
return parsed.toString().replace(/\/+$/u, "");
|
|
1925
1499
|
}
|
|
1926
|
-
function stringFlag(parsed, name) {
|
|
1927
|
-
const value = parsed.flags.get(name);
|
|
1928
|
-
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
1929
|
-
}
|
|
1930
|
-
function stringListFlag(parsed, name, fallback) {
|
|
1931
|
-
const value = stringFlag(parsed, name);
|
|
1932
|
-
if (!value) {
|
|
1933
|
-
return fallback;
|
|
1934
|
-
}
|
|
1935
|
-
const parsedValues = value
|
|
1936
|
-
.split(",")
|
|
1937
|
-
.map((item) => item.trim())
|
|
1938
|
-
.filter(Boolean);
|
|
1939
|
-
return parsedValues.length > 0 ? parsedValues : fallback;
|
|
1940
|
-
}
|
|
1941
|
-
function numberFlag(parsed, name) {
|
|
1942
|
-
const value = stringFlag(parsed, name);
|
|
1943
|
-
if (!value) {
|
|
1944
|
-
return undefined;
|
|
1945
|
-
}
|
|
1946
|
-
const parsedValue = Number(value);
|
|
1947
|
-
if (!Number.isFinite(parsedValue) || parsedValue <= 0) {
|
|
1948
|
-
throw new Error(`${name} must be a positive number`);
|
|
1949
|
-
}
|
|
1950
|
-
return parsedValue;
|
|
1951
|
-
}
|
|
1952
|
-
function nonNegativeNumberFlag(parsed, name) {
|
|
1953
|
-
const value = stringFlag(parsed, name);
|
|
1954
|
-
if (!value) {
|
|
1955
|
-
return undefined;
|
|
1956
|
-
}
|
|
1957
|
-
const parsedValue = Number(value);
|
|
1958
|
-
if (!Number.isFinite(parsedValue) || parsedValue < 0) {
|
|
1959
|
-
throw new Error(`${name} must be a non-negative number`);
|
|
1960
|
-
}
|
|
1961
|
-
return parsedValue;
|
|
1962
|
-
}
|
|
1963
|
-
function minutesFlag(parsed, name) {
|
|
1964
|
-
const value = numberFlag(parsed, name);
|
|
1965
|
-
return value === undefined ? undefined : value * 60 * 1000;
|
|
1966
|
-
}
|
|
1967
|
-
function booleanFlag(parsed, name) {
|
|
1968
|
-
return parsed.flags.get(name) === true;
|
|
1969
|
-
}
|
|
1970
1500
|
function formatCockpitTaskStatus(status) {
|
|
1971
1501
|
switch (status) {
|
|
1972
1502
|
case "waiting":
|