@agentbridge1/cli 0.0.7 → 0.0.8
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/build-info.json +4 -4
- package/dist/commands/connect.js +58 -122
- package/dist/commands/doctor.js +46 -8
- package/dist/commands/setup-mcp.js +54 -44
- package/dist/commands/start.js +85 -22
- package/dist/commands/watch.js +661 -92
- package/dist/contract-verdict.js +186 -0
- package/dist/error-catalog.js +29 -0
- package/dist/git-status.js +6 -2
- package/dist/index.js +11 -5
- package/dist/intent-validation.js +37 -0
- package/dist/local-proof.js +12 -4
- package/dist/mcp/agentbridge-mcp.js +602 -23
- package/dist/mcp/agentbridge-mcp.js.map +4 -4
- package/dist/mcp-config.js +64 -0
- package/dist/supervision.js +191 -48
- package/dist/test-runner.js +201 -15
- package/package.json +1 -1
package/dist/commands/start.js
CHANGED
|
@@ -33,12 +33,14 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.runLocalStart = runLocalStart;
|
|
36
37
|
exports.runStart = runStart;
|
|
37
38
|
const config_1 = require("../config");
|
|
38
39
|
const domain_resolution_1 = require("../domain-resolution");
|
|
39
40
|
const errors_1 = require("../errors");
|
|
40
41
|
const error_catalog_1 = require("../error-catalog");
|
|
41
42
|
const http_1 = require("../http");
|
|
43
|
+
const intent_validation_1 = require("../intent-validation");
|
|
42
44
|
const session_1 = require("../session");
|
|
43
45
|
const session_state_1 = require("../session-state");
|
|
44
46
|
const server_sync_1 = require("../server-sync");
|
|
@@ -300,10 +302,19 @@ async function resolveStartOwnership(input) {
|
|
|
300
302
|
projectId: ctx.projectId,
|
|
301
303
|
identities,
|
|
302
304
|
});
|
|
303
|
-
|
|
304
|
-
|
|
305
|
+
const explicitDomain = input.explicitDomain?.trim();
|
|
306
|
+
const inferredScopeDomain = (0, domain_resolution_1.inferLaneFromFiles)([input.scope], input.configuredDomains).laneDomain;
|
|
307
|
+
let resolvedDomain = explicitDomain ||
|
|
308
|
+
inferredScopeDomain ||
|
|
305
309
|
callerIdentity.domainName ||
|
|
306
310
|
undefined;
|
|
311
|
+
let laneClaimSource = explicitDomain
|
|
312
|
+
? "explicit_domain"
|
|
313
|
+
: inferredScopeDomain
|
|
314
|
+
? "scope_pattern"
|
|
315
|
+
: callerIdentity.domainName
|
|
316
|
+
? "caller_identity_domain"
|
|
317
|
+
: "unresolved";
|
|
307
318
|
let packetDomainOwner = null;
|
|
308
319
|
let packetDomainName = null;
|
|
309
320
|
try {
|
|
@@ -315,6 +326,7 @@ async function resolveStartOwnership(input) {
|
|
|
315
326
|
const first = domainPacket.domains[0];
|
|
316
327
|
if (!resolvedDomain && first?.domain_name) {
|
|
317
328
|
resolvedDomain = first.domain_name;
|
|
329
|
+
laneClaimSource = "domain_packet";
|
|
318
330
|
}
|
|
319
331
|
packetDomainOwner = first?.owner_work_identity_id ?? null;
|
|
320
332
|
packetDomainName = first?.domain_name ?? null;
|
|
@@ -325,6 +337,11 @@ async function resolveStartOwnership(input) {
|
|
|
325
337
|
if (!resolvedDomain) {
|
|
326
338
|
throw (0, errors_1.catalogCliError)("START_DOMAIN_UNRESOLVED");
|
|
327
339
|
}
|
|
340
|
+
const laneClaimConfidence = laneClaimSource === "explicit_domain" || laneClaimSource === "scope_pattern"
|
|
341
|
+
? "high"
|
|
342
|
+
: laneClaimSource === "domain_packet" || laneClaimSource === "caller_identity_domain"
|
|
343
|
+
? "medium"
|
|
344
|
+
: "low";
|
|
328
345
|
const projectDomain = projectPacket.domains_summary.find((domain) => equalsIgnoreCase(domain.domain_name, resolvedDomain));
|
|
329
346
|
const ownerFromProjectPacket = projectDomain?.owner_work_identity_id ?? null;
|
|
330
347
|
const ownerFromPacket = packetDomainOwner;
|
|
@@ -343,6 +360,8 @@ async function resolveStartOwnership(input) {
|
|
|
343
360
|
identitySource: resolvedIdentity.source,
|
|
344
361
|
identityWarning: resolvedIdentity.warning,
|
|
345
362
|
suggestedActiveAgentId: resolvedIdentity.suggestedActiveAgentId,
|
|
363
|
+
laneClaimConfidence,
|
|
364
|
+
laneClaimSource,
|
|
346
365
|
};
|
|
347
366
|
}
|
|
348
367
|
async function ensureChangeRequestReady(changeRequestId, ownerWorkIdentityId, resolvedDomain, scope) {
|
|
@@ -441,6 +460,14 @@ async function executeStartWorkSession(opts) {
|
|
|
441
460
|
});
|
|
442
461
|
const resolvedDomain = ownership.resolvedDomain;
|
|
443
462
|
const activeAgentId = ownership.resolvedAgentId;
|
|
463
|
+
if (ownership.laneClaimConfidence === "low") {
|
|
464
|
+
throw (0, errors_1.catalogCliError)("START_LANE_CLAIM_LOW_CONFIDENCE");
|
|
465
|
+
}
|
|
466
|
+
if (ownership.laneClaimConfidence === "medium" && opts.confirmDomain !== true) {
|
|
467
|
+
throw (0, errors_1.catalogCliError)("START_LANE_CLAIM_CONFIRM_REQUIRED", {
|
|
468
|
+
what: `Lane claim is medium confidence (${ownership.laneClaimSource}) for domain "${resolvedDomain}".`,
|
|
469
|
+
});
|
|
470
|
+
}
|
|
444
471
|
const explicitResume = opts.resume === true;
|
|
445
472
|
const explicitCrId = opts.changeRequestId?.trim() || undefined;
|
|
446
473
|
const existingCrId = explicitCrId ?? (explicitResume ? cfg.activeChangeRequestId?.trim() || undefined : undefined);
|
|
@@ -545,18 +572,31 @@ async function executeStartWorkSession(opts) {
|
|
|
545
572
|
}
|
|
546
573
|
(0, config_1.updateConfig)({ activeChangeRequestId: changeRequest.id });
|
|
547
574
|
const output = [
|
|
548
|
-
"AgentBridge
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
`- ${
|
|
554
|
-
...(activeAgentId ? [
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
"
|
|
575
|
+
"AgentBridge start",
|
|
576
|
+
"",
|
|
577
|
+
"1) Actions performed",
|
|
578
|
+
`- Started tracked work for scope: ${scope}`,
|
|
579
|
+
`- Linked task ${changeRequest.id} to run ${workSessionId}`,
|
|
580
|
+
`- Work session: ${workSessionId}`,
|
|
581
|
+
...(activeAgentId ? [`- Agent: ${activeAgentId}`] : []),
|
|
582
|
+
...(resolvedDomain ? [`- Domain: ${resolvedDomain}`] : []),
|
|
583
|
+
"",
|
|
584
|
+
"2) Proof present / missing",
|
|
585
|
+
"- Present: task + run are active and linked",
|
|
586
|
+
"- Missing: verification proof for this change (tests/checks not recorded yet)",
|
|
587
|
+
`- Identity source: ${ownership.identitySource}`,
|
|
588
|
+
`- Lane claim confidence: ${ownership.laneClaimConfidence} (${ownership.laneClaimSource})`,
|
|
589
|
+
...(ownership.identityWarning
|
|
590
|
+
? [
|
|
591
|
+
"- Warning: identity config mismatch detected (using caller identity fallback)",
|
|
592
|
+
ownership.identityWarning,
|
|
593
|
+
]
|
|
594
|
+
: []),
|
|
595
|
+
"",
|
|
596
|
+
"3) Next move",
|
|
597
|
+
"- Keep supervision running with `agentbridge watch`",
|
|
598
|
+
"- After changes, run `agentbridge verify -- <command>`",
|
|
599
|
+
"- Re-run `agentbridge watch` to confirm proof and boundaries",
|
|
560
600
|
];
|
|
561
601
|
process.stdout.write(`${renderOtherSessions(output, [...new Set(otherSessionIds)]).join("\n")}\n`);
|
|
562
602
|
return {
|
|
@@ -567,14 +607,31 @@ async function executeStartWorkSession(opts) {
|
|
|
567
607
|
};
|
|
568
608
|
}
|
|
569
609
|
function hasActiveLocalRun() {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
if (
|
|
576
|
-
|
|
577
|
-
|
|
610
|
+
return (0, session_state_1.isActiveLocalSession)((0, session_state_1.readSessionState)());
|
|
611
|
+
}
|
|
612
|
+
async function runLocalStart(intent) {
|
|
613
|
+
const validatedIntent = (0, intent_validation_1.validateIntent)(intent);
|
|
614
|
+
const existing = (0, session_state_1.readSessionState)();
|
|
615
|
+
if ((0, session_state_1.isActiveLocalSession)(existing)) {
|
|
616
|
+
if (existing.intent?.trim() === validatedIntent) {
|
|
617
|
+
process.stdout.write(`Contract already active: ${validatedIntent}\n`);
|
|
618
|
+
return existing;
|
|
619
|
+
}
|
|
620
|
+
throw (0, errors_1.catalogCliError)("START_EXPLICIT_PAIR_REQUIRED", {
|
|
621
|
+
what: "A different AgentBridge contract is already active.",
|
|
622
|
+
why: `Current contract: ${existing.intent ?? "(unknown)"}`,
|
|
623
|
+
next: "Finish the current contract in watch, or close it before starting a new one.",
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
const session = (0, session_1.openLocalSession)({
|
|
627
|
+
agentId: "local",
|
|
628
|
+
laneDomain: null,
|
|
629
|
+
intent: validatedIntent,
|
|
630
|
+
domains: [],
|
|
631
|
+
mode: "local_supervision",
|
|
632
|
+
});
|
|
633
|
+
process.stdout.write(`Contract created: ${validatedIntent}\n`);
|
|
634
|
+
return session;
|
|
578
635
|
}
|
|
579
636
|
async function runDefaultStart(opts = {}) {
|
|
580
637
|
const { runLocalSupervision } = await Promise.resolve().then(() => __importStar(require("../local-supervision")));
|
|
@@ -595,6 +652,12 @@ function isStrictTrackedStartRequest(opts) {
|
|
|
595
652
|
return explicitSummaryFlag || explicitScopeFlag || explicitInputProvided;
|
|
596
653
|
}
|
|
597
654
|
async function runStart(opts = {}) {
|
|
655
|
+
const cfg = (0, config_1.readConfig)();
|
|
656
|
+
const localIntent = opts.prompt?.trim() || opts.summary?.trim();
|
|
657
|
+
if (!cfg.projectId?.trim() && localIntent) {
|
|
658
|
+
await runLocalStart(localIntent);
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
598
661
|
const strictTrackedStart = isStrictTrackedStartRequest(opts);
|
|
599
662
|
const explicitSummaryFlag = opts.summaryFlagProvided === true;
|
|
600
663
|
const explicitScopeFlag = opts.scopeFlagProvided === true;
|