From 500072d8409f21fb8c04e5b777514f5d4f9ffdf7 Mon Sep 17 00:00:00 2001 From: WuYongJie <549727955@qq.com> Date: Thu, 3 Dec 2026 15:27:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B0=8F=E5=A3=B9=E7=9F=A5?= =?UTF-8?q?=E8=AF=86=E5=BA=93=E5=B7=A5=E5=85=B7=E9=80=89=E6=8B=A9=E5=92=8C?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E6=A8=A1=E6=9D=BF=E6=81=A2=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/detail-agent-pi/src/agent.mjs | 5 ++--- .../src/native-knowledge-http.mjs | 1 + apps/detail-agent-pi/test/workflow.test.mjs | 1 + .../test/xiaoyi-release.test.mjs | 18 ++++++++++++++++++ .../photocraft/src/jiansun_knowledge_http.rs | 4 ++-- .../photocraft/src/jiansun_template_cache.rs | 3 ++- 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/apps/detail-agent-pi/src/agent.mjs b/apps/detail-agent-pi/src/agent.mjs index 093d45d9..613f843b 100644 --- a/apps/detail-agent-pi/src/agent.mjs +++ b/apps/detail-agent-pi/src/agent.mjs @@ -1,7 +1,6 @@ import { canvasToolReceipts } from './stdio-canvas.mjs'; import { toolSchema, defineTool } from './tool-schema.mjs'; import { productRequestScope } from './production-recovery.mjs'; -import { enterpriseTools } from './enterprise-knowledge.mjs'; import { executeWorkflow } from './workflow-execute.mjs'; import { PresentationBatch, StreamOutputMeter, StreamPresentation, presentText, stripProductionToolText } from './stream-presentation.mjs'; import path from 'node:path'; @@ -258,7 +257,7 @@ const SYSTEM = `你是由壹点详情页的本地协作助手“小壹”。使 ${PRODUCT_VOICE} 用「workflow_read」读取项目目标、商品、实时进度和图位分页。以 status 和 selectedCandidateId 为准。canvasFirst 项目直接用模板画布,不把旧向导空状态当阻塞。 用「context_read」读取当前绑定的规则。缺少关键资料时询问,用户新确认的信息覆盖旧信息。用「memory_set」保存明确确认的事实,引用用户原话;用「memory_search」读取历史。 -用「tool_search」查找企业资料,按照本项目锁定的 Skill 和补充规则工作。通用建议可以直接讨论,不借用其他品牌的规则或臆测产品事实。 +按照「context_read」返回的本项目锁定 Skill 和补充规则工作。通用建议可以直接讨论,不借用其他品牌的规则或臆测产品事实。 用「copywriting_options」提供卖点选项,用「copywriting_fields」提供逐格预览和采纳。「workflow_propose」只创建待审核建议,「workflow_navigate」只切换视图。用户取消表示未决定。 ${LIVE_CANVAS_WRITES} 申请写入许可后执行实际修改。只确认经回执验证的结果;未知的付费或写入操作按原编号核查。`; @@ -340,7 +339,7 @@ function toolsFor(host) { return receipt ?? {toolCallId:id,found:false,matches:await host.store.search(query,host.manager)}; }), ]; - const projectResources = [...commands, ...enterpriseTools(host, make), ...productionVideoTools(host, make)]; + const projectResources = [...commands, ...productionVideoTools(host, make)]; const productionKit = productionTools.map(([name, description, schema])=>({ ...make(name,description,schema,(args,signal)=>callProductionTool(host,name,args,signal), ['read_output_screen','read_slot_images'].includes(name)?result=>result: diff --git a/apps/detail-agent-pi/src/native-knowledge-http.mjs b/apps/detail-agent-pi/src/native-knowledge-http.mjs index 8579289f..b13627c1 100644 --- a/apps/detail-agent-pi/src/native-knowledge-http.mjs +++ b/apps/detail-agent-pi/src/native-knowledge-http.mjs @@ -9,6 +9,7 @@ const errors = { 'session-unavailable': '素材库小壹知识库签发服务不可用(HTTP 503),请联系管理员核对配置', 'session-login': '素材库授权已失效,请重新登录', 'session-forbidden': '当前账户无权使用小壹知识库', + 'session-invalid': '小壹知识库自动授权无效,请联系管理员', 'session-network': '连不上素材库服务器,请检查网络、VPN 或代理', 'session-timeout': '素材库换签请求超时,请检查网络后重试', unconfigured: '企业知识库宿主未配置', diff --git a/apps/detail-agent-pi/test/workflow.test.mjs b/apps/detail-agent-pi/test/workflow.test.mjs index f0448e72..c30c1718 100644 --- a/apps/detail-agent-pi/test/workflow.test.mjs +++ b/apps/detail-agent-pi/test/workflow.test.mjs @@ -434,6 +434,7 @@ test('normal conversation reads the pinned Xiaoyi rules without the general know template: { id: 'desk', enterprise: true, knowledgeVersion: 'desk@v1' }, }); x.host.enterpriseContext = { load: async () => assert.fail('一般知识库不应被调用') }; + assert.ok(x.host.session.getAllTools().every(tool => !tool.name.startsWith('ekb_'))); await x.host.prompt('请读取当前模板规则。'); const context = x.calls[1].evidence; assert.equal(context.currentWorkflow.template.knowledgeVersion, 'desk@v1'); diff --git a/apps/detail-agent-pi/test/xiaoyi-release.test.mjs b/apps/detail-agent-pi/test/xiaoyi-release.test.mjs index 0831453b..1913e22b 100644 --- a/apps/detail-agent-pi/test/xiaoyi-release.test.mjs +++ b/apps/detail-agent-pi/test/xiaoyi-release.test.mjs @@ -284,6 +284,24 @@ test('first production prepares the component from only manifest bindings and re assert.ok(requests.every(([route])=>route.startsWith('/api/xiaoyi/v1/'))); }); +test('catalog-only intake is retained when rebuilding the selected fixed version', async t => { + const intake = {version:1,productFields:[{id:'material',label:'材质',type:'text',required:true}],barcodeFields:[]}; + const {options} = await fixture(t,{withBindings:true}); + const root = path.join(options.directory,'catalog-root'); + const catalog = {items:[{templateId:'CHAIR',name:'Fixture chair',brand:'Fixture',category:'Chair', + version:'v1',knowledgeVersion:'CHAIR@v1',components:[{id:'detail'}],intake}]}; + const fetch = async (url,init) => url.pathname === '/api/xiaoyi/v1/templates' + ? Response.json(catalog) : options.fetch(url.pathname,init); + const common = {root,brandId:'ekb:brand:Fixture',brandName:'Fixture',categoryId:'ekb:category:Chair',categoryName:'Chair'}; + const choice = await templateRequest({...common,action:'resource-component',resourceSetId:'CHAIR',componentId:'detail'},{fetch}); + const original = choice.items[0].pack; + const projectDir = path.join(root,'catalog',sha(JSON.stringify(['CHAIR','v1']))); + const recovered = await xiaoyiPacks({templateId:'CHAIR',projectDir,cache:path.join(root,'blobs'), + name:'Fixture chair',brandId:common.brandId,categoryId:common.categoryId, + knowledgeVersion:'CHAIR@v1',intake:original.xiaoyi.intake},{fetch}); + assert.deepEqual(recovered.packs.detail, original); +}); + test('production Key browses brands, categories, templates and component mappings without downloading originals', async t => { const intake = {version:1,productFields:[{id:'material',label:'材质',type:'text',required:true}], diff --git a/apps/detail-photocraft/apps/photocraft/src/jiansun_knowledge_http.rs b/apps/detail-photocraft/apps/photocraft/src/jiansun_knowledge_http.rs index 03832933..611967e0 100644 --- a/apps/detail-photocraft/apps/photocraft/src/jiansun_knowledge_http.rs +++ b/apps/detail-photocraft/apps/photocraft/src/jiansun_knowledge_http.rs @@ -140,7 +140,7 @@ fn account_credential(account: &Account) -> R { .ok_or(AUTOMATIC_INVALID)?; let remaining = expiry.timestamp() - chrono::Utc::now().timestamp(); if remaining <= 5 { return Err(AUTOMATIC_INVALID.into()); } - let token = normalize_key(token)?; + let token = normalize_key(token).map_err(|_| AUTOMATIC_INVALID)?; // Refresh frequently so remotely revoked access stops within 30 seconds. let lifetime = u64::try_from((remaining - 5).min(30)).map_err(|_| AUTOMATIC_INVALID)?; *cache = Some((token.clone(), std::time::Instant::now() + Duration::from_secs(lifetime))); @@ -395,7 +395,7 @@ fn emit_error(result: R<()>, emit: &mut impl FnMut(Value) -> R<()>) -> R<()> { GATEWAY => ("gateway", GATEWAY), SESSION_MISSING => ("session-missing", SESSION_MISSING), SESSION_UNAVAILABLE => ("session-unavailable", SESSION_UNAVAILABLE), - AUTOMATIC_INVALID => ("credential", AUTOMATIC_INVALID), + AUTOMATIC_INVALID => ("session-invalid", AUTOMATIC_INVALID), INVALID => ("boundary", INVALID), _ => ("response", RESPONSE), }; diff --git a/apps/detail-photocraft/apps/photocraft/src/jiansun_template_cache.rs b/apps/detail-photocraft/apps/photocraft/src/jiansun_template_cache.rs index dc9e37b0..4db408a2 100644 --- a/apps/detail-photocraft/apps/photocraft/src/jiansun_template_cache.rs +++ b/apps/detail-photocraft/apps/photocraft/src/jiansun_template_cache.rs @@ -187,7 +187,8 @@ impl Backend { let project_dir = root.join("catalog").join(hash(&json!([id, version]).to_string())); let result = self.enterprise_template_request(json!({"action":"xiaoyi-pack","templateId":id, "name":selected["name"],"brandId":brand,"categoryId":category,"projectDir":project_dir, - "cache":root.join("blobs"),"knowledgeVersion":format!("{id}@{version}")}))?; + "cache":root.join("blobs"),"knowledgeVersion":format!("{id}@{version}"), + "intake":selected["intake"]}))?; let mut pack = result["packs"][component].clone(); pack["contentHash"] = json!(template_slots::pack_hash(&pack)?); matching_pack(&pack, brand, category)?;