@cirtium/acent-connect 1.1.2 → 1.1.4
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/acent/.claude-plugin/plugin.json +1 -1
- package/acent/.codex-plugin/plugin.json +1 -1
- package/acent/.cursor-plugin/plugin.json +1 -1
- package/acent/scripts/acent-connect.mjs +43 -26
- package/acent/scripts/bridge-capture.mjs +120 -0
- package/acent/scripts/bridge-checks.mjs +12 -2
- package/acent/scripts/bridge-finalize.mjs +10 -1
- package/acent/scripts/bridge-refinement.mjs +93 -22
- package/acent/scripts/bridge-review-result.mjs +12 -0
- package/acent/scripts/bridge-runners.mjs +170 -86
- package/acent/scripts/bridge.mjs +70 -13
- package/acent/scripts/capture-activity.mjs +5 -3
- package/acent/scripts/hook.mjs +11 -0
- package/acent/scripts/mcp-proxy.mjs +17 -1
- package/acent/skills/acent-bridge/SKILL.md +25 -2
- package/antigravity/plugin.json +1 -1
- package/package.json +1 -1
|
@@ -12,7 +12,7 @@ export function modelFamily(model) {
|
|
|
12
12
|
const value = model?.toLowerCase() ?? ""
|
|
13
13
|
if (/^(?:openai[/:])?(?:gpt[- ]|o[134](?:[- ]|$))/.test(value)) return "gpt"
|
|
14
14
|
if (
|
|
15
|
-
/^(?:anthropic[/:])?(?:claude[- ]|sonnet
|
|
15
|
+
/^(?:anthropic[/:])?(?:claude[- ]|(?:sonnet|opus|haiku|fable|mythos)(?:[- ]|$))/.test(
|
|
16
16
|
value
|
|
17
17
|
)
|
|
18
18
|
)
|
|
@@ -248,7 +248,7 @@ export async function bridgeAccountRevision(tool) {
|
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
function modelRows(output) {
|
|
251
|
+
function modelRows(output, tabular = false) {
|
|
252
252
|
return [
|
|
253
253
|
...new Set(
|
|
254
254
|
output
|
|
@@ -258,7 +258,13 @@ function modelRows(output) {
|
|
|
258
258
|
.replace(/\x1b\[[0-9;]*m/g, "")
|
|
259
259
|
.trim()
|
|
260
260
|
.replace(/^[›*•]\s*/, "")
|
|
261
|
-
return clean.match(/^[\w][\w.:/-]*/)?.[0]
|
|
261
|
+
if (!tabular) return clean.match(/^[\w][\w.:/-]*/)?.[0]
|
|
262
|
+
|
|
263
|
+
// Antigravity prints a model ID and display name separated by a tab.
|
|
264
|
+
// Also accept bare model IDs from known families.
|
|
265
|
+
const row = clean.match(/^([\w][\w.:/-]*)\t+\S/)
|
|
266
|
+
if (row) return row[1]
|
|
267
|
+
if (/^[\w][\w.:/-]*$/.test(clean) && modelFamily(clean)) return clean
|
|
262
268
|
})
|
|
263
269
|
.filter((id) => id && /[-.:/]/.test(id) && !id.endsWith(":"))
|
|
264
270
|
),
|
|
@@ -391,7 +397,7 @@ export async function readBridgeQuota(tool, cwd, run = runProcess) {
|
|
|
391
397
|
}
|
|
392
398
|
|
|
393
399
|
const authenticationRequired =
|
|
394
|
-
|
|
400
|
+
/^\s*(?:(?:error|warning):\s*)?(?:you (?:are|are currently) )?(?:not (?:logged in|signed in|authenticated)|unauthenticated|authentication required|(?:login|sign[ -]in) required|please (?:log|sign) in)\b/im
|
|
395
401
|
|
|
396
402
|
export async function discoverBridgeTarget(
|
|
397
403
|
tool,
|
|
@@ -413,20 +419,26 @@ export async function discoverBridgeTarget(
|
|
|
413
419
|
...options,
|
|
414
420
|
...(result.env ? { env: result.env } : {}),
|
|
415
421
|
})
|
|
416
|
-
const diagnostics = result.stdout
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
422
|
+
const diagnostics = `${result.stdout}\n${result.stderr}`.replace(
|
|
423
|
+
/\x1b\[[0-9;]*m/g,
|
|
424
|
+
""
|
|
425
|
+
)
|
|
420
426
|
if (tool === "Claude Code") {
|
|
421
427
|
let account
|
|
422
428
|
try {
|
|
423
429
|
account = JSON.parse(result.stdout)
|
|
424
430
|
} catch {
|
|
425
|
-
return {
|
|
431
|
+
return {
|
|
432
|
+
tool,
|
|
433
|
+
status: authenticationRequired.test(diagnostics)
|
|
434
|
+
? "login_required"
|
|
435
|
+
: "unavailable",
|
|
436
|
+
models: [],
|
|
437
|
+
}
|
|
426
438
|
}
|
|
427
|
-
if (account
|
|
439
|
+
if (account?.loggedIn === false)
|
|
428
440
|
return { tool, status: "login_required", models: [] }
|
|
429
|
-
if (
|
|
441
|
+
if (account?.loggedIn !== true || result.code !== 0)
|
|
430
442
|
return { tool, status: "unavailable", models: [] }
|
|
431
443
|
const models = await claudeModelList(cwd, runSelected)
|
|
432
444
|
return {
|
|
@@ -440,13 +452,20 @@ export async function discoverBridgeTarget(
|
|
|
440
452
|
: undefined,
|
|
441
453
|
}
|
|
442
454
|
}
|
|
455
|
+
if (authenticationRequired.test(diagnostics)) {
|
|
456
|
+
return { tool, status: "login_required", models: [] }
|
|
457
|
+
}
|
|
443
458
|
if (result.code !== 0) return { tool, status: "unavailable", models: [] }
|
|
444
459
|
const codex = tool === "Codex" ? await codexInfo(runSelected, cwd) : undefined
|
|
445
460
|
const cursorModels =
|
|
446
461
|
tool === "Cursor" ? await runSelected(null, ["models"], { cwd }) : undefined
|
|
447
462
|
let modelCatalogFailure = cursorModels?.failure
|
|
448
463
|
if (cursorModels && !modelCatalogFailure) {
|
|
449
|
-
const diagnostics =
|
|
464
|
+
const diagnostics =
|
|
465
|
+
`${cursorModels.stdout}\n${cursorModels.stderr}`.replace(
|
|
466
|
+
/\x1b\[[0-9;]*m/g,
|
|
467
|
+
""
|
|
468
|
+
)
|
|
450
469
|
if (authenticationRequired.test(diagnostics))
|
|
451
470
|
modelCatalogFailure = "login_required"
|
|
452
471
|
else if (cursorModels.code !== 0) modelCatalogFailure = "failed"
|
|
@@ -454,7 +473,7 @@ export async function discoverBridgeTarget(
|
|
|
454
473
|
const ids = codex
|
|
455
474
|
? codex.models
|
|
456
475
|
: tool === "Antigravity"
|
|
457
|
-
? modelRows(result.stdout)
|
|
476
|
+
? modelRows(result.stdout, true)
|
|
458
477
|
: !modelCatalogFailure
|
|
459
478
|
? modelRows(cursorModels?.stdout ?? "")
|
|
460
479
|
: []
|
|
@@ -473,20 +492,107 @@ export async function discoverBridgeTarget(
|
|
|
473
492
|
}
|
|
474
493
|
}
|
|
475
494
|
|
|
495
|
+
function reportedModel(value) {
|
|
496
|
+
const name = typeof value === "string" ? value.trim() : ""
|
|
497
|
+
if (/^[\p{L}\p{N}][\p{L}\p{N}\p{M}_ .:/()+-]{0,199}$/u.test(name) &&
|
|
498
|
+
!/^(?:auto|default|unknown)$/i.test(name))
|
|
499
|
+
return name
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
function bridgeEvents(stdout) {
|
|
503
|
+
return (stdout ?? "").split("\n").flatMap((line) => {
|
|
504
|
+
try {
|
|
505
|
+
const event = JSON.parse(line)
|
|
506
|
+
return event && typeof event === "object" ? [event] : []
|
|
507
|
+
} catch {
|
|
508
|
+
return []
|
|
509
|
+
}
|
|
510
|
+
})
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
async function executeCodex({ cwd, model, prompt, readOnly }, options, run) {
|
|
514
|
+
let threadId
|
|
515
|
+
let summary
|
|
516
|
+
let usage
|
|
517
|
+
let actualModel
|
|
518
|
+
let completed = false
|
|
519
|
+
let error
|
|
520
|
+
const result = await runHost("Codex", ["app-server"], {
|
|
521
|
+
...options,
|
|
522
|
+
initialize: {
|
|
523
|
+
id: 1,
|
|
524
|
+
method: "initialize",
|
|
525
|
+
params: { clientInfo: { name: "acent", version: "1.0" } },
|
|
526
|
+
},
|
|
527
|
+
onLine(event, send) {
|
|
528
|
+
if (!event || typeof event !== "object") return
|
|
529
|
+
if (event.method && event.id !== undefined) {
|
|
530
|
+
send({ id: event.id, error: { code: -32601, message: "Unsupported request" } })
|
|
531
|
+
return
|
|
532
|
+
}
|
|
533
|
+
if ([1, 2, 3].includes(event.id) && event.error) {
|
|
534
|
+
error = event.error.message || "Codex could not start the turn."
|
|
535
|
+
send(null)
|
|
536
|
+
return
|
|
537
|
+
}
|
|
538
|
+
if (event.id === 1) {
|
|
539
|
+
send({ method: "initialized" })
|
|
540
|
+
send({
|
|
541
|
+
id: 2,
|
|
542
|
+
method: "thread/start",
|
|
543
|
+
params: {
|
|
544
|
+
cwd,
|
|
545
|
+
model,
|
|
546
|
+
sandbox: readOnly ? "read-only" : "workspace-write",
|
|
547
|
+
approvalPolicy: "never",
|
|
548
|
+
},
|
|
549
|
+
})
|
|
550
|
+
return
|
|
551
|
+
}
|
|
552
|
+
if (event.id === 2) {
|
|
553
|
+
threadId = event.result?.thread?.id
|
|
554
|
+
if (!threadId) {
|
|
555
|
+
error = "Codex did not report a thread ID."
|
|
556
|
+
send(null)
|
|
557
|
+
return
|
|
558
|
+
}
|
|
559
|
+
actualModel = reportedModel(event.result.model)
|
|
560
|
+
send({
|
|
561
|
+
id: 3,
|
|
562
|
+
method: "turn/start",
|
|
563
|
+
params: { threadId, input: [{ type: "text", text: prompt, text_elements: [] }] },
|
|
564
|
+
})
|
|
565
|
+
return
|
|
566
|
+
}
|
|
567
|
+
if (!threadId || event.params?.threadId !== threadId) return
|
|
568
|
+
const { item, turn, toModel, tokenUsage } = event.params
|
|
569
|
+
if (event.method === "item/completed" && item?.type === "agentMessage")
|
|
570
|
+
summary = item.text
|
|
571
|
+
if (event.method === "thread/tokenUsage/updated")
|
|
572
|
+
usage = tokenUsage?.total
|
|
573
|
+
if (event.method === "model/rerouted")
|
|
574
|
+
actualModel = reportedModel(toModel) ?? actualModel
|
|
575
|
+
if (event.method === "turn/completed") {
|
|
576
|
+
completed = turn?.status === "completed"
|
|
577
|
+
if (!completed) error = turn?.error?.message || "Codex did not complete the turn."
|
|
578
|
+
send(null)
|
|
579
|
+
}
|
|
580
|
+
},
|
|
581
|
+
}, run)
|
|
582
|
+
return {
|
|
583
|
+
result,
|
|
584
|
+
summary,
|
|
585
|
+
usage,
|
|
586
|
+
actualModel: completed ? actualModel : undefined,
|
|
587
|
+
error: completed ? undefined : (error ?? "Codex did not report a completed turn."),
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
|
|
476
591
|
export async function executeBridgeTarget(
|
|
477
592
|
{ tool, model, readOnly, managedWorkspace, cwd, prompt, signal, onSpawn },
|
|
478
593
|
run = runProcess
|
|
479
594
|
) {
|
|
480
595
|
const args = {
|
|
481
|
-
Codex: [
|
|
482
|
-
"exec",
|
|
483
|
-
"--json",
|
|
484
|
-
"--sandbox",
|
|
485
|
-
readOnly ? "read-only" : "workspace-write",
|
|
486
|
-
...(model ? ["-m", model] : []),
|
|
487
|
-
"--",
|
|
488
|
-
"-",
|
|
489
|
-
],
|
|
490
596
|
"Claude Code": [
|
|
491
597
|
"-p",
|
|
492
598
|
"--output-format",
|
|
@@ -498,7 +604,7 @@ export async function executeBridgeTarget(
|
|
|
498
604
|
],
|
|
499
605
|
Cursor: [
|
|
500
606
|
"--output-format",
|
|
501
|
-
"json",
|
|
607
|
+
"stream-json",
|
|
502
608
|
...(managedWorkspace ? ["--trust"] : []),
|
|
503
609
|
...(readOnly ? ["--mode=ask"] : []),
|
|
504
610
|
...(model ? ["--model", model] : []),
|
|
@@ -515,50 +621,38 @@ export async function executeBridgeTarget(
|
|
|
515
621
|
prompt,
|
|
516
622
|
],
|
|
517
623
|
}[tool]
|
|
518
|
-
const
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
)
|
|
624
|
+
const options = {
|
|
625
|
+
cwd,
|
|
626
|
+
signal,
|
|
627
|
+
onSpawn,
|
|
628
|
+
processGroup: true,
|
|
629
|
+
env: { ...bridgeGitEnvironment(), ACENT_BRIDGE_WORKER: "1" },
|
|
630
|
+
input: tool === "Claude Code" ? prompt : undefined,
|
|
631
|
+
timeout: 10 * 60 * 1000,
|
|
632
|
+
maxBytes: 8 * 1024 * 1024,
|
|
633
|
+
}
|
|
634
|
+
const codex = tool === "Codex"
|
|
635
|
+
? await executeCodex({ cwd, model, prompt, readOnly }, options, run)
|
|
636
|
+
: undefined
|
|
637
|
+
const result = codex?.result ?? await runHost(tool, args, options, run)
|
|
533
638
|
let summary
|
|
534
639
|
let error
|
|
535
640
|
let usage
|
|
536
641
|
let actualModel
|
|
537
642
|
let rateLimitResetAt
|
|
538
|
-
if (
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
return []
|
|
544
|
-
}
|
|
545
|
-
})
|
|
546
|
-
if (tool === "Codex") {
|
|
547
|
-
const turn = events.findLast((event) => event.type === "turn.completed")
|
|
548
|
-
summary = events.findLast((event) => event.item?.type === "agent_message")
|
|
549
|
-
?.item.text
|
|
550
|
-
error = events.findLast((event) => event.type === "turn.failed")?.error
|
|
551
|
-
?.message
|
|
552
|
-
if (!turn && !error) error = "Codex did not report a completed turn."
|
|
553
|
-
usage = turn?.usage
|
|
554
|
-
} else {
|
|
643
|
+
if (codex) {
|
|
644
|
+
({ summary, error, usage, actualModel } = codex)
|
|
645
|
+
} else {
|
|
646
|
+
const events = bridgeEvents(result.stdout)
|
|
647
|
+
if (tool === "Claude Code") {
|
|
555
648
|
const terminal = events.findLast((event) => event.type === "result")
|
|
556
649
|
summary = terminal?.result
|
|
557
650
|
usage = terminal?.usage
|
|
558
|
-
actualModel = events.findLast(
|
|
559
|
-
(event) =>
|
|
560
|
-
event.
|
|
561
|
-
|
|
651
|
+
actualModel = reportedModel(events.findLast(
|
|
652
|
+
(event) => event.type === "assistant" &&
|
|
653
|
+
!event.parent_tool_use_id && !event.is_api_error_message &&
|
|
654
|
+
reportedModel(event.message?.model)
|
|
655
|
+
)?.message.model)
|
|
562
656
|
const limit = events.findLast(
|
|
563
657
|
(event) =>
|
|
564
658
|
event.type === "rate_limit_event" &&
|
|
@@ -578,35 +672,27 @@ export async function executeBridgeTarget(
|
|
|
578
672
|
summary ||
|
|
579
673
|
"Claude Code did not report a completed turn."
|
|
580
674
|
}
|
|
581
|
-
}
|
|
582
|
-
} else {
|
|
583
|
-
try {
|
|
675
|
+
} else {
|
|
584
676
|
const event =
|
|
585
677
|
tool === "Antigravity"
|
|
586
|
-
? result
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
} catch {
|
|
592
|
-
return []
|
|
593
|
-
}
|
|
594
|
-
})
|
|
595
|
-
.findLast((item) => item.event === "result")
|
|
596
|
-
: JSON.parse(result.stdout)
|
|
597
|
-
if (!event) throw new Error("Missing final CLI result")
|
|
678
|
+
? events.findLast((item) => item.event === "result")
|
|
679
|
+
: events.findLast((item) => item.type === "result")
|
|
680
|
+
const initModel = tool === "Antigravity"
|
|
681
|
+
? events.find((item) => item.event === "init")?.init?.model
|
|
682
|
+
: events.find((item) => item.type === "system" && item.subtype === "init")?.model
|
|
598
683
|
const payload =
|
|
599
|
-
typeof event
|
|
684
|
+
typeof event?.result === "object" && event.result ? event.result : event
|
|
600
685
|
summary =
|
|
601
|
-
payload
|
|
602
|
-
(typeof payload
|
|
603
|
-
usage = payload
|
|
604
|
-
|
|
605
|
-
|
|
686
|
+
payload?.response ??
|
|
687
|
+
(typeof payload?.result === "string" ? payload.result : undefined)
|
|
688
|
+
usage = payload?.usage
|
|
689
|
+
actualModel =
|
|
690
|
+
reportedModel(payload?.model) ?? reportedModel(event?.model) ?? reportedModel(initModel)
|
|
606
691
|
if (
|
|
607
|
-
event
|
|
608
|
-
payload
|
|
609
|
-
|
|
692
|
+
event?.is_error ||
|
|
693
|
+
payload?.is_error ||
|
|
694
|
+
(payload?.status && !/^success$/i.test(payload.status)) ||
|
|
695
|
+
(event?.subtype && event.subtype !== "success")
|
|
610
696
|
) {
|
|
611
697
|
error =
|
|
612
698
|
payload.error ||
|
|
@@ -614,8 +700,6 @@ export async function executeBridgeTarget(
|
|
|
614
700
|
payload.status ||
|
|
615
701
|
"Agent returned an error."
|
|
616
702
|
}
|
|
617
|
-
} catch {
|
|
618
|
-
// A non-JSON response cannot verify that a delegated turn completed.
|
|
619
703
|
}
|
|
620
704
|
}
|
|
621
705
|
const diagnostics = [
|
|
@@ -681,7 +765,7 @@ export async function executeBridgeTarget(
|
|
|
681
765
|
!error && typeof summary === "string"
|
|
682
766
|
? summary.slice(0, 16000)
|
|
683
767
|
: undefined,
|
|
684
|
-
actualModel,
|
|
768
|
+
actualModel: failure ? undefined : actualModel,
|
|
685
769
|
rateLimitResetAt,
|
|
686
770
|
...(Object.keys(tokens).length ? { tokens } : {}),
|
|
687
771
|
}
|
package/acent/scripts/bridge.mjs
CHANGED
|
@@ -13,8 +13,10 @@ import { homedir } from "node:os"
|
|
|
13
13
|
import { dirname, join } from "node:path"
|
|
14
14
|
import { setTimeout as pause } from "node:timers/promises"
|
|
15
15
|
import { lock } from "./acent-connect.mjs"
|
|
16
|
+
import { bridgeChangeContributors } from "./bridge-capture.mjs"
|
|
16
17
|
import { createBridgeFinalizer } from "./bridge-finalize.mjs"
|
|
17
18
|
import { createBridgeRetention } from "./bridge-retention.mjs"
|
|
19
|
+
import { bridgeReviewResult } from "./bridge-review-result.mjs"
|
|
18
20
|
import {
|
|
19
21
|
createBridgeRefinement,
|
|
20
22
|
reviewFindings,
|
|
@@ -30,6 +32,7 @@ import {
|
|
|
30
32
|
mismatchedBridgePaths,
|
|
31
33
|
pathsOverlap,
|
|
32
34
|
projectSnapshot,
|
|
35
|
+
projectFileVersions,
|
|
33
36
|
withinPaths,
|
|
34
37
|
} from "./bridge-workspace.mjs"
|
|
35
38
|
import {
|
|
@@ -278,11 +281,19 @@ export const bridgeTools = [
|
|
|
278
281
|
]
|
|
279
282
|
|
|
280
283
|
export const bridgeInstructions = [
|
|
281
|
-
"Use Acent Bridge when the user explicitly asks to delegate. For agent-initiated delegation,
|
|
284
|
+
"Use Acent Bridge when the user explicitly asks to delegate. For agent-initiated delegation, call acent_bridge_settings when planning a task that matches an automatic delegation trigger, or as soon as the trigger becomes clear. If the project reports automatic=true and a suitable candidate is available, start the matching Bridge workflow. Pass automatic=true when listing candidates, starting a task, or starting refinement. Honor any user instruction to keep the work in the current agent.",
|
|
285
|
+
"Automatic delegation triggers are independent implementation tasks with disjoint write scopes and verifiable outcomes, substantive changes to payments, authorization, privacy, or durable data that need independent review, and difficult failures where the cause remains unclear or a fix repeatedly fails. Start parallel implementation or read-only diagnosis when the scope is clear. For high-impact changes, have a different model family review the concrete changes before reporting completion.",
|
|
286
|
+
"Keep one writer responsible for each shared contract, state machine, or business rule, even if the files are disjoint. Resolve shared design decisions before starting parallel implementation. If one task needs an earlier result, pass dependsOn or finish the prerequisite first. Handle small, straightforward edits and dependent steps directly. Use read-only review or diagnosis for independent work when writes need one owner.",
|
|
287
|
+
"Keep authorized production actions such as deploys, database migrations, and live payments or refunds with the coordinating agent. Use Bridge for independent review of the plan and verification of the result.",
|
|
288
|
+
"If automatic delegation is disabled, continue the task directly. If automatic delegation is enabled but no suitable candidate is available, continue work you can verify and state the specific reason the independent work did not run. Report only the reviews and checks that actually completed.",
|
|
282
289
|
"Get candidates for each new task and choose a tool and model that fit the work and the user's preference. Favor lower-usage options for routine work when verified quota is low and the user has not pinned a model. Start tasks with concrete acceptance criteria.",
|
|
290
|
+
"In the final answer after using Bridge, name any enabled or explicitly requested tools that could not participate because CLI authentication was required, even if other tools completed the work. Use loginRequiredTools from candidate selection and login_required from task or refinement status as evidence. If the tool later succeeds in the same request, report its final outcome instead. Do not infer sign-out from missing models or an unavailable tool. Point users to Set up in Acent Bridge when they need to sign in.",
|
|
283
291
|
"Check several jobs together with acent_bridge_activity while doing independent work. If a delegate requests context, answer from the conversation or ask the user if their judgment is needed, then continue. Use acent_bridge_integrate to check and apply completed diffs.",
|
|
284
292
|
"For substantive authorized edits with a defined write scope, use acent_bridge_refine to run independent review, repair and re-review. Select eligible models and set apply=true only within the user's authorized editing scope. Continue unrelated work while it runs.",
|
|
285
293
|
"At needs_checks, call verify with the current checkRevision and authorized test commands to run in the private staging workspace. For a pending verified patch, inspect and approve it with apply and checkRevision. Replace a failed reviewer with replace_reviewer and an eligible reviewer. Resolve context requests using acent_bridge_continue and then resume refinement status. For standalone review of integrated work, submit commands to acent_bridge_finalize and poll without commands until verification finishes. Use setupCommands if the private check copy needs project-specific preparation. Remain responsible for the final result.",
|
|
294
|
+
"Include an Acent Bridge section in the first final answer after any Bridge run or requested independent review, including when a requested review could not run. Start with a bold Acent Bridge label and the observed status in the user's language. Follow it immediately with a Markdown table with columns for agent or check, scope, outcome, and findings or evidence. Include the table even when only one delegate participated or its execution model is unknown. Name the coordinator and delegate separately for the checks each performed. For delegates, use actualModel as the host-reported model. For the coordinator, use the host's model metadata for that turn when available. When the execution model is unavailable, label any requested model as requested and mark the execution model unconfirmed. Keep model families separate from model names.",
|
|
295
|
+
"Use one row per task, reviewer, or check. Use reviewResult and reviewResults to distinguish findings, no findings in the reviewed scope, unclassified results, failed or blocked reviews, and reviews that did not run. Include relevant earlier and replacement rows with their round, and list checksNotRun as not run. Keep findings reported by a single reviewer visible. Report whether each material finding was reproduced, remains unverified, or was fixed and rechecked. Cite file lines and short observed evidence in the table or in an Evidence section above the conclusion. Keep raw logs and credentials out of the answer.",
|
|
296
|
+
"End the Bridge report with a final conclusion stating whether the patch was applied or is awaiting application, which material findings or checks remain, and the recommended next action when needed. For read-only work, conclude with the result and any remaining uncertainty.",
|
|
286
297
|
].join(" ")
|
|
287
298
|
|
|
288
299
|
const cacheDuration = 120_000
|
|
@@ -390,7 +401,7 @@ function taskPrompt(job) {
|
|
|
390
401
|
? "Read-only review or diagnosis. Report evidence with file references."
|
|
391
402
|
: "Make the requested changes in this copy and report which checks actually ran.",
|
|
392
403
|
"If a prior decision or information from the original conversation is required, end your response with <acent-context>one specific question and why it blocks you</acent-context>.",
|
|
393
|
-
...(job.
|
|
404
|
+
...(job.kind === "review" ? [reviewFormat] : []),
|
|
394
405
|
"Task: " + job.task,
|
|
395
406
|
"Acceptance criteria: " + job.acceptance,
|
|
396
407
|
...(job.context
|
|
@@ -560,6 +571,13 @@ export function createBridge({
|
|
|
560
571
|
.filter((tool) => !args.tool || tool === args.tool)
|
|
561
572
|
.map((tool) => getTarget(tool, folder))
|
|
562
573
|
)
|
|
574
|
+
const loginRequiredTools = targets
|
|
575
|
+
.filter(
|
|
576
|
+
({ tool, status }) =>
|
|
577
|
+
status === "login_required" &&
|
|
578
|
+
(settings.targets.includes(tool) || args.tool === tool)
|
|
579
|
+
)
|
|
580
|
+
.map(({ tool }) => tool)
|
|
563
581
|
const choices = targets.flatMap((item) =>
|
|
564
582
|
item.status !== "ready"
|
|
565
583
|
? []
|
|
@@ -584,6 +602,7 @@ export function createBridge({
|
|
|
584
602
|
return {
|
|
585
603
|
status: choices.length ? "ready" : "no_candidate",
|
|
586
604
|
candidates: choices,
|
|
605
|
+
...(loginRequiredTools.length ? { loginRequiredTools } : {}),
|
|
587
606
|
tools: await Promise.all(
|
|
588
607
|
targets.map(async (item) => ({
|
|
589
608
|
tool: item.tool,
|
|
@@ -634,7 +653,8 @@ export function createBridge({
|
|
|
634
653
|
projectDir,
|
|
635
654
|
coordination,
|
|
636
655
|
prepare,
|
|
637
|
-
snapshot
|
|
656
|
+
snapshot,
|
|
657
|
+
captureEvidence
|
|
638
658
|
) {
|
|
639
659
|
const jobDir = join(projectDir, job.id)
|
|
640
660
|
const record = join(jobDir, "job.json")
|
|
@@ -772,6 +792,7 @@ export function createBridge({
|
|
|
772
792
|
attempt,
|
|
773
793
|
startedAt: lease.startedAt,
|
|
774
794
|
finishedAt: undefined,
|
|
795
|
+
actualModel: undefined,
|
|
775
796
|
lastRunTokens: undefined,
|
|
776
797
|
lastRunErrorCode: undefined,
|
|
777
798
|
remainingQuota: undefined,
|
|
@@ -836,6 +857,9 @@ export function createBridge({
|
|
|
836
857
|
baseline.scopes ?? delegateScopes(job)
|
|
837
858
|
))
|
|
838
859
|
const target = invalidWorkspace ? {} : await getTarget(job.tool, folder)
|
|
860
|
+
const beforeAttempt = !prepare && !invalidWorkspace && !reviewOnly(job.kind)
|
|
861
|
+
? await projectFileVersions(work, job.paths.length ? job.paths : undefined)
|
|
862
|
+
: null
|
|
839
863
|
await cancelled()
|
|
840
864
|
let result
|
|
841
865
|
if (abort.signal.aborted) result = { failure: "cancelled" }
|
|
@@ -861,9 +885,10 @@ export function createBridge({
|
|
|
861
885
|
job.status = abort.signal.aborted
|
|
862
886
|
? "cancelled"
|
|
863
887
|
: (result.failure ?? (question ? "needs_context" : "completed"))
|
|
864
|
-
if (job.
|
|
865
|
-
job.findings = reviewFindings(job.summary)
|
|
866
|
-
if (!job.findings
|
|
888
|
+
if (job.kind === "review" && job.status === "completed") {
|
|
889
|
+
job.findings = reviewFindings(job.summary) ?? undefined
|
|
890
|
+
if (!job.findings && job.structuredReview)
|
|
891
|
+
job.status = "invalid_review"
|
|
867
892
|
}
|
|
868
893
|
job.actualModel = result.actualModel
|
|
869
894
|
if (
|
|
@@ -907,6 +932,7 @@ export function createBridge({
|
|
|
907
932
|
mode: 0o600,
|
|
908
933
|
})
|
|
909
934
|
job.patchBytes = Buffer.byteLength(changes.patch)
|
|
935
|
+
job.changeContributors = bridgeChangeContributors(job, changes.changes, beforeAttempt)
|
|
910
936
|
job.changes = changes.changes
|
|
911
937
|
if (job.status === "completed" && !changes.patch)
|
|
912
938
|
job.status = "no_changes"
|
|
@@ -990,13 +1016,17 @@ export function createBridge({
|
|
|
990
1016
|
entries.filter((item) => item.attempt !== attempt)
|
|
991
1017
|
)
|
|
992
1018
|
})
|
|
1019
|
+
if (captureEvidence) await captureEvidence({
|
|
1020
|
+
id: job.id, phase: job.kind, status: job.status, at: job.finishedAt,
|
|
1021
|
+
attempt, job,
|
|
1022
|
+
})
|
|
993
1023
|
}
|
|
994
1024
|
})()
|
|
995
1025
|
task.catch(() => {})
|
|
996
1026
|
return { id: job.id, status: "running", tool: job.tool, model: job.model }
|
|
997
1027
|
}
|
|
998
1028
|
|
|
999
|
-
async function integrate(folder, projectDir, coordination, ids, apply) {
|
|
1029
|
+
async function integrate(folder, projectDir, coordination, ids, apply, captureEvidence) {
|
|
1000
1030
|
if (!safeIds(ids) || (apply !== undefined && typeof apply !== "boolean"))
|
|
1001
1031
|
throw new Error("Select one to four completed Bridge task IDs.")
|
|
1002
1032
|
return withWorkspaceLock(coordination, async () => {
|
|
@@ -1053,7 +1083,17 @@ export function createBridge({
|
|
|
1053
1083
|
if (overlaps.length)
|
|
1054
1084
|
return { status: "patch_overlap", paths: [...new Set(overlaps)] }
|
|
1055
1085
|
const paths = changes.map((change) => change.path)
|
|
1086
|
+
const captureApplied = async (at) => {
|
|
1087
|
+
if (!captureEvidence) return
|
|
1088
|
+
for (const { job, directory } of records)
|
|
1089
|
+
await captureEvidence({
|
|
1090
|
+
id: job.id, phase: "apply", status: "applied", at, job,
|
|
1091
|
+
patch: await readFile(join(directory, "changes.patch"), "utf8").catch(() => ""),
|
|
1092
|
+
changes: job.changes ?? [], jobs: [job],
|
|
1093
|
+
})
|
|
1094
|
+
}
|
|
1056
1095
|
if (receipt?.status === "applied") {
|
|
1096
|
+
if (apply) await captureApplied(receipt.appliedAt)
|
|
1057
1097
|
const conflicts = await mismatchedBridgePaths(folder, changes)
|
|
1058
1098
|
return conflicts.length
|
|
1059
1099
|
? { status: "working_copy_changed", paths: conflicts }
|
|
@@ -1068,6 +1108,7 @@ export function createBridge({
|
|
|
1068
1108
|
appliedAt,
|
|
1069
1109
|
})
|
|
1070
1110
|
await writeJson(receiptPath, { status: "applied", paths, appliedAt })
|
|
1111
|
+
await captureApplied(appliedAt)
|
|
1071
1112
|
return {
|
|
1072
1113
|
status: "applied",
|
|
1073
1114
|
ids,
|
|
@@ -1201,6 +1242,8 @@ export function createBridge({
|
|
|
1201
1242
|
rm(stageDir, { recursive: true, force: true }),
|
|
1202
1243
|
launch: async (task, currentSettings, snapshot) => {
|
|
1203
1244
|
const available = await candidates(task, folder, currentSettings)
|
|
1245
|
+
if (available.loginRequiredTools?.includes(task.tool))
|
|
1246
|
+
return { status: "login_required" }
|
|
1204
1247
|
if (
|
|
1205
1248
|
!available.candidates.some(
|
|
1206
1249
|
({ tool, model }) => tool === task.tool && model === task.model
|
|
@@ -1222,7 +1265,8 @@ export function createBridge({
|
|
|
1222
1265
|
projectDir,
|
|
1223
1266
|
coordination,
|
|
1224
1267
|
true,
|
|
1225
|
-
snapshot && (await snapshot())
|
|
1268
|
+
snapshot && (await snapshot()),
|
|
1269
|
+
settings.captureEvidence
|
|
1226
1270
|
)
|
|
1227
1271
|
},
|
|
1228
1272
|
readRepairPatch: (id) =>
|
|
@@ -1243,9 +1287,18 @@ export function createBridge({
|
|
|
1243
1287
|
},
|
|
1244
1288
|
})
|
|
1245
1289
|
if (name === "acent_bridge_integrate")
|
|
1246
|
-
return integrate(folder, projectDir, coordination, args.ids, args.apply)
|
|
1247
|
-
if (name === "acent_bridge_finalize")
|
|
1248
|
-
|
|
1290
|
+
return integrate(folder, projectDir, coordination, args.ids, args.apply, settings.captureEvidence)
|
|
1291
|
+
if (name === "acent_bridge_finalize") {
|
|
1292
|
+
const result = await finalize(folder, projectDir, coordination, args)
|
|
1293
|
+
if (settings.captureEvidence && result.checkedAt)
|
|
1294
|
+
await settings.captureEvidence({
|
|
1295
|
+
id: args.reviewId, phase: "verify", status: result.status, at: result.checkedAt,
|
|
1296
|
+
attempt: result.checkedAt,
|
|
1297
|
+
result: { review: result.reviewResult, checks: result.checks?.map(({ name, outcome }) => ({ name, outcome })),
|
|
1298
|
+
checksNotRun: result.checksNotRun?.length },
|
|
1299
|
+
})
|
|
1300
|
+
return result
|
|
1301
|
+
}
|
|
1249
1302
|
if (name === "acent_bridge_activity") {
|
|
1250
1303
|
const entries = await readdir(projectDir).catch((error) => {
|
|
1251
1304
|
if (error.code === "ENOENT") return []
|
|
@@ -1268,6 +1321,7 @@ export function createBridge({
|
|
|
1268
1321
|
task: job.task.slice(0, 200),
|
|
1269
1322
|
tool: job.tool,
|
|
1270
1323
|
model: job.model,
|
|
1324
|
+
actualModel: job.actualModel,
|
|
1271
1325
|
status: taskState(job),
|
|
1272
1326
|
phase: job.phase,
|
|
1273
1327
|
paths: job.paths,
|
|
@@ -1364,7 +1418,7 @@ export function createBridge({
|
|
|
1364
1418
|
: available
|
|
1365
1419
|
if (!reviewOnly(job.kind) && !paths.length)
|
|
1366
1420
|
return { status: "write_scope_required" }
|
|
1367
|
-
return start(job, folder, projectDir, coordination, true)
|
|
1421
|
+
return start(job, folder, projectDir, coordination, true, undefined, settings.captureEvidence)
|
|
1368
1422
|
}
|
|
1369
1423
|
|
|
1370
1424
|
if (typeof args.id !== "string" || !taskId.test(args.id))
|
|
@@ -1418,6 +1472,7 @@ export function createBridge({
|
|
|
1418
1472
|
status,
|
|
1419
1473
|
summary,
|
|
1420
1474
|
findings,
|
|
1475
|
+
...(job.kind === "review" ? { reviewResult: bridgeReviewResult(job) } : {}),
|
|
1421
1476
|
question,
|
|
1422
1477
|
patch,
|
|
1423
1478
|
patchPath,
|
|
@@ -1474,7 +1529,9 @@ export function createBridge({
|
|
|
1474
1529
|
folder,
|
|
1475
1530
|
projectDir,
|
|
1476
1531
|
coordination,
|
|
1477
|
-
false
|
|
1532
|
+
false,
|
|
1533
|
+
undefined,
|
|
1534
|
+
settings.captureEvidence
|
|
1478
1535
|
)
|
|
1479
1536
|
}
|
|
1480
1537
|
}
|
|
@@ -9,7 +9,7 @@ async function save(path, value) {
|
|
|
9
9
|
await writeFile(temp, JSON.stringify(value), { mode: 0o600 })
|
|
10
10
|
await rename(temp, path)
|
|
11
11
|
}
|
|
12
|
-
export function redactActivity(value) {
|
|
12
|
+
export function redactActivity(value, limit = 16000) {
|
|
13
13
|
const secret = /authorization|cookie|password|passwd|secret|token|api[-_]?key|private[-_]?key/i
|
|
14
14
|
let clipped = false
|
|
15
15
|
function visit(v, depth = 0) {
|
|
@@ -29,7 +29,7 @@ export function redactActivity(value) {
|
|
|
29
29
|
if (typeof value === "string") { try { value = JSON.parse(value) } catch {} }
|
|
30
30
|
const clean = visit(value)
|
|
31
31
|
const text = typeof clean === "string" ? clean : JSON.stringify(clean, null, 2)
|
|
32
|
-
return { text: text.slice(0,
|
|
32
|
+
return { text: text.slice(0, limit), truncated: clipped || text.length > limit || JSON.stringify(value).length > limit }
|
|
33
33
|
}
|
|
34
34
|
export async function captureActivity(p, config, directory, includeContent = true) {
|
|
35
35
|
const event = p.acent_hook || p.hook_event_name
|
|
@@ -73,6 +73,8 @@ export async function captureActivity(p, config, directory, includeContent = tru
|
|
|
73
73
|
}
|
|
74
74
|
return true
|
|
75
75
|
}
|
|
76
|
+
// Bridge publishes applied edits and structured outcomes through its own capture.
|
|
77
|
+
const bridge = /(?:^|__)acent_bridge_/.test(name)
|
|
76
78
|
const raw = p.tool_response ?? p.tool_output ?? p.toolResult ?? p.error_message ?? p.error
|
|
77
79
|
let output = raw
|
|
78
80
|
if (typeof output === "string") { try { output = JSON.parse(output) } catch {} }
|
|
@@ -86,7 +88,7 @@ export async function captureActivity(p, config, directory, includeContent = tru
|
|
|
86
88
|
startedAt: state?.at ?? null, durationMs: duration == null ? null : Math.min(Math.round(duration), 604800000),
|
|
87
89
|
request: includeContent ? (state ? state.request : hostTurn || p.acent_request ? request : null) : null,
|
|
88
90
|
input: includeContent && input.text === null && state ? state.input : input,
|
|
89
|
-
output: redactActivity(includeContent ? raw : null),
|
|
91
|
+
output: redactActivity(includeContent && !bridge ? raw : null),
|
|
90
92
|
changeIds: (p.acent_code_changes ?? []).map(change => change.id).slice(0, 32),
|
|
91
93
|
}
|
|
92
94
|
await save(path, { completed: record })
|
package/acent/scripts/hook.mjs
CHANGED
|
@@ -23,6 +23,17 @@ try {
|
|
|
23
23
|
const session = payload.session_id || payload.conversation_id || payload.conversationId
|
|
24
24
|
if (typeof session !== "string" || !session.trim())
|
|
25
25
|
throw new Error("Hook is missing a conversation identifier")
|
|
26
|
+
// The host delivers this context to the turn that made the Bridge call.
|
|
27
|
+
if (process.argv.includes("Codex") &&
|
|
28
|
+
payload.hook_event_name === "PostToolUse" &&
|
|
29
|
+
/^mcp__acent__acent_bridge_[a-z_]+$/.test(payload.tool_name ?? "") &&
|
|
30
|
+
typeof payload.model === "string" && /^[\w][\w.:/-]{0,159}$/.test(payload.model) &&
|
|
31
|
+
!/^(?:auto|default|unknown)$/i.test(payload.model)) {
|
|
32
|
+
process.stdout.write(JSON.stringify({ hookSpecificOutput: {
|
|
33
|
+
hookEventName: "PostToolUse",
|
|
34
|
+
additionalContext: `Codex reports ${payload.model} as the coordinating model for this turn. Use it for this turn's direct-work row in the Acent Bridge report.`,
|
|
35
|
+
} }) + "\n")
|
|
36
|
+
}
|
|
26
37
|
await main(["collect", ...process.argv.slice(2),
|
|
27
38
|
...(folder ? ["--folder", folder] : ["--general"])], text)
|
|
28
39
|
|