Refine seal-home skill routing docs
This commit is contained in:
1 parent
b0c688a8ba
commit
12dc40e80e
8 files changed
+550
-172
No files matched your search
+54
-166
@@ -1,15 +1,13 @@
|
||||
---
|
||||
name: seal-home
|
||||
description: Use when working with Seal Home approval automation, seal-home CLI or MCP tools, approval rules and documents, approval run history, simulations, enterprise auth diagnostics, and Langfuse trace hints.
|
||||
description: Use when working with Seal Home approval automation: 合思/易快报企业认证, Hose authorization links, approval run lookup by 单号/SN/recordId/batch, compact approval run summaries, AI cited rules, document/attachment summaries, approval rules by count/list/version/code/runtime-id, approval knowledge search, simulations, and Langfuse trace hints.
|
||||
metadata:
|
||||
short-description: Seal approval automation tools
|
||||
---
|
||||
|
||||
# Seal Home
|
||||
|
||||
## Quick Start
|
||||
|
||||
Use the global `seal-home` CLI. It should work from any directory after installation:
|
||||
Use the global `seal-home` CLI. This skill is a routing layer for agents: keep this file short, choose the right command, and read a focused reference only when the task needs detail.
|
||||
|
||||
```bash
|
||||
seal-home help
|
||||
@@ -17,182 +15,72 @@ seal-home version
|
||||
seal-home tools list
|
||||
```
|
||||
|
||||
Use CLI for broad or detailed operations. The CLI intentionally exposes the full fine-grained tool list and is the primary interface for shared/public use.
|
||||
## First Rules
|
||||
|
||||
Enterprise configs are loaded from `SEAL_HOME_ENTERPRISES_DIR` when it is set. Otherwise `./enterprises` and `~/.config/seal-home/enterprises` are merged, with user-level configs overriding same-ID local configs. Prefer user-level config for shared/public installs so commands do not depend on the repository working directory.
|
||||
- Prefer compact commands first: `pick`, `--summary`, `--fields`, `attachments --summary`, `rules count`, and `rules list --summary`.
|
||||
- Parse JSON stdout. Do not scrape human text.
|
||||
- Do not hand-edit enterprise configs for normal setup. Use `seal-home corps ...`.
|
||||
- Before write operations on rules, documents, style preferences, or publishing, fetch current state and confirm the intended mutation with the user.
|
||||
- For date questions, use explicit dates and `--timezone Asia/Shanghai`.
|
||||
- If output may be large, use `--summary`, `--fields`, `--count`, or `--output-file`; use `--full` only when the user really needs full payloads.
|
||||
|
||||
Optional local service commands:
|
||||
## Route By Intent
|
||||
|
||||
- Current tenant or identity: `seal-home tool seal_whoami`.
|
||||
- Enterprise list/current/switch/add: `seal-home corps ...`; for Hose setup read `references/hose-enterprise-auth.md`.
|
||||
- Hose login/SSO/auth failures: `seal-home auth diagnose --corp <corpId>`.
|
||||
- User-facing 合思 authorization link: `seal-home auth hose-link --corp <corpId> --expire 7200`; read `references/hose-enterprise-auth.md`.
|
||||
- One approval document by 单号/SN: use `seal-home approval-runs pick --sn <单号> --latest`; read `references/approval-run-lightweight.md`.
|
||||
- One approval run detail: use `approval-runs get <recordId> --summary` or `--fields ...`; read `references/approval-run-lightweight.md`.
|
||||
- AI used which rules: use `approval-runs cited-rules <recordId>`; read `references/approval-run-lightweight.md`.
|
||||
- Case/document facts before deep dive: use `approval-runs document-summary <recordId>`.
|
||||
- Attachments/invoices without full raw document: use `approval-runs attachments <recordId> --summary`.
|
||||
- Customer disputes OCR, receipt, invoice, image, or attachment findings: read `references/approval-attachment-trace.md`.
|
||||
- Rules count/list/version lookup: use `rules count`, `rules list --summary`, or `rules get`; read `references/rule-lightweight.md`.
|
||||
- Rule/document/style maintenance: use fine-grained `seal-home tool <toolName> --json ...`.
|
||||
- Approval knowledge search: use `seal_approval_search` with `snippetOnly`, `maxChars`, and `fields` when possible; read `references/rule-lightweight.md`.
|
||||
- Daily run summary: `seal-home approval-runs summary --date YYYY-MM-DD --timezone Asia/Shanghai --limit 100`.
|
||||
- Simulation batch: `seal-home simulation batch-records <batchId>`.
|
||||
- Full CLI inventory: read `references/cli.md`.
|
||||
|
||||
## High-Value Commands
|
||||
|
||||
```bash
|
||||
seal-home service start
|
||||
seal-home service status
|
||||
seal-home service restart
|
||||
seal-home service stop
|
||||
seal-home update
|
||||
```
|
||||
|
||||
Use `seal-home update` after pulling new versions; it restarts the service if it was running so new code is picked up.
|
||||
|
||||
## Decision Guide
|
||||
|
||||
- For current identity or tenant: use `seal-home tool seal_whoami`.
|
||||
- For configured enterprises: use `seal-home corps list`.
|
||||
- For Hose login, SSO, or "Unable to connect" authentication failures: use `seal-home auth diagnose [--corp <corpId>]`.
|
||||
- For an unredacted Hose provisional auth link: use `seal-home auth hose-link --corp <corpId> --expire 7200`.
|
||||
- For source-derived enterprise config: use `seal-home source config`.
|
||||
- For daily approval run questions: use `seal-home approval-runs summary --date YYYY-MM-DD --timezone Asia/Shanghai`.
|
||||
- For approval run lookup by document SN, ID, status, mode, or trace: use `seal-home approval-runs search`.
|
||||
- For compact approval run detail: use `seal-home approval-runs get <recordId> --fields metadata`, `seal-home approval-runs attachments <recordId>`, or `seal-home approval-runs result <recordId> --summary`.
|
||||
- For Hose enterprise assist links: use `seal-home approval-runs url`; add `<recordId>` or `--sourceDocumentSN B26001887` when a document link is also needed.
|
||||
- For Langfuse lookup hints: use `seal-home approval-runs bridge`.
|
||||
- For one simulation batch: use `seal-home simulation batch-records <batchId>`.
|
||||
- For approval rule/document/style maintenance: use `seal-home tool <toolName> --json '{...}'`.
|
||||
|
||||
## Task Playbooks
|
||||
|
||||
### Diagnose Hose authentication
|
||||
|
||||
Use when a Hose/合思 sourced enterprise cannot log in, `seal_whoami` fails, or an agent needs to verify a newly added enterprise config.
|
||||
|
||||
```bash
|
||||
seal-home auth diagnose --corp <corpId>
|
||||
```
|
||||
|
||||
Read the JSON `stages` in order:
|
||||
|
||||
- `hose.openapi`: appKey/appSecurity can get a Hose OpenAPI token and corporation ID.
|
||||
- `hose.provisional`: `proxyStaffBizId`/staff ID can get a provisional auth URL.
|
||||
- `seal.sso`: Seal accepts the Hose provisional token and returns a bearer session.
|
||||
- `seal.whoami`: the Seal bearer can read current user and tenant.
|
||||
|
||||
Do not expect tokens in the output; the command intentionally redacts or omits them. If a stage fails, report that stage and its error, then stop assuming later stages worked.
|
||||
|
||||
### Diagnose one approval document
|
||||
|
||||
Use when the user gives a 合思/易快报单号, Seal source document SN, source document ID, or asks why one approval did or did not pass.
|
||||
|
||||
1. Search runs:
|
||||
|
||||
```bash
|
||||
seal-home approval-runs search --query <document-or-trace-key> --limit 50
|
||||
```
|
||||
|
||||
2. If a likely record is found, get bridge hints:
|
||||
|
||||
```bash
|
||||
seal-home approval-runs bridge --sourceDocumentSN <sourceDocumentSN>
|
||||
```
|
||||
|
||||
3. Report `status`, `taskMode`, `finalExecutionMode`, `recordId`, `simulationBatchId`, `langfuseTraceId`, and `langfuseSessionFallback`. If `langfuseTraceId` is absent, tell the caller to use the session fallback.
|
||||
|
||||
### Summarize one day of approval runs
|
||||
|
||||
Use explicit local date and timezone:
|
||||
|
||||
```bash
|
||||
seal-home approval-runs summary --date YYYY-MM-DD --timezone Asia/Shanghai --limit 100
|
||||
```
|
||||
|
||||
Report matched count, status counts, task mode counts, and the most relevant failed or simulated records. If `matched` is unexpectedly low, rerun with broader `limit` or targeted `query`.
|
||||
|
||||
### Inspect a simulation batch
|
||||
|
||||
```bash
|
||||
seal-home simulation batch-records <batchId>
|
||||
```
|
||||
|
||||
Summarize count, statuses, source document identifiers, and bridge hints. For failures, preserve record IDs so another tool can inspect the trace.
|
||||
|
||||
### Search approval knowledge
|
||||
|
||||
Use for "which rule/document mentions X" or before changing rule/document content:
|
||||
|
||||
```bash
|
||||
seal-home tool seal_approval_search --json '{"keywords":["关键词"],"matchMode":"any","maxResults":20}'
|
||||
```
|
||||
|
||||
Use `areas` to narrow to `rules`, `documents`, or `preferences`. Separate CLI invocations are short-lived processes and do not share in-memory search caches. Use the local service as the restartable long-lived process for future cached workflows.
|
||||
|
||||
### Update approval rules
|
||||
|
||||
Write workflow:
|
||||
|
||||
1. Read current rules with `seal_approval_rules_list` or `seal_approval_context_get`.
|
||||
2. Identify the exact rule ID or create payload.
|
||||
3. Present the intended change and ask for confirmation.
|
||||
4. Run `seal_approval_rule_create`, `seal_approval_rule_update`, or `seal_approval_rule_delete`.
|
||||
5. Read rules again to verify.
|
||||
6. Publish only when explicitly requested, using `seal_approval_rule_version_publish` with a clear `versionName`.
|
||||
|
||||
### Update approval documents
|
||||
|
||||
Write workflow:
|
||||
|
||||
1. List or fetch the target document.
|
||||
2. Present the intended title/purpose/content/status/scenario/tag change.
|
||||
3. Ask for confirmation.
|
||||
4. Run `seal_approval_document_create` or `seal_approval_document_update`.
|
||||
5. Fetch the document again to verify.
|
||||
|
||||
There is no dedicated delete command in the current CLI. If deactivation is intended and the API supports it, update with `enabled:false`.
|
||||
|
||||
### Update style preferences
|
||||
|
||||
Read first:
|
||||
|
||||
```bash
|
||||
seal-home tool seal_approval_style_preferences_get
|
||||
```
|
||||
|
||||
Then update only explicit fields:
|
||||
|
||||
```bash
|
||||
seal-home tool seal_approval_style_preferences_update --json '{"tone":"...","language":"..."}'
|
||||
```
|
||||
|
||||
Verify by reading again.
|
||||
|
||||
## Important Fields
|
||||
|
||||
- `sourceDocumentSN`: external source document number, often the easiest 合思/易快报 lookup key.
|
||||
- `sourceDocumentId`: external source document ID.
|
||||
- `status`: run status such as completed or failed.
|
||||
- `taskMode`: execution mode category such as assisted or simulation.
|
||||
- `finalExecutionMode`: final mode chosen by the approval agent.
|
||||
- `recordId`: Seal approval run record ID.
|
||||
- `simulationBatchId`: simulation batch identifier when the run came from a batch.
|
||||
- `langfuseTraceId`: direct Langfuse trace lookup key when present.
|
||||
- `langfuseSessionFallback`: fallback session key, usually `hosecloud-{sourceDocumentSN}`, when direct trace ID is absent.
|
||||
|
||||
## CLI Patterns
|
||||
|
||||
Read `references/cli.md` when you need the full tool list, parameter examples, or maintenance commands.
|
||||
|
||||
Preferred command forms:
|
||||
|
||||
```bash
|
||||
seal-home approval-runs summary --date 2026-06-09 --timezone Asia/Shanghai
|
||||
seal-home approval-runs pick --sn B26001887 --latest
|
||||
seal-home approval-runs pick --sn <sourceDocumentSN> --latest
|
||||
seal-home approval-runs pick --sn <sourceDocumentSN> --batch <batchId> --latest --fields recordId,status,aiDecision,aiSummary
|
||||
seal-home approval-runs get <recordId> --summary
|
||||
seal-home approval-runs get <recordId> --fields metadata,document.fields,result.summary
|
||||
seal-home approval-runs document-summary <recordId>
|
||||
seal-home approval-runs cited-rules <recordId>
|
||||
seal-home approval-runs attachments <recordId> --summary
|
||||
seal-home approval-runs result <recordId> --summary
|
||||
seal-home rules count --corp <corpId>
|
||||
seal-home rules list --corp <corpId> --summary
|
||||
seal-home rules get --version 16 --code '#0038'
|
||||
seal-home approval-runs url
|
||||
seal-home approval-runs url --sourceDocumentSN B26001887
|
||||
seal-home approval-runs bridge --sourceDocumentSN B26001887
|
||||
seal-home tool seal_approval_search --json '{"keywords":["差旅","发票"],"areas":["rules","documents"]}'
|
||||
seal-home rules get --record-id <recordId> --runtime-id rule-205
|
||||
seal-home tool seal_approval_search --json '{"keywords":["差旅","发票"],"areas":["rules"],"snippetOnly":true,"maxChars":500,"fields":["id","title","snippet"]}'
|
||||
```
|
||||
|
||||
## Output Handling
|
||||
## Important Fields
|
||||
|
||||
CLI output is JSON on stdout. Parse JSON instead of scraping text. Keep broad responses compact: avoid `includeBridge true` unless trace/session bridge rows are needed.
|
||||
- `sourceDocumentSN`: external document number, often the easiest 合思/易快报 lookup key.
|
||||
- `sourceDocumentId`: external source document ID.
|
||||
- `recordId`: Seal approval run record ID.
|
||||
- `simulationBatchId`: simulation batch identifier.
|
||||
- `status`: run status.
|
||||
- `taskMode` / `finalExecutionMode`: execution mode information.
|
||||
- `ruleSetVersionNumber`: approval rule version used by a run.
|
||||
- `langfuseTraceId`: direct Langfuse trace lookup key.
|
||||
- `langfuseSessionFallback`: fallback session key, usually `hosecloud-{sourceDocumentSN}`.
|
||||
|
||||
For date-based questions, use explicit dates and timezone. Default timezone is usually `Asia/Shanghai`; pass it explicitly when answering business questions.
|
||||
## References
|
||||
|
||||
- `references/approval-run-lightweight.md`: 单号定位、字段裁剪、摘要、引用规则、单据摘要、附件摘要。
|
||||
- `references/rule-lightweight.md`: 规则 count/list summary、按版本/编号取单条规则、规则搜索裁剪。
|
||||
- `references/hose-enterprise-auth.md`: Hose 企业配置、认证诊断、授权链接。
|
||||
- `references/approval-attachment-trace.md`: 附件/发票/OCR/图片争议的 Langfuse 追踪工作流。
|
||||
- `references/cli.md`: 完整 CLI 命令清单。
|
||||
|
||||
## Safety
|
||||
|
||||
Rule, document, style preference, and publish actions mutate Seal configuration. Before running write operations, make sure the target enterprise is clear and the requested payload is explicit. Prefer listing or fetching the current state before update/delete/publish.
|
||||
|
||||
For public or shared use, assume the CLI runs locally with the user's own credentials. Do not send real `enterprises/*.json` files to GitHub, chat, logs, or tickets.
|
||||
Rule, document, style preference, and publish actions mutate Seal configuration. Make the target enterprise explicit, show the intended payload, and verify after the write. Never send real `enterprises/*.json` files, tokens, signed URLs, or full raw documents to GitHub, tickets, logs, or chat unless the user explicitly requests a safe export.
|
||||
@@ -1,4 +1,4 @@
|
||||
interface:
|
||||
display_name: "Seal Home"
|
||||
short_description: "Use Seal approval context and run diagnostics"
|
||||
default_prompt: "Use $seal-home to inspect Seal approval rules, documents, run history, and Langfuse trace hints."
|
||||
short_description: "Inspect Seal approval runs, rules, Hose auth, and compact diagnostics"
|
||||
default_prompt: "Use $seal-home for Seal approval automation: locate runs by 单号/SN, read compact summaries, inspect cited rules, rule versions, Hose auth links, and Langfuse trace hints."
|
||||
@@ -0,0 +1,221 @@
|
||||
# Approval Attachment Trace Investigation
|
||||
|
||||
Use this workflow when a customer disputes an AI approval finding about an attachment, invoice, receipt, OCR result, or a UI-highlighted audit result.
|
||||
|
||||
The goal is to locate where an imprecise claim first entered the pipeline. Do not jump directly from the final approval result to a rule change. Many issues start earlier in the attachment understanding or attachment review stages.
|
||||
|
||||
## Mental Model
|
||||
|
||||
Approval traces commonly contain these stages:
|
||||
|
||||
1. Source document rendering
|
||||
- Seal converts the approval document into the Markdown-like "AI saw" document.
|
||||
- This may include both structured invoice fields and raw attachment fields.
|
||||
2. Rule matching
|
||||
- Selects applicable rule scopes such as "存在发票或收据时" or "存在发票时".
|
||||
- This stage is not the final source of attachment type judgments; it works from the rendered document.
|
||||
3. Image understanding
|
||||
- Vision model reads each image attachment and writes `document_content`.
|
||||
- This is often where loose labels such as "发票(或收据)", "定额发票", "销售单", or "支付凭证" first appear.
|
||||
4. Pre-analysis
|
||||
- Generates `attachmentInstructions` and `reviewPoints` for later per-attachment review.
|
||||
- This stage can matter when a later attachment review seems to ignore or override values already present in the generated review points.
|
||||
5. Document parsing / attachment review
|
||||
- A text model checks review points against the image-understanding text.
|
||||
- If the review point already says "该附件(定额发票)", it usually inherited that label from the previous stage instead of independently classifying the original image.
|
||||
- Check whether this stage uses values passed in the review point, or reclassifies the attachment and discards them.
|
||||
6. Final approval review
|
||||
- Produces `rulesResult`, summaries, and UI findings.
|
||||
- Final findings can amplify earlier labels into business conclusions, for example "附件中存在定额发票未上传至发票栏位".
|
||||
|
||||
## Commands
|
||||
|
||||
Start from the Seal run and Langfuse trace.
|
||||
|
||||
```bash
|
||||
seal-home approval-runs search --query <sourceDocumentSN> --limit 50
|
||||
seal-home approval-runs get <recordId> > /tmp/seal-run.json
|
||||
seal-home approval-runs bridge --sourceDocumentSN <sourceDocumentSN>
|
||||
```
|
||||
|
||||
Refresh and inspect the Langfuse trace.
|
||||
|
||||
```bash
|
||||
langfuse-home call langfuse_trace_cache_refresh --json '{"traceId":"<traceId>"}'
|
||||
langfuse-home call langfuse_trace_url_get --json '{"traceId":"<traceId>"}'
|
||||
langfuse-home call langfuse_trace_outline_get --json '{"traceId":"<traceId>","includeInput":true,"includeOutput":true,"maxPreviewChars":800}'
|
||||
```
|
||||
|
||||
If `langfuse_trace_qrep_search` does not find Chinese terms reliably, grep the cached JSON directly.
|
||||
|
||||
```bash
|
||||
rg -n "发票未上传至发票栏位|附件中存在定额发票|检查该附件(定额发票)|<file-name-or-fileId>" \
|
||||
.cache/langfuse/traces/default/<traceId>.json
|
||||
```
|
||||
|
||||
Read focused IO for the relevant observations.
|
||||
|
||||
```bash
|
||||
langfuse-home call langfuse_observation_io_get --json '{"traceId":"<traceId>","observationId":"<observationId>","maxChars":30000}'
|
||||
```
|
||||
|
||||
## Separate Object IDs Before Judging
|
||||
|
||||
Never assume same-looking file names are the same object.
|
||||
|
||||
In Seal run detail, invoice-list entries and raw attachment entries can be separate objects:
|
||||
|
||||
- `invoiceForm` / `发票列表` entries often have source invoice IDs, invoice numbers, OCR-derived file names, `verifyResult`, `fileInfo.fileType=invoice`, and invoice metadata.
|
||||
- `attachments` / `附件` entries often have UI file IDs such as `file-7`, Hose file IDs inside `token`, `category=file`, `mimeType=image/jpeg`, and their own OSS path.
|
||||
|
||||
Use `jq` to list them side by side.
|
||||
|
||||
```bash
|
||||
jq -r '
|
||||
.document.fields[] | select(.key=="details") | .value[0][] | select(.key=="invoiceForm") | .value[] |
|
||||
["invoiceForm", .sourceInvoiceId, .invoice.invoiceNumber, .invoice.fileInfo.fileName, .invoice.fileInfo.fileType, .invoice.fileInfo.ossPath, (.invoice.verifyResult.rawData | fromjson? | .form.sourceEntityId // "")] | @tsv
|
||||
' /tmp/seal-run.json
|
||||
```
|
||||
|
||||
```bash
|
||||
jq -r '
|
||||
.document.fields[] | select(.key=="details") | .value[0][] | select(.key=="attachments") | .value[] |
|
||||
["attachments", .fileId, .name, .category, .mimeType, .ossPath, .token] | @tsv
|
||||
' /tmp/seal-run.json
|
||||
```
|
||||
|
||||
When explaining the result, say precisely whether the disputed item is:
|
||||
|
||||
- a structured invoice-list object,
|
||||
- a raw attachment object,
|
||||
- or two distinct objects with similar file names/content.
|
||||
|
||||
## Find Where A Bad Label First Appeared
|
||||
|
||||
Search for the UI finding text and the disputed label.
|
||||
|
||||
```bash
|
||||
jq -r '
|
||||
def walkobs(o): o, ((o.children // [])[] | walkobs(.));
|
||||
.trace.observations[] | walkobs(.)
|
||||
| select(((.input|tostring)+"\n"+(.output|tostring))
|
||||
| contains("发票未上传至发票栏位")
|
||||
or contains("附件中存在定额发票")
|
||||
or contains("检查该附件(定额发票)"))
|
||||
| [.id,.name,.type,.startTime,((.output|tostring)|gsub("\n";" ")|.[0:500])] | @tsv
|
||||
' .cache/langfuse/traces/default/<traceId>.json
|
||||
```
|
||||
|
||||
Then inspect the earliest matching observation. Typical interpretation:
|
||||
|
||||
- `image_understanding:ai.streamText`: the vision stage first assigned the type label.
|
||||
- `pre_analysis:ai.streamText`: the instruction-generation stage turned matched rules and parsed attachments into per-file `reviewPoints`; this is where attachment-side values or labels can be copied into prompts.
|
||||
- `document_parsing:ai.streamText`: the attachment review inherited the label in its review point or document content.
|
||||
- `approval_review:ai.streamText`: the final model converted inherited labels into a rule finding.
|
||||
|
||||
## Check Pre-Analysis For Amount-Total Disputes
|
||||
|
||||
When the customer says the AI "did not recognize the correct amount", "missed one payment screenshot", or "the total should be X", start with the normal trace: source document, image understanding, attachment review, and final review. Inspect `pre_analysis` when the evidence suggests the disputed amount was recognized earlier but later ignored, or when final review is aggregating inconsistent per-attachment conclusions. Treat this as a possible failure mode, not as the default cause.
|
||||
|
||||
Find the node:
|
||||
|
||||
```bash
|
||||
jq -r '
|
||||
def walkobs(x; depth): (x + {depth: depth}), ((x.children? // [])[] | walkobs(.; depth+1));
|
||||
.trace.observations[] | walkobs(.; 0)
|
||||
| select(.name? | test("pre_analysis"))
|
||||
| [.startTime,.id,.name,.type,.parentObservationId,((.input|tostring|length)//0),((.output|tostring|length)//0)] | @tsv
|
||||
' .cache/langfuse/traces/default/<traceId>.json
|
||||
```
|
||||
|
||||
Then inspect its output for the disputed file and rule:
|
||||
|
||||
```bash
|
||||
jq -r '
|
||||
def walkobs(x): x, ((x.children? // [])[] | walkobs(.));
|
||||
.trace.observations[] | walkobs(.)
|
||||
| select(.name? == "pre_analysis:ai.streamText")
|
||||
| .output
|
||||
' .cache/langfuse/traces/default/<traceId>.json | rg -n "fileId|fileName|<file-name>|付款截图金额|收款金额|金额合计"
|
||||
```
|
||||
|
||||
Look for these failure patterns:
|
||||
|
||||
- A global aggregate requirement was split into per-attachment review points, for example each attachment is asked whether its amount plus "other attachments" reaches the reimbursement amount.
|
||||
- The pre-analysis prompt says not to write attachment OCR/image-understanding candidate values into review points, but the output still includes values such as "付款截图金额(1850.00元)" or labels such as "收款凭证".
|
||||
- The same physical image appears twice because it exists under both form-level attachments and fee-detail attachments, producing duplicate `fileId`s and potentially inconsistent later judgments.
|
||||
- `pre_analysis` passes a value down, but `document_parsing` reclassifies the file and ignores that value, for example a review point says "付款截图金额(1850.00元)" while the parser answer says "收款凭证,非付款截图".
|
||||
|
||||
For these cases, the amount may not be lost in OCR or image understanding. It may be lost when a later attachment-review node overrides the pre-analysis task premise, or when final approval review aggregates inconsistent per-file conclusions. For concrete examples, see `approval-bad-cases.md`.
|
||||
|
||||
## Check Images When The Dispute Is Visual
|
||||
|
||||
If the issue depends on whether an image is a receipt or invoice, inspect the raw image. Do not rely only on the model's textual description.
|
||||
|
||||
Extract raw attachment signed URLs from `/tmp/seal-run.json` and download the disputed files.
|
||||
|
||||
```bash
|
||||
jq -r '
|
||||
.document.fields[] | select(.key=="details") | .value[0][] | select(.key=="attachments") | .value[] |
|
||||
select(.fileId=="file-7" or .fileId=="file-9") |
|
||||
[.fileId,.name,.ossSignedUrl] | @tsv
|
||||
' /tmp/seal-run.json
|
||||
```
|
||||
|
||||
Look for invoice-specific elements:
|
||||
|
||||
- "发票" text in the title
|
||||
- invoice code / invoice number
|
||||
- tax bureau supervision seal
|
||||
- tax invoice QR/code metadata
|
||||
- buyer/seller tax information
|
||||
- taxable amount / tax rate / tax amount fields
|
||||
|
||||
If those are absent and the document is a store-stamped handwritten slip, it is safer to call it a receipt or sales voucher, not a formal invoice.
|
||||
|
||||
## Reporting Pattern
|
||||
|
||||
When answering the user, separate:
|
||||
|
||||
- What the final UI finding says.
|
||||
- The first pipeline stage where the disputed claim appeared.
|
||||
- Whether the disputed file is a raw attachment or a structured invoice-list object.
|
||||
- Whether the raw image supports the claim.
|
||||
- Whether the final decision still stands for other independent reasons.
|
||||
|
||||
Example wording:
|
||||
|
||||
```text
|
||||
The UI finding was produced in final approval review, but the imprecise label started earlier:
|
||||
image_understanding labeled file-9 as "定额发票"; document_parsing then inherited that as "该附件(定额发票)"; approval_review converted it into the rule-3 finding.
|
||||
|
||||
The raw attachment object itself is not structurally marked as invoice; it is category=file, mimeType=image/jpeg. The image lacks formal invoice elements, so the customer's receipt interpretation is reasonable.
|
||||
```
|
||||
|
||||
## Case Note: Receipt-Like Attachments Labeled As Invoices
|
||||
|
||||
This case involved a UI finding:
|
||||
|
||||
```text
|
||||
发票未上传至发票栏位:附件中存在定额发票(金额160元、90元),但未上传至发票栏位。
|
||||
```
|
||||
|
||||
Important correction:
|
||||
|
||||
- `file-7` and `file-9` were raw attachment objects, not the same objects as the invoice-list entries.
|
||||
- The invoice list had separate IDs (`ID01P95oy1RWbB`, `ID01P95oy22hnV`).
|
||||
- The raw attachments had separate file IDs (`file-7` / Hose `ID01P95CwuNGLJ`, and `file-9` / Hose `ID01P95RUC9T79`).
|
||||
|
||||
Root of imprecision:
|
||||
|
||||
- `file-7` was first described by `image_understanding` as "发票(或收据)", then later attachment review used "定额发票".
|
||||
- `file-9` was directly described by `image_understanding` as "定额发票".
|
||||
- Final `approval_review` turned those inherited labels into the rule-3 UI warning.
|
||||
|
||||
Manual image check:
|
||||
|
||||
- The 160 and 90 slips looked like store-stamped handwritten receipts/sales vouchers.
|
||||
- They lacked obvious formal invoice elements.
|
||||
- The customer's objection that they were receipts rather than invoices was reasonable.
|
||||
|
||||
However, the final rejection also had an independent rule-37 reason: payment screenshots totaled 699.48 while reimbursement was 700.00.
|
||||
@@ -0,0 +1,50 @@
|
||||
# Approval Bad Case Catalog
|
||||
|
||||
Use this file only as a comparison catalog after inspecting the current trace. Do not treat any case below as a default diagnosis.
|
||||
|
||||
## Case A: Receipt-Like Attachments Labeled As Invoices
|
||||
|
||||
Symptom:
|
||||
|
||||
- UI finding said attachments contained fixed-amount invoices that were not uploaded to the invoice field.
|
||||
- Customer said the 160 and 90 slips were receipts, not invoices.
|
||||
|
||||
Failure pattern:
|
||||
|
||||
- Raw attachment objects and invoice-list objects had similar names/content but different IDs.
|
||||
- `image_understanding` first introduced loose or wrong labels such as "发票(或收据)" and "定额发票".
|
||||
- `document_parsing` inherited those labels.
|
||||
- `approval_review` converted the inherited labels into a rule finding.
|
||||
|
||||
Checklist:
|
||||
|
||||
- Compare raw attachment IDs and invoice-list IDs before making a claim.
|
||||
- Inspect the original image for formal invoice elements.
|
||||
- If the image lacks invoice title, tax supervision seal, invoice code/number, and tax fields, the customer's receipt interpretation may be reasonable.
|
||||
|
||||
## Case B: Payment Amount Passed Earlier, Then Excluded Later
|
||||
|
||||
Symptom:
|
||||
|
||||
- UI finding said payment screenshots totaled only 1550 (`650+900`) against reimbursement amount 3400.
|
||||
- Customer said the 1850 screenshot was also a payment-support screenshot and should have been included.
|
||||
|
||||
Failure pattern:
|
||||
|
||||
- The same six images appeared twice: under fee-detail attachments (`file-1` to `file-6`) and form-level attachments (`file-7` to `file-12`).
|
||||
- `image_understanding` did not lose the 1850 amount; it extracted `1850.00`.
|
||||
- `pre_analysis` explicitly passed 1850 as a payment-screenshot amount candidate in a review point: "付款截图金额(1850.00元)".
|
||||
- `document_parsing` later reclassified `1850.jpg` as "收款凭证,非付款截图", overriding the review-point premise.
|
||||
- Duplicate `900.jpg` entries produced inconsistent parser conclusions; final review included 900 but excluded 1850.
|
||||
|
||||
Checklist:
|
||||
|
||||
- If an amount is missing from the final total, check whether it was recognized in `image_understanding`.
|
||||
- If recognized, check whether `pre_analysis` passed it in `attachmentInstructions.reviewPoints`.
|
||||
- If passed, check whether `document_parsing` ignored or reclassified it.
|
||||
- If the same image appears under multiple `fileId`s, compare duplicate conclusions before trusting final aggregation.
|
||||
|
||||
Important nuance:
|
||||
|
||||
- This is a bad-case pattern, not a general rule that every amount-total dispute is caused by `pre_analysis`.
|
||||
- Use it when the current trace shows recognized amounts being excluded downstream or duplicate attachments producing inconsistent conclusions.
|
||||
@@ -0,0 +1,82 @@
|
||||
# Approval Run Lightweight Queries
|
||||
|
||||
Use this reference when the user gives a 合思/易快报单号, source document SN, record ID, simulation batch ID, or asks for an approval decision without needing the full raw run payload.
|
||||
|
||||
## Locate A Run By Document Number
|
||||
|
||||
Prefer `pick` before broad search + bridge + get.
|
||||
|
||||
```bash
|
||||
seal-home approval-runs pick --corp <corpId> --sn <sourceDocumentSN> --latest
|
||||
seal-home approval-runs pick --corp <corpId> --sn <sourceDocumentSN> --batch <batchId> --latest
|
||||
seal-home approval-runs pick --corp <corpId> --sn <sourceDocumentSN> --latest --fields recordId,sourceDocumentSN,status,aiDecision,aiSummary
|
||||
```
|
||||
|
||||
Default output is intentionally small: `recordId`, `sourceDocumentSN`, `sourceDocumentId`, `simulationBatchId`, `status`, `taskMode`, `ruleSetVersionNumber`, `langfuseTraceId`, `manualResult`, `aiDecision`, and `aiSummary`.
|
||||
|
||||
If there are multiple candidates and `--latest` was not used, report the candidates and ask which one to inspect.
|
||||
|
||||
## Read Compact Run Detail
|
||||
|
||||
Use `--summary` for most diagnosis and support questions.
|
||||
|
||||
```bash
|
||||
seal-home approval-runs get <recordId> --summary
|
||||
```
|
||||
|
||||
Use `--fields` when the user needs a particular slice.
|
||||
|
||||
```bash
|
||||
seal-home approval-runs get <recordId> --fields metadata
|
||||
seal-home approval-runs get <recordId> --fields document.fields,result.summary
|
||||
seal-home approval-runs get <recordId> --fields result.summary,result.decision,result.riskPoints
|
||||
seal-home approval-runs get <recordId> --fields document.keyFields,result,manualApprovalRecord,ruleSetVersionNumber
|
||||
```
|
||||
|
||||
Avoid full `approval-runs get <recordId>` unless the user specifically needs raw document fields, pipeline logs, invoice rawData, or signed URLs. Prefer `--output-file` for full payloads.
|
||||
|
||||
## Understand The Case First
|
||||
|
||||
Before pulling the full document, use:
|
||||
|
||||
```bash
|
||||
seal-home approval-runs document-summary <recordId>
|
||||
```
|
||||
|
||||
This is for quick case reading: template/title, key fields, amount, expense type, cost company, payee, invoice summary, attachment names, AI result, and manual result.
|
||||
|
||||
## Extract AI-Cited Rules
|
||||
|
||||
Use this when the user asks "AI 用了哪条规则", "为什么命中这条", or needs the rule evidence for a specific run.
|
||||
|
||||
```bash
|
||||
seal-home approval-runs cited-rules <recordId>
|
||||
```
|
||||
|
||||
Return and discuss `runtimeRuleId`, `ruleCode`, `versionNumber`, `scope`, `strictness`, `appliedAnalysis`, `checkResult`, and `findings` when present.
|
||||
|
||||
If the user then wants the full text of one cited rule, use `rules get --record-id <recordId> --runtime-id rule-205` from `rule-lightweight.md`.
|
||||
|
||||
## Attachments Without Raw Payloads
|
||||
|
||||
Use:
|
||||
|
||||
```bash
|
||||
seal-home approval-runs attachments <recordId> --summary
|
||||
```
|
||||
|
||||
This should be enough for file names, file IDs, mime types, positions, invoice/attachment grouping, and links when available. For customer disputes about OCR, receipt/invoice classification, or image content, switch to `approval-attachment-trace.md`.
|
||||
|
||||
## Result Summary
|
||||
|
||||
Use:
|
||||
|
||||
```bash
|
||||
seal-home approval-runs result <recordId> --summary
|
||||
```
|
||||
|
||||
This is for decision, summary, risk point count, matched rule count, trace ID, and record ID.
|
||||
|
||||
## Output Discipline
|
||||
|
||||
If a command warns that output is large, do not retry with `--full` reflexively. Narrow with `--summary`, `--fields`, or `--output-file` first.
|
||||
@@ -35,8 +35,8 @@ seal-home approval-runs attachments <recordId>
|
||||
seal-home approval-runs result <recordId> [--summary]
|
||||
seal-home approval-runs url
|
||||
seal-home approval-runs url <recordId>
|
||||
seal-home approval-runs url --sourceDocumentSN B26001887
|
||||
seal-home approval-runs bridge [--sourceDocumentSN B26001887]
|
||||
seal-home approval-runs url --sourceDocumentSN <sourceDocumentSN>
|
||||
seal-home approval-runs bridge [--sourceDocumentSN <sourceDocumentSN>]
|
||||
seal-home simulation batch-records <batchId>
|
||||
```
|
||||
|
||||
@@ -171,13 +171,13 @@ seal-home approval-runs summary --date 2026-06-09 --timezone Asia/Shanghai --lim
|
||||
Find a run and include Langfuse bridge rows:
|
||||
|
||||
```bash
|
||||
seal-home approval-runs search --query B26001887 --limit 20 --includeBridge true
|
||||
seal-home approval-runs search --query <sourceDocumentSN> --limit 20 --includeBridge true
|
||||
```
|
||||
|
||||
Resolve Langfuse trace/session hints:
|
||||
|
||||
```bash
|
||||
seal-home approval-runs bridge --sourceDocumentSN B26001887
|
||||
seal-home approval-runs bridge --sourceDocumentSN <sourceDocumentSN>
|
||||
```
|
||||
|
||||
Read simulation batch records:
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
# Hose Enterprise Auth
|
||||
|
||||
Use this reference for Hose/合思 enterprise configuration and user-facing Hose authorization links.
|
||||
|
||||
## Add or switch an enterprise
|
||||
|
||||
Use the CLI for normal enterprise setup. Do not inspect source code or hand-edit `~/.config/seal-home/enterprises/*.json` unless the CLI fails or the user explicitly asks for low-level config debugging.
|
||||
|
||||
```bash
|
||||
seal-home corps add-hose --json '{"name":"企业名称","domain":"https://app.ekuaibao.com","appKey":"...","appSecurity":"...","proxyStaffBizId":"corpId:staffId"}'
|
||||
seal-home corps list
|
||||
seal-home corps current
|
||||
seal-home corps switch <corpId>
|
||||
```
|
||||
|
||||
`corps add-hose` verifies by default and writes the enterprise config. If the user says not to operate business logic, stop at `corps` and auth/config commands; do not run approval, rule, document, simulation, or approval-run commands.
|
||||
|
||||
## Diagnose authentication
|
||||
|
||||
```bash
|
||||
seal-home auth diagnose --corp <corpId>
|
||||
```
|
||||
|
||||
Read the JSON `stages` in order:
|
||||
|
||||
- `hose.openapi`: appKey/appSecurity can get a Hose OpenAPI token and corporation ID.
|
||||
- `hose.provisional`: `proxyStaffBizId`/staff ID can get a provisional auth URL.
|
||||
- `seal.sso`: Seal accepts the Hose provisional token and returns a bearer session.
|
||||
- `seal.whoami`: the Seal bearer can read current user and tenant.
|
||||
|
||||
Do not expect tokens in the output; the command intentionally redacts or omits them.
|
||||
|
||||
## Get a Hose authorization link
|
||||
|
||||
When the user asks for a 合思/易快报授权链接、登录链接、入口链接, or says "来一个授权链接" for a Hose sourced enterprise, return the Hose provisional/CloseAPI URL from `getProvisionalAuth`'s `value.message`.
|
||||
|
||||
Flow:
|
||||
|
||||
1. Obtain an OpenAPI token with appKey/appSecurity:
|
||||
|
||||
```text
|
||||
POST /api/openapi/v1/auth/getAccessToken
|
||||
body: {"appKey":"...","appSecurity":"..."}
|
||||
```
|
||||
|
||||
2. Call provisional auth:
|
||||
|
||||
```text
|
||||
POST /api/openapi/v1.1/provisional/getProvisionalAuth?accessToken=<openapi-token>
|
||||
body: {"uid":"corpId:staffId","pageType":"home","expireDate":7200}
|
||||
```
|
||||
|
||||
3. Return the exact `value.message` URL.
|
||||
|
||||
Important:
|
||||
|
||||
- Do not return the Seal tenant URL such as `https://<tenant>.sealai.cc`; that is not the Hose authorization link.
|
||||
- Do not manually assemble `thirdparty.html` with a global/OpenAPI token.
|
||||
- `seal-home auth diagnose` proves this stage works but redacts the token, so it is not enough when the user needs the actual clickable Hose link.
|
||||
- If the CLI later provides a dedicated command for this, prefer that command.
|
||||
@@ -0,0 +1,77 @@
|
||||
# Rule Lightweight Queries
|
||||
|
||||
Use this reference when the user wants rule counts, compact rule lists, one rule from a historical version, or approval knowledge search without dumping hundreds of rule descriptions.
|
||||
|
||||
## Count Rules
|
||||
|
||||
Use count when only scale or existence matters.
|
||||
|
||||
```bash
|
||||
seal-home rules count --corp <corpId>
|
||||
```
|
||||
|
||||
Expected shape:
|
||||
|
||||
```json
|
||||
{ "count": 191 }
|
||||
```
|
||||
|
||||
Tool-layer equivalent:
|
||||
|
||||
```bash
|
||||
seal-home tool seal_approval_rules_list --json '{"countOnly":true}'
|
||||
seal-home tool seal_approval_rules_list --json '{"fields":["id"],"limit":0}'
|
||||
```
|
||||
|
||||
## List Rule Summaries
|
||||
|
||||
Use summaries for navigation and selection.
|
||||
|
||||
```bash
|
||||
seal-home rules list --corp <corpId> --summary
|
||||
```
|
||||
|
||||
Default summary should include only fields such as `id`, `scope`, `strictness`, `status`, and `updatedAt`. Do not pull `description` unless the user needs rule text.
|
||||
|
||||
Tool-layer equivalent:
|
||||
|
||||
```bash
|
||||
seal-home tool seal_approval_rules_list --json '{"fields":["id","scope","strictness","status","updatedAt"]}'
|
||||
```
|
||||
|
||||
## Get One Historical Rule
|
||||
|
||||
Use this when a run used a historical rule version and current rules may differ.
|
||||
|
||||
```bash
|
||||
seal-home rules get --version 16 --code '#0038'
|
||||
seal-home rules get --version latest --code '#0038'
|
||||
```
|
||||
|
||||
If the user starts from a run and a runtime ID such as `rule-205`, resolve against that run:
|
||||
|
||||
```bash
|
||||
seal-home rules get --record-id <recordId> --runtime-id rule-205
|
||||
```
|
||||
|
||||
Return the single rule text plus `scope`, `strictness`, `status`, `versionNumber`, and version metadata. Avoid commands that dump a whole rule version unless the user asks for the full version.
|
||||
|
||||
## Search Approval Knowledge Compactly
|
||||
|
||||
Prefer scoped and trimmed search:
|
||||
|
||||
```bash
|
||||
seal-home tool seal_approval_search --json '{"keywords":["关键词"],"areas":["rules"],"matchMode":"any","maxResults":20,"snippetOnly":true,"maxChars":500,"fields":["id","title","snippet"]}'
|
||||
```
|
||||
|
||||
When investigating historical behavior, search the matching rule version if the API supports it:
|
||||
|
||||
```bash
|
||||
seal-home tool seal_approval_search --json '{"keywords":["关键词"],"areas":["rules"],"ruleVersionScope":"version","versionNumber":16,"snippetOnly":true,"maxChars":500}'
|
||||
```
|
||||
|
||||
Use current search only when the question is about current draft/current knowledge, not why a historical run behaved a certain way.
|
||||
|
||||
## Output Discipline
|
||||
|
||||
If a rule command would return many descriptions or more than about 20 rules, use `rules count`, `rules list --summary`, `fields`, `snippetOnly`, or `--output-file`. Use `--full` only for deliberate exports.
|
||||
Reference in new issue
Block a user