@tokentestai/ais 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.en.md +238 -0
- package/README.fr.md +238 -0
- package/README.ja.md +234 -0
- package/README.ko.md +234 -0
- package/README.md +234 -0
- package/dist/chunk-WVTDLVUU.js +1400 -0
- package/dist/chunk-WVTDLVUU.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +6145 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +547 -0
- package/dist/index.js +5784 -0
- package/dist/index.js.map +1 -0
- package/dist/postinstall.d.ts +27 -0
- package/dist/postinstall.js +54 -0
- package/dist/postinstall.js.map +1 -0
- package/package.json +62 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,547 @@
|
|
|
1
|
+
import { Readable, Writable } from 'node:stream';
|
|
2
|
+
|
|
3
|
+
interface PackageInfo {
|
|
4
|
+
name: string;
|
|
5
|
+
version: string;
|
|
6
|
+
}
|
|
7
|
+
declare function getPackageInfo(): PackageInfo;
|
|
8
|
+
declare const PACKAGE_NAME: string;
|
|
9
|
+
declare const VERSION: string;
|
|
10
|
+
|
|
11
|
+
declare const SECRET_TYPES: readonly ["PASSWORD", "APIKEY", "DBCONN", "PRIVATE_KEY", "BEARER_TOKEN", "JWT", "GENERIC"];
|
|
12
|
+
type SecretType = (typeof SECRET_TYPES)[number];
|
|
13
|
+
declare const SECRET_SOURCES: readonly ["manual", "argv", "stdin", "proxy"];
|
|
14
|
+
type SecretSource = (typeof SECRET_SOURCES)[number];
|
|
15
|
+
interface VaultEntry {
|
|
16
|
+
token: string;
|
|
17
|
+
secret: string;
|
|
18
|
+
type: SecretType;
|
|
19
|
+
createdAt: number;
|
|
20
|
+
hitCount: number;
|
|
21
|
+
name?: string;
|
|
22
|
+
source?: SecretSource;
|
|
23
|
+
}
|
|
24
|
+
type TokenGenerator = (secret: string, type: SecretType, sessionId: string) => string;
|
|
25
|
+
|
|
26
|
+
declare const DEFAULT_AIS_STATE_PATH_DISPLAY = "~/.ais/ais-state.json";
|
|
27
|
+
interface AisRecentRecord {
|
|
28
|
+
id: string;
|
|
29
|
+
createdAt: number;
|
|
30
|
+
lastSeenAt: number;
|
|
31
|
+
name?: string;
|
|
32
|
+
preview: string;
|
|
33
|
+
seenCount: number;
|
|
34
|
+
source: SecretSource;
|
|
35
|
+
type: SecretType;
|
|
36
|
+
}
|
|
37
|
+
interface AisState {
|
|
38
|
+
excludedRecordIds: string[];
|
|
39
|
+
excludedTypes: SecretType[];
|
|
40
|
+
recentRecords: AisRecentRecord[];
|
|
41
|
+
}
|
|
42
|
+
interface AisStoreOptions {
|
|
43
|
+
path?: string;
|
|
44
|
+
recentLimit?: number;
|
|
45
|
+
}
|
|
46
|
+
interface RecordSecretOptions {
|
|
47
|
+
name?: string;
|
|
48
|
+
source: SecretSource;
|
|
49
|
+
timestamp?: number;
|
|
50
|
+
}
|
|
51
|
+
declare function createDefaultAisState(): AisState;
|
|
52
|
+
declare function buildAisRecordId(secret: string): string;
|
|
53
|
+
declare function resolveAisStatePath(path?: string): string;
|
|
54
|
+
declare class AisStore {
|
|
55
|
+
private readonly options;
|
|
56
|
+
private dirty;
|
|
57
|
+
private loaded;
|
|
58
|
+
private state;
|
|
59
|
+
constructor(options?: AisStoreOptions);
|
|
60
|
+
load(): Promise<AisState>;
|
|
61
|
+
save(): Promise<void>;
|
|
62
|
+
getPath(): string;
|
|
63
|
+
getState(): AisState;
|
|
64
|
+
isExcluded(secret: string, type: SecretType): boolean;
|
|
65
|
+
recordSecret(secret: string, type: SecretType, options: RecordSecretOptions): AisRecentRecord;
|
|
66
|
+
setRecordExcluded(id: string, excluded: boolean): boolean;
|
|
67
|
+
setTypeExcluded(type: SecretType, excluded: boolean): void;
|
|
68
|
+
private assertLoaded;
|
|
69
|
+
private sortRecentRecords;
|
|
70
|
+
private trimRecentRecords;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
declare const PROTECT_TOOLS: readonly ["claude", "codex", "openclaw"];
|
|
74
|
+
declare const UPDATE_CHANNELS: readonly ["latest", "next"];
|
|
75
|
+
type ProtectTool = (typeof PROTECT_TOOLS)[number];
|
|
76
|
+
type UpdateChannel = (typeof UPDATE_CHANNELS)[number];
|
|
77
|
+
declare function isProtectTool(value: string): value is ProtectTool;
|
|
78
|
+
declare function isUpdateChannel(value: string): value is UpdateChannel;
|
|
79
|
+
|
|
80
|
+
declare const DEFAULT_AUTOMATION_STATE_PATH_DISPLAY = "~/.ais/automation-state.json";
|
|
81
|
+
type UpdateCheckResult = 'available' | 'failed' | 'never' | 'skipped' | 'up-to-date' | 'updated';
|
|
82
|
+
interface ProtectToolRuntimeState {
|
|
83
|
+
backupPath?: string;
|
|
84
|
+
installed: boolean;
|
|
85
|
+
lastChangedAt?: number;
|
|
86
|
+
lastError?: string;
|
|
87
|
+
managedPath?: string;
|
|
88
|
+
originalCommandPath?: string;
|
|
89
|
+
suspended: boolean;
|
|
90
|
+
}
|
|
91
|
+
interface AutomationState {
|
|
92
|
+
protect: {
|
|
93
|
+
tools: Record<ProtectTool, ProtectToolRuntimeState>;
|
|
94
|
+
};
|
|
95
|
+
update: {
|
|
96
|
+
lastChannel?: UpdateChannel;
|
|
97
|
+
lastCheckedAt?: number;
|
|
98
|
+
lastError?: string;
|
|
99
|
+
lastLocalVersion?: string;
|
|
100
|
+
lastRemoteVersion?: string;
|
|
101
|
+
lastResult: UpdateCheckResult;
|
|
102
|
+
skipNextCheck: boolean;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
interface LoadedAutomationState {
|
|
106
|
+
exists: boolean;
|
|
107
|
+
path: string;
|
|
108
|
+
recoveredFrom?: string;
|
|
109
|
+
recoveryReason?: string;
|
|
110
|
+
state: AutomationState;
|
|
111
|
+
}
|
|
112
|
+
declare function createDefaultAutomationState(): AutomationState;
|
|
113
|
+
declare function createDefaultProtectToolRuntimeState(): ProtectToolRuntimeState;
|
|
114
|
+
declare function resolveAutomationStatePath(path?: string): string;
|
|
115
|
+
declare function loadAutomationState(path?: string): Promise<LoadedAutomationState>;
|
|
116
|
+
declare function saveAutomationState(state: AutomationState, path?: string): Promise<void>;
|
|
117
|
+
declare function clearProtectRuntimeState(state: AutomationState, tool?: ProtectTool, now?: number): AutomationState;
|
|
118
|
+
declare function cloneAutomationState(state: AutomationState): AutomationState;
|
|
119
|
+
|
|
120
|
+
type DetectionConfidence = 'high' | 'medium' | 'low';
|
|
121
|
+
interface DetectedSecret {
|
|
122
|
+
value: string;
|
|
123
|
+
type: SecretType;
|
|
124
|
+
confidence: DetectionConfidence;
|
|
125
|
+
start: number;
|
|
126
|
+
end: number;
|
|
127
|
+
patternId: string;
|
|
128
|
+
}
|
|
129
|
+
interface SecretDetector {
|
|
130
|
+
detect(input: string): DetectedSecret[];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
interface PatternDefinition {
|
|
134
|
+
extractValue(match: RegExpMatchArray): string | null;
|
|
135
|
+
id: string;
|
|
136
|
+
type: SecretType;
|
|
137
|
+
expression: RegExp;
|
|
138
|
+
}
|
|
139
|
+
interface CustomPatternDefinition {
|
|
140
|
+
id: string;
|
|
141
|
+
regex: string;
|
|
142
|
+
type: SecretType;
|
|
143
|
+
}
|
|
144
|
+
interface PatternDetectorOptions {
|
|
145
|
+
customPatterns?: CustomPatternDefinition[];
|
|
146
|
+
}
|
|
147
|
+
declare const KNOWN_SECRET_PATTERNS: PatternDefinition[];
|
|
148
|
+
declare class PatternDetector implements SecretDetector {
|
|
149
|
+
private readonly patterns;
|
|
150
|
+
constructor(options?: PatternDetectorOptions);
|
|
151
|
+
detect(input: string): DetectedSecret[];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
interface CombinedDetectorOptions {
|
|
155
|
+
customPatterns?: CustomPatternDefinition[];
|
|
156
|
+
enablePattern?: boolean;
|
|
157
|
+
enableContext?: boolean;
|
|
158
|
+
enableEntropy?: boolean;
|
|
159
|
+
entropyThreshold?: number;
|
|
160
|
+
}
|
|
161
|
+
declare class CombinedDetector implements SecretDetector {
|
|
162
|
+
private readonly stages;
|
|
163
|
+
constructor(options?: CombinedDetectorOptions);
|
|
164
|
+
detect(input: string): DetectedSecret[];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
declare class ContextDetector implements SecretDetector {
|
|
168
|
+
detect(input: string): DetectedSecret[];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
interface EntropyDetectorOptions {
|
|
172
|
+
threshold?: number;
|
|
173
|
+
}
|
|
174
|
+
declare function calculateShannonEntropy(value: string): number;
|
|
175
|
+
declare class EntropyDetector implements SecretDetector {
|
|
176
|
+
private readonly options;
|
|
177
|
+
constructor(options?: EntropyDetectorOptions);
|
|
178
|
+
detect(input: string): DetectedSecret[];
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
interface PtyWrapperOptions {
|
|
182
|
+
flushStdinData?: () => string;
|
|
183
|
+
flushStdoutData?: () => string;
|
|
184
|
+
onStdinData?: (data: string) => string;
|
|
185
|
+
onStdoutData?: (data: string) => string;
|
|
186
|
+
stdin?: Readable & {
|
|
187
|
+
isRaw?: boolean;
|
|
188
|
+
isTTY?: boolean;
|
|
189
|
+
setRawMode?: (mode: boolean) => void;
|
|
190
|
+
};
|
|
191
|
+
stdout?: Writable & {
|
|
192
|
+
columns?: number;
|
|
193
|
+
isTTY?: boolean;
|
|
194
|
+
rows?: number;
|
|
195
|
+
};
|
|
196
|
+
cwd?: string;
|
|
197
|
+
env?: NodeJS.ProcessEnv;
|
|
198
|
+
}
|
|
199
|
+
declare function runPtyCommand(command: string, args: string[], options?: PtyWrapperOptions): Promise<number>;
|
|
200
|
+
declare function createPtyWrapper(command: string, args: string[], options?: PtyWrapperOptions): Promise<void>;
|
|
201
|
+
|
|
202
|
+
type ProxyProvider = 'anthropic' | 'openai';
|
|
203
|
+
type ProxyTargets = Record<ProxyProvider, string>;
|
|
204
|
+
|
|
205
|
+
declare const DEFAULT_TARGETS: ProxyTargets;
|
|
206
|
+
declare function getDefaultProxyTargets(env?: NodeJS.ProcessEnv): ProxyTargets;
|
|
207
|
+
declare function buildProxyEnvironment(proxyBaseUrl: string, env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
208
|
+
|
|
209
|
+
declare const TOKEN_REGEX: RegExp;
|
|
210
|
+
declare const TOKEN_MAX_LENGTH: number;
|
|
211
|
+
interface SessionVaultOptions {
|
|
212
|
+
sessionId?: string;
|
|
213
|
+
tokenGenerator?: TokenGenerator;
|
|
214
|
+
}
|
|
215
|
+
interface RegisterSecretOptions {
|
|
216
|
+
createdAt?: number;
|
|
217
|
+
hitCount?: number;
|
|
218
|
+
name?: string;
|
|
219
|
+
source?: SecretSource;
|
|
220
|
+
token?: string;
|
|
221
|
+
}
|
|
222
|
+
declare function generateToken(secret: string, type: SecretType, sessionId: string): string;
|
|
223
|
+
declare class SessionVault {
|
|
224
|
+
private readonly nameToSecret;
|
|
225
|
+
private revisionNumber;
|
|
226
|
+
private readonly secretToEntry;
|
|
227
|
+
private readonly tokenToEntry;
|
|
228
|
+
private readonly sessionId;
|
|
229
|
+
private readonly tokenGenerator;
|
|
230
|
+
constructor(options?: SessionVaultOptions);
|
|
231
|
+
get size(): number;
|
|
232
|
+
get revision(): number;
|
|
233
|
+
register(secret: string, type: SecretType, options?: RegisterSecretOptions): string;
|
|
234
|
+
findByName(name: string): VaultEntry | null;
|
|
235
|
+
resolve(token: string): string | null;
|
|
236
|
+
getSecretToTokenPairs(): Array<[string, string]>;
|
|
237
|
+
snapshot(): VaultEntry[];
|
|
238
|
+
removeByName(name: string): VaultEntry | null;
|
|
239
|
+
getTokenToSecretPairs(): Array<[string, string]>;
|
|
240
|
+
isToken(value: string): boolean;
|
|
241
|
+
destroy(): void;
|
|
242
|
+
private removeBySecret;
|
|
243
|
+
private updateExistingEntry;
|
|
244
|
+
private assertNameAvailable;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
interface ProxyOptions {
|
|
248
|
+
captureDir?: string;
|
|
249
|
+
defaultProvider?: ProxyProvider;
|
|
250
|
+
host?: string;
|
|
251
|
+
maxPortAttempts?: number;
|
|
252
|
+
onRequestText?: (body: string) => void;
|
|
253
|
+
port?: number;
|
|
254
|
+
publicHost?: string;
|
|
255
|
+
targetBaseUrl?: string;
|
|
256
|
+
targets?: Partial<ProxyTargets>;
|
|
257
|
+
timeoutMs?: number;
|
|
258
|
+
vault: SessionVault;
|
|
259
|
+
}
|
|
260
|
+
declare class ProxyServer {
|
|
261
|
+
private readonly options;
|
|
262
|
+
private activePort;
|
|
263
|
+
private readonly activeUpgradeSockets;
|
|
264
|
+
private readonly captureDir?;
|
|
265
|
+
private readonly defaultProvider?;
|
|
266
|
+
private readonly host;
|
|
267
|
+
private readonly maxPortAttempts;
|
|
268
|
+
private readonly port;
|
|
269
|
+
private readonly publicHost;
|
|
270
|
+
private readonly responsesCompatibilityStore;
|
|
271
|
+
private server;
|
|
272
|
+
private readonly targets;
|
|
273
|
+
private readonly timeoutMs;
|
|
274
|
+
constructor(options: ProxyOptions);
|
|
275
|
+
getBaseUrl(): string;
|
|
276
|
+
start(): Promise<number>;
|
|
277
|
+
stop(): Promise<void>;
|
|
278
|
+
private handleUpgrade;
|
|
279
|
+
private handleRequest;
|
|
280
|
+
private handleResponsesCompatibilityRead;
|
|
281
|
+
private forwardResponsesRequestWithFallback;
|
|
282
|
+
private forwardTranslatedResponsesCompatibilityRequest;
|
|
283
|
+
private forwardResponsesCompatibilityResponse;
|
|
284
|
+
private forwardUpgradeFallbackResponse;
|
|
285
|
+
private sendUpgradeError;
|
|
286
|
+
private trackUpgradeSocket;
|
|
287
|
+
private forwardRequest;
|
|
288
|
+
private forwardResponse;
|
|
289
|
+
private inspectAndMaskTextBody;
|
|
290
|
+
private writeResponsesCompatibilityCapture;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
declare const DEFAULT_VAULT_PATH: string;
|
|
294
|
+
declare class EncryptedVault {
|
|
295
|
+
static exists(path?: string): boolean;
|
|
296
|
+
static save(data: Record<string, VaultEntry>, password: string, path?: string): Promise<void>;
|
|
297
|
+
static load(password: string, path?: string): Promise<Record<string, VaultEntry>>;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
interface KeychainModule {
|
|
301
|
+
deletePassword(service: string, account: string): Promise<boolean>;
|
|
302
|
+
getPassword(service: string, account: string): Promise<string | null>;
|
|
303
|
+
setPassword(service: string, account: string, password: string): Promise<void>;
|
|
304
|
+
}
|
|
305
|
+
type KeychainModuleLoader = () => Promise<KeychainModule | {
|
|
306
|
+
default: KeychainModule;
|
|
307
|
+
}>;
|
|
308
|
+
declare function setKeychainModuleLoaderForTesting(loader: KeychainModuleLoader): void;
|
|
309
|
+
declare function resetKeychainModuleLoaderForTesting(): void;
|
|
310
|
+
declare class KeychainStore {
|
|
311
|
+
static readonly SERVICE = "ais";
|
|
312
|
+
private static readonly ACCOUNT;
|
|
313
|
+
static setVaultPassword(password: string): Promise<void>;
|
|
314
|
+
static getVaultPassword(): Promise<string | null>;
|
|
315
|
+
static deleteVaultPassword(): Promise<void>;
|
|
316
|
+
static isAvailable(): Promise<boolean>;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
interface KeychainStoreLike {
|
|
320
|
+
getVaultPassword(): Promise<string | null>;
|
|
321
|
+
isAvailable(): Promise<boolean>;
|
|
322
|
+
setVaultPassword(password: string): Promise<void>;
|
|
323
|
+
}
|
|
324
|
+
interface StorageManagerOptions {
|
|
325
|
+
env?: NodeJS.ProcessEnv;
|
|
326
|
+
keychain?: KeychainStoreLike;
|
|
327
|
+
persistDetectedSecrets?: boolean;
|
|
328
|
+
vaultOptions?: SessionVaultOptions;
|
|
329
|
+
vaultPassword?: string;
|
|
330
|
+
vaultPath?: string;
|
|
331
|
+
}
|
|
332
|
+
declare class StorageManager {
|
|
333
|
+
private readonly options;
|
|
334
|
+
private cachedPassword;
|
|
335
|
+
private readonly env;
|
|
336
|
+
private readonly keychain;
|
|
337
|
+
constructor(options?: StorageManagerOptions);
|
|
338
|
+
initialize(): Promise<SessionVault>;
|
|
339
|
+
save(vault: SessionVault): Promise<void>;
|
|
340
|
+
setup(): Promise<boolean>;
|
|
341
|
+
getVaultPath(): string;
|
|
342
|
+
private getReadablePassword;
|
|
343
|
+
private getWritablePassword;
|
|
344
|
+
private getDirectPassword;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
interface RegisterSecretValueOptions {
|
|
348
|
+
name?: string;
|
|
349
|
+
}
|
|
350
|
+
interface AisStats {
|
|
351
|
+
detectedSecrets: number;
|
|
352
|
+
maskedInputs: number;
|
|
353
|
+
proxyEnabled: boolean;
|
|
354
|
+
proxyPort: number | null;
|
|
355
|
+
registeredSecrets: number;
|
|
356
|
+
restoredOutputs: number;
|
|
357
|
+
}
|
|
358
|
+
interface AisRuntimeOptions {
|
|
359
|
+
ais?: (AisStoreOptions & {
|
|
360
|
+
store?: AisStore;
|
|
361
|
+
}) | false;
|
|
362
|
+
automation?: {
|
|
363
|
+
path: string;
|
|
364
|
+
protect: {
|
|
365
|
+
enabled: boolean;
|
|
366
|
+
tools: Record<ProtectTool, boolean>;
|
|
367
|
+
};
|
|
368
|
+
state: AutomationState;
|
|
369
|
+
update: {
|
|
370
|
+
channel: UpdateChannel;
|
|
371
|
+
checkIntervalMinutes: number;
|
|
372
|
+
enabled: boolean;
|
|
373
|
+
silent: boolean;
|
|
374
|
+
skipCheck: boolean;
|
|
375
|
+
};
|
|
376
|
+
};
|
|
377
|
+
cwd?: string;
|
|
378
|
+
debug?: boolean;
|
|
379
|
+
detectionWindow?: number;
|
|
380
|
+
detector?: CombinedDetectorOptions;
|
|
381
|
+
dryRun?: boolean;
|
|
382
|
+
env?: NodeJS.ProcessEnv;
|
|
383
|
+
logFile?: string;
|
|
384
|
+
proxy?: Omit<ProxyOptions, 'vault'>;
|
|
385
|
+
storage?: (StorageManagerOptions & {
|
|
386
|
+
manager?: StorageManager;
|
|
387
|
+
}) | false;
|
|
388
|
+
stdin?: PtyWrapperOptions['stdin'];
|
|
389
|
+
stdout?: PtyWrapperOptions['stdout'];
|
|
390
|
+
vault?: SessionVaultOptions;
|
|
391
|
+
}
|
|
392
|
+
declare function stripVaultArtifacts(input: string): string;
|
|
393
|
+
declare class AisRuntime {
|
|
394
|
+
private readonly options;
|
|
395
|
+
private readonly argvDetector;
|
|
396
|
+
private readonly detector;
|
|
397
|
+
private readonly detectionBuffers;
|
|
398
|
+
private readonly aisStore?;
|
|
399
|
+
private readonly interceptor;
|
|
400
|
+
private proxyPort;
|
|
401
|
+
private readonly proxy;
|
|
402
|
+
private readonly storageManager?;
|
|
403
|
+
private storageLoaded;
|
|
404
|
+
private readonly stdoutRestorer;
|
|
405
|
+
private readonly vault;
|
|
406
|
+
private readonly stats;
|
|
407
|
+
private running;
|
|
408
|
+
constructor(options?: AisRuntimeOptions);
|
|
409
|
+
start(command: string, args: string[]): Promise<void>;
|
|
410
|
+
registerSecret(secret: string, type?: SecretType, options?: RegisterSecretValueOptions): string;
|
|
411
|
+
getStats(): AisStats;
|
|
412
|
+
private debug;
|
|
413
|
+
private warn;
|
|
414
|
+
private writeMessage;
|
|
415
|
+
private loadStoredSecrets;
|
|
416
|
+
private loadAisState;
|
|
417
|
+
private detectSecrets;
|
|
418
|
+
private flushStdin;
|
|
419
|
+
private flushStdout;
|
|
420
|
+
private handleStdin;
|
|
421
|
+
private handleStdout;
|
|
422
|
+
private handleProxyRequestText;
|
|
423
|
+
private prepareArgs;
|
|
424
|
+
private registerSecretValue;
|
|
425
|
+
private resetDetectionBuffers;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
declare const DEFAULT_CONFIG_PATH: string;
|
|
429
|
+
declare const DEFAULT_VAULT_PATH_DISPLAY = "~/.ais/vault.enc";
|
|
430
|
+
interface CustomPatternConfig {
|
|
431
|
+
id: string;
|
|
432
|
+
regex: string;
|
|
433
|
+
type: SecretType;
|
|
434
|
+
}
|
|
435
|
+
interface AisConfig {
|
|
436
|
+
ais: {
|
|
437
|
+
recentLimit: number;
|
|
438
|
+
statePath: string;
|
|
439
|
+
};
|
|
440
|
+
automation: {
|
|
441
|
+
statePath: string;
|
|
442
|
+
};
|
|
443
|
+
customPatterns: CustomPatternConfig[];
|
|
444
|
+
detection: {
|
|
445
|
+
context: boolean;
|
|
446
|
+
entropy: boolean;
|
|
447
|
+
entropyThreshold: number;
|
|
448
|
+
patterns: boolean;
|
|
449
|
+
};
|
|
450
|
+
display: {
|
|
451
|
+
debug: boolean;
|
|
452
|
+
};
|
|
453
|
+
protect: {
|
|
454
|
+
enabled: boolean;
|
|
455
|
+
tools: {
|
|
456
|
+
claude: boolean;
|
|
457
|
+
codex: boolean;
|
|
458
|
+
openclaw: boolean;
|
|
459
|
+
};
|
|
460
|
+
};
|
|
461
|
+
storage: {
|
|
462
|
+
persistSecrets: boolean;
|
|
463
|
+
vaultPath: string;
|
|
464
|
+
};
|
|
465
|
+
update: {
|
|
466
|
+
channel: UpdateChannel;
|
|
467
|
+
checkIntervalMinutes: number;
|
|
468
|
+
enabled: boolean;
|
|
469
|
+
silent: boolean;
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
interface LoadedConfig {
|
|
473
|
+
config: AisConfig;
|
|
474
|
+
exists: boolean;
|
|
475
|
+
path: string;
|
|
476
|
+
}
|
|
477
|
+
declare function createDefaultConfig(): AisConfig;
|
|
478
|
+
declare function expandHomePath(path: string): string;
|
|
479
|
+
declare function resolveConfigPath(path?: string): string;
|
|
480
|
+
declare function loadConfig(path?: string): Promise<LoadedConfig>;
|
|
481
|
+
declare function saveConfig(config: AisConfig, path?: string): Promise<void>;
|
|
482
|
+
|
|
483
|
+
interface BidirectionalFlushResult {
|
|
484
|
+
apiResponse: string;
|
|
485
|
+
input: string;
|
|
486
|
+
output: string;
|
|
487
|
+
}
|
|
488
|
+
declare class BidirectionalInterceptor {
|
|
489
|
+
private readonly vault;
|
|
490
|
+
private readonly apiResponseReplacer;
|
|
491
|
+
private readonly inputReplacer;
|
|
492
|
+
private readonly outputReplacer;
|
|
493
|
+
private syncedRevision;
|
|
494
|
+
constructor(vault: SessionVault);
|
|
495
|
+
processInput(chunk: string): string;
|
|
496
|
+
processOutput(chunk: string): string;
|
|
497
|
+
processApiResponse(chunk: string): string;
|
|
498
|
+
flush(): BidirectionalFlushResult;
|
|
499
|
+
updateRules(): void;
|
|
500
|
+
private syncRules;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
declare class StreamReplacer {
|
|
504
|
+
private buffer;
|
|
505
|
+
private matcher;
|
|
506
|
+
private maxPatternLen;
|
|
507
|
+
private prefixes;
|
|
508
|
+
constructor(replacements: Map<string, string>);
|
|
509
|
+
push(chunk: string): string;
|
|
510
|
+
flush(): string;
|
|
511
|
+
updateRules(replacements: Map<string, string>): void;
|
|
512
|
+
private getLookbehindLength;
|
|
513
|
+
private getSafeLimit;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
interface ProtectShellCommandResult {
|
|
517
|
+
exitCode: number;
|
|
518
|
+
stderr: string;
|
|
519
|
+
stdout: string;
|
|
520
|
+
}
|
|
521
|
+
type ProtectShellRunner = (command: string, args: string[], options: {
|
|
522
|
+
env?: NodeJS.ProcessEnv;
|
|
523
|
+
}) => Promise<ProtectShellCommandResult>;
|
|
524
|
+
interface ProtectRuntimeOptions {
|
|
525
|
+
aisCliPath?: string;
|
|
526
|
+
env?: NodeJS.ProcessEnv;
|
|
527
|
+
homeDir?: string;
|
|
528
|
+
nodePath?: string;
|
|
529
|
+
now?: () => number;
|
|
530
|
+
shellPath?: string;
|
|
531
|
+
shellRunner?: ProtectShellRunner;
|
|
532
|
+
}
|
|
533
|
+
interface ProtectSyncResult {
|
|
534
|
+
changed: boolean;
|
|
535
|
+
errors: string[];
|
|
536
|
+
state: AutomationState;
|
|
537
|
+
warnings: string[];
|
|
538
|
+
}
|
|
539
|
+
interface ProtectRestoreResult extends ProtectSyncResult {
|
|
540
|
+
config: AisConfig;
|
|
541
|
+
}
|
|
542
|
+
declare function syncProtectRuntime(config: AisConfig, state: AutomationState, options?: ProtectRuntimeOptions): Promise<ProtectSyncResult>;
|
|
543
|
+
declare function refreshProtectRuntime(state: AutomationState, options?: ProtectRuntimeOptions): Promise<ProtectSyncResult>;
|
|
544
|
+
declare function restoreProtectRuntime(config: AisConfig, state: AutomationState, options?: ProtectRuntimeOptions): Promise<ProtectRestoreResult>;
|
|
545
|
+
declare function resolveProtectedCommand(command: string, env?: NodeJS.ProcessEnv, options?: Pick<ProtectRuntimeOptions, 'homeDir'>): Promise<string>;
|
|
546
|
+
|
|
547
|
+
export { type AisConfig, type AisRecentRecord, AisRuntime, type AisRuntimeOptions, type AisState, type AisStats, AisStore, type AisStoreOptions, type AutomationState, type BidirectionalFlushResult, BidirectionalInterceptor, CombinedDetector, type CombinedDetectorOptions, ContextDetector, type CustomPatternConfig, type CustomPatternDefinition, DEFAULT_AIS_STATE_PATH_DISPLAY, DEFAULT_AUTOMATION_STATE_PATH_DISPLAY, DEFAULT_CONFIG_PATH, DEFAULT_TARGETS as DEFAULT_PROXY_TARGETS, DEFAULT_VAULT_PATH, DEFAULT_VAULT_PATH_DISPLAY, type DetectedSecret, type DetectionConfidence, EncryptedVault, EntropyDetector, type EntropyDetectorOptions, KNOWN_SECRET_PATTERNS, KeychainStore, type LoadedAutomationState, type LoadedConfig, PACKAGE_NAME, PROTECT_TOOLS, PatternDetector, type PatternDetectorOptions, type ProtectRestoreResult, type ProtectRuntimeOptions, type ProtectShellCommandResult, type ProtectShellRunner, type ProtectSyncResult, type ProtectTool, type ProtectToolRuntimeState, type ProxyOptions, type ProxyProvider, ProxyServer, type ProxyTargets, type PtyWrapperOptions, type RecordSecretOptions, type RegisterSecretOptions, type RegisterSecretValueOptions, type SecretDetector, type SecretSource, type SecretType, SessionVault, type SessionVaultOptions, StorageManager, type StorageManagerOptions, StreamReplacer, TOKEN_MAX_LENGTH, TOKEN_REGEX, type TokenGenerator, UPDATE_CHANNELS, type UpdateChannel, type UpdateCheckResult, VERSION, type VaultEntry, buildAisRecordId, buildProxyEnvironment, calculateShannonEntropy, clearProtectRuntimeState, cloneAutomationState, createDefaultAisState, createDefaultAutomationState, createDefaultConfig, createDefaultProtectToolRuntimeState, createPtyWrapper, expandHomePath, generateToken, getDefaultProxyTargets, getPackageInfo, isProtectTool, isUpdateChannel, loadAutomationState, loadConfig, refreshProtectRuntime, resetKeychainModuleLoaderForTesting, resolveAisStatePath, resolveAutomationStatePath, resolveConfigPath, resolveProtectedCommand, restoreProtectRuntime, runPtyCommand, saveAutomationState, saveConfig, setKeychainModuleLoaderForTesting, stripVaultArtifacts, syncProtectRuntime };
|