@aiquants/enrichment-react-router 0.2.0 → 0.2.2

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/README.md CHANGED
@@ -182,7 +182,7 @@ A host read answers every failure it can describe as an outcome. The reads whose
182
182
  | Prop | Required | Purpose |
183
183
  | --- | --- | --- |
184
184
  | `onSearch: MetadataSearchRunner` | yes | Runs a metadata search. The workbench is the first tab and cannot be hidden, so the host must supply the runner; this package names no route. |
185
- | `loadIntegrityOverview: IntegrityOverviewLoader` | yes | `(signal) => Promise<ResourceOutcome<IntegrityAuditOverview>>` — the same overview the store reads, through the host's own route. The view polls it while a run is active, reads it once on every return to the tab while an overview is shown, and calls it from the reload of a failed first read. |
185
+ | `loadIntegrityOverview: IntegrityOverviewLoader` | yes | `(signal) => Promise<ResourceOutcome<IntegrityAuditOverview>>` — the same overview the store reads, through the host's own route. The view polls it while a run is active, reads it once on every return to the tab while an overview is shown, and calls it from the reload of a failed first read. A 403 keeps its status, and its `reason` names only the cause the route declared (which permission or scope to fix), or is `""` when it declared none (`@aiquants/console-ui`'s `ResourceOutcome` contract): the view states the refusal itself and follows it with that cause. |
186
186
  | `loadIntegrityFindings: IntegrityFindingsLoader` | yes | `(query, signal) => Promise<ResourceOutcome<IntegrityFindingPage>>` — a page of one cell's findings, for the audit card's findings inspector. |
187
187
  | `policyConflicts: PolicyConflictHost` | yes | The summary, the list's pages, a pair's detail, the decision and the detection (`@aiquants/governance-react`); reads answer `ResourceOutcome`, the decision and the detection `CommandOutcome` with the core's rejection body. |
188
188
  | `documentAuthority: DocumentAuthorityHost` | yes | The ledger's pages, the unregistered candidates, the replaceable rows and the command (`CommandOutcome` with the core's rejection body). |
@@ -190,7 +190,7 @@ A host read answers every failure it can describe as an outcome. The reads whose
190
190
  | `graphTraversal?: GraphTraversalHost` | no | `{ run: GraphTraversalRunner; listRelationshipTypes: GraphRelationshipTypesReader }` — graph traversal and the relationship types it may follow, supplied together; the traversal form is absent without it. `listRelationshipTypes` answers the deployment's offer (`{ ok: true, relationshipTypes }`, e.g. from the governance backend's `POST /ai/governance/admin/kg/relationship-types`, or `{ ok: false, reason }`); the form offers exactly those types, says why nothing can be traversed when the offer is empty, and re-reads when the function changes — keep the object stable (a module constant). A traversal that names no type follows the whole offer. `run` hands the backend's rows over unchanged (`label`, `from_label`, `to_label` included): the result map names each node by label and identifier, so an `Entity` and a `File` with the same identifier stay two nodes, and offers only `Entity` nodes as the next start. |
191
191
  | `onBrowseGraphNodes?` | no | Reads one page of a label's nodes; the index is absent without it. |
192
192
  | `onSimulateGovernance?: SimulationRunner` | no | Governance dry run; the dry-run console is absent without it. |
193
- | `onLoadDocumentRuns?: DocumentRunsLoader` | no | `(metadataId, signal) => Promise<ResourceOutcome<readonly PipelineRunRecord[]>>` — every recorded run of one document, with steps, **newest first**, read with the caller's tenant (an empty `value` is a document with no run). A failed read's `reason` is shown inside `処理履歴を読めませんでした (<reason>)。`, so answer it as a short phrase without a final 。 (e.g. `HTTP 503 で拒まれました`). The panel aborts the read (`signal`) when it opens another document or closes. Without it the history panel, the 詳細 button on each recent run and the 履歴 button on each ingest row are all absent. |
193
+ | `onLoadDocumentRuns?: DocumentRunsLoader` | no | `(metadataId, signal) => Promise<ResourceOutcome<readonly PipelineRunRecord[]>>` — every recorded run of one document, with steps, **newest first**, read with the caller's tenant (an empty `value` is a document with no run). A failed read's `reason` is shown inside `処理履歴を読めませんでした (<reason>)。`, so answer it as a short phrase without a final 。 (e.g. `HTTP 503 で拒まれました`); a 403 is shown as `処理履歴を閲覧する権限がありません。` followed by its `reason` as a second sentence, so a 403's `reason` names only the cause the route declared (which permission or scope to fix), or is `""` when it declared none (`@aiquants/console-ui`'s `ResourceOutcome` contract). The panel aborts the read (`signal`) when it opens another document or closes. Without it the history panel, the 詳細 button on each recent run and the 履歴 button on each ingest row are all absent. |
194
194
  | `onCompareVariants?: ModelComparisonRunner` | no | Runs a side-by-side search over two strategy rows (`ComparisonInput.strategyIds`, answered per `strategyId`); the model-comparison workbench (below the search workbench) is absent without it. A search that could not run should be answered as `{ ok: false, reason }` (the reason is shown as given); a rejection is shown as a failure too and clears the previous outcome. |
195
195
  | `data?` / `fetcher?` / `integrityFetcher?` / `renderHeader?` | no | Overrides for tests and special mounts (`integrityFetcher` carries the audit card's start and cancel only). The view is mounted under a data router in every case: it re-reads the route's loader (`useRevalidator`) after a start or cancel failure that outdates the overview, and an injected `data` does not receive that re-read. |
196
196
 
@@ -214,21 +214,33 @@ Only the selected panel is mounted, so leaving a tab discards what was typed the
214
214
  - Headers, run / document ids, kind, trigger, attempt, times and the 詳細 button never wrap (`whitespace-nowrap`); only the failed step and the requester (`wrap-anywhere`) wrap, so a squeezed table breaks long values instead of splitting 詳細 or きっかけ mid-word.
215
215
  - The document history panel (`PipelineRunInspector`) opens above the panels and stays open across tabs.
216
216
  - A recent run's 詳細 opens that run's document with that run selected. An ingest row's 履歴 opens the document's whole history and selects the newest run once it is read — also for a row with no recorded run, which the panel then states as a neutral `role="status"` note.
217
- - The panel reads through `onLoadDocumentRuns`, shows `処理履歴を読めませんでした (<reason>)。` when the read fails, rejects or throws (for a rejection or a throw the reason is the error's message), and ignores a read that settles after it was closed or another document was opened.
217
+ - The panel reads through `onLoadDocumentRuns`, shows `処理履歴を読めませんでした (<reason>)。` when the read fails, rejects or throws (for a rejection or a throw the reason is the error's message; a `""` reason leaves out the parentheses), and ignores a read that settles after it was closed or another document was opened.
218
+ - A 403 is not wrapped in that sentence: the panel states the refusal, `処理履歴を閲覧する権限がありません。`, followed by the declared cause as a second sentence (`…ありません。<reason>。`, the same composition as `ResourceFailed`'s), or that sentence alone for `""`.
218
219
  - An entry point's run stays selected even when the history does not list it (the panel says so); the newest run is never substituted for it.
219
220
  - Re-targeting keeps the one panel mounted. Every open from outside the panel (a 詳細 or 履歴 press, including one that names the run already shown) bumps the panel's `openRequest`, so focus moves to its heading each time; a load settling on the newest run does not move focus.
220
221
  - On 閉じる or Escape focus returns to the entry point that opened the panel most recently; when that element has left the page (its tab panel was switched away), the panel's `returnFocusFallback` hands focus to the active tab's button.
221
222
  - A history holding a provenance string with nothing to read (any string a step's report carries, such as `provider` or `model`) — empty, or only white space of JavaScript's and Python's `\s` — is shown as a failure naming the run, the step and the field (`処理履歴の記録に読めない来歴の値があります (実行 <id> の段 <sequence> の <field>)。`, not wrapped in the failed-read sentence), and its runs are not handed to the panel (the panel's measured text slot would refuse it while rendering and take the console with it).
222
223
  - `search` draws `MetadataSearchWorkbench` and, when `onCompareVariants` is supplied, `ModelComparisonWorkbench`, keyed by `strategyId`, with each variant labelled `<domainKey> / <variantKey> (<embeddingModel>)`.
223
224
  - `knowledge-authority` (権威台帳 & 規程衝突) draws `DocumentAuthorityRegistry` (its `canUpdate` is the loader's `canUpdateKnowledge`) and then `PolicyConflictQueue`. The view keeps a policy conflict revision: the ledger's `onPolicyConflictsChanged` advances it, and the queue re-reads its summary, its first page and the open detail in place when it changes.
224
- - `data-retention` (データ保持 & 整合性監査) draws `TriStoreIntegrityAudit`, then `PolicyConflictSummaryCard` (its `knowledgeTabLabel` is the knowledge-authority tab's label, and its link switches to that tab and moves focus to it), then the bulk-retry notice and the `SyncStatusMonitor` / `QdrantStorageCard` grid.
225
+ - `data-retention` (データ保持 & 整合性監査) draws `TriStoreIntegrityAudit`, then `PolicyConflictSummaryCard` (its `knowledgeTabLabel` is the knowledge-authority tab's label, and its link switches to that tab and moves focus to it), then the bulk-retry notice and the `SyncStatusMonitor` / `QdrantStorageCard` grid. `SyncStatusMonitor` sits in a `<section tabIndex={-1}>` (`sync-status-region`) named `エンリッチメント同期ステータス`, its card's own heading.
225
226
  - The overview is kept last-good: the loader's answer, every poll and the reload are applied in arrival order through the console foundation's `keepLastGood`, so an overview once shown stays through later failures, which show only `更新に失敗しました (<reason>)。`. A success whose `readAt` is strictly earlier than the shown one (the core's `isStrictlyEarlier`, which compares every fractional digit across offsets) is dropped.
226
- - Until an overview has been shown, a card titled `Tri-Store データ整合性監査` (`audit-overview-failed`) holds the console foundation's `ResourceFailed` (`audit-overview-failed-resource`): `監査の概況を読めませんでした (<reason>)。` with `再読み込み`, or for a 403 only `監査の概況を閲覧する権限がありません。`. Besides the loader's next answer, the reload is the only way back (neither the polling nor a return to the tab reads without an overview); focus that was on `再読み込み` moves to the audit card's heading on success, or to this card's heading when the reload answers 403.
227
- - While the shown overview has an active run, the tab is shown and the document is visible, the overview is re-read every 2 s (`INTEGRITY_RUN_POLL_MS`), or every 10 s while the run's heartbeat is stale; a hidden document or another tab stops the polling and aborts the read in flight. The polling stops when a read shows the run ended, and when a re-read is refused (401 / 403: repeating it would only repeat the refusal; the shown overview stays with `更新に失敗しました (<reason>)。`).
227
+ - A 403 is the exception: it withdraws a shown overview, since the operator may no longer read it and the card's refresh note carries no status to say so. The overview is then drawn as a first read answered 403 is (below), and focus that was inside the audit card moves to the heading of the card drawn in its place.
228
+ - Until an overview has been shown, and after a 403 withdrew it, a card titled `Tri-Store データ整合性監査` (`audit-overview-failed`) holds the console foundation's `ResourceFailed` (`audit-overview-failed-resource`).
229
+ It reads `監査の概況を読めませんでした (<reason>)。` with `再読み込み` (a `""` reason leaves out the parentheses), or for a 403 `監査の概況を閲覧する権限がありません。` followed by the cause the route declared (`…ありません。<reason>。`, that sentence alone for `""`) and no reload.
230
+ For a failure other than 403, the reload is, besides the loader's next answer, the only way back (neither the polling nor a return to the tab reads without an overview); a 403 card offers no reload, so only the loader's next answer brings the overview back. Focus that was on `再読み込み` moves to the audit card's heading on success, or to this card's heading when the reload answers 403.
231
+ - While the shown overview has an active run, the tab is shown and the document is visible, the overview is re-read every 2 s (`INTEGRITY_RUN_POLL_MS`), or every 10 s while the run's heartbeat is stale; a hidden document or another tab stops the polling and aborts the read in flight. The polling stops when a read shows the run ended, when a re-read is refused with 401 (repeating it would only repeat the refusal; the shown overview stays with `更新に失敗しました (<reason>)。`), and when a 403 withdraws the overview.
228
232
  - Whenever the tab is shown and the document visible again after either was not — the first visit to the tab after the console mounted on another included — the overview is read once at once, with or without an active run: the card, mounted again with the tab, counts its age label from `readAt` plus the time since its own mount, and a successful read corrects the time away. A failed read leaves the relative age short by the time away, while the absolute 最終測定 time and `更新に失敗しました (<reason>)。` stay correct. A mount on the tab itself reads nothing: the loader has just answered.
229
- - The audit card's start (`start_integrity_run`) and cancel (`cancel_integrity_run`) go through a fetcher of their own (`integrityFetcher`), so a sync retry on the same tab never aborts them, nor they a retry (React Router aborts a fetcher's earlier submission when it submits again); the card is told which one is in flight. The console's alert states the `{ error }` of whichever fetcher settled last.
233
+ - The audit card's start (`start_integrity_run`) and cancel (`cancel_integrity_run`) go through a fetcher of their own (`integrityFetcher`), so a sync retry on the same tab never aborts them, nor they a retry (React Router aborts a fetcher's earlier submission when it submits again); the card is told which one is in flight. The console's alert states the `{ error }` of whichever fetcher settled last, except the findings inspector's own resync (below), which the inspector states instead.
230
234
  A failure the action answers as `{ failure }` — the `storage_admin:update` refusal included — reaches the card as `{ failure, occurrence }`, never the console's error alert (the occurrence advances with every failure, so a repeated failure is announced again).
231
235
  The session and operator gates (no session, a blank `email`) and a malformed form answer `{ error }` in the console's alert, as for every intent. Any answer without a failure clears the card's, and so does leaving the tab, so a failure is announced once: one that settled while another tab was shown is shown when the operator returns. After a failure that outdates the overview the view re-reads the loader.
236
+ - The card's findings inspector gets the console's document controls and remedy places:
237
+ - `onShowHistory` is the ingest rows' history entry: a row's `履歴` opens the document history panel on the row's document and selects its newest run. Without `onLoadDocumentRuns` the rows offer no `履歴` and no remedy names it.
238
+ - `resync`: a row's `再同期` or `再試行` sets the console's one press state (`InspectorResync`: `{ metadataId, intent: "retry_job", status: "pending", error: null }`) and submits `retry_job` with the document's metadata id as `fileId` on the shared fetcher, as the sync monitor's retries do. The inspector draws the state (`pending` busy row buttons; `accepted` a sentence read once; `refused` an alert in the inspector with the action's `error`) and dismisses it once it goes away (a cell switch, 閉じる, Escape, a link to another tab, a tab switch, a newer run), which sets the state to `null`.
239
+ - A press while the shared fetcher is not idle (submitting or revalidating anything: the sync monitor's `retry_all_failed` or `retry_job`, the press of an inspector that went away, a command still in flight from another tab) sends nothing: submitting would make React Router drop that submission's answer, such as the `retry-all-skipped` rows or a retry's refusal.
240
+ The state becomes `refused` with the reason `送信中の操作 (同期の再試行など) の結果を待っているため、送っていません。結果が出てから押し直してください。`, which the inspector states as its own refusal (once per press); the console's alert and the other submission's settlement are untouched. Pressing again once the fetcher is idle submits.
241
+ - A settlement of the shared fetcher while the state is `pending` is routed by its intent. `retry_job` is the press's own (while it is in flight `isRetrying` disables the sync monitor's retries, and a fetcher settles only its latest submission): the state becomes `accepted`, or `refused` with the answer's `error`, and the console's alert states nothing until the next settlement of either fetcher. Any other intent superseded the press, so the state is dropped and the settlement reaches the console's alert as usual.
242
+ Without a `pending` state (dismissed, never pressed, or a press refused because the fetcher was busy) every settlement reaches the console's alert: a press whose inspector went away shows its refusal there, and its success stays silent like the sync monitor's own retries.
243
+ - `remedyDestinations`: the strategies are the `パイプライン & 接続状態` tab and the projection policy the `モデル & パラメータ設定` tab, each named by its tab's label; their links open the tab and move focus to its tab button, which takes the card and its inspector away (`closesInspector: true`). The failed-sync list is `エンリッチメント同期ステータス`: its link moves focus to the region around `SyncStatusMonitor` on the same tab and leaves the inspector open (`closesInspector: false`).
232
244
  - The route must re-read its loader after a successful start or cancel: that re-read is how the new run appears and the polling begins. React Router's default `shouldRevalidate` does; a host that skips the re-read for intents without a loader effect must not list these two.
233
245
 
234
246
  The console derives its in-flight and settled state from the fetcher: `isRetrying` / `isResolving` follow the intent in flight, rows skipped by `retry_all_failed` are listed in a `retry-all-skipped` notice, and the transcription-adaptation saves return a promise that settles with the submission (rejecting with the action's `error`), so the board keeps its inputs on refusal.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var Ie=Object.defineProperty;var Rt=Object.getOwnPropertyDescriptor;var ht=Object.getOwnPropertyNames;var vt=Object.prototype.hasOwnProperty;var It=(e,t)=>{for(var n in t)Ie(e,n,{get:t[n],enumerable:!0})},wt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ht(t))!vt.call(e,i)&&i!==n&&Ie(e,i,{get:()=>t[i],enumerable:!(r=Rt(t,i))||r.enumerable});return e};var At=e=>wt(Ie({},"__esModule",{value:!0}),e);var yn={};It(yn,{StorageAdminConsoleView:()=>Ee,checkAllSystemHealth:()=>xe,checkBackendApiHealth:()=>rt,checkNeo4jHealth:()=>et,checkQdrantHealth:()=>Xe,checkRedisHealth:()=>tt,checkSqlServerHealth:()=>nt,createStorageAdminApp:()=>gn,createStorageAdminServer:()=>Le});module.exports=At(yn);var q=require("@aiquants/console-ui"),U=require("@aiquants/enrichment-core"),S=require("@aiquants/enrichment-react"),h=require("@aiquants/governance-react"),g=require("react"),$=require("react-router");var oe="ja-JP";var Pt=/[^\s\x1c-\x1f\x85\ufeff]/;function le(e){return Pt.test(e)}function te(e,t){return new Promise(n=>n(e())).catch(n=>t(n instanceof Error?n.message:String(n)))}var ue=require("@aiquants/console-ui/core"),$e=require("@aiquants/enrichment-core"),T=require("react");var Nt=2e3,Tt=1e4;function we(e,t){return t.ok&&e.kind==="ready"&&(0,$e.isStrictlyEarlier)(t.value.readAt,e.value.readAt)?e:(0,ue.keepLastGood)(e,t)}var Et=new Set([401,403]);function _t(e){return e.kind==="failed"||e.refreshFailure!==null&&Et.has(e.refreshFailure.status)?null:e.value.active}function Ke(e,t){let[n,r]=(0,T.useState)(()=>({loaded:e,overview:we({kind:"loading"},e)}));n.loaded!==e&&r({loaded:e,overview:we(n.overview,e)});let i=(0,T.useRef)(t);i.current=t;let s=(0,T.useRef)(null);(0,T.useEffect)(()=>()=>s.current?.abort(),[]);let l=(0,T.useCallback)((c,m)=>te(m,y=>({ok:!1,status:null,reason:y})).then(y=>{c.aborted||r(v=>({loaded:v.loaded,overview:we(v.overview,y)}))}),[]),u=(0,T.useCallback)(()=>{let c=new AbortController;s.current=c,r(m=>({loaded:m.loaded,overview:(0,ue.beginReload)(m.overview,"reload")})),l(c.signal,()=>i.current(c.signal))},[l]),d=(0,T.useCallback)(c=>l(c,()=>i.current(c)),[l]);return{overview:n.overview,reload:u,poll:d}}function Ct(e){return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)}function xt(){return document.visibilityState==="visible"}function Ot(){return!0}function qe(e,t,n){let r=(0,T.useSyncExternalStore)(Ct,xt,Ot),i=t&&r,s=(0,T.useRef)(i),l=e.kind==="ready",u=_t(e),d=u===null?null:u.run.runUid,c=u===null?!1:u.isStale;(0,T.useEffect)(()=>{let m=i&&!s.current;if(s.current=i,!i||d===null&&!(m&&l))return;let y=new AbortController,v=c?Tt:Nt,b,I=async()=>{await n(y.signal),!y.signal.aborted&&d!==null&&(b=setTimeout(I,v))};return b=setTimeout(I,m?0:v),()=>{y.abort(),clearTimeout(b)}},[i,l,d,c,n])}var Ae={columns:2,className:"grid-cols-2",spanClassNames:{1:"col-span-1",2:"col-span-2"}},Pe={columns:4,className:"@min-[41.5rem]:grid-cols-4",spanClassNames:{1:"@min-[41.5rem]:col-span-1",2:"@min-[41.5rem]:col-span-2",3:"@min-[41.5rem]:col-span-3",4:"@min-[41.5rem]:col-span-4"}},Ne={className:"@min-[82rem]:grid-flow-col @min-[82rem]:auto-cols-fr @min-[82rem]:grid-cols-none",lastTabClassName:"@min-[82rem]:col-auto"};function Te(e,t){let n=t%e.columns,r=n===0?1:e.columns-n+1;return e.spanClassNames[r]}var a=require("react/jsx-runtime"),Ve="tab",de={key:"knowledge-authority",phrases:["\u6A29\u5A01\u53F0\u5E33 & \u898F\u7A0B\u885D\u7A81"]},K=[{key:"search",phrases:["\u30E1\u30BF\u30C7\u30FC\u30BF\u691C\u7D22","\u30EF\u30FC\u30AF\u30D9\u30F3\u30C1"]},{key:"ingest",phrases:["\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8","\u53D6\u308A\u8FBC\u307F & \u30E1\u30BF\u751F\u6210"]},{key:"pipeline",phrases:["\u30D1\u30A4\u30D7\u30E9\u30A4\u30F3 & \u63A5\u7D9A\u72B6\u614B"]},{key:"knowledge-graph",phrases:["\u30CA\u30EC\u30C3\u30B8\u30B0\u30E9\u30D5","\u63A2\u7D22"]},{key:"parameters",phrases:["\u30E2\u30C7\u30EB & \u30D1\u30E9\u30E1\u30FC\u30BF\u8A2D\u5B9A"]},{key:"prompts",phrases:["\u30D7\u30ED\u30F3\u30D7\u30C8 & \u30C9\u30E9\u30A4\u30E9\u30F3"]},de,{key:"data-retention",phrases:["\u30C7\u30FC\u30BF\u4FDD\u6301 & \u6574\u5408\u6027\u76E3\u67FB"]}];function Lt(e){return e.phrases.join("")}function Ft(e){return e!==null&&K.some(t=>t.key===e)}var jt="Tri-Store \u30C7\u30FC\u30BF\u6574\u5408\u6027\u76E3\u67FB";function Ut(e){return`\u76E3\u67FB\u306E\u6982\u6CC1\u3092\u8AAD\u3081\u307E\u305B\u3093\u3067\u3057\u305F (${e})\u3002`}function Dt(e){return`\u51E6\u7406\u5C65\u6B74\u3092\u8AAD\u3081\u307E\u305B\u3093\u3067\u3057\u305F (${e})\u3002`}var Be={state:"idle",formData:null,data:null,submit:()=>Promise.resolve()};function Je({data:e,fetcher:t,integrityFetcher:n,renderHeader:r,graphTraversal:i,onBrowseGraphNodes:s,onSimulateGovernance:l,onRefreshIngestQueue:u,onSearch:d,onLoadDocumentRuns:c,onCompareVariants:m,loadIntegrityOverview:y,loadIntegrityFindings:v,policyConflicts:b,documentAuthority:I}){let[f,B]=(0,g.useState)(null),[H,x]=(0,g.useState)(null),[O,k]=(0,g.useState)(!1),Q=(0,g.useMemo)(()=>{if(s!==void 0)return(o,R)=>{k(!0),te(()=>s(o,R),w=>({ok:!1,reason:w})).then(w=>{k(!1),x(w.ok?null:w.reason),w.ok&&B(w.page)})}},[s]),[G,z]=(0,$.useSearchParams)(),L=G.get(Ve),A=Ft(L)?L:K[0].key,F=o=>{z(R=>{let w=new URLSearchParams(R);return w.set(Ve,o),w},{replace:!1,preventScrollReset:!0})},re=Ht(e.recentIngestItems,u,A==="ingest"),j=Ke(e.integrityAudit,y);qe(j.overview,A==="data-retention",j.poll);let Z=(0,g.useRef)(null),me=(0,q.useFocusRescue)(()=>Z.current),[ge,ye]=(0,g.useState)(0),fe=(0,g.useCallback)(()=>ye(o=>o+1),[]),p=re===null?e:{...e,recentIngestItems:[...re]},J=(0,g.useRef)({}),be=(0,g.useCallback)(()=>J.current[A]??null,[A]),se=(0,g.useMemo)(()=>$t(e.enrichmentStrategies),[e.enrichmentStrategies]),Se=(0,g.useMemo)(()=>e.strategyVariants.map(Kt),[e.strategyVariants]),E=Bt(c),W=E.open,Re=W===void 0?void 0:o=>W(o,null),he=W===void 0?void 0:o=>W(o.metadataId,o.id),ie=(o,R)=>{let w=K.length-1,_;if(o.key==="ArrowRight"||o.key==="ArrowDown")_=R===w?0:R+1;else if(o.key==="ArrowLeft"||o.key==="ArrowUp")_=R===0?w:R-1;else if(o.key==="Home")_=0;else if(o.key==="End")_=w;else return;o.preventDefault();let ae=K[_].key;F(ae),J.current[ae]?.focus()},Fe={...p.featureFlags};if(t.formData&&t.formData.get("intent")==="toggle_flag"){let o=String(t.formData.get("flagKey")??""),R=String(t.formData.get("enabled")??"")==="true";o&&(Fe[o]=R)}let ot=t.data&&"inspection"in t.data?t.data.inspection:void 0,X=t.state==="idle"?null:t.formData?.get("intent"),lt=X==="inspect_uri",ut=X==="ingest_document",dt=X==="retry_job"||X==="retry_all_failed",ct=X==="resolve_entity",je=n.state==="idle"?null:n.formData?.get("intent"),pt=je==="start_integrity_run"?{kind:"starting",mode:U.IntegrityRunModeSchema.parse(n.formData?.get("mode"))}:je==="cancel_integrity_run"?{kind:"cancelling"}:{kind:"idle"},mt=(0,$.useRevalidator)(),[gt,ve]=(0,g.useState)(null),Ue=A!=="data-retention";(0,g.useEffect)(()=>{Ue&&ve(null)},[Ue]);let yt=o=>{let R=o?.failure;if(R===void 0){ve(null);return}ve(w=>({failure:R,occurrence:w===null?1:w.occurrence+1})),(0,h.integrityFailureNeedsOverviewReread)(R)&&mt.revalidate()},[ft,De]=(0,g.useState)("console"),{settledIntent:bt,submitAndAwait:Me}=Ge(t,()=>De("console"));Ge(n,o=>{De("integrity"),yt(o)});let He=(ft==="console"?t:n).data?.error,St=()=>{F(de.key),J.current[de.key]?.focus()},ee=bt==="retry_all_failed"&&t.data?.skipped!==void 0&&t.data.requeued!==void 0?{requeued:t.data.requeued,skipped:t.data.skipped}:null;return(0,a.jsx)(q.ConsoleUiRoot,{locale:"ja",formatLocale:oe,timeZone:p.displayTimeZone,testId:"storage-admin-console-ui",children:(0,a.jsxs)("div",{className:"container mx-auto space-y-6 p-6 font-sans text-slate-900","data-testid":"storage-admin-console",children:[He&&(0,a.jsx)("div",{className:"rounded-lg border border-red-200 border-solid bg-red-50 p-4 font-medium text-red-700 text-sm shadow-sm",role:"alert","data-testid":"storage-admin-error-alert",children:He}),r?r({title:"\u30B9\u30C8\u30EC\u30FC\u30B8 AI \u30A8\u30F3\u30EA\u30C3\u30C1\u30E1\u30F3\u30C8 & \u30AC\u30D0\u30CA\u30F3\u30B9\u904B\u7528\u7BA1\u7406",tenantId:p.tenantId}):(0,a.jsxs)("header",{className:"flex flex-col justify-between gap-2 border-slate-200 border-b border-solid pb-4 md:flex-row md:items-center",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"font-bold text-2xl tracking-tight",children:"\u30B9\u30C8\u30EC\u30FC\u30B8 AI \u30A8\u30F3\u30EA\u30C3\u30C1\u30E1\u30F3\u30C8 & \u30AC\u30D0\u30CA\u30F3\u30B9\u904B\u7528\u7BA1\u7406"}),(0,a.jsxs)("p",{className:"mt-1 text-slate-500 text-sm",children:["\u30C6\u30CA\u30F3\u30C8: ",(0,a.jsx)("code",{className:"font-semibold text-slate-800",children:p.tenantId})," | \u5168\u30B7\u30B9\u30C6\u30E0\u72B6\u614B\u30FB\u30D1\u30E9\u30E1\u30FC\u30BF\u5236\u5FA1\u30FB\u6574\u5408\u6027\u76E3\u67FB"]})]}),(0,a.jsx)("div",{className:"flex items-center gap-2",children:(0,a.jsxs)("button",{type:"button","data-testid":"header-health-status-button",onClick:()=>F("pipeline"),className:"inline-flex items-center gap-2 rounded-full border border-slate-200 border-solid bg-slate-50 px-3 py-1.5 font-medium text-slate-700 text-xs transition-colors hover:bg-slate-100",children:[(0,a.jsx)("span",{className:`h-2 w-2 rounded-full ${p.systemHealth.allHealthy?"bg-emerald-500":"bg-amber-500"}`}),(0,a.jsxs)("span",{children:["\u5468\u8FBA\u6A5F\u80FD: ",p.systemHealth.allHealthy?"\u5168\u30B5\u30FC\u30D3\u30B9\u6B63\u5E38":"\u63A5\u7D9A\u8981\u78BA\u8A8D"]})]})})]}),(0,a.jsxs)("div",{className:"w-full space-y-6",children:[(0,a.jsx)("div",{className:"@container w-full","data-testid":"storage-admin-tablist-frame",children:(0,a.jsx)("div",{className:`grid w-full ${Ae.className} ${Pe.className} ${Ne.className} gap-1 rounded-xl bg-slate-100 p-1`,role:"tablist","aria-label":"\u904B\u7528\u7BA1\u7406\u30B3\u30F3\u30BD\u30FC\u30EB\u306E\u753B\u9762",children:K.map((o,R)=>{let w=A===o.key;return(0,a.jsx)("button",{id:`tab-${o.key}`,type:"button",role:"tab",ref:_=>{J.current[o.key]=_},"aria-selected":w,"aria-controls":`panel-${o.key}`,tabIndex:w?0:-1,"data-testid":`tab-trigger-${o.key}`,onKeyDown:_=>ie(_,R),onClick:()=>F(o.key),className:`wrap-anywhere break-keep rounded-lg px-3 py-2.5 text-center font-medium text-sm transition-all ${R===K.length-1?`${Te(Ae,K.length)} ${Te(Pe,K.length)} ${Ne.lastTabClassName}`:""} ${w?"bg-white text-slate-900 shadow-sm":"text-slate-600 hover:bg-slate-200/50 hover:text-slate-900"}`,children:o.phrases.map((_,ae)=>(0,a.jsxs)(g.Fragment,{children:[ae>0&&(0,a.jsx)("wbr",{}),_]},_))},o.key)})})}),E.metadataId!==null&&(0,a.jsx)(S.PipelineRunInspector,{metadataId:E.metadataId,runs:E.runs,selectedRunId:E.selectedRunId,onSelectRun:E.selectRun,isLoading:E.isLoading,failure:E.failure,onClose:E.close,openRequest:E.openRequest,returnFocusFallback:be}),A==="search"&&(0,a.jsxs)("div",{role:"tabpanel",id:"panel-search","aria-labelledby":"tab-search",className:"space-y-6","data-testid":"tab-content-search",children:[(0,a.jsx)(S.MetadataSearchWorkbench,{tenantId:p.tenantId,onSearch:d,circuitBreakerStatus:p.circuitBreakerStatus}),m!==void 0&&(0,a.jsx)(S.ModelComparisonWorkbench,{variants:Se,onCompare:m})]}),A==="ingest"&&(0,a.jsx)("div",{role:"tabpanel",id:"panel-ingest","aria-labelledby":"tab-ingest",className:"space-y-6","data-testid":"tab-content-ingest",children:(0,a.jsx)(S.DocumentIngestConsole,{tenantId:p.tenantId,policies:p.confidentialityPolicies,domainOptions:se,recentItems:p.recentIngestItems,inspectionResult:ot,isInspecting:lt,isSubmitting:ut,onInspectUri:o=>{t.submit({intent:"inspect_uri",fileUri:o},{method:"post"})},onIngestDocument:o=>{t.submit({intent:"ingest_document",payload:JSON.stringify(o)},{method:"post"})},onRetryItem:o=>{t.submit({intent:"retry_job",fileId:String(o)},{method:"post"})},onShowHistory:Re})}),A==="pipeline"&&(0,a.jsxs)("div",{role:"tabpanel",id:"panel-pipeline","aria-labelledby":"tab-pipeline",className:"space-y-6","data-testid":"tab-content-pipeline",children:[(0,a.jsx)(S.PipelineFlowViewer,{featureFlags:p.featureFlags,metrics:p.pipelineStepMetrics,metricSampleWindow:p.pipelineStepMetricWindow}),(0,a.jsx)(qt,{runs:p.recentPipelineRuns,onOpenRun:he}),(0,a.jsx)(S.EnrichmentStrategyBoard,{strategies:p.enrichmentStrategies,featureFlags:p.featureFlags,isUpdating:t.state!=="idle",onToggleStage:(o,R,w)=>t.submit({intent:"update_enrichment_strategy",strategyId:String(o.id),domainId:String(o.domainId),stage:R,enabled:String(w)},{method:"post"})}),(0,a.jsx)(S.InfrastructureHealthMonitor,{health:p.systemHealth,isRefreshing:t.state!=="idle",onRefresh:()=>t.submit({intent:"refresh_health"},{method:"post"})})]}),A==="knowledge-graph"&&(0,a.jsxs)("div",{role:"tabpanel",id:"panel-knowledge-graph","aria-labelledby":"tab-knowledge-graph",className:"space-y-6","data-testid":"tab-content-knowledge-graph",children:[(0,a.jsx)(S.OntologyStatusCard,{tenantId:p.tenantId,ontologyStatus:p.ontologyStatus}),(0,a.jsx)(h.KnowledgeGraphExplorer,{topologyMaxLabels:U.GRAPH_INDEX_LIMITS.topologyLabels.default,schema:p.graphSchema,tenantId:p.tenantId,unresolvedEntities:p.unresolvedEntities,traversal:i,onBrowseLabel:Q,nodeIndexPage:f,nodeIndexFailure:H,isNodeIndexLoading:O,isResolving:ct,onResolveEntity:(o,R)=>{t.submit({intent:"resolve_entity",entityId:o,action:R},{method:"post"})}})]}),A==="parameters"&&(0,a.jsxs)("div",{role:"tabpanel",id:"panel-parameters","aria-labelledby":"tab-parameters",className:"space-y-6","data-testid":"tab-content-parameters",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2",children:[(0,a.jsx)(h.FeatureFlagBoard,{flags:Fe,isUpdating:t.state!=="idle",onToggleFlag:(o,R)=>{t.submit({intent:"toggle_flag",flagKey:o,enabled:String(R)},{method:"post"})}}),(0,a.jsx)(h.ClassificationRuleEditor,{rules:p.classificationRules,domainOptions:se,consultedBy:p.classificationRuleConsumer,onReorderRules:o=>{t.submit({intent:"reorder_rules",orderedRuleIds:JSON.stringify(o)},{method:"post"})}})]}),p.policiesMissingDestination.length>0&&(0,a.jsxs)("div",{"data-testid":"policies-missing-destination",role:"alert",style:{padding:"10px 12px",borderRadius:"6px",backgroundColor:"#fef2f2",color:"#b91c1c",fontSize:"12px"},children:[(0,a.jsx)("strong",{children:"\u6B21\u306E\u533A\u5206\u30FB\u6A5F\u80FD\u306F\u5B9F\u884C\u6642\u306B\u5931\u6557\u3057\u307E\u3059\u3002"})," \u53C2\u7167\u3059\u308B\u30D7\u30ED\u30F3\u30D7\u30C8\u884C\u306B\u5B9B\u5148\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002",(0,a.jsx)("ul",{style:{margin:"6px 0 0",paddingInlineStart:"18px"},children:p.policiesMissingDestination.map(o=>(0,a.jsxs)("li",{"data-testid":`missing-destination-${o.confidentialityLevel}-${o.capability}`,children:[o.confidentialityLevel," / ",o.capability," \u2192 ",o.promptKey," (",o.modelProvider,") \u306E ",(0,a.jsx)("code",{children:"extra_params.base_url"})]},`${o.confidentialityLevel}:${o.capability}`))}),(0,a.jsx)("span",{style:{display:"block",marginTop:"4px",fontSize:"11px"},children:"\u5B9B\u5148\u3092\u8A2D\u5B9A\u3057\u3066\u3082\u3001\u305D\u306E\u30DB\u30B9\u30C8\u304C\u914D\u5099\u5185\u3068\u3057\u3066\u767B\u9332\u3055\u308C\u3066\u3044\u306A\u3051\u308C\u3070\u62D2\u5426\u3055\u308C\u307E\u3059\u3002"})]}),(0,a.jsx)(h.ConfidentialityPolicyBoard,{policies:p.confidentialityPolicies,promptKeys:p.promptTemplates.map(o=>o.template_key),isUpdating:t.state!=="idle",onChangePolicy:o=>{t.submit({intent:"update_confidentiality_policy",confidentialityLevel:o.confidentialityLevel,capability:o.capability,isEnabled:String(o.isEnabled),allowCloudProvider:String(o.allowCloudProvider),promptKey:o.promptKey??""},{method:"post"})}}),(0,a.jsx)(h.TranscriptionAdaptationBoard,{vocabulary:p.transcriptionVocabulary,references:p.transcriptionReferences,unresolvedUris:p.unresolvedReferenceUris,isUpdating:t.state!=="idle",onSaveTerm:o=>Me({intent:"save_transcription_term",id:o.id===null?"":String(o.id),term:o.term,reading:o.reading??"",boost:o.boost===null?"":String(o.boost),domainKey:o.domainKey??"",isActive:String(o.isActive)},{method:"post"}),onSaveReference:o=>Me({intent:"save_transcription_reference",id:o.id===null?"":String(o.id),fileUri:o.fileUri,domainKey:o.domainKey??"",isActive:String(o.isActive)},{method:"post"})}),(0,a.jsx)(h.SystemParameterTable,{parameters:p.systemParameters,onSaveParameter:(o,R)=>{t.submit({intent:"update_parameter",paramKey:o,paramValue:String(R)},{method:"post"})}})]}),A==="prompts"&&(0,a.jsxs)("div",{role:"tabpanel",id:"panel-prompts","aria-labelledby":"tab-prompts",className:"space-y-6","data-testid":"tab-content-prompts",children:[(0,a.jsx)(h.PromptTemplateConsole,{templates:p.promptTemplates,isSaving:t.state!=="idle",onSaveTemplate:o=>{t.submit({intent:"update_prompt",templateKey:o.template_key,payload:JSON.stringify({templateText:o.template_text,modelName:o.model_name,temperature:o.temperature,maxOutputTokens:o.max_output_tokens,responseSchema:o.response_schema,endpointBaseUrl:o.endpoint_base_url??null})},{method:"post"})}}),(0,a.jsx)(h.GovernanceDryRunConsole,{onSimulate:l})]}),A==="knowledge-authority"&&(0,a.jsxs)("div",{role:"tabpanel",id:"panel-knowledge-authority","aria-labelledby":"tab-knowledge-authority",className:"space-y-6","data-testid":"tab-content-knowledge-authority",children:[(0,a.jsx)(h.DocumentAuthorityRegistry,{host:I,canUpdate:p.canUpdateKnowledge,onPolicyConflictsChanged:fe}),(0,a.jsx)(h.PolicyConflictQueue,{host:b,revision:ge})]}),A==="data-retention"&&(0,a.jsxs)("div",{role:"tabpanel",id:"panel-data-retention","aria-labelledby":"tab-data-retention",className:"space-y-6","data-testid":"tab-content-data-retention",children:[j.overview.kind==="ready"?(0,a.jsx)(h.TriStoreIntegrityAudit,{overview:j.overview.value,canReadFindings:p.canReadIntegrityFindings,command:pt,commandFailure:gt,onStartRun:(o,R)=>{n.submit(R===null?{intent:"start_integrity_run",mode:o}:{intent:"start_integrity_run",mode:o,basisRunUid:R},{method:"post"})},onCancelRun:o=>{n.submit({intent:"cancel_integrity_run",runUid:o},{method:"post"})},loadFindings:v,refreshFailure:j.overview.refreshFailure===null?null:j.overview.refreshFailure.reason,headingRef:Z}):(0,a.jsx)(q.Card,{title:jt,testId:"audit-overview-failed",headingRef:Z,children:(0,a.jsx)(q.ResourceFailed,{failure:j.overview,onReload:j.reload,forbiddenMessage:"\u76E3\u67FB\u306E\u6982\u6CC1\u3092\u95B2\u89A7\u3059\u308B\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093\u3002",failureMessage:Ut,rescueRef:me,testId:"audit-overview-failed-resource"})}),(0,a.jsx)(h.PolicyConflictSummaryCard,{host:b,knowledgeTabLabel:Lt(de),onOpenKnowledgeTab:St}),ee!==null&&ee.skipped.length>0&&(0,a.jsxs)("div",{role:"status","data-testid":"retry-all-skipped",className:"rounded-lg border border-amber-200 border-solid bg-amber-50 p-4 text-amber-800 text-sm",children:[(0,a.jsxs)("strong",{children:["\u4E00\u62EC\u518D\u8A66\u884C: ",ee.requeued," \u4EF6\u3092\u518D\u6295\u5165\u3057\u3001",ee.skipped.length," \u4EF6\u3092\u636E\u3048\u7F6E\u304D\u307E\u3057\u305F\u3002"]})," ","\u636E\u3048\u7F6E\u3044\u305F\u884C\u306F\u5931\u6557\u306E\u307E\u307E\u6B8B\u3063\u3066\u3044\u307E\u3059\u3002",(0,a.jsx)("ul",{className:"mt-1.5 list-disc ps-5",children:ee.skipped.map(o=>(0,a.jsxs)("li",{"data-testid":`retry-all-skipped-${o.metadataId}`,children:["#",o.metadataId,": ",o.reason]},o.metadataId))})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2",children:[(0,a.jsx)(S.SyncStatusMonitor,{counts:p.syncCounts,totalFiles:p.totalFiles,failedItems:p.failedSyncItems,isRetrying:dt,onRetryItem:o=>{t.submit({intent:"retry_job",fileId:String(o)},{method:"post"})},onRetryAll:()=>{t.submit({intent:"retry_all_failed"},{method:"post"})}}),(0,a.jsx)(S.QdrantStorageCard,{overview:p.qdrantCollections,health:{healthy:p.systemHealth.services.qdrant.status==="connected",latency_ms:p.systemHealth.services.qdrant.latencyMs}})]})]})]})]})})}var Mt=new Set(U.EnrichmentSyncStatusSchema.options.filter(e=>e!=="SYNCED"&&!e.startsWith("FAILED"))),Qe=2e3;function Ht(e,t,n){let[r,i]=(0,g.useState)(null),s=(0,g.useRef)(t);s.current=t;let l=(0,g.useRef)(e);l.current!==e&&(l.current=e,r!==null&&i(null));let d=(r??e)?.some(c=>Mt.has(c.syncStatus))===!0;return(0,g.useEffect)(()=>{if(!(n&&d&&s.current))return;let c=!1,m,y=async()=>{let v=s.current;if(v!==void 0){try{let b=await v();if(c)return;i(b)}catch{if(c)return}m=setTimeout(y,Qe)}};return m=setTimeout(y,Qe),()=>{c=!0,clearTimeout(m)}},[d,n]),r}function Ge(e,t){let n=(0,g.useRef)(t);n.current=t;let r=(0,g.useRef)(null),i=(0,g.useRef)(!1),s=(0,g.useRef)(null);if(e.state!=="idle"){i.current=!0;let u=e.formData?.get("intent");typeof u=="string"&&(r.current=u)}(0,g.useEffect)(()=>{if(e.state!=="idle"||!i.current)return;i.current=!1,n.current(e.data);let u=s.current;if(u===null)return;s.current=null;let d=e.data?.error;typeof d=="string"?u.reject(new Error(d)):u.resolve()},[e.state,e.data]);let l=(0,g.useCallback)((...u)=>new Promise((d,c)=>{s.current?.reject(new Error("\u3053\u306E\u4FDD\u5B58\u306F\u5F8C\u7D9A\u306E\u9001\u4FE1\u306B\u7F6E\u304D\u63DB\u3048\u3089\u308C\u307E\u3057\u305F\u3002")),s.current={resolve:d,reject:c},e.submit(...u)}),[e]);return{settledIntent:e.state==="idle"?r.current:null,submitAndAwait:l}}function $t(e){let t=new Set,n=[];for(let r of e)t.has(r.domainKey)||(t.add(r.domainKey),n.push({key:r.domainKey,label:r.domainLabel}));return n}function Kt(e){return{strategyId:e.strategyId,label:`${e.domainKey} / ${e.variantKey}`,embeddingModel:e.embeddingModel}}function qt({runs:e,onOpenRun:t}){return(0,a.jsxs)("section",{className:"rounded-xl border border-slate-200 border-solid bg-white p-6 shadow-sm","aria-labelledby":"pipeline-recent-runs-heading","data-testid":"pipeline-recent-runs",children:[(0,a.jsx)("h2",{id:"pipeline-recent-runs-heading",className:"font-bold text-base text-slate-900",children:"\u76F4\u8FD1\u306E\u5B9F\u884C"}),e.length===0?(0,a.jsx)("p",{className:"mt-4 text-[13px] text-slate-500","data-testid":"pipeline-recent-runs-empty",children:"\u8A18\u9332\u3055\u308C\u305F\u5B9F\u884C\u304C\u3042\u308A\u307E\u305B\u3093\u3002"}):(0,a.jsx)("div",{className:"relative mt-4 overflow-x-auto","data-testid":"pipeline-recent-runs-scroll",children:(0,a.jsxs)("table",{className:"w-full text-left text-[13px]",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"whitespace-nowrap border-slate-200 border-b border-solid text-[11px] text-slate-500 uppercase",children:[(0,a.jsx)("th",{scope:"col",className:"px-3 py-2",children:"\u5B9F\u884C"}),(0,a.jsx)("th",{scope:"col",className:"px-3 py-2",children:"\u6587\u66F8"}),(0,a.jsx)("th",{scope:"col",className:"px-3 py-2",children:"\u7A2E\u985E"}),(0,a.jsx)("th",{scope:"col",className:"px-3 py-2",children:"\u304D\u3063\u304B\u3051"}),(0,a.jsx)("th",{scope:"col",className:"px-3 py-2",children:"\u8A66\u884C"}),(0,a.jsx)("th",{scope:"col",className:"px-3 py-2",children:"\u72B6\u614B"}),(0,a.jsx)("th",{scope:"col",className:"px-3 py-2",children:"\u6B62\u307E\u3063\u305F\u6BB5"}),(0,a.jsx)("th",{scope:"col",className:"px-3 py-2",children:"\u958B\u59CB"}),(0,a.jsx)("th",{scope:"col",className:"px-3 py-2",children:"\u7D42\u4E86"}),(0,a.jsx)("th",{scope:"col",className:"px-3 py-2",children:"\u8981\u6C42\u8005"}),t!==void 0&&(0,a.jsx)("th",{scope:"col",className:"px-3 py-2",children:(0,a.jsx)("span",{className:"sr-only","data-testid":"pipeline-recent-runs-action-header",children:"\u64CD\u4F5C"})})]})}),(0,a.jsx)("tbody",{children:e.map(n=>{let r=(0,S.pipelineRunPresentationKey)(n),i=S.PIPELINE_RUN_STATUS_PRESENTATION[r];return(0,a.jsxs)("tr",{className:"border-slate-100 border-b border-solid","data-testid":`pipeline-run-row-${n.id}`,"data-status":n.status,children:[(0,a.jsxs)("td",{className:"whitespace-nowrap px-3 py-2 font-mono","data-testid":`pipeline-run-id-${n.id}`,children:["#",n.id]}),(0,a.jsxs)("td",{className:"whitespace-nowrap px-3 py-2 font-mono","data-testid":`pipeline-run-metadata-${n.id}`,children:["#",n.metadataId]}),(0,a.jsx)("td",{className:"whitespace-nowrap px-3 py-2","data-testid":`pipeline-run-kind-${n.id}`,children:U.DOCUMENT_KIND_LABELS[n.documentKind]}),(0,a.jsx)("td",{className:"whitespace-nowrap px-3 py-2","data-testid":`pipeline-run-trigger-${n.id}`,"data-trigger":n.trigger,children:S.PIPELINE_TRIGGER_LABELS[n.trigger]}),(0,a.jsx)("td",{className:"whitespace-nowrap px-3 py-2","data-testid":`pipeline-run-attempt-${n.id}`,children:n.attempt}),(0,a.jsx)("td",{className:"px-3 py-2",children:(0,a.jsx)("span",{className:`inline-flex whitespace-nowrap rounded-full px-2 py-0.5 font-semibold text-[11px] ${i.className}`,"data-testid":`pipeline-run-status-${n.id}`,"data-status":n.status,"data-presentation":r,children:i.label})}),(0,a.jsx)("td",{className:"px-3 py-2","data-testid":`pipeline-run-failed-step-${n.id}`,children:n.failedStepKey===null?"\u2014":U.PIPELINE_STEPS[n.failedStepKey].label}),(0,a.jsx)("td",{className:"whitespace-nowrap px-3 py-2 text-slate-500","data-testid":`pipeline-run-started-${n.id}`,children:(0,a.jsx)(S.RecordedInstant,{iso:n.startedAt,testId:`pipeline-run-started-value-${n.id}`})}),(0,a.jsx)("td",{className:"whitespace-nowrap px-3 py-2 text-slate-500","data-testid":`pipeline-run-finished-${n.id}`,children:(0,a.jsx)(S.FinishedInstant,{iso:n.finishedAt,testId:`pipeline-run-finished-value-${n.id}`})}),(0,a.jsx)("td",{className:"wrap-anywhere px-3 py-2","data-testid":`pipeline-run-requested-by-${n.id}`,children:n.requestedBy}),t!==void 0&&(0,a.jsx)("td",{className:"whitespace-nowrap px-3 py-2 text-right",children:(0,a.jsx)("button",{type:"button",onClick:()=>t(n),"aria-label":`\u5B9F\u884C #${n.id} (\u6587\u66F8 #${n.metadataId}) \u306E\u8A73\u7D30`,className:"whitespace-nowrap rounded-sm border border-slate-300 border-solid bg-white px-2 py-0.5 font-semibold text-[11px] text-slate-700 hover:bg-slate-50","data-testid":`pipeline-run-open-${n.id}`,children:"\u8A73\u7D30"})})]},n.id)})})]})})]})}var ze={metadataId:null,runs:[],selectedRunId:null,isLoading:!1,failure:null};function Vt(e){for(let t of e)for(let n of t.steps){let r=n.provenance;if(r!==null){for(let[i,s]of Object.entries(r))if(typeof s=="string"&&!le(s))return`\u51E6\u7406\u5C65\u6B74\u306E\u8A18\u9332\u306B\u8AAD\u3081\u306A\u3044\u6765\u6B74\u306E\u5024\u304C\u3042\u308A\u307E\u3059 (\u5B9F\u884C ${t.id} \u306E\u6BB5 ${n.sequence} \u306E ${i})\u3002`}}return null}function Bt(e){let[t,n]=(0,g.useState)(ze),[r,i]=(0,g.useState)(0),s=(0,g.useRef)(0),l=(0,g.useRef)(null),u=(0,g.useMemo)(()=>{if(e!==void 0)return(m,y)=>{s.current+=1;let v=s.current;l.current?.abort();let b=new AbortController;l.current=b,i(I=>I+1),n({metadataId:m,runs:[],selectedRunId:y,isLoading:!0,failure:null}),te(()=>e(m,b.signal),I=>({ok:!1,status:null,reason:I})).then(I=>{if(s.current!==v)return;let f=I.ok?Vt(I.value):Dt(I.reason);if(!I.ok||f!==null){n({metadataId:m,runs:[],selectedRunId:y,isLoading:!1,failure:f});return}n({metadataId:m,runs:I.value,selectedRunId:y===null?Qt(I.value):y,isLoading:!1,failure:null})})}},[e]),d=(0,g.useCallback)(m=>{n(y=>({...y,selectedRunId:m}))},[]),c=(0,g.useCallback)(()=>{s.current+=1,l.current?.abort(),l.current=null,n(ze)},[]);return{...t,openRequest:r,open:u,selectRun:d,close:c}}function Qt(e){return e.length===0?null:e[0].id}function Gt(e){let t=(0,$.useLoaderData)(),n=(0,$.useFetcher)(),r=(0,$.useFetcher)(),i=e.data??t,s=e.fetcher??n,l=e.integrityFetcher??r;return i?(0,a.jsx)(Je,{...e,data:i,fetcher:s,integrityFetcher:l}):(0,a.jsx)("div",{className:"p-8 text-center text-slate-500","data-testid":"storage-admin-loading",children:"\u30C7\u30FC\u30BF\u8AAD\u307F\u8FBC\u307F\u4E2D..."})}function Ee(e){return e.data?(0,a.jsx)(Je,{...e,data:e.data,fetcher:e.fetcher??Be,integrityFetcher:e.integrityFetcher??Be}):(0,a.jsx)(Gt,{...e})}var ke=require("@aiquants/authz-core"),it=require("@aiquants/console-ui/core"),P=require("@aiquants/enrichment-core"),V=require("@aiquants/governance-core"),N=require("zod");var Ce=3e3;function M(e){return Math.round(performance.now()-e)}function C(e){return typeof e=="string"&&le(e)?e:null}function D(e){let t=globalThis.process;return t===void 0?void 0:t.env[e]}function ce(e,t){let n=e?.trim();if(!n)throw new Error(`${t} is not configured; this probe will not guess an endpoint to send credentials to.`);return n}function We(e,t,n){let r=e??(t?.trim()?Number(t):Number.NaN);if(!Number.isInteger(r)||r<=0||r>65535)throw new Error(`${n} is not configured with a valid port; this probe will not guess one.`);return r}function Ye(e,t){if(e!==void 0)return e;let n=t?.trim().toLowerCase();if(!(n===void 0||n===""))return n==="1"||n==="true"||n==="yes"||n==="on"}function Ze(e){let t=e.trim().split("://",1)[0]?.toLowerCase();if(t&&e.includes("://"))return t.endsWith("s")||t.includes("+s")}function zt(e){let n=e.split("://").slice(-1)[0].split("/",1)[0],r=n.split(":").pop();if(!r||r===n)return;let i=Number(r);return Number.isInteger(i)&&i>0&&i<=65535?i:void 0}async function _e(e,t){let n;try{return await Promise.race([e,new Promise((r,i)=>{n=setTimeout(()=>i(new Error(`Probe timed out after ${t}ms`)),t)})])}finally{clearTimeout(n)}}async function Xe(e){let t=e?.qdrantApiKey??D("QDRANT_API_KEY")??"",n=e?.timeoutMs??Ce,r=performance.now(),i="";try{i=ce(e?.qdrantUrl??D("QDRANT_URL"),"QDRANT_URL");let s={};t&&(s["api-key"]=t);let[l,u]=await Promise.all([fetch(`${i}/`,{headers:s,signal:AbortSignal.timeout(n)}),fetch(`${i}/collections`,{headers:s,signal:AbortSignal.timeout(n)})]);if(!l.ok)throw new Error(`HTTP ${l.status}: ${l.statusText}`);if(!u.ok)throw new Error(`HTTP ${u.status}: ${u.statusText} (/collections)`);let d=await l.json(),c=M(r),y=(await u.json()).result?.collections?.length??0;return{serviceName:"Qdrant",category:"vector",status:"connected",version:C(d.version),endpoint:i,latencyMs:c,details:{engine:C(d.title),collectionsCount:y,restPort:zt(i)??null,tls:Ze(i)??null}}}catch(s){let l=M(r),u=s instanceof Error?s.message:String(s);return{serviceName:"Qdrant",category:"vector",status:"error",version:null,endpoint:i,latencyMs:l,details:{},errorMessage:u}}}async function et(e){let t=e?.timeoutMs??Ce,n=performance.now(),r=C(e?.neo4jBoltUri??D("NEO4J_URI")),i=r===null?"":r;try{let s=e?.graphReader;if(!s)throw new Error("Graph reader not configured");let l=e?.tenantId,[u,d]=await Promise.all([_e(s("CALL dbms.components() YIELD versions, edition RETURN versions[0] AS version, edition",{}),t),_e(l?s("MATCH (n {tenantId: $tenantId}) RETURN count(n) AS node_count",{tenantId:l}):s("RETURN null AS node_count",{}),t)]);if(!u.ok)throw new Error(u.reason);if(!d.ok)throw new Error(d.reason);let[c,m]=u.rows[0]??[],y=d.rows[0]?.[0],v=M(n);return{serviceName:"Neo4j",category:"graph",status:"connected",version:C(c),endpoint:i,latencyMs:v,details:{edition:C(m),boltUri:r,nodeCount:typeof y=="number"?y:null,tls:r===null?null:Ze(r)??null}}}catch(s){let l=M(n),u=s instanceof Error?s.message:String(s);return{serviceName:"Neo4j",category:"graph",status:"error",version:null,endpoint:i,latencyMs:l,details:{},errorMessage:u}}}async function tt(e){let t=performance.now(),n="",r=Ye(e?.redisTls,D("REDIS_TLS")),i=Number.NaN;try{let s=e?.redisClient;if(!s)throw new Error("Redis client not configured");let l=ce(e?.redisHost??D("REDIS_HOST"),"REDIS_HOST");i=We(e?.redisPort,D("REDIS_PORT"),"REDIS_PORT"),n=`${r===!1?"redis":"rediss"}://${l}:${i}`,await s.ping();let u=await s.info("server"),d=C(u.match(/redis_version:([^\r\n]+)/)?.[1]),c=null;if(typeof s.dbSize=="function")try{c=await s.dbSize()}catch{c=null}let m=M(t);return{serviceName:"Redis",category:"cache",status:"connected",version:d,endpoint:n,latencyMs:m,details:{totalKeys:c,port:i,tls:r??null,database:0}}}catch(s){let l=M(t),u=s instanceof Error?s.message:String(s);return{serviceName:"Redis",category:"cache",status:"error",version:null,endpoint:n,latencyMs:l,details:{},errorMessage:u}}}function Jt(e){let t=e.match(/Microsoft SQL Server \d+ \([^)]+\)/);return C(t===null?e.substring(0,30):t[0].replace("Microsoft SQL Server ",""))}async function nt(e){let t=performance.now(),n="",r=Ye(e?.sqlServerTls,D("SQL_SERVER_TLS")),i=Number.NaN;try{let s=e?.sqlServerExecute;if(!s)throw new Error("SQL Server executor not configured");let l=ce(e?.sqlServerHost??D("SQL_SERVER_HOST"),"SQL_SERVER_HOST");i=We(e?.sqlServerPort,D("SQL_SERVER_PORT"),"SQL_SERVER_PORT"),n=`${l}:${i}`;let u=await s(),d=C(u.db_name),c=C(u.version),m=c===null?null:C(c.split(`
2
- `)[0]),y=m===null?null:Jt(m),v=M(t);return{serviceName:"SQL Server",category:"database",status:"connected",version:y,endpoint:n,latencyMs:v,details:{database:d,port:i,tls:r??null,fullVersion:m}}}catch(s){let l=M(t),u=s instanceof Error?s.message:String(s);return{serviceName:"SQL Server",category:"database",status:"error",version:null,endpoint:n,latencyMs:l,details:{},errorMessage:u}}}async function rt(e){let t=e?.timeoutMs??Ce,n=performance.now(),r="";try{r=ce(e?.backendApiHost??D("BACKEND_API_HOST"),"BACKEND_API_HOST");let i=await fetch(`${r}/openapi.json`,{signal:AbortSignal.timeout(t)});if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);let s=await i.json(),l=Object.keys(s.paths??{}).length,u=M(n);return{serviceName:"AI Quant API",category:"api",status:"connected",version:C(s.info?.version),endpoint:r,latencyMs:u,details:{title:C(s.info?.title),endpointsCount:l}}}catch(i){let s=M(n),l=i instanceof Error?i.message:String(i);return{serviceName:"AI Quant API",category:"api",status:"error",version:null,endpoint:r,latencyMs:s,details:{},errorMessage:l}}}async function xe(e){let[t,n,r,i,s]=await Promise.all([Xe(e),et(e),tt(e),nt(e),rt(e)]),l=t.status==="connected"&&n.status==="connected"&&r.status==="connected"&&i.status==="connected"&&s.status==="connected";return{services:{qdrant:t,neo4j:n,redis:r,sqlServer:i,quantsApi:s},allHealthy:l,checkedAt:new Date().toISOString()}}var Wt=N.z.object({templateText:N.z.string(),modelName:N.z.string(),temperature:N.z.number(),maxOutputTokens:N.z.number(),responseSchema:N.z.union([N.z.record(N.z.string(),N.z.unknown()),N.z.string(),N.z.null()]).optional(),endpointBaseUrl:N.z.string().nullable()}).strict(),Yt=N.z.discriminatedUnion("mode",[N.z.object({mode:P.IntegrityRunModeSchema.extract(["SCAN"]),basisRunUid:N.z.null()}).strict(),N.z.object({mode:P.IntegrityRunModeSchema.extract(["REPAIR"]),basisRunUid:N.z.string().uuid()}).strict()]),Zt=N.z.object({runUid:N.z.string().uuid()}).strict();function at(e){return e==="start_integrity_run"?"start":e==="cancel_integrity_run"?"cancel":null}function Y(e,t){return e.issues.map(n=>`${n.path.length===0?t:n.path.join(".")}: ${n.message}`).join("; ")}function Xt(e,t){if(e==="bool")return t==="true"||t==="false"?null:"paramValue must be 'true' or 'false' for a bool parameter";if(e==="int")return/^[+-]?\d+$/.test(t)&&Number.isSafeInteger(Number(t))?null:"paramValue must be a safe integer for an int parameter";if(e==="float")return t.trim()!==""&&Number.isFinite(Number(t))?null:"paramValue must be a finite number for a float parameter";if(e==="json")try{return JSON.parse(t),null}catch{return"paramValue must be valid JSON for a json parameter"}return null}function en(e){let t=P.PipelineRunSummarySchema.array().safeParse(e);if(!t.success)throw new Error(`getRecentPipelineRuns answered something that is not a run summary: ${Y(t.error,"getRecentPipelineRuns")}`);return t.data}function tn(e){let t=P.PipelineStepMetricSchema.array().safeParse(e);if(!t.success)throw new Error(`getPipelineStepMetrics answered something that is not a step metric: ${Y(t.error,"getPipelineStepMetrics")}`);let n=new Set;for(let r of t.data){let i=`${r.documentKind}/${r.stepKey}`;if(n.has(i))throw new Error(`getPipelineStepMetrics answered more than one metric for (documentKind, stepKey) = (${r.documentKind}, ${r.stepKey})`);n.add(i)}return t.data}function nn(e){if(!Number.isSafeInteger(e)||e<=0)throw new Error(`pipelineStepMetricWindow must be a positive safe integer, got ${String(e)}`);return e}async function rn(e,t){let n;try{n=await e.readIntegrityAuditOverview(t)}catch(i){return{ok:!1,status:null,reason:i instanceof Error?i.message:String(i)}}let r=P.IntegrityAuditOverviewSchema.safeParse(n);return r.success?{ok:!0,value:r.data}:{ok:!1,status:null,reason:`readIntegrityAuditOverview answered something that is not an audit overview: ${Y(r.error,"readIntegrityAuditOverview")}`}}function sn(e){return!Array.isArray(e)||e.length===0?"orderedRuleIds must be a non-empty array of rule ids":e.every(t=>typeof t=="number"&&Number.isSafeInteger(t)&&t>0)?new Set(e).size!==e.length?"orderedRuleIds must not name a rule twice":null:"orderedRuleIds must contain positive integers only"}function Le(e){let{store:t,healthProbeOptions:n,resourceKey:r="storage_admin",requireUser:i,requirePermission:s,resolveTenantId:l,authorizeIngest:u,canReadIntegrityFindings:d,canUpdateKnowledge:c}=e;async function m(v){let{request:b}=v;if(!await i(b))throw new Response("\u8A8D\u8A3C\u304C\u5FC5\u8981\u3067\u3059\u3002",{status:401});try{await s(b,{resourceKey:r,action:"read"})}catch(ie){throw ie instanceof ke.AuthzDeniedError?new Response("\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093\u3002",{status:403}):ie}let f=await l(b),B=nn(t.pipelineStepMetricWindow),[H,x,O]=await Promise.all([t.getFeatureFlags(f),t.getSystemParameters(f),t.getSyncCounts(f)]),k={featureFlags:H,systemParameters:x,syncCounts:O},[Q,G,z,L,A,F,re,j,Z,me,ge,ye,fe,p,J,be,se,Se,E,W,Re]=await Promise.all([t.getConfidentialityPolicies(f),t.getTranscriptionVocabulary(f),t.getTranscriptionReferences(f),t.getUnresolvedReferenceUris(f),t.getPoliciesMissingDestination(f),t.getPromptTemplates(f),t.getClassificationRules(f),t.getFailedSyncItems(f),t.getGraphSchema(f),rn(t,f),d(b),c(b),t.getUnresolvedEntities(f),t.getQdrantCollections(f),xe({...n,tenantId:f}),t.getRecentIngestItems(f),t.getOntologyStatus(f,k),t.getEnrichmentStrategies(f),t.getStrategyVariants(f),t.getPipelineStepMetrics(f),t.getRecentPipelineRuns(f)]),he=t.getCircuitBreakerStatus();return{tenantId:f,featureFlags:k.featureFlags,confidentialityPolicies:Q,transcriptionVocabulary:G,transcriptionReferences:z,unresolvedReferenceUris:L,policiesMissingDestination:A,systemParameters:k.systemParameters,promptTemplates:F,classificationRules:re,classificationRuleConsumer:t.classificationRuleConsumer??null,syncCounts:k.syncCounts.counts,totalFiles:k.syncCounts.total,failedSyncItems:j,circuitBreakerStatus:he,pipelineStepMetrics:tn(W),pipelineStepMetricWindow:B,recentPipelineRuns:en(Re),displayTimeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,graphSchema:Z,enrichmentStrategies:Se,strategyVariants:E,integrityAudit:me,canReadIntegrityFindings:ge,canUpdateKnowledge:ye,unresolvedEntities:fe,qdrantCollections:p,systemHealth:J,recentIngestItems:be,ontologyStatus:se}}async function y(v){let{request:b}=v,I=await i(b);if(!I)return Response.json({error:"\u8A8D\u8A3C\u304C\u5FC5\u8981\u3067\u3059\u3002"},{status:401});if(I.email.trim()==="")return Response.json({error:"\u64CD\u4F5C\u8005\u3092\u7279\u5B9A\u3067\u304D\u306A\u3044\u305F\u3081\u8A2D\u5B9A\u3092\u5909\u66F4\u3067\u304D\u307E\u305B\u3093\u3002"},{status:403});if(I.accessToken==="")throw new Error("requireUser resolved an operator whose accessToken is an empty string; answer null when the session holds no token the upstream services accept");let f=I.email,B=I.accessToken===null?void 0:I.accessToken;try{await s(b,{resourceKey:r,action:"update"})}catch(L){if(L instanceof ke.AuthzDeniedError)return await un(b);throw L}let H=await l(b),x=await b.formData(),O=String(x.get("intent")??"");if(O==="refresh_health")return Response.json({success:!0,refreshed:!0});let k=await on(t,H,O,x,f);if(k)return k;let Q=await ln(t,H,O,x,f,B);if(Q)return Q;let G=await dn(t,H,O,x,B,()=>d(b));if(G)return G;if(O==="resolve_entity"){let L=String(x.get("entityId")??""),A=String(x.get("action")??"");if(!L||A!=="merge"&&A!=="promote")return Response.json({error:"Valid entityId and action ('merge' | 'promote') are required"},{status:400});try{return await t.resolveEntity(H,L,A),Response.json({success:!0,entityId:L,action:A})}catch(F){return Response.json({error:F instanceof Error?F.message:String(F)},{status:400})}}let z=await mn(t,H,O,x,f,b,u,B);return z||Response.json({error:`Unknown intent: ${O}`},{status:400})}return{loader:m,action:y}}function Oe(e){let t=String(e??"").trim();return t===""?null:t}function pe(e){let t=String(e??"").trim();if(t==="")return null;let n=Number(t);if(!(!Number.isSafeInteger(n)||n<=0))return n}function an(e){let t=String(e??"").trim();if(t==="")return null;let n=Number(t);if(!(!Number.isFinite(n)||n<=0))return n}async function on(e,t,n,r,i){if(n==="update_enrichment_strategy"){let s=String(r.get("stage")??"");if(!(0,P.isEnrichmentStageKey)(s))return Response.json({error:"stage must be a canonical enrichment stage key"},{status:400});let l=pe(r.get("strategyId")),u=pe(r.get("domainId"));if(l==null||u===void 0||u===null)return Response.json({error:"strategyId and domainId must be positive integers naming existing rows"},{status:400});let d=String(r.get("enabled")??"")==="true";try{await e.updateEnrichmentStrategy(t,{strategyId:l,domainId:u,stage:s,enabled:d},i)}catch(c){return Response.json({error:c instanceof Error?c.message:"\u53D6\u308A\u8FBC\u307F\u6226\u7565\u3092\u66F4\u65B0\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002"},{status:400})}return Response.json({success:!0,strategyId:l,domainId:u,stage:s,enabled:d})}if(n==="toggle_flag"){let s=String(r.get("flagKey")??""),l=String(r.get("enabled")??"")==="true";if(!s)return Response.json({error:"flagKey is required"},{status:400});let u=await e.getFeatureFlags(t);return Object.hasOwn(u,s)?(await e.toggleFeatureFlag(t,s,l,i),Response.json({success:!0,flagKey:s,enabled:l})):Response.json({error:`flagKey names no feature flag of this tenant: ${s}`},{status:400})}if(n==="update_confidentiality_policy"){let s=String(r.get("confidentialityLevel")??""),l=String(r.get("capability")??"");if(!(V.ConfidentialityLevelSchema.safeParse(s).success&&V.GovernedCapabilitySchema.safeParse(l).success))return Response.json({error:"confidentialityLevel and capability must be canonical values"},{status:400});let u=String(r.get("allowCloudProvider")??"")==="true";if(u&&!V.CLOUD_CAPABLE_CAPABILITIES.includes(l))return Response.json({error:`${l} sends nothing outside the deployment, so it has no cloud permission to grant`},{status:400});let d=String(r.get("promptKey")??"");return await e.updateConfidentialityPolicy(t,{confidentialityLevel:s,capability:l,isEnabled:String(r.get("isEnabled")??"")==="true",allowCloudProvider:u,promptKey:d===""?null:d},i),Response.json({success:!0,confidentialityLevel:s,capability:l})}if(n==="save_transcription_term"){let s=String(r.get("term")??"").trim();if(!s)return Response.json({error:"term is required"},{status:400});let l=an(r.get("boost"));if(l===void 0)return Response.json({error:"boost must be a number greater than zero, or absent to let the service decide"},{status:400});let u=pe(r.get("id"));if(u===void 0)return Response.json({error:"id must be a positive integer naming an existing row, or absent for a new one"},{status:400});try{await e.saveTranscriptionTerm(t,{id:u,term:s,reading:Oe(r.get("reading")),boost:l,domainKey:Oe(r.get("domainKey")),isActive:String(r.get("isActive")??"true")==="true"},i)}catch(d){return Response.json({error:d instanceof Error?d.message:"\u8A9E\u5F59\u3092\u4FDD\u5B58\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002"},{status:400})}return Response.json({success:!0,term:s})}if(n==="save_transcription_reference"){let s=String(r.get("fileUri")??"").trim();if(!s)return Response.json({error:"fileUri is required"},{status:400});let l=pe(r.get("id"));if(l===void 0)return Response.json({error:"id must be a positive integer naming an existing row, or absent for a new one"},{status:400});try{await e.saveTranscriptionReference(t,{id:l,fileUri:s,domainKey:Oe(r.get("domainKey")),isActive:String(r.get("isActive")??"true")==="true"},i)}catch(u){return Response.json({error:u instanceof Error?u.message:"\u53C2\u7167\u8CC7\u6599\u3092\u4FDD\u5B58\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002"},{status:400})}return Response.json({success:!0,fileUri:s})}if(n==="update_parameter"){let s=String(r.get("paramKey")??""),l=String(r.get("paramValue")??"");if(!s)return Response.json({error:"paramKey is required"},{status:400});let u=(await e.getSystemParameters(t)).find(c=>c.key===s);if(u===void 0)return Response.json({error:`paramKey names no parameter of this tenant: ${s}`},{status:400});let d=Xt(u.data_type,l);if(d!==null)return Response.json({error:d},{status:400});try{(0,P.assertSystemParameterInRange)(s,Number(l))}catch(c){return Response.json({error:c.message},{status:400})}return await e.updateSystemParameter(t,s,l,i),Response.json({success:!0,paramKey:s,paramValue:l})}if(n==="update_prompt"){let s=String(r.get("templateKey")??""),l=String(r.get("payload")??"{}"),u;try{u=JSON.parse(l)}catch{return Response.json({error:"Invalid JSON payload"},{status:400})}if(!s)return Response.json({error:"templateKey is required"},{status:400});let d=Wt.safeParse(u);if(!d.success)return Response.json({error:`payload does not carry a prompt template update: ${Y(d.error,"payload")}`},{status:400});let c=d.data;try{return await e.updatePromptTemplate(t,s,c,i),Response.json({success:!0,templateKey:s})}catch(m){return Response.json({error:m instanceof Error?m.message:String(m)},{status:400})}}if(n==="reorder_rules"){let s=String(r.get("orderedRuleIds")??"[]"),l;try{l=JSON.parse(s)}catch{return Response.json({error:"Invalid orderedRuleIds JSON"},{status:400})}let u=sn(l);if(u!==null)return Response.json({error:u},{status:400});let d=l;return await e.reorderClassificationRules(t,d,i),Response.json({success:!0,orderedRuleIds:d})}return null}async function ln(e,t,n,r,i,s){if(n==="retry_job"){let l=String(r.get("fileId")??"");if(!l)return Response.json({error:"fileId is required"},{status:400});try{return await e.retrySyncItem(t,l,i,s),Response.json({success:!0,fileId:l})}catch(u){return Response.json({error:u instanceof Error?u.message:String(u)},{status:400})}}if(n==="retry_all_failed")try{let{requeued:l,skipped:u}=await e.retryAllFailedSyncItems(t,i,s);return Response.json({success:!0,requeued:l,skipped:u})}catch(l){return Response.json({error:l instanceof Error?l.message:String(l)},{status:400})}return null}function ne(e,t,n){let r=P.IntegrityCommandFailureSchema.parse({command:e,code:t,status:n}),i=P.INTEGRITY_COMMAND_CODES.find(s=>s.code===r.code);return Response.json({failure:r},{status:i===void 0?502:i.status})}async function un(e){let t=await e.formData().catch(()=>null),n=t===null?null:at(t.get("intent"));return n===null?Response.json({error:"\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093\u3002"},{status:403}):ne(n,"FORBIDDEN",null)}async function st(e,t){let n;try{n=P.IntegrityCommandReplySchema.parse(await t())}catch{return ne(e,"UPSTREAM_FAILED",null)}return n.ok?Response.json({success:!0,runUid:n.runUid}):ne(e,(0,P.integrityCommandFailureCodeOf)(e,n.status,n.errorCode),n.status)}async function dn(e,t,n,r,i,s){let l=at(n);if(l==="start"){let u=Yt.safeParse({mode:r.get("mode"),basisRunUid:r.get("basisRunUid")});if(!u.success)return Response.json({error:`start_integrity_run takes mode SCAN without basisRunUid, or mode REPAIR with basisRunUid (a UUID): ${Y(u.error,"form")}`},{status:400});let{mode:d,basisRunUid:c}=u.data;return i===void 0||d==="REPAIR"&&!await s()?ne(l,"FORBIDDEN",null):await st(l,()=>e.startIntegrityRun(t,d,c,i))}if(l==="cancel"){let u=Zt.safeParse({runUid:r.get("runUid")});return u.success?i===void 0?ne(l,"FORBIDDEN",null):await st(l,()=>e.cancelIntegrityRun(t,u.data.runUid,i)):Response.json({error:`cancel_integrity_run takes runUid (a UUID): ${Y(u.error,"form")}`},{status:400})}return null}function cn(e){if(typeof e!="object"||e===null)return"payload must be an object";let t=e;if(typeof t.fileUri!="string"||t.fileUri.trim()==="")return"payload.fileUri is required";if(!V.ConfidentialityLevelSchema.safeParse(t.confidentialityLevel).success)return`payload.confidentialityLevel must be one of ${V.ConfidentialityLevelSchema.options.join(", ")}`;let r=t.departmentId;return r!=null&&(typeof r!="number"||!Number.isInteger(r))?"payload.departmentId must be an integer or null":null}function pn(e){try{return(0,it.formatCount)(e,oe),null}catch{return`inspectFileUri answered a fileSize that is not a byte count (a non-negative safe integer): ${String(e)}`}}async function mn(e,t,n,r,i,s,l,u){if(n==="ingest_document"){let d=String(r.get("payload")??"");if(!d)return Response.json({error:"payload is required"},{status:400});let c;try{c=JSON.parse(d)}catch{return Response.json({error:"Invalid JSON payload"},{status:400})}let m=cn(c);if(m)return Response.json({error:m},{status:400});let y=c,v=await l(s,y);if(v!==null)return Response.json({error:v},{status:403});try{let b=u===void 0?await e.ingestDocument(t,y,i):await e.ingestDocument(t,y,i,u);return Response.json({success:!0,result:b})}catch(b){return Response.json({error:b instanceof Error?b.message:String(b)},{status:400})}}if(n==="inspect_uri"){let d=String(r.get("fileUri")??"").trim();if(!d)return Response.json({error:"fileUri is required"},{status:400});if(!e.inspectFileUri)return Response.json({error:"inspectFileUri is not implemented"},{status:501});let c;try{c=u===void 0?await e.inspectFileUri(t,d):await e.inspectFileUri(t,d,u)}catch(y){return Response.json({error:y instanceof Error?y.message:String(y)},{status:400})}let m=pn(c.fileSize);return m!==null?Response.json({error:m},{status:400}):Response.json({success:!0,inspection:c})}return null}function gn(e){let t=Le(e);return{loader:t.loader,action:t.action,View:Ee,server:t}}0&&(module.exports={StorageAdminConsoleView,checkAllSystemHealth,checkBackendApiHealth,checkNeo4jHealth,checkQdrantHealth,checkRedisHealth,checkSqlServerHealth,createStorageAdminApp,createStorageAdminServer});
1
+ "use strict";var Pe=Object.defineProperty;var Ot=Object.getOwnPropertyDescriptor;var xt=Object.getOwnPropertyNames;var kt=Object.prototype.hasOwnProperty;var Lt=(e,t)=>{for(var n in t)Pe(e,n,{get:t[n],enumerable:!0})},Ft=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of xt(t))!kt.call(e,o)&&o!==n&&Pe(e,o,{get:()=>t[o],enumerable:!(r=Ot(t,o))||r.enumerable});return e};var jt=e=>Ft(Pe({},"__esModule",{value:!0}),e);var Nn={};Lt(Nn,{StorageAdminConsoleView:()=>je,checkAllSystemHealth:()=>He,checkBackendApiHealth:()=>gt,checkNeo4jHealth:()=>ct,checkQdrantHealth:()=>dt,checkRedisHealth:()=>pt,checkSqlServerHealth:()=>mt,createStorageAdminApp:()=>Tn,createStorageAdminServer:()=>Ke});module.exports=jt(Nn);var _=require("@aiquants/console-ui"),U=require("@aiquants/enrichment-core"),R=require("@aiquants/enrichment-react"),h=require("@aiquants/governance-react"),g=require("react"),K=require("react-router");var ce="ja-JP";var Dt=/[^\s\x1c-\x1f\x85\ufeff]/;function pe(e){return Dt.test(e)}function re(e,t){return new Promise(n=>n(e())).catch(n=>t(n instanceof Error?n.message:String(n)))}var me=require("@aiquants/console-ui/core"),We=require("@aiquants/enrichment-core"),N=require("react");var Ut=2e3,Ht=1e4;function Te(e,t){if(t.ok&&e.kind==="ready"&&(0,We.isStrictlyEarlier)(t.value.readAt,e.value.readAt))return e;let n=!t.ok&&t.status===403&&e.kind==="ready";return(0,me.keepLastGood)(n?{kind:"loading"}:e,t)}var Mt=401;function $t(e){return e.kind==="failed"||e.refreshFailure!==null&&e.refreshFailure.status===Mt?null:e.value.active}function Ye(e,t){let[n,r]=(0,N.useState)(()=>({loaded:e,overview:Te({kind:"loading"},e)}));n.loaded!==e&&r({loaded:e,overview:Te(n.overview,e)});let o=(0,N.useRef)(t);o.current=t;let s=(0,N.useRef)(null);(0,N.useEffect)(()=>()=>s.current?.abort(),[]);let l=(0,N.useCallback)((c,m)=>re(m,y=>({ok:!1,status:null,reason:y})).then(y=>{c.aborted||r(I=>({loaded:I.loaded,overview:Te(I.overview,y)}))}),[]),u=(0,N.useCallback)(()=>{let c=new AbortController;s.current=c,r(m=>({loaded:m.loaded,overview:(0,me.beginReload)(m.overview,"reload")})),l(c.signal,()=>o.current(c.signal))},[l]),d=(0,N.useCallback)(c=>l(c,()=>o.current(c)),[l]);return{overview:n.overview,reload:u,poll:d}}function Kt(e){return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)}function qt(){return document.visibilityState==="visible"}function Bt(){return!0}function Ze(e,t,n){let r=(0,N.useSyncExternalStore)(Kt,qt,Bt),o=t&&r,s=(0,N.useRef)(o),l=e.kind==="ready",u=$t(e),d=u===null?null:u.run.runUid,c=u===null?!1:u.isStale;(0,N.useEffect)(()=>{let m=o&&!s.current;if(s.current=o,!o||d===null&&!(m&&l))return;let y=new AbortController,I=c?Ht:Ut,b,w=async()=>{await n(y.signal),!y.signal.aborted&&d!==null&&(b=setTimeout(w,I))};return b=setTimeout(w,m?0:I),()=>{y.abort(),clearTimeout(b)}},[o,l,d,c,n])}var _e={columns:2,className:"grid-cols-2",spanClassNames:{1:"col-span-1",2:"col-span-2"}},Ee={columns:4,className:"@min-[41.5rem]:grid-cols-4",spanClassNames:{1:"@min-[41.5rem]:col-span-1",2:"@min-[41.5rem]:col-span-2",3:"@min-[41.5rem]:col-span-3",4:"@min-[41.5rem]:col-span-4"}},Ce={className:"@min-[82rem]:grid-flow-col @min-[82rem]:auto-cols-fr @min-[82rem]:grid-cols-none",lastTabClassName:"@min-[82rem]:col-auto"};function Oe(e,t){let n=t%e.columns,r=n===0?1:e.columns-n+1;return e.spanClassNames[r]}var a=require("react/jsx-runtime"),Xe="tab",ke={key:"knowledge-authority",phrases:["\u6A29\u5A01\u53F0\u5E33 & \u898F\u7A0B\u885D\u7A81"]},Le={key:"pipeline",phrases:["\u30D1\u30A4\u30D7\u30E9\u30A4\u30F3 & \u63A5\u7D9A\u72B6\u614B"]},Fe={key:"parameters",phrases:["\u30E2\u30C7\u30EB & \u30D1\u30E9\u30E1\u30FC\u30BF\u8A2D\u5B9A"]},et="\u30A8\u30F3\u30EA\u30C3\u30C1\u30E1\u30F3\u30C8\u540C\u671F\u30B9\u30C6\u30FC\u30BF\u30B9",Vt="\u9001\u4FE1\u4E2D\u306E\u64CD\u4F5C (\u540C\u671F\u306E\u518D\u8A66\u884C\u306A\u3069) \u306E\u7D50\u679C\u3092\u5F85\u3063\u3066\u3044\u308B\u305F\u3081\u3001\u9001\u3063\u3066\u3044\u307E\u305B\u3093\u3002\u7D50\u679C\u304C\u51FA\u3066\u304B\u3089\u62BC\u3057\u76F4\u3057\u3066\u304F\u3060\u3055\u3044\u3002",q=[{key:"search",phrases:["\u30E1\u30BF\u30C7\u30FC\u30BF\u691C\u7D22","\u30EF\u30FC\u30AF\u30D9\u30F3\u30C1"]},{key:"ingest",phrases:["\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8","\u53D6\u308A\u8FBC\u307F & \u30E1\u30BF\u751F\u6210"]},Le,{key:"knowledge-graph",phrases:["\u30CA\u30EC\u30C3\u30B8\u30B0\u30E9\u30D5","\u63A2\u7D22"]},Fe,{key:"prompts",phrases:["\u30D7\u30ED\u30F3\u30D7\u30C8 & \u30C9\u30E9\u30A4\u30E9\u30F3"]},ke,{key:"data-retention",phrases:["\u30C7\u30FC\u30BF\u4FDD\u6301 & \u6574\u5408\u6027\u76E3\u67FB"]}];function xe(e){return e.phrases.join("")}function Gt(e){return e!==null&&q.some(t=>t.key===e)}var Qt="Tri-Store \u30C7\u30FC\u30BF\u6574\u5408\u6027\u76E3\u67FB";function zt(e){return`\u76E3\u67FB\u306E\u6982\u6CC1\u3092\u8AAD\u3081\u307E\u305B\u3093\u3067\u3057\u305F${(0,_.reasonAside)(e)}\u3002`}var Jt=(0,_.resolveConsoleUiLabels)("ja");function Wt(e){return e.status===403?Jt.forbiddenBecause("\u51E6\u7406\u5C65\u6B74\u3092\u95B2\u89A7\u3059\u308B\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093\u3002",e.reason):`\u51E6\u7406\u5C65\u6B74\u3092\u8AAD\u3081\u307E\u305B\u3093\u3067\u3057\u305F${(0,_.reasonAside)(e.reason)}\u3002`}var tt={state:"idle",formData:null,data:null,submit:()=>Promise.resolve()};function at({data:e,fetcher:t,integrityFetcher:n,renderHeader:r,graphTraversal:o,onBrowseGraphNodes:s,onSimulateGovernance:l,onRefreshIngestQueue:u,onSearch:d,onLoadDocumentRuns:c,onCompareVariants:m,loadIntegrityOverview:y,loadIntegrityFindings:I,policyConflicts:b,documentAuthority:w}){let[f,V]=(0,g.useState)(null),[$,x]=(0,g.useState)(null),[k,L]=(0,g.useState)(!1),G=(0,g.useMemo)(()=>{if(s!==void 0)return(i,S)=>{L(!0),re(()=>s(i,S),v=>({ok:!1,reason:v})).then(v=>{L(!1),x(v.ok?null:v.reason),v.ok&&V(v.page)})}},[s]),[Q,z]=(0,K.useSearchParams)(),F=Q.get(Xe),A=Gt(F)?F:q[0].key,j=i=>{z(S=>{let v=new URLSearchParams(S);return v.set(Xe,i),v},{replace:!1,preventScrollReset:!0})},ie=Zt(e.recentIngestItems,u,A==="ingest"),D=Ye(e.integrityAudit,y);Ze(D.overview,A==="data-retention",D.poll);let Z=(0,g.useRef)(null),ae=(0,_.useFocusRescue)(()=>Z.current),[fe,be]=(0,g.useState)(0),Se=(0,g.useCallback)(()=>be(i=>i+1),[]),p=ie===null?e:{...e,recentIngestItems:[...ie]},J=(0,g.useRef)({}),Re=(0,g.useCallback)(()=>J.current[A]??null,[A]),oe=(0,g.useMemo)(()=>Xt(e.enrichmentStrategies),[e.enrichmentStrategies]),he=(0,g.useMemo)(()=>e.strategyVariants.map(en),[e.strategyVariants]),E=rn(c),W=E.open,le=W===void 0?void 0:i=>W(i,null),ve=W===void 0?void 0:i=>W(i.metadataId,i.id),ue=(i,S)=>{let v=q.length-1,C;if(i.key==="ArrowRight"||i.key==="ArrowDown")C=S===v?0:S+1;else if(i.key==="ArrowLeft"||i.key==="ArrowUp")C=S===0?v:S-1;else if(i.key==="Home")C=0;else if(i.key==="End")C=v;else return;i.preventDefault();let de=q[C].key;j(de),J.current[de]?.focus()},qe={...p.featureFlags};if(t.formData&&t.formData.get("intent")==="toggle_flag"){let i=String(t.formData.get("flagKey")??""),S=String(t.formData.get("enabled")??"")==="true";i&&(qe[i]=S)}let St=t.data&&"inspection"in t.data?t.data.inspection:void 0,X=t.state==="idle"?null:t.formData?.get("intent"),Rt=X==="inspect_uri",ht=X==="ingest_document",vt=X==="retry_job"||X==="retry_all_failed",It=X==="resolve_entity",Be=n.state==="idle"?null:n.formData?.get("intent"),wt=Be==="start_integrity_run"?{kind:"starting",mode:U.IntegrityRunModeSchema.parse(n.formData?.get("mode"))}:Be==="cancel_integrity_run"?{kind:"cancelling"}:{kind:"idle"},At=(0,K.useRevalidator)(),[Pt,Ie]=(0,g.useState)(null),Ve=A!=="data-retention";(0,g.useEffect)(()=>{Ve&&Ie(null)},[Ve]);let Tt=i=>{let S=i?.failure;if(S===void 0){Ie(null);return}Ie(v=>({failure:S,occurrence:v===null?1:v.occurrence+1})),(0,h.integrityFailureNeedsOverviewReread)(S)&&At.revalidate()},[ee,te]=(0,g.useState)(null),Nt=i=>{if(t.state!=="idle"){te({metadataId:i,intent:"retry_job",status:"refused",error:Vt});return}te({metadataId:i,intent:"retry_job",status:"pending",error:null}),t.submit({intent:"retry_job",fileId:String(i)},{method:"post"})},[Ge,we]=(0,g.useState)("console"),_t=(i,S)=>{if(ee!==null&&ee.status==="pending"){if(S==="retry_job"){let v=i?.error;te(v===void 0?{...ee,status:"accepted",error:null}:{...ee,status:"refused",error:v}),we("inspector");return}te(null)}we("console")},{settledIntent:Et,submitAndAwait:Qe}=rt(t,_t);rt(n,i=>{we("integrity"),Tt(i)});let ze=Ge==="inspector"?void 0:(Ge==="console"?t:n).data?.error,Ae=i=>{j(i),J.current[i]?.focus()},Je=(0,g.useRef)(null),Ct={strategies:{label:xe(Le),onOpen:()=>Ae(Le.key),closesInspector:!0},projectionPolicy:{label:xe(Fe),onOpen:()=>Ae(Fe.key),closesInspector:!0},failedSync:{label:et,onOpen:()=>Je.current?.focus(),closesInspector:!1}},ne=Et==="retry_all_failed"&&t.data?.skipped!==void 0&&t.data.requeued!==void 0?{requeued:t.data.requeued,skipped:t.data.skipped}:null;return(0,a.jsx)(_.ConsoleUiRoot,{locale:"ja",formatLocale:ce,timeZone:p.displayTimeZone,testId:"storage-admin-console-ui",children:(0,a.jsxs)("div",{className:"container mx-auto space-y-6 p-6 font-sans text-slate-900","data-testid":"storage-admin-console",children:[ze&&(0,a.jsx)("div",{className:"rounded-lg border border-red-200 border-solid bg-red-50 p-4 font-medium text-red-700 text-sm shadow-sm",role:"alert","data-testid":"storage-admin-error-alert",children:ze}),r?r({title:"\u30B9\u30C8\u30EC\u30FC\u30B8 AI \u30A8\u30F3\u30EA\u30C3\u30C1\u30E1\u30F3\u30C8 & \u30AC\u30D0\u30CA\u30F3\u30B9\u904B\u7528\u7BA1\u7406",tenantId:p.tenantId}):(0,a.jsxs)("header",{className:"flex flex-col justify-between gap-2 border-slate-200 border-b border-solid pb-4 md:flex-row md:items-center",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"font-bold text-2xl tracking-tight",children:"\u30B9\u30C8\u30EC\u30FC\u30B8 AI \u30A8\u30F3\u30EA\u30C3\u30C1\u30E1\u30F3\u30C8 & \u30AC\u30D0\u30CA\u30F3\u30B9\u904B\u7528\u7BA1\u7406"}),(0,a.jsxs)("p",{className:"mt-1 text-slate-500 text-sm",children:["\u30C6\u30CA\u30F3\u30C8: ",(0,a.jsx)("code",{className:"font-semibold text-slate-800",children:p.tenantId})," | \u5168\u30B7\u30B9\u30C6\u30E0\u72B6\u614B\u30FB\u30D1\u30E9\u30E1\u30FC\u30BF\u5236\u5FA1\u30FB\u6574\u5408\u6027\u76E3\u67FB"]})]}),(0,a.jsx)("div",{className:"flex items-center gap-2",children:(0,a.jsxs)("button",{type:"button","data-testid":"header-health-status-button",onClick:()=>j("pipeline"),className:"inline-flex items-center gap-2 rounded-full border border-slate-200 border-solid bg-slate-50 px-3 py-1.5 font-medium text-slate-700 text-xs transition-colors hover:bg-slate-100",children:[(0,a.jsx)("span",{className:`h-2 w-2 rounded-full ${p.systemHealth.allHealthy?"bg-emerald-500":"bg-amber-500"}`}),(0,a.jsxs)("span",{children:["\u5468\u8FBA\u6A5F\u80FD: ",p.systemHealth.allHealthy?"\u5168\u30B5\u30FC\u30D3\u30B9\u6B63\u5E38":"\u63A5\u7D9A\u8981\u78BA\u8A8D"]})]})})]}),(0,a.jsxs)("div",{className:"w-full space-y-6",children:[(0,a.jsx)("div",{className:"@container w-full","data-testid":"storage-admin-tablist-frame",children:(0,a.jsx)("div",{className:`grid w-full ${_e.className} ${Ee.className} ${Ce.className} gap-1 rounded-xl bg-slate-100 p-1`,role:"tablist","aria-label":"\u904B\u7528\u7BA1\u7406\u30B3\u30F3\u30BD\u30FC\u30EB\u306E\u753B\u9762",children:q.map((i,S)=>{let v=A===i.key;return(0,a.jsx)("button",{id:`tab-${i.key}`,type:"button",role:"tab",ref:C=>{J.current[i.key]=C},"aria-selected":v,"aria-controls":`panel-${i.key}`,tabIndex:v?0:-1,"data-testid":`tab-trigger-${i.key}`,onKeyDown:C=>ue(C,S),onClick:()=>j(i.key),className:`wrap-anywhere break-keep rounded-lg px-3 py-2.5 text-center font-medium text-sm transition-all ${S===q.length-1?`${Oe(_e,q.length)} ${Oe(Ee,q.length)} ${Ce.lastTabClassName}`:""} ${v?"bg-white text-slate-900 shadow-sm":"text-slate-600 hover:bg-slate-200/50 hover:text-slate-900"}`,children:i.phrases.map((C,de)=>(0,a.jsxs)(g.Fragment,{children:[de>0&&(0,a.jsx)("wbr",{}),C]},C))},i.key)})})}),E.metadataId!==null&&(0,a.jsx)(R.PipelineRunInspector,{metadataId:E.metadataId,runs:E.runs,selectedRunId:E.selectedRunId,onSelectRun:E.selectRun,isLoading:E.isLoading,failure:E.failure,onClose:E.close,openRequest:E.openRequest,returnFocusFallback:Re}),A==="search"&&(0,a.jsxs)("div",{role:"tabpanel",id:"panel-search","aria-labelledby":"tab-search",className:"space-y-6","data-testid":"tab-content-search",children:[(0,a.jsx)(R.MetadataSearchWorkbench,{tenantId:p.tenantId,onSearch:d,circuitBreakerStatus:p.circuitBreakerStatus}),m!==void 0&&(0,a.jsx)(R.ModelComparisonWorkbench,{variants:he,onCompare:m})]}),A==="ingest"&&(0,a.jsx)("div",{role:"tabpanel",id:"panel-ingest","aria-labelledby":"tab-ingest",className:"space-y-6","data-testid":"tab-content-ingest",children:(0,a.jsx)(R.DocumentIngestConsole,{tenantId:p.tenantId,policies:p.confidentialityPolicies,domainOptions:oe,recentItems:p.recentIngestItems,inspectionResult:St,isInspecting:Rt,isSubmitting:ht,onInspectUri:i=>{t.submit({intent:"inspect_uri",fileUri:i},{method:"post"})},onIngestDocument:i=>{t.submit({intent:"ingest_document",payload:JSON.stringify(i)},{method:"post"})},onRetryItem:i=>{t.submit({intent:"retry_job",fileId:String(i)},{method:"post"})},onShowHistory:le})}),A==="pipeline"&&(0,a.jsxs)("div",{role:"tabpanel",id:"panel-pipeline","aria-labelledby":"tab-pipeline",className:"space-y-6","data-testid":"tab-content-pipeline",children:[(0,a.jsx)(R.PipelineFlowViewer,{featureFlags:p.featureFlags,metrics:p.pipelineStepMetrics,metricSampleWindow:p.pipelineStepMetricWindow}),(0,a.jsx)(tn,{runs:p.recentPipelineRuns,onOpenRun:ve}),(0,a.jsx)(R.EnrichmentStrategyBoard,{strategies:p.enrichmentStrategies,featureFlags:p.featureFlags,isUpdating:t.state!=="idle",onToggleStage:(i,S,v)=>t.submit({intent:"update_enrichment_strategy",strategyId:String(i.id),domainId:String(i.domainId),stage:S,enabled:String(v)},{method:"post"})}),(0,a.jsx)(R.InfrastructureHealthMonitor,{health:p.systemHealth,isRefreshing:t.state!=="idle",onRefresh:()=>t.submit({intent:"refresh_health"},{method:"post"})})]}),A==="knowledge-graph"&&(0,a.jsxs)("div",{role:"tabpanel",id:"panel-knowledge-graph","aria-labelledby":"tab-knowledge-graph",className:"space-y-6","data-testid":"tab-content-knowledge-graph",children:[(0,a.jsx)(R.OntologyStatusCard,{tenantId:p.tenantId,ontologyStatus:p.ontologyStatus}),(0,a.jsx)(h.KnowledgeGraphExplorer,{topologyMaxLabels:U.GRAPH_INDEX_LIMITS.topologyLabels.default,schema:p.graphSchema,tenantId:p.tenantId,unresolvedEntities:p.unresolvedEntities,traversal:o,onBrowseLabel:G,nodeIndexPage:f,nodeIndexFailure:$,isNodeIndexLoading:k,isResolving:It,onResolveEntity:(i,S)=>{t.submit({intent:"resolve_entity",entityId:i,action:S},{method:"post"})}})]}),A==="parameters"&&(0,a.jsxs)("div",{role:"tabpanel",id:"panel-parameters","aria-labelledby":"tab-parameters",className:"space-y-6","data-testid":"tab-content-parameters",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2",children:[(0,a.jsx)(h.FeatureFlagBoard,{flags:qe,isUpdating:t.state!=="idle",onToggleFlag:(i,S)=>{t.submit({intent:"toggle_flag",flagKey:i,enabled:String(S)},{method:"post"})}}),(0,a.jsx)(h.ClassificationRuleEditor,{rules:p.classificationRules,domainOptions:oe,consultedBy:p.classificationRuleConsumer,onReorderRules:i=>{t.submit({intent:"reorder_rules",orderedRuleIds:JSON.stringify(i)},{method:"post"})}})]}),p.policiesMissingDestination.length>0&&(0,a.jsxs)("div",{"data-testid":"policies-missing-destination",role:"alert",style:{padding:"10px 12px",borderRadius:"6px",backgroundColor:"#fef2f2",color:"#b91c1c",fontSize:"12px"},children:[(0,a.jsx)("strong",{children:"\u6B21\u306E\u533A\u5206\u30FB\u6A5F\u80FD\u306F\u5B9F\u884C\u6642\u306B\u5931\u6557\u3057\u307E\u3059\u3002"})," \u53C2\u7167\u3059\u308B\u30D7\u30ED\u30F3\u30D7\u30C8\u884C\u306B\u5B9B\u5148\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002",(0,a.jsx)("ul",{style:{margin:"6px 0 0",paddingInlineStart:"18px"},children:p.policiesMissingDestination.map(i=>(0,a.jsxs)("li",{"data-testid":`missing-destination-${i.confidentialityLevel}-${i.capability}`,children:[i.confidentialityLevel," / ",i.capability," \u2192 ",i.promptKey," (",i.modelProvider,") \u306E ",(0,a.jsx)("code",{children:"extra_params.base_url"})]},`${i.confidentialityLevel}:${i.capability}`))}),(0,a.jsx)("span",{style:{display:"block",marginTop:"4px",fontSize:"11px"},children:"\u5B9B\u5148\u3092\u8A2D\u5B9A\u3057\u3066\u3082\u3001\u305D\u306E\u30DB\u30B9\u30C8\u304C\u914D\u5099\u5185\u3068\u3057\u3066\u767B\u9332\u3055\u308C\u3066\u3044\u306A\u3051\u308C\u3070\u62D2\u5426\u3055\u308C\u307E\u3059\u3002"})]}),(0,a.jsx)(h.ConfidentialityPolicyBoard,{policies:p.confidentialityPolicies,promptKeys:p.promptTemplates.map(i=>i.template_key),isUpdating:t.state!=="idle",onChangePolicy:i=>{t.submit({intent:"update_confidentiality_policy",confidentialityLevel:i.confidentialityLevel,capability:i.capability,isEnabled:String(i.isEnabled),allowCloudProvider:String(i.allowCloudProvider),promptKey:i.promptKey??""},{method:"post"})}}),(0,a.jsx)(h.TranscriptionAdaptationBoard,{vocabulary:p.transcriptionVocabulary,references:p.transcriptionReferences,unresolvedUris:p.unresolvedReferenceUris,isUpdating:t.state!=="idle",onSaveTerm:i=>Qe({intent:"save_transcription_term",id:i.id===null?"":String(i.id),term:i.term,reading:i.reading??"",boost:i.boost===null?"":String(i.boost),domainKey:i.domainKey??"",isActive:String(i.isActive)},{method:"post"}),onSaveReference:i=>Qe({intent:"save_transcription_reference",id:i.id===null?"":String(i.id),fileUri:i.fileUri,domainKey:i.domainKey??"",isActive:String(i.isActive)},{method:"post"})}),(0,a.jsx)(h.SystemParameterTable,{parameters:p.systemParameters,onSaveParameter:(i,S)=>{t.submit({intent:"update_parameter",paramKey:i,paramValue:String(S)},{method:"post"})}})]}),A==="prompts"&&(0,a.jsxs)("div",{role:"tabpanel",id:"panel-prompts","aria-labelledby":"tab-prompts",className:"space-y-6","data-testid":"tab-content-prompts",children:[(0,a.jsx)(h.PromptTemplateConsole,{templates:p.promptTemplates,isSaving:t.state!=="idle",onSaveTemplate:i=>{t.submit({intent:"update_prompt",templateKey:i.template_key,payload:JSON.stringify({templateText:i.template_text,modelName:i.model_name,temperature:i.temperature,maxOutputTokens:i.max_output_tokens,responseSchema:i.response_schema,endpointBaseUrl:i.endpoint_base_url??null})},{method:"post"})}}),(0,a.jsx)(h.GovernanceDryRunConsole,{onSimulate:l})]}),A==="knowledge-authority"&&(0,a.jsxs)("div",{role:"tabpanel",id:"panel-knowledge-authority","aria-labelledby":"tab-knowledge-authority",className:"space-y-6","data-testid":"tab-content-knowledge-authority",children:[(0,a.jsx)(h.DocumentAuthorityRegistry,{host:w,canUpdate:p.canUpdateKnowledge,onPolicyConflictsChanged:Se}),(0,a.jsx)(h.PolicyConflictQueue,{host:b,revision:fe})]}),A==="data-retention"&&(0,a.jsxs)("div",{role:"tabpanel",id:"panel-data-retention","aria-labelledby":"tab-data-retention",className:"space-y-6","data-testid":"tab-content-data-retention",children:[D.overview.kind==="ready"?(0,a.jsx)("div",{ref:ae,children:(0,a.jsx)(h.TriStoreIntegrityAudit,{overview:D.overview.value,canReadFindings:p.canReadIntegrityFindings,command:wt,commandFailure:Pt,onStartRun:(i,S)=>{n.submit(S===null?{intent:"start_integrity_run",mode:i}:{intent:"start_integrity_run",mode:i,basisRunUid:S},{method:"post"})},onCancelRun:i=>{n.submit({intent:"cancel_integrity_run",runUid:i},{method:"post"})},loadFindings:I,refreshFailure:D.overview.refreshFailure===null?null:D.overview.refreshFailure.reason,headingRef:Z,onShowHistory:le,resync:{onResync:Nt,onDismiss:()=>te(null),feedback:ee},remedyDestinations:Ct})}):(0,a.jsx)(_.Card,{title:Qt,testId:"audit-overview-failed",headingRef:Z,children:(0,a.jsx)(_.ResourceFailed,{failure:D.overview,onReload:D.reload,forbiddenMessage:"\u76E3\u67FB\u306E\u6982\u6CC1\u3092\u95B2\u89A7\u3059\u308B\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093\u3002",failureMessage:zt,rescueRef:ae,testId:"audit-overview-failed-resource"})}),(0,a.jsx)(h.PolicyConflictSummaryCard,{host:b,knowledgeTabLabel:xe(ke),onOpenKnowledgeTab:()=>Ae(ke.key)}),ne!==null&&ne.skipped.length>0&&(0,a.jsxs)("div",{role:"status","data-testid":"retry-all-skipped",className:"rounded-lg border border-amber-200 border-solid bg-amber-50 p-4 text-amber-800 text-sm",children:[(0,a.jsxs)("strong",{children:["\u4E00\u62EC\u518D\u8A66\u884C: ",ne.requeued," \u4EF6\u3092\u518D\u6295\u5165\u3057\u3001",ne.skipped.length," \u4EF6\u3092\u636E\u3048\u7F6E\u304D\u307E\u3057\u305F\u3002"]})," ","\u636E\u3048\u7F6E\u3044\u305F\u884C\u306F\u5931\u6557\u306E\u307E\u307E\u6B8B\u3063\u3066\u3044\u307E\u3059\u3002",(0,a.jsx)("ul",{className:"mt-1.5 list-disc ps-5",children:ne.skipped.map(i=>(0,a.jsxs)("li",{"data-testid":`retry-all-skipped-${i.metadataId}`,children:["#",i.metadataId,": ",i.reason]},i.metadataId))})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2",children:[(0,a.jsx)("section",{ref:Je,tabIndex:-1,"aria-label":et,"data-testid":"sync-status-region",children:(0,a.jsx)(R.SyncStatusMonitor,{counts:p.syncCounts,totalFiles:p.totalFiles,failedItems:p.failedSyncItems,isRetrying:vt,onRetryItem:i=>{t.submit({intent:"retry_job",fileId:String(i)},{method:"post"})},onRetryAll:()=>{t.submit({intent:"retry_all_failed"},{method:"post"})}})}),(0,a.jsx)(R.QdrantStorageCard,{overview:p.qdrantCollections,health:{healthy:p.systemHealth.services.qdrant.status==="connected",latency_ms:p.systemHealth.services.qdrant.latencyMs}})]})]})]})]})})}var Yt=new Set(U.EnrichmentSyncStatusSchema.options.filter(e=>e!=="SYNCED"&&!e.startsWith("FAILED"))),nt=2e3;function Zt(e,t,n){let[r,o]=(0,g.useState)(null),s=(0,g.useRef)(t);s.current=t;let l=(0,g.useRef)(e);l.current!==e&&(l.current=e,r!==null&&o(null));let d=(r??e)?.some(c=>Yt.has(c.syncStatus))===!0;return(0,g.useEffect)(()=>{if(!(n&&d&&s.current))return;let c=!1,m,y=async()=>{let I=s.current;if(I!==void 0){try{let b=await I();if(c)return;o(b)}catch{if(c)return}m=setTimeout(y,nt)}};return m=setTimeout(y,nt),()=>{c=!0,clearTimeout(m)}},[d,n]),r}function rt(e,t){let n=(0,g.useRef)(t);n.current=t;let r=(0,g.useRef)(null),o=(0,g.useRef)(!1),s=(0,g.useRef)(null);if(e.state!=="idle"){o.current=!0;let u=e.formData?.get("intent");typeof u=="string"&&(r.current=u)}(0,g.useEffect)(()=>{if(e.state!=="idle"||!o.current)return;o.current=!1,n.current(e.data,r.current);let u=s.current;if(u===null)return;s.current=null;let d=e.data?.error;typeof d=="string"?u.reject(new Error(d)):u.resolve()},[e.state,e.data]);let l=(0,g.useCallback)((...u)=>new Promise((d,c)=>{s.current?.reject(new Error("\u3053\u306E\u4FDD\u5B58\u306F\u5F8C\u7D9A\u306E\u9001\u4FE1\u306B\u7F6E\u304D\u63DB\u3048\u3089\u308C\u307E\u3057\u305F\u3002")),s.current={resolve:d,reject:c},e.submit(...u)}),[e]);return{settledIntent:e.state==="idle"?r.current:null,submitAndAwait:l}}function Xt(e){let t=new Set,n=[];for(let r of e)t.has(r.domainKey)||(t.add(r.domainKey),n.push({key:r.domainKey,label:r.domainLabel}));return n}function en(e){return{strategyId:e.strategyId,label:`${e.domainKey} / ${e.variantKey}`,embeddingModel:e.embeddingModel}}function tn({runs:e,onOpenRun:t}){return(0,a.jsxs)("section",{className:"rounded-xl border border-slate-200 border-solid bg-white p-6 shadow-sm","aria-labelledby":"pipeline-recent-runs-heading","data-testid":"pipeline-recent-runs",children:[(0,a.jsx)("h2",{id:"pipeline-recent-runs-heading",className:"font-bold text-base text-slate-900",children:"\u76F4\u8FD1\u306E\u5B9F\u884C"}),e.length===0?(0,a.jsx)("p",{className:"mt-4 text-[13px] text-slate-500","data-testid":"pipeline-recent-runs-empty",children:"\u8A18\u9332\u3055\u308C\u305F\u5B9F\u884C\u304C\u3042\u308A\u307E\u305B\u3093\u3002"}):(0,a.jsx)("div",{className:"relative mt-4 overflow-x-auto","data-testid":"pipeline-recent-runs-scroll",children:(0,a.jsxs)("table",{className:"w-full text-left text-[13px]",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"whitespace-nowrap border-slate-200 border-b border-solid text-[11px] text-slate-500 uppercase",children:[(0,a.jsx)("th",{scope:"col",className:"px-3 py-2",children:"\u5B9F\u884C"}),(0,a.jsx)("th",{scope:"col",className:"px-3 py-2",children:"\u6587\u66F8"}),(0,a.jsx)("th",{scope:"col",className:"px-3 py-2",children:"\u7A2E\u985E"}),(0,a.jsx)("th",{scope:"col",className:"px-3 py-2",children:"\u304D\u3063\u304B\u3051"}),(0,a.jsx)("th",{scope:"col",className:"px-3 py-2",children:"\u8A66\u884C"}),(0,a.jsx)("th",{scope:"col",className:"px-3 py-2",children:"\u72B6\u614B"}),(0,a.jsx)("th",{scope:"col",className:"px-3 py-2",children:"\u6B62\u307E\u3063\u305F\u6BB5"}),(0,a.jsx)("th",{scope:"col",className:"px-3 py-2",children:"\u958B\u59CB"}),(0,a.jsx)("th",{scope:"col",className:"px-3 py-2",children:"\u7D42\u4E86"}),(0,a.jsx)("th",{scope:"col",className:"px-3 py-2",children:"\u8981\u6C42\u8005"}),t!==void 0&&(0,a.jsx)("th",{scope:"col",className:"px-3 py-2",children:(0,a.jsx)("span",{className:"sr-only","data-testid":"pipeline-recent-runs-action-header",children:"\u64CD\u4F5C"})})]})}),(0,a.jsx)("tbody",{children:e.map(n=>{let r=(0,R.pipelineRunPresentationKey)(n),o=R.PIPELINE_RUN_STATUS_PRESENTATION[r];return(0,a.jsxs)("tr",{className:"border-slate-100 border-b border-solid","data-testid":`pipeline-run-row-${n.id}`,"data-status":n.status,children:[(0,a.jsxs)("td",{className:"whitespace-nowrap px-3 py-2 font-mono","data-testid":`pipeline-run-id-${n.id}`,children:["#",n.id]}),(0,a.jsxs)("td",{className:"whitespace-nowrap px-3 py-2 font-mono","data-testid":`pipeline-run-metadata-${n.id}`,children:["#",n.metadataId]}),(0,a.jsx)("td",{className:"whitespace-nowrap px-3 py-2","data-testid":`pipeline-run-kind-${n.id}`,children:U.DOCUMENT_KIND_LABELS[n.documentKind]}),(0,a.jsx)("td",{className:"whitespace-nowrap px-3 py-2","data-testid":`pipeline-run-trigger-${n.id}`,"data-trigger":n.trigger,children:R.PIPELINE_TRIGGER_LABELS[n.trigger]}),(0,a.jsx)("td",{className:"whitespace-nowrap px-3 py-2","data-testid":`pipeline-run-attempt-${n.id}`,children:n.attempt}),(0,a.jsx)("td",{className:"px-3 py-2",children:(0,a.jsx)("span",{className:`inline-flex whitespace-nowrap rounded-full px-2 py-0.5 font-semibold text-[11px] ${o.className}`,"data-testid":`pipeline-run-status-${n.id}`,"data-status":n.status,"data-presentation":r,children:o.label})}),(0,a.jsx)("td",{className:"px-3 py-2","data-testid":`pipeline-run-failed-step-${n.id}`,children:n.failedStepKey===null?"\u2014":U.PIPELINE_STEPS[n.failedStepKey].label}),(0,a.jsx)("td",{className:"whitespace-nowrap px-3 py-2 text-slate-500","data-testid":`pipeline-run-started-${n.id}`,children:(0,a.jsx)(R.RecordedInstant,{iso:n.startedAt,testId:`pipeline-run-started-value-${n.id}`})}),(0,a.jsx)("td",{className:"whitespace-nowrap px-3 py-2 text-slate-500","data-testid":`pipeline-run-finished-${n.id}`,children:(0,a.jsx)(R.FinishedInstant,{iso:n.finishedAt,testId:`pipeline-run-finished-value-${n.id}`})}),(0,a.jsx)("td",{className:"wrap-anywhere px-3 py-2","data-testid":`pipeline-run-requested-by-${n.id}`,children:n.requestedBy}),t!==void 0&&(0,a.jsx)("td",{className:"whitespace-nowrap px-3 py-2 text-right",children:(0,a.jsx)("button",{type:"button",onClick:()=>t(n),"aria-label":`\u5B9F\u884C #${n.id} (\u6587\u66F8 #${n.metadataId}) \u306E\u8A73\u7D30`,className:"whitespace-nowrap rounded-sm border border-slate-300 border-solid bg-white px-2 py-0.5 font-semibold text-[11px] text-slate-700 hover:bg-slate-50","data-testid":`pipeline-run-open-${n.id}`,children:"\u8A73\u7D30"})})]},n.id)})})]})})]})}var st={metadataId:null,runs:[],selectedRunId:null,isLoading:!1,failure:null};function nn(e){for(let t of e)for(let n of t.steps){let r=n.provenance;if(r!==null){for(let[o,s]of Object.entries(r))if(typeof s=="string"&&!pe(s))return`\u51E6\u7406\u5C65\u6B74\u306E\u8A18\u9332\u306B\u8AAD\u3081\u306A\u3044\u6765\u6B74\u306E\u5024\u304C\u3042\u308A\u307E\u3059 (\u5B9F\u884C ${t.id} \u306E\u6BB5 ${n.sequence} \u306E ${o})\u3002`}}return null}function rn(e){let[t,n]=(0,g.useState)(st),[r,o]=(0,g.useState)(0),s=(0,g.useRef)(0),l=(0,g.useRef)(null),u=(0,g.useMemo)(()=>{if(e!==void 0)return(m,y)=>{s.current+=1;let I=s.current;l.current?.abort();let b=new AbortController;l.current=b,o(w=>w+1),n({metadataId:m,runs:[],selectedRunId:y,isLoading:!0,failure:null}),re(()=>e(m,b.signal),w=>({ok:!1,status:null,reason:w})).then(w=>{if(s.current!==I)return;let f=w.ok?nn(w.value):Wt(w);if(!w.ok||f!==null){n({metadataId:m,runs:[],selectedRunId:y,isLoading:!1,failure:f});return}n({metadataId:m,runs:w.value,selectedRunId:y===null?sn(w.value):y,isLoading:!1,failure:null})})}},[e]),d=(0,g.useCallback)(m=>{n(y=>({...y,selectedRunId:m}))},[]),c=(0,g.useCallback)(()=>{s.current+=1,l.current?.abort(),l.current=null,n(st)},[]);return{...t,openRequest:r,open:u,selectRun:d,close:c}}function sn(e){return e.length===0?null:e[0].id}function an(e){let t=(0,K.useLoaderData)(),n=(0,K.useFetcher)(),r=(0,K.useFetcher)(),o=e.data??t,s=e.fetcher??n,l=e.integrityFetcher??r;return o?(0,a.jsx)(at,{...e,data:o,fetcher:s,integrityFetcher:l}):(0,a.jsx)("div",{className:"p-8 text-center text-slate-500","data-testid":"storage-admin-loading",children:"\u30C7\u30FC\u30BF\u8AAD\u307F\u8FBC\u307F\u4E2D..."})}function je(e){return e.data?(0,a.jsx)(at,{...e,data:e.data,fetcher:e.fetcher??tt,integrityFetcher:e.integrityFetcher??tt}):(0,a.jsx)(an,{...e})}var $e=require("@aiquants/authz-core"),ft=require("@aiquants/console-ui/core"),P=require("@aiquants/enrichment-core"),B=require("@aiquants/governance-core"),T=require("zod");var Ue=3e3;function M(e){return Math.round(performance.now()-e)}function O(e){return typeof e=="string"&&pe(e)?e:null}function H(e){let t=globalThis.process;return t===void 0?void 0:t.env[e]}function ge(e,t){let n=e?.trim();if(!n)throw new Error(`${t} is not configured; this probe will not guess an endpoint to send credentials to.`);return n}function ot(e,t,n){let r=e??(t?.trim()?Number(t):Number.NaN);if(!Number.isInteger(r)||r<=0||r>65535)throw new Error(`${n} is not configured with a valid port; this probe will not guess one.`);return r}function lt(e,t){if(e!==void 0)return e;let n=t?.trim().toLowerCase();if(!(n===void 0||n===""))return n==="1"||n==="true"||n==="yes"||n==="on"}function ut(e){let t=e.trim().split("://",1)[0]?.toLowerCase();if(t&&e.includes("://"))return t.endsWith("s")||t.includes("+s")}function on(e){let n=e.split("://").slice(-1)[0].split("/",1)[0],r=n.split(":").pop();if(!r||r===n)return;let o=Number(r);return Number.isInteger(o)&&o>0&&o<=65535?o:void 0}async function De(e,t){let n;try{return await Promise.race([e,new Promise((r,o)=>{n=setTimeout(()=>o(new Error(`Probe timed out after ${t}ms`)),t)})])}finally{clearTimeout(n)}}async function dt(e){let t=e?.qdrantApiKey??H("QDRANT_API_KEY")??"",n=e?.timeoutMs??Ue,r=performance.now(),o="";try{o=ge(e?.qdrantUrl??H("QDRANT_URL"),"QDRANT_URL");let s={};t&&(s["api-key"]=t);let[l,u]=await Promise.all([fetch(`${o}/`,{headers:s,signal:AbortSignal.timeout(n)}),fetch(`${o}/collections`,{headers:s,signal:AbortSignal.timeout(n)})]);if(!l.ok)throw new Error(`HTTP ${l.status}: ${l.statusText}`);if(!u.ok)throw new Error(`HTTP ${u.status}: ${u.statusText} (/collections)`);let d=await l.json(),c=M(r),y=(await u.json()).result?.collections?.length??0;return{serviceName:"Qdrant",category:"vector",status:"connected",version:O(d.version),endpoint:o,latencyMs:c,details:{engine:O(d.title),collectionsCount:y,restPort:on(o)??null,tls:ut(o)??null}}}catch(s){let l=M(r),u=s instanceof Error?s.message:String(s);return{serviceName:"Qdrant",category:"vector",status:"error",version:null,endpoint:o,latencyMs:l,details:{},errorMessage:u}}}async function ct(e){let t=e?.timeoutMs??Ue,n=performance.now(),r=O(e?.neo4jBoltUri??H("NEO4J_URI")),o=r===null?"":r;try{let s=e?.graphReader;if(!s)throw new Error("Graph reader not configured");let l=e?.tenantId,[u,d]=await Promise.all([De(s("CALL dbms.components() YIELD versions, edition RETURN versions[0] AS version, edition",{}),t),De(l?s("MATCH (n {tenantId: $tenantId}) RETURN count(n) AS node_count",{tenantId:l}):s("RETURN null AS node_count",{}),t)]);if(!u.ok)throw new Error(u.reason);if(!d.ok)throw new Error(d.reason);let[c,m]=u.rows[0]??[],y=d.rows[0]?.[0],I=M(n);return{serviceName:"Neo4j",category:"graph",status:"connected",version:O(c),endpoint:o,latencyMs:I,details:{edition:O(m),boltUri:r,nodeCount:typeof y=="number"?y:null,tls:r===null?null:ut(r)??null}}}catch(s){let l=M(n),u=s instanceof Error?s.message:String(s);return{serviceName:"Neo4j",category:"graph",status:"error",version:null,endpoint:o,latencyMs:l,details:{},errorMessage:u}}}async function pt(e){let t=performance.now(),n="",r=lt(e?.redisTls,H("REDIS_TLS")),o=Number.NaN;try{let s=e?.redisClient;if(!s)throw new Error("Redis client not configured");let l=ge(e?.redisHost??H("REDIS_HOST"),"REDIS_HOST");o=ot(e?.redisPort,H("REDIS_PORT"),"REDIS_PORT"),n=`${r===!1?"redis":"rediss"}://${l}:${o}`,await s.ping();let u=await s.info("server"),d=O(u.match(/redis_version:([^\r\n]+)/)?.[1]),c=null;if(typeof s.dbSize=="function")try{c=await s.dbSize()}catch{c=null}let m=M(t);return{serviceName:"Redis",category:"cache",status:"connected",version:d,endpoint:n,latencyMs:m,details:{totalKeys:c,port:o,tls:r??null,database:0}}}catch(s){let l=M(t),u=s instanceof Error?s.message:String(s);return{serviceName:"Redis",category:"cache",status:"error",version:null,endpoint:n,latencyMs:l,details:{},errorMessage:u}}}function ln(e){let t=e.match(/Microsoft SQL Server \d+ \([^)]+\)/);return O(t===null?e.substring(0,30):t[0].replace("Microsoft SQL Server ",""))}async function mt(e){let t=performance.now(),n="",r=lt(e?.sqlServerTls,H("SQL_SERVER_TLS")),o=Number.NaN;try{let s=e?.sqlServerExecute;if(!s)throw new Error("SQL Server executor not configured");let l=ge(e?.sqlServerHost??H("SQL_SERVER_HOST"),"SQL_SERVER_HOST");o=ot(e?.sqlServerPort,H("SQL_SERVER_PORT"),"SQL_SERVER_PORT"),n=`${l}:${o}`;let u=await s(),d=O(u.db_name),c=O(u.version),m=c===null?null:O(c.split(`
2
+ `)[0]),y=m===null?null:ln(m),I=M(t);return{serviceName:"SQL Server",category:"database",status:"connected",version:y,endpoint:n,latencyMs:I,details:{database:d,port:o,tls:r??null,fullVersion:m}}}catch(s){let l=M(t),u=s instanceof Error?s.message:String(s);return{serviceName:"SQL Server",category:"database",status:"error",version:null,endpoint:n,latencyMs:l,details:{},errorMessage:u}}}async function gt(e){let t=e?.timeoutMs??Ue,n=performance.now(),r="";try{r=ge(e?.backendApiHost??H("BACKEND_API_HOST"),"BACKEND_API_HOST");let o=await fetch(`${r}/openapi.json`,{signal:AbortSignal.timeout(t)});if(!o.ok)throw new Error(`HTTP ${o.status}: ${o.statusText}`);let s=await o.json(),l=Object.keys(s.paths??{}).length,u=M(n);return{serviceName:"AI Quant API",category:"api",status:"connected",version:O(s.info?.version),endpoint:r,latencyMs:u,details:{title:O(s.info?.title),endpointsCount:l}}}catch(o){let s=M(n),l=o instanceof Error?o.message:String(o);return{serviceName:"AI Quant API",category:"api",status:"error",version:null,endpoint:r,latencyMs:s,details:{},errorMessage:l}}}async function He(e){let[t,n,r,o,s]=await Promise.all([dt(e),ct(e),pt(e),mt(e),gt(e)]),l=t.status==="connected"&&n.status==="connected"&&r.status==="connected"&&o.status==="connected"&&s.status==="connected";return{services:{qdrant:t,neo4j:n,redis:r,sqlServer:o,quantsApi:s},allHealthy:l,checkedAt:new Date().toISOString()}}var un=T.z.object({templateText:T.z.string(),modelName:T.z.string(),temperature:T.z.number(),maxOutputTokens:T.z.number(),responseSchema:T.z.union([T.z.record(T.z.string(),T.z.unknown()),T.z.string(),T.z.null()]).optional(),endpointBaseUrl:T.z.string().nullable()}).strict(),dn=T.z.discriminatedUnion("mode",[T.z.object({mode:P.IntegrityRunModeSchema.extract(["SCAN"]),basisRunUid:T.z.null()}).strict(),T.z.object({mode:P.IntegrityRunModeSchema.extract(["REPAIR"]),basisRunUid:T.z.string().uuid()}).strict()]),cn=T.z.object({runUid:T.z.string().uuid()}).strict();function bt(e){return e==="start_integrity_run"?"start":e==="cancel_integrity_run"?"cancel":null}function Y(e,t){return e.issues.map(n=>`${n.path.length===0?t:n.path.join(".")}: ${n.message}`).join("; ")}function pn(e,t){if(e==="bool")return t==="true"||t==="false"?null:"paramValue must be 'true' or 'false' for a bool parameter";if(e==="int")return/^[+-]?\d+$/.test(t)&&Number.isSafeInteger(Number(t))?null:"paramValue must be a safe integer for an int parameter";if(e==="float")return t.trim()!==""&&Number.isFinite(Number(t))?null:"paramValue must be a finite number for a float parameter";if(e==="json")try{return JSON.parse(t),null}catch{return"paramValue must be valid JSON for a json parameter"}return null}function mn(e){let t=P.PipelineRunSummarySchema.array().safeParse(e);if(!t.success)throw new Error(`getRecentPipelineRuns answered something that is not a run summary: ${Y(t.error,"getRecentPipelineRuns")}`);return t.data}function gn(e){let t=P.PipelineStepMetricSchema.array().safeParse(e);if(!t.success)throw new Error(`getPipelineStepMetrics answered something that is not a step metric: ${Y(t.error,"getPipelineStepMetrics")}`);let n=new Set;for(let r of t.data){let o=`${r.documentKind}/${r.stepKey}`;if(n.has(o))throw new Error(`getPipelineStepMetrics answered more than one metric for (documentKind, stepKey) = (${r.documentKind}, ${r.stepKey})`);n.add(o)}return t.data}function yn(e){if(!Number.isSafeInteger(e)||e<=0)throw new Error(`pipelineStepMetricWindow must be a positive safe integer, got ${String(e)}`);return e}async function fn(e,t){let n;try{n=await e.readIntegrityAuditOverview(t)}catch(o){return{ok:!1,status:null,reason:o instanceof Error?o.message:String(o)}}let r=P.IntegrityAuditOverviewSchema.safeParse(n);return r.success?{ok:!0,value:r.data}:{ok:!1,status:null,reason:`readIntegrityAuditOverview answered something that is not an audit overview: ${Y(r.error,"readIntegrityAuditOverview")}`}}function bn(e){return!Array.isArray(e)||e.length===0?"orderedRuleIds must be a non-empty array of rule ids":e.every(t=>typeof t=="number"&&Number.isSafeInteger(t)&&t>0)?new Set(e).size!==e.length?"orderedRuleIds must not name a rule twice":null:"orderedRuleIds must contain positive integers only"}function Ke(e){let{store:t,healthProbeOptions:n,resourceKey:r="storage_admin",requireUser:o,requirePermission:s,resolveTenantId:l,authorizeIngest:u,canReadIntegrityFindings:d,canUpdateKnowledge:c}=e;async function m(I){let{request:b}=I;if(!await o(b))throw new Response("\u8A8D\u8A3C\u304C\u5FC5\u8981\u3067\u3059\u3002",{status:401});try{await s(b,{resourceKey:r,action:"read"})}catch(ue){throw ue instanceof $e.AuthzDeniedError?new Response("\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093\u3002",{status:403}):ue}let f=await l(b),V=yn(t.pipelineStepMetricWindow),[$,x,k]=await Promise.all([t.getFeatureFlags(f),t.getSystemParameters(f),t.getSyncCounts(f)]),L={featureFlags:$,systemParameters:x,syncCounts:k},[G,Q,z,F,A,j,ie,D,Z,ae,fe,be,Se,p,J,Re,oe,he,E,W,le]=await Promise.all([t.getConfidentialityPolicies(f),t.getTranscriptionVocabulary(f),t.getTranscriptionReferences(f),t.getUnresolvedReferenceUris(f),t.getPoliciesMissingDestination(f),t.getPromptTemplates(f),t.getClassificationRules(f),t.getFailedSyncItems(f),t.getGraphSchema(f),fn(t,f),d(b),c(b),t.getUnresolvedEntities(f),t.getQdrantCollections(f),He({...n,tenantId:f}),t.getRecentIngestItems(f),t.getOntologyStatus(f,L),t.getEnrichmentStrategies(f),t.getStrategyVariants(f),t.getPipelineStepMetrics(f),t.getRecentPipelineRuns(f)]),ve=t.getCircuitBreakerStatus();return{tenantId:f,featureFlags:L.featureFlags,confidentialityPolicies:G,transcriptionVocabulary:Q,transcriptionReferences:z,unresolvedReferenceUris:F,policiesMissingDestination:A,systemParameters:L.systemParameters,promptTemplates:j,classificationRules:ie,classificationRuleConsumer:t.classificationRuleConsumer??null,syncCounts:L.syncCounts.counts,totalFiles:L.syncCounts.total,failedSyncItems:D,circuitBreakerStatus:ve,pipelineStepMetrics:gn(W),pipelineStepMetricWindow:V,recentPipelineRuns:mn(le),displayTimeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,graphSchema:Z,enrichmentStrategies:he,strategyVariants:E,integrityAudit:ae,canReadIntegrityFindings:fe,canUpdateKnowledge:be,unresolvedEntities:Se,qdrantCollections:p,systemHealth:J,recentIngestItems:Re,ontologyStatus:oe}}async function y(I){let{request:b}=I,w=await o(b);if(!w)return Response.json({error:"\u8A8D\u8A3C\u304C\u5FC5\u8981\u3067\u3059\u3002"},{status:401});if(w.email.trim()==="")return Response.json({error:"\u64CD\u4F5C\u8005\u3092\u7279\u5B9A\u3067\u304D\u306A\u3044\u305F\u3081\u8A2D\u5B9A\u3092\u5909\u66F4\u3067\u304D\u307E\u305B\u3093\u3002"},{status:403});if(w.accessToken==="")throw new Error("requireUser resolved an operator whose accessToken is an empty string; answer null when the session holds no token the upstream services accept");let f=w.email,V=w.accessToken===null?void 0:w.accessToken;try{await s(b,{resourceKey:r,action:"update"})}catch(F){if(F instanceof $e.AuthzDeniedError)return await vn(b);throw F}let $=await l(b),x=await b.formData(),k=String(x.get("intent")??"");if(k==="refresh_health")return Response.json({success:!0,refreshed:!0});let L=await Rn(t,$,k,x,f);if(L)return L;let G=await hn(t,$,k,x,f,V);if(G)return G;let Q=await In(t,$,k,x,V,()=>d(b));if(Q)return Q;if(k==="resolve_entity"){let F=String(x.get("entityId")??""),A=String(x.get("action")??"");if(!F||A!=="merge"&&A!=="promote")return Response.json({error:"Valid entityId and action ('merge' | 'promote') are required"},{status:400});try{return await t.resolveEntity($,F,A),Response.json({success:!0,entityId:F,action:A})}catch(j){return Response.json({error:j instanceof Error?j.message:String(j)},{status:400})}}let z=await Pn(t,$,k,x,f,b,u,V);return z||Response.json({error:`Unknown intent: ${k}`},{status:400})}return{loader:m,action:y}}function Me(e){let t=String(e??"").trim();return t===""?null:t}function ye(e){let t=String(e??"").trim();if(t==="")return null;let n=Number(t);if(!(!Number.isSafeInteger(n)||n<=0))return n}function Sn(e){let t=String(e??"").trim();if(t==="")return null;let n=Number(t);if(!(!Number.isFinite(n)||n<=0))return n}async function Rn(e,t,n,r,o){if(n==="update_enrichment_strategy"){let s=String(r.get("stage")??"");if(!(0,P.isEnrichmentStageKey)(s))return Response.json({error:"stage must be a canonical enrichment stage key"},{status:400});let l=ye(r.get("strategyId")),u=ye(r.get("domainId"));if(l==null||u===void 0||u===null)return Response.json({error:"strategyId and domainId must be positive integers naming existing rows"},{status:400});let d=String(r.get("enabled")??"")==="true";try{await e.updateEnrichmentStrategy(t,{strategyId:l,domainId:u,stage:s,enabled:d},o)}catch(c){return Response.json({error:c instanceof Error?c.message:"\u53D6\u308A\u8FBC\u307F\u6226\u7565\u3092\u66F4\u65B0\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002"},{status:400})}return Response.json({success:!0,strategyId:l,domainId:u,stage:s,enabled:d})}if(n==="toggle_flag"){let s=String(r.get("flagKey")??""),l=String(r.get("enabled")??"")==="true";if(!s)return Response.json({error:"flagKey is required"},{status:400});let u=await e.getFeatureFlags(t);return Object.hasOwn(u,s)?(await e.toggleFeatureFlag(t,s,l,o),Response.json({success:!0,flagKey:s,enabled:l})):Response.json({error:`flagKey names no feature flag of this tenant: ${s}`},{status:400})}if(n==="update_confidentiality_policy"){let s=String(r.get("confidentialityLevel")??""),l=String(r.get("capability")??"");if(!(B.ConfidentialityLevelSchema.safeParse(s).success&&B.GovernedCapabilitySchema.safeParse(l).success))return Response.json({error:"confidentialityLevel and capability must be canonical values"},{status:400});let u=String(r.get("allowCloudProvider")??"")==="true";if(u&&!B.CLOUD_CAPABLE_CAPABILITIES.includes(l))return Response.json({error:`${l} sends nothing outside the deployment, so it has no cloud permission to grant`},{status:400});let d=String(r.get("promptKey")??"");return await e.updateConfidentialityPolicy(t,{confidentialityLevel:s,capability:l,isEnabled:String(r.get("isEnabled")??"")==="true",allowCloudProvider:u,promptKey:d===""?null:d},o),Response.json({success:!0,confidentialityLevel:s,capability:l})}if(n==="save_transcription_term"){let s=String(r.get("term")??"").trim();if(!s)return Response.json({error:"term is required"},{status:400});let l=Sn(r.get("boost"));if(l===void 0)return Response.json({error:"boost must be a number greater than zero, or absent to let the service decide"},{status:400});let u=ye(r.get("id"));if(u===void 0)return Response.json({error:"id must be a positive integer naming an existing row, or absent for a new one"},{status:400});try{await e.saveTranscriptionTerm(t,{id:u,term:s,reading:Me(r.get("reading")),boost:l,domainKey:Me(r.get("domainKey")),isActive:String(r.get("isActive")??"true")==="true"},o)}catch(d){return Response.json({error:d instanceof Error?d.message:"\u8A9E\u5F59\u3092\u4FDD\u5B58\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002"},{status:400})}return Response.json({success:!0,term:s})}if(n==="save_transcription_reference"){let s=String(r.get("fileUri")??"").trim();if(!s)return Response.json({error:"fileUri is required"},{status:400});let l=ye(r.get("id"));if(l===void 0)return Response.json({error:"id must be a positive integer naming an existing row, or absent for a new one"},{status:400});try{await e.saveTranscriptionReference(t,{id:l,fileUri:s,domainKey:Me(r.get("domainKey")),isActive:String(r.get("isActive")??"true")==="true"},o)}catch(u){return Response.json({error:u instanceof Error?u.message:"\u53C2\u7167\u8CC7\u6599\u3092\u4FDD\u5B58\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002"},{status:400})}return Response.json({success:!0,fileUri:s})}if(n==="update_parameter"){let s=String(r.get("paramKey")??""),l=String(r.get("paramValue")??"");if(!s)return Response.json({error:"paramKey is required"},{status:400});let u=(await e.getSystemParameters(t)).find(c=>c.key===s);if(u===void 0)return Response.json({error:`paramKey names no parameter of this tenant: ${s}`},{status:400});let d=pn(u.data_type,l);if(d!==null)return Response.json({error:d},{status:400});try{(0,P.assertSystemParameterInRange)(s,Number(l))}catch(c){return Response.json({error:c.message},{status:400})}return await e.updateSystemParameter(t,s,l,o),Response.json({success:!0,paramKey:s,paramValue:l})}if(n==="update_prompt"){let s=String(r.get("templateKey")??""),l=String(r.get("payload")??"{}"),u;try{u=JSON.parse(l)}catch{return Response.json({error:"Invalid JSON payload"},{status:400})}if(!s)return Response.json({error:"templateKey is required"},{status:400});let d=un.safeParse(u);if(!d.success)return Response.json({error:`payload does not carry a prompt template update: ${Y(d.error,"payload")}`},{status:400});let c=d.data;try{return await e.updatePromptTemplate(t,s,c,o),Response.json({success:!0,templateKey:s})}catch(m){return Response.json({error:m instanceof Error?m.message:String(m)},{status:400})}}if(n==="reorder_rules"){let s=String(r.get("orderedRuleIds")??"[]"),l;try{l=JSON.parse(s)}catch{return Response.json({error:"Invalid orderedRuleIds JSON"},{status:400})}let u=bn(l);if(u!==null)return Response.json({error:u},{status:400});let d=l;return await e.reorderClassificationRules(t,d,o),Response.json({success:!0,orderedRuleIds:d})}return null}async function hn(e,t,n,r,o,s){if(n==="retry_job"){let l=String(r.get("fileId")??"");if(!l)return Response.json({error:"fileId is required"},{status:400});try{return await e.retrySyncItem(t,l,o,s),Response.json({success:!0,fileId:l})}catch(u){return Response.json({error:u instanceof Error?u.message:String(u)},{status:400})}}if(n==="retry_all_failed")try{let{requeued:l,skipped:u}=await e.retryAllFailedSyncItems(t,o,s);return Response.json({success:!0,requeued:l,skipped:u})}catch(l){return Response.json({error:l instanceof Error?l.message:String(l)},{status:400})}return null}function se(e,t,n){let r=P.IntegrityCommandFailureSchema.parse({command:e,code:t,status:n}),o=P.INTEGRITY_COMMAND_CODES.find(s=>s.code===r.code);return Response.json({failure:r},{status:o===void 0?502:o.status})}async function vn(e){let t=await e.formData().catch(()=>null),n=t===null?null:bt(t.get("intent"));return n===null?Response.json({error:"\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093\u3002"},{status:403}):se(n,"FORBIDDEN",null)}async function yt(e,t){let n;try{n=P.IntegrityCommandReplySchema.parse(await t())}catch{return se(e,"UPSTREAM_FAILED",null)}return n.ok?Response.json({success:!0,runUid:n.runUid}):se(e,(0,P.integrityCommandFailureCodeOf)(e,n.status,n.errorCode),n.status)}async function In(e,t,n,r,o,s){let l=bt(n);if(l==="start"){let u=dn.safeParse({mode:r.get("mode"),basisRunUid:r.get("basisRunUid")});if(!u.success)return Response.json({error:`start_integrity_run takes mode SCAN without basisRunUid, or mode REPAIR with basisRunUid (a UUID): ${Y(u.error,"form")}`},{status:400});let{mode:d,basisRunUid:c}=u.data;return o===void 0||d==="REPAIR"&&!await s()?se(l,"FORBIDDEN",null):await yt(l,()=>e.startIntegrityRun(t,d,c,o))}if(l==="cancel"){let u=cn.safeParse({runUid:r.get("runUid")});return u.success?o===void 0?se(l,"FORBIDDEN",null):await yt(l,()=>e.cancelIntegrityRun(t,u.data.runUid,o)):Response.json({error:`cancel_integrity_run takes runUid (a UUID): ${Y(u.error,"form")}`},{status:400})}return null}function wn(e){if(typeof e!="object"||e===null)return"payload must be an object";let t=e;if(typeof t.fileUri!="string"||t.fileUri.trim()==="")return"payload.fileUri is required";if(!B.ConfidentialityLevelSchema.safeParse(t.confidentialityLevel).success)return`payload.confidentialityLevel must be one of ${B.ConfidentialityLevelSchema.options.join(", ")}`;let r=t.departmentId;return r!=null&&(typeof r!="number"||!Number.isInteger(r))?"payload.departmentId must be an integer or null":null}function An(e){try{return(0,ft.formatCount)(e,ce),null}catch{return`inspectFileUri answered a fileSize that is not a byte count (a non-negative safe integer): ${String(e)}`}}async function Pn(e,t,n,r,o,s,l,u){if(n==="ingest_document"){let d=String(r.get("payload")??"");if(!d)return Response.json({error:"payload is required"},{status:400});let c;try{c=JSON.parse(d)}catch{return Response.json({error:"Invalid JSON payload"},{status:400})}let m=wn(c);if(m)return Response.json({error:m},{status:400});let y=c,I=await l(s,y);if(I!==null)return Response.json({error:I},{status:403});try{let b=u===void 0?await e.ingestDocument(t,y,o):await e.ingestDocument(t,y,o,u);return Response.json({success:!0,result:b})}catch(b){return Response.json({error:b instanceof Error?b.message:String(b)},{status:400})}}if(n==="inspect_uri"){let d=String(r.get("fileUri")??"").trim();if(!d)return Response.json({error:"fileUri is required"},{status:400});if(!e.inspectFileUri)return Response.json({error:"inspectFileUri is not implemented"},{status:501});let c;try{c=u===void 0?await e.inspectFileUri(t,d):await e.inspectFileUri(t,d,u)}catch(y){return Response.json({error:y instanceof Error?y.message:String(y)},{status:400})}let m=An(c.fileSize);return m!==null?Response.json({error:m},{status:400}):Response.json({success:!0,inspection:c})}return null}function Tn(e){let t=Ke(e);return{loader:t.loader,action:t.action,View:je,server:t}}0&&(module.exports={StorageAdminConsoleView,checkAllSystemHealth,checkBackendApiHealth,checkNeo4jHealth,checkQdrantHealth,checkRedisHealth,checkSqlServerHealth,createStorageAdminApp,createStorageAdminServer});
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{Card as Tt,ConsoleUiRoot as Et,ResourceFailed as _t,useFocusRescue as Ct}from"@aiquants/console-ui";import{DOCUMENT_KIND_LABELS as xt,EnrichmentSyncStatusSchema as Ot,GRAPH_INDEX_LIMITS as kt,IntegrityRunModeSchema as Lt,PIPELINE_STEPS as Ft}from"@aiquants/enrichment-core";import{DocumentIngestConsole as jt,EnrichmentStrategyBoard as Ut,FinishedInstant as Dt,InfrastructureHealthMonitor as Mt,MetadataSearchWorkbench as Ht,ModelComparisonWorkbench as $t,OntologyStatusCard as Kt,PIPELINE_RUN_STATUS_PRESENTATION as qt,PIPELINE_TRIGGER_LABELS as Vt,PipelineFlowViewer as Bt,PipelineRunInspector as Qt,pipelineRunPresentationKey as Gt,QdrantStorageCard as zt,RecordedInstant as Jt,SyncStatusMonitor as Wt}from"@aiquants/enrichment-react";import{ClassificationRuleEditor as Yt,ConfidentialityPolicyBoard as Zt,DocumentAuthorityRegistry as Xt,FeatureFlagBoard as en,GovernanceDryRunConsole as tn,integrityFailureNeedsOverviewReread as nn,KnowledgeGraphExplorer as rn,PolicyConflictQueue as sn,PolicyConflictSummaryCard as an,PromptTemplateConsole as on,SystemParameterTable as ln,TranscriptionAdaptationBoard as un,TriStoreIntegrityAudit as dn}from"@aiquants/governance-react";import{Fragment as cn,useCallback as W,useEffect as Ae,useMemo as se,useRef as k,useState as U}from"react";import{useFetcher as De,useLoaderData as pn,useRevalidator as mn,useSearchParams as gn}from"react-router";var ne="ja-JP";var mt=/[^\s\x1c-\x1f\x85\ufeff]/;function re(e){return mt.test(e)}function J(e,t){return new Promise(n=>n(e())).catch(n=>t(n instanceof Error?n.message:String(n)))}import{beginReload as gt,keepLastGood as yt}from"@aiquants/console-ui/core";import{isStrictlyEarlier as ft}from"@aiquants/enrichment-core";import{useCallback as be,useEffect as Fe,useRef as Re,useState as bt,useSyncExternalStore as St}from"react";var Rt=2e3,ht=1e4;function Se(e,t){return t.ok&&e.kind==="ready"&&ft(t.value.readAt,e.value.readAt)?e:yt(e,t)}var vt=new Set([401,403]);function It(e){return e.kind==="failed"||e.refreshFailure!==null&&vt.has(e.refreshFailure.status)?null:e.value.active}function je(e,t){let[n,r]=bt(()=>({loaded:e,overview:Se({kind:"loading"},e)}));n.loaded!==e&&r({loaded:e,overview:Se(n.overview,e)});let o=Re(t);o.current=t;let s=Re(null);Fe(()=>()=>s.current?.abort(),[]);let a=be((c,m)=>J(m,g=>({ok:!1,status:null,reason:g})).then(g=>{c.aborted||r(R=>({loaded:R.loaded,overview:Se(R.overview,g)}))}),[]),l=be(()=>{let c=new AbortController;s.current=c,r(m=>({loaded:m.loaded,overview:gt(m.overview,"reload")})),a(c.signal,()=>o.current(c.signal))},[a]),d=be(c=>a(c,()=>o.current(c)),[a]);return{overview:n.overview,reload:l,poll:d}}function wt(e){return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)}function At(){return document.visibilityState==="visible"}function Pt(){return!0}function Ue(e,t,n){let r=St(wt,At,Pt),o=t&&r,s=Re(o),a=e.kind==="ready",l=It(e),d=l===null?null:l.run.runUid,c=l===null?!1:l.isStale;Fe(()=>{let m=o&&!s.current;if(s.current=o,!o||d===null&&!(m&&a))return;let g=new AbortController,R=c?ht:Rt,f,h=async()=>{await n(g.signal),!g.signal.aborted&&d!==null&&(f=setTimeout(h,R))};return f=setTimeout(h,m?0:R),()=>{g.abort(),clearTimeout(f)}},[o,a,d,c,n])}var he={columns:2,className:"grid-cols-2",spanClassNames:{1:"col-span-1",2:"col-span-2"}},ve={columns:4,className:"@min-[41.5rem]:grid-cols-4",spanClassNames:{1:"@min-[41.5rem]:col-span-1",2:"@min-[41.5rem]:col-span-2",3:"@min-[41.5rem]:col-span-3",4:"@min-[41.5rem]:col-span-4"}},Ie={className:"@min-[82rem]:grid-flow-col @min-[82rem]:auto-cols-fr @min-[82rem]:grid-cols-none",lastTabClassName:"@min-[82rem]:col-auto"};function we(e,t){let n=t%e.columns,r=n===0?1:e.columns-n+1;return e.spanClassNames[r]}import{jsx as u,jsxs as S}from"react/jsx-runtime";var Me="tab",ie={key:"knowledge-authority",phrases:["\u6A29\u5A01\u53F0\u5E33 & \u898F\u7A0B\u885D\u7A81"]},D=[{key:"search",phrases:["\u30E1\u30BF\u30C7\u30FC\u30BF\u691C\u7D22","\u30EF\u30FC\u30AF\u30D9\u30F3\u30C1"]},{key:"ingest",phrases:["\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8","\u53D6\u308A\u8FBC\u307F & \u30E1\u30BF\u751F\u6210"]},{key:"pipeline",phrases:["\u30D1\u30A4\u30D7\u30E9\u30A4\u30F3 & \u63A5\u7D9A\u72B6\u614B"]},{key:"knowledge-graph",phrases:["\u30CA\u30EC\u30C3\u30B8\u30B0\u30E9\u30D5","\u63A2\u7D22"]},{key:"parameters",phrases:["\u30E2\u30C7\u30EB & \u30D1\u30E9\u30E1\u30FC\u30BF\u8A2D\u5B9A"]},{key:"prompts",phrases:["\u30D7\u30ED\u30F3\u30D7\u30C8 & \u30C9\u30E9\u30A4\u30E9\u30F3"]},ie,{key:"data-retention",phrases:["\u30C7\u30FC\u30BF\u4FDD\u6301 & \u6574\u5408\u6027\u76E3\u67FB"]}];function yn(e){return e.phrases.join("")}function fn(e){return e!==null&&D.some(t=>t.key===e)}var bn="Tri-Store \u30C7\u30FC\u30BF\u6574\u5408\u6027\u76E3\u67FB";function Sn(e){return`\u76E3\u67FB\u306E\u6982\u6CC1\u3092\u8AAD\u3081\u307E\u305B\u3093\u3067\u3057\u305F (${e})\u3002`}function Rn(e){return`\u51E6\u7406\u5C65\u6B74\u3092\u8AAD\u3081\u307E\u305B\u3093\u3067\u3057\u305F (${e})\u3002`}var He={state:"idle",formData:null,data:null,submit:()=>Promise.resolve()};function Ve({data:e,fetcher:t,integrityFetcher:n,renderHeader:r,graphTraversal:o,onBrowseGraphNodes:s,onSimulateGovernance:a,onRefreshIngestQueue:l,onSearch:d,onLoadDocumentRuns:c,onCompareVariants:m,loadIntegrityOverview:g,loadIntegrityFindings:R,policyConflicts:f,documentAuthority:h}){let[y,M]=U(null),[j,T]=U(null),[E,_]=U(!1),H=se(()=>{if(s!==void 0)return(i,b)=>{_(!0),J(()=>s(i,b),v=>({ok:!1,reason:v})).then(v=>{_(!1),T(v.ok?null:v.reason),v.ok&&M(v.page)})}},[s]),[$,K]=gn(),C=$.get(Me),I=fn(C)?C:D[0].key,x=i=>{K(b=>{let v=new URLSearchParams(b);return v.set(Me,i),v},{replace:!1,preventScrollReset:!0})},Z=vn(e.recentIngestItems,l,I==="ingest"),O=je(e.integrityAudit,g);Ue(O.overview,I==="data-retention",O.poll);let Q=k(null),le=Ct(()=>Q.current),[ue,de]=U(0),ce=W(()=>de(i=>i+1),[]),p=Z===null?e:{...e,recentIngestItems:[...Z]},q=k({}),pe=W(()=>q.current[I]??null,[I]),X=se(()=>In(e.enrichmentStrategies),[e.enrichmentStrategies]),me=se(()=>e.strategyVariants.map(wn),[e.strategyVariants]),A=Nn(c),V=A.open,ge=V===void 0?void 0:i=>V(i,null),ye=V===void 0?void 0:i=>V(i.metadataId,i.id),ee=(i,b)=>{let v=D.length-1,P;if(i.key==="ArrowRight"||i.key==="ArrowDown")P=b===v?0:b+1;else if(i.key==="ArrowLeft"||i.key==="ArrowUp")P=b===0?v:b-1;else if(i.key==="Home")P=0;else if(i.key==="End")P=v;else return;i.preventDefault();let te=D[P].key;x(te),q.current[te]?.focus()},_e={...p.featureFlags};if(t.formData&&t.formData.get("intent")==="toggle_flag"){let i=String(t.formData.get("flagKey")??""),b=String(t.formData.get("enabled")??"")==="true";i&&(_e[i]=b)}let tt=t.data&&"inspection"in t.data?t.data.inspection:void 0,G=t.state==="idle"?null:t.formData?.get("intent"),nt=G==="inspect_uri",rt=G==="ingest_document",st=G==="retry_job"||G==="retry_all_failed",it=G==="resolve_entity",Ce=n.state==="idle"?null:n.formData?.get("intent"),at=Ce==="start_integrity_run"?{kind:"starting",mode:Lt.parse(n.formData?.get("mode"))}:Ce==="cancel_integrity_run"?{kind:"cancelling"}:{kind:"idle"},ot=mn(),[lt,fe]=U(null),xe=I!=="data-retention";Ae(()=>{xe&&fe(null)},[xe]);let ut=i=>{let b=i?.failure;if(b===void 0){fe(null);return}fe(v=>({failure:b,occurrence:v===null?1:v.occurrence+1})),nn(b)&&ot.revalidate()},[dt,Oe]=U("console"),{settledIntent:ct,submitAndAwait:ke}=Ke(t,()=>Oe("console"));Ke(n,i=>{Oe("integrity"),ut(i)});let Le=(dt==="console"?t:n).data?.error,pt=()=>{x(ie.key),q.current[ie.key]?.focus()},z=ct==="retry_all_failed"&&t.data?.skipped!==void 0&&t.data.requeued!==void 0?{requeued:t.data.requeued,skipped:t.data.skipped}:null;return u(Et,{locale:"ja",formatLocale:ne,timeZone:p.displayTimeZone,testId:"storage-admin-console-ui",children:S("div",{className:"container mx-auto space-y-6 p-6 font-sans text-slate-900","data-testid":"storage-admin-console",children:[Le&&u("div",{className:"rounded-lg border border-red-200 border-solid bg-red-50 p-4 font-medium text-red-700 text-sm shadow-sm",role:"alert","data-testid":"storage-admin-error-alert",children:Le}),r?r({title:"\u30B9\u30C8\u30EC\u30FC\u30B8 AI \u30A8\u30F3\u30EA\u30C3\u30C1\u30E1\u30F3\u30C8 & \u30AC\u30D0\u30CA\u30F3\u30B9\u904B\u7528\u7BA1\u7406",tenantId:p.tenantId}):S("header",{className:"flex flex-col justify-between gap-2 border-slate-200 border-b border-solid pb-4 md:flex-row md:items-center",children:[S("div",{children:[u("h1",{className:"font-bold text-2xl tracking-tight",children:"\u30B9\u30C8\u30EC\u30FC\u30B8 AI \u30A8\u30F3\u30EA\u30C3\u30C1\u30E1\u30F3\u30C8 & \u30AC\u30D0\u30CA\u30F3\u30B9\u904B\u7528\u7BA1\u7406"}),S("p",{className:"mt-1 text-slate-500 text-sm",children:["\u30C6\u30CA\u30F3\u30C8: ",u("code",{className:"font-semibold text-slate-800",children:p.tenantId})," | \u5168\u30B7\u30B9\u30C6\u30E0\u72B6\u614B\u30FB\u30D1\u30E9\u30E1\u30FC\u30BF\u5236\u5FA1\u30FB\u6574\u5408\u6027\u76E3\u67FB"]})]}),u("div",{className:"flex items-center gap-2",children:S("button",{type:"button","data-testid":"header-health-status-button",onClick:()=>x("pipeline"),className:"inline-flex items-center gap-2 rounded-full border border-slate-200 border-solid bg-slate-50 px-3 py-1.5 font-medium text-slate-700 text-xs transition-colors hover:bg-slate-100",children:[u("span",{className:`h-2 w-2 rounded-full ${p.systemHealth.allHealthy?"bg-emerald-500":"bg-amber-500"}`}),S("span",{children:["\u5468\u8FBA\u6A5F\u80FD: ",p.systemHealth.allHealthy?"\u5168\u30B5\u30FC\u30D3\u30B9\u6B63\u5E38":"\u63A5\u7D9A\u8981\u78BA\u8A8D"]})]})})]}),S("div",{className:"w-full space-y-6",children:[u("div",{className:"@container w-full","data-testid":"storage-admin-tablist-frame",children:u("div",{className:`grid w-full ${he.className} ${ve.className} ${Ie.className} gap-1 rounded-xl bg-slate-100 p-1`,role:"tablist","aria-label":"\u904B\u7528\u7BA1\u7406\u30B3\u30F3\u30BD\u30FC\u30EB\u306E\u753B\u9762",children:D.map((i,b)=>{let v=I===i.key;return u("button",{id:`tab-${i.key}`,type:"button",role:"tab",ref:P=>{q.current[i.key]=P},"aria-selected":v,"aria-controls":`panel-${i.key}`,tabIndex:v?0:-1,"data-testid":`tab-trigger-${i.key}`,onKeyDown:P=>ee(P,b),onClick:()=>x(i.key),className:`wrap-anywhere break-keep rounded-lg px-3 py-2.5 text-center font-medium text-sm transition-all ${b===D.length-1?`${we(he,D.length)} ${we(ve,D.length)} ${Ie.lastTabClassName}`:""} ${v?"bg-white text-slate-900 shadow-sm":"text-slate-600 hover:bg-slate-200/50 hover:text-slate-900"}`,children:i.phrases.map((P,te)=>S(cn,{children:[te>0&&u("wbr",{}),P]},P))},i.key)})})}),A.metadataId!==null&&u(Qt,{metadataId:A.metadataId,runs:A.runs,selectedRunId:A.selectedRunId,onSelectRun:A.selectRun,isLoading:A.isLoading,failure:A.failure,onClose:A.close,openRequest:A.openRequest,returnFocusFallback:pe}),I==="search"&&S("div",{role:"tabpanel",id:"panel-search","aria-labelledby":"tab-search",className:"space-y-6","data-testid":"tab-content-search",children:[u(Ht,{tenantId:p.tenantId,onSearch:d,circuitBreakerStatus:p.circuitBreakerStatus}),m!==void 0&&u($t,{variants:me,onCompare:m})]}),I==="ingest"&&u("div",{role:"tabpanel",id:"panel-ingest","aria-labelledby":"tab-ingest",className:"space-y-6","data-testid":"tab-content-ingest",children:u(jt,{tenantId:p.tenantId,policies:p.confidentialityPolicies,domainOptions:X,recentItems:p.recentIngestItems,inspectionResult:tt,isInspecting:nt,isSubmitting:rt,onInspectUri:i=>{t.submit({intent:"inspect_uri",fileUri:i},{method:"post"})},onIngestDocument:i=>{t.submit({intent:"ingest_document",payload:JSON.stringify(i)},{method:"post"})},onRetryItem:i=>{t.submit({intent:"retry_job",fileId:String(i)},{method:"post"})},onShowHistory:ge})}),I==="pipeline"&&S("div",{role:"tabpanel",id:"panel-pipeline","aria-labelledby":"tab-pipeline",className:"space-y-6","data-testid":"tab-content-pipeline",children:[u(Bt,{featureFlags:p.featureFlags,metrics:p.pipelineStepMetrics,metricSampleWindow:p.pipelineStepMetricWindow}),u(An,{runs:p.recentPipelineRuns,onOpenRun:ye}),u(Ut,{strategies:p.enrichmentStrategies,featureFlags:p.featureFlags,isUpdating:t.state!=="idle",onToggleStage:(i,b,v)=>t.submit({intent:"update_enrichment_strategy",strategyId:String(i.id),domainId:String(i.domainId),stage:b,enabled:String(v)},{method:"post"})}),u(Mt,{health:p.systemHealth,isRefreshing:t.state!=="idle",onRefresh:()=>t.submit({intent:"refresh_health"},{method:"post"})})]}),I==="knowledge-graph"&&S("div",{role:"tabpanel",id:"panel-knowledge-graph","aria-labelledby":"tab-knowledge-graph",className:"space-y-6","data-testid":"tab-content-knowledge-graph",children:[u(Kt,{tenantId:p.tenantId,ontologyStatus:p.ontologyStatus}),u(rn,{topologyMaxLabels:kt.topologyLabels.default,schema:p.graphSchema,tenantId:p.tenantId,unresolvedEntities:p.unresolvedEntities,traversal:o,onBrowseLabel:H,nodeIndexPage:y,nodeIndexFailure:j,isNodeIndexLoading:E,isResolving:it,onResolveEntity:(i,b)=>{t.submit({intent:"resolve_entity",entityId:i,action:b},{method:"post"})}})]}),I==="parameters"&&S("div",{role:"tabpanel",id:"panel-parameters","aria-labelledby":"tab-parameters",className:"space-y-6","data-testid":"tab-content-parameters",children:[S("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2",children:[u(en,{flags:_e,isUpdating:t.state!=="idle",onToggleFlag:(i,b)=>{t.submit({intent:"toggle_flag",flagKey:i,enabled:String(b)},{method:"post"})}}),u(Yt,{rules:p.classificationRules,domainOptions:X,consultedBy:p.classificationRuleConsumer,onReorderRules:i=>{t.submit({intent:"reorder_rules",orderedRuleIds:JSON.stringify(i)},{method:"post"})}})]}),p.policiesMissingDestination.length>0&&S("div",{"data-testid":"policies-missing-destination",role:"alert",style:{padding:"10px 12px",borderRadius:"6px",backgroundColor:"#fef2f2",color:"#b91c1c",fontSize:"12px"},children:[u("strong",{children:"\u6B21\u306E\u533A\u5206\u30FB\u6A5F\u80FD\u306F\u5B9F\u884C\u6642\u306B\u5931\u6557\u3057\u307E\u3059\u3002"})," \u53C2\u7167\u3059\u308B\u30D7\u30ED\u30F3\u30D7\u30C8\u884C\u306B\u5B9B\u5148\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002",u("ul",{style:{margin:"6px 0 0",paddingInlineStart:"18px"},children:p.policiesMissingDestination.map(i=>S("li",{"data-testid":`missing-destination-${i.confidentialityLevel}-${i.capability}`,children:[i.confidentialityLevel," / ",i.capability," \u2192 ",i.promptKey," (",i.modelProvider,") \u306E ",u("code",{children:"extra_params.base_url"})]},`${i.confidentialityLevel}:${i.capability}`))}),u("span",{style:{display:"block",marginTop:"4px",fontSize:"11px"},children:"\u5B9B\u5148\u3092\u8A2D\u5B9A\u3057\u3066\u3082\u3001\u305D\u306E\u30DB\u30B9\u30C8\u304C\u914D\u5099\u5185\u3068\u3057\u3066\u767B\u9332\u3055\u308C\u3066\u3044\u306A\u3051\u308C\u3070\u62D2\u5426\u3055\u308C\u307E\u3059\u3002"})]}),u(Zt,{policies:p.confidentialityPolicies,promptKeys:p.promptTemplates.map(i=>i.template_key),isUpdating:t.state!=="idle",onChangePolicy:i=>{t.submit({intent:"update_confidentiality_policy",confidentialityLevel:i.confidentialityLevel,capability:i.capability,isEnabled:String(i.isEnabled),allowCloudProvider:String(i.allowCloudProvider),promptKey:i.promptKey??""},{method:"post"})}}),u(un,{vocabulary:p.transcriptionVocabulary,references:p.transcriptionReferences,unresolvedUris:p.unresolvedReferenceUris,isUpdating:t.state!=="idle",onSaveTerm:i=>ke({intent:"save_transcription_term",id:i.id===null?"":String(i.id),term:i.term,reading:i.reading??"",boost:i.boost===null?"":String(i.boost),domainKey:i.domainKey??"",isActive:String(i.isActive)},{method:"post"}),onSaveReference:i=>ke({intent:"save_transcription_reference",id:i.id===null?"":String(i.id),fileUri:i.fileUri,domainKey:i.domainKey??"",isActive:String(i.isActive)},{method:"post"})}),u(ln,{parameters:p.systemParameters,onSaveParameter:(i,b)=>{t.submit({intent:"update_parameter",paramKey:i,paramValue:String(b)},{method:"post"})}})]}),I==="prompts"&&S("div",{role:"tabpanel",id:"panel-prompts","aria-labelledby":"tab-prompts",className:"space-y-6","data-testid":"tab-content-prompts",children:[u(on,{templates:p.promptTemplates,isSaving:t.state!=="idle",onSaveTemplate:i=>{t.submit({intent:"update_prompt",templateKey:i.template_key,payload:JSON.stringify({templateText:i.template_text,modelName:i.model_name,temperature:i.temperature,maxOutputTokens:i.max_output_tokens,responseSchema:i.response_schema,endpointBaseUrl:i.endpoint_base_url??null})},{method:"post"})}}),u(tn,{onSimulate:a})]}),I==="knowledge-authority"&&S("div",{role:"tabpanel",id:"panel-knowledge-authority","aria-labelledby":"tab-knowledge-authority",className:"space-y-6","data-testid":"tab-content-knowledge-authority",children:[u(Xt,{host:h,canUpdate:p.canUpdateKnowledge,onPolicyConflictsChanged:ce}),u(sn,{host:f,revision:ue})]}),I==="data-retention"&&S("div",{role:"tabpanel",id:"panel-data-retention","aria-labelledby":"tab-data-retention",className:"space-y-6","data-testid":"tab-content-data-retention",children:[O.overview.kind==="ready"?u(dn,{overview:O.overview.value,canReadFindings:p.canReadIntegrityFindings,command:at,commandFailure:lt,onStartRun:(i,b)=>{n.submit(b===null?{intent:"start_integrity_run",mode:i}:{intent:"start_integrity_run",mode:i,basisRunUid:b},{method:"post"})},onCancelRun:i=>{n.submit({intent:"cancel_integrity_run",runUid:i},{method:"post"})},loadFindings:R,refreshFailure:O.overview.refreshFailure===null?null:O.overview.refreshFailure.reason,headingRef:Q}):u(Tt,{title:bn,testId:"audit-overview-failed",headingRef:Q,children:u(_t,{failure:O.overview,onReload:O.reload,forbiddenMessage:"\u76E3\u67FB\u306E\u6982\u6CC1\u3092\u95B2\u89A7\u3059\u308B\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093\u3002",failureMessage:Sn,rescueRef:le,testId:"audit-overview-failed-resource"})}),u(an,{host:f,knowledgeTabLabel:yn(ie),onOpenKnowledgeTab:pt}),z!==null&&z.skipped.length>0&&S("div",{role:"status","data-testid":"retry-all-skipped",className:"rounded-lg border border-amber-200 border-solid bg-amber-50 p-4 text-amber-800 text-sm",children:[S("strong",{children:["\u4E00\u62EC\u518D\u8A66\u884C: ",z.requeued," \u4EF6\u3092\u518D\u6295\u5165\u3057\u3001",z.skipped.length," \u4EF6\u3092\u636E\u3048\u7F6E\u304D\u307E\u3057\u305F\u3002"]})," ","\u636E\u3048\u7F6E\u3044\u305F\u884C\u306F\u5931\u6557\u306E\u307E\u307E\u6B8B\u3063\u3066\u3044\u307E\u3059\u3002",u("ul",{className:"mt-1.5 list-disc ps-5",children:z.skipped.map(i=>S("li",{"data-testid":`retry-all-skipped-${i.metadataId}`,children:["#",i.metadataId,": ",i.reason]},i.metadataId))})]}),S("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2",children:[u(Wt,{counts:p.syncCounts,totalFiles:p.totalFiles,failedItems:p.failedSyncItems,isRetrying:st,onRetryItem:i=>{t.submit({intent:"retry_job",fileId:String(i)},{method:"post"})},onRetryAll:()=>{t.submit({intent:"retry_all_failed"},{method:"post"})}}),u(zt,{overview:p.qdrantCollections,health:{healthy:p.systemHealth.services.qdrant.status==="connected",latency_ms:p.systemHealth.services.qdrant.latencyMs}})]})]})]})]})})}var hn=new Set(Ot.options.filter(e=>e!=="SYNCED"&&!e.startsWith("FAILED"))),$e=2e3;function vn(e,t,n){let[r,o]=U(null),s=k(t);s.current=t;let a=k(e);a.current!==e&&(a.current=e,r!==null&&o(null));let d=(r??e)?.some(c=>hn.has(c.syncStatus))===!0;return Ae(()=>{if(!(n&&d&&s.current))return;let c=!1,m,g=async()=>{let R=s.current;if(R!==void 0){try{let f=await R();if(c)return;o(f)}catch{if(c)return}m=setTimeout(g,$e)}};return m=setTimeout(g,$e),()=>{c=!0,clearTimeout(m)}},[d,n]),r}function Ke(e,t){let n=k(t);n.current=t;let r=k(null),o=k(!1),s=k(null);if(e.state!=="idle"){o.current=!0;let l=e.formData?.get("intent");typeof l=="string"&&(r.current=l)}Ae(()=>{if(e.state!=="idle"||!o.current)return;o.current=!1,n.current(e.data);let l=s.current;if(l===null)return;s.current=null;let d=e.data?.error;typeof d=="string"?l.reject(new Error(d)):l.resolve()},[e.state,e.data]);let a=W((...l)=>new Promise((d,c)=>{s.current?.reject(new Error("\u3053\u306E\u4FDD\u5B58\u306F\u5F8C\u7D9A\u306E\u9001\u4FE1\u306B\u7F6E\u304D\u63DB\u3048\u3089\u308C\u307E\u3057\u305F\u3002")),s.current={resolve:d,reject:c},e.submit(...l)}),[e]);return{settledIntent:e.state==="idle"?r.current:null,submitAndAwait:a}}function In(e){let t=new Set,n=[];for(let r of e)t.has(r.domainKey)||(t.add(r.domainKey),n.push({key:r.domainKey,label:r.domainLabel}));return n}function wn(e){return{strategyId:e.strategyId,label:`${e.domainKey} / ${e.variantKey}`,embeddingModel:e.embeddingModel}}function An({runs:e,onOpenRun:t}){return S("section",{className:"rounded-xl border border-slate-200 border-solid bg-white p-6 shadow-sm","aria-labelledby":"pipeline-recent-runs-heading","data-testid":"pipeline-recent-runs",children:[u("h2",{id:"pipeline-recent-runs-heading",className:"font-bold text-base text-slate-900",children:"\u76F4\u8FD1\u306E\u5B9F\u884C"}),e.length===0?u("p",{className:"mt-4 text-[13px] text-slate-500","data-testid":"pipeline-recent-runs-empty",children:"\u8A18\u9332\u3055\u308C\u305F\u5B9F\u884C\u304C\u3042\u308A\u307E\u305B\u3093\u3002"}):u("div",{className:"relative mt-4 overflow-x-auto","data-testid":"pipeline-recent-runs-scroll",children:S("table",{className:"w-full text-left text-[13px]",children:[u("thead",{children:S("tr",{className:"whitespace-nowrap border-slate-200 border-b border-solid text-[11px] text-slate-500 uppercase",children:[u("th",{scope:"col",className:"px-3 py-2",children:"\u5B9F\u884C"}),u("th",{scope:"col",className:"px-3 py-2",children:"\u6587\u66F8"}),u("th",{scope:"col",className:"px-3 py-2",children:"\u7A2E\u985E"}),u("th",{scope:"col",className:"px-3 py-2",children:"\u304D\u3063\u304B\u3051"}),u("th",{scope:"col",className:"px-3 py-2",children:"\u8A66\u884C"}),u("th",{scope:"col",className:"px-3 py-2",children:"\u72B6\u614B"}),u("th",{scope:"col",className:"px-3 py-2",children:"\u6B62\u307E\u3063\u305F\u6BB5"}),u("th",{scope:"col",className:"px-3 py-2",children:"\u958B\u59CB"}),u("th",{scope:"col",className:"px-3 py-2",children:"\u7D42\u4E86"}),u("th",{scope:"col",className:"px-3 py-2",children:"\u8981\u6C42\u8005"}),t!==void 0&&u("th",{scope:"col",className:"px-3 py-2",children:u("span",{className:"sr-only","data-testid":"pipeline-recent-runs-action-header",children:"\u64CD\u4F5C"})})]})}),u("tbody",{children:e.map(n=>{let r=Gt(n),o=qt[r];return S("tr",{className:"border-slate-100 border-b border-solid","data-testid":`pipeline-run-row-${n.id}`,"data-status":n.status,children:[S("td",{className:"whitespace-nowrap px-3 py-2 font-mono","data-testid":`pipeline-run-id-${n.id}`,children:["#",n.id]}),S("td",{className:"whitespace-nowrap px-3 py-2 font-mono","data-testid":`pipeline-run-metadata-${n.id}`,children:["#",n.metadataId]}),u("td",{className:"whitespace-nowrap px-3 py-2","data-testid":`pipeline-run-kind-${n.id}`,children:xt[n.documentKind]}),u("td",{className:"whitespace-nowrap px-3 py-2","data-testid":`pipeline-run-trigger-${n.id}`,"data-trigger":n.trigger,children:Vt[n.trigger]}),u("td",{className:"whitespace-nowrap px-3 py-2","data-testid":`pipeline-run-attempt-${n.id}`,children:n.attempt}),u("td",{className:"px-3 py-2",children:u("span",{className:`inline-flex whitespace-nowrap rounded-full px-2 py-0.5 font-semibold text-[11px] ${o.className}`,"data-testid":`pipeline-run-status-${n.id}`,"data-status":n.status,"data-presentation":r,children:o.label})}),u("td",{className:"px-3 py-2","data-testid":`pipeline-run-failed-step-${n.id}`,children:n.failedStepKey===null?"\u2014":Ft[n.failedStepKey].label}),u("td",{className:"whitespace-nowrap px-3 py-2 text-slate-500","data-testid":`pipeline-run-started-${n.id}`,children:u(Jt,{iso:n.startedAt,testId:`pipeline-run-started-value-${n.id}`})}),u("td",{className:"whitespace-nowrap px-3 py-2 text-slate-500","data-testid":`pipeline-run-finished-${n.id}`,children:u(Dt,{iso:n.finishedAt,testId:`pipeline-run-finished-value-${n.id}`})}),u("td",{className:"wrap-anywhere px-3 py-2","data-testid":`pipeline-run-requested-by-${n.id}`,children:n.requestedBy}),t!==void 0&&u("td",{className:"whitespace-nowrap px-3 py-2 text-right",children:u("button",{type:"button",onClick:()=>t(n),"aria-label":`\u5B9F\u884C #${n.id} (\u6587\u66F8 #${n.metadataId}) \u306E\u8A73\u7D30`,className:"whitespace-nowrap rounded-sm border border-slate-300 border-solid bg-white px-2 py-0.5 font-semibold text-[11px] text-slate-700 hover:bg-slate-50","data-testid":`pipeline-run-open-${n.id}`,children:"\u8A73\u7D30"})})]},n.id)})})]})})]})}var qe={metadataId:null,runs:[],selectedRunId:null,isLoading:!1,failure:null};function Pn(e){for(let t of e)for(let n of t.steps){let r=n.provenance;if(r!==null){for(let[o,s]of Object.entries(r))if(typeof s=="string"&&!re(s))return`\u51E6\u7406\u5C65\u6B74\u306E\u8A18\u9332\u306B\u8AAD\u3081\u306A\u3044\u6765\u6B74\u306E\u5024\u304C\u3042\u308A\u307E\u3059 (\u5B9F\u884C ${t.id} \u306E\u6BB5 ${n.sequence} \u306E ${o})\u3002`}}return null}function Nn(e){let[t,n]=U(qe),[r,o]=U(0),s=k(0),a=k(null),l=se(()=>{if(e!==void 0)return(m,g)=>{s.current+=1;let R=s.current;a.current?.abort();let f=new AbortController;a.current=f,o(h=>h+1),n({metadataId:m,runs:[],selectedRunId:g,isLoading:!0,failure:null}),J(()=>e(m,f.signal),h=>({ok:!1,status:null,reason:h})).then(h=>{if(s.current!==R)return;let y=h.ok?Pn(h.value):Rn(h.reason);if(!h.ok||y!==null){n({metadataId:m,runs:[],selectedRunId:g,isLoading:!1,failure:y});return}n({metadataId:m,runs:h.value,selectedRunId:g===null?Tn(h.value):g,isLoading:!1,failure:null})})}},[e]),d=W(m=>{n(g=>({...g,selectedRunId:m}))},[]),c=W(()=>{s.current+=1,a.current?.abort(),a.current=null,n(qe)},[]);return{...t,openRequest:r,open:l,selectRun:d,close:c}}function Tn(e){return e.length===0?null:e[0].id}function En(e){let t=pn(),n=De(),r=De(),o=e.data??t,s=e.fetcher??n,a=e.integrityFetcher??r;return o?u(Ve,{...e,data:o,fetcher:s,integrityFetcher:a}):u("div",{className:"p-8 text-center text-slate-500","data-testid":"storage-admin-loading",children:"\u30C7\u30FC\u30BF\u8AAD\u307F\u8FBC\u307F\u4E2D..."})}function Be(e){return e.data?u(Ve,{...e,data:e.data,fetcher:e.fetcher??He,integrityFetcher:e.integrityFetcher??He}):u(En,{...e})}import{AuthzDeniedError as We}from"@aiquants/authz-core";import{formatCount as jn}from"@aiquants/console-ui/core";import{assertSystemParameterInRange as Un,INTEGRITY_COMMAND_CODES as Dn,IntegrityAuditOverviewSchema as Mn,IntegrityCommandFailureSchema as Hn,IntegrityCommandReplySchema as $n,IntegrityRunModeSchema as Ye,integrityCommandFailureCodeOf as Kn,isEnrichmentStageKey as qn,PipelineRunSummarySchema as Vn,PipelineStepMetricSchema as Bn}from"@aiquants/enrichment-core";import{CLOUD_CAPABLE_CAPABILITIES as Qn,ConfidentialityLevelSchema as Ee,GovernedCapabilitySchema as Gn}from"@aiquants/governance-core";import{z as w}from"zod";var Ne=3e3;function F(e){return Math.round(performance.now()-e)}function N(e){return typeof e=="string"&&re(e)?e:null}function L(e){let t=globalThis.process;return t===void 0?void 0:t.env[e]}function ae(e,t){let n=e?.trim();if(!n)throw new Error(`${t} is not configured; this probe will not guess an endpoint to send credentials to.`);return n}function Qe(e,t,n){let r=e??(t?.trim()?Number(t):Number.NaN);if(!Number.isInteger(r)||r<=0||r>65535)throw new Error(`${n} is not configured with a valid port; this probe will not guess one.`);return r}function Ge(e,t){if(e!==void 0)return e;let n=t?.trim().toLowerCase();if(!(n===void 0||n===""))return n==="1"||n==="true"||n==="yes"||n==="on"}function ze(e){let t=e.trim().split("://",1)[0]?.toLowerCase();if(t&&e.includes("://"))return t.endsWith("s")||t.includes("+s")}function _n(e){let n=e.split("://").slice(-1)[0].split("/",1)[0],r=n.split(":").pop();if(!r||r===n)return;let o=Number(r);return Number.isInteger(o)&&o>0&&o<=65535?o:void 0}async function Pe(e,t){let n;try{return await Promise.race([e,new Promise((r,o)=>{n=setTimeout(()=>o(new Error(`Probe timed out after ${t}ms`)),t)})])}finally{clearTimeout(n)}}async function Cn(e){let t=e?.qdrantApiKey??L("QDRANT_API_KEY")??"",n=e?.timeoutMs??Ne,r=performance.now(),o="";try{o=ae(e?.qdrantUrl??L("QDRANT_URL"),"QDRANT_URL");let s={};t&&(s["api-key"]=t);let[a,l]=await Promise.all([fetch(`${o}/`,{headers:s,signal:AbortSignal.timeout(n)}),fetch(`${o}/collections`,{headers:s,signal:AbortSignal.timeout(n)})]);if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);if(!l.ok)throw new Error(`HTTP ${l.status}: ${l.statusText} (/collections)`);let d=await a.json(),c=F(r),g=(await l.json()).result?.collections?.length??0;return{serviceName:"Qdrant",category:"vector",status:"connected",version:N(d.version),endpoint:o,latencyMs:c,details:{engine:N(d.title),collectionsCount:g,restPort:_n(o)??null,tls:ze(o)??null}}}catch(s){let a=F(r),l=s instanceof Error?s.message:String(s);return{serviceName:"Qdrant",category:"vector",status:"error",version:null,endpoint:o,latencyMs:a,details:{},errorMessage:l}}}async function xn(e){let t=e?.timeoutMs??Ne,n=performance.now(),r=N(e?.neo4jBoltUri??L("NEO4J_URI")),o=r===null?"":r;try{let s=e?.graphReader;if(!s)throw new Error("Graph reader not configured");let a=e?.tenantId,[l,d]=await Promise.all([Pe(s("CALL dbms.components() YIELD versions, edition RETURN versions[0] AS version, edition",{}),t),Pe(a?s("MATCH (n {tenantId: $tenantId}) RETURN count(n) AS node_count",{tenantId:a}):s("RETURN null AS node_count",{}),t)]);if(!l.ok)throw new Error(l.reason);if(!d.ok)throw new Error(d.reason);let[c,m]=l.rows[0]??[],g=d.rows[0]?.[0],R=F(n);return{serviceName:"Neo4j",category:"graph",status:"connected",version:N(c),endpoint:o,latencyMs:R,details:{edition:N(m),boltUri:r,nodeCount:typeof g=="number"?g:null,tls:r===null?null:ze(r)??null}}}catch(s){let a=F(n),l=s instanceof Error?s.message:String(s);return{serviceName:"Neo4j",category:"graph",status:"error",version:null,endpoint:o,latencyMs:a,details:{},errorMessage:l}}}async function On(e){let t=performance.now(),n="",r=Ge(e?.redisTls,L("REDIS_TLS")),o=Number.NaN;try{let s=e?.redisClient;if(!s)throw new Error("Redis client not configured");let a=ae(e?.redisHost??L("REDIS_HOST"),"REDIS_HOST");o=Qe(e?.redisPort,L("REDIS_PORT"),"REDIS_PORT"),n=`${r===!1?"redis":"rediss"}://${a}:${o}`,await s.ping();let l=await s.info("server"),d=N(l.match(/redis_version:([^\r\n]+)/)?.[1]),c=null;if(typeof s.dbSize=="function")try{c=await s.dbSize()}catch{c=null}let m=F(t);return{serviceName:"Redis",category:"cache",status:"connected",version:d,endpoint:n,latencyMs:m,details:{totalKeys:c,port:o,tls:r??null,database:0}}}catch(s){let a=F(t),l=s instanceof Error?s.message:String(s);return{serviceName:"Redis",category:"cache",status:"error",version:null,endpoint:n,latencyMs:a,details:{},errorMessage:l}}}function kn(e){let t=e.match(/Microsoft SQL Server \d+ \([^)]+\)/);return N(t===null?e.substring(0,30):t[0].replace("Microsoft SQL Server ",""))}async function Ln(e){let t=performance.now(),n="",r=Ge(e?.sqlServerTls,L("SQL_SERVER_TLS")),o=Number.NaN;try{let s=e?.sqlServerExecute;if(!s)throw new Error("SQL Server executor not configured");let a=ae(e?.sqlServerHost??L("SQL_SERVER_HOST"),"SQL_SERVER_HOST");o=Qe(e?.sqlServerPort,L("SQL_SERVER_PORT"),"SQL_SERVER_PORT"),n=`${a}:${o}`;let l=await s(),d=N(l.db_name),c=N(l.version),m=c===null?null:N(c.split(`
2
- `)[0]),g=m===null?null:kn(m),R=F(t);return{serviceName:"SQL Server",category:"database",status:"connected",version:g,endpoint:n,latencyMs:R,details:{database:d,port:o,tls:r??null,fullVersion:m}}}catch(s){let a=F(t),l=s instanceof Error?s.message:String(s);return{serviceName:"SQL Server",category:"database",status:"error",version:null,endpoint:n,latencyMs:a,details:{},errorMessage:l}}}async function Fn(e){let t=e?.timeoutMs??Ne,n=performance.now(),r="";try{r=ae(e?.backendApiHost??L("BACKEND_API_HOST"),"BACKEND_API_HOST");let o=await fetch(`${r}/openapi.json`,{signal:AbortSignal.timeout(t)});if(!o.ok)throw new Error(`HTTP ${o.status}: ${o.statusText}`);let s=await o.json(),a=Object.keys(s.paths??{}).length,l=F(n);return{serviceName:"AI Quant API",category:"api",status:"connected",version:N(s.info?.version),endpoint:r,latencyMs:l,details:{title:N(s.info?.title),endpointsCount:a}}}catch(o){let s=F(n),a=o instanceof Error?o.message:String(o);return{serviceName:"AI Quant API",category:"api",status:"error",version:null,endpoint:r,latencyMs:s,details:{},errorMessage:a}}}async function Je(e){let[t,n,r,o,s]=await Promise.all([Cn(e),xn(e),On(e),Ln(e),Fn(e)]),a=t.status==="connected"&&n.status==="connected"&&r.status==="connected"&&o.status==="connected"&&s.status==="connected";return{services:{qdrant:t,neo4j:n,redis:r,sqlServer:o,quantsApi:s},allHealthy:a,checkedAt:new Date().toISOString()}}var zn=w.object({templateText:w.string(),modelName:w.string(),temperature:w.number(),maxOutputTokens:w.number(),responseSchema:w.union([w.record(w.string(),w.unknown()),w.string(),w.null()]).optional(),endpointBaseUrl:w.string().nullable()}).strict(),Jn=w.discriminatedUnion("mode",[w.object({mode:Ye.extract(["SCAN"]),basisRunUid:w.null()}).strict(),w.object({mode:Ye.extract(["REPAIR"]),basisRunUid:w.string().uuid()}).strict()]),Wn=w.object({runUid:w.string().uuid()}).strict();function Xe(e){return e==="start_integrity_run"?"start":e==="cancel_integrity_run"?"cancel":null}function B(e,t){return e.issues.map(n=>`${n.path.length===0?t:n.path.join(".")}: ${n.message}`).join("; ")}function Yn(e,t){if(e==="bool")return t==="true"||t==="false"?null:"paramValue must be 'true' or 'false' for a bool parameter";if(e==="int")return/^[+-]?\d+$/.test(t)&&Number.isSafeInteger(Number(t))?null:"paramValue must be a safe integer for an int parameter";if(e==="float")return t.trim()!==""&&Number.isFinite(Number(t))?null:"paramValue must be a finite number for a float parameter";if(e==="json")try{return JSON.parse(t),null}catch{return"paramValue must be valid JSON for a json parameter"}return null}function Zn(e){let t=Vn.array().safeParse(e);if(!t.success)throw new Error(`getRecentPipelineRuns answered something that is not a run summary: ${B(t.error,"getRecentPipelineRuns")}`);return t.data}function Xn(e){let t=Bn.array().safeParse(e);if(!t.success)throw new Error(`getPipelineStepMetrics answered something that is not a step metric: ${B(t.error,"getPipelineStepMetrics")}`);let n=new Set;for(let r of t.data){let o=`${r.documentKind}/${r.stepKey}`;if(n.has(o))throw new Error(`getPipelineStepMetrics answered more than one metric for (documentKind, stepKey) = (${r.documentKind}, ${r.stepKey})`);n.add(o)}return t.data}function er(e){if(!Number.isSafeInteger(e)||e<=0)throw new Error(`pipelineStepMetricWindow must be a positive safe integer, got ${String(e)}`);return e}async function tr(e,t){let n;try{n=await e.readIntegrityAuditOverview(t)}catch(o){return{ok:!1,status:null,reason:o instanceof Error?o.message:String(o)}}let r=Mn.safeParse(n);return r.success?{ok:!0,value:r.data}:{ok:!1,status:null,reason:`readIntegrityAuditOverview answered something that is not an audit overview: ${B(r.error,"readIntegrityAuditOverview")}`}}function nr(e){return!Array.isArray(e)||e.length===0?"orderedRuleIds must be a non-empty array of rule ids":e.every(t=>typeof t=="number"&&Number.isSafeInteger(t)&&t>0)?new Set(e).size!==e.length?"orderedRuleIds must not name a rule twice":null:"orderedRuleIds must contain positive integers only"}function et(e){let{store:t,healthProbeOptions:n,resourceKey:r="storage_admin",requireUser:o,requirePermission:s,resolveTenantId:a,authorizeIngest:l,canReadIntegrityFindings:d,canUpdateKnowledge:c}=e;async function m(R){let{request:f}=R;if(!await o(f))throw new Response("\u8A8D\u8A3C\u304C\u5FC5\u8981\u3067\u3059\u3002",{status:401});try{await s(f,{resourceKey:r,action:"read"})}catch(ee){throw ee instanceof We?new Response("\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093\u3002",{status:403}):ee}let y=await a(f),M=er(t.pipelineStepMetricWindow),[j,T,E]=await Promise.all([t.getFeatureFlags(y),t.getSystemParameters(y),t.getSyncCounts(y)]),_={featureFlags:j,systemParameters:T,syncCounts:E},[H,$,K,C,I,x,Z,O,Q,le,ue,de,ce,p,q,pe,X,me,A,V,ge]=await Promise.all([t.getConfidentialityPolicies(y),t.getTranscriptionVocabulary(y),t.getTranscriptionReferences(y),t.getUnresolvedReferenceUris(y),t.getPoliciesMissingDestination(y),t.getPromptTemplates(y),t.getClassificationRules(y),t.getFailedSyncItems(y),t.getGraphSchema(y),tr(t,y),d(f),c(f),t.getUnresolvedEntities(y),t.getQdrantCollections(y),Je({...n,tenantId:y}),t.getRecentIngestItems(y),t.getOntologyStatus(y,_),t.getEnrichmentStrategies(y),t.getStrategyVariants(y),t.getPipelineStepMetrics(y),t.getRecentPipelineRuns(y)]),ye=t.getCircuitBreakerStatus();return{tenantId:y,featureFlags:_.featureFlags,confidentialityPolicies:H,transcriptionVocabulary:$,transcriptionReferences:K,unresolvedReferenceUris:C,policiesMissingDestination:I,systemParameters:_.systemParameters,promptTemplates:x,classificationRules:Z,classificationRuleConsumer:t.classificationRuleConsumer??null,syncCounts:_.syncCounts.counts,totalFiles:_.syncCounts.total,failedSyncItems:O,circuitBreakerStatus:ye,pipelineStepMetrics:Xn(V),pipelineStepMetricWindow:M,recentPipelineRuns:Zn(ge),displayTimeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,graphSchema:Q,enrichmentStrategies:me,strategyVariants:A,integrityAudit:le,canReadIntegrityFindings:ue,canUpdateKnowledge:de,unresolvedEntities:ce,qdrantCollections:p,systemHealth:q,recentIngestItems:pe,ontologyStatus:X}}async function g(R){let{request:f}=R,h=await o(f);if(!h)return Response.json({error:"\u8A8D\u8A3C\u304C\u5FC5\u8981\u3067\u3059\u3002"},{status:401});if(h.email.trim()==="")return Response.json({error:"\u64CD\u4F5C\u8005\u3092\u7279\u5B9A\u3067\u304D\u306A\u3044\u305F\u3081\u8A2D\u5B9A\u3092\u5909\u66F4\u3067\u304D\u307E\u305B\u3093\u3002"},{status:403});if(h.accessToken==="")throw new Error("requireUser resolved an operator whose accessToken is an empty string; answer null when the session holds no token the upstream services accept");let y=h.email,M=h.accessToken===null?void 0:h.accessToken;try{await s(f,{resourceKey:r,action:"update"})}catch(C){if(C instanceof We)return await ar(f);throw C}let j=await a(f),T=await f.formData(),E=String(T.get("intent")??"");if(E==="refresh_health")return Response.json({success:!0,refreshed:!0});let _=await sr(t,j,E,T,y);if(_)return _;let H=await ir(t,j,E,T,y,M);if(H)return H;let $=await or(t,j,E,T,M,()=>d(f));if($)return $;if(E==="resolve_entity"){let C=String(T.get("entityId")??""),I=String(T.get("action")??"");if(!C||I!=="merge"&&I!=="promote")return Response.json({error:"Valid entityId and action ('merge' | 'promote') are required"},{status:400});try{return await t.resolveEntity(j,C,I),Response.json({success:!0,entityId:C,action:I})}catch(x){return Response.json({error:x instanceof Error?x.message:String(x)},{status:400})}}let K=await dr(t,j,E,T,y,f,l,M);return K||Response.json({error:`Unknown intent: ${E}`},{status:400})}return{loader:m,action:g}}function Te(e){let t=String(e??"").trim();return t===""?null:t}function oe(e){let t=String(e??"").trim();if(t==="")return null;let n=Number(t);if(!(!Number.isSafeInteger(n)||n<=0))return n}function rr(e){let t=String(e??"").trim();if(t==="")return null;let n=Number(t);if(!(!Number.isFinite(n)||n<=0))return n}async function sr(e,t,n,r,o){if(n==="update_enrichment_strategy"){let s=String(r.get("stage")??"");if(!qn(s))return Response.json({error:"stage must be a canonical enrichment stage key"},{status:400});let a=oe(r.get("strategyId")),l=oe(r.get("domainId"));if(a==null||l===void 0||l===null)return Response.json({error:"strategyId and domainId must be positive integers naming existing rows"},{status:400});let d=String(r.get("enabled")??"")==="true";try{await e.updateEnrichmentStrategy(t,{strategyId:a,domainId:l,stage:s,enabled:d},o)}catch(c){return Response.json({error:c instanceof Error?c.message:"\u53D6\u308A\u8FBC\u307F\u6226\u7565\u3092\u66F4\u65B0\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002"},{status:400})}return Response.json({success:!0,strategyId:a,domainId:l,stage:s,enabled:d})}if(n==="toggle_flag"){let s=String(r.get("flagKey")??""),a=String(r.get("enabled")??"")==="true";if(!s)return Response.json({error:"flagKey is required"},{status:400});let l=await e.getFeatureFlags(t);return Object.hasOwn(l,s)?(await e.toggleFeatureFlag(t,s,a,o),Response.json({success:!0,flagKey:s,enabled:a})):Response.json({error:`flagKey names no feature flag of this tenant: ${s}`},{status:400})}if(n==="update_confidentiality_policy"){let s=String(r.get("confidentialityLevel")??""),a=String(r.get("capability")??"");if(!(Ee.safeParse(s).success&&Gn.safeParse(a).success))return Response.json({error:"confidentialityLevel and capability must be canonical values"},{status:400});let l=String(r.get("allowCloudProvider")??"")==="true";if(l&&!Qn.includes(a))return Response.json({error:`${a} sends nothing outside the deployment, so it has no cloud permission to grant`},{status:400});let d=String(r.get("promptKey")??"");return await e.updateConfidentialityPolicy(t,{confidentialityLevel:s,capability:a,isEnabled:String(r.get("isEnabled")??"")==="true",allowCloudProvider:l,promptKey:d===""?null:d},o),Response.json({success:!0,confidentialityLevel:s,capability:a})}if(n==="save_transcription_term"){let s=String(r.get("term")??"").trim();if(!s)return Response.json({error:"term is required"},{status:400});let a=rr(r.get("boost"));if(a===void 0)return Response.json({error:"boost must be a number greater than zero, or absent to let the service decide"},{status:400});let l=oe(r.get("id"));if(l===void 0)return Response.json({error:"id must be a positive integer naming an existing row, or absent for a new one"},{status:400});try{await e.saveTranscriptionTerm(t,{id:l,term:s,reading:Te(r.get("reading")),boost:a,domainKey:Te(r.get("domainKey")),isActive:String(r.get("isActive")??"true")==="true"},o)}catch(d){return Response.json({error:d instanceof Error?d.message:"\u8A9E\u5F59\u3092\u4FDD\u5B58\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002"},{status:400})}return Response.json({success:!0,term:s})}if(n==="save_transcription_reference"){let s=String(r.get("fileUri")??"").trim();if(!s)return Response.json({error:"fileUri is required"},{status:400});let a=oe(r.get("id"));if(a===void 0)return Response.json({error:"id must be a positive integer naming an existing row, or absent for a new one"},{status:400});try{await e.saveTranscriptionReference(t,{id:a,fileUri:s,domainKey:Te(r.get("domainKey")),isActive:String(r.get("isActive")??"true")==="true"},o)}catch(l){return Response.json({error:l instanceof Error?l.message:"\u53C2\u7167\u8CC7\u6599\u3092\u4FDD\u5B58\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002"},{status:400})}return Response.json({success:!0,fileUri:s})}if(n==="update_parameter"){let s=String(r.get("paramKey")??""),a=String(r.get("paramValue")??"");if(!s)return Response.json({error:"paramKey is required"},{status:400});let l=(await e.getSystemParameters(t)).find(c=>c.key===s);if(l===void 0)return Response.json({error:`paramKey names no parameter of this tenant: ${s}`},{status:400});let d=Yn(l.data_type,a);if(d!==null)return Response.json({error:d},{status:400});try{Un(s,Number(a))}catch(c){return Response.json({error:c.message},{status:400})}return await e.updateSystemParameter(t,s,a,o),Response.json({success:!0,paramKey:s,paramValue:a})}if(n==="update_prompt"){let s=String(r.get("templateKey")??""),a=String(r.get("payload")??"{}"),l;try{l=JSON.parse(a)}catch{return Response.json({error:"Invalid JSON payload"},{status:400})}if(!s)return Response.json({error:"templateKey is required"},{status:400});let d=zn.safeParse(l);if(!d.success)return Response.json({error:`payload does not carry a prompt template update: ${B(d.error,"payload")}`},{status:400});let c=d.data;try{return await e.updatePromptTemplate(t,s,c,o),Response.json({success:!0,templateKey:s})}catch(m){return Response.json({error:m instanceof Error?m.message:String(m)},{status:400})}}if(n==="reorder_rules"){let s=String(r.get("orderedRuleIds")??"[]"),a;try{a=JSON.parse(s)}catch{return Response.json({error:"Invalid orderedRuleIds JSON"},{status:400})}let l=nr(a);if(l!==null)return Response.json({error:l},{status:400});let d=a;return await e.reorderClassificationRules(t,d,o),Response.json({success:!0,orderedRuleIds:d})}return null}async function ir(e,t,n,r,o,s){if(n==="retry_job"){let a=String(r.get("fileId")??"");if(!a)return Response.json({error:"fileId is required"},{status:400});try{return await e.retrySyncItem(t,a,o,s),Response.json({success:!0,fileId:a})}catch(l){return Response.json({error:l instanceof Error?l.message:String(l)},{status:400})}}if(n==="retry_all_failed")try{let{requeued:a,skipped:l}=await e.retryAllFailedSyncItems(t,o,s);return Response.json({success:!0,requeued:a,skipped:l})}catch(a){return Response.json({error:a instanceof Error?a.message:String(a)},{status:400})}return null}function Y(e,t,n){let r=Hn.parse({command:e,code:t,status:n}),o=Dn.find(s=>s.code===r.code);return Response.json({failure:r},{status:o===void 0?502:o.status})}async function ar(e){let t=await e.formData().catch(()=>null),n=t===null?null:Xe(t.get("intent"));return n===null?Response.json({error:"\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093\u3002"},{status:403}):Y(n,"FORBIDDEN",null)}async function Ze(e,t){let n;try{n=$n.parse(await t())}catch{return Y(e,"UPSTREAM_FAILED",null)}return n.ok?Response.json({success:!0,runUid:n.runUid}):Y(e,Kn(e,n.status,n.errorCode),n.status)}async function or(e,t,n,r,o,s){let a=Xe(n);if(a==="start"){let l=Jn.safeParse({mode:r.get("mode"),basisRunUid:r.get("basisRunUid")});if(!l.success)return Response.json({error:`start_integrity_run takes mode SCAN without basisRunUid, or mode REPAIR with basisRunUid (a UUID): ${B(l.error,"form")}`},{status:400});let{mode:d,basisRunUid:c}=l.data;return o===void 0||d==="REPAIR"&&!await s()?Y(a,"FORBIDDEN",null):await Ze(a,()=>e.startIntegrityRun(t,d,c,o))}if(a==="cancel"){let l=Wn.safeParse({runUid:r.get("runUid")});return l.success?o===void 0?Y(a,"FORBIDDEN",null):await Ze(a,()=>e.cancelIntegrityRun(t,l.data.runUid,o)):Response.json({error:`cancel_integrity_run takes runUid (a UUID): ${B(l.error,"form")}`},{status:400})}return null}function lr(e){if(typeof e!="object"||e===null)return"payload must be an object";let t=e;if(typeof t.fileUri!="string"||t.fileUri.trim()==="")return"payload.fileUri is required";if(!Ee.safeParse(t.confidentialityLevel).success)return`payload.confidentialityLevel must be one of ${Ee.options.join(", ")}`;let r=t.departmentId;return r!=null&&(typeof r!="number"||!Number.isInteger(r))?"payload.departmentId must be an integer or null":null}function ur(e){try{return jn(e,ne),null}catch{return`inspectFileUri answered a fileSize that is not a byte count (a non-negative safe integer): ${String(e)}`}}async function dr(e,t,n,r,o,s,a,l){if(n==="ingest_document"){let d=String(r.get("payload")??"");if(!d)return Response.json({error:"payload is required"},{status:400});let c;try{c=JSON.parse(d)}catch{return Response.json({error:"Invalid JSON payload"},{status:400})}let m=lr(c);if(m)return Response.json({error:m},{status:400});let g=c,R=await a(s,g);if(R!==null)return Response.json({error:R},{status:403});try{let f=l===void 0?await e.ingestDocument(t,g,o):await e.ingestDocument(t,g,o,l);return Response.json({success:!0,result:f})}catch(f){return Response.json({error:f instanceof Error?f.message:String(f)},{status:400})}}if(n==="inspect_uri"){let d=String(r.get("fileUri")??"").trim();if(!d)return Response.json({error:"fileUri is required"},{status:400});if(!e.inspectFileUri)return Response.json({error:"inspectFileUri is not implemented"},{status:501});let c;try{c=l===void 0?await e.inspectFileUri(t,d):await e.inspectFileUri(t,d,l)}catch(g){return Response.json({error:g instanceof Error?g.message:String(g)},{status:400})}let m=ur(c.fileSize);return m!==null?Response.json({error:m},{status:400}):Response.json({success:!0,inspection:c})}return null}function Br(e){let t=et(e);return{loader:t.loader,action:t.action,View:Be,server:t}}export{Be as StorageAdminConsoleView,Je as checkAllSystemHealth,Fn as checkBackendApiHealth,xn as checkNeo4jHealth,Cn as checkQdrantHealth,On as checkRedisHealth,Ln as checkSqlServerHealth,Br as createStorageAdminApp,et as createStorageAdminServer};
1
+ import{Card as Ht,ConsoleUiRoot as Mt,ResourceFailed as $t,reasonAside as tt,resolveConsoleUiLabels as Kt,useFocusRescue as qt}from"@aiquants/console-ui";import{DOCUMENT_KIND_LABELS as Bt,EnrichmentSyncStatusSchema as Vt,GRAPH_INDEX_LIMITS as Gt,IntegrityRunModeSchema as Qt,PIPELINE_STEPS as zt}from"@aiquants/enrichment-core";import{DocumentIngestConsole as Jt,EnrichmentStrategyBoard as Wt,FinishedInstant as Yt,InfrastructureHealthMonitor as Zt,MetadataSearchWorkbench as Xt,ModelComparisonWorkbench as en,OntologyStatusCard as tn,PIPELINE_RUN_STATUS_PRESENTATION as nn,PIPELINE_TRIGGER_LABELS as rn,PipelineFlowViewer as sn,PipelineRunInspector as an,pipelineRunPresentationKey as on,QdrantStorageCard as ln,RecordedInstant as un,SyncStatusMonitor as dn}from"@aiquants/enrichment-react";import{ClassificationRuleEditor as cn,ConfidentialityPolicyBoard as pn,DocumentAuthorityRegistry as mn,FeatureFlagBoard as gn,GovernanceDryRunConsole as yn,integrityFailureNeedsOverviewReread as fn,KnowledgeGraphExplorer as bn,PolicyConflictQueue as Sn,PolicyConflictSummaryCard as Rn,PromptTemplateConsole as hn,SystemParameterTable as vn,TranscriptionAdaptationBoard as In,TriStoreIntegrityAudit as wn}from"@aiquants/governance-react";import{Fragment as An,useCallback as Z,useEffect as xe,useMemo as le,useRef as O,useState as L}from"react";import{useFetcher as Qe,useLoaderData as Pn,useRevalidator as Tn,useSearchParams as Nn}from"react-router";var ae="ja-JP";var Tt=/[^\s\x1c-\x1f\x85\ufeff]/;function oe(e){return Tt.test(e)}function Y(e,t){return new Promise(n=>n(e())).catch(n=>t(n instanceof Error?n.message:String(n)))}import{beginReload as Nt,keepLastGood as _t}from"@aiquants/console-ui/core";import{isStrictlyEarlier as Et}from"@aiquants/enrichment-core";import{useCallback as he,useEffect as Be,useRef as Ie,useState as Ct,useSyncExternalStore as Ot}from"react";var xt=2e3,kt=1e4;function ve(e,t){if(t.ok&&e.kind==="ready"&&Et(t.value.readAt,e.value.readAt))return e;let n=!t.ok&&t.status===403&&e.kind==="ready";return _t(n?{kind:"loading"}:e,t)}var Lt=401;function Ft(e){return e.kind==="failed"||e.refreshFailure!==null&&e.refreshFailure.status===Lt?null:e.value.active}function Ve(e,t){let[n,r]=Ct(()=>({loaded:e,overview:ve({kind:"loading"},e)}));n.loaded!==e&&r({loaded:e,overview:ve(n.overview,e)});let o=Ie(t);o.current=t;let s=Ie(null);Be(()=>()=>s.current?.abort(),[]);let a=he((c,m)=>Y(m,g=>({ok:!1,status:null,reason:g})).then(g=>{c.aborted||r(h=>({loaded:h.loaded,overview:ve(h.overview,g)}))}),[]),l=he(()=>{let c=new AbortController;s.current=c,r(m=>({loaded:m.loaded,overview:Nt(m.overview,"reload")})),a(c.signal,()=>o.current(c.signal))},[a]),d=he(c=>a(c,()=>o.current(c)),[a]);return{overview:n.overview,reload:l,poll:d}}function jt(e){return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)}function Dt(){return document.visibilityState==="visible"}function Ut(){return!0}function Ge(e,t,n){let r=Ot(jt,Dt,Ut),o=t&&r,s=Ie(o),a=e.kind==="ready",l=Ft(e),d=l===null?null:l.run.runUid,c=l===null?!1:l.isStale;Be(()=>{let m=o&&!s.current;if(s.current=o,!o||d===null&&!(m&&a))return;let g=new AbortController,h=c?kt:xt,f,v=async()=>{await n(g.signal),!g.signal.aborted&&d!==null&&(f=setTimeout(v,h))};return f=setTimeout(v,m?0:h),()=>{g.abort(),clearTimeout(f)}},[o,a,d,c,n])}var Ae={columns:2,className:"grid-cols-2",spanClassNames:{1:"col-span-1",2:"col-span-2"}},Pe={columns:4,className:"@min-[41.5rem]:grid-cols-4",spanClassNames:{1:"@min-[41.5rem]:col-span-1",2:"@min-[41.5rem]:col-span-2",3:"@min-[41.5rem]:col-span-3",4:"@min-[41.5rem]:col-span-4"}},Te={className:"@min-[82rem]:grid-flow-col @min-[82rem]:auto-cols-fr @min-[82rem]:grid-cols-none",lastTabClassName:"@min-[82rem]:col-auto"};function Ne(e,t){let n=t%e.columns,r=n===0?1:e.columns-n+1;return e.spanClassNames[r]}import{jsx as u,jsxs as S}from"react/jsx-runtime";var ze="tab",Ee={key:"knowledge-authority",phrases:["\u6A29\u5A01\u53F0\u5E33 & \u898F\u7A0B\u885D\u7A81"]},Ce={key:"pipeline",phrases:["\u30D1\u30A4\u30D7\u30E9\u30A4\u30F3 & \u63A5\u7D9A\u72B6\u614B"]},Oe={key:"parameters",phrases:["\u30E2\u30C7\u30EB & \u30D1\u30E9\u30E1\u30FC\u30BF\u8A2D\u5B9A"]},Je="\u30A8\u30F3\u30EA\u30C3\u30C1\u30E1\u30F3\u30C8\u540C\u671F\u30B9\u30C6\u30FC\u30BF\u30B9",_n="\u9001\u4FE1\u4E2D\u306E\u64CD\u4F5C (\u540C\u671F\u306E\u518D\u8A66\u884C\u306A\u3069) \u306E\u7D50\u679C\u3092\u5F85\u3063\u3066\u3044\u308B\u305F\u3081\u3001\u9001\u3063\u3066\u3044\u307E\u305B\u3093\u3002\u7D50\u679C\u304C\u51FA\u3066\u304B\u3089\u62BC\u3057\u76F4\u3057\u3066\u304F\u3060\u3055\u3044\u3002",U=[{key:"search",phrases:["\u30E1\u30BF\u30C7\u30FC\u30BF\u691C\u7D22","\u30EF\u30FC\u30AF\u30D9\u30F3\u30C1"]},{key:"ingest",phrases:["\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8","\u53D6\u308A\u8FBC\u307F & \u30E1\u30BF\u751F\u6210"]},Ce,{key:"knowledge-graph",phrases:["\u30CA\u30EC\u30C3\u30B8\u30B0\u30E9\u30D5","\u63A2\u7D22"]},Oe,{key:"prompts",phrases:["\u30D7\u30ED\u30F3\u30D7\u30C8 & \u30C9\u30E9\u30A4\u30E9\u30F3"]},Ee,{key:"data-retention",phrases:["\u30C7\u30FC\u30BF\u4FDD\u6301 & \u6574\u5408\u6027\u76E3\u67FB"]}];function _e(e){return e.phrases.join("")}function En(e){return e!==null&&U.some(t=>t.key===e)}var Cn="Tri-Store \u30C7\u30FC\u30BF\u6574\u5408\u6027\u76E3\u67FB";function On(e){return`\u76E3\u67FB\u306E\u6982\u6CC1\u3092\u8AAD\u3081\u307E\u305B\u3093\u3067\u3057\u305F${tt(e)}\u3002`}var xn=Kt("ja");function kn(e){return e.status===403?xn.forbiddenBecause("\u51E6\u7406\u5C65\u6B74\u3092\u95B2\u89A7\u3059\u308B\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093\u3002",e.reason):`\u51E6\u7406\u5C65\u6B74\u3092\u8AAD\u3081\u307E\u305B\u3093\u3067\u3057\u305F${tt(e.reason)}\u3002`}var We={state:"idle",formData:null,data:null,submit:()=>Promise.resolve()};function nt({data:e,fetcher:t,integrityFetcher:n,renderHeader:r,graphTraversal:o,onBrowseGraphNodes:s,onSimulateGovernance:a,onRefreshIngestQueue:l,onSearch:d,onLoadDocumentRuns:c,onCompareVariants:m,loadIntegrityOverview:g,loadIntegrityFindings:h,policyConflicts:f,documentAuthority:v}){let[y,H]=L(null),[D,N]=L(null),[_,E]=L(!1),M=le(()=>{if(s!==void 0)return(i,b)=>{E(!0),Y(()=>s(i,b),R=>({ok:!1,reason:R})).then(R=>{E(!1),N(R.ok?null:R.reason),R.ok&&H(R.page)})}},[s]),[$,K]=Nn(),C=$.get(ze),I=En(C)?C:U[0].key,x=i=>{K(b=>{let R=new URLSearchParams(b);return R.set(ze,i),R},{replace:!1,preventScrollReset:!0})},ee=Fn(e.recentIngestItems,l,I==="ingest"),k=Ve(e.integrityAudit,g);Ge(k.overview,I==="data-retention",k.poll);let G=O(null),te=qt(()=>G.current),[ce,pe]=L(0),me=Z(()=>pe(i=>i+1),[]),p=ee===null?e:{...e,recentIngestItems:[...ee]},q=O({}),ge=Z(()=>q.current[I]??null,[I]),ne=le(()=>jn(e.enrichmentStrategies),[e.enrichmentStrategies]),ye=le(()=>e.strategyVariants.map(Dn),[e.strategyVariants]),A=Mn(c),B=A.open,re=B===void 0?void 0:i=>B(i,null),fe=B===void 0?void 0:i=>B(i.metadataId,i.id),se=(i,b)=>{let R=U.length-1,P;if(i.key==="ArrowRight"||i.key==="ArrowDown")P=b===R?0:b+1;else if(i.key==="ArrowLeft"||i.key==="ArrowUp")P=b===0?R:b-1;else if(i.key==="Home")P=0;else if(i.key==="End")P=R;else return;i.preventDefault();let ie=U[P].key;x(ie),q.current[ie]?.focus()},De={...p.featureFlags};if(t.formData&&t.formData.get("intent")==="toggle_flag"){let i=String(t.formData.get("flagKey")??""),b=String(t.formData.get("enabled")??"")==="true";i&&(De[i]=b)}let mt=t.data&&"inspection"in t.data?t.data.inspection:void 0,Q=t.state==="idle"?null:t.formData?.get("intent"),gt=Q==="inspect_uri",yt=Q==="ingest_document",ft=Q==="retry_job"||Q==="retry_all_failed",bt=Q==="resolve_entity",Ue=n.state==="idle"?null:n.formData?.get("intent"),St=Ue==="start_integrity_run"?{kind:"starting",mode:Qt.parse(n.formData?.get("mode"))}:Ue==="cancel_integrity_run"?{kind:"cancelling"}:{kind:"idle"},Rt=Tn(),[ht,be]=L(null),He=I!=="data-retention";xe(()=>{He&&be(null)},[He]);let vt=i=>{let b=i?.failure;if(b===void 0){be(null);return}be(R=>({failure:b,occurrence:R===null?1:R.occurrence+1})),fn(b)&&Rt.revalidate()},[z,J]=L(null),It=i=>{if(t.state!=="idle"){J({metadataId:i,intent:"retry_job",status:"refused",error:_n});return}J({metadataId:i,intent:"retry_job",status:"pending",error:null}),t.submit({intent:"retry_job",fileId:String(i)},{method:"post"})},[Me,Se]=L("console"),wt=(i,b)=>{if(z!==null&&z.status==="pending"){if(b==="retry_job"){let R=i?.error;J(R===void 0?{...z,status:"accepted",error:null}:{...z,status:"refused",error:R}),Se("inspector");return}J(null)}Se("console")},{settledIntent:At,submitAndAwait:$e}=Ze(t,wt);Ze(n,i=>{Se("integrity"),vt(i)});let Ke=Me==="inspector"?void 0:(Me==="console"?t:n).data?.error,Re=i=>{x(i),q.current[i]?.focus()},qe=O(null),Pt={strategies:{label:_e(Ce),onOpen:()=>Re(Ce.key),closesInspector:!0},projectionPolicy:{label:_e(Oe),onOpen:()=>Re(Oe.key),closesInspector:!0},failedSync:{label:Je,onOpen:()=>qe.current?.focus(),closesInspector:!1}},W=At==="retry_all_failed"&&t.data?.skipped!==void 0&&t.data.requeued!==void 0?{requeued:t.data.requeued,skipped:t.data.skipped}:null;return u(Mt,{locale:"ja",formatLocale:ae,timeZone:p.displayTimeZone,testId:"storage-admin-console-ui",children:S("div",{className:"container mx-auto space-y-6 p-6 font-sans text-slate-900","data-testid":"storage-admin-console",children:[Ke&&u("div",{className:"rounded-lg border border-red-200 border-solid bg-red-50 p-4 font-medium text-red-700 text-sm shadow-sm",role:"alert","data-testid":"storage-admin-error-alert",children:Ke}),r?r({title:"\u30B9\u30C8\u30EC\u30FC\u30B8 AI \u30A8\u30F3\u30EA\u30C3\u30C1\u30E1\u30F3\u30C8 & \u30AC\u30D0\u30CA\u30F3\u30B9\u904B\u7528\u7BA1\u7406",tenantId:p.tenantId}):S("header",{className:"flex flex-col justify-between gap-2 border-slate-200 border-b border-solid pb-4 md:flex-row md:items-center",children:[S("div",{children:[u("h1",{className:"font-bold text-2xl tracking-tight",children:"\u30B9\u30C8\u30EC\u30FC\u30B8 AI \u30A8\u30F3\u30EA\u30C3\u30C1\u30E1\u30F3\u30C8 & \u30AC\u30D0\u30CA\u30F3\u30B9\u904B\u7528\u7BA1\u7406"}),S("p",{className:"mt-1 text-slate-500 text-sm",children:["\u30C6\u30CA\u30F3\u30C8: ",u("code",{className:"font-semibold text-slate-800",children:p.tenantId})," | \u5168\u30B7\u30B9\u30C6\u30E0\u72B6\u614B\u30FB\u30D1\u30E9\u30E1\u30FC\u30BF\u5236\u5FA1\u30FB\u6574\u5408\u6027\u76E3\u67FB"]})]}),u("div",{className:"flex items-center gap-2",children:S("button",{type:"button","data-testid":"header-health-status-button",onClick:()=>x("pipeline"),className:"inline-flex items-center gap-2 rounded-full border border-slate-200 border-solid bg-slate-50 px-3 py-1.5 font-medium text-slate-700 text-xs transition-colors hover:bg-slate-100",children:[u("span",{className:`h-2 w-2 rounded-full ${p.systemHealth.allHealthy?"bg-emerald-500":"bg-amber-500"}`}),S("span",{children:["\u5468\u8FBA\u6A5F\u80FD: ",p.systemHealth.allHealthy?"\u5168\u30B5\u30FC\u30D3\u30B9\u6B63\u5E38":"\u63A5\u7D9A\u8981\u78BA\u8A8D"]})]})})]}),S("div",{className:"w-full space-y-6",children:[u("div",{className:"@container w-full","data-testid":"storage-admin-tablist-frame",children:u("div",{className:`grid w-full ${Ae.className} ${Pe.className} ${Te.className} gap-1 rounded-xl bg-slate-100 p-1`,role:"tablist","aria-label":"\u904B\u7528\u7BA1\u7406\u30B3\u30F3\u30BD\u30FC\u30EB\u306E\u753B\u9762",children:U.map((i,b)=>{let R=I===i.key;return u("button",{id:`tab-${i.key}`,type:"button",role:"tab",ref:P=>{q.current[i.key]=P},"aria-selected":R,"aria-controls":`panel-${i.key}`,tabIndex:R?0:-1,"data-testid":`tab-trigger-${i.key}`,onKeyDown:P=>se(P,b),onClick:()=>x(i.key),className:`wrap-anywhere break-keep rounded-lg px-3 py-2.5 text-center font-medium text-sm transition-all ${b===U.length-1?`${Ne(Ae,U.length)} ${Ne(Pe,U.length)} ${Te.lastTabClassName}`:""} ${R?"bg-white text-slate-900 shadow-sm":"text-slate-600 hover:bg-slate-200/50 hover:text-slate-900"}`,children:i.phrases.map((P,ie)=>S(An,{children:[ie>0&&u("wbr",{}),P]},P))},i.key)})})}),A.metadataId!==null&&u(an,{metadataId:A.metadataId,runs:A.runs,selectedRunId:A.selectedRunId,onSelectRun:A.selectRun,isLoading:A.isLoading,failure:A.failure,onClose:A.close,openRequest:A.openRequest,returnFocusFallback:ge}),I==="search"&&S("div",{role:"tabpanel",id:"panel-search","aria-labelledby":"tab-search",className:"space-y-6","data-testid":"tab-content-search",children:[u(Xt,{tenantId:p.tenantId,onSearch:d,circuitBreakerStatus:p.circuitBreakerStatus}),m!==void 0&&u(en,{variants:ye,onCompare:m})]}),I==="ingest"&&u("div",{role:"tabpanel",id:"panel-ingest","aria-labelledby":"tab-ingest",className:"space-y-6","data-testid":"tab-content-ingest",children:u(Jt,{tenantId:p.tenantId,policies:p.confidentialityPolicies,domainOptions:ne,recentItems:p.recentIngestItems,inspectionResult:mt,isInspecting:gt,isSubmitting:yt,onInspectUri:i=>{t.submit({intent:"inspect_uri",fileUri:i},{method:"post"})},onIngestDocument:i=>{t.submit({intent:"ingest_document",payload:JSON.stringify(i)},{method:"post"})},onRetryItem:i=>{t.submit({intent:"retry_job",fileId:String(i)},{method:"post"})},onShowHistory:re})}),I==="pipeline"&&S("div",{role:"tabpanel",id:"panel-pipeline","aria-labelledby":"tab-pipeline",className:"space-y-6","data-testid":"tab-content-pipeline",children:[u(sn,{featureFlags:p.featureFlags,metrics:p.pipelineStepMetrics,metricSampleWindow:p.pipelineStepMetricWindow}),u(Un,{runs:p.recentPipelineRuns,onOpenRun:fe}),u(Wt,{strategies:p.enrichmentStrategies,featureFlags:p.featureFlags,isUpdating:t.state!=="idle",onToggleStage:(i,b,R)=>t.submit({intent:"update_enrichment_strategy",strategyId:String(i.id),domainId:String(i.domainId),stage:b,enabled:String(R)},{method:"post"})}),u(Zt,{health:p.systemHealth,isRefreshing:t.state!=="idle",onRefresh:()=>t.submit({intent:"refresh_health"},{method:"post"})})]}),I==="knowledge-graph"&&S("div",{role:"tabpanel",id:"panel-knowledge-graph","aria-labelledby":"tab-knowledge-graph",className:"space-y-6","data-testid":"tab-content-knowledge-graph",children:[u(tn,{tenantId:p.tenantId,ontologyStatus:p.ontologyStatus}),u(bn,{topologyMaxLabels:Gt.topologyLabels.default,schema:p.graphSchema,tenantId:p.tenantId,unresolvedEntities:p.unresolvedEntities,traversal:o,onBrowseLabel:M,nodeIndexPage:y,nodeIndexFailure:D,isNodeIndexLoading:_,isResolving:bt,onResolveEntity:(i,b)=>{t.submit({intent:"resolve_entity",entityId:i,action:b},{method:"post"})}})]}),I==="parameters"&&S("div",{role:"tabpanel",id:"panel-parameters","aria-labelledby":"tab-parameters",className:"space-y-6","data-testid":"tab-content-parameters",children:[S("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2",children:[u(gn,{flags:De,isUpdating:t.state!=="idle",onToggleFlag:(i,b)=>{t.submit({intent:"toggle_flag",flagKey:i,enabled:String(b)},{method:"post"})}}),u(cn,{rules:p.classificationRules,domainOptions:ne,consultedBy:p.classificationRuleConsumer,onReorderRules:i=>{t.submit({intent:"reorder_rules",orderedRuleIds:JSON.stringify(i)},{method:"post"})}})]}),p.policiesMissingDestination.length>0&&S("div",{"data-testid":"policies-missing-destination",role:"alert",style:{padding:"10px 12px",borderRadius:"6px",backgroundColor:"#fef2f2",color:"#b91c1c",fontSize:"12px"},children:[u("strong",{children:"\u6B21\u306E\u533A\u5206\u30FB\u6A5F\u80FD\u306F\u5B9F\u884C\u6642\u306B\u5931\u6557\u3057\u307E\u3059\u3002"})," \u53C2\u7167\u3059\u308B\u30D7\u30ED\u30F3\u30D7\u30C8\u884C\u306B\u5B9B\u5148\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002",u("ul",{style:{margin:"6px 0 0",paddingInlineStart:"18px"},children:p.policiesMissingDestination.map(i=>S("li",{"data-testid":`missing-destination-${i.confidentialityLevel}-${i.capability}`,children:[i.confidentialityLevel," / ",i.capability," \u2192 ",i.promptKey," (",i.modelProvider,") \u306E ",u("code",{children:"extra_params.base_url"})]},`${i.confidentialityLevel}:${i.capability}`))}),u("span",{style:{display:"block",marginTop:"4px",fontSize:"11px"},children:"\u5B9B\u5148\u3092\u8A2D\u5B9A\u3057\u3066\u3082\u3001\u305D\u306E\u30DB\u30B9\u30C8\u304C\u914D\u5099\u5185\u3068\u3057\u3066\u767B\u9332\u3055\u308C\u3066\u3044\u306A\u3051\u308C\u3070\u62D2\u5426\u3055\u308C\u307E\u3059\u3002"})]}),u(pn,{policies:p.confidentialityPolicies,promptKeys:p.promptTemplates.map(i=>i.template_key),isUpdating:t.state!=="idle",onChangePolicy:i=>{t.submit({intent:"update_confidentiality_policy",confidentialityLevel:i.confidentialityLevel,capability:i.capability,isEnabled:String(i.isEnabled),allowCloudProvider:String(i.allowCloudProvider),promptKey:i.promptKey??""},{method:"post"})}}),u(In,{vocabulary:p.transcriptionVocabulary,references:p.transcriptionReferences,unresolvedUris:p.unresolvedReferenceUris,isUpdating:t.state!=="idle",onSaveTerm:i=>$e({intent:"save_transcription_term",id:i.id===null?"":String(i.id),term:i.term,reading:i.reading??"",boost:i.boost===null?"":String(i.boost),domainKey:i.domainKey??"",isActive:String(i.isActive)},{method:"post"}),onSaveReference:i=>$e({intent:"save_transcription_reference",id:i.id===null?"":String(i.id),fileUri:i.fileUri,domainKey:i.domainKey??"",isActive:String(i.isActive)},{method:"post"})}),u(vn,{parameters:p.systemParameters,onSaveParameter:(i,b)=>{t.submit({intent:"update_parameter",paramKey:i,paramValue:String(b)},{method:"post"})}})]}),I==="prompts"&&S("div",{role:"tabpanel",id:"panel-prompts","aria-labelledby":"tab-prompts",className:"space-y-6","data-testid":"tab-content-prompts",children:[u(hn,{templates:p.promptTemplates,isSaving:t.state!=="idle",onSaveTemplate:i=>{t.submit({intent:"update_prompt",templateKey:i.template_key,payload:JSON.stringify({templateText:i.template_text,modelName:i.model_name,temperature:i.temperature,maxOutputTokens:i.max_output_tokens,responseSchema:i.response_schema,endpointBaseUrl:i.endpoint_base_url??null})},{method:"post"})}}),u(yn,{onSimulate:a})]}),I==="knowledge-authority"&&S("div",{role:"tabpanel",id:"panel-knowledge-authority","aria-labelledby":"tab-knowledge-authority",className:"space-y-6","data-testid":"tab-content-knowledge-authority",children:[u(mn,{host:v,canUpdate:p.canUpdateKnowledge,onPolicyConflictsChanged:me}),u(Sn,{host:f,revision:ce})]}),I==="data-retention"&&S("div",{role:"tabpanel",id:"panel-data-retention","aria-labelledby":"tab-data-retention",className:"space-y-6","data-testid":"tab-content-data-retention",children:[k.overview.kind==="ready"?u("div",{ref:te,children:u(wn,{overview:k.overview.value,canReadFindings:p.canReadIntegrityFindings,command:St,commandFailure:ht,onStartRun:(i,b)=>{n.submit(b===null?{intent:"start_integrity_run",mode:i}:{intent:"start_integrity_run",mode:i,basisRunUid:b},{method:"post"})},onCancelRun:i=>{n.submit({intent:"cancel_integrity_run",runUid:i},{method:"post"})},loadFindings:h,refreshFailure:k.overview.refreshFailure===null?null:k.overview.refreshFailure.reason,headingRef:G,onShowHistory:re,resync:{onResync:It,onDismiss:()=>J(null),feedback:z},remedyDestinations:Pt})}):u(Ht,{title:Cn,testId:"audit-overview-failed",headingRef:G,children:u($t,{failure:k.overview,onReload:k.reload,forbiddenMessage:"\u76E3\u67FB\u306E\u6982\u6CC1\u3092\u95B2\u89A7\u3059\u308B\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093\u3002",failureMessage:On,rescueRef:te,testId:"audit-overview-failed-resource"})}),u(Rn,{host:f,knowledgeTabLabel:_e(Ee),onOpenKnowledgeTab:()=>Re(Ee.key)}),W!==null&&W.skipped.length>0&&S("div",{role:"status","data-testid":"retry-all-skipped",className:"rounded-lg border border-amber-200 border-solid bg-amber-50 p-4 text-amber-800 text-sm",children:[S("strong",{children:["\u4E00\u62EC\u518D\u8A66\u884C: ",W.requeued," \u4EF6\u3092\u518D\u6295\u5165\u3057\u3001",W.skipped.length," \u4EF6\u3092\u636E\u3048\u7F6E\u304D\u307E\u3057\u305F\u3002"]})," ","\u636E\u3048\u7F6E\u3044\u305F\u884C\u306F\u5931\u6557\u306E\u307E\u307E\u6B8B\u3063\u3066\u3044\u307E\u3059\u3002",u("ul",{className:"mt-1.5 list-disc ps-5",children:W.skipped.map(i=>S("li",{"data-testid":`retry-all-skipped-${i.metadataId}`,children:["#",i.metadataId,": ",i.reason]},i.metadataId))})]}),S("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2",children:[u("section",{ref:qe,tabIndex:-1,"aria-label":Je,"data-testid":"sync-status-region",children:u(dn,{counts:p.syncCounts,totalFiles:p.totalFiles,failedItems:p.failedSyncItems,isRetrying:ft,onRetryItem:i=>{t.submit({intent:"retry_job",fileId:String(i)},{method:"post"})},onRetryAll:()=>{t.submit({intent:"retry_all_failed"},{method:"post"})}})}),u(ln,{overview:p.qdrantCollections,health:{healthy:p.systemHealth.services.qdrant.status==="connected",latency_ms:p.systemHealth.services.qdrant.latencyMs}})]})]})]})]})})}var Ln=new Set(Vt.options.filter(e=>e!=="SYNCED"&&!e.startsWith("FAILED"))),Ye=2e3;function Fn(e,t,n){let[r,o]=L(null),s=O(t);s.current=t;let a=O(e);a.current!==e&&(a.current=e,r!==null&&o(null));let d=(r??e)?.some(c=>Ln.has(c.syncStatus))===!0;return xe(()=>{if(!(n&&d&&s.current))return;let c=!1,m,g=async()=>{let h=s.current;if(h!==void 0){try{let f=await h();if(c)return;o(f)}catch{if(c)return}m=setTimeout(g,Ye)}};return m=setTimeout(g,Ye),()=>{c=!0,clearTimeout(m)}},[d,n]),r}function Ze(e,t){let n=O(t);n.current=t;let r=O(null),o=O(!1),s=O(null);if(e.state!=="idle"){o.current=!0;let l=e.formData?.get("intent");typeof l=="string"&&(r.current=l)}xe(()=>{if(e.state!=="idle"||!o.current)return;o.current=!1,n.current(e.data,r.current);let l=s.current;if(l===null)return;s.current=null;let d=e.data?.error;typeof d=="string"?l.reject(new Error(d)):l.resolve()},[e.state,e.data]);let a=Z((...l)=>new Promise((d,c)=>{s.current?.reject(new Error("\u3053\u306E\u4FDD\u5B58\u306F\u5F8C\u7D9A\u306E\u9001\u4FE1\u306B\u7F6E\u304D\u63DB\u3048\u3089\u308C\u307E\u3057\u305F\u3002")),s.current={resolve:d,reject:c},e.submit(...l)}),[e]);return{settledIntent:e.state==="idle"?r.current:null,submitAndAwait:a}}function jn(e){let t=new Set,n=[];for(let r of e)t.has(r.domainKey)||(t.add(r.domainKey),n.push({key:r.domainKey,label:r.domainLabel}));return n}function Dn(e){return{strategyId:e.strategyId,label:`${e.domainKey} / ${e.variantKey}`,embeddingModel:e.embeddingModel}}function Un({runs:e,onOpenRun:t}){return S("section",{className:"rounded-xl border border-slate-200 border-solid bg-white p-6 shadow-sm","aria-labelledby":"pipeline-recent-runs-heading","data-testid":"pipeline-recent-runs",children:[u("h2",{id:"pipeline-recent-runs-heading",className:"font-bold text-base text-slate-900",children:"\u76F4\u8FD1\u306E\u5B9F\u884C"}),e.length===0?u("p",{className:"mt-4 text-[13px] text-slate-500","data-testid":"pipeline-recent-runs-empty",children:"\u8A18\u9332\u3055\u308C\u305F\u5B9F\u884C\u304C\u3042\u308A\u307E\u305B\u3093\u3002"}):u("div",{className:"relative mt-4 overflow-x-auto","data-testid":"pipeline-recent-runs-scroll",children:S("table",{className:"w-full text-left text-[13px]",children:[u("thead",{children:S("tr",{className:"whitespace-nowrap border-slate-200 border-b border-solid text-[11px] text-slate-500 uppercase",children:[u("th",{scope:"col",className:"px-3 py-2",children:"\u5B9F\u884C"}),u("th",{scope:"col",className:"px-3 py-2",children:"\u6587\u66F8"}),u("th",{scope:"col",className:"px-3 py-2",children:"\u7A2E\u985E"}),u("th",{scope:"col",className:"px-3 py-2",children:"\u304D\u3063\u304B\u3051"}),u("th",{scope:"col",className:"px-3 py-2",children:"\u8A66\u884C"}),u("th",{scope:"col",className:"px-3 py-2",children:"\u72B6\u614B"}),u("th",{scope:"col",className:"px-3 py-2",children:"\u6B62\u307E\u3063\u305F\u6BB5"}),u("th",{scope:"col",className:"px-3 py-2",children:"\u958B\u59CB"}),u("th",{scope:"col",className:"px-3 py-2",children:"\u7D42\u4E86"}),u("th",{scope:"col",className:"px-3 py-2",children:"\u8981\u6C42\u8005"}),t!==void 0&&u("th",{scope:"col",className:"px-3 py-2",children:u("span",{className:"sr-only","data-testid":"pipeline-recent-runs-action-header",children:"\u64CD\u4F5C"})})]})}),u("tbody",{children:e.map(n=>{let r=on(n),o=nn[r];return S("tr",{className:"border-slate-100 border-b border-solid","data-testid":`pipeline-run-row-${n.id}`,"data-status":n.status,children:[S("td",{className:"whitespace-nowrap px-3 py-2 font-mono","data-testid":`pipeline-run-id-${n.id}`,children:["#",n.id]}),S("td",{className:"whitespace-nowrap px-3 py-2 font-mono","data-testid":`pipeline-run-metadata-${n.id}`,children:["#",n.metadataId]}),u("td",{className:"whitespace-nowrap px-3 py-2","data-testid":`pipeline-run-kind-${n.id}`,children:Bt[n.documentKind]}),u("td",{className:"whitespace-nowrap px-3 py-2","data-testid":`pipeline-run-trigger-${n.id}`,"data-trigger":n.trigger,children:rn[n.trigger]}),u("td",{className:"whitespace-nowrap px-3 py-2","data-testid":`pipeline-run-attempt-${n.id}`,children:n.attempt}),u("td",{className:"px-3 py-2",children:u("span",{className:`inline-flex whitespace-nowrap rounded-full px-2 py-0.5 font-semibold text-[11px] ${o.className}`,"data-testid":`pipeline-run-status-${n.id}`,"data-status":n.status,"data-presentation":r,children:o.label})}),u("td",{className:"px-3 py-2","data-testid":`pipeline-run-failed-step-${n.id}`,children:n.failedStepKey===null?"\u2014":zt[n.failedStepKey].label}),u("td",{className:"whitespace-nowrap px-3 py-2 text-slate-500","data-testid":`pipeline-run-started-${n.id}`,children:u(un,{iso:n.startedAt,testId:`pipeline-run-started-value-${n.id}`})}),u("td",{className:"whitespace-nowrap px-3 py-2 text-slate-500","data-testid":`pipeline-run-finished-${n.id}`,children:u(Yt,{iso:n.finishedAt,testId:`pipeline-run-finished-value-${n.id}`})}),u("td",{className:"wrap-anywhere px-3 py-2","data-testid":`pipeline-run-requested-by-${n.id}`,children:n.requestedBy}),t!==void 0&&u("td",{className:"whitespace-nowrap px-3 py-2 text-right",children:u("button",{type:"button",onClick:()=>t(n),"aria-label":`\u5B9F\u884C #${n.id} (\u6587\u66F8 #${n.metadataId}) \u306E\u8A73\u7D30`,className:"whitespace-nowrap rounded-sm border border-slate-300 border-solid bg-white px-2 py-0.5 font-semibold text-[11px] text-slate-700 hover:bg-slate-50","data-testid":`pipeline-run-open-${n.id}`,children:"\u8A73\u7D30"})})]},n.id)})})]})})]})}var Xe={metadataId:null,runs:[],selectedRunId:null,isLoading:!1,failure:null};function Hn(e){for(let t of e)for(let n of t.steps){let r=n.provenance;if(r!==null){for(let[o,s]of Object.entries(r))if(typeof s=="string"&&!oe(s))return`\u51E6\u7406\u5C65\u6B74\u306E\u8A18\u9332\u306B\u8AAD\u3081\u306A\u3044\u6765\u6B74\u306E\u5024\u304C\u3042\u308A\u307E\u3059 (\u5B9F\u884C ${t.id} \u306E\u6BB5 ${n.sequence} \u306E ${o})\u3002`}}return null}function Mn(e){let[t,n]=L(Xe),[r,o]=L(0),s=O(0),a=O(null),l=le(()=>{if(e!==void 0)return(m,g)=>{s.current+=1;let h=s.current;a.current?.abort();let f=new AbortController;a.current=f,o(v=>v+1),n({metadataId:m,runs:[],selectedRunId:g,isLoading:!0,failure:null}),Y(()=>e(m,f.signal),v=>({ok:!1,status:null,reason:v})).then(v=>{if(s.current!==h)return;let y=v.ok?Hn(v.value):kn(v);if(!v.ok||y!==null){n({metadataId:m,runs:[],selectedRunId:g,isLoading:!1,failure:y});return}n({metadataId:m,runs:v.value,selectedRunId:g===null?$n(v.value):g,isLoading:!1,failure:null})})}},[e]),d=Z(m=>{n(g=>({...g,selectedRunId:m}))},[]),c=Z(()=>{s.current+=1,a.current?.abort(),a.current=null,n(Xe)},[]);return{...t,openRequest:r,open:l,selectRun:d,close:c}}function $n(e){return e.length===0?null:e[0].id}function Kn(e){let t=Pn(),n=Qe(),r=Qe(),o=e.data??t,s=e.fetcher??n,a=e.integrityFetcher??r;return o?u(nt,{...e,data:o,fetcher:s,integrityFetcher:a}):u("div",{className:"p-8 text-center text-slate-500","data-testid":"storage-admin-loading",children:"\u30C7\u30FC\u30BF\u8AAD\u307F\u8FBC\u307F\u4E2D..."})}function rt(e){return e.data?u(nt,{...e,data:e.data,fetcher:e.fetcher??We,integrityFetcher:e.integrityFetcher??We}):u(Kn,{...e})}import{AuthzDeniedError as lt}from"@aiquants/authz-core";import{formatCount as Wn}from"@aiquants/console-ui/core";import{assertSystemParameterInRange as Yn,INTEGRITY_COMMAND_CODES as Zn,IntegrityAuditOverviewSchema as Xn,IntegrityCommandFailureSchema as er,IntegrityCommandReplySchema as tr,IntegrityRunModeSchema as ut,integrityCommandFailureCodeOf as nr,isEnrichmentStageKey as rr,PipelineRunSummarySchema as sr,PipelineStepMetricSchema as ir}from"@aiquants/enrichment-core";import{CLOUD_CAPABLE_CAPABILITIES as ar,ConfidentialityLevelSchema as je,GovernedCapabilitySchema as or}from"@aiquants/governance-core";import{z as w}from"zod";var Le=3e3;function j(e){return Math.round(performance.now()-e)}function T(e){return typeof e=="string"&&oe(e)?e:null}function F(e){let t=globalThis.process;return t===void 0?void 0:t.env[e]}function ue(e,t){let n=e?.trim();if(!n)throw new Error(`${t} is not configured; this probe will not guess an endpoint to send credentials to.`);return n}function st(e,t,n){let r=e??(t?.trim()?Number(t):Number.NaN);if(!Number.isInteger(r)||r<=0||r>65535)throw new Error(`${n} is not configured with a valid port; this probe will not guess one.`);return r}function it(e,t){if(e!==void 0)return e;let n=t?.trim().toLowerCase();if(!(n===void 0||n===""))return n==="1"||n==="true"||n==="yes"||n==="on"}function at(e){let t=e.trim().split("://",1)[0]?.toLowerCase();if(t&&e.includes("://"))return t.endsWith("s")||t.includes("+s")}function qn(e){let n=e.split("://").slice(-1)[0].split("/",1)[0],r=n.split(":").pop();if(!r||r===n)return;let o=Number(r);return Number.isInteger(o)&&o>0&&o<=65535?o:void 0}async function ke(e,t){let n;try{return await Promise.race([e,new Promise((r,o)=>{n=setTimeout(()=>o(new Error(`Probe timed out after ${t}ms`)),t)})])}finally{clearTimeout(n)}}async function Bn(e){let t=e?.qdrantApiKey??F("QDRANT_API_KEY")??"",n=e?.timeoutMs??Le,r=performance.now(),o="";try{o=ue(e?.qdrantUrl??F("QDRANT_URL"),"QDRANT_URL");let s={};t&&(s["api-key"]=t);let[a,l]=await Promise.all([fetch(`${o}/`,{headers:s,signal:AbortSignal.timeout(n)}),fetch(`${o}/collections`,{headers:s,signal:AbortSignal.timeout(n)})]);if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);if(!l.ok)throw new Error(`HTTP ${l.status}: ${l.statusText} (/collections)`);let d=await a.json(),c=j(r),g=(await l.json()).result?.collections?.length??0;return{serviceName:"Qdrant",category:"vector",status:"connected",version:T(d.version),endpoint:o,latencyMs:c,details:{engine:T(d.title),collectionsCount:g,restPort:qn(o)??null,tls:at(o)??null}}}catch(s){let a=j(r),l=s instanceof Error?s.message:String(s);return{serviceName:"Qdrant",category:"vector",status:"error",version:null,endpoint:o,latencyMs:a,details:{},errorMessage:l}}}async function Vn(e){let t=e?.timeoutMs??Le,n=performance.now(),r=T(e?.neo4jBoltUri??F("NEO4J_URI")),o=r===null?"":r;try{let s=e?.graphReader;if(!s)throw new Error("Graph reader not configured");let a=e?.tenantId,[l,d]=await Promise.all([ke(s("CALL dbms.components() YIELD versions, edition RETURN versions[0] AS version, edition",{}),t),ke(a?s("MATCH (n {tenantId: $tenantId}) RETURN count(n) AS node_count",{tenantId:a}):s("RETURN null AS node_count",{}),t)]);if(!l.ok)throw new Error(l.reason);if(!d.ok)throw new Error(d.reason);let[c,m]=l.rows[0]??[],g=d.rows[0]?.[0],h=j(n);return{serviceName:"Neo4j",category:"graph",status:"connected",version:T(c),endpoint:o,latencyMs:h,details:{edition:T(m),boltUri:r,nodeCount:typeof g=="number"?g:null,tls:r===null?null:at(r)??null}}}catch(s){let a=j(n),l=s instanceof Error?s.message:String(s);return{serviceName:"Neo4j",category:"graph",status:"error",version:null,endpoint:o,latencyMs:a,details:{},errorMessage:l}}}async function Gn(e){let t=performance.now(),n="",r=it(e?.redisTls,F("REDIS_TLS")),o=Number.NaN;try{let s=e?.redisClient;if(!s)throw new Error("Redis client not configured");let a=ue(e?.redisHost??F("REDIS_HOST"),"REDIS_HOST");o=st(e?.redisPort,F("REDIS_PORT"),"REDIS_PORT"),n=`${r===!1?"redis":"rediss"}://${a}:${o}`,await s.ping();let l=await s.info("server"),d=T(l.match(/redis_version:([^\r\n]+)/)?.[1]),c=null;if(typeof s.dbSize=="function")try{c=await s.dbSize()}catch{c=null}let m=j(t);return{serviceName:"Redis",category:"cache",status:"connected",version:d,endpoint:n,latencyMs:m,details:{totalKeys:c,port:o,tls:r??null,database:0}}}catch(s){let a=j(t),l=s instanceof Error?s.message:String(s);return{serviceName:"Redis",category:"cache",status:"error",version:null,endpoint:n,latencyMs:a,details:{},errorMessage:l}}}function Qn(e){let t=e.match(/Microsoft SQL Server \d+ \([^)]+\)/);return T(t===null?e.substring(0,30):t[0].replace("Microsoft SQL Server ",""))}async function zn(e){let t=performance.now(),n="",r=it(e?.sqlServerTls,F("SQL_SERVER_TLS")),o=Number.NaN;try{let s=e?.sqlServerExecute;if(!s)throw new Error("SQL Server executor not configured");let a=ue(e?.sqlServerHost??F("SQL_SERVER_HOST"),"SQL_SERVER_HOST");o=st(e?.sqlServerPort,F("SQL_SERVER_PORT"),"SQL_SERVER_PORT"),n=`${a}:${o}`;let l=await s(),d=T(l.db_name),c=T(l.version),m=c===null?null:T(c.split(`
2
+ `)[0]),g=m===null?null:Qn(m),h=j(t);return{serviceName:"SQL Server",category:"database",status:"connected",version:g,endpoint:n,latencyMs:h,details:{database:d,port:o,tls:r??null,fullVersion:m}}}catch(s){let a=j(t),l=s instanceof Error?s.message:String(s);return{serviceName:"SQL Server",category:"database",status:"error",version:null,endpoint:n,latencyMs:a,details:{},errorMessage:l}}}async function Jn(e){let t=e?.timeoutMs??Le,n=performance.now(),r="";try{r=ue(e?.backendApiHost??F("BACKEND_API_HOST"),"BACKEND_API_HOST");let o=await fetch(`${r}/openapi.json`,{signal:AbortSignal.timeout(t)});if(!o.ok)throw new Error(`HTTP ${o.status}: ${o.statusText}`);let s=await o.json(),a=Object.keys(s.paths??{}).length,l=j(n);return{serviceName:"AI Quant API",category:"api",status:"connected",version:T(s.info?.version),endpoint:r,latencyMs:l,details:{title:T(s.info?.title),endpointsCount:a}}}catch(o){let s=j(n),a=o instanceof Error?o.message:String(o);return{serviceName:"AI Quant API",category:"api",status:"error",version:null,endpoint:r,latencyMs:s,details:{},errorMessage:a}}}async function ot(e){let[t,n,r,o,s]=await Promise.all([Bn(e),Vn(e),Gn(e),zn(e),Jn(e)]),a=t.status==="connected"&&n.status==="connected"&&r.status==="connected"&&o.status==="connected"&&s.status==="connected";return{services:{qdrant:t,neo4j:n,redis:r,sqlServer:o,quantsApi:s},allHealthy:a,checkedAt:new Date().toISOString()}}var lr=w.object({templateText:w.string(),modelName:w.string(),temperature:w.number(),maxOutputTokens:w.number(),responseSchema:w.union([w.record(w.string(),w.unknown()),w.string(),w.null()]).optional(),endpointBaseUrl:w.string().nullable()}).strict(),ur=w.discriminatedUnion("mode",[w.object({mode:ut.extract(["SCAN"]),basisRunUid:w.null()}).strict(),w.object({mode:ut.extract(["REPAIR"]),basisRunUid:w.string().uuid()}).strict()]),dr=w.object({runUid:w.string().uuid()}).strict();function ct(e){return e==="start_integrity_run"?"start":e==="cancel_integrity_run"?"cancel":null}function V(e,t){return e.issues.map(n=>`${n.path.length===0?t:n.path.join(".")}: ${n.message}`).join("; ")}function cr(e,t){if(e==="bool")return t==="true"||t==="false"?null:"paramValue must be 'true' or 'false' for a bool parameter";if(e==="int")return/^[+-]?\d+$/.test(t)&&Number.isSafeInteger(Number(t))?null:"paramValue must be a safe integer for an int parameter";if(e==="float")return t.trim()!==""&&Number.isFinite(Number(t))?null:"paramValue must be a finite number for a float parameter";if(e==="json")try{return JSON.parse(t),null}catch{return"paramValue must be valid JSON for a json parameter"}return null}function pr(e){let t=sr.array().safeParse(e);if(!t.success)throw new Error(`getRecentPipelineRuns answered something that is not a run summary: ${V(t.error,"getRecentPipelineRuns")}`);return t.data}function mr(e){let t=ir.array().safeParse(e);if(!t.success)throw new Error(`getPipelineStepMetrics answered something that is not a step metric: ${V(t.error,"getPipelineStepMetrics")}`);let n=new Set;for(let r of t.data){let o=`${r.documentKind}/${r.stepKey}`;if(n.has(o))throw new Error(`getPipelineStepMetrics answered more than one metric for (documentKind, stepKey) = (${r.documentKind}, ${r.stepKey})`);n.add(o)}return t.data}function gr(e){if(!Number.isSafeInteger(e)||e<=0)throw new Error(`pipelineStepMetricWindow must be a positive safe integer, got ${String(e)}`);return e}async function yr(e,t){let n;try{n=await e.readIntegrityAuditOverview(t)}catch(o){return{ok:!1,status:null,reason:o instanceof Error?o.message:String(o)}}let r=Xn.safeParse(n);return r.success?{ok:!0,value:r.data}:{ok:!1,status:null,reason:`readIntegrityAuditOverview answered something that is not an audit overview: ${V(r.error,"readIntegrityAuditOverview")}`}}function fr(e){return!Array.isArray(e)||e.length===0?"orderedRuleIds must be a non-empty array of rule ids":e.every(t=>typeof t=="number"&&Number.isSafeInteger(t)&&t>0)?new Set(e).size!==e.length?"orderedRuleIds must not name a rule twice":null:"orderedRuleIds must contain positive integers only"}function pt(e){let{store:t,healthProbeOptions:n,resourceKey:r="storage_admin",requireUser:o,requirePermission:s,resolveTenantId:a,authorizeIngest:l,canReadIntegrityFindings:d,canUpdateKnowledge:c}=e;async function m(h){let{request:f}=h;if(!await o(f))throw new Response("\u8A8D\u8A3C\u304C\u5FC5\u8981\u3067\u3059\u3002",{status:401});try{await s(f,{resourceKey:r,action:"read"})}catch(se){throw se instanceof lt?new Response("\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093\u3002",{status:403}):se}let y=await a(f),H=gr(t.pipelineStepMetricWindow),[D,N,_]=await Promise.all([t.getFeatureFlags(y),t.getSystemParameters(y),t.getSyncCounts(y)]),E={featureFlags:D,systemParameters:N,syncCounts:_},[M,$,K,C,I,x,ee,k,G,te,ce,pe,me,p,q,ge,ne,ye,A,B,re]=await Promise.all([t.getConfidentialityPolicies(y),t.getTranscriptionVocabulary(y),t.getTranscriptionReferences(y),t.getUnresolvedReferenceUris(y),t.getPoliciesMissingDestination(y),t.getPromptTemplates(y),t.getClassificationRules(y),t.getFailedSyncItems(y),t.getGraphSchema(y),yr(t,y),d(f),c(f),t.getUnresolvedEntities(y),t.getQdrantCollections(y),ot({...n,tenantId:y}),t.getRecentIngestItems(y),t.getOntologyStatus(y,E),t.getEnrichmentStrategies(y),t.getStrategyVariants(y),t.getPipelineStepMetrics(y),t.getRecentPipelineRuns(y)]),fe=t.getCircuitBreakerStatus();return{tenantId:y,featureFlags:E.featureFlags,confidentialityPolicies:M,transcriptionVocabulary:$,transcriptionReferences:K,unresolvedReferenceUris:C,policiesMissingDestination:I,systemParameters:E.systemParameters,promptTemplates:x,classificationRules:ee,classificationRuleConsumer:t.classificationRuleConsumer??null,syncCounts:E.syncCounts.counts,totalFiles:E.syncCounts.total,failedSyncItems:k,circuitBreakerStatus:fe,pipelineStepMetrics:mr(B),pipelineStepMetricWindow:H,recentPipelineRuns:pr(re),displayTimeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,graphSchema:G,enrichmentStrategies:ye,strategyVariants:A,integrityAudit:te,canReadIntegrityFindings:ce,canUpdateKnowledge:pe,unresolvedEntities:me,qdrantCollections:p,systemHealth:q,recentIngestItems:ge,ontologyStatus:ne}}async function g(h){let{request:f}=h,v=await o(f);if(!v)return Response.json({error:"\u8A8D\u8A3C\u304C\u5FC5\u8981\u3067\u3059\u3002"},{status:401});if(v.email.trim()==="")return Response.json({error:"\u64CD\u4F5C\u8005\u3092\u7279\u5B9A\u3067\u304D\u306A\u3044\u305F\u3081\u8A2D\u5B9A\u3092\u5909\u66F4\u3067\u304D\u307E\u305B\u3093\u3002"},{status:403});if(v.accessToken==="")throw new Error("requireUser resolved an operator whose accessToken is an empty string; answer null when the session holds no token the upstream services accept");let y=v.email,H=v.accessToken===null?void 0:v.accessToken;try{await s(f,{resourceKey:r,action:"update"})}catch(C){if(C instanceof lt)return await hr(f);throw C}let D=await a(f),N=await f.formData(),_=String(N.get("intent")??"");if(_==="refresh_health")return Response.json({success:!0,refreshed:!0});let E=await Sr(t,D,_,N,y);if(E)return E;let M=await Rr(t,D,_,N,y,H);if(M)return M;let $=await vr(t,D,_,N,H,()=>d(f));if($)return $;if(_==="resolve_entity"){let C=String(N.get("entityId")??""),I=String(N.get("action")??"");if(!C||I!=="merge"&&I!=="promote")return Response.json({error:"Valid entityId and action ('merge' | 'promote') are required"},{status:400});try{return await t.resolveEntity(D,C,I),Response.json({success:!0,entityId:C,action:I})}catch(x){return Response.json({error:x instanceof Error?x.message:String(x)},{status:400})}}let K=await Ar(t,D,_,N,y,f,l,H);return K||Response.json({error:`Unknown intent: ${_}`},{status:400})}return{loader:m,action:g}}function Fe(e){let t=String(e??"").trim();return t===""?null:t}function de(e){let t=String(e??"").trim();if(t==="")return null;let n=Number(t);if(!(!Number.isSafeInteger(n)||n<=0))return n}function br(e){let t=String(e??"").trim();if(t==="")return null;let n=Number(t);if(!(!Number.isFinite(n)||n<=0))return n}async function Sr(e,t,n,r,o){if(n==="update_enrichment_strategy"){let s=String(r.get("stage")??"");if(!rr(s))return Response.json({error:"stage must be a canonical enrichment stage key"},{status:400});let a=de(r.get("strategyId")),l=de(r.get("domainId"));if(a==null||l===void 0||l===null)return Response.json({error:"strategyId and domainId must be positive integers naming existing rows"},{status:400});let d=String(r.get("enabled")??"")==="true";try{await e.updateEnrichmentStrategy(t,{strategyId:a,domainId:l,stage:s,enabled:d},o)}catch(c){return Response.json({error:c instanceof Error?c.message:"\u53D6\u308A\u8FBC\u307F\u6226\u7565\u3092\u66F4\u65B0\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002"},{status:400})}return Response.json({success:!0,strategyId:a,domainId:l,stage:s,enabled:d})}if(n==="toggle_flag"){let s=String(r.get("flagKey")??""),a=String(r.get("enabled")??"")==="true";if(!s)return Response.json({error:"flagKey is required"},{status:400});let l=await e.getFeatureFlags(t);return Object.hasOwn(l,s)?(await e.toggleFeatureFlag(t,s,a,o),Response.json({success:!0,flagKey:s,enabled:a})):Response.json({error:`flagKey names no feature flag of this tenant: ${s}`},{status:400})}if(n==="update_confidentiality_policy"){let s=String(r.get("confidentialityLevel")??""),a=String(r.get("capability")??"");if(!(je.safeParse(s).success&&or.safeParse(a).success))return Response.json({error:"confidentialityLevel and capability must be canonical values"},{status:400});let l=String(r.get("allowCloudProvider")??"")==="true";if(l&&!ar.includes(a))return Response.json({error:`${a} sends nothing outside the deployment, so it has no cloud permission to grant`},{status:400});let d=String(r.get("promptKey")??"");return await e.updateConfidentialityPolicy(t,{confidentialityLevel:s,capability:a,isEnabled:String(r.get("isEnabled")??"")==="true",allowCloudProvider:l,promptKey:d===""?null:d},o),Response.json({success:!0,confidentialityLevel:s,capability:a})}if(n==="save_transcription_term"){let s=String(r.get("term")??"").trim();if(!s)return Response.json({error:"term is required"},{status:400});let a=br(r.get("boost"));if(a===void 0)return Response.json({error:"boost must be a number greater than zero, or absent to let the service decide"},{status:400});let l=de(r.get("id"));if(l===void 0)return Response.json({error:"id must be a positive integer naming an existing row, or absent for a new one"},{status:400});try{await e.saveTranscriptionTerm(t,{id:l,term:s,reading:Fe(r.get("reading")),boost:a,domainKey:Fe(r.get("domainKey")),isActive:String(r.get("isActive")??"true")==="true"},o)}catch(d){return Response.json({error:d instanceof Error?d.message:"\u8A9E\u5F59\u3092\u4FDD\u5B58\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002"},{status:400})}return Response.json({success:!0,term:s})}if(n==="save_transcription_reference"){let s=String(r.get("fileUri")??"").trim();if(!s)return Response.json({error:"fileUri is required"},{status:400});let a=de(r.get("id"));if(a===void 0)return Response.json({error:"id must be a positive integer naming an existing row, or absent for a new one"},{status:400});try{await e.saveTranscriptionReference(t,{id:a,fileUri:s,domainKey:Fe(r.get("domainKey")),isActive:String(r.get("isActive")??"true")==="true"},o)}catch(l){return Response.json({error:l instanceof Error?l.message:"\u53C2\u7167\u8CC7\u6599\u3092\u4FDD\u5B58\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002"},{status:400})}return Response.json({success:!0,fileUri:s})}if(n==="update_parameter"){let s=String(r.get("paramKey")??""),a=String(r.get("paramValue")??"");if(!s)return Response.json({error:"paramKey is required"},{status:400});let l=(await e.getSystemParameters(t)).find(c=>c.key===s);if(l===void 0)return Response.json({error:`paramKey names no parameter of this tenant: ${s}`},{status:400});let d=cr(l.data_type,a);if(d!==null)return Response.json({error:d},{status:400});try{Yn(s,Number(a))}catch(c){return Response.json({error:c.message},{status:400})}return await e.updateSystemParameter(t,s,a,o),Response.json({success:!0,paramKey:s,paramValue:a})}if(n==="update_prompt"){let s=String(r.get("templateKey")??""),a=String(r.get("payload")??"{}"),l;try{l=JSON.parse(a)}catch{return Response.json({error:"Invalid JSON payload"},{status:400})}if(!s)return Response.json({error:"templateKey is required"},{status:400});let d=lr.safeParse(l);if(!d.success)return Response.json({error:`payload does not carry a prompt template update: ${V(d.error,"payload")}`},{status:400});let c=d.data;try{return await e.updatePromptTemplate(t,s,c,o),Response.json({success:!0,templateKey:s})}catch(m){return Response.json({error:m instanceof Error?m.message:String(m)},{status:400})}}if(n==="reorder_rules"){let s=String(r.get("orderedRuleIds")??"[]"),a;try{a=JSON.parse(s)}catch{return Response.json({error:"Invalid orderedRuleIds JSON"},{status:400})}let l=fr(a);if(l!==null)return Response.json({error:l},{status:400});let d=a;return await e.reorderClassificationRules(t,d,o),Response.json({success:!0,orderedRuleIds:d})}return null}async function Rr(e,t,n,r,o,s){if(n==="retry_job"){let a=String(r.get("fileId")??"");if(!a)return Response.json({error:"fileId is required"},{status:400});try{return await e.retrySyncItem(t,a,o,s),Response.json({success:!0,fileId:a})}catch(l){return Response.json({error:l instanceof Error?l.message:String(l)},{status:400})}}if(n==="retry_all_failed")try{let{requeued:a,skipped:l}=await e.retryAllFailedSyncItems(t,o,s);return Response.json({success:!0,requeued:a,skipped:l})}catch(a){return Response.json({error:a instanceof Error?a.message:String(a)},{status:400})}return null}function X(e,t,n){let r=er.parse({command:e,code:t,status:n}),o=Zn.find(s=>s.code===r.code);return Response.json({failure:r},{status:o===void 0?502:o.status})}async function hr(e){let t=await e.formData().catch(()=>null),n=t===null?null:ct(t.get("intent"));return n===null?Response.json({error:"\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093\u3002"},{status:403}):X(n,"FORBIDDEN",null)}async function dt(e,t){let n;try{n=tr.parse(await t())}catch{return X(e,"UPSTREAM_FAILED",null)}return n.ok?Response.json({success:!0,runUid:n.runUid}):X(e,nr(e,n.status,n.errorCode),n.status)}async function vr(e,t,n,r,o,s){let a=ct(n);if(a==="start"){let l=ur.safeParse({mode:r.get("mode"),basisRunUid:r.get("basisRunUid")});if(!l.success)return Response.json({error:`start_integrity_run takes mode SCAN without basisRunUid, or mode REPAIR with basisRunUid (a UUID): ${V(l.error,"form")}`},{status:400});let{mode:d,basisRunUid:c}=l.data;return o===void 0||d==="REPAIR"&&!await s()?X(a,"FORBIDDEN",null):await dt(a,()=>e.startIntegrityRun(t,d,c,o))}if(a==="cancel"){let l=dr.safeParse({runUid:r.get("runUid")});return l.success?o===void 0?X(a,"FORBIDDEN",null):await dt(a,()=>e.cancelIntegrityRun(t,l.data.runUid,o)):Response.json({error:`cancel_integrity_run takes runUid (a UUID): ${V(l.error,"form")}`},{status:400})}return null}function Ir(e){if(typeof e!="object"||e===null)return"payload must be an object";let t=e;if(typeof t.fileUri!="string"||t.fileUri.trim()==="")return"payload.fileUri is required";if(!je.safeParse(t.confidentialityLevel).success)return`payload.confidentialityLevel must be one of ${je.options.join(", ")}`;let r=t.departmentId;return r!=null&&(typeof r!="number"||!Number.isInteger(r))?"payload.departmentId must be an integer or null":null}function wr(e){try{return Wn(e,ae),null}catch{return`inspectFileUri answered a fileSize that is not a byte count (a non-negative safe integer): ${String(e)}`}}async function Ar(e,t,n,r,o,s,a,l){if(n==="ingest_document"){let d=String(r.get("payload")??"");if(!d)return Response.json({error:"payload is required"},{status:400});let c;try{c=JSON.parse(d)}catch{return Response.json({error:"Invalid JSON payload"},{status:400})}let m=Ir(c);if(m)return Response.json({error:m},{status:400});let g=c,h=await a(s,g);if(h!==null)return Response.json({error:h},{status:403});try{let f=l===void 0?await e.ingestDocument(t,g,o):await e.ingestDocument(t,g,o,l);return Response.json({success:!0,result:f})}catch(f){return Response.json({error:f instanceof Error?f.message:String(f)},{status:400})}}if(n==="inspect_uri"){let d=String(r.get("fileUri")??"").trim();if(!d)return Response.json({error:"fileUri is required"},{status:400});if(!e.inspectFileUri)return Response.json({error:"inspectFileUri is not implemented"},{status:501});let c;try{c=l===void 0?await e.inspectFileUri(t,d):await e.inspectFileUri(t,d,l)}catch(g){return Response.json({error:g instanceof Error?g.message:String(g)},{status:400})}let m=wr(c.fileSize);return m!==null?Response.json({error:m},{status:400}):Response.json({success:!0,inspection:c})}return null}function is(e){let t=pt(e);return{loader:t.loader,action:t.action,View:rt,server:t}}export{rt as StorageAdminConsoleView,ot as checkAllSystemHealth,Jn as checkBackendApiHealth,Vn as checkNeo4jHealth,Bn as checkQdrantHealth,Gn as checkRedisHealth,zn as checkSqlServerHealth,is as createStorageAdminApp,pt as createStorageAdminServer};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiquants/enrichment-react-router",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "React Router (v7 / v8) adapter for storage AI enrichment & knowledge governance admin console.",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -36,11 +36,11 @@
36
36
  "license": "MIT",
37
37
  "peerDependencies": {
38
38
  "@aiquants/authz-core": "^0.6.1",
39
- "@aiquants/console-ui": "^0.1.0",
40
- "@aiquants/enrichment-core": "^0.3.1",
41
- "@aiquants/enrichment-react": "^0.2.0",
39
+ "@aiquants/console-ui": "^0.1.1",
40
+ "@aiquants/enrichment-core": "^0.3.2",
41
+ "@aiquants/enrichment-react": "^0.2.1",
42
42
  "@aiquants/governance-core": "^0.2.1",
43
- "@aiquants/governance-react": "^0.2.0",
43
+ "@aiquants/governance-react": "^0.2.2",
44
44
  "react": ">=19",
45
45
  "react-dom": ">=19",
46
46
  "react-router": "^7.0.0 || ^8.0.0",
@@ -48,11 +48,11 @@
48
48
  },
49
49
  "devDependencies": {
50
50
  "@aiquants/authz-core": "0.6.1",
51
- "@aiquants/console-ui": "0.1.0",
52
- "@aiquants/enrichment-core": "0.3.1",
53
- "@aiquants/enrichment-react": "0.2.0",
51
+ "@aiquants/console-ui": "0.1.1",
52
+ "@aiquants/enrichment-core": "0.3.2",
53
+ "@aiquants/enrichment-react": "0.2.1",
54
54
  "@aiquants/governance-core": "0.2.1",
55
- "@aiquants/governance-react": "0.2.0",
55
+ "@aiquants/governance-react": "0.2.2",
56
56
  "@testing-library/jest-dom": "^6.9.1",
57
57
  "@testing-library/react": "^16.3.2",
58
58
  "@testing-library/user-event": "^14.6.1",