@theronap/agnoclast-mcp 0.9.324 → 0.9.326

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.
@@ -0,0 +1,48 @@
1
+ // capture_record files its own save (ADR-0101 §2.2). Every account seals every capture into private intake, and a
2
+ // save the person asked for "already carries the judgment … sealed, then filed in the same call by every surface
3
+ // that creates it". The hosted connector did that (fileSealedUnit, web/lib/mcp/tools.ts); this package did not, so
4
+ // an agent on it (Muse's runner, Hermes) left each save sealed as a unit nobody would file — found in the agent
5
+ // harness spike, 2026-11-06, when Grok's save became a record and Muse's and Hermes's did not.
6
+ //
7
+ // Claim first, as every filer must: a materialize resolves whatever claim is on a unit, so filing an unclaimed one
8
+ // could close a session's lease. fetchCortex already sends this process's x-cortex-session-key.
9
+ //
10
+ // NOTES. This package's default source is 'handoff', a TRANSCRIPT source, and the materialize route files a
11
+ // transcript only with notes (`notes_required`; two layers on every transcript, Theron 2026-10-08). The caller's
12
+ // `summary` IS the notes. A short note with none is its own gist, so its text is passed as its notes; a long one
13
+ // with none stays sealed and the reply asks for a summary (first live run, Hermes, 2026-11-07).
14
+ export const SHORT_NOTE_CHARS = 2000
15
+
16
+ /** PURE. The notes to file a capture with: the caller's summary, else a short note's own text, else null. */
17
+ export function notesFor({ summary, text }) {
18
+ if (typeof summary === 'string' && summary.trim()) return summary.trim()
19
+ if (typeof text === 'string' && text.trim() && text.trim().length <= SHORT_NOTE_CHARS) return text.trim()
20
+ return null
21
+ }
22
+
23
+ /**
24
+ * File one sealed capture as a record in `orgId`. `fetchJson(path, body)` POSTs and resolves to
25
+ * `{ ok: boolean, status: number, body: object|null }`; it must not throw (callers wrap the network).
26
+ * @returns {Promise<{ ok: true, recordId: string|null } | { ok: false, why: string }>}
27
+ */
28
+ export async function fileSealedCapture(fetchJson, { intakeItemId, orgId, title, summary, text }) {
29
+ if (!intakeItemId || !orgId) return { ok: false, why: 'the save came back without its unit or brain' }
30
+ const c = await fetchJson('/api/intake/claim', { claimKind: 'relevance', intakeItemIds: [intakeItemId] })
31
+ if (!c.ok) return { ok: false, why: `could not hold it to file (${c.body?.error ?? `HTTP ${c.status}`})` }
32
+ const outcome = (c.body?.outcomes ?? []).find((o) => (o.intakeItemId ?? o.id) === intakeItemId)?.outcome
33
+ if (outcome && outcome !== 'claimed' && outcome !== 'held_by_you') return { ok: false, why: `it cannot be filed now (${outcome})` }
34
+ const m = await fetchJson('/api/intake/materialize', {
35
+ intakeItemId,
36
+ orgId,
37
+ documentIds: [],
38
+ // NESTED under `record`: the route ignores a top-level title (see log_session's materialize in server.mjs).
39
+ record: { ...(title ? { title } : {}), ...(notesFor({ summary, text }) ? { summary: notesFor({ summary, text }) } : {}) },
40
+ attachmentMeta: [],
41
+ origin: 'session',
42
+ })
43
+ if (!m.ok) {
44
+ const b = m.body ?? {}
45
+ return { ok: false, why: `not filed: ${b.error ?? `HTTP ${m.status}`}${b.hint ? ` — ${b.hint}` : b.detail ? ` — ${b.detail}` : ''}` }
46
+ }
47
+ return { ok: true, recordId: m.body?.recordId ?? null }
48
+ }
@@ -23,6 +23,8 @@ export const REGULAR_ONLY_TOOLS = [
23
23
  'relabel_record_people', 'supersede_record', 'move_record', 'contain_record', 'pending_records', 'claim_record',
24
24
  'route_record', 'unroute_record', 'request_file', 'get_file', 'create_custom_source', 'search_spam_email',
25
25
  'gmail_modify', 'draft_email_reply', 'request_send_email', 'send_imessage',
26
+ // Agents are Regular (obligation ea1ee929).
27
+ 'hand_task', 'my_tasks', 'tasks_waiting', 'hold_task', 'finish_task', 'handed_tasks', 'set_working_hours',
26
28
  ]
27
29
 
28
30
  /** What a locked tool answers when the check itself could not be made. Nothing was run. */
@@ -20,6 +20,8 @@ const SOURCE_LABEL = {
20
20
  github: 'GitHub', email: 'Email', 'email-in': 'Email', gmail: 'Email', 'claude-code': 'Claude Code session',
21
21
  imessage: 'Text messages', 'google-calendar': 'Calendar', 'agnoclast-calendar': 'Calendar',
22
22
  handoff: 'Transcript or document', meeting: 'Meeting',
23
+ // Every remote connector's saves, not only claude.ai's: which AI made one is rec.capturedBy (header line below).
24
+ 'claude-connector': 'Saved through a connector',
23
25
  }
24
26
 
25
27
  const label = (source) => SOURCE_LABEL[source] ?? source
@@ -38,7 +40,8 @@ export function renderRecord(rec, maxChars = READ_RECORD_DEFAULT_CHARS, part = '
38
40
  const cap = Number.isFinite(maxChars) && maxChars > 0 ? Math.trunc(maxChars) : READ_RECORD_DEFAULT_CHARS
39
41
  const out = []
40
42
  out.push(`# ${rec.title || '(untitled record)'}`)
41
- out.push(`${label(rec.source)} · ${rec.occurredAt} · brain ${rec.brain?.name ?? rec.brain ?? '?'}${rec.superseded ? ' · ⚠ superseded by a newer version' : ''}`)
43
+ const by = typeof rec.capturedBy === 'string' && rec.capturedBy ? ` (${rec.capturedBy})` : ''
44
+ out.push(`${label(rec.source)}${by} · ${rec.occurredAt} · brain ${rec.brain?.name ?? rec.brain ?? '?'}${rec.superseded ? ' · ⚠ superseded by a newer version' : ''}`)
42
45
  out.push(`id: ${rec.id}`)
43
46
  out.push('')
44
47
  const content = typeof rec.content === 'string' ? rec.content : ''
package/lib/server.mjs CHANGED
@@ -46,6 +46,7 @@ import {
46
46
  UPDATE_EVENT_DESCRIPTION, UPDATE_SERIES_DESCRIPTION, renderEventCancelled, renderSeriesRevised, seriesPatchBody,
47
47
  } from './calendar_events.mjs'
48
48
  import { formatFoundDocuments } from './found_documents.mjs'
49
+ import { fileSealedCapture } from './file_sealed_capture.mjs'
49
50
 
50
51
  // PAGE tiers (ADR-0071). Six for a PAGE; a RECORD keeps three (`privacy` on log_session and
51
52
  // set_record_privacy below) — an owner-relative tier is applied to a page's records when they are read
@@ -4431,8 +4432,36 @@ function renderNudge(payload) {
4431
4432
  // On a private-intake account the content is stored encrypted and becomes a record only when
4432
4433
  // materialised — so it cannot be found, routed or contained until then. Reporting it as a
4433
4434
  // plain success is how someone believes a transcript is filed when it is sitting sealed.
4435
+ // ADR-0101 §2.2: a save the person asked for is sealed, then FILED IN THE SAME CALL — the brain is named and the
4436
+ // judgment is made. Only when filing fails does the unit stay sealed, and the reply below says so.
4437
+ let fileFailed = null
4438
+ if (body.sealed && body.intakeItemId && body.orgId && !body.duplicate) {
4439
+ const filed = await fileSealedCapture(async (path, payload) => {
4440
+ try {
4441
+ const r = await fetchCortex(`${BASE}${path}`, {
4442
+ method: 'POST',
4443
+ headers: { Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'application/json' },
4444
+ body: JSON.stringify(payload),
4445
+ })
4446
+ return { ok: r.ok, status: r.status, body: await r.json().catch(() => null) }
4447
+ } catch (e) {
4448
+ return { ok: false, status: 0, body: { error: e.message } }
4449
+ }
4450
+ }, { intakeItemId: body.intakeItemId, orgId: body.orgId, title, summary, text })
4451
+ if (filed.ok) {
4452
+ const lines = [`Captured "${title}" as record ${filed.recordId ?? '(id not returned)'}.`]
4453
+ if (body.identifiers?.length || body.routed_by?.length) lines.push(`Routes via: ${(body.routed_by ?? body.identifiers).join(', ')} — it reaches whatever page claims those.`)
4454
+ else lines.push('⚠ NO IDENTIFIERS — this record reaches no page. Nobody will find it unless you give it one (identifiers) or attach it by hand.')
4455
+ if (body.containerDeferred) lines.push(`Placed inside container ${body.containerRecordId} as it was filed.`)
4456
+ const check = obligationCheckLine(spawnObligationWorker(filed.recordId ? { target: { recordId: filed.recordId }, text, title } : { target: { intakeItemId: body.intakeItemId }, text, title }), false)
4457
+ if (check) lines.push(check)
4458
+ return { content: [{ type: 'text', text: lines.join('\n') }] }
4459
+ }
4460
+ fileFailed = filed.why
4461
+ }
4434
4462
  if (body.sealed) {
4435
4463
  const l = [`Stored "${title}" as a SEALED private-intake unit (${body.intakeItemId}).`]
4464
+ if (fileFailed) l.push(`Filing it in the same call failed (${fileFailed}). ${/notes_required/.test(fileFailed) ? 'Capture it again with `summary` (the notes: the gist, decisions, action items), or ' : ''}File it with intake_materialize, naming the page it is about.`)
4436
4465
  l.push('It is NOT a record yet — it becomes one when you materialise it, and only then can it be routed or placed in a container.')
4437
4466
  if (body.duplicate) l.push('This matched an existing unit rather than creating a new one.')
4438
4467
  if (body.routed_by?.length) l.push(`Carries: ${body.routed_by.join(', ')} — it will route on those once materialised.`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theronap/agnoclast-mcp",
3
- "version": "0.9.324",
3
+ "version": "0.9.326",
4
4
  "description": "Connect your AI assistant to Cortex — your org's projects, activity, gaps, and directives, scoped to you.",
5
5
  "type": "module",
6
6
  "bin": {