@neurcode-ai/cli 0.14.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +60 -8
- package/dist/api-client.d.ts +284 -0
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +111 -0
- package/dist/api-client.js.map +1 -1
- package/dist/commands/activate.d.ts +82 -0
- package/dist/commands/activate.d.ts.map +1 -0
- package/dist/commands/activate.js +551 -0
- package/dist/commands/activate.js.map +1 -0
- package/dist/commands/admission.d.ts +67 -0
- package/dist/commands/admission.d.ts.map +1 -0
- package/dist/commands/admission.js +350 -0
- package/dist/commands/admission.js.map +1 -0
- package/dist/commands/agent.d.ts +3 -0
- package/dist/commands/agent.d.ts.map +1 -0
- package/dist/commands/agent.js +2045 -0
- package/dist/commands/agent.js.map +1 -0
- package/dist/commands/demo.d.ts +3 -0
- package/dist/commands/demo.d.ts.map +1 -0
- package/dist/commands/demo.js +102 -0
- package/dist/commands/demo.js.map +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +58 -44
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/login.d.ts +1 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +44 -22
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/profile.d.ts +14 -0
- package/dist/commands/profile.d.ts.map +1 -0
- package/dist/commands/profile.js +118 -0
- package/dist/commands/profile.js.map +1 -0
- package/dist/commands/quickstart.d.ts +2 -2
- package/dist/commands/quickstart.d.ts.map +1 -1
- package/dist/commands/quickstart.js +31 -30
- package/dist/commands/quickstart.js.map +1 -1
- package/dist/commands/remediate-export.d.ts +6 -1
- package/dist/commands/remediate-export.d.ts.map +1 -1
- package/dist/commands/remediate-export.js +359 -7
- package/dist/commands/remediate-export.js.map +1 -1
- package/dist/commands/replay.d.ts.map +1 -1
- package/dist/commands/replay.js +84 -0
- package/dist/commands/replay.js.map +1 -1
- package/dist/commands/run.d.ts +3 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +98 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/runtime-adapter.d.ts +8 -0
- package/dist/commands/runtime-adapter.d.ts.map +1 -0
- package/dist/commands/runtime-adapter.js +375 -0
- package/dist/commands/runtime-adapter.js.map +1 -0
- package/dist/commands/runtime-doctor.d.ts +6 -0
- package/dist/commands/runtime-doctor.d.ts.map +1 -0
- package/dist/commands/runtime-doctor.js +478 -0
- package/dist/commands/runtime-doctor.js.map +1 -0
- package/dist/commands/runtime-report.d.ts +13 -0
- package/dist/commands/runtime-report.d.ts.map +1 -0
- package/dist/commands/runtime-report.js +81 -0
- package/dist/commands/runtime-report.js.map +1 -0
- package/dist/commands/runtime-sync.d.ts +17 -0
- package/dist/commands/runtime-sync.d.ts.map +1 -0
- package/dist/commands/runtime-sync.js +656 -0
- package/dist/commands/runtime-sync.js.map +1 -0
- package/dist/commands/runtime.d.ts +16 -0
- package/dist/commands/runtime.d.ts.map +1 -0
- package/dist/commands/runtime.js +380 -0
- package/dist/commands/runtime.js.map +1 -0
- package/dist/commands/session-hook.d.ts +35 -0
- package/dist/commands/session-hook.d.ts.map +1 -0
- package/dist/commands/session-hook.js +1297 -0
- package/dist/commands/session-hook.js.map +1 -0
- package/dist/commands/session.d.ts +91 -0
- package/dist/commands/session.d.ts.map +1 -1
- package/dist/commands/session.js +1226 -0
- package/dist/commands/session.js.map +1 -1
- package/dist/commands/whoami.d.ts +7 -4
- package/dist/commands/whoami.d.ts.map +1 -1
- package/dist/commands/whoami.js +59 -34
- package/dist/commands/whoami.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +24 -5
- package/dist/config.js.map +1 -1
- package/dist/daemon/routes.d.ts.map +1 -1
- package/dist/daemon/routes.js +8 -0
- package/dist/daemon/routes.js.map +1 -1
- package/dist/daemon/server.d.ts.map +1 -1
- package/dist/daemon/server.js +88 -0
- package/dist/daemon/server.js.map +1 -1
- package/dist/governance/impact-analysis.d.ts +27 -0
- package/dist/governance/impact-analysis.d.ts.map +1 -0
- package/dist/governance/impact-analysis.js +274 -0
- package/dist/governance/impact-analysis.js.map +1 -0
- package/dist/index.js +472 -29
- package/dist/index.js.map +1 -1
- package/dist/intent-engine/matcher.d.ts.map +1 -1
- package/dist/intent-engine/matcher.js +3 -12
- package/dist/intent-engine/matcher.js.map +1 -1
- package/dist/utils/admission-artifact.d.ts +59 -0
- package/dist/utils/admission-artifact.d.ts.map +1 -0
- package/dist/utils/admission-artifact.js +410 -0
- package/dist/utils/admission-artifact.js.map +1 -0
- package/dist/utils/agent-adapter-setup.d.ts +80 -0
- package/dist/utils/agent-adapter-setup.d.ts.map +1 -0
- package/dist/utils/agent-adapter-setup.js +577 -0
- package/dist/utils/agent-adapter-setup.js.map +1 -0
- package/dist/utils/agent-guard-supervisor.d.ts +75 -0
- package/dist/utils/agent-guard-supervisor.d.ts.map +1 -0
- package/dist/utils/agent-guard-supervisor.js +388 -0
- package/dist/utils/agent-guard-supervisor.js.map +1 -0
- package/dist/utils/agent-guard.d.ts +92 -0
- package/dist/utils/agent-guard.d.ts.map +1 -0
- package/dist/utils/agent-guard.js +326 -0
- package/dist/utils/agent-guard.js.map +1 -0
- package/dist/utils/agent-session-launcher.d.ts +89 -0
- package/dist/utils/agent-session-launcher.d.ts.map +1 -0
- package/dist/utils/agent-session-launcher.js +308 -0
- package/dist/utils/agent-session-launcher.js.map +1 -0
- package/dist/utils/bash-command-analysis.d.ts +19 -0
- package/dist/utils/bash-command-analysis.d.ts.map +1 -0
- package/dist/utils/bash-command-analysis.js +295 -0
- package/dist/utils/bash-command-analysis.js.map +1 -0
- package/dist/utils/consequence-nudges.d.ts +30 -0
- package/dist/utils/consequence-nudges.d.ts.map +1 -0
- package/dist/utils/consequence-nudges.js +313 -0
- package/dist/utils/consequence-nudges.js.map +1 -0
- package/dist/utils/drift-intelligence.d.ts.map +1 -1
- package/dist/utils/drift-intelligence.js +29 -7
- package/dist/utils/drift-intelligence.js.map +1 -1
- package/dist/utils/git-coverage.d.ts +57 -0
- package/dist/utils/git-coverage.d.ts.map +1 -0
- package/dist/utils/git-coverage.js +302 -0
- package/dist/utils/git-coverage.js.map +1 -0
- package/dist/utils/gitignore.d.ts.map +1 -1
- package/dist/utils/gitignore.js +2 -1
- package/dist/utils/gitignore.js.map +1 -1
- package/dist/utils/governed-intent.d.ts +10 -0
- package/dist/utils/governed-intent.d.ts.map +1 -0
- package/dist/utils/governed-intent.js +108 -0
- package/dist/utils/governed-intent.js.map +1 -0
- package/dist/utils/hook-heartbeat.d.ts +55 -0
- package/dist/utils/hook-heartbeat.d.ts.map +1 -0
- package/dist/utils/hook-heartbeat.js +116 -0
- package/dist/utils/hook-heartbeat.js.map +1 -0
- package/dist/utils/intent-continuity.d.ts +21 -0
- package/dist/utils/intent-continuity.d.ts.map +1 -0
- package/dist/utils/intent-continuity.js +192 -0
- package/dist/utils/intent-continuity.js.map +1 -0
- package/dist/utils/messages.d.ts +1 -1
- package/dist/utils/messages.d.ts.map +1 -1
- package/dist/utils/messages.js +24 -21
- package/dist/utils/messages.js.map +1 -1
- package/dist/utils/runtime-companion.d.ts +137 -0
- package/dist/utils/runtime-companion.d.ts.map +1 -0
- package/dist/utils/runtime-companion.js +231 -0
- package/dist/utils/runtime-companion.js.map +1 -0
- package/dist/utils/runtime-connection.d.ts +46 -0
- package/dist/utils/runtime-connection.d.ts.map +1 -0
- package/dist/utils/runtime-connection.js +148 -0
- package/dist/utils/runtime-connection.js.map +1 -0
- package/dist/utils/runtime-evidence.d.ts +68 -0
- package/dist/utils/runtime-evidence.d.ts.map +1 -0
- package/dist/utils/runtime-evidence.js +248 -0
- package/dist/utils/runtime-evidence.js.map +1 -0
- package/dist/utils/runtime-live.d.ts +33 -0
- package/dist/utils/runtime-live.d.ts.map +1 -0
- package/dist/utils/runtime-live.js +361 -0
- package/dist/utils/runtime-live.js.map +1 -0
- package/dist/utils/runtime-outbox.d.ts +76 -0
- package/dist/utils/runtime-outbox.d.ts.map +1 -0
- package/dist/utils/runtime-outbox.js +410 -0
- package/dist/utils/runtime-outbox.js.map +1 -0
- package/dist/utils/runtime-receipt.d.ts +50 -0
- package/dist/utils/runtime-receipt.d.ts.map +1 -0
- package/dist/utils/runtime-receipt.js +223 -0
- package/dist/utils/runtime-receipt.js.map +1 -0
- package/dist/utils/state.d.ts +21 -0
- package/dist/utils/state.d.ts.map +1 -1
- package/dist/utils/state.js +30 -0
- package/dist/utils/state.js.map +1 -1
- package/dist/utils/structural-understanding.d.ts +334 -0
- package/dist/utils/structural-understanding.d.ts.map +1 -0
- package/dist/utils/structural-understanding.js +2316 -0
- package/dist/utils/structural-understanding.js.map +1 -0
- package/dist/utils/v0-governance.d.ts +197 -0
- package/dist/utils/v0-governance.d.ts.map +1 -0
- package/dist/utils/v0-governance.js +904 -0
- package/dist/utils/v0-governance.js.map +1 -0
- package/package.json +11 -12
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseSinceDuration = parseSinceDuration;
|
|
4
|
+
exports.listRuntimeSessions = listRuntimeSessions;
|
|
5
|
+
exports.buildRuntimeEvidenceReport = buildRuntimeEvidenceReport;
|
|
6
|
+
exports.renderRuntimeEvidenceMarkdown = renderRuntimeEvidenceMarkdown;
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const governance_runtime_1 = require("@neurcode-ai/governance-runtime");
|
|
10
|
+
const v0_governance_1 = require("./v0-governance");
|
|
11
|
+
function increment(map, key) {
|
|
12
|
+
if (!key)
|
|
13
|
+
return;
|
|
14
|
+
map.set(key, (map.get(key) ?? 0) + 1);
|
|
15
|
+
}
|
|
16
|
+
function toSortedEntries(map, keyName) {
|
|
17
|
+
return Array.from(map.entries())
|
|
18
|
+
.sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))
|
|
19
|
+
.map(([key, count]) => ({ [keyName]: key, count }));
|
|
20
|
+
}
|
|
21
|
+
function eventOwners(event) {
|
|
22
|
+
const detail = event.detail;
|
|
23
|
+
const context = detail && typeof detail === 'object'
|
|
24
|
+
? detail['approvalContext']
|
|
25
|
+
: null;
|
|
26
|
+
if (context && typeof context === 'object') {
|
|
27
|
+
const owners = context['owners'];
|
|
28
|
+
if (Array.isArray(owners)) {
|
|
29
|
+
return owners.filter((owner) => typeof owner === 'string');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const message = event.message ?? '';
|
|
33
|
+
const ownerMatch = message.match(/owned by ([^)\\.]+)/);
|
|
34
|
+
if (!ownerMatch)
|
|
35
|
+
return [];
|
|
36
|
+
return ownerMatch[1]
|
|
37
|
+
.split(',')
|
|
38
|
+
.map((owner) => owner.trim())
|
|
39
|
+
.filter(Boolean);
|
|
40
|
+
}
|
|
41
|
+
function matchesBoundary(filePath, glob) {
|
|
42
|
+
if (!filePath)
|
|
43
|
+
return false;
|
|
44
|
+
const prefix = glob.replace('/**', '').replace('/*', '');
|
|
45
|
+
return filePath === prefix || filePath.startsWith(prefix + '/');
|
|
46
|
+
}
|
|
47
|
+
function sessionStartedAt(session) {
|
|
48
|
+
return session.events.find((event) => event.type === 'session_start')?.ts ?? null;
|
|
49
|
+
}
|
|
50
|
+
function isReportActiveSession(record) {
|
|
51
|
+
if (record.session.status !== 'active')
|
|
52
|
+
return false;
|
|
53
|
+
if (!record.startedAt)
|
|
54
|
+
return false;
|
|
55
|
+
const parsed = Date.parse(record.startedAt);
|
|
56
|
+
return Number.isFinite(parsed);
|
|
57
|
+
}
|
|
58
|
+
function eventTime(event) {
|
|
59
|
+
const parsed = Date.parse(event.ts);
|
|
60
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
61
|
+
}
|
|
62
|
+
function boundaryVerdict(event) {
|
|
63
|
+
const detail = event.detail;
|
|
64
|
+
if (!detail || typeof detail !== 'object' || Array.isArray(detail))
|
|
65
|
+
return null;
|
|
66
|
+
const value = detail.boundaryVerdict;
|
|
67
|
+
return typeof value === 'string' && value.trim() ? value.trim() : null;
|
|
68
|
+
}
|
|
69
|
+
function isAllowedAdvisoryEvent(event) {
|
|
70
|
+
return event.type === 'check_warn' && boundaryVerdict(event) === 'ok';
|
|
71
|
+
}
|
|
72
|
+
function isSensitiveWarningEvent(event) {
|
|
73
|
+
if (event.type !== 'check_warn')
|
|
74
|
+
return false;
|
|
75
|
+
const verdict = boundaryVerdict(event);
|
|
76
|
+
return verdict !== 'ok';
|
|
77
|
+
}
|
|
78
|
+
function parseSinceDuration(input) {
|
|
79
|
+
if (!input)
|
|
80
|
+
return { cutoffMs: null, label: null };
|
|
81
|
+
const trimmed = input.trim();
|
|
82
|
+
const match = trimmed.match(/^(\d+)(m|h|d|w)$/i);
|
|
83
|
+
if (!match)
|
|
84
|
+
throw new Error(`Invalid --since value "${input}". Use formats like 24h, 7d, or 2w.`);
|
|
85
|
+
const value = Number.parseInt(match[1], 10);
|
|
86
|
+
const unit = match[2].toLowerCase();
|
|
87
|
+
const multiplier = unit === 'm' ? 60_000 :
|
|
88
|
+
unit === 'h' ? 3_600_000 :
|
|
89
|
+
unit === 'd' ? 86_400_000 :
|
|
90
|
+
7 * 86_400_000;
|
|
91
|
+
return {
|
|
92
|
+
cutoffMs: Date.now() - value * multiplier,
|
|
93
|
+
label: trimmed,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function listRuntimeSessions(repoRoot, options = {}) {
|
|
97
|
+
const parsedSince = parseSinceDuration(options.since);
|
|
98
|
+
const dir = (0, governance_runtime_1.sessionsDir)(repoRoot);
|
|
99
|
+
if (!(0, fs_1.existsSync)(dir))
|
|
100
|
+
return [];
|
|
101
|
+
const records = [];
|
|
102
|
+
for (const file of (0, fs_1.readdirSync)(dir).filter((name) => name.endsWith('.json') && !name.endsWith('.change-record.json')).sort()) {
|
|
103
|
+
const path = (0, path_1.join)(dir, file);
|
|
104
|
+
try {
|
|
105
|
+
const session = JSON.parse((0, fs_1.readFileSync)(path, 'utf8'));
|
|
106
|
+
const lastEventMs = Math.max(...session.events.map(eventTime), 0);
|
|
107
|
+
if (parsedSince.cutoffMs !== null && lastEventMs < parsedSince.cutoffMs)
|
|
108
|
+
continue;
|
|
109
|
+
records.push({
|
|
110
|
+
session,
|
|
111
|
+
path,
|
|
112
|
+
startedAt: sessionStartedAt(session),
|
|
113
|
+
blockCount: session.events.filter((event) => event.type === 'check_block').length,
|
|
114
|
+
warnCount: session.events.filter(isSensitiveWarningEvent).length,
|
|
115
|
+
okCount: session.events.filter((event) => event.type === 'check_ok' || isAllowedAdvisoryEvent(event)).length,
|
|
116
|
+
approvalCount: session.events.filter((event) => event.type === 'approval_decision').length,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
// Corrupt session files should not make the pilot report unusable.
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return records.sort((a, b) => {
|
|
124
|
+
const aTime = a.startedAt ? Date.parse(a.startedAt) : 0;
|
|
125
|
+
const bTime = b.startedAt ? Date.parse(b.startedAt) : 0;
|
|
126
|
+
return bTime - aTime || a.session.sessionId.localeCompare(b.session.sessionId);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function buildRuntimeEvidenceReport(repoRoot, options = {}) {
|
|
130
|
+
const since = parseSinceDuration(options.since);
|
|
131
|
+
const records = listRuntimeSessions(repoRoot, options);
|
|
132
|
+
const profile = (0, v0_governance_1.getProfileStaleness)(repoRoot);
|
|
133
|
+
const blockedPaths = new Map();
|
|
134
|
+
const owners = new Map();
|
|
135
|
+
const boundaries = new Map();
|
|
136
|
+
for (const record of records) {
|
|
137
|
+
for (const event of record.session.events) {
|
|
138
|
+
if (event.type !== 'check_block' && event.type !== 'check_warn')
|
|
139
|
+
continue;
|
|
140
|
+
if (event.type === 'check_block') {
|
|
141
|
+
increment(blockedPaths, event.filePath);
|
|
142
|
+
}
|
|
143
|
+
for (const owner of eventOwners(event))
|
|
144
|
+
increment(owners, owner);
|
|
145
|
+
for (const boundary of record.session.contract.approvalRequiredGlobs) {
|
|
146
|
+
if (matchesBoundary(event.filePath, boundary))
|
|
147
|
+
increment(boundaries, boundary);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const activeSessions = records.filter(isReportActiveSession).length;
|
|
152
|
+
const finishedSessions = records.filter((record) => record.session.status === 'finished').length;
|
|
153
|
+
const totalChecks = records.reduce((sum, record) => sum + record.blockCount + record.warnCount + record.okCount, 0);
|
|
154
|
+
const allowedWithAdvisories = records.reduce((sum, record) => sum + record.session.events.filter(isAllowedAdvisoryEvent).length, 0);
|
|
155
|
+
return {
|
|
156
|
+
repoRoot,
|
|
157
|
+
generatedAt: new Date().toISOString(),
|
|
158
|
+
since: since.label,
|
|
159
|
+
profile: {
|
|
160
|
+
status: profile.status,
|
|
161
|
+
profilePath: profile.profilePath,
|
|
162
|
+
reasons: profile.reasons,
|
|
163
|
+
},
|
|
164
|
+
summary: {
|
|
165
|
+
sessions: records.length,
|
|
166
|
+
activeSessions,
|
|
167
|
+
finishedSessions,
|
|
168
|
+
totalChecks,
|
|
169
|
+
blockedEdits: records.reduce((sum, record) => sum + record.blockCount, 0),
|
|
170
|
+
warnedSensitiveEdits: records.reduce((sum, record) => sum + record.warnCount, 0),
|
|
171
|
+
allowedWithAdvisories,
|
|
172
|
+
allowedEdits: records.reduce((sum, record) => sum + record.okCount, 0),
|
|
173
|
+
approvalsGranted: records.reduce((sum, record) => sum + record.approvalCount, 0),
|
|
174
|
+
},
|
|
175
|
+
topBlockedPaths: toSortedEntries(blockedPaths, 'path').slice(0, 10),
|
|
176
|
+
topOwners: toSortedEntries(owners, 'owner').slice(0, 10),
|
|
177
|
+
approvalRequiredBoundariesTouched: toSortedEntries(boundaries, 'boundary').slice(0, 10),
|
|
178
|
+
sessions: records.map((record) => ({
|
|
179
|
+
sessionId: record.session.sessionId,
|
|
180
|
+
status: record.session.status,
|
|
181
|
+
goal: record.session.contract.goal,
|
|
182
|
+
scopeMode: record.session.contract.scopeMode,
|
|
183
|
+
blockCount: record.blockCount,
|
|
184
|
+
warnCount: record.warnCount,
|
|
185
|
+
okCount: record.okCount,
|
|
186
|
+
approvalCount: record.approvalCount,
|
|
187
|
+
approvedPaths: record.session.contract.approvedPaths,
|
|
188
|
+
replayHash: record.session.replayHash,
|
|
189
|
+
recordPath: record.path,
|
|
190
|
+
})),
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
function tableRows(items, columns) {
|
|
194
|
+
if (items.length === 0)
|
|
195
|
+
return ['none'];
|
|
196
|
+
return items.map((item) => columns.map(([label, key]) => `${label}: ${String(item[key] ?? '')}`).join(' | '));
|
|
197
|
+
}
|
|
198
|
+
function renderRuntimeEvidenceMarkdown(report) {
|
|
199
|
+
const lines = [];
|
|
200
|
+
lines.push('# Neurcode Runtime Evidence Report');
|
|
201
|
+
lines.push('');
|
|
202
|
+
lines.push(`Generated: ${report.generatedAt}`);
|
|
203
|
+
lines.push(`Repo: ${report.repoRoot}`);
|
|
204
|
+
if (report.since)
|
|
205
|
+
lines.push(`Window: ${report.since}`);
|
|
206
|
+
lines.push(`Profile: ${report.profile.status}${report.profile.reasons.length ? ` (${report.profile.reasons.join('; ')})` : ''}`);
|
|
207
|
+
lines.push('');
|
|
208
|
+
lines.push('## Summary');
|
|
209
|
+
lines.push('');
|
|
210
|
+
lines.push(`- Sessions: ${report.summary.sessions} (${report.summary.activeSessions} active, ${report.summary.finishedSessions} finished)`);
|
|
211
|
+
lines.push(`- Total edit checks: ${report.summary.totalChecks}`);
|
|
212
|
+
lines.push(`- Blocked edits: ${report.summary.blockedEdits}`);
|
|
213
|
+
lines.push(`- Warned sensitive edits: ${report.summary.warnedSensitiveEdits}`);
|
|
214
|
+
lines.push(`- Allowed edits with advisory obligations: ${report.summary.allowedWithAdvisories}`);
|
|
215
|
+
lines.push(`- Allowed edits: ${report.summary.allowedEdits}`);
|
|
216
|
+
lines.push(`- Approvals granted: ${report.summary.approvalsGranted}`);
|
|
217
|
+
lines.push('');
|
|
218
|
+
lines.push('## Top Blocked Paths');
|
|
219
|
+
lines.push('');
|
|
220
|
+
for (const row of tableRows(report.topBlockedPaths, [['path', 'path'], ['count', 'count']]))
|
|
221
|
+
lines.push(`- ${row}`);
|
|
222
|
+
lines.push('');
|
|
223
|
+
lines.push('## Owners Involved');
|
|
224
|
+
lines.push('');
|
|
225
|
+
for (const row of tableRows(report.topOwners, [['owner', 'owner'], ['count', 'count']]))
|
|
226
|
+
lines.push(`- ${row}`);
|
|
227
|
+
lines.push('');
|
|
228
|
+
lines.push('## Approval-Required Boundaries Touched');
|
|
229
|
+
lines.push('');
|
|
230
|
+
for (const row of tableRows(report.approvalRequiredBoundariesTouched, [['boundary', 'boundary'], ['count', 'count']]))
|
|
231
|
+
lines.push(`- ${row}`);
|
|
232
|
+
lines.push('');
|
|
233
|
+
lines.push('## Sessions');
|
|
234
|
+
lines.push('');
|
|
235
|
+
if (report.sessions.length === 0) {
|
|
236
|
+
lines.push('- none');
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
for (const session of report.sessions) {
|
|
240
|
+
lines.push(`- ${session.sessionId} (${session.status}) blocks=${session.blockCount} warnings=${session.warnCount} approvals=${session.approvalCount} replay=${session.replayHash ?? 'n/a'}`);
|
|
241
|
+
lines.push(` - Goal: ${session.goal}`);
|
|
242
|
+
lines.push(` - Record: ${session.recordPath}`);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
lines.push('');
|
|
246
|
+
return lines.join('\n');
|
|
247
|
+
}
|
|
248
|
+
//# sourceMappingURL=runtime-evidence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-evidence.js","sourceRoot":"","sources":["../../src/utils/runtime-evidence.ts"],"names":[],"mappings":";;AAoIA,gDAgBC;AAED,kDAkCC;AAED,gEAyEC;AASD,sEA4CC;AAxTD,2BAIY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AAC,IAAI,EAAE,CAAC,CAAC;YACxC,KAAK,CAAC,IAAI,CAAC,eAAe,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type GovernanceSession } from '@neurcode-ai/governance-runtime';
|
|
2
|
+
import { type RuntimeOutboxStatus } from './runtime-outbox';
|
|
3
|
+
import type { ProfileFreshnessSignal } from './v0-governance';
|
|
4
|
+
export declare function publishRuntimeLiveStatus(repoRoot: string, session: GovernanceSession, options?: {
|
|
5
|
+
profileFreshness?: ProfileFreshnessSignal;
|
|
6
|
+
}): Promise<{
|
|
7
|
+
ok: boolean;
|
|
8
|
+
queued?: boolean;
|
|
9
|
+
pending?: number;
|
|
10
|
+
skipped?: string;
|
|
11
|
+
error?: string;
|
|
12
|
+
}>;
|
|
13
|
+
export interface RuntimeLiveOutboxFlushResult {
|
|
14
|
+
attempted: number;
|
|
15
|
+
delivered: number;
|
|
16
|
+
failed: number;
|
|
17
|
+
deadLettered: number;
|
|
18
|
+
pending: number;
|
|
19
|
+
skipped?: string;
|
|
20
|
+
lastError?: string;
|
|
21
|
+
status: RuntimeOutboxStatus;
|
|
22
|
+
}
|
|
23
|
+
export declare function flushRuntimeLiveOutbox(repoRoot: string, options?: {
|
|
24
|
+
maxEvents?: number;
|
|
25
|
+
timeoutMs?: number;
|
|
26
|
+
force?: boolean;
|
|
27
|
+
}): Promise<RuntimeLiveOutboxFlushResult>;
|
|
28
|
+
export declare function applyPendingRuntimeLiveApprovals(repoRoot: string, sessionId: string): Promise<{
|
|
29
|
+
applied: number;
|
|
30
|
+
revoked: number;
|
|
31
|
+
failed: number;
|
|
32
|
+
}>;
|
|
33
|
+
//# sourceMappingURL=runtime-live.d.ts.map
|
|
@@ -0,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C;IACnG,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAuED"}
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.publishRuntimeLiveStatus = publishRuntimeLiveStatus;
|
|
4
|
+
exports.flushRuntimeLiveOutbox = flushRuntimeLiveOutbox;
|
|
5
|
+
exports.applyPendingRuntimeLiveApprovals = applyPendingRuntimeLiveApprovals;
|
|
6
|
+
const governance_runtime_1 = require("@neurcode-ai/governance-runtime");
|
|
7
|
+
const config_1 = require("../config");
|
|
8
|
+
const runtime_connection_1 = require("./runtime-connection");
|
|
9
|
+
const runtime_outbox_1 = require("./runtime-outbox");
|
|
10
|
+
const SOURCE_LIKE_KEYS = new Set([
|
|
11
|
+
'content',
|
|
12
|
+
'fileContent',
|
|
13
|
+
'file_content',
|
|
14
|
+
'sourceText',
|
|
15
|
+
'source_text',
|
|
16
|
+
'diff',
|
|
17
|
+
'diffText',
|
|
18
|
+
'diff_text',
|
|
19
|
+
'patch',
|
|
20
|
+
'before',
|
|
21
|
+
'after',
|
|
22
|
+
]);
|
|
23
|
+
const LIVE_SESSION_SCHEMA_VERSION = 'neurcode.runtime-live-session.v2';
|
|
24
|
+
const MAX_LIVE_TEXT = 800;
|
|
25
|
+
const MAX_LIVE_ARRAY_ITEMS = 80;
|
|
26
|
+
const MAX_LIVE_EVENTS = 80;
|
|
27
|
+
const MAX_LIVE_OBJECT_KEYS = 100;
|
|
28
|
+
const LIVE_OMITTED_KEYS = new Set([
|
|
29
|
+
'architectureGraph',
|
|
30
|
+
'dependencyGraph',
|
|
31
|
+
'ownershipGraph',
|
|
32
|
+
'profile',
|
|
33
|
+
'profileGraph',
|
|
34
|
+
'facts',
|
|
35
|
+
'fileFacts',
|
|
36
|
+
'repoFacts',
|
|
37
|
+
]);
|
|
38
|
+
function sanitizeForRuntimeLive(value) {
|
|
39
|
+
if (Array.isArray(value))
|
|
40
|
+
return value.map((item) => sanitizeForRuntimeLive(item));
|
|
41
|
+
if (!value || typeof value !== 'object')
|
|
42
|
+
return value;
|
|
43
|
+
const out = {};
|
|
44
|
+
for (const [key, child] of Object.entries(value)) {
|
|
45
|
+
if (SOURCE_LIKE_KEYS.has(key))
|
|
46
|
+
continue;
|
|
47
|
+
out[key] = sanitizeForRuntimeLive(child);
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
function isRecord(value) {
|
|
52
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
53
|
+
}
|
|
54
|
+
function compactText(value) {
|
|
55
|
+
if (value.length <= MAX_LIVE_TEXT)
|
|
56
|
+
return value;
|
|
57
|
+
return `${value.slice(0, MAX_LIVE_TEXT)}... [truncated ${value.length - MAX_LIVE_TEXT} chars]`;
|
|
58
|
+
}
|
|
59
|
+
function compactRuntimeLiveValue(value, depth = 0) {
|
|
60
|
+
if (typeof value === 'string')
|
|
61
|
+
return compactText(value);
|
|
62
|
+
if (Array.isArray(value)) {
|
|
63
|
+
return value
|
|
64
|
+
.slice(0, MAX_LIVE_ARRAY_ITEMS)
|
|
65
|
+
.map((item) => compactRuntimeLiveValue(item, depth + 1));
|
|
66
|
+
}
|
|
67
|
+
if (!isRecord(value))
|
|
68
|
+
return value;
|
|
69
|
+
const out = {};
|
|
70
|
+
let keys = 0;
|
|
71
|
+
for (const [key, child] of Object.entries(value)) {
|
|
72
|
+
if (SOURCE_LIKE_KEYS.has(key) || LIVE_OMITTED_KEYS.has(key))
|
|
73
|
+
continue;
|
|
74
|
+
if (keys >= MAX_LIVE_OBJECT_KEYS) {
|
|
75
|
+
out.__truncatedKeys = true;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
keys += 1;
|
|
79
|
+
out[key] = depth > 8 ? '[max-depth]' : compactRuntimeLiveValue(child, depth + 1);
|
|
80
|
+
}
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
function compactRuntimeLiveEvent(event) {
|
|
84
|
+
if (!isRecord(event))
|
|
85
|
+
return compactRuntimeLiveValue(event);
|
|
86
|
+
const out = {};
|
|
87
|
+
for (const key of [
|
|
88
|
+
'type',
|
|
89
|
+
'ts',
|
|
90
|
+
'filePath',
|
|
91
|
+
'verdict',
|
|
92
|
+
'decision',
|
|
93
|
+
'message',
|
|
94
|
+
'reason',
|
|
95
|
+
'source',
|
|
96
|
+
]) {
|
|
97
|
+
if (key in event)
|
|
98
|
+
out[key] = compactRuntimeLiveValue(event[key]);
|
|
99
|
+
}
|
|
100
|
+
if (isRecord(event.detail)) {
|
|
101
|
+
out.detail = compactRuntimeLiveValue(event.detail);
|
|
102
|
+
}
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
function compactRuntimeLiveSession(session) {
|
|
106
|
+
const sanitized = sanitizeForRuntimeLive(session);
|
|
107
|
+
const input = isRecord(sanitized) ? sanitized : {};
|
|
108
|
+
const contract = isRecord(input.contract) ? input.contract : {};
|
|
109
|
+
const events = Array.isArray(input.events) ? input.events : [];
|
|
110
|
+
const compactEvents = events.slice(-MAX_LIVE_EVENTS).map(compactRuntimeLiveEvent);
|
|
111
|
+
return {
|
|
112
|
+
schemaVersion: input.schemaVersion,
|
|
113
|
+
runtimeLiveSchemaVersion: LIVE_SESSION_SCHEMA_VERSION,
|
|
114
|
+
sessionId: input.sessionId,
|
|
115
|
+
repoName: input.repoName,
|
|
116
|
+
profileHash: input.profileHash,
|
|
117
|
+
status: input.status,
|
|
118
|
+
startedAt: input.startedAt,
|
|
119
|
+
finishedAt: input.finishedAt,
|
|
120
|
+
replayHash: input.replayHash,
|
|
121
|
+
contract: compactRuntimeLiveValue(contract),
|
|
122
|
+
events: compactEvents,
|
|
123
|
+
livePayload: {
|
|
124
|
+
schemaVersion: LIVE_SESSION_SCHEMA_VERSION,
|
|
125
|
+
compacted: true,
|
|
126
|
+
originalEventCount: events.length,
|
|
127
|
+
includedEventCount: compactEvents.length,
|
|
128
|
+
maxTextChars: MAX_LIVE_TEXT,
|
|
129
|
+
maxArrayItems: MAX_LIVE_ARRAY_ITEMS,
|
|
130
|
+
omittedKeys: Array.from(LIVE_OMITTED_KEYS).sort(),
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function runtimeAuth(repoRoot) {
|
|
135
|
+
const connection = (0, runtime_connection_1.loadRuntimeConnection)(repoRoot);
|
|
136
|
+
if (!connection)
|
|
137
|
+
return null;
|
|
138
|
+
const apiKey = (0, config_1.getApiKey)(connection.organizationId);
|
|
139
|
+
if (!apiKey)
|
|
140
|
+
return null;
|
|
141
|
+
const authHeader = apiKey.startsWith('Bearer ') ? apiKey : `Bearer ${apiKey}`;
|
|
142
|
+
return {
|
|
143
|
+
apiUrl: connection.apiUrl.replace(/\/$/, ''),
|
|
144
|
+
repoKey: connection.repo.repoKey,
|
|
145
|
+
headers: {
|
|
146
|
+
Authorization: authHeader,
|
|
147
|
+
'Content-Type': 'application/json',
|
|
148
|
+
'x-org-id': connection.organizationId,
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
async function runtimeFetch(repoRoot, path, init, timeoutMs = 1500) {
|
|
153
|
+
const auth = runtimeAuth(repoRoot);
|
|
154
|
+
if (!auth)
|
|
155
|
+
return null;
|
|
156
|
+
const controller = new AbortController();
|
|
157
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
158
|
+
try {
|
|
159
|
+
return await fetch(`${auth.apiUrl}${path}`, {
|
|
160
|
+
...init,
|
|
161
|
+
headers: {
|
|
162
|
+
...auth.headers,
|
|
163
|
+
...init.headers,
|
|
164
|
+
},
|
|
165
|
+
signal: controller.signal,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
finally {
|
|
169
|
+
clearTimeout(timeout);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async function publishRuntimeLiveStatus(repoRoot, session, options = {}) {
|
|
173
|
+
const repo = (0, runtime_connection_1.collectRuntimeRepoMetadata)(repoRoot, options.profileFreshness);
|
|
174
|
+
const body = {
|
|
175
|
+
repo,
|
|
176
|
+
generatedAt: new Date().toISOString(),
|
|
177
|
+
session: compactRuntimeLiveSession(session),
|
|
178
|
+
};
|
|
179
|
+
try {
|
|
180
|
+
(0, runtime_outbox_1.enqueueRuntimeSessionSnapshot)(repoRoot, session.sessionId, body);
|
|
181
|
+
const flushed = await flushRuntimeLiveOutbox(repoRoot, {
|
|
182
|
+
maxEvents: 2,
|
|
183
|
+
timeoutMs: 500,
|
|
184
|
+
});
|
|
185
|
+
return {
|
|
186
|
+
ok: flushed.failed === 0 && !flushed.skipped && flushed.status.health !== 'degraded',
|
|
187
|
+
queued: flushed.pending > 0,
|
|
188
|
+
pending: flushed.pending,
|
|
189
|
+
...(flushed.skipped ? { skipped: flushed.skipped } : {}),
|
|
190
|
+
...(flushed.lastError ? { error: flushed.lastError } : {}),
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
async function flushRuntimeLiveOutbox(repoRoot, options = {}) {
|
|
198
|
+
if (!runtimeAuth(repoRoot)) {
|
|
199
|
+
const status = (0, runtime_outbox_1.inspectRuntimeOutbox)(repoRoot);
|
|
200
|
+
return {
|
|
201
|
+
attempted: 0,
|
|
202
|
+
delivered: 0,
|
|
203
|
+
failed: 0,
|
|
204
|
+
deadLettered: 0,
|
|
205
|
+
pending: status.pendingEvents,
|
|
206
|
+
skipped: 'not connected',
|
|
207
|
+
status,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
const events = (0, runtime_outbox_1.pendingRuntimeOutboxEvents)(repoRoot, {
|
|
211
|
+
limit: options.maxEvents ?? 10,
|
|
212
|
+
force: options.force,
|
|
213
|
+
});
|
|
214
|
+
let delivered = 0;
|
|
215
|
+
let failed = 0;
|
|
216
|
+
let deadLettered = 0;
|
|
217
|
+
let lastError;
|
|
218
|
+
for (const event of events) {
|
|
219
|
+
try {
|
|
220
|
+
const envelope = (0, runtime_outbox_1.runtimeDeliveryEnvelope)(event);
|
|
221
|
+
let response;
|
|
222
|
+
if (event.eventType === 'session_snapshot') {
|
|
223
|
+
response = await runtimeFetch(repoRoot, '/api/v1/runtime/live-sessions/status', {
|
|
224
|
+
method: 'POST',
|
|
225
|
+
body: JSON.stringify({
|
|
226
|
+
...event.payload,
|
|
227
|
+
delivery: envelope,
|
|
228
|
+
}),
|
|
229
|
+
}, options.timeoutMs ?? 1_500);
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
const approvalId = typeof event.payload.approvalId === 'string' ? event.payload.approvalId : '';
|
|
233
|
+
response = approvalId
|
|
234
|
+
? await runtimeFetch(repoRoot, `/api/v1/runtime/live-sessions/${encodeURIComponent(event.sessionId)}/approvals/${encodeURIComponent(approvalId)}/applied`, {
|
|
235
|
+
method: 'POST',
|
|
236
|
+
body: JSON.stringify({
|
|
237
|
+
...event.payload.body,
|
|
238
|
+
delivery: envelope,
|
|
239
|
+
}),
|
|
240
|
+
}, options.timeoutMs ?? 1_500)
|
|
241
|
+
: null;
|
|
242
|
+
}
|
|
243
|
+
if (!response)
|
|
244
|
+
throw new Error('runtime transport unavailable');
|
|
245
|
+
if (!response.ok)
|
|
246
|
+
throw new Error(`HTTP ${response.status}`);
|
|
247
|
+
(0, runtime_outbox_1.markRuntimeOutboxDelivered)(repoRoot, event.eventId);
|
|
248
|
+
delivered += 1;
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
lastError = error instanceof Error ? error.message : String(error);
|
|
252
|
+
const failure = (0, runtime_outbox_1.markRuntimeOutboxFailed)(repoRoot, event.eventId, lastError);
|
|
253
|
+
if (failure.deadLettered)
|
|
254
|
+
deadLettered += 1;
|
|
255
|
+
failed += 1;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
const status = (0, runtime_outbox_1.inspectRuntimeOutbox)(repoRoot);
|
|
259
|
+
return {
|
|
260
|
+
attempted: events.length,
|
|
261
|
+
delivered,
|
|
262
|
+
failed,
|
|
263
|
+
deadLettered,
|
|
264
|
+
pending: status.pendingEvents,
|
|
265
|
+
...(lastError ? { lastError } : {}),
|
|
266
|
+
status,
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
async function fetchPendingApprovals(repoRoot, sessionId) {
|
|
270
|
+
const auth = runtimeAuth(repoRoot);
|
|
271
|
+
if (!auth)
|
|
272
|
+
return [];
|
|
273
|
+
try {
|
|
274
|
+
const response = await runtimeFetch(repoRoot, `/api/v1/runtime/live-sessions/${encodeURIComponent(sessionId)}/approvals?repoKey=${encodeURIComponent(auth.repoKey)}`, { method: 'GET' }, 1500);
|
|
275
|
+
if (!response || !response.ok)
|
|
276
|
+
return [];
|
|
277
|
+
const body = await response.json();
|
|
278
|
+
return Array.isArray(body.approvals) ? body.approvals : [];
|
|
279
|
+
}
|
|
280
|
+
catch {
|
|
281
|
+
return [];
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
function queueApprovalAcknowledgement(repoRoot, sessionId, approval, body) {
|
|
285
|
+
if (!approval.id)
|
|
286
|
+
return;
|
|
287
|
+
(0, runtime_outbox_1.enqueueRuntimeApprovalAck)(repoRoot, sessionId, {
|
|
288
|
+
approvalId: approval.id,
|
|
289
|
+
body,
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
async function applyPendingRuntimeLiveApprovals(repoRoot, sessionId) {
|
|
293
|
+
await flushRuntimeLiveOutbox(repoRoot, { maxEvents: 20, timeoutMs: 750 });
|
|
294
|
+
const approvals = await fetchPendingApprovals(repoRoot, sessionId);
|
|
295
|
+
let applied = 0;
|
|
296
|
+
let revoked = 0;
|
|
297
|
+
let failed = 0;
|
|
298
|
+
for (const approval of approvals) {
|
|
299
|
+
if (!approval.path)
|
|
300
|
+
continue;
|
|
301
|
+
if (approval.status === 'revoked') {
|
|
302
|
+
try {
|
|
303
|
+
(0, governance_runtime_1.revokeSessionApproval)(repoRoot, approval.path, {
|
|
304
|
+
sessionId,
|
|
305
|
+
requestId: approval.id,
|
|
306
|
+
source: 'dashboard',
|
|
307
|
+
revokedBy: approval.revokedBy || null,
|
|
308
|
+
reason: approval.revocationReason || 'dashboard live approval revoked',
|
|
309
|
+
});
|
|
310
|
+
revoked += 1;
|
|
311
|
+
queueApprovalAcknowledgement(repoRoot, sessionId, approval, {
|
|
312
|
+
status: 'revoked',
|
|
313
|
+
appliedPath: approval.path,
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
catch (error) {
|
|
317
|
+
failed += 1;
|
|
318
|
+
queueApprovalAcknowledgement(repoRoot, sessionId, approval, {
|
|
319
|
+
status: 'failed',
|
|
320
|
+
message: error instanceof Error ? error.message : String(error),
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
if (approval.status !== 'pending')
|
|
326
|
+
continue;
|
|
327
|
+
try {
|
|
328
|
+
const session = (0, governance_runtime_1.loadSession)(repoRoot, sessionId);
|
|
329
|
+
const existingGrant = session?.contract.approvalGrants?.find((grant) => Boolean(approval.id) && grant.requestId === approval.id);
|
|
330
|
+
const result = existingGrant
|
|
331
|
+
? {
|
|
332
|
+
approvedPath: existingGrant.path,
|
|
333
|
+
expiresAt: existingGrant.expiresAt,
|
|
334
|
+
}
|
|
335
|
+
: (0, governance_runtime_1.approveSession)(repoRoot, approval.path, {
|
|
336
|
+
reason: approval.reason || 'dashboard live approval',
|
|
337
|
+
sessionId,
|
|
338
|
+
expiresAt: approval.expiresAt || undefined,
|
|
339
|
+
source: 'dashboard',
|
|
340
|
+
approvedBy: approval.requestedBy || null,
|
|
341
|
+
requestId: approval.id || null,
|
|
342
|
+
});
|
|
343
|
+
applied += 1;
|
|
344
|
+
queueApprovalAcknowledgement(repoRoot, sessionId, approval, {
|
|
345
|
+
status: 'applied',
|
|
346
|
+
appliedPath: result.approvedPath,
|
|
347
|
+
expiresAt: result.expiresAt,
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
catch (error) {
|
|
351
|
+
failed += 1;
|
|
352
|
+
queueApprovalAcknowledgement(repoRoot, sessionId, approval, {
|
|
353
|
+
status: 'failed',
|
|
354
|
+
message: error instanceof Error ? error.message : String(error),
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
await flushRuntimeLiveOutbox(repoRoot, { maxEvents: 20, timeoutMs: 750 });
|
|
359
|
+
return { applied, revoked, failed };
|
|
360
|
+
}
|
|
361
|
+
//# sourceMappingURL=runtime-live.js.map
|