@qlairoslabs/acp-client 0.6.0 → 0.7.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.
Files changed (40) hide show
  1. package/CONSUMER_GUIDE.md +579 -292
  2. package/README.md +25 -0
  3. package/package.json +1 -1
  4. package/src/agent-session.ts +2188 -96
  5. package/src/cli/index.ts +33 -5
  6. package/src/cli/managed.ts +220 -0
  7. package/src/controller.ts +13 -0
  8. package/src/index.ts +228 -3
  9. package/src/metering/engine.ts +9 -1
  10. package/src/metering/record.ts +2 -1
  11. package/src/persistence/activity-projection.ts +71 -0
  12. package/src/persistence/audit-log-reader.ts +506 -0
  13. package/src/persistence/audit-runtime.ts +162 -0
  14. package/src/persistence/checkpoint.ts +304 -0
  15. package/src/persistence/config.ts +538 -0
  16. package/src/persistence/configuration-state.ts +191 -0
  17. package/src/persistence/deletion.ts +227 -0
  18. package/src/persistence/file-registry-store.ts +740 -0
  19. package/src/persistence/integrity.ts +147 -0
  20. package/src/persistence/legacy-registry-import.ts +240 -0
  21. package/src/persistence/managed-checkpoint.ts +81 -0
  22. package/src/persistence/managed-creation.ts +456 -0
  23. package/src/persistence/managed-load.ts +172 -0
  24. package/src/persistence/managed-registry.ts +57 -0
  25. package/src/persistence/migration.ts +298 -0
  26. package/src/persistence/paths.ts +172 -0
  27. package/src/persistence/projection.ts +373 -0
  28. package/src/persistence/reconfiguration.ts +453 -0
  29. package/src/persistence/records.ts +873 -0
  30. package/src/persistence/reducer.ts +498 -0
  31. package/src/persistence/registry.ts +446 -0
  32. package/src/persistence/restoration.ts +689 -0
  33. package/src/persistence/session-log-writer.ts +480 -0
  34. package/src/persistence/state-runtime.ts +176 -0
  35. package/src/persistence/transcript-reader.ts +980 -0
  36. package/src/persistence/transcript-runtime.ts +667 -0
  37. package/src/persistence/transcript-scanner.ts +385 -0
  38. package/src/persistence/truncation.ts +276 -0
  39. package/src/session-manager.ts +257 -7
  40. package/src/transcript.ts +3 -3
@@ -0,0 +1,538 @@
1
+ import { homedir } from "node:os";
2
+ import { isAbsolute, resolve } from "node:path";
3
+
4
+ export type TranscriptPreset = "conversation" | "activity" | "detailed" | "diagnostic";
5
+
6
+ export interface TranscriptCapturePolicy {
7
+ messages: "none" | "text";
8
+ reasoning: "none" | "text";
9
+ tools: "none" | "metadata" | "input" | "content";
10
+ lifecycle: boolean;
11
+ transitions: "none" | "metadata" | "content";
12
+ permissions: "none" | "decision" | "full";
13
+ usage: boolean;
14
+ configuration: "none" | "selections" | "definitions";
15
+ protocol: "none" | "metadata" | "raw";
16
+ }
17
+
18
+ export interface AuditLogCapturePolicy {
19
+ reasoning: TranscriptCapturePolicy["reasoning"];
20
+ tools: TranscriptCapturePolicy["tools"];
21
+ lifecycle: boolean;
22
+ transitions: "none" | "metadata";
23
+ permissions: TranscriptCapturePolicy["permissions"];
24
+ usage: boolean;
25
+ configuration: TranscriptCapturePolicy["configuration"];
26
+ }
27
+
28
+ export interface TranscriptConfig {
29
+ path?: string;
30
+ preset?: TranscriptPreset;
31
+ capture?: Partial<TranscriptCapturePolicy>;
32
+ includeTruncationDigests?: boolean;
33
+ }
34
+
35
+ export interface AuditLogConfig {
36
+ path?: string;
37
+ capture?: Partial<AuditLogCapturePolicy>;
38
+ includeTruncationDigests?: boolean;
39
+ }
40
+
41
+ export interface SessionConfigurationPersistenceConfig {
42
+ values?: "none" | "typed" | "all";
43
+ include?: readonly string[];
44
+ exclude?: readonly string[];
45
+ }
46
+
47
+ export interface PersistenceLimits {
48
+ maxRecordBytes: number;
49
+ maxCapturedFieldBytes: number;
50
+ maxJsonDepth: number;
51
+ maxCursorBytes: number;
52
+ }
53
+
54
+ export interface AgentSessionPersistenceOptions {
55
+ root?: string;
56
+ transcript?: false | TranscriptConfig;
57
+ auditLog?: false | AuditLogConfig;
58
+ sessionConfiguration?: SessionConfigurationPersistenceConfig;
59
+ limits?: Partial<PersistenceLimits>;
60
+ }
61
+
62
+ export type ManagedSessionPersistenceOptions = Omit<AgentSessionPersistenceOptions, "root">;
63
+
64
+ export interface SessionPersistenceConstraints {
65
+ transcript?: "optional" | "required" | "forbidden";
66
+ auditLog?: "optional" | "required" | "forbidden";
67
+ }
68
+
69
+ export interface ResolvedTranscriptConfig {
70
+ readonly path?: string;
71
+ readonly preset: TranscriptPreset;
72
+ readonly capture: Readonly<TranscriptCapturePolicy>;
73
+ readonly includeTruncationDigests: boolean;
74
+ }
75
+
76
+ export interface ResolvedAuditLogConfig {
77
+ readonly path?: string;
78
+ readonly capture: Readonly<AuditLogCapturePolicy>;
79
+ readonly includeTruncationDigests: boolean;
80
+ }
81
+
82
+ export interface ResolvedSessionConfigurationPersistence {
83
+ readonly values: "none" | "typed" | "all";
84
+ readonly include: readonly string[];
85
+ readonly exclude: readonly string[];
86
+ }
87
+
88
+ export interface ResolvedAgentSessionPersistence {
89
+ readonly root: string;
90
+ readonly transcript: false | ResolvedTranscriptConfig;
91
+ readonly auditLog: false | ResolvedAuditLogConfig;
92
+ readonly sessionConfiguration: ResolvedSessionConfigurationPersistence;
93
+ readonly limits: Readonly<PersistenceLimits>;
94
+ }
95
+
96
+ export class PersistenceConfigurationError extends Error {
97
+ constructor(message: string) {
98
+ super(message);
99
+ this.name = "PersistenceConfigurationError";
100
+ }
101
+ }
102
+
103
+ export const DEFAULT_PERSISTENCE_LIMITS: Readonly<PersistenceLimits> = Object.freeze({
104
+ maxRecordBytes: 1_048_576,
105
+ maxCapturedFieldBytes: 262_144,
106
+ maxJsonDepth: 64,
107
+ maxCursorBytes: 4_096,
108
+ });
109
+
110
+ export const TRANSCRIPT_PRESETS: Readonly<Record<TranscriptPreset, Readonly<TranscriptCapturePolicy>>> =
111
+ Object.freeze({
112
+ conversation: Object.freeze({
113
+ messages: "text",
114
+ reasoning: "none",
115
+ tools: "none",
116
+ lifecycle: false,
117
+ transitions: "metadata",
118
+ permissions: "none",
119
+ usage: false,
120
+ configuration: "none",
121
+ protocol: "none",
122
+ }),
123
+ activity: Object.freeze({
124
+ messages: "text",
125
+ reasoning: "none",
126
+ tools: "metadata",
127
+ lifecycle: true,
128
+ transitions: "metadata",
129
+ permissions: "decision",
130
+ usage: true,
131
+ configuration: "selections",
132
+ protocol: "none",
133
+ }),
134
+ detailed: Object.freeze({
135
+ messages: "text",
136
+ reasoning: "text",
137
+ tools: "content",
138
+ lifecycle: true,
139
+ transitions: "content",
140
+ permissions: "full",
141
+ usage: true,
142
+ configuration: "selections",
143
+ protocol: "none",
144
+ }),
145
+ diagnostic: Object.freeze({
146
+ messages: "text",
147
+ reasoning: "text",
148
+ tools: "content",
149
+ lifecycle: true,
150
+ transitions: "content",
151
+ permissions: "full",
152
+ usage: true,
153
+ configuration: "definitions",
154
+ protocol: "raw",
155
+ }),
156
+ });
157
+
158
+ export const DEFAULT_AUDIT_LOG_CAPTURE: Readonly<AuditLogCapturePolicy> = Object.freeze({
159
+ reasoning: "none",
160
+ tools: "input",
161
+ lifecycle: true,
162
+ transitions: "metadata",
163
+ permissions: "decision",
164
+ usage: true,
165
+ configuration: "selections",
166
+ });
167
+
168
+ const DEFAULT_SESSION_CONFIGURATION: Readonly<ResolvedSessionConfigurationPersistence> =
169
+ Object.freeze({ values: "typed", include: Object.freeze([]), exclude: Object.freeze([]) });
170
+
171
+ export interface PersistenceRootEnvironment {
172
+ readonly env?: Readonly<Record<string, string | undefined>>;
173
+ readonly home?: string;
174
+ readonly cwd?: string;
175
+ }
176
+
177
+ /** Resolve only the persistence root. Filesystem-dependent log-path resolution is separate. */
178
+ export function resolvePersistenceRoot(
179
+ explicitRoot?: string,
180
+ environment: PersistenceRootEnvironment = {},
181
+ ): string {
182
+ const env = environment.env ?? process.env;
183
+ const home = environment.home ?? homedir();
184
+ const cwd = environment.cwd ?? process.cwd();
185
+ const selected = explicitRoot ?? nonblank(env.ACP_CLIENT_HOME) ?? `${home}/.acp-client`;
186
+ if (!selected.trim()) throw new PersistenceConfigurationError("persistence root cannot be blank");
187
+
188
+ const expanded = selected === "~"
189
+ ? home
190
+ : selected.startsWith("~/")
191
+ ? `${home}/${selected.slice(2)}`
192
+ : selected;
193
+ if (expanded.startsWith("~")) {
194
+ throw new PersistenceConfigurationError("persistence root supports only ~ or ~/ expansion");
195
+ }
196
+ return isAbsolute(expanded) ? resolve(expanded) : resolve(cwd, expanded);
197
+ }
198
+
199
+ /** Direct sessions remain persistence-free unless this function receives an options object. */
200
+ export function resolveDirectPersistence(
201
+ options: false | AgentSessionPersistenceOptions | undefined,
202
+ environment: PersistenceRootEnvironment = {},
203
+ ): false | ResolvedAgentSessionPersistence {
204
+ if (options === false || options === undefined) return false;
205
+ return resolveLayers(resolvePersistenceRoot(options.root, environment), [options]);
206
+ }
207
+
208
+ export function resolveManagedPersistence(
209
+ root: string | undefined,
210
+ managerDefaults?: ManagedSessionPersistenceOptions,
211
+ sessionOptions?: ManagedSessionPersistenceOptions,
212
+ constraints: SessionPersistenceConstraints = {},
213
+ environment: PersistenceRootEnvironment = {},
214
+ ): ResolvedAgentSessionPersistence {
215
+ validateManagedLayer(managerDefaults, "sessionDefaults");
216
+ validateManagedLayer(sessionOptions, "session persistence");
217
+ const resolved = resolveLayers(
218
+ resolvePersistenceRoot(root, environment),
219
+ [managerDefaults, sessionOptions],
220
+ );
221
+ enforceConstraint("transcript", resolved.transcript !== false, constraints.transcript);
222
+ enforceConstraint("audit log", resolved.auditLog !== false, constraints.auditLog);
223
+ return resolved;
224
+ }
225
+
226
+ /** Validate an already-recorded session against manager policy without re-resolving it. */
227
+ export function enforceSessionPersistenceConstraints(
228
+ enabled: { readonly transcript: boolean; readonly auditLog: boolean },
229
+ constraints: SessionPersistenceConstraints,
230
+ ): void {
231
+ enforceConstraint("transcript", enabled.transcript, constraints.transcript);
232
+ enforceConstraint("audit log", enabled.auditLog, constraints.auditLog);
233
+ }
234
+
235
+ function validateManagedLayer(
236
+ value: ManagedSessionPersistenceOptions | undefined,
237
+ name: string,
238
+ ): void {
239
+ if (!value) return;
240
+ assertKnownKeys(name, value, ["transcript", "auditLog", "sessionConfiguration", "limits"]);
241
+ }
242
+
243
+ function resolveLayers(
244
+ root: string,
245
+ layers: readonly (ManagedSessionPersistenceOptions | AgentSessionPersistenceOptions | undefined)[],
246
+ ): ResolvedAgentSessionPersistence {
247
+ let transcript: false | ResolvedTranscriptConfig = defaultTranscript();
248
+ let auditLog: false | ResolvedAuditLogConfig = false;
249
+ let sessionConfiguration = cloneSessionConfiguration(DEFAULT_SESSION_CONFIGURATION);
250
+ let limits: PersistenceLimits = { ...DEFAULT_PERSISTENCE_LIMITS };
251
+
252
+ for (const layer of layers) {
253
+ if (!layer) continue;
254
+ assertKnownKeys("persistence", layer, [
255
+ "root",
256
+ "transcript",
257
+ "auditLog",
258
+ "sessionConfiguration",
259
+ "limits",
260
+ ]);
261
+ transcript = mergeTranscript(transcript, layer.transcript);
262
+ auditLog = mergeAuditLog(auditLog, layer.auditLog);
263
+ sessionConfiguration = mergeSessionConfiguration(
264
+ sessionConfiguration,
265
+ layer.sessionConfiguration,
266
+ );
267
+ if (layer.limits) {
268
+ assertKnownKeys("limits", layer.limits, [
269
+ "maxRecordBytes",
270
+ "maxCapturedFieldBytes",
271
+ "maxJsonDepth",
272
+ "maxCursorBytes",
273
+ ]);
274
+ limits = { ...limits, ...layer.limits };
275
+ }
276
+ }
277
+
278
+ validatePersistenceLimits(limits);
279
+ return Object.freeze({
280
+ root,
281
+ transcript: freezeTranscript(transcript),
282
+ auditLog: freezeAuditLog(auditLog),
283
+ sessionConfiguration: Object.freeze({
284
+ ...sessionConfiguration,
285
+ include: Object.freeze([...sessionConfiguration.include]),
286
+ exclude: Object.freeze([...sessionConfiguration.exclude]),
287
+ }),
288
+ limits: Object.freeze(limits),
289
+ });
290
+ }
291
+
292
+ function mergeTranscript(
293
+ current: false | ResolvedTranscriptConfig,
294
+ next: false | TranscriptConfig | undefined,
295
+ ): false | ResolvedTranscriptConfig {
296
+ if (next === undefined) return current;
297
+ if (next === false) return false;
298
+ assertKnownKeys("transcript", next, [
299
+ "path",
300
+ "preset",
301
+ "capture",
302
+ "includeTruncationDigests",
303
+ ]);
304
+ validateOptionalPath(next.path, "transcript.path");
305
+ validateOptionalBoolean(next.includeTruncationDigests, "transcript.includeTruncationDigests");
306
+ if (next.capture) {
307
+ assertKnownKeys("transcript.capture", next.capture, [
308
+ "messages",
309
+ "reasoning",
310
+ "tools",
311
+ "lifecycle",
312
+ "transitions",
313
+ "permissions",
314
+ "usage",
315
+ "configuration",
316
+ "protocol",
317
+ ]);
318
+ }
319
+
320
+ const inherited = current === false ? defaultTranscript() : current;
321
+ const preset = next.preset ?? inherited.preset;
322
+ const captureBase = next.preset ? presetCapture(next.preset) : inherited.capture;
323
+ const capture = { ...captureBase, ...next.capture };
324
+ validateTranscriptCapturePolicy(capture);
325
+ return {
326
+ ...(next.path !== undefined
327
+ ? { path: next.path }
328
+ : inherited.path !== undefined
329
+ ? { path: inherited.path }
330
+ : {}),
331
+ preset,
332
+ capture,
333
+ includeTruncationDigests:
334
+ next.includeTruncationDigests ?? inherited.includeTruncationDigests,
335
+ };
336
+ }
337
+
338
+ function mergeAuditLog(
339
+ current: false | ResolvedAuditLogConfig,
340
+ next: false | AuditLogConfig | undefined,
341
+ ): false | ResolvedAuditLogConfig {
342
+ if (next === undefined) return current;
343
+ if (next === false) return false;
344
+ assertKnownKeys("auditLog", next, ["path", "capture", "includeTruncationDigests"]);
345
+ validateOptionalPath(next.path, "auditLog.path");
346
+ validateOptionalBoolean(next.includeTruncationDigests, "auditLog.includeTruncationDigests");
347
+ if (next.capture) {
348
+ assertKnownKeys("auditLog.capture", next.capture, [
349
+ "reasoning",
350
+ "tools",
351
+ "lifecycle",
352
+ "transitions",
353
+ "permissions",
354
+ "usage",
355
+ "configuration",
356
+ ]);
357
+ }
358
+
359
+ const inherited = current === false ? defaultAuditLog() : current;
360
+ const capture = { ...inherited.capture, ...next.capture };
361
+ validateAuditLogCapturePolicy(capture);
362
+ return {
363
+ ...(next.path !== undefined
364
+ ? { path: next.path }
365
+ : inherited.path !== undefined
366
+ ? { path: inherited.path }
367
+ : {}),
368
+ capture,
369
+ includeTruncationDigests:
370
+ next.includeTruncationDigests ?? inherited.includeTruncationDigests,
371
+ };
372
+ }
373
+
374
+ function mergeSessionConfiguration(
375
+ current: ResolvedSessionConfigurationPersistence,
376
+ next: SessionConfigurationPersistenceConfig | undefined,
377
+ ): ResolvedSessionConfigurationPersistence {
378
+ if (!next) return current;
379
+ assertKnownKeys("sessionConfiguration", next, ["values", "include", "exclude"]);
380
+ if (next.values !== undefined && !["none", "typed", "all"].includes(next.values)) {
381
+ throw new PersistenceConfigurationError("sessionConfiguration.values is invalid");
382
+ }
383
+ const include = next.include === undefined ? current.include : validateIds(next.include, "include");
384
+ const exclude = next.exclude === undefined ? current.exclude : validateIds(next.exclude, "exclude");
385
+ return { values: next.values ?? current.values, include, exclude };
386
+ }
387
+
388
+ function defaultTranscript(): ResolvedTranscriptConfig {
389
+ return {
390
+ preset: "activity",
391
+ capture: { ...TRANSCRIPT_PRESETS.activity },
392
+ includeTruncationDigests: false,
393
+ };
394
+ }
395
+
396
+ function defaultAuditLog(): ResolvedAuditLogConfig {
397
+ return {
398
+ capture: { ...DEFAULT_AUDIT_LOG_CAPTURE },
399
+ includeTruncationDigests: false,
400
+ };
401
+ }
402
+
403
+ function presetCapture(preset: TranscriptPreset): TranscriptCapturePolicy {
404
+ const capture = TRANSCRIPT_PRESETS[preset];
405
+ if (!capture) throw new PersistenceConfigurationError(`unknown transcript preset: ${preset}`);
406
+ return { ...capture };
407
+ }
408
+
409
+ export function validatePersistenceLimits(limits: PersistenceLimits): void {
410
+ assertKnownKeys("limits", limits, [
411
+ "maxRecordBytes",
412
+ "maxCapturedFieldBytes",
413
+ "maxJsonDepth",
414
+ "maxCursorBytes",
415
+ ]);
416
+ validateIntegerRange("maxRecordBytes", limits.maxRecordBytes, 4_096, 16_777_216);
417
+ validateIntegerRange(
418
+ "maxCapturedFieldBytes",
419
+ limits.maxCapturedFieldBytes,
420
+ 1_024,
421
+ limits.maxRecordBytes,
422
+ );
423
+ validateIntegerRange("maxJsonDepth", limits.maxJsonDepth, 1, 128);
424
+ validateIntegerRange("maxCursorBytes", limits.maxCursorBytes, 256, 16_384);
425
+ }
426
+
427
+ function validateIntegerRange(name: string, value: number, min: number, max: number): void {
428
+ if (!Number.isSafeInteger(value) || value < min || value > max) {
429
+ throw new PersistenceConfigurationError(`${name} must be an integer from ${min} through ${max}`);
430
+ }
431
+ }
432
+
433
+ export function validateTranscriptCapturePolicy(value: TranscriptCapturePolicy): void {
434
+ assertKnownKeys("capture", value, [
435
+ "messages", "reasoning", "tools", "lifecycle", "transitions", "permissions",
436
+ "usage", "configuration", "protocol",
437
+ ]);
438
+ oneOf("capture.messages", value.messages, ["none", "text"]);
439
+ oneOf("capture.reasoning", value.reasoning, ["none", "text"]);
440
+ oneOf("capture.tools", value.tools, ["none", "metadata", "input", "content"]);
441
+ bool("capture.lifecycle", value.lifecycle);
442
+ oneOf("capture.transitions", value.transitions, ["none", "metadata", "content"]);
443
+ oneOf("capture.permissions", value.permissions, ["none", "decision", "full"]);
444
+ bool("capture.usage", value.usage);
445
+ oneOf("capture.configuration", value.configuration, ["none", "selections", "definitions"]);
446
+ oneOf("capture.protocol", value.protocol, ["none", "metadata", "raw"]);
447
+ }
448
+
449
+ export function validateAuditLogCapturePolicy(value: AuditLogCapturePolicy): void {
450
+ assertKnownKeys("auditLog.capture", value, [
451
+ "reasoning", "tools", "lifecycle", "transitions", "permissions", "usage",
452
+ "configuration",
453
+ ]);
454
+ oneOf("auditLog.capture.reasoning", value.reasoning, ["none", "text"]);
455
+ oneOf("auditLog.capture.tools", value.tools, ["none", "metadata", "input", "content"]);
456
+ bool("auditLog.capture.lifecycle", value.lifecycle);
457
+ oneOf("auditLog.capture.transitions", value.transitions, ["none", "metadata"]);
458
+ oneOf("auditLog.capture.permissions", value.permissions, ["none", "decision", "full"]);
459
+ bool("auditLog.capture.usage", value.usage);
460
+ oneOf("auditLog.capture.configuration", value.configuration, ["none", "selections", "definitions"]);
461
+ }
462
+
463
+ function oneOf(name: string, value: unknown, allowed: readonly unknown[]): void {
464
+ if (!allowed.includes(value)) {
465
+ throw new PersistenceConfigurationError(`${name} is invalid`);
466
+ }
467
+ }
468
+
469
+ function bool(name: string, value: unknown): void {
470
+ if (typeof value !== "boolean") throw new PersistenceConfigurationError(`${name} must be boolean`);
471
+ }
472
+
473
+ function validateOptionalPath(value: string | undefined, name: string): void {
474
+ if (value !== undefined && (typeof value !== "string" || !value.trim())) {
475
+ throw new PersistenceConfigurationError(`${name} cannot be blank`);
476
+ }
477
+ }
478
+
479
+ function validateOptionalBoolean(value: boolean | undefined, name: string): void {
480
+ if (value !== undefined && typeof value !== "boolean") {
481
+ throw new PersistenceConfigurationError(`${name} must be boolean`);
482
+ }
483
+ }
484
+
485
+ function assertKnownKeys(
486
+ name: string,
487
+ value: object,
488
+ allowed: readonly string[],
489
+ ): void {
490
+ const allowedSet = new Set(allowed);
491
+ const unknown = Object.keys(value).find((key) => !allowedSet.has(key));
492
+ if (unknown) throw new PersistenceConfigurationError(`${name}.${unknown} is not supported`);
493
+ }
494
+
495
+ function validateIds(values: readonly string[], name: string): readonly string[] {
496
+ if (!Array.isArray(values) || values.some((value) => typeof value !== "string" || !value.trim())) {
497
+ throw new PersistenceConfigurationError(`sessionConfiguration.${name} must contain nonblank IDs`);
498
+ }
499
+ return Object.freeze([...values]);
500
+ }
501
+
502
+ function enforceConstraint(
503
+ label: string,
504
+ enabled: boolean,
505
+ constraint: "optional" | "required" | "forbidden" | undefined,
506
+ ): void {
507
+ if (constraint !== undefined && !["optional", "required", "forbidden"].includes(constraint)) {
508
+ throw new PersistenceConfigurationError(`${label} constraint is invalid`);
509
+ }
510
+ if (constraint === "required" && !enabled) {
511
+ throw new PersistenceConfigurationError(`${label} persistence is required by the session manager`);
512
+ }
513
+ if (constraint === "forbidden" && enabled) {
514
+ throw new PersistenceConfigurationError(`${label} persistence is forbidden by the session manager`);
515
+ }
516
+ }
517
+
518
+ function cloneSessionConfiguration(
519
+ value: ResolvedSessionConfigurationPersistence,
520
+ ): ResolvedSessionConfigurationPersistence {
521
+ return { values: value.values, include: [...value.include], exclude: [...value.exclude] };
522
+ }
523
+
524
+ function freezeTranscript(
525
+ value: false | ResolvedTranscriptConfig,
526
+ ): false | ResolvedTranscriptConfig {
527
+ if (value === false) return false;
528
+ return Object.freeze({ ...value, capture: Object.freeze({ ...value.capture }) });
529
+ }
530
+
531
+ function freezeAuditLog(value: false | ResolvedAuditLogConfig): false | ResolvedAuditLogConfig {
532
+ if (value === false) return false;
533
+ return Object.freeze({ ...value, capture: Object.freeze({ ...value.capture }) });
534
+ }
535
+
536
+ function nonblank(value: string | undefined): string | undefined {
537
+ return value?.trim() ? value : undefined;
538
+ }