metheus-governance-mcp-cli 0.2.218 → 0.2.219
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/cli.mjs +17 -2
- package/lib/runner-orchestration.mjs +112 -67
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -184,6 +184,7 @@ import {
|
|
|
184
184
|
runRunnerAIExecution,
|
|
185
185
|
} from "./lib/runner-execution.mjs";
|
|
186
186
|
import {
|
|
187
|
+
buildRunnerResponderAdjudicationFromHumanIntent,
|
|
187
188
|
processRunnerSelectedRecord,
|
|
188
189
|
resolveHumanIntentContext,
|
|
189
190
|
resolveRunnerResponderAdjudication,
|
|
@@ -8287,7 +8288,14 @@ async function processRunnerRouteOnce(route, runtime, mode, options = {}) {
|
|
|
8287
8288
|
executionPlan,
|
|
8288
8289
|
deps: routingExecutionDeps,
|
|
8289
8290
|
});
|
|
8290
|
-
const
|
|
8291
|
+
const precomputedAdjudication = buildRunnerResponderAdjudicationFromHumanIntent({
|
|
8292
|
+
selectedRecord,
|
|
8293
|
+
normalizedRoute,
|
|
8294
|
+
bot,
|
|
8295
|
+
deps: routingExecutionDeps,
|
|
8296
|
+
precomputedHumanIntent: safeObject(sharedHumanIntentContext).humanIntent || null,
|
|
8297
|
+
});
|
|
8298
|
+
const adjudication = precomputedAdjudication || await resolveRunnerResponderAdjudication({
|
|
8291
8299
|
selectedRecord,
|
|
8292
8300
|
pendingOrdered: pending.ordered,
|
|
8293
8301
|
normalizedRoute,
|
|
@@ -8540,7 +8548,14 @@ async function processRunnerRouteOnce(route, runtime, mode, options = {}) {
|
|
|
8540
8548
|
executionPlan,
|
|
8541
8549
|
deps: routingExecutionDeps,
|
|
8542
8550
|
});
|
|
8543
|
-
const
|
|
8551
|
+
const precomputedInlineAdjudication = buildRunnerResponderAdjudicationFromHumanIntent({
|
|
8552
|
+
selectedRecord,
|
|
8553
|
+
normalizedRoute,
|
|
8554
|
+
bot,
|
|
8555
|
+
deps: routingExecutionDeps,
|
|
8556
|
+
precomputedHumanIntent: safeObject(sharedHumanIntentContext).humanIntent || null,
|
|
8557
|
+
});
|
|
8558
|
+
const inlineAdjudication = precomputedInlineAdjudication || await resolveRunnerResponderAdjudication({
|
|
8544
8559
|
selectedRecord,
|
|
8545
8560
|
pendingOrdered: pending.ordered,
|
|
8546
8561
|
normalizedRoute,
|
|
@@ -4285,17 +4285,20 @@ export async function resolveRunnerResponderAdjudication({
|
|
|
4285
4285
|
? deps.adjudicateRunnerRespondersWithAI
|
|
4286
4286
|
: null;
|
|
4287
4287
|
const promise = (async () => {
|
|
4288
|
-
|
|
4288
|
+
const managedBots = buildResponderAdjudicationManagedBots({
|
|
4289
4289
|
selectedRecord,
|
|
4290
4290
|
normalizedRoute,
|
|
4291
4291
|
bot,
|
|
4292
4292
|
deps,
|
|
4293
4293
|
});
|
|
4294
|
-
const
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
);
|
|
4294
|
+
const contractAdjudication = buildRunnerResponderAdjudicationFromHumanIntent({
|
|
4295
|
+
selectedRecord,
|
|
4296
|
+
managedBots,
|
|
4297
|
+
precomputedHumanIntent,
|
|
4298
|
+
});
|
|
4299
|
+
if (contractAdjudication) {
|
|
4300
|
+
return contractAdjudication;
|
|
4301
|
+
}
|
|
4299
4302
|
const triggerFacts = {
|
|
4300
4303
|
message_kind: String(safeObject(selectedRecord?.parsedArchive).kind || "").trim(),
|
|
4301
4304
|
chat_type: String(safeObject(selectedRecord?.parsedArchive).chatType || "").trim(),
|
|
@@ -4311,60 +4314,6 @@ export async function resolveRunnerResponderAdjudication({
|
|
|
4311
4314
|
trigger_reason: String(entry.trigger_reason || "").trim(),
|
|
4312
4315
|
})),
|
|
4313
4316
|
};
|
|
4314
|
-
const humanIntent = safeObject(precomputedHumanIntent);
|
|
4315
|
-
const contractInitialResponders = uniqueOrdered(
|
|
4316
|
-
ensureArray(humanIntent.initialResponderSelectors)
|
|
4317
|
-
.map((value) => normalizeMentionSelector(value))
|
|
4318
|
-
.filter((value) => value && managedBotSelectors.has(value)),
|
|
4319
|
-
);
|
|
4320
|
-
const contractAllowedResponders = uniqueOrdered(
|
|
4321
|
-
ensureArray(humanIntent.allowedResponderSelectors)
|
|
4322
|
-
.map((value) => normalizeMentionSelector(value))
|
|
4323
|
-
.filter((value) => value && managedBotSelectors.has(value)),
|
|
4324
|
-
);
|
|
4325
|
-
const contractParticipants = uniqueOrdered(
|
|
4326
|
-
ensureArray(humanIntent.participantSelectors)
|
|
4327
|
-
.map((value) => normalizeMentionSelector(value))
|
|
4328
|
-
.filter((value) => value && managedBotSelectors.has(value)),
|
|
4329
|
-
);
|
|
4330
|
-
const contractLeadBot = normalizeMentionSelector(humanIntent.leadBotSelector);
|
|
4331
|
-
const selectedFromContract = uniqueOrdered(
|
|
4332
|
-
(
|
|
4333
|
-
contractInitialResponders.length
|
|
4334
|
-
? contractInitialResponders
|
|
4335
|
-
: contractAllowedResponders.length
|
|
4336
|
-
? contractAllowedResponders
|
|
4337
|
-
: contractParticipants.length
|
|
4338
|
-
? contractParticipants
|
|
4339
|
-
: contractLeadBot && managedBotSelectors.has(contractLeadBot)
|
|
4340
|
-
? [contractLeadBot]
|
|
4341
|
-
: []
|
|
4342
|
-
).filter(Boolean),
|
|
4343
|
-
);
|
|
4344
|
-
if (selectedFromContract.length > 0) {
|
|
4345
|
-
return {
|
|
4346
|
-
decision: selectedFromContract.length > 1 ? "multiple_responders" : "single_responder",
|
|
4347
|
-
selected_bot_usernames: selectedFromContract,
|
|
4348
|
-
referenced_bot_usernames: triggerFacts.mentioned_bot_usernames,
|
|
4349
|
-
confidence: "high",
|
|
4350
|
-
reason_code: "precomputed_human_intent_contract",
|
|
4351
|
-
clarification: "",
|
|
4352
|
-
managed_bots: managedBots,
|
|
4353
|
-
};
|
|
4354
|
-
}
|
|
4355
|
-
if (hasHumanIntentContractSignals(humanIntent)) {
|
|
4356
|
-
return {
|
|
4357
|
-
decision: "no_responder",
|
|
4358
|
-
selected_bot_usernames: [],
|
|
4359
|
-
referenced_bot_usernames: triggerFacts.mentioned_bot_usernames,
|
|
4360
|
-
confidence: "high",
|
|
4361
|
-
reason_code: isCompleteHumanIntentContract(humanIntent)
|
|
4362
|
-
? "precomputed_human_intent_contract_no_responder"
|
|
4363
|
-
: "incomplete_human_intent_contract",
|
|
4364
|
-
clarification: "",
|
|
4365
|
-
managed_bots: managedBots,
|
|
4366
|
-
};
|
|
4367
|
-
}
|
|
4368
4317
|
if (!adjudicator) {
|
|
4369
4318
|
const fallbackSelected = managedBots
|
|
4370
4319
|
.filter((entry) => entry.trigger_eligible === true)
|
|
@@ -4422,6 +4371,90 @@ export async function resolveRunnerResponderAdjudication({
|
|
|
4422
4371
|
runnerResponderAdjudicationPromises.set(cacheKey, promise);
|
|
4423
4372
|
return promise;
|
|
4424
4373
|
}
|
|
4374
|
+
|
|
4375
|
+
export function buildRunnerResponderAdjudicationFromHumanIntent({
|
|
4376
|
+
selectedRecord,
|
|
4377
|
+
managedBots = [],
|
|
4378
|
+
normalizedRoute = null,
|
|
4379
|
+
bot = null,
|
|
4380
|
+
deps = null,
|
|
4381
|
+
precomputedHumanIntent = null,
|
|
4382
|
+
}) {
|
|
4383
|
+
const humanIntent = safeObject(precomputedHumanIntent);
|
|
4384
|
+
if (!hasHumanIntentContractSignals(humanIntent)) {
|
|
4385
|
+
return null;
|
|
4386
|
+
}
|
|
4387
|
+
const fallbackManagedBots = ensureArray(managedBots).length
|
|
4388
|
+
? managedBots
|
|
4389
|
+
: buildResponderAdjudicationManagedBots({
|
|
4390
|
+
selectedRecord,
|
|
4391
|
+
normalizedRoute,
|
|
4392
|
+
bot,
|
|
4393
|
+
deps,
|
|
4394
|
+
});
|
|
4395
|
+
const normalizedManagedBots = ensureArray(fallbackManagedBots)
|
|
4396
|
+
.map((entry) => safeObject(entry))
|
|
4397
|
+
.filter((entry) => normalizeMentionSelector(entry.username));
|
|
4398
|
+
const managedBotSelectors = new Set(
|
|
4399
|
+
normalizedManagedBots
|
|
4400
|
+
.map((entry) => normalizeMentionSelector(entry.username))
|
|
4401
|
+
.filter(Boolean),
|
|
4402
|
+
);
|
|
4403
|
+
const referencedBotUsernames = ensureArray(safeObject(selectedRecord?.parsedArchive).mentionUsernames)
|
|
4404
|
+
.map((value) => normalizeMentionSelector(value))
|
|
4405
|
+
.filter(Boolean);
|
|
4406
|
+
const contractInitialResponders = uniqueOrdered(
|
|
4407
|
+
ensureArray(humanIntent.initialResponderSelectors)
|
|
4408
|
+
.map((value) => normalizeMentionSelector(value))
|
|
4409
|
+
.filter((value) => value && managedBotSelectors.has(value)),
|
|
4410
|
+
);
|
|
4411
|
+
const contractAllowedResponders = uniqueOrdered(
|
|
4412
|
+
ensureArray(humanIntent.allowedResponderSelectors)
|
|
4413
|
+
.map((value) => normalizeMentionSelector(value))
|
|
4414
|
+
.filter((value) => value && managedBotSelectors.has(value)),
|
|
4415
|
+
);
|
|
4416
|
+
const contractParticipants = uniqueOrdered(
|
|
4417
|
+
ensureArray(humanIntent.participantSelectors)
|
|
4418
|
+
.map((value) => normalizeMentionSelector(value))
|
|
4419
|
+
.filter((value) => value && managedBotSelectors.has(value)),
|
|
4420
|
+
);
|
|
4421
|
+
const contractLeadBot = normalizeMentionSelector(humanIntent.leadBotSelector);
|
|
4422
|
+
const selectedFromContract = uniqueOrdered(
|
|
4423
|
+
(
|
|
4424
|
+
contractInitialResponders.length
|
|
4425
|
+
? contractInitialResponders
|
|
4426
|
+
: contractAllowedResponders.length
|
|
4427
|
+
? contractAllowedResponders
|
|
4428
|
+
: contractParticipants.length
|
|
4429
|
+
? contractParticipants
|
|
4430
|
+
: contractLeadBot && managedBotSelectors.has(contractLeadBot)
|
|
4431
|
+
? [contractLeadBot]
|
|
4432
|
+
: []
|
|
4433
|
+
).filter(Boolean),
|
|
4434
|
+
);
|
|
4435
|
+
if (selectedFromContract.length > 0) {
|
|
4436
|
+
return {
|
|
4437
|
+
decision: selectedFromContract.length > 1 ? "multiple_responders" : "single_responder",
|
|
4438
|
+
selected_bot_usernames: selectedFromContract,
|
|
4439
|
+
referenced_bot_usernames: referencedBotUsernames,
|
|
4440
|
+
confidence: "high",
|
|
4441
|
+
reason_code: "precomputed_human_intent_contract",
|
|
4442
|
+
clarification: "",
|
|
4443
|
+
managed_bots: normalizedManagedBots,
|
|
4444
|
+
};
|
|
4445
|
+
}
|
|
4446
|
+
return {
|
|
4447
|
+
decision: "no_responder",
|
|
4448
|
+
selected_bot_usernames: [],
|
|
4449
|
+
referenced_bot_usernames: referencedBotUsernames,
|
|
4450
|
+
confidence: "high",
|
|
4451
|
+
reason_code: isCompleteHumanIntentContract(humanIntent)
|
|
4452
|
+
? "precomputed_human_intent_contract_no_responder"
|
|
4453
|
+
: "incomplete_human_intent_contract",
|
|
4454
|
+
clarification: "",
|
|
4455
|
+
managed_bots: normalizedManagedBots,
|
|
4456
|
+
};
|
|
4457
|
+
}
|
|
4425
4458
|
|
|
4426
4459
|
export function selectRunnerPendingWork({
|
|
4427
4460
|
comments,
|
|
@@ -4582,17 +4615,29 @@ export async function processRunnerSelectedRecord({
|
|
|
4582
4615
|
const normalizedPrecomputedHumanIntent = safeObject(
|
|
4583
4616
|
resolvedPreAdjudicationHumanIntentContext?.humanIntent || normalizedPrecomputedHumanIntentContext.humanIntent,
|
|
4584
4617
|
);
|
|
4585
|
-
const
|
|
4586
|
-
|
|
4587
|
-
:
|
|
4618
|
+
const precomputedResponderSelection = buildRunnerResponderAdjudicationFromHumanIntent({
|
|
4619
|
+
selectedRecord,
|
|
4620
|
+
managedBots: buildResponderAdjudicationManagedBots({
|
|
4588
4621
|
selectedRecord,
|
|
4589
|
-
pendingOrdered,
|
|
4590
4622
|
normalizedRoute,
|
|
4591
4623
|
bot,
|
|
4592
|
-
executionPlan,
|
|
4593
4624
|
deps: executionDeps,
|
|
4594
|
-
|
|
4595
|
-
|
|
4625
|
+
}),
|
|
4626
|
+
precomputedHumanIntent: normalizedPrecomputedHumanIntent,
|
|
4627
|
+
});
|
|
4628
|
+
const responderAdjudication = Object.keys(safeObject(precomputedResponderAdjudication)).length > 0
|
|
4629
|
+
? safeObject(precomputedResponderAdjudication)
|
|
4630
|
+
: precomputedResponderSelection
|
|
4631
|
+
? precomputedResponderSelection
|
|
4632
|
+
: await resolveRunnerResponderAdjudication({
|
|
4633
|
+
selectedRecord,
|
|
4634
|
+
pendingOrdered,
|
|
4635
|
+
normalizedRoute,
|
|
4636
|
+
bot,
|
|
4637
|
+
executionPlan,
|
|
4638
|
+
deps: executionDeps,
|
|
4639
|
+
precomputedHumanIntent: normalizedPrecomputedHumanIntent,
|
|
4640
|
+
});
|
|
4596
4641
|
const selectedResponderSelectors = ensureArray(responderAdjudication.selected_bot_usernames)
|
|
4597
4642
|
.map((value) => normalizeMentionSelector(value))
|
|
4598
4643
|
.filter(Boolean);
|