@cirtium/acent-connect 0.4.0 → 1.0.0

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "acent",
3
- "version": "0.4.0",
3
+ "version": "1.0.0",
4
4
  "description": "Recall past work, trace code changes, revisit decisions, and resume tasks with Acent.",
5
5
  "mcpServers": "./mcp-claude.json",
6
6
  "hooks": "./hooks/claude.json"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "acent",
3
- "version": "0.4.0",
3
+ "version": "1.0.0",
4
4
  "description": "Recall past work, trace code changes, revisit decisions, and resume tasks with Acent.",
5
5
  "skills": "./skills/",
6
6
  "mcpServers": "./mcp-codex.json",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "acent",
3
- "version": "0.4.0",
3
+ "version": "1.0.0",
4
4
  "description": "Recall past work, trace code changes, revisit decisions, and resume tasks with Acent.",
5
5
  "author": {
6
6
  "name": "Cirtium"
@@ -1,12 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { createPairing, encryptCapture, privateGrant } from "./encrypted-capture.mjs"
2
+ import { capturePayload, isToolActivityHook } from "./capture-policy.mjs"
3
3
  import { captureActivity } from "./capture-activity.mjs"
4
4
  /** Local connection/capture adapter. No AI calls; credentials never go to stdout. */
5
5
  import { captureCodeChanges } from "./capture-code-changes.mjs"
6
6
  import { captureCodexEvent } from "./codex-capture.mjs"
7
7
  import { captureAntigravityEvent } from "./antigravity-capture.mjs"
8
- import { attachFiles } from "./capture-attachments.mjs"
9
- import { attachScreenshots } from "./capture-images.mjs"
10
8
  import { createHash, randomBytes } from "node:crypto"
11
9
  import {
12
10
  mkdir,
@@ -246,13 +244,19 @@ async function token(config, directory) {
246
244
  export async function drain(config, directory) {
247
245
  return lock(directory, async () => {
248
246
  const grant = await readCredentials(directory)
249
- const encrypted = privateGrant(grant.client_id)
250
- const queue = encrypted ? join(directory, "private-queue", hash(grant.client_id)) : join(directory, "queue")
247
+ if (!grant.client_id || grant.client_id.startsWith("ac_private_client_")) return
248
+ const queue = join(directory, "managed-queue", hash(grant.client_id))
251
249
  const files = (await readdir(queue).catch(error => { if (error.code === "ENOENT") return []; throw error }))
252
250
  .filter((file) => file.endsWith(".json"))
253
251
  .sort()
254
252
  if (!files.length) return
255
253
  const access = await token(config, directory)
254
+ const headers = { Authorization: "Bearer " + access }
255
+ const policy = await request(config, "/api/external/managed", { headers })
256
+ if (!policy.enabled) {
257
+ for (const file of files) await unlink(join(queue, file))
258
+ return
259
+ }
256
260
  const deferred = new Set()
257
261
  // A code event can race its prompt upload. Retry it after queued prompts;
258
262
  // never let an early 409 permanently block the request behind it.
@@ -260,22 +264,18 @@ export async function drain(config, directory) {
260
264
  const payload = JSON.parse(
261
265
  await readFile(join(queue, file), "utf8")
262
266
  )
267
+ // An outbox entry belongs to the project approved at capture time.
268
+ if (payload.acent_destination !== policy.destination) continue
263
269
  try {
264
- if (encrypted) {
265
- await request(config, "/api/external/encrypted", {
266
- method: "POST", headers: { Authorization: "Bearer " + access, "Content-Type": "application/json" },
267
- body: JSON.stringify(payload),
268
- })
269
- } else await request(config, "/api/external/collect", {
270
- method: "POST",
271
- headers: {
272
- Authorization: `Bearer ${access}`,
273
- "Content-Type": "application/json",
274
- },
275
- body: JSON.stringify({ source: config.tool, payload: await (async () => {
276
- const attachments = await attachFiles(payload, config, access, request)
277
- return attachments.enabled ? attachments.payload : await attachScreenshots(payload, config, access, request).catch(() => payload)
278
- })() }),
270
+ const filtered = capturePayload(payload, policy.code === true, policy.activity === true)
271
+ if ((payload.acent_code_changes || payload.acent_activity) &&
272
+ !filtered.acent_code_changes?.length && !filtered.acent_activity?.length) {
273
+ await unlink(join(queue, file))
274
+ continue
275
+ }
276
+ await request(config, "/api/external/managed", {
277
+ method: "POST", headers: { ...headers, "Content-Type": "application/json" },
278
+ body: JSON.stringify({ id: hash(file), destination: policy.destination, at: Number(file.split("-")[0]), payload: filtered }),
279
279
  })
280
280
  } catch (error) {
281
281
  if (error.status === 409 && error.code === "prompt_pending" && !deferred.has(file)) {
@@ -283,7 +283,12 @@ export async function drain(config, directory) {
283
283
  files.push(file)
284
284
  continue
285
285
  }
286
- if (error.status === 401 || error.status === 403) {
286
+ if (error.code === "destination_changed") continue
287
+ if (error.code === "capture_disabled") {
288
+ await unlink(join(queue, file))
289
+ continue
290
+ }
291
+ if (error.code === "invalid_token" || error.code === "insufficient_scope") {
287
292
  const credentials = JSON.parse(
288
293
  await readFile(join(directory, "credentials.json"), "utf8")
289
294
  )
@@ -291,7 +296,7 @@ export async function drain(config, directory) {
291
296
  ...credentials,
292
297
  captureBlocked: true,
293
298
  })
294
- if (encrypted) await rm(join(directory, "paired-capture", hash(grant.client_id)), {recursive:true, force:true})
299
+
295
300
  await rm(join(directory, "code-capture"), { recursive: true, force: true })
296
301
  for (const queued of await readdir(queue))
297
302
  await unlink(join(queue, queued))
@@ -318,16 +323,14 @@ export async function connect(config, directory, open = openBrowser) {
318
323
  await mkdir(connectionDirectory, { recursive: true, mode: 0o700 })
319
324
  const completed = await lock(connectionDirectory, async () => {
320
325
  const verifier = random()
321
- const pairing = await createPairing()
326
+
322
327
  const started = await request(config, "/api/external/setup/start", {
323
328
  method: "POST", headers: { "Content-Type": "application/json" },
324
- body: JSON.stringify({ tool: config.tool, folder: config.folder, encrypted: true, challenge: createHash("sha256").update(verifier).digest("base64url") }),
329
+ body: JSON.stringify({ tool: config.tool, folder: config.folder, managed: true, challenge: createHash("sha256").update(verifier).digest("base64url") }),
325
330
  })
326
331
  const url = new URL(started.authorization_url)
327
332
  if (url.origin !== config.server || url.pathname !== "/oauth/authorize" || !url.searchParams.has("setup"))
328
333
  throw new Error("Acent returned an invalid connection address.")
329
- url.searchParams.set("device", pairing.publicKey)
330
- url.hash = new URLSearchParams({ pairing: pairing.proof }).toString()
331
334
  const expires = Math.min(Date.parse(started.expires_at), Date.now() + 15 * 60_000)
332
335
  if (!Number.isFinite(expires) || expires <= Date.now() || !started.poll_token || !started.client_id)
333
336
  throw new Error("Acent returned an invalid connection session.")
@@ -341,17 +344,11 @@ export async function connect(config, directory, open = openBrowser) {
341
344
  if (tokens.status === "cancelled") throw new Error("Connection was cancelled.")
342
345
  if (tokens.status === "issued") {
343
346
  if (!tokens.access_token || !tokens.refresh_token) throw new Error("Connection response was incomplete. Request a new link.")
344
- if (!privateGrant(started.client_id)) throw new Error("Server does not support encrypted capture.")
345
- let captureKey, project
346
- if (tokens.scope?.split(" ").includes("conversation:write")) {
347
- const wrapped = await request(config, "/api/external/encrypted", { headers: { Authorization: "Bearer " + tokens.access_token } })
348
- project = wrapped.project
349
- captureKey = pairing.unwrap(wrapped.wrapped)
350
- }
347
+ if (!started.client_id.startsWith("ac_managed_client_")) throw new Error("Update the server before connecting.")
351
348
  let saved = false
352
349
  for (let attempt = 0; attempt < 200 && !saved; attempt++) {
353
350
  saved = await lock(directory, () => atomicJson(join(directory, "credentials.json"), {
354
- ...tokens, captureKey, project, client_id: started.client_id, expiresAt: Date.now() + tokens.expires_in * 1000,
351
+ ...tokens, client_id: started.client_id, expiresAt: Date.now() + tokens.expires_in * 1000,
355
352
  }))
356
353
  if (!saved) await new Promise(resolve => setTimeout(resolve, 100))
357
354
  }
@@ -387,7 +384,7 @@ export async function main(args = process.argv.slice(2), eventText) {
387
384
  .then(JSON.parse)
388
385
  .catch(() => null)
389
386
  if (
390
- !credentials ||
387
+ !credentials?.client_id || credentials.client_id.startsWith("ac_private_client_") ||
391
388
  credentials.captureBlocked ||
392
389
  !credentials.scope?.split(" ").includes("conversation:write")
393
390
  )
@@ -412,19 +409,28 @@ export async function main(args = process.argv.slice(2), eventText) {
412
409
  }))
413
410
  if (Buffer.byteLength(content) > 2 * 1024 * 1024)
414
411
  throw new Error("Event exceeds 2 MiB.")
415
- const captureDirectory = privateGrant(credentials.client_id) ? join(directory, "paired-capture", hash(credentials.client_id)) : directory
412
+ const captureDirectory = join(directory, "managed-capture", hash(credentials.client_id))
413
+ const access = await accessToken(config, directory)
414
+ const policy = await request(config, "/api/external/managed", { headers: { Authorization: "Bearer " + access } })
415
+ if (!policy.enabled) return
416
+ const code = policy.code === true
417
+ const activity = policy.activity === true
416
418
  const payload = JSON.parse(content)
419
+ const hook = payload.acent_hook || payload.hook_event_name
420
+ const toolEvent = isToolActivityHook(hook)
421
+ if ((toolEvent && !activity && !code) || (hook === "afterFileEdit" && !code)) return
417
422
  if (config.tool === "Codex" && !(await captureCodexEvent(payload, captureDirectory))) return
418
- const toolEvent = ["PreToolUse", "PostToolUse", "PostToolUseFailure"].includes(payload.acent_hook || payload.hook_event_name)
419
423
  if (config.tool === "Antigravity" && toolEvent) {
420
- await captureAntigravityEvent(payload, captureDirectory).catch(error => {
424
+ if (code) await captureAntigravityEvent(payload, captureDirectory).catch(() => {
421
425
  payload.acent_request = null
422
- console.error(`Acent request link unavailable: ${error.message}`)
426
+ console.error("Acent request link unavailable.")
423
427
  })
424
428
  }
425
- const codeEvent = await captureCodeChanges(payload, config, captureDirectory)
426
- const activityEvent = await captureActivity(payload, config, captureDirectory)
427
- if ((codeEvent || activityEvent) && !payload.acent_code_changes?.length && !payload.acent_activity?.length) return
429
+ const codeEvent = code && await captureCodeChanges(payload, config, captureDirectory)
430
+ const activityEvent = activity && await captureActivity(payload, config, captureDirectory, code)
431
+ const changes = code ? payload.acent_code_changes ?? [] : []
432
+ const toolActivities = activity ? payload.acent_activity ?? [] : []
433
+ if ((codeEvent || activityEvent || toolEvent) && !changes.length && !toolActivities.length) return
428
434
  if (config.tool === "Antigravity" && !codeEvent && !activityEvent && !(await captureAntigravityEvent(payload, captureDirectory))) return
429
435
  if (codeEvent || activityEvent) {
430
436
  // Forward only bounded, redacted activity and validated edit records; never the raw host envelope.
@@ -440,16 +446,15 @@ export async function main(args = process.argv.slice(2), eventText) {
440
446
  }
441
447
  const events = codeEvent || activityEvent
442
448
  ? [
443
- ...(payload.acent_code_changes ?? []).map(change => ({ ...payload, acent_activity: undefined, acent_code_changes: [change] })),
444
- ...(payload.acent_activity ?? []).map(activity => ({ ...payload, acent_code_changes: undefined, acent_activity: [activity] })),
449
+ ...changes.map(change => ({ ...payload, acent_activity: undefined, acent_code_changes: [change] })),
450
+ ...toolActivities.map(record => ({ ...payload, acent_code_changes: undefined, acent_activity: [record] })),
445
451
  ]
446
452
  : [payload]
447
453
  if (events.some(event => Buffer.byteLength(JSON.stringify(event)) > 2 * 1024 * 1024))
448
454
  throw new Error("Collected event exceeds 2 MiB.")
449
- const encrypted = privateGrant(credentials.client_id)
450
- const queue = encrypted ? join(directory, "private-queue", hash(credentials.client_id)) : join(directory, "queue")
455
+ const queue = join(directory, "managed-queue", hash(credentials.client_id))
451
456
  await mkdir(queue, { recursive: true, mode: 0o700 })
452
- const packets = encrypted ? events.map(event => encryptCapture(event, credentials, config.tool)) : events
457
+ const packets = events.map(event => ({ ...capturePayload(event, code, activity), acent_destination: policy.destination }))
453
458
  const eventBytes = packets.reduce((sum, event) => sum + Buffer.byteLength(JSON.stringify(event)), 0)
454
459
  async function capacityError() {
455
460
  const files = (await readdir(queue)).filter(file => file.endsWith(".json"))
@@ -493,6 +498,8 @@ export async function main(args = process.argv.slice(2), eventText) {
493
498
  }),
494
499
  })
495
500
  await unlink(file)
501
+ await rm(join(directory, "managed-capture"), {recursive:true, force:true})
502
+ await rm(join(directory, "managed-queue"), {recursive:true, force:true})
496
503
  await rm(join(directory, "paired-capture"), {recursive:true, force:true})
497
504
  await rm(join(directory, "private-queue"), { recursive: true, force: true })
498
505
  await rm(join(directory, "code-capture"), { recursive: true, force: true })
@@ -504,6 +511,6 @@ export async function main(args = process.argv.slice(2), eventText) {
504
511
  }
505
512
  if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
506
513
  main().catch((error) => {
507
- console.error(error.message)
514
+ console.error("Acent request failed.")
508
515
  process.exitCode = 1
509
516
  })
@@ -10,7 +10,6 @@ try {
10
10
  }
11
11
  const payload = JSON.parse(raw)
12
12
  payload.acent_hook = process.argv[2]
13
- console.error("Acent capture timing: " + JSON.stringify({at:new Date().toISOString(),stage:"hook",event:payload.acent_hook,fullyIdle:payload.fullyIdle === true,terminationReason:payload.terminationReason,hasError:!!payload.error}))
14
13
  if (!["PreInvocation", "PostInvocation", "Stop", "PreToolUse", "PostToolUse"].includes(payload.acent_hook)) throw new Error("Unknown Antigravity hook.")
15
14
  await new Promise((resolve, reject) => {
16
15
  const child = spawn(process.execPath, [fileURLToPath(new URL("./hook.mjs", import.meta.url)), "--tool", "Antigravity"],
@@ -21,6 +20,6 @@ try {
21
20
  child.stdin.end(JSON.stringify(payload))
22
21
  })
23
22
  console.error("Acent capture timing: " + JSON.stringify({at:new Date().toISOString(),stage:"finished",durationMs:Date.now()-started}))
24
- } catch (error) { console.error(`Acent saving: ${error.message}`) }
23
+ } catch (error) { console.error("Acent could not save this event.") }
25
24
  // Hooks must emit a JSON object and must never force the agent to continue.
26
25
  process.stdout.write("{}\n")
@@ -31,7 +31,7 @@ export function redactActivity(value) {
31
31
  const text = typeof clean === "string" ? clean : JSON.stringify(clean, null, 2)
32
32
  return { text: text.slice(0, 16000), truncated: clipped || text.length > 16000 || JSON.stringify(value).length > 16000 }
33
33
  }
34
- export async function captureActivity(p, config, directory) {
34
+ export async function captureActivity(p, config, directory, includeContent = true) {
35
35
  const event = p.acent_hook || p.hook_event_name
36
36
  const pre = ["PreToolUse", "preToolUse"].includes(event)
37
37
  const post = ["PostToolUse", "PostToolUseFailure", "postToolUse", "postToolUseFailure"].includes(event)
@@ -50,10 +50,12 @@ export async function captureActivity(p, config, directory) {
50
50
  const state = await read(path)
51
51
  if (state?.completed) { if (post) p.acent_activity = [state.completed]; return true }
52
52
  const hostTurn = config.tool === "Codex" ? p.turn_id : config.tool === "Cursor" ? p.generation_id : p.acent_turn_id || p.prompt_id
53
- let request = config.tool === "Antigravity" ? p.acent_request : await read(join(directory, "code-capture", hash(session) + ".request.json"))
53
+ let request = includeContent
54
+ ? config.tool === "Antigravity" ? p.acent_request : await read(join(directory, "code-capture", hash(session) + ".request.json"))
55
+ : null
54
56
  if (hostTurn && request?.turnId !== hostTurn) request = null
55
57
  if (request) request = { ...request, content: redactActivity(request.content).text, truncated: request.content.length > 16000 }
56
- const input = redactActivity(p.tool_input ?? p.toolCall?.args)
58
+ const input = redactActivity(includeContent ? p.tool_input ?? p.toolCall?.args : null)
57
59
  const at = new Date().toISOString()
58
60
  if (pre) {
59
61
  if (!state) await save(path, { request, input, at })
@@ -82,9 +84,9 @@ export async function captureActivity(p, config, directory) {
82
84
  const record = {
83
85
  id, callId, name: name.slice(0, 300), kind, status, capturedAt: at,
84
86
  startedAt: state?.at ?? null, durationMs: duration == null ? null : Math.min(Math.round(duration), 604800000),
85
- request: state ? state.request : hostTurn || p.acent_request ? request : null,
86
- input: input.text === null && state ? state.input : input,
87
- output: redactActivity(raw),
87
+ request: includeContent ? (state ? state.request : hostTurn || p.acent_request ? request : null) : null,
88
+ input: includeContent && input.text === null && state ? state.input : input,
89
+ output: redactActivity(includeContent ? raw : null),
88
90
  changeIds: (p.acent_code_changes ?? []).map(change => change.id).slice(0, 32),
89
91
  }
90
92
  await save(path, { completed: record })
@@ -0,0 +1,89 @@
1
+ export function isToolActivityHook(hook) {
2
+ return ["PreToolUse", "PostToolUse", "PostToolUseFailure",
3
+ "preToolUse", "postToolUse", "postToolUseFailure"].includes(hook)
4
+ }
5
+
6
+ // Only conversation fields understood by the host adapters cross the capture boundary.
7
+ export function capturePayload(event, code, activity) {
8
+ /** @type {Record<string, any>} */
9
+ const result = {}
10
+ for (const field of [
11
+ "session_id",
12
+ "conversation_id",
13
+ "conversationId",
14
+ "turn_id",
15
+ "prompt_id",
16
+ "generation_id",
17
+ "acent_turn_id",
18
+ "model",
19
+ "modelName",
20
+ "hook_event_name",
21
+ "event",
22
+ "prompt",
23
+ "last_assistant_message",
24
+ "text",
25
+ "response",
26
+ ]) {
27
+ if (typeof event[field] === "string") result[field] = event[field]
28
+ }
29
+ function message(item) {
30
+ if (!item || !["user", "assistant"].includes(item.role)) return null
31
+ const content =
32
+ typeof item.content === "string"
33
+ ? item.content
34
+ : Array.isArray(item.content)
35
+ ? item.content
36
+ .filter(
37
+ (part) => part?.type === "text" && typeof part.text === "string"
38
+ )
39
+ .map((part) => part.text)
40
+ .join("")
41
+ : ""
42
+ return {
43
+ role: item.role,
44
+ content,
45
+ ...(typeof item.model === "string" && { model: item.model }),
46
+ ...(typeof item.turnId === "string" && { turnId: item.turnId }),
47
+ }
48
+ }
49
+ if (Array.isArray(event.messages))
50
+ result.messages = event.messages.map(message).filter(Boolean)
51
+ if (event.message)
52
+ result.message = message({
53
+ ...event.message,
54
+ role: event.message.role ?? "user",
55
+ })
56
+ if (event.result)
57
+ result.result = Object.fromEntries(
58
+ ["response", "conversation_id"]
59
+ .filter((field) => typeof event.result[field] === "string")
60
+ .map((field) => [field, event.result[field]])
61
+ )
62
+ if (Number.isSafeInteger(event.num_turns)) result.num_turns = event.num_turns
63
+ if (result.result && Number.isSafeInteger(event.result?.num_turns))
64
+ result.result.num_turns = event.result.num_turns
65
+ if (activity && Array.isArray(event.acent_activity))
66
+ result.acent_activity = event.acent_activity.map((item) =>
67
+ code
68
+ ? item
69
+ : {
70
+ id: item.id,
71
+ callId: item.callId,
72
+ name: item.name,
73
+ kind: item.kind,
74
+ status: item.status,
75
+ capturedAt: item.capturedAt,
76
+ startedAt: item.startedAt,
77
+ durationMs: item.durationMs,
78
+ request: null,
79
+ input: { text: null, truncated: false },
80
+ output: { text: null, truncated: false },
81
+ changeIds: [],
82
+ }
83
+ )
84
+ if (code && Array.isArray(event.acent_code_changes))
85
+ result.acent_code_changes = event.acent_code_changes
86
+ if (code && Array.isArray(event.acent_activities))
87
+ result.acent_activities = event.acent_activities
88
+ return result
89
+ }
@@ -1,83 +1,4 @@
1
- import {
2
- createCipheriv,
3
- createHash,
4
- generateKeyPair,
5
- privateDecrypt,
6
- randomBytes,
7
- timingSafeEqual,
8
- } from "node:crypto"
9
- import { promisify } from "node:util"
10
-
11
- export async function createPairing() {
12
- const pair = await promisify(generateKeyPair)("rsa", { modulusLength: 3072 })
13
- const challenge = randomBytes(32)
14
- return {
15
- proof: challenge.toString("base64url"),
16
- publicKey: pair.publicKey
17
- .export({ type: "spki", format: "der" })
18
- .toString("base64url"),
19
- unwrap(ciphertext) {
20
- const key = privateDecrypt(
21
- { key: pair.privateKey, oaepHash: "sha256" },
22
- Buffer.from(ciphertext, "base64")
23
- )
24
- if (key.length !== 64 || !timingSafeEqual(key.subarray(0, 32), challenge))
25
- throw new Error("Device pairing failed verification.")
26
- return key.subarray(32).toString("base64")
27
- },
28
- }
29
- }
30
-
31
- // Encode only host fields consumed by the conversation and activity readers.
32
- const fields = [
33
- "session_id",
34
- "conversation_id",
35
- "conversationId",
36
- "turn_id",
37
- "prompt_id",
38
- "generation_id",
39
- "acent_turn_id",
40
- "model",
41
- "modelName",
42
- "hook_event_name",
43
- "event",
44
- "messages",
45
- "prompt",
46
- "last_assistant_message",
47
- "text",
48
- "message",
49
- "response",
50
- "num_turns",
51
- "result",
52
- "acent_activity",
53
- "acent_code_changes",
54
- "acent_activities",
55
- ]
56
-
57
- export function encryptCapture(event, credentials, source) {
58
- const key = Buffer.from(credentials.captureKey ?? "", "base64")
59
- if (key.length !== 32)
60
- throw new Error("Encrypted capture requires a paired key.")
61
- const payload = Object.fromEntries(
62
- fields
63
- .filter((field) => field in event)
64
- .map((field) => [field, event[field]])
65
- )
66
- const iv = randomBytes(12)
67
- const cipher = createCipheriv("aes-256-gcm", key, iv)
68
- cipher.setAAD(Buffer.from("acent:external:v1:" + credentials.client_id))
69
- const body = Buffer.from(JSON.stringify({ source, project: credentials.project, at: Date.now(), payload }))
70
- const sealed = Buffer.concat([
71
- iv,
72
- cipher.update(body),
73
- cipher.final(),
74
- cipher.getAuthTag(),
75
- ])
76
- return {
77
- id: createHash("sha256").update(sealed).digest("hex"),
78
- ciphertext: sealed.toString("base64"),
79
- }
80
- }
1
+ import { createHash } from "node:crypto"
81
2
 
82
3
  export const privateGrant = (id) =>
83
4
  typeof id === "string" && id.startsWith("ac_private_client_")
@@ -120,9 +41,10 @@ export async function readEncryptedRecords(
120
41
  )
121
42
  throw new Error("Invalid search.")
122
43
  const init = { headers: { Authorization: "Bearer " + access } }
44
+ const endpoint = "/api/external/encrypted"
123
45
  const page = args.id
124
46
  ? { records: [args.id], nextOffset: null }
125
- : await request(config, "/api/external/encrypted?" + params, init)
47
+ : await request(config, endpoint + "?" + params, init)
126
48
  const key = await crypto.subtle.importKey(
127
49
  "raw",
128
50
  Buffer.from(grant.captureKey, "base64"),
@@ -135,7 +57,7 @@ export async function readEncryptedRecords(
135
57
  if (!/^[a-f0-9]{64}$/.test(id)) throw new Error("Invalid record ID.")
136
58
  const record = await request(
137
59
  config,
138
- "/api/external/encrypted?records=1&id=" + id,
60
+ endpoint + "?records=1&id=" + id,
139
61
  init
140
62
  )
141
63
  const bytes = Buffer.from(record.ciphertext, "base64")
@@ -28,5 +28,5 @@ try {
28
28
 
29
29
  } catch (error) {
30
30
  // Acent outages must not block or mark a successful AI turn as failed.
31
- console.error(`Acent saving: ${error.message}`)
31
+ console.error("Acent could not save this event.")
32
32
  }
@@ -0,0 +1,62 @@
1
+ // Shared by new captures and the device that indexes older immutable records.
2
+ export function listFields(record) {
3
+ const event = record.payload ?? {}
4
+ const sessionId =
5
+ record.kind === "summary"
6
+ ? record.sessionId
7
+ : record.source === "Cursor"
8
+ ? event.conversation_id
9
+ : record.source === "Antigravity"
10
+ ? event.conversationId ||
11
+ event.conversation_id ||
12
+ event.result?.conversation_id
13
+ : event.session_id
14
+ const result = record.result ?? {}
15
+ const first = event.messages?.find?.((m) => typeof m?.content === "string")
16
+ const message =
17
+ event.prompt ||
18
+ first?.content ||
19
+ event.message?.content ||
20
+ event.last_assistant_message ||
21
+ event.text ||
22
+ event.result?.response ||
23
+ event.response
24
+ const summary = record.kind === "summary"
25
+ const completed =
26
+ event.hook_event_name === "Stop" ||
27
+ event.hook_event_name === "afterAgentResponse" ||
28
+ event.event === "result" ||
29
+ event.messages?.at?.(-1)?.role === "assistant"
30
+ const project = typeof record.project === "string" ? record.project : ""
31
+ return {
32
+ sessionId: typeof sessionId === "string" ? sessionId.trim() : "",
33
+ type: summary
34
+ ? "summary"
35
+ : typeof message === "string" && message.trim()
36
+ ? "message"
37
+ : "event",
38
+ pending: summary
39
+ ? !!record.more
40
+ : completed
41
+ ? true
42
+ : message
43
+ ? false
44
+ : undefined,
45
+ decision: !!result.decisions?.length,
46
+ learning: !!result.learnings?.length,
47
+ preview: {
48
+ title: String(
49
+ summary
50
+ ? result.title || record.source
51
+ : (typeof message === "string" && message.trim()) ||
52
+ record.source ||
53
+ ""
54
+ ).slice(0, 100),
55
+ body: String(result.summary || "").slice(0, 220),
56
+ project,
57
+ source: record.source,
58
+ model: String(event.model || event.modelName || "").slice(0, 80),
59
+ summaryStatus: summary ? "Summarized" : "Original conversation",
60
+ },
61
+ }
62
+ }
@@ -99,7 +99,7 @@ async function startConnection(config) {
99
99
  })
100
100
  .catch((error) => {
101
101
  ready.reject(error)
102
- console.error(`Acent: ${error.message}`)
102
+ console.error("Acent request failed.")
103
103
  })
104
104
  .finally(() => {
105
105
  pendingConnection = undefined
@@ -234,7 +234,7 @@ async function handleLine(line) {
234
234
  }
235
235
  if (message.method === "tools/call" && message.params?.name === encryptedReadTool.name) {
236
236
  const grant = JSON.parse(await readFile(directory + "/credentials.json", "utf8"))
237
- if (!privateGrant(grant.client_id)) throw new Error("Encrypted connection required.")
237
+ if (!privateGrant(grant.client_id)) throw new Error("Session access unavailable.")
238
238
  const value = await readEncryptedRecords(config, grant, access, message.params.arguments ?? {}, request)
239
239
  reply(content(JSON.stringify(value)))
240
240
  return
@@ -260,12 +260,14 @@ 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
- : [attachmentTool]
263
+ : grant.client_id?.startsWith("ac_managed_client_")
264
+ ? []
265
+ : [attachmentTool]
264
266
  result.result.tools = [...result.result.tools.filter((tool) => tool.name !== clarificationTool.name), setupTool, clarificationTool, ...localTools]
265
267
  }
266
268
  write(result)
267
269
  } catch (error) {
268
- console.error(`Acent: ${error.message}`)
270
+ console.error("Acent request failed.")
269
271
  if (message?.id !== undefined)
270
272
  write({
271
273
  jsonrpc: "2.0",
@@ -3,6 +3,7 @@
3
3
  export const memoryInstructions = [
4
4
  "Acent has five named skills: Acent Recall finds past context; Acent Trace explains saved code edits; Acent Decisions retrieves choices and reasons; Acent Resume continues saved work; Acent Connect manages connection setup. Recognize these names in user requests and use the relevant exposed tools. These are workflows within the Acent plugin, not separate connections. Automatic capture remains controlled by saving consent.",
5
5
  "Use connected Acent as the first source for missing project history when it could change the answer or next action, including within the same conversation or after context compaction. Search before asking the user to restate that history, even without an explicit mention of Acent. For example, if the user says 'do it like last time' or '저번처럼 해줘' and the earlier approach is unclear, search using the task, feature, or error they mention. Also retrieve for resumed work, unexplained past decisions or constraints, conflicting records, and recurring failures where earlier attempts could affect the next step. Skip retrieval when the current context and files already answer the question. Reuse evidence already read and search again when the task changes, a reference is stale, or later corrections may matter.",
6
+ "When looking for conversations saved by this plugin connection, use read_saved_sessions when available. For an earlier device-encrypted connection use read_encrypted_sessions when available. Follow the returned pagination to continue a search.",
6
7
  "Choose one focused entry point rather than calling every search tool. For recent work without a named task use get_recent_work first (just now, earlier, recently, 방금, 방금 전, 좀 전, 아까, 최근). An agent name identifies the source, so for '방금 Codex에서 어디까지 했지?' call get_recent_work with provider=codex when supported. For a named task use get_handoff with the task topic; for a specific choice, rejection, change or reported outcome use get_decision_context with 1–8 distinctive keywords. Use search_evidence for missing details, failed attempts, conflicts or later unsummarized corrections; use keyword mode for exact code or errors and hybrid for meaning. Use read_evidence for selected passages that need more context. To open the exact archived decision message, use read_original with the originalReference id and messageIndex when available. For saved files or images use search_attachments with a known sourceId, filename, extracted text or distinctive surrounding words. Use read_saved_file for extracted document text and follow nextOffset only as needed. Check analysis_status: partial is not the whole file and saved does not mean analyzed. Image links are not visual inspection.",
7
8
  "Read the smallest relevant scope. Follow nextOffset only while the question remains unresolved; do not dump the whole project or send entire conversations as search queries. If a focused search misses, try a distinct term or permitted source before declaring the evidence unavailable; avoid repeated equivalent searches. No result does not prove no decision exists. Only use exposed tools within the approved project and account-wide scope. If original access is unavailable, use search_memories and read_memory when available, state the coverage limit, and never bypass it. If retrieval fails, report the limitation and continue independent work; ask for missing information only when needed for the dependent task.",
8
9
  "For questions about past events, success, or decision reasons, use the evidence already available when it clearly supports the answer. Search original evidence and open the relevant passage with surrounding turns when summaries or excerpts are ambiguous, conflicting, incomplete, or fail to establish the requested fact. Also read the original when the user explicitly requests it or exact wording matters. Do not open originals routinely merely because a question concerns the past. Use read_evidence with the returned ID and revision, read_original with the originalReference ID and messageIndex, or read_context for legacy row hits. Reuse an original passage already read when it contains enough context. Continue adjacent passages or pagination only until the claimed action, its reported result, and relevant later corrections are clear. These read-only steps within approved access do not require another confirmation.",
@@ -195,6 +195,6 @@ if (
195
195
  import.meta.url === pathToFileURL(resolve(process.argv[1])).href
196
196
  )
197
197
  provideDiff(process.argv.slice(2)).catch((error) => {
198
- console.error(error.message)
198
+ console.error("Acent could not prepare the diff.")
199
199
  process.exitCode = 1
200
200
  })
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://antigravity.google/schemas/v1/plugin.json",
3
3
  "name": "acent",
4
4
  "displayName": "Acent",
5
- "version": "0.4.0",
5
+ "version": "1.0.0",
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cirtium/acent-connect",
3
- "version": "0.4.0",
3
+ "version": "1.0.0",
4
4
  "type": "module",
5
5
  "description": "Install and connect the shared Acent coding-tool plugin",
6
6
  "repository": {