@cleocode/core 2026.9.16 → 2026.9.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/changesets/parser.d.ts.map +1 -1
- package/dist/changesets/parser.js +67 -0
- package/dist/changesets/parser.js.map +1 -1
- package/dist/crypto/credentials.d.ts +128 -26
- package/dist/crypto/credentials.d.ts.map +1 -1
- package/dist/crypto/credentials.js +183 -142
- package/dist/crypto/credentials.js.map +1 -1
- package/dist/docs/export-document.js +14705 -12949
- package/dist/docs/export-document.js.map +3 -3
- package/dist/doctor/index.d.ts +1 -1
- package/dist/doctor/index.d.ts.map +1 -1
- package/dist/doctor/index.js +1 -1
- package/dist/doctor/index.js.map +1 -1
- package/dist/doctor/nexus-schema-residency.d.ts +1 -1
- package/dist/doctor/nexus-schema-residency.d.ts.map +1 -1
- package/dist/doctor/nexus-schema-residency.js +1 -0
- package/dist/doctor/nexus-schema-residency.js.map +1 -1
- package/dist/doctor/project-identity.d.ts +124 -0
- package/dist/doctor/project-identity.d.ts.map +1 -0
- package/dist/doctor/project-identity.js +307 -0
- package/dist/doctor/project-identity.js.map +1 -0
- package/dist/doctor/superseded-store.d.ts +8 -0
- package/dist/doctor/superseded-store.d.ts.map +1 -1
- package/dist/doctor/superseded-store.js +48 -3
- package/dist/doctor/superseded-store.js.map +1 -1
- package/dist/init.d.ts +7 -0
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +17 -2
- package/dist/init.js.map +1 -1
- package/dist/internal.d.ts +6 -3
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +4 -2
- package/dist/internal.js.map +1 -1
- package/dist/llm/credentials-store.d.ts +10 -0
- package/dist/llm/credentials-store.d.ts.map +1 -1
- package/dist/llm/credentials-store.js +7 -1
- package/dist/llm/credentials-store.js.map +1 -1
- package/dist/llm/plugin-facade.js +13368 -1550
- package/dist/llm/plugin-facade.js.map +3 -3
- package/dist/nexus/analyze-orchestrator.d.ts +20 -3
- package/dist/nexus/analyze-orchestrator.d.ts.map +1 -1
- package/dist/nexus/analyze-orchestrator.js +210 -16
- package/dist/nexus/analyze-orchestrator.js.map +1 -1
- package/dist/nexus/assessment-store.d.ts +86 -0
- package/dist/nexus/assessment-store.d.ts.map +1 -0
- package/dist/nexus/assessment-store.js +113 -0
- package/dist/nexus/assessment-store.js.map +1 -0
- package/dist/nexus/freshness.d.ts +131 -0
- package/dist/nexus/freshness.d.ts.map +1 -0
- package/dist/nexus/freshness.js +391 -0
- package/dist/nexus/freshness.js.map +1 -0
- package/dist/nexus/graph-manifest.d.ts +88 -0
- package/dist/nexus/graph-manifest.d.ts.map +1 -0
- package/dist/nexus/graph-manifest.js +114 -0
- package/dist/nexus/graph-manifest.js.map +1 -0
- package/dist/nexus/knowledge.d.ts +21 -1
- package/dist/nexus/knowledge.d.ts.map +1 -1
- package/dist/nexus/knowledge.js +74 -37
- package/dist/nexus/knowledge.js.map +1 -1
- package/dist/nexus/path-map.d.ts +55 -0
- package/dist/nexus/path-map.d.ts.map +1 -0
- package/dist/nexus/path-map.js +87 -0
- package/dist/nexus/path-map.js.map +1 -0
- package/dist/nexus/projects-clean.d.ts +21 -28
- package/dist/nexus/projects-clean.d.ts.map +1 -1
- package/dist/nexus/projects-clean.js +168 -85
- package/dist/nexus/projects-clean.js.map +1 -1
- package/dist/nexus/query.d.ts.map +1 -1
- package/dist/nexus/query.js +3 -2
- package/dist/nexus/query.js.map +1 -1
- package/dist/nexus/registry-hygiene.d.ts +70 -0
- package/dist/nexus/registry-hygiene.d.ts.map +1 -0
- package/dist/nexus/registry-hygiene.js +113 -0
- package/dist/nexus/registry-hygiene.js.map +1 -0
- package/dist/nexus/registry.d.ts +2 -2
- package/dist/nexus/registry.d.ts.map +1 -1
- package/dist/nexus/registry.js +48 -12
- package/dist/nexus/registry.js.map +1 -1
- package/dist/paths.d.ts +26 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +99 -6
- package/dist/paths.js.map +1 -1
- package/dist/release/index.d.ts +1 -1
- package/dist/release/index.d.ts.map +1 -1
- package/dist/release/index.js.map +1 -1
- package/dist/release/plan.d.ts +84 -2
- package/dist/release/plan.d.ts.map +1 -1
- package/dist/release/plan.js +61 -14
- package/dist/release/plan.js.map +1 -1
- package/dist/release/pr-evidence.d.ts +81 -1
- package/dist/release/pr-evidence.d.ts.map +1 -1
- package/dist/release/pr-evidence.js +149 -9
- package/dist/release/pr-evidence.js.map +1 -1
- package/dist/render/nexus/graph/index.d.ts.map +1 -1
- package/dist/render/nexus/graph/index.js +8 -0
- package/dist/render/nexus/graph/index.js.map +1 -1
- package/dist/scaffold/ensure-config.d.ts +12 -3
- package/dist/scaffold/ensure-config.d.ts.map +1 -1
- package/dist/scaffold/ensure-config.js +61 -38
- package/dist/scaffold/ensure-config.js.map +1 -1
- package/dist/scaffold/project-identity.d.ts +136 -0
- package/dist/scaffold/project-identity.d.ts.map +1 -0
- package/dist/scaffold/project-identity.js +225 -0
- package/dist/scaffold/project-identity.js.map +1 -0
- package/dist/selfimprove/fix-gen.js +13319 -1556
- package/dist/selfimprove/fix-gen.js.map +3 -3
- package/dist/store/agent-api-key.d.ts +114 -0
- package/dist/store/agent-api-key.d.ts.map +1 -0
- package/dist/store/agent-api-key.js +136 -0
- package/dist/store/agent-api-key.js.map +1 -0
- package/dist/store/agent-registry-accessor.d.ts +4 -2
- package/dist/store/agent-registry-accessor.d.ts.map +1 -1
- package/dist/store/agent-registry-accessor.js +39 -89
- package/dist/store/agent-registry-accessor.js.map +1 -1
- package/dist/store/api-key-kdf.d.ts +7 -0
- package/dist/store/api-key-kdf.d.ts.map +1 -1
- package/dist/store/api-key-kdf.js +7 -0
- package/dist/store/api-key-kdf.js.map +1 -1
- package/dist/store/backup-crypto.d.ts +49 -0
- package/dist/store/backup-crypto.d.ts.map +1 -1
- package/dist/store/backup-crypto.js +154 -0
- package/dist/store/backup-crypto.js.map +1 -1
- package/dist/store/credential-transfer.d.ts +303 -0
- package/dist/store/credential-transfer.d.ts.map +1 -0
- package/dist/store/credential-transfer.js +774 -0
- package/dist/store/credential-transfer.js.map +1 -0
- package/dist/store/exodus/column-transforms.d.ts +79 -4
- package/dist/store/exodus/column-transforms.d.ts.map +1 -1
- package/dist/store/exodus/column-transforms.js +121 -4
- package/dist/store/exodus/column-transforms.js.map +1 -1
- package/dist/store/exodus/index.d.ts +1 -0
- package/dist/store/exodus/index.d.ts.map +1 -1
- package/dist/store/exodus/index.js +1 -0
- package/dist/store/exodus/index.js.map +1 -1
- package/dist/store/exodus/migrate.d.ts +17 -1
- package/dist/store/exodus/migrate.d.ts.map +1 -1
- package/dist/store/exodus/migrate.js +155 -33
- package/dist/store/exodus/migrate.js.map +1 -1
- package/dist/store/exodus/on-open.d.ts +14 -0
- package/dist/store/exodus/on-open.d.ts.map +1 -1
- package/dist/store/exodus/on-open.js +115 -6
- package/dist/store/exodus/on-open.js.map +1 -1
- package/dist/store/exodus/reconcile.d.ts +103 -0
- package/dist/store/exodus/reconcile.d.ts.map +1 -0
- package/dist/store/exodus/reconcile.js +728 -0
- package/dist/store/exodus/reconcile.js.map +1 -0
- package/dist/store/exodus/recovery.d.ts.map +1 -1
- package/dist/store/exodus/recovery.js +14 -2
- package/dist/store/exodus/recovery.js.map +1 -1
- package/dist/store/exodus/runtime-targets.d.ts +39 -0
- package/dist/store/exodus/runtime-targets.d.ts.map +1 -0
- package/dist/store/exodus/runtime-targets.js +63 -0
- package/dist/store/exodus/runtime-targets.js.map +1 -0
- package/dist/store/exodus/table-name-map.d.ts.map +1 -1
- package/dist/store/exodus/table-name-map.js +5 -0
- package/dist/store/exodus/table-name-map.js.map +1 -1
- package/dist/store/exodus/table-order.d.ts +35 -0
- package/dist/store/exodus/table-order.d.ts.map +1 -0
- package/dist/store/exodus/table-order.js +62 -0
- package/dist/store/exodus/table-order.js.map +1 -0
- package/dist/store/exodus/verify-migration.d.ts +4 -1
- package/dist/store/exodus/verify-migration.d.ts.map +1 -1
- package/dist/store/exodus/verify-migration.js +142 -10
- package/dist/store/exodus/verify-migration.js.map +1 -1
- package/dist/store/global-salt.d.ts +16 -0
- package/dist/store/global-salt.d.ts.map +1 -1
- package/dist/store/global-salt.js +22 -7
- package/dist/store/global-salt.js.map +1 -1
- package/dist/store/legacy-tasks-lineage.d.ts +86 -0
- package/dist/store/legacy-tasks-lineage.d.ts.map +1 -0
- package/dist/store/legacy-tasks-lineage.js +285 -0
- package/dist/store/legacy-tasks-lineage.js.map +1 -0
- package/dist/store/migration-manager.d.ts +27 -0
- package/dist/store/migration-manager.d.ts.map +1 -1
- package/dist/store/migration-manager.js +63 -0
- package/dist/store/migration-manager.js.map +1 -1
- package/dist/store/portable-bundle-import.d.ts +117 -0
- package/dist/store/portable-bundle-import.d.ts.map +1 -0
- package/dist/store/portable-bundle-import.js +589 -0
- package/dist/store/portable-bundle-import.js.map +1 -0
- package/dist/store/portable-bundle-relocate.d.ts +66 -0
- package/dist/store/portable-bundle-relocate.d.ts.map +1 -0
- package/dist/store/portable-bundle-relocate.js +304 -0
- package/dist/store/portable-bundle-relocate.js.map +1 -0
- package/dist/store/portable-bundle-scan.d.ts +167 -0
- package/dist/store/portable-bundle-scan.d.ts.map +1 -0
- package/dist/store/portable-bundle-scan.js +569 -0
- package/dist/store/portable-bundle-scan.js.map +1 -0
- package/dist/store/portable-bundle.d.ts +146 -0
- package/dist/store/portable-bundle.d.ts.map +1 -0
- package/dist/store/portable-bundle.js +674 -0
- package/dist/store/portable-bundle.js.map +1 -0
- package/dist/store/regenerators.d.ts +3 -1
- package/dist/store/regenerators.d.ts.map +1 -1
- package/dist/store/regenerators.js +6 -2
- package/dist/store/regenerators.js.map +1 -1
- package/dist/store/schema/cleo-global/nexus.d.ts +98 -0
- package/dist/store/schema/cleo-global/nexus.d.ts.map +1 -1
- package/dist/store/schema/cleo-global/nexus.js +19 -0
- package/dist/store/schema/cleo-global/nexus.js.map +1 -1
- package/dist/store/schema/nexus-schema.d.ts +102 -0
- package/dist/store/schema/nexus-schema.d.ts.map +1 -1
- package/dist/store/schema/nexus-schema.js +24 -0
- package/dist/store/schema/nexus-schema.js.map +1 -1
- package/dist/store/split-brain-import.d.ts +176 -0
- package/dist/store/split-brain-import.d.ts.map +1 -0
- package/dist/store/split-brain-import.js +680 -0
- package/dist/store/split-brain-import.js.map +1 -0
- package/dist/store/sqlite.d.ts +29 -0
- package/dist/store/sqlite.d.ts.map +1 -1
- package/dist/store/sqlite.js +57 -5
- package/dist/store/sqlite.js.map +1 -1
- package/dist/system/health.d.ts.map +1 -1
- package/dist/system/health.js +30 -5
- package/dist/system/health.js.map +1 -1
- package/dist/tasks/complete.d.ts.map +1 -1
- package/dist/tasks/complete.js +5 -27
- package/dist/tasks/complete.js.map +1 -1
- package/dist/tasks/evidence.js +1 -1
- package/dist/tasks/evidence.js.map +1 -1
- package/dist/tasks/verification-policy.d.ts +55 -0
- package/dist/tasks/verification-policy.d.ts.map +1 -0
- package/dist/tasks/verification-policy.js +75 -0
- package/dist/tasks/verification-policy.js.map +1 -0
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +60 -0
- package/dist/upgrade.js.map +1 -1
- package/dist/validation/doctor/checks.d.ts +14 -0
- package/dist/validation/doctor/checks.d.ts.map +1 -1
- package/dist/validation/doctor/checks.js +33 -0
- package/dist/validation/doctor/checks.js.map +1 -1
- package/migrations/drizzle-cleo-global/20260924000000_t12354-project-paths/migration.sql +40 -0
- package/migrations/drizzle-nexus/20260924000000_t12315-nexus-parse-cache/migration.sql +21 -0
- package/package.json +13 -13
- package/templates/CLEO-INJECTION.md +3 -3
- package/templates/cleo-gitignore +7 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* credential-transfer.ts — move stored credentials between devices without
|
|
3
|
+
* moving the device key.
|
|
4
|
+
*
|
|
5
|
+
* Every stored credential is encrypted under a key derived from the local
|
|
6
|
+
* `machine-key` (`crypto/credentials.ts`). Copying that key to another device
|
|
7
|
+
* would make the two devices one trust domain, so it is never exported. A
|
|
8
|
+
* credential crosses devices one of two ways instead:
|
|
9
|
+
*
|
|
10
|
+
* - **Sealed** (encrypted backups) — {@link sealCredentials} decrypts every
|
|
11
|
+
* local credential and seals the plaintexts under a passphrase-derived key
|
|
12
|
+
* (scrypt + AES-256-GCM, the same envelope as encrypted bundles).
|
|
13
|
+
* {@link unsealCredentials} on the target device opens that payload and
|
|
14
|
+
* re-encrypts each credential under the TARGET machine-key.
|
|
15
|
+
* - **Re-entered** (unencrypted backups) — {@link redactCredentialCiphertexts}
|
|
16
|
+
* blanks the device-bound ciphertexts in the STAGED snapshot (they are
|
|
17
|
+
* useless elsewhere) and {@link listCredentialsForReentry} names every
|
|
18
|
+
* credential with the one command that re-enters it.
|
|
19
|
+
*
|
|
20
|
+
* This module also migrates project credentials from the legacy path-bound
|
|
21
|
+
* KDF to the project-identity KDF ({@link migrateProjectCredentials}), so a
|
|
22
|
+
* moved project directory keeps its credentials.
|
|
23
|
+
*
|
|
24
|
+
* Stores covered:
|
|
25
|
+
*
|
|
26
|
+
* | Store | Location | Encryption |
|
|
27
|
+
* |-------|----------|------------|
|
|
28
|
+
* | `project-agent` | project `cleo.db` → `tasks_agent_credentials.api_key_encrypted` | project KDF |
|
|
29
|
+
* | `service-connection` | global `cleo.db` → `service_connections.credentials_enc` | global KDF, id `service:<provider>:<label>` |
|
|
30
|
+
* | `llm-pool` | `<cleoHome>/llm-credentials.json` | none (0600 plaintext file) |
|
|
31
|
+
* | `agent-registry` | global `cleo.db` → `agent_registry_agents.api_key_encrypted` | global KDF, id `agent:<agentId>` (T12352) |
|
|
32
|
+
*
|
|
33
|
+
* The LLM pool stays a plaintext 0600 file on purpose (T12326 decision).
|
|
34
|
+
* Encrypting it under the machine-key would add little on-device protection,
|
|
35
|
+
* because the key sits in the same directory with the same mode. It would also
|
|
36
|
+
* force a key read into the synchronous resolver hot path
|
|
37
|
+
* (`pickCredentialForProviderSync`) and break the tools that read the file
|
|
38
|
+
* directly. What matters is that the pool never enters an unencrypted bundle,
|
|
39
|
+
* and this module guarantees that: the pool is either sealed or listed for
|
|
40
|
+
* re-entry.
|
|
41
|
+
*
|
|
42
|
+
* Callers pass FILE PATHS (live stores, or a backup's staged snapshots); the
|
|
43
|
+
* module opens short-lived raw handles and closes them before returning.
|
|
44
|
+
*
|
|
45
|
+
* @task T12326
|
|
46
|
+
* @module store/credential-transfer
|
|
47
|
+
*/
|
|
48
|
+
import type { CredentialDescriptor, CredentialReentry, ProjectCredentialMigrationResult, SealCredentialsResult, UnsealCredentialsResult } from '@cleocode/contracts';
|
|
49
|
+
/**
|
|
50
|
+
* Where to read credentials from. Every field is optional; an omitted store is
|
|
51
|
+
* skipped.
|
|
52
|
+
*
|
|
53
|
+
* @task T12326
|
|
54
|
+
*/
|
|
55
|
+
export interface CredentialSources {
|
|
56
|
+
/** Project `cleo.db` (live, or a staged snapshot). */
|
|
57
|
+
readonly projectDbPath?: string;
|
|
58
|
+
/** Project identity keying the project KDF. Required when the project store has rows. */
|
|
59
|
+
readonly projectId?: string;
|
|
60
|
+
/** Candidate paths for legacy path-bound project ciphertexts (usually the project root). */
|
|
61
|
+
readonly legacyProjectPaths?: readonly string[];
|
|
62
|
+
/** Global `cleo.db` (live, or a staged snapshot). */
|
|
63
|
+
readonly globalDbPath?: string;
|
|
64
|
+
/** LLM credential pool file. Defaults to none; pass `credentialsStorePath()` for the live pool. */
|
|
65
|
+
readonly llmStorePath?: string;
|
|
66
|
+
/** CLEO home whose machine-key (and global-salt) decrypt the stores. Defaults to the ambient home. */
|
|
67
|
+
readonly cleoHome?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Where {@link unsealCredentials} writes. The restored database files must
|
|
71
|
+
* already be in place — rows are updated, never created.
|
|
72
|
+
*
|
|
73
|
+
* @task T12326
|
|
74
|
+
*/
|
|
75
|
+
export interface CredentialTargets {
|
|
76
|
+
/** Restored project `cleo.db`. */
|
|
77
|
+
readonly projectDbPath?: string;
|
|
78
|
+
/** Identity of the restored project (its `.cleo/project-info.json` `projectId`). */
|
|
79
|
+
readonly projectId?: string;
|
|
80
|
+
/** Restored global `cleo.db`. */
|
|
81
|
+
readonly globalDbPath?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Write `llm-pool` entries into the local pool (`<cleoHome>/llm-credentials.json`).
|
|
84
|
+
* Default `true`. Only the AMBIENT home's pool can be written; with a
|
|
85
|
+
* different `cleoHome` the entries are reported for re-entry instead.
|
|
86
|
+
*/
|
|
87
|
+
readonly restoreLlmPool?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* CLEO home whose machine-key (and global-salt) re-encrypt the credentials —
|
|
90
|
+
* the home being restored INTO. Defaults to the ambient home.
|
|
91
|
+
*/
|
|
92
|
+
readonly cleoHome?: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Error codes raised by this module.
|
|
96
|
+
*
|
|
97
|
+
* - `E_CREDENTIAL_PASSPHRASE` — the passphrase did not open the sealed payload.
|
|
98
|
+
* - `E_CREDENTIAL_PAYLOAD` — the payload opened but is not a credential payload.
|
|
99
|
+
* - `E_CREDENTIAL_PROJECT_ID` — a project store has credentials but no project id was given.
|
|
100
|
+
* - `E_CREDENTIAL_LIVE_STORE` — {@link redactCredentialCiphertexts} was pointed at a live store.
|
|
101
|
+
*
|
|
102
|
+
* @task T12326
|
|
103
|
+
*/
|
|
104
|
+
export type CredentialTransferErrorCode = 'E_CREDENTIAL_PASSPHRASE' | 'E_CREDENTIAL_PAYLOAD' | 'E_CREDENTIAL_PROJECT_ID' | 'E_CREDENTIAL_LIVE_STORE';
|
|
105
|
+
/**
|
|
106
|
+
* Error thrown by credential transfer. Raised BEFORE any write, so a caller
|
|
107
|
+
* that catches it knows no store was modified.
|
|
108
|
+
*
|
|
109
|
+
* @task T12326
|
|
110
|
+
*/
|
|
111
|
+
export declare class CredentialTransferError extends Error {
|
|
112
|
+
/** Machine-readable failure code. */
|
|
113
|
+
readonly code: CredentialTransferErrorCode;
|
|
114
|
+
/**
|
|
115
|
+
* @param code - Failure code.
|
|
116
|
+
* @param message - Human-readable explanation, including the remedy.
|
|
117
|
+
*/
|
|
118
|
+
constructor(code: CredentialTransferErrorCode, message: string);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Build the re-entry record for a credential: its identity, why it must be
|
|
122
|
+
* re-entered, and the one command that re-enters it.
|
|
123
|
+
*
|
|
124
|
+
* @param descriptor - The credential.
|
|
125
|
+
* @param reason - Why it could not be carried over.
|
|
126
|
+
* @returns The re-entry record.
|
|
127
|
+
* @task T12326
|
|
128
|
+
*/
|
|
129
|
+
export declare function reentryFor(descriptor: CredentialDescriptor, reason: string): CredentialReentry;
|
|
130
|
+
/**
|
|
131
|
+
* List every credential in `sources` with the command that re-enters it.
|
|
132
|
+
* Reads identities only — nothing is decrypted.
|
|
133
|
+
*
|
|
134
|
+
* Use for an UNENCRYPTED backup: its import cannot carry credentials, so the
|
|
135
|
+
* import report prints this list.
|
|
136
|
+
*
|
|
137
|
+
* @param sources - Stores to enumerate.
|
|
138
|
+
* @param reason - Why the credentials must be re-entered (shown per entry).
|
|
139
|
+
* @returns One re-entry record per credential.
|
|
140
|
+
* @task T12326
|
|
141
|
+
*/
|
|
142
|
+
export declare function listCredentialsForReentry(sources: CredentialSources, reason?: string): CredentialReentry[];
|
|
143
|
+
/**
|
|
144
|
+
* Blank the device-bound ciphertexts in STAGED snapshot databases and report
|
|
145
|
+
* what was removed.
|
|
146
|
+
*
|
|
147
|
+
* An unencrypted bundle must not carry credential ciphertext: it cannot be
|
|
148
|
+
* decrypted on another device, and it would be decryptable by anyone who
|
|
149
|
+
* later obtains this device's machine-key. Sets
|
|
150
|
+
* `tasks_agent_credentials.api_key_encrypted = ''` (the column is NOT NULL)
|
|
151
|
+
* and `service_connections.credentials_enc = NULL`; every non-secret column
|
|
152
|
+
* is kept. The LLM pool FILE is not touched — the bundle writer must exclude
|
|
153
|
+
* it, and can take its entries from the returned list.
|
|
154
|
+
*
|
|
155
|
+
* @param sources - Staged snapshot paths (`projectDbPath` / `globalDbPath`);
|
|
156
|
+
* `llmStorePath` is listed, not modified.
|
|
157
|
+
* @returns Re-entry records for every redacted or excluded credential.
|
|
158
|
+
* @throws {CredentialTransferError} `E_CREDENTIAL_LIVE_STORE` when a path is
|
|
159
|
+
* a live store.
|
|
160
|
+
* @task T12326
|
|
161
|
+
*/
|
|
162
|
+
export declare function redactCredentialCiphertexts(sources: CredentialSources): CredentialReentry[];
|
|
163
|
+
/**
|
|
164
|
+
* Seal every credential in `sources` under a passphrase.
|
|
165
|
+
*
|
|
166
|
+
* Each credential is decrypted with THIS device's keys and the plaintexts are
|
|
167
|
+
* sealed together (scrypt-derived key, AES-256-GCM — {@link encryptBundle}).
|
|
168
|
+
* The payload carries credentials, never key material: the machine-key and
|
|
169
|
+
* global-salt stay on this device. A credential this device cannot decrypt is
|
|
170
|
+
* not sealed; it is reported in `reentry` (and carried into the payload so
|
|
171
|
+
* the importing device reports it too).
|
|
172
|
+
*
|
|
173
|
+
* @param sources - Stores to read (live stores or staged snapshots).
|
|
174
|
+
* @param passphrase - User passphrase; the same one opens the payload.
|
|
175
|
+
* @returns Sealed bytes plus what was sealed and what needs re-entry. A
|
|
176
|
+
* project credential with no `sources.projectId` is reported for re-entry.
|
|
177
|
+
* @task T12326
|
|
178
|
+
*/
|
|
179
|
+
export declare function sealCredentials(sources: CredentialSources, passphrase: string): Promise<SealCredentialsResult>;
|
|
180
|
+
/**
|
|
181
|
+
* Open a sealed payload and write every credential into the local stores,
|
|
182
|
+
* re-encrypted under THIS device's machine-key.
|
|
183
|
+
*
|
|
184
|
+
* Order of operations: the passphrase is checked and the payload validated
|
|
185
|
+
* BEFORE anything is written — a wrong passphrase leaves every store
|
|
186
|
+
* untouched. Database rows are updated in place (the restore must already
|
|
187
|
+
* have put the rows there); a credential whose row is absent, or whose store
|
|
188
|
+
* has no target, is reported for re-entry instead of being dropped silently.
|
|
189
|
+
*
|
|
190
|
+
* Call after the restored database files and any restored `global-salt` are in
|
|
191
|
+
* place: the global KDF reads the salt. Pass `targets.cleoHome` so the salt is
|
|
192
|
+
* read fresh from that home rather than from the process memo.
|
|
193
|
+
*
|
|
194
|
+
* @param sealed - Bytes from {@link sealCredentials}.
|
|
195
|
+
* @param passphrase - The passphrase used to seal.
|
|
196
|
+
* @param targets - Restored stores to write into.
|
|
197
|
+
* @returns What was restored and what must be re-entered (with commands).
|
|
198
|
+
* @throws {CredentialTransferError} `E_CREDENTIAL_PASSPHRASE` (wrong
|
|
199
|
+
* passphrase or corrupted payload) or `E_CREDENTIAL_PAYLOAD` — nothing written.
|
|
200
|
+
* @task T12326
|
|
201
|
+
*/
|
|
202
|
+
export declare function unsealCredentials(sealed: Uint8Array, passphrase: string, targets: CredentialTargets): Promise<UnsealCredentialsResult>;
|
|
203
|
+
/**
|
|
204
|
+
* Re-encrypt project credentials from the legacy path-bound KDF to the
|
|
205
|
+
* project-identity KDF, in place.
|
|
206
|
+
*
|
|
207
|
+
* Each ciphertext is opened with {@link decryptProjectSecret}; a legacy one is
|
|
208
|
+
* rewritten with the re-wrapped ciphertext it returns. Current ciphertexts are
|
|
209
|
+
* left alone. A credential no candidate key opens is left UNTOUCHED (never
|
|
210
|
+
* deleted) and reported with its re-entry command — typically because it was
|
|
211
|
+
* encrypted at a path not in `legacyProjectPaths`, or on another device.
|
|
212
|
+
* Idempotent: a second run reports everything as `current`. With `dryRun`
|
|
213
|
+
* nothing is written and `migrated` lists what WOULD be migrated.
|
|
214
|
+
*
|
|
215
|
+
* @param sources - `projectDbPath`, `projectId`, and `legacyProjectPaths`.
|
|
216
|
+
* @param options - `dryRun` to report without writing.
|
|
217
|
+
* @returns Migrated, already-current, and unrecoverable credentials.
|
|
218
|
+
* @throws {CredentialTransferError} `E_CREDENTIAL_PROJECT_ID` when rows exist
|
|
219
|
+
* and `projectId` is missing.
|
|
220
|
+
* @task T12326
|
|
221
|
+
*/
|
|
222
|
+
export declare function migrateProjectCredentials(sources: Pick<CredentialSources, 'projectDbPath' | 'projectId' | 'legacyProjectPaths' | 'cleoHome'>, options?: {
|
|
223
|
+
readonly dryRun?: boolean;
|
|
224
|
+
}): Promise<ProjectCredentialMigrationResult>;
|
|
225
|
+
/**
|
|
226
|
+
* Outcome of {@link migrateProjectCredentialsAtRoot}.
|
|
227
|
+
*
|
|
228
|
+
* @task T12326
|
|
229
|
+
*/
|
|
230
|
+
export interface ProjectRootCredentialMigration extends ProjectCredentialMigrationResult {
|
|
231
|
+
/** Project store examined. */
|
|
232
|
+
readonly projectDbPath: string;
|
|
233
|
+
/** Project identity keying the new KDF (null when project-info.json has none). */
|
|
234
|
+
readonly projectId: string | null;
|
|
235
|
+
/** Whether this was a dry run (nothing written). */
|
|
236
|
+
readonly dryRun: boolean;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Migrate a project's stored credentials off the path-bound KDF, resolving
|
|
240
|
+
* everything from the project root: the store is `<root>/.cleo/cleo.db`, the
|
|
241
|
+
* identity is `projectId` from `.cleo/project-info.json`, and the legacy
|
|
242
|
+
* candidates are the root as given and its real path.
|
|
243
|
+
*
|
|
244
|
+
* This is the trigger used by `cleo upgrade` and `cleo doctor credentials`.
|
|
245
|
+
* It is idempotent and never deletes; unrecoverable rows come back in
|
|
246
|
+
* `reentry` with the command that re-enters each one. A project with no
|
|
247
|
+
* credential rows returns empty lists without opening anything for write.
|
|
248
|
+
*
|
|
249
|
+
* @param projectRoot - Absolute project root.
|
|
250
|
+
* @param options - `dryRun` to report without writing; `cleoHome` to key with another home.
|
|
251
|
+
* @returns What was (or would be) migrated, what is current, and what must be re-entered.
|
|
252
|
+
* @throws {CredentialTransferError} `E_CREDENTIAL_PROJECT_ID` when credential
|
|
253
|
+
* rows exist but project-info.json has no `projectId`.
|
|
254
|
+
* @task T12326
|
|
255
|
+
*/
|
|
256
|
+
export declare function migrateProjectCredentialsAtRoot(projectRoot: string, options?: {
|
|
257
|
+
readonly dryRun?: boolean;
|
|
258
|
+
readonly cleoHome?: string;
|
|
259
|
+
}): Promise<ProjectRootCredentialMigration>;
|
|
260
|
+
/**
|
|
261
|
+
* Outcome of {@link auditAgentRegistryKeys}.
|
|
262
|
+
*
|
|
263
|
+
* @task T12352
|
|
264
|
+
*/
|
|
265
|
+
export interface AgentRegistryKeyAudit {
|
|
266
|
+
/** Global store examined. */
|
|
267
|
+
readonly globalDbPath: string;
|
|
268
|
+
/** Agents whose stored key decrypts to the real key. */
|
|
269
|
+
readonly current: readonly CredentialDescriptor[];
|
|
270
|
+
/** Agents whose real key is not recoverable, each with the re-register command. */
|
|
271
|
+
readonly reentry: readonly CredentialReentry[];
|
|
272
|
+
/** Rows newly flagged `requires_reauth = 1` (0 on a dry run). */
|
|
273
|
+
readonly flagged: number;
|
|
274
|
+
/** Whether this was a dry run. */
|
|
275
|
+
readonly dryRun: boolean;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Find agents whose stored API key cannot be recovered and, unless `dryRun`,
|
|
279
|
+
* flag them `requires_reauth = 1` (T12352).
|
|
280
|
+
*
|
|
281
|
+
* Before T12352 `api_key_encrypted` held a derived HMAC instead of the key.
|
|
282
|
+
* The real key was discarded, so those rows cannot be migrated, only flagged
|
|
283
|
+
* and listed with the command that re-registers the key. Never modifies the
|
|
284
|
+
* stored value; idempotent.
|
|
285
|
+
*
|
|
286
|
+
* @param globalDbPath - Global `cleo.db`.
|
|
287
|
+
* @param options - `dryRun` to report without flagging; `cleoHome` for the keys.
|
|
288
|
+
* @returns Recoverable agents, agents to re-register, and how many were flagged.
|
|
289
|
+
* @task T12352
|
|
290
|
+
*/
|
|
291
|
+
export declare function auditAgentRegistryKeys(globalDbPath: string, options?: {
|
|
292
|
+
readonly dryRun?: boolean;
|
|
293
|
+
readonly cleoHome?: string;
|
|
294
|
+
}): Promise<AgentRegistryKeyAudit>;
|
|
295
|
+
/**
|
|
296
|
+
* The live LLM pool path, re-exported so a bundle writer need not import the
|
|
297
|
+
* LLM module to fill {@link CredentialSources.llmStorePath}.
|
|
298
|
+
*
|
|
299
|
+
* @returns `<cleoHome>/llm-credentials.json`.
|
|
300
|
+
* @task T12326
|
|
301
|
+
*/
|
|
302
|
+
export declare function liveLlmCredentialStorePath(): string;
|
|
303
|
+
//# sourceMappingURL=credential-transfer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-transfer.d.ts","sourceRoot":"","sources":["../../src/store/credential-transfer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAMH,OAAO,KAAK,EACV,oBAAoB,EACpB,iBAAiB,EACjB,gCAAgC,EAChC,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,qBAAqB,CAAC;AA+B7B;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,sDAAsD;IACtD,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,yFAAyF;IACzF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,4FAA4F;IAC5F,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChD,qDAAqD;IACrD,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,mGAAmG;IACnG,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,sGAAsG;IACtG,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,kCAAkC;IAClC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,oFAAoF;IACpF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,iCAAiC;IACjC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;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