dsh-form-fill-agent 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -43,7 +43,7 @@ dsh plugin --profile web add dsh-form-fill-agent@latest
43
43
 
44
44
  ## 使用边界与数据保存
45
45
 
46
- 补充要求为模型可读文本;字段或工作表范围请通过向导/工作台修改,不能仅改文字后假定执行范围已同步。任务 schema 5 可读取 schema 1–5;回退旧版本请使用升级前目录副本或独立任务目录。主包为 0.2.6,共享内核和 Provider 保持 0.2.0。
46
+ 补充要求为模型可读文本;字段或工作表范围请通过向导/工作台修改,不能仅改文字后假定执行范围已同步。任务 schema 5 可读取 schema 1–5;回退旧版本请使用升级前目录副本或独立任务目录。主包为 0.2.7,共享内核和 Provider 保持 0.2.0。
47
47
 
48
48
  支持企业完整登记名称或 18 位信用代码;简称、主体不一致或多候选不会自动猜选。仅有信用代码的表格也可作为查询锚点。连接候选检索工具时可检索简称,仍需人工确认;缺少工具时降级人工输入。字段映射采用确定性规则及人工确认,不让模型编造事实。支持普通内部公式、固定区域下拉、基础条件格式和普通表格对象;复杂 Excel 结构和 Word 暂不支持,保真边界见下方安全说明。
49
49
 
@@ -51,10 +51,12 @@ dsh plugin --profile web add dsh-form-fill-agent@latest
51
51
 
52
52
  显式设置 DSH_HOME 时,任务保存至其 form-fill-tasks 目录,默认 24 小时过期;未设置时使用内存。任务保存输入表格和归一化预览,不持久化原始 MCP 响应,可主动删除任务。模型及 MCP 凭据由宿主管理。
53
53
 
54
- 0.2.6 保存任务 schema 5,兼容读取旧 schema 1–4;回退旧版本须使用升级前任务目录副本或新目录,防止丢失已确认的字段/主体设置。
54
+ 0.2.7 保存任务 schema 5,兼容读取旧 schema 1–4;回退旧版本须使用升级前任务目录副本或新目录,防止丢失已确认的字段/主体设置。
55
55
 
56
56
  ## 文档与反馈
57
57
 
58
+ 调用次数:默认无本地次数上限。可通过 DSH_FORM_FILL_MAX_CALLS 设置正整数上限,0 或未设置表示不限;修改后重启 DSH。这不是企查查余额或积分配置,上游服务限制仍有效。
59
+
58
60
  - [源码与完整说明](https://github.com/duhu2000/dsh-form-fill-agent)
59
61
  - [安全与保真边界](https://github.com/duhu2000/dsh-form-fill-agent/blob/main/docs/security.md)
60
62
  - [双基线原生验收](https://github.com/duhu2000/dsh-form-fill-agent/blob/main/docs/U2-NATIVE-ACCEPTANCE.md)
package/lib/ui.html CHANGED
@@ -244,7 +244,7 @@ initWizard();filterResults();syncActions();if($('wizard').open)renderWizard();
244
244
  $('anchor-alert').textContent=missing.length?'有 '+missing.length+' 行缺少可用主体标识。请把实际包含名称的列映射为“企业名称”,或提供非空信用代码;当前不会查询这些行。':'';
245
245
  }
246
246
  async function restore(silent=false){if(busy||!current&& !location.hash)return;const id=new URLSearchParams(location.hash.slice(1)).get('task');if(!id)return;try{const data=await api('/task/'+encodeURIComponent(id));if(!silent||data.revision!==current?.revision){render(data);if(!silent){const target=pendingNavigation||(data.confirmed?'download':'preview');pendingNavigation=undefined;if(target==='history')$('history-tab').click();else navigate(target)}}}catch(e){if(!silent)$('status').textContent=e.message}}
247
- async function preview(buffer,name,demo=false){controls(true);try{const bytes=new Uint8Array(buffer);if(bytes.length>8388608)throw Error('文件超过 8 MiB');let binary='';for(let i=0;i<bytes.length;i+=32768)binary+=String.fromCharCode(...bytes.subarray(i,i+32768));render(await api('/preview',{base64:btoa(binary),filename:name,sessionId,analyzeOnly:!demo}));navigate(demo?'preview':'rules');$('status').textContent='预览已准备好,请检查后确认。'}catch(e){$('status').textContent=e.message;$('wizard-message').textContent=e.message}finally{controls(false)}}
247
+ async function preview(buffer,name,demo=false){controls(true);try{const bytes=new Uint8Array(buffer);if(bytes.length>8388608)throw Error('文件超过 8 MiB');let binary='';for(let i=0;i<bytes.length;i+=32768)binary+=String.fromCharCode(...bytes.subarray(i,i+32768));$('grid').open=true;render(await api('/preview',{base64:btoa(binary),filename:name,sessionId,analyzeOnly:!demo}));navigate(demo?'preview':'rules');$('status').textContent='预览已准备好,请检查后确认。'}catch(e){$('status').textContent=e.message;$('wizard-message').textContent=e.message}finally{controls(false)}}
248
248
  document.querySelectorAll('[data-step]').forEach(b=>b.onclick=()=>navigate(b.dataset.step));
249
249
  $('upload').onclick=async()=>{const f=$('file').files[0];if(!f){$('status').textContent='请先选择 XLSX 文件';return}await preview(await f.arrayBuffer(),f.name)};
250
250
  function readMapping(){const configuration={sheets:[],headers:[],mappings:[]};for(const section of $('mapping').querySelectorAll('fieldset')){if(!section.querySelector('.sheet-enabled').checked)continue;const sheet=section.dataset.sheet;configuration.sheets.push(sheet);configuration.headers.push({sheet,row:Number(section.querySelector('.header-row').value)});for(const field of section.querySelectorAll('[data-column]'))configuration.mappings.push({sheet,column:Number(field.dataset.column),field:field.value||null})}return configuration}
package/lib/workflow.js CHANGED
@@ -3,7 +3,12 @@ import { join, resolve, dirname, basename } from 'node:path';
3
3
  import { analyzeDocument, buildFillPlan, executePlan, applyChangeSet, serialize, FillError } from 'form-fill-core';
4
4
  import { createMockProvider, FIELD_CATALOG } from 'qcc-form-fill-provider';
5
5
 
6
- export async function previewBytes(bytes, { provider = createMockProvider(), maxCalls = 100, confirmPaidCalls = false, configuration = {}, selectedFields, signal, onProgress, previousChangeSet, retryOnly } = {}) {
6
+ export function configuredCallLimit(value = process.env.DSH_FORM_FILL_MAX_CALLS) {
7
+ if (value === undefined || value === '' || value === '0') return Infinity;
8
+ if (!/^[1-9]\d*$/.test(value) || !Number.isSafeInteger(Number(value))) throw new FillError('CALL_LIMIT_CONFIG', 'DSH_FORM_FILL_MAX_CALLS 必须为非负整数,0 表示不限次数');
9
+ return Number(value);
10
+ }
11
+ export async function previewBytes(bytes, { provider = createMockProvider(), maxCalls = configuredCallLimit(), confirmPaidCalls = false, configuration = {}, selectedFields, signal, onProgress, previousChangeSet, retryOnly } = {}) {
7
12
  if (provider.mode !== 'mock' && (provider.mode !== 'qcc' || confirmPaidCalls !== true)) throw new FillError('REAL_PROVIDER_DISABLED', '真实来源需要调用方明确授权');
8
13
  const { analysis } = analyzeDocument(bytes, FIELD_CATALOG, configuration);
9
14
  if (selectedFields !== undefined) {
@@ -12,6 +17,7 @@ export async function previewBytes(bytes, { provider = createMockProvider(), max
12
17
  analysis.opportunities=analysis.opportunities.filter(o=>selectedFields.includes(o.field));
13
18
  }
14
19
  const plan = buildFillPlan(analysis, provider.capabilities, provider.version);
20
+ if (plan.estimatedCalls > maxCalls) throw new FillError('BUDGET_EXCEEDED', '预计 '+plan.estimatedCalls+' 次调用,超过本地插件上限 '+maxCalls+';这不是企查查余额限制。请调整 DSH_FORM_FILL_MAX_CALLS(0 为不限)并重启 DSH;retry 不绕过此计划检查。');
15
21
  const changeSet = await executePlan(plan, provider, { maxCalls, confirmPaidCalls, signal, onProgress:onProgress?p=>onProgress({...p,analysis,plan}):undefined, previousChangeSet, retryOnly });
16
22
  return { analysis, plan, changeSet };
17
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-form-fill-agent",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "private": false,
5
5
  "description": "AI填表智能体:XLSX blank-cell preview, QCC enrichment and persistent tasks for DSH.",
6
6
  "repository": { "type": "git", "url": "git+https://github.com/duhu2000/dsh-form-fill-agent.git", "directory": "packages/dsh-form-fill-agent" },