@aiquants/enrichment-core 0.3.1 → 0.3.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 +17 -13
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +59 -32
- package/dist/index.d.ts +59 -32
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,8 @@ Transport- and DB-agnostic storage metadata AI enrichment core: canonical types,
|
|
|
11
11
|
- **EnrichmentClient**: ハイブリッド検索 (`POST /ai/search/hybrid`) を呼ぶ HTTP クライアント SDK。要求・応答のスキーマ (`SearchRequestSchema` / `SearchResponseSchema`) は Python 側 `HybridSearchRequest` / `HybridSearchResponse` と項目ごとに一致する。詳細は下の「Search client contract」。
|
|
12
12
|
- **Pipeline flow as data** (`flow.ts`): 文書種 (`DOCUMENT_KINDS` / `classifyDocumentKind`)、段 (`PIPELINE_STEPS`)、種類ごとの段の DAG (`PIPELINE_FLOWS` / `flowFor` / `orderedSteps`)。ワーカーの実行順とコンソールの図はこの 1 つの表から導く。段は自分を閉じるテナントのフラグ (`gates`) と、閉じたときの意味 (`skip` / `fail`) を宣言し、流れは段ごとにその意味を上書きできる (`FlowStep.gatePolicy`)。流れの中の門は `flowStepGates` で読む。詳細は下の「Pipeline flow contract」。
|
|
13
13
|
- **Pipeline records** (`pipelineRecord.ts`): 1 回の実行 (`PipelineRunRecordSchema`) と段ごとの記録 (`PipelineStepRecordSchema`)、段を除いた実行の要約 (`PipelineRunSummarySchema`、一覧向け)、段が自身について報告する値 (`StageProvenanceSchema`、Python 側の `StageProvenance` と項目ごとに一致)、段の集計 (`PipelineStepMetricSchema`)、飛ばした理由の文法 (`SkipReason` / `formatSkipReason` / `parseSkipReason`、読む対象が無かったときの値 `NOTHING_TO_READ_TOKENS` / `NothingToReadTokenSchema`)。測っていない値は `null` で、欠落させない。詳細は下の「Pipeline record contract」。
|
|
14
|
-
- **Integrity audit contract** (`integrity.ts`): Tri-Store 整合性監査の記録の語彙 (`IntegrityStoreSchema` を含む 12 の列挙と、所見を記録する区分 `IntegrityFindingItemClassSchema`)、区分の扱いと処置の表 (`INTEGRITY_CLASS_POLICY`)、概況 (`IntegrityAuditOverviewSchema`)、所見の頁と要求 (`IntegrityFindingPageSchema` / `IntegrityFindingsQuerySchema`)、開始・中止の命令と命令ごとの失敗の語彙 (`IntegrityCommandSchema` / `IntegrityCommandFailureSchema`) と (状態, 業務コード) の表 (`integrityCommandCodes.json` / `INTEGRITY_COMMAND_CODES` / `integrityCommandFailureCodeOf`)、ホストのストアの応答 (`IntegrityCommandReplySchema`)、契約の時刻の前後の比較 (`isStrictlyEarlier`)
|
|
14
|
+
- **Integrity audit contract** (`integrity.ts`): Tri-Store 整合性監査の記録の語彙 (`IntegrityStoreSchema` を含む 12 の列挙と、所見を記録する区分 `IntegrityFindingItemClassSchema`)、区分の扱いと処置の表 (`INTEGRITY_CLASS_POLICY`)、概況 (`IntegrityAuditOverviewSchema`)、所見の頁と要求 (`IntegrityFindingPageSchema` / `IntegrityFindingsQuerySchema`)、配置の所見が観測したドメイン (`IntegrityPlacementObservedSchema`)、開始・中止の命令と命令ごとの失敗の語彙 (`IntegrityCommandSchema` / `IntegrityCommandFailureSchema`) と (状態, 業務コード) の表 (`integrityCommandCodes.json` / `INTEGRITY_COMMAND_CODES` / `integrityCommandFailureCodeOf`)、ホストのストアの応答 (`IntegrityCommandReplySchema`)、契約の時刻の前後の比較 (`isStrictlyEarlier`)。
|
|
15
|
+
詳細は下の「Integrity audit contract」。
|
|
15
16
|
- **System parameter ranges** (`systemParameterRanges.ts`): 値域を持つシステムパラメータの唯一の表 (`systemParameterRanges.json` / `SYSTEM_PARAMETER_RANGES`) と、書き手が当てる検査 (`assertSystemParameterInRange`) と読み手が当てる検査 (`assertBoundedSystemParameter`)。詳細は下の「System parameter ranges」。
|
|
16
17
|
|
|
17
18
|
## Search client contract / 検索クライアントの契約
|
|
@@ -44,7 +45,7 @@ Transport- and DB-agnostic storage metadata AI enrichment core: canonical types,
|
|
|
44
45
|
| `FlowStep.gatePolicy` (`FlowGatePolicy`) | 1 つの流れに限り、その段の全ての門の意味を上書きする。宣言できるのは `{ whenClosed: "fail", failureStatus }` だけ。門を持たない段に書くと `orderedSteps` が throw する |
|
|
45
46
|
| `flowStepGates(flowStep)` | 流れの中で段が持つ門 (上書きを適用した結果、宣言順)。ワーカーが評価し、コンソールが描くのはこの値であり、`PIPELINE_STEPS[key].gates` を直に読まない |
|
|
46
47
|
|
|
47
|
-
- 子の読み取りの段 (`ocr_children`) は門を宣言しない。子の文字層 (テキスト・メール・Office・PDF) は `ENABLE_OCR` に関係なく読まなければならず、段ごと飛ばすと添付のテキストが本文から消えるためである。認識の要る子だけが API
|
|
48
|
+
- 子の読み取りの段 (`ocr_children`) は門を宣言しない。子の文字層 (テキスト・メール・Office・PDF) は `ENABLE_OCR` に関係なく読まなければならず、段ごと飛ばすと添付のテキストが本文から消えるためである。認識の要る子だけが API サーバーの中で `ENABLE_OCR` に従い、閉じていればワーカーはその子の行を `gate_closed:ENABLE_OCR` で `SKIPPED` と記録する (段のキーに OCR の名が残るのは、共有 DB の段の記録と集計がこのキーで引かれるためであり、運用者に見せる名前は「子アセットの読み取り」)。
|
|
48
49
|
- 出荷する上書きは 2 つだけ: 画像の流れの `ocr_document` とメディアの流れの `analyze_media`。どちらも流れの唯一の本文の出所であり、フラグ (`ENABLE_OCR` / `ENABLE_MEDIA_ANALYSIS`) が閉じていれば、その門で実行を `FAILED_EXTRACT` として止める。文字層を持つ流れ (pdf / email / office / google_native) の `ocr_document` は宣言どおり飛ばす。
|
|
49
50
|
- 実行側の契約 (`orderedSteps` の docstring): ワーカーは `orderedSteps(flow)` の順に段を走らせ、各段の前に `flowStepGates(step)` を評価する。最初に閉じていた門が決める — `skip` は段を `gate_closed:<flag>` で `SKIPPED` と記録して次へ進み、`fail` は段を `FAILED` と記録してその門の `failureStatus` で実行を終える。段は全ての門が開いているときだけ走る。
|
|
50
51
|
- どの流れも、門で飛ばされうる段だけに本文を頼らない (本文を作りうる段 `extract_text` / `ocr_document` / `analyze_media` のうち少なくとも 1 つは、閉じれば実行を止めるか門を持たない)。テストが出荷する全ての流れでこれを検査する。
|
|
@@ -92,7 +93,7 @@ Transport- and DB-agnostic storage metadata AI enrichment core: canonical types,
|
|
|
92
93
|
|
|
93
94
|
## Integrity audit contract / 整合性監査の契約
|
|
94
95
|
|
|
95
|
-
監査は API
|
|
96
|
+
監査は API サーバーの中で走り、`td_integrity_audit_run` / `td_integrity_audit_quantity` / `td_integrity_audit_finding` へ記録する。ホストはその行を読み、次の形でコンソールへ渡す。記録の語彙 (下の表の `IntegrityStoreSchema` から `IntegrityRepairSkipReasonSchema` までの 12 の列挙と `IntegrityFindingItemClassSchema`) と区分の方針 (`INTEGRITY_CLASS_POLICY`) は各表の CHECK 制約の写しであり、実行の行の制約が持つ削除印の保持日数の範囲は、実行の見出しを検める `SYSTEM_PARAMETER_RANGES.INTEGRITY_TOMBSTONE_RETENTION_DAYS` の写しである。写しの一致はホストの試験が DDL を読んで確かめる (本パッケージはホストの DDL の置き場所を知らない)。
|
|
96
97
|
|
|
97
98
|
命令の語彙 (`IntegrityCommandSchema` / `IntegrityCommandFailureCodeSchema` と命令ごとのその部分集合) はコンソールの契約の持ち物で、DDL に写しを持たない。全てのスキーマは `.strict()` で、未知の鍵と鍵の欠落を拒む (最初の頁で省く `IntegrityFindingsQuerySchema.after` を除く)。`null` は宣言した項目 (測っていない・まだ無い) だけが持てる。
|
|
98
99
|
|
|
@@ -104,7 +105,7 @@ Transport- and DB-agnostic storage metadata AI enrichment core: canonical types,
|
|
|
104
105
|
|
|
105
106
|
これらを破る値は書き手か読み手の欠陥であり、契約は描かずに拒む。
|
|
106
107
|
|
|
107
|
-
実行の UID (`runUid` / `basisRunUid`、所見の要求と応答の `runUid` を含む) は 16 進の桁を大小文字を問わず受け入れ、小文字へ直して返す (RFC 9562 は桁を大小文字を問わず読み、小文字で書く)。API
|
|
108
|
+
実行の UID (`runUid` / `basisRunUid`、所見の要求と応答の `runUid` を含む) は 16 進の桁を大小文字を問わず受け入れ、小文字へ直して返す (RFC 9562 は桁を大小文字を問わず読み、小文字で書く)。API サーバーは小文字で発行し、SQL Server の `uniqueidentifier` は tedious から大文字で届くが、契約を通した後は 1 つの実行が 1 つの綴りを持つ (コンソールは実行を文字列の等しさで比べる)。ホストの読み手が綴りを直す必要は無い。
|
|
108
109
|
|
|
109
110
|
契約の時刻 (`readAt`・`startedAt`・`heartbeatAt` など) の前後は、`Date.parse` でなく公開する `isStrictlyEarlier(earlier, later)` で比べる (`Date.parse` はミリ秒までしか保たず、100 ns 違う 2 つの時刻を等しいと見る)。両方が契約の受ける時刻で `earlier` が `later` より厳密に前のときだけ `true` を返し、時差 (`Z`・`±HH:mm`・`±HHmm`)・秒の省略・1 秒未満の全ての桁を読んで比べる。どちらかが契約の受ける時刻でなければどちらの向きにも `false` なので、`!isStrictlyEarlier(a, b)` は「`a` が `b` の後か同時」ではない。比べる前に値を契約 (`IntegrityAuditOverviewSchema` など) で検める。契約自身も同じ関数で、`finishedAt` と `heartbeatAt` が `startedAt` より前でないことを検める。
|
|
110
111
|
|
|
@@ -112,8 +113,8 @@ Transport- and DB-agnostic storage metadata AI enrichment core: canonical types,
|
|
|
112
113
|
| --- | --- |
|
|
113
114
|
| `IntegrityStoreSchema` | `QDRANT` / `NEO4J` |
|
|
114
115
|
| `IntegrityScopeRoleSchema` | `PRODUCTION` / `VARIANT` / `LABEL` |
|
|
115
|
-
| `IntegrityItemClassSchema` |
|
|
116
|
-
| `IntegrityFindingItemClassSchema` | 所見を記録する
|
|
116
|
+
| `IntegrityItemClassSchema` | 25 区分 (`EXPECTED`・`LIVE`・`HISTORY`・`TOMBSTONE`・`AWAITING_SUCCESSOR`・情報の 7 区分・不整合の 13 区分)。意味は監査の判定表 (S1 §6.5) が定める |
|
|
117
|
+
| `IntegrityFindingItemClassSchema` | 所見を記録する 22 区分 (`EXPECTED`・`LIVE`・`HISTORY` を除く。`CK_td_integrity_audit_finding_vocabulary`)。所見を開けるのはこの区分の組だけ |
|
|
117
118
|
| `IntegrityUnitSchema` | `POINT` / `NODE` / `CHUNK` / `DOCUMENT` |
|
|
118
119
|
| `IntegrityDispositionSchema` | `EXPECTED` / `HEALTHY` / `RETAINED` / `INFORMATIONAL` / `DISCREPANCY` |
|
|
119
120
|
| `IntegrityRepairActionSchema` | `NONE` / `PURGE` / `FLAG` / `REPROJECT` |
|
|
@@ -122,7 +123,7 @@ Transport- and DB-agnostic storage metadata AI enrichment core: canonical types,
|
|
|
122
123
|
| `IntegrityVerdictSchema` | `CONSISTENT` / `INCONSISTENT` / `UNDETERMINED` |
|
|
123
124
|
| `IntegrityPhaseSchema` | `QDRANT` / `NEO4J` / `DOCUMENTS` |
|
|
124
125
|
| `IntegrityRepairOutcomeSchema` | `APPLIED` / `SKIPPED` / `FAILED` |
|
|
125
|
-
| `IntegrityRepairSkipReasonSchema` | `RECLASSIFIED` / `IN_FLIGHT` / `DESTINATION_PENDING` / `BASIS_EXHAUSTED` / `PROJECTION_REFUSED` |
|
|
126
|
+
| `IntegrityRepairSkipReasonSchema` | `RECLASSIFIED` / `IN_FLIGHT` / `DESTINATION_PENDING` / `BASIS_EXHAUSTED` / `PROJECTION_REFUSED` / `PIPELINE_FAILED` / `UNRECORDED` / `OUTSIDE` (後の 4 つは、文書の再投影で書き直す項目を、文書を再投影しないときに文書の所属で見送る理由: 前段の失敗・投影記録なし・投影の門が拒む・店が文書を期待しない (ドメインが不明・本番の戦略なし・その店の段が閉じている・生きたチャンクなし)) |
|
|
126
127
|
|
|
127
128
|
区分が扱いと処置を決める (`INTEGRITY_CLASS_POLICY`、`CK_td_integrity_audit_quantity_class_policy` の写し。表と各行は凍結してある):
|
|
128
129
|
|
|
@@ -132,12 +133,14 @@ Transport- and DB-agnostic storage metadata AI enrichment core: canonical types,
|
|
|
132
133
|
| `LIVE` | `HEALTHY` | `NONE` |
|
|
133
134
|
| `HISTORY`・`TOMBSTONE`・`AWAITING_SUCCESSOR` | `RETAINED` | `NONE` |
|
|
134
135
|
| `IN_FLIGHT`・`UNPLACED`・`UNRECORDED`・`UNREFERENCED`・`CHANGED_AFTER_START`・`PIPELINE_FAILED`・`PROJECTION_REFUSED` | `INFORMATIONAL` | `NONE` |
|
|
135
|
-
| `ORPHAN`・`TOMBSTONE_EXPIRED`・`STALE_REVISION`・`MISPLACED` | `DISCREPANCY` | `PURGE` |
|
|
136
|
+
| `ORPHAN`・`TOMBSTONE_EXPIRED`・`STALE_REVISION`・`MISPLACED`・`OUT_OF_TIER` | `DISCREPANCY` | `PURGE` |
|
|
136
137
|
| `UNPROPAGATED_DELETE`・`UNMARKED_SUPERSEDED` | `DISCREPANCY` | `FLAG` |
|
|
137
|
-
| `
|
|
138
|
-
| `MISSING`・`COUNT_MISMATCH` | `DISCREPANCY` | `REPROJECT` |
|
|
138
|
+
| `DETACHED`・`UNKEYED`・`VARIANT_FLAG_DRIFT` | `DISCREPANCY` | `NONE` |
|
|
139
|
+
| `FLAG_DRIFT`・`MISSING`・`COUNT_MISMATCH` | `DISCREPANCY` | `REPROJECT` |
|
|
139
140
|
|
|
140
|
-
|
|
141
|
+
`REPROJECT` は文書に働く。文書の区分 (`MISSING`・`COUNT_MISMATCH`) では文書を再投影し、項目の区分 (`FLAG_DRIFT`) では項目を文書の再投影で書き直し (修復済は文書の再投影が成功したことを表し、項目を読み直さない)、再投影しない文書の項目は理由 (`IntegrityRepairSkipReasonSchema`) を付けて見送る。`OUT_OF_TIER` は `ORPHAN` と同じく除き、その数は根拠の走査の組の件数を上限とする。
|
|
142
|
+
|
|
143
|
+
判定 (`IntegrityVerdictSchema`) は `DISCREPANCY` の量を数え、`CONSISTENT` になれるのは扱いに依らず全ての量が測れたときだけ (測れた不整合が 1 つでも正なら、他の量の未測定に依らず `INCONSISTENT`)。判定の規則は API サーバーが持ち、この契約は判定と量の突き合わせをしない。判定とタイルは単位 (`IntegrityUnitSchema`) の違う量を足さない。単位を混ぜた唯一の和は、不成功の修復の `repairAppliedItems` (除去したか印を付けた点とノードの数。処置が `PURGE` と `FLAG` の量の直した件数の和で、再投影で書き直した項目は数えない) である。
|
|
141
144
|
|
|
142
145
|
| Schema | Rules checked across fields / 項目の間で検める規則 |
|
|
143
146
|
| --- | --- |
|
|
@@ -146,6 +149,7 @@ Transport- and DB-agnostic storage metadata AI enrichment core: canonical types,
|
|
|
146
149
|
| `IntegrityActiveRunSchema` | 実行は `RUNNING`。`heartbeatAt` は `run.startedAt` より前でない。段が `null` なら範囲・進行・総数も `null`。`DOCUMENTS` の段は範囲 (`phaseScope`) を持たない。進行は見積もりの総数を超えうる |
|
|
147
150
|
| `IntegrityAuditOverviewSchema` | `lastCompleted.run` は `COMPLETED` で、量は (店, 範囲, 区分) の組ごとに 1 つ、`SCAN` の量は修復の件数を持たない。`newerUnsuccessful.run` は `FAILED` / `CANCELLED` / `ABANDONED`。不成功の `SCAN` は `repairAppliedItems` を持たず、不成功の `REPAIR` の `hasNewerRepair` は真 (それ自身がより新しい修復)。入れ子の見出し・量・実行中の実行もそれぞれの規則で検める |
|
|
148
151
|
| `IntegrityFindingSchema` | `repairErrorClass` は `FAILED` だけ、`repairSkipReason` は `SKIPPED` だけ。`sequence` と `metadataId` (SoT の行の ID) は 1 以上の整数。`fileUri` と `revision` は派生ストアの項目が名乗る値の写しなので、空の URI と 0 以下の版もそのまま運ぶ (`revision` は整数) |
|
|
152
|
+
| `IntegrityPlacementObservedSchema` | `UNPLACED` と `OUT_OF_TIER` の所見の `observed` を読む形。`sotDomain` (SoT が項目の現行の文書に与えるドメイン) は必須で文字列か `null`、他の観測値の鍵はそのまま通す。`null` は文書がドメインを持たないこと (再同期が導き直す)、`UNPLACED` の文字列は本番の戦略の無いドメイン、`OUT_OF_TIER` の文字列は戦略がその店の段を閉じたドメイン (`OUT_OF_TIER` は必ず文字列を持つ)。組はドメインを混ぜるので、ドメインは行ごとの値で組の値ではない。SoT が書いた値の写しなので空の文字列も拒まない |
|
|
149
153
|
| `IntegrityFindingPageSchema` | 行は `sequence` の昇順で重複しない。`nextAfter` は `null` か、この頁の最後の行の `sequence`。`recordedCount` は `totalCount` と突き合わせない (書き手は鍵の無いグラフのノードを数えた後に標本を取るので、その間に作られたノードで標本が全数を超えうる) |
|
|
150
154
|
| `IntegrityFindingsQuerySchema` | `itemClass` は所見を記録する区分 (`IntegrityFindingItemClassSchema`) だけ。`limit` は必須で 1〜`INTEGRITY_FINDINGS_PAGE_LIMIT_MAX` (100) の整数 (0・負・`NaN`・文字列を拒む)。`after` は 1 以上の整数で、最初の頁では省く |
|
|
151
155
|
|
|
@@ -155,7 +159,7 @@ Transport- and DB-agnostic storage metadata AI enrichment core: canonical types,
|
|
|
155
159
|
- 中止 (`IntegrityCancelFailureCodeSchema`): `DEPLOYMENT_DISABLED` / `RUN_ALREADY_FINISHED` / `FORBIDDEN` / `UPSTREAM_FAILED` (中止も共有の DB の実行の行を書くので、実行の切替を課される (修復の切替は課さない)。実行を始めることも根拠を名指すことも無い)
|
|
156
160
|
- 命令の語彙の型は `IntegrityCommandFailureCodeFor<Command>` で引ける。画面の文の表は命令ごとにこの型で漏れなく書ける。
|
|
157
161
|
- 表が名指す `code` は、その行の状態を持つ (`DEPLOYMENT_DISABLED` は 503、`RUN_ALREADY_ACTIVE` / `BASIS_INVALID` / `RUN_ALREADY_FINISHED` は 409、`FORBIDDEN` は 403)。例外は状態の無い `FORBIDDEN` だけ (ホストはトークンを持たない命令を送らずに拒むので、応答が無い)。`UPSTREAM_FAILED` は表に無い全ての失敗で、来た状態を持つか、応答が無ければ `status: null`。違反は `status` の問題として拒む。
|
|
158
|
-
- (状態, 業務コード) → `code` の表は `integrityCommandCodes.json` だけが持つ (このリポジトリの中では API
|
|
162
|
+
- (状態, 業務コード) → `code` の表は `integrityCommandCodes.json` だけが持つ (このリポジトリの中では API サーバーの試験も同じファイルを読む。公開する成果物は表を埋め込み、表と各行を凍結する。各行はモジュールの読み込みの時に検め、`UPSTREAM_FAILED` へ写す行・他の鍵を持つ行・300〜599 の外の状態の行があれば読み込みが投げる)。行の `code` がどの命令のものかは表でなく命令ごとの語彙が決める。
|
|
159
163
|
- `integrityCommandFailureCodeOf(command, status, errorCode)` は、状態が等しく、業務コードが `null` か等しく、`code` がその命令の語彙である最初の行の `code` を、その命令の語彙の型で返す。業務コードが `null` の行 (`403` → `FORBIDDEN`) はその状態の全ての業務コードに一致する。その命令について一致する行の無い組 (もう一方の命令だけの語彙へ写す組、`503` / `5030` と `503` / `5032` を含む) は `UPSTREAM_FAILED`。返した `code` は、命令と応答の状態とともに `IntegrityCommandFailureSchema` が受け入れる失敗になる。
|
|
160
164
|
|
|
161
165
|
| `status` | `errorCode` | `code` | 開始 | 中止 |
|
|
@@ -178,7 +182,7 @@ Transport- and DB-agnostic storage metadata AI enrichment core: canonical types,
|
|
|
178
182
|
| `INTEGRITY_RUN_RETENTION_COUNT` | 2〜100 |
|
|
179
183
|
| `POLICY_CONFLICT_MAX_TIE_GROUP_SIZE` | 2〜60 |
|
|
180
184
|
|
|
181
|
-
- 表の正本は `src/systemParameterRanges.json` の 1 つ。他の言語のホストは自分の写しを持ち、このリポジトリの中ではその試験がこのファイルを読んで一致を確かめる (API
|
|
185
|
+
- 表の正本は `src/systemParameterRanges.json` の 1 つ。他の言語のホストは自分の写しを持ち、このリポジトリの中ではその試験がこのファイルを読んで一致を確かめる (API サーバーの `PARAMETER_RANGES`)。公開する成果物は表を埋め込む。
|
|
182
186
|
- `SYSTEM_PARAMETER_RANGES` は表と各値域を凍結してあり、型も値域まで読み取り専用である (プロセスの中の読み手の 1 つが値域を広げ、他の書き手と読み手の拒否を外すことができない)。
|
|
183
187
|
- `INTEGRITY_TOMBSTONE_RETENTION_DAYS` の値域は、実行の行の制約 (保持日数の範囲) と実行の見出しの契約 (`IntegrityRunHeaderSchema.tombstoneRetentionDays`) の範囲でもある。制約はこの表の写しなので、値域を変えるときは制約も同じ変更で改める (ホストの試験が一致を検める)。
|
|
184
188
|
- 表が抑えるパラメータは全て整数である。整数でないパラメータは、項目が型を宣言するまで表に加えられない。
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var M=Object.defineProperty;var pt=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var ut=Object.prototype.hasOwnProperty;var mt=(e,t)=>{for(var n in t)M(e,n,{get:t[n],enumerable:!0})},yt=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of dt(t))!ut.call(e,s)&&s!==n&&M(e,s,{get:()=>t[s],enumerable:!(i=pt(t,s))||i.enumerable});return e};var ft=e=>yt(M({},"__esModule",{value:!0}),e);var xn={};mt(xn,{AmountEntrySchema:()=>me,BaseEnrichmentClient:()=>A,BodySourceSchema:()=>Ze,BoundingBoxSchema:()=>Ct,CIRCUIT_BREAKER_SERVICES:()=>ae,CanonicalDomainKeySchema:()=>Ee,ChapterSegmentSchema:()=>de,ChunkingStrategySchema:()=>bt,CircuitBreakerStatusSchema:()=>xt,ConfidentialityLevelSchema:()=>D,DISPATCH_DEGRADATION_REASONS:()=>ce,DOCUMENT_KINDS:()=>j,DOCUMENT_KIND_LABELS:()=>Dt,DocumentKindSchema:()=>ne,DocumentStructuredDataSchema:()=>Tt,ENRICHMENT_STAGES:()=>re,EnrichmentClient:()=>H,EnrichmentClientError:()=>I,EnrichmentSyncStatusSchema:()=>Nt,FILTERABLE_CONFIDENTIALITY_LEVELS:()=>St,FileUriSchema:()=>At,GRAPH_INDEX_LIMITS:()=>Nn,GraphSearchHitSchema:()=>he,INTEGRITY_CLASS_POLICY:()=>we,INTEGRITY_COMMAND_CODES:()=>W,INTEGRITY_FINDINGS_PAGE_LIMIT_MAX:()=>Be,IntegrityActiveRunSchema:()=>$e,IntegrityAuditOverviewSchema:()=>Zt,IntegrityCancelFailureCodeSchema:()=>qe,IntegrityCommandFailureCodeSchema:()=>k,IntegrityCommandFailureSchema:()=>cn,IntegrityCommandReplySchema:()=>dn,IntegrityCommandSchema:()=>X,IntegrityDispositionSchema:()=>ve,IntegrityFindingItemClassSchema:()=>Fe,IntegrityFindingPageSchema:()=>on,IntegrityFindingSchema:()=>Ve,IntegrityFindingsQuerySchema:()=>an,IntegrityItemClassSchema:()=>Q,IntegrityPhaseSchema:()=>ze,IntegrityQuantitySchema:()=>Ye,IntegrityRepairActionSchema:()=>ke,IntegrityRepairOutcomeSchema:()=>Ke,IntegrityRepairSkipReasonSchema:()=>He,IntegrityRunHeaderSchema:()=>v,IntegrityRunModeSchema:()=>Me,IntegrityRunStatusSchema:()=>Ue,IntegrityScopeRoleSchema:()=>Pe,IntegrityStartFailureCodeSchema:()=>Xe,IntegrityStoreSchema:()=>J,IntegrityUnitSchema:()=>Le,IntegrityVerdictSchema:()=>Ge,LOCAL_DEGRADATION_REASONS:()=>se,MIME_KIND_RULES:()=>Ae,MODE_TIERS:()=>N,ModelProviderSchema:()=>oe,NOTHING_TO_READ_TOKENS:()=>tt,NothingToReadTokenSchema:()=>nt,PIPELINE_FLOWS:()=>Ne,PIPELINE_PHASES:()=>Pt,PIPELINE_STEPS:()=>$,PIPELINE_STEP_KEYS:()=>Y,PipelineRunRecordSchema:()=>Sn,PipelineRunStatusSchema:()=>Je,PipelineRunSummarySchema:()=>hn,PipelineStepKeySchema:()=>b,PipelineStepMetricSchema:()=>In,PipelineStepRecordSchema:()=>it,PipelineStepStatusSchema:()=>Qe,PipelineTriggerSchema:()=>We,QUARANTINED_CONFIDENTIALITY_LEVEL:()=>O,REMOTE_DEGRADATION_REASONS:()=>le,SEARCH_DEGRADATION_REASONS:()=>_t,SEARCH_MODES:()=>G,SEARCH_PARAM_LIMITS:()=>Et,SYSTEM_PARAMETER_RANGES:()=>x,SearchHitSchema:()=>Se,SearchMetadataSchema:()=>fe,SearchModeSchema:()=>ye,SearchRequestSchema:()=>z,SearchResponseSchema:()=>K,StageProvenanceSchema:()=>et,TenantIdSchema:()=>pe,TranscriptSegmentSchema:()=>ue,assertBoundedSystemParameter:()=>Kt,assertSystemParameterInRange:()=>zt,classifyDocumentKind:()=>Ot,comparePhases:()=>kt,enrichmentStage:()=>An,flowFor:()=>Ft,flowStepGates:()=>Lt,formatSkipReason:()=>mn,generateUuidV7:()=>Cn,integrityCommandFailureCodeOf:()=>pn,isEnrichmentStageKey:()=>_n,isStrictlyEarlier:()=>T,isValidUuidV7:()=>lt,modeFusesRankings:()=>Rt,modeNeedsRemoteTiers:()=>ht,modeScoreIsSimilarity:()=>gt,narrowModeToAllowedTiers:()=>It,orderedSteps:()=>vt,parseSkipReason:()=>ot,uuidv7ToDate:()=>Tn});module.exports=ft(xn);var I=class extends Error{statusCode;responseBody;parsedBody;constructor(t,n,i,s){super(t),this.name="EnrichmentClientError",this.statusCode=n,this.responseBody=i,this.parsedBody=s}},A=class{baseUrl;apiKey;fetchFn;timeoutMs;constructor(t){if(!t||typeof t.baseUrl!="string"||t.baseUrl.trim().length===0)throw new Error("baseUrl is required and must be a non-empty string for EnrichmentClient.");let n=t.baseUrl.trim().replace(/\/$/,"");if(t.apiKey&&n.startsWith("http://")&&!n.includes("localhost")&&!n.includes("127.0.0.1"))throw new Error("Security Violation: Transmitting Bearer tokens over unencrypted HTTP to non-localhost hosts is strictly prohibited.");this.baseUrl=n,this.apiKey=t.apiKey,this.fetchFn=t.fetchFn??fetch,this.timeoutMs=t.timeoutMs&&t.timeoutMs>0?t.timeoutMs:3e4}async request(t,n,i){let s=`${this.baseUrl}${t}`,c={Accept:"application/json","Content-Type":"application/json","X-Tenant-Id":n};this.apiKey&&(c.Authorization=`Bearer ${this.apiKey}`);let d=new AbortController,m=setTimeout(()=>d.abort(),this.timeoutMs),f;try{f=await this.fetchFn(s,{method:"POST",headers:c,body:JSON.stringify(i),signal:d.signal})}catch(y){let g=y instanceof Error?y.message:String(y);throw new I(`Network request failed for POST ${s}: ${g}`,0,"")}finally{clearTimeout(m)}if(!f.ok){let y=await f.text().catch(()=>""),g;try{g=JSON.parse(y)}catch{}throw new I(`API request failed with status ${f.status}: ${y}`,f.status,y,g)}let R=await f.text().catch(()=>"");if(R.trim().length!==0)try{return JSON.parse(R)}catch(y){let g=y instanceof Error?y.message:String(y);throw new I(`Failed to parse response JSON from ${s}: ${g}`,f.status,R)}}};var r=require("zod");var U=require("zod"),oe=U.z.enum(["google_cloud","google_vision","yomitoku_local","faster_whisper_local","google_speech","ollama_local","openai","anthropic","azure_openai","bedrock","custom_openai_compatible"]),D=U.z.enum(["PUBLIC","INTERNAL","DEPARTMENT","CONFIDENTIAL","RESTRICTED"]),O="RESTRICTED";var Et={rrfK:{min:1,max:200,default:60},alpha:{min:0,max:1,default:.7},threshold:{min:0,max:1},limit:{min:1,max:50,default:10}},ie=D.options.filter(e=>e!==O);if(ie.length===0)throw new Error("The confidentiality vocabulary left nothing filterable after removing the quarantined level; a validator built from this list would reject every request.");var St=ie,G=["KEYWORD","SPARSE","DENSE","HYBRID","GRAPH_TRAVERSE"],N={KEYWORD:{dense:!1,sparse:!1,graph:!1,lexical:!0},SPARSE:{dense:!1,sparse:!0,graph:!1,lexical:!1},DENSE:{dense:!0,sparse:!1,graph:!1,lexical:!1},HYBRID:{dense:!0,sparse:!0,graph:!0,lexical:!0},GRAPH_TRAVERSE:{dense:!1,sparse:!1,graph:!0,lexical:!1}};function ht(e){let t=N[e];return t.dense||t.sparse||t.graph}function gt(e){let t=N[e];return t.dense&&!t.sparse}function It(e,t){let n=N[e],i=(n.dense||n.sparse)&&t.vector,s=n.graph&&t.graph;return i||s?i?s?{mode:e,discardGraph:!1}:n.dense&&n.sparse?{mode:e,discardGraph:!0}:{mode:n.dense?"DENSE":"SPARSE",discardGraph:!1}:{mode:"GRAPH_TRAVERSE",discardGraph:!1}:null}function Rt(e){let t=N[e];return[t.dense,t.sparse,t.graph,t.lexical].filter(Boolean).length>1}var ae=["vector","graph"],se=["empty_query","caller_token_unavailable","time_window_unsupported"],le=["vector_tier_not_configured","graph_tier_not_configured","no_active_vector_collection","vector_collections_missing"],ce=["remote_tiers_unavailable","remote_tiers_timed_out","remote_tiers_refused_caller","remote_tiers_rejected_request","remote_tiers_failed","remote_tiers_not_executed","vector_search_disabled","graph_search_disabled"],_t=[...se,...le,...ce,...ae.map(e=>`circuit_breaker_open:${e}`)];var pe=r.z.string().trim().min(1,"tenant_id must be a non-empty string"),At=r.z.string().trim().min(1,"file_uri must be a non-empty string"),Nt=r.z.enum(["PENDING","EXTRACTING","ENRICHING","PROJECTING","SYNCED","FAILED_EXTRACT","FAILED_ENRICH","FAILED_VECTOR","FAILED_GRAPH"]),Ct=r.z.object({page:r.z.number().int().positive().optional(),x:r.z.number().nonnegative().optional(),y:r.z.number().nonnegative().optional(),width:r.z.number().positive().optional(),height:r.z.number().positive().optional(),start_sec:r.z.number().nonnegative().optional(),end_sec:r.z.number().nonnegative().optional(),frame_index:r.z.number().int().nonnegative().optional(),timestamp_sec:r.z.number().nonnegative().optional(),scene_confidence:r.z.number().min(0).max(1).optional()}),de=r.z.object({title:r.z.string().trim().min(1),start_sec:r.z.number().nonnegative(),end_sec:r.z.number().nonnegative(),summary:r.z.string()}),ue=r.z.object({start_sec:r.z.number().nonnegative(),end_sec:r.z.number().nonnegative(),speaker:r.z.string().trim().min(1),text:r.z.string()}),me=r.z.object({label:r.z.string(),value:r.z.number(),currency:r.z.string()}),Tt=r.z.object({document_type:r.z.string().optional(),title:r.z.string().optional(),organization:r.z.string().optional(),key_entities:r.z.array(r.z.string()).optional(),dates:r.z.array(r.z.string()).optional(),amounts:r.z.array(me).optional(),media_type:r.z.enum(["video","audio"]).optional(),duration_sec:r.z.number().nonnegative().optional(),chapters:r.z.array(de).optional(),transcript_segments:r.z.array(ue).optional()}),xt=r.z.enum(["CLOSED","OPEN","HALF_OPEN"]),ye=r.z.enum(G),fe=r.z.object({circuit_breaker_status:r.z.string(),quality_tier:r.z.string(),latency_ms:r.z.number().nonnegative(),total_hits:r.z.number().int().nonnegative(),fallback_applied:r.z.boolean(),degraded_reason:r.z.string().nullable()}),Ee=r.z.enum(["CONTRACT_LEGAL","EMAIL_THREAD","DAILY_REPORT","FINANCIAL_REPORT","TECHNICAL_SPEC","MASTER_DATA","MEDIA_ASSET","GENERAL_DOCUMENT"]),bt=r.z.enum(["hierarchical","conversation","section","fixed_size","table_aware","semantic","none","multimodal"]),Se=r.z.object({metadata_id:r.z.number().int().positive(),chunk_index:r.z.number().int().nonnegative(),text:r.z.string(),score:r.z.number()}),he=r.z.object({metadata_id:r.z.number().int().positive(),relation:r.z.string(),target_name:r.z.string()}),z=r.z.object({query:r.z.string().trim().min(1,"query must not be empty"),tenant_id:pe,domain_key:Ee.optional(),limit:r.z.number().int().positive().optional(),department_id:r.z.number().int().positive().optional(),search_mode:ye.optional(),strategy_id:r.z.number().int().positive().optional()}).strict(),K=r.z.object({hits:r.z.array(Se),graph_hits:r.z.array(he),tiers:r.z.record(r.z.string(),r.z.boolean()),metadata:fe});var H=class extends A{async search(t){let n=z.parse(t),i=await this.request("/ai/search/hybrid",n.tenant_id,n);return K.parse(i)}};var j=["email","pdf","office","image","media","text","google_native","other"],Dt={email:"\u30E1\u30FC\u30EB",pdf:"PDF",office:"Office \u6587\u66F8",image:"\u753B\u50CF",media:"\u97F3\u58F0\u30FB\u52D5\u753B",text:"\u30C6\u30AD\u30B9\u30C8",google_native:"Google \u30CD\u30A4\u30C6\u30A3\u30D6",other:"\u305D\u306E\u4ED6"},Ae=[["message/rfc822","email"],["application/pdf","pdf"],["application/vnd.openxmlformats-officedocument.*","office"],["application/msword","office"],["application/vnd.ms-excel","office"],["application/vnd.ms-powerpoint","office"],["application/vnd.google-apps.*","google_native"],["image/svg+xml","text"],["image/emf","other"],["image/x-emf","other"],["image/wmf","other"],["image/x-wmf","other"],["image/*","image"],["audio/*","media"],["video/*","media"],["text/*","text"],["application/json","text"],["application/xml","text"]];function Ot(e){let t=(e.split(";")[0]??"").trim().toLowerCase();for(let[n,i]of Ae)if(n.endsWith("*")?t.startsWith(n.slice(0,-1)):t===n)return i;return"other"}var Y=["delete_child_assets","extract_text","analyze_media","extract_assets","ocr_children","ocr_document","resolve_body","enrich_document","project_to_indexes"],Pt=["EXTRACTING","ENRICHING","PROJECTING"],B=e=>({featureFlagKey:e,whenClosed:"skip",failureStatus:null}),ge=(e,t)=>({featureFlagKey:e,whenClosed:"fail",failureStatus:t}),$={delete_child_assets:{key:"delete_child_assets",label:"\u65E7\u7248\u306E\u5B50\u30A2\u30BB\u30C3\u30C8\u524A\u9664",description:"\u3053\u306E\u7248\u3088\u308A\u524D\u306E\u7248\u304C\u751F\u3093\u3060\u5B50\u30A2\u30BB\u30C3\u30C8\u3092\u4FDD\u7BA1\u5C64\u3068\u7D22\u5F15\u304B\u3089\u5916\u3059\u3002",endpoint:"/ai/assets/delete",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[],capability:null,fanOut:null},extract_text:{key:"extract_text",label:"\u6587\u5B57\u5C64\u306E\u62BD\u51FA",description:"\u6587\u66F8\u304C\u6301\u3064\u6587\u5B57\u5C64 (PDF \u306E\u6587\u5B57\u30FBOffice \u306E\u672C\u6587\u30FB\u30E1\u30FC\u30EB\u306E\u672C\u6587\u3068\u898B\u51FA\u3057) \u3092\u8AAD\u307F\u3001\u4F4D\u7F6E\u60C5\u5831\u3068\u5171\u306B\u4FDD\u5B58\u3059\u308B\u3002",endpoint:"/ai/enrichment/extract",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[],capability:null,fanOut:null},analyze_media:{key:"analyze_media",label:"\u30E1\u30C7\u30A3\u30A2\u89E3\u6790",description:"\u97F3\u58F0\u30FB\u52D5\u753B\u3092\u8EE2\u5199\u3057\u3001\u767A\u8A71\u533A\u9593\u4ED8\u304D\u306E\u30C1\u30E3\u30F3\u30AF\u3068\u30AD\u30FC\u30D5\u30EC\u30FC\u30E0\u6570\u3092\u8A18\u9332\u3059\u308B\u3002",endpoint:"/ai/media/analyze",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[B("ENABLE_MEDIA_ANALYSIS")],capability:"transcription",fanOut:null},extract_assets:{key:"extract_assets",label:"\u5B50\u30A2\u30BB\u30C3\u30C8\u306E\u62BD\u51FA",description:"\u57CB\u3081\u8FBC\u307F\u753B\u50CF\u3084\u30E1\u30FC\u30EB\u306E\u6DFB\u4ED8\u3092\u5B50\u30A2\u30BB\u30C3\u30C8\u3068\u3057\u3066\u5207\u308A\u51FA\u3057\u3001\u6587\u66F8\u306E\u96A3\u306B\u4FDD\u7BA1\u3057\u3066\u767B\u9332\u3059\u308B\u3002",endpoint:"/ai/assets/extract",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[B("ENABLE_ASSET_EXTRACTION")],capability:"asset_extraction",fanOut:null},ocr_children:{key:"ocr_children",label:"\u5B50\u30A2\u30BB\u30C3\u30C8\u306E\u8AAD\u307F\u53D6\u308A",description:"\u5207\u308A\u51FA\u3057\u305F\u5B50\u30A2\u30BB\u30C3\u30C8\u3092\u62BD\u51FA\u9806\u306B 1 \u4EF6\u305A\u3064\u8AAD\u307F\u3001\u6587\u5B57\u5C64\u3092\u8AAD\u3081\u308B\u5B50 (\u30C6\u30AD\u30B9\u30C8\u30FB\u30E1\u30FC\u30EB\u30FBOffice\u30FBPDF) \u306F\u305D\u306E\u6587\u5B57\u5C64\u3092\u3001\u8AAD\u3081\u306A\u3044\u5B50\u306F\u7248\u9762\u3092\u5149\u5B66\u8A8D\u8B58\u3067\u8AAD\u3093\u3067\u3001\u5B50\u3054\u3068\u306B\u672C\u6587\u3068\u51FA\u6240\u3092\u4FDD\u5B58\u3059\u308B\u3002",endpoint:"/ai/ocr/run",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[],capability:"ocr",fanOut:"children"},ocr_document:{key:"ocr_document",label:"\u6587\u66F8\u306E OCR",description:"\u6587\u66F8\u81EA\u8EAB\u306E\u7248\u9762 (\u753B\u50CF\u30FBPDF \u306E\u5404\u30DA\u30FC\u30B8) \u3092\u5149\u5B66\u8A8D\u8B58\u306B\u304B\u3051\u308B\u3002",endpoint:"/ai/ocr/run",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[B("ENABLE_OCR")],capability:"ocr",fanOut:null},resolve_body:{key:"resolve_body",label:"\u672C\u6587\u306E\u78BA\u5B9A",description:"\u6587\u5B57\u5C64\u30FBOCR\u30FB\u8EE2\u5199\u306E\u3069\u308C\u3092\u672C\u6587\u3068\u3059\u308B\u304B\u3092\u6C7A\u3081\u3001\u51FA\u6240\u3092\u8A18\u9332\u3059\u308B\u3002",endpoint:"/ai/enrichment/body",phase:"ENRICHING",failureStatus:"FAILED_ENRICH",gates:[],capability:null,fanOut:null},enrich_document:{key:"enrich_document",label:"\u8981\u7D04\u3068\u69CB\u9020\u5316\u62BD\u51FA",description:"\u672C\u6587\u3092\u30E2\u30C7\u30EB\u3078\u6E21\u3057\u3001\u8981\u7D04\u30FB\u30BF\u30B0\u30FB\u69CB\u9020\u5316\u30C7\u30FC\u30BF\u30FB\u30C9\u30E1\u30A4\u30F3\u5206\u985E\u3092\u5F97\u308B\u3002",endpoint:"/ai/enrichment/document",phase:"ENRICHING",failureStatus:"FAILED_ENRICH",gates:[],capability:"enrichment",fanOut:null},project_to_indexes:{key:"project_to_indexes",label:"\u30D9\u30AF\u30C8\u30EB\u3068\u30B0\u30E9\u30D5\u3078\u306E\u6295\u5F71",description:"\u672C\u6587\u3092\u30C1\u30E3\u30F3\u30AF\u306B\u3057\u3066\u57CB\u3081\u8FBC\u307F\u3001\u30D9\u30AF\u30C8\u30EB\u7D22\u5F15\u3068\u30CA\u30EC\u30C3\u30B8\u30B0\u30E9\u30D5\u3078\u66F8\u304F\u3002",endpoint:"/ai/enrichment/project",phase:"PROJECTING",failureStatus:"FAILED_VECTOR",gates:[ge("ENABLE_VECTOR_INDEXING","FAILED_VECTOR"),ge("ENABLE_GRAPH_INDEXING","FAILED_GRAPH")],capability:null,fanOut:null}},Ie={whenClosed:"fail",failureStatus:"FAILED_EXTRACT"},P=[{step:"delete_child_assets",dependsOn:[]},{step:"extract_text",dependsOn:["delete_child_assets"]},{step:"extract_assets",dependsOn:["extract_text"]},{step:"ocr_children",dependsOn:["extract_assets"]},{step:"ocr_document",dependsOn:["extract_text"]},{step:"resolve_body",dependsOn:["ocr_children","ocr_document"]},{step:"enrich_document",dependsOn:["resolve_body"]},{step:"project_to_indexes",dependsOn:["enrich_document"],chunkSource:"rebuild"}],Re=[{step:"delete_child_assets",dependsOn:[]},{step:"extract_text",dependsOn:["delete_child_assets"]},{step:"resolve_body",dependsOn:["extract_text"]},{step:"enrich_document",dependsOn:["resolve_body"]},{step:"project_to_indexes",dependsOn:["enrich_document"],chunkSource:"rebuild"}],Ne={email:{kind:"email",steps:P},pdf:{kind:"pdf",steps:P},office:{kind:"office",steps:P},google_native:{kind:"google_native",steps:P},image:{kind:"image",steps:[{step:"delete_child_assets",dependsOn:[]},{step:"ocr_document",dependsOn:["delete_child_assets"],gatePolicy:Ie},{step:"resolve_body",dependsOn:["ocr_document"]},{step:"enrich_document",dependsOn:["resolve_body"]},{step:"project_to_indexes",dependsOn:["enrich_document"],chunkSource:"rebuild"}]},media:{kind:"media",steps:[{step:"delete_child_assets",dependsOn:[]},{step:"analyze_media",dependsOn:["delete_child_assets"],gatePolicy:Ie},{step:"resolve_body",dependsOn:["analyze_media"]},{step:"enrich_document",dependsOn:["resolve_body"]},{step:"project_to_indexes",dependsOn:["enrich_document"],chunkSource:"existing"}]},text:{kind:"text",steps:Re},other:{kind:"other",steps:Re}};function Ft(e){return Ne[e]}function Lt(e){let{gates:t}=$[e.step],{gatePolicy:n}=e;return n===void 0?t:t.map(i=>({featureFlagKey:i.featureFlagKey,whenClosed:n.whenClosed,failureStatus:n.failureStatus}))}function vt(e){let t=new Map(e.steps.map(c=>[c.step,c]));for(let c of e.steps){if(c.gatePolicy!==void 0&&$[c.step].gates.length===0)throw new Error(`Flow ${e.kind}: step ${c.step} overrides its gate policy, but the step has no gate to close.`);for(let d of c.dependsOn)if(!t.has(d))throw new Error(`Flow ${e.kind}: step ${c.step} depends on ${d}, which the flow does not contain.`)}let n=[...e.steps],i=new Set,s=[];for(;n.length>0;){let c=n.findIndex(m=>m.dependsOn.every(f=>i.has(f)));if(c===-1)throw new Error(`Flow ${e.kind}: the steps ${n.map(m=>m.step).join(", ")} depend on each other in a cycle.`);let[d]=n.splice(c,1);i.add(d.step),s.push(d)}return s}var _e={EXTRACTING:0,ENRICHING:1,PROJECTING:2};function kt(e,t){return _e[e]-_e[t]}var o=require("zod");var Ce=[{code:"DEPLOYMENT_DISABLED",status:503,errorCode:5035},{code:"RUN_ALREADY_ACTIVE",status:409,errorCode:4091},{code:"BASIS_INVALID",status:409,errorCode:4092},{code:"RUN_ALREADY_FINISHED",status:409,errorCode:4093},{code:"FORBIDDEN",status:403,errorCode:null}];var F=require("zod"),C=F.z.string().uuid().transform(e=>e.toLowerCase()),u=F.z.string().datetime({offset:!0}),l=(e,t,n)=>{e.addIssue({code:F.z.ZodIssueCode.custom,path:[...t],message:n})},Mt=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(?:Z|([+-])(\d{2}):?(\d{2}))$/,Te=e=>{let t=u.safeParse(e).success?Mt.exec(e):null;if(t===null)return null;let[,n,i,s,c,d,m,f,R,y,g]=t,w=new Date(0);w.setUTCFullYear(Number(n),Number(i)-1,Number(s)),w.setUTCHours(Number(c),Number(d),m===void 0?0:Number(m),0);let ct=R===void 0?0:(R==="+"?1:-1)*(Number(y)*3600+Number(g)*60);return{epochSeconds:w.getTime()/1e3-ct,fraction:f===void 0?"":f}},T=(e,t)=>{let n=Te(e),i=Te(t);if(n===null||i===null)return!1;if(n.epochSeconds!==i.epochSeconds)return n.epochSeconds<i.epochSeconds;let s=Math.max(n.fraction.length,i.fraction.length);return n.fraction.padEnd(s,"0")<i.fraction.padEnd(s,"0")};var xe={INTEGRITY_TOMBSTONE_RETENTION_DAYS:{min:1,max:3650},INTEGRITY_FINDING_SAMPLE_LIMIT:{min:1,max:5e3},INTEGRITY_RUN_HEARTBEAT_TIMEOUT_SECONDS:{min:30,max:3600},INTEGRITY_RUN_RETENTION_COUNT:{min:2,max:100},POLICY_CONFLICT_MAX_TIE_GROUP_SIZE:{min:2,max:60}};var Gt=e=>{for(let t of Object.values(e))Object.freeze(t);return Object.freeze(e)},x=Gt(xe),be=e=>Object.hasOwn(x,e),De=(e,t)=>{let{min:n,max:i}=x[e];if(!Number.isInteger(t)||t<n||t>i)throw new RangeError(`${e} \u306F ${n}\u301C${i} \u306E\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)},zt=(e,t)=>{be(e)&&De(e,t)},Kt=(e,t)=>{if(!be(e))throw new TypeError(`The range table bounds no parameter named ${JSON.stringify(e)}.`);De(e,t)};var J=o.z.enum(["QDRANT","NEO4J"]),Pe=o.z.enum(["PRODUCTION","VARIANT","LABEL"]),Q=o.z.enum(["EXPECTED","LIVE","HISTORY","TOMBSTONE","AWAITING_SUCCESSOR","IN_FLIGHT","UNPLACED","UNRECORDED","UNREFERENCED","CHANGED_AFTER_START","PIPELINE_FAILED","PROJECTION_REFUSED","ORPHAN","TOMBSTONE_EXPIRED","UNPROPAGATED_DELETE","STALE_REVISION","MISPLACED","UNMARKED_SUPERSEDED","FLAG_DRIFT","DETACHED","UNKEYED","MISSING","COUNT_MISMATCH"]),Fe=Q.exclude(["EXPECTED","LIVE","HISTORY"]),Le=o.z.enum(["POINT","NODE","CHUNK","DOCUMENT"]),ve=o.z.enum(["EXPECTED","HEALTHY","RETAINED","INFORMATIONAL","DISCREPANCY"]),ke=o.z.enum(["NONE","PURGE","FLAG","REPROJECT"]),p=(e,t)=>Object.freeze({disposition:e,repairAction:t}),we=Object.freeze({EXPECTED:p("EXPECTED","NONE"),LIVE:p("HEALTHY","NONE"),HISTORY:p("RETAINED","NONE"),TOMBSTONE:p("RETAINED","NONE"),AWAITING_SUCCESSOR:p("RETAINED","NONE"),IN_FLIGHT:p("INFORMATIONAL","NONE"),UNPLACED:p("INFORMATIONAL","NONE"),UNRECORDED:p("INFORMATIONAL","NONE"),UNREFERENCED:p("INFORMATIONAL","NONE"),CHANGED_AFTER_START:p("INFORMATIONAL","NONE"),PIPELINE_FAILED:p("INFORMATIONAL","NONE"),PROJECTION_REFUSED:p("INFORMATIONAL","NONE"),ORPHAN:p("DISCREPANCY","PURGE"),TOMBSTONE_EXPIRED:p("DISCREPANCY","PURGE"),UNPROPAGATED_DELETE:p("DISCREPANCY","FLAG"),STALE_REVISION:p("DISCREPANCY","PURGE"),MISPLACED:p("DISCREPANCY","PURGE"),UNMARKED_SUPERSEDED:p("DISCREPANCY","FLAG"),FLAG_DRIFT:p("DISCREPANCY","NONE"),DETACHED:p("DISCREPANCY","NONE"),UNKEYED:p("DISCREPANCY","NONE"),MISSING:p("DISCREPANCY","REPROJECT"),COUNT_MISMATCH:p("DISCREPANCY","REPROJECT")}),Me=o.z.enum(["SCAN","REPAIR"]),Ue=o.z.enum(["RUNNING","COMPLETED","FAILED","CANCELLED","ABANDONED"]),Ge=o.z.enum(["CONSISTENT","INCONSISTENT","UNDETERMINED"]),ze=o.z.enum(["QDRANT","NEO4J","DOCUMENTS"]),Ke=o.z.enum(["APPLIED","SKIPPED","FAILED"]),He=o.z.enum(["RECLASSIFIED","IN_FLIGHT","DESTINATION_PENDING","BASIS_EXHAUSTED","PROJECTION_REFUSED"]),Be=100,E=o.z.number().int().nonnegative(),L=o.z.number().int().min(300).max(599),V=["repairedCount","repairFailedCount","repairSkippedCount"],je=o.z.string().regex(/^[0-9a-f]{64}$/,"A store fingerprint is 64 lowercase hexadecimal digits."),Oe=x.INTEGRITY_TOMBSTONE_RETENTION_DAYS,Ht=o.z.object({runUid:C,mode:Me,status:Ue,requestedBy:o.z.string().min(1),executor:o.z.string().min(1),basisRunUid:C.nullable(),storeFingerprint:je,tombstoneRetentionDays:o.z.number().int().min(Oe.min).max(Oe.max),startedAt:u,finishedAt:u.nullable(),verdict:Ge.nullable(),errorClass:o.z.string().min(1).nullable(),reprojectDocuments:E.nullable(),reprojectRebuildDocuments:E.nullable()}).strict(),Bt=(e,t)=>{let n=e.status==="COMPLETED";e.mode==="REPAIR"!=(e.basisRunUid!==null)&&l(t,["basisRunUid"],"A REPAIR run names its basis SCAN run, and a SCAN run names none."),n!==(e.verdict!==null)&&l(t,["verdict"],"Only a COMPLETED run has a verdict."),n!==(e.reprojectDocuments!==null)&&l(t,["reprojectDocuments"],"Only a COMPLETED run has the count of documents to re-project.");let{reprojectDocuments:i,reprojectRebuildDocuments:s}=e;i===null||s===null?i!==s&&l(t,["reprojectRebuildDocuments"],"The documents a re-projection embeds are counted together with the documents it re-projects."):s>i&&l(t,["reprojectRebuildDocuments"],"The documents a re-projection embeds are no more than the documents it re-projects."),e.status==="RUNNING"!=(e.finishedAt===null)&&l(t,["finishedAt"],"Only a RUNNING run has not finished."),e.finishedAt!==null&&T(e.finishedAt,e.startedAt)&&l(t,["finishedAt"],"A run does not finish before it starts."),(e.status==="FAILED"||e.status==="ABANDONED")!=(e.errorClass!==null)&&l(t,["errorClass"],"Only a FAILED or ABANDONED run names an error class.")},v=Ht.superRefine(Bt),jt=o.z.object({store:J,scopeKey:o.z.string().min(1),scopeRole:Pe,itemClass:Q,unit:Le,disposition:ve,repairAction:ke,itemCount:E.nullable(),unmeasuredReason:o.z.string().min(1).nullable(),measuredAt:u.nullable(),repairedCount:E.nullable(),repairFailedCount:E.nullable(),repairSkippedCount:E.nullable()}).strict(),Yt=(e,t)=>{let n=we[e.itemClass];e.disposition!==n.disposition&&l(t,["disposition"],`A ${e.itemClass} quantity is ${n.disposition}.`),e.repairAction!==n.repairAction&&l(t,["repairAction"],`A repair's action on ${e.itemClass} items is ${n.repairAction}.`);let i=e.itemCount===null;i!==(e.unmeasuredReason!==null)&&l(t,["unmeasuredReason"],"An unmeasured quantity (itemCount null) has a reason, and a measured one has none."),i!==(e.measuredAt===null)&&l(t,["measuredAt"],"Only a measured quantity has a measurement time.");let{repairedCount:s,repairFailedCount:c,repairSkippedCount:d}=e;if(s===null||c===null||d===null){if(V.some(m=>e[m]!==null))for(let m of V)e[m]===null&&l(t,[m],"The repaired, failed and skipped counts are recorded together or not at all.");return}e.repairAction==="NONE"&&l(t,["repairAction"],"Only a class with a repair action carries repair counts."),e.itemCount!==null&&s+c+d>e.itemCount&&l(t,["itemCount"],"The repaired, failed and skipped counts together do not exceed the measured count.")},Ye=jt.superRefine(Yt),$t=o.z.object({run:v,phase:ze.nullable(),phaseScope:o.z.string().min(1).nullable(),phaseDone:E.nullable(),phaseTotal:E.nullable(),heartbeatAt:u,isStale:o.z.boolean(),cancelRequestedAt:u.nullable()}).strict(),Vt=(e,t)=>{if(e.run.status!=="RUNNING"&&l(t,["run","status"],"The active run is a RUNNING run."),T(e.heartbeatAt,e.run.startedAt)&&l(t,["heartbeatAt"],"A run's heartbeat is not earlier than its start."),e.phase===null)for(let n of["phaseScope","phaseDone","phaseTotal"])e[n]!==null&&l(t,[n],"A run with no phase has no phase progress.");e.phase==="DOCUMENTS"&&e.phaseScope!==null&&l(t,["phaseScope"],"The DOCUMENTS phase scans no scope.")},$e=$t.superRefine(Vt),Xt=o.z.object({run:v,quantities:o.z.array(Ye),previousStoreFingerprint:je.nullable()}).strict(),qt=(e,t)=>{e.run.status!=="COMPLETED"&&l(t,["run","status"],"The last completed run is a COMPLETED run.");let n=new Set;for(let[i,s]of e.quantities.entries()){let c=JSON.stringify([s.store,s.scopeKey,s.itemClass]);if(n.has(c)&&l(t,["quantities",i],"A run records each (store, scope, class) cell once."),n.add(c),e.run.mode==="SCAN")for(let d of V)s[d]!==null&&l(t,["quantities",i,d],"A SCAN run repairs nothing, so its quantities carry no repair counts.")}},Jt=["FAILED","CANCELLED","ABANDONED"],Qt=o.z.object({run:v,repairAppliedItems:E.nullable(),hasNewerRepair:o.z.boolean()}).strict(),Wt=(e,t)=>{Jt.includes(e.run.status)||l(t,["run","status"],"A newer unsuccessful run is FAILED, CANCELLED or ABANDONED."),e.run.mode==="SCAN"&&e.repairAppliedItems!==null&&l(t,["repairAppliedItems"],"A SCAN run applies nothing."),e.run.mode==="REPAIR"&&!e.hasNewerRepair&&l(t,["hasNewerRepair"],"An unsuccessful REPAIR run is itself a repair newer than the last completed run.")},Zt=o.z.object({readAt:u,lastCompleted:Xt.superRefine(qt).nullable(),active:$e.nullable(),newerUnsuccessful:Qt.superRefine(Wt).nullable()}).strict(),en=o.z.object({sequence:o.z.number().int().min(1),itemKey:o.z.string().min(1),metadataId:o.z.number().int().positive().nullable(),fileUri:o.z.string().nullable(),revision:o.z.number().int().nullable(),observed:o.z.record(o.z.string(),o.z.unknown()),repairOutcome:Ke.nullable(),repairErrorClass:o.z.string().min(1).nullable(),repairSkipReason:He.nullable()}).strict(),tn=(e,t)=>{e.repairOutcome==="FAILED"!=(e.repairErrorClass!==null)&&l(t,["repairErrorClass"],"Only a FAILED finding names an error class."),e.repairOutcome==="SKIPPED"!=(e.repairSkipReason!==null)&&l(t,["repairSkipReason"],"Only a SKIPPED finding names a skip reason.")},Ve=en.superRefine(tn),nn=o.z.object({rows:o.z.array(Ve),nextAfter:o.z.number().int().min(1).nullable(),recordedCount:E,totalCount:E.nullable()}).strict(),rn=(e,t)=>{for(let[n,i]of e.rows.entries()){let s=e.rows[n-1];s!==void 0&&i.sequence<=s.sequence&&l(t,["rows",n,"sequence"],"A page lists its rows in ascending sequence.")}e.nextAfter!==null&&e.nextAfter!==e.rows.at(-1)?.sequence&&l(t,["nextAfter"],"The next page starts after the sequence of this page's last row.")},on=nn.superRefine(rn),an=o.z.object({runUid:C,store:J,scopeKey:o.z.string().min(1),itemClass:Fe,after:o.z.number().int().min(1).optional(),limit:o.z.number().int().min(1).max(Be)}).strict(),k=o.z.enum(["DEPLOYMENT_DISABLED","RUN_ALREADY_ACTIVE","BASIS_INVALID","RUN_ALREADY_FINISHED","FORBIDDEN","UPSTREAM_FAILED"]),X=o.z.enum(["start","cancel"]),Xe=k.extract(["DEPLOYMENT_DISABLED","RUN_ALREADY_ACTIVE","BASIS_INVALID","FORBIDDEN","UPSTREAM_FAILED"]),qe=k.extract(["DEPLOYMENT_DISABLED","RUN_ALREADY_FINISHED","FORBIDDEN","UPSTREAM_FAILED"]),q={start:Xe,cancel:qe},sn=o.z.object({code:k.exclude(["UPSTREAM_FAILED"]),status:L,errorCode:o.z.number().int().nullable()}).strict(),W=Object.freeze(o.z.array(sn).parse(Ce).map(e=>Object.freeze(e))),ln=(e,t)=>{e.code==="UPSTREAM_FAILED"||e.code==="FORBIDDEN"&&e.status===null||W.some(n=>n.code===e.code&&n.status===e.status)||l(t,["status"],`A ${e.code} failure carries the status of its row in the code table.`)},cn=o.z.discriminatedUnion("command",[o.z.object({command:X.extract(["start"]),code:q.start,status:L.nullable()}).strict(),o.z.object({command:X.extract(["cancel"]),code:q.cancel,status:L.nullable()}).strict()]).superRefine(ln),pn=(e,t,n)=>{let i=q[e],s=W.find(c=>c.status===t&&(c.errorCode===null||c.errorCode===n)&&i.safeParse(c.code).success);return s===void 0?"UPSTREAM_FAILED":s.code},dn=o.z.discriminatedUnion("ok",[o.z.object({ok:o.z.literal(!0),runUid:C}).strict(),o.z.object({ok:o.z.literal(!1),status:L,errorCode:o.z.number().int().nullable()}).strict()]);var a=require("zod");var ne=a.z.enum(j),b=a.z.enum(Y),Je=a.z.enum(["RUNNING","SUCCEEDED","FAILED"]),Qe=a.z.enum(["RUNNING","SUCCEEDED","SKIPPED","FAILED"]),We=a.z.enum(["ingest","retry","resync"]),Ze=a.z.enum(["text_layer","ocr","transcript"]),S=a.z.number().int().nonnegative().nullable(),et=a.z.object({provider:a.z.string().nullable(),model:a.z.string().nullable(),engine:a.z.string().nullable(),prompt_key:a.z.string().nullable(),prompt_version:a.z.number().int().nullable(),duration_ms:S,input_chars:S,output_chars:S,pages_read:S,pages_total:S,chunk_count:S,points_upserted:S,collection:a.z.string().nullable(),embedding_model:a.z.string().nullable(),strategy_id:a.z.number().int().positive().nullable(),graph_nodes:S,body_source:Ze.nullable(),detail:a.z.record(a.z.string(),a.z.unknown())}).strict(),tt=["no_pages","no_pages_rendered"],nt=a.z.enum(tt),Z="gate_closed:",ee="source_skipped:",te="nothing_to_read:",rt="no_children",un=/^[A-Z][A-Z0-9_]*$/;function ot(e){if(e===rt)return{kind:"no_children"};if(e.startsWith(Z)){let t=e.slice(Z.length);return un.test(t)?{kind:"gate_closed",featureFlagKey:t}:null}if(e.startsWith(ee)){let t=b.safeParse(e.slice(ee.length));return t.success?{kind:"source_skipped",stepKey:t.data}:null}if(e.startsWith(te)){let t=nt.safeParse(e.slice(te.length));return t.success?{kind:"nothing_to_read",token:t.data}:null}return null}function mn(e){let t=yn(e);if(ot(t)===null)throw new RangeError(`Skip reason ${JSON.stringify(e)} has no text form: ${JSON.stringify(t)} is outside the skip-reason grammar.`);return t}function yn(e){switch(e.kind){case"gate_closed":return`${Z}${e.featureFlagKey}`;case"no_children":return rt;case"source_skipped":return`${ee}${e.stepKey}`;case"nothing_to_read":return`${te}${e.token}`;default:{let t=e;throw new RangeError(`Unknown skip reason kind: ${JSON.stringify(t)}`)}}}var fn=a.z.object({id:a.z.number().int().positive(),runId:a.z.number().int().positive(),sequence:a.z.number().int().nonnegative(),stepKey:b,targetMetadataId:a.z.number().int().positive(),status:Qe,skipReason:a.z.string().nullable(),provenance:et.nullable(),strategyId:a.z.number().int().positive().nullable(),httpStatus:a.z.number().int().nullable(),errorCode:a.z.string().nullable(),errorMessage:a.z.string().nullable(),startedAt:u,finishedAt:u.nullable(),durationMs:S}).strict();function En(e,t){switch(e.status){case"SKIPPED":e.skipReason===null&&l(t,["skipReason"],"A SKIPPED step must record why it was skipped."),e.provenance!==null&&l(t,["provenance"],"A SKIPPED step read nothing, so it has no report.");return;case"SUCCEEDED":e.provenance===null&&l(t,["provenance"],"A SUCCEEDED step must carry its report."),e.skipReason!==null&&l(t,["skipReason"],"A SUCCEEDED step was not skipped.");return;case"RUNNING":e.finishedAt!==null&&l(t,["finishedAt"],"A RUNNING step has not finished.");return;case"FAILED":e.skipReason!==null&&l(t,["skipReason"],"A FAILED step was not skipped.");return}}var it=fn.superRefine(En),at=a.z.object({id:a.z.number().int().positive(),tenantId:a.z.string().min(1),metadataId:a.z.number().int().positive(),revision:a.z.number().int().positive(),runUid:a.z.string().uuid(),jobId:a.z.string().min(1),attempt:a.z.number().int().positive(),trigger:We,documentKind:ne,flowKey:a.z.string().min(1),status:Je,retryScheduled:a.z.boolean(),failedStepKey:b.nullable(),errorMessage:a.z.string().nullable(),requestedBy:a.z.string().min(1),startedAt:u,finishedAt:u.nullable(),steps:a.z.array(it)}).strict();function st(e,t){e.retryScheduled&&e.status!=="FAILED"&&l(t,["retryScheduled"],"Only a FAILED run can have a retry scheduled.")}var Sn=at.superRefine(st),hn=at.omit({steps:!0}).superRefine(st);function gn(e,t){e.sampleCount>0||(e.durationP50Ms!==null&&l(t,["durationP50Ms"],"A step with no sample has no median latency."),e.durationP95Ms!==null&&l(t,["durationP95Ms"],"A step with no sample has no 95th-percentile latency."))}var In=a.z.object({documentKind:ne,stepKey:b,sampleCount:a.z.number().int().nonnegative(),succeeded:a.z.number().int().nonnegative(),failed:a.z.number().int().nonnegative(),skipped:a.z.number().int().nonnegative(),durationP50Ms:S,durationP95Ms:S,lastStartedAt:u.nullable()}).strict().superRefine(gn);var re=[{key:"enable_summary_generation",featureFlagKey:null,label:"\u8981\u7D04\u751F\u6210"},{key:"enable_structured_extraction",featureFlagKey:null,label:"\u69CB\u9020\u5316\u62BD\u51FA"},{key:"enable_asset_extraction",featureFlagKey:"ENABLE_ASSET_EXTRACTION",label:"\u30A2\u30BB\u30C3\u30C8\u62BD\u51FA"},{key:"enable_vector_indexing",featureFlagKey:"ENABLE_VECTOR_INDEXING",label:"\u30D9\u30AF\u30C8\u30EB\u7D22\u5F15"},{key:"enable_graph_indexing",featureFlagKey:"ENABLE_GRAPH_INDEXING",label:"\u30B0\u30E9\u30D5\u6295\u5F71"}],Rn=new Set(re.map(e=>e.key));function _n(e){return Rn.has(e)}function An(e){let t=re.find(n=>n.key===e);if(t===void 0)throw new Error(`ENRICHMENT_STAGES does not carry ${e}; the canonical list and the key type have drifted apart.`);return t}var Nn={pageSize:{min:1,max:200,default:50},topologyLabels:{min:1,max:24,default:24}};var _=-1,h=0;function lt(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}function Cn(){let e=typeof globalThis<"u"&&globalThis.crypto?globalThis.crypto:typeof crypto<"u"?crypto:void 0;if(!e||typeof e.getRandomValues!="function")throw new Error("Cryptographically secure random number generator (crypto.getRandomValues) is required but not available.");let t=new Uint8Array(16);e.getRandomValues(t);let n=Date.now();if(n===_){if(h++,h>4095){for(;Date.now()<=_;);n=Date.now(),_=n,h=(t[6]<<4|t[7]&15)&1023}}else n>_?(_=n,h=(t[6]<<4|t[7]&15)&1023):(n=_,h++,h>4095&&(h=0));t[0]=Math.floor(n/1099511627776)&255,t[1]=Math.floor(n/4294967296)&255,t[2]=n>>>24&255,t[3]=n>>>16&255,t[4]=n>>>8&255,t[5]=n&255,t[6]=112|h>>>8&15,t[7]=h&255,t[8]=128|t[8]&63;let i=Array.from(t,c=>c.toString(16).padStart(2,"0")).join("");return`${i.slice(0,8)}-${i.slice(8,12)}-${i.slice(12,16)}-${i.slice(16,20)}-${i.slice(20)}`}function Tn(e){if(!lt(e))throw new Error(`Invalid RFC 9562 UUIDv7 string: "${e}"`);let t=e.slice(0,8)+e.slice(9,13),n=parseInt(t,16);if(Number.isNaN(n))throw new Error(`Invalid hex timestamp in UUIDv7: "${t}"`);return new Date(n)}0&&(module.exports={AmountEntrySchema,BaseEnrichmentClient,BodySourceSchema,BoundingBoxSchema,CIRCUIT_BREAKER_SERVICES,CanonicalDomainKeySchema,ChapterSegmentSchema,ChunkingStrategySchema,CircuitBreakerStatusSchema,ConfidentialityLevelSchema,DISPATCH_DEGRADATION_REASONS,DOCUMENT_KINDS,DOCUMENT_KIND_LABELS,DocumentKindSchema,DocumentStructuredDataSchema,ENRICHMENT_STAGES,EnrichmentClient,EnrichmentClientError,EnrichmentSyncStatusSchema,FILTERABLE_CONFIDENTIALITY_LEVELS,FileUriSchema,GRAPH_INDEX_LIMITS,GraphSearchHitSchema,INTEGRITY_CLASS_POLICY,INTEGRITY_COMMAND_CODES,INTEGRITY_FINDINGS_PAGE_LIMIT_MAX,IntegrityActiveRunSchema,IntegrityAuditOverviewSchema,IntegrityCancelFailureCodeSchema,IntegrityCommandFailureCodeSchema,IntegrityCommandFailureSchema,IntegrityCommandReplySchema,IntegrityCommandSchema,IntegrityDispositionSchema,IntegrityFindingItemClassSchema,IntegrityFindingPageSchema,IntegrityFindingSchema,IntegrityFindingsQuerySchema,IntegrityItemClassSchema,IntegrityPhaseSchema,IntegrityQuantitySchema,IntegrityRepairActionSchema,IntegrityRepairOutcomeSchema,IntegrityRepairSkipReasonSchema,IntegrityRunHeaderSchema,IntegrityRunModeSchema,IntegrityRunStatusSchema,IntegrityScopeRoleSchema,IntegrityStartFailureCodeSchema,IntegrityStoreSchema,IntegrityUnitSchema,IntegrityVerdictSchema,LOCAL_DEGRADATION_REASONS,MIME_KIND_RULES,MODE_TIERS,ModelProviderSchema,NOTHING_TO_READ_TOKENS,NothingToReadTokenSchema,PIPELINE_FLOWS,PIPELINE_PHASES,PIPELINE_STEPS,PIPELINE_STEP_KEYS,PipelineRunRecordSchema,PipelineRunStatusSchema,PipelineRunSummarySchema,PipelineStepKeySchema,PipelineStepMetricSchema,PipelineStepRecordSchema,PipelineStepStatusSchema,PipelineTriggerSchema,QUARANTINED_CONFIDENTIALITY_LEVEL,REMOTE_DEGRADATION_REASONS,SEARCH_DEGRADATION_REASONS,SEARCH_MODES,SEARCH_PARAM_LIMITS,SYSTEM_PARAMETER_RANGES,SearchHitSchema,SearchMetadataSchema,SearchModeSchema,SearchRequestSchema,SearchResponseSchema,StageProvenanceSchema,TenantIdSchema,TranscriptSegmentSchema,assertBoundedSystemParameter,assertSystemParameterInRange,classifyDocumentKind,comparePhases,enrichmentStage,flowFor,flowStepGates,formatSkipReason,generateUuidV7,integrityCommandFailureCodeOf,isEnrichmentStageKey,isStrictlyEarlier,isValidUuidV7,modeFusesRankings,modeNeedsRemoteTiers,modeScoreIsSimilarity,narrowModeToAllowedTiers,orderedSteps,parseSkipReason,uuidv7ToDate});
|
|
1
|
+
"use strict";var M=Object.defineProperty;var pt=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var ut=Object.prototype.hasOwnProperty;var mt=(e,t)=>{for(var n in t)M(e,n,{get:t[n],enumerable:!0})},yt=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of dt(t))!ut.call(e,s)&&s!==n&&M(e,s,{get:()=>t[s],enumerable:!(i=pt(t,s))||i.enumerable});return e};var ft=e=>yt(M({},"__esModule",{value:!0}),e);var xn={};mt(xn,{AmountEntrySchema:()=>me,BaseEnrichmentClient:()=>A,BodySourceSchema:()=>Ze,BoundingBoxSchema:()=>Ct,CIRCUIT_BREAKER_SERVICES:()=>ae,CanonicalDomainKeySchema:()=>Ee,ChapterSegmentSchema:()=>de,ChunkingStrategySchema:()=>xt,CircuitBreakerStatusSchema:()=>bt,ConfidentialityLevelSchema:()=>D,DISPATCH_DEGRADATION_REASONS:()=>ce,DOCUMENT_KINDS:()=>Y,DOCUMENT_KIND_LABELS:()=>Dt,DocumentKindSchema:()=>ne,DocumentStructuredDataSchema:()=>Tt,ENRICHMENT_STAGES:()=>re,EnrichmentClient:()=>H,EnrichmentClientError:()=>g,EnrichmentSyncStatusSchema:()=>Nt,FILTERABLE_CONFIDENTIALITY_LEVELS:()=>St,FileUriSchema:()=>At,GRAPH_INDEX_LIMITS:()=>Cn,GraphSearchHitSchema:()=>he,INTEGRITY_CLASS_POLICY:()=>we,INTEGRITY_COMMAND_CODES:()=>W,INTEGRITY_FINDINGS_PAGE_LIMIT_MAX:()=>Be,IntegrityActiveRunSchema:()=>$e,IntegrityAuditOverviewSchema:()=>Zt,IntegrityCancelFailureCodeSchema:()=>qe,IntegrityCommandFailureCodeSchema:()=>k,IntegrityCommandFailureSchema:()=>pn,IntegrityCommandReplySchema:()=>un,IntegrityCommandSchema:()=>X,IntegrityDispositionSchema:()=>ve,IntegrityFindingItemClassSchema:()=>Fe,IntegrityFindingPageSchema:()=>an,IntegrityFindingSchema:()=>Ve,IntegrityFindingsQuerySchema:()=>sn,IntegrityItemClassSchema:()=>Q,IntegrityPhaseSchema:()=>ze,IntegrityPlacementObservedSchema:()=>nn,IntegrityQuantitySchema:()=>je,IntegrityRepairActionSchema:()=>ke,IntegrityRepairOutcomeSchema:()=>Ke,IntegrityRepairSkipReasonSchema:()=>He,IntegrityRunHeaderSchema:()=>v,IntegrityRunModeSchema:()=>Me,IntegrityRunStatusSchema:()=>Ue,IntegrityScopeRoleSchema:()=>Pe,IntegrityStartFailureCodeSchema:()=>Xe,IntegrityStoreSchema:()=>J,IntegrityUnitSchema:()=>Le,IntegrityVerdictSchema:()=>Ge,LOCAL_DEGRADATION_REASONS:()=>se,MIME_KIND_RULES:()=>Ae,MODE_TIERS:()=>N,ModelProviderSchema:()=>oe,NOTHING_TO_READ_TOKENS:()=>tt,NothingToReadTokenSchema:()=>nt,PIPELINE_FLOWS:()=>Ne,PIPELINE_PHASES:()=>Pt,PIPELINE_STEPS:()=>$,PIPELINE_STEP_KEYS:()=>j,PipelineRunRecordSchema:()=>hn,PipelineRunStatusSchema:()=>Je,PipelineRunSummarySchema:()=>In,PipelineStepKeySchema:()=>x,PipelineStepMetricSchema:()=>Rn,PipelineStepRecordSchema:()=>it,PipelineStepStatusSchema:()=>Qe,PipelineTriggerSchema:()=>We,QUARANTINED_CONFIDENTIALITY_LEVEL:()=>O,REMOTE_DEGRADATION_REASONS:()=>le,SEARCH_DEGRADATION_REASONS:()=>_t,SEARCH_MODES:()=>G,SEARCH_PARAM_LIMITS:()=>Et,SYSTEM_PARAMETER_RANGES:()=>b,SearchHitSchema:()=>Se,SearchMetadataSchema:()=>fe,SearchModeSchema:()=>ye,SearchRequestSchema:()=>z,SearchResponseSchema:()=>K,StageProvenanceSchema:()=>et,TenantIdSchema:()=>pe,TranscriptSegmentSchema:()=>ue,assertBoundedSystemParameter:()=>Kt,assertSystemParameterInRange:()=>zt,classifyDocumentKind:()=>Ot,comparePhases:()=>kt,enrichmentStage:()=>Nn,flowFor:()=>Ft,flowStepGates:()=>Lt,formatSkipReason:()=>yn,generateUuidV7:()=>Tn,integrityCommandFailureCodeOf:()=>dn,isEnrichmentStageKey:()=>An,isStrictlyEarlier:()=>T,isValidUuidV7:()=>lt,modeFusesRankings:()=>Rt,modeNeedsRemoteTiers:()=>ht,modeScoreIsSimilarity:()=>It,narrowModeToAllowedTiers:()=>gt,orderedSteps:()=>vt,parseSkipReason:()=>ot,uuidv7ToDate:()=>bn});module.exports=ft(xn);var g=class extends Error{statusCode;responseBody;parsedBody;constructor(t,n,i,s){super(t),this.name="EnrichmentClientError",this.statusCode=n,this.responseBody=i,this.parsedBody=s}},A=class{baseUrl;apiKey;fetchFn;timeoutMs;constructor(t){if(!t||typeof t.baseUrl!="string"||t.baseUrl.trim().length===0)throw new Error("baseUrl is required and must be a non-empty string for EnrichmentClient.");let n=t.baseUrl.trim().replace(/\/$/,"");if(t.apiKey&&n.startsWith("http://")&&!n.includes("localhost")&&!n.includes("127.0.0.1"))throw new Error("Security Violation: Transmitting Bearer tokens over unencrypted HTTP to non-localhost hosts is strictly prohibited.");this.baseUrl=n,this.apiKey=t.apiKey,this.fetchFn=t.fetchFn??fetch,this.timeoutMs=t.timeoutMs&&t.timeoutMs>0?t.timeoutMs:3e4}async request(t,n,i){let s=`${this.baseUrl}${t}`,c={Accept:"application/json","Content-Type":"application/json","X-Tenant-Id":n};this.apiKey&&(c.Authorization=`Bearer ${this.apiKey}`);let d=new AbortController,m=setTimeout(()=>d.abort(),this.timeoutMs),f;try{f=await this.fetchFn(s,{method:"POST",headers:c,body:JSON.stringify(i),signal:d.signal})}catch(y){let I=y instanceof Error?y.message:String(y);throw new g(`Network request failed for POST ${s}: ${I}`,0,"")}finally{clearTimeout(m)}if(!f.ok){let y=await f.text().catch(()=>""),I;try{I=JSON.parse(y)}catch{}throw new g(`API request failed with status ${f.status}: ${y}`,f.status,y,I)}let R=await f.text().catch(()=>"");if(R.trim().length!==0)try{return JSON.parse(R)}catch(y){let I=y instanceof Error?y.message:String(y);throw new g(`Failed to parse response JSON from ${s}: ${I}`,f.status,R)}}};var r=require("zod");var U=require("zod"),oe=U.z.enum(["google_cloud","google_vision","yomitoku_local","faster_whisper_local","google_speech","ollama_local","openai","anthropic","azure_openai","bedrock","custom_openai_compatible"]),D=U.z.enum(["PUBLIC","INTERNAL","DEPARTMENT","CONFIDENTIAL","RESTRICTED"]),O="RESTRICTED";var Et={rrfK:{min:1,max:200,default:60},alpha:{min:0,max:1,default:.7},threshold:{min:0,max:1},limit:{min:1,max:50,default:10}},ie=D.options.filter(e=>e!==O);if(ie.length===0)throw new Error("The confidentiality vocabulary left nothing filterable after removing the quarantined level; a validator built from this list would reject every request.");var St=ie,G=["KEYWORD","SPARSE","DENSE","HYBRID","GRAPH_TRAVERSE"],N={KEYWORD:{dense:!1,sparse:!1,graph:!1,lexical:!0},SPARSE:{dense:!1,sparse:!0,graph:!1,lexical:!1},DENSE:{dense:!0,sparse:!1,graph:!1,lexical:!1},HYBRID:{dense:!0,sparse:!0,graph:!0,lexical:!0},GRAPH_TRAVERSE:{dense:!1,sparse:!1,graph:!0,lexical:!1}};function ht(e){let t=N[e];return t.dense||t.sparse||t.graph}function It(e){let t=N[e];return t.dense&&!t.sparse}function gt(e,t){let n=N[e],i=(n.dense||n.sparse)&&t.vector,s=n.graph&&t.graph;return i||s?i?s?{mode:e,discardGraph:!1}:n.dense&&n.sparse?{mode:e,discardGraph:!0}:{mode:n.dense?"DENSE":"SPARSE",discardGraph:!1}:{mode:"GRAPH_TRAVERSE",discardGraph:!1}:null}function Rt(e){let t=N[e];return[t.dense,t.sparse,t.graph,t.lexical].filter(Boolean).length>1}var ae=["vector","graph"],se=["empty_query","caller_token_unavailable","time_window_unsupported"],le=["vector_tier_not_configured","graph_tier_not_configured","no_active_vector_collection","vector_collections_missing"],ce=["remote_tiers_unavailable","remote_tiers_timed_out","remote_tiers_refused_caller","remote_tiers_rejected_request","remote_tiers_failed","remote_tiers_not_executed","vector_search_disabled","graph_search_disabled"],_t=[...se,...le,...ce,...ae.map(e=>`circuit_breaker_open:${e}`)];var pe=r.z.string().trim().min(1,"tenant_id must be a non-empty string"),At=r.z.string().trim().min(1,"file_uri must be a non-empty string"),Nt=r.z.enum(["PENDING","EXTRACTING","ENRICHING","PROJECTING","SYNCED","FAILED_EXTRACT","FAILED_ENRICH","FAILED_VECTOR","FAILED_GRAPH"]),Ct=r.z.object({page:r.z.number().int().positive().optional(),x:r.z.number().nonnegative().optional(),y:r.z.number().nonnegative().optional(),width:r.z.number().positive().optional(),height:r.z.number().positive().optional(),start_sec:r.z.number().nonnegative().optional(),end_sec:r.z.number().nonnegative().optional(),frame_index:r.z.number().int().nonnegative().optional(),timestamp_sec:r.z.number().nonnegative().optional(),scene_confidence:r.z.number().min(0).max(1).optional()}),de=r.z.object({title:r.z.string().trim().min(1),start_sec:r.z.number().nonnegative(),end_sec:r.z.number().nonnegative(),summary:r.z.string()}),ue=r.z.object({start_sec:r.z.number().nonnegative(),end_sec:r.z.number().nonnegative(),speaker:r.z.string().trim().min(1),text:r.z.string()}),me=r.z.object({label:r.z.string(),value:r.z.number(),currency:r.z.string()}),Tt=r.z.object({document_type:r.z.string().optional(),title:r.z.string().optional(),organization:r.z.string().optional(),key_entities:r.z.array(r.z.string()).optional(),dates:r.z.array(r.z.string()).optional(),amounts:r.z.array(me).optional(),media_type:r.z.enum(["video","audio"]).optional(),duration_sec:r.z.number().nonnegative().optional(),chapters:r.z.array(de).optional(),transcript_segments:r.z.array(ue).optional()}),bt=r.z.enum(["CLOSED","OPEN","HALF_OPEN"]),ye=r.z.enum(G),fe=r.z.object({circuit_breaker_status:r.z.string(),quality_tier:r.z.string(),latency_ms:r.z.number().nonnegative(),total_hits:r.z.number().int().nonnegative(),fallback_applied:r.z.boolean(),degraded_reason:r.z.string().nullable()}),Ee=r.z.enum(["CONTRACT_LEGAL","EMAIL_THREAD","DAILY_REPORT","FINANCIAL_REPORT","TECHNICAL_SPEC","MASTER_DATA","MEDIA_ASSET","GENERAL_DOCUMENT"]),xt=r.z.enum(["hierarchical","conversation","section","fixed_size","table_aware","semantic","none","multimodal"]),Se=r.z.object({metadata_id:r.z.number().int().positive(),chunk_index:r.z.number().int().nonnegative(),text:r.z.string(),score:r.z.number()}),he=r.z.object({metadata_id:r.z.number().int().positive(),relation:r.z.string(),target_name:r.z.string()}),z=r.z.object({query:r.z.string().trim().min(1,"query must not be empty"),tenant_id:pe,domain_key:Ee.optional(),limit:r.z.number().int().positive().optional(),department_id:r.z.number().int().positive().optional(),search_mode:ye.optional(),strategy_id:r.z.number().int().positive().optional()}).strict(),K=r.z.object({hits:r.z.array(Se),graph_hits:r.z.array(he),tiers:r.z.record(r.z.string(),r.z.boolean()),metadata:fe});var H=class extends A{async search(t){let n=z.parse(t),i=await this.request("/ai/search/hybrid",n.tenant_id,n);return K.parse(i)}};var Y=["email","pdf","office","image","media","text","google_native","other"],Dt={email:"\u30E1\u30FC\u30EB",pdf:"PDF",office:"Office \u6587\u66F8",image:"\u753B\u50CF",media:"\u97F3\u58F0\u30FB\u52D5\u753B",text:"\u30C6\u30AD\u30B9\u30C8",google_native:"Google \u30CD\u30A4\u30C6\u30A3\u30D6",other:"\u305D\u306E\u4ED6"},Ae=[["message/rfc822","email"],["application/pdf","pdf"],["application/vnd.openxmlformats-officedocument.*","office"],["application/msword","office"],["application/vnd.ms-excel","office"],["application/vnd.ms-powerpoint","office"],["application/vnd.google-apps.*","google_native"],["image/svg+xml","text"],["image/emf","other"],["image/x-emf","other"],["image/wmf","other"],["image/x-wmf","other"],["image/*","image"],["audio/*","media"],["video/*","media"],["text/*","text"],["application/json","text"],["application/xml","text"]];function Ot(e){let t=(e.split(";")[0]??"").trim().toLowerCase();for(let[n,i]of Ae)if(n.endsWith("*")?t.startsWith(n.slice(0,-1)):t===n)return i;return"other"}var j=["delete_child_assets","extract_text","analyze_media","extract_assets","ocr_children","ocr_document","resolve_body","enrich_document","project_to_indexes"],Pt=["EXTRACTING","ENRICHING","PROJECTING"],B=e=>({featureFlagKey:e,whenClosed:"skip",failureStatus:null}),Ie=(e,t)=>({featureFlagKey:e,whenClosed:"fail",failureStatus:t}),$={delete_child_assets:{key:"delete_child_assets",label:"\u65E7\u7248\u306E\u5B50\u30A2\u30BB\u30C3\u30C8\u524A\u9664",description:"\u3053\u306E\u7248\u3088\u308A\u524D\u306E\u7248\u304C\u751F\u3093\u3060\u5B50\u30A2\u30BB\u30C3\u30C8\u3092\u4FDD\u7BA1\u5C64\u3068\u7D22\u5F15\u304B\u3089\u5916\u3059\u3002",endpoint:"/ai/assets/delete",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[],capability:null,fanOut:null},extract_text:{key:"extract_text",label:"\u6587\u5B57\u5C64\u306E\u62BD\u51FA",description:"\u6587\u66F8\u304C\u6301\u3064\u6587\u5B57\u5C64 (PDF \u306E\u6587\u5B57\u30FBOffice \u306E\u672C\u6587\u30FB\u30E1\u30FC\u30EB\u306E\u672C\u6587\u3068\u898B\u51FA\u3057) \u3092\u8AAD\u307F\u3001\u4F4D\u7F6E\u60C5\u5831\u3068\u5171\u306B\u4FDD\u5B58\u3059\u308B\u3002",endpoint:"/ai/enrichment/extract",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[],capability:null,fanOut:null},analyze_media:{key:"analyze_media",label:"\u30E1\u30C7\u30A3\u30A2\u89E3\u6790",description:"\u97F3\u58F0\u30FB\u52D5\u753B\u3092\u8EE2\u5199\u3057\u3001\u767A\u8A71\u533A\u9593\u4ED8\u304D\u306E\u30C1\u30E3\u30F3\u30AF\u3068\u30AD\u30FC\u30D5\u30EC\u30FC\u30E0\u6570\u3092\u8A18\u9332\u3059\u308B\u3002",endpoint:"/ai/media/analyze",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[B("ENABLE_MEDIA_ANALYSIS")],capability:"transcription",fanOut:null},extract_assets:{key:"extract_assets",label:"\u5B50\u30A2\u30BB\u30C3\u30C8\u306E\u62BD\u51FA",description:"\u57CB\u3081\u8FBC\u307F\u753B\u50CF\u3084\u30E1\u30FC\u30EB\u306E\u6DFB\u4ED8\u3092\u5B50\u30A2\u30BB\u30C3\u30C8\u3068\u3057\u3066\u5207\u308A\u51FA\u3057\u3001\u6587\u66F8\u306E\u96A3\u306B\u4FDD\u7BA1\u3057\u3066\u767B\u9332\u3059\u308B\u3002",endpoint:"/ai/assets/extract",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[B("ENABLE_ASSET_EXTRACTION")],capability:"asset_extraction",fanOut:null},ocr_children:{key:"ocr_children",label:"\u5B50\u30A2\u30BB\u30C3\u30C8\u306E\u8AAD\u307F\u53D6\u308A",description:"\u5207\u308A\u51FA\u3057\u305F\u5B50\u30A2\u30BB\u30C3\u30C8\u3092\u62BD\u51FA\u9806\u306B 1 \u4EF6\u305A\u3064\u8AAD\u307F\u3001\u6587\u5B57\u5C64\u3092\u8AAD\u3081\u308B\u5B50 (\u30C6\u30AD\u30B9\u30C8\u30FB\u30E1\u30FC\u30EB\u30FBOffice\u30FBPDF) \u306F\u305D\u306E\u6587\u5B57\u5C64\u3092\u3001\u8AAD\u3081\u306A\u3044\u5B50\u306F\u7248\u9762\u3092\u5149\u5B66\u8A8D\u8B58\u3067\u8AAD\u3093\u3067\u3001\u5B50\u3054\u3068\u306B\u672C\u6587\u3068\u51FA\u6240\u3092\u4FDD\u5B58\u3059\u308B\u3002",endpoint:"/ai/ocr/run",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[],capability:"ocr",fanOut:"children"},ocr_document:{key:"ocr_document",label:"\u6587\u66F8\u306E OCR",description:"\u6587\u66F8\u81EA\u8EAB\u306E\u7248\u9762 (\u753B\u50CF\u30FBPDF \u306E\u5404\u30DA\u30FC\u30B8) \u3092\u5149\u5B66\u8A8D\u8B58\u306B\u304B\u3051\u308B\u3002",endpoint:"/ai/ocr/run",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[B("ENABLE_OCR")],capability:"ocr",fanOut:null},resolve_body:{key:"resolve_body",label:"\u672C\u6587\u306E\u78BA\u5B9A",description:"\u6587\u5B57\u5C64\u30FBOCR\u30FB\u8EE2\u5199\u306E\u3069\u308C\u3092\u672C\u6587\u3068\u3059\u308B\u304B\u3092\u6C7A\u3081\u3001\u51FA\u6240\u3092\u8A18\u9332\u3059\u308B\u3002",endpoint:"/ai/enrichment/body",phase:"ENRICHING",failureStatus:"FAILED_ENRICH",gates:[],capability:null,fanOut:null},enrich_document:{key:"enrich_document",label:"\u8981\u7D04\u3068\u69CB\u9020\u5316\u62BD\u51FA",description:"\u672C\u6587\u3092\u30E2\u30C7\u30EB\u3078\u6E21\u3057\u3001\u8981\u7D04\u30FB\u30BF\u30B0\u30FB\u69CB\u9020\u5316\u30C7\u30FC\u30BF\u30FB\u30C9\u30E1\u30A4\u30F3\u5206\u985E\u3092\u5F97\u308B\u3002",endpoint:"/ai/enrichment/document",phase:"ENRICHING",failureStatus:"FAILED_ENRICH",gates:[],capability:"enrichment",fanOut:null},project_to_indexes:{key:"project_to_indexes",label:"\u30D9\u30AF\u30C8\u30EB\u3068\u30B0\u30E9\u30D5\u3078\u306E\u6295\u5F71",description:"\u672C\u6587\u3092\u30C1\u30E3\u30F3\u30AF\u306B\u3057\u3066\u57CB\u3081\u8FBC\u307F\u3001\u30D9\u30AF\u30C8\u30EB\u7D22\u5F15\u3068\u30CA\u30EC\u30C3\u30B8\u30B0\u30E9\u30D5\u3078\u66F8\u304F\u3002",endpoint:"/ai/enrichment/project",phase:"PROJECTING",failureStatus:"FAILED_VECTOR",gates:[Ie("ENABLE_VECTOR_INDEXING","FAILED_VECTOR"),Ie("ENABLE_GRAPH_INDEXING","FAILED_GRAPH")],capability:null,fanOut:null}},ge={whenClosed:"fail",failureStatus:"FAILED_EXTRACT"},P=[{step:"delete_child_assets",dependsOn:[]},{step:"extract_text",dependsOn:["delete_child_assets"]},{step:"extract_assets",dependsOn:["extract_text"]},{step:"ocr_children",dependsOn:["extract_assets"]},{step:"ocr_document",dependsOn:["extract_text"]},{step:"resolve_body",dependsOn:["ocr_children","ocr_document"]},{step:"enrich_document",dependsOn:["resolve_body"]},{step:"project_to_indexes",dependsOn:["enrich_document"],chunkSource:"rebuild"}],Re=[{step:"delete_child_assets",dependsOn:[]},{step:"extract_text",dependsOn:["delete_child_assets"]},{step:"resolve_body",dependsOn:["extract_text"]},{step:"enrich_document",dependsOn:["resolve_body"]},{step:"project_to_indexes",dependsOn:["enrich_document"],chunkSource:"rebuild"}],Ne={email:{kind:"email",steps:P},pdf:{kind:"pdf",steps:P},office:{kind:"office",steps:P},google_native:{kind:"google_native",steps:P},image:{kind:"image",steps:[{step:"delete_child_assets",dependsOn:[]},{step:"ocr_document",dependsOn:["delete_child_assets"],gatePolicy:ge},{step:"resolve_body",dependsOn:["ocr_document"]},{step:"enrich_document",dependsOn:["resolve_body"]},{step:"project_to_indexes",dependsOn:["enrich_document"],chunkSource:"rebuild"}]},media:{kind:"media",steps:[{step:"delete_child_assets",dependsOn:[]},{step:"analyze_media",dependsOn:["delete_child_assets"],gatePolicy:ge},{step:"resolve_body",dependsOn:["analyze_media"]},{step:"enrich_document",dependsOn:["resolve_body"]},{step:"project_to_indexes",dependsOn:["enrich_document"],chunkSource:"existing"}]},text:{kind:"text",steps:Re},other:{kind:"other",steps:Re}};function Ft(e){return Ne[e]}function Lt(e){let{gates:t}=$[e.step],{gatePolicy:n}=e;return n===void 0?t:t.map(i=>({featureFlagKey:i.featureFlagKey,whenClosed:n.whenClosed,failureStatus:n.failureStatus}))}function vt(e){let t=new Map(e.steps.map(c=>[c.step,c]));for(let c of e.steps){if(c.gatePolicy!==void 0&&$[c.step].gates.length===0)throw new Error(`Flow ${e.kind}: step ${c.step} overrides its gate policy, but the step has no gate to close.`);for(let d of c.dependsOn)if(!t.has(d))throw new Error(`Flow ${e.kind}: step ${c.step} depends on ${d}, which the flow does not contain.`)}let n=[...e.steps],i=new Set,s=[];for(;n.length>0;){let c=n.findIndex(m=>m.dependsOn.every(f=>i.has(f)));if(c===-1)throw new Error(`Flow ${e.kind}: the steps ${n.map(m=>m.step).join(", ")} depend on each other in a cycle.`);let[d]=n.splice(c,1);i.add(d.step),s.push(d)}return s}var _e={EXTRACTING:0,ENRICHING:1,PROJECTING:2};function kt(e,t){return _e[e]-_e[t]}var o=require("zod");var Ce=[{code:"DEPLOYMENT_DISABLED",status:503,errorCode:5035},{code:"RUN_ALREADY_ACTIVE",status:409,errorCode:4091},{code:"BASIS_INVALID",status:409,errorCode:4092},{code:"RUN_ALREADY_FINISHED",status:409,errorCode:4093},{code:"FORBIDDEN",status:403,errorCode:null}];var F=require("zod"),C=F.z.string().uuid().transform(e=>e.toLowerCase()),u=F.z.string().datetime({offset:!0}),l=(e,t,n)=>{e.addIssue({code:F.z.ZodIssueCode.custom,path:[...t],message:n})},Mt=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(?:Z|([+-])(\d{2}):?(\d{2}))$/,Te=e=>{let t=u.safeParse(e).success?Mt.exec(e):null;if(t===null)return null;let[,n,i,s,c,d,m,f,R,y,I]=t,w=new Date(0);w.setUTCFullYear(Number(n),Number(i)-1,Number(s)),w.setUTCHours(Number(c),Number(d),m===void 0?0:Number(m),0);let ct=R===void 0?0:(R==="+"?1:-1)*(Number(y)*3600+Number(I)*60);return{epochSeconds:w.getTime()/1e3-ct,fraction:f===void 0?"":f}},T=(e,t)=>{let n=Te(e),i=Te(t);if(n===null||i===null)return!1;if(n.epochSeconds!==i.epochSeconds)return n.epochSeconds<i.epochSeconds;let s=Math.max(n.fraction.length,i.fraction.length);return n.fraction.padEnd(s,"0")<i.fraction.padEnd(s,"0")};var be={INTEGRITY_TOMBSTONE_RETENTION_DAYS:{min:1,max:3650},INTEGRITY_FINDING_SAMPLE_LIMIT:{min:1,max:5e3},INTEGRITY_RUN_HEARTBEAT_TIMEOUT_SECONDS:{min:30,max:3600},INTEGRITY_RUN_RETENTION_COUNT:{min:2,max:100},POLICY_CONFLICT_MAX_TIE_GROUP_SIZE:{min:2,max:60}};var Gt=e=>{for(let t of Object.values(e))Object.freeze(t);return Object.freeze(e)},b=Gt(be),xe=e=>Object.hasOwn(b,e),De=(e,t)=>{let{min:n,max:i}=b[e];if(!Number.isInteger(t)||t<n||t>i)throw new RangeError(`${e} \u306F ${n}\u301C${i} \u306E\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)},zt=(e,t)=>{xe(e)&&De(e,t)},Kt=(e,t)=>{if(!xe(e))throw new TypeError(`The range table bounds no parameter named ${JSON.stringify(e)}.`);De(e,t)};var J=o.z.enum(["QDRANT","NEO4J"]),Pe=o.z.enum(["PRODUCTION","VARIANT","LABEL"]),Q=o.z.enum(["EXPECTED","LIVE","HISTORY","TOMBSTONE","AWAITING_SUCCESSOR","IN_FLIGHT","UNPLACED","UNRECORDED","UNREFERENCED","CHANGED_AFTER_START","PIPELINE_FAILED","PROJECTION_REFUSED","ORPHAN","TOMBSTONE_EXPIRED","UNPROPAGATED_DELETE","STALE_REVISION","MISPLACED","OUT_OF_TIER","UNMARKED_SUPERSEDED","FLAG_DRIFT","VARIANT_FLAG_DRIFT","DETACHED","UNKEYED","MISSING","COUNT_MISMATCH"]),Fe=Q.exclude(["EXPECTED","LIVE","HISTORY"]),Le=o.z.enum(["POINT","NODE","CHUNK","DOCUMENT"]),ve=o.z.enum(["EXPECTED","HEALTHY","RETAINED","INFORMATIONAL","DISCREPANCY"]),ke=o.z.enum(["NONE","PURGE","FLAG","REPROJECT"]),p=(e,t)=>Object.freeze({disposition:e,repairAction:t}),we=Object.freeze({EXPECTED:p("EXPECTED","NONE"),LIVE:p("HEALTHY","NONE"),HISTORY:p("RETAINED","NONE"),TOMBSTONE:p("RETAINED","NONE"),AWAITING_SUCCESSOR:p("RETAINED","NONE"),IN_FLIGHT:p("INFORMATIONAL","NONE"),UNPLACED:p("INFORMATIONAL","NONE"),UNRECORDED:p("INFORMATIONAL","NONE"),UNREFERENCED:p("INFORMATIONAL","NONE"),CHANGED_AFTER_START:p("INFORMATIONAL","NONE"),PIPELINE_FAILED:p("INFORMATIONAL","NONE"),PROJECTION_REFUSED:p("INFORMATIONAL","NONE"),ORPHAN:p("DISCREPANCY","PURGE"),TOMBSTONE_EXPIRED:p("DISCREPANCY","PURGE"),UNPROPAGATED_DELETE:p("DISCREPANCY","FLAG"),STALE_REVISION:p("DISCREPANCY","PURGE"),MISPLACED:p("DISCREPANCY","PURGE"),OUT_OF_TIER:p("DISCREPANCY","PURGE"),UNMARKED_SUPERSEDED:p("DISCREPANCY","FLAG"),FLAG_DRIFT:p("DISCREPANCY","REPROJECT"),VARIANT_FLAG_DRIFT:p("DISCREPANCY","NONE"),DETACHED:p("DISCREPANCY","NONE"),UNKEYED:p("DISCREPANCY","NONE"),MISSING:p("DISCREPANCY","REPROJECT"),COUNT_MISMATCH:p("DISCREPANCY","REPROJECT")}),Me=o.z.enum(["SCAN","REPAIR"]),Ue=o.z.enum(["RUNNING","COMPLETED","FAILED","CANCELLED","ABANDONED"]),Ge=o.z.enum(["CONSISTENT","INCONSISTENT","UNDETERMINED"]),ze=o.z.enum(["QDRANT","NEO4J","DOCUMENTS"]),Ke=o.z.enum(["APPLIED","SKIPPED","FAILED"]),He=o.z.enum(["RECLASSIFIED","IN_FLIGHT","DESTINATION_PENDING","BASIS_EXHAUSTED","PROJECTION_REFUSED","PIPELINE_FAILED","UNRECORDED","OUTSIDE"]),Be=100,E=o.z.number().int().nonnegative(),L=o.z.number().int().min(300).max(599),V=["repairedCount","repairFailedCount","repairSkippedCount"],Ye=o.z.string().regex(/^[0-9a-f]{64}$/,"A store fingerprint is 64 lowercase hexadecimal digits."),Oe=b.INTEGRITY_TOMBSTONE_RETENTION_DAYS,Ht=o.z.object({runUid:C,mode:Me,status:Ue,requestedBy:o.z.string().min(1),executor:o.z.string().min(1),basisRunUid:C.nullable(),storeFingerprint:Ye,tombstoneRetentionDays:o.z.number().int().min(Oe.min).max(Oe.max),startedAt:u,finishedAt:u.nullable(),verdict:Ge.nullable(),errorClass:o.z.string().min(1).nullable(),reprojectDocuments:E.nullable(),reprojectRebuildDocuments:E.nullable()}).strict(),Bt=(e,t)=>{let n=e.status==="COMPLETED";e.mode==="REPAIR"!=(e.basisRunUid!==null)&&l(t,["basisRunUid"],"A REPAIR run names its basis SCAN run, and a SCAN run names none."),n!==(e.verdict!==null)&&l(t,["verdict"],"Only a COMPLETED run has a verdict."),n!==(e.reprojectDocuments!==null)&&l(t,["reprojectDocuments"],"Only a COMPLETED run has the count of documents to re-project.");let{reprojectDocuments:i,reprojectRebuildDocuments:s}=e;i===null||s===null?i!==s&&l(t,["reprojectRebuildDocuments"],"The documents a re-projection embeds are counted together with the documents it re-projects."):s>i&&l(t,["reprojectRebuildDocuments"],"The documents a re-projection embeds are no more than the documents it re-projects."),e.status==="RUNNING"!=(e.finishedAt===null)&&l(t,["finishedAt"],"Only a RUNNING run has not finished."),e.finishedAt!==null&&T(e.finishedAt,e.startedAt)&&l(t,["finishedAt"],"A run does not finish before it starts."),(e.status==="FAILED"||e.status==="ABANDONED")!=(e.errorClass!==null)&&l(t,["errorClass"],"Only a FAILED or ABANDONED run names an error class.")},v=Ht.superRefine(Bt),Yt=o.z.object({store:J,scopeKey:o.z.string().min(1),scopeRole:Pe,itemClass:Q,unit:Le,disposition:ve,repairAction:ke,itemCount:E.nullable(),unmeasuredReason:o.z.string().min(1).nullable(),measuredAt:u.nullable(),repairedCount:E.nullable(),repairFailedCount:E.nullable(),repairSkippedCount:E.nullable()}).strict(),jt=(e,t)=>{let n=we[e.itemClass];e.disposition!==n.disposition&&l(t,["disposition"],`A ${e.itemClass} quantity is ${n.disposition}.`),e.repairAction!==n.repairAction&&l(t,["repairAction"],`A repair's action on ${e.itemClass} items is ${n.repairAction}.`);let i=e.itemCount===null;i!==(e.unmeasuredReason!==null)&&l(t,["unmeasuredReason"],"An unmeasured quantity (itemCount null) has a reason, and a measured one has none."),i!==(e.measuredAt===null)&&l(t,["measuredAt"],"Only a measured quantity has a measurement time.");let{repairedCount:s,repairFailedCount:c,repairSkippedCount:d}=e;if(s===null||c===null||d===null){if(V.some(m=>e[m]!==null))for(let m of V)e[m]===null&&l(t,[m],"The repaired, failed and skipped counts are recorded together or not at all.");return}e.repairAction==="NONE"&&l(t,["repairAction"],"Only a class with a repair action carries repair counts."),e.itemCount!==null&&s+c+d>e.itemCount&&l(t,["itemCount"],"The repaired, failed and skipped counts together do not exceed the measured count.")},je=Yt.superRefine(jt),$t=o.z.object({run:v,phase:ze.nullable(),phaseScope:o.z.string().min(1).nullable(),phaseDone:E.nullable(),phaseTotal:E.nullable(),heartbeatAt:u,isStale:o.z.boolean(),cancelRequestedAt:u.nullable()}).strict(),Vt=(e,t)=>{if(e.run.status!=="RUNNING"&&l(t,["run","status"],"The active run is a RUNNING run."),T(e.heartbeatAt,e.run.startedAt)&&l(t,["heartbeatAt"],"A run's heartbeat is not earlier than its start."),e.phase===null)for(let n of["phaseScope","phaseDone","phaseTotal"])e[n]!==null&&l(t,[n],"A run with no phase has no phase progress.");e.phase==="DOCUMENTS"&&e.phaseScope!==null&&l(t,["phaseScope"],"The DOCUMENTS phase scans no scope.")},$e=$t.superRefine(Vt),Xt=o.z.object({run:v,quantities:o.z.array(je),previousStoreFingerprint:Ye.nullable()}).strict(),qt=(e,t)=>{e.run.status!=="COMPLETED"&&l(t,["run","status"],"The last completed run is a COMPLETED run.");let n=new Set;for(let[i,s]of e.quantities.entries()){let c=JSON.stringify([s.store,s.scopeKey,s.itemClass]);if(n.has(c)&&l(t,["quantities",i],"A run records each (store, scope, class) cell once."),n.add(c),e.run.mode==="SCAN")for(let d of V)s[d]!==null&&l(t,["quantities",i,d],"A SCAN run repairs nothing, so its quantities carry no repair counts.")}},Jt=["FAILED","CANCELLED","ABANDONED"],Qt=o.z.object({run:v,repairAppliedItems:E.nullable(),hasNewerRepair:o.z.boolean()}).strict(),Wt=(e,t)=>{Jt.includes(e.run.status)||l(t,["run","status"],"A newer unsuccessful run is FAILED, CANCELLED or ABANDONED."),e.run.mode==="SCAN"&&e.repairAppliedItems!==null&&l(t,["repairAppliedItems"],"A SCAN run applies nothing."),e.run.mode==="REPAIR"&&!e.hasNewerRepair&&l(t,["hasNewerRepair"],"An unsuccessful REPAIR run is itself a repair newer than the last completed run.")},Zt=o.z.object({readAt:u,lastCompleted:Xt.superRefine(qt).nullable(),active:$e.nullable(),newerUnsuccessful:Qt.superRefine(Wt).nullable()}).strict(),en=o.z.object({sequence:o.z.number().int().min(1),itemKey:o.z.string().min(1),metadataId:o.z.number().int().positive().nullable(),fileUri:o.z.string().nullable(),revision:o.z.number().int().nullable(),observed:o.z.record(o.z.string(),o.z.unknown()),repairOutcome:Ke.nullable(),repairErrorClass:o.z.string().min(1).nullable(),repairSkipReason:He.nullable()}).strict(),tn=(e,t)=>{e.repairOutcome==="FAILED"!=(e.repairErrorClass!==null)&&l(t,["repairErrorClass"],"Only a FAILED finding names an error class."),e.repairOutcome==="SKIPPED"!=(e.repairSkipReason!==null)&&l(t,["repairSkipReason"],"Only a SKIPPED finding names a skip reason.")},Ve=en.superRefine(tn),nn=o.z.object({sotDomain:o.z.string().nullable()}).passthrough(),rn=o.z.object({rows:o.z.array(Ve),nextAfter:o.z.number().int().min(1).nullable(),recordedCount:E,totalCount:E.nullable()}).strict(),on=(e,t)=>{for(let[n,i]of e.rows.entries()){let s=e.rows[n-1];s!==void 0&&i.sequence<=s.sequence&&l(t,["rows",n,"sequence"],"A page lists its rows in ascending sequence.")}e.nextAfter!==null&&e.nextAfter!==e.rows.at(-1)?.sequence&&l(t,["nextAfter"],"The next page starts after the sequence of this page's last row.")},an=rn.superRefine(on),sn=o.z.object({runUid:C,store:J,scopeKey:o.z.string().min(1),itemClass:Fe,after:o.z.number().int().min(1).optional(),limit:o.z.number().int().min(1).max(Be)}).strict(),k=o.z.enum(["DEPLOYMENT_DISABLED","RUN_ALREADY_ACTIVE","BASIS_INVALID","RUN_ALREADY_FINISHED","FORBIDDEN","UPSTREAM_FAILED"]),X=o.z.enum(["start","cancel"]),Xe=k.extract(["DEPLOYMENT_DISABLED","RUN_ALREADY_ACTIVE","BASIS_INVALID","FORBIDDEN","UPSTREAM_FAILED"]),qe=k.extract(["DEPLOYMENT_DISABLED","RUN_ALREADY_FINISHED","FORBIDDEN","UPSTREAM_FAILED"]),q={start:Xe,cancel:qe},ln=o.z.object({code:k.exclude(["UPSTREAM_FAILED"]),status:L,errorCode:o.z.number().int().nullable()}).strict(),W=Object.freeze(o.z.array(ln).parse(Ce).map(e=>Object.freeze(e))),cn=(e,t)=>{e.code==="UPSTREAM_FAILED"||e.code==="FORBIDDEN"&&e.status===null||W.some(n=>n.code===e.code&&n.status===e.status)||l(t,["status"],`A ${e.code} failure carries the status of its row in the code table.`)},pn=o.z.discriminatedUnion("command",[o.z.object({command:X.extract(["start"]),code:q.start,status:L.nullable()}).strict(),o.z.object({command:X.extract(["cancel"]),code:q.cancel,status:L.nullable()}).strict()]).superRefine(cn),dn=(e,t,n)=>{let i=q[e],s=W.find(c=>c.status===t&&(c.errorCode===null||c.errorCode===n)&&i.safeParse(c.code).success);return s===void 0?"UPSTREAM_FAILED":s.code},un=o.z.discriminatedUnion("ok",[o.z.object({ok:o.z.literal(!0),runUid:C}).strict(),o.z.object({ok:o.z.literal(!1),status:L,errorCode:o.z.number().int().nullable()}).strict()]);var a=require("zod");var ne=a.z.enum(Y),x=a.z.enum(j),Je=a.z.enum(["RUNNING","SUCCEEDED","FAILED"]),Qe=a.z.enum(["RUNNING","SUCCEEDED","SKIPPED","FAILED"]),We=a.z.enum(["ingest","retry","resync"]),Ze=a.z.enum(["text_layer","ocr","transcript"]),S=a.z.number().int().nonnegative().nullable(),et=a.z.object({provider:a.z.string().nullable(),model:a.z.string().nullable(),engine:a.z.string().nullable(),prompt_key:a.z.string().nullable(),prompt_version:a.z.number().int().nullable(),duration_ms:S,input_chars:S,output_chars:S,pages_read:S,pages_total:S,chunk_count:S,points_upserted:S,collection:a.z.string().nullable(),embedding_model:a.z.string().nullable(),strategy_id:a.z.number().int().positive().nullable(),graph_nodes:S,body_source:Ze.nullable(),detail:a.z.record(a.z.string(),a.z.unknown())}).strict(),tt=["no_pages","no_pages_rendered"],nt=a.z.enum(tt),Z="gate_closed:",ee="source_skipped:",te="nothing_to_read:",rt="no_children",mn=/^[A-Z][A-Z0-9_]*$/;function ot(e){if(e===rt)return{kind:"no_children"};if(e.startsWith(Z)){let t=e.slice(Z.length);return mn.test(t)?{kind:"gate_closed",featureFlagKey:t}:null}if(e.startsWith(ee)){let t=x.safeParse(e.slice(ee.length));return t.success?{kind:"source_skipped",stepKey:t.data}:null}if(e.startsWith(te)){let t=nt.safeParse(e.slice(te.length));return t.success?{kind:"nothing_to_read",token:t.data}:null}return null}function yn(e){let t=fn(e);if(ot(t)===null)throw new RangeError(`Skip reason ${JSON.stringify(e)} has no text form: ${JSON.stringify(t)} is outside the skip-reason grammar.`);return t}function fn(e){switch(e.kind){case"gate_closed":return`${Z}${e.featureFlagKey}`;case"no_children":return rt;case"source_skipped":return`${ee}${e.stepKey}`;case"nothing_to_read":return`${te}${e.token}`;default:{let t=e;throw new RangeError(`Unknown skip reason kind: ${JSON.stringify(t)}`)}}}var En=a.z.object({id:a.z.number().int().positive(),runId:a.z.number().int().positive(),sequence:a.z.number().int().nonnegative(),stepKey:x,targetMetadataId:a.z.number().int().positive(),status:Qe,skipReason:a.z.string().nullable(),provenance:et.nullable(),strategyId:a.z.number().int().positive().nullable(),httpStatus:a.z.number().int().nullable(),errorCode:a.z.string().nullable(),errorMessage:a.z.string().nullable(),startedAt:u,finishedAt:u.nullable(),durationMs:S}).strict();function Sn(e,t){switch(e.status){case"SKIPPED":e.skipReason===null&&l(t,["skipReason"],"A SKIPPED step must record why it was skipped."),e.provenance!==null&&l(t,["provenance"],"A SKIPPED step read nothing, so it has no report.");return;case"SUCCEEDED":e.provenance===null&&l(t,["provenance"],"A SUCCEEDED step must carry its report."),e.skipReason!==null&&l(t,["skipReason"],"A SUCCEEDED step was not skipped.");return;case"RUNNING":e.finishedAt!==null&&l(t,["finishedAt"],"A RUNNING step has not finished.");return;case"FAILED":e.skipReason!==null&&l(t,["skipReason"],"A FAILED step was not skipped.");return}}var it=En.superRefine(Sn),at=a.z.object({id:a.z.number().int().positive(),tenantId:a.z.string().min(1),metadataId:a.z.number().int().positive(),revision:a.z.number().int().positive(),runUid:a.z.string().uuid(),jobId:a.z.string().min(1),attempt:a.z.number().int().positive(),trigger:We,documentKind:ne,flowKey:a.z.string().min(1),status:Je,retryScheduled:a.z.boolean(),failedStepKey:x.nullable(),errorMessage:a.z.string().nullable(),requestedBy:a.z.string().min(1),startedAt:u,finishedAt:u.nullable(),steps:a.z.array(it)}).strict();function st(e,t){e.retryScheduled&&e.status!=="FAILED"&&l(t,["retryScheduled"],"Only a FAILED run can have a retry scheduled.")}var hn=at.superRefine(st),In=at.omit({steps:!0}).superRefine(st);function gn(e,t){e.sampleCount>0||(e.durationP50Ms!==null&&l(t,["durationP50Ms"],"A step with no sample has no median latency."),e.durationP95Ms!==null&&l(t,["durationP95Ms"],"A step with no sample has no 95th-percentile latency."))}var Rn=a.z.object({documentKind:ne,stepKey:x,sampleCount:a.z.number().int().nonnegative(),succeeded:a.z.number().int().nonnegative(),failed:a.z.number().int().nonnegative(),skipped:a.z.number().int().nonnegative(),durationP50Ms:S,durationP95Ms:S,lastStartedAt:u.nullable()}).strict().superRefine(gn);var re=[{key:"enable_summary_generation",featureFlagKey:null,label:"\u8981\u7D04\u751F\u6210"},{key:"enable_structured_extraction",featureFlagKey:null,label:"\u69CB\u9020\u5316\u62BD\u51FA"},{key:"enable_asset_extraction",featureFlagKey:"ENABLE_ASSET_EXTRACTION",label:"\u30A2\u30BB\u30C3\u30C8\u62BD\u51FA"},{key:"enable_vector_indexing",featureFlagKey:"ENABLE_VECTOR_INDEXING",label:"\u30D9\u30AF\u30C8\u30EB\u7D22\u5F15"},{key:"enable_graph_indexing",featureFlagKey:"ENABLE_GRAPH_INDEXING",label:"\u30B0\u30E9\u30D5\u6295\u5F71"}],_n=new Set(re.map(e=>e.key));function An(e){return _n.has(e)}function Nn(e){let t=re.find(n=>n.key===e);if(t===void 0)throw new Error(`ENRICHMENT_STAGES does not carry ${e}; the canonical list and the key type have drifted apart.`);return t}var Cn={pageSize:{min:1,max:200,default:50},topologyLabels:{min:1,max:24,default:24}};var _=-1,h=0;function lt(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}function Tn(){let e=typeof globalThis<"u"&&globalThis.crypto?globalThis.crypto:typeof crypto<"u"?crypto:void 0;if(!e||typeof e.getRandomValues!="function")throw new Error("Cryptographically secure random number generator (crypto.getRandomValues) is required but not available.");let t=new Uint8Array(16);e.getRandomValues(t);let n=Date.now();if(n===_){if(h++,h>4095){for(;Date.now()<=_;);n=Date.now(),_=n,h=(t[6]<<4|t[7]&15)&1023}}else n>_?(_=n,h=(t[6]<<4|t[7]&15)&1023):(n=_,h++,h>4095&&(h=0));t[0]=Math.floor(n/1099511627776)&255,t[1]=Math.floor(n/4294967296)&255,t[2]=n>>>24&255,t[3]=n>>>16&255,t[4]=n>>>8&255,t[5]=n&255,t[6]=112|h>>>8&15,t[7]=h&255,t[8]=128|t[8]&63;let i=Array.from(t,c=>c.toString(16).padStart(2,"0")).join("");return`${i.slice(0,8)}-${i.slice(8,12)}-${i.slice(12,16)}-${i.slice(16,20)}-${i.slice(20)}`}function bn(e){if(!lt(e))throw new Error(`Invalid RFC 9562 UUIDv7 string: "${e}"`);let t=e.slice(0,8)+e.slice(9,13),n=parseInt(t,16);if(Number.isNaN(n))throw new Error(`Invalid hex timestamp in UUIDv7: "${t}"`);return new Date(n)}0&&(module.exports={AmountEntrySchema,BaseEnrichmentClient,BodySourceSchema,BoundingBoxSchema,CIRCUIT_BREAKER_SERVICES,CanonicalDomainKeySchema,ChapterSegmentSchema,ChunkingStrategySchema,CircuitBreakerStatusSchema,ConfidentialityLevelSchema,DISPATCH_DEGRADATION_REASONS,DOCUMENT_KINDS,DOCUMENT_KIND_LABELS,DocumentKindSchema,DocumentStructuredDataSchema,ENRICHMENT_STAGES,EnrichmentClient,EnrichmentClientError,EnrichmentSyncStatusSchema,FILTERABLE_CONFIDENTIALITY_LEVELS,FileUriSchema,GRAPH_INDEX_LIMITS,GraphSearchHitSchema,INTEGRITY_CLASS_POLICY,INTEGRITY_COMMAND_CODES,INTEGRITY_FINDINGS_PAGE_LIMIT_MAX,IntegrityActiveRunSchema,IntegrityAuditOverviewSchema,IntegrityCancelFailureCodeSchema,IntegrityCommandFailureCodeSchema,IntegrityCommandFailureSchema,IntegrityCommandReplySchema,IntegrityCommandSchema,IntegrityDispositionSchema,IntegrityFindingItemClassSchema,IntegrityFindingPageSchema,IntegrityFindingSchema,IntegrityFindingsQuerySchema,IntegrityItemClassSchema,IntegrityPhaseSchema,IntegrityPlacementObservedSchema,IntegrityQuantitySchema,IntegrityRepairActionSchema,IntegrityRepairOutcomeSchema,IntegrityRepairSkipReasonSchema,IntegrityRunHeaderSchema,IntegrityRunModeSchema,IntegrityRunStatusSchema,IntegrityScopeRoleSchema,IntegrityStartFailureCodeSchema,IntegrityStoreSchema,IntegrityUnitSchema,IntegrityVerdictSchema,LOCAL_DEGRADATION_REASONS,MIME_KIND_RULES,MODE_TIERS,ModelProviderSchema,NOTHING_TO_READ_TOKENS,NothingToReadTokenSchema,PIPELINE_FLOWS,PIPELINE_PHASES,PIPELINE_STEPS,PIPELINE_STEP_KEYS,PipelineRunRecordSchema,PipelineRunStatusSchema,PipelineRunSummarySchema,PipelineStepKeySchema,PipelineStepMetricSchema,PipelineStepRecordSchema,PipelineStepStatusSchema,PipelineTriggerSchema,QUARANTINED_CONFIDENTIALITY_LEVEL,REMOTE_DEGRADATION_REASONS,SEARCH_DEGRADATION_REASONS,SEARCH_MODES,SEARCH_PARAM_LIMITS,SYSTEM_PARAMETER_RANGES,SearchHitSchema,SearchMetadataSchema,SearchModeSchema,SearchRequestSchema,SearchResponseSchema,StageProvenanceSchema,TenantIdSchema,TranscriptSegmentSchema,assertBoundedSystemParameter,assertSystemParameterInRange,classifyDocumentKind,comparePhases,enrichmentStage,flowFor,flowStepGates,formatSkipReason,generateUuidV7,integrityCommandFailureCodeOf,isEnrichmentStageKey,isStrictlyEarlier,isValidUuidV7,modeFusesRankings,modeNeedsRemoteTiers,modeScoreIsSimilarity,narrowModeToAllowedTiers,orderedSteps,parseSkipReason,uuidv7ToDate});
|