@cirtium/acent-connect 1.0.0 → 1.0.1
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 +10 -1
- package/acent/scripts/capture-attachments.mjs +23 -8
- package/acent/scripts/mcp-proxy.mjs +1 -3
- package/antigravity/plugin.json +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { capturePayload, isToolActivityHook } from "./capture-policy.mjs"
|
|
3
3
|
import { captureActivity } from "./capture-activity.mjs"
|
|
4
|
+
import { attachFiles } from "./capture-attachments.mjs"
|
|
4
5
|
/** Local connection/capture adapter. No AI calls; credentials never go to stdout. */
|
|
5
6
|
import { captureCodeChanges } from "./capture-code-changes.mjs"
|
|
6
7
|
import { captureCodexEvent } from "./codex-capture.mjs"
|
|
@@ -415,7 +416,7 @@ export async function main(args = process.argv.slice(2), eventText) {
|
|
|
415
416
|
if (!policy.enabled) return
|
|
416
417
|
const code = policy.code === true
|
|
417
418
|
const activity = policy.activity === true
|
|
418
|
-
|
|
419
|
+
let payload = JSON.parse(content)
|
|
419
420
|
const hook = payload.acent_hook || payload.hook_event_name
|
|
420
421
|
const toolEvent = isToolActivityHook(hook)
|
|
421
422
|
if ((toolEvent && !activity && !code) || (hook === "afterFileEdit" && !code)) return
|
|
@@ -432,6 +433,14 @@ export async function main(args = process.argv.slice(2), eventText) {
|
|
|
432
433
|
const toolActivities = activity ? payload.acent_activity ?? [] : []
|
|
433
434
|
if ((codeEvent || activityEvent || toolEvent) && !changes.length && !toolActivities.length) return
|
|
434
435
|
if (config.tool === "Antigravity" && !codeEvent && !activityEvent && !(await captureAntigravityEvent(payload, captureDirectory))) return
|
|
436
|
+
if (policy.attachments === true && !codeEvent && !activityEvent && !toolEvent) {
|
|
437
|
+
try {
|
|
438
|
+
payload = (await attachFiles(payload, config, access, request, policy.destination)).payload
|
|
439
|
+
} catch {
|
|
440
|
+
// Keep conversation capture available if file storage is temporarily down.
|
|
441
|
+
console.error("Acent could not save the attached files.")
|
|
442
|
+
}
|
|
443
|
+
}
|
|
435
444
|
if (codeEvent || activityEvent) {
|
|
436
445
|
// Forward only bounded, redacted activity and validated edit records; never the raw host envelope.
|
|
437
446
|
const minimal = {
|
|
@@ -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 }
|
|
@@ -260,9 +260,7 @@ async function handleLine(line) {
|
|
|
260
260
|
const grant = JSON.parse(await readFile(directory + "/credentials.json", "utf8"))
|
|
261
261
|
const localTools = privateGrant(grant.client_id)
|
|
262
262
|
? (grant.captureKey && grant.scope?.split(" ").includes("original:read") ? [encryptedReadTool] : [])
|
|
263
|
-
: grant.
|
|
264
|
-
? []
|
|
265
|
-
: [attachmentTool]
|
|
263
|
+
: grant.scope?.split(" ").includes("conversation:write") ? [attachmentTool] : []
|
|
266
264
|
result.result.tools = [...result.result.tools.filter((tool) => tool.name !== clarificationTool.name), setupTool, clarificationTool, ...localTools]
|
|
267
265
|
}
|
|
268
266
|
write(result)
|
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.1",
|
|
6
6
|
"description": "Recall past work, trace code changes, revisit decisions, and resume tasks with Acent.",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "Cirtium"
|