@omnicross/daemon 0.4.3 → 0.4.4
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/cli.cjs +68 -13
- package/dist/cli.js +68 -13
- package/dist/index.cjs +68 -13
- package/dist/index.d.cts +1466 -1440
- package/dist/index.d.ts +1466 -1440
- package/dist/index.js +68 -13
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Logger, OutboundApiServerConfig, ProviderConfigSource, TransformerService, Transformer, ResolvedTransformerChain, ApiServerSettingsStore, PricingStore, AutomaticPricingSource, OutboundPermission, OutboundKeyDb, OutboundKeyDbRow, OutboundKeyPolicy, PricingEngine as PricingEngine$1, OpenAIOperationRegistry } from '@omnicross/core';
|
|
2
2
|
import { SearchRuntime, SearchFrontendModes } from '@omnicross/core/search';
|
|
3
3
|
import { ApiKeyPoolService } from '@omnicross/core/completion/ApiKeyPoolService';
|
|
4
|
-
import { AllowanceSchedulingConfig, AccountProbeConfig, ImageProviderId, OutboundKeyDb as OutboundKeyDb$1, VoucherDb, KeySpendReader, OutboundApiServer
|
|
4
|
+
import { AllowanceSchedulingConfig, AccountProbeConfig, ImagesServerConfig, ImageProviderId, OutboundKeyDb as OutboundKeyDb$1, VoucherDb, KeySpendReader, OutboundApiServer } from '@omnicross/core/outbound-api';
|
|
5
5
|
import { RouteLeaseManager, ProviderProxy } from '@omnicross/core/provider-proxy';
|
|
6
6
|
import { UsageRecorder, PricingEngine } from '@omnicross/core/usage';
|
|
7
7
|
import { SubscriptionCredentialStore, FetchLike, CodexImageCapabilityEvidenceSource, CodexImageCapabilityEvidenceRequest, CodexImageCapabilityEvidence, CodexImageCapabilityObservation, ImageExecutionScheduler, ImageExecutionAccountKey, ImageExecutionSchedulerRequest, ImageExecutionSchedulerGrant, SubscriptionAccountService, SubscriptionProviderRegistry } from '@omnicross/subscriptions';
|
|
@@ -21,8 +21,8 @@ import { AuditRecord, AuditStats, AuditBodyResult, AuditConfig } from '@omnicros
|
|
|
21
21
|
import { BillingDeliveryStatus, BillingConfig, BillingEvent } from '@omnicross/contracts/billing-types';
|
|
22
22
|
import http from 'node:http';
|
|
23
23
|
import * as _omnicross_contracts_image_generation_types from '@omnicross/contracts/image-generation-types';
|
|
24
|
-
import {
|
|
25
|
-
import { ImageApiContributions, ResponsesImageGenerationContribution, ResponsesImageInspectionInput, ResponsesImageAdmission, ResponsesHostedToolSelection, ResponsesImageRequestScope, ImageTelemetrySink, ImageApiAuditRecord, ImageTelemetryRecord,
|
|
24
|
+
import { ImageReferenceMetadata, ImageReferenceId, ImageGenerationErrorCode, ImageCapabilityUnavailableReason, ImageCapabilities } from '@omnicross/contracts/image-generation-types';
|
|
25
|
+
import { ImageReferenceStore, ImageReferenceSaveInput, ImageReferenceResolution, ImageApiContributions, ResponsesImageGenerationContribution, ResponsesImageInspectionInput, ResponsesImageAdmission, ResponsesHostedToolSelection, ResponsesImageRequestScope, ImageTelemetrySink, ImageApiAuditRecord, ImageTelemetryRecord, ImageTemporaryResourceBudget, ImageTemporaryResourceBudgetLease, ImageApiLimits, ImageRequestResourceScope, ImageApiRuntimeResolver, RemoteImageAssetResolver, ImageProvider, ImageProviderRegistry, ImageOrchestrator } from '@omnicross/core/image-generation';
|
|
26
26
|
import { LLMProvider, AgentDefaultModels, GlobalModelParameters } from '@omnicross/contracts/llm-config';
|
|
27
27
|
import { PricingEntry, PricingEntryInput, PricingResolution, PricingSourceRefreshResult } from '@omnicross/contracts/pricing-types';
|
|
28
28
|
import { ResponsesImageStateStore, ResponsesImageStateCommitInput, ResponsesImageCallBinding, ResponsesImageCallId, ResponsesImageCallResolution, ResponsesImageResponseResolution } from '@omnicross/core/image-generation/responses';
|
|
@@ -2325,1551 +2325,1575 @@ interface ProviderKeyQuota {
|
|
|
2325
2325
|
errorCode?: string;
|
|
2326
2326
|
}
|
|
2327
2327
|
|
|
2328
|
-
type
|
|
2329
|
-
|
|
2330
|
-
readonly
|
|
2331
|
-
readonly
|
|
2332
|
-
readonly
|
|
2333
|
-
readonly
|
|
2334
|
-
readonly
|
|
2335
|
-
readonly
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
readonly
|
|
2339
|
-
readonly enabled: false;
|
|
2340
|
-
dispose(): void | Promise<void>;
|
|
2341
|
-
};
|
|
2342
|
-
interface HostedImageRuntimeGenerationLease {
|
|
2343
|
-
readonly generationId: string;
|
|
2344
|
-
/** Compatibility/debug view; callers should prefer the deep methods below. */
|
|
2345
|
-
readonly contribution: ResponsesImageGenerationContribution;
|
|
2346
|
-
inspectRequest(input: ResponsesImageInspectionInput): ResponsesImageAdmission;
|
|
2347
|
-
validateSelection(admission: ResponsesImageAdmission, selection: ResponsesHostedToolSelection): void;
|
|
2348
|
-
openRequest(input: HostedImageOpenRequestInput): Promise<ResponsesImageRequestScope>;
|
|
2349
|
-
release(): Promise<void>;
|
|
2350
|
-
}
|
|
2351
|
-
interface HostedImageRuntimePolicy {
|
|
2352
|
-
readonly providerId: string;
|
|
2353
|
-
readonly imageModel: string;
|
|
2354
|
-
readonly referenceTtlMs: number;
|
|
2355
|
-
readonly maxOutputBytes: number;
|
|
2356
|
-
readonly maxTotalOutputBytes: number;
|
|
2357
|
-
readonly preferredAccountId?: string;
|
|
2358
|
-
readonly preferredAccountGroup?: string;
|
|
2359
|
-
readonly boundAccountFallbackPolicy?: 'strict' | 'pool';
|
|
2328
|
+
type DaemonImagePathArea = 'temporary' | 'artifacts' | 'state' | 'evidence' | 'mountManifest';
|
|
2329
|
+
interface DaemonImagePaths {
|
|
2330
|
+
readonly applicationDataRoot: string;
|
|
2331
|
+
readonly imagesRoot: string;
|
|
2332
|
+
readonly temporaryRoot: string;
|
|
2333
|
+
readonly durableRoot: string;
|
|
2334
|
+
readonly artifactsRoot: string;
|
|
2335
|
+
readonly stateRoot: string;
|
|
2336
|
+
readonly evidenceRoot: string;
|
|
2337
|
+
readonly mountManifestRoot: string;
|
|
2338
|
+
readonly mountManifestPath: string;
|
|
2360
2339
|
}
|
|
2361
|
-
interface
|
|
2362
|
-
readonly
|
|
2363
|
-
readonly
|
|
2364
|
-
readonly
|
|
2365
|
-
readonly
|
|
2366
|
-
readonly signal: AbortSignal;
|
|
2367
|
-
readonly authorizedPreviousResponseId?: string;
|
|
2368
|
-
/** Trusted affinity fact forwarded unchanged into the contribution scope. */
|
|
2369
|
-
readonly authorizedPreviousResponseKnownEmpty?: boolean;
|
|
2370
|
-
readonly mainProviderId: string;
|
|
2371
|
-
readonly selectedMainAccountId?: string;
|
|
2340
|
+
interface ImageRootValidationOptions {
|
|
2341
|
+
readonly label?: string;
|
|
2342
|
+
readonly processDirectory?: string;
|
|
2343
|
+
readonly userHome?: string;
|
|
2344
|
+
readonly temporaryDirectory?: string;
|
|
2372
2345
|
}
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2346
|
+
interface CreateDaemonImagePathResolverOptions extends ImageRootValidationOptions {
|
|
2347
|
+
readonly configPath: string;
|
|
2348
|
+
readonly storageRoot?: string;
|
|
2376
2349
|
}
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
readonly
|
|
2381
|
-
readonly enabled: boolean;
|
|
2382
|
-
readonly httpLeases: number;
|
|
2383
|
-
readonly hostedLeases: number;
|
|
2350
|
+
interface VerifiedDaemonImagePath {
|
|
2351
|
+
readonly area: DaemonImagePathArea;
|
|
2352
|
+
readonly absolutePath: string;
|
|
2353
|
+
readonly kind: 'opaque-file' | 'opaque-directory' | 'mount-manifest';
|
|
2384
2354
|
}
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2355
|
+
/**
|
|
2356
|
+
* Owns all daemon Images filesystem names. Callers receive opaque capabilities,
|
|
2357
|
+
* never a filename-accepting delete primitive; destructive methods revalidate
|
|
2358
|
+
* the root identity, descendant relationship, basename, and symlink state.
|
|
2359
|
+
*/
|
|
2360
|
+
declare class DaemonImagePathResolver {
|
|
2361
|
+
#private;
|
|
2362
|
+
readonly paths: DaemonImagePaths;
|
|
2363
|
+
constructor(options: CreateDaemonImagePathResolverOptions);
|
|
2364
|
+
createOpaqueFile(area: Exclude<DaemonImagePathArea, 'temporary' | 'mountManifest'>, format?: 'bin' | 'json' | 'tmp'): VerifiedDaemonImagePath;
|
|
2365
|
+
createOpaqueDirectory(area?: Exclude<DaemonImagePathArea, 'mountManifest'>): VerifiedDaemonImagePath;
|
|
2366
|
+
mountManifest(): VerifiedDaemonImagePath;
|
|
2367
|
+
/** Revalidate and return one internal root for store-local bounded I/O. */
|
|
2368
|
+
verifiedRoot(area: DaemonImagePathArea): string;
|
|
2369
|
+
/** Revalidate immediately before unlinking a resolver-issued file capability. */
|
|
2370
|
+
removeFile(target: VerifiedDaemonImagePath): void;
|
|
2371
|
+
/** Only empty opaque directories may be removed until the owned-marker layer is composed. */
|
|
2372
|
+
removeEmptyDirectory(target: VerifiedDaemonImagePath): void;
|
|
2373
|
+
private issue;
|
|
2374
|
+
private verifyDestructiveTarget;
|
|
2389
2375
|
}
|
|
2390
|
-
type ImageRuntimeSafeUnavailableReason = ImageCapabilityUnavailableReason | 'disabled' | 'runtime_unavailable';
|
|
2391
2376
|
|
|
2392
|
-
interface
|
|
2393
|
-
readonly
|
|
2394
|
-
readonly
|
|
2395
|
-
readonly
|
|
2396
|
-
readonly
|
|
2397
|
-
readonly
|
|
2398
|
-
readonly
|
|
2399
|
-
readonly capabilities?: ImageCapabilities;
|
|
2400
|
-
/**
|
|
2401
|
-
* Route-table keys whose ROUTED provider's fresh capability intersection
|
|
2402
|
-
* affirms them (multi-provider-image-generation 6.1: /v1/models lists
|
|
2403
|
-
* routed-model × fresh-evidence). Absent on synthetic/legacy generations —
|
|
2404
|
-
* `listAvailableModels` then falls back to the single-model shape.
|
|
2405
|
-
*/
|
|
2406
|
-
readonly routedModels?: readonly string[];
|
|
2377
|
+
interface FileCodexImageCapabilityEvidenceManifestOwnerOptions {
|
|
2378
|
+
readonly paths: DaemonImagePathResolver;
|
|
2379
|
+
readonly maxEntries?: number;
|
|
2380
|
+
readonly now?: () => number;
|
|
2381
|
+
readonly random?: (bytes: number) => Buffer;
|
|
2382
|
+
readonly hmacSalt?: Uint8Array;
|
|
2383
|
+
readonly replaceManifest?: (targetPath: string, contents: Uint8Array) => void;
|
|
2407
2384
|
}
|
|
2408
|
-
|
|
2409
|
-
readonly
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
}>;
|
|
2420
|
-
readonly temporary: Readonly<{
|
|
2421
|
-
activeScopes: number;
|
|
2422
|
-
totalBytes: number;
|
|
2423
|
-
tenantCount: number;
|
|
2424
|
-
maxActiveScopes: number;
|
|
2425
|
-
maxTotalBytes: number;
|
|
2426
|
-
maxTenantBytes: number;
|
|
2427
|
-
}>;
|
|
2428
|
-
readonly storage: Readonly<{
|
|
2429
|
-
mounts: number;
|
|
2430
|
-
retiredMounts: number;
|
|
2431
|
-
referenceEntries: number;
|
|
2432
|
-
referenceBytes: number;
|
|
2433
|
-
referenceTombstones: number;
|
|
2434
|
-
stateCalls: number;
|
|
2435
|
-
stateResponses: number;
|
|
2436
|
-
stateTombstones: number;
|
|
2437
|
-
pendingReferenceDeletes: number;
|
|
2438
|
-
maxReferenceEntries: number;
|
|
2439
|
-
maxReferenceBytes: number;
|
|
2440
|
-
maxTenantReferenceBytes: number;
|
|
2441
|
-
maxStateCalls: number;
|
|
2442
|
-
maxStateResponses: number;
|
|
2443
|
-
}>;
|
|
2385
|
+
type FileCodexImageCapabilityEvidenceSourceOptions = Readonly<(FileCodexImageCapabilityEvidenceManifestOwnerOptions & {
|
|
2386
|
+
readonly ttlMs: number;
|
|
2387
|
+
}) | {
|
|
2388
|
+
readonly owner: FileCodexImageCapabilityEvidenceManifestOwner;
|
|
2389
|
+
readonly ttlMs: number;
|
|
2390
|
+
}>;
|
|
2391
|
+
interface FileCodexImageCapabilityEvidenceStatus {
|
|
2392
|
+
readonly entries: number;
|
|
2393
|
+
readonly freshEntries: number;
|
|
2394
|
+
readonly staleEntries: number;
|
|
2395
|
+
readonly bytes: number;
|
|
2444
2396
|
}
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2397
|
+
/** Revision-aware manifest owner shared by runtime generations, doctor, and cleanup. */
|
|
2398
|
+
declare class FileCodexImageCapabilityEvidenceManifestOwner {
|
|
2399
|
+
#private;
|
|
2400
|
+
constructor(options: FileCodexImageCapabilityEvidenceManifestOwnerOptions);
|
|
2401
|
+
createSource(ttlMs: number): FileCodexImageCapabilityEvidenceSource;
|
|
2402
|
+
resolveWithTtl(request: CodexImageCapabilityEvidenceRequest, ttlMs: number): Promise<CodexImageCapabilityEvidence>;
|
|
2403
|
+
recordSuccessfulVerificationWithTtl(observation: CodexImageCapabilityObservation, ttlMs: number): Promise<void>;
|
|
2404
|
+
cleanup(now: number, limit: number): Promise<{
|
|
2405
|
+
readonly entriesRemoved: number;
|
|
2406
|
+
readonly bytesRemoved: number;
|
|
2407
|
+
}>;
|
|
2408
|
+
statusWithTtl(ttlMs: number): FileCodexImageCapabilityEvidenceStatus;
|
|
2450
2409
|
}
|
|
2451
|
-
/**
|
|
2452
|
-
declare class
|
|
2410
|
+
/** Immutable TTL view over a revision-aware file-backed evidence manifest owner. */
|
|
2411
|
+
declare class FileCodexImageCapabilityEvidenceSource implements CodexImageCapabilityEvidenceSource {
|
|
2453
2412
|
#private;
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2413
|
+
constructor(options: FileCodexImageCapabilityEvidenceSourceOptions);
|
|
2414
|
+
createView(ttlMs: number): FileCodexImageCapabilityEvidenceSource;
|
|
2415
|
+
resolve(request: CodexImageCapabilityEvidenceRequest): Promise<CodexImageCapabilityEvidence>;
|
|
2416
|
+
recordSuccessfulVerification(observation: CodexImageCapabilityObservation): Promise<void>;
|
|
2417
|
+
cleanup(now: number, limit: number): Promise<{
|
|
2418
|
+
readonly entriesRemoved: number;
|
|
2419
|
+
readonly bytesRemoved: number;
|
|
2420
|
+
}>;
|
|
2421
|
+
status(): FileCodexImageCapabilityEvidenceStatus;
|
|
2422
|
+
ttlMs(): number;
|
|
2423
|
+
/** Lifecycle-symmetric no-op; physical safety no longer depends on local leases. */
|
|
2424
|
+
dispose(): void;
|
|
2463
2425
|
}
|
|
2464
2426
|
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
declare const IMAGE_CONFIGURATION_AUDIT_FIELDS: readonly ["enablement", "provider", "model", "account", "queue", "temporary", "limits", "retention", "storage", "remote", "evidence"];
|
|
2474
|
-
type ImageConfigurationAuditField = typeof IMAGE_CONFIGURATION_AUDIT_FIELDS[number];
|
|
2475
|
-
/** Values are deliberately limited to safe categories and internal generation ids. */
|
|
2476
|
-
interface ImageConfigurationAuditRecord {
|
|
2477
|
-
readonly outcome: 'applied';
|
|
2478
|
-
readonly fields: readonly ImageConfigurationAuditField[];
|
|
2479
|
-
readonly previousGenerationId?: string;
|
|
2480
|
-
readonly generationId?: string;
|
|
2427
|
+
interface FileImageReferenceStoreLimits {
|
|
2428
|
+
readonly ttlMs: number;
|
|
2429
|
+
readonly maxArtifactBytes: number;
|
|
2430
|
+
readonly maxTotalBytes: number;
|
|
2431
|
+
readonly maxTenantBytes: number;
|
|
2432
|
+
readonly maxEntries: number;
|
|
2433
|
+
readonly maxTombstones: number;
|
|
2434
|
+
readonly tombstoneTtlMs: number;
|
|
2481
2435
|
}
|
|
2482
|
-
interface
|
|
2483
|
-
readonly
|
|
2484
|
-
readonly
|
|
2485
|
-
|
|
2486
|
-
readonly
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
}[];
|
|
2436
|
+
interface FileImageReferenceStoreOptions {
|
|
2437
|
+
readonly paths: DaemonImagePathResolver;
|
|
2438
|
+
readonly limits: FileImageReferenceStoreLimits;
|
|
2439
|
+
readonly secretBox?: SecretBox;
|
|
2440
|
+
readonly now?: () => number;
|
|
2441
|
+
readonly random?: (bytes: number) => Buffer;
|
|
2442
|
+
readonly replaceManifest?: (targetPath: string, contents: Uint8Array) => void;
|
|
2490
2443
|
}
|
|
2491
|
-
interface
|
|
2492
|
-
readonly
|
|
2493
|
-
readonly
|
|
2494
|
-
readonly
|
|
2495
|
-
readonly
|
|
2496
|
-
readonly
|
|
2497
|
-
readonly background: SafeBackground;
|
|
2498
|
-
readonly outputFormat: SafeOutputFormat;
|
|
2499
|
-
readonly streaming: SafeBooleanOption;
|
|
2500
|
-
readonly requestedOutputs: SafeCountOption;
|
|
2501
|
-
readonly partialImages: SafeCountOption;
|
|
2502
|
-
readonly terminal: 'completed' | 'failed' | 'cancelled';
|
|
2503
|
-
readonly errorCode: SafeErrorCode;
|
|
2504
|
-
}
|
|
2505
|
-
interface ImageExecutionMetricDimensions {
|
|
2506
|
-
readonly provider: SafeProvider;
|
|
2507
|
-
readonly model: SafeModel;
|
|
2508
|
-
readonly action: 'generate' | 'edit' | 'other';
|
|
2509
|
-
readonly quality: SafeQuality;
|
|
2510
|
-
readonly background: SafeBackground;
|
|
2511
|
-
readonly outputFormat: SafeOutputFormat;
|
|
2512
|
-
readonly streaming: SafeBooleanOption;
|
|
2513
|
-
readonly requestedOutputs: SafeCountOption;
|
|
2514
|
-
readonly terminal: 'completed' | 'failed' | 'cancelled' | 'other';
|
|
2515
|
-
readonly errorCode: SafeErrorCode;
|
|
2444
|
+
interface FileImageReferenceReconciliationResult {
|
|
2445
|
+
readonly metadataRemoved: number;
|
|
2446
|
+
readonly metadataDegradedToProviderReference: number;
|
|
2447
|
+
readonly orphanFilesRemoved: number;
|
|
2448
|
+
readonly incompleteFilesRemoved: number;
|
|
2449
|
+
readonly invalidDescendants: number;
|
|
2516
2450
|
}
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2451
|
+
declare class FileImageReferenceStore implements ImageReferenceStore {
|
|
2452
|
+
#private;
|
|
2453
|
+
constructor(options: FileImageReferenceStoreOptions);
|
|
2454
|
+
save(input: ImageReferenceSaveInput): Promise<ImageReferenceMetadata>;
|
|
2455
|
+
/** Generation-bound write entry point; reads and maintenance remain shared. */
|
|
2456
|
+
saveWithLimits(input: ImageReferenceSaveInput, limits: FileImageReferenceStoreLimits): Promise<ImageReferenceMetadata>;
|
|
2457
|
+
/** Updates only app-session maintenance policy; pinned writes pass their own limits. */
|
|
2458
|
+
updateMaintenanceLimits(limits: FileImageReferenceStoreLimits): void;
|
|
2459
|
+
resolve(tenantId: string, referenceId: ImageReferenceId): Promise<ImageReferenceResolution>;
|
|
2460
|
+
delete(tenantId: string, referenceId: ImageReferenceId): Promise<boolean>;
|
|
2461
|
+
/** Daemon-internal cleanup path; accepts only the local reference-domain tenant HMAC. */
|
|
2462
|
+
deleteByHashedTenantKey(tenantKey: string, referenceId: ImageReferenceId): Promise<boolean>;
|
|
2463
|
+
cleanup(now?: number): Promise<number>;
|
|
2464
|
+
status(): {
|
|
2465
|
+
readonly entries: number;
|
|
2466
|
+
readonly bytes: number;
|
|
2467
|
+
readonly tombstones: number;
|
|
2468
|
+
};
|
|
2469
|
+
hasLiveReferenceByHashedTenantKey(tenantKey: string, referenceId: ImageReferenceId, now?: number): Promise<boolean>;
|
|
2470
|
+
reconcileOwnedFiles(maxEntries: number): Promise<FileImageReferenceReconciliationResult>;
|
|
2471
|
+
openArtifact(fileName: string, byteLength: number, signal?: AbortSignal): Promise<ReadableStream<Uint8Array>>;
|
|
2472
|
+
private exclusive;
|
|
2473
|
+
private tenantKey;
|
|
2474
|
+
private newReferenceId;
|
|
2475
|
+
private validateSaveInput;
|
|
2476
|
+
private selectVictims;
|
|
2477
|
+
private nextTombstones;
|
|
2478
|
+
private writeArtifact;
|
|
2479
|
+
private artifactPath;
|
|
2480
|
+
private validArtifact;
|
|
2481
|
+
private removeArtifact;
|
|
2482
|
+
private safeUnlinkArtifactPath;
|
|
2483
|
+
private releaseLease;
|
|
2484
|
+
private manifestPath;
|
|
2485
|
+
private persist;
|
|
2486
|
+
private atomicReplace;
|
|
2487
|
+
private loadManifest;
|
|
2532
2488
|
}
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
readonly
|
|
2536
|
-
readonly
|
|
2537
|
-
readonly
|
|
2538
|
-
readonly
|
|
2539
|
-
readonly firstPartialLatencyMs?: ImageHistogramSnapshot;
|
|
2540
|
-
readonly inputCount: ImageHistogramSnapshot;
|
|
2541
|
-
readonly inputBytes: ImageHistogramSnapshot;
|
|
2542
|
-
readonly outputCount: ImageHistogramSnapshot;
|
|
2543
|
-
readonly outputBytes: ImageHistogramSnapshot;
|
|
2544
|
-
readonly retryCount?: ImageHistogramSnapshot;
|
|
2545
|
-
readonly authRefreshCount?: ImageHistogramSnapshot;
|
|
2546
|
-
readonly referenceSaveCount?: ImageHistogramSnapshot;
|
|
2547
|
-
readonly retentionRollbackFailures?: ImageHistogramSnapshot;
|
|
2489
|
+
|
|
2490
|
+
interface FileResponsesImageStateStoreLimits {
|
|
2491
|
+
readonly maxCalls: number;
|
|
2492
|
+
readonly maxResponses: number;
|
|
2493
|
+
readonly maxTombstones: number;
|
|
2494
|
+
readonly tombstoneTtlMs: number;
|
|
2548
2495
|
}
|
|
2549
|
-
interface
|
|
2550
|
-
readonly
|
|
2551
|
-
readonly
|
|
2552
|
-
readonly
|
|
2553
|
-
readonly
|
|
2554
|
-
|
|
2555
|
-
telemetryRecords: number;
|
|
2556
|
-
}>;
|
|
2496
|
+
interface FileResponsesImageStateStoreOptions {
|
|
2497
|
+
readonly paths: DaemonImagePathResolver;
|
|
2498
|
+
readonly limits: FileResponsesImageStateStoreLimits;
|
|
2499
|
+
readonly now?: () => number;
|
|
2500
|
+
readonly random?: (bytes: number) => Buffer;
|
|
2501
|
+
readonly replaceManifest?: (targetPath: string, contents: Uint8Array) => void;
|
|
2557
2502
|
}
|
|
2558
|
-
interface
|
|
2559
|
-
|
|
2560
|
-
readonly
|
|
2503
|
+
interface PendingResponsesImageReferenceDelete {
|
|
2504
|
+
readonly referenceTenantKey: string;
|
|
2505
|
+
readonly binding: ResponsesImageCallBinding;
|
|
2561
2506
|
}
|
|
2562
|
-
/**
|
|
2563
|
-
declare class
|
|
2507
|
+
/** Durable production implementation of the existing Responses image-state contract. */
|
|
2508
|
+
declare class FileResponsesImageStateStore implements ResponsesImageStateStore {
|
|
2564
2509
|
#private;
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2510
|
+
constructor(options: FileResponsesImageStateStoreOptions);
|
|
2511
|
+
commit(input: ResponsesImageStateCommitInput): Promise<readonly ResponsesImageCallBinding[]>;
|
|
2512
|
+
/** Generation-bound write entry point; reads and maintenance remain shared. */
|
|
2513
|
+
commitWithLimits(input: ResponsesImageStateCommitInput, limits: FileResponsesImageStateStoreLimits): Promise<readonly ResponsesImageCallBinding[]>;
|
|
2514
|
+
/** Updates only app-session maintenance policy; pinned commits pass their own limits. */
|
|
2515
|
+
updateMaintenanceLimits(limits: FileResponsesImageStateStoreLimits): void;
|
|
2516
|
+
resolveCall(tenantId: string, callId: ResponsesImageCallId): Promise<ResponsesImageCallResolution>;
|
|
2517
|
+
resolveResponse(tenantId: string, responseId: string): Promise<ResponsesImageResponseResolution>;
|
|
2518
|
+
deleteCall(tenantId: string, callId: ResponsesImageCallId): Promise<ResponsesImageCallBinding | undefined>;
|
|
2519
|
+
deleteResponse(tenantId: string, responseId: string): Promise<boolean>;
|
|
2520
|
+
cleanup(now?: number): Promise<readonly ResponsesImageCallBinding[]>;
|
|
2521
|
+
pendingReferenceDeletes(limit?: number): readonly PendingResponsesImageReferenceDelete[];
|
|
2522
|
+
acknowledgeReferenceDeletes(completed: readonly PendingResponsesImageReferenceDelete[]): Promise<number>;
|
|
2523
|
+
reconcileBrokenReferenceLinks(hasLiveReference: (referenceTenantKey: string, referenceId: ResponsesImageCallBinding['referenceId']) => Promise<boolean>, maxEntries: number): Promise<readonly ResponsesImageCallBinding[]>;
|
|
2524
|
+
status(): {
|
|
2525
|
+
readonly calls: number;
|
|
2526
|
+
readonly responses: number;
|
|
2527
|
+
readonly tombstones: number;
|
|
2528
|
+
readonly pendingReferenceDeletes: number;
|
|
2529
|
+
};
|
|
2530
|
+
private exclusive;
|
|
2531
|
+
private failure;
|
|
2532
|
+
private assertCommit;
|
|
2533
|
+
private tenantKey;
|
|
2534
|
+
private rememberTombstone;
|
|
2535
|
+
private enqueuePendingReferenceDelete;
|
|
2536
|
+
private hasTombstone;
|
|
2537
|
+
private prunedTombstones;
|
|
2538
|
+
private pruneTombstonesInPlace;
|
|
2539
|
+
private sameTombstones;
|
|
2540
|
+
private touch;
|
|
2541
|
+
private releaseCall;
|
|
2542
|
+
private releaseResponse;
|
|
2543
|
+
private manifestPath;
|
|
2544
|
+
private persist;
|
|
2545
|
+
private atomicReplace;
|
|
2546
|
+
private loadManifest;
|
|
2573
2547
|
}
|
|
2574
2548
|
|
|
2575
|
-
interface
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
dispose(): void | Promise<void>;
|
|
2549
|
+
interface ImageStorageMountBackend {
|
|
2550
|
+
readonly id: string;
|
|
2551
|
+
readonly createdAt: number;
|
|
2552
|
+
readonly resolver: DaemonImagePathResolver;
|
|
2553
|
+
readonly references: FileImageReferenceStore;
|
|
2554
|
+
readonly responsesState: FileResponsesImageStateStore;
|
|
2582
2555
|
}
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
* - `markAutoDisabled(keyId, status, at)` records `{ status, at, reason }`,
|
|
2594
|
-
* - `isDisabled(keyId)` / `get(keyId)` read it back,
|
|
2595
|
-
* - `loadPoolKeys` reads this store and flips a flagged key's `enabled` to
|
|
2596
|
-
* `false`, so `getAvailableKeys` skips it within this process lifetime.
|
|
2597
|
-
*
|
|
2598
|
-
* Restart resets the store (the honest v1 boundary — see spec). Persistence
|
|
2599
|
-
* (encrypted write-back) is a child-3 follow-up.
|
|
2600
|
-
*
|
|
2601
|
-
* @module @omnicross/daemon/pool/autoDisableStore
|
|
2602
|
-
*/
|
|
2603
|
-
/** One in-memory auto-disable record for a pool key. */
|
|
2604
|
-
interface AutoDisableRecord {
|
|
2605
|
-
/** The HTTP status that triggered the disable (401/403). */
|
|
2606
|
-
status: number;
|
|
2607
|
-
/** Epoch-ms when the disable was recorded. */
|
|
2608
|
-
at: number;
|
|
2609
|
-
/** Always `'auth_failure'` in v1 (the only auto-disable trigger). */
|
|
2610
|
-
reason: 'auth_failure';
|
|
2556
|
+
interface ImageStorageMountCatalogOptions {
|
|
2557
|
+
readonly pathOptions: Omit<CreateDaemonImagePathResolverOptions, 'storageRoot'>;
|
|
2558
|
+
readonly activeStorageRoot?: string;
|
|
2559
|
+
readonly referenceLimits: FileImageReferenceStoreLimits;
|
|
2560
|
+
readonly responsesStateLimits: FileResponsesImageStateStoreLimits;
|
|
2561
|
+
readonly secretBox?: SecretBox;
|
|
2562
|
+
readonly now?: () => number;
|
|
2563
|
+
readonly random?: (bytes: number) => Buffer;
|
|
2564
|
+
readonly replaceCatalog?: (targetPath: string, contents: Uint8Array) => void;
|
|
2565
|
+
readonly reconcileCorruptManifests?: boolean;
|
|
2611
2566
|
}
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
* `disableKey` / `markAutoDisabled` sinks AND read by `loadPoolKeys`.
|
|
2616
|
-
*/
|
|
2617
|
-
declare class AutoDisableStore {
|
|
2618
|
-
private readonly records;
|
|
2619
|
-
/** Record (or overwrite) an auth-failure auto-disable for `keyId`. */
|
|
2620
|
-
markAutoDisabled(keyId: string, status: number, at: number): void;
|
|
2621
|
-
/** Whether `keyId` is currently auto-disabled in this process. */
|
|
2622
|
-
isDisabled(keyId: string): boolean;
|
|
2623
|
-
/** Read the auto-disable record for `keyId`, or `undefined` when healthy. */
|
|
2624
|
-
get(keyId: string): AutoDisableRecord | undefined;
|
|
2625
|
-
/** Clear all records (tests / teardown). */
|
|
2626
|
-
clear(): void;
|
|
2567
|
+
interface ImageStorageMountPolicy {
|
|
2568
|
+
readonly referenceLimits: FileImageReferenceStoreLimits;
|
|
2569
|
+
readonly responsesStateLimits: FileResponsesImageStateStoreLimits;
|
|
2627
2570
|
}
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
/**
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
private
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
setProviders(providers: readonly DaemonProviderConfig[]): void;
|
|
2691
|
-
getProvider(id: string): Promise<LLMProvider | null>;
|
|
2692
|
-
getTransformerService(): TransformerService | undefined;
|
|
2693
|
-
getMainTransformer(providerId: string): Promise<Transformer | null>;
|
|
2694
|
-
resolveTransformerChain(providerId: string, _model?: string): Promise<ResolvedTransformerChain>;
|
|
2695
|
-
resolveRoutedModel(): Promise<null>;
|
|
2696
|
-
resolveEffectiveModels(): Promise<{
|
|
2697
|
-
background?: string;
|
|
2698
|
-
vision?: string;
|
|
2571
|
+
interface PreparedImageStorageMountActivation {
|
|
2572
|
+
readonly backend: ImageStorageMountBackend;
|
|
2573
|
+
publish(): ImageStorageMountBackend;
|
|
2574
|
+
rollback(): void;
|
|
2575
|
+
dispose(): void;
|
|
2576
|
+
}
|
|
2577
|
+
/** Owns the durable-root set independently from any one runtime generation. */
|
|
2578
|
+
declare class ImageStorageMountCatalog {
|
|
2579
|
+
#private;
|
|
2580
|
+
constructor(options: ImageStorageMountCatalogOptions);
|
|
2581
|
+
active(): ImageStorageMountBackend;
|
|
2582
|
+
mountsForRead(): readonly ImageStorageMountBackend[];
|
|
2583
|
+
status(): {
|
|
2584
|
+
readonly mounts: number;
|
|
2585
|
+
readonly retiredMounts: number;
|
|
2586
|
+
};
|
|
2587
|
+
startupReconciliationStatus(): {
|
|
2588
|
+
readonly corruptManifestsQuarantined: number;
|
|
2589
|
+
};
|
|
2590
|
+
utilization(): {
|
|
2591
|
+
readonly referenceEntries: number;
|
|
2592
|
+
readonly referenceBytes: number;
|
|
2593
|
+
readonly referenceTombstones: number;
|
|
2594
|
+
readonly stateCalls: number;
|
|
2595
|
+
readonly stateResponses: number;
|
|
2596
|
+
readonly stateTombstones: number;
|
|
2597
|
+
readonly pendingReferenceDeletes: number;
|
|
2598
|
+
};
|
|
2599
|
+
/** Pins a backend object until its owning runtime generation drains. */
|
|
2600
|
+
retainBackend(backend: ImageStorageMountBackend): () => void;
|
|
2601
|
+
activate(storageRoot?: string): ImageStorageMountBackend;
|
|
2602
|
+
/** Prepare a validated backend without changing the catalog's active mount. */
|
|
2603
|
+
prepareActivation(storageRoot?: string, policy?: ImageStorageMountPolicy): PreparedImageStorageMountActivation;
|
|
2604
|
+
retireEmptyMount(mountId: string): boolean;
|
|
2605
|
+
private createResolver;
|
|
2606
|
+
private createBackend;
|
|
2607
|
+
private applyMaintenancePolicy;
|
|
2608
|
+
private newMountId;
|
|
2609
|
+
private isManifestError;
|
|
2610
|
+
private quarantineManifest;
|
|
2611
|
+
private isVerifiedEmpty;
|
|
2612
|
+
private catalogPath;
|
|
2613
|
+
private persist;
|
|
2614
|
+
private atomicReplace;
|
|
2615
|
+
private loadCatalog;
|
|
2616
|
+
}
|
|
2617
|
+
declare class MountedImageReferenceStore implements ImageReferenceStore {
|
|
2618
|
+
private readonly catalog;
|
|
2619
|
+
private readonly writeBackend?;
|
|
2620
|
+
private readonly writeLimits?;
|
|
2621
|
+
constructor(catalog: ImageStorageMountCatalog, writeBackend?: ImageStorageMountBackend | undefined, writeLimits?: FileImageReferenceStoreLimits | undefined);
|
|
2622
|
+
bindWriteBackend(backend: ImageStorageMountBackend, limits: FileImageReferenceStoreLimits): MountedImageReferenceStore;
|
|
2623
|
+
status(): Readonly<{
|
|
2624
|
+
referenceEntries: number;
|
|
2625
|
+
referenceBytes: number;
|
|
2626
|
+
referenceTombstones: number;
|
|
2627
|
+
stateCalls: number;
|
|
2628
|
+
stateResponses: number;
|
|
2629
|
+
stateTombstones: number;
|
|
2630
|
+
pendingReferenceDeletes: number;
|
|
2631
|
+
mounts: number;
|
|
2632
|
+
retiredMounts: number;
|
|
2699
2633
|
}>;
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2634
|
+
save(input: ImageReferenceSaveInput): Promise<_omnicross_contracts_image_generation_types.ImageReferenceMetadata>;
|
|
2635
|
+
resolve(tenantId: string, referenceId: ImageReferenceId): Promise<ImageReferenceResolution>;
|
|
2636
|
+
delete(tenantId: string, referenceId: ImageReferenceId): Promise<boolean>;
|
|
2637
|
+
deleteByHashedTenantKey(tenantKey: string, referenceId: ImageReferenceId): Promise<boolean>;
|
|
2638
|
+
cleanup(now?: number): Promise<number>;
|
|
2639
|
+
}
|
|
2640
|
+
declare class MountedResponsesImageStateStore implements ResponsesImageStateStore {
|
|
2641
|
+
private readonly catalog;
|
|
2642
|
+
private readonly writeBackend?;
|
|
2643
|
+
private readonly writeLimits?;
|
|
2644
|
+
constructor(catalog: ImageStorageMountCatalog, writeBackend?: ImageStorageMountBackend | undefined, writeLimits?: FileResponsesImageStateStoreLimits | undefined);
|
|
2645
|
+
bindWriteBackend(backend: ImageStorageMountBackend, limits: FileResponsesImageStateStoreLimits): MountedResponsesImageStateStore;
|
|
2646
|
+
commit(input: ResponsesImageStateCommitInput): Promise<readonly ResponsesImageCallBinding[]>;
|
|
2647
|
+
resolveCall(tenantId: string, callId: ResponsesImageCallId): Promise<ResponsesImageCallResolution>;
|
|
2648
|
+
resolveResponse(tenantId: string, responseId: string): Promise<ResponsesImageResponseResolution>;
|
|
2649
|
+
deleteCall(tenantId: string, callId: ResponsesImageCallId): Promise<ResponsesImageCallBinding | undefined>;
|
|
2650
|
+
deleteResponse(tenantId: string, responseId: string): Promise<boolean>;
|
|
2651
|
+
cleanup(now?: number): Promise<readonly ResponsesImageCallBinding[]>;
|
|
2704
2652
|
}
|
|
2705
2653
|
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2654
|
+
interface ImageDoctorLocalSnapshot {
|
|
2655
|
+
readonly config: Readonly<{
|
|
2656
|
+
enabled: boolean;
|
|
2657
|
+
provider: ImageProviderId;
|
|
2658
|
+
model: string;
|
|
2659
|
+
valid: boolean;
|
|
2660
|
+
errorCount: number;
|
|
2661
|
+
/** Distinct providers the routing table names (doctor per-provider rows). */
|
|
2662
|
+
routedProviders: readonly ImageProviderId[];
|
|
2663
|
+
}>;
|
|
2664
|
+
readonly roots: Readonly<{
|
|
2665
|
+
valid: boolean;
|
|
2666
|
+
verifiedAreas: number;
|
|
2667
|
+
expectedAreas: number;
|
|
2668
|
+
}>;
|
|
2669
|
+
readonly stores: Readonly<{
|
|
2670
|
+
valid: boolean;
|
|
2671
|
+
mounts: number;
|
|
2672
|
+
retiredMounts: number;
|
|
2673
|
+
referenceEntries: number;
|
|
2674
|
+
referenceBytes: number;
|
|
2675
|
+
stateCalls: number;
|
|
2676
|
+
stateResponses: number;
|
|
2677
|
+
corruptManifestsQuarantined: number;
|
|
2678
|
+
}>;
|
|
2679
|
+
readonly permissions: Readonly<{
|
|
2680
|
+
valid: boolean;
|
|
2681
|
+
rows: number;
|
|
2682
|
+
legacyRows: number;
|
|
2683
|
+
invalidRows: number;
|
|
2684
|
+
imagesAuthorizedRows: number;
|
|
2685
|
+
}>;
|
|
2686
|
+
/** The Codex-subscription account backing codex-routed image models. */
|
|
2687
|
+
readonly account: Readonly<{
|
|
2688
|
+
present: boolean;
|
|
2689
|
+
usable: boolean;
|
|
2690
|
+
reason: 'ready' | 'missing' | 'unavailable';
|
|
2691
|
+
}>;
|
|
2692
|
+
/** The Antigravity-subscription account backing NanoBanana image models. */
|
|
2693
|
+
readonly antigravityAccount: Readonly<{
|
|
2694
|
+
present: boolean;
|
|
2695
|
+
usable: boolean;
|
|
2696
|
+
reason: 'ready' | 'missing' | 'unavailable';
|
|
2697
|
+
}>;
|
|
2698
|
+
readonly evidence: Readonly<FileCodexImageCapabilityEvidenceStatus & {
|
|
2699
|
+
valid: boolean;
|
|
2700
|
+
}>;
|
|
2727
2701
|
}
|
|
2728
|
-
type
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
set<T = unknown>(key: string, value: T): Promise<void>;
|
|
2744
|
-
/** Capture the exact prior document for an admin transaction rollback. */
|
|
2745
|
-
captureDocumentSnapshot(): JsonSettingsDocumentSnapshot;
|
|
2746
|
-
/** Restore exact prior bytes (including unrelated fields and encrypted secrets). */
|
|
2747
|
-
restoreDocumentSnapshot(snapshot: JsonSettingsDocumentSnapshot): void;
|
|
2748
|
-
/** Encrypt the proxy passwords + webhook + billing secrets before persisting (no-op without a box). */
|
|
2749
|
-
private encryptSecrets;
|
|
2750
|
-
/** Decrypt the proxy passwords + webhook + billing secrets on read (no-op without a box). */
|
|
2751
|
-
private decryptSecrets;
|
|
2752
|
-
/** Read the config.json, tolerating a missing/corrupt file (→ empty shape). */
|
|
2753
|
-
private readFile;
|
|
2702
|
+
type ImageDoctorLiveFailureCode = 'images_disabled' | 'codex_account_unavailable' | 'evidence_store_unavailable' | 'evidence_persist_failed' | ImageGenerationErrorCode;
|
|
2703
|
+
type ImageDoctorLiveResult = Readonly<{
|
|
2704
|
+
ok: true;
|
|
2705
|
+
code: 'verified';
|
|
2706
|
+
model: 'gpt-image-2';
|
|
2707
|
+
quality: 'low';
|
|
2708
|
+
outputFormat: 'png';
|
|
2709
|
+
freshEvidenceEntries: number;
|
|
2710
|
+
}> | Readonly<{
|
|
2711
|
+
ok: false;
|
|
2712
|
+
code: ImageDoctorLiveFailureCode;
|
|
2713
|
+
}>;
|
|
2714
|
+
interface ImageDoctorService {
|
|
2715
|
+
inspectLocal(config: ImagesServerConfig): Promise<ImageDoctorLocalSnapshot>;
|
|
2716
|
+
verifyLive(config: ImagesServerConfig, signal: AbortSignal): Promise<ImageDoctorLiveResult>;
|
|
2754
2717
|
}
|
|
2755
2718
|
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2719
|
+
type PreparedImageRuntimeGeneration = {
|
|
2720
|
+
readonly id: string;
|
|
2721
|
+
readonly enabled: true;
|
|
2722
|
+
readonly imageApi: ImageApiContributions;
|
|
2723
|
+
readonly hosted: ResponsesImageGenerationContribution;
|
|
2724
|
+
readonly hostedRuntime: HostedImageRuntimePolicy;
|
|
2725
|
+
readonly inspectCapability?: (apiKeyId: string) => Promise<Omit<ImageRuntimeCapabilityInspection, 'generationId'>>;
|
|
2726
|
+
readonly readRuntimeStatus?: () => ImageRuntimeResourceStatus;
|
|
2727
|
+
dispose(): void | Promise<void>;
|
|
2728
|
+
} | {
|
|
2729
|
+
readonly id: string;
|
|
2730
|
+
readonly enabled: false;
|
|
2731
|
+
dispose(): void | Promise<void>;
|
|
2732
|
+
};
|
|
2733
|
+
interface HostedImageRuntimeGenerationLease {
|
|
2734
|
+
readonly generationId: string;
|
|
2735
|
+
/** Compatibility/debug view; callers should prefer the deep methods below. */
|
|
2736
|
+
readonly contribution: ResponsesImageGenerationContribution;
|
|
2737
|
+
inspectRequest(input: ResponsesImageInspectionInput): ResponsesImageAdmission;
|
|
2738
|
+
validateSelection(admission: ResponsesImageAdmission, selection: ResponsesHostedToolSelection): void;
|
|
2739
|
+
openRequest(input: HostedImageOpenRequestInput): Promise<ResponsesImageRequestScope>;
|
|
2740
|
+
release(): Promise<void>;
|
|
2741
|
+
}
|
|
2742
|
+
interface HostedImageRuntimePolicy {
|
|
2743
|
+
readonly providerId: string;
|
|
2744
|
+
readonly imageModel: string;
|
|
2745
|
+
readonly referenceTtlMs: number;
|
|
2746
|
+
readonly maxOutputBytes: number;
|
|
2747
|
+
readonly maxTotalOutputBytes: number;
|
|
2748
|
+
readonly preferredAccountId?: string;
|
|
2749
|
+
readonly preferredAccountGroup?: string;
|
|
2750
|
+
readonly boundAccountFallbackPolicy?: 'strict' | 'pool';
|
|
2751
|
+
}
|
|
2752
|
+
interface HostedImageOpenRequestInput {
|
|
2753
|
+
readonly admission: ResponsesImageAdmission;
|
|
2754
|
+
readonly tenantId: string;
|
|
2755
|
+
readonly requestId: string;
|
|
2756
|
+
readonly sessionKey: string;
|
|
2757
|
+
readonly signal: AbortSignal;
|
|
2758
|
+
readonly authorizedPreviousResponseId?: string;
|
|
2759
|
+
/** Trusted affinity fact forwarded unchanged into the contribution scope. */
|
|
2760
|
+
readonly authorizedPreviousResponseKnownEmpty?: boolean;
|
|
2761
|
+
readonly mainProviderId: string;
|
|
2762
|
+
readonly selectedMainAccountId?: string;
|
|
2763
|
+
}
|
|
2764
|
+
/** Dormant integration seam for a later Native Responses owner. */
|
|
2765
|
+
interface HostedImageContributionFactory {
|
|
2766
|
+
acquire(): Promise<HostedImageRuntimeGenerationLease>;
|
|
2767
|
+
}
|
|
2768
|
+
/** Bind a stable factory to one app-session runtime manager without acquiring. */
|
|
2769
|
+
declare function createHostedImageContributionFactory(manager: ImageRuntimeManager): HostedImageContributionFactory;
|
|
2770
|
+
interface ImageRuntimeGenerationStatus {
|
|
2771
|
+
readonly generationId: string;
|
|
2772
|
+
readonly enabled: boolean;
|
|
2773
|
+
readonly httpLeases: number;
|
|
2774
|
+
readonly hostedLeases: number;
|
|
2775
|
+
}
|
|
2776
|
+
interface ImageRuntimeManagerStatus {
|
|
2777
|
+
readonly disposed: boolean;
|
|
2778
|
+
readonly current: ImageRuntimeGenerationStatus;
|
|
2779
|
+
readonly draining: readonly ImageRuntimeGenerationStatus[];
|
|
2780
|
+
}
|
|
2781
|
+
type ImageRuntimeSafeUnavailableReason = ImageCapabilityUnavailableReason | 'disabled' | 'runtime_unavailable';
|
|
2772
2782
|
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
* otherwise unusable pricing table after a crash or manual file edit.
|
|
2782
|
-
*/
|
|
2783
|
-
hasUsableSnapshot(): boolean;
|
|
2784
|
-
getAll(): Promise<PricingEntry[]>;
|
|
2785
|
-
/**
|
|
2786
|
-
* Insert or update one row keyed (providerId, modelId). `asUserEdit` stamps
|
|
2787
|
-
* user provenance (source 'user', userEdited, editedAt now) so the row is
|
|
2788
|
-
* protected from auto-overwrite during source refreshes; a non-user upsert
|
|
2789
|
-
* stamps source 'litellm' and clears nothing it should not (a plain source
|
|
2790
|
-
* upsert through this method overwrites the row wholesale).
|
|
2791
|
-
*/
|
|
2792
|
-
upsert(input: PricingEntryInput, asUserEdit: boolean): Promise<PricingEntry>;
|
|
2793
|
-
/**
|
|
2794
|
-
* Apply a batch fetched from a pricing source. Rows whose local copy is
|
|
2795
|
-
* user-edited are NOT applied — they come back as `{ current, incoming }`
|
|
2796
|
-
* conflicts; everything else is upserted with the supplied automatic source.
|
|
2797
|
-
* ONE file write for the whole batch.
|
|
2798
|
-
*/
|
|
2799
|
-
bulkApplyFromSource(entries: PricingEntryInput[], source?: AutomaticPricingSource): Promise<{
|
|
2800
|
-
applied: PricingEntry[];
|
|
2801
|
-
conflicts: Array<{
|
|
2802
|
-
current: PricingEntry;
|
|
2803
|
-
incoming: PricingEntryInput;
|
|
2804
|
-
}>;
|
|
2805
|
-
}>;
|
|
2783
|
+
interface ImageRuntimeCapabilityInspection {
|
|
2784
|
+
readonly generationId: string;
|
|
2785
|
+
readonly enabled: boolean;
|
|
2786
|
+
readonly available: boolean;
|
|
2787
|
+
readonly providerId?: ImageProviderId;
|
|
2788
|
+
readonly model?: string;
|
|
2789
|
+
readonly reason?: ImageRuntimeSafeUnavailableReason;
|
|
2790
|
+
readonly capabilities?: ImageCapabilities;
|
|
2806
2791
|
/**
|
|
2807
|
-
*
|
|
2808
|
-
*
|
|
2792
|
+
* Route-table keys whose ROUTED provider's fresh capability intersection
|
|
2793
|
+
* affirms them (multi-provider-image-generation 6.1: /v1/models lists
|
|
2794
|
+
* routed-model × fresh-evidence). Absent on synthetic/legacy generations —
|
|
2795
|
+
* `listAvailableModels` then falls back to the single-model shape.
|
|
2809
2796
|
*/
|
|
2810
|
-
|
|
2811
|
-
incoming: PricingEntryInput;
|
|
2812
|
-
action: 'overwrite' | 'skip';
|
|
2813
|
-
}>): Promise<PricingResolution>;
|
|
2797
|
+
readonly routedModels?: readonly string[];
|
|
2814
2798
|
/**
|
|
2815
|
-
*
|
|
2816
|
-
*
|
|
2817
|
-
* the
|
|
2799
|
+
* One row per provider named by the routing table (images-settings-tab D2):
|
|
2800
|
+
* availability with a safe reason, the models its own fresh evidence
|
|
2801
|
+
* affirms, and the capability values for evidence-age projection. Absent on
|
|
2802
|
+
* synthetic/legacy generations.
|
|
2818
2803
|
*/
|
|
2819
|
-
|
|
2820
|
-
/** Upsert into `rows` IN PLACE (no write) and return the resulting entry. */
|
|
2821
|
-
private applyUpsert;
|
|
2822
|
-
/** Read the pricing rows, tolerating a missing/corrupt file (→ empty list). */
|
|
2823
|
-
private readRows;
|
|
2824
|
-
private writeRows;
|
|
2825
|
-
/** Isolated for deterministic failure testing; never removes the target. */
|
|
2826
|
-
private replaceFile;
|
|
2804
|
+
readonly providers?: readonly ImageRuntimeProviderInspection[];
|
|
2827
2805
|
}
|
|
2828
|
-
|
|
2829
|
-
interface
|
|
2830
|
-
|
|
2831
|
-
|
|
2806
|
+
/** Per-provider capability inspection row (images-settings-tab D2). */
|
|
2807
|
+
interface ImageRuntimeProviderInspection {
|
|
2808
|
+
readonly providerId: ImageProviderId;
|
|
2809
|
+
readonly available: boolean;
|
|
2810
|
+
readonly reason?: ImageRuntimeSafeUnavailableReason;
|
|
2811
|
+
/** This provider's route keys affirmed by its fresh evidence intersection. */
|
|
2812
|
+
readonly models: readonly string[];
|
|
2813
|
+
readonly capabilities?: ImageCapabilities;
|
|
2832
2814
|
}
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2815
|
+
interface ImageRuntimeResourceStatus {
|
|
2816
|
+
readonly queue: Readonly<{
|
|
2817
|
+
activeJobs: number;
|
|
2818
|
+
waitingJobs: number;
|
|
2819
|
+
activeAccounts: number;
|
|
2820
|
+
waitingAccounts: number;
|
|
2821
|
+
waitingTenants: number;
|
|
2822
|
+
maxConcurrentJobsPerAccount: number;
|
|
2823
|
+
maxQueuedJobs: number;
|
|
2824
|
+
accepting: boolean;
|
|
2825
|
+
shuttingDown: boolean;
|
|
2826
|
+
}>;
|
|
2827
|
+
readonly temporary: Readonly<{
|
|
2828
|
+
activeScopes: number;
|
|
2829
|
+
totalBytes: number;
|
|
2830
|
+
tenantCount: number;
|
|
2831
|
+
maxActiveScopes: number;
|
|
2832
|
+
maxTotalBytes: number;
|
|
2833
|
+
maxTenantBytes: number;
|
|
2834
|
+
}>;
|
|
2835
|
+
readonly storage: Readonly<{
|
|
2836
|
+
mounts: number;
|
|
2837
|
+
retiredMounts: number;
|
|
2838
|
+
referenceEntries: number;
|
|
2839
|
+
referenceBytes: number;
|
|
2840
|
+
referenceTombstones: number;
|
|
2841
|
+
stateCalls: number;
|
|
2842
|
+
stateResponses: number;
|
|
2843
|
+
stateTombstones: number;
|
|
2844
|
+
pendingReferenceDeletes: number;
|
|
2845
|
+
maxReferenceEntries: number;
|
|
2846
|
+
maxReferenceBytes: number;
|
|
2847
|
+
maxTenantReferenceBytes: number;
|
|
2848
|
+
maxStateCalls: number;
|
|
2849
|
+
maxStateResponses: number;
|
|
2850
|
+
}>;
|
|
2840
2851
|
}
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
ownership: IntegrationKeyOwnership;
|
|
2847
|
-
revealable: boolean;
|
|
2848
|
-
enabled: boolean;
|
|
2849
|
-
revoked: boolean;
|
|
2850
|
-
allowedEndpoints: OutboundPermission[];
|
|
2851
|
-
requiredEndpoints: OutboundPermission[];
|
|
2852
|
-
loopbackOnly: boolean;
|
|
2852
|
+
interface PreparedImageRuntimeChange {
|
|
2853
|
+
readonly generationId: string;
|
|
2854
|
+
publish(): void;
|
|
2855
|
+
rollback(): void;
|
|
2856
|
+
dispose(): Promise<void>;
|
|
2853
2857
|
}
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2858
|
+
/** App-session owner for stable forwarders and generation-pinned work. */
|
|
2859
|
+
declare class ImageRuntimeManager {
|
|
2860
|
+
#private;
|
|
2861
|
+
readonly contributions: ImageApiContributions;
|
|
2862
|
+
constructor(initial?: PreparedImageRuntimeGeneration);
|
|
2863
|
+
prepare(generation: PreparedImageRuntimeGeneration): PreparedImageRuntimeChange;
|
|
2864
|
+
acquireHosted(): Promise<HostedImageRuntimeGenerationLease>;
|
|
2865
|
+
inspectCapability(apiKeyId: string): Promise<ImageRuntimeCapabilityInspection>;
|
|
2866
|
+
listAvailableModels(apiKeyId: string): Promise<readonly string[]>;
|
|
2867
|
+
resourceStatus(): ImageRuntimeResourceStatus | undefined;
|
|
2868
|
+
status(): ImageRuntimeManagerStatus;
|
|
2869
|
+
dispose(): Promise<void>;
|
|
2864
2870
|
}
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2871
|
+
|
|
2872
|
+
type SafeProvider = 'codex-subscription' | 'unknown' | 'other';
|
|
2873
|
+
type SafeModel = 'gpt-image-2' | 'unknown' | 'other';
|
|
2874
|
+
type SafeErrorCode = ImageGenerationErrorCode | 'none' | 'other';
|
|
2875
|
+
type SafeCountOption = 'unknown' | '0' | '1' | '2-4' | '5+';
|
|
2876
|
+
type SafeBooleanOption = boolean | 'unknown';
|
|
2877
|
+
type SafeQuality = 'auto' | 'low' | 'medium' | 'high' | 'unknown' | 'other';
|
|
2878
|
+
type SafeBackground = 'auto' | 'opaque' | 'transparent' | 'unknown' | 'other';
|
|
2879
|
+
type SafeOutputFormat = 'png' | 'jpeg' | 'webp' | 'unknown' | 'other';
|
|
2880
|
+
declare const IMAGE_CONFIGURATION_AUDIT_FIELDS: readonly ["enablement", "provider", "model", "account", "queue", "temporary", "limits", "retention", "storage", "remote", "evidence"];
|
|
2881
|
+
type ImageConfigurationAuditField = typeof IMAGE_CONFIGURATION_AUDIT_FIELDS[number];
|
|
2882
|
+
/** Values are deliberately limited to safe categories and internal generation ids. */
|
|
2883
|
+
interface ImageConfigurationAuditRecord {
|
|
2884
|
+
readonly outcome: 'applied';
|
|
2885
|
+
readonly fields: readonly ImageConfigurationAuditField[];
|
|
2886
|
+
readonly previousGenerationId?: string;
|
|
2887
|
+
readonly generationId?: string;
|
|
2873
2888
|
}
|
|
2874
|
-
interface
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
installedAt: number;
|
|
2883
|
-
gatewayBaseUrl: string;
|
|
2884
|
-
/** Codex auth.json snapshot and installed hash; absent on legacy records. */
|
|
2885
|
-
credentialFile?: IntegrationManagedFileRecord;
|
|
2886
|
-
}
|
|
2887
|
-
interface IntegrationManagedFileRecord {
|
|
2888
|
-
path: string;
|
|
2889
|
-
originalExisted: boolean;
|
|
2890
|
-
/** Encrypted by IntegrationStateStore before it reaches disk. */
|
|
2891
|
-
originalContent: string;
|
|
2892
|
-
originalHash: string;
|
|
2893
|
-
installedHash: string;
|
|
2889
|
+
interface ImageHistogramSnapshot {
|
|
2890
|
+
readonly count: number;
|
|
2891
|
+
readonly sum: number;
|
|
2892
|
+
/** Non-cumulative fixed buckets; `upperBound:null` is the overflow bucket. */
|
|
2893
|
+
readonly buckets: readonly {
|
|
2894
|
+
readonly upperBound: number | null;
|
|
2895
|
+
readonly count: number;
|
|
2896
|
+
}[];
|
|
2894
2897
|
}
|
|
2895
|
-
interface
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2898
|
+
interface ImageApiMetricDimensions {
|
|
2899
|
+
readonly endpoint: 'images.generate' | 'images.edit';
|
|
2900
|
+
readonly provider: SafeProvider;
|
|
2901
|
+
readonly model: SafeModel;
|
|
2902
|
+
readonly action: 'generate' | 'edit';
|
|
2903
|
+
readonly quality: SafeQuality;
|
|
2904
|
+
readonly background: SafeBackground;
|
|
2905
|
+
readonly outputFormat: SafeOutputFormat;
|
|
2906
|
+
readonly streaming: SafeBooleanOption;
|
|
2907
|
+
readonly requestedOutputs: SafeCountOption;
|
|
2908
|
+
readonly partialImages: SafeCountOption;
|
|
2909
|
+
readonly terminal: 'completed' | 'failed' | 'cancelled';
|
|
2910
|
+
readonly errorCode: SafeErrorCode;
|
|
2900
2911
|
}
|
|
2901
|
-
interface
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2912
|
+
interface ImageExecutionMetricDimensions {
|
|
2913
|
+
readonly provider: SafeProvider;
|
|
2914
|
+
readonly model: SafeModel;
|
|
2915
|
+
readonly action: 'generate' | 'edit' | 'other';
|
|
2916
|
+
readonly quality: SafeQuality;
|
|
2917
|
+
readonly background: SafeBackground;
|
|
2918
|
+
readonly outputFormat: SafeOutputFormat;
|
|
2919
|
+
readonly streaming: SafeBooleanOption;
|
|
2920
|
+
readonly requestedOutputs: SafeCountOption;
|
|
2921
|
+
readonly terminal: 'completed' | 'failed' | 'cancelled' | 'other';
|
|
2922
|
+
readonly errorCode: SafeErrorCode;
|
|
2907
2923
|
}
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
readonly
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2924
|
+
interface ImageApiMetricSnapshot {
|
|
2925
|
+
readonly dimensions: ImageApiMetricDimensions;
|
|
2926
|
+
readonly requests: number;
|
|
2927
|
+
readonly inputCount?: ImageHistogramSnapshot;
|
|
2928
|
+
readonly inputBytes?: ImageHistogramSnapshot;
|
|
2929
|
+
readonly referenceOutcomes: Readonly<{
|
|
2930
|
+
hits: number;
|
|
2931
|
+
notFound: number;
|
|
2932
|
+
expired: number;
|
|
2933
|
+
failed: number;
|
|
2934
|
+
}>;
|
|
2935
|
+
readonly cleanupOutcomes: Readonly<{
|
|
2936
|
+
completed: number;
|
|
2937
|
+
failed: number;
|
|
2938
|
+
}>;
|
|
2916
2939
|
}
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2940
|
+
interface ImageExecutionMetricSnapshot {
|
|
2941
|
+
readonly dimensions: ImageExecutionMetricDimensions;
|
|
2942
|
+
readonly executions: number;
|
|
2943
|
+
readonly finalLatencyMs: ImageHistogramSnapshot;
|
|
2944
|
+
readonly queueWaitMs?: ImageHistogramSnapshot;
|
|
2945
|
+
readonly generationDurationMs?: ImageHistogramSnapshot;
|
|
2946
|
+
readonly firstPartialLatencyMs?: ImageHistogramSnapshot;
|
|
2947
|
+
readonly inputCount: ImageHistogramSnapshot;
|
|
2948
|
+
readonly inputBytes: ImageHistogramSnapshot;
|
|
2949
|
+
readonly outputCount: ImageHistogramSnapshot;
|
|
2950
|
+
readonly outputBytes: ImageHistogramSnapshot;
|
|
2951
|
+
readonly retryCount?: ImageHistogramSnapshot;
|
|
2952
|
+
readonly authRefreshCount?: ImageHistogramSnapshot;
|
|
2953
|
+
readonly referenceSaveCount?: ImageHistogramSnapshot;
|
|
2954
|
+
readonly retentionRollbackFailures?: ImageHistogramSnapshot;
|
|
2925
2955
|
}
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
plan(client: IntegrationClientId, configPath?: string): Promise<IntegrationChangePlan>;
|
|
2934
|
-
install(client: IntegrationClientId, configPath?: string): Promise<IntegrationClientStatus>;
|
|
2935
|
-
repair(client: IntegrationClientId): Promise<IntegrationClientStatus>;
|
|
2936
|
-
remove(client: IntegrationClientId): Promise<IntegrationClientStatus>;
|
|
2937
|
-
/** Bind a user-confirmed access key and grant only this client's required endpoints. */
|
|
2938
|
-
bindIntegrationKey(client: IntegrationClientId, keyId: string): Promise<IntegrationClientStatus>;
|
|
2939
|
-
/** Rotate every Omnicross-managed client binding; user-selected keys remain untouched. */
|
|
2940
|
-
rotateGatewayKey(): Promise<{
|
|
2941
|
-
keyIds: Partial<Record<IntegrationClientId, string>>;
|
|
2956
|
+
interface ImageObservabilitySnapshot {
|
|
2957
|
+
readonly apiRequests: readonly ImageApiMetricSnapshot[];
|
|
2958
|
+
readonly executions: readonly ImageExecutionMetricSnapshot[];
|
|
2959
|
+
readonly configurationChanges: readonly ImageConfigurationAuditRecord[];
|
|
2960
|
+
readonly overflow: Readonly<{
|
|
2961
|
+
apiRecords: number;
|
|
2962
|
+
telemetryRecords: number;
|
|
2942
2963
|
}>;
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
/**
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
private
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2964
|
+
}
|
|
2965
|
+
interface ImageObservabilityOptions {
|
|
2966
|
+
/** Hard cap applied independently to API and execution dimension maps. */
|
|
2967
|
+
readonly maxDimensionSets?: number;
|
|
2968
|
+
}
|
|
2969
|
+
/** Process-local, metadata-only aggregation for HTTP and hosted Images work. */
|
|
2970
|
+
declare class ImageObservability {
|
|
2971
|
+
#private;
|
|
2972
|
+
readonly telemetrySink: ImageTelemetrySink;
|
|
2973
|
+
readonly audit: (record: ImageApiAuditRecord) => void;
|
|
2974
|
+
constructor(options?: ImageObservabilityOptions);
|
|
2975
|
+
recordApiAudit(record: ImageApiAuditRecord): void;
|
|
2976
|
+
recordTelemetry(record: ImageTelemetryRecord): void;
|
|
2977
|
+
recordConfigurationAudit(record: ImageConfigurationAuditRecord): void;
|
|
2978
|
+
snapshot(): ImageObservabilitySnapshot;
|
|
2979
|
+
reset(): void;
|
|
2980
|
+
}
|
|
2981
|
+
|
|
2982
|
+
interface PreparedServerConfigChange {
|
|
2983
|
+
/** Publish the prepared snapshot. Implementations should make this an infallible swap. */
|
|
2984
|
+
publish(): void | Promise<void>;
|
|
2985
|
+
/** Restore the exact runtime snapshot that preceded publish. */
|
|
2986
|
+
rollback(): void | Promise<void>;
|
|
2987
|
+
/** Release an unpublished or rolled-back replacement. */
|
|
2988
|
+
dispose(): void | Promise<void>;
|
|
2956
2989
|
}
|
|
2957
2990
|
|
|
2958
2991
|
/**
|
|
2959
|
-
*
|
|
2960
|
-
* OAuth path (`POST /accounts/antigravity/oauth/start` +
|
|
2961
|
-
* `GET /accounts/antigravity/oauth/:sessionId/status`).
|
|
2962
|
-
*
|
|
2963
|
-
* Modeled on the codex loopback flow (`accountsCodexOAuth`): antigravity's
|
|
2964
|
-
* redirect is a FIXED loopback `http://127.0.0.1:51121/oauth-callback`, so the
|
|
2965
|
-
* flow is ASYNC + POLLED — `start` arms the one-shot loopback listener, kicks
|
|
2966
|
-
* the capture→exchange→email→project-handshake→persist chain off ASYNC, and
|
|
2967
|
-
* returns ONLY `{ authUrl, sessionId }` (public — client_id + state). The app
|
|
2968
|
-
* opens `authUrl`; the browser redirects to the loopback; the daemon captures
|
|
2969
|
-
* the `code`, validates `state`, exchanges it, resolves the userinfo email and
|
|
2970
|
-
* the Code Assist project (the antigravity dialect of the shared resolver),
|
|
2971
|
-
* and persists the minted token through the encrypted credential store. The
|
|
2972
|
-
* app POLLS `status` until `done`/`error`.
|
|
2992
|
+
* autoDisableStore.ts — the daemon's PROCESS-IN-MEMORY auto-disable store.
|
|
2973
2993
|
*
|
|
2974
|
-
*
|
|
2975
|
-
*
|
|
2976
|
-
*
|
|
2977
|
-
*
|
|
2994
|
+
* A DB-backed embedder can persist 401/403 auto-disable durably so a UI can
|
|
2995
|
+
* render per-key health. The daemon has no DB, and its only
|
|
2996
|
+
* durable layer is `config.json` — but writing auto-disable back there in v1
|
|
2997
|
+
* would (1) cause write amplification under a 401 storm and (2) collide with
|
|
2998
|
+
* the at-rest encryption schema that owns the `apiKeys[]` on-disk
|
|
2999
|
+
* format. So v1 records auto-disable IN MEMORY only:
|
|
3000
|
+
* - `markAutoDisabled(keyId, status, at)` records `{ status, at, reason }`,
|
|
3001
|
+
* - `isDisabled(keyId)` / `get(keyId)` read it back,
|
|
3002
|
+
* - `loadPoolKeys` reads this store and flips a flagged key's `enabled` to
|
|
3003
|
+
* `false`, so `getAvailableKeys` skips it within this process lifetime.
|
|
2978
3004
|
*
|
|
2979
|
-
*
|
|
2980
|
-
*
|
|
2981
|
-
* the authorize/exchange/handshake logic.
|
|
3005
|
+
* Restart resets the store (the honest v1 boundary — see spec). Persistence
|
|
3006
|
+
* (encrypted write-back) is a child-3 follow-up.
|
|
2982
3007
|
*
|
|
2983
|
-
* @module @omnicross/daemon/
|
|
3008
|
+
* @module @omnicross/daemon/pool/autoDisableStore
|
|
2984
3009
|
*/
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
3010
|
+
/** One in-memory auto-disable record for a pool key. */
|
|
3011
|
+
interface AutoDisableRecord {
|
|
3012
|
+
/** The HTTP status that triggered the disable (401/403). */
|
|
3013
|
+
status: number;
|
|
3014
|
+
/** Epoch-ms when the disable was recorded. */
|
|
3015
|
+
at: number;
|
|
3016
|
+
/** Always `'auth_failure'` in v1 (the only auto-disable trigger). */
|
|
3017
|
+
reason: 'auth_failure';
|
|
3018
|
+
}
|
|
3019
|
+
/**
|
|
3020
|
+
* A process-lifetime in-memory store of auto-disabled pool keys, keyed by the
|
|
3021
|
+
* pool key id. Constructed once in `buildDaemon` and injected as the pool's
|
|
3022
|
+
* `disableKey` / `markAutoDisabled` sinks AND read by `loadPoolKeys`.
|
|
3023
|
+
*/
|
|
3024
|
+
declare class AutoDisableStore {
|
|
3025
|
+
private readonly records;
|
|
3026
|
+
/** Record (or overwrite) an auth-failure auto-disable for `keyId`. */
|
|
3027
|
+
markAutoDisabled(keyId: string, status: number, at: number): void;
|
|
3028
|
+
/** Whether `keyId` is currently auto-disabled in this process. */
|
|
3029
|
+
isDisabled(keyId: string): boolean;
|
|
3030
|
+
/** Read the auto-disable record for `keyId`, or `undefined` when healthy. */
|
|
3031
|
+
get(keyId: string): AutoDisableRecord | undefined;
|
|
3032
|
+
/** Clear all records (tests / teardown). */
|
|
3033
|
+
clear(): void;
|
|
3034
|
+
}
|
|
2988
3035
|
|
|
2989
3036
|
/**
|
|
2990
|
-
*
|
|
2991
|
-
*
|
|
3037
|
+
* ConfigFileProviderConfigSource — the daemon's file-backed `ProviderConfigSource`
|
|
3038
|
+
* port impl: an embedder of `@omnicross/core`'s provider catalog port.
|
|
2992
3039
|
*
|
|
2993
|
-
*
|
|
2994
|
-
*
|
|
2995
|
-
*
|
|
2996
|
-
*
|
|
2997
|
-
*
|
|
2998
|
-
*
|
|
2999
|
-
*
|
|
3040
|
+
* The daemon's `config.json` provider rows ARE the catalog. Of the port's ten
|
|
3041
|
+
* methods, FOUR are real (the ones the BYO proxy/outbound path actually hits):
|
|
3042
|
+
* - `getProvider(id)` — map a `DaemonProviderConfig` row to an `LLMProvider`.
|
|
3043
|
+
* - `getTransformerService()` — a single `TransformerService` seeded by
|
|
3044
|
+
* `registerBuiltinTransformers` in the ctor.
|
|
3045
|
+
* - `getMainTransformer(id)` — the transformer for the provider's target wire
|
|
3046
|
+
* format (anthropic → AnthropicTransformer, gemini → GeminiTransformer,
|
|
3047
|
+
* openai → null/identity), mirroring the host `AgentModelsManager` switch.
|
|
3048
|
+
* `resolveProviderChain` unshifts this FORMAT-FIRST into the provider chain.
|
|
3049
|
+
* - `resolveTransformerChain(id, model)` — the provider's CUSTOM
|
|
3050
|
+
* `transformer.use[]` chain (app-parity-2 child 2: ENFORCED). The format
|
|
3051
|
+
* transformer is NOT included here (getMainTransformer supplies it,
|
|
3052
|
+
* format-first); no `transformer.use[]` → empty chain.
|
|
3000
3053
|
*
|
|
3001
|
-
*
|
|
3002
|
-
*
|
|
3003
|
-
* (inherited by the terminal), never the command line / a file on disk.
|
|
3054
|
+
* The remaining SIX are minimal sensible stubs (never hit on the BYO single-key
|
|
3055
|
+
* path — the boot smoke test is the proof).
|
|
3004
3056
|
*
|
|
3005
|
-
* @module @omnicross/daemon/
|
|
3057
|
+
* @module @omnicross/daemon/ports/ConfigFileProviderConfigSource
|
|
3006
3058
|
*/
|
|
3007
3059
|
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
/**
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3060
|
+
declare class ConfigFileProviderConfigSource implements ProviderConfigSource {
|
|
3061
|
+
private readonly providers;
|
|
3062
|
+
private readonly transformerService;
|
|
3063
|
+
/**
|
|
3064
|
+
* Optional reload-hook (key-pool change, design D4). A no-type-coupling
|
|
3065
|
+
* callback invoked at the END of `reload(...)`. `buildDaemon` injects
|
|
3066
|
+
* `() => pool.invalidateCache()` so the `ApiKeyPoolService.keyCache` is
|
|
3067
|
+
* flushed after a hot-reload swaps the catalog — WITHOUT this port ever
|
|
3068
|
+
* importing/depending on `ApiKeyPoolService`. Absent = no-op (single-key
|
|
3069
|
+
* boots that never construct a pool stay byte-identical).
|
|
3070
|
+
*/
|
|
3071
|
+
private reloadHook;
|
|
3072
|
+
constructor(config: DaemonConfig);
|
|
3073
|
+
/**
|
|
3074
|
+
* Register a callback fired after every `reload(...)`. Used by `buildDaemon`
|
|
3075
|
+
* to invalidate the pool's keyCache on a hot-reload. The port stays ignorant
|
|
3076
|
+
* of what the callback does (no pool type dependency).
|
|
3077
|
+
*/
|
|
3078
|
+
setReloadHook(fn: () => void): void;
|
|
3079
|
+
/**
|
|
3080
|
+
* Read the live (post-reload) provider row for `providerId`, or `undefined`.
|
|
3081
|
+
* Exposed so the pool's `loadKeys` reads the SAME live catalog Map this port
|
|
3082
|
+
* serves (so a hot-reload is observed on the next load after `invalidateCache`).
|
|
3083
|
+
*/
|
|
3084
|
+
getProviderRow(providerId: string): DaemonProviderConfig | undefined;
|
|
3085
|
+
/** Await the built-in transformer registration (tests await this before dispatch). */
|
|
3086
|
+
ready(): Promise<void>;
|
|
3087
|
+
/**
|
|
3088
|
+
* Replace the live provider catalog in place (additive — does NOT touch the
|
|
3089
|
+
* ten port methods, the seeded `TransformerService`, or `ready()`). Called by
|
|
3090
|
+
* the admin API after a provider POST/PUT/DELETE persists `config.json`, so the
|
|
3091
|
+
* next outbound request sees the new catalog WITHOUT a daemon restart. The Map
|
|
3092
|
+
* swap is synchronous; an in-flight request keeps its already-resolved
|
|
3093
|
+
* provider (no locking needed for a single-operator local daemon).
|
|
3094
|
+
*/
|
|
3095
|
+
reload(config: DaemonConfig): void;
|
|
3096
|
+
/** Clear + repopulate the private providers Map from a fresh provider list. */
|
|
3097
|
+
setProviders(providers: readonly DaemonProviderConfig[]): void;
|
|
3098
|
+
getProvider(id: string): Promise<LLMProvider | null>;
|
|
3099
|
+
getTransformerService(): TransformerService | undefined;
|
|
3100
|
+
getMainTransformer(providerId: string): Promise<Transformer | null>;
|
|
3101
|
+
resolveTransformerChain(providerId: string, _model?: string): Promise<ResolvedTransformerChain>;
|
|
3102
|
+
resolveRoutedModel(): Promise<null>;
|
|
3103
|
+
resolveEffectiveModels(): Promise<{
|
|
3104
|
+
background?: string;
|
|
3105
|
+
vision?: string;
|
|
3106
|
+
}>;
|
|
3107
|
+
getAgentDefaultModels(): Promise<AgentDefaultModels>;
|
|
3108
|
+
hasVisionCapability(): Promise<boolean>;
|
|
3109
|
+
getGlobalModelParameters(): Promise<GlobalModelParameters>;
|
|
3110
|
+
getDiscoveredModelMaxTokens(): Promise<number | undefined>;
|
|
3111
|
+
}
|
|
3030
3112
|
|
|
3031
3113
|
/**
|
|
3032
|
-
*
|
|
3033
|
-
*
|
|
3034
|
-
*
|
|
3035
|
-
* Three routes over the daemon's search state, dispatched from `adminApi.ts`'s
|
|
3036
|
-
* `case 'search'`:
|
|
3037
|
-
*
|
|
3038
|
-
* - `GET /admin/api/search/diagnostics` — a READ-ONLY, secret-free, network-free
|
|
3039
|
-
* snapshot: one row per provider the daemon can run (the ONE runtime's
|
|
3040
|
-
* descriptors, plus `unconfigured` rows for known API providers the persisted
|
|
3041
|
-
* config does not name — the doctor's classification), the effective frontend
|
|
3042
|
-
* modes, and the explicit apply semantics (codex immediate, rest restart).
|
|
3043
|
-
* - `POST /admin/api/search/test { providerId }` — ONE live fixed-query check on
|
|
3044
|
-
* a configured provider, classified by the doctor's pure functions. The
|
|
3045
|
-
* machine-facing health probe: it sends exactly `SEARCH_DOCTOR_QUERY`, never a
|
|
3046
|
-
* caller-supplied query, and never returns result content (plan §11.3 — its
|
|
3047
|
-
* contract is the automated doctor's fixed-query discipline).
|
|
3048
|
-
* - `POST /admin/api/search/query { providerId, query }` — the INTERACTIVE
|
|
3049
|
-
* channel for the settings page's per-provider test panel (owner feedback
|
|
3050
|
-
* 2026-09-02): ONE operator-typed query through ONE provider's contribution
|
|
3051
|
-
* built from the PERSISTED config, returning the doctor-classified diagnostic
|
|
3052
|
-
* PLUS the sanitized results. The two disciplines stay separate routes on
|
|
3053
|
-
* purpose: bending `/test` to accept a query would erase the boundary its
|
|
3054
|
-
* pinned tests and consumers depend on.
|
|
3114
|
+
* JsonApiServerSettingsStore — the daemon's file-backed `ApiServerSettingsStore`
|
|
3115
|
+
* port impl.
|
|
3055
3116
|
*
|
|
3056
|
-
*
|
|
3057
|
-
*
|
|
3058
|
-
*
|
|
3059
|
-
*
|
|
3060
|
-
*
|
|
3061
|
-
*
|
|
3117
|
+
* The serving core persists the outbound-API server config (`{ enabled,
|
|
3118
|
+
* networkBinding, endpoints, port }`) under a SINGLE settings key
|
|
3119
|
+
* (`OUTBOUND_API_SERVER_CONFIG_KEY === 'outboundApiServer.config'`). Here that
|
|
3120
|
+
* store is the daemon's `config.json` `server`
|
|
3121
|
+
* field. `loadServerConfig(store)` / `saveServerConfig(store, cfg)` (core)
|
|
3122
|
+
* normalize + persist through this 2-method surface.
|
|
3062
3123
|
*
|
|
3063
|
-
*
|
|
3064
|
-
*
|
|
3065
|
-
* optionality precedent) rather than a fabricated snapshot.
|
|
3124
|
+
* Only the one outbound-API key is ever read/written — any other key is a no-op
|
|
3125
|
+
* miss (returns `undefined`) so the surface stays honest about what it backs.
|
|
3066
3126
|
*
|
|
3067
|
-
* @module @omnicross/daemon/
|
|
3127
|
+
* @module @omnicross/daemon/ports/JsonApiServerSettingsStore
|
|
3068
3128
|
*/
|
|
3069
3129
|
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
readonly
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3130
|
+
interface JsonSettingsDocumentSnapshot {
|
|
3131
|
+
readonly existed: boolean;
|
|
3132
|
+
/** Raw persisted bytes; may contain encrypted secrets and must never enter a DTO or log. */
|
|
3133
|
+
readonly bytes?: Uint8Array;
|
|
3134
|
+
}
|
|
3135
|
+
type AtomicDocumentReplace = (targetPath: string, contents: Uint8Array) => void;
|
|
3136
|
+
declare class JsonApiServerSettingsStore implements ApiServerSettingsStore {
|
|
3137
|
+
private readonly configPath;
|
|
3138
|
+
private readonly box;
|
|
3139
|
+
private readonly atomicReplace;
|
|
3140
|
+
/**
|
|
3141
|
+
* @param configPath the daemon config.json whose `server` field is backed.
|
|
3142
|
+
* @param box OPTIONAL at-rest `SecretBox` (upstream-proxy). When set, the
|
|
3143
|
+
* `server.proxy.*` passwords are encrypted-on-`set` /
|
|
3144
|
+
* decrypted-on-`get` (the settings-store path is otherwise not
|
|
3145
|
+
* secret-aware — every OTHER server field is non-secret). Null
|
|
3146
|
+
* ⇒ passthrough (legacy/pure tests unchanged).
|
|
3147
|
+
*/
|
|
3148
|
+
constructor(configPath: string, box?: SecretBox | null, atomicReplace?: AtomicDocumentReplace);
|
|
3149
|
+
get<T = unknown>(key: string): Promise<T | undefined>;
|
|
3150
|
+
set<T = unknown>(key: string, value: T): Promise<void>;
|
|
3151
|
+
/** Capture the exact prior document for an admin transaction rollback. */
|
|
3152
|
+
captureDocumentSnapshot(): JsonSettingsDocumentSnapshot;
|
|
3153
|
+
/** Restore exact prior bytes (including unrelated fields and encrypted secrets). */
|
|
3154
|
+
restoreDocumentSnapshot(snapshot: JsonSettingsDocumentSnapshot): void;
|
|
3155
|
+
/** Encrypt the proxy passwords + webhook + billing secrets before persisting (no-op without a box). */
|
|
3156
|
+
private encryptSecrets;
|
|
3157
|
+
/** Decrypt the proxy passwords + webhook + billing secrets on read (no-op without a box). */
|
|
3158
|
+
private decryptSecrets;
|
|
3159
|
+
/** Read the config.json, tolerating a missing/corrupt file (→ empty shape). */
|
|
3160
|
+
private readFile;
|
|
3083
3161
|
}
|
|
3084
3162
|
|
|
3085
3163
|
/**
|
|
3086
|
-
*
|
|
3087
|
-
* (app-parity child 6, design D2/D3/D5).
|
|
3088
|
-
*
|
|
3089
|
-
* EXPORT (`gatherExport`): read the FULL local state DECRYPTED in-memory — every
|
|
3090
|
-
* provider row (scalars / modelConfigs / single apiKey / pool apiKeys /
|
|
3091
|
-
* transformer) via `loadConfig` (the at-rest box decrypts on read) AND the
|
|
3092
|
-
* subscription tokens via `credentialStore.getFullConfig()` (also decrypted) —
|
|
3093
|
-
* serialize to ONE bundle JSON, and `sealPack` it under the passphrase-derived
|
|
3094
|
-
* key. The caller returns ONLY the opaque pack; the decrypted bundle + the
|
|
3095
|
-
* passphrase live only in local variables and are never logged.
|
|
3164
|
+
* JsonPricingStore — the daemon's file-backed `PricingStore` port impl.
|
|
3096
3165
|
*
|
|
3097
|
-
*
|
|
3098
|
-
*
|
|
3099
|
-
*
|
|
3100
|
-
*
|
|
3101
|
-
*
|
|
3102
|
-
*
|
|
3103
|
-
* Apply merges by provider id (additive default): a new id is added; a colliding
|
|
3104
|
-
* id is skipped (or overwritten with `mode:'overwrite'`). Writes go through the
|
|
3105
|
-
* EXISTING paths (`saveConfig` re-encrypts at-rest under the LOCAL box +
|
|
3106
|
-
* `writeProviderTokens`/`appendProviderAccount`), so imported secrets land
|
|
3107
|
-
* `enc:`-encrypted under the TARGET machine's key — the passphrase key is used
|
|
3108
|
-
* ONLY for transport.
|
|
3166
|
+
* Durable storage for the model pricing table, backed by a pretty-printed json
|
|
3167
|
+
* file (a sibling of `config.json`, `pricing.json` by convention) holding a
|
|
3168
|
+
* `PricingEntry[]`. Reads tolerate a missing/corrupt file (→ empty table);
|
|
3169
|
+
* every mutation rewrites the full array (the table is at most a few thousand
|
|
3170
|
+
* rows — same trade-off as `JsonOutboundKeyDb`). The table starts EMPTY: no
|
|
3171
|
+
* seeding — the first pricing-source refresh (or a manual upsert) populates it.
|
|
3109
3172
|
*
|
|
3110
|
-
*
|
|
3111
|
-
*
|
|
3112
|
-
*
|
|
3173
|
+
* Beyond the core port, the store exposes a STORE-LOCAL `delete` (the port is
|
|
3174
|
+
* frozen; the admin DELETE route calls the concrete class and then invalidates
|
|
3175
|
+
* the engine cache).
|
|
3113
3176
|
*
|
|
3114
|
-
* @module @omnicross/daemon/
|
|
3115
|
-
*/
|
|
3116
|
-
|
|
3117
|
-
/**
|
|
3118
|
-
* The credential-store surface the migration paths need: the full DECRYPTED read
|
|
3119
|
-
* (export) + the multi-account append (import re-encrypts at-rest). One shape so
|
|
3120
|
-
* `ExportDeps` + `ImportDeps` can be unified into `MigrationDeps` without a
|
|
3121
|
-
* `credentialStore` type conflict.
|
|
3177
|
+
* @module @omnicross/daemon/ports/JsonPricingStore
|
|
3122
3178
|
*/
|
|
3123
|
-
interface MigrationCredentialStore extends SubscriptionAccountAppender {
|
|
3124
|
-
getFullConfig(): Promise<AccountTokensConfig>;
|
|
3125
|
-
}
|
|
3126
|
-
|
|
3127
|
-
/** Minimal, auth-gated admin API for secret-free account allowance snapshots. */
|
|
3128
|
-
|
|
3129
|
-
interface AccountAllowanceAdminReader {
|
|
3130
|
-
list(filter?: {
|
|
3131
|
-
providerId?: SubscriptionProviderId;
|
|
3132
|
-
accountId?: string;
|
|
3133
|
-
}): Promise<AccountAllowanceSnapshot[]>;
|
|
3134
|
-
refreshClaude(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
|
|
3135
|
-
/** Optional: Codex active `/wham/usage` refresh (absent on older daemons). */
|
|
3136
|
-
refreshCodex?(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
|
|
3137
|
-
/** Optional: Kimi `/coding/v1/usages` refresh (absent on older daemons). */
|
|
3138
|
-
refreshKimi?(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
|
|
3139
|
-
/** Optional: OpenCodeGo `/v1/usage` refresh (absent on older daemons). */
|
|
3140
|
-
refreshOpenCodeGo?(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
|
|
3141
|
-
/** Optional: Grok CLI-billing refresh (absent on older daemons). */
|
|
3142
|
-
refreshGrok?(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
|
|
3143
|
-
/** Optional: Copilot user-quota refresh (absent on older daemons). */
|
|
3144
|
-
refreshCopilot?(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
|
|
3145
|
-
/** Optional: Gemini Code-Assist quota refresh (absent on older daemons). */
|
|
3146
|
-
refreshGemini?(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
|
|
3147
|
-
/** Optional: Antigravity quotaSummary refresh (absent on older daemons). */
|
|
3148
|
-
refreshAntigravity?(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
|
|
3149
|
-
removeAccountSnapshot?(providerId: SubscriptionProviderId, accountId: string): void;
|
|
3150
|
-
removeProviderSnapshots?(providerId: SubscriptionProviderId): void;
|
|
3151
|
-
getSchedulingStatus?(): AccountAllowanceSchedulingStatus;
|
|
3152
|
-
}
|
|
3153
3179
|
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
}
|
|
3158
|
-
/** One key's live cooldown health (mirrors core `KeyHealthEntry`; read-only). */
|
|
3159
|
-
interface PoolKeyHealth {
|
|
3160
|
-
until: number;
|
|
3161
|
-
errors: number;
|
|
3162
|
-
lastStatus: number | null;
|
|
3163
|
-
}
|
|
3164
|
-
/**
|
|
3165
|
-
* The READ-ONLY pool-health surface the admin view needs (key-pool design D7).
|
|
3166
|
-
* Structurally satisfied by core's `ApiKeyPoolService.getKeyHealth`; typed as a
|
|
3167
|
-
* minimal reader so `adminApi` carries no class coupling and can never reach a
|
|
3168
|
-
* key value through it (cooldown health only).
|
|
3169
|
-
*/
|
|
3170
|
-
interface PoolHealthReader {
|
|
3171
|
-
getKeyHealth(providerId: string): Promise<Record<string, PoolKeyHealth>>;
|
|
3172
|
-
}
|
|
3173
|
-
/**
|
|
3174
|
-
* The BYO provider-key quota surface the keys view needs — structurally
|
|
3175
|
-
* satisfied by `ProviderKeyQuotaService`. Read-only; the DTO is secret-free by
|
|
3176
|
-
* construction (normalized windows + diagnostic codes only).
|
|
3177
|
-
*/
|
|
3178
|
-
interface ProviderKeyQuotaReader {
|
|
3179
|
-
quotaFor(row: DaemonProviderConfig, keyId: string, options?: {
|
|
3180
|
-
force?: boolean;
|
|
3181
|
-
}): Promise<ProviderKeyQuota | null>;
|
|
3182
|
-
}
|
|
3183
|
-
interface AdminImagesStatusReader {
|
|
3184
|
-
inspectCapability(apiKeyId: string): Promise<ImageRuntimeCapabilityInspection>;
|
|
3185
|
-
status(): ImageRuntimeManagerStatus;
|
|
3186
|
-
resourceStatus(): ImageRuntimeResourceStatus | undefined;
|
|
3187
|
-
}
|
|
3188
|
-
/** The live daemon handles the management API operates over. */
|
|
3189
|
-
interface AdminApiDeps {
|
|
3190
|
-
/** Path to the daemon's `config.json` (provider catalog + `server` field). */
|
|
3191
|
-
readonly configPath: string;
|
|
3192
|
-
/** Live provider catalog (hot-reload target). */
|
|
3193
|
-
readonly llmConfig: ConfigFileProviderConfigSource;
|
|
3194
|
-
/** Named outbound-key store. */
|
|
3195
|
-
readonly keyDb: OutboundKeyDb$1;
|
|
3180
|
+
declare class JsonPricingStore implements PricingStore {
|
|
3181
|
+
private readonly pricingPath;
|
|
3182
|
+
constructor(pricingPath: string);
|
|
3196
3183
|
/**
|
|
3197
|
-
*
|
|
3198
|
-
*
|
|
3199
|
-
*
|
|
3184
|
+
* Return whether the durable snapshot can actually serve at least one price.
|
|
3185
|
+
*
|
|
3186
|
+
* This intentionally checks the file itself instead of relying on refresh
|
|
3187
|
+
* metadata: a recent `lastSuccessAt` must not hide a deleted, truncated, or
|
|
3188
|
+
* otherwise unusable pricing table after a crash or manual file edit.
|
|
3200
3189
|
*/
|
|
3201
|
-
|
|
3190
|
+
hasUsableSnapshot(): boolean;
|
|
3191
|
+
getAll(): Promise<PricingEntry[]>;
|
|
3202
3192
|
/**
|
|
3203
|
-
*
|
|
3204
|
-
*
|
|
3205
|
-
*
|
|
3193
|
+
* Insert or update one row keyed (providerId, modelId). `asUserEdit` stamps
|
|
3194
|
+
* user provenance (source 'user', userEdited, editedAt now) so the row is
|
|
3195
|
+
* protected from auto-overwrite during source refreshes; a non-user upsert
|
|
3196
|
+
* stamps source 'litellm' and clears nothing it should not (a plain source
|
|
3197
|
+
* upsert through this method overwrites the row wholesale).
|
|
3206
3198
|
*/
|
|
3207
|
-
|
|
3208
|
-
/** Outbound server settings store (server config persistence). */
|
|
3209
|
-
readonly settingsStore: JsonApiServerSettingsStore;
|
|
3210
|
-
/** The running outbound server (status + live applyConfig). */
|
|
3211
|
-
readonly outboundApiServer: OutboundApiServer;
|
|
3212
|
-
/** True only when production composed the hardened per-hop remote resolver. */
|
|
3213
|
-
readonly imageRemoteResolverAvailable?: boolean;
|
|
3214
|
-
/** Optional production Images runtime generation participant. */
|
|
3215
|
-
readonly imageRuntimeConfig?: {
|
|
3216
|
-
prepareConfig(config: ImagesServerConfig): Promise<PreparedServerConfigChange>;
|
|
3217
|
-
};
|
|
3218
|
-
/** Narrow metadata-only reader for authenticated Images capability/status. */
|
|
3219
|
-
readonly imageRuntimeStatus?: AdminImagesStatusReader;
|
|
3220
|
-
/** Metadata-only successful Images configuration audit sink. */
|
|
3221
|
-
readonly imageConfigAudit?: (record: ImageConfigurationAuditRecord) => void;
|
|
3222
|
-
/** Process-local machine-managed routing leases (optional for light embedders). */
|
|
3223
|
-
readonly routeLeaseManager?: RouteLeaseManager;
|
|
3224
|
-
/** Subscription accounts (token-free `listAll`). */
|
|
3225
|
-
readonly subscriptionAccounts: AdminAccountsLister;
|
|
3199
|
+
upsert(input: PricingEntryInput, asUserEdit: boolean): Promise<PricingEntry>;
|
|
3226
3200
|
/**
|
|
3227
|
-
*
|
|
3228
|
-
*
|
|
3201
|
+
* Apply a batch fetched from a pricing source. Rows whose local copy is
|
|
3202
|
+
* user-edited are NOT applied — they come back as `{ current, incoming }`
|
|
3203
|
+
* conflicts; everything else is upserted with the supplied automatic source.
|
|
3204
|
+
* ONE file write for the whole batch.
|
|
3229
3205
|
*/
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
probeAccount(providerId: _omnicross_contracts_subscription_types.SubscriptionProviderId, accountId: string): Promise<{
|
|
3236
|
-
ok: boolean;
|
|
3237
|
-
marked: boolean;
|
|
3238
|
-
}>;
|
|
3239
|
-
testAccountConnection(providerId: _omnicross_contracts_subscription_types.SubscriptionProviderId, accountId: string): Promise<{
|
|
3240
|
-
ok: boolean;
|
|
3241
|
-
marked: boolean;
|
|
3242
|
-
tier: 'local' | 'upstream' | 'generation';
|
|
3243
|
-
model?: string;
|
|
3206
|
+
bulkApplyFromSource(entries: PricingEntryInput[], source?: AutomaticPricingSource): Promise<{
|
|
3207
|
+
applied: PricingEntry[];
|
|
3208
|
+
conflicts: Array<{
|
|
3209
|
+
current: PricingEntry;
|
|
3210
|
+
incoming: PricingEntryInput;
|
|
3244
3211
|
}>;
|
|
3245
|
-
}
|
|
3246
|
-
/**
|
|
3247
|
-
* Least-authority subscription-token WRITER (design D4) — ONLY the mutation
|
|
3248
|
-
* methods (`writeProviderTokens` / `clearProvider`), never a token-returning
|
|
3249
|
-
* read. The token-free `subscriptionAccounts` lister stays separate so a GET
|
|
3250
|
-
* handler can never reach a token through this dep.
|
|
3251
|
-
*/
|
|
3252
|
-
readonly subscriptionTokenWriter: SubscriptionTokenWriter;
|
|
3253
|
-
/**
|
|
3254
|
-
* Read-only pool-health reader (key-pool design D7) — cooldown health only,
|
|
3255
|
-
* never a key value. Drives `GET /admin/api/providers/:id/keys`.
|
|
3256
|
-
*/
|
|
3257
|
-
readonly apiKeyPool: PoolHealthReader;
|
|
3258
|
-
/** In-memory auto-disable store (design D5) — read-only for the health view. */
|
|
3259
|
-
readonly autoDisableStore: AutoDisableStore;
|
|
3260
|
-
/**
|
|
3261
|
-
* OPTIONAL BYO provider-key quota service — same-key usage/quota probes for
|
|
3262
|
-
* provider rows with a known adapter (Z.AI coding plan, MiniMax Token Plan).
|
|
3263
|
-
* Absent ⇒ the keys view carries no `quota` field (light embedders).
|
|
3264
|
-
*/
|
|
3265
|
-
readonly providerKeyQuota?: ProviderKeyQuotaReader;
|
|
3266
|
-
/**
|
|
3267
|
-
* Pending interactive-OAuth sessions (app-parity child 4, design D1) — the
|
|
3268
|
-
* in-memory `{ codeVerifier, state }` map keyed by a minted `sessionId`,
|
|
3269
|
-
* NEVER serialized to the client.
|
|
3270
|
-
*/
|
|
3271
|
-
readonly oauthSessions: OAuthSessionStore;
|
|
3272
|
-
/**
|
|
3273
|
-
* Injected token-exchange `FetchLike` FACTORY (oauth design D2-a) — built per
|
|
3274
|
-
* provider in `bootstrap.ts` so the exchange carries a `{ providerId }` egress
|
|
3275
|
-
* ctx (per-provider proxy layer + upstream trace, bodies redacted); tests
|
|
3276
|
-
* inject a mock so no real token endpoint is hit. Mirrors how `login.ts`
|
|
3277
|
-
* injects its exchange fetch.
|
|
3278
|
-
*/
|
|
3279
|
-
readonly oauthExchangeFetch: (providerId: SubscriptionProviderId) => FetchLike;
|
|
3280
|
-
/**
|
|
3281
|
-
* NARROW append handle (oauth design D2-a) — the OAuth complete handler needs
|
|
3282
|
-
* `appendProviderAccount` (NOT on the least-authority `SubscriptionTokenWriter`).
|
|
3283
|
-
* A minimal interface, NOT the full read-capable store, so no token-returning
|
|
3284
|
-
* read is reachable. Wired from the concrete `credentialStore` in `bootstrap.ts`.
|
|
3285
|
-
*/
|
|
3286
|
-
readonly subscriptionAccountAppender: SubscriptionAccountAppender;
|
|
3287
|
-
/**
|
|
3288
|
-
* Codex interactive-OAuth flow store (app-parity-2 child 5). Tracks the async
|
|
3289
|
-
* loopback sign-in's polled status (token-free); only ONE codex login may be in
|
|
3290
|
-
* flight (port 1455 is one resource). Wired in `bootstrap.ts`.
|
|
3291
|
-
*/
|
|
3292
|
-
readonly codexSessions: CodexOAuthSessionStore;
|
|
3293
|
-
/**
|
|
3294
|
-
* Kimi interactive-OAuth flow store (device code). Same token-free polled
|
|
3295
|
-
* shape as codex; one sign-in at a time. Wired in `bootstrap.ts`.
|
|
3296
|
-
*/
|
|
3297
|
-
readonly kimiSessions: CodexOAuthSessionStore;
|
|
3298
|
-
/**
|
|
3299
|
-
* Grok interactive-OAuth flow store (device code). Same token-free polled
|
|
3300
|
-
* shape as codex; one sign-in at a time. Wired in `bootstrap.ts`.
|
|
3301
|
-
*/
|
|
3302
|
-
readonly grokSessions: CodexOAuthSessionStore;
|
|
3303
|
-
/**
|
|
3304
|
-
* Copilot interactive-OAuth flow store (device code). Same token-free
|
|
3305
|
-
* polled shape; one sign-in at a time. Wired in `bootstrap.ts`.
|
|
3306
|
-
*/
|
|
3307
|
-
readonly copilotSessions: CodexOAuthSessionStore;
|
|
3308
|
-
/** Antigravity interactive OAuth (loopback 51121) — the async flow store. */
|
|
3309
|
-
readonly antigravitySessions: CodexOAuthSessionStore;
|
|
3310
|
-
/** The one-shot 127.0.0.1:51121 listener (test seam like `codexAwaitLoopback`). */
|
|
3311
|
-
readonly antigravityAwaitLoopback: AntigravityLoopbackFn;
|
|
3312
|
-
/**
|
|
3313
|
-
* Resolve the ACTIVE antigravity account's access token for the dynamic
|
|
3314
|
-
* model-catalog probe (secret used daemon-side only; the route is
|
|
3315
|
-
* secret-free). Optional for older tests; absent → static-only catalog.
|
|
3316
|
-
*/
|
|
3317
|
-
readonly resolveAntigravityAccessToken?: () => Promise<string | null>;
|
|
3318
|
-
/**
|
|
3319
|
-
* Codex loopback listener (app-parity-2 child 5) — defaults to `awaitLoopbackCode`
|
|
3320
|
-
* (binds 127.0.0.1:1455) in `bootstrap.ts`; tests inject a mock so no real port
|
|
3321
|
-
* is bound. The captured code crosses to the daemon ONLY (never the client).
|
|
3322
|
-
*/
|
|
3323
|
-
readonly codexAwaitLoopback: CodexLoopbackFn;
|
|
3324
|
-
/**
|
|
3325
|
-
* Migration credential-store handle (app-parity child 6, design D2/D3). The
|
|
3326
|
-
* export gather needs `getFullConfig()` (full DECRYPTED tokens, in-memory only —
|
|
3327
|
-
* the pack is the only thing that leaves) and import needs `appendProviderAccount`
|
|
3328
|
-
* (multi-account append + re-encrypt at-rest). Confined to the migration
|
|
3329
|
-
* handlers (which seal/validate everything); never reached by a GET handler.
|
|
3330
|
-
* Wired from the concrete `credentialStore` in `bootstrap.ts`.
|
|
3331
|
-
*/
|
|
3332
|
-
readonly migrationCredentialStore: MigrationCredentialStore;
|
|
3333
|
-
/**
|
|
3334
|
-
* Usage-stats query facade (usage-pricing child) — delegates to the JSONL
|
|
3335
|
-
* usage-event store. Aggregates only; carries no key material.
|
|
3336
|
-
*/
|
|
3337
|
-
readonly usageRecorder: UsageRecorder;
|
|
3338
|
-
/** Pricing engine (upsert / source refresh / conflict resolution). */
|
|
3339
|
-
readonly pricingEngine: PricingEngine;
|
|
3340
|
-
/**
|
|
3341
|
-
* CONCRETE pricing store — ONLY for the store-local row `delete` (the core
|
|
3342
|
-
* `PricingStore` port is frozen; delete is a daemon-local extra).
|
|
3343
|
-
*/
|
|
3344
|
-
readonly pricingStore: JsonPricingStore;
|
|
3345
|
-
/**
|
|
3346
|
-
* External-terminal opener for the Code CLI launch route (dashboard parity).
|
|
3347
|
-
* Optional — defaults to the real `defaultTerminalOpener`; tests inject a spy so
|
|
3348
|
-
* no terminal window is actually spawned.
|
|
3349
|
-
*/
|
|
3350
|
-
readonly cliTerminalOpener?: TerminalOpener;
|
|
3351
|
-
/** Injectable PATH probe for CLI detection (tests fake "installed"). */
|
|
3352
|
-
readonly cliPathProbe?: PathProbe;
|
|
3212
|
+
}>;
|
|
3353
3213
|
/**
|
|
3354
|
-
*
|
|
3355
|
-
*
|
|
3356
|
-
* actually runs.
|
|
3214
|
+
* Apply per-row conflict decisions: 'overwrite' replaces the local row with
|
|
3215
|
+
* the incoming values (clearing the user-edited mark), 'skip' counts only.
|
|
3357
3216
|
*/
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3217
|
+
applyResolutions(resolutions: Array<{
|
|
3218
|
+
incoming: PricingEntryInput;
|
|
3219
|
+
action: 'overwrite' | 'skip';
|
|
3220
|
+
}>): Promise<PricingResolution>;
|
|
3361
3221
|
/**
|
|
3362
|
-
*
|
|
3363
|
-
*
|
|
3364
|
-
*
|
|
3365
|
-
* routes return 501 when absent (the voucher/allowance optionality precedent).
|
|
3222
|
+
* STORE-LOCAL (not on the core port): remove one row. Returns whether a row
|
|
3223
|
+
* was actually removed. The admin DELETE handler calls this then invalidates
|
|
3224
|
+
* the engine cache.
|
|
3366
3225
|
*/
|
|
3367
|
-
|
|
3226
|
+
delete(providerId: string, modelId: string): Promise<boolean>;
|
|
3227
|
+
/** Upsert into `rows` IN PLACE (no write) and return the resulting entry. */
|
|
3228
|
+
private applyUpsert;
|
|
3229
|
+
/** Read the pricing rows, tolerating a missing/corrupt file (→ empty list). */
|
|
3230
|
+
private readRows;
|
|
3231
|
+
private writeRows;
|
|
3232
|
+
/** Isolated for deterministic failure testing; never removes the target. */
|
|
3233
|
+
private replaceFile;
|
|
3368
3234
|
}
|
|
3369
|
-
/**
|
|
3370
|
-
* Dispatch one `/admin/api/*` request. `path` is the already-extracted pathname
|
|
3371
|
-
* (no query). The auth gate has already run in `AdminServer`.
|
|
3372
|
-
*/
|
|
3373
|
-
declare function handleAdminApi(req: http.IncomingMessage, res: http.ServerResponse, path: string, deps: AdminApiDeps): Promise<void>;
|
|
3374
|
-
|
|
3375
|
-
/**
|
|
3376
|
-
* AdminServer — the daemon's localhost admin/dashboard HTTP listener (RT3,
|
|
3377
|
-
* design D1/D2).
|
|
3378
|
-
*
|
|
3379
|
-
* A SEPARATE `node:http` listener distinct from core's outbound `/v1/*` server
|
|
3380
|
-
* (port 8765, untouched). Mirrors `OutboundApiServer`'s proven shape:
|
|
3381
|
-
* - `http.createServer`, default bind `127.0.0.1` (or `0.0.0.0` when
|
|
3382
|
-
* `networkBinding`), `listen` with `EADDRINUSE`→ephemeral(port 0) fallback,
|
|
3383
|
-
* - `getStatus()` (running / bound port / dashboard URL), `start` / `stop`.
|
|
3384
|
-
* Default admin port 8766.
|
|
3385
|
-
*
|
|
3386
|
-
* Auth (design D2):
|
|
3387
|
-
* - Baseline = localhost bind, no token → reachable only from the machine.
|
|
3388
|
-
* - Optional `admin.token` → every `/admin/*` request (incl. `GET /`) must
|
|
3389
|
-
* carry `Authorization: Bearer <token>` or `X-Admin-Token: <token>`; compared
|
|
3390
|
-
* server-side with a constant-time equality → `401` on a miss.
|
|
3391
|
-
* - HARD SAFETY GATE: `networkBinding` (LAN/`0.0.0.0`) without a non-empty
|
|
3392
|
-
* `admin.token` → `start` REFUSES to bind (logs + stays down, fail closed).
|
|
3393
|
-
*
|
|
3394
|
-
* Routing: `GET /` (and `GET /admin`) → `302 /ui/`; `* /admin/api/*` → the
|
|
3395
|
-
* management API (`handleAdminApi`); `GET /ui[/...]` → the Control Panel static
|
|
3396
|
-
* UI (`handleUiStatic`, from `@omnicross/ui`); everything else → `404`.
|
|
3397
|
-
*
|
|
3398
|
-
* @module @omnicross/daemon/admin/AdminServer
|
|
3399
|
-
*/
|
|
3400
3235
|
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
getAdminConfig: () => ResolvedAdminConfig;
|
|
3405
|
-
/**
|
|
3406
|
-
* Build the coarse, secret-free `/health` report (daemon-health-endpoint). A
|
|
3407
|
-
* shared closure over live handles (bootstrap wires the SAME builder into the
|
|
3408
|
-
* outbound server), served UNAUTHENTICATED — before the admin auth gate.
|
|
3409
|
-
*/
|
|
3410
|
-
getHealthReport: () => HealthReport;
|
|
3411
|
-
/**
|
|
3412
|
-
* Injected logger (configurable-logging) — the admin listener's OWN lifecycle
|
|
3413
|
-
* lines (bind/refuse/error) route through it so they honor the configured
|
|
3414
|
-
* level / format / file sink.
|
|
3415
|
-
*/
|
|
3416
|
-
logger: Logger;
|
|
3417
|
-
/**
|
|
3418
|
-
* OPTIONAL per-account probe-history reader (subscription-account-probe #8,
|
|
3419
|
-
* design D5). When wired (bootstrap → the `AccountHealthProbeScheduler`), the
|
|
3420
|
-
* AUTHED `GET /admin/api/account-probes` returns per-account probe history.
|
|
3421
|
-
* Absent ⇒ the route serves an empty list (byte-safe for embedders/tests that
|
|
3422
|
-
* do not wire it). Read-only + secret-free (ids + status labels, no tokens).
|
|
3423
|
-
*/
|
|
3424
|
-
probeHistoryReader?: AccountProbeHistoryReader;
|
|
3425
|
-
/**
|
|
3426
|
-
* OPTIONAL audit query reader (request-audit-log, design D6). When wired
|
|
3427
|
-
* (bootstrap → the date-rotated store), the AUTHED `GET /admin/api/audit`
|
|
3428
|
-
* returns filtered records. Absent ⇒ the route serves an empty list. The
|
|
3429
|
-
* records carry IP/UA/bodies → this route is behind the auth gate ONLY, NEVER
|
|
3430
|
-
* unauthenticated, NEVER on `/health`.
|
|
3431
|
-
*/
|
|
3432
|
-
auditReader?: AuditQueryReader;
|
|
3433
|
-
/** Metadata-only audit aggregate used by the overview error-rate metric. */
|
|
3434
|
-
auditStatsReader?: AuditStatsReader;
|
|
3435
|
-
/**
|
|
3436
|
-
* Reconstructs one record's bodies from the per-session shard store
|
|
3437
|
-
* (audit-store-sharding). Absent when audit was never enabled.
|
|
3438
|
-
*/
|
|
3439
|
-
auditBodyReader?: AuditBodyReader;
|
|
3440
|
-
/** Runs cross-session body compaction on demand (audit-store-sharding D8). */
|
|
3441
|
-
auditCompactor?: AuditCompactor;
|
|
3442
|
-
/**
|
|
3443
|
-
* OPTIONAL billing delivery-status reader (billing-event-stream, design D5).
|
|
3444
|
-
* When wired (bootstrap → the ledger dir), the AUTHED `GET /admin/api/billing-status`
|
|
3445
|
-
* returns secret-free total/delivered/pending counts. Absent ⇒ zeroed counts.
|
|
3446
|
-
*/
|
|
3447
|
-
billingStatusReader?: BillingStatusReader;
|
|
3448
|
-
}
|
|
3449
|
-
/** A live status snapshot for the admin listener. */
|
|
3450
|
-
interface AdminServerStatus {
|
|
3451
|
-
running: boolean;
|
|
3452
|
-
/** Actual bound port (0 when not running). */
|
|
3453
|
-
port: number;
|
|
3454
|
-
/** The dashboard URL (loopback or LAN base), or null when not running. */
|
|
3455
|
-
url: string | null;
|
|
3456
|
-
}
|
|
3457
|
-
declare class AdminServer {
|
|
3458
|
-
private readonly deps;
|
|
3459
|
-
private server;
|
|
3460
|
-
private boundPort;
|
|
3461
|
-
private boundAddr;
|
|
3462
|
-
/** Control Panel dist dir (resolved once at first request; null = no UI). */
|
|
3463
|
-
private uiDist;
|
|
3464
|
-
constructor(deps: AdminServerDeps);
|
|
3465
|
-
/**
|
|
3466
|
-
* Start the admin listener honoring the resolved admin config. Returns the
|
|
3467
|
-
* actual bound port, or `0` when it refuses/declines to bind (disabled or the
|
|
3468
|
-
* LAN fail-closed gate). Idempotent: a second call returns the bound port.
|
|
3469
|
-
*/
|
|
3470
|
-
start(): Promise<number>;
|
|
3471
|
-
/** Bind once; on EADDRINUSE retry with an ephemeral port (port 0). */
|
|
3472
|
-
private listen;
|
|
3473
|
-
/** Per-request handler: auth gate (when a token is set) → routing. */
|
|
3474
|
-
private onRequest;
|
|
3475
|
-
private dispatch;
|
|
3476
|
-
/** Constant-time bearer/header check against the configured token. */
|
|
3477
|
-
private isAuthorized;
|
|
3478
|
-
/** Stop the listener and release the port. */
|
|
3479
|
-
stop(): Promise<void>;
|
|
3480
|
-
/** A live status snapshot. */
|
|
3481
|
-
getStatus(): AdminServerStatus;
|
|
3236
|
+
interface CodexAuthHelperConfig {
|
|
3237
|
+
command: string;
|
|
3238
|
+
args: string[];
|
|
3482
3239
|
}
|
|
3483
3240
|
|
|
3484
|
-
type
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
readonly artifactsRoot: string;
|
|
3491
|
-
readonly stateRoot: string;
|
|
3492
|
-
readonly evidenceRoot: string;
|
|
3493
|
-
readonly mountManifestRoot: string;
|
|
3494
|
-
readonly mountManifestPath: string;
|
|
3495
|
-
}
|
|
3496
|
-
interface ImageRootValidationOptions {
|
|
3497
|
-
readonly label?: string;
|
|
3498
|
-
readonly processDirectory?: string;
|
|
3499
|
-
readonly userHome?: string;
|
|
3500
|
-
readonly temporaryDirectory?: string;
|
|
3241
|
+
type IntegrationClientId = 'codex' | 'claude';
|
|
3242
|
+
type IntegrationKeyOwnership = 'managed' | 'selected';
|
|
3243
|
+
/** Secret-free pointer to an access key. The plaintext remains in the encrypted key store. */
|
|
3244
|
+
interface IntegrationKeyBinding {
|
|
3245
|
+
keyId: string;
|
|
3246
|
+
ownership: IntegrationKeyOwnership;
|
|
3501
3247
|
}
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3248
|
+
/** Redacted access-key state exposed by the integrations admin API. */
|
|
3249
|
+
interface IntegrationKeyBindingStatus {
|
|
3250
|
+
id: string;
|
|
3251
|
+
name: string;
|
|
3252
|
+
keyPrefix: string;
|
|
3253
|
+
ownership: IntegrationKeyOwnership;
|
|
3254
|
+
revealable: boolean;
|
|
3255
|
+
enabled: boolean;
|
|
3256
|
+
revoked: boolean;
|
|
3257
|
+
allowedEndpoints: OutboundPermission[];
|
|
3258
|
+
requiredEndpoints: OutboundPermission[];
|
|
3259
|
+
loopbackOnly: boolean;
|
|
3505
3260
|
}
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3261
|
+
type IntegrationStatusKind = 'not-installed' | 'enabled' | 'configuration-drift' | 'configuration-missing' | 'key-missing';
|
|
3262
|
+
interface IntegrationClientStatus {
|
|
3263
|
+
client: IntegrationClientId;
|
|
3264
|
+
status: IntegrationStatusKind;
|
|
3265
|
+
configPath: string;
|
|
3266
|
+
installedAt?: number;
|
|
3267
|
+
gatewayBaseUrl?: string;
|
|
3268
|
+
message?: string;
|
|
3269
|
+
/** Selected key metadata only; never contains plaintext or the encrypted envelope. */
|
|
3270
|
+
key?: IntegrationKeyBindingStatus;
|
|
3510
3271
|
}
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
constructor(options: CreateDaemonImagePathResolverOptions);
|
|
3520
|
-
createOpaqueFile(area: Exclude<DaemonImagePathArea, 'temporary' | 'mountManifest'>, format?: 'bin' | 'json' | 'tmp'): VerifiedDaemonImagePath;
|
|
3521
|
-
createOpaqueDirectory(area?: Exclude<DaemonImagePathArea, 'mountManifest'>): VerifiedDaemonImagePath;
|
|
3522
|
-
mountManifest(): VerifiedDaemonImagePath;
|
|
3523
|
-
/** Revalidate and return one internal root for store-local bounded I/O. */
|
|
3524
|
-
verifiedRoot(area: DaemonImagePathArea): string;
|
|
3525
|
-
/** Revalidate immediately before unlinking a resolver-issued file capability. */
|
|
3526
|
-
removeFile(target: VerifiedDaemonImagePath): void;
|
|
3527
|
-
/** Only empty opaque directories may be removed until the owned-marker layer is composed. */
|
|
3528
|
-
removeEmptyDirectory(target: VerifiedDaemonImagePath): void;
|
|
3529
|
-
private issue;
|
|
3530
|
-
private verifyDestructiveTarget;
|
|
3272
|
+
interface IntegrationChangePlan {
|
|
3273
|
+
client: IntegrationClientId;
|
|
3274
|
+
configPath: string;
|
|
3275
|
+
action: 'install' | 'none' | 'repair';
|
|
3276
|
+
canApply: boolean;
|
|
3277
|
+
/** Redacted logical fields only; never file contents or credential values. */
|
|
3278
|
+
changes: string[];
|
|
3279
|
+
warnings: string[];
|
|
3531
3280
|
}
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3281
|
+
interface IntegrationInstallRecord {
|
|
3282
|
+
client: IntegrationClientId;
|
|
3283
|
+
configPath: string;
|
|
3284
|
+
originalExisted: boolean;
|
|
3285
|
+
/** Encrypted by IntegrationStateStore before it reaches disk. */
|
|
3286
|
+
originalContent: string;
|
|
3287
|
+
originalHash: string;
|
|
3288
|
+
installedHash: string;
|
|
3289
|
+
installedAt: number;
|
|
3290
|
+
gatewayBaseUrl: string;
|
|
3291
|
+
/** Codex auth.json snapshot and installed hash; absent on legacy records. */
|
|
3292
|
+
credentialFile?: IntegrationManagedFileRecord;
|
|
3540
3293
|
}
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
readonly entries: number;
|
|
3549
|
-
readonly freshEntries: number;
|
|
3550
|
-
readonly staleEntries: number;
|
|
3551
|
-
readonly bytes: number;
|
|
3294
|
+
interface IntegrationManagedFileRecord {
|
|
3295
|
+
path: string;
|
|
3296
|
+
originalExisted: boolean;
|
|
3297
|
+
/** Encrypted by IntegrationStateStore before it reaches disk. */
|
|
3298
|
+
originalContent: string;
|
|
3299
|
+
originalHash: string;
|
|
3300
|
+
installedHash: string;
|
|
3552
3301
|
}
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
resolveWithTtl(request: CodexImageCapabilityEvidenceRequest, ttlMs: number): Promise<CodexImageCapabilityEvidence>;
|
|
3559
|
-
recordSuccessfulVerificationWithTtl(observation: CodexImageCapabilityObservation, ttlMs: number): Promise<void>;
|
|
3560
|
-
cleanup(now: number, limit: number): Promise<{
|
|
3561
|
-
readonly entriesRemoved: number;
|
|
3562
|
-
readonly bytesRemoved: number;
|
|
3563
|
-
}>;
|
|
3564
|
-
statusWithTtl(ttlMs: number): FileCodexImageCapabilityEvidenceStatus;
|
|
3302
|
+
interface IntegrationGatewayKeyRecord {
|
|
3303
|
+
id: string;
|
|
3304
|
+
/** Encrypted by IntegrationStateStore before it reaches disk. */
|
|
3305
|
+
secret: string;
|
|
3306
|
+
createdAt: number;
|
|
3565
3307
|
}
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
recordSuccessfulVerification(observation: CodexImageCapabilityObservation): Promise<void>;
|
|
3573
|
-
cleanup(now: number, limit: number): Promise<{
|
|
3574
|
-
readonly entriesRemoved: number;
|
|
3575
|
-
readonly bytesRemoved: number;
|
|
3576
|
-
}>;
|
|
3577
|
-
status(): FileCodexImageCapabilityEvidenceStatus;
|
|
3578
|
-
ttlMs(): number;
|
|
3579
|
-
/** Lifecycle-symmetric no-op; physical safety no longer depends on local leases. */
|
|
3580
|
-
dispose(): void;
|
|
3308
|
+
interface IntegrationState {
|
|
3309
|
+
version: 1;
|
|
3310
|
+
/** Legacy shared-key layout. New installs use `keyBindings`; retained for safe migration. */
|
|
3311
|
+
gatewayKey?: IntegrationGatewayKeyRecord;
|
|
3312
|
+
keyBindings?: Partial<Record<IntegrationClientId, IntegrationKeyBinding>>;
|
|
3313
|
+
clients: Partial<Record<IntegrationClientId, IntegrationInstallRecord>>;
|
|
3581
3314
|
}
|
|
3582
3315
|
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
readonly
|
|
3586
|
-
readonly
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
readonly tombstoneTtlMs: number;
|
|
3591
|
-
}
|
|
3592
|
-
interface FileImageReferenceStoreOptions {
|
|
3593
|
-
readonly paths: DaemonImagePathResolver;
|
|
3594
|
-
readonly limits: FileImageReferenceStoreLimits;
|
|
3595
|
-
readonly secretBox?: SecretBox;
|
|
3596
|
-
readonly now?: () => number;
|
|
3597
|
-
readonly random?: (bytes: number) => Buffer;
|
|
3598
|
-
readonly replaceManifest?: (targetPath: string, contents: Uint8Array) => void;
|
|
3599
|
-
}
|
|
3600
|
-
interface FileImageReferenceReconciliationResult {
|
|
3601
|
-
readonly metadataRemoved: number;
|
|
3602
|
-
readonly metadataDegradedToProviderReference: number;
|
|
3603
|
-
readonly orphanFilesRemoved: number;
|
|
3604
|
-
readonly incompleteFilesRemoved: number;
|
|
3605
|
-
readonly invalidDescendants: number;
|
|
3606
|
-
}
|
|
3607
|
-
declare class FileImageReferenceStore implements ImageReferenceStore {
|
|
3608
|
-
#private;
|
|
3609
|
-
constructor(options: FileImageReferenceStoreOptions);
|
|
3610
|
-
save(input: ImageReferenceSaveInput): Promise<ImageReferenceMetadata>;
|
|
3611
|
-
/** Generation-bound write entry point; reads and maintenance remain shared. */
|
|
3612
|
-
saveWithLimits(input: ImageReferenceSaveInput, limits: FileImageReferenceStoreLimits): Promise<ImageReferenceMetadata>;
|
|
3613
|
-
/** Updates only app-session maintenance policy; pinned writes pass their own limits. */
|
|
3614
|
-
updateMaintenanceLimits(limits: FileImageReferenceStoreLimits): void;
|
|
3615
|
-
resolve(tenantId: string, referenceId: ImageReferenceId): Promise<ImageReferenceResolution>;
|
|
3616
|
-
delete(tenantId: string, referenceId: ImageReferenceId): Promise<boolean>;
|
|
3617
|
-
/** Daemon-internal cleanup path; accepts only the local reference-domain tenant HMAC. */
|
|
3618
|
-
deleteByHashedTenantKey(tenantKey: string, referenceId: ImageReferenceId): Promise<boolean>;
|
|
3619
|
-
cleanup(now?: number): Promise<number>;
|
|
3620
|
-
status(): {
|
|
3621
|
-
readonly entries: number;
|
|
3622
|
-
readonly bytes: number;
|
|
3623
|
-
readonly tombstones: number;
|
|
3624
|
-
};
|
|
3625
|
-
hasLiveReferenceByHashedTenantKey(tenantKey: string, referenceId: ImageReferenceId, now?: number): Promise<boolean>;
|
|
3626
|
-
reconcileOwnedFiles(maxEntries: number): Promise<FileImageReferenceReconciliationResult>;
|
|
3627
|
-
openArtifact(fileName: string, byteLength: number, signal?: AbortSignal): Promise<ReadableStream<Uint8Array>>;
|
|
3628
|
-
private exclusive;
|
|
3629
|
-
private tenantKey;
|
|
3630
|
-
private newReferenceId;
|
|
3631
|
-
private validateSaveInput;
|
|
3632
|
-
private selectVictims;
|
|
3633
|
-
private nextTombstones;
|
|
3634
|
-
private writeArtifact;
|
|
3635
|
-
private artifactPath;
|
|
3636
|
-
private validArtifact;
|
|
3637
|
-
private removeArtifact;
|
|
3638
|
-
private safeUnlinkArtifactPath;
|
|
3639
|
-
private releaseLease;
|
|
3640
|
-
private manifestPath;
|
|
3641
|
-
private persist;
|
|
3642
|
-
private atomicReplace;
|
|
3643
|
-
private loadManifest;
|
|
3644
|
-
}
|
|
3645
|
-
|
|
3646
|
-
interface FileResponsesImageStateStoreLimits {
|
|
3647
|
-
readonly maxCalls: number;
|
|
3648
|
-
readonly maxResponses: number;
|
|
3649
|
-
readonly maxTombstones: number;
|
|
3650
|
-
readonly tombstoneTtlMs: number;
|
|
3651
|
-
}
|
|
3652
|
-
interface FileResponsesImageStateStoreOptions {
|
|
3653
|
-
readonly paths: DaemonImagePathResolver;
|
|
3654
|
-
readonly limits: FileResponsesImageStateStoreLimits;
|
|
3655
|
-
readonly now?: () => number;
|
|
3656
|
-
readonly random?: (bytes: number) => Buffer;
|
|
3657
|
-
readonly replaceManifest?: (targetPath: string, contents: Uint8Array) => void;
|
|
3658
|
-
}
|
|
3659
|
-
interface PendingResponsesImageReferenceDelete {
|
|
3660
|
-
readonly referenceTenantKey: string;
|
|
3661
|
-
readonly binding: ResponsesImageCallBinding;
|
|
3662
|
-
}
|
|
3663
|
-
/** Durable production implementation of the existing Responses image-state contract. */
|
|
3664
|
-
declare class FileResponsesImageStateStore implements ResponsesImageStateStore {
|
|
3665
|
-
#private;
|
|
3666
|
-
constructor(options: FileResponsesImageStateStoreOptions);
|
|
3667
|
-
commit(input: ResponsesImageStateCommitInput): Promise<readonly ResponsesImageCallBinding[]>;
|
|
3668
|
-
/** Generation-bound write entry point; reads and maintenance remain shared. */
|
|
3669
|
-
commitWithLimits(input: ResponsesImageStateCommitInput, limits: FileResponsesImageStateStoreLimits): Promise<readonly ResponsesImageCallBinding[]>;
|
|
3670
|
-
/** Updates only app-session maintenance policy; pinned commits pass their own limits. */
|
|
3671
|
-
updateMaintenanceLimits(limits: FileResponsesImageStateStoreLimits): void;
|
|
3672
|
-
resolveCall(tenantId: string, callId: ResponsesImageCallId): Promise<ResponsesImageCallResolution>;
|
|
3673
|
-
resolveResponse(tenantId: string, responseId: string): Promise<ResponsesImageResponseResolution>;
|
|
3674
|
-
deleteCall(tenantId: string, callId: ResponsesImageCallId): Promise<ResponsesImageCallBinding | undefined>;
|
|
3675
|
-
deleteResponse(tenantId: string, responseId: string): Promise<boolean>;
|
|
3676
|
-
cleanup(now?: number): Promise<readonly ResponsesImageCallBinding[]>;
|
|
3677
|
-
pendingReferenceDeletes(limit?: number): readonly PendingResponsesImageReferenceDelete[];
|
|
3678
|
-
acknowledgeReferenceDeletes(completed: readonly PendingResponsesImageReferenceDelete[]): Promise<number>;
|
|
3679
|
-
reconcileBrokenReferenceLinks(hasLiveReference: (referenceTenantKey: string, referenceId: ResponsesImageCallBinding['referenceId']) => Promise<boolean>, maxEntries: number): Promise<readonly ResponsesImageCallBinding[]>;
|
|
3680
|
-
status(): {
|
|
3681
|
-
readonly calls: number;
|
|
3682
|
-
readonly responses: number;
|
|
3683
|
-
readonly tombstones: number;
|
|
3684
|
-
readonly pendingReferenceDeletes: number;
|
|
3685
|
-
};
|
|
3686
|
-
private exclusive;
|
|
3687
|
-
private failure;
|
|
3688
|
-
private assertCommit;
|
|
3689
|
-
private tenantKey;
|
|
3690
|
-
private rememberTombstone;
|
|
3691
|
-
private enqueuePendingReferenceDelete;
|
|
3692
|
-
private hasTombstone;
|
|
3693
|
-
private prunedTombstones;
|
|
3694
|
-
private pruneTombstonesInPlace;
|
|
3695
|
-
private sameTombstones;
|
|
3696
|
-
private touch;
|
|
3697
|
-
private releaseCall;
|
|
3698
|
-
private releaseResponse;
|
|
3699
|
-
private manifestPath;
|
|
3700
|
-
private persist;
|
|
3701
|
-
private atomicReplace;
|
|
3702
|
-
private loadManifest;
|
|
3316
|
+
/** Encrypted, Omnicross-owned state for reversible native CLI configuration. */
|
|
3317
|
+
declare class IntegrationStateStore {
|
|
3318
|
+
readonly path: string;
|
|
3319
|
+
private readonly box;
|
|
3320
|
+
constructor(path: string, box: SecretBox);
|
|
3321
|
+
load(): IntegrationState;
|
|
3322
|
+
save(state: IntegrationState): void;
|
|
3703
3323
|
}
|
|
3704
3324
|
|
|
3705
|
-
interface
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
interface ImageStorageMountCatalogOptions {
|
|
3713
|
-
readonly pathOptions: Omit<CreateDaemonImagePathResolverOptions, 'storageRoot'>;
|
|
3714
|
-
readonly activeStorageRoot?: string;
|
|
3715
|
-
readonly referenceLimits: FileImageReferenceStoreLimits;
|
|
3716
|
-
readonly responsesStateLimits: FileResponsesImageStateStoreLimits;
|
|
3717
|
-
readonly secretBox?: SecretBox;
|
|
3718
|
-
readonly now?: () => number;
|
|
3719
|
-
readonly random?: (bytes: number) => Buffer;
|
|
3720
|
-
readonly replaceCatalog?: (targetPath: string, contents: Uint8Array) => void;
|
|
3721
|
-
readonly reconcileCorruptManifests?: boolean;
|
|
3722
|
-
}
|
|
3723
|
-
interface ImageStorageMountPolicy {
|
|
3724
|
-
readonly referenceLimits: FileImageReferenceStoreLimits;
|
|
3725
|
-
readonly responsesStateLimits: FileResponsesImageStateStoreLimits;
|
|
3726
|
-
}
|
|
3727
|
-
interface PreparedImageStorageMountActivation {
|
|
3728
|
-
readonly backend: ImageStorageMountBackend;
|
|
3729
|
-
publish(): ImageStorageMountBackend;
|
|
3730
|
-
rollback(): void;
|
|
3731
|
-
dispose(): void;
|
|
3732
|
-
}
|
|
3733
|
-
/** Owns the durable-root set independently from any one runtime generation. */
|
|
3734
|
-
declare class ImageStorageMountCatalog {
|
|
3735
|
-
#private;
|
|
3736
|
-
constructor(options: ImageStorageMountCatalogOptions);
|
|
3737
|
-
active(): ImageStorageMountBackend;
|
|
3738
|
-
mountsForRead(): readonly ImageStorageMountBackend[];
|
|
3739
|
-
status(): {
|
|
3740
|
-
readonly mounts: number;
|
|
3741
|
-
readonly retiredMounts: number;
|
|
3742
|
-
};
|
|
3743
|
-
startupReconciliationStatus(): {
|
|
3744
|
-
readonly corruptManifestsQuarantined: number;
|
|
3745
|
-
};
|
|
3746
|
-
utilization(): {
|
|
3747
|
-
readonly referenceEntries: number;
|
|
3748
|
-
readonly referenceBytes: number;
|
|
3749
|
-
readonly referenceTombstones: number;
|
|
3750
|
-
readonly stateCalls: number;
|
|
3751
|
-
readonly stateResponses: number;
|
|
3752
|
-
readonly stateTombstones: number;
|
|
3753
|
-
readonly pendingReferenceDeletes: number;
|
|
3754
|
-
};
|
|
3755
|
-
/** Pins a backend object until its owning runtime generation drains. */
|
|
3756
|
-
retainBackend(backend: ImageStorageMountBackend): () => void;
|
|
3757
|
-
activate(storageRoot?: string): ImageStorageMountBackend;
|
|
3758
|
-
/** Prepare a validated backend without changing the catalog's active mount. */
|
|
3759
|
-
prepareActivation(storageRoot?: string, policy?: ImageStorageMountPolicy): PreparedImageStorageMountActivation;
|
|
3760
|
-
retireEmptyMount(mountId: string): boolean;
|
|
3761
|
-
private createResolver;
|
|
3762
|
-
private createBackend;
|
|
3763
|
-
private applyMaintenancePolicy;
|
|
3764
|
-
private newMountId;
|
|
3765
|
-
private isManifestError;
|
|
3766
|
-
private quarantineManifest;
|
|
3767
|
-
private isVerifiedEmpty;
|
|
3768
|
-
private catalogPath;
|
|
3769
|
-
private persist;
|
|
3770
|
-
private atomicReplace;
|
|
3771
|
-
private loadCatalog;
|
|
3325
|
+
interface IntegrationManagerOptions {
|
|
3326
|
+
configPath: string;
|
|
3327
|
+
gatewayBaseUrl: string;
|
|
3328
|
+
keyDb: OutboundKeyDb;
|
|
3329
|
+
stateStore: IntegrationStateStore;
|
|
3330
|
+
codexAuthHelper?: CodexAuthHelperConfig;
|
|
3331
|
+
homeDir?: string;
|
|
3772
3332
|
}
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
private readonly
|
|
3776
|
-
private readonly
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3333
|
+
/** Coordinates per-client least-privilege keys with reversible native CLI config edits. */
|
|
3334
|
+
declare class IntegrationManager {
|
|
3335
|
+
private readonly options;
|
|
3336
|
+
private readonly homeDir;
|
|
3337
|
+
private readonly codexAuthHelper;
|
|
3338
|
+
constructor(options: IntegrationManagerOptions);
|
|
3339
|
+
listStatus(): Promise<IntegrationClientStatus[]>;
|
|
3340
|
+
plan(client: IntegrationClientId, configPath?: string): Promise<IntegrationChangePlan>;
|
|
3341
|
+
install(client: IntegrationClientId, configPath?: string): Promise<IntegrationClientStatus>;
|
|
3342
|
+
repair(client: IntegrationClientId): Promise<IntegrationClientStatus>;
|
|
3343
|
+
remove(client: IntegrationClientId): Promise<IntegrationClientStatus>;
|
|
3344
|
+
/** Bind a user-confirmed access key and grant only this client's required endpoints. */
|
|
3345
|
+
bindIntegrationKey(client: IntegrationClientId, keyId: string): Promise<IntegrationClientStatus>;
|
|
3346
|
+
/** Rotate every Omnicross-managed client binding; user-selected keys remain untouched. */
|
|
3347
|
+
rotateGatewayKey(): Promise<{
|
|
3348
|
+
keyIds: Partial<Record<IntegrationClientId, string>>;
|
|
3789
3349
|
}>;
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
private
|
|
3798
|
-
private
|
|
3799
|
-
private
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
resolveCall(tenantId: string, callId: ResponsesImageCallId): Promise<ResponsesImageCallResolution>;
|
|
3804
|
-
resolveResponse(tenantId: string, responseId: string): Promise<ResponsesImageResponseResolution>;
|
|
3805
|
-
deleteCall(tenantId: string, callId: ResponsesImageCallId): Promise<ResponsesImageCallBinding | undefined>;
|
|
3806
|
-
deleteResponse(tenantId: string, responseId: string): Promise<boolean>;
|
|
3807
|
-
cleanup(now?: number): Promise<readonly ResponsesImageCallBinding[]>;
|
|
3350
|
+
/** Resolve the plaintext only for the command-auth helper; callers must not log it. */
|
|
3351
|
+
getIntegrationToken(client: IntegrationClientId): Promise<string>;
|
|
3352
|
+
/** Compatibility alias for callers predating per-client bindings. */
|
|
3353
|
+
getGatewayToken(client?: IntegrationClientId): Promise<string>;
|
|
3354
|
+
private ensureClientKey;
|
|
3355
|
+
private createManagedClientKey;
|
|
3356
|
+
private installedSecret;
|
|
3357
|
+
private rebindInstalledClient;
|
|
3358
|
+
private statusFor;
|
|
3359
|
+
private boundKeyDetails;
|
|
3360
|
+
private retireManagedKeys;
|
|
3361
|
+
private defaultConfigPath;
|
|
3362
|
+
private renderInstalled;
|
|
3808
3363
|
}
|
|
3809
3364
|
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3365
|
+
/**
|
|
3366
|
+
* accountsAntigravityOAuth — the daemon admin API's ANTIGRAVITY interactive
|
|
3367
|
+
* OAuth path (`POST /accounts/antigravity/oauth/start` +
|
|
3368
|
+
* `GET /accounts/antigravity/oauth/:sessionId/status`).
|
|
3369
|
+
*
|
|
3370
|
+
* Modeled on the codex loopback flow (`accountsCodexOAuth`): antigravity's
|
|
3371
|
+
* redirect is a FIXED loopback `http://127.0.0.1:51121/oauth-callback`, so the
|
|
3372
|
+
* flow is ASYNC + POLLED — `start` arms the one-shot loopback listener, kicks
|
|
3373
|
+
* the capture→exchange→email→project-handshake→persist chain off ASYNC, and
|
|
3374
|
+
* returns ONLY `{ authUrl, sessionId }` (public — client_id + state). The app
|
|
3375
|
+
* opens `authUrl`; the browser redirects to the loopback; the daemon captures
|
|
3376
|
+
* the `code`, validates `state`, exchanges it, resolves the userinfo email and
|
|
3377
|
+
* the Code Assist project (the antigravity dialect of the shared resolver),
|
|
3378
|
+
* and persists the minted token through the encrypted credential store. The
|
|
3379
|
+
* app POLLS `status` until `done`/`error`.
|
|
3380
|
+
*
|
|
3381
|
+
* SECRET SPINE (same invariant as codex/grok): the minted access/refresh token
|
|
3382
|
+
* NEVER crosses to the client — it lands ONLY in the encrypted store. The
|
|
3383
|
+
* poll `status` body is TOKEN-FREE (`{ state, message? }`). Port 51121 is a
|
|
3384
|
+
* single resource → only ONE antigravity sign-in may be in flight (409).
|
|
3385
|
+
*
|
|
3386
|
+
* REUSES the `@omnicross/subscriptions` antigravity flow + the CLI's
|
|
3387
|
+
* `awaitLoopbackCode` listener (parameterized binding) — it does NOT rebuild
|
|
3388
|
+
* the authorize/exchange/handshake logic.
|
|
3389
|
+
*
|
|
3390
|
+
* @module @omnicross/daemon/admin/accountsAntigravityOAuth
|
|
3391
|
+
*/
|
|
3392
|
+
|
|
3393
|
+
/** The loopback-listener fn (injected so tests need not bind a real port). */
|
|
3394
|
+
type AntigravityLoopbackFn = (state: string, timeoutMs?: number, signal?: AbortSignal) => Promise<string>;
|
|
3395
|
+
|
|
3396
|
+
/**
|
|
3397
|
+
* cliLaunch — the admin API's "launch a coding CLI in a terminal, pointed at the
|
|
3398
|
+
* daemon" surface (dashboard parity with the desktop app's Code CLI tab).
|
|
3399
|
+
*
|
|
3400
|
+
* This is the EXTERNAL-terminal analogue of `commands/launch.ts`: it reuses the
|
|
3401
|
+
* same `@omnicross/cli-launcher` builders (which register one route on the
|
|
3402
|
+
* RESIDENT `ProviderProxy` and return the redirect env — `ANTHROPIC_BASE_URL` +
|
|
3403
|
+
* a one-shot ROUTE token, codex's `-c base_url=…` overrides, etc.), then opens a
|
|
3404
|
+
* NEW terminal window running the CLI with that env injected. The route token —
|
|
3405
|
+
* NOT an upstream credential — is the only secret in the env; it is removed when
|
|
3406
|
+
* the session is stopped (`onSessionEnd`).
|
|
3407
|
+
*
|
|
3408
|
+
* SECRET DISCIPLINE: the env carries a route token (proxy-scoped, revocable),
|
|
3409
|
+
* never a provider key. On win32 the token rides the spawned process environment
|
|
3410
|
+
* (inherited by the terminal), never the command line / a file on disk.
|
|
3411
|
+
*
|
|
3412
|
+
* @module @omnicross/daemon/admin/cliLaunch
|
|
3413
|
+
*/
|
|
3414
|
+
|
|
3415
|
+
/** Injectable PATH probe (tests stub this; default scans `process.env.PATH`). */
|
|
3416
|
+
type PathProbe = (candidate: string) => string | null;
|
|
3417
|
+
/** Open a NEW terminal window running `command [extraArgs…]` with `env` injected. */
|
|
3418
|
+
type TerminalCleanup = () => void;
|
|
3419
|
+
type TerminalOpener = (input: {
|
|
3420
|
+
cli: string;
|
|
3421
|
+
command: string;
|
|
3422
|
+
extraArgs: string[];
|
|
3423
|
+
env: Record<string, string>;
|
|
3424
|
+
cwd?: string;
|
|
3425
|
+
platform: NodeJS.Platform;
|
|
3426
|
+
onFailure?: () => void;
|
|
3427
|
+
}) => void | TerminalCleanup;
|
|
3428
|
+
/**
|
|
3429
|
+
* Injectable shell runner for `POST /cli/:cli/install` (tests stub this; the
|
|
3430
|
+
* default execs the install command with a bounded timeout). Returns the host's
|
|
3431
|
+
* honest install outcome — `error` carries stderr/the failure reason.
|
|
3432
|
+
*/
|
|
3433
|
+
type CommandRunner = (command: string) => Promise<{
|
|
3434
|
+
ok: boolean;
|
|
3435
|
+
error?: string;
|
|
3436
|
+
}>;
|
|
3437
|
+
|
|
3438
|
+
/**
|
|
3439
|
+
* searchAdminApi — the admin API's search surface (search-settings-ui D3 +
|
|
3440
|
+
* search-settings-tab D4).
|
|
3441
|
+
*
|
|
3442
|
+
* Three routes over the daemon's search state, dispatched from `adminApi.ts`'s
|
|
3443
|
+
* `case 'search'`:
|
|
3444
|
+
*
|
|
3445
|
+
* - `GET /admin/api/search/diagnostics` — a READ-ONLY, secret-free, network-free
|
|
3446
|
+
* snapshot: one row per provider the daemon can run (the ONE runtime's
|
|
3447
|
+
* descriptors, plus `unconfigured` rows for known API providers the persisted
|
|
3448
|
+
* config does not name — the doctor's classification), the effective frontend
|
|
3449
|
+
* modes, and the explicit apply semantics (codex immediate, rest restart).
|
|
3450
|
+
* - `POST /admin/api/search/test { providerId }` — ONE live fixed-query check on
|
|
3451
|
+
* a configured provider, classified by the doctor's pure functions. The
|
|
3452
|
+
* machine-facing health probe: it sends exactly `SEARCH_DOCTOR_QUERY`, never a
|
|
3453
|
+
* caller-supplied query, and never returns result content (plan §11.3 — its
|
|
3454
|
+
* contract is the automated doctor's fixed-query discipline).
|
|
3455
|
+
* - `POST /admin/api/search/query { providerId, query }` — the INTERACTIVE
|
|
3456
|
+
* channel for the settings page's per-provider test panel (owner feedback
|
|
3457
|
+
* 2026-09-02): ONE operator-typed query through ONE provider's contribution
|
|
3458
|
+
* built from the PERSISTED config, returning the doctor-classified diagnostic
|
|
3459
|
+
* PLUS the sanitized results. The two disciplines stay separate routes on
|
|
3460
|
+
* purpose: bending `/test` to accept a query would erase the boundary its
|
|
3461
|
+
* pinned tests and consumers depend on.
|
|
3462
|
+
*
|
|
3463
|
+
* SECRET SPINE (all three routes): no response ever carries a configured VALUE,
|
|
3464
|
+
* and a failure response carries only the doctor's SANITIZED error shape — raw
|
|
3465
|
+
* upstream error bodies (which may quote the stored key) never serialize. The
|
|
3466
|
+
* query endpoint additionally sanitizes every returned result field BEFORE
|
|
3467
|
+
* serialization (plan §11.1: search results are untrusted input), and the
|
|
3468
|
+
* operator's query is never logged anywhere.
|
|
3469
|
+
*
|
|
3470
|
+
* The diagnostics dep is OPTIONAL (`AdminApiDeps.searchStatus`): light embedders
|
|
3471
|
+
* that wire no search runtime get 501 for all routes (the voucher/allowance
|
|
3472
|
+
* optionality precedent) rather than a fabricated snapshot.
|
|
3473
|
+
*
|
|
3474
|
+
* @module @omnicross/daemon/admin/searchAdminApi
|
|
3475
|
+
*/
|
|
3476
|
+
|
|
3477
|
+
/**
|
|
3478
|
+
* The daemon search state the admin surface needs. Structurally satisfied by
|
|
3479
|
+
* what `bootstrap.ts` already holds (the ONE runtime + its captured modes);
|
|
3480
|
+
* `testFetch` is a TEST SEAM so route tests can intercept the one live probe
|
|
3481
|
+
* without any network.
|
|
3482
|
+
*/
|
|
3483
|
+
interface SearchAdminRuntimeStatus {
|
|
3484
|
+
/** The daemon's ONE assembled search runtime (provider descriptors). */
|
|
3485
|
+
readonly runtime: SearchRuntime;
|
|
3486
|
+
/** Modes as captured at bootstrap (responses/anthropic are these, live). */
|
|
3487
|
+
readonly modes: SearchFrontendModes;
|
|
3488
|
+
/** TEST SEAM: fetch primitive for the live-test probe. Absent ⇒ real transport. */
|
|
3489
|
+
readonly testFetch?: (url: string, init: RequestInit) => Promise<Response>;
|
|
3490
|
+
}
|
|
3491
|
+
|
|
3492
|
+
/**
|
|
3493
|
+
* migration.ts — the export gather + import apply logic for the passphrase pack
|
|
3494
|
+
* (app-parity child 6, design D2/D3/D5).
|
|
3495
|
+
*
|
|
3496
|
+
* EXPORT (`gatherExport`): read the FULL local state DECRYPTED in-memory — every
|
|
3497
|
+
* provider row (scalars / modelConfigs / single apiKey / pool apiKeys /
|
|
3498
|
+
* transformer) via `loadConfig` (the at-rest box decrypts on read) AND the
|
|
3499
|
+
* subscription tokens via `credentialStore.getFullConfig()` (also decrypted) —
|
|
3500
|
+
* serialize to ONE bundle JSON, and `sealPack` it under the passphrase-derived
|
|
3501
|
+
* key. The caller returns ONLY the opaque pack; the decrypted bundle + the
|
|
3502
|
+
* passphrase live only in local variables and are never logged.
|
|
3503
|
+
*
|
|
3504
|
+
* IMPORT (`applyImport`): `openPack` decrypts + authenticates (a wrong passphrase
|
|
3505
|
+
* or a tampered pack fails the GCM auth-tag BEFORE any write — atomic). Every
|
|
3506
|
+
* provider is re-validated through `parseProviderInput` and every token block
|
|
3507
|
+
* through `validateTokenBody` (deny-by-default — a malicious blob cannot inject
|
|
3508
|
+
* unknown fields or escape the allowlist). Validation collects ALL rows BEFORE
|
|
3509
|
+
* applying, so a structurally invalid pack does not leave a half-applied state.
|
|
3510
|
+
* Apply merges by provider id (additive default): a new id is added; a colliding
|
|
3511
|
+
* id is skipped (or overwritten with `mode:'overwrite'`). Writes go through the
|
|
3512
|
+
* EXISTING paths (`saveConfig` re-encrypts at-rest under the LOCAL box +
|
|
3513
|
+
* `writeProviderTokens`/`appendProviderAccount`), so imported secrets land
|
|
3514
|
+
* `enc:`-encrypted under the TARGET machine's key — the passphrase key is used
|
|
3515
|
+
* ONLY for transport.
|
|
3516
|
+
*
|
|
3517
|
+
* SECRET SPINE: the export RESPONSE is the opaque pack ONLY; the import RESPONSE
|
|
3518
|
+
* is status-only counts. No decrypted secret + no passphrase ever reaches a
|
|
3519
|
+
* response body or a log here.
|
|
3520
|
+
*
|
|
3521
|
+
* @module @omnicross/daemon/migration/migration
|
|
3522
|
+
*/
|
|
3523
|
+
|
|
3524
|
+
/**
|
|
3525
|
+
* The credential-store surface the migration paths need: the full DECRYPTED read
|
|
3526
|
+
* (export) + the multi-account append (import re-encrypts at-rest). One shape so
|
|
3527
|
+
* `ExportDeps` + `ImportDeps` can be unified into `MigrationDeps` without a
|
|
3528
|
+
* `credentialStore` type conflict.
|
|
3529
|
+
*/
|
|
3530
|
+
interface MigrationCredentialStore extends SubscriptionAccountAppender {
|
|
3531
|
+
getFullConfig(): Promise<AccountTokensConfig>;
|
|
3532
|
+
}
|
|
3533
|
+
|
|
3534
|
+
/** Minimal, auth-gated admin API for secret-free account allowance snapshots. */
|
|
3535
|
+
|
|
3536
|
+
interface AccountAllowanceAdminReader {
|
|
3537
|
+
list(filter?: {
|
|
3538
|
+
providerId?: SubscriptionProviderId;
|
|
3539
|
+
accountId?: string;
|
|
3540
|
+
}): Promise<AccountAllowanceSnapshot[]>;
|
|
3541
|
+
refreshClaude(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
|
|
3542
|
+
/** Optional: Codex active `/wham/usage` refresh (absent on older daemons). */
|
|
3543
|
+
refreshCodex?(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
|
|
3544
|
+
/** Optional: Kimi `/coding/v1/usages` refresh (absent on older daemons). */
|
|
3545
|
+
refreshKimi?(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
|
|
3546
|
+
/** Optional: OpenCodeGo `/v1/usage` refresh (absent on older daemons). */
|
|
3547
|
+
refreshOpenCodeGo?(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
|
|
3548
|
+
/** Optional: Grok CLI-billing refresh (absent on older daemons). */
|
|
3549
|
+
refreshGrok?(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
|
|
3550
|
+
/** Optional: Copilot user-quota refresh (absent on older daemons). */
|
|
3551
|
+
refreshCopilot?(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
|
|
3552
|
+
/** Optional: Gemini Code-Assist quota refresh (absent on older daemons). */
|
|
3553
|
+
refreshGemini?(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
|
|
3554
|
+
/** Optional: Antigravity quotaSummary refresh (absent on older daemons). */
|
|
3555
|
+
refreshAntigravity?(accountId?: string): Promise<AccountAllowanceSnapshot[]>;
|
|
3556
|
+
removeAccountSnapshot?(providerId: SubscriptionProviderId, accountId: string): void;
|
|
3557
|
+
removeProviderSnapshots?(providerId: SubscriptionProviderId): void;
|
|
3558
|
+
getSchedulingStatus?(): AccountAllowanceSchedulingStatus;
|
|
3559
|
+
}
|
|
3560
|
+
|
|
3561
|
+
/** Token-free subscription account list entry (passthrough from core's service). */
|
|
3562
|
+
interface AdminAccountsLister {
|
|
3563
|
+
listAll(): Promise<unknown[]>;
|
|
3564
|
+
}
|
|
3565
|
+
/** One key's live cooldown health (mirrors core `KeyHealthEntry`; read-only). */
|
|
3566
|
+
interface PoolKeyHealth {
|
|
3567
|
+
until: number;
|
|
3568
|
+
errors: number;
|
|
3569
|
+
lastStatus: number | null;
|
|
3570
|
+
}
|
|
3571
|
+
/**
|
|
3572
|
+
* The READ-ONLY pool-health surface the admin view needs (key-pool design D7).
|
|
3573
|
+
* Structurally satisfied by core's `ApiKeyPoolService.getKeyHealth`; typed as a
|
|
3574
|
+
* minimal reader so `adminApi` carries no class coupling and can never reach a
|
|
3575
|
+
* key value through it (cooldown health only).
|
|
3576
|
+
*/
|
|
3577
|
+
interface PoolHealthReader {
|
|
3578
|
+
getKeyHealth(providerId: string): Promise<Record<string, PoolKeyHealth>>;
|
|
3579
|
+
}
|
|
3580
|
+
/**
|
|
3581
|
+
* The BYO provider-key quota surface the keys view needs — structurally
|
|
3582
|
+
* satisfied by `ProviderKeyQuotaService`. Read-only; the DTO is secret-free by
|
|
3583
|
+
* construction (normalized windows + diagnostic codes only).
|
|
3584
|
+
*/
|
|
3585
|
+
interface ProviderKeyQuotaReader {
|
|
3586
|
+
quotaFor(row: DaemonProviderConfig, keyId: string, options?: {
|
|
3587
|
+
force?: boolean;
|
|
3588
|
+
}): Promise<ProviderKeyQuota | null>;
|
|
3589
|
+
}
|
|
3590
|
+
interface AdminImagesStatusReader {
|
|
3591
|
+
inspectCapability(apiKeyId: string): Promise<ImageRuntimeCapabilityInspection>;
|
|
3592
|
+
status(): ImageRuntimeManagerStatus;
|
|
3593
|
+
resourceStatus(): ImageRuntimeResourceStatus | undefined;
|
|
3594
|
+
}
|
|
3595
|
+
/** The live daemon handles the management API operates over. */
|
|
3596
|
+
interface AdminApiDeps {
|
|
3597
|
+
/** Path to the daemon's `config.json` (provider catalog + `server` field). */
|
|
3598
|
+
readonly configPath: string;
|
|
3599
|
+
/** Live provider catalog (hot-reload target). */
|
|
3600
|
+
readonly llmConfig: ConfigFileProviderConfigSource;
|
|
3601
|
+
/** Named outbound-key store. */
|
|
3602
|
+
readonly keyDb: OutboundKeyDb$1;
|
|
3603
|
+
/**
|
|
3604
|
+
* OPTIONAL voucher (redemption-card) store (voucher-redemption #9). When wired,
|
|
3605
|
+
* the `/admin/api/voucher` surface can generate/list/revoke cards. Absent ⇒ the
|
|
3606
|
+
* surface returns 501 (feature not available in this build).
|
|
3607
|
+
*/
|
|
3608
|
+
readonly voucherDb?: VoucherDb;
|
|
3609
|
+
/**
|
|
3610
|
+
* OPTIONAL per-key spend reader (outbound-key-policy). When wired, the key list
|
|
3611
|
+
* surfaces each key's OWN accumulated spend (daily/weekly/total) so the admin
|
|
3612
|
+
* can see spend-vs-limit. Leak-safe: only the key's own numbers are exposed.
|
|
3613
|
+
*/
|
|
3614
|
+
readonly keySpendReader?: KeySpendReader;
|
|
3615
|
+
/** Outbound server settings store (server config persistence). */
|
|
3616
|
+
readonly settingsStore: JsonApiServerSettingsStore;
|
|
3617
|
+
/** The running outbound server (status + live applyConfig). */
|
|
3618
|
+
readonly outboundApiServer: OutboundApiServer;
|
|
3619
|
+
/** True only when production composed the hardened per-hop remote resolver. */
|
|
3620
|
+
readonly imageRemoteResolverAvailable?: boolean;
|
|
3621
|
+
/** Optional production Images runtime generation participant. */
|
|
3622
|
+
readonly imageRuntimeConfig?: {
|
|
3623
|
+
prepareConfig(config: ImagesServerConfig): Promise<PreparedServerConfigChange>;
|
|
3624
|
+
};
|
|
3625
|
+
/** Narrow metadata-only reader for authenticated Images capability/status. */
|
|
3626
|
+
readonly imageRuntimeStatus?: AdminImagesStatusReader;
|
|
3627
|
+
/**
|
|
3628
|
+
* Explicitly-consuming live image verification (images-settings-tab D3) —
|
|
3629
|
+
* delegates to the doctor service's `verifyLive` (Codex wire only). Absent
|
|
3630
|
+
* on light embedders; the endpoint then responds 501 and consumes nothing.
|
|
3631
|
+
*/
|
|
3632
|
+
readonly imageLiveVerifier?: {
|
|
3633
|
+
verifyLive(config: ImagesServerConfig, signal: AbortSignal): Promise<ImageDoctorLiveResult>;
|
|
3634
|
+
};
|
|
3635
|
+
/** Metadata-only successful Images configuration audit sink. */
|
|
3636
|
+
readonly imageConfigAudit?: (record: ImageConfigurationAuditRecord) => void;
|
|
3637
|
+
/** Process-local machine-managed routing leases (optional for light embedders). */
|
|
3638
|
+
readonly routeLeaseManager?: RouteLeaseManager;
|
|
3639
|
+
/** Subscription accounts (token-free `listAll`). */
|
|
3640
|
+
readonly subscriptionAccounts: AdminAccountsLister;
|
|
3641
|
+
/**
|
|
3642
|
+
* Secret-free upstream allowance facade. Optional for lightweight embedders;
|
|
3643
|
+
* the standalone daemon wires it and the route returns 501 when absent.
|
|
3644
|
+
*/
|
|
3645
|
+
readonly accountAllowanceService?: AccountAllowanceAdminReader;
|
|
3646
|
+
/** Live Claude cache worker; hot-reconfigured with allowance scheduling. */
|
|
3647
|
+
readonly allowanceRefreshScheduler?: Pick<ClaudeAllowanceRefreshScheduler, 'configure'>;
|
|
3648
|
+
/** Optional secret-free account connection probe + rolling history surface. */
|
|
3649
|
+
readonly accountProbeService?: AccountProbeHistoryReader & {
|
|
3650
|
+
probeAccount(providerId: _omnicross_contracts_subscription_types.SubscriptionProviderId, accountId: string): Promise<{
|
|
3651
|
+
ok: boolean;
|
|
3652
|
+
marked: boolean;
|
|
3653
|
+
}>;
|
|
3654
|
+
testAccountConnection(providerId: _omnicross_contracts_subscription_types.SubscriptionProviderId, accountId: string): Promise<{
|
|
3655
|
+
ok: boolean;
|
|
3656
|
+
marked: boolean;
|
|
3657
|
+
tier: 'local' | 'upstream' | 'generation';
|
|
3658
|
+
model?: string;
|
|
3659
|
+
}>;
|
|
3660
|
+
};
|
|
3661
|
+
/**
|
|
3662
|
+
* Least-authority subscription-token WRITER (design D4) — ONLY the mutation
|
|
3663
|
+
* methods (`writeProviderTokens` / `clearProvider`), never a token-returning
|
|
3664
|
+
* read. The token-free `subscriptionAccounts` lister stays separate so a GET
|
|
3665
|
+
* handler can never reach a token through this dep.
|
|
3666
|
+
*/
|
|
3667
|
+
readonly subscriptionTokenWriter: SubscriptionTokenWriter;
|
|
3668
|
+
/**
|
|
3669
|
+
* Read-only pool-health reader (key-pool design D7) — cooldown health only,
|
|
3670
|
+
* never a key value. Drives `GET /admin/api/providers/:id/keys`.
|
|
3671
|
+
*/
|
|
3672
|
+
readonly apiKeyPool: PoolHealthReader;
|
|
3673
|
+
/** In-memory auto-disable store (design D5) — read-only for the health view. */
|
|
3674
|
+
readonly autoDisableStore: AutoDisableStore;
|
|
3675
|
+
/**
|
|
3676
|
+
* OPTIONAL BYO provider-key quota service — same-key usage/quota probes for
|
|
3677
|
+
* provider rows with a known adapter (Z.AI coding plan, MiniMax Token Plan).
|
|
3678
|
+
* Absent ⇒ the keys view carries no `quota` field (light embedders).
|
|
3679
|
+
*/
|
|
3680
|
+
readonly providerKeyQuota?: ProviderKeyQuotaReader;
|
|
3681
|
+
/**
|
|
3682
|
+
* Pending interactive-OAuth sessions (app-parity child 4, design D1) — the
|
|
3683
|
+
* in-memory `{ codeVerifier, state }` map keyed by a minted `sessionId`,
|
|
3684
|
+
* NEVER serialized to the client.
|
|
3685
|
+
*/
|
|
3686
|
+
readonly oauthSessions: OAuthSessionStore;
|
|
3687
|
+
/**
|
|
3688
|
+
* Injected token-exchange `FetchLike` FACTORY (oauth design D2-a) — built per
|
|
3689
|
+
* provider in `bootstrap.ts` so the exchange carries a `{ providerId }` egress
|
|
3690
|
+
* ctx (per-provider proxy layer + upstream trace, bodies redacted); tests
|
|
3691
|
+
* inject a mock so no real token endpoint is hit. Mirrors how `login.ts`
|
|
3692
|
+
* injects its exchange fetch.
|
|
3693
|
+
*/
|
|
3694
|
+
readonly oauthExchangeFetch: (providerId: SubscriptionProviderId) => FetchLike;
|
|
3695
|
+
/**
|
|
3696
|
+
* NARROW append handle (oauth design D2-a) — the OAuth complete handler needs
|
|
3697
|
+
* `appendProviderAccount` (NOT on the least-authority `SubscriptionTokenWriter`).
|
|
3698
|
+
* A minimal interface, NOT the full read-capable store, so no token-returning
|
|
3699
|
+
* read is reachable. Wired from the concrete `credentialStore` in `bootstrap.ts`.
|
|
3700
|
+
*/
|
|
3701
|
+
readonly subscriptionAccountAppender: SubscriptionAccountAppender;
|
|
3702
|
+
/**
|
|
3703
|
+
* Codex interactive-OAuth flow store (app-parity-2 child 5). Tracks the async
|
|
3704
|
+
* loopback sign-in's polled status (token-free); only ONE codex login may be in
|
|
3705
|
+
* flight (port 1455 is one resource). Wired in `bootstrap.ts`.
|
|
3706
|
+
*/
|
|
3707
|
+
readonly codexSessions: CodexOAuthSessionStore;
|
|
3708
|
+
/**
|
|
3709
|
+
* Kimi interactive-OAuth flow store (device code). Same token-free polled
|
|
3710
|
+
* shape as codex; one sign-in at a time. Wired in `bootstrap.ts`.
|
|
3711
|
+
*/
|
|
3712
|
+
readonly kimiSessions: CodexOAuthSessionStore;
|
|
3713
|
+
/**
|
|
3714
|
+
* Grok interactive-OAuth flow store (device code). Same token-free polled
|
|
3715
|
+
* shape as codex; one sign-in at a time. Wired in `bootstrap.ts`.
|
|
3716
|
+
*/
|
|
3717
|
+
readonly grokSessions: CodexOAuthSessionStore;
|
|
3718
|
+
/**
|
|
3719
|
+
* Copilot interactive-OAuth flow store (device code). Same token-free
|
|
3720
|
+
* polled shape; one sign-in at a time. Wired in `bootstrap.ts`.
|
|
3721
|
+
*/
|
|
3722
|
+
readonly copilotSessions: CodexOAuthSessionStore;
|
|
3723
|
+
/** Antigravity interactive OAuth (loopback 51121) — the async flow store. */
|
|
3724
|
+
readonly antigravitySessions: CodexOAuthSessionStore;
|
|
3725
|
+
/** The one-shot 127.0.0.1:51121 listener (test seam like `codexAwaitLoopback`). */
|
|
3726
|
+
readonly antigravityAwaitLoopback: AntigravityLoopbackFn;
|
|
3727
|
+
/**
|
|
3728
|
+
* Resolve the ACTIVE antigravity account's access token for the dynamic
|
|
3729
|
+
* model-catalog probe (secret used daemon-side only; the route is
|
|
3730
|
+
* secret-free). Optional for older tests; absent → static-only catalog.
|
|
3731
|
+
*/
|
|
3732
|
+
readonly resolveAntigravityAccessToken?: () => Promise<string | null>;
|
|
3733
|
+
/**
|
|
3734
|
+
* Codex loopback listener (app-parity-2 child 5) — defaults to `awaitLoopbackCode`
|
|
3735
|
+
* (binds 127.0.0.1:1455) in `bootstrap.ts`; tests inject a mock so no real port
|
|
3736
|
+
* is bound. The captured code crosses to the daemon ONLY (never the client).
|
|
3737
|
+
*/
|
|
3738
|
+
readonly codexAwaitLoopback: CodexLoopbackFn;
|
|
3739
|
+
/**
|
|
3740
|
+
* Migration credential-store handle (app-parity child 6, design D2/D3). The
|
|
3741
|
+
* export gather needs `getFullConfig()` (full DECRYPTED tokens, in-memory only —
|
|
3742
|
+
* the pack is the only thing that leaves) and import needs `appendProviderAccount`
|
|
3743
|
+
* (multi-account append + re-encrypt at-rest). Confined to the migration
|
|
3744
|
+
* handlers (which seal/validate everything); never reached by a GET handler.
|
|
3745
|
+
* Wired from the concrete `credentialStore` in `bootstrap.ts`.
|
|
3746
|
+
*/
|
|
3747
|
+
readonly migrationCredentialStore: MigrationCredentialStore;
|
|
3748
|
+
/**
|
|
3749
|
+
* Usage-stats query facade (usage-pricing child) — delegates to the JSONL
|
|
3750
|
+
* usage-event store. Aggregates only; carries no key material.
|
|
3751
|
+
*/
|
|
3752
|
+
readonly usageRecorder: UsageRecorder;
|
|
3753
|
+
/** Pricing engine (upsert / source refresh / conflict resolution). */
|
|
3754
|
+
readonly pricingEngine: PricingEngine;
|
|
3755
|
+
/**
|
|
3756
|
+
* CONCRETE pricing store — ONLY for the store-local row `delete` (the core
|
|
3757
|
+
* `PricingStore` port is frozen; delete is a daemon-local extra).
|
|
3758
|
+
*/
|
|
3759
|
+
readonly pricingStore: JsonPricingStore;
|
|
3760
|
+
/**
|
|
3761
|
+
* External-terminal opener for the Code CLI launch route (dashboard parity).
|
|
3762
|
+
* Optional — defaults to the real `defaultTerminalOpener`; tests inject a spy so
|
|
3763
|
+
* no terminal window is actually spawned.
|
|
3764
|
+
*/
|
|
3765
|
+
readonly cliTerminalOpener?: TerminalOpener;
|
|
3766
|
+
/** Injectable PATH probe for CLI detection (tests fake "installed"). */
|
|
3767
|
+
readonly cliPathProbe?: PathProbe;
|
|
3768
|
+
/**
|
|
3769
|
+
* Injectable shell runner for the Code CLI install route. Optional — defaults
|
|
3770
|
+
* to the real `exec`-based runner; tests inject a stub so no package manager
|
|
3771
|
+
* actually runs.
|
|
3772
|
+
*/
|
|
3773
|
+
readonly cliCommandRunner?: CommandRunner;
|
|
3774
|
+
/** Factory so each request observes the outbound server's current loopback port. */
|
|
3775
|
+
readonly integrationManagerFactory?: () => IntegrationManager;
|
|
3776
|
+
/**
|
|
3777
|
+
* search-settings-ui D3: the daemon's ONE search runtime plus its
|
|
3778
|
+
* bootstrap-captured frontend modes. Optional for lightweight embedders; the
|
|
3779
|
+
* standalone daemon wires it and the `/admin/api/search` diagnostics/test
|
|
3780
|
+
* routes return 501 when absent (the voucher/allowance optionality precedent).
|
|
3781
|
+
*/
|
|
3782
|
+
readonly searchStatus?: SearchAdminRuntimeStatus;
|
|
3857
3783
|
}
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3784
|
+
/**
|
|
3785
|
+
* Dispatch one `/admin/api/*` request. `path` is the already-extracted pathname
|
|
3786
|
+
* (no query). The auth gate has already run in `AdminServer`.
|
|
3787
|
+
*/
|
|
3788
|
+
declare function handleAdminApi(req: http.IncomingMessage, res: http.ServerResponse, path: string, deps: AdminApiDeps): Promise<void>;
|
|
3789
|
+
|
|
3790
|
+
/**
|
|
3791
|
+
* AdminServer — the daemon's localhost admin/dashboard HTTP listener (RT3,
|
|
3792
|
+
* design D1/D2).
|
|
3793
|
+
*
|
|
3794
|
+
* A SEPARATE `node:http` listener distinct from core's outbound `/v1/*` server
|
|
3795
|
+
* (port 8765, untouched). Mirrors `OutboundApiServer`'s proven shape:
|
|
3796
|
+
* - `http.createServer`, default bind `127.0.0.1` (or `0.0.0.0` when
|
|
3797
|
+
* `networkBinding`), `listen` with `EADDRINUSE`→ephemeral(port 0) fallback,
|
|
3798
|
+
* - `getStatus()` (running / bound port / dashboard URL), `start` / `stop`.
|
|
3799
|
+
* Default admin port 8766.
|
|
3800
|
+
*
|
|
3801
|
+
* Auth (design D2):
|
|
3802
|
+
* - Baseline = localhost bind, no token → reachable only from the machine.
|
|
3803
|
+
* - Optional `admin.token` → every `/admin/*` request (incl. `GET /`) must
|
|
3804
|
+
* carry `Authorization: Bearer <token>` or `X-Admin-Token: <token>`; compared
|
|
3805
|
+
* server-side with a constant-time equality → `401` on a miss.
|
|
3806
|
+
* - HARD SAFETY GATE: `networkBinding` (LAN/`0.0.0.0`) without a non-empty
|
|
3807
|
+
* `admin.token` → `start` REFUSES to bind (logs + stays down, fail closed).
|
|
3808
|
+
*
|
|
3809
|
+
* Routing: `GET /` (and `GET /admin`) → `302 /ui/`; `* /admin/api/*` → the
|
|
3810
|
+
* management API (`handleAdminApi`); `GET /ui[/...]` → the Control Panel static
|
|
3811
|
+
* UI (`handleUiStatic`, from `@omnicross/ui`); everything else → `404`.
|
|
3812
|
+
*
|
|
3813
|
+
* @module @omnicross/daemon/admin/AdminServer
|
|
3814
|
+
*/
|
|
3815
|
+
|
|
3816
|
+
/** The dependencies the admin server + its API need (live daemon handles). */
|
|
3817
|
+
interface AdminServerDeps extends AdminApiDeps {
|
|
3818
|
+
/** Read the resolved admin config (enabled/port/networkBinding/token). */
|
|
3819
|
+
getAdminConfig: () => ResolvedAdminConfig;
|
|
3820
|
+
/**
|
|
3821
|
+
* Build the coarse, secret-free `/health` report (daemon-health-endpoint). A
|
|
3822
|
+
* shared closure over live handles (bootstrap wires the SAME builder into the
|
|
3823
|
+
* outbound server), served UNAUTHENTICATED — before the admin auth gate.
|
|
3824
|
+
*/
|
|
3825
|
+
getHealthReport: () => HealthReport;
|
|
3826
|
+
/**
|
|
3827
|
+
* Injected logger (configurable-logging) — the admin listener's OWN lifecycle
|
|
3828
|
+
* lines (bind/refuse/error) route through it so they honor the configured
|
|
3829
|
+
* level / format / file sink.
|
|
3830
|
+
*/
|
|
3831
|
+
logger: Logger;
|
|
3832
|
+
/**
|
|
3833
|
+
* OPTIONAL per-account probe-history reader (subscription-account-probe #8,
|
|
3834
|
+
* design D5). When wired (bootstrap → the `AccountHealthProbeScheduler`), the
|
|
3835
|
+
* AUTHED `GET /admin/api/account-probes` returns per-account probe history.
|
|
3836
|
+
* Absent ⇒ the route serves an empty list (byte-safe for embedders/tests that
|
|
3837
|
+
* do not wire it). Read-only + secret-free (ids + status labels, no tokens).
|
|
3838
|
+
*/
|
|
3839
|
+
probeHistoryReader?: AccountProbeHistoryReader;
|
|
3840
|
+
/**
|
|
3841
|
+
* OPTIONAL audit query reader (request-audit-log, design D6). When wired
|
|
3842
|
+
* (bootstrap → the date-rotated store), the AUTHED `GET /admin/api/audit`
|
|
3843
|
+
* returns filtered records. Absent ⇒ the route serves an empty list. The
|
|
3844
|
+
* records carry IP/UA/bodies → this route is behind the auth gate ONLY, NEVER
|
|
3845
|
+
* unauthenticated, NEVER on `/health`.
|
|
3846
|
+
*/
|
|
3847
|
+
auditReader?: AuditQueryReader;
|
|
3848
|
+
/** Metadata-only audit aggregate used by the overview error-rate metric. */
|
|
3849
|
+
auditStatsReader?: AuditStatsReader;
|
|
3850
|
+
/**
|
|
3851
|
+
* Reconstructs one record's bodies from the per-session shard store
|
|
3852
|
+
* (audit-store-sharding). Absent when audit was never enabled.
|
|
3853
|
+
*/
|
|
3854
|
+
auditBodyReader?: AuditBodyReader;
|
|
3855
|
+
/** Runs cross-session body compaction on demand (audit-store-sharding D8). */
|
|
3856
|
+
auditCompactor?: AuditCompactor;
|
|
3857
|
+
/**
|
|
3858
|
+
* OPTIONAL billing delivery-status reader (billing-event-stream, design D5).
|
|
3859
|
+
* When wired (bootstrap → the ledger dir), the AUTHED `GET /admin/api/billing-status`
|
|
3860
|
+
* returns secret-free total/delivered/pending counts. Absent ⇒ zeroed counts.
|
|
3861
|
+
*/
|
|
3862
|
+
billingStatusReader?: BillingStatusReader;
|
|
3863
|
+
}
|
|
3864
|
+
/** A live status snapshot for the admin listener. */
|
|
3865
|
+
interface AdminServerStatus {
|
|
3866
|
+
running: boolean;
|
|
3867
|
+
/** Actual bound port (0 when not running). */
|
|
3868
|
+
port: number;
|
|
3869
|
+
/** The dashboard URL (loopback or LAN base), or null when not running. */
|
|
3870
|
+
url: string | null;
|
|
3871
|
+
}
|
|
3872
|
+
declare class AdminServer {
|
|
3873
|
+
private readonly deps;
|
|
3874
|
+
private server;
|
|
3875
|
+
private boundPort;
|
|
3876
|
+
private boundAddr;
|
|
3877
|
+
/** Control Panel dist dir (resolved once at first request; null = no UI). */
|
|
3878
|
+
private uiDist;
|
|
3879
|
+
constructor(deps: AdminServerDeps);
|
|
3880
|
+
/**
|
|
3881
|
+
* Start the admin listener honoring the resolved admin config. Returns the
|
|
3882
|
+
* actual bound port, or `0` when it refuses/declines to bind (disabled or the
|
|
3883
|
+
* LAN fail-closed gate). Idempotent: a second call returns the bound port.
|
|
3884
|
+
*/
|
|
3885
|
+
start(): Promise<number>;
|
|
3886
|
+
/** Bind once; on EADDRINUSE retry with an ephemeral port (port 0). */
|
|
3887
|
+
private listen;
|
|
3888
|
+
/** Per-request handler: auth gate (when a token is set) → routing. */
|
|
3889
|
+
private onRequest;
|
|
3890
|
+
private dispatch;
|
|
3891
|
+
/** Constant-time bearer/header check against the configured token. */
|
|
3892
|
+
private isAuthorized;
|
|
3893
|
+
/** Stop the listener and release the port. */
|
|
3894
|
+
stop(): Promise<void>;
|
|
3895
|
+
/** A live status snapshot. */
|
|
3896
|
+
getStatus(): AdminServerStatus;
|
|
3873
3897
|
}
|
|
3874
3898
|
|
|
3875
3899
|
interface ImageTemporaryBudgetStatus {
|
|
@@ -4800,6 +4824,8 @@ interface DaemonPaths {
|
|
|
4800
4824
|
imageRuntimeConfig?: AdminApiDeps['imageRuntimeConfig'];
|
|
4801
4825
|
/** TEST/COMPOSITION SEAM: metadata-only Images status reader. */
|
|
4802
4826
|
imageRuntimeStatus?: AdminApiDeps['imageRuntimeStatus'];
|
|
4827
|
+
/** TEST/COMPOSITION SEAM: explicitly-consuming Images live verifier. */
|
|
4828
|
+
imageLiveVerifier?: AdminApiDeps['imageLiveVerifier'];
|
|
4803
4829
|
/** TEST/COMPOSITION SEAM: metadata-only successful Images config audit sink. */
|
|
4804
4830
|
imageConfigAudit?: AdminApiDeps['imageConfigAudit'];
|
|
4805
4831
|
/** TEST ONLY: deterministic Tier-A provider inside the production Images composition. */
|