@cirtium/acent-connect 1.1.2 → 1.1.3
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 +31 -12
- package/acent/scripts/bridge.mjs +68 -13
- package/acent/scripts/capture-activity.mjs +5 -3
- package/acent/scripts/mcp-proxy.mjs +17 -1
- package/acent/skills/acent-bridge/SKILL.md +15 -2
- package/antigravity/plugin.json +1 -1
- package/package.json +1 -1
|
@@ -308,6 +308,48 @@ export async function drain(config, directory) {
|
|
|
308
308
|
}
|
|
309
309
|
})
|
|
310
310
|
}
|
|
311
|
+
export async function queueManagedCapture(config, directory, policy, events, at = Date.now()) {
|
|
312
|
+
if (!events.length) return
|
|
313
|
+
const credentials = await readCredentials(directory)
|
|
314
|
+
if (!credentials.client_id || credentials.client_id.startsWith("ac_private_client_") ||
|
|
315
|
+
credentials.captureBlocked ||
|
|
316
|
+
!credentials.scope?.split(" ").includes("conversation:write")) return
|
|
317
|
+
const queue = join(directory, "managed-queue", hash(credentials.client_id))
|
|
318
|
+
await mkdir(queue, { recursive: true, mode: 0o700 })
|
|
319
|
+
const packets = events.map(event => ({
|
|
320
|
+
...capturePayload(event, policy.code === true, policy.activity === true),
|
|
321
|
+
acent_destination: policy.destination,
|
|
322
|
+
}))
|
|
323
|
+
const eventBytes = packets.reduce((sum, event) => {
|
|
324
|
+
const bytes = Buffer.byteLength(JSON.stringify(event))
|
|
325
|
+
if (bytes > 2 * 1024 * 1024) throw new Error("Collected event exceeds 2 MiB.")
|
|
326
|
+
return sum + bytes
|
|
327
|
+
}, 0)
|
|
328
|
+
async function capacityError() {
|
|
329
|
+
const files = (await readdir(queue)).filter(file => file.endsWith(".json"))
|
|
330
|
+
if (files.length + packets.length > 500) return "Capture queue is full."
|
|
331
|
+
const sizes = await Promise.all(files.map(file =>
|
|
332
|
+
stat(join(queue, file)).catch(error => {
|
|
333
|
+
if (error.code === "ENOENT") return { size: 0 }
|
|
334
|
+
throw error
|
|
335
|
+
})
|
|
336
|
+
))
|
|
337
|
+
if (sizes.reduce((sum, file) => sum + file.size, eventBytes) > 32 * 1024 * 1024)
|
|
338
|
+
return "Capture queue exceeds 32 MiB."
|
|
339
|
+
}
|
|
340
|
+
if (await capacityError()) {
|
|
341
|
+
await drain(config, directory)
|
|
342
|
+
const error = await capacityError()
|
|
343
|
+
if (error) throw new Error(error + " Retry after pending events are sent.")
|
|
344
|
+
}
|
|
345
|
+
for (const packet of packets) {
|
|
346
|
+
const bridgeId = packet.hook_event_name === "AcentBridge"
|
|
347
|
+
? packet.acent_code_changes?.[0]?.id ?? packet.acent_activity?.[0]?.id
|
|
348
|
+
: null
|
|
349
|
+
const key = bridgeId ? hash(JSON.stringify([packet.acent_destination, packet.session_id, bridgeId])) : random()
|
|
350
|
+
await atomicJson(join(queue, `${at}-${key}.json`), packet)
|
|
351
|
+
}
|
|
352
|
+
}
|
|
311
353
|
function openBrowser(url) {
|
|
312
354
|
const command =
|
|
313
355
|
process.platform === "darwin"
|
|
@@ -459,32 +501,7 @@ export async function main(args = process.argv.slice(2), eventText) {
|
|
|
459
501
|
...toolActivities.map(record => ({ ...payload, acent_code_changes: undefined, acent_activity: [record] })),
|
|
460
502
|
]
|
|
461
503
|
: [payload]
|
|
462
|
-
|
|
463
|
-
throw new Error("Collected event exceeds 2 MiB.")
|
|
464
|
-
const queue = join(directory, "managed-queue", hash(credentials.client_id))
|
|
465
|
-
await mkdir(queue, { recursive: true, mode: 0o700 })
|
|
466
|
-
const packets = events.map(event => ({ ...capturePayload(event, code, activity), acent_destination: policy.destination }))
|
|
467
|
-
const eventBytes = packets.reduce((sum, event) => sum + Buffer.byteLength(JSON.stringify(event)), 0)
|
|
468
|
-
async function capacityError() {
|
|
469
|
-
const files = (await readdir(queue)).filter(file => file.endsWith(".json"))
|
|
470
|
-
if (files.length + events.length > 500) return "Capture queue is full."
|
|
471
|
-
const sizes = await Promise.all(files.map(file =>
|
|
472
|
-
stat(join(queue, file)).catch(error => {
|
|
473
|
-
if (error.code === "ENOENT") return { size: 0 }
|
|
474
|
-
throw error
|
|
475
|
-
})
|
|
476
|
-
))
|
|
477
|
-
if (sizes.reduce((sum, file) => sum + file.size, eventBytes) > 32 * 1024 * 1024)
|
|
478
|
-
return "Capture queue exceeds 32 MiB."
|
|
479
|
-
}
|
|
480
|
-
if (await capacityError()) {
|
|
481
|
-
await drain(config, directory)
|
|
482
|
-
const error = await capacityError()
|
|
483
|
-
if (error) throw new Error(error + " Retry after pending events are sent.")
|
|
484
|
-
}
|
|
485
|
-
for (const event of packets) await atomicJson(
|
|
486
|
-
join(queue, `${Date.now()}-${random()}.json`), event
|
|
487
|
-
)
|
|
504
|
+
await queueManagedCapture(config, directory, policy, events)
|
|
488
505
|
return drain(config, directory)
|
|
489
506
|
}
|
|
490
507
|
if (config.command === "flush") {
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { createHash } from "node:crypto"
|
|
2
|
+
import { redactActivity } from "./capture-activity.mjs"
|
|
3
|
+
import { delegateWorkspacePath } from "./bridge-workspace.mjs"
|
|
4
|
+
|
|
5
|
+
const hash = (parts) => createHash("sha256").update(JSON.stringify(parts)).digest("hex")
|
|
6
|
+
const iso = (at) => new Date(at).toISOString()
|
|
7
|
+
const empty = { text: null, truncated: false }
|
|
8
|
+
const modelName = (value) =>
|
|
9
|
+
typeof value === "string" && value.trim() ? value.trim().slice(0, 200) : null
|
|
10
|
+
const versionHash = (version) =>
|
|
11
|
+
/^[x-]:[a-f0-9]{64}$/.test(version) ? version.slice(2) : null
|
|
12
|
+
|
|
13
|
+
function contributor(job) {
|
|
14
|
+
return {
|
|
15
|
+
taskId: job.id,
|
|
16
|
+
...(job.attempt && { attemptId: job.attempt }),
|
|
17
|
+
tool: job.tool,
|
|
18
|
+
actualModel: modelName(job.actualModel),
|
|
19
|
+
requestedModel: modelName(job.model),
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function bridgeChangeContributors(job, changes, beforeAttempt) {
|
|
24
|
+
const previous = new Map((job.changes ?? []).map((change) => [change.path, change.after]))
|
|
25
|
+
return Object.fromEntries(changes.map(({ path, before, after }) => {
|
|
26
|
+
const start = beforeAttempt ? beforeAttempt[path] ?? null : before
|
|
27
|
+
const prior = start !== before && previous.get(path) === start
|
|
28
|
+
? job.changeContributors?.[path] ?? []
|
|
29
|
+
: []
|
|
30
|
+
return [path, start === after ? prior : [...prior, contributor(job)].slice(-8)]
|
|
31
|
+
}))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function edits({ id, phase, changes, patch, jobs, at, job, result }) {
|
|
35
|
+
// Git reports --name-only and emits --no-renames patches in the same order.
|
|
36
|
+
const chunks = patch?.split(/(?=^diff --git )/m) ?? []
|
|
37
|
+
const aligned = chunks.length === changes.length && chunks.every((chunk) => chunk.startsWith("diff --git "))
|
|
38
|
+
const callId = `bridge:${id}:${phase}`
|
|
39
|
+
return changes.flatMap(({ path, before, after }, index) => {
|
|
40
|
+
if (!delegateWorkspacePath(path) || path.split("/").some((part) => /^(?:\.ssh|\.aws|\.env(?:\..*)?)$/i.test(part)) ||
|
|
41
|
+
/\.(?:pfx|p12)$/i.test(path)) return []
|
|
42
|
+
const raw = aligned ? chunks[index] : null
|
|
43
|
+
const binary = raw && /^(?:GIT binary patch|Binary files .+ differ)$/m.test(raw)
|
|
44
|
+
const oversized = raw && Buffer.byteLength(raw) > 262144
|
|
45
|
+
const diff = raw && !binary && !oversized ? redactActivity(raw, 262144).text : null
|
|
46
|
+
return [{
|
|
47
|
+
id: hash([callId, path]),
|
|
48
|
+
path,
|
|
49
|
+
diff,
|
|
50
|
+
status: diff ? "captured" : binary ? "binary" : oversized ? "oversized" : "diff_failed",
|
|
51
|
+
basis: "before_after",
|
|
52
|
+
beforeHash: versionHash(before),
|
|
53
|
+
afterHash: versionHash(after),
|
|
54
|
+
beforeExists: before !== null,
|
|
55
|
+
afterExists: after !== null,
|
|
56
|
+
callId,
|
|
57
|
+
capturedAt: iso(at),
|
|
58
|
+
request: null,
|
|
59
|
+
agentNote: redactActivity(job?.task ?? result?.task, 4000).text,
|
|
60
|
+
toolFailed: false,
|
|
61
|
+
attribution: "observed_during_tool",
|
|
62
|
+
bridge: {
|
|
63
|
+
contributors: jobs
|
|
64
|
+
.filter((job) => job.changes?.some((change) => change.path === path))
|
|
65
|
+
.flatMap((job) => job.changeContributors
|
|
66
|
+
? job.changeContributors[path] ?? []
|
|
67
|
+
: job.history?.length ? [] : [contributor(job)])
|
|
68
|
+
.slice(-8),
|
|
69
|
+
...(diff && raw !== diff ? { redacted: true } : {}),
|
|
70
|
+
},
|
|
71
|
+
}]
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function bridgeCaptureEvents(evidence, policy) {
|
|
76
|
+
const { id, phase, status, at, attempt, job, result } = evidence
|
|
77
|
+
const session = `bridge:${id}`
|
|
78
|
+
const envelope = {
|
|
79
|
+
session_id: session,
|
|
80
|
+
conversation_id: session,
|
|
81
|
+
conversationId: session,
|
|
82
|
+
hook_event_name: "AcentBridge",
|
|
83
|
+
}
|
|
84
|
+
const changes = policy.code && evidence.changes ? edits(evidence) : []
|
|
85
|
+
const packets = changes.map((change) => ({ ...envelope, acent_code_changes: [change] }))
|
|
86
|
+
if (!policy.activity) return packets
|
|
87
|
+
const callId = `bridge:${id}:${phase}`
|
|
88
|
+
const outcome = ["applied", "completed", "verified", "no_changes"].includes(status)
|
|
89
|
+
? "succeeded"
|
|
90
|
+
: ["needs_context", "changes_requested", "cancelled", "expired"].includes(status)
|
|
91
|
+
? "unknown"
|
|
92
|
+
: "failed"
|
|
93
|
+
const details = {
|
|
94
|
+
status,
|
|
95
|
+
...(job && { worker: contributor(job), task: job.task, summary: job.summary, findings: job.findings }),
|
|
96
|
+
...result,
|
|
97
|
+
}
|
|
98
|
+
const editIds = changes.map(({ id }) => id)
|
|
99
|
+
// Keep each batch within the existing activity-to-changes link limit.
|
|
100
|
+
for (let index = 0; index < Math.max(1, editIds.length); index += 32) {
|
|
101
|
+
packets.push({
|
|
102
|
+
...envelope,
|
|
103
|
+
acent_activity: [{
|
|
104
|
+
id: hash([callId, attempt ?? status, index]),
|
|
105
|
+
callId,
|
|
106
|
+
name: `Acent Bridge · ${phase} · ${status}`,
|
|
107
|
+
kind: "integration",
|
|
108
|
+
status: outcome,
|
|
109
|
+
capturedAt: iso(at),
|
|
110
|
+
startedAt: null,
|
|
111
|
+
durationMs: null,
|
|
112
|
+
request: null,
|
|
113
|
+
input: empty,
|
|
114
|
+
output: policy.code ? redactActivity(details) : empty,
|
|
115
|
+
changeIds: editIds.slice(index, index + 32),
|
|
116
|
+
}],
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
return packets
|
|
120
|
+
}
|
|
@@ -50,6 +50,15 @@ export function bridgeCheckPlan({ commands, setupCommands }) {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
const checkName = ({ command, args }) =>
|
|
54
|
+
[command, ...args].join(" ").slice(0, 1500)
|
|
55
|
+
|
|
56
|
+
export function bridgeChecksNotRun(commands = [], results = [], setup = []) {
|
|
57
|
+
const failed = ({ outcome }) => outcome === "failed"
|
|
58
|
+
if (!results.some(failed) && !setup.some(failed)) return []
|
|
59
|
+
return commands.slice(results.length).map(checkName)
|
|
60
|
+
}
|
|
61
|
+
|
|
53
62
|
async function readCheckFile(path) {
|
|
54
63
|
try {
|
|
55
64
|
return JSON.parse(await readFile(path, "utf8"))
|
|
@@ -182,7 +191,8 @@ async function runCheckCommands(request, directory, signal) {
|
|
|
182
191
|
XDG_CACHE_HOME: join(scratch, "cache"),
|
|
183
192
|
npm_config_cache: join(scratch, "npm"),
|
|
184
193
|
}
|
|
185
|
-
async function runCheck(
|
|
194
|
+
async function runCheck(check) {
|
|
195
|
+
const { command, args } = check
|
|
186
196
|
let deadline
|
|
187
197
|
const run = runProcess(sandbox, [...prefix, command, ...args], {
|
|
188
198
|
cwd,
|
|
@@ -204,7 +214,7 @@ async function runCheckCommands(request, directory, signal) {
|
|
|
204
214
|
]).finally(() => clearTimeout(deadline))
|
|
205
215
|
const outcome = result.code === 0 && !result.failure ? "passed" : "failed"
|
|
206
216
|
return {
|
|
207
|
-
name:
|
|
217
|
+
name: checkName(check),
|
|
208
218
|
outcome,
|
|
209
219
|
evidence: [
|
|
210
220
|
result.failure ?? `Exit code ${result.code}`,
|
|
@@ -4,8 +4,10 @@ import { join } from "node:path"
|
|
|
4
4
|
import {
|
|
5
5
|
bridgeCheckPlan,
|
|
6
6
|
bridgeCheckState,
|
|
7
|
+
bridgeChecksNotRun,
|
|
7
8
|
startBridgeCheckWorker,
|
|
8
9
|
} from "./bridge-checks.mjs"
|
|
10
|
+
import { bridgeReviewResult } from "./bridge-review-result.mjs"
|
|
9
11
|
import {
|
|
10
12
|
appliedBridgeChanges,
|
|
11
13
|
bridgeFileVersions,
|
|
@@ -67,7 +69,12 @@ export function createBridgeFinalizer({
|
|
|
67
69
|
if (paths.length) return { status: "review_scope_incomplete", ids, paths }
|
|
68
70
|
}
|
|
69
71
|
|
|
70
|
-
const base = {
|
|
72
|
+
const base = {
|
|
73
|
+
ids: taskIds,
|
|
74
|
+
reviewId,
|
|
75
|
+
reviewSummary: review.summary,
|
|
76
|
+
reviewResult: bridgeReviewResult(review),
|
|
77
|
+
}
|
|
71
78
|
let stored = await readJson(record, null)
|
|
72
79
|
if (stored?.version !== 2) stored = null
|
|
73
80
|
const sameTasks = JSON.stringify(stored?.ids) === JSON.stringify(taskIds)
|
|
@@ -77,6 +84,7 @@ export function createBridgeFinalizer({
|
|
|
77
84
|
const publicResult = ({
|
|
78
85
|
status,
|
|
79
86
|
checks,
|
|
87
|
+
plan: checkPlan,
|
|
80
88
|
setup,
|
|
81
89
|
details,
|
|
82
90
|
paths,
|
|
@@ -85,6 +93,7 @@ export function createBridgeFinalizer({
|
|
|
85
93
|
...base,
|
|
86
94
|
status,
|
|
87
95
|
checks,
|
|
96
|
+
checksNotRun: bridgeChecksNotRun(checkPlan?.commands, checks, setup),
|
|
88
97
|
setup,
|
|
89
98
|
details,
|
|
90
99
|
paths,
|
|
@@ -3,9 +3,11 @@ import { mkdir } from "node:fs/promises"
|
|
|
3
3
|
import { join } from "node:path"
|
|
4
4
|
import { setTimeout } from "node:timers"
|
|
5
5
|
import { modelFamily } from "./bridge-runners.mjs"
|
|
6
|
+
import { bridgeReviewResult } from "./bridge-review-result.mjs"
|
|
6
7
|
import {
|
|
7
8
|
bridgeCheckPlan,
|
|
8
9
|
bridgeCheckState,
|
|
10
|
+
bridgeChecksNotRun,
|
|
9
11
|
startBridgeCheckWorker,
|
|
10
12
|
} from "./bridge-checks.mjs"
|
|
11
13
|
import {
|
|
@@ -192,7 +194,57 @@ const waitingForCoordinator = (cycle) =>
|
|
|
192
194
|
cycle.waiting.length > 0 &&
|
|
193
195
|
!cycle.waiting.some(({ status }) => retryableWaits.has(status))
|
|
194
196
|
|
|
195
|
-
function publicCycle(cycle) {
|
|
197
|
+
async function publicCycle(cycle, getJob, jobState) {
|
|
198
|
+
const waiting = new Map(cycle.waiting.map(({ id, status }) => [id, status]))
|
|
199
|
+
async function describeReview(review, status) {
|
|
200
|
+
const job = await getJob(review.id)
|
|
201
|
+
if (job) return bridgeReviewResult(job, status ?? jobState(job))
|
|
202
|
+
if (status === "completed") return bridgeReviewResult(review, status)
|
|
203
|
+
return {
|
|
204
|
+
...bridgeReviewResult(review, "not_run"),
|
|
205
|
+
...(status ? { reason: status } : {}),
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
async function reviewsInRound(round, reviews) {
|
|
209
|
+
const replaced = (cycle.replacedReviews ?? []).filter(
|
|
210
|
+
(review) => review.round === round
|
|
211
|
+
)
|
|
212
|
+
return Promise.all([
|
|
213
|
+
...replaced.map(async (review) => ({
|
|
214
|
+
...(await describeReview(review, review.status)),
|
|
215
|
+
replaced: true,
|
|
216
|
+
})),
|
|
217
|
+
...reviews,
|
|
218
|
+
])
|
|
219
|
+
}
|
|
220
|
+
const [reviewResults, history] = await Promise.all([
|
|
221
|
+
reviewsInRound(
|
|
222
|
+
cycle.round,
|
|
223
|
+
cycle.reviews.map((review) =>
|
|
224
|
+
describeReview(review, waiting.get(review.id))
|
|
225
|
+
)
|
|
226
|
+
),
|
|
227
|
+
Promise.all(
|
|
228
|
+
cycle.history.map(async ({ round, reviewIds, repairId, findings }) => ({
|
|
229
|
+
round,
|
|
230
|
+
reviewIds,
|
|
231
|
+
repairId,
|
|
232
|
+
reviewResults: await reviewsInRound(
|
|
233
|
+
round,
|
|
234
|
+
reviewIds.map((id) => describeReview({ id }, "completed"))
|
|
235
|
+
),
|
|
236
|
+
findings: findings.map(
|
|
237
|
+
({ path, line, issue, severity, reviewerIds }) => ({
|
|
238
|
+
path,
|
|
239
|
+
line,
|
|
240
|
+
issue,
|
|
241
|
+
severity,
|
|
242
|
+
reviewerIds,
|
|
243
|
+
})
|
|
244
|
+
),
|
|
245
|
+
}))
|
|
246
|
+
),
|
|
247
|
+
])
|
|
196
248
|
return {
|
|
197
249
|
id: cycle.id,
|
|
198
250
|
status:
|
|
@@ -204,25 +256,14 @@ function publicCycle(cycle) {
|
|
|
204
256
|
repairsApplied: cycle.repairsApplied,
|
|
205
257
|
reviews: cycle.reviews.map(({ id, tool, model }) => ({ id, tool, model })),
|
|
206
258
|
repairId: cycle.repairId,
|
|
207
|
-
history
|
|
208
|
-
|
|
209
|
-
reviewIds,
|
|
210
|
-
repairId,
|
|
211
|
-
findings: findings.map(
|
|
212
|
-
({ path, line, issue, severity, reviewerIds }) => ({
|
|
213
|
-
path,
|
|
214
|
-
line,
|
|
215
|
-
issue,
|
|
216
|
-
severity,
|
|
217
|
-
reviewerIds,
|
|
218
|
-
})
|
|
219
|
-
),
|
|
220
|
-
})),
|
|
259
|
+
history,
|
|
260
|
+
reviewResults,
|
|
221
261
|
findings: cycle.findings,
|
|
222
262
|
waiting: cycle.waiting,
|
|
223
263
|
patchPath: cycle.patchPath,
|
|
224
264
|
details: cycle.details,
|
|
225
265
|
checks: cycle.checks,
|
|
266
|
+
checksNotRun: bridgeChecksNotRun(cycle.commands, cycle.checks, cycle.setup),
|
|
226
267
|
setup: cycle.setup,
|
|
227
268
|
checkRevision: ["needs_checks", "checks_failed", "patch_ready"].includes(
|
|
228
269
|
cycle.status
|
|
@@ -268,6 +309,18 @@ export function createBridgeRefinement({
|
|
|
268
309
|
select,
|
|
269
310
|
cancelJob,
|
|
270
311
|
} = operations
|
|
312
|
+
const checkResults = (cycle) => cycle.checks?.map(({ name, outcome }) => ({ name, outcome }))
|
|
313
|
+
const respond = async (cycle) => {
|
|
314
|
+
const result = await publicCycle(cycle, getJob, jobState)
|
|
315
|
+
if (settings.captureEvidence &&
|
|
316
|
+
["checks_failed", "changes_requested", "cancelled", "expired"].includes(result.status))
|
|
317
|
+
await settings.captureEvidence({
|
|
318
|
+
id: cycle.id, phase: "refine", status: result.status, at: Date.now(),
|
|
319
|
+
attempt: `${cycle.round}:${cycle.checkAttempt ?? ""}:${result.status}`,
|
|
320
|
+
result: { reviews: result.reviewResults, findings: result.findings, checks: checkResults(cycle) },
|
|
321
|
+
})
|
|
322
|
+
return result
|
|
323
|
+
}
|
|
271
324
|
const action = args.action ?? "status"
|
|
272
325
|
if (
|
|
273
326
|
![
|
|
@@ -722,6 +775,12 @@ export function createBridgeRefinement({
|
|
|
722
775
|
throw new Error(
|
|
723
776
|
"Select an available replacement from the Bridge candidate list."
|
|
724
777
|
)
|
|
778
|
+
cycle.replacedReviews ??= []
|
|
779
|
+
cycle.replacedReviews.push({
|
|
780
|
+
...cycle.reviews[index],
|
|
781
|
+
round: cycle.round,
|
|
782
|
+
status: failure,
|
|
783
|
+
})
|
|
725
784
|
cycle.reviews[index] = { id: randomUUID(), tool, model }
|
|
726
785
|
cycle.waiting = cycle.waiting.filter(({ id }) => id !== args.reviewId)
|
|
727
786
|
await save(cycle)
|
|
@@ -836,7 +895,8 @@ export function createBridgeRefinement({
|
|
|
836
895
|
}
|
|
837
896
|
|
|
838
897
|
async function apply(cycle) {
|
|
839
|
-
|
|
898
|
+
const current = await allowed(cycle)
|
|
899
|
+
if (!current) return
|
|
840
900
|
await lockWorkspace(async () => {
|
|
841
901
|
if (await cancellationRequested()) return
|
|
842
902
|
if (await preparingWorkspace()) {
|
|
@@ -845,6 +905,7 @@ export function createBridgeRefinement({
|
|
|
845
905
|
}
|
|
846
906
|
const expected = await expectedFiles(cycle)
|
|
847
907
|
const actual = await originalVersions()
|
|
908
|
+
const change = cycle.patchPath ? await readJson(cycle.patchPath, null) : null
|
|
848
909
|
// A restarted process can recognize the exact patch it previously started applying.
|
|
849
910
|
if (
|
|
850
911
|
!cycle.applying ||
|
|
@@ -853,7 +914,6 @@ export function createBridgeRefinement({
|
|
|
853
914
|
if (stale(cycle, expected.original, actual)) return
|
|
854
915
|
if (!(await checkDependencies(cycle, folder))) return
|
|
855
916
|
if (cycle.patchPath) {
|
|
856
|
-
const change = await readJson(cycle.patchPath, null)
|
|
857
917
|
if (!change || patchDigest(change) !== cycle.patchDigest) {
|
|
858
918
|
cycle.status = "changes_requested"
|
|
859
919
|
cycle.details = { reason: "verified_patch_unavailable" }
|
|
@@ -888,6 +948,17 @@ export function createBridgeRefinement({
|
|
|
888
948
|
await lock(promotionGate, async () => {
|
|
889
949
|
if (!cycle.applying && (await cancellationRequested())) return
|
|
890
950
|
cycle.status = "verified"
|
|
951
|
+
const at = Date.now()
|
|
952
|
+
if (current.captureEvidence) {
|
|
953
|
+
const jobs = await Promise.all(cycle.history
|
|
954
|
+
.filter(({ repairId }) => repairId)
|
|
955
|
+
.map(({ repairId }) => getJob(repairId)))
|
|
956
|
+
await current.captureEvidence({
|
|
957
|
+
id: cycle.id, phase: "refine", status: "verified", at,
|
|
958
|
+
changes: change?.changes, patch: change?.patch, jobs: jobs.filter(Boolean),
|
|
959
|
+
result: { task: cycle.input.task, reviews: cycle.reviews, checks: checkResults(cycle) },
|
|
960
|
+
})
|
|
961
|
+
}
|
|
891
962
|
cycle.patchPath = undefined
|
|
892
963
|
await save(cycle)
|
|
893
964
|
})
|
|
@@ -950,9 +1021,9 @@ export function createBridgeRefinement({
|
|
|
950
1021
|
if (
|
|
951
1022
|
["verified", "cancelled", "expired", "applying"].includes(value.status)
|
|
952
1023
|
)
|
|
953
|
-
return
|
|
1024
|
+
return respond(value)
|
|
954
1025
|
schedule(value, true)
|
|
955
|
-
return
|
|
1026
|
+
return respond({ ...value, status: "cancelling" })
|
|
956
1027
|
}
|
|
957
1028
|
if (action === "status") {
|
|
958
1029
|
const active = await readJson(record, null)
|
|
@@ -962,14 +1033,14 @@ export function createBridgeRefinement({
|
|
|
962
1033
|
(await cancellationRequested())
|
|
963
1034
|
) {
|
|
964
1035
|
schedule(active, true)
|
|
965
|
-
return
|
|
1036
|
+
return respond({ ...active, status: "cancelling" })
|
|
966
1037
|
}
|
|
967
1038
|
if (
|
|
968
1039
|
timers.has(record) &&
|
|
969
1040
|
active?.status === "running" &&
|
|
970
1041
|
active.phase === "checks"
|
|
971
1042
|
)
|
|
972
|
-
return
|
|
1043
|
+
return respond(active)
|
|
973
1044
|
}
|
|
974
1045
|
const cycle = await lock(directory, async () => {
|
|
975
1046
|
let value = await readJson(record, null)
|
|
@@ -1077,6 +1148,6 @@ export function createBridgeRefinement({
|
|
|
1077
1148
|
return value
|
|
1078
1149
|
})
|
|
1079
1150
|
schedule(cycle)
|
|
1080
|
-
return
|
|
1151
|
+
return respond(cycle)
|
|
1081
1152
|
}
|
|
1082
1153
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function bridgeReviewResult(review, status = review.status) {
|
|
2
|
+
const { id, tool, model, actualModel, findings } = review
|
|
3
|
+
const result = { id, tool, model, actualModel, status }
|
|
4
|
+
if (status !== "completed") return result
|
|
5
|
+
|
|
6
|
+
if (!Array.isArray(findings)) return { ...result, outcome: "unclassified" }
|
|
7
|
+
return {
|
|
8
|
+
...result,
|
|
9
|
+
outcome: findings.length ? "findings_reported" : "no_findings",
|
|
10
|
+
findings,
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -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
|
: []
|
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
|
+
"Report Bridge results in the user's language. Start the Bridge section with a bold Acent Bridge label and the observed status, then list the participating tools and their roles or tasks in short bullets. Put the confirmed execution model in parentheses after the tool name. Prefer actualModel and omit the model if only a requested model is known.",
|
|
295
|
+
"For cross-validation or multiple tasks, follow with a Markdown table with one row per task, reviewer, or check and columns for agent or check, scope, outcome, and findings or evidence. 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")
|
|
@@ -836,6 +856,9 @@ export function createBridge({
|
|
|
836
856
|
baseline.scopes ?? delegateScopes(job)
|
|
837
857
|
))
|
|
838
858
|
const target = invalidWorkspace ? {} : await getTarget(job.tool, folder)
|
|
859
|
+
const beforeAttempt = !prepare && !invalidWorkspace && !reviewOnly(job.kind)
|
|
860
|
+
? await projectFileVersions(work, job.paths.length ? job.paths : undefined)
|
|
861
|
+
: null
|
|
839
862
|
await cancelled()
|
|
840
863
|
let result
|
|
841
864
|
if (abort.signal.aborted) result = { failure: "cancelled" }
|
|
@@ -861,9 +884,10 @@ export function createBridge({
|
|
|
861
884
|
job.status = abort.signal.aborted
|
|
862
885
|
? "cancelled"
|
|
863
886
|
: (result.failure ?? (question ? "needs_context" : "completed"))
|
|
864
|
-
if (job.
|
|
865
|
-
job.findings = reviewFindings(job.summary)
|
|
866
|
-
if (!job.findings
|
|
887
|
+
if (job.kind === "review" && job.status === "completed") {
|
|
888
|
+
job.findings = reviewFindings(job.summary) ?? undefined
|
|
889
|
+
if (!job.findings && job.structuredReview)
|
|
890
|
+
job.status = "invalid_review"
|
|
867
891
|
}
|
|
868
892
|
job.actualModel = result.actualModel
|
|
869
893
|
if (
|
|
@@ -907,6 +931,7 @@ export function createBridge({
|
|
|
907
931
|
mode: 0o600,
|
|
908
932
|
})
|
|
909
933
|
job.patchBytes = Buffer.byteLength(changes.patch)
|
|
934
|
+
job.changeContributors = bridgeChangeContributors(job, changes.changes, beforeAttempt)
|
|
910
935
|
job.changes = changes.changes
|
|
911
936
|
if (job.status === "completed" && !changes.patch)
|
|
912
937
|
job.status = "no_changes"
|
|
@@ -990,13 +1015,17 @@ export function createBridge({
|
|
|
990
1015
|
entries.filter((item) => item.attempt !== attempt)
|
|
991
1016
|
)
|
|
992
1017
|
})
|
|
1018
|
+
if (captureEvidence) await captureEvidence({
|
|
1019
|
+
id: job.id, phase: job.kind, status: job.status, at: job.finishedAt,
|
|
1020
|
+
attempt, job,
|
|
1021
|
+
})
|
|
993
1022
|
}
|
|
994
1023
|
})()
|
|
995
1024
|
task.catch(() => {})
|
|
996
1025
|
return { id: job.id, status: "running", tool: job.tool, model: job.model }
|
|
997
1026
|
}
|
|
998
1027
|
|
|
999
|
-
async function integrate(folder, projectDir, coordination, ids, apply) {
|
|
1028
|
+
async function integrate(folder, projectDir, coordination, ids, apply, captureEvidence) {
|
|
1000
1029
|
if (!safeIds(ids) || (apply !== undefined && typeof apply !== "boolean"))
|
|
1001
1030
|
throw new Error("Select one to four completed Bridge task IDs.")
|
|
1002
1031
|
return withWorkspaceLock(coordination, async () => {
|
|
@@ -1053,7 +1082,17 @@ export function createBridge({
|
|
|
1053
1082
|
if (overlaps.length)
|
|
1054
1083
|
return { status: "patch_overlap", paths: [...new Set(overlaps)] }
|
|
1055
1084
|
const paths = changes.map((change) => change.path)
|
|
1085
|
+
const captureApplied = async (at) => {
|
|
1086
|
+
if (!captureEvidence) return
|
|
1087
|
+
for (const { job, directory } of records)
|
|
1088
|
+
await captureEvidence({
|
|
1089
|
+
id: job.id, phase: "apply", status: "applied", at, job,
|
|
1090
|
+
patch: await readFile(join(directory, "changes.patch"), "utf8").catch(() => ""),
|
|
1091
|
+
changes: job.changes ?? [], jobs: [job],
|
|
1092
|
+
})
|
|
1093
|
+
}
|
|
1056
1094
|
if (receipt?.status === "applied") {
|
|
1095
|
+
if (apply) await captureApplied(receipt.appliedAt)
|
|
1057
1096
|
const conflicts = await mismatchedBridgePaths(folder, changes)
|
|
1058
1097
|
return conflicts.length
|
|
1059
1098
|
? { status: "working_copy_changed", paths: conflicts }
|
|
@@ -1068,6 +1107,7 @@ export function createBridge({
|
|
|
1068
1107
|
appliedAt,
|
|
1069
1108
|
})
|
|
1070
1109
|
await writeJson(receiptPath, { status: "applied", paths, appliedAt })
|
|
1110
|
+
await captureApplied(appliedAt)
|
|
1071
1111
|
return {
|
|
1072
1112
|
status: "applied",
|
|
1073
1113
|
ids,
|
|
@@ -1201,6 +1241,8 @@ export function createBridge({
|
|
|
1201
1241
|
rm(stageDir, { recursive: true, force: true }),
|
|
1202
1242
|
launch: async (task, currentSettings, snapshot) => {
|
|
1203
1243
|
const available = await candidates(task, folder, currentSettings)
|
|
1244
|
+
if (available.loginRequiredTools?.includes(task.tool))
|
|
1245
|
+
return { status: "login_required" }
|
|
1204
1246
|
if (
|
|
1205
1247
|
!available.candidates.some(
|
|
1206
1248
|
({ tool, model }) => tool === task.tool && model === task.model
|
|
@@ -1222,7 +1264,8 @@ export function createBridge({
|
|
|
1222
1264
|
projectDir,
|
|
1223
1265
|
coordination,
|
|
1224
1266
|
true,
|
|
1225
|
-
snapshot && (await snapshot())
|
|
1267
|
+
snapshot && (await snapshot()),
|
|
1268
|
+
settings.captureEvidence
|
|
1226
1269
|
)
|
|
1227
1270
|
},
|
|
1228
1271
|
readRepairPatch: (id) =>
|
|
@@ -1243,9 +1286,18 @@ export function createBridge({
|
|
|
1243
1286
|
},
|
|
1244
1287
|
})
|
|
1245
1288
|
if (name === "acent_bridge_integrate")
|
|
1246
|
-
return integrate(folder, projectDir, coordination, args.ids, args.apply)
|
|
1247
|
-
if (name === "acent_bridge_finalize")
|
|
1248
|
-
|
|
1289
|
+
return integrate(folder, projectDir, coordination, args.ids, args.apply, settings.captureEvidence)
|
|
1290
|
+
if (name === "acent_bridge_finalize") {
|
|
1291
|
+
const result = await finalize(folder, projectDir, coordination, args)
|
|
1292
|
+
if (settings.captureEvidence && result.checkedAt)
|
|
1293
|
+
await settings.captureEvidence({
|
|
1294
|
+
id: args.reviewId, phase: "verify", status: result.status, at: result.checkedAt,
|
|
1295
|
+
attempt: result.checkedAt,
|
|
1296
|
+
result: { review: result.reviewResult, checks: result.checks?.map(({ name, outcome }) => ({ name, outcome })),
|
|
1297
|
+
checksNotRun: result.checksNotRun?.length },
|
|
1298
|
+
})
|
|
1299
|
+
return result
|
|
1300
|
+
}
|
|
1249
1301
|
if (name === "acent_bridge_activity") {
|
|
1250
1302
|
const entries = await readdir(projectDir).catch((error) => {
|
|
1251
1303
|
if (error.code === "ENOENT") return []
|
|
@@ -1364,7 +1416,7 @@ export function createBridge({
|
|
|
1364
1416
|
: available
|
|
1365
1417
|
if (!reviewOnly(job.kind) && !paths.length)
|
|
1366
1418
|
return { status: "write_scope_required" }
|
|
1367
|
-
return start(job, folder, projectDir, coordination, true)
|
|
1419
|
+
return start(job, folder, projectDir, coordination, true, undefined, settings.captureEvidence)
|
|
1368
1420
|
}
|
|
1369
1421
|
|
|
1370
1422
|
if (typeof args.id !== "string" || !taskId.test(args.id))
|
|
@@ -1418,6 +1470,7 @@ export function createBridge({
|
|
|
1418
1470
|
status,
|
|
1419
1471
|
summary,
|
|
1420
1472
|
findings,
|
|
1473
|
+
...(job.kind === "review" ? { reviewResult: bridgeReviewResult(job) } : {}),
|
|
1421
1474
|
question,
|
|
1422
1475
|
patch,
|
|
1423
1476
|
patchPath,
|
|
@@ -1474,7 +1527,9 @@ export function createBridge({
|
|
|
1474
1527
|
folder,
|
|
1475
1528
|
projectDir,
|
|
1476
1529
|
coordination,
|
|
1477
|
-
false
|
|
1530
|
+
false,
|
|
1531
|
+
undefined,
|
|
1532
|
+
settings.captureEvidence
|
|
1478
1533
|
)
|
|
1479
1534
|
}
|
|
1480
1535
|
}
|
|
@@ -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 })
|
|
@@ -8,6 +8,7 @@ import { connectionContext, createRootsChannel, projectFolder } from "./connecti
|
|
|
8
8
|
import { memoryInstructions } from "./memory-instructions.mjs"
|
|
9
9
|
import { attachmentTool, saveAttachments } from "./capture-attachments.mjs"
|
|
10
10
|
import { bridgeInstructions, bridgeTools, createBridge } from "./bridge.mjs"
|
|
11
|
+
import { bridgeCaptureEvents } from "./bridge-capture.mjs"
|
|
11
12
|
import { createInterface } from "node:readline"
|
|
12
13
|
import { mkdir } from "node:fs/promises"
|
|
13
14
|
import { dirname } from "node:path"
|
|
@@ -19,6 +20,8 @@ import {
|
|
|
19
20
|
accessToken,
|
|
20
21
|
request,
|
|
21
22
|
connect,
|
|
23
|
+
drain,
|
|
24
|
+
queueManagedCapture,
|
|
22
25
|
} from "./acent-connect.mjs"
|
|
23
26
|
const launchArgs = process.argv.slice(2)
|
|
24
27
|
// Hosts can leave workspaceFolder unsubstituted in a projectless window.
|
|
@@ -218,9 +221,22 @@ async function handleLine(line) {
|
|
|
218
221
|
])
|
|
219
222
|
try {
|
|
220
223
|
const access = await accessToken(projectConfig, configDirectory(projectConfig))
|
|
221
|
-
|
|
224
|
+
const settings = await request(projectConfig, "/api/external/bridge", {
|
|
222
225
|
headers: { Authorization: `Bearer ${access}` },
|
|
223
226
|
})
|
|
227
|
+
if (settings.capture?.code || settings.capture?.activity) {
|
|
228
|
+
const directory = configDirectory(projectConfig)
|
|
229
|
+
settings.captureEvidence = async (evidence) => {
|
|
230
|
+
try {
|
|
231
|
+
await queueManagedCapture(projectConfig, directory, settings.capture,
|
|
232
|
+
bridgeCaptureEvents(evidence, settings.capture), evidence.at)
|
|
233
|
+
void drain(projectConfig, directory).catch(() => {})
|
|
234
|
+
} catch {
|
|
235
|
+
console.error("Acent could not queue Bridge history.")
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return settings
|
|
224
240
|
} catch (error) {
|
|
225
241
|
if (needsConnection(error))
|
|
226
242
|
throw new Error("Connect this project folder to Acent before using Bridge.")
|
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: acent-bridge
|
|
3
|
-
description: Acent Bridge delegates work to another coding agent in the current project. Use
|
|
3
|
+
description: Acent Bridge delegates work to another coding agent in the current project. Use for explicit delegation requests and when evaluating automatic delegation for independent implementation tasks, high-impact reviews, or difficult diagnoses.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Acent Bridge
|
|
7
7
|
|
|
8
8
|
Use the Acent Bridge MCP tools in a session with one local project folder open. If the tools are unavailable, tell the user that Bridge is unavailable in the current session.
|
|
9
9
|
|
|
10
|
-
-
|
|
10
|
+
- Check `acent_bridge_settings` while planning work that matches any trigger below. Check as soon as a trigger becomes clear during the task. If the project reports `automatic: true` and a suitable candidate is available, start the matching workflow. Pass `automatic: true` when listing candidates, starting a task, or starting refinement. Honor the user's instructions about delegation. Users can change the setting in the project's Bridge dialog.
|
|
11
|
+
- **Parallel implementation.** Delegate independently verifiable tasks with disjoint write scopes once shared design decisions are settled.
|
|
12
|
+
- **Independent review.** Have a different model family review substantive changes to payments, authorization, privacy, or durable data before reporting completion. The coordinating agent can perform the implementation.
|
|
13
|
+
- **Independent diagnosis.** Delegate a read-only investigation if the cause remains unclear or a fix repeatedly fails.
|
|
14
|
+
- Keep small, straightforward edits and dependent steps with the coordinating agent. Give each shared contract, state machine, or business rule one writer, even when it spans separate files. Finish a prerequisite first or use `dependsOn` when later work needs its result. Use read-only review or diagnosis for independent work when writes need one owner.
|
|
15
|
+
- Keep authorized production actions with the coordinating agent, including deployments, database migrations, and live payments or refunds. Bridge can review the plan or verify the outcome independently.
|
|
16
|
+
- If automatic delegation is disabled, continue directly. If it is enabled and no suitable candidate is available, continue the work you can verify and report why independent work did not run.
|
|
11
17
|
- Classify the work as `implement`, `review`, or `diagnose`. Call `acent_bridge_candidates` and select a returned tool and model that fit the task and the user's preference. For review and diagnosis, pass the verified originating model ID so Bridge can restrict candidates to a different model family. Report when no eligible candidate is available.
|
|
12
18
|
- Use a reported quota snapshot as a tiebreaker among suitable candidates. When a quota is low, favor a lower-usage option if it still fits the task and the user has not pinned a model. Quota windows are provider-specific, and tokens from the last run cannot establish remaining quota.
|
|
13
19
|
- Start with `acent_bridge_start`. Use `paths` for the files to review or the files an implementation may edit. Use `readPaths` for additional context the delegate may read. Include the relevant decisions and how to verify completion. Run up to four independent tasks with disjoint write scopes. Pass `dependsOn` when a task needs the result of earlier work. Review and diagnosis run in read-only mode.
|
|
14
20
|
- Check multiple jobs together with `acent_bridge_activity`, or use `acent_bridge_status` for a patch or a full answer. While jobs run, continue independent work and avoid tight polling. If a delegate requests context, answer with the relevant evidence using `acent_bridge_continue`. Ask the user if their judgment is needed. Resume interrupted work from its existing copy or use `acent_bridge_cancel` to stop work that is no longer needed.
|
|
21
|
+
- In the final answer, name any enabled or explicitly requested tool that could not participate because its CLI required authentication. Use `loginRequiredTools` from candidate selection or `login_required` from task or refinement status. Include the tool even if others completed the work, and use its final result if it later succeeded. Point the user to **Set up** in Acent Bridge. Report model catalog failures and other unavailable states with their own reasons.
|
|
15
22
|
- Use `acent_bridge_integrate` to check completed patches together. Review them before applying. For substantive changes you are authorized to edit, start `acent_bridge_refine` with a UUID, the original task and constraints, the scoped files, a repair model, and one or more reviewers from distinct model families outside the original and repair families. Pass applied task IDs in `dependsOn`. For a read-only request, use the standalone review instead.
|
|
16
23
|
- Refinement supplies the original scoped Git diff and the cumulative repair diff to reviewers. It gathers independent findings and re-reviews repairs in a private staging workspace. Keep working on unrelated files while it runs. Check its status when results are needed. If a worker requests context, answer with `acent_bridge_continue` and then check refinement status. If a reviewer cannot run, call `replace_reviewer` with that review ID and an eligible replacement model. Completed reviews in that round stay in place.
|
|
17
24
|
- At `needs_checks`, call the refinement's `verify` action with the current `checkRevision` and the authorized test executables and arguments. Bridge runs them in a private copy of the reviewed candidate. For a standalone review of integrated edits, submit `commands` to `acent_bridge_finalize` and poll without them. Both flows prepare dependencies in the private test copy. Bridge can install locked npm dependencies automatically, and `setupCommands` can supply the project's own preparation steps. Report verification after `verified`. If project files captured in the verification snapshot change, begin from the latest changes.
|
|
18
25
|
- Use `apply: true` to apply scoped repairs after the stage passes review and tests. Otherwise inspect the verified patch and call `apply` with the current `checkRevision`. If the user stops verification or refinement, call its `cancel` action and confirm the final state. If promotion has already started, check what was applied. If findings remain after three repairs or require files outside the approved scope, report the blocker.
|
|
26
|
+
|
|
27
|
+
## Report Bridge results
|
|
28
|
+
|
|
29
|
+
1. Start the Bridge section with `**Acent Bridge** · <status>` in the user's language. Below it, list each participating tool and its role or task in a short bullet. Put the confirmed execution model in parentheses after the tool name. Prefer `actualModel` and omit the model when only a requested model is known.
|
|
30
|
+
2. For cross-validation or multiple tasks, follow with a Markdown table with columns for agent or check, scope, outcome, and findings or evidence. Use one row per distinct task, review, or check. Keep relevant earlier rounds and replacement reviewers visible. Use `reviewResult` and `reviewResults` to distinguish findings, no findings in the reviewed scope, unclassified output, failed or blocked reviews, and reviews that did not run. Mark `checksNotRun` as not run and report other unavailable tools with their observed reasons. Preserve findings reported by a single reviewer. Say whether each material finding was reproduced, fixed and rechecked, or still needs verification. 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.
|
|
31
|
+
3. End 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 one is needed. For read-only work, conclude with the result and any remaining uncertainty.
|
package/antigravity/plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://antigravity.google/schemas/v1/plugin.json",
|
|
3
3
|
"name": "acent",
|
|
4
4
|
"displayName": "Acent",
|
|
5
|
-
"version": "1.1.
|
|
5
|
+
"version": "1.1.3",
|
|
6
6
|
"description": "Recall past work, trace code changes, revisit decisions, and resume tasks with Acent.",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "Cirtium"
|