@cirtium/acent-connect 1.0.0 → 1.0.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/README.md +4 -0
- 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 +12 -3
- package/acent/scripts/bridge-checks.mjs +305 -0
- package/acent/scripts/bridge-finalize.mjs +233 -0
- package/acent/scripts/bridge-refinement.mjs +1073 -0
- package/acent/scripts/bridge-retention.mjs +168 -0
- package/acent/scripts/bridge-runners.mjs +605 -0
- package/acent/scripts/bridge-workspace.mjs +512 -0
- package/acent/scripts/bridge.mjs +1330 -0
- package/acent/scripts/capture-attachments.mjs +23 -8
- package/acent/scripts/host-executables.mjs +56 -0
- package/acent/scripts/mcp-proxy.mjs +70 -11
- package/acent/scripts/plugin-updates.mjs +184 -0
- package/acent/skills/acent-bridge/SKILL.md +18 -0
- package/acent/skills/acent-bridge/agents/openai.yaml +4 -0
- package/antigravity/plugin.json +1 -1
- package/package.json +1 -1
- package/scripts/install-plugin.mjs +2 -41
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { constants } from "node:fs"
|
|
2
2
|
import { open } from "node:fs/promises"
|
|
3
3
|
import { basename, isAbsolute } from "node:path"
|
|
4
|
-
import { createHash } from "node:crypto"
|
|
4
|
+
import { createCipheriv, createHash, randomBytes } from "node:crypto"
|
|
5
5
|
|
|
6
6
|
export const attachmentTool = {
|
|
7
7
|
name: "acent_save_attachments",
|
|
@@ -33,9 +33,9 @@ export async function saveAttachments(paths, config, access, request, upload = f
|
|
|
33
33
|
if (!Array.isArray(paths) || !paths.length || paths.length > 20 ||
|
|
34
34
|
paths.some(path => typeof path !== "string" || !isAbsolute(path)))
|
|
35
35
|
throw new Error("Supply 1–20 absolute paths of user-attached files.")
|
|
36
|
-
const headers = { Authorization: "Bearer " + access }
|
|
36
|
+
const headers = { Authorization: "Bearer " + access, "X-Acent-Attachment-Encryption": "1" }
|
|
37
37
|
const settings = await request(config, "/api/external/attachments", { headers })
|
|
38
|
-
if (!settings.enabled) return { enabled: false, files: [] }
|
|
38
|
+
if (!settings.enabled || settings.encrypted !== true) return { enabled: false, files: [] }
|
|
39
39
|
const maxBytes = Math.min(50 * 1024 ** 2, settings.maxBytes)
|
|
40
40
|
if (!Number.isSafeInteger(maxBytes) || maxBytes <= 0) throw new Error("Attachment limit unavailable.")
|
|
41
41
|
const files = []
|
|
@@ -72,14 +72,23 @@ export async function saveAttachments(paths, config, access, request, upload = f
|
|
|
72
72
|
body: JSON.stringify({ ...metadata, ...(complete ? { complete: true } : {}) }),
|
|
73
73
|
})
|
|
74
74
|
let result = await post(false)
|
|
75
|
+
let savedId = result.id ?? id
|
|
75
76
|
if (result.uploadUrl) {
|
|
76
77
|
const url = new URL(result.uploadUrl)
|
|
77
78
|
if (url.protocol !== "https:" && !(url.protocol === "http:" && ["localhost", "127.0.0.1"].includes(url.hostname)))
|
|
78
79
|
throw new Error("Invalid upload URL")
|
|
79
80
|
// Never forward the Acent bearer token to Storage. Signed URL is path-scoped.
|
|
81
|
+
if (!/^[a-f0-9]{64}$/.test(result.id) || typeof result.uploadKey !== "string")
|
|
82
|
+
throw new Error("Encrypted upload unavailable")
|
|
83
|
+
const key = Buffer.from(result.uploadKey, "base64")
|
|
84
|
+
const iv = randomBytes(12)
|
|
85
|
+
const cipher = createCipheriv("aes-256-gcm", key, iv)
|
|
86
|
+
cipher.setAAD(Buffer.from(`acent:attachment:v1:${result.id}:original`))
|
|
87
|
+
const body = Buffer.concat([iv, cipher.update(bytes), cipher.final(), cipher.getAuthTag()])
|
|
88
|
+
savedId = result.id
|
|
80
89
|
const response = await upload(url, {
|
|
81
90
|
method: "PUT", headers: { "Content-Type": "application/octet-stream", "x-upsert": "false" },
|
|
82
|
-
body
|
|
91
|
+
body, signal: AbortSignal.timeout(120_000),
|
|
83
92
|
})
|
|
84
93
|
if (!response.ok && response.status !== 409) {
|
|
85
94
|
const error = await response.json().catch(() => ({}))
|
|
@@ -87,18 +96,24 @@ export async function saveAttachments(paths, config, access, request, upload = f
|
|
|
87
96
|
}
|
|
88
97
|
result = await post(true)
|
|
89
98
|
}
|
|
90
|
-
if (result.id !==
|
|
91
|
-
|
|
99
|
+
if (result.id !== savedId || result.status !== "saved")
|
|
100
|
+
throw new Error("Upload not confirmed")
|
|
101
|
+
files.push({ ...metadata, id: savedId, status: "saved" })
|
|
92
102
|
} catch { files.push({ name, size, status: "failed" }) }
|
|
93
103
|
}
|
|
94
104
|
return { enabled: true, files }
|
|
95
105
|
}
|
|
96
106
|
|
|
97
|
-
export async function attachFiles(payload, config, access, request) {
|
|
107
|
+
export async function attachFiles(payload, config, access, request, destination) {
|
|
98
108
|
const paths = attachedPaths(payload, config.tool)
|
|
99
109
|
if (!paths.length) return { payload, enabled: false }
|
|
100
110
|
let result
|
|
101
|
-
|
|
111
|
+
const scopedRequest = destination
|
|
112
|
+
? (config, path, options) => request(config, path, {
|
|
113
|
+
...options, headers: { ...options.headers, "X-Acent-Capture-Destination": destination },
|
|
114
|
+
})
|
|
115
|
+
: request
|
|
116
|
+
try { result = await saveAttachments(paths.slice(0, 20), config, access, scopedRequest) }
|
|
102
117
|
catch (error) {
|
|
103
118
|
// Retry service/auth failures through the normal queue; never silently claim success.
|
|
104
119
|
if ([400, 404].includes(error.status)) return { payload, enabled: false }
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { readdir } from "node:fs/promises"
|
|
2
|
+
import { homedir } from "node:os"
|
|
3
|
+
import { join } from "node:path"
|
|
4
|
+
|
|
5
|
+
async function claudeDesktopExecutables(home) {
|
|
6
|
+
const root = join(home, "Library/Application Support/Claude/claude-code")
|
|
7
|
+
const versions = (
|
|
8
|
+
await readdir(root, { withFileTypes: true }).catch(() => [])
|
|
9
|
+
)
|
|
10
|
+
.filter(
|
|
11
|
+
(entry) => entry.isDirectory() && /^\d+\.\d+\.\d+$/.test(entry.name)
|
|
12
|
+
)
|
|
13
|
+
.sort((a, b) => b.name.localeCompare(a.name, "en", { numeric: true }))
|
|
14
|
+
const executables = []
|
|
15
|
+
for (const version of versions) {
|
|
16
|
+
const directory = join(root, version.name)
|
|
17
|
+
const builds = await readdir(directory, { withFileTypes: true }).catch(
|
|
18
|
+
() => []
|
|
19
|
+
)
|
|
20
|
+
for (const entry of builds) {
|
|
21
|
+
if (entry.isDirectory() && /^[a-f0-9]+$/i.test(entry.name))
|
|
22
|
+
executables.push(
|
|
23
|
+
join(directory, entry.name, "claude.app/Contents/MacOS/claude")
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return executables
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function hostExecutableCandidates(tool, command) {
|
|
31
|
+
const home = homedir()
|
|
32
|
+
const candidates = [command, join(home, ".local", "bin", command)]
|
|
33
|
+
if (tool === "Antigravity")
|
|
34
|
+
candidates.push(join(home, ".antigravity", "antigravity", "bin", "agy"))
|
|
35
|
+
if (process.platform === "darwin") {
|
|
36
|
+
if (tool === "Codex") {
|
|
37
|
+
for (const applications of [
|
|
38
|
+
"/Applications",
|
|
39
|
+
join(home, "Applications"),
|
|
40
|
+
]) {
|
|
41
|
+
candidates.push(
|
|
42
|
+
join(applications, "Codex.app/Contents/Resources/codex"),
|
|
43
|
+
join(
|
|
44
|
+
applications,
|
|
45
|
+
"ChatGPT.app/Contents/Resources/codex-cli/CodexCLI.app/Contents/MacOS/codex"
|
|
46
|
+
)
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (tool === "Claude Code")
|
|
51
|
+
candidates.push(...(await claudeDesktopExecutables(home)))
|
|
52
|
+
}
|
|
53
|
+
if (tool === "Cursor" && command === "agent")
|
|
54
|
+
candidates.push("cursor-agent", join(home, ".local", "bin", "cursor-agent"))
|
|
55
|
+
return candidates
|
|
56
|
+
}
|
|
@@ -7,8 +7,11 @@ import { clarificationInstructions, clarificationTool, clarify, createQuestionCh
|
|
|
7
7
|
import { connectionContext, createRootsChannel, projectFolder } from "./connection-context.mjs"
|
|
8
8
|
import { memoryInstructions } from "./memory-instructions.mjs"
|
|
9
9
|
import { attachmentTool, saveAttachments } from "./capture-attachments.mjs"
|
|
10
|
+
import { bridgeInstructions, bridgeTools, createBridge } from "./bridge.mjs"
|
|
10
11
|
import { createInterface } from "node:readline"
|
|
11
12
|
import { mkdir } from "node:fs/promises"
|
|
13
|
+
import { dirname } from "node:path"
|
|
14
|
+
import { createPluginUpdateNotice, pluginUpdateInstructions, readPluginInstallation } from "./plugin-updates.mjs"
|
|
12
15
|
import {
|
|
13
16
|
options,
|
|
14
17
|
boundConfig,
|
|
@@ -23,6 +26,8 @@ const folderIndex = launchArgs.indexOf("--folder")
|
|
|
23
26
|
const launchFolder = folderIndex < 0 ? undefined : launchArgs[folderIndex + 1]
|
|
24
27
|
if (folderIndex >= 0 && !projectFolder(launchFolder)) launchArgs.splice(folderIndex, 2)
|
|
25
28
|
let activeConfig = await boundConfig(["flush", ...launchArgs])
|
|
29
|
+
const installation = await readPluginInstallation(activeConfig.tool).catch(() => null)
|
|
30
|
+
let pluginUpdates
|
|
26
31
|
let clientCapabilities = {}
|
|
27
32
|
let protocol
|
|
28
33
|
let pendingConnection
|
|
@@ -42,10 +47,24 @@ const setupTool = {
|
|
|
42
47
|
const write = (value) => process.stdout.write(JSON.stringify(value) + "\n")
|
|
43
48
|
const questions = createQuestionChannel(write)
|
|
44
49
|
const rootRequests = createRootsChannel(write)
|
|
50
|
+
const localBridgeTools = process.env.ACENT_BRIDGE_WORKER === "1" ? [] : bridgeTools
|
|
51
|
+
const bridge = createBridge()
|
|
45
52
|
const content = (text, isError = false) => ({
|
|
46
53
|
content: [{ type: "text", text }],
|
|
47
54
|
isError,
|
|
48
55
|
})
|
|
56
|
+
async function withPluginUpdate(result) {
|
|
57
|
+
if (!pluginUpdates || result?.isError || !result?.content?.length) return result
|
|
58
|
+
const notice = await pluginUpdates.take().catch(() => undefined)
|
|
59
|
+
if (!notice) return result
|
|
60
|
+
return {
|
|
61
|
+
...result,
|
|
62
|
+
content: [
|
|
63
|
+
...result.content,
|
|
64
|
+
{ type: "text", text: notice, annotations: { audience: ["user", "assistant"] } },
|
|
65
|
+
],
|
|
66
|
+
}
|
|
67
|
+
}
|
|
49
68
|
const needsConnection = (error) =>
|
|
50
69
|
error.code === "ENOENT" ||
|
|
51
70
|
error.code === "invalid_grant" ||
|
|
@@ -124,7 +143,15 @@ async function handleLine(line) {
|
|
|
124
143
|
// Responses are never forwarded to the HTTP tool endpoint.
|
|
125
144
|
if (!message.method) return
|
|
126
145
|
const reply = (result) => write({ jsonrpc: "2.0", id: message.id, result })
|
|
146
|
+
const replyTool = async (result) => reply(await withPluginUpdate(result))
|
|
127
147
|
if (message.method === "initialize") {
|
|
148
|
+
if (!pluginUpdates && installation && process.env.ACENT_BRIDGE_WORKER !== "1" &&
|
|
149
|
+
config.server === "https://www.acent.cloud") {
|
|
150
|
+
pluginUpdates = createPluginUpdateNotice({
|
|
151
|
+
installation,
|
|
152
|
+
configHome: dirname(configDirectory(config)),
|
|
153
|
+
})
|
|
154
|
+
}
|
|
128
155
|
clientCapabilities = message.params?.capabilities ?? {}
|
|
129
156
|
protocol = [
|
|
130
157
|
"2025-11-25",
|
|
@@ -137,9 +164,11 @@ async function handleLine(line) {
|
|
|
137
164
|
reply({
|
|
138
165
|
protocolVersion: protocol,
|
|
139
166
|
capabilities: { tools: { listChanged: true } },
|
|
140
|
-
serverInfo: { name: "acent", version: "0.2.0" },
|
|
167
|
+
serverInfo: { name: "acent", version: installation?.version ?? "0.2.0" },
|
|
141
168
|
instructions:
|
|
142
|
-
"Use acent_connect to connect Acent when setup is needed; its default scope is auto. If it returns needs_user_input, ask its question once in the user’s language and wait for their answer. Show its authorization link to the user. After approval, refresh tools/list and continue the original request. Never approve on the user's behalf. " + memoryInstructions + "\n\n" + clarificationInstructions
|
|
169
|
+
"Use acent_connect to connect Acent when setup is needed; its default scope is auto. If it returns needs_user_input, ask its question once in the user’s language and wait for their answer. Show its authorization link to the user. After approval, refresh tools/list and continue the original request. Never approve on the user's behalf. " + memoryInstructions + "\n\n" + clarificationInstructions +
|
|
170
|
+
(localBridgeTools.length ? "\n\n" + bridgeInstructions : "") +
|
|
171
|
+
(pluginUpdates ? "\n\n" + pluginUpdateInstructions : ""),
|
|
143
172
|
})
|
|
144
173
|
return
|
|
145
174
|
}
|
|
@@ -148,6 +177,35 @@ async function handleLine(line) {
|
|
|
148
177
|
reply({})
|
|
149
178
|
return
|
|
150
179
|
}
|
|
180
|
+
if (message.method === "tools/call" &&
|
|
181
|
+
localBridgeTools.some(tool => tool.name === message.params?.name)) {
|
|
182
|
+
try {
|
|
183
|
+
const args = message.params.arguments ?? {}
|
|
184
|
+
const roots = clientCapabilities.roots ? await rootRequests.request() : undefined
|
|
185
|
+
const context = connectionContext({ roots, explicitFolder: launchFolder ||
|
|
186
|
+
(config.tool === "Cursor" ? process.env.CURSOR_PROJECT_DIR : undefined), bound: config })
|
|
187
|
+
const value = await bridge(message.params.name, args,
|
|
188
|
+
context.scope === "folder" ? context.folder : undefined, async (folder) => {
|
|
189
|
+
const projectConfig = options([
|
|
190
|
+
"flush", "--tool", config.tool, "--server", config.server, "--folder", folder,
|
|
191
|
+
])
|
|
192
|
+
try {
|
|
193
|
+
const access = await accessToken(projectConfig, configDirectory(projectConfig))
|
|
194
|
+
return await request(projectConfig, "/api/external/bridge", {
|
|
195
|
+
headers: { Authorization: `Bearer ${access}` },
|
|
196
|
+
})
|
|
197
|
+
} catch (error) {
|
|
198
|
+
if (needsConnection(error))
|
|
199
|
+
throw new Error("Connect this project folder to Acent before using Bridge.")
|
|
200
|
+
throw error
|
|
201
|
+
}
|
|
202
|
+
})
|
|
203
|
+
await replyTool({ ...content(JSON.stringify(value)), structuredContent: value })
|
|
204
|
+
} catch (error) {
|
|
205
|
+
reply(content(error.message, true))
|
|
206
|
+
}
|
|
207
|
+
return
|
|
208
|
+
}
|
|
151
209
|
if (
|
|
152
210
|
message.method === "tools/call" &&
|
|
153
211
|
message.params?.name === setupTool.name
|
|
@@ -196,7 +254,7 @@ async function handleLine(line) {
|
|
|
196
254
|
jsonrpc: "2.0", id: message.id, method: "tools/list",
|
|
197
255
|
})
|
|
198
256
|
await response.body?.cancel()
|
|
199
|
-
|
|
257
|
+
await replyTool(content(connectionGuidance(config.tool)))
|
|
200
258
|
write({ jsonrpc: "2.0", method: "notifications/tools/list_changed" })
|
|
201
259
|
return
|
|
202
260
|
} catch (error) {
|
|
@@ -217,7 +275,7 @@ async function handleLine(line) {
|
|
|
217
275
|
access = await accessToken(config, directory)
|
|
218
276
|
} catch (error) {
|
|
219
277
|
if (message.method === "tools/list" && needsConnection(error)) {
|
|
220
|
-
reply({ tools: [setupTool] })
|
|
278
|
+
reply({ tools: [setupTool, ...localBridgeTools] })
|
|
221
279
|
return
|
|
222
280
|
}
|
|
223
281
|
throw error
|
|
@@ -236,13 +294,13 @@ async function handleLine(line) {
|
|
|
236
294
|
const grant = JSON.parse(await readFile(directory + "/credentials.json", "utf8"))
|
|
237
295
|
if (!privateGrant(grant.client_id)) throw new Error("Session access unavailable.")
|
|
238
296
|
const value = await readEncryptedRecords(config, grant, access, message.params.arguments ?? {}, request)
|
|
239
|
-
|
|
297
|
+
await replyTool(content(JSON.stringify(value)))
|
|
240
298
|
return
|
|
241
299
|
}
|
|
242
300
|
if (message.method === "tools/call" && message.params?.name === attachmentTool.name) {
|
|
243
301
|
try {
|
|
244
302
|
const value = await saveAttachments(message.params.arguments?.paths, config, access, request)
|
|
245
|
-
|
|
303
|
+
await replyTool({ ...content(JSON.stringify(value), !value.enabled || value.files.some(file => file.status !== "saved")), structuredContent: value })
|
|
246
304
|
} catch (error) { reply(content(error.message, true)) }
|
|
247
305
|
return
|
|
248
306
|
}
|
|
@@ -251,7 +309,7 @@ async function handleLine(line) {
|
|
|
251
309
|
response = await postMcp(config, access, message)
|
|
252
310
|
} catch (error) {
|
|
253
311
|
if (message.method === "tools/list" && needsConnection(error))
|
|
254
|
-
return reply({ tools: [setupTool] })
|
|
312
|
+
return reply({ tools: [setupTool, ...localBridgeTools] })
|
|
255
313
|
throw error
|
|
256
314
|
}
|
|
257
315
|
if (response.status === 202 || response.status === 204) return
|
|
@@ -260,11 +318,11 @@ async function handleLine(line) {
|
|
|
260
318
|
const grant = JSON.parse(await readFile(directory + "/credentials.json", "utf8"))
|
|
261
319
|
const localTools = privateGrant(grant.client_id)
|
|
262
320
|
? (grant.captureKey && grant.scope?.split(" ").includes("original:read") ? [encryptedReadTool] : [])
|
|
263
|
-
: grant.
|
|
264
|
-
|
|
265
|
-
: [attachmentTool]
|
|
266
|
-
result.result.tools = [...result.result.tools.filter((tool) => tool.name !== clarificationTool.name), setupTool, clarificationTool, ...localTools]
|
|
321
|
+
: grant.scope?.split(" ").includes("conversation:write") ? [attachmentTool] : []
|
|
322
|
+
result.result.tools = [...result.result.tools.filter((tool) => tool.name !== clarificationTool.name), setupTool, clarificationTool, ...localTools, ...localBridgeTools]
|
|
267
323
|
}
|
|
324
|
+
if (message.method === "tools/call" && result.result)
|
|
325
|
+
result.result = await withPluginUpdate(result.result)
|
|
268
326
|
write(result)
|
|
269
327
|
} catch (error) {
|
|
270
328
|
console.error("Acent request failed.")
|
|
@@ -296,3 +354,4 @@ for await (const line of lines) {
|
|
|
296
354
|
rootRequests.close()
|
|
297
355
|
questions.close()
|
|
298
356
|
await Promise.allSettled(active)
|
|
357
|
+
pluginUpdates?.close()
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { mkdir, readFile } from "node:fs/promises"
|
|
2
|
+
import { dirname, join } from "node:path"
|
|
3
|
+
import { fileURLToPath } from "node:url"
|
|
4
|
+
import { atomicJson, lock } from "./acent-connect.mjs"
|
|
5
|
+
|
|
6
|
+
const packageName = "@cirtium/acent-connect"
|
|
7
|
+
const releaseUrl =
|
|
8
|
+
"https://registry.npmjs.org/" + packageName.replace("/", "%2f") + "/latest"
|
|
9
|
+
const checkInterval = 24 * 60 * 60_000
|
|
10
|
+
const retryInterval = 60 * 60_000
|
|
11
|
+
const supportedTools = {
|
|
12
|
+
Codex: { manifest: ".codex-plugin/plugin.json", key: "codex", nested: true },
|
|
13
|
+
"Claude Code": {
|
|
14
|
+
manifest: ".claude-plugin/plugin.json",
|
|
15
|
+
key: "claude",
|
|
16
|
+
nested: true,
|
|
17
|
+
},
|
|
18
|
+
Cursor: { manifest: ".cursor-plugin/plugin.json", key: "cursor" },
|
|
19
|
+
Antigravity: { manifest: "plugin.json", key: "antigravity" },
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function readJson(path) {
|
|
23
|
+
try {
|
|
24
|
+
return JSON.parse(await readFile(path, "utf8"))
|
|
25
|
+
} catch (error) {
|
|
26
|
+
if (error.code !== "ENOENT" && !(error instanceof SyntaxError)) throw error
|
|
27
|
+
return null
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function parseVersion(version) {
|
|
32
|
+
if (typeof version !== "string") return null
|
|
33
|
+
const match = version.match(
|
|
34
|
+
/^(0|[1-9][0-9]{0,8})\.(0|[1-9][0-9]{0,8})\.(0|[1-9][0-9]{0,8})(?:-([a-z0-9-]+(?:\.[a-z0-9-]+)*))?(?:\+[a-z0-9-]+(?:\.[a-z0-9-]+)*)?$/i
|
|
35
|
+
)
|
|
36
|
+
return (
|
|
37
|
+
match && {
|
|
38
|
+
parts: match.slice(1, 4).map(Number),
|
|
39
|
+
prerelease: Boolean(match[4]),
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function newer(release, installed) {
|
|
45
|
+
const left = parseVersion(release)
|
|
46
|
+
const right = parseVersion(installed)
|
|
47
|
+
if (!left || left.prerelease || !right) return false
|
|
48
|
+
for (const [index, part] of left.parts.entries()) {
|
|
49
|
+
if (part !== right.parts[index]) return part > right.parts[index]
|
|
50
|
+
}
|
|
51
|
+
return right.prerelease
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export async function readPluginInstallation(
|
|
55
|
+
tool,
|
|
56
|
+
root = fileURLToPath(new URL("../", import.meta.url))
|
|
57
|
+
) {
|
|
58
|
+
const host = supportedTools[tool]
|
|
59
|
+
if (!host) return null
|
|
60
|
+
const manifest = await readJson(join(root, host.manifest))
|
|
61
|
+
if (manifest?.name !== "acent" || !parseVersion(manifest.version)) return null
|
|
62
|
+
const marker =
|
|
63
|
+
(await readJson(join(root, ".acent-cli-install.json"))) ??
|
|
64
|
+
(host.nested
|
|
65
|
+
? await readJson(join(dirname(root), ".acent-cli-install.json"))
|
|
66
|
+
: null)
|
|
67
|
+
const cli =
|
|
68
|
+
marker?.owner === "acent-cli" &&
|
|
69
|
+
marker.tool === tool &&
|
|
70
|
+
marker.version === manifest.version
|
|
71
|
+
return { tool, key: host.key, version: manifest.version, cli }
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const pluginUpdateInstructions =
|
|
75
|
+
"If a successful Acent tool response includes an Acent update notice, briefly show it in the user's language after addressing their request. Leave installation to the user's choice."
|
|
76
|
+
|
|
77
|
+
export function createPluginUpdateNotice({
|
|
78
|
+
installation,
|
|
79
|
+
configHome,
|
|
80
|
+
fetchRelease = fetch,
|
|
81
|
+
now = Date.now,
|
|
82
|
+
}) {
|
|
83
|
+
const directory = join(configHome, "plugin-updates")
|
|
84
|
+
const releaseDir = join(directory, "registry")
|
|
85
|
+
const releaseFile = join(releaseDir, "latest.json")
|
|
86
|
+
const noticeDir = join(
|
|
87
|
+
directory,
|
|
88
|
+
"notices",
|
|
89
|
+
installation.key,
|
|
90
|
+
installation.cli ? "cli" : "host"
|
|
91
|
+
)
|
|
92
|
+
const noticeFile = join(noticeDir, "shown.json")
|
|
93
|
+
const abort = new AbortController()
|
|
94
|
+
let cached
|
|
95
|
+
let pending
|
|
96
|
+
let nextCheck = 0
|
|
97
|
+
let shown
|
|
98
|
+
|
|
99
|
+
async function refresh() {
|
|
100
|
+
cached = await readJson(releaseFile)
|
|
101
|
+
if (cached?.retryAt > now()) {
|
|
102
|
+
nextCheck = cached.retryAt
|
|
103
|
+
return
|
|
104
|
+
}
|
|
105
|
+
await mkdir(releaseDir, { recursive: true, mode: 0o700 })
|
|
106
|
+
await lock(releaseDir, async () => {
|
|
107
|
+
cached = await readJson(releaseFile)
|
|
108
|
+
if (cached?.retryAt > now()) {
|
|
109
|
+
nextCheck = cached.retryAt
|
|
110
|
+
return
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
const response = await fetchRelease(releaseUrl, {
|
|
114
|
+
credentials: "omit",
|
|
115
|
+
redirect: "error",
|
|
116
|
+
signal: AbortSignal.any([abort.signal, AbortSignal.timeout(3000)]),
|
|
117
|
+
})
|
|
118
|
+
if (!response.ok) throw new Error("Acent release lookup failed")
|
|
119
|
+
const release = await response.json()
|
|
120
|
+
const version = parseVersion(release.version)
|
|
121
|
+
if (release.name !== packageName || !version || version.prerelease)
|
|
122
|
+
throw new Error("Invalid Acent release")
|
|
123
|
+
const checkedAt = now()
|
|
124
|
+
cached = {
|
|
125
|
+
version: release.version,
|
|
126
|
+
checkedAt,
|
|
127
|
+
retryAt: checkedAt + checkInterval,
|
|
128
|
+
}
|
|
129
|
+
} catch {
|
|
130
|
+
if (abort.signal.aborted) return
|
|
131
|
+
cached = { ...cached, retryAt: now() + retryInterval }
|
|
132
|
+
}
|
|
133
|
+
nextCheck = cached.retryAt
|
|
134
|
+
await atomicJson(releaseFile, cached)
|
|
135
|
+
})
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function check() {
|
|
139
|
+
if (pending || abort.signal.aborted || now() < nextCheck) return pending
|
|
140
|
+
nextCheck = now() + 1000
|
|
141
|
+
pending = refresh()
|
|
142
|
+
.catch(() => {})
|
|
143
|
+
.finally(() => {
|
|
144
|
+
pending = undefined
|
|
145
|
+
})
|
|
146
|
+
return pending
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async function take() {
|
|
150
|
+
void check()
|
|
151
|
+
const current = now()
|
|
152
|
+
if (
|
|
153
|
+
!Number.isFinite(cached?.checkedAt) ||
|
|
154
|
+
cached.checkedAt > current ||
|
|
155
|
+
current >= cached.checkedAt + checkInterval
|
|
156
|
+
)
|
|
157
|
+
return
|
|
158
|
+
const version = cached.version
|
|
159
|
+
if (
|
|
160
|
+
!newer(version, installation.version) ||
|
|
161
|
+
(parseVersion(shown) && !newer(version, shown))
|
|
162
|
+
)
|
|
163
|
+
return
|
|
164
|
+
try {
|
|
165
|
+
await mkdir(noticeDir, { recursive: true, mode: 0o700 })
|
|
166
|
+
let notice
|
|
167
|
+
await lock(noticeDir, async () => {
|
|
168
|
+
shown = (await readJson(noticeFile))?.version
|
|
169
|
+
if (parseVersion(shown) && !newer(version, shown)) return
|
|
170
|
+
await atomicJson(noticeFile, { version })
|
|
171
|
+
shown = version
|
|
172
|
+
notice = installation.cli
|
|
173
|
+
? `Acent plugin update available for ${installation.tool} (${installation.version} → ${version}). To update the Acent plugins installed by the CLI, run \`npx @cirtium/acent-connect@latest update --all\`.`
|
|
174
|
+
: `Acent ${version} has been released. This ${installation.tool} plugin reports ${installation.version}. Check Acent for updates in the ${installation.tool} plugin manager.`
|
|
175
|
+
})
|
|
176
|
+
return notice
|
|
177
|
+
} catch {
|
|
178
|
+
// A notification failure must leave the tool response usable.
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
void check()
|
|
183
|
+
return { check, take, close: () => abort.abort() }
|
|
184
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: acent-bridge
|
|
3
|
+
description: Acent Bridge delegates work to another coding agent in the current project. Use when the user asks to hand off a task, get an independent review or second opinion from another model, run independent work in parallel, or manage Bridge delegation.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Acent Bridge
|
|
7
|
+
|
|
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
|
+
|
|
10
|
+
- Use `acent_bridge_settings` to inspect project settings. Change them in the project's Bridge dialog in Acent. For automatic delegation, pass `automatic: true` when listing candidates and starting a task.
|
|
11
|
+
- 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
|
+
- 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
|
+
- Start with `acent_bridge_start`. Include the relevant files, prior 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
|
+
- 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.
|
|
15
|
+
- 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
|
+
- 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
|
+
- 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
|
+
- 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.
|
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.0.
|
|
5
|
+
"version": "1.0.2",
|
|
6
6
|
"description": "Recall past work, trace code changes, revisit decisions, and resume tasks with Acent.",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "Cirtium"
|
package/package.json
CHANGED
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
mkdir,
|
|
6
6
|
mkdtemp,
|
|
7
7
|
readFile,
|
|
8
|
-
readdir,
|
|
9
8
|
writeFile,
|
|
10
9
|
rename,
|
|
11
10
|
rm,
|
|
@@ -15,6 +14,7 @@ import {
|
|
|
15
14
|
import { homedir } from "node:os"
|
|
16
15
|
import { join, dirname } from "node:path"
|
|
17
16
|
import { fileURLToPath } from "node:url"
|
|
17
|
+
import { hostExecutableCandidates } from "../acent/scripts/host-executables.mjs"
|
|
18
18
|
import { build } from "../antigravity/build.mjs"
|
|
19
19
|
|
|
20
20
|
export const packageRoot = fileURLToPath(new URL("../", import.meta.url))
|
|
@@ -46,48 +46,9 @@ export function probe(tool, executable) {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
async function claudeDesktopExecutables(home) {
|
|
50
|
-
const root = join(home, "Library/Application Support/Claude/claude-code")
|
|
51
|
-
const versions = (await readdir(root, { withFileTypes: true }).catch(() => []))
|
|
52
|
-
.filter((entry) => entry.isDirectory() && /^\d+\.\d+\.\d+$/.test(entry.name))
|
|
53
|
-
.sort((a, b) => b.name.localeCompare(a.name, "en", { numeric: true }))
|
|
54
|
-
const executables = []
|
|
55
|
-
for (const version of versions) {
|
|
56
|
-
const directory = join(root, version.name)
|
|
57
|
-
const builds = await readdir(directory, { withFileTypes: true }).catch(() => [])
|
|
58
|
-
for (const entry of builds) {
|
|
59
|
-
if (entry.isDirectory() && /^[a-f0-9]+$/i.test(entry.name))
|
|
60
|
-
executables.push(
|
|
61
|
-
join(directory, entry.name, "claude.app/Contents/MacOS/claude")
|
|
62
|
-
)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return executables
|
|
66
|
-
}
|
|
67
|
-
|
|
68
49
|
export async function detect(tool, explicit) {
|
|
69
50
|
const info = probe(tool, explicit)
|
|
70
|
-
const
|
|
71
|
-
const candidates = explicit
|
|
72
|
-
? [explicit]
|
|
73
|
-
: [info.executable, join(home, ".local/bin", info.executable)]
|
|
74
|
-
if (tool === "Antigravity" && !explicit)
|
|
75
|
-
candidates.push(join(home, ".antigravity/antigravity/bin/agy"))
|
|
76
|
-
if (!explicit && process.platform === "darwin") {
|
|
77
|
-
if (tool === "Codex") {
|
|
78
|
-
for (const applications of ["/Applications", join(home, "Applications")]) {
|
|
79
|
-
candidates.push(
|
|
80
|
-
join(applications, "Codex.app/Contents/Resources/codex"),
|
|
81
|
-
join(
|
|
82
|
-
applications,
|
|
83
|
-
"ChatGPT.app/Contents/Resources/codex-cli/CodexCLI.app/Contents/MacOS/codex"
|
|
84
|
-
)
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
if (tool === "Claude Code")
|
|
89
|
-
candidates.push(...(await claudeDesktopExecutables(home)))
|
|
90
|
-
}
|
|
51
|
+
const candidates = explicit ? [explicit] : await hostExecutableCandidates(tool, info.executable)
|
|
91
52
|
for (const executable of candidates) {
|
|
92
53
|
const result = spawnSync(executable, info.args, {
|
|
93
54
|
encoding: "utf8",
|