@omnicross/daemon 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
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
+ import { SearchRuntime, SearchFrontendModes } from '@omnicross/core/search';
2
3
  import { ApiKeyPoolService } from '@omnicross/core/completion/ApiKeyPoolService';
3
4
  import { AllowanceSchedulingConfig, AccountProbeConfig, OutboundKeyDb as OutboundKeyDb$1, VoucherDb, KeySpendReader, OutboundApiServer, ImagesServerConfig } from '@omnicross/core/outbound-api';
4
5
  import { RouteLeaseManager, ProviderProxy } from '@omnicross/core/provider-proxy';
@@ -2406,6 +2407,60 @@ type CommandRunner = (command: string) => Promise<{
2406
2407
  error?: string;
2407
2408
  }>;
2408
2409
 
2410
+ /**
2411
+ * searchAdminApi — the admin API's search surface (search-settings-ui D3 +
2412
+ * search-settings-tab D4).
2413
+ *
2414
+ * Three routes over the daemon's search state, dispatched from `adminApi.ts`'s
2415
+ * `case 'search'`:
2416
+ *
2417
+ * - `GET /admin/api/search/diagnostics` — a READ-ONLY, secret-free, network-free
2418
+ * snapshot: one row per provider the daemon can run (the ONE runtime's
2419
+ * descriptors, plus `unconfigured` rows for known API providers the persisted
2420
+ * config does not name — the doctor's classification), the effective frontend
2421
+ * modes, and the explicit apply semantics (codex immediate, rest restart).
2422
+ * - `POST /admin/api/search/test { providerId }` — ONE live fixed-query check on
2423
+ * a configured provider, classified by the doctor's pure functions. The
2424
+ * machine-facing health probe: it sends exactly `SEARCH_DOCTOR_QUERY`, never a
2425
+ * caller-supplied query, and never returns result content (plan §11.3 — its
2426
+ * contract is the automated doctor's fixed-query discipline).
2427
+ * - `POST /admin/api/search/query { providerId, query }` — the INTERACTIVE
2428
+ * channel for the settings page's per-provider test panel (owner feedback
2429
+ * 2026-09-02): ONE operator-typed query through ONE provider's contribution
2430
+ * built from the PERSISTED config, returning the doctor-classified diagnostic
2431
+ * PLUS the sanitized results. The two disciplines stay separate routes on
2432
+ * purpose: bending `/test` to accept a query would erase the boundary its
2433
+ * pinned tests and consumers depend on.
2434
+ *
2435
+ * SECRET SPINE (all three routes): no response ever carries a configured VALUE,
2436
+ * and a failure response carries only the doctor's SANITIZED error shape — raw
2437
+ * upstream error bodies (which may quote the stored key) never serialize. The
2438
+ * query endpoint additionally sanitizes every returned result field BEFORE
2439
+ * serialization (plan §11.1: search results are untrusted input), and the
2440
+ * operator's query is never logged anywhere.
2441
+ *
2442
+ * The diagnostics dep is OPTIONAL (`AdminApiDeps.searchStatus`): light embedders
2443
+ * that wire no search runtime get 501 for all routes (the voucher/allowance
2444
+ * optionality precedent) rather than a fabricated snapshot.
2445
+ *
2446
+ * @module @omnicross/daemon/admin/searchAdminApi
2447
+ */
2448
+
2449
+ /**
2450
+ * The daemon search state the admin surface needs. Structurally satisfied by
2451
+ * what `bootstrap.ts` already holds (the ONE runtime + its captured modes);
2452
+ * `testFetch` is a TEST SEAM so route tests can intercept the one live probe
2453
+ * without any network.
2454
+ */
2455
+ interface SearchAdminRuntimeStatus {
2456
+ /** The daemon's ONE assembled search runtime (provider descriptors). */
2457
+ readonly runtime: SearchRuntime;
2458
+ /** Modes as captured at bootstrap (responses/anthropic are these, live). */
2459
+ readonly modes: SearchFrontendModes;
2460
+ /** TEST SEAM: fetch primitive for the live-test probe. Absent ⇒ real transport. */
2461
+ readonly testFetch?: (url: string, init: RequestInit) => Promise<Response>;
2462
+ }
2463
+
2409
2464
  /**
2410
2465
  * migration.ts — the export gather + import apply logic for the passphrase pack
2411
2466
  * (app-parity child 6, design D2/D3/D5).
@@ -2627,6 +2682,13 @@ interface AdminApiDeps {
2627
2682
  readonly cliCommandRunner?: CommandRunner;
2628
2683
  /** Factory so each request observes the outbound server's current loopback port. */
2629
2684
  readonly integrationManagerFactory?: () => IntegrationManager;
2685
+ /**
2686
+ * search-settings-ui D3: the daemon's ONE search runtime plus its
2687
+ * bootstrap-captured frontend modes. Optional for lightweight embedders; the
2688
+ * standalone daemon wires it and the `/admin/api/search` diagnostics/test
2689
+ * routes return 501 when absent (the voucher/allowance optionality precedent).
2690
+ */
2691
+ readonly searchStatus?: SearchAdminRuntimeStatus;
2630
2692
  }
2631
2693
  /**
2632
2694
  * Dispatch one `/admin/api/*` request. `path` is the already-extracted pathname
@@ -4065,6 +4127,13 @@ interface Daemon {
4065
4127
  readonly settingsStore: JsonApiServerSettingsStore;
4066
4128
  /** App-session extension-operation registry shared with the resident proxy. */
4067
4129
  readonly openAIOperationRegistry: OpenAIOperationRegistry;
4130
+ /**
4131
+ * The ONE search runtime for this daemon (plan 阶段5 §6.3). The same object
4132
+ * the Codex route, both managed frontends and the search doctor hold.
4133
+ */
4134
+ readonly searchRuntime: SearchRuntime;
4135
+ /** Per-frontend search modes as loaded at bootstrap. */
4136
+ readonly searchFrontendModes: SearchFrontendModes;
4068
4137
  /** Stable Images forwarders and generation lifecycle owner for this app session. */
4069
4138
  readonly imageRuntimeManager: ImageRuntimeManager;
4070
4139
  /** Bounded process-local metadata aggregation shared by every runtime generation. */
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
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
+ import { SearchRuntime, SearchFrontendModes } from '@omnicross/core/search';
2
3
  import { ApiKeyPoolService } from '@omnicross/core/completion/ApiKeyPoolService';
3
4
  import { AllowanceSchedulingConfig, AccountProbeConfig, OutboundKeyDb as OutboundKeyDb$1, VoucherDb, KeySpendReader, OutboundApiServer, ImagesServerConfig } from '@omnicross/core/outbound-api';
4
5
  import { RouteLeaseManager, ProviderProxy } from '@omnicross/core/provider-proxy';
@@ -2406,6 +2407,60 @@ type CommandRunner = (command: string) => Promise<{
2406
2407
  error?: string;
2407
2408
  }>;
2408
2409
 
2410
+ /**
2411
+ * searchAdminApi — the admin API's search surface (search-settings-ui D3 +
2412
+ * search-settings-tab D4).
2413
+ *
2414
+ * Three routes over the daemon's search state, dispatched from `adminApi.ts`'s
2415
+ * `case 'search'`:
2416
+ *
2417
+ * - `GET /admin/api/search/diagnostics` — a READ-ONLY, secret-free, network-free
2418
+ * snapshot: one row per provider the daemon can run (the ONE runtime's
2419
+ * descriptors, plus `unconfigured` rows for known API providers the persisted
2420
+ * config does not name — the doctor's classification), the effective frontend
2421
+ * modes, and the explicit apply semantics (codex immediate, rest restart).
2422
+ * - `POST /admin/api/search/test { providerId }` — ONE live fixed-query check on
2423
+ * a configured provider, classified by the doctor's pure functions. The
2424
+ * machine-facing health probe: it sends exactly `SEARCH_DOCTOR_QUERY`, never a
2425
+ * caller-supplied query, and never returns result content (plan §11.3 — its
2426
+ * contract is the automated doctor's fixed-query discipline).
2427
+ * - `POST /admin/api/search/query { providerId, query }` — the INTERACTIVE
2428
+ * channel for the settings page's per-provider test panel (owner feedback
2429
+ * 2026-09-02): ONE operator-typed query through ONE provider's contribution
2430
+ * built from the PERSISTED config, returning the doctor-classified diagnostic
2431
+ * PLUS the sanitized results. The two disciplines stay separate routes on
2432
+ * purpose: bending `/test` to accept a query would erase the boundary its
2433
+ * pinned tests and consumers depend on.
2434
+ *
2435
+ * SECRET SPINE (all three routes): no response ever carries a configured VALUE,
2436
+ * and a failure response carries only the doctor's SANITIZED error shape — raw
2437
+ * upstream error bodies (which may quote the stored key) never serialize. The
2438
+ * query endpoint additionally sanitizes every returned result field BEFORE
2439
+ * serialization (plan §11.1: search results are untrusted input), and the
2440
+ * operator's query is never logged anywhere.
2441
+ *
2442
+ * The diagnostics dep is OPTIONAL (`AdminApiDeps.searchStatus`): light embedders
2443
+ * that wire no search runtime get 501 for all routes (the voucher/allowance
2444
+ * optionality precedent) rather than a fabricated snapshot.
2445
+ *
2446
+ * @module @omnicross/daemon/admin/searchAdminApi
2447
+ */
2448
+
2449
+ /**
2450
+ * The daemon search state the admin surface needs. Structurally satisfied by
2451
+ * what `bootstrap.ts` already holds (the ONE runtime + its captured modes);
2452
+ * `testFetch` is a TEST SEAM so route tests can intercept the one live probe
2453
+ * without any network.
2454
+ */
2455
+ interface SearchAdminRuntimeStatus {
2456
+ /** The daemon's ONE assembled search runtime (provider descriptors). */
2457
+ readonly runtime: SearchRuntime;
2458
+ /** Modes as captured at bootstrap (responses/anthropic are these, live). */
2459
+ readonly modes: SearchFrontendModes;
2460
+ /** TEST SEAM: fetch primitive for the live-test probe. Absent ⇒ real transport. */
2461
+ readonly testFetch?: (url: string, init: RequestInit) => Promise<Response>;
2462
+ }
2463
+
2409
2464
  /**
2410
2465
  * migration.ts — the export gather + import apply logic for the passphrase pack
2411
2466
  * (app-parity child 6, design D2/D3/D5).
@@ -2627,6 +2682,13 @@ interface AdminApiDeps {
2627
2682
  readonly cliCommandRunner?: CommandRunner;
2628
2683
  /** Factory so each request observes the outbound server's current loopback port. */
2629
2684
  readonly integrationManagerFactory?: () => IntegrationManager;
2685
+ /**
2686
+ * search-settings-ui D3: the daemon's ONE search runtime plus its
2687
+ * bootstrap-captured frontend modes. Optional for lightweight embedders; the
2688
+ * standalone daemon wires it and the `/admin/api/search` diagnostics/test
2689
+ * routes return 501 when absent (the voucher/allowance optionality precedent).
2690
+ */
2691
+ readonly searchStatus?: SearchAdminRuntimeStatus;
2630
2692
  }
2631
2693
  /**
2632
2694
  * Dispatch one `/admin/api/*` request. `path` is the already-extracted pathname
@@ -4065,6 +4127,13 @@ interface Daemon {
4065
4127
  readonly settingsStore: JsonApiServerSettingsStore;
4066
4128
  /** App-session extension-operation registry shared with the resident proxy. */
4067
4129
  readonly openAIOperationRegistry: OpenAIOperationRegistry;
4130
+ /**
4131
+ * The ONE search runtime for this daemon (plan 阶段5 §6.3). The same object
4132
+ * the Codex route, both managed frontends and the search doctor hold.
4133
+ */
4134
+ readonly searchRuntime: SearchRuntime;
4135
+ /** Per-frontend search modes as loaded at bootstrap. */
4136
+ readonly searchFrontendModes: SearchFrontendModes;
4068
4137
  /** Stable Images forwarders and generation lifecycle owner for this app session. */
4069
4138
  readonly imageRuntimeManager: ImageRuntimeManager;
4070
4139
  /** Bounded process-local metadata aggregation shared by every runtime generation. */