@groundnuty/macf-channel-server 0.2.10 → 0.2.11
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/dist/checkpoint.d.ts +76 -0
- package/dist/checkpoint.d.ts.map +1 -0
- package/dist/checkpoint.js +322 -0
- package/dist/checkpoint.js.map +1 -0
- package/dist/refresh-aware-client.d.ts +15 -0
- package/dist/refresh-aware-client.d.ts.map +1 -0
- package/dist/refresh-aware-client.js +82 -0
- package/dist/refresh-aware-client.js.map +1 -0
- package/dist/server.js +74 -8
- package/dist/server.js.map +1 -1
- package/dist/token-refresh.d.ts +46 -0
- package/dist/token-refresh.d.ts.map +1 -0
- package/dist/token-refresh.js +202 -0
- package/dist/token-refresh.js.map +1 -0
- package/dist/tracing.d.ts +4 -0
- package/dist/tracing.d.ts.map +1 -1
- package/dist/tracing.js +10 -0
- package/dist/tracing.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { Logger } from '@groundnuty/macf-core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const CheckpointToMemoryInputSchema: {
|
|
4
|
+
readonly session_id: z.ZodString;
|
|
5
|
+
readonly transcript_path: z.ZodOptional<z.ZodString>;
|
|
6
|
+
readonly cwd: z.ZodString;
|
|
7
|
+
readonly trigger: z.ZodOptional<z.ZodEnum<{
|
|
8
|
+
manual: "manual";
|
|
9
|
+
auto: "auto";
|
|
10
|
+
}>>;
|
|
11
|
+
readonly summary: z.ZodOptional<z.ZodString>;
|
|
12
|
+
};
|
|
13
|
+
export declare const CheckpointToMemoryOutputSchema: {
|
|
14
|
+
readonly written: z.ZodBoolean;
|
|
15
|
+
readonly path: z.ZodOptional<z.ZodString>;
|
|
16
|
+
readonly deduplicated: z.ZodBoolean;
|
|
17
|
+
readonly reason: z.ZodOptional<z.ZodString>;
|
|
18
|
+
};
|
|
19
|
+
export interface CheckpointToMemoryDeps {
|
|
20
|
+
readonly selfAgentName: string;
|
|
21
|
+
readonly logger: Logger;
|
|
22
|
+
/**
|
|
23
|
+
* Override for `~/.claude/projects` location. Production code uses
|
|
24
|
+
* `os.homedir()`; tests inject a temp dir. Optional — when absent,
|
|
25
|
+
* defaults to `${HOME}/.claude/projects`.
|
|
26
|
+
*/
|
|
27
|
+
readonly projectsRootOverride?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Override for `new Date()` so dedup-naming is testable against
|
|
30
|
+
* fixed dates. Production: undefined (uses real clock). Test: returns
|
|
31
|
+
* a fixed Date.
|
|
32
|
+
*/
|
|
33
|
+
readonly nowOverride?: () => Date;
|
|
34
|
+
}
|
|
35
|
+
export interface CheckpointToMemoryInput {
|
|
36
|
+
readonly session_id: string;
|
|
37
|
+
readonly transcript_path?: string;
|
|
38
|
+
readonly cwd: string;
|
|
39
|
+
readonly trigger?: 'manual' | 'auto';
|
|
40
|
+
readonly summary?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface CheckpointToMemoryResult {
|
|
43
|
+
readonly written: boolean;
|
|
44
|
+
readonly path?: string;
|
|
45
|
+
readonly deduplicated: boolean;
|
|
46
|
+
readonly reason?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Encode an absolute filesystem path into Claude Code's per-project
|
|
50
|
+
* directory naming scheme used under `~/.claude/projects/`.
|
|
51
|
+
*
|
|
52
|
+
* Empirical scheme (verified by listing existing project dirs in the
|
|
53
|
+
* env): every `/` is replaced with `-`. The resulting string is the
|
|
54
|
+
* directory name; no other normalization is applied (case + spaces
|
|
55
|
+
* preserved).
|
|
56
|
+
*/
|
|
57
|
+
export declare function encodeProjectDir(cwd: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Resolve the canonical memory directory for a given project cwd.
|
|
60
|
+
* Pure function — does not touch the filesystem.
|
|
61
|
+
*/
|
|
62
|
+
export declare function resolveMemoryDir(cwd: string, projectsRoot: string): string;
|
|
63
|
+
/**
|
|
64
|
+
* Tool body — resolves memory dir, dedups by session-id, writes file.
|
|
65
|
+
*
|
|
66
|
+
* Wrapped in OTel span `macf.tool.checkpoint_to_memory` (SpanKind.INTERNAL —
|
|
67
|
+
* pure local filesystem op, no outbound network) per DR-023 telemetry
|
|
68
|
+
* pattern. Span attributes mirror the input shape so checkpoint cadence
|
|
69
|
+
* + outcome are visible in Tempo: trigger, deduplicated, written.
|
|
70
|
+
*
|
|
71
|
+
* Non-blocking: any error path resolves with `written: false` + a
|
|
72
|
+
* `reason` string. Never throws to the caller. The caller (server.ts
|
|
73
|
+
* tool wrapper) returns `isError: false` so PreCompact proceeds.
|
|
74
|
+
*/
|
|
75
|
+
export declare function checkpointToMemory(deps: CheckpointToMemoryDeps, input: CheckpointToMemoryInput): Promise<CheckpointToMemoryResult>;
|
|
76
|
+
//# sourceMappingURL=checkpoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkpoint.d.ts","sourceRoot":"","sources":["../src/checkpoint.ts"],"names":[],"mappings":"AAyCA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,6BAA6B;;;;;;;;;CAWhC,CAAC;AAEX,eAAO,MAAM,8BAA8B;;;;;CASjC,CAAC;AAEX,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IACvC;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;CACnC;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IACrC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAE1E;AAwGD;;;;;;;;;;;GAWG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,sBAAsB,EAC5B,KAAK,EAAE,uBAAuB,GAC7B,OAAO,CAAC,wBAAwB,CAAC,CAmInC"}
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `checkpoint_to_memory` MCP tool implementation per macf#271 / DR-023 UC-3.
|
|
3
|
+
*
|
|
4
|
+
* Registered on the channel-server's MCP surface; called by Claude Code's
|
|
5
|
+
* plugin loader when the `PreCompact` hook fires (per
|
|
6
|
+
* `packages/macf/plugin/hooks/hooks.json`). The tool writes a structured
|
|
7
|
+
* session-handoff entry to the agent's per-project memory directory
|
|
8
|
+
* (`~/.claude/projects/<encoded-cwd>/memory/`) so the next session can
|
|
9
|
+
* read the entry via the standard MEMORY.md index lookup pattern.
|
|
10
|
+
*
|
|
11
|
+
* Hook event: `PreCompact` (NOT `Stop`).
|
|
12
|
+
*
|
|
13
|
+
* The original macf#271 issue body framed UC-3 as a `Stop` hook. That
|
|
14
|
+
* was wrong-cadence: per `feedback_stop_hook_fires_on_turn_end_not_session_exit.md`
|
|
15
|
+
* + Claude Code 2.1.118+ behaviour, `Stop` fires after every LLM turn
|
|
16
|
+
* completes, not at session exit / before compaction. `/exit` is a TUI-
|
|
17
|
+
* local command and bypasses Stop hooks entirely. The natural trigger
|
|
18
|
+
* for "synthesize before context loss" is `PreCompact` — fires before
|
|
19
|
+
* BOTH `/compact` (manual) and auto-compaction. Confirmed in macf#271
|
|
20
|
+
* comment exchange between code-agent + science-agent (2026-05-01);
|
|
21
|
+
* DR-023 §UC-3 amendment in this PR codifies the resolution.
|
|
22
|
+
*
|
|
23
|
+
* Failure semantics (per DR-023 §UC-3 + §"Failure-mode contract"):
|
|
24
|
+
*
|
|
25
|
+
* The hook layer is observational + non-blocking by default. Memory
|
|
26
|
+
* directory missing, file write failure, malformed input — all log a
|
|
27
|
+
* diagnostic event and return `{written: false, reason}` to the hook
|
|
28
|
+
* without raising. The caller (server.ts tool wrapper) returns
|
|
29
|
+
* `isError: false` regardless so the PreCompact event always proceeds.
|
|
30
|
+
* A failed checkpoint is recoverable: the operator can manually
|
|
31
|
+
* author a handoff entry post-compaction (the existing
|
|
32
|
+
* `synthesize-before-compaction` discipline).
|
|
33
|
+
*
|
|
34
|
+
* Critically: the hook MUST NOT block compaction even on failure.
|
|
35
|
+
* PreCompact CAN block (`{decision: "block", reason}`) but the design
|
|
36
|
+
* choice here is observational — checkpoint is best-effort, missing
|
|
37
|
+
* one is a lost paragraph, not a safety violation.
|
|
38
|
+
*/
|
|
39
|
+
import { writeFile, mkdir, readdir, readFile } from 'node:fs/promises';
|
|
40
|
+
import { homedir } from 'node:os';
|
|
41
|
+
import { join } from 'node:path';
|
|
42
|
+
import { z } from 'zod';
|
|
43
|
+
import { context, SpanKind, SpanStatusCode, trace } from '@opentelemetry/api';
|
|
44
|
+
import { SpanNames, Attr, GenAiAttr } from './tracing.js';
|
|
45
|
+
export const CheckpointToMemoryInputSchema = {
|
|
46
|
+
session_id: z.string().min(1)
|
|
47
|
+
.describe('Claude Code session identifier (UUID). Substituted from PreCompact hook input ${session_id}.'),
|
|
48
|
+
transcript_path: z.string().optional()
|
|
49
|
+
.describe('Absolute path to session transcript (jsonl). Substituted from ${transcript_path}.'),
|
|
50
|
+
cwd: z.string().min(1)
|
|
51
|
+
.describe('Workspace directory the session is operating in. Substituted from ${cwd}. Used to resolve the per-project memory directory.'),
|
|
52
|
+
trigger: z.enum(['manual', 'auto']).optional()
|
|
53
|
+
.describe('What triggered compaction — "manual" (`/compact` invocation) or "auto" (token threshold). Substituted from PreCompact matcher.'),
|
|
54
|
+
summary: z.string().optional()
|
|
55
|
+
.describe('Optional human-authored synthesis text to embed in the checkpoint body. When omitted, a stub body is written with metadata only — the LLM can populate it post-compaction or operator can author manually.'),
|
|
56
|
+
};
|
|
57
|
+
export const CheckpointToMemoryOutputSchema = {
|
|
58
|
+
written: z.boolean()
|
|
59
|
+
.describe('True if the checkpoint file was successfully written to disk.'),
|
|
60
|
+
path: z.string().optional()
|
|
61
|
+
.describe('Absolute path of the written or updated checkpoint file. Present when `written=true`.'),
|
|
62
|
+
deduplicated: z.boolean()
|
|
63
|
+
.describe('True if a pre-existing checkpoint for this session_id was updated (rather than a new file created).'),
|
|
64
|
+
reason: z.string().optional()
|
|
65
|
+
.describe('Diagnostic reason when `written=false`. Present on failure paths only.'),
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Encode an absolute filesystem path into Claude Code's per-project
|
|
69
|
+
* directory naming scheme used under `~/.claude/projects/`.
|
|
70
|
+
*
|
|
71
|
+
* Empirical scheme (verified by listing existing project dirs in the
|
|
72
|
+
* env): every `/` is replaced with `-`. The resulting string is the
|
|
73
|
+
* directory name; no other normalization is applied (case + spaces
|
|
74
|
+
* preserved).
|
|
75
|
+
*/
|
|
76
|
+
export function encodeProjectDir(cwd) {
|
|
77
|
+
return cwd.replace(/\//g, '-');
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Resolve the canonical memory directory for a given project cwd.
|
|
81
|
+
* Pure function — does not touch the filesystem.
|
|
82
|
+
*/
|
|
83
|
+
export function resolveMemoryDir(cwd, projectsRoot) {
|
|
84
|
+
return join(projectsRoot, encodeProjectDir(cwd), 'memory');
|
|
85
|
+
}
|
|
86
|
+
/** Format YYYY_MM_DD per `project_session_handoff_<date>.md` convention. */
|
|
87
|
+
function formatDate(d) {
|
|
88
|
+
const yyyy = d.getUTCFullYear().toString().padStart(4, '0');
|
|
89
|
+
const mm = (d.getUTCMonth() + 1).toString().padStart(2, '0');
|
|
90
|
+
const dd = d.getUTCDate().toString().padStart(2, '0');
|
|
91
|
+
return `${yyyy}_${mm}_${dd}`;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Look for a pre-existing checkpoint with the same `originSessionId`
|
|
95
|
+
* in this memory directory. If found, return its absolute path so the
|
|
96
|
+
* caller can OVERWRITE it (deduplication: PreCompact may fire multiple
|
|
97
|
+
* times in a single session for sequential auto-compactions). If
|
|
98
|
+
* not found, return undefined.
|
|
99
|
+
*
|
|
100
|
+
* Scans only files matching the `project_session_handoff_*.md` glob
|
|
101
|
+
* to keep cost bounded (memory dirs accumulate ~50-100 entries; reading
|
|
102
|
+
* all of them on every PreCompact would be wasteful).
|
|
103
|
+
*/
|
|
104
|
+
async function findExistingCheckpoint(memoryDir, sessionId) {
|
|
105
|
+
let entries;
|
|
106
|
+
try {
|
|
107
|
+
entries = await readdir(memoryDir);
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
for (const entry of entries) {
|
|
113
|
+
if (!entry.startsWith('project_session_handoff_') || !entry.endsWith('.md')) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
const fullPath = join(memoryDir, entry);
|
|
117
|
+
let body;
|
|
118
|
+
try {
|
|
119
|
+
body = await readFile(fullPath, 'utf8');
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
// Frontmatter is YAML at top of file: ---\n...\n---
|
|
125
|
+
// Look for `originSessionId: <sessionId>` line within first ~20
|
|
126
|
+
// lines (frontmatter is short by convention).
|
|
127
|
+
const head = body.split('\n', 25).join('\n');
|
|
128
|
+
if (head.includes(`originSessionId: ${sessionId}`)) {
|
|
129
|
+
return fullPath;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Build the checkpoint markdown body. Frontmatter follows the existing
|
|
136
|
+
* `project_session_handoff_*.md` convention (verified against actual
|
|
137
|
+
* memory entries: name, description, type=project, originSessionId).
|
|
138
|
+
*
|
|
139
|
+
* Body shape: when `summary` provided, embeds it directly. Without
|
|
140
|
+
* summary, writes a minimal-stub body so the file is well-formed +
|
|
141
|
+
* findable; future tools can append.
|
|
142
|
+
*
|
|
143
|
+
* Why ISO-8601 date in the description: matches the existing entries'
|
|
144
|
+
* pattern (e.g., "2026-04-30 session handoff — three release cycles
|
|
145
|
+
* (v0.2.5 → v0.2.7) ...") so the MEMORY.md index renders consistently
|
|
146
|
+
* if/when an entry for this checkpoint is added.
|
|
147
|
+
*/
|
|
148
|
+
function buildCheckpointBody(input, agentName, date) {
|
|
149
|
+
const isoDate = date.toISOString();
|
|
150
|
+
const dateOnly = formatDate(date).replace(/_/g, '-');
|
|
151
|
+
const trigger = input.trigger ?? 'unknown';
|
|
152
|
+
const transcriptLine = input.transcript_path !== undefined
|
|
153
|
+
? `\n- transcript: \`${input.transcript_path}\``
|
|
154
|
+
: '';
|
|
155
|
+
const description = `Auto-checkpoint written by ${agentName} on ${dateOnly} via PreCompact hook (trigger=${trigger}).`;
|
|
156
|
+
const bodyContent = input.summary !== undefined && input.summary.length > 0
|
|
157
|
+
? input.summary
|
|
158
|
+
: '_Auto-checkpoint stub — body not populated by hook input. The next session reads this frontmatter for session-id correlation; populate the body manually if a synthesis paragraph is needed._';
|
|
159
|
+
return `---
|
|
160
|
+
name: ${dateOnly} session checkpoint (PreCompact auto-write)
|
|
161
|
+
description: ${description}
|
|
162
|
+
type: project
|
|
163
|
+
originSessionId: ${input.session_id}
|
|
164
|
+
---
|
|
165
|
+
**Auto-checkpoint** written by \`${agentName}\` at \`${isoDate}\` via PreCompact hook (DR-023 UC-3).
|
|
166
|
+
|
|
167
|
+
## Session metadata
|
|
168
|
+
|
|
169
|
+
- agent: \`${agentName}\`
|
|
170
|
+
- session_id: \`${input.session_id}\`
|
|
171
|
+
- cwd: \`${input.cwd}\`
|
|
172
|
+
- trigger: \`${trigger}\`${transcriptLine}
|
|
173
|
+
|
|
174
|
+
## Body
|
|
175
|
+
|
|
176
|
+
${bodyContent}
|
|
177
|
+
`;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Tool body — resolves memory dir, dedups by session-id, writes file.
|
|
181
|
+
*
|
|
182
|
+
* Wrapped in OTel span `macf.tool.checkpoint_to_memory` (SpanKind.INTERNAL —
|
|
183
|
+
* pure local filesystem op, no outbound network) per DR-023 telemetry
|
|
184
|
+
* pattern. Span attributes mirror the input shape so checkpoint cadence
|
|
185
|
+
* + outcome are visible in Tempo: trigger, deduplicated, written.
|
|
186
|
+
*
|
|
187
|
+
* Non-blocking: any error path resolves with `written: false` + a
|
|
188
|
+
* `reason` string. Never throws to the caller. The caller (server.ts
|
|
189
|
+
* tool wrapper) returns `isError: false` so PreCompact proceeds.
|
|
190
|
+
*/
|
|
191
|
+
export async function checkpointToMemory(deps, input) {
|
|
192
|
+
const tracer = trace.getTracer('macf');
|
|
193
|
+
return tracer.startActiveSpan(SpanNames.ToolCheckpointToMemory, {
|
|
194
|
+
kind: SpanKind.INTERNAL,
|
|
195
|
+
attributes: {
|
|
196
|
+
[GenAiAttr.System]: 'macf',
|
|
197
|
+
[GenAiAttr.OperationName]: 'checkpoint_to_memory',
|
|
198
|
+
[Attr.CheckpointTrigger]: input.trigger ?? 'unknown',
|
|
199
|
+
},
|
|
200
|
+
}, async (span) => {
|
|
201
|
+
try {
|
|
202
|
+
const projectsRoot = deps.projectsRootOverride
|
|
203
|
+
?? join(homedir(), '.claude', 'projects');
|
|
204
|
+
const memoryDir = resolveMemoryDir(input.cwd, projectsRoot);
|
|
205
|
+
// Ensure dir exists. mkdir recursive is idempotent.
|
|
206
|
+
try {
|
|
207
|
+
await mkdir(memoryDir, { recursive: true });
|
|
208
|
+
}
|
|
209
|
+
catch (err) {
|
|
210
|
+
const reason = `mkdir_failed: ${err instanceof Error ? err.message : String(err)}`;
|
|
211
|
+
deps.logger.warn('checkpoint_mkdir_failed', {
|
|
212
|
+
memory_dir: memoryDir,
|
|
213
|
+
error: reason,
|
|
214
|
+
});
|
|
215
|
+
span.setAttribute(Attr.CheckpointWritten, false);
|
|
216
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
217
|
+
return { written: false, deduplicated: false, reason };
|
|
218
|
+
}
|
|
219
|
+
// Dedup: if an existing entry has originSessionId === input.session_id,
|
|
220
|
+
// overwrite it. Otherwise allocate a fresh path. Naming pattern matches
|
|
221
|
+
// existing convention `project_session_handoff_<YYYY_MM_DD>.md`; if
|
|
222
|
+
// multiple session-ids hit the same date, the second (and later) get
|
|
223
|
+
// a short-session-id suffix to avoid collision.
|
|
224
|
+
const existing = await findExistingCheckpoint(memoryDir, input.session_id);
|
|
225
|
+
const now = (deps.nowOverride ?? (() => new Date()))();
|
|
226
|
+
let targetPath;
|
|
227
|
+
let deduplicated;
|
|
228
|
+
if (existing !== undefined) {
|
|
229
|
+
targetPath = existing;
|
|
230
|
+
deduplicated = true;
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
deduplicated = false;
|
|
234
|
+
const baseName = `project_session_handoff_${formatDate(now)}.md`;
|
|
235
|
+
const base = join(memoryDir, baseName);
|
|
236
|
+
// If `base` exists and belongs to a DIFFERENT session, suffix
|
|
237
|
+
// with the first 8 chars of the session-id so two sessions in
|
|
238
|
+
// a single calendar-date both land cleanly.
|
|
239
|
+
let collides = false;
|
|
240
|
+
try {
|
|
241
|
+
const existingBody = await readFile(base, 'utf8');
|
|
242
|
+
const head = existingBody.split('\n', 25).join('\n');
|
|
243
|
+
// Different session-id already at the canonical path
|
|
244
|
+
if (!head.includes(`originSessionId: ${input.session_id}`)) {
|
|
245
|
+
collides = true;
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
// Same session-id; the readdir scan above should have caught
|
|
249
|
+
// this — fallthrough to overwrite (defensive: still a write).
|
|
250
|
+
targetPath = base;
|
|
251
|
+
const body = buildCheckpointBody(input, deps.selfAgentName, now);
|
|
252
|
+
await writeFile(targetPath, body, 'utf8');
|
|
253
|
+
span.setAttribute(Attr.CheckpointWritten, true);
|
|
254
|
+
span.setAttribute(Attr.CheckpointDeduplicated, true);
|
|
255
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
256
|
+
deps.logger.info('checkpoint_written', {
|
|
257
|
+
path: targetPath,
|
|
258
|
+
session_id: input.session_id,
|
|
259
|
+
deduplicated: 'true',
|
|
260
|
+
});
|
|
261
|
+
return { written: true, path: targetPath, deduplicated: true };
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
// ENOENT or read error → no collision; use base.
|
|
266
|
+
collides = false;
|
|
267
|
+
}
|
|
268
|
+
if (collides) {
|
|
269
|
+
const shortSid = input.session_id.slice(0, 8);
|
|
270
|
+
targetPath = join(memoryDir, `project_session_handoff_${formatDate(now)}_${shortSid}.md`);
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
targetPath = base;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
const body = buildCheckpointBody(input, deps.selfAgentName, now);
|
|
277
|
+
try {
|
|
278
|
+
await writeFile(targetPath, body, 'utf8');
|
|
279
|
+
}
|
|
280
|
+
catch (err) {
|
|
281
|
+
const reason = `write_failed: ${err instanceof Error ? err.message : String(err)}`;
|
|
282
|
+
deps.logger.warn('checkpoint_write_failed', {
|
|
283
|
+
path: targetPath,
|
|
284
|
+
error: reason,
|
|
285
|
+
});
|
|
286
|
+
span.setAttribute(Attr.CheckpointWritten, false);
|
|
287
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
288
|
+
return { written: false, deduplicated, reason };
|
|
289
|
+
}
|
|
290
|
+
span.setAttribute(Attr.CheckpointWritten, true);
|
|
291
|
+
span.setAttribute(Attr.CheckpointDeduplicated, deduplicated);
|
|
292
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
293
|
+
deps.logger.info('checkpoint_written', {
|
|
294
|
+
path: targetPath,
|
|
295
|
+
session_id: input.session_id,
|
|
296
|
+
deduplicated: deduplicated ? 'true' : 'false',
|
|
297
|
+
});
|
|
298
|
+
return { written: true, path: targetPath, deduplicated };
|
|
299
|
+
}
|
|
300
|
+
catch (err) {
|
|
301
|
+
// Defense-in-depth: any unexpected throw inside the body still
|
|
302
|
+
// surfaces as a non-blocking outcome to the caller.
|
|
303
|
+
span.recordException(err);
|
|
304
|
+
span.setStatus({
|
|
305
|
+
code: SpanStatusCode.ERROR,
|
|
306
|
+
message: err instanceof Error ? err.message : String(err),
|
|
307
|
+
});
|
|
308
|
+
const reason = `unexpected_error: ${err instanceof Error ? err.message : String(err)}`;
|
|
309
|
+
deps.logger.error('checkpoint_unexpected_error', {
|
|
310
|
+
error: reason,
|
|
311
|
+
});
|
|
312
|
+
return { written: false, deduplicated: false, reason };
|
|
313
|
+
}
|
|
314
|
+
finally {
|
|
315
|
+
span.end();
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
// Suppress unused-import lint for `context` — kept for future
|
|
320
|
+
// trace-correlation use (parent-span handoff) symmetric with notify-peer.ts.
|
|
321
|
+
void context;
|
|
322
|
+
//# sourceMappingURL=checkpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkpoint.js","sourceRoot":"","sources":["../src/checkpoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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-refresh.js';
|
|
3
|
+
export interface RefreshAwareClientDeps {
|
|
4
|
+
readonly pathPrefix: string;
|
|
5
|
+
readonly tokenRefresher: TokenRefresher;
|
|
6
|
+
readonly logger: Logger;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Wrap a path-prefix + token-refresher into a `GitHubVariablesClient`
|
|
10
|
+
* that auto-refreshes on 401. Drop-in replacement for the bare
|
|
11
|
+
* `createGitHubClient(pathPrefix, token)` call in `server.ts` —
|
|
12
|
+
* passes through the existing Registry.create chain unchanged.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createRefreshAwareClient(deps: RefreshAwareClientDeps): GitHubVariablesClient;
|
|
15
|
+
//# sourceMappingURL=refresh-aware-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refresh-aware-client.d.ts","sourceRoot":"","sources":["../src/refresh-aware-client.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,sBAAsB,GAC3B,qBAAqB,CA+CvB"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refresh-aware wrapper around `GitHubVariablesClient` (macf#317).
|
|
3
|
+
*
|
|
4
|
+
* Decorates a base client with two behaviors:
|
|
5
|
+
*
|
|
6
|
+
* 1. **Pre-call refresh** — every method invocation calls
|
|
7
|
+
* `tokenRefresher.getRefreshedToken()` to get a current token + builds
|
|
8
|
+
* a fresh inner client. The cache inside `tokenRefresher` keeps this
|
|
9
|
+
* cheap (no fresh mint within ~50 min of last refresh).
|
|
10
|
+
*
|
|
11
|
+
* 2. **401 retry with force-refresh** — if the inner call throws
|
|
12
|
+
* `GitHubApiError` with `status === 401`, the wrapper invokes
|
|
13
|
+
* `getRefreshedToken({ forceRefresh: true })` (bypasses cache),
|
|
14
|
+
* rebuilds the inner client, and retries the call once. A second 401
|
|
15
|
+
* bubbles up — the issue isn't expiry but a different auth problem
|
|
16
|
+
* (revoked App, deleted installation, etc).
|
|
17
|
+
*
|
|
18
|
+
* Why decorate at the GitHubVariablesClient layer (not the Registry layer):
|
|
19
|
+
* the Registry interface is project-business-logic (register/get/list/
|
|
20
|
+
* remove for agents). The token-stale failure surfaces at the lower
|
|
21
|
+
* (HTTP/auth) layer. Decorating at the lower layer keeps the failure-
|
|
22
|
+
* recovery surface small + uniform across all 4 Registry methods, plus
|
|
23
|
+
* the `/sign` flow's `varsClient`. One wrapper, all callers benefit.
|
|
24
|
+
*
|
|
25
|
+
* Note on closure-capture: the inner client built by `createGitHubClient`
|
|
26
|
+
* captures the token in its closure — there's no mutable token slot. So
|
|
27
|
+
* "rebuild the inner client when the token changes" is the cheapest +
|
|
28
|
+
* cleanest change. Builds are pure-function pricing (~microseconds);
|
|
29
|
+
* negligible vs the network round-trip.
|
|
30
|
+
*/
|
|
31
|
+
import { createGitHubClient, GitHubApiError } from '@groundnuty/macf-core';
|
|
32
|
+
/**
|
|
33
|
+
* Wrap a path-prefix + token-refresher into a `GitHubVariablesClient`
|
|
34
|
+
* that auto-refreshes on 401. Drop-in replacement for the bare
|
|
35
|
+
* `createGitHubClient(pathPrefix, token)` call in `server.ts` —
|
|
36
|
+
* passes through the existing Registry.create chain unchanged.
|
|
37
|
+
*/
|
|
38
|
+
export function createRefreshAwareClient(deps) {
|
|
39
|
+
const { pathPrefix, tokenRefresher, logger } = deps;
|
|
40
|
+
/**
|
|
41
|
+
* Per-call: get token (cached or fresh), build inner client, invoke fn.
|
|
42
|
+
* On 401, force-refresh + rebuild + retry once. Anything else propagates.
|
|
43
|
+
*/
|
|
44
|
+
async function withRefresh(label, fn) {
|
|
45
|
+
const initialToken = await tokenRefresher.getRefreshedToken();
|
|
46
|
+
const inner = createGitHubClient(pathPrefix, initialToken);
|
|
47
|
+
try {
|
|
48
|
+
return await fn(inner);
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
// GitHubApiError carries status; 401 means token-related auth
|
|
52
|
+
// failure (expired, revoked, missing perm). Other GitHubApiError
|
|
53
|
+
// statuses (404, 422, 5xx) aren't auth-related; let them through.
|
|
54
|
+
if (err instanceof GitHubApiError && err.status === 401) {
|
|
55
|
+
logger.warn('github_api_401_refreshing_and_retrying', {
|
|
56
|
+
method: label,
|
|
57
|
+
});
|
|
58
|
+
const freshToken = await tokenRefresher.getRefreshedToken({
|
|
59
|
+
forceRefresh: true,
|
|
60
|
+
});
|
|
61
|
+
const fresh = createGitHubClient(pathPrefix, freshToken);
|
|
62
|
+
return await fn(fresh);
|
|
63
|
+
}
|
|
64
|
+
throw err;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
async writeVariable(name, value) {
|
|
69
|
+
await withRefresh('writeVariable', (c) => c.writeVariable(name, value));
|
|
70
|
+
},
|
|
71
|
+
async readVariable(name) {
|
|
72
|
+
return withRefresh('readVariable', (c) => c.readVariable(name));
|
|
73
|
+
},
|
|
74
|
+
async listVariables() {
|
|
75
|
+
return withRefresh('listVariables', (c) => c.listVariables());
|
|
76
|
+
},
|
|
77
|
+
async deleteVariable(name) {
|
|
78
|
+
await withRefresh('deleteVariable', (c) => c.deleteVariable(name));
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=refresh-aware-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refresh-aware-client.js","sourceRoot":"","sources":["../src/refresh-aware-client.ts"],"names":[],"mappings":"AAAA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AAK,CAAC,YAAY,CAAC,IAAY;YAC7B,OAAO,WAAW,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;QAClE,CAAC;QACD,KAAK,CAAC,aAAa;YACjB,OAAO,WAAW,CAAC,eAAe,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC;QAChE,CAAC;QACD,KAAK,CAAC,cAAc,CAAC,IAAY;YAC/B,MAAM,WAAW,CAAC,gBAAgB,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;QACrE,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/server.js
CHANGED
|
@@ -13,10 +13,11 @@ import { createLogger } from '@groundnuty/macf-core';
|
|
|
13
13
|
import { createMcpChannel } from './mcp.js';
|
|
14
14
|
import { createHealthState } from './health.js';
|
|
15
15
|
import { createHttpsServer } from './https.js';
|
|
16
|
-
import {
|
|
16
|
+
import { createRegistry } from '@groundnuty/macf-core';
|
|
17
17
|
import { checkCollision, CollisionError } from './collision.js';
|
|
18
18
|
import { registerShutdownHandler } from './shutdown.js';
|
|
19
|
-
import {
|
|
19
|
+
import { createTokenRefresher } from './token-refresh.js';
|
|
20
|
+
import { createRefreshAwareClient } from './refresh-aware-client.js';
|
|
20
21
|
import { createChallenge, verifyAndConsumeChallenge } from '@groundnuty/macf-core';
|
|
21
22
|
import { createChallengeStore } from '@groundnuty/macf-core';
|
|
22
23
|
import { signCSR } from '@groundnuty/macf-core';
|
|
@@ -138,11 +139,15 @@ async function main() {
|
|
|
138
139
|
});
|
|
139
140
|
}
|
|
140
141
|
};
|
|
141
|
-
// P2:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
//
|
|
142
|
+
// P2: Resolve path prefix once — both the project registry client +
|
|
143
|
+
// the /sign varsClient share the same base URL prefix shape.
|
|
144
|
+
//
|
|
145
|
+
// Pre-macf#317 this section also called `await generateToken()` to
|
|
146
|
+
// mint a static token + pass it into `createRegistryFromConfig` +
|
|
147
|
+
// `createGitHubClient`. The token-refresh wrapper now handles minting
|
|
148
|
+
// lazily (first call to `tokenRefresher.getRefreshedToken()`) — we
|
|
149
|
+
// don't pre-mint here because the refresh-aware client mints on first
|
|
150
|
+
// use anyway, and pre-minting wouldn't improve startup signal.
|
|
146
151
|
let signPathPrefix;
|
|
147
152
|
switch (config.registry.type) {
|
|
148
153
|
case 'org':
|
|
@@ -155,7 +160,32 @@ async function main() {
|
|
|
155
160
|
signPathPrefix = `/repos/${config.registry.owner}/${config.registry.repo}`;
|
|
156
161
|
break;
|
|
157
162
|
}
|
|
158
|
-
|
|
163
|
+
// macf#317: in-runner token refresh. The refresher caches the current
|
|
164
|
+
// token in-process; on each call it returns cached if age < 50min,
|
|
165
|
+
// else mints fresh via macf-gh-token.sh. On 401 from a downstream API
|
|
166
|
+
// call, the refresh-aware client retries once with forceRefresh: true.
|
|
167
|
+
// This closes the >1hr-session expiry gap (silent-fallback Instance 1
|
|
168
|
+
// expiry sub-case) — the cv-architect 401 at 67min uptime witnessed
|
|
169
|
+
// 2026-05-01 was the motivating incident.
|
|
170
|
+
const tokenRefresher = createTokenRefresher({ logger });
|
|
171
|
+
// Project-registry path prefix differs from /sign prefix only in the
|
|
172
|
+
// org case (registry uses /orgs/<org> too — same shape). Re-derive
|
|
173
|
+
// here for clarity even though it's identical to signPathPrefix.
|
|
174
|
+
const registryPathPrefix = signPathPrefix;
|
|
175
|
+
const registryClient = createRefreshAwareClient({
|
|
176
|
+
pathPrefix: registryPathPrefix,
|
|
177
|
+
tokenRefresher,
|
|
178
|
+
logger,
|
|
179
|
+
});
|
|
180
|
+
const registry = createRegistry(registryClient, config.project);
|
|
181
|
+
// Build the variables client for the /sign challenge flow with the
|
|
182
|
+
// same refresh-aware wrapping. Stop hook + /sign both 401 after the
|
|
183
|
+
// 1-hour token TTL absent this fix.
|
|
184
|
+
const varsClient = createRefreshAwareClient({
|
|
185
|
+
pathPrefix: signPathPrefix,
|
|
186
|
+
tokenRefresher,
|
|
187
|
+
logger,
|
|
188
|
+
});
|
|
159
189
|
// In-memory challenge store (DR-010, #80). Process-local; server restart
|
|
160
190
|
// between step 1 and step 2 of a flow invalidates outstanding challenges.
|
|
161
191
|
const challengeStore = createChallengeStore();
|
|
@@ -259,6 +289,42 @@ async function main() {
|
|
|
259
289
|
isError: result.peers_attempted > 0 && result.peers_delivered === 0,
|
|
260
290
|
};
|
|
261
291
|
});
|
|
292
|
+
// macf#271 / DR-023 UC-3: register checkpoint_to_memory MCP tool on
|
|
293
|
+
// the same MCP channel. Hook event is PreCompact (NOT Stop, despite
|
|
294
|
+
// the issue's original framing — see DR-023 §UC-3 amendment + the
|
|
295
|
+
// checkpoint.ts file-header for the reframe rationale). Tool writes
|
|
296
|
+
// a session-handoff file to the agent's per-project memory directory
|
|
297
|
+
// under `~/.claude/projects/<encoded-cwd>/memory/`. Failure-mode is
|
|
298
|
+
// observational + non-blocking: any error path returns
|
|
299
|
+
// `{written: false, reason}` and `isError: false` so PreCompact
|
|
300
|
+
// proceeds (a missed checkpoint is recoverable; blocking compaction
|
|
301
|
+
// is not).
|
|
302
|
+
const { checkpointToMemory, CheckpointToMemoryInputSchema, CheckpointToMemoryOutputSchema, } = await import('./checkpoint.js');
|
|
303
|
+
const checkpointDeps = {
|
|
304
|
+
selfAgentName: config.agentName,
|
|
305
|
+
logger,
|
|
306
|
+
};
|
|
307
|
+
mcp.mcp.registerTool('checkpoint_to_memory', {
|
|
308
|
+
description: 'Write a session-handoff checkpoint to the agent\'s per-project ' +
|
|
309
|
+
'memory directory. Invoked by the PreCompact hook (DR-023 UC-3) before context ' +
|
|
310
|
+
'compaction so the next session can read structured handoff state via the ' +
|
|
311
|
+
'MEMORY.md index pattern. Failure-mode is observational + non-blocking — write ' +
|
|
312
|
+
'failures log + return `{written: false, reason}` to the hook without raising; ' +
|
|
313
|
+
'compaction always proceeds.',
|
|
314
|
+
inputSchema: CheckpointToMemoryInputSchema,
|
|
315
|
+
outputSchema: CheckpointToMemoryOutputSchema,
|
|
316
|
+
}, async (input) => {
|
|
317
|
+
const result = await checkpointToMemory(checkpointDeps, input);
|
|
318
|
+
return {
|
|
319
|
+
content: [{ type: 'text', text: JSON.stringify(result) }],
|
|
320
|
+
structuredContent: { ...result },
|
|
321
|
+
// Per DR-023 §UC-3: PreCompact is best-effort. Even on
|
|
322
|
+
// write-failure, surface isError:false so compaction proceeds.
|
|
323
|
+
// The `reason` field in structured output is sufficient signal
|
|
324
|
+
// for LLM self-correction in subsequent turns.
|
|
325
|
+
isError: false,
|
|
326
|
+
};
|
|
327
|
+
});
|
|
262
328
|
// P1: Connect MCP channel
|
|
263
329
|
await mcp.connect();
|
|
264
330
|
// P1: Bind port
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AACA,mEAAmE;AACnE,kEAAkE;AAClE,2DAA2D;AAC3D,uEAAuE;AACvE,qEAAqE;AACrE,8CAA8C;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,O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G,EAAE,EAAE;IACnB,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,UAAU,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAC/D,CAAC;IACF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Logger } from '@groundnuty/macf-core';
|
|
2
|
+
/**
|
|
3
|
+
* Token cache TTL — 50 minutes. 10-minute safety margin under the 1-hour
|
|
4
|
+
* installation-token TTL (GitHub App contract). Calls within this window
|
|
5
|
+
* return the cached token; calls past this window mint fresh.
|
|
6
|
+
*
|
|
7
|
+
* Exposed as a const so tests can assert the value without re-deriving.
|
|
8
|
+
*/
|
|
9
|
+
export declare const REFRESH_AGE_MS: number;
|
|
10
|
+
export interface TokenRefresherDeps {
|
|
11
|
+
/** Optional override for the canonical helper-script path; tests inject. */
|
|
12
|
+
readonly tokenScriptPath?: string;
|
|
13
|
+
/** Optional clock injection for tests. */
|
|
14
|
+
readonly clock?: {
|
|
15
|
+
readonly now: () => number;
|
|
16
|
+
};
|
|
17
|
+
/** Optional execFile injection for tests (avoids spawning real shell). */
|
|
18
|
+
readonly exec?: (cmd: string, args: readonly string[], opts?: {
|
|
19
|
+
readonly encoding?: 'utf-8';
|
|
20
|
+
}) => Promise<{
|
|
21
|
+
readonly stdout: string;
|
|
22
|
+
readonly stderr: string;
|
|
23
|
+
}>;
|
|
24
|
+
/** Logger for diagnostic output. */
|
|
25
|
+
readonly logger: Logger;
|
|
26
|
+
}
|
|
27
|
+
export interface GetRefreshedTokenOptions {
|
|
28
|
+
/** Force a fresh mint regardless of cache age (used on 401 retry). */
|
|
29
|
+
readonly forceRefresh?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface TokenRefresher {
|
|
32
|
+
/**
|
|
33
|
+
* Returns a current token, minting fresh if the cache is older than
|
|
34
|
+
* `REFRESH_AGE_MS` or `forceRefresh: true`. Throws on mint failure;
|
|
35
|
+
* never returns a stale token silently.
|
|
36
|
+
*/
|
|
37
|
+
readonly getRefreshedToken: (opts?: GetRefreshedTokenOptions) => Promise<string>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Create a token refresher with an in-process cache. Caller invokes
|
|
41
|
+
* `getRefreshedToken()` per-API-call; the cache returns the same token
|
|
42
|
+
* for ~50 min then mints fresh. On 401, caller invokes with
|
|
43
|
+
* `forceRefresh: true` to bypass cache.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createTokenRefresher(deps: TokenRefresherDeps): TokenRefresher;
|
|
46
|
+
//# sourceMappingURL=token-refresh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-refresh.d.ts","sourceRoot":"","sources":["../src/token-refresh.ts"],"names":[],"mappings":"AAqDA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAIpD;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,QAAiB,CAAC;AAE7C,MAAM,WAAW,kBAAkB;IACjC,4EAA4E;IAC5E,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,0CAA0C;IAC1C,QAAQ,CAAC,KAAK,CAAC,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,MAAM,CAAA;KAAE,CAAC;IAChD,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,CAAC,EAAE,CACd,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,KACnC,OAAO,CAAC;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnE,oCAAoC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,wBAAwB;IACvC,sEAAsE;IACtE,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,iBAAiB,EAAE,CAC1B,IAAI,CAAC,EAAE,wBAAwB,KAC5B,OAAO,CAAC,MAAM,CAAC,CAAC;CACtB;AAsHD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,kBAAkB,GAAG,cAAc,CAyC7E"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-runner GH_TOKEN refresh helper (macf#317).
|
|
3
|
+
*
|
|
4
|
+
* Bot installation tokens have a **1-hour TTL by design** (GitHub App contract).
|
|
5
|
+
* `claude.sh` mints a fresh token at session start + exports `GH_TOKEN`; the
|
|
6
|
+
* channel-server inherits that token via `process.env`. Without an in-runner
|
|
7
|
+
* refresh, every gh-API-using handler 401s after ~60 minutes of session
|
|
8
|
+
* uptime. Witnessed 2026-05-01 ~14:30Z on cv-architect's Stop hook at
|
|
9
|
+
* ~67min uptime — the operator-witnessed incident motivating this module.
|
|
10
|
+
*
|
|
11
|
+
* Architecture: an in-process token cache. Holds {token, mintedAt}; on
|
|
12
|
+
* every `getRefreshedToken()` call, returns cached if `age < REFRESH_AGE_MS`
|
|
13
|
+
* (50min — 10min safety margin under 1hr TTL); otherwise mints fresh via
|
|
14
|
+
* the canonical `macf-gh-token.sh` helper. On a 401 from a downstream API
|
|
15
|
+
* call, the caller re-invokes with `forceRefresh: true` to bypass cache.
|
|
16
|
+
*
|
|
17
|
+
* Critical: refreshed tokens stay **in-process**. We never `process.env.GH_TOKEN
|
|
18
|
+
* = ...` or pass tokens to child processes via env mutation — a stale
|
|
19
|
+
* `GH_TOKEN` env var elsewhere is a separate hazard surface. The wrapper-
|
|
20
|
+
* around-GitHub-client pattern (refresh-aware-client.ts) holds the fresh
|
|
21
|
+
* token in closure, never leaks it.
|
|
22
|
+
*
|
|
23
|
+
* Failure semantics: refresh failures (clock drift, missing key, rotated
|
|
24
|
+
* key, deleted App) throw with diagnostic. We do NOT silently fall back
|
|
25
|
+
* to the stale env-var token — that would extend the silent-fallback class
|
|
26
|
+
* (Instance 1, gh-token attribution traps) by re-introducing a quiet path
|
|
27
|
+
* where ops continue under wrong identity. Loud failure preserves the
|
|
28
|
+
* fail-loud invariant.
|
|
29
|
+
*
|
|
30
|
+
* Sister-shape reference: macf-testbed#135 (closed/deferred — sweep-
|
|
31
|
+
* harness-side refresh between iterations). Same hazard class, different
|
|
32
|
+
* surface; this module is the channel-server-side response.
|
|
33
|
+
*
|
|
34
|
+
* Helper-script discoverability: in-runner refresh requires the canonical
|
|
35
|
+
* `macf-gh-token.sh` to be invokable. Resolution order:
|
|
36
|
+
* 1. Caller-injected `tokenScriptPath` (testing override)
|
|
37
|
+
* 2. `$MACF_WORKSPACE_DIR/.claude/scripts/macf-gh-token.sh` (canonical
|
|
38
|
+
* consumer-fleet path; set by claude.sh per macf#161)
|
|
39
|
+
*
|
|
40
|
+
* Falls back to `generateToken()` from macf-core if the helper script isn't
|
|
41
|
+
* resolvable (substrate / non-init'd workspaces). The core helper handles
|
|
42
|
+
* the same APP_ID/INSTALL_ID/KEY_PATH env path; only difference is fail-
|
|
43
|
+
* loud diagnostics live in the shell wrapper.
|
|
44
|
+
*
|
|
45
|
+
* SAFETY NOTE: this module uses `execFile` (NOT `exec`), so arguments are
|
|
46
|
+
* passed as an argv array — no shell interpretation, no injection surface
|
|
47
|
+
* for the operator-controlled APP_ID/INSTALL_ID/KEY_PATH values.
|
|
48
|
+
*/
|
|
49
|
+
import { execFile } from 'node:child_process';
|
|
50
|
+
import { promisify } from 'node:util';
|
|
51
|
+
import { existsSync } from 'node:fs';
|
|
52
|
+
import { join } from 'node:path';
|
|
53
|
+
import { generateToken } from '@groundnuty/macf-core';
|
|
54
|
+
const execFileAsync = promisify(execFile);
|
|
55
|
+
/**
|
|
56
|
+
* Token cache TTL — 50 minutes. 10-minute safety margin under the 1-hour
|
|
57
|
+
* installation-token TTL (GitHub App contract). Calls within this window
|
|
58
|
+
* return the cached token; calls past this window mint fresh.
|
|
59
|
+
*
|
|
60
|
+
* Exposed as a const so tests can assert the value without re-deriving.
|
|
61
|
+
*/
|
|
62
|
+
export const REFRESH_AGE_MS = 50 * 60 * 1000;
|
|
63
|
+
/**
|
|
64
|
+
* Locate the canonical token helper script. Returns the resolved path or
|
|
65
|
+
* `null` if not findable; caller falls back to `generateToken()`.
|
|
66
|
+
*/
|
|
67
|
+
function resolveScriptPath(override) {
|
|
68
|
+
if (override !== undefined)
|
|
69
|
+
return override;
|
|
70
|
+
const workspaceDir = process.env['MACF_WORKSPACE_DIR'];
|
|
71
|
+
if (workspaceDir === undefined || workspaceDir === '')
|
|
72
|
+
return null;
|
|
73
|
+
const candidate = join(workspaceDir, '.claude', 'scripts', 'macf-gh-token.sh');
|
|
74
|
+
return existsSync(candidate) ? candidate : null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Validate token shape — must be a non-empty `ghs_*` installation token.
|
|
78
|
+
* Mirrors the canonical fail-loud prefix check from `macf-gh-token.sh`.
|
|
79
|
+
* Defensive against scenarios where the helper exits 0 but produces empty
|
|
80
|
+
* stdout (shouldn't happen — the helper has its own check — but this is
|
|
81
|
+
* the result-invariant assertion at the channel-server boundary).
|
|
82
|
+
*/
|
|
83
|
+
function assertTokenShape(token) {
|
|
84
|
+
if (token === '') {
|
|
85
|
+
throw new Error('Token refresh failed: empty token returned');
|
|
86
|
+
}
|
|
87
|
+
if (!token.startsWith('ghs_')) {
|
|
88
|
+
const prefix = token.slice(0, 4);
|
|
89
|
+
throw new Error(`Token refresh failed: bad prefix '${prefix}' — expected 'ghs_' (installation token). ` +
|
|
90
|
+
'Refusing to use non-installation token to avoid mis-attribution.');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Mint a fresh token. Tries the canonical shell helper first (fail-loud
|
|
95
|
+
* with diagnostics) and falls back to `generateToken()` from core.
|
|
96
|
+
*/
|
|
97
|
+
async function mintToken(deps) {
|
|
98
|
+
const scriptPath = resolveScriptPath(deps.tokenScriptPath);
|
|
99
|
+
if (scriptPath !== null) {
|
|
100
|
+
const appId = process.env['APP_ID'];
|
|
101
|
+
const installId = process.env['INSTALL_ID'];
|
|
102
|
+
const keyPath = process.env['KEY_PATH'];
|
|
103
|
+
if (appId === undefined || appId === '' ||
|
|
104
|
+
installId === undefined || installId === '' ||
|
|
105
|
+
keyPath === undefined || keyPath === '') {
|
|
106
|
+
throw new Error('Token refresh failed: APP_ID/INSTALL_ID/KEY_PATH env vars required ' +
|
|
107
|
+
'for in-runner refresh; channel-server inherits these from claude.sh. ' +
|
|
108
|
+
'If unset, the claude.sh launcher did not set them — check workspace ' +
|
|
109
|
+
'config (.claude/settings.local.json) and macf doctor.');
|
|
110
|
+
}
|
|
111
|
+
const runExec = deps.exec ?? execFileAsync;
|
|
112
|
+
try {
|
|
113
|
+
const { stdout } = await runExec(scriptPath, ['--app-id', appId, '--install-id', installId, '--key', keyPath], { encoding: 'utf-8' });
|
|
114
|
+
const token = stdout.trim();
|
|
115
|
+
assertTokenShape(token);
|
|
116
|
+
return token;
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
120
|
+
throw new Error(`Token refresh failed via ${scriptPath}: ${msg}. ` +
|
|
121
|
+
'Common causes: clock drift (timedatectl status), wrong/rotated key, ' +
|
|
122
|
+
'or wrong APP_ID/INSTALL_ID. Channel-server WILL NOT silently fall ' +
|
|
123
|
+
'back to the stale inherited GH_TOKEN — fail loud per silent-fallback-' +
|
|
124
|
+
'hazards.md Instance 1 (expiry sub-case).', { cause: err });
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// Fallback: core's generateToken (no helper-script available — substrate
|
|
128
|
+
// / non-init'd workspaces). Same APP_ID/INSTALL_ID/KEY_PATH env path,
|
|
129
|
+
// less verbose diagnostics.
|
|
130
|
+
try {
|
|
131
|
+
// generateToken's precedence is GH_TOKEN env > TokenSource > env vars.
|
|
132
|
+
// When GH_TOKEN is set (typical), generateToken returns it as-is —
|
|
133
|
+
// which is the very stale token we're trying to refresh. To force a
|
|
134
|
+
// fresh mint, we'd need to either (a) clear GH_TOKEN before the call
|
|
135
|
+
// or (b) call into the gh CLI directly. Operators in this fallback
|
|
136
|
+
// path (no MACF_WORKSPACE_DIR + no helper script) get the env-var
|
|
137
|
+
// token unchanged; expiry hazard remains. The forceRefresh-on-401
|
|
138
|
+
// retry path still attempts a fresh mint — but if the env var keeps
|
|
139
|
+
// winning, the retry returns the same stale token. Documented for
|
|
140
|
+
// operators: in-runner refresh requires either the helper script or
|
|
141
|
+
// unsetting GH_TOKEN at claude-sh level. Substrate / non-init'd
|
|
142
|
+
// workspaces should ensure GH_TOKEN is not set OR ship the helper
|
|
143
|
+
// script.
|
|
144
|
+
const token = await generateToken();
|
|
145
|
+
assertTokenShape(token);
|
|
146
|
+
return token;
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
150
|
+
throw new Error(`Token refresh failed via generateToken fallback: ${msg}. ` +
|
|
151
|
+
'No MACF_WORKSPACE_DIR set + no APP_ID/INSTALL_ID/KEY_PATH env vars. ' +
|
|
152
|
+
'In-runner refresh is not viable in this configuration.', { cause: err });
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Create a token refresher with an in-process cache. Caller invokes
|
|
157
|
+
* `getRefreshedToken()` per-API-call; the cache returns the same token
|
|
158
|
+
* for ~50 min then mints fresh. On 401, caller invokes with
|
|
159
|
+
* `forceRefresh: true` to bypass cache.
|
|
160
|
+
*/
|
|
161
|
+
export function createTokenRefresher(deps) {
|
|
162
|
+
const clock = deps.clock ?? { now: () => Date.now() };
|
|
163
|
+
let cachedToken = null;
|
|
164
|
+
let mintedAt = 0;
|
|
165
|
+
let inFlight = null;
|
|
166
|
+
async function mintAndCache() {
|
|
167
|
+
// De-duplicate concurrent refresh attempts: if one mint is already
|
|
168
|
+
// in-flight, return the same promise. Prevents N concurrent gh-token-
|
|
169
|
+
// generate spawns when N concurrent /notify handlers all hit the
|
|
170
|
+
// refresh boundary simultaneously.
|
|
171
|
+
if (inFlight !== null)
|
|
172
|
+
return inFlight;
|
|
173
|
+
inFlight = (async () => {
|
|
174
|
+
try {
|
|
175
|
+
const token = await mintToken(deps);
|
|
176
|
+
cachedToken = token;
|
|
177
|
+
mintedAt = clock.now();
|
|
178
|
+
deps.logger.info('token_refreshed', {
|
|
179
|
+
age_ms: '0',
|
|
180
|
+
source: deps.tokenScriptPath ?? 'workspace_helper',
|
|
181
|
+
});
|
|
182
|
+
return token;
|
|
183
|
+
}
|
|
184
|
+
finally {
|
|
185
|
+
inFlight = null;
|
|
186
|
+
}
|
|
187
|
+
})();
|
|
188
|
+
return inFlight;
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
async getRefreshedToken(opts) {
|
|
192
|
+
const force = opts?.forceRefresh === true;
|
|
193
|
+
const now = clock.now();
|
|
194
|
+
const age = now - mintedAt;
|
|
195
|
+
if (!force && cachedToken !== null && age < REFRESH_AGE_MS) {
|
|
196
|
+
return cachedToken;
|
|
197
|
+
}
|
|
198
|
+
return mintAndCache();
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=token-refresh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-refresh.js","sourceRoot":"","sources":["../src/token-refresh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAA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YACrB,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC;gBACpC,WAAW,GAAG,KAAK,CAAC;gBACpB,QAAQ,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;gBACvB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE;oBAClC,MAAM,EAAE,GAAG;oBACX,MAAM,EAAE,IAAI,CAAC,eAAe,IAAI,kBAAkB;iBACnD,CAAC,CAAC;gBACH,OAAO,KAAK,CAAC;YACf,CAAC;oBAAS,CAAC;gBACT,QAAQ,GAAG,IAAI,CAAC;YAClB,CAAC;QACH,CAAC,CAAC,EAAE,CAAC;QACL,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,OAAO;QACL,KAAK,CAAC,iBAAiB,CAAC,IAA+B;YACrD,MAAM,KAAK,GAAG,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;YAC1C,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;YACxB,MAAM,GAAG,GAAG,GAAG,GAAG,QAAQ,CAAC;YAE3B,IAAI,CAAC,KAAK,IAAI,WAAW,KAAK,IAAI,IAAI,GAAG,GAAG,cAAc,EAAE,CAAC;gBAC3D,OAAO,WAAW,CAAC;YACrB,CAAC;YACD,OAAO,YAAY,EAAE,CAAC;QACxB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/tracing.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare const SpanNames: {
|
|
|
13
13
|
readonly CertsVerifyChallenge: "macf.certs.verify_challenge";
|
|
14
14
|
readonly CertsSign: "macf.certs.sign";
|
|
15
15
|
readonly ToolNotifyPeer: "macf.tool.notify_peer";
|
|
16
|
+
readonly ToolCheckpointToMemory: "macf.tool.checkpoint_to_memory";
|
|
16
17
|
};
|
|
17
18
|
/** MACF-specific attribute keys (not covered by OTEL semconv). */
|
|
18
19
|
export declare const Attr: {
|
|
@@ -26,6 +27,9 @@ export declare const Attr: {
|
|
|
26
27
|
readonly NotifyEvent: "macf.notify.event";
|
|
27
28
|
readonly PeersAttempted: "macf.notify.peers_attempted";
|
|
28
29
|
readonly PeersDelivered: "macf.notify.peers_delivered";
|
|
30
|
+
readonly CheckpointTrigger: "macf.checkpoint.trigger";
|
|
31
|
+
readonly CheckpointWritten: "macf.checkpoint.written";
|
|
32
|
+
readonly CheckpointDeduplicated: "macf.checkpoint.deduplicated";
|
|
29
33
|
};
|
|
30
34
|
/** GenAI semconv keys (experimental in v1.36+). */
|
|
31
35
|
export declare const GenAiAttr: {
|
package/dist/tracing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../src/tracing.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,gEAAgE;AAChE,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED,uDAAuD;AACvD,eAAO,MAAM,SAAS
|
|
1
|
+
{"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../src/tracing.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,gEAAgE;AAChE,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED,uDAAuD;AACvD,eAAO,MAAM,SAAS;;;;;;;;;;;CAmBZ,CAAC;AAEX,kEAAkE;AAClE,eAAO,MAAM,IAAI;;;;;;;;;;;;;;CAqBP,CAAC;AAEX,mDAAmD;AACnD,eAAO,MAAM,SAAS;;;;;CAKZ,CAAC;AAEX;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,CA0B9E"}
|
package/dist/tracing.js
CHANGED
|
@@ -38,6 +38,10 @@ export const SpanNames = {
|
|
|
38
38
|
// parent-child relationship to receiver's NotifyReceived span via
|
|
39
39
|
// W3C traceparent propagation.
|
|
40
40
|
ToolNotifyPeer: 'macf.tool.notify_peer',
|
|
41
|
+
// macf#271: PreCompact-driven checkpoint_to_memory span. INTERNAL-kind
|
|
42
|
+
// (purely local filesystem write). Attributes: trigger (manual|auto),
|
|
43
|
+
// written (bool), deduplicated (bool). DR-023 §UC-3 telemetry pattern.
|
|
44
|
+
ToolCheckpointToMemory: 'macf.tool.checkpoint_to_memory',
|
|
41
45
|
};
|
|
42
46
|
/** MACF-specific attribute keys (not covered by OTEL semconv). */
|
|
43
47
|
export const Attr = {
|
|
@@ -55,6 +59,12 @@ export const Attr = {
|
|
|
55
59
|
NotifyEvent: 'macf.notify.event',
|
|
56
60
|
PeersAttempted: 'macf.notify.peers_attempted',
|
|
57
61
|
PeersDelivered: 'macf.notify.peers_delivered',
|
|
62
|
+
// macf#271: checkpoint_to_memory span attributes. Surface PreCompact
|
|
63
|
+
// trigger source (manual / auto) + outcome (written, deduplicated)
|
|
64
|
+
// for DR-023 UC-3 telemetry.
|
|
65
|
+
CheckpointTrigger: 'macf.checkpoint.trigger',
|
|
66
|
+
CheckpointWritten: 'macf.checkpoint.written',
|
|
67
|
+
CheckpointDeduplicated: 'macf.checkpoint.deduplicated',
|
|
58
68
|
};
|
|
59
69
|
/** GenAI semconv keys (experimental in v1.36+). */
|
|
60
70
|
export const GenAiAttr = {
|
package/dist/tracing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracing.js","sourceRoot":"","sources":["../src/tracing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAI3C,gEAAgE;AAChE,MAAM,UAAU,SAAS;IACvB,OAAO,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,C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|
|
4
4
|
"description": "MCP channel server for the Multi-Agent Coordination Framework. HTTPS + mTLS endpoint agents connect to for inter-agent messaging (notify), CI-completion routing, and /sign certificate issuance. Invoked by Claude Code's plugin via `npx -y @groundnuty/macf-channel-server` per DR-022.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"test:e2e": "vitest run --config vitest.e2e.config.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@groundnuty/macf-core": "0.2.
|
|
35
|
+
"@groundnuty/macf-core": "0.2.11",
|
|
36
36
|
"@modelcontextprotocol/sdk": "~1.29.0",
|
|
37
37
|
"@opentelemetry/api": "1.9.1",
|
|
38
38
|
"@opentelemetry/exporter-metrics-otlp-proto": "0.215.0",
|