@cirtium/acent-connect 1.2.0 → 1.2.2
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/antigravity-hook.mjs +10 -3
- package/acent/scripts/antigravity-workspace.mjs +92 -0
- package/acent/scripts/bridge.mjs +30 -10
- package/acent/scripts/hook.mjs +1 -1
- package/acent/scripts/mcp-proxy.mjs +86 -27
- package/acent/skills/acent-bridge/SKILL.md +1 -1
- package/antigravity/plugin.json +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { spawn } from "node:child_process"
|
|
3
3
|
import { fileURLToPath } from "node:url"
|
|
4
|
+
import { recordWorkspaceCall, workspaceInstructions } from "./antigravity-workspace.mjs"
|
|
4
5
|
const started = Date.now()
|
|
6
|
+
const event = process.argv[2]
|
|
7
|
+
let output = event === "PreToolUse" ? { decision: "allow" } : {}
|
|
5
8
|
try {
|
|
6
9
|
let raw = ""
|
|
7
10
|
for await (const chunk of process.stdin) {
|
|
@@ -9,8 +12,12 @@ try {
|
|
|
9
12
|
if (Buffer.byteLength(raw) > 2 * 1024 * 1024) throw new Error("Hook event exceeds 2 MiB.")
|
|
10
13
|
}
|
|
11
14
|
const payload = JSON.parse(raw)
|
|
12
|
-
payload.acent_hook =
|
|
15
|
+
payload.acent_hook = event
|
|
13
16
|
if (!["PreInvocation", "PostInvocation", "Stop", "PreToolUse", "PostToolUse"].includes(payload.acent_hook)) throw new Error("Unknown Antigravity hook.")
|
|
17
|
+
if (event === "PreInvocation") output = workspaceInstructions(payload)
|
|
18
|
+
if (event === "PreToolUse") {
|
|
19
|
+
await recordWorkspaceCall(payload).catch(() => console.error("Acent could not verify this workspace call."))
|
|
20
|
+
}
|
|
14
21
|
await new Promise((resolve, reject) => {
|
|
15
22
|
const child = spawn(process.execPath, [fileURLToPath(new URL("./hook.mjs", import.meta.url)), "--tool", "Antigravity"],
|
|
16
23
|
{ stdio: ["pipe", "ignore", "inherit"] })
|
|
@@ -21,5 +28,5 @@ try {
|
|
|
21
28
|
})
|
|
22
29
|
console.error("Acent capture timing: " + JSON.stringify({at:new Date().toISOString(),stage:"finished",durationMs:Date.now()-started}))
|
|
23
30
|
} catch (error) { console.error("Acent could not save this event.") }
|
|
24
|
-
//
|
|
25
|
-
process.stdout.write("
|
|
31
|
+
// PreToolUse delegates the decision to Antigravity's normal permission policy.
|
|
32
|
+
process.stdout.write(JSON.stringify(output) + "\n")
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto"
|
|
2
|
+
import { mkdir, readFile, readdir, realpath, rename, stat, unlink, writeFile } from "node:fs/promises"
|
|
3
|
+
import { homedir } from "node:os"
|
|
4
|
+
import { join } from "node:path"
|
|
5
|
+
import { projectFolder } from "./connection-context.mjs"
|
|
6
|
+
|
|
7
|
+
const lifetimeMs = 60_000
|
|
8
|
+
const toolName = "acent_workspace"
|
|
9
|
+
const serverName = "acent_acent"
|
|
10
|
+
const isConversationId = value => typeof value === "string" && /^[a-zA-Z0-9_-]{1,128}$/.test(value)
|
|
11
|
+
|
|
12
|
+
export const antigravityWorkspaceTool = {
|
|
13
|
+
name: toolName,
|
|
14
|
+
description: "Use Acent in the current Antigravity chat when the regular Acent tools cannot identify its workspace. Use the conversation ID supplied by the Acent hook. Omit tool to list the available tools, or set tool to acent_connect or an Acent tool from the returned list.",
|
|
15
|
+
inputSchema: {
|
|
16
|
+
type: "object",
|
|
17
|
+
properties: {
|
|
18
|
+
conversationId: { type: "string", description: "Conversation ID supplied by the Acent hook in this chat." },
|
|
19
|
+
tool: { type: "string", description: "Acent tool to call. Omit to list tools." },
|
|
20
|
+
arguments: { type: "object", description: "Arguments for the selected Acent tool." },
|
|
21
|
+
},
|
|
22
|
+
required: ["conversationId"],
|
|
23
|
+
additionalProperties: false,
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function ordered(value) {
|
|
28
|
+
if (Array.isArray(value)) return value.map(ordered)
|
|
29
|
+
if (!value || typeof value !== "object") return value
|
|
30
|
+
return Object.fromEntries(Object.keys(value).sort().map(key => [key, ordered(value[key])]))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function evidenceFile(args) {
|
|
34
|
+
const dir = join(process.env.ACENT_CONFIG_HOME || join(homedir(), ".config", "acent"), "antigravity-workspaces")
|
|
35
|
+
const key = createHash("sha256").update(JSON.stringify(ordered(args))).digest("hex")
|
|
36
|
+
return { dir, file: join(dir, `${key}.json`) }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function workspaceInstructions(payload) {
|
|
40
|
+
if (payload.invocationNum !== 0 || !isConversationId(payload.conversationId)) return {}
|
|
41
|
+
return { injectSteps: [{ systemMessage: { systemMessage:
|
|
42
|
+
`When Acent tools are needed and the regular Acent server cannot identify this workspace, use ${toolName} on ${serverName} with conversationId ${payload.conversationId}. To connect, set tool to acent_connect. To use connected tools, omit tool to list them, then pass the chosen tool and its arguments to ${toolName}. Use only the conversation ID supplied by this hook.`
|
|
43
|
+
} }] }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function recordWorkspaceCall(payload) {
|
|
47
|
+
const call = payload.toolCall
|
|
48
|
+
const lazy = call?.name === "call_mcp_tool" && call.args?.ServerName === serverName && call.args?.ToolName === toolName
|
|
49
|
+
const eager = call?.name === `mcp_${serverName}_${toolName}`
|
|
50
|
+
if (!lazy && !eager) return
|
|
51
|
+
const args = lazy ? call.args.Arguments : call.args
|
|
52
|
+
if (!isConversationId(payload.conversationId) || args?.conversationId !== payload.conversationId) return
|
|
53
|
+
|
|
54
|
+
const roots = payload.workspacePaths
|
|
55
|
+
if (!Array.isArray(roots) || roots.length > 1) return
|
|
56
|
+
const folder = roots.length === 1 ? projectFolder(roots[0]) : undefined
|
|
57
|
+
if (roots.length === 1 && !folder) return
|
|
58
|
+
const context = folder ? { scope: "folder", folder: await realpath(folder) } : { scope: "general" }
|
|
59
|
+
const { dir, file } = evidenceFile(args)
|
|
60
|
+
await mkdir(dir, { recursive: true, mode: 0o700 })
|
|
61
|
+
const now = Date.now()
|
|
62
|
+
await Promise.all((await readdir(dir)).map(async entry => {
|
|
63
|
+
const path = join(dir, entry)
|
|
64
|
+
const info = await stat(path).catch(() => undefined)
|
|
65
|
+
if (info?.isFile() && now - info.mtimeMs > lifetimeMs) await unlink(path).catch(() => {})
|
|
66
|
+
}))
|
|
67
|
+
const temporary = `${file}.${randomUUID()}`
|
|
68
|
+
try {
|
|
69
|
+
await writeFile(temporary, JSON.stringify({ context, expires: now + lifetimeMs }), { mode: 0o600, flag: "wx" })
|
|
70
|
+
await rename(temporary, file)
|
|
71
|
+
} finally {
|
|
72
|
+
await unlink(temporary).catch(() => {})
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export async function consumeWorkspaceCall(args) {
|
|
77
|
+
if (!isConversationId(args?.conversationId)) return undefined
|
|
78
|
+
const { file } = evidenceFile(args)
|
|
79
|
+
const claimed = `${file}.${randomUUID()}`
|
|
80
|
+
try {
|
|
81
|
+
await rename(file, claimed)
|
|
82
|
+
} catch (error) {
|
|
83
|
+
if (error.code === "ENOENT") return undefined
|
|
84
|
+
throw error
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
const { context, expires } = JSON.parse(await readFile(claimed, "utf8"))
|
|
88
|
+
return expires >= Date.now() ? context : undefined
|
|
89
|
+
} finally {
|
|
90
|
+
await unlink(claimed).catch(() => {})
|
|
91
|
+
}
|
|
92
|
+
}
|
package/acent/scripts/bridge.mjs
CHANGED
|
@@ -118,6 +118,10 @@ const checkCommands = {
|
|
|
118
118
|
"Optional dependency preparation for the private test copy. Defaults to a locked npm install when applicable. Use an empty array to skip setup.",
|
|
119
119
|
},
|
|
120
120
|
}
|
|
121
|
+
const reviewModelInputs = {
|
|
122
|
+
originModel: text("Verified model ID for the earlier work being reviewed, when known."),
|
|
123
|
+
currentModel: text("Host-reported model ID for the requesting agent's current turn. Used when there is no verified earlier model."),
|
|
124
|
+
}
|
|
121
125
|
export const bridgeTools = [
|
|
122
126
|
toolSchema(
|
|
123
127
|
"acent_bridge_settings",
|
|
@@ -126,10 +130,10 @@ export const bridgeTools = [
|
|
|
126
130
|
),
|
|
127
131
|
toolSchema(
|
|
128
132
|
"acent_bridge_candidates",
|
|
129
|
-
"List locally available tool and model combinations for a new Bridge task.
|
|
133
|
+
"List locally available tool and model combinations for a new Bridge task. Review and diagnosis use the current model by default, or a verified model from the earlier work when supplied. Omit a tool to consider all enabled tools.",
|
|
130
134
|
{
|
|
131
135
|
kind,
|
|
132
|
-
|
|
136
|
+
...reviewModelInputs,
|
|
133
137
|
tool: target,
|
|
134
138
|
automatic: {
|
|
135
139
|
type: "boolean",
|
|
@@ -144,7 +148,7 @@ export const bridgeTools = [
|
|
|
144
148
|
"Submit one authorized task in a private project copy. Select a candidate from acent_bridge_candidates. Bridge expands from four to eight concurrent tasks per working folder as needed. Ready tasks submitted at capacity are queued and start automatically as slots open. Parallel writes require disjoint paths. Use the returned task ID to check its status.",
|
|
145
149
|
{
|
|
146
150
|
kind,
|
|
147
|
-
|
|
151
|
+
...reviewModelInputs,
|
|
148
152
|
tool: target,
|
|
149
153
|
model: text(
|
|
150
154
|
"Model ID from the candidates list. Omit for the tool default."
|
|
@@ -258,7 +262,7 @@ export const bridgeTools = [
|
|
|
258
262
|
context: text(
|
|
259
263
|
"Required when starting: relevant decisions, constraints, and evidence for reviewers and the repair worker."
|
|
260
264
|
),
|
|
261
|
-
|
|
265
|
+
...reviewModelInputs,
|
|
262
266
|
reviewers: { type: "array", minItems: 1, maxItems: 4, items: reviewSelection },
|
|
263
267
|
repair: selection,
|
|
264
268
|
paths: {
|
|
@@ -297,6 +301,7 @@ export const bridgeInstructions = [
|
|
|
297
301
|
"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.",
|
|
298
302
|
"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.",
|
|
299
303
|
"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.",
|
|
304
|
+
"For review, diagnosis, or refinement, use the host-reported current turn model as currentModel. Supply originModel only when the user is revisiting earlier work and its model is known. If earlier model metadata is missing, proceed with currentModel. In Codex, the Bridge tool hook can report the current model after a call. If Bridge returns origin_model_unverified and the hook reports a model, retry with that currentModel. Pass the same model inputs when starting the selected review. Never guess a model ID.",
|
|
300
305
|
"Before starting a task or refinement, gather the decisions, constraints, and evidence that affect the delegated work. Reuse current evidence and use Acent Decisions or Recall first if missing project history could change the work. Pass the relevant facts and any unresolved constraints in context on the initial request. For self-contained work, include the current facts the delegate needs.",
|
|
301
306
|
"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.",
|
|
302
307
|
"Bridge runs four tasks per project folder as a baseline and expands to eight as needed; extra ready tasks queue and start as slots open. Track queued jobs using their existing IDs. 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.",
|
|
@@ -336,6 +341,14 @@ const diagnosticCodes = new Set([
|
|
|
336
341
|
])
|
|
337
342
|
const xmlTag = /<acent-context>([\s\S]+?)<\/acent-context>\s*$/
|
|
338
343
|
const reviewOnly = (kind) => kind === "review" || kind === "diagnose"
|
|
344
|
+
|
|
345
|
+
function reviewModelReference({ originModel, currentModel }) {
|
|
346
|
+
for (const [model, source] of [[originModel, "original"], [currentModel, "current"]]) {
|
|
347
|
+
if (typeof model !== "string") continue
|
|
348
|
+
const family = modelFamily(model)
|
|
349
|
+
if (family) return { model, source, family }
|
|
350
|
+
}
|
|
351
|
+
}
|
|
339
352
|
const taskId = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/
|
|
340
353
|
const isTaskId = (id) => typeof id === "string" && taskId.test(id)
|
|
341
354
|
function workerAlive(pid) {
|
|
@@ -576,8 +589,8 @@ export function createBridge({
|
|
|
576
589
|
async function candidates(args, folder, settings) {
|
|
577
590
|
if (args.automatic && !settings.automatic)
|
|
578
591
|
return { status: "automatic_disabled", candidates: [] }
|
|
579
|
-
const
|
|
580
|
-
if (reviewOnly(args.kind) && !
|
|
592
|
+
const reference = reviewOnly(args.kind) ? reviewModelReference(args) : undefined
|
|
593
|
+
if (reviewOnly(args.kind) && !reference)
|
|
581
594
|
return { status: "origin_model_unverified", candidates: [] }
|
|
582
595
|
const permittedTargets = args.automatic ? settings.targets : bridgeTargets
|
|
583
596
|
const targets = await Promise.all(
|
|
@@ -598,8 +611,8 @@ export function createBridge({
|
|
|
598
611
|
: [{ id: null, family: item.defaultFamily ?? null }, ...item.models]
|
|
599
612
|
.filter(
|
|
600
613
|
(model) =>
|
|
601
|
-
!
|
|
602
|
-
(model.family && model.family !==
|
|
614
|
+
!reference ||
|
|
615
|
+
(model.family && model.family !== reference.family)
|
|
603
616
|
)
|
|
604
617
|
.filter(
|
|
605
618
|
(model) =>
|
|
@@ -616,6 +629,7 @@ export function createBridge({
|
|
|
616
629
|
return {
|
|
617
630
|
status: choices.length ? "ready" : "no_candidate",
|
|
618
631
|
candidates: choices,
|
|
632
|
+
...(reference ? { referenceModel: reference.model, referenceModelSource: reference.source } : {}),
|
|
619
633
|
...(loginRequiredTools.length ? { loginRequiredTools } : {}),
|
|
620
634
|
tools: await Promise.all(
|
|
621
635
|
targets.map(async (item) => ({
|
|
@@ -1334,7 +1348,12 @@ export function createBridge({
|
|
|
1334
1348
|
}
|
|
1335
1349
|
if (name === "acent_bridge_candidates")
|
|
1336
1350
|
return candidates(args, folder, settings)
|
|
1337
|
-
if (name === "acent_bridge_refine")
|
|
1351
|
+
if (name === "acent_bridge_refine") {
|
|
1352
|
+
if (args.action === "start") {
|
|
1353
|
+
const reference = reviewModelReference(args)
|
|
1354
|
+
if (!reference) return { status: "origin_model_unverified" }
|
|
1355
|
+
args = { ...args, originModel: reference.model }
|
|
1356
|
+
}
|
|
1338
1357
|
return refine(args, {
|
|
1339
1358
|
folder,
|
|
1340
1359
|
projectDir,
|
|
@@ -1408,6 +1427,7 @@ export function createBridge({
|
|
|
1408
1427
|
),
|
|
1409
1428
|
cancelJob: (id) => cancelJob(projectDir, coordination, id),
|
|
1410
1429
|
})
|
|
1430
|
+
}
|
|
1411
1431
|
if (name === "acent_bridge_integrate")
|
|
1412
1432
|
return integrate(folder, projectDir, coordination, args.ids, args.apply, settings.captureEvidence)
|
|
1413
1433
|
if (name === "acent_bridge_finalize") {
|
|
@@ -1501,7 +1521,7 @@ export function createBridge({
|
|
|
1501
1521
|
const job = {
|
|
1502
1522
|
id,
|
|
1503
1523
|
kind: args.kind,
|
|
1504
|
-
originModel: args.originModel,
|
|
1524
|
+
originModel: reviewOnly(args.kind) ? reviewModelReference(args)?.model : args.originModel,
|
|
1505
1525
|
tool: args.tool,
|
|
1506
1526
|
model: args.model ?? null,
|
|
1507
1527
|
task: args.task,
|
package/acent/scripts/hook.mjs
CHANGED
|
@@ -31,7 +31,7 @@ try {
|
|
|
31
31
|
!/^(?:auto|default|unknown)$/i.test(payload.model)) {
|
|
32
32
|
process.stdout.write(JSON.stringify({ hookSpecificOutput: {
|
|
33
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.`,
|
|
34
|
+
additionalContext: `Codex reports ${payload.model} as the coordinating model for this turn. Use this ID as currentModel for Bridge review, diagnosis, and refinement in this turn. If candidate selection could not verify a reference model, retry with this currentModel. Use it for this turn's direct-work row in the Acent Bridge report.`,
|
|
35
35
|
} }) + "\n")
|
|
36
36
|
}
|
|
37
37
|
await main(["collect", ...process.argv.slice(2),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { encryptedReadTool, readEncryptedRecords, privateGrant } from "./encrypted-capture.mjs"
|
|
3
|
-
import { readFile } from "node:fs/promises"
|
|
3
|
+
import { readFile, realpath } from "node:fs/promises"
|
|
4
4
|
import { connectionGuidance } from "./host-guidance.mjs"
|
|
5
5
|
// Folder-scoped MCP with setup available even before the first authorization.
|
|
6
6
|
import { clarificationInstructions, clarificationTool, clarify, createQuestionChannel } from "./clarification.mjs"
|
|
@@ -11,7 +11,9 @@ import { bridgeInstructions, bridgeTools, createBridge } from "./bridge.mjs"
|
|
|
11
11
|
import { bridgeCaptureEvents } from "./bridge-capture.mjs"
|
|
12
12
|
import { createInterface } from "node:readline"
|
|
13
13
|
import { mkdir } from "node:fs/promises"
|
|
14
|
-
import { dirname } from "node:path"
|
|
14
|
+
import { dirname, resolve } from "node:path"
|
|
15
|
+
import { fileURLToPath } from "node:url"
|
|
16
|
+
import { antigravityWorkspaceTool, consumeWorkspaceCall } from "./antigravity-workspace.mjs"
|
|
15
17
|
import { createPluginUpdateNotice, pluginUpdateInstructions, readPluginInstallation } from "./plugin-updates.mjs"
|
|
16
18
|
import {
|
|
17
19
|
options,
|
|
@@ -30,6 +32,8 @@ const launchFolder = folderIndex < 0 ? undefined : launchArgs[folderIndex + 1]
|
|
|
30
32
|
if (folderIndex >= 0 && !projectFolder(launchFolder)) launchArgs.splice(folderIndex, 2)
|
|
31
33
|
const startupConfig = await boundConfig(["flush", ...launchArgs])
|
|
32
34
|
let activeConfig = startupConfig
|
|
35
|
+
const isAntigravity = startupConfig.tool === "Antigravity"
|
|
36
|
+
const pluginFolder = resolve(fileURLToPath(new URL("..", import.meta.url)))
|
|
33
37
|
const recoverCursorFolder = startupConfig.tool === "Cursor" &&
|
|
34
38
|
launchFolder === "${workspaceFolder}" && !launchArgs.includes("--general")
|
|
35
39
|
const installation = await readPluginInstallation(activeConfig.tool).catch(() => null)
|
|
@@ -38,6 +42,7 @@ let clientCapabilities = {}
|
|
|
38
42
|
let protocol
|
|
39
43
|
let pendingConnection
|
|
40
44
|
let connectionUrl
|
|
45
|
+
let connectionDirectory
|
|
41
46
|
const setupTool = {
|
|
42
47
|
name: "acent_connect",
|
|
43
48
|
title: "Acent Connect",
|
|
@@ -67,14 +72,26 @@ function recoverCursorConfig() {
|
|
|
67
72
|
return cursorFolderRecovery
|
|
68
73
|
}
|
|
69
74
|
|
|
70
|
-
async function detectConnectionContext(config) {
|
|
75
|
+
async function detectConnectionContext(config, verifiedWorkspace) {
|
|
76
|
+
if (verifiedWorkspace) {
|
|
77
|
+
return { context: verifiedWorkspace, roots: verifiedWorkspace.folder ? undefined : [] }
|
|
78
|
+
}
|
|
71
79
|
const roots = clientCapabilities.roots ? await rootRequests.request() : undefined
|
|
80
|
+
const explicitGeneral = config.general &&
|
|
81
|
+
(config !== startupConfig || launchArgs.includes("--general"))
|
|
82
|
+
const bound = isAntigravity && !projectFolder(launchFolder)
|
|
83
|
+
? explicitGeneral ? { ...config, bindingKnown: true } : undefined
|
|
84
|
+
: config
|
|
72
85
|
const context = connectionContext({
|
|
73
86
|
roots,
|
|
74
87
|
explicitFolder: projectFolder(launchFolder) ||
|
|
75
88
|
(config.tool === "Cursor" ? process.env.CURSOR_PROJECT_DIR : undefined),
|
|
76
|
-
bound: recoverCursorFolder && config === startupConfig ? undefined :
|
|
89
|
+
bound: recoverCursorFolder && config === startupConfig ? undefined : bound,
|
|
77
90
|
})
|
|
91
|
+
if (isAntigravity && context.scope === "folder" &&
|
|
92
|
+
await realpath(context.folder).catch(() => resolve(context.folder)) === pluginFolder) {
|
|
93
|
+
return { context: { scope: "unknown" }, roots }
|
|
94
|
+
}
|
|
78
95
|
return { context, roots }
|
|
79
96
|
}
|
|
80
97
|
|
|
@@ -101,7 +118,8 @@ const needsConnection = (error) =>
|
|
|
101
118
|
error.code === "invalid_grant" ||
|
|
102
119
|
error.code === "project_unavailable" ||
|
|
103
120
|
error.status === 401
|
|
104
|
-
const
|
|
121
|
+
const workspaceTools = isAntigravity ? [antigravityWorkspaceTool] : []
|
|
122
|
+
const setupTools = () => ({ tools: [setupTool, ...localBridgeTools, ...workspaceTools] })
|
|
105
123
|
|
|
106
124
|
function toolErrorMessage(error) {
|
|
107
125
|
if (needsConnection(error))
|
|
@@ -137,13 +155,16 @@ async function postMcp(config, access, message) {
|
|
|
137
155
|
}
|
|
138
156
|
async function startConnection(config) {
|
|
139
157
|
const directory = configDirectory(config)
|
|
140
|
-
if (pendingConnection)
|
|
141
|
-
|
|
158
|
+
if (pendingConnection) {
|
|
159
|
+
if (directory !== connectionDirectory)
|
|
160
|
+
throw new Error("Finish the pending connection before changing its workspace")
|
|
161
|
+
return connectionUrl
|
|
162
|
+
}
|
|
163
|
+
connectionDirectory = directory
|
|
142
164
|
const ready = Promise.withResolvers()
|
|
143
|
-
pendingConnection = connect(config, directory, (url) => {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
})
|
|
165
|
+
pendingConnection = mkdir(directory, { recursive: true, mode: 0o700 }).then(() => connect(config, directory, (url) => {
|
|
166
|
+
ready.resolve(url.toString())
|
|
167
|
+
}))
|
|
147
168
|
.then(() => {
|
|
148
169
|
config.bindingKnown = true
|
|
149
170
|
write({ jsonrpc: "2.0", method: "notifications/tools/list_changed" })
|
|
@@ -155,13 +176,16 @@ async function startConnection(config) {
|
|
|
155
176
|
.finally(() => {
|
|
156
177
|
pendingConnection = undefined
|
|
157
178
|
connectionUrl = undefined
|
|
179
|
+
connectionDirectory = undefined
|
|
158
180
|
})
|
|
159
|
-
|
|
181
|
+
connectionUrl = ready.promise
|
|
182
|
+
return connectionUrl
|
|
160
183
|
}
|
|
161
184
|
const lines = createInterface({ input: process.stdin, crlfDelay: Infinity })
|
|
162
185
|
async function handleLine(line) {
|
|
163
186
|
if (!line.trim()) return
|
|
164
187
|
let message
|
|
188
|
+
let workspaceCatalog = false
|
|
165
189
|
try {
|
|
166
190
|
let config = activeConfig
|
|
167
191
|
if (Buffer.byteLength(line) > 64 * 1024)
|
|
@@ -174,7 +198,8 @@ async function handleLine(line) {
|
|
|
174
198
|
}
|
|
175
199
|
// Responses are never forwarded to the HTTP tool endpoint.
|
|
176
200
|
if (!message.method) return
|
|
177
|
-
const reply = (result) => write({ jsonrpc: "2.0", id: message.id, result
|
|
201
|
+
const reply = (result) => write({ jsonrpc: "2.0", id: message.id, result: workspaceCatalog
|
|
202
|
+
? { ...content(JSON.stringify(result)), structuredContent: result } : result })
|
|
178
203
|
const replyTool = async (result) => reply(await withPluginUpdate(result))
|
|
179
204
|
if (message.method === "initialize") {
|
|
180
205
|
if (!pluginUpdates && installation && process.env.ACENT_BRIDGE_WORKER !== "1" &&
|
|
@@ -209,11 +234,27 @@ async function handleLine(line) {
|
|
|
209
234
|
reply({})
|
|
210
235
|
return
|
|
211
236
|
}
|
|
237
|
+
let verifiedWorkspace
|
|
238
|
+
if (isAntigravity && message.method === "tools/call" && message.params?.name === antigravityWorkspaceTool.name) {
|
|
239
|
+
const args = message.params.arguments ?? {}
|
|
240
|
+
verifiedWorkspace = await consumeWorkspaceCall(args)
|
|
241
|
+
if (!verifiedWorkspace || verifiedWorkspace.folder === pluginFolder) {
|
|
242
|
+
reply(content("Acent could not verify this Antigravity chat's workspace. Use the conversation ID supplied by the Acent hook with a single workspace folder open.", true))
|
|
243
|
+
return
|
|
244
|
+
}
|
|
245
|
+
if (args.tool === antigravityWorkspaceTool.name) {
|
|
246
|
+
reply(content("Choose an Acent tool from the workspace tool list.", true))
|
|
247
|
+
return
|
|
248
|
+
}
|
|
249
|
+
workspaceCatalog = args.tool === undefined
|
|
250
|
+
message.method = workspaceCatalog ? "tools/list" : "tools/call"
|
|
251
|
+
message.params = workspaceCatalog ? undefined : { name: args.tool, arguments: args.arguments }
|
|
252
|
+
}
|
|
212
253
|
if (message.method === "tools/call" &&
|
|
213
254
|
localBridgeTools.some(tool => tool.name === message.params?.name)) {
|
|
214
255
|
try {
|
|
215
256
|
const args = message.params.arguments ?? {}
|
|
216
|
-
const { context } = await detectConnectionContext(config)
|
|
257
|
+
const { context } = await detectConnectionContext(config, verifiedWorkspace)
|
|
217
258
|
const value = await bridge(message.params.name, args,
|
|
218
259
|
context.scope === "folder" ? context.folder : undefined, async (folder) => {
|
|
219
260
|
const projectConfig = options([
|
|
@@ -256,13 +297,17 @@ async function handleLine(line) {
|
|
|
256
297
|
let scope = message.params.arguments?.scope ?? "auto"
|
|
257
298
|
let detectedFolder
|
|
258
299
|
let projectlessRoots = false
|
|
259
|
-
const resumePending = scope === "auto" && !!pendingConnection
|
|
300
|
+
const resumePending = !isAntigravity && scope === "auto" && !!pendingConnection
|
|
260
301
|
if (scope !== "auto" && scope !== "folder" && scope !== "general")
|
|
261
302
|
throw new Error("Choose folder or general scope")
|
|
262
303
|
if (resumePending) scope = config.general ? "general" : "folder"
|
|
263
|
-
if (scope === "auto") {
|
|
264
|
-
const { context: detected, roots } = await detectConnectionContext(config)
|
|
265
|
-
if (detected.scope
|
|
304
|
+
if (scope === "auto" || isAntigravity) {
|
|
305
|
+
const { context: detected, roots } = await detectConnectionContext(config, verifiedWorkspace)
|
|
306
|
+
if (isAntigravity && scope === "folder" && detected.scope !== "folder") {
|
|
307
|
+
reply(content("Acent could not identify the Antigravity project folder. Open a single workspace folder in Antigravity and try again.", true))
|
|
308
|
+
return
|
|
309
|
+
}
|
|
310
|
+
if (scope === "auto" && detected.scope === "unknown") {
|
|
266
311
|
const value = {
|
|
267
312
|
status: "needs_user_input",
|
|
268
313
|
question: "Connect Acent to this project's conversations or to general conversations outside projects?",
|
|
@@ -273,18 +318,20 @@ async function handleLine(line) {
|
|
|
273
318
|
return
|
|
274
319
|
}
|
|
275
320
|
projectlessRoots = Array.isArray(roots) && roots.length === 0
|
|
276
|
-
scope = detected.scope
|
|
321
|
+
if (scope === "auto") scope = detected.scope
|
|
277
322
|
detectedFolder = detected.folder
|
|
278
323
|
}
|
|
279
324
|
if (!resumePending) {
|
|
280
|
-
const folder =
|
|
325
|
+
const folder = isAntigravity
|
|
326
|
+
? detectedFolder || config.contextFolder
|
|
327
|
+
: detectedFolder || config.contextFolder || config.folder || process.cwd()
|
|
281
328
|
config = options(["flush", "--tool", config.tool, "--server", config.server,
|
|
282
329
|
...(scope === "general" ? ["--general"] : []),
|
|
283
|
-
...(projectlessRoots
|
|
330
|
+
...(!projectlessRoots && folder ? ["--folder", folder] : []),
|
|
284
331
|
])
|
|
285
|
-
if (pendingConnection && configDirectory(config) !==
|
|
332
|
+
if (pendingConnection && configDirectory(config) !== connectionDirectory)
|
|
286
333
|
throw new Error("Finish the pending connection before changing its scope")
|
|
287
|
-
activeConfig = config
|
|
334
|
+
if (!verifiedWorkspace) activeConfig = config
|
|
288
335
|
}
|
|
289
336
|
if (message.params.arguments?.reconnect !== true) {
|
|
290
337
|
try {
|
|
@@ -309,7 +356,18 @@ async function handleLine(line) {
|
|
|
309
356
|
)
|
|
310
357
|
return
|
|
311
358
|
}
|
|
312
|
-
if (
|
|
359
|
+
if (isAntigravity) {
|
|
360
|
+
const { context, roots } = await detectConnectionContext(config, verifiedWorkspace)
|
|
361
|
+
if (context.scope === "unknown") {
|
|
362
|
+
if (message.method === "tools/list") return reply(setupTools())
|
|
363
|
+
throw Object.assign(new Error("No workspace connection"), { code: "ENOENT" })
|
|
364
|
+
}
|
|
365
|
+
const folder = context.folder || (roots === undefined ? config.contextFolder : undefined)
|
|
366
|
+
config = await boundConfig(["flush", "--tool", config.tool, "--server", config.server,
|
|
367
|
+
...(context.scope === "general" ? ["--general"] : []),
|
|
368
|
+
...(folder ? ["--folder", folder] : []),
|
|
369
|
+
])
|
|
370
|
+
} else if (recoverCursorFolder && config === startupConfig) {
|
|
313
371
|
await recoverCursorConfig()
|
|
314
372
|
config = activeConfig
|
|
315
373
|
if (config === startupConfig) {
|
|
@@ -367,18 +425,19 @@ async function handleLine(line) {
|
|
|
367
425
|
const localTools = privateGrant(grant.client_id)
|
|
368
426
|
? (grant.captureKey && grant.scope?.split(" ").includes("original:read") ? [encryptedReadTool] : [])
|
|
369
427
|
: grant.scope?.split(" ").includes("conversation:write") ? [attachmentTool] : []
|
|
370
|
-
result.result.tools = [...result.result.tools.filter((tool) => tool.name !== clarificationTool.name), setupTool, clarificationTool, ...localTools, ...localBridgeTools]
|
|
428
|
+
result.result.tools = [...result.result.tools.filter((tool) => tool.name !== clarificationTool.name), setupTool, clarificationTool, ...localTools, ...localBridgeTools, ...workspaceTools]
|
|
371
429
|
}
|
|
372
430
|
if (message.method === "tools/call" && result.result)
|
|
373
431
|
result.result = await withPluginUpdate(result.result)
|
|
374
|
-
|
|
432
|
+
if (workspaceCatalog && result.result) reply(result.result)
|
|
433
|
+
else write(result)
|
|
375
434
|
} catch (error) {
|
|
376
435
|
console.error("Acent request failed.")
|
|
377
436
|
if (message?.id !== undefined)
|
|
378
437
|
write({
|
|
379
438
|
jsonrpc: "2.0",
|
|
380
439
|
id: message.id,
|
|
381
|
-
...(message.method === "tools/call"
|
|
440
|
+
...(message.method === "tools/call" || workspaceCatalog
|
|
382
441
|
? {
|
|
383
442
|
result: content(toolErrorMessage(error), true),
|
|
384
443
|
}
|
|
@@ -15,7 +15,7 @@ Use the Acent Bridge MCP tools in a session with one local project folder open.
|
|
|
15
15
|
- 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.
|
|
16
16
|
- 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.
|
|
17
17
|
- 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.
|
|
18
|
-
- 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
|
|
18
|
+
- 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, diagnosis, and refinement, pass the host-reported model for this turn as `currentModel`. Supply `originModel` when reviewing earlier work whose originating model is known. Bridge uses the earlier model when supplied and recognized, otherwise it checks independence against the current model. In Codex, if candidate selection returns `origin_model_unverified` and the Bridge hook reports the current model, retry with that ID. Pass the same model inputs to start the selected work. Report when no eligible candidate is available.
|
|
19
19
|
- 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.
|
|
20
20
|
- Before starting any task or refinement, gather the active decisions, constraints, and prior findings that affect the delegated scope. Use evidence already available. If missing project history could change the work, use [Acent Decisions](../acent-decisions/SKILL.md) for prior choices or [Acent Recall](../acent-recall/SKILL.md) for earlier requirements and attempts. Put the relevant facts, decision rationale where it affects the task, and unresolved points in `context` on the first call. For self-contained work, pass the current facts the delegate needs.
|
|
21
21
|
- 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. Specify how to verify completion in `acceptance`. The folder shares four baseline slots across implementation, review, and diagnosis and expands up to eight as needed. Ready tasks submitted after all eight slots fill are queued and start as slots open. Track their existing IDs. Pass `dependsOn` when a task needs the result of earlier work. Review and diagnosis run in read-only mode.
|
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.2.
|
|
5
|
+
"version": "1.2.2",
|
|
6
6
|
"description": "Recall past work, trace code changes, revisit decisions, and resume tasks with Acent.",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "Cirtium"
|