qlogicagent 2.22.8 → 2.23.0
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/dist/agent.js +51 -42
- package/dist/cli.js +7 -1
- package/dist/host-contract.js +1 -1
- package/dist/index.js +358 -365
- package/dist/orchestration.js +1 -1
- package/dist/skills/builtin/desktop-screenshot/SKILL.md +0 -1
- package/dist/skills/builtin/office-doc-reading/SKILL.md +0 -1
- package/dist/skills/builtin/web-research/SKILL.md +0 -1
- package/dist/types/agent/tool-loop/tool-failure-policy.d.ts +15 -0
- package/dist/types/agent/tool-loop/tool-schema-conformance.d.ts +10 -0
- package/dist/types/agent/tool-loop.d.ts +0 -2
- package/dist/types/agent/types.d.ts +4 -2
- package/dist/types/cli/handlers/turn-handler.d.ts +2 -13
- package/dist/types/contracts/tool-execution-evidence.d.ts +7 -0
- package/dist/types/contracts/tool-name.d.ts +4 -0
- package/dist/types/host-contract/index.d.ts +7 -8
- package/dist/types/orchestration/tool-loop/tool-schema.d.ts +4 -0
- package/dist/types/protocol/wire/chat-types.d.ts +8 -15
- package/dist/types/protocol/wire/notification-payloads.d.ts +6 -8
- package/dist/types/runtime/execution/streaming-tool-executor.d.ts +0 -2
- package/dist/types/runtime/execution/tool-result-storage.d.ts +2 -25
- package/dist/types/runtime/infra/turn-telemetry-store.d.ts +14 -0
- package/dist/types/runtime/ports/agent-execution-contracts.d.ts +4 -0
- package/dist/types/runtime/ports/agent-runtime-ports.d.ts +1 -2
- package/dist/types/runtime/ports/tool-call-contracts.d.ts +4 -0
- package/dist/types/runtime/ports/tool-contracts.d.ts +5 -1
- package/dist/types/runtime/prompt/capability-routing-policy.d.ts +3 -5
- package/dist/types/runtime/prompt/environment-context.d.ts +0 -5
- package/dist/types/skills/mcp/mcp-manager.d.ts +7 -6
- package/dist/types/skills/portable-tool.d.ts +5 -3
- package/dist/types/skills/tools/read-tool.d.ts +1 -1
- package/package.json +4 -3
- package/dist/types/cli/handlers/pinned-skill-context.d.ts +0 -3
- package/dist/types/runtime/execution/mcp-capability-selection.d.ts +0 -63
package/dist/orchestration.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function be(e,t,n,o){return{role:"assistant",content:t||null,tool_calls:e,...n&&n.length>0?{thinkingBlocks:n}:{},...o?{reasoning_content:o}:{}}}function Re(e,t){let n=t.ok?typeof t.payload=="string"?t.payload:JSON.stringify(t.payload??""):`Error: ${t.error??"Tool execution failed"}`;return{role:"tool",tool_call_id:e,content:n,...!t.ok&&{is_error:!0},...t.toolReferences?.length?{toolReferences:t.toolReferences}:{},...t.imageUrls?.length?{imageUrls:t.imageUrls}:{}}}var xe=/\b(?:daily|weekly|monthly)(?:\/(?:daily|weekly|monthly))* (?:usage )?limit(?:s)?(?: (?:exhausted|reached|exceeded))?\b/i,T={rateLimit:[/rate[_ ]limit|too many requests|429/,"model_cooldown","exceeded your current quota","resource has been exhausted","quota exceeded","resource_exhausted","usage limit",/\btpm\b/i,"tokens per minute","tokens per day"],overloaded:[/overloaded_error|"type"\s*:\s*"overloaded_error"/i,"overloaded",/service[_ ]unavailable.*(?:overload|capacity|high[_ ]demand)|(?:overload|capacity|high[_ ]demand).*service[_ ]unavailable/i,"high demand"],timeout:["timeout","timed out","service unavailable","deadline exceeded","context deadline exceeded","connection error","network error","network request failed","fetch failed","socket hang up",/\beconn(?:refused|reset|aborted)\b/i,/\benotfound\b/i,/\beai_again\b/i,/without sending (?:any )?chunks?/i,/\bstop reason:\s*(?:abort|error|network_error)\b/i,/\breason:\s*(?:abort|error|network_error)\b/i,/\bunhandled stop reason:\s*(?:abort|error|network_error)\b/i],billing:[/["']?(?:status|code)["']?\s*[:=]\s*402\b|\bhttp\s*402\b|\berror(?:\s+code)?\s*[:=]?\s*402\b|\b(?:got|returned|received)\s+(?:a\s+)?402\b|^\s*402\s+payment/i,"payment required","insufficient credits",/insufficient[_ ]quota/i,"credit balance","plans & billing","insufficient balance"],authPermanent:[/api[_ ]?key[_ ]?(?:revoked|invalid|deactivated|deleted)/i,"invalid_api_key","key has been disabled","key has been revoked","account has been deactivated",/could not (?:authenticate|validate).*(?:api[_ ]?key|credentials)/i,"permission_error","not allowed for this organization"],auth:[/invalid[_ ]?api[_ ]?key/,"incorrect api key","invalid token","authentication","re-authenticate","oauth token refresh failed","unauthorized","forbidden","access denied","insufficient permissions","insufficient permission",/missing scopes?:/i,"expired","token has expired",/\b401\b/,/\b403\b/,"no credentials found","no api key found"],format:["string should match pattern","tool_use.id","tool_use_id","messages.1.content.1.tool_use.id","invalid request format",/tool call id was.*must be/i]},Ae=/^(?:error[:\s-]+)?billing(?:\s+error)?(?:[:\s-]+|$)|^(?:error[:\s-]+)?(?:credit balance|insufficient credits?|payment required|http\s*402\b)/i,Se=/["']?(?:status|code)["']?\s*[:=]\s*402\b|\bhttp\s*402\b|\berror(?:\s+code)?\s*[:=]?\s*402\b|^\s*402\s+payment/i,ke=512,Ee=/^(?:http\s*)?(\d{3})(?:\s+([\s\S]+))?$/i;var Me=new Set([500,502,503,504,521,522,523,524,529]),Ie=["insufficient credits","insufficient quota","credit balance","insufficient balance","plans & billing","add more credits","top up"],ve=["upgrade your plan","upgrade plan","current plan","subscription"],we=["daily","weekly","monthly"],Oe=["try again","retry","temporary","cooldown"],Le=["usage limit","rate limit","organization usage"],Pe=["organization","workspace"],Ne=["billing period","exceeded","reached","exhausted"],De=/["']?(?:status|code)["']?\s*[:=]\s*402\b|\bhttp\s*402\b|\berror(?:\s+code)?\s*[:=]?\s*402\b|\b(?:got|returned|received)\s+(?:a\s+)?402\b|^\s*402\s+payment required\b/i,Fe=/^(?:error[:\s-]+)?(?:(?:http\s*)?402(?:\s+payment required)?|payment required)(?:[:\s-]+|$)/i;function h(e,t){if(!e)return!1;let n=e.toLowerCase();return t.some(o=>o instanceof RegExp?o.test(n):n.includes(o))}function Be(e){return h(e,T.format)}function Q(e){return h(e,T.rateLimit)}function Ue(e){return h(e,T.timeout)}function Ge(e){return xe.test(e)}function P(e){let t=e.toLowerCase();return t?e.length>ke?Se.test(t):h(t,T.billing)?!0:Ae.test(e)?t.includes("upgrade")||t.includes("credits")||t.includes("payment")||t.includes("plan"):!1:!1}function ee(e){return h(e,T.authPermanent)}function $e(e){return h(e,T.auth)}function te(e){return h(e,T.overloaded)}function y(e,t){return t.some(n=>e.includes(n))}function je(e){return y(e,Ie)||y(e,ve)&&e.includes("limit")||e.includes("billing hard limit")||e.includes("hard limit reached")||e.includes("maximum allowed")&&e.includes("limit")}function ze(e){let t=y(e,we),n=e.includes("spend limit")||e.includes("spending limit"),o=y(e,Pe);return y(e,Oe)&&y(e,Le)||t&&(e.includes("usage limit")||n)||t&&e.includes("limit")&&e.includes("reset")||o&&e.includes("limit")&&(n||y(e,Ne))}function qe(e){return e.trim().toLowerCase().replace(Fe,"").trim()}function ne(e){let t=qe(e);return!t||je(t)?"billing":Q(t)||ze(t)?"rate_limit":"billing"}function He(e){return De.test(e)?ne(e):null}function oe(e){let t=e.match(Ee);if(!t)return null;let n=Number(t[1]);return Number.isFinite(n)?{code:n,rest:(t[2]??"").trim()}:null}function Ye(e){if(!e)return!1;let t=e.toLowerCase();return t.includes('"type":"api_error"')&&t.includes("internal server error")}function Xe(e){let t=e.trim();if(!t)return!1;let n=oe(t);return n?Me.has(n.code):!1}function re(e,t){return typeof e!="number"||!Number.isFinite(e)?null:e===402?t?ne(t):"billing":e===429?"rate_limit":e===401||e===403?t&&ee(t)?"auth_permanent":"auth":e===408?"timeout":e===503?t&&te(t)?"overloaded":"timeout":e===502||e===504?"timeout":e===529?"overloaded":e===400?t&&P(t)?"billing":"format":null}function We(e){if(!e)return!1;let t=e.toLowerCase();return!!(t.includes("unknown model")||t.includes("model not found")||t.includes("model_not_found")||t.includes("not_found_error")||t.includes("does not exist")&&t.includes("model")||t.includes("invalid model")&&!t.includes("invalid model reference")||/models\/[^\s]+ is not found/i.test(e)||/\b404\b/.test(e)&&/not[-_ ]?found/i.test(e))}function Ke(e){if(!e)return!1;let t=e.toLowerCase();return t.includes("session not found")||t.includes("session does not exist")||t.includes("session expired")||t.includes("session invalid")||t.includes("conversation not found")||t.includes("conversation does not exist")||t.includes("conversation expired")||t.includes("conversation invalid")||t.includes("no such session")||t.includes("invalid session")||t.includes("session id not found")||t.includes("conversation id not found")}function se(e){if(Ke(e))return"session_expired";if(We(e))return"model_not_found";let t=He(e);return t||(Ge(e)?P(e)?"billing":"rate_limit":Q(e)?"rate_limit":te(e)?"overloaded":Xe(e)?oe(e.trim())?.code===529?"overloaded":"timeout":Ye(e)?"timeout":Be(e)?"format":P(e)?"billing":Ue(e)?"timeout":ee(e)?"auth_permanent":$e(e)?"auth":null)}var Ve=new Set(["RETRYABLE_TRANSIENT","RETRYABLE_DEGRADED","TOOL_EXECUTION_FAILED"]);function ie(e){return Ve.has(e)}var Je={timeout:"RETRYABLE_TRANSIENT",overloaded:"RETRYABLE_TRANSIENT",rate_limit:"RETRYABLE_DEGRADED",auth:"NON_RETRYABLE_AUTH",auth_permanent:"NON_RETRYABLE_AUTH",billing:"NON_RETRYABLE_QUOTA",format:"NON_RETRYABLE_CONTENT",model_not_found:"NON_RETRYABLE_CONTENT",session_expired:"NON_RETRYABLE_CONTENT",unknown:"RETRYABLE_TRANSIENT"};function Ze(e,t){let n=re(e,t)??(t?se(t):null);return n?Je[n]:typeof e=="number"&&e>=400&&e<500?"NON_RETRYABLE_CONTENT":"RETRYABLE_TRANSIENT"}function q(e){return typeof e.compressAsync=="function"}var E="[Context capsule v1]";function C(e){return e.replace(/\b(api[_-]?key|access[_-]?token|refresh[_-]?token|password|passwd|secret)\b\s*[:=]\s*["']?[^\s"',;]+/giu,"$1=[REDACTED]").replace(/\b(?:sk|rk|pk)-[A-Za-z0-9_-]{12,}\b/gu,"[REDACTED_TOKEN]").replace(/\bBearer\s+[A-Za-z0-9._~+/=-]{8,}\b/giu,"Bearer [REDACTED]")}function Qe(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,"0")}function A(e){if(!(!e||typeof e.content!="string"||!e.content.startsWith(E)))try{let t=JSON.parse(e.content.slice(E.length).trim());return t?.receipt?.version===1&&typeof t.receipt.digest=="string"?t:void 0}catch{return}}function ce(e,t,n,o){let r=e.map(c=>c.itemId).filter(c=>!!c),i={...o?.state.anchors??{}};for(let c of e)for(let u of c.contextAnchors??[]){let p=i[u.category]??[];i[u.category]=[...new Set([...p,C(u.value)])].slice(-50)}let s=[...o?.state.userRequests??[],...e.filter(c=>c.role==="user").map(c=>C(typeof c.content=="string"?c.content:JSON.stringify(c.content??"")))].slice(-50),a={summary:C(t),userRequests:s,anchors:i},l={version:1,sourceMessageCount:(o?.receipt.sourceMessageCount??0)+e.length,sourceItemIds:[...new Set([...o?.receipt.sourceItemIds??[],...r])].slice(-200),firstItemId:o?.receipt.firstItemId??r[0],lastItemId:r.at(-1)??o?.receipt.lastItemId,priorDigest:o?.receipt.digest,tokensBefore:(o?.receipt.tokensBefore??0)+e.reduce((c,u)=>c+n(u),0)};return{receipt:{...l,digest:Qe(JSON.stringify({receipt:l,state:a}))},state:a}}function ue(e){return{role:"system",content:`${E}
|
|
1
|
+
function be(e,t,n,o){return{role:"assistant",content:t||null,tool_calls:e,...n&&n.length>0?{thinkingBlocks:n}:{},...o?{reasoning_content:o}:{}}}function Re(e,t){let n=t.ok?typeof t.payload=="string"?t.payload:JSON.stringify(t.payload??""):`Error: ${t.error??"Tool execution failed"}`;return{role:"tool",tool_call_id:e,content:n,...!t.ok&&{is_error:!0},...t.toolReferences?.length?{toolReferences:t.toolReferences}:{},...t.imageUrls?.length?{imageUrls:t.imageUrls}:{},...t.contentBlocks!==void 0?{contentBlocks:t.contentBlocks}:{},...t.structuredContent!==void 0?{structuredContent:t.structuredContent}:{},...t.mcpMeta!==void 0?{mcpMeta:t.mcpMeta}:{},...t.mcpIsError!==void 0?{mcpIsError:t.mcpIsError}:{}}}var xe=/\b(?:daily|weekly|monthly)(?:\/(?:daily|weekly|monthly))* (?:usage )?limit(?:s)?(?: (?:exhausted|reached|exceeded))?\b/i,T={rateLimit:[/rate[_ ]limit|too many requests|429/,"model_cooldown","exceeded your current quota","resource has been exhausted","quota exceeded","resource_exhausted","usage limit",/\btpm\b/i,"tokens per minute","tokens per day"],overloaded:[/overloaded_error|"type"\s*:\s*"overloaded_error"/i,"overloaded",/service[_ ]unavailable.*(?:overload|capacity|high[_ ]demand)|(?:overload|capacity|high[_ ]demand).*service[_ ]unavailable/i,"high demand"],timeout:["timeout","timed out","service unavailable","deadline exceeded","context deadline exceeded","connection error","network error","network request failed","fetch failed","socket hang up",/\beconn(?:refused|reset|aborted)\b/i,/\benotfound\b/i,/\beai_again\b/i,/without sending (?:any )?chunks?/i,/\bstop reason:\s*(?:abort|error|network_error)\b/i,/\breason:\s*(?:abort|error|network_error)\b/i,/\bunhandled stop reason:\s*(?:abort|error|network_error)\b/i],billing:[/["']?(?:status|code)["']?\s*[:=]\s*402\b|\bhttp\s*402\b|\berror(?:\s+code)?\s*[:=]?\s*402\b|\b(?:got|returned|received)\s+(?:a\s+)?402\b|^\s*402\s+payment/i,"payment required","insufficient credits",/insufficient[_ ]quota/i,"credit balance","plans & billing","insufficient balance"],authPermanent:[/api[_ ]?key[_ ]?(?:revoked|invalid|deactivated|deleted)/i,"invalid_api_key","key has been disabled","key has been revoked","account has been deactivated",/could not (?:authenticate|validate).*(?:api[_ ]?key|credentials)/i,"permission_error","not allowed for this organization"],auth:[/invalid[_ ]?api[_ ]?key/,"incorrect api key","invalid token","authentication","re-authenticate","oauth token refresh failed","unauthorized","forbidden","access denied","insufficient permissions","insufficient permission",/missing scopes?:/i,"expired","token has expired",/\b401\b/,/\b403\b/,"no credentials found","no api key found"],format:["string should match pattern","tool_use.id","tool_use_id","messages.1.content.1.tool_use.id","invalid request format",/tool call id was.*must be/i]},Ae=/^(?:error[:\s-]+)?billing(?:\s+error)?(?:[:\s-]+|$)|^(?:error[:\s-]+)?(?:credit balance|insufficient credits?|payment required|http\s*402\b)/i,Se=/["']?(?:status|code)["']?\s*[:=]\s*402\b|\bhttp\s*402\b|\berror(?:\s+code)?\s*[:=]?\s*402\b|^\s*402\s+payment/i,ke=512,Ee=/^(?:http\s*)?(\d{3})(?:\s+([\s\S]+))?$/i;var Me=new Set([500,502,503,504,521,522,523,524,529]),Ie=["insufficient credits","insufficient quota","credit balance","insufficient balance","plans & billing","add more credits","top up"],ve=["upgrade your plan","upgrade plan","current plan","subscription"],we=["daily","weekly","monthly"],Oe=["try again","retry","temporary","cooldown"],Le=["usage limit","rate limit","organization usage"],Pe=["organization","workspace"],Ne=["billing period","exceeded","reached","exhausted"],De=/["']?(?:status|code)["']?\s*[:=]\s*402\b|\bhttp\s*402\b|\berror(?:\s+code)?\s*[:=]?\s*402\b|\b(?:got|returned|received)\s+(?:a\s+)?402\b|^\s*402\s+payment required\b/i,Fe=/^(?:error[:\s-]+)?(?:(?:http\s*)?402(?:\s+payment required)?|payment required)(?:[:\s-]+|$)/i;function h(e,t){if(!e)return!1;let n=e.toLowerCase();return t.some(o=>o instanceof RegExp?o.test(n):n.includes(o))}function Be(e){return h(e,T.format)}function Q(e){return h(e,T.rateLimit)}function Ue(e){return h(e,T.timeout)}function Ge(e){return xe.test(e)}function P(e){let t=e.toLowerCase();return t?e.length>ke?Se.test(t):h(t,T.billing)?!0:Ae.test(e)?t.includes("upgrade")||t.includes("credits")||t.includes("payment")||t.includes("plan"):!1:!1}function ee(e){return h(e,T.authPermanent)}function $e(e){return h(e,T.auth)}function te(e){return h(e,T.overloaded)}function y(e,t){return t.some(n=>e.includes(n))}function je(e){return y(e,Ie)||y(e,ve)&&e.includes("limit")||e.includes("billing hard limit")||e.includes("hard limit reached")||e.includes("maximum allowed")&&e.includes("limit")}function ze(e){let t=y(e,we),n=e.includes("spend limit")||e.includes("spending limit"),o=y(e,Pe);return y(e,Oe)&&y(e,Le)||t&&(e.includes("usage limit")||n)||t&&e.includes("limit")&&e.includes("reset")||o&&e.includes("limit")&&(n||y(e,Ne))}function qe(e){return e.trim().toLowerCase().replace(Fe,"").trim()}function ne(e){let t=qe(e);return!t||je(t)?"billing":Q(t)||ze(t)?"rate_limit":"billing"}function He(e){return De.test(e)?ne(e):null}function oe(e){let t=e.match(Ee);if(!t)return null;let n=Number(t[1]);return Number.isFinite(n)?{code:n,rest:(t[2]??"").trim()}:null}function Ye(e){if(!e)return!1;let t=e.toLowerCase();return t.includes('"type":"api_error"')&&t.includes("internal server error")}function Xe(e){let t=e.trim();if(!t)return!1;let n=oe(t);return n?Me.has(n.code):!1}function re(e,t){return typeof e!="number"||!Number.isFinite(e)?null:e===402?t?ne(t):"billing":e===429?"rate_limit":e===401||e===403?t&&ee(t)?"auth_permanent":"auth":e===408?"timeout":e===503?t&&te(t)?"overloaded":"timeout":e===502||e===504?"timeout":e===529?"overloaded":e===400?t&&P(t)?"billing":"format":null}function We(e){if(!e)return!1;let t=e.toLowerCase();return!!(t.includes("unknown model")||t.includes("model not found")||t.includes("model_not_found")||t.includes("not_found_error")||t.includes("does not exist")&&t.includes("model")||t.includes("invalid model")&&!t.includes("invalid model reference")||/models\/[^\s]+ is not found/i.test(e)||/\b404\b/.test(e)&&/not[-_ ]?found/i.test(e))}function Ke(e){if(!e)return!1;let t=e.toLowerCase();return t.includes("session not found")||t.includes("session does not exist")||t.includes("session expired")||t.includes("session invalid")||t.includes("conversation not found")||t.includes("conversation does not exist")||t.includes("conversation expired")||t.includes("conversation invalid")||t.includes("no such session")||t.includes("invalid session")||t.includes("session id not found")||t.includes("conversation id not found")}function se(e){if(Ke(e))return"session_expired";if(We(e))return"model_not_found";let t=He(e);return t||(Ge(e)?P(e)?"billing":"rate_limit":Q(e)?"rate_limit":te(e)?"overloaded":Xe(e)?oe(e.trim())?.code===529?"overloaded":"timeout":Ye(e)?"timeout":Be(e)?"format":P(e)?"billing":Ue(e)?"timeout":ee(e)?"auth_permanent":$e(e)?"auth":null)}var Ve=new Set(["RETRYABLE_TRANSIENT","RETRYABLE_DEGRADED","TOOL_EXECUTION_FAILED"]);function ie(e){return Ve.has(e)}var Je={timeout:"RETRYABLE_TRANSIENT",overloaded:"RETRYABLE_TRANSIENT",rate_limit:"RETRYABLE_DEGRADED",auth:"NON_RETRYABLE_AUTH",auth_permanent:"NON_RETRYABLE_AUTH",billing:"NON_RETRYABLE_QUOTA",format:"NON_RETRYABLE_CONTENT",model_not_found:"NON_RETRYABLE_CONTENT",session_expired:"NON_RETRYABLE_CONTENT",unknown:"RETRYABLE_TRANSIENT"};function Ze(e,t){let n=re(e,t)??(t?se(t):null);return n?Je[n]:typeof e=="number"&&e>=400&&e<500?"NON_RETRYABLE_CONTENT":"RETRYABLE_TRANSIENT"}function q(e){return typeof e.compressAsync=="function"}var E="[Context capsule v1]";function C(e){return e.replace(/\b(api[_-]?key|access[_-]?token|refresh[_-]?token|password|passwd|secret)\b\s*[:=]\s*["']?[^\s"',;]+/giu,"$1=[REDACTED]").replace(/\b(?:sk|rk|pk)-[A-Za-z0-9_-]{12,}\b/gu,"[REDACTED_TOKEN]").replace(/\bBearer\s+[A-Za-z0-9._~+/=-]{8,}\b/giu,"Bearer [REDACTED]")}function Qe(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,"0")}function A(e){if(!(!e||typeof e.content!="string"||!e.content.startsWith(E)))try{let t=JSON.parse(e.content.slice(E.length).trim());return t?.receipt?.version===1&&typeof t.receipt.digest=="string"?t:void 0}catch{return}}function ce(e,t,n,o){let r=e.map(c=>c.itemId).filter(c=>!!c),i={...o?.state.anchors??{}};for(let c of e)for(let u of c.contextAnchors??[]){let p=i[u.category]??[];i[u.category]=[...new Set([...p,C(u.value)])].slice(-50)}let s=[...o?.state.userRequests??[],...e.filter(c=>c.role==="user").map(c=>C(typeof c.content=="string"?c.content:JSON.stringify(c.content??"")))].slice(-50),a={summary:C(t),userRequests:s,anchors:i},l={version:1,sourceMessageCount:(o?.receipt.sourceMessageCount??0)+e.length,sourceItemIds:[...new Set([...o?.receipt.sourceItemIds??[],...r])].slice(-200),firstItemId:o?.receipt.firstItemId??r[0],lastItemId:r.at(-1)??o?.receipt.lastItemId,priorDigest:o?.receipt.digest,tokensBefore:(o?.receipt.tokensBefore??0)+e.reduce((c,u)=>c+n(u),0)};return{receipt:{...l,digest:Qe(JSON.stringify({receipt:l,state:a}))},state:a}}function ue(e){return{role:"system",content:`${E}
|
|
2
2
|
${JSON.stringify(e)}`}}var ae=4;function le(e){return{role:"system",content:`[${e} earlier messages removed to fit the context budget]`}}var N=class{constructor(t){this.estimateTokens=t}estimateTokens;compress(t,n){let o=[],r=[];for(let p of t)p.role==="system"?o.push(p):r.push(p);let i=n;for(let p of o)i-=this.estimateTokens(p);let s;for(let p of r)if(p.role==="user"){s=p;break}if(s&&(i-=this.estimateTokens(s)),i<=0){let p=r.length-(s?1:0),d=s?[...o,s]:[...o];return p>0&&d.push(le(p)),{messages:d,droppedCount:p,strategy:"sliding-window"}}let a=[],l=0;for(let p=r.length-1;p>=0;p--){let d=r[p];if(d===s)continue;let m=this.estimateTokens(d);if(i-m<0&&l>=ae)break;if(i-m<0&&l<ae){a.unshift(d),l++;continue}i-=m,a.unshift(d),l++}let c=r.length-(a.length+(s&&!a.includes(s)?1:0)),u=[...o];return s&&!a.includes(s)&&u.push(s),c>0&&u.push(le(c)),u.push(...a),{messages:u,droppedCount:c,strategy:"sliding-window"}}},D=class{constructor(t,n){this.recentCount=t;this.summarize=n}recentCount;summarize;compress(t,n){let o=t.filter(l=>l.role==="system"),r=t.filter(l=>l.role!=="system");if(r.length<=this.recentCount)return{messages:t,droppedCount:0,strategy:"summarize-old"};let i=r.slice(0,r.length-this.recentCount),s=r.slice(r.length-this.recentCount),a=this.summarize(i);return{messages:[...o,{role:"system",content:`[Conversation summary]
|
|
3
3
|
${a}`},...s],droppedCount:i.length,strategy:"summarize-old"}}},F=class{constructor(t=8e3){this.maxToolResultChars=t}maxToolResultChars;compress(t,n){let o=0;return{messages:t.map(i=>i.role!=="tool"||typeof i.content!="string"||i.content.length<=this.maxToolResultChars?i:(o++,{...i,content:et(i.content,this.maxToolResultChars)})),droppedCount:o,strategy:"tool-result-trim"}}};function et(e,t){if(e.length<=t)return e;let n=e.slice(0,t);if(e.trimStart().startsWith("{")||e.trimStart().startsWith("[")){let i=Math.max(n.lastIndexOf("},"),n.lastIndexOf("],"),n.lastIndexOf(`}
|
|
4
4
|
`),n.lastIndexOf(`]
|
|
@@ -5,6 +5,21 @@ export interface VariantBlockedToolCall {
|
|
|
5
5
|
failCount: number;
|
|
6
6
|
error: string;
|
|
7
7
|
}
|
|
8
|
+
export interface TypedCommercialRetryContract {
|
|
9
|
+
billed: boolean | null;
|
|
10
|
+
retryable: boolean;
|
|
11
|
+
safeToRetry: boolean;
|
|
12
|
+
retryMode: string;
|
|
13
|
+
automaticRetryAuthorized: boolean;
|
|
14
|
+
stage?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Locate the execution owner's explicit commercial retry contract without coupling the Agent
|
|
18
|
+
* loop to a provider, MCP server, Skill, tool name, or error-envelope nesting convention.
|
|
19
|
+
* A commercial operation is never eligible for an automatic verbatim retry unless every field
|
|
20
|
+
* is present and the owner explicitly authorized it.
|
|
21
|
+
*/
|
|
22
|
+
export declare function findTypedCommercialRetryContract(value: unknown): TypedCommercialRetryContract | undefined;
|
|
8
23
|
export declare function splitVariantToolCalls(calls: readonly OpenAiToolCall[], toolFailureCounts: ReadonlyMap<string, number>,
|
|
9
24
|
/**
|
|
10
25
|
* Exact call signatures (name::rawArguments) that were variant-blocked at least once and are
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface ToolSchemaConformance {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
error?: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Validate a model-produced tool argument object against the exact JSON Schema
|
|
7
|
+
* offered for that round. This is deliberately capability-agnostic: Host tools,
|
|
8
|
+
* Skills, and third-party MCP tools all pass through the same boundary.
|
|
9
|
+
*/
|
|
10
|
+
export declare function validateToolArgumentsSchema(toolName: string, schema: Record<string, unknown> | undefined, rawArguments: string): ToolSchemaConformance;
|
|
@@ -47,8 +47,6 @@ export interface ToolLoopParams {
|
|
|
47
47
|
* observed violation).
|
|
48
48
|
*/
|
|
49
49
|
freshEvidenceRequired?: boolean;
|
|
50
|
-
/** Exact Host Skill selections; execution stays gated until every required read completes. */
|
|
51
|
-
requiredSkillNames?: string[];
|
|
52
50
|
/** Versioned pre-model capability route for auditable product attribution. */
|
|
53
51
|
capabilityRoutingEvidence?: CapabilityRoutingEvidence;
|
|
54
52
|
/**
|
|
@@ -154,8 +154,6 @@ export interface TurnConfig {
|
|
|
154
154
|
toolChoice?: "auto" | "none" | "required";
|
|
155
155
|
/** Turn demands fresh tool evidence — arms the loop's reactive one-shot forced retry. */
|
|
156
156
|
freshEvidenceRequired?: boolean;
|
|
157
|
-
/** Exact Host Skill names explicitly selected for this turn. */
|
|
158
|
-
requiredSkillNames?: string[];
|
|
159
157
|
/** Versioned pre-model capability route used by product trace and baseline attribution. */
|
|
160
158
|
capabilityRoutingEvidence?: CapabilityRoutingEvidence;
|
|
161
159
|
/** Parent fork depth (0 = top-level, default 0). CC: depth tracking for fork recursion limit. */
|
|
@@ -208,6 +206,10 @@ export interface ToolInvoker {
|
|
|
208
206
|
error?: string;
|
|
209
207
|
toolReferences?: string[];
|
|
210
208
|
imageUrls?: string[];
|
|
209
|
+
contentBlocks?: Array<Record<string, unknown>>;
|
|
210
|
+
structuredContent?: Record<string, unknown>;
|
|
211
|
+
mcpMeta?: Record<string, unknown>;
|
|
212
|
+
mcpIsError?: boolean;
|
|
211
213
|
details?: Record<string, unknown>;
|
|
212
214
|
}>;
|
|
213
215
|
}
|
|
@@ -107,23 +107,12 @@ export declare function hydrateAttachmentReferenceUrlsForTurn(messages: ChatMess
|
|
|
107
107
|
*/
|
|
108
108
|
export declare function augmentLastUserMessageContent(messages: ChatMessage[], modelContext: string): ChatMessage[];
|
|
109
109
|
export declare function getLatestUserTextForTurn(messages: readonly ChatMessage[]): string;
|
|
110
|
-
/**
|
|
111
|
-
* Insert a SYSTEM-role context message immediately BEFORE the last user message (LLM view only).
|
|
112
|
-
*
|
|
113
|
-
* Used for user-selected Host Skill instructions: the model must load the Skill for THIS turn, but
|
|
114
|
-
* the selection directive must NOT be parsed as part of the user's literal request. The completion-
|
|
115
|
-
* verification heuristics (final-marker extraction, explicit required-file checks, explicit-artifact
|
|
116
|
-
* counting, round/tool budget sizing) all scan `role === "user"` content only. A system message
|
|
117
|
-
* keeps the model bound to the Host loading directive while being
|
|
118
|
-
* invisible to those user-intent scans. The original array/objects are never mutated.
|
|
119
|
-
*/
|
|
120
|
-
export declare function injectSkillContextBeforeLastUser(messages: ChatMessage[], skillContext: string): ChatMessage[];
|
|
121
110
|
/**
|
|
122
111
|
* Insert the per-turn DOMAIN guidance block as a SYSTEM-role message immediately BEFORE the
|
|
123
112
|
* last user message (LLM view only) — the prompt-cache alignment path.
|
|
124
113
|
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
114
|
+
* The domain block carries markdown headers ("# Doing Tasks"), the word "artifact", and example
|
|
115
|
+
* file paths — baking it into the user message
|
|
127
116
|
* would poison the user-intent scans (final-marker extraction, artifact counting, round/tool
|
|
128
117
|
* budgets) that read `role === "user"` content. A system message keeps the model bound to the
|
|
129
118
|
* guidance while staying invisible to those scans. Kept out of the system PROMPT so a domain
|
|
@@ -7,4 +7,11 @@ export declare function classifyToolFailureKind(result: {
|
|
|
7
7
|
error?: string;
|
|
8
8
|
details?: Record<string, unknown>;
|
|
9
9
|
}): ToolCallExecutionEvidence["failureKind"];
|
|
10
|
+
export declare function summarizeToolExecutionOutcomes(toolCalls: readonly Pick<ToolCallExecutionEvidence, "name" | "status">[], blockedToolCalls: readonly {
|
|
11
|
+
name: string;
|
|
12
|
+
reason: string;
|
|
13
|
+
}[]): {
|
|
14
|
+
failedTools: string[];
|
|
15
|
+
blockedTools: string[];
|
|
16
|
+
};
|
|
10
17
|
export declare function buildFinalAnswerEvidence(freshEvidenceRequired: boolean, toolCalls: readonly ToolCallExecutionEvidence[], requiredSuccessfulLogicalToolNames?: readonly string[]): FinalAnswerEvidence;
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* 其字段以 freeze 正文/recon 注释为据;实现 lane 负责与现状 store 形状做映射。
|
|
13
13
|
*/
|
|
14
14
|
import { type ModelPurpose } from "@xiaozhiclaw/module-sdk/model-access";
|
|
15
|
+
import type { CapabilityRequirementV1 } from "@xiaozhiclaw/module-sdk";
|
|
15
16
|
import type { AcpContentBlock } from "./acp-content.js";
|
|
16
17
|
import type { NativeTranscript } from "../host-session-collection-contract.js";
|
|
17
18
|
export { MODEL_PURPOSES, type ModelPurpose } from "@xiaozhiclaw/module-sdk/model-access";
|
|
@@ -317,17 +318,13 @@ export interface InstallRequest {
|
|
|
317
318
|
export interface CapabilityService {
|
|
318
319
|
/** 供 Supervisor 在 spawn 每个 agent 时统一注入的能力接入点(对小智自己也走同一 endpoint)。 */
|
|
319
320
|
getEndpoint(forAgent: AgentId, session: SessionContext): CapabilityEndpoint;
|
|
320
|
-
/** 已装技能注册表(host 持有;装一次共享)。 */
|
|
321
|
-
listSkills(session: SessionContext): SkillRef[];
|
|
322
|
-
viewSkill(name: string): {
|
|
323
|
-
name: string;
|
|
324
|
-
content: string;
|
|
325
|
-
};
|
|
326
321
|
/** MCP 连接器:发现 + 调用(mcp_connectors_list / mcp_tool_call 的后端)。 */
|
|
327
322
|
listConnectors(session: SessionContext): ConnectorRef[];
|
|
328
323
|
callConnector(toolName: string, args: unknown): Promise<{
|
|
329
324
|
content: unknown;
|
|
330
|
-
|
|
325
|
+
structuredContent?: unknown;
|
|
326
|
+
_meta?: unknown;
|
|
327
|
+
isError?: boolean;
|
|
331
328
|
imageUrls?: string[];
|
|
332
329
|
}>;
|
|
333
330
|
/** host 管理的安装(装一次,全员共享)。 */
|
|
@@ -1144,7 +1141,6 @@ export interface HostSkillSnapshotEntry {
|
|
|
1144
1141
|
version?: string;
|
|
1145
1142
|
category?: string;
|
|
1146
1143
|
author?: string;
|
|
1147
|
-
requiredTools?: string[];
|
|
1148
1144
|
environments?: string[];
|
|
1149
1145
|
source?: HostSkillLifecycleRecord["source"];
|
|
1150
1146
|
registryVersion?: string;
|
|
@@ -1722,6 +1718,9 @@ export interface HostPrepareSkillInstallParams {
|
|
|
1722
1718
|
resourceRiskTier: HostSkillInstallRiskTier;
|
|
1723
1719
|
effectiveRiskTier: HostSkillInstallRiskTier;
|
|
1724
1720
|
};
|
|
1721
|
+
manifestSchemaVersion: 18;
|
|
1722
|
+
manifestDigest: `sha256:${string}`;
|
|
1723
|
+
requiredCapabilities: CapabilityRequirementV1[];
|
|
1725
1724
|
}
|
|
1726
1725
|
export interface HostPrepareSkillInstallResult {
|
|
1727
1726
|
installationId: string;
|
|
@@ -43,4 +43,8 @@ export declare function buildToolResultMessage(callId: string, result: {
|
|
|
43
43
|
error?: string;
|
|
44
44
|
toolReferences?: string[];
|
|
45
45
|
imageUrls?: string[];
|
|
46
|
+
contentBlocks?: Array<Record<string, unknown>>;
|
|
47
|
+
structuredContent?: Record<string, unknown>;
|
|
48
|
+
mcpMeta?: Record<string, unknown>;
|
|
49
|
+
mcpIsError?: boolean;
|
|
46
50
|
}): Record<string, unknown>;
|
|
@@ -20,8 +20,6 @@ export interface SemanticToolCapability {
|
|
|
20
20
|
effects?: string[];
|
|
21
21
|
modalities?: string[];
|
|
22
22
|
constraints?: string[];
|
|
23
|
-
/** Exact Host Skill ids that the execution state machine must load first. */
|
|
24
|
-
requiredSkills?: string[];
|
|
25
23
|
}
|
|
26
24
|
export type ChatMessageRole = "system" | "user" | "assistant" | "tool";
|
|
27
25
|
export type ContextAnchorCategory = "objective" | "acceptance" | "decision" | "constraint" | "task" | "blocker" | "artifact";
|
|
@@ -83,6 +81,14 @@ export interface ChatMessage {
|
|
|
83
81
|
thinkingBlocks?: ThinkingBlock[];
|
|
84
82
|
/** Image URLs for vision-capable models. */
|
|
85
83
|
imageUrls?: string[];
|
|
84
|
+
/** Exact MCP content blocks retained alongside the model-compatible text/media projection. */
|
|
85
|
+
contentBlocks?: Array<Record<string, unknown>>;
|
|
86
|
+
/** Exact standard MCP structuredContent field. */
|
|
87
|
+
structuredContent?: Record<string, unknown>;
|
|
88
|
+
/** Exact standard MCP result `_meta` field. */
|
|
89
|
+
mcpMeta?: Record<string, unknown>;
|
|
90
|
+
/** Exact standard MCP result isError field, including explicit false. */
|
|
91
|
+
mcpIsError?: boolean;
|
|
86
92
|
/** Image detail level: 'auto' | 'low' | 'high' | 'xhigh'. */
|
|
87
93
|
imageDetail?: "auto" | "low" | "high" | "xhigh";
|
|
88
94
|
/** Max image pixels budget (Volcengine image_pixel_limit). */
|
|
@@ -133,17 +139,6 @@ export interface ToolIdentity {
|
|
|
133
139
|
serverId?: string;
|
|
134
140
|
capabilityId: string;
|
|
135
141
|
}
|
|
136
|
-
export interface SkillDirectoryEntry {
|
|
137
|
-
id: string;
|
|
138
|
-
description: string;
|
|
139
|
-
version?: string;
|
|
140
|
-
requiredTools?: string[];
|
|
141
|
-
memberCount?: number;
|
|
142
|
-
}
|
|
143
|
-
export interface SkillDirectory {
|
|
144
|
-
schemaVersion: 1;
|
|
145
|
-
entries: SkillDirectoryEntry[];
|
|
146
|
-
}
|
|
147
142
|
/**
|
|
148
143
|
* Tool definition — wire format as sent over JSON-RPC.
|
|
149
144
|
*
|
|
@@ -164,8 +159,6 @@ export interface ToolDefinition {
|
|
|
164
159
|
displayName?: LocalizedToolText;
|
|
165
160
|
displayDescription?: LocalizedToolText;
|
|
166
161
|
semanticCapability?: SemanticToolCapability;
|
|
167
|
-
/** Host-authored, bounded Skill routing index. Full instructions remain behind skill_read. */
|
|
168
|
-
skillDirectory?: SkillDirectory;
|
|
169
162
|
serialOnly?: boolean;
|
|
170
163
|
parallelSafe?: boolean;
|
|
171
164
|
/** Unified permission risk class. */
|
|
@@ -338,15 +338,13 @@ export interface TurnToolUseSummaryNotification {
|
|
|
338
338
|
reason: string;
|
|
339
339
|
}>;
|
|
340
340
|
}
|
|
341
|
-
/**
|
|
341
|
+
/** Typed turn ownership and authorized tool-surface telemetry. */
|
|
342
342
|
export interface CapabilityRoutingEvidence {
|
|
343
|
-
schemaVersion:
|
|
344
|
-
owner: "structured-planner" | "direct-response" | "
|
|
345
|
-
source: "structured-planner" | "direct-response" | "
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
score?: number;
|
|
349
|
-
runnerUpScore?: number;
|
|
343
|
+
schemaVersion: 2;
|
|
344
|
+
owner: "structured-planner" | "direct-response" | "typed-builtin";
|
|
345
|
+
source: "structured-planner" | "direct-response" | "typed-builtin";
|
|
346
|
+
routingStatus: "selected";
|
|
347
|
+
routingReason: string;
|
|
350
348
|
availableToolCount: number;
|
|
351
349
|
exposedToolCount: number;
|
|
352
350
|
}
|
|
@@ -43,8 +43,6 @@ export interface StreamingToolExecutorConfig {
|
|
|
43
43
|
maxExecutionMs?: number;
|
|
44
44
|
/** Optional per-tool deadlines; entries override maxExecutionMs for that tool only. */
|
|
45
45
|
executionTimeoutMsByTool?: ReadonlyMap<string, number>;
|
|
46
|
-
/** Host-declared Skill cores that must be loaded before a tool can execute. */
|
|
47
|
-
requiredSkillsByTool?: ReadonlyMap<string, readonly string[]>;
|
|
48
46
|
}
|
|
49
47
|
/**
|
|
50
48
|
* Executes tools with concurrency control and streaming progress.
|
|
@@ -38,11 +38,9 @@ export type ContentReplacementState = {
|
|
|
38
38
|
replacements: Map<string, string>;
|
|
39
39
|
contextPolicies: Map<string, ToolResultContextPolicy>;
|
|
40
40
|
contextSizes: Map<string, number>;
|
|
41
|
-
loadedSkillNames: Set<string>;
|
|
42
|
-
skillReadiness: Map<string, SkillReadinessActivation>;
|
|
43
41
|
};
|
|
44
42
|
export type ToolResultContextPolicy = {
|
|
45
|
-
kind: "
|
|
43
|
+
kind: "data";
|
|
46
44
|
retention: "required" | "compactable";
|
|
47
45
|
budgetClass: "instructions" | "evidence" | "bulk";
|
|
48
46
|
};
|
|
@@ -50,25 +48,6 @@ export type ToolResultContextBudget = {
|
|
|
50
48
|
maxItemChars: number;
|
|
51
49
|
maxAggregateChars: number;
|
|
52
50
|
};
|
|
53
|
-
type SkillReadinessResource = {
|
|
54
|
-
path: string;
|
|
55
|
-
label: string;
|
|
56
|
-
requiresNext?: boolean;
|
|
57
|
-
};
|
|
58
|
-
type SkillReadinessSet = {
|
|
59
|
-
id: string;
|
|
60
|
-
minReads: number;
|
|
61
|
-
resources: SkillReadinessResource[];
|
|
62
|
-
};
|
|
63
|
-
type PendingSkillReadinessSet = SkillReadinessSet & {
|
|
64
|
-
readPaths: Set<string>;
|
|
65
|
-
readCallIds: Set<string>;
|
|
66
|
-
nextSets: SkillReadinessSet[];
|
|
67
|
-
};
|
|
68
|
-
type SkillReadinessActivation = {
|
|
69
|
-
skillName: string;
|
|
70
|
-
pendingSets: PendingSkillReadinessSet[];
|
|
71
|
-
};
|
|
72
51
|
export type PersistedToolResult = {
|
|
73
52
|
filepath: string;
|
|
74
53
|
originalSize: number;
|
|
@@ -88,9 +67,7 @@ export declare function createContentReplacementState(): ContentReplacementState
|
|
|
88
67
|
export declare function toolResultContextPolicy(details: Record<string, unknown> | undefined): ToolResultContextPolicy;
|
|
89
68
|
export declare function toolResultContextBudget(policy: ToolResultContextPolicy): ToolResultContextBudget;
|
|
90
69
|
export declare function requiredContextBudgetViolation(state: ContentReplacementState | undefined, details: Record<string, unknown> | undefined, contentSize: number): string | undefined;
|
|
91
|
-
export declare function registerToolResultContext(state: ContentReplacementState | undefined, toolCallId: string, details: Record<string, unknown> | undefined, contentSize?: number): void;
|
|
92
|
-
export declare function requiredSkillCoreBlockReason(state: ContentReplacementState | undefined, toolName: string, requiredSkillsByTool: ReadonlyMap<string, readonly string[]> | undefined): string | undefined;
|
|
93
|
-
export declare function skillReadinessBlockReason(state: ContentReplacementState | undefined, toolName: string): string | undefined;
|
|
70
|
+
export declare function registerToolResultContext(state: ContentReplacementState | undefined, toolCallId: string, details: Record<string, unknown> | undefined, contentSize?: number, _invocationArgs?: Record<string, unknown>): void;
|
|
94
71
|
/**
|
|
95
72
|
* Re-apply required Host instruction context after generic compression stages.
|
|
96
73
|
* Existing tool messages are restored in place; if a whole tool exchange was removed,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { HostDelegationTelemetrySummary } from "../../host-contract/index.js";
|
|
2
|
+
import type { CapabilityRoutingEvidence, FinalAnswerEvidence, ToolCallExecutionEvidence } from "../../protocol/wire/notification-payloads.js";
|
|
2
3
|
export type AgentMode = "chat" | "solo" | "product" | "workflow" | "unknown";
|
|
3
4
|
export interface TurnTelemetryUsage {
|
|
4
5
|
inputTokens?: number;
|
|
@@ -15,6 +16,18 @@ export interface TurnTelemetryFileContext {
|
|
|
15
16
|
changedPathsPreview?: string[];
|
|
16
17
|
hasTurnFileChanges?: boolean;
|
|
17
18
|
}
|
|
19
|
+
export interface TurnTelemetryExecutionEvidence {
|
|
20
|
+
ledgerSchemaVersion: 4;
|
|
21
|
+
routingEvidence?: CapabilityRoutingEvidence;
|
|
22
|
+
toolCalls: ToolCallExecutionEvidence[];
|
|
23
|
+
finalAnswerEvidence: FinalAnswerEvidence;
|
|
24
|
+
availableToolNames: string[];
|
|
25
|
+
enabledToolNames: string[];
|
|
26
|
+
blockedToolCalls: Array<{
|
|
27
|
+
name: string;
|
|
28
|
+
reason: string;
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
18
31
|
export interface TurnTelemetrySnapshot {
|
|
19
32
|
turnId: string;
|
|
20
33
|
sessionId: string;
|
|
@@ -27,6 +40,7 @@ export interface TurnTelemetrySnapshot {
|
|
|
27
40
|
sourceChannel?: string;
|
|
28
41
|
usage?: TurnTelemetryUsage;
|
|
29
42
|
toolSummary?: TurnTelemetryToolSummary;
|
|
43
|
+
executionEvidence?: TurnTelemetryExecutionEvidence;
|
|
30
44
|
fileContext?: TurnTelemetryFileContext;
|
|
31
45
|
delegationSummary?: HostDelegationTelemetrySummary;
|
|
32
46
|
createdAt: string;
|
|
@@ -13,6 +13,10 @@ export interface ToolInvoker {
|
|
|
13
13
|
error?: string;
|
|
14
14
|
toolReferences?: string[];
|
|
15
15
|
imageUrls?: string[];
|
|
16
|
+
contentBlocks?: Array<Record<string, unknown>>;
|
|
17
|
+
structuredContent?: Record<string, unknown>;
|
|
18
|
+
mcpMeta?: Record<string, unknown>;
|
|
19
|
+
mcpIsError?: boolean;
|
|
16
20
|
details?: Record<string, unknown>;
|
|
17
21
|
}>;
|
|
18
22
|
}
|
|
@@ -36,10 +36,9 @@ export interface StreamingToolExecutorPortConfig {
|
|
|
36
36
|
maxConcurrentTools?: number;
|
|
37
37
|
maxExecutionMs?: number;
|
|
38
38
|
executionTimeoutMsByTool?: ReadonlyMap<string, number>;
|
|
39
|
-
requiredSkillsByTool?: ReadonlyMap<string, readonly string[]>;
|
|
40
39
|
/** Turn workspace/cwd — routes oversized tool-result spillover to the session's reachable data dir. */
|
|
41
40
|
projectRoot?: string;
|
|
42
|
-
/** Opaque per-turn
|
|
41
|
+
/** Opaque per-turn tool-result context budget state. */
|
|
43
42
|
contextState?: unknown;
|
|
44
43
|
}
|
|
45
44
|
export interface ContextCompressionEnginePort {
|
|
@@ -12,5 +12,9 @@ export interface ToolResultMessageInput {
|
|
|
12
12
|
error?: string;
|
|
13
13
|
toolReferences?: string[];
|
|
14
14
|
imageUrls?: string[];
|
|
15
|
+
contentBlocks?: Array<Record<string, unknown>>;
|
|
16
|
+
structuredContent?: Record<string, unknown>;
|
|
17
|
+
mcpMeta?: Record<string, unknown>;
|
|
18
|
+
mcpIsError?: boolean;
|
|
15
19
|
}
|
|
16
20
|
export declare function buildToolResultMessage(callId: string, result: ToolResultMessageInput): Record<string, unknown>;
|
|
@@ -28,11 +28,15 @@ export interface RuntimeToolContract {
|
|
|
28
28
|
isEnabled?: () => boolean;
|
|
29
29
|
execute?(toolCallId: string, params: any, signal?: AbortSignal): Promise<{
|
|
30
30
|
content: Array<{
|
|
31
|
-
type:
|
|
31
|
+
type: string;
|
|
32
32
|
text?: string;
|
|
33
33
|
data?: string;
|
|
34
34
|
mimeType?: string;
|
|
35
|
+
[key: string]: unknown;
|
|
35
36
|
}>;
|
|
37
|
+
isError?: boolean;
|
|
38
|
+
structuredContent?: Record<string, unknown>;
|
|
39
|
+
_meta?: Record<string, unknown>;
|
|
36
40
|
details?: Record<string, unknown>;
|
|
37
41
|
imageUrls?: string[];
|
|
38
42
|
}>;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
export type CapabilityRoutingOwner = "structured-planner" | "direct-response" | "
|
|
1
|
+
export type CapabilityRoutingOwner = "structured-planner" | "direct-response" | "typed-builtin";
|
|
2
2
|
/**
|
|
3
|
-
* Resolves
|
|
4
|
-
*
|
|
3
|
+
* Resolves the typed turn owner. Skill and MCP selection stays with the primary
|
|
4
|
+
* model over the complete Host-authorized tool surface.
|
|
5
5
|
*/
|
|
6
6
|
export declare function resolveCapabilityRoutingOwner(input: {
|
|
7
7
|
structuredPlannerTurn: boolean;
|
|
8
8
|
directResponse: boolean;
|
|
9
|
-
mcpCapabilitySelection: boolean;
|
|
10
|
-
pinnedSkillCount: number;
|
|
11
9
|
}): CapabilityRoutingOwner;
|
|
@@ -89,11 +89,6 @@ export declare function createToolGuidanceSection(): SystemPromptSection;
|
|
|
89
89
|
* (e.g., Chinese INDEX.md + English tool guidance).
|
|
90
90
|
*/
|
|
91
91
|
export declare function createLanguageSection(language?: string): SystemPromptSection;
|
|
92
|
-
/**
|
|
93
|
-
* Available Skills — Host-owned discovery. qlogicagent advertises only the projected MCP workflow;
|
|
94
|
-
* it does not scan, parse, cache, or read the Host Skill store.
|
|
95
|
-
*/
|
|
96
|
-
export declare function createAvailableSkillsSection(availableToolNames?: string[]): SystemPromptSection;
|
|
97
92
|
/**
|
|
98
93
|
* Detect the response language from the user's current-turn text so the strong
|
|
99
94
|
* explicit-language branch of createLanguageSection actually fires.
|
|
@@ -99,6 +99,7 @@ export declare class McpManager {
|
|
|
99
99
|
private runtime;
|
|
100
100
|
private definitions;
|
|
101
101
|
private toolsByServer;
|
|
102
|
+
private instructionsByServer;
|
|
102
103
|
private refreshAllPromise;
|
|
103
104
|
private injectedNames;
|
|
104
105
|
private injectedNamesByServer;
|
|
@@ -144,6 +145,7 @@ export declare class McpManager {
|
|
|
144
145
|
*/
|
|
145
146
|
disconnectAll(): Promise<void>;
|
|
146
147
|
private toPortableTool;
|
|
148
|
+
private refreshServerInstructions;
|
|
147
149
|
private wrapToolsForWorkspaceBoundary;
|
|
148
150
|
private injectPortableTools;
|
|
149
151
|
private retractServerTools;
|
|
@@ -151,7 +153,7 @@ export declare class McpManager {
|
|
|
151
153
|
private removeRegisteredTool;
|
|
152
154
|
}
|
|
153
155
|
export declare function mcpFallbackToolTitle(serverName: string, toolName: string): string;
|
|
154
|
-
export declare function mcpPortableToolMetadata(serverName: string, mcpTool: McpServerToolInfo): Pick<PortableTool, "name" | "label" | "description" | "semanticCapability" | "
|
|
156
|
+
export declare function mcpPortableToolMetadata(serverName: string, mcpTool: McpServerToolInfo): Pick<PortableTool, "name" | "label" | "description" | "semanticCapability" | "searchHint" | "isConcurrencySafe" | "isReadOnly" | "isDestructive" | "riskLevel" | "isEgress" | "egressCarriesData">;
|
|
155
157
|
/**
|
|
156
158
|
* MCP bridges may already expose a globally-scoped `{server}__{tool}` name.
|
|
157
159
|
* Prefixing that name again makes the model-facing function opaque and can push
|
|
@@ -160,13 +162,12 @@ export declare function mcpPortableToolMetadata(serverName: string, mcpTool: Mcp
|
|
|
160
162
|
*/
|
|
161
163
|
export declare function mcpPortableFunctionName(serverName: string, toolName: string): string;
|
|
162
164
|
/**
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
* "(no text output)" for a result that DID produce blocks is a lie.
|
|
165
|
+
* Preserve the complete standard MCP CallToolResult. Provider adapters may add
|
|
166
|
+
* a model-compatible text/media projection, but the protocol fields remain
|
|
167
|
+
* available unchanged for transcripts, artifacts, and capable transports.
|
|
167
168
|
* Exported for unit tests only.
|
|
168
169
|
*/
|
|
169
|
-
export declare function toPortableResult(result: unknown,
|
|
170
|
+
export declare function toPortableResult(result: unknown, _source?: {
|
|
170
171
|
serverName: string;
|
|
171
172
|
toolName: string;
|
|
172
173
|
args?: Record<string, unknown>;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import type { PermissionRiskLevel } from "../runtime/ports/index.js";
|
|
6
6
|
import type { SemanticToolCapability, ToolIdentity } from "../protocol/wire/index.js";
|
|
7
7
|
export interface ToolContentBlock {
|
|
8
|
-
type:
|
|
8
|
+
type: string;
|
|
9
9
|
text?: string;
|
|
10
10
|
/**
|
|
11
11
|
* base64-encoded image data (only when type === "image").
|
|
@@ -15,6 +15,7 @@ export interface ToolContentBlock {
|
|
|
15
15
|
*/
|
|
16
16
|
data?: string;
|
|
17
17
|
mimeType?: string;
|
|
18
|
+
[key: string]: unknown;
|
|
18
19
|
}
|
|
19
20
|
export type LocaleCode = "zh-CN" | "en-US" | (string & {});
|
|
20
21
|
export interface LocalizedText {
|
|
@@ -35,6 +36,9 @@ export type ToolRiskLevel = PermissionRiskLevel;
|
|
|
35
36
|
*/
|
|
36
37
|
export interface PortableToolResult {
|
|
37
38
|
content: ToolContentBlock[];
|
|
39
|
+
isError?: boolean;
|
|
40
|
+
structuredContent?: Record<string, unknown>;
|
|
41
|
+
_meta?: Record<string, unknown>;
|
|
38
42
|
/** Arbitrary structured metadata for the calling runtime. */
|
|
39
43
|
details?: Record<string, unknown>;
|
|
40
44
|
/**
|
|
@@ -69,8 +73,6 @@ export interface PortableTool<TParams = Record<string, unknown>> {
|
|
|
69
73
|
description: string;
|
|
70
74
|
/** Structured semantics used by model-based capability discovery and routing. */
|
|
71
75
|
semanticCapability?: SemanticToolCapability;
|
|
72
|
-
/** Host-authored, bounded Skill routing index attached only to skill_list. */
|
|
73
|
-
skillDirectory?: import("../protocol/wire/chat-types.js").SkillDirectory;
|
|
74
76
|
/** JSON Schema object describing the tool's parameters. */
|
|
75
77
|
parameters: Record<string, unknown>;
|
|
76
78
|
/**
|
|
@@ -11,7 +11,7 @@ export declare const READ_TOOL_SCHEMA: {
|
|
|
11
11
|
readonly properties: {
|
|
12
12
|
readonly path: {
|
|
13
13
|
readonly type: "string";
|
|
14
|
-
readonly description: "Absolute path to
|
|
14
|
+
readonly description: "Absolute path to one plain-text file. Do not pass a structured binary document, archive, or media file for content inspection; use its dedicated typed capability.";
|
|
15
15
|
};
|
|
16
16
|
readonly offset: {
|
|
17
17
|
readonly type: "number";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qlogicagent",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.23.0",
|
|
4
4
|
"packageManager": "pnpm@10.23.0",
|
|
5
5
|
"description": "XiaozhiClaw Agent CLI — subprocess architecture (JSON-RPC over stdio)",
|
|
6
6
|
"type": "module",
|
|
@@ -170,8 +170,9 @@
|
|
|
170
170
|
"dependencies": {
|
|
171
171
|
"@agentclientprotocol/sdk": "^0.25.0",
|
|
172
172
|
"@napi-rs/canvas": "0.1.100",
|
|
173
|
-
"@xiaozhiclaw/module-sdk": "0.
|
|
174
|
-
"@xiaozhiclaw/provider-core": "0.1.
|
|
173
|
+
"@xiaozhiclaw/module-sdk": "0.3.0",
|
|
174
|
+
"@xiaozhiclaw/provider-core": "0.1.33",
|
|
175
|
+
"ajv": "8.20.0",
|
|
175
176
|
"better-sqlite3": "^12.10.0",
|
|
176
177
|
"dotenv": "^17.3.1",
|
|
177
178
|
"ioredis": "^5.11.1",
|