aegisone 1.0.32 → 1.0.34
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/README.md +1 -1
- package/bin/aegis.js +322 -1
- package/package.json +5 -4
- package/scripts/bump.mjs +211 -1
- package/scripts/bundle.js +129 -1
- package/scripts/predist.mjs +976 -1
- package/src/child.js +285 -1
- package/src/dispatch.js +269 -1
- package/src/doctor.js +639 -1
- package/src/host.js +111 -1
- package/src/permissions.js +383 -1
- package/src/probes.js +159 -1
- package/src/release.js +409 -1
- package/vendor/cli/package.json +7 -3
- package/vendor/cli/scripts/check.mjs +52 -1
- package/vendor/cli/scripts/demo.mjs +94 -1
- package/vendor/cli/scripts/predist.mjs +75 -1
- package/vendor/cli/scripts/runtests.mjs +56 -1
- package/vendor/cli/scripts/seal-gate.mjs +74 -1
- package/vendor/cli/src/agents.js +139 -1
- package/vendor/cli/src/app.js +2957 -1
- package/vendor/cli/src/art.js +289 -1
- package/vendor/cli/src/chatflow.js +3023 -1
- package/vendor/cli/src/checkpoint.js +90 -1
- package/vendor/cli/src/clipboard.js +424 -1
- package/vendor/cli/src/cloudsync.js +528 -1
- package/vendor/cli/src/commands.js +4089 -1
- package/vendor/cli/src/config.js +581 -1
- package/vendor/cli/src/connect.js +349 -1
- package/vendor/cli/src/credentials.js +33 -1
- package/vendor/cli/src/deps.js +232 -1
- package/vendor/cli/src/devrun.js +187 -1
- package/vendor/cli/src/diff.js +333 -1
- package/vendor/cli/src/diffview.js +296 -1
- package/vendor/cli/src/engine.js +297 -1
- package/vendor/cli/src/entitlement.js +355 -1
- package/vendor/cli/src/events.js +707 -1
- package/vendor/cli/src/export.js +67 -1
- package/vendor/cli/src/filepreview.js +153 -1
- package/vendor/cli/src/fingerprint.js +592 -1
- package/vendor/cli/src/format.js +259 -1
- package/vendor/cli/src/fuzzy.js +119 -1
- package/vendor/cli/src/history.js +423 -1
- package/vendor/cli/src/init.js +175 -1
- package/vendor/cli/src/input.js +139 -1
- package/vendor/cli/src/keys.js +183 -1
- package/vendor/cli/src/markdown.js +306 -1
- package/vendor/cli/src/models.js +507 -1
- package/vendor/cli/src/naming.js +57 -1
- package/vendor/cli/src/overlays.js +462 -1
- package/vendor/cli/src/panels.js +1418 -1
- package/vendor/cli/src/ping.js +226 -1
- package/vendor/cli/src/presence.js +238 -1
- package/vendor/cli/src/render.js +516 -1
- package/vendor/cli/src/screen.js +518 -1
- package/vendor/cli/src/screens.js +896 -1
- package/vendor/cli/src/secret.js +59 -1
- package/vendor/cli/src/securefs.js +359 -1
- package/vendor/cli/src/settings.js +155 -1
- package/vendor/cli/src/shared.js +52 -1
- package/vendor/cli/src/sharedpaths.js +53 -1
- package/vendor/cli/src/signup.js +156 -1
- package/vendor/cli/src/summarize.js +95 -1
- package/vendor/cli/src/sysdiag.js +585 -1
- package/vendor/cli/src/system.js +40 -1
- package/vendor/cli/src/theme.js +570 -1
- package/vendor/cli/src/title.js +220 -1
- package/vendor/cli/src/todos.js +115 -1
- package/vendor/cli/src/tokens.js +263 -1
- package/vendor/cli/src/topup.js +210 -1
- package/vendor/cli/src/update.js +191 -1
- package/vendor/cli/vendor/client/aegis.js +2441 -1
- package/vendor/cli/vendor/client/attest.js +518 -1
- package/vendor/cli/vendor/client/authorship-key.js +410 -1
- package/vendor/cli/vendor/client/auto-provision.js +134 -1
- package/vendor/cli/vendor/client/brain-catalog.js +268 -1
- package/vendor/cli/vendor/client/byok-catalog.js +199 -1
- package/vendor/cli/vendor/client/catalog-client.js +487 -1
- package/vendor/cli/vendor/client/conversation-export.js +177 -1
- package/vendor/cli/vendor/client/credentials.js +494 -1
- package/vendor/cli/vendor/client/device-fingerprint.js +141 -1
- package/vendor/cli/vendor/client/drive-connect.js +110 -1
- package/vendor/cli/vendor/client/drive-upload.js +234 -1
- package/vendor/cli/vendor/client/env-file.js +1273 -1
- package/vendor/cli/vendor/client/fingerprint.js +1064 -1
- package/vendor/cli/vendor/client/foreign-memory.js +669 -1
- package/vendor/cli/vendor/client/google-signin.js +133 -1
- package/vendor/cli/vendor/client/hooks.js +430 -1
- package/vendor/cli/vendor/client/model-discovery.js +373 -1
- package/vendor/cli/vendor/client/naming.js +283 -1
- package/vendor/cli/vendor/client/platform.js +937 -1
- package/vendor/cli/vendor/client/prefs.js +351 -1
- package/vendor/cli/vendor/client/presence-constants.js +107 -1
- package/vendor/cli/vendor/client/presence.js +438 -1
- package/vendor/cli/vendor/client/record-vault.js +1055 -3
- package/vendor/cli/vendor/client/session-store.js +575 -1
- package/vendor/cli/vendor/client/topup.js +297 -1
- package/vendor/cli/vendor/client/touch.js +458 -1
- package/vendor/cli/vendor/client/update.js +763 -1
- package/vendor/cli/vendor/client/user-models.js +381 -1
- package/vendor/cli/vendor/desktop/lib/local/agents.js +105 -1
- package/vendor/cli/vendor/desktop/lib/local/attachments.js +276 -1
- package/vendor/cli/vendor/desktop/lib/local/autonomous.js +1045 -1
- package/vendor/cli/vendor/desktop/lib/local/claude-pro.js +1028 -1
- package/vendor/cli/vendor/desktop/lib/local/context.js +125 -1
- package/vendor/cli/vendor/desktop/lib/local/engine.js +3666 -1
- package/vendor/cli/vendor/desktop/lib/local/entitlement.js +660 -1
- package/vendor/cli/vendor/desktop/lib/local/git-scope.js +228 -1
- package/vendor/cli/vendor/desktop/lib/local/local.js +2145 -1
- package/vendor/cli/vendor/desktop/lib/local/prompt.js +280 -1
- package/vendor/cli/vendor/desktop/lib/local/queue.js +560 -1
- package/vendor/cli/vendor/desktop/lib/local/session-rounds.js +238 -1
- package/vendor/cli/vendor/desktop/lib/local/spill.js +75 -1
- package/vendor/cli/vendor/desktop/lib/local/turn-guard.js +300 -1
- package/vendor/cli/vendor/desktop/lib/local/worktree-lock.js +235 -1
- package/vendor/cli/vendor/desktop/lib/settings.js +890 -1
- package/vendor/cli/vendor/desktop/renderer/usage.js +1239 -1
- package/vendor/cli/vendor/hosts/install.js +638 -1
- package/vendor/cli/vendor/hosts/openai-shim.js +515 -1
- package/vendor/cli/vendor/hosts/spec.js +164 -1
- package/vendor/cli/vendor/hosts/targets.js +346 -1
- package/vendor/cli/vendor/mcp/server.js +221 -1
- package/vendor/cli/vendor/mcp/tools.js +408 -1
- package/vendor/cli/vendor/one/src/child.js +285 -1
- package/vendor/cli/vendor/one/src/permissions.js +383 -1
- package/vendor/desktop/bin/aegis.js +32 -1
- package/vendor/desktop/lib/account-key.js +56 -1
- package/vendor/desktop/lib/auto.js +461 -1
- package/vendor/desktop/lib/avatar/companion.js +698 -1
- package/vendor/desktop/lib/avatar/cosmetics.js +532 -1
- package/vendor/desktop/lib/avatar/events.js +344 -1
- package/vendor/desktop/lib/avatar/holder-turn.js +350 -1
- package/vendor/desktop/lib/avatar/holders.js +612 -1
- package/vendor/desktop/lib/avatar/identity.js +641 -1
- package/vendor/desktop/lib/avatar/level.js +368 -1
- package/vendor/desktop/lib/avatar/mirror.js +524 -1
- package/vendor/desktop/lib/avatar/persona.js +388 -1
- package/vendor/desktop/lib/avatar/profile.js +977 -1
- package/vendor/desktop/lib/avatar/register.js +307 -1
- package/vendor/desktop/lib/avatar/store.js +472 -1
- package/vendor/desktop/lib/avatar/tiers.js +38 -1
- package/vendor/desktop/lib/avatar/transfer.js +415 -1
- package/vendor/desktop/lib/avatar/turn.js +216 -1
- package/vendor/desktop/lib/avatar/voice.js +328 -1
- package/vendor/desktop/lib/avatar/xp.js +404 -1
- package/vendor/desktop/lib/deep-link.js +120 -1
- package/vendor/desktop/lib/fingerprint.js +347 -2
- package/vendor/desktop/lib/google-connect.js +323 -1
- package/vendor/desktop/lib/local/agents.js +105 -1
- package/vendor/desktop/lib/local/attachments.js +276 -1
- package/vendor/desktop/lib/local/autonomous.js +1045 -1
- package/vendor/desktop/lib/local/claude-pro.js +1028 -1
- package/vendor/desktop/lib/local/context.js +125 -1
- package/vendor/desktop/lib/local/engine.js +3666 -1
- package/vendor/desktop/lib/local/entitlement.js +660 -1
- package/vendor/desktop/lib/local/git-scope.js +228 -1
- package/vendor/desktop/lib/local/local.js +2145 -1
- package/vendor/desktop/lib/local/prompt.js +280 -1
- package/vendor/desktop/lib/local/queue.js +560 -1
- package/vendor/desktop/lib/local/session-rounds.js +238 -1
- package/vendor/desktop/lib/local/spill.js +75 -1
- package/vendor/desktop/lib/local/telemetry.js +470 -1
- package/vendor/desktop/lib/local/turn-guard.js +300 -1
- package/vendor/desktop/lib/local/worktree-lock.js +235 -1
- package/vendor/desktop/lib/provider-key-mirror.js +252 -1
- package/vendor/desktop/lib/quick-launcher.js +84 -1
- package/vendor/desktop/lib/settings.js +890 -1
- package/vendor/desktop/lib/sync/memory-queue.js +60 -1
- package/vendor/desktop/lib/sync/persist-gate.js +148 -1
- package/vendor/desktop/lib/sync/sessions.js +106 -1
- package/vendor/desktop/lib/window-state.js +66 -1
- package/vendor/desktop/package.json +5 -3
- package/vendor/desktop/preload.js +679 -1
- package/vendor/desktop/renderer/app.js +7250 -1
- package/vendor/desktop/renderer/avatar/assemble.js +335 -1
- package/vendor/desktop/renderer/avatar/avatar.js +380 -1
- package/vendor/desktop/renderer/avatar/cards.js +141 -1
- package/vendor/desktop/renderer/avatar/hud.js +206 -1
- package/vendor/desktop/renderer/avatar/machine.js +213 -1
- package/vendor/desktop/renderer/avatar/pane.js +439 -1
- package/vendor/desktop/renderer/avatar/parts.js +437 -1
- package/vendor/desktop/renderer/budget.js +172 -1
- package/vendor/desktop/renderer/companion.js +223 -1
- package/vendor/desktop/renderer/diff.js +359 -1
- package/vendor/desktop/renderer/diffview.js +336 -1
- package/vendor/desktop/renderer/filepreview.js +211 -1
- package/vendor/desktop/renderer/fingerprint.js +789 -3
- package/vendor/desktop/renderer/markdown.js +168 -1
- package/vendor/desktop/renderer/provider-mark.js +311 -1
- package/vendor/desktop/renderer/provider-toolbar.js +134 -1
- package/vendor/desktop/renderer/providers.js +259 -1
- package/vendor/desktop/renderer/quick.js +285 -1
- package/vendor/desktop/renderer/stream-policy.js +387 -1
- package/vendor/desktop/renderer/transcript-view.js +323 -1
- package/vendor/desktop/renderer/usage.js +1239 -1
- package/vendor/desktop/vendor/aegis.js +2441 -1
- package/vendor/desktop/vendor/attest.js +518 -1
- package/vendor/desktop/vendor/authorship-key.js +410 -1
- package/vendor/desktop/vendor/auto-provision.js +134 -1
- package/vendor/desktop/vendor/brain-catalog.js +268 -1
- package/vendor/desktop/vendor/byok-catalog.js +199 -1
- package/vendor/desktop/vendor/catalog-client.js +487 -1
- package/vendor/desktop/vendor/conversation-export.js +177 -1
- package/vendor/desktop/vendor/credentials.js +494 -1
- package/vendor/desktop/vendor/device-fingerprint.js +141 -1
- package/vendor/desktop/vendor/drive-connect.js +110 -1
- package/vendor/desktop/vendor/drive-upload.js +234 -1
- package/vendor/desktop/vendor/env-file.js +1273 -1
- package/vendor/desktop/vendor/fingerprint.js +1064 -1
- package/vendor/desktop/vendor/foreign-memory.js +669 -1
- package/vendor/desktop/vendor/google-signin.js +133 -1
- package/vendor/desktop/vendor/hooks.js +430 -1
- package/vendor/desktop/vendor/model-discovery.js +373 -1
- package/vendor/desktop/vendor/naming.js +283 -1
- package/vendor/desktop/vendor/platform.js +937 -1
- package/vendor/desktop/vendor/prefs.js +351 -1
- package/vendor/desktop/vendor/presence-constants.js +107 -1
- package/vendor/desktop/vendor/presence.js +438 -1
- package/vendor/desktop/vendor/record-vault.js +1055 -3
- package/vendor/desktop/vendor/session-store.js +575 -1
- package/vendor/desktop/vendor/topup.js +297 -1
- package/vendor/desktop/vendor/touch.js +458 -1
- package/vendor/desktop/vendor/update.js +763 -1
- package/vendor/desktop/vendor/user-models.js +381 -1
- package/LICENSE +0 -661
- package/SOURCE-OFFER.txt +0 -9
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
2
|
// Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
|
|
3
|
-
|
|
3
|
+
// AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
|
|
4
|
+
// Conveying a modified copy, or running one as a network service, owes the
|
|
5
|
+
// corresponding source under this licence (§5/§13) — see LICENSING.md.
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
4
8
|
/**
|
|
5
9
|
* The desktop's φ(α) surface: the same keys and the same records the terminal
|
|
6
10
|
* host mints, driven over IPC instead of argv.
|
|
@@ -43,4 +47,345 @@
|
|
|
43
47
|
* method` string with the real message buried in main-process logs; a returned
|
|
44
48
|
* error is a message the UI can show verbatim, which matters most for the one
|
|
45
49
|
* error a user is likely to hit ("this key file is readable by other users").
|
|
46
|
-
*/
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
const fs = require('node:fs');
|
|
53
|
+
const path = require('node:path');
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Resolve a shared client module by existence: repo checkout first, then the
|
|
57
|
+
* packaged app's flattened `vendor/` (electron-builder cannot reach outside the
|
|
58
|
+
* app directory — see scripts/predist.mjs, which must stage all four).
|
|
59
|
+
*/
|
|
60
|
+
function resolveShared(name) {
|
|
61
|
+
const candidates = [
|
|
62
|
+
path.join(__dirname, '..', '..', 'client', name), // dev / CI: repo root
|
|
63
|
+
path.join(__dirname, '..', 'vendor', name), // packaged: desktop/vendor
|
|
64
|
+
];
|
|
65
|
+
for (const candidate of candidates) {
|
|
66
|
+
if (fs.existsSync(candidate)) return candidate;
|
|
67
|
+
}
|
|
68
|
+
throw new Error(
|
|
69
|
+
`aegis-desktop: cannot find client/${name} — expected it beside desktop/ in the repo ` +
|
|
70
|
+
'or under desktop/vendor/ in a build. Run `npm run predist` in desktop/.',
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function load() {
|
|
75
|
+
const fp = require(resolveShared('fingerprint.js'));
|
|
76
|
+
return {
|
|
77
|
+
fp,
|
|
78
|
+
authorship: require(resolveShared('authorship-key.js')),
|
|
79
|
+
attest: require(resolveShared('attest.js')),
|
|
80
|
+
vault: require(resolveShared('record-vault.js')),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function slug(value, max = 80) {
|
|
85
|
+
return (
|
|
86
|
+
String(value || 'session')
|
|
87
|
+
.replace(/[^A-Za-z0-9._-]+/g, '_')
|
|
88
|
+
.replace(/^[._-]+/, '')
|
|
89
|
+
.slice(0, max) || 'session'
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @param {object} o
|
|
95
|
+
* @param {string} o.dir the app's data directory (userData in a package)
|
|
96
|
+
* @param {object} [o.env] process env, injectable for tests
|
|
97
|
+
* @param {() => string} [o.getVaultBackend] reads the live preference
|
|
98
|
+
* ('aegiscloud' | 'drive' | 'off', desktop/lib/settings.js's
|
|
99
|
+
* vaultBackendConfig) — a function, not a value, so a change made in
|
|
100
|
+
* Settings while the app is running reaches the very next vault call with
|
|
101
|
+
* no restart, the same contract getConfirmMode's gate already keeps.
|
|
102
|
+
*/
|
|
103
|
+
function createFingerprintService({ dir, env, getVaultBackend } = {}) {
|
|
104
|
+
if (!dir) throw new Error('aegis-desktop: createFingerprintService needs a data dir');
|
|
105
|
+
// One store: the shared modules read AEGIS_HOME and nothing else.
|
|
106
|
+
const scope = { ...(env || process.env), AEGIS_HOME: (env || process.env).AEGIS_HOME || dir };
|
|
107
|
+
|
|
108
|
+
/** `true` only when the user has explicitly turned sync off — not when no
|
|
109
|
+
* preference has been recorded yet, which must keep resolving to whatever
|
|
110
|
+
* record-vault.js's own default is. */
|
|
111
|
+
function vaultDisabled() {
|
|
112
|
+
return typeof getVaultBackend === 'function' && getVaultBackend() === 'off';
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* `scope`, with the vault backend layered on top of it when a preference
|
|
117
|
+
* names one. 'aegiscloud' and an absent preference both fall through to
|
|
118
|
+
* `scope` unchanged — client/record-vault.js's own DEFAULT_BACKEND is
|
|
119
|
+
* already 'aegiscloud', so there is nothing to add for either case. 'drive'
|
|
120
|
+
* is the one preference that actually changes the destination: it asks the
|
|
121
|
+
* rclone adapter for the `gdrive` remote (the user's own Google Drive,
|
|
122
|
+
* configured by them — see client/record-vault.js's DEFAULT_REMOTE). 'off'
|
|
123
|
+
* is handled by `vaultDisabled()` before this is ever called, not here.
|
|
124
|
+
*/
|
|
125
|
+
function vaultScope() {
|
|
126
|
+
if (typeof getVaultBackend === 'function' && getVaultBackend() === 'drive') {
|
|
127
|
+
return { ...scope, AEGIS_VAULT_BACKEND: 'rclone', AEGIS_VAULT_REMOTE: scope.AEGIS_VAULT_REMOTE || 'gdrive' };
|
|
128
|
+
}
|
|
129
|
+
return scope;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const VAULT_OFF_ERROR = 'the vault is turned off — turn it back on (Google Drive or AE) in Settings to publish or inspect it';
|
|
133
|
+
|
|
134
|
+
const recordPath = (record, session) =>
|
|
135
|
+
path.join(dir, 'fingerprints', `${slug(session)}.${String(record.createdAt).replace(/[:.]/g, '-')}.json`);
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
/** Which key is in use, and where it came from. Never returns the key. */
|
|
139
|
+
status() {
|
|
140
|
+
try {
|
|
141
|
+
const { fp, authorship, vault } = load();
|
|
142
|
+
const key = authorship.resolveKey({ argv: [], env: scope });
|
|
143
|
+
const history = path.join(authorship.dataDir(scope), 'history.jsonl');
|
|
144
|
+
if (vaultDisabled()) {
|
|
145
|
+
return {
|
|
146
|
+
ok: true,
|
|
147
|
+
configured: Boolean(key.secret),
|
|
148
|
+
keySource: key.source,
|
|
149
|
+
keyPath: key.path,
|
|
150
|
+
keyFingerprint: key.secret ? fp.keyFingerprint(key.secret) : null,
|
|
151
|
+
publicKey: key.public,
|
|
152
|
+
defaultKeyPath: authorship.defaultKeyPath(scope),
|
|
153
|
+
historyPath: history,
|
|
154
|
+
historyPresent: fs.existsSync(history),
|
|
155
|
+
dataDir: authorship.dataDir(scope),
|
|
156
|
+
vault: { backend: 'off', remote: null, root: null, recordsDir: null },
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
const target = vault.vaultTarget(vaultScope());
|
|
160
|
+
return {
|
|
161
|
+
ok: true,
|
|
162
|
+
configured: Boolean(key.secret),
|
|
163
|
+
keySource: key.source,
|
|
164
|
+
keyPath: key.path,
|
|
165
|
+
keyFingerprint: key.secret ? fp.keyFingerprint(key.secret) : null,
|
|
166
|
+
publicKey: key.public,
|
|
167
|
+
defaultKeyPath: authorship.defaultKeyPath(scope),
|
|
168
|
+
historyPath: history,
|
|
169
|
+
historyPresent: fs.existsSync(history),
|
|
170
|
+
dataDir: authorship.dataDir(scope),
|
|
171
|
+
// Where a publish goes, so the panel can say it before the user asks
|
|
172
|
+
// for one — and so a misconfigured root is visible, not discovered by
|
|
173
|
+
// a record landing in the wrong folder.
|
|
174
|
+
vault: {
|
|
175
|
+
backend: target.backend,
|
|
176
|
+
remote: target.remote,
|
|
177
|
+
root: target.root,
|
|
178
|
+
recordsDir: target.backend === vault.BACKEND_CLOUD ? vault.CLOUD_PREFIX : `${target.root}/${vault.RECORDS_DIR}`,
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
} catch (e) {
|
|
182
|
+
return { ok: false, error: (e && e.message) || String(e) };
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
/** Mint a private key. `force` replaces one, which orphans its records. */
|
|
187
|
+
keygen({ out = null, force = false } = {}) {
|
|
188
|
+
try {
|
|
189
|
+
const { authorship } = load();
|
|
190
|
+
const argv = [];
|
|
191
|
+
if (out) argv.push('--out', out);
|
|
192
|
+
if (force) argv.push('--force');
|
|
193
|
+
const r = authorship.keygen({ argv, env: scope });
|
|
194
|
+
return { ok: true, ...r };
|
|
195
|
+
} catch (e) {
|
|
196
|
+
return { ok: false, error: (e && e.message) || String(e) };
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Seal a session as a record.
|
|
202
|
+
*
|
|
203
|
+
* `turns` may be passed in (the renderer's own view of the session) or left
|
|
204
|
+
* out, in which case the shared adapter reads the session log — same code
|
|
205
|
+
* path as the CLI, so a GUI record and a terminal record of the same
|
|
206
|
+
* session carry the same behaviour digest — and the same AI digest, from the
|
|
207
|
+
* same turns.
|
|
208
|
+
*/
|
|
209
|
+
async mint({ history = null, session = null, turns = null, label = null, account = null,
|
|
210
|
+
model = null, tools = null, codeRoots = null, codeDirty = null, out = null,
|
|
211
|
+
createdAt = null, publish = false, aiSecret = undefined, aiModel = null } = {}) {
|
|
212
|
+
try {
|
|
213
|
+
const { attest, authorship } = load();
|
|
214
|
+
const roots = Array.isArray(codeRoots) ? codeRoots.filter(Boolean) : [];
|
|
215
|
+
const r = attest.mintSession({
|
|
216
|
+
argv: [],
|
|
217
|
+
env: scope,
|
|
218
|
+
history: history || path.join(authorship.dataDir(scope), 'history.jsonl'),
|
|
219
|
+
session: session || undefined,
|
|
220
|
+
turns: turns || undefined,
|
|
221
|
+
label: label || undefined,
|
|
222
|
+
account: account || undefined,
|
|
223
|
+
model: model || undefined,
|
|
224
|
+
tools: Array.isArray(tools) ? tools : undefined,
|
|
225
|
+
code: roots.length ? attest.collectCode({ roots }) : [],
|
|
226
|
+
codeDirty: typeof codeDirty === 'boolean' ? codeDirty : null,
|
|
227
|
+
// The AI axis. `undefined` walks the shared rungs (`--ai-secret` never
|
|
228
|
+
// applies here; `$AEGIS_AI_SECRET` in the app's scope does), and an
|
|
229
|
+
// explicit null means "no credential — mint the axis as unobserved".
|
|
230
|
+
// The authorship key is never borrowed for this: it says who sealed the
|
|
231
|
+
// record, not which mind answered.
|
|
232
|
+
aiSecret,
|
|
233
|
+
aiModel: aiModel === null ? undefined : aiModel,
|
|
234
|
+
// Pinning the time is how the CLI and the app mint the *same* record
|
|
235
|
+
// for the same session (see client/attest.js). Left null, the record
|
|
236
|
+
// is stamped now, which is what an ordinary seal wants.
|
|
237
|
+
createdAt: createdAt || undefined,
|
|
238
|
+
});
|
|
239
|
+
const file = path.resolve(out || recordPath(r.record, session || 'last'));
|
|
240
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
241
|
+
fs.writeFileSync(file, JSON.stringify(r.record, null, 2) + '\n');
|
|
242
|
+
|
|
243
|
+
// Sealing and travelling are separate acts: `publish` is opt-in, and a
|
|
244
|
+
// failed publish NEVER unseals the record — the local file is already
|
|
245
|
+
// written and the error is reported beside it, because the seal is the
|
|
246
|
+
// evidence and the copy is the convenience.
|
|
247
|
+
let vault = null;
|
|
248
|
+
let vaultError = null;
|
|
249
|
+
if (publish) {
|
|
250
|
+
if (vaultDisabled()) {
|
|
251
|
+
vaultError = VAULT_OFF_ERROR;
|
|
252
|
+
} else {
|
|
253
|
+
try {
|
|
254
|
+
const key = authorship.resolveKey({ argv: [], env: scope });
|
|
255
|
+
vault = await load().vault.publish({ file, argv: [], env: vaultScope(), secret: key.secret });
|
|
256
|
+
} catch (e) {
|
|
257
|
+
vaultError = (e && e.message) || String(e);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return {
|
|
262
|
+
ok: true,
|
|
263
|
+
record: r.record,
|
|
264
|
+
out: file,
|
|
265
|
+
keySource: r.keySource,
|
|
266
|
+
public: r.public,
|
|
267
|
+
vault,
|
|
268
|
+
vaultError,
|
|
269
|
+
};
|
|
270
|
+
} catch (e) {
|
|
271
|
+
return { ok: false, error: (e && e.message) || String(e) };
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Publish a sealed record to the vault, and link the local copy to it.
|
|
277
|
+
*
|
|
278
|
+
* `record` is accepted as well as `file` so the panel can publish what it
|
|
279
|
+
* just minted without a round trip through the filesystem — but the
|
|
280
|
+
* preferred path is the file, because the sha256 in the anchor is then about
|
|
281
|
+
* the bytes on disk rather than a re-serialisation of them.
|
|
282
|
+
*/
|
|
283
|
+
async publish({ file = null, record = null, dryRun = false } = {}) {
|
|
284
|
+
if (vaultDisabled()) return { ok: false, error: VAULT_OFF_ERROR };
|
|
285
|
+
try {
|
|
286
|
+
const { authorship, vault } = load();
|
|
287
|
+
const key = authorship.resolveKey({ argv: [], env: scope });
|
|
288
|
+
return {
|
|
289
|
+
ok: true,
|
|
290
|
+
...(await vault.publish({ file, record, argv: [], env: vaultScope(), secret: key.secret, dryRun })),
|
|
291
|
+
};
|
|
292
|
+
} catch (e) {
|
|
293
|
+
return { ok: false, error: (e && e.message) || String(e) };
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Is the published copy still the record that was sealed?
|
|
299
|
+
*
|
|
300
|
+
* Reports the three claims separately (`present`, `unchanged`, `attested`),
|
|
301
|
+
* because "the file is gone" and "the file was replaced" and "the key that
|
|
302
|
+
* sealed it has moved on" are three different situations and a single
|
|
303
|
+
* boolean would flatten them into one that hides the interesting case.
|
|
304
|
+
*/
|
|
305
|
+
async anchor({ file = null, record = null, anchor = null } = {}) {
|
|
306
|
+
if (vaultDisabled()) return { ok: false, error: VAULT_OFF_ERROR };
|
|
307
|
+
try {
|
|
308
|
+
const { authorship, vault } = load();
|
|
309
|
+
if (!file && !record && !anchor) return { ok: false, error: 'anchor needs a record or an anchor' };
|
|
310
|
+
const key = authorship.resolveKey({ argv: [], env: scope });
|
|
311
|
+
return { ok: true, ...(await vault.checkAnchor({ file, record, anchor, argv: [], env: vaultScope(), key })) };
|
|
312
|
+
} catch (e) {
|
|
313
|
+
return { ok: false, error: (e && e.message) || String(e) };
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
|
|
317
|
+
/** What is in the vault. */
|
|
318
|
+
async vaultList() {
|
|
319
|
+
if (vaultDisabled()) return { ok: false, error: VAULT_OFF_ERROR };
|
|
320
|
+
try {
|
|
321
|
+
const { vault } = load();
|
|
322
|
+
return { ok: true, ...(await vault.list({ argv: [], env: vaultScope() })) };
|
|
323
|
+
} catch (e) {
|
|
324
|
+
return { ok: false, error: (e && e.message) || String(e) };
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Inspect the vault for key material — including the `keys/` copy that was
|
|
330
|
+
* already there before publishing was restricted. A finding is a fact about
|
|
331
|
+
* the vault, not about this app, so it is returned rather than acted on.
|
|
332
|
+
*/
|
|
333
|
+
async vaultAudit() {
|
|
334
|
+
if (vaultDisabled()) return { ok: false, error: VAULT_OFF_ERROR };
|
|
335
|
+
try {
|
|
336
|
+
const { authorship, vault } = load();
|
|
337
|
+
const key = authorship.resolveKey({ argv: [], env: scope });
|
|
338
|
+
return { ok: true, ...(await vault.audit({ argv: [], env: vaultScope(), secret: key.secret || null })) };
|
|
339
|
+
} catch (e) {
|
|
340
|
+
return { ok: false, error: (e && e.message) || String(e) };
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Recompute a record's attestation. Accepts a path or the record itself, so
|
|
346
|
+
* the renderer can verify what it just minted without a round trip through
|
|
347
|
+
* the filesystem.
|
|
348
|
+
*/
|
|
349
|
+
verify({ file = null, record = null } = {}) {
|
|
350
|
+
try {
|
|
351
|
+
const { fp, authorship } = load();
|
|
352
|
+
let body = record;
|
|
353
|
+
if (!body) {
|
|
354
|
+
if (!file) return { ok: false, error: 'verify needs a record file or the record itself' };
|
|
355
|
+
body = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
356
|
+
}
|
|
357
|
+
const key = authorship.resolveKey({ argv: [], env: scope });
|
|
358
|
+
if (!key.secret) {
|
|
359
|
+
return { ok: false, error: 'no authorship key — run keygen first', reason: 'no key' };
|
|
360
|
+
}
|
|
361
|
+
const v = fp.verify(body, key.secret);
|
|
362
|
+
return {
|
|
363
|
+
ok: v.ok,
|
|
364
|
+
reason: v.reason,
|
|
365
|
+
id: v.id,
|
|
366
|
+
credentialMatch: v.credentialMatch,
|
|
367
|
+
keySource: key.source,
|
|
368
|
+
recordedKeyFingerprint: body.keyFingerprint || null,
|
|
369
|
+
};
|
|
370
|
+
} catch (e) {
|
|
371
|
+
return { ok: false, error: (e && e.message) || String(e) };
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
|
|
375
|
+
/** Copy the key out. Refuses a destination inside a non-ignored git tree. */
|
|
376
|
+
backup({ to = null, name = null, allowGit = false } = {}) {
|
|
377
|
+
try {
|
|
378
|
+
if (!to) return { ok: false, error: 'backup needs a destination directory' };
|
|
379
|
+
const { authorship } = load();
|
|
380
|
+
const argv = ['--to', to];
|
|
381
|
+
if (name) argv.push('--name', name);
|
|
382
|
+
if (allowGit) argv.push('--allow-git');
|
|
383
|
+
return { ok: true, ...authorship.backup({ argv, env: scope }) };
|
|
384
|
+
} catch (e) {
|
|
385
|
+
return { ok: false, error: (e && e.message) || String(e) };
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
module.exports = { createFingerprintService, resolveShared, slug };
|