synabun 2.4.5 → 2.4.6
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/CHANGELOG.md +25 -0
- package/README.md +1 -1
- package/docs/whatsapp.md +17 -1
- package/hooks/claude-code/session-start.mjs +21 -18
- package/lib/claude-global-config.js +214 -0
- package/lib/client-config-repair.js +17 -3
- package/mcp-server/dist/index.d.ts.map +1 -1
- package/mcp-server/dist/index.js +6 -1
- package/mcp-server/dist/index.js.map +1 -1
- package/mcp-server/dist/services/tool-catalog.js +1 -1
- package/mcp-server/dist/services/tool-catalog.js.map +1 -1
- package/mcp-server/dist/tools/agents.d.ts +2 -0
- package/mcp-server/dist/tools/agents.d.ts.map +1 -1
- package/mcp-server/dist/tools/agents.js +11 -5
- package/mcp-server/dist/tools/agents.js.map +1 -1
- package/mcp-server/dist/tools/skill-tools.d.ts +24 -5
- package/mcp-server/dist/tools/skill-tools.d.ts.map +1 -1
- package/mcp-server/dist/tools/skill-tools.js +88 -8
- package/mcp-server/dist/tools/skill-tools.js.map +1 -1
- package/mcp-server/dist/tools/tool-groups.d.ts.map +1 -1
- package/mcp-server/dist/tools/tool-groups.js +19 -4
- package/mcp-server/dist/tools/tool-groups.js.map +1 -1
- package/mcp-server/package-lock.json +2 -2
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/index.ts +6 -1
- package/mcp-server/src/services/tool-catalog.ts +1 -1
- package/mcp-server/src/tools/agents.ts +11 -5
- package/mcp-server/src/tools/skill-tools.ts +82 -9
- package/mcp-server/src/tools/tool-groups.ts +19 -4
- package/neural-interface/i18n/en.json +135 -10
- package/neural-interface/i18n/pt-BR.json +135 -10
- package/neural-interface/lib/antigravity/panel-bridge.js +7 -3
- package/neural-interface/lib/assistant-dispatch.js +15 -1
- package/neural-interface/lib/assistant-runtime.js +79 -8
- package/neural-interface/lib/assistant-user-context.js +7 -3
- package/neural-interface/lib/claude-agent-bridge.js +13 -2
- package/neural-interface/lib/codex-thread-history.js +144 -7
- package/neural-interface/lib/codex-worker-app-server.js +84 -30
- package/neural-interface/lib/db.js +26 -0
- package/neural-interface/lib/greeting/sources.js +7 -3
- package/neural-interface/lib/jsonl-lines.js +10 -11
- package/neural-interface/lib/line-buffer.js +88 -0
- package/neural-interface/lib/loop-stall.js +15 -1
- package/neural-interface/lib/memory-list-read.js +105 -0
- package/neural-interface/lib/memory-timers.js +4 -1
- package/neural-interface/lib/native-loop-runtime.js +7 -3
- package/neural-interface/lib/provider-panel-api-key-auth.js +33 -6
- package/neural-interface/lib/skills/api-v2.js +18 -3
- package/neural-interface/lib/skills/bundle.js +2 -2
- package/neural-interface/lib/skills/deploy.js +169 -34
- package/neural-interface/lib/skills/digest.js +57 -3
- package/neural-interface/lib/skills/health.js +55 -1
- package/neural-interface/lib/skills/known-bridge-digests.json +12 -0
- package/neural-interface/lib/skills/runtime-checks.js +7 -4
- package/neural-interface/lib/skills/scan-shell.js +56 -7
- package/neural-interface/lib/skills/scan.js +13 -12
- package/neural-interface/lib/skills/service.js +7 -2
- package/neural-interface/lib/skills/telemetry.js +2 -2
- package/neural-interface/lib/teams/README.md +12 -5
- package/neural-interface/lib/teams/api.js +15 -4
- package/neural-interface/lib/teams/index.js +2 -0
- package/neural-interface/lib/teams/landing.js +195 -75
- package/neural-interface/lib/teams/scheduler.js +31 -32
- package/neural-interface/lib/terminal-token-redaction.js +228 -58
- package/neural-interface/lib/terminal-tokens.js +18 -0
- package/neural-interface/lib/whatsapp/brain.js +21 -0
- package/neural-interface/lib/whatsapp/bridge.js +40 -4
- package/neural-interface/package-lock.json +2 -2
- package/neural-interface/package.json +1 -1
- package/neural-interface/public/index.html +117 -37
- package/neural-interface/public/shared/agents/studio/ax-api.js +11 -0
- package/neural-interface/public/shared/agents/studio/ax-create-view.js +1 -1
- package/neural-interface/public/shared/agents/studio/ax-icons.js +1 -0
- package/neural-interface/public/shared/agents/studio/ax-library-view.js +3 -2
- package/neural-interface/public/shared/agents/studio/ax-main.js +127 -41
- package/neural-interface/public/shared/agents/studio/ax-review-view.js +3 -2
- package/neural-interface/public/shared/agents/studio/ax-teams-view.js +137 -39
- package/neural-interface/public/shared/agents/studio/ax-teams.js +219 -4
- package/neural-interface/public/shared/agents/studio/ax-ui.js +31 -0
- package/neural-interface/public/shared/agents/studio/ax-views.js +67 -69
- package/neural-interface/public/shared/agents/studio/ax-work-answer.js +86 -0
- package/neural-interface/public/shared/agents/studio/ax-work-view.js +305 -0
- package/neural-interface/public/shared/agents/studio/ax-work.css +74 -0
- package/neural-interface/public/shared/agents/studio/ax-work.js +300 -0
- package/neural-interface/public/shared/cdx/cdx-deferred.js +90 -0
- package/neural-interface/public/shared/cdx/cdx-render.js +18 -7
- package/neural-interface/public/shared/cdx/cdx-tabs.js +2 -1
- package/neural-interface/public/shared/loading-diagnostic-entry.js +16 -1
- package/neural-interface/public/shared/skills/studio/sx-operations-view.js +5 -0
- package/neural-interface/public/shared/skills/studio/sx-plan.js +42 -3
- package/neural-interface/public/shared/skills/studio/sx-publish-view.js +20 -4
- package/neural-interface/server.js +316 -252
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
- package/skills/skill-forge/SKILL.md +7 -3
|
@@ -20,8 +20,10 @@
|
|
|
20
20
|
// Every install is recorded (DATA_HOME/data/skills/installations.json, schema 2): the revision, the export and its
|
|
21
21
|
// digest, the destination and the runtimes it reaches, what it replaced (its backup), and its state: written
|
|
22
22
|
// (checked by digest), discoverable (the runtime's rules, read statically), eligible (enabled in the runtime's
|
|
23
|
-
// settings, when that can be read
|
|
24
|
-
//
|
|
23
|
+
// settings, when that can be read: per runtime in eligibilityByRuntime, the aggregate over the runtimes that were
|
|
24
|
+
// checked), discovered (only what a runtime itself answered), loaded (never claimed), and the refresh a running
|
|
25
|
+
// session needs. Right after each committed target the static part of verify() runs by itself (no runtime is
|
|
26
|
+
// started or asked); asking Codex or OpenCode stays an explicit request (verify with probeRuntime). A rollback puts back exactly what the install replaced; an uninstall
|
|
25
27
|
// removes only what SynaBun installed and still holds those bytes (or what the owner confirmed as it is now).
|
|
26
28
|
|
|
27
29
|
import { effectiveInstallName, nameChecks } from './scan-context.js';
|
|
@@ -31,7 +33,7 @@ import { chmodSync, lstatSync, mkdirSync, renameSync, rmSync } from 'node:fs';
|
|
|
31
33
|
import { basename, dirname, join, resolve } from 'node:path';
|
|
32
34
|
import { PathConfineError, isInside, isPlainName, realPathOf } from '../path-confine.js';
|
|
33
35
|
import { makeConfinedDir, readConfinedFile, removeConfinedEntry, replaceFileAtomic, writeConfinedFile } from '../confined-fs.js';
|
|
34
|
-
import { readManifest } from './digest.js';
|
|
36
|
+
import { executablePaths, intendedDigest, keepsExecutableBit, readManifest } from './digest.js';
|
|
35
37
|
import { LibraryError, digestOf } from './library.js';
|
|
36
38
|
import { buildExport, readHeadOf, readSidecar } from './export.js';
|
|
37
39
|
import { scanArtifact, scanAllows, withExternalScans, scanEvidenceKey } from './scan.js';
|
|
@@ -100,8 +102,9 @@ export function normalizeTarget(t) {
|
|
|
100
102
|
* @param {string} o.name the folder's name in the root
|
|
101
103
|
* @param {{ files, dirs }} o.folder
|
|
102
104
|
* @param {string} o.digest what the folder must read back as
|
|
103
|
-
* @param {string|null} o.expectedCurrentDigest what must be at the destination now (null: nothing)
|
|
104
|
-
* @returns {{ destination: string, leftover: string|null, rootCreated: boolean }}
|
|
105
|
+
* @param {string|null} o.expectedCurrentDigest what must be at the destination now (null: nothing), as read
|
|
106
|
+
* @returns {{ destination: string, leftover: string|null, rootCreated: boolean, readDigest: string }} `readDigest`:
|
|
107
|
+
* what the folder reads as in place (the same as `digest`, except on a file system that keeps no executable bit)
|
|
105
108
|
*/
|
|
106
109
|
export function swapFolderIn({ root, anchor = null, name, folder, digest, expectedCurrentDigest, random = () => randomBytes(8).toString('hex') }) {
|
|
107
110
|
if (!isPlainName(name) || bundleNameProblem(name)) throw new DeployError(400, `"${name}" cannot be a skill folder's name.`, 'invalid_name');
|
|
@@ -138,8 +141,11 @@ export function swapFolderIn({ root, anchor = null, name, folder, digest, expect
|
|
|
138
141
|
writeConfinedFile(staged, join(staged, f.path), f.bytes, { exclusive: true, mode });
|
|
139
142
|
if (Number.isInteger(f.mode)) chmodSync(join(staged, f.path), mode);
|
|
140
143
|
}
|
|
144
|
+
// Every byte, size, path and folder as read; the executable bit from what was meant where files keep none
|
|
145
|
+
// (Windows reads 0o755 back as 0o666): digest.js intendedDigest.
|
|
146
|
+
const meant = executablePaths(folder.files);
|
|
141
147
|
const written = readManifest(staged);
|
|
142
|
-
if (written
|
|
148
|
+
if (intendedDigest(written, meant) !== digest) throw new DeployError(500, 'The staged files do not match what was meant to be written. Nothing was changed.', 'stage_mismatch');
|
|
143
149
|
const now = readManifest(destination);
|
|
144
150
|
const nowDigest = now.kind === 'absent' ? null : now.digest;
|
|
145
151
|
if (now.kind !== 'absent' && !now.digest) throw new DeployError(409, `"${destination}" could not be read whole: nothing was replaced.`, 'destination_unreadable');
|
|
@@ -153,7 +159,7 @@ export function swapFolderIn({ root, anchor = null, name, folder, digest, expect
|
|
|
153
159
|
throw new DeployError(500, `The new folder could not be put in place (${err?.code || err?.message}). What was there is back.`, 'swap_failed');
|
|
154
160
|
}
|
|
155
161
|
const check = readManifest(destination);
|
|
156
|
-
if (check
|
|
162
|
+
if (intendedDigest(check, meant) !== digest) {
|
|
157
163
|
try { rmSync(destination, { recursive: true, force: true }); } catch {}
|
|
158
164
|
if (moved) { try { renameSync(old, destination); } catch {} }
|
|
159
165
|
throw new DeployError(500, 'The installed folder does not read back as it was written. What was there is back.', 'verify_failed');
|
|
@@ -163,12 +169,60 @@ export function swapFolderIn({ root, anchor = null, name, folder, digest, expect
|
|
|
163
169
|
for (const [rel, mode] of dirModes) { try { chmodSync(rel === '.' ? destination : join(destination, rel), mode & 0o777); } catch { /* keeps the mode it was made with */ } }
|
|
164
170
|
let leftover = null;
|
|
165
171
|
if (moved) { try { rmSync(old, { recursive: true, force: true }); } catch { leftover = old; } }
|
|
166
|
-
return { destination, leftover, rootCreated };
|
|
172
|
+
return { destination, leftover, rootCreated, readDigest: check.digest };
|
|
167
173
|
} finally {
|
|
168
174
|
try { rmSync(stage, { recursive: true, force: true }); } catch {}
|
|
169
175
|
}
|
|
170
176
|
}
|
|
171
177
|
|
|
178
|
+
// ── What an installation says of each runtime's settings and of asking the runtime ──
|
|
179
|
+
// eligibilityByRuntime: one word per runtime ('enabled' | 'disabled' | 'unknown' | 'not-checked'); the reasons
|
|
180
|
+
// (the setting that turns it off, the file that could not be read, "not read") are in eligibilityReasons. A runtime
|
|
181
|
+
// SynaBun does not check ('not-checked': Antigravity's settings are not read) is left out of the aggregate
|
|
182
|
+
// `eligibility` and named in eligibilityNotChecked, so it never turns what was checked into 'unknown'.
|
|
183
|
+
export const ELIGIBILITY_STATES = Object.freeze(['enabled', 'disabled', 'unknown', 'not-checked']);
|
|
184
|
+
// Which runtimes have a listing to ask (runtime-checks.js probe): Codex and OpenCode, on the owner's or an
|
|
185
|
+
// assistant's explicit request only. Claude Code and Antigravity have none: they can never be probed.
|
|
186
|
+
export const PROBEABLE_RUNTIMES = Object.freeze(['codex', 'opencode']);
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* The aggregate of per-runtime eligibility over the runtimes that were checked: 'disabled' when one turns it off,
|
|
190
|
+
* 'enabled' when every checked one lets it through (and at least one was checked), else 'unknown'.
|
|
191
|
+
* @param {Record<string, string>} byRuntime
|
|
192
|
+
* @returns {{ eligibility: 'enabled'|'disabled'|'unknown', checked: string[], notChecked: string[] }}
|
|
193
|
+
*/
|
|
194
|
+
export function summarizeEligibility(byRuntime) {
|
|
195
|
+
const entries = Object.entries(byRuntime && typeof byRuntime === 'object' ? byRuntime : {});
|
|
196
|
+
const notChecked = entries.filter(([, v]) => v === 'not-checked').map(([r]) => r);
|
|
197
|
+
const checked = entries.filter(([, v]) => v !== 'not-checked');
|
|
198
|
+
const states = checked.map(([, v]) => v);
|
|
199
|
+
const eligibility = states.includes('disabled') ? 'disabled' : (states.length && states.every((v) => v === 'enabled') ? 'enabled' : 'unknown');
|
|
200
|
+
return { eligibility, checked: checked.map(([r]) => r), notChecked };
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Per runtime of an installation, whether the runtime itself was or can be asked: 'found' / 'not-found' (its
|
|
205
|
+
* answer), 'no-answer' (asked, no answer: the probe's code is kept in `code`), 'not-probed' (Codex, OpenCode: there
|
|
206
|
+
* is a listing, nobody asked yet), 'cannot-probe' (Claude Code, Antigravity: there is no listing to ask). Works on a
|
|
207
|
+
* record from before these fields: it reads only `destination.affectedRuntimes` and `state.discovered`.
|
|
208
|
+
*/
|
|
209
|
+
export function probeStates(installation) {
|
|
210
|
+
const runtimes = Array.isArray(installation?.destination?.affectedRuntimes) ? installation.destination.affectedRuntimes : [];
|
|
211
|
+
const discovered = installation?.state?.discovered && typeof installation.state.discovered === 'object' ? installation.state.discovered : {};
|
|
212
|
+
const out = {};
|
|
213
|
+
for (const runtime of runtimes) {
|
|
214
|
+
const d = discovered[runtime];
|
|
215
|
+
const answer = d && typeof d === 'object' ? d.discovered : (typeof d === 'boolean' ? d : undefined);
|
|
216
|
+
if (answer === true) out[runtime] = { state: 'found' };
|
|
217
|
+
else if (answer === false) out[runtime] = { state: 'not-found' };
|
|
218
|
+
else if (!PROBEABLE_RUNTIMES.includes(runtime) || d?.code === 'no-list') out[runtime] = { state: 'cannot-probe', code: 'no-list' };
|
|
219
|
+
else if (d?.code === 'terminal-only') out[runtime] = { state: 'cannot-probe', code: 'terminal-only' };
|
|
220
|
+
else if (d && typeof d === 'object') out[runtime] = { state: 'no-answer', code: d.code || 'no-answer' };
|
|
221
|
+
else out[runtime] = { state: 'not-probed' };
|
|
222
|
+
}
|
|
223
|
+
return out;
|
|
224
|
+
}
|
|
225
|
+
|
|
172
226
|
/**
|
|
173
227
|
* @param {object} o
|
|
174
228
|
* @param {object} o.library lib/skills/library.js
|
|
@@ -184,9 +238,48 @@ export function swapFolderIn({ root, anchor = null, name, folder, digest, expect
|
|
|
184
238
|
* @param {() => string[]} [o.shippedNames] the names of the skills SynaBun ships (what a scan checks names against)
|
|
185
239
|
* @param {(revisionId: string) => ({ installName: string|null }|null)} [o.approvalOf] the approval a revision has
|
|
186
240
|
* (lib/skills/reviews.js approvalOf): an agent's revision installs only under the name it was approved for
|
|
241
|
+
* @param {(installationId: string) => Promise<object>} [o.checkAfterInstall] the check run after each committed
|
|
242
|
+
* target (default: verify() without a runtime probe). A failure is recorded on the installation, never the install's.
|
|
187
243
|
*/
|
|
188
|
-
export function createDeployer({ library, roots, ownership, dataDir, config = () => ({}), catalogEntries = async () => [], probe = null, eligibility = () => 'unknown', eligibilityDetail = null, emit = () => {}, now = () => new Date().toISOString(), newId = (p) => `${p}_${randomBytes(10).toString('hex')}`, shippedNames = () => [], approvalOf = null }) {
|
|
244
|
+
export function createDeployer({ library, roots, ownership, dataDir, config = () => ({}), catalogEntries = async () => [], probe = null, eligibility = () => 'unknown', eligibilityDetail = null, emit = () => {}, now = () => new Date().toISOString(), newId = (p) => `${p}_${randomBytes(10).toString('hex')}`, shippedNames = () => [], approvalOf = null, checkAfterInstall = null }) {
|
|
189
245
|
let externalScanner = async () => [];
|
|
246
|
+
/** One runtime's settings, read statically: `{ state, reason }`, never a throw. */
|
|
247
|
+
function eligibilityOf(o) {
|
|
248
|
+
try {
|
|
249
|
+
const d = typeof eligibilityDetail === 'function' ? eligibilityDetail(o) : { state: eligibility(o) || 'unknown', reason: null };
|
|
250
|
+
return { state: ELIGIBILITY_STATES.includes(d?.state) ? d.state : 'unknown', reason: d?.reason || null };
|
|
251
|
+
} catch (err) { return { state: 'unknown', reason: { kind: 'error', message: String(err?.message || err).slice(0, 300) } }; }
|
|
252
|
+
}
|
|
253
|
+
/** The eligibility fields of an installation's state, from `{ runtime: { state, reason } }`. */
|
|
254
|
+
function eligibilityFields(detailByRuntime) {
|
|
255
|
+
const byRuntime = {};
|
|
256
|
+
const reasons = {};
|
|
257
|
+
for (const [runtime, d] of Object.entries(detailByRuntime && typeof detailByRuntime === 'object' ? detailByRuntime : {})) {
|
|
258
|
+
byRuntime[runtime] = ELIGIBILITY_STATES.includes(d?.state) ? d.state : 'unknown';
|
|
259
|
+
if (d?.reason) reasons[runtime] = d.reason;
|
|
260
|
+
}
|
|
261
|
+
const sum = summarizeEligibility(byRuntime);
|
|
262
|
+
return { eligibility: sum.eligibility, eligibilityByRuntime: byRuntime, eligibilityReasons: reasons, eligibilityNotChecked: sum.notChecked };
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* After a committed target: verify() without a probe (or the injected check). Never throws: a check that fails
|
|
266
|
+
* leaves the record as the install wrote it, with `state.staticCheck` saying it failed and why.
|
|
267
|
+
*/
|
|
268
|
+
async function checkInstalled(installationId) {
|
|
269
|
+
try {
|
|
270
|
+
if (typeof checkAfterInstall === 'function') await checkAfterInstall(installationId);
|
|
271
|
+
else await verify(installationId, { probeRuntime: false, trigger: 'install' });
|
|
272
|
+
} catch (err) {
|
|
273
|
+
try {
|
|
274
|
+
const store = readStore();
|
|
275
|
+
const rec = store.records.find((r) => r.installationId === installationId);
|
|
276
|
+
if (rec) {
|
|
277
|
+
rec.state = { ...rec.state, staticCheck: { state: 'error', trigger: 'install', error: String(err?.message || err).slice(0, 300), at: now() } };
|
|
278
|
+
writeStore(store);
|
|
279
|
+
}
|
|
280
|
+
} catch { /* the record stays as the install wrote it */ }
|
|
281
|
+
}
|
|
282
|
+
}
|
|
190
283
|
function setExternalScanner(scan) { externalScanner = scan; }
|
|
191
284
|
const storePath = join(dataDir, 'installations.json');
|
|
192
285
|
|
|
@@ -216,6 +309,32 @@ export function createDeployer({ library, roots, ownership, dataDir, config = ()
|
|
|
216
309
|
return readStore().records.find((r) => r.active && sameDest(r.destination.path, destination)) || null;
|
|
217
310
|
}
|
|
218
311
|
|
|
312
|
+
/**
|
|
313
|
+
* The files an installation meant executable: its record's list, or, for a record from before the list was kept,
|
|
314
|
+
* those of its revision's export when that export is still exactly what it installed (else none).
|
|
315
|
+
*/
|
|
316
|
+
function installedExecutables(inst) {
|
|
317
|
+
if (Array.isArray(inst?.export?.executables)) return inst.export.executables;
|
|
318
|
+
try {
|
|
319
|
+
const source = library.readRevisionFiles(inst.sourceRevisionId);
|
|
320
|
+
let exported = { files: source.files, dirs: source.dirs };
|
|
321
|
+
for (const runtime of inst.destination.affectedRuntimes || []) exported = buildExport(exported, TARGET_PROFILE[runtime]);
|
|
322
|
+
if (exported.digest === inst.export.artifactDigest) return [...executablePaths(exported.files)];
|
|
323
|
+
} catch { /* the revision is gone: nothing is taken for executable */ }
|
|
324
|
+
return [];
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* What an installation's folder reads as, to compare with `inst.export.artifactDigest`: the digest on disk, with
|
|
329
|
+
* each file's executable bit taken from the installation where files keep none (Windows). Bytes, sizes, paths,
|
|
330
|
+
* folders and links are compared exactly everywhere. Null when the folder is absent or not read whole.
|
|
331
|
+
*/
|
|
332
|
+
function installedDigest(inst, current = readManifest(inst.destination.path)) {
|
|
333
|
+
if (!current?.digest) return null;
|
|
334
|
+
if (keepsExecutableBit()) return current.digest;
|
|
335
|
+
return intendedDigest(current, installedExecutables(inst));
|
|
336
|
+
}
|
|
337
|
+
|
|
219
338
|
const installName = effectiveInstallName;
|
|
220
339
|
const shipped = () => { try { return shippedNames() || []; } catch { return []; } };
|
|
221
340
|
|
|
@@ -313,7 +432,12 @@ export function createDeployer({ library, roots, ownership, dataDir, config = ()
|
|
|
313
432
|
else if (approvalStale) blocked.push({ code: 'approval_stale', message: approvalStale });
|
|
314
433
|
const destination = join(root.path, name);
|
|
315
434
|
const inspected = ownership.inspect({ destination, payload: { kind: 'dir', digest: exported.digest } });
|
|
316
|
-
|
|
435
|
+
let state = inspected.state;
|
|
436
|
+
// Where files keep no executable bit (Windows), a folder that holds exactly these bytes, sizes and paths is
|
|
437
|
+
// these files: its scripts read back as not executable, which the file system cannot say otherwise.
|
|
438
|
+
if (!keepsExecutableBit() && inspected.current.kind === 'dir' && inspected.current.digest && ['owned', 'modified', 'unowned'].includes(state)
|
|
439
|
+
&& intendedDigest(inspected.current, exported.files) === exported.digest) state = 'identical';
|
|
440
|
+
// What is there, as read: the digest a confirmation names and the swap checks again.
|
|
317
441
|
const currentDigest = inspected.current.kind === 'absent' ? null : inspected.current.digest;
|
|
318
442
|
if (state === 'unreadable') blocked.push({ code: 'destination_unreadable', message: `"${destination}" cannot be read whole: move it away yourself first.` });
|
|
319
443
|
if (state === 'modified' || state === 'unowned') needs.push({ code: 'confirm_replace', currentDigest, message: `"${destination}" ${state === 'modified' ? 'was installed by SynaBun but has been changed since' : 'was not installed by SynaBun'}. Replace it? A backup is kept.` });
|
|
@@ -330,12 +454,7 @@ export function createDeployer({ library, roots, ownership, dataDir, config = ()
|
|
|
330
454
|
// page offers the one-click fix for a runtime that turns it off). Not part of the plan's digest: it changes
|
|
331
455
|
// nothing of what is written.
|
|
332
456
|
const eligible = {};
|
|
333
|
-
for (const r of runtimes) {
|
|
334
|
-
try {
|
|
335
|
-
const d = typeof eligibilityDetail === 'function' ? eligibilityDetail({ runtime: r, name, skillMd: join(destination, 'SKILL.md'), accountId: target.accountId, projectPath: target.projectPath }) : { state: eligibility({ runtime: r, name, skillMd: join(destination, 'SKILL.md'), accountId: target.accountId, projectPath: target.projectPath }) || 'unknown', reason: null };
|
|
336
|
-
eligible[r] = { state: ['enabled', 'disabled', 'unknown'].includes(d?.state) ? d.state : 'unknown', reason: d?.reason || null };
|
|
337
|
-
} catch { eligible[r] = { state: 'unknown', reason: null }; }
|
|
338
|
-
}
|
|
457
|
+
for (const r of runtimes) eligible[r] = eligibilityOf({ runtime: r, name, skillMd: join(destination, 'SKILL.md'), accountId: target.accountId, projectPath: target.projectPath });
|
|
339
458
|
out.push({
|
|
340
459
|
targetKey: target.key, ...target, name,
|
|
341
460
|
root: { rootId: root.rootId, path: root.path, status: root.status, scope: root.scope, sourceKind: root.sourceKind, policy: root.policy },
|
|
@@ -382,17 +501,20 @@ export function createDeployer({ library, roots, ownership, dataDir, config = ()
|
|
|
382
501
|
if (t.destinationState.state !== 'absent' && t.destinationState.state !== 'identical') {
|
|
383
502
|
backupId = ownership.backup({ destination: t.destination, target: t.runtime, name: t.name, reason: `install of ${revisionId} over ${t.destinationState.state}` });
|
|
384
503
|
}
|
|
385
|
-
let swap = { destination: t.destination, leftover: null, rootCreated: false };
|
|
504
|
+
let swap = { destination: t.destination, leftover: null, rootCreated: false, readDigest: t.destinationState.currentDigest };
|
|
386
505
|
if (t.destinationState.state !== 'identical') {
|
|
387
506
|
swap = swapFolderIn({ root: t.root.path, anchor: t.scope === 'project' ? t.projectPath : null, name: t.name, folder: exported, digest: t.export.artifactDigest, expectedCurrentDigest: t.destinationState.currentDigest });
|
|
388
507
|
}
|
|
389
508
|
// What the ledger said of this place before: a rollback puts that claim back (or none, when there was none).
|
|
390
509
|
const priorRecord = ownership.recordFor(t.destination);
|
|
391
|
-
|
|
510
|
+
// The ledger holds what the folder reads as (lib/skills/ownership.js compares it with a read of the folder):
|
|
511
|
+
// the export's digest, except where files keep no executable bit. The record keeps the export's digest and
|
|
512
|
+
// which of its files are executable.
|
|
513
|
+
ownership.recordWrite({ target: t.runtime, name: t.name, destination: t.destination, digest: swap.readDigest || t.export.artifactDigest, kind: 'dir', source: { kind: 'library', skillId: fresh.skillId, revisionId, digest: fresh.contentDigest } });
|
|
392
514
|
const installationId = newId('ins');
|
|
393
515
|
const record = {
|
|
394
516
|
schemaVersion: INSTALLATIONS_SCHEMA, installationId, skillId: fresh.skillId, sourceRevisionId: revisionId, sourceDigest: fresh.contentDigest,
|
|
395
|
-
export: { profileId: t.export.profileId, profileVersion: t.export.profileVersion, artifactDigest: t.export.artifactDigest, manifestDigest: t.export.artifactDigest, transforms: t.export.transforms },
|
|
517
|
+
export: { profileId: t.export.profileId, profileVersion: t.export.profileVersion, artifactDigest: t.export.artifactDigest, manifestDigest: t.export.artifactDigest, transforms: t.export.transforms, executables: [...executablePaths(exported.files)].sort() },
|
|
396
518
|
target: { runtime: t.runtime, scope: t.scope, accountId: t.accountId, projectPath: t.projectPath },
|
|
397
519
|
destination: { rootId: t.root.rootId, root: t.root.path, path: t.destination, relativePath: t.name, method: 'copy', affectedRuntimes: t.affectedRuntimes },
|
|
398
520
|
ownership: {
|
|
@@ -407,13 +529,17 @@ export function createDeployer({ library, roots, ownership, dataDir, config = ()
|
|
|
407
529
|
scanAcknowledgement: (decision.acknowledgedDigest === t.scan.digest || t.scan.trustedBundled) ? { digest: t.scan.digest, evidenceKey: t.scan.evidenceKey, engineVersion: t.scan.engineVersion, policy: t.scan.policy, at: now() } : null,
|
|
408
530
|
authorization: { principal: principal?.kind || 'owner', planDigest },
|
|
409
531
|
transaction: { state: 'committed', at: now(), leftover: swap.leftover },
|
|
410
|
-
|
|
532
|
+
// The plan's reading of each runtime's settings is kept as it is (the check below reads them again).
|
|
533
|
+
state: { written: true, verifiedDigest: t.export.artifactDigest, discoverable: null, ...eligibilityFields(t.eligibility), discovered: null, loadedRevisionId: null, refresh: t.refresh, tested: false, checkedAt: now() },
|
|
411
534
|
active: true, createdAt: now(),
|
|
412
535
|
};
|
|
413
536
|
const store = readStore();
|
|
414
537
|
for (const r of store.records) if (r.active && sameDest(r.destination.path, t.destination)) { r.active = false; r.supersededBy = installationId; }
|
|
415
538
|
store.records.push(record);
|
|
416
539
|
writeStore(store);
|
|
540
|
+
// The static part of verify (the bytes, the folder rules, the settings; never a runtime probe), so a fresh
|
|
541
|
+
// record already says whether it is discoverable and eligible. The install is committed whatever it says.
|
|
542
|
+
await checkInstalled(installationId);
|
|
417
543
|
results.push({ targetKey: t.targetKey, status: 'committed', installationId, backupId, destination: t.destination, refresh: t.refresh, unchanged: t.destinationState.state === 'identical', leftover: swap.leftover });
|
|
418
544
|
emit({ type: 'installation.changed', skillId: fresh.skillId, installationId, rootIds: [t.root.rootId], action: 'install' });
|
|
419
545
|
} catch (err) {
|
|
@@ -436,7 +562,7 @@ export function createDeployer({ library, roots, ownership, dataDir, config = ()
|
|
|
436
562
|
const current = readManifest(destination);
|
|
437
563
|
const currentDigest = current.kind === 'absent' ? null : current.digest;
|
|
438
564
|
if (current.kind !== 'absent' && !current.digest) throw new DeployError(409, `"${destination}" cannot be read whole: nothing was changed.`, 'destination_unreadable');
|
|
439
|
-
if (
|
|
565
|
+
if (installedDigest(inst, current) !== inst.export.artifactDigest && expectedDestinationDigest !== currentDigest) {
|
|
440
566
|
throw new DeployError(409, `"${destination}" was changed since it was installed. To roll back anyway, confirm it as it is now: a backup is kept.`, 'rollback_conflict', { currentDigest });
|
|
441
567
|
}
|
|
442
568
|
let restoredTo = 'absent';
|
|
@@ -465,7 +591,8 @@ export function createDeployer({ library, roots, ownership, dataDir, config = ()
|
|
|
465
591
|
const prior = inst.previousInstallationId ? store.records.find((r) => r.installationId === inst.previousInstallationId) : null;
|
|
466
592
|
const back = readManifest(destination);
|
|
467
593
|
const priorRecord = inst.ownership?.priorRecord || null;
|
|
468
|
-
|
|
594
|
+
const reactivate = !!prior && !!back.digest && installedDigest(prior, back) === prior.export.artifactDigest;
|
|
595
|
+
if (reactivate) {
|
|
469
596
|
prior.active = true;
|
|
470
597
|
prior.supersededBy = null;
|
|
471
598
|
ownership.recordWrite({ target: prior.target.runtime, name: prior.destination.relativePath, destination, digest: back.digest, kind: 'dir', source: { kind: 'library', skillId: prior.skillId, revisionId: prior.sourceRevisionId, digest: prior.sourceDigest } });
|
|
@@ -477,7 +604,7 @@ export function createDeployer({ library, roots, ownership, dataDir, config = ()
|
|
|
477
604
|
}
|
|
478
605
|
writeStore(store);
|
|
479
606
|
emit({ type: 'installation.changed', skillId: inst.skillId, installationId, rootIds: [inst.destination.rootId], action: 'rollback' });
|
|
480
|
-
return { ok: true, installationId, restoredTo, safetyBackupId: safety, reactivated:
|
|
607
|
+
return { ok: true, installationId, restoredTo, safetyBackupId: safety, reactivated: reactivate ? prior.installationId : null };
|
|
481
608
|
}
|
|
482
609
|
|
|
483
610
|
/** Remove an installation's folder: SynaBun's own bytes, or what the owner confirmed as it is now. A backup is kept. */
|
|
@@ -490,7 +617,7 @@ export function createDeployer({ library, roots, ownership, dataDir, config = ()
|
|
|
490
617
|
let backupId = null;
|
|
491
618
|
if (current.kind !== 'absent') {
|
|
492
619
|
if (!current.digest) throw new DeployError(409, `"${destination}" cannot be read whole: nothing was removed.`, 'destination_unreadable');
|
|
493
|
-
if (
|
|
620
|
+
if (installedDigest(inst, current) !== inst.export.artifactDigest && expectedDestinationDigest !== currentDigest) {
|
|
494
621
|
throw new DeployError(409, `"${destination}" was changed since it was installed. To remove it anyway, confirm it as it is now: a backup is kept.`, 'uninstall_conflict', { currentDigest });
|
|
495
622
|
}
|
|
496
623
|
backupId = ownership.backup({ destination, target: inst.target.runtime, name: inst.destination.relativePath, reason: `uninstall of ${installationId}` });
|
|
@@ -511,13 +638,15 @@ export function createDeployer({ library, roots, ownership, dataDir, config = ()
|
|
|
511
638
|
|
|
512
639
|
/**
|
|
513
640
|
* Check an installation: the bytes (by digest), what the runtime's rules say of the folder, its settings
|
|
514
|
-
* (eligibility), and — only when asked and a probe exists — whether the runtime itself lists it now
|
|
641
|
+
* (eligibility, per runtime), and — only when asked and a probe exists — whether the runtime itself lists it now
|
|
642
|
+
* (Codex and OpenCode only: Claude Code and Antigravity have no listing). Without `probeRuntime` nothing is
|
|
643
|
+
* started: this static part runs by itself after every committed install (`trigger: 'install'`).
|
|
515
644
|
*/
|
|
516
|
-
async function verify(installationId, { probeRuntime = false } = {}) {
|
|
645
|
+
async function verify(installationId, { probeRuntime = false, trigger = 'verify' } = {}) {
|
|
517
646
|
const inst = getInstallation(installationId);
|
|
518
647
|
const destination = inst.destination.path;
|
|
519
648
|
const current = readManifest(destination);
|
|
520
|
-
const written = current.kind === 'absent' ? 'missing' : (current
|
|
649
|
+
const written = current.kind === 'absent' ? 'missing' : (installedDigest(inst, current) === inst.export.artifactDigest ? 'verified' : 'changed');
|
|
521
650
|
const checks = [];
|
|
522
651
|
let discoverable = written === 'verified';
|
|
523
652
|
let live = null;
|
|
@@ -541,13 +670,16 @@ export function createDeployer({ library, roots, ownership, dataDir, config = ()
|
|
|
541
670
|
}
|
|
542
671
|
} catch (err) { discoverable = false; checks.push({ ok: false, message: `SKILL.md cannot be read (${err?.message || err}).` }); }
|
|
543
672
|
}
|
|
544
|
-
const
|
|
673
|
+
const eligible = {};
|
|
545
674
|
for (const runtime of inst.destination.affectedRuntimes) {
|
|
546
|
-
|
|
675
|
+
eligible[runtime] = eligibilityOf({ runtime, name: inst.destination.relativePath, path: destination, skillMd: join(destination, 'SKILL.md'), accountId: inst.target.accountId, projectPath: inst.target.projectPath });
|
|
547
676
|
}
|
|
548
677
|
const discovered = {};
|
|
549
|
-
|
|
678
|
+
const probed = probeRuntime === true && typeof probe === 'function' && written === 'verified';
|
|
679
|
+
if (probed) {
|
|
550
680
|
for (const runtime of inst.destination.affectedRuntimes) {
|
|
681
|
+
// Claude Code and Antigravity have no listing: nothing is started or asked for them.
|
|
682
|
+
if (!PROBEABLE_RUNTIMES.includes(runtime)) { discovered[runtime] = { discovered: null, code: 'no-list', method: 'none', reason: `${RUNTIME_LABEL[runtime] || runtime} has no list to ask; its folder rules were checked instead.` }; continue; }
|
|
551
683
|
// A Claude Code folder reaches a terminal OpenCode only: SynaBun's own serve (OPENCODE_DISABLE_CLAUDE_CODE=1)
|
|
552
684
|
// would answer "not listed" for a folder it never reads, so it is not asked (REFRESH `terminal-only`).
|
|
553
685
|
if (runtime === 'opencode' && live?.family === 'claude') { discovered[runtime] = { discovered: null, code: 'terminal-only', method: 'none', reason: 'SynaBun\'s OpenCode never reads Claude Code\'s folder; an OpenCode in a terminal does.' }; continue; }
|
|
@@ -556,14 +688,17 @@ export function createDeployer({ library, roots, ownership, dataDir, config = ()
|
|
|
556
688
|
}
|
|
557
689
|
const store = readStore();
|
|
558
690
|
const rec = store.records.find((r) => r.installationId === installationId);
|
|
691
|
+
const at = now();
|
|
559
692
|
rec.state = {
|
|
560
|
-
...rec.state, written: written === 'verified', writtenCheck: written, verifiedDigest: current.digest || null, discoverable, checks,
|
|
561
|
-
|
|
562
|
-
|
|
693
|
+
...rec.state, written: written === 'verified', writtenCheck: written, verifiedDigest: written === 'verified' ? inst.export.artifactDigest : (current.digest || null), discoverable, checks,
|
|
694
|
+
...eligibilityFields(eligible),
|
|
695
|
+
discovered: Object.keys(discovered).length ? discovered : (rec.state?.discovered ?? null), loadedRevisionId: null, checkedAt: at,
|
|
696
|
+
staticCheck: { state: 'ok', trigger, at },
|
|
697
|
+
...(probed ? { probedAt: at } : {}),
|
|
563
698
|
};
|
|
564
699
|
writeStore(store);
|
|
565
700
|
return rec;
|
|
566
701
|
}
|
|
567
702
|
|
|
568
|
-
return { setExternalScanner, plan, install, rollback, uninstall, verify, listInstallations, getInstallation, activeAt, paths: { storePath } };
|
|
703
|
+
return { setExternalScanner, plan, install, rollback, uninstall, verify, listInstallations, getInstallation, activeAt, installedDigest, paths: { storePath } };
|
|
569
704
|
}
|
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
//
|
|
9
9
|
// Reading a folder never follows a link (a link is an entry, with its target as text), never opens a FIFO or a
|
|
10
10
|
// device (listed as `other`, never read), and is bounded in entries, depth and bytes.
|
|
11
|
+
//
|
|
12
|
+
// Windows keeps no POSIX executable bit: `fs.statSync(file).mode` is 0o100666 even right after
|
|
13
|
+
// `chmodSync(file, 0o755)`. There a folder read from disk says every file is not executable, and a comparison with
|
|
14
|
+
// a digest that names a file executable (a revision's, an export's) goes through `intendedDigest`: the bytes, sizes,
|
|
15
|
+
// paths, folders and links as read, the executable bit taken from what was meant to be written. Elsewhere it is the
|
|
16
|
+
// digest as read, and a lost executable bit is a difference like any other.
|
|
11
17
|
|
|
12
18
|
import { createHash } from 'node:crypto';
|
|
13
19
|
import { lstatSync, readdirSync, readlinkSync } from 'node:fs';
|
|
@@ -29,6 +35,48 @@ export const TREE_LIMITS = Object.freeze({ maxEntries: 5000, maxDepth: 24, maxBy
|
|
|
29
35
|
|
|
30
36
|
const byPath = (a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
|
31
37
|
|
|
38
|
+
// ── The executable bit, where the file system keeps one ──
|
|
39
|
+
|
|
40
|
+
let platformOverride = null;
|
|
41
|
+
/** Tests only: read folders as on `platform` ('win32' keeps no executable bit); null puts the real one back. */
|
|
42
|
+
export function setDigestPlatform(platform) { platformOverride = typeof platform === 'string' && platform ? platform : null; }
|
|
43
|
+
/** The platform folders are read as (the real one unless a test set another). */
|
|
44
|
+
export const digestPlatform = () => platformOverride || process.platform;
|
|
45
|
+
/** Whether files on this platform keep the executable bit SynaBun writes (Windows keeps none). */
|
|
46
|
+
export function keepsExecutableBit(platform = digestPlatform()) { return platform !== 'win32'; }
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The paths a list names as executable files: manifest entries or files (`{ path, type?, executable }`, the
|
|
50
|
+
* `executable` flag only: the one a digest is made of), or the paths themselves.
|
|
51
|
+
*/
|
|
52
|
+
export function executablePaths(from) {
|
|
53
|
+
const out = new Set();
|
|
54
|
+
for (const e of from instanceof Set ? [...from] : Array.isArray(from) ? from : []) {
|
|
55
|
+
if (typeof e === 'string') out.add(e);
|
|
56
|
+
else if (e && typeof e.path === 'string' && (e.type === undefined || e.type === 'file') && e.executable === true) out.add(e.path);
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** A manifest's entries with each file's executable bit taken from `from` (executablePaths), everything else as it is. */
|
|
62
|
+
export function withExecutables(entries, from) {
|
|
63
|
+
const executable = executablePaths(from);
|
|
64
|
+
return (entries || []).map((e) => (e.type === 'file' ? { ...e, executable: executable.has(e.path) } : e));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* What a manifest read from disk (readManifest) is compared with a digest by. Where files keep the executable bit
|
|
69
|
+
* it is the manifest's own digest. Where they keep none (Windows) it is the digest of the same entries (paths,
|
|
70
|
+
* sizes, bytes, folders, links) with each file's executable bit taken from `meant`: what was meant to be written
|
|
71
|
+
* (the folder's files, an export's, an installation's list of executable paths). Null when the manifest has no
|
|
72
|
+
* digest (absent, or not read whole).
|
|
73
|
+
*/
|
|
74
|
+
export function intendedDigest(manifest, meant, { platform = digestPlatform() } = {}) {
|
|
75
|
+
if (!manifest?.digest) return null;
|
|
76
|
+
if (keepsExecutableBit(platform)) return manifest.digest;
|
|
77
|
+
return manifestDigest(withExecutables(manifest.entries, meant));
|
|
78
|
+
}
|
|
79
|
+
|
|
32
80
|
/**
|
|
33
81
|
* The digest of a list of entries: `{ path, type: 'file'|'dir'|'link'|'other', size?, executable?, sha256?, target? }`.
|
|
34
82
|
* Order does not matter; the entries are sorted by path first.
|
|
@@ -51,11 +99,17 @@ export function fileEntry(path, bytes, { executable = false } = {}) {
|
|
|
51
99
|
|
|
52
100
|
/**
|
|
53
101
|
* Read what is at `path` as a manifest, without following any link.
|
|
102
|
+
* @param {string} path
|
|
103
|
+
* @param {object} [limits] TREE_LIMITS
|
|
104
|
+
* @param {{ platform?: string }} [o] where files keep no executable bit (Windows) every file reads as not
|
|
105
|
+
* executable: compare such a manifest with a digest through intendedDigest
|
|
54
106
|
* @returns {{ kind: 'absent'|'file'|'dir'|'link'|'other', entries: object[], digest: string|null, complete: boolean,
|
|
55
107
|
* reason?: string }} `digest` is null when the folder could not be read whole (too large, changed while read):
|
|
56
108
|
* such a destination is never taken for SynaBun's own.
|
|
57
109
|
*/
|
|
58
|
-
export function readManifest(path, limits = TREE_LIMITS) {
|
|
110
|
+
export function readManifest(path, limits = TREE_LIMITS, { platform = digestPlatform() } = {}) {
|
|
111
|
+
const keepsBit = keepsExecutableBit(platform);
|
|
112
|
+
const executableOf = (st) => keepsBit && (st.mode & 0o111) !== 0;
|
|
59
113
|
let st;
|
|
60
114
|
try { st = lstatSync(path); } catch { return { kind: 'absent', entries: [], digest: null, complete: true }; }
|
|
61
115
|
if (st.isSymbolicLink()) {
|
|
@@ -69,7 +123,7 @@ export function readManifest(path, limits = TREE_LIMITS) {
|
|
|
69
123
|
try {
|
|
70
124
|
real = realPathOf(path);
|
|
71
125
|
const bytes = readConfinedFile(dirname(real), real, { maxBytes: limits.maxFileBytes });
|
|
72
|
-
const entries = [fileEntry('.', bytes, { executable: (st
|
|
126
|
+
const entries = [fileEntry('.', bytes, { executable: executableOf(st) })];
|
|
73
127
|
return { kind: 'file', entries, digest: manifestDigest(entries), complete: true };
|
|
74
128
|
} catch (err) {
|
|
75
129
|
return { kind: 'file', entries: [], digest: null, complete: false, reason: String(err?.message || err) };
|
|
@@ -105,7 +159,7 @@ export function readManifest(path, limits = TREE_LIMITS) {
|
|
|
105
159
|
let bytes;
|
|
106
160
|
try { bytes = readConfinedFile(base, full, { maxBytes: limits.maxFileBytes }); } catch (err) { state.complete = false; state.reason = String(err?.message || err); return; }
|
|
107
161
|
state.bytes += bytes.length;
|
|
108
|
-
entries.push(fileEntry(relPath, bytes, { executable: (est
|
|
162
|
+
entries.push(fileEntry(relPath, bytes, { executable: executableOf(est) }));
|
|
109
163
|
} else {
|
|
110
164
|
entries.push({ path: relPath, type: 'other' });
|
|
111
165
|
}
|
|
@@ -5,6 +5,47 @@ import { scanEvidenceKey, scanAllows, SCAN_ENGINE_VERSION, SCAN_POLICY } from '.
|
|
|
5
5
|
import { buildExport } from './export.js';
|
|
6
6
|
import { TARGET_PROFILE } from '../../public/shared/skills/ss-profiles.js';
|
|
7
7
|
import { folderDigest } from './library.js';
|
|
8
|
+
import { PROBEABLE_RUNTIMES, probeStates } from './deploy.js';
|
|
9
|
+
|
|
10
|
+
// Runtimes whose settings SynaBun deliberately does not read ('not-checked' is their normal answer, never a gap).
|
|
11
|
+
const SETTINGS_NOT_READ = Object.freeze(['antigravity']);
|
|
12
|
+
// Per-runtime verification words that leave a runtime unconfirmed (status `unverified_runtime`).
|
|
13
|
+
const UNVERIFIED = Object.freeze(['unprobed', 'settings-unknown']);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* How far SynaBun verified each runtime of an installation, from the state verify() wrote:
|
|
17
|
+
* 'listed' (a probe of this check found it), 'static-only' (Claude Code, Antigravity, and OpenCode reading Claude
|
|
18
|
+
* Code's folder: there is no listing SynaBun can ask, and the files, the folder rules and the settings passed),
|
|
19
|
+
* 'unprobed' (Codex, OpenCode: a listing exists and this check did not get a "found" from it),
|
|
20
|
+
* 'settings-unknown' (the runtime's settings could not be read), and the problems 'disabled', 'not-listed',
|
|
21
|
+
* 'static-failed'. Returns null for a record from before the static check (no `staticCheck` or no
|
|
22
|
+
* `eligibilityByRuntime`): the caller keeps the earlier rule for those.
|
|
23
|
+
*/
|
|
24
|
+
export function runtimeVerification(inst, state, { probed = false } = {}) {
|
|
25
|
+
if (!state?.staticCheck || !state?.eligibilityByRuntime || typeof state.eligibilityByRuntime !== 'object') return null;
|
|
26
|
+
const runtimes = Array.isArray(inst?.destination?.affectedRuntimes) ? inst.destination.affectedRuntimes : [];
|
|
27
|
+
const probes = probeStates({ destination: inst?.destination, state });
|
|
28
|
+
const staticOk = state.staticCheck.state === 'ok' && state.written === true && state.discoverable === true;
|
|
29
|
+
const out = {};
|
|
30
|
+
for (const runtime of runtimes) {
|
|
31
|
+
let probe = probes[runtime] || { state: 'not-probed' };
|
|
32
|
+
// SynaBun's own OpenCode never reads Claude Code's folder (deploy.js verify: `terminal-only`), so it cannot ask.
|
|
33
|
+
if (runtime === 'opencode' && inst?.target?.runtime === 'claude' && probe.state === 'not-probed') probe = { state: 'cannot-probe', code: 'terminal-only' };
|
|
34
|
+
const eligibility = state.eligibilityByRuntime[runtime] || 'unknown';
|
|
35
|
+
const settingsOk = eligibility === 'enabled' || (eligibility === 'not-checked' && SETTINGS_NOT_READ.includes(runtime));
|
|
36
|
+
const cannotProbe = !PROBEABLE_RUNTIMES.includes(runtime) || probe.state === 'cannot-probe';
|
|
37
|
+
let verification;
|
|
38
|
+
if (eligibility === 'disabled') verification = 'disabled';
|
|
39
|
+
else if (probed && probe.state === 'not-found') verification = 'not-listed';
|
|
40
|
+
else if (!staticOk) verification = 'static-failed';
|
|
41
|
+
else if (!settingsOk) verification = 'settings-unknown';
|
|
42
|
+
else if (cannotProbe) verification = 'static-only';
|
|
43
|
+
else if (probed && probe.state === 'found') verification = 'listed';
|
|
44
|
+
else verification = 'unprobed';
|
|
45
|
+
out[runtime] = { verification, probe: probe.state, ...(probe.code ? { probeCode: probe.code } : {}), eligibility };
|
|
46
|
+
}
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
8
49
|
|
|
9
50
|
export function createSkillHealth({ dataDir, service, settings, notify = () => false, now = Date.now }) {
|
|
10
51
|
const store = localRecord(dataDir, 'health', { checkedAt: null, rows: [], notifications: [] });
|
|
@@ -34,13 +75,26 @@ export function createSkillHealth({ dataDir, service, settings, notify = () => f
|
|
|
34
75
|
if (!state.discoverable) issues.push('not_discoverable');
|
|
35
76
|
if (state.eligibility === 'disabled') issues.push('disabled');
|
|
36
77
|
if (probe && Object.values(state.discovered || {}).some((v) => v?.discovered === false)) issues.push('not_listed');
|
|
78
|
+
if (state.staticCheck && state.staticCheck.state !== 'ok') issues.push('static_check_failed');
|
|
37
79
|
const acknowledged = inst.scanAcknowledgement?.evidenceKey === scanEvidenceKey(scan) ? inst.scanAcknowledgement.digest : null;
|
|
38
80
|
if (!scanAllows(scan, { digest: scan.digest, acknowledgedDigest: acknowledged }).ok) issues.push(`scan_${scan.gate === 'allowed' ? 'blocked' : scan.gate}`);
|
|
81
|
+
const byRuntime = runtimeVerification(inst, state, { probed: probe });
|
|
82
|
+
const unverifiedRuntimes = byRuntime ? Object.keys(byRuntime).filter((r) => UNVERIFIED.includes(byRuntime[r].verification)) : null;
|
|
83
|
+
const words = byRuntime ? Object.values(byRuntime).map((v) => v.verification) : [];
|
|
84
|
+
let status;
|
|
85
|
+
if (issues.length) status = 'attention';
|
|
86
|
+
// A record from before the static check: the earlier rule, unchanged.
|
|
87
|
+
else if (!byRuntime) status = state.eligibility === 'unknown' || !probe || !inst.destination.affectedRuntimes.every((r) => state.discovered?.[r]?.discovered === true) ? 'unverified_runtime' : 'checked';
|
|
88
|
+
else if (unverifiedRuntimes.length || !words.length) status = 'unverified_runtime';
|
|
89
|
+
else if (words.every((w) => w === 'static-only')) status = 'static_only';
|
|
90
|
+
else if (words.every((w) => w === 'listed' || w === 'static-only')) status = 'checked';
|
|
91
|
+
// A per-runtime problem the installation-level issues did not name: never healthy.
|
|
92
|
+
else status = 'attention';
|
|
39
93
|
const old = previous.rows.find((r) => r.installationId === inst.installationId);
|
|
40
94
|
const rulesChanged = !!old && (old.scan?.engineVersion !== scan.engineVersion || old.scan?.policy !== scan.policy);
|
|
41
95
|
rows.push({ installationId: inst.installationId, skillId: inst.skillId, revisionId: inst.sourceRevisionId,
|
|
42
96
|
name: skill.name, runtime: inst.target.runtime, checkedAt: now(), state, scan, rulesChanged, issues,
|
|
43
|
-
status
|
|
97
|
+
status, runtimes: byRuntime, unverifiedRuntimes,
|
|
44
98
|
discoveryFresh: probe,
|
|
45
99
|
// A runtime listing is still not execution or proof of quality.
|
|
46
100
|
executed: null });
|
|
@@ -316,6 +316,18 @@
|
|
|
316
316
|
"firstCommit": "52d9d1712c34",
|
|
317
317
|
"firstDate": "2026-10-31"
|
|
318
318
|
},
|
|
319
|
+
{
|
|
320
|
+
"digest": "e10efa4c45bd185005d9fc613dd4f2da8b82db5567e99051e3e399284862e291",
|
|
321
|
+
"sep": "any",
|
|
322
|
+
"generators": [
|
|
323
|
+
"g3"
|
|
324
|
+
],
|
|
325
|
+
"skillMd": [
|
|
326
|
+
"04520041e281"
|
|
327
|
+
],
|
|
328
|
+
"firstCommit": "worktree",
|
|
329
|
+
"firstDate": null
|
|
330
|
+
},
|
|
319
331
|
{
|
|
320
332
|
"digest": "4b619a432fc38e95310399f2d59a0f1501a3984b67007febd8ff92634afffa8f",
|
|
321
333
|
"sep": "any",
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
// "off", a deny rule on Skill(name)), OpenCode's opencode.json and opencode.jsonc (the last rule of
|
|
7
7
|
// action `skill` whose resource matches the name: OpenCode 2's `permissions`, an OpenCode 1
|
|
8
8
|
// `permission.skill` read as OpenCode reads it). 'enabled', 'disabled', or 'unknown' when the
|
|
9
|
-
// settings cannot be read
|
|
9
|
+
// settings cannot be read. Antigravity's settings are not read at all: 'not-checked', with the
|
|
10
|
+
// reason `{ kind: 'not-read' }`, a state of its own so it never stands for "could not be read"
|
|
11
|
+
// (deploy.js leaves a runtime that was not checked out of an installation's aggregate).
|
|
10
12
|
// probe asked of the runtime itself, only when the owner asks (Verify in the Studio): Codex lists its
|
|
11
13
|
// skills through `codex app-server` (skills/list, forceReload); OpenCode through SynaBun's own
|
|
12
14
|
// running serve. Claude Code and Antigravity have no listing to ask: they say null with the reason.
|
|
@@ -160,12 +162,13 @@ export function createSkillsRuntimeChecks({ codexHome, claudeHome, opencodeConfi
|
|
|
160
162
|
if (decided?.effect !== 'deny') return { state: 'enabled', reason: null };
|
|
161
163
|
return { state: 'disabled', reason: { kind: 'opencode-permission', file: decided.file, pattern: decided.resource, action: 'deny' } };
|
|
162
164
|
}
|
|
163
|
-
// Antigravity: SynaBun reads none of its settings, so nothing is said of them
|
|
164
|
-
|
|
165
|
+
// Antigravity: SynaBun reads none of its settings, so nothing is said of them: not checked (never 'unknown',
|
|
166
|
+
// which means "there, but could not be read").
|
|
167
|
+
if (runtime === 'antigravity') return { state: 'not-checked', reason: { kind: 'not-read', runtime: 'antigravity' } };
|
|
165
168
|
return { state: 'unknown', reason: { kind: 'unknown-runtime' } };
|
|
166
169
|
}
|
|
167
170
|
|
|
168
|
-
/** 'enabled' | 'disabled' | 'unknown' (eligibilityDetail's state). */
|
|
171
|
+
/** 'enabled' | 'disabled' | 'unknown' | 'not-checked' (eligibilityDetail's state). */
|
|
169
172
|
function eligibility(o) { return eligibilityDetail(o).state; }
|
|
170
173
|
|
|
171
174
|
/**
|