pi-agent-ide 0.7.0 → 0.7.1
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/CHANGELOG.md +7 -0
- package/dist/chunk-2TRHFMCZ.js +11 -0
- package/dist/{chunk-FXNKMNSJ.js → chunk-4GCWGE2C.js} +1 -1
- package/dist/chunk-4XMY4H4V.js +1 -0
- package/dist/{chunk-3HYXQ4YA.js → chunk-76ZK5ODR.js} +2 -2
- package/dist/{chunk-6CZO43OH.js → chunk-BU7IZLKB.js} +1 -1
- package/dist/chunk-CWD4O5PM.js +3 -0
- package/dist/chunk-D3WTDA6V.js +2 -0
- package/dist/chunk-GXEGY7GV.js +1 -0
- package/dist/{chunk-GBLKIB6O.js → chunk-HZEY4GT4.js} +1 -1
- package/dist/{chunk-S5LXX32D.js → chunk-LEEQIQ7D.js} +6 -6
- package/dist/chunk-NRZO5KJT.js +9 -0
- package/dist/chunk-OMVRLWMX.js +5 -0
- package/dist/{chunk-KR36BT5E.js → chunk-PGIVHICI.js} +1 -1
- package/dist/{chunk-YRF7OATP.js → chunk-PKKDDIWW.js} +1 -1
- package/dist/{chunk-EDURPQAV.js → chunk-QRJLIV6P.js} +6 -6
- package/dist/{chunk-OBNING2A.js → chunk-S5PL5DFQ.js} +1 -1
- package/dist/chunk-VMTR74FF.js +2 -0
- package/dist/{chunk-PYPPV2F5.js → chunk-WMO6RNE2.js} +1 -1
- package/dist/{chunk-3JO7QFIL.js → chunk-WU6ZK6YD.js} +1 -1
- package/dist/{chunk-F5YZG77W.js → chunk-XH5WN5XA.js} +1 -1
- package/dist/{chunk-AJRIASPQ.js → chunk-YP46DVVP.js} +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-15.js +1 -1
- package/dist/entry-17.js +1 -1
- package/dist/entry-25.js +2 -2
- package/dist/entry-26.js +1 -1
- package/dist/entry-27.js +2 -2
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +1 -1
- package/dist/entry-31.js +13 -12
- package/dist/entry-33.js +1 -1
- package/dist/entry-37.js +6 -6
- package/dist/entry-41.js +1 -1
- package/dist/entry-43.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +13 -14
- package/dist/entry-46.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +2 -2
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -1
- package/dist/entry-56.js +1 -1
- package/dist/entry-57.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-62.js +1 -1
- package/dist/entry-65.js +1 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-77.js +33 -34
- package/dist/entry-78.js +1 -1
- package/dist/entry-79.js +1 -1
- package/dist/entry-80.js +1 -1
- package/dist/entry-82.js +2 -2
- package/dist/entry-83.js +1 -1
- package/dist/entry-84.js +1 -1
- package/dist/entry-85.js +1 -1
- package/dist/entry-86.js +1 -1
- package/dist/pi-agent-ide.js +14 -9
- package/docs/agent-guides/editing.md +35 -46
- package/docs/agent-guides/read-resources.md +5 -9
- package/docs/agent-guides/search-code.md +12 -17
- package/docs/agent-guides/select-code.md +61 -140
- package/docs/structured-results.md +27 -62
- package/docs/tools.md +6 -10
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-documentation/package.json +1 -1
- package/node_modules/pi-agent-filesystem/index.ts +7 -6
- package/node_modules/pi-agent-filesystem/package.json +7 -7
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- package/node_modules/pi-agent-filesystem-jq/index.ts +4 -3
- package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
- package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
- package/node_modules/pi-agent-filesystem-text/package.json +3 -3
- package/node_modules/pi-agent-ide-ast/package.json +13 -13
- package/node_modules/pi-agent-ide-ast/src/extension.ts +7 -4
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +35 -6
- package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +1 -1
- package/node_modules/pi-agent-ide-ast/src/select-schema.ts +2 -2
- package/node_modules/pi-agent-ide-ast/src/tool-select.ts +18 -1
- package/node_modules/pi-agent-ide-changes/index.ts +4 -3
- package/node_modules/pi-agent-ide-changes/package.json +8 -8
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lsp/index.ts +3 -3
- package/node_modules/pi-agent-ide-lsp/package.json +9 -9
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +5 -1
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-invariant/package.json +1 -1
- package/node_modules/pi-agent-pdf/package.json +2 -2
- package/node_modules/pi-agent-read/package.json +7 -7
- package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +38 -1
- package/node_modules/pi-agent-read/src/api/tools/read.ts +7 -1
- package/node_modules/pi-agent-read/src/core/extension.ts +7 -1
- package/node_modules/pi-agent-read/src/core/read-core.ts +50 -35
- package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +3 -3
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +9 -2
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/result-targets.ts +183 -9
- package/node_modules/pi-agent-resource/src/tool-result.ts +13 -1
- package/node_modules/pi-agent-search/package.json +5 -5
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +1 -1
- package/node_modules/pi-agent-search-text/index.ts +1 -1
- package/node_modules/pi-agent-search-text/package.json +7 -7
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/index.ts +65 -4
- package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +12 -2
- package/node_modules/pi-agent-text-anchor-line-hash/index.ts +4 -3
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/node_modules/pi-agent-text-editor/package.json +9 -9
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +3 -1
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +10 -3
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +3 -13
- package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +18 -11
- package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +43 -209
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +37 -31
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +2 -7
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +2 -2
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +1 -1
- package/node_modules/pi-agent-text-editor-renderer/package.json +5 -5
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/node_modules/pi-agent-tool-call-interception/package.json +2 -2
- package/node_modules/pi-agent-tool-call-interception/src/index.ts +3 -0
- package/node_modules/pi-agent-tool-ui/package.json +1 -1
- package/node_modules/pi-agent-web/index.ts +4 -3
- package/node_modules/pi-agent-web/package.json +7 -7
- package/node_modules/pi-agent-web-html/package.json +2 -2
- package/node_modules/pi-agent-web-image/package.json +3 -3
- package/node_modules/pi-agent-web-pdf/package.json +3 -3
- package/node_modules/pi-agent-web-text/package.json +3 -3
- package/package.json +35 -35
- package/src/composite/text-results.ts +221 -0
- package/src/documentation/extension.ts +11 -9
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +7 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/index.ts +4 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +4 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +2 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +3 -3
- package/src/extensions/pi-agent-read/package.json +7 -7
- package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +38 -1
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +7 -1
- package/src/extensions/pi-agent-read/src/core/extension.ts +7 -1
- package/src/extensions/pi-agent-read/src/core/read-core.ts +50 -35
- package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +3 -3
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +9 -2
- package/src/extensions/pi-agent-search/package.json +5 -5
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +1 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +7 -7
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +1 -1
- package/src/extensions/pi-agent-text-editor/package.json +9 -9
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/index.ts +65 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts +12 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +4 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +3 -1
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +10 -3
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +3 -13
- package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +18 -11
- package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +43 -209
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +37 -31
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +2 -7
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +2 -2
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +1 -1
- package/src/pi-agent-ide.ts +4 -1
- package/src/plugins/pi-agent-ide-ast/package.json +13 -13
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +7 -4
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +35 -6
- package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +1 -1
- package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +2 -2
- package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +18 -1
- package/src/plugins/pi-agent-ide-changes/index.ts +4 -3
- package/src/plugins/pi-agent-ide-changes/package.json +8 -8
- package/src/plugins/pi-agent-ide-debugger/index.ts +5 -3
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +5 -3
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lsp/index.ts +3 -3
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +5 -1
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +8 -6
- package/src/plugins/pi-agent-ide-vision/index.ts +12 -4
- package/dist/chunk-4NIFBFFR.js +0 -11
- package/dist/chunk-7LZKOHH2.js +0 -1
- package/dist/chunk-FK42RSF4.js +0 -1
- package/dist/chunk-KBP3QUDT.js +0 -2
- package/dist/chunk-OE7QVAI2.js +0 -5
- package/dist/chunk-SILJ3OL4.js +0 -9
- package/dist/chunk-SQKAXYIR.js +0 -2
- package/dist/chunk-VCGNVTXQ.js +0 -1
package/dist/chunk-SILJ3OL4.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import"./chunk-MPT3R4BL.js";import{a as y,b as A,c as D,d as k}from"./chunk-T7I2VX3J.js";import{a as I}from"./chunk-6CZO43OH.js";import{a as E,b as P}from"./chunk-OBNING2A.js";import{a}from"./chunk-EI7MMDWY.js";var N=/^[a-z0-9]+(?:[.-][a-z0-9]+)*$/,h=class{static{a(this,"AgentDocumentationRegistry")}#e=new Map;register(n){let o=new Set(this.#e.keys());for(let r of n)_(r,o),o.add(r.id);for(let r of n)this.#e.set(r.id,b(r))}list(){return[...this.#e.values()].sort((n,o)=>n.id.localeCompare(o.id))}get(n){return this.#e.get(n)}matching(n,o){let r=v(o);return r?.startsWith("docs:")===!0?[]:this.list().filter(s=>s.triggers.some(d=>{if(d.tool!==n)return!1;let l=d.resourcePrefixes===void 0||r!==void 0&&d.resourcePrefixes.some(i=>r.startsWith(i)),t=d.viewPrefixes===void 0||T(o).some(i=>d.viewPrefixes?.some(u=>i.startsWith(u)));return l&&t}))}};function _(e,n){if(!N.test(e.id))throw new Error(`Invalid documentation ID: ${e.id}`);if(e.description.trim().length===0)throw new Error(`Documentation ${e.id} has no description`);if(e.markdown.trim().length===0)throw new Error(`Documentation ${e.id} has no Markdown content`);if(e.triggers.length===0||e.triggers.some(o=>o.tool.trim().length===0||o.resourcePrefixes?.some(r=>r.length===0)===!0||o.viewPrefixes?.some(r=>r.length===0)===!0))throw new Error(`Documentation ${e.id} has no valid triggers`);if(n.has(e.id))throw new Error(`Documentation ${e.id} is already registered`)}a(_,"validateDocument");function b(e){return Object.freeze({...e,triggers:Object.freeze(e.triggers.map(n=>Object.freeze({...n,...n.resourcePrefixes===void 0?{}:{resourcePrefixes:Object.freeze([...n.resourcePrefixes])},...n.viewPrefixes===void 0?{}:{viewPrefixes:Object.freeze([...n.viewPrefixes])}})))})}a(b,"freezeDocument");function T(e){if(typeof e!="object"||e===null)return[];let n=e.views;return Array.isArray(n)?n.filter(o=>typeof o=="string"):[]}a(T,"readViews");function v(e){if(typeof e!="object"||e===null)return;let n=e.path;return typeof n=="string"?n:void 0}a(v,"readPath");var R="agent-documentation-read";async function M(e){let n=new h,o=new Set,r=new Map,s=new Map,d=a(t=>{let i=t.filter(u=>!o.has(u));if(i.length!==0){e.appendEntry(R,{ids:i});for(let u of i)o.add(u)}},"remember"),l=e.events.on(k,t=>{if(!z(t))throw new Error("Invalid agent documentation registration");n.register(t.documents)});e.on("session_shutdown",l),await I(e,{protocol:E,apiVersion:P,id:"agent-documentation",setup(t){t.addResolver({resolver:{id:"agent-documentation",tryResolve(i){if(!i.startsWith("docs:"))return Promise.resolve({kind:"not-handled"});let u=i.slice(5),m=u.length===0?void 0:n.get(u),g=u.length===0?$(n.list()):m?.markdown;return g===void 0?Promise.resolve({kind:"failed",error:new Error(`Unknown documentation ID: ${u}`)}):Promise.resolve({kind:"resolved",resource:{source:i,read:a(()=>Promise.resolve([{type:"text",text:g}]),"read")}})}}}),t.describe(()=>n.list().length===0?void 0:"docs: and docs:<id> \u2014 list or read packaged agent guidance."),t.addPromptGuideline(()=>j(n.list()))}}),e.on("session_start",(t,i)=>{w(i.sessionManager.getBranch(),n,o)}),e.on("session_tree",(t,i)=>{w(i.sessionManager.getBranch(),n,o)}),e.on("session_compact",(t,i)=>{w(i.sessionManager.getBranch(),n,o)}),e.on("tool_call",t=>{t.toolCallId.includes("-preflight-")||t.parentToolCallId!==void 0&&r.set(t.toolCallId,t.parentToolCallId)}),e.on("tool_result",t=>{if(t.toolCallId.includes("-preflight-"))return;let i=r.get(t.toolCallId);r.delete(t.toolCallId);let u=s.get(t.toolCallId)??[];s.delete(t.toolCallId);let m=t.toolName==="read"?S(t.input):void 0;if(m!==void 0){let c=m.slice(5),C=c.length===0||n.get(c)!==void 0,p=n.get(c);return p!==void 0&&!t.isError&&O(t.content,p)&&d([c]),{content:t.content,structuredContent:t.structuredContent,details:{...f(t.details)?t.details:{},documentation:C?c.length===0?{kind:"list",ids:n.list().map(x=>x.id)}:{kind:"document",id:c}:{kind:"error",code:"UNKNOWN_DOCUMENTATION",id:c}},isError:t.isError}}let g=[...u,...n.matching(t.toolName,t.input).filter(c=>!o.has(c.id))];if(g.length!==0)return d(g.map(c=>c.id)),i!==void 0&&t.structuredContent!==void 0&&s.set(i,[...s.get(i)??[],...g]),{content:[...t.content,...g.map(c=>({type:"text",text:`
|
|
2
|
-
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Guide: ${c.id}
|
|
6
|
-
|
|
7
|
-
${c.markdown.trim()}`}))],structuredContent:t.structuredContent,details:{...f(t.details)?t.details:{},documentation:{kind:"attachment",ids:g.map(c=>c.id)}},isError:t.isError}}),e.events.emit(D,{protocol:y,apiVersion:A})}a(M,"registerProgressiveDocumentation");function $(e){return e.length===0?"No agent documentation is currently available.":["# Available agent documentation","",...e.map(n=>`- \`${n.id}\` \u2014 ${n.description}`)].join(`
|
|
8
|
-
`)}a($,"renderListing");function j(e){if(e.length!==0)return["Read the matching docs:<id> before using any tool or feature with packaged guidance, including tools discovered later or called through Codemode. Read each guide once per branch. Tool descriptions and docs: listings do not replace the full guide.","If a result includes a Guide, read it before your next use. The call has already run: do not repeat it just to obtain documentation. Native structured child calls keep their guides on the parent result. Output readable-only child results to retain their guides; filtering those results can hide them.","Available documents:",...e.map(n=>` - ${n.id} \u2014 ${n.description}`)].join(`
|
|
9
|
-
`)}a(j,"renderPromptGuideline");function w(e,n,o){o.clear();for(let s of e){if(!f(s))continue;if(s.type==="custom"&&s.customType===R&&f(s.data)){r(s.data.ids);continue}if(s.type!=="message"||!f(s.message))continue;let d=s.message;if(d.role!=="toolResult"||!f(d.details))continue;let l=d.details.documentation;if(f(l)&&(l.kind==="attachment"&&r(l.ids),l.kind==="document"&&!d.isError&&typeof l.id=="string")){let t=n.get(l.id);t!==void 0&&O(d.content,t)&&r([t.id])}}function r(s){if(Array.isArray(s))for(let d of s)typeof d=="string"&&n.get(d)!==void 0&&o.add(d)}a(r,"addIds")}a(w,"restoreClaims");function O(e,n){return Array.isArray(e)&&e.some(o=>f(o)&&o.type==="text"&&typeof o.text=="string"&&o.text.includes(n.markdown.trim()))}a(O,"containsFullGuide");function S(e){if(!(!f(e)||typeof e.path!="string"||!e.path.startsWith("docs:")))return e.path}a(S,"documentationSource");function z(e){return f(e)&&Array.isArray(e.documents)}a(z,"isRegistrationRequest");function f(e){return typeof e=="object"&&e!==null}a(f,"isRecord");export{M as default};
|
package/dist/chunk-SQKAXYIR.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as i}from"./chunk-EI7MMDWY.js";import{AsyncLocalStorage as ye}from"node:async_hooks";function re(){return{pending:new Set,active:new ye}}i(re,"createSchedulerState");function Ce(t,e){return t===void 0||e===void 0?!0:t.some(r=>e.some(n=>(r.mode==="write"||n.mode==="write")&&(r.resource==="*"||n.resource==="*"||r.resource===n.resource||r.recursive===!0&&n.resource.startsWith(r.resource.endsWith("/")?r.resource:`${r.resource}/`)||n.recursive===!0&&r.resource.startsWith(n.resource.endsWith("/")?n.resource:`${n.resource}/`))))}i(Ce,"conflicts");function ve(t,e,r){if(e===void 0||!r&&e.some(o=>o.mode!=="read"))return!1;if(t===void 0)return!0;let n=new Map;for(let o of e){let s=o.group??o.resource;n.set(s,[...n.get(s)??[],o])}return[...n.values()].every(o=>o.some(s=>t.some(a=>(s.mode==="read"||a.mode==="write")&&(a.resource==="*"||s.resource===a.resource&&(s.recursive!==!0||a.recursive===!0)||a.recursive===!0&&s.resource.startsWith(a.resource.endsWith("/")?a.resource:`${a.resource}/`)))))}i(ve,"coveredAccess");async function Re(t,e){if(e===void 0)return await t;e.throwIfAborted();let r,n=new Promise((o,s)=>{r=i(()=>s(e.reason),"abort"),e.addEventListener("abort",r,{once:!0})});try{return await Promise.race([t,n])}finally{e.removeEventListener("abort",r)}}i(Re,"waitForDependencies");var _=class t{constructor(e=re()){this.state=e}static{i(this,"ResourceScheduler")}run(e,r,n,o={}){let s=Promise.resolve(e),a=this.state.active.getStore();if(a?.open){let E=s.then(h=>{if(n?.throwIfAborted(),!ve(a.accesses,h,a.allowNestedWrites))throw Object.assign(new Error("Nested resource access must be covered by its parent reservation and permitted by its owner."),{code:"UNDECLARED_RESOURCE_ACCESS"});return h});a.nested??=new t;let g=a.nested.run(E,r,n,{allowNestedWrites:a.allowNestedWrites});return a.children.add(g),g.then(()=>a.children.delete(g),()=>a.children.delete(g)),g}let d=[...this.state.pending],p=s.catch(()=>{}),y,l=new Promise(E=>{y=E}),S={accesses:p,done:l};return this.state.pending.add(S),(async()=>{try{n?.throwIfAborted();let E=await Re(s.then(async h=>(await Promise.all(d.map(F=>Promise.race([F.done,F.accesses.then(me=>Ce(h,me)?F.done:void 0)]))),h)),n);n?.throwIfAborted();let g={accesses:E,children:new Set,open:!0,allowNestedWrites:o.allowNestedWrites===!0};try{return await this.state.active.run(g,r)}finally{for(;g.children.size>0;)await Promise.allSettled([...g.children]);g.open=!1}}finally{this.state.pending.delete(S),y()}})()}},he=Symbol.for("pi-agent-resource.resource-scheduler-state"),we=globalThis,Te=we[he]??=re(),Se=new _(Te);import{realpath as Ee,stat as be}from"node:fs/promises";import N from"node:path";import{fileURLToPath as xe}from"node:url";async function ne(t,e,r){if(/^[a-z][a-z\d+.-]*:/iu.test(t)&&!/^[a-z]:[\\/]/iu.test(t)&&!t.startsWith("file:"))return[{resource:t,mode:r}];let n=N.resolve(e,t.startsWith("file:")?xe(t):t),[o,s]=await Promise.allSettled([Ee(n),be(n,{bigint:!0})]),a;if(o.status==="fulfilled")a=o.value;else{let l=o.reason;if(!(l instanceof Error)||!("code"in l)||l.code!=="ENOENT")throw l;let S=N.dirname(n);if(S===n)a=n;else{let g=(await ne(S,e,r)).find(h=>h.resource.startsWith("file:"));a=N.join(g?.resource.slice(5)??S,N.basename(n))}}let d=a.split(N.sep).join("/"),p=`file:${process.platform==="win32"?d.toLowerCase():d}`,y=[{resource:p,group:p,mode:r}];if(s.status==="fulfilled"){let l=s.value;l.isDirectory()&&(y[0]={resource:p,group:p,mode:r,recursive:!0}),l.ino!==0n&&y.push({resource:`inode:${l.dev}:${l.ino}`,group:p,mode:r,recursive:l.isDirectory()})}else{let l=s.reason;if(!(l instanceof Error)||!("code"in l)||l.code!=="ENOENT")throw l}return y}i(ne,"resourceAccesses");import{Type as f}from"typebox";import{Value as Ae}from"typebox/value";var M=f.Object({code:f.String(),message:f.String(),source:f.Optional(f.String())},{additionalProperties:!1});function oe(t){return f.Union([f.Object({status:f.Literal("success"),data:t,errors:f.Array(M,{maxItems:0})},{additionalProperties:!1}),f.Object({status:f.Union([f.Literal("error"),f.Literal("partial")]),data:f.Optional(t),errors:f.Array(M,{minItems:1})},{additionalProperties:!1})])}i(oe,"structuredResultSchema");var se=1024*1024;function q(t){let e=new Set,r=i(n=>{if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(typeof n!="object"||e.has(n))throw new TypeError("Structured data must be finite, acyclic JSON");if(!Array.isArray(n)&&Object.getPrototypeOf(n)!==Object.prototype&&Object.getPrototypeOf(n)!==null)throw new TypeError("Structured data must not contain classes or raw byte buffers");e.add(n);for(let o of Array.isArray(n)?n:Object.values(n))r(o);e.delete(n)}},"visit");if(r(t),Buffer.byteLength(JSON.stringify(t))>se)throw new RangeError("Structured data exceeds 1 MiB; return a smaller window or a full-result reference")}i(q,"assertJsonData");function ie(t,e="EXECUTION_FAILED",r){return{code:typeof t=="object"&&t!==null&&"code"in t&&typeof t.code=="string"?t.code:e,message:t instanceof Error?t.message:String(t),...r===void 0?{}:{source:r}}}i(ie,"resultError");function Oe(t,e,r){try{if(q(r),!Ae.Check(oe(e),r))throw new TypeError("Result adapter returned data outside its public schema");return{...t,structuredContent:r,isError:r.status!=="success"}}catch(n){let o=ie(n,"INVALID_STRUCTURED_RESULT"),s={status:"error",errors:[o]};return q(s),{...t,content:[...t.content,{type:"text",text:o.message}],structuredContent:s,isError:!0}}}i(Oe,"withStructuredResult");function Ne(t,e){if(e.length===0)return;let r=t.trim();if(r.length===0||/[\r\n]/u.test(r))throw new TypeError("Content provider summary must be one non-empty line");return[r,...e.map(({description:n})=>n)].join(`
|
|
2
|
-
`)}i(Ne,"renderContentDescription");import{Type as u}from"typebox";import{Value as Ve}from"typebox/value";import{Type as c}from"typebox";import{Value as ke}from"typebox/value";var m={additionalProperties:!0},k=c.Function([],c.Unknown()),C=c.String({minLength:1}),Pe=c.Object({type:c.Literal("text"),text:c.String(),textSignature:c.Optional(c.String())},m),je=c.Object({type:c.Literal("image"),data:c.String(),mimeType:c.String()},m),Ie=c.Object({type:c.Literal("custom"),kind:C,data:c.Unknown()},m),_e=c.Array(c.Union([Pe,je,Ie]),{minItems:1}),ae=c.Union([c.Object({source:C,link:c.Optional(C),read:k,write:c.Optional(c.Never())},m),c.Object({source:C,link:c.Optional(C),read:c.Optional(c.Never()),write:k},m),c.Object({source:C,link:c.Optional(C),read:k,write:k},m)]),Ue=c.Object({id:C,tryResolve:k},m),De=c.Union([c.Object({kind:c.Literal("not-handled")},m),c.Object({kind:c.Literal("resolved"),resource:ae},m),c.Object({kind:c.Literal("failed"),error:c.Unknown()},m)]);function z(t){return U(_e,t)?D(()=>t.every(e=>e.type!=="text"||!("textSignature"in e)||typeof e.textSignature=="string")):!1}i(z,"isAgentContent");function ce(t){return U(ae,t)?D(()=>{let e=t,r=!("read"in e)||typeof e.read=="function",n=!("write"in e)||typeof e.write=="function";return r&&n}):!1}i(ce,"isResource");function Le(t){return U(Ue,t)}i(Le,"isResourceResolver");function $e(t){return U(De,t)?D(()=>{let e=t;return e.kind!=="resolved"||ce(e.resource)}):!1}i($e,"isResourceResolutionAttempt");function U(t,e){return D(()=>ke.Check(t,e))}i(U,"safeCheck");function D(t){try{return t()}catch{return!1}}i(D,"safeEvaluate");var v={additionalProperties:!0},We=u.Function([],u.Unknown()),L=u.String({minLength:1}),He=u.Object({provider:L,capability:u.Union([u.Literal("read"),u.Literal("write")])},v),Ke=u.Object({source:L,bytes:u.Unknown(),mediaType:u.Optional(u.String())},v),Fe=u.Object({signal:u.Optional(u.Unknown())},v),Me=u.Object({id:L,description:L,tryConvert:We},v),qe=u.Union([u.Object({kind:u.Literal("not-handled")},v),u.Object({kind:u.Literal("converted"),content:u.Unknown()},v),u.Object({kind:u.Literal("failed"),error:u.Unknown()},v)]),ze=u.Object({target:u.Unknown(),converter:u.Unknown(),priority:u.Optional(u.Number())},v);function b(t){return x(He,t)&&T(()=>t.provider.trim().length>0)}i(b,"isContentTarget");function B(t){return x(Ke,t)?T(()=>{let e=t;return e.bytes instanceof Uint8Array&&(!("mediaType"in e)||typeof e.mediaType=="string")}):!1}i(B,"isContentInput");function J(t){return x(Fe,t)?T(()=>{let e=t;return!("signal"in e)||e.signal instanceof AbortSignal}):!1}i(J,"isContentConversionContext");function ue(t){return x(Me,t)?T(()=>{let e=t;return e.id.trim().length>0&&e.description.trim().length>0&&!/[\r\n]/u.test(e.description)}):!1}i(ue,"isContentConverter");function Y(t){return x(qe,t)?T(()=>{let e=t;return e.kind!=="converted"||z(e.content)}):!1}i(Y,"isContentConversionAttempt");function w(t){return x(ze,t)?T(()=>{let e=t;return b(e.target)&&ue(e.converter)&&(!("priority"in e)||typeof e.priority=="number"&&Number.isFinite(e.priority))}):!1}i(w,"isContentConverterRegistration");function x(t,e){return T(()=>Ve.Check(t,e))}i(x,"safeCheck");function T(t){try{return t()}catch{return!1}}i(T,"safeEvaluate");var $=class extends Error{static{i(this,"UnsupportedContentError")}source;target;constructor(e,r){super(`No content converter for ${e} in ${r.provider}/${r.capability}`),this.name="UnsupportedContentError",this.source=e,this.target=r}};function X(t){if(!b(t))throw new TypeError("Invalid content target");let e={...t},r=[],n=i(()=>[...r].sort((o,s)=>o.priority-s.priority||o.order-s.order),"snapshotConverters");return{target:e,register(o){if(!w(o))throw new TypeError("Invalid content converter registration");if(!A(e,o.target))throw new Error(`Content converter ${o.converter.id} targets ${o.target.provider}/${o.target.capability}, not ${e.provider}/${e.capability}`);if(r.some(({converter:s})=>s.id===o.converter.id))throw new Error(`Content converter ${o.converter.id} is already registered for ${e.provider}/${e.capability}`);r.push({converter:o.converter,priority:o.priority??0,order:r.length})},listDescriptions(){return n().map(({converter:o})=>({id:o.id,description:o.description}))},async convert(o,s){if(!B(o))throw new TypeError("Invalid content input");if(!J(s))throw new TypeError("Invalid content conversion context");G(s.signal);let a=n();for(let{converter:d}of a){G(s.signal);let p=await d.tryConvert(o,s);if(G(s.signal),!Y(p))throw new TypeError(`Content converter ${d.id} returned an invalid outcome`);if(p.kind!=="not-handled"){if(p.kind==="failed")throw p.error;return p.content}}throw new $(o.source,e)}}}i(X,"createContentRunner");function A(t,e){return t.provider===e.provider&&t.capability===e.capability}i(A,"targetsEqual");function G(t){t?.throwIfAborted()}i(G,"throwIfAborted");import{Type as R}from"typebox";import{Value as Be}from"typebox/value";var O="pi-agent-resource/content-conversion",V=2,P=`${O}/host/ready`,j=`${O}/converter/register`,de={additionalProperties:!0},Je=R.Function([],R.Unknown()),Ye=R.Object({protocol:R.Literal(O),apiVersion:R.Literal(V),target:R.Unknown()},de),Ge=R.Object({registration:R.Unknown(),accept:Je},de);function Q(t){return le(Ye,t)&&ee(()=>b(t.target))}i(Q,"isContentHostReady");function Z(t){return le(Ge,t)&&ee(()=>w(t.registration))}i(Z,"isContentConverterRegistrationRequest");function le(t,e){return ee(()=>Be.Check(t,e))}i(le,"safeCheck");function ee(t){try{return t()}catch{return!1}}i(ee,"safeEvaluate");function Xe(t,e){let r=X(e),n=t.events.on(j,o=>{if(!Z(o))throw new Error("Invalid content converter registration request");if(!A(r.target,o.registration.target))return;let s;try{r.register(o.registration),s=Promise.resolve()}catch(a){s=Promise.reject(a instanceof Error?a:new Error("Content converter registration failed",{cause:a}))}o.accept(s)});return t.on("session_shutdown",n),t.events.emit(P,{protocol:O,apiVersion:V,target:r.target}),{target:r.target,listDescriptions(){return r.listDescriptions()},convert(o,s){return r.convert(o,s)}}}i(Xe,"createContentHost");function Qe(t,e){if(!w(e))throw new TypeError("Invalid content converter registration");let r=i(()=>{let s,a={registration:e,accept(d){if(s!==void 0)throw new Error(`Content converter ${e.converter.id} registration was accepted more than once`);s=d}};return t.events.emit(j,a),s},"announce"),n=i(()=>{},"unsubscribe");n=t.events.on(P,s=>{if(!Q(s))throw new Error("Invalid content conversion host readiness event");if(!A(e.target,s.target))return;let a=r();if(a===void 0)throw new Error(`${s.target.provider}/${s.target.capability} announced readiness without accepting content converter ${e.converter.id}`);n(),a.catch(()=>{})}),t.on("session_shutdown",n);let o=r();if(o!==void 0)return n(),o}i(Qe,"connectContentConverter");import{randomUUID as pe}from"node:crypto";import{readFile as Ze}from"node:fs/promises";import W from"node:path";import{Type as I}from"typebox";var et=I.Union([I.String(),I.Object({},{additionalProperties:!0}),I.Array(I.Unknown())]),H="RESULT#",fe="pi-agent-resource:result-targets",K=class{static{i(this,"ResultTargetStore")}#e=new Map;clear(){this.#e.clear()}register(e,r,n=!0){let o=`${H}${pe()}`;return this.#e.set(o,{state:"ready",targets:te(e),complete:n,cwd:W.resolve(r)}),o}reserve(e){let r=`${H}${pe()}`;return this.#e.set(r,{state:"pending",cwd:W.resolve(e)}),r}confirm(e,r,n){let o=this.#e.get(e);if(o?.state!=="pending"||o.cwd!==W.resolve(n))throw new Error("Only a pending result in this worktree can be confirmed.");this.#e.set(e,{state:"ready",cwd:o.cwd,targets:te(r),complete:!0})}reject(e,r){let n=this.#e.get(e);n?.state==="pending"&&this.#e.set(e,{state:"rejected",cwd:n.cwd,reason:r})}resolve(e,r){let n=this.#t(e),o=[],s=!0;for(let a of n){let d=this.#e.get(a);if(d===void 0)throw new Error("Result target expired or unknown; repeat Read/Search.");if(d.cwd!==W.resolve(r))throw new Error("Result target belongs to another worktree.");if(d.state==="pending")throw new Error("Result target is pending; its write has not been confirmed.");if(d.state==="rejected")throw new Error(d.reason);s&&=d.complete,o.push(...d.targets)}return{targets:te(o),complete:s}}resolveOrdered(e,r){let n=this.resolve(e,r),o=[],s=new Set;for(let a of new Set(this.#t(e)))for(let d of this.resolve(a,r).targets)for(let p of d.ranges){let y=JSON.stringify([d.source,p]);s.has(y)||(s.add(y),o.push({...d,ranges:[p]}))}return{targets:o,complete:n.complete}}async verify(e,r){await ge(e,r)}#t(e){if(typeof e=="string"&&e.startsWith(H))return[e];if(Array.isArray(e))return e.flatMap(n=>this.#t(n));if(e===null||typeof e!="object")throw new Error("Unsupported result input.");let r=e;if("status"in r){if(r.status!=="success")throw new Error("Only successful source results can be consumed.");return this.#t(r.data)}if(typeof r.target=="string"&&r.target.startsWith(H))return[r.target];if(r.kind==="resources"&&Array.isArray(r.resources))return this.#t(r.resources);throw new Error("This result has no supported source target; do not use preview text as a source.")}};async function ge(t,e){let r=new Map;for(let n of t.targets){e?.throwIfAborted();let o=r.get(n.source);if(o===void 0&&(o=await Ze(n.source,{encoding:"utf8",signal:e}),r.set(n.source,o)),o!==n.expectedContent)throw new Error("Result target is stale; repeat Read/Search.")}}i(ge,"verifyResultTargets");function te(t){let e=new Map;for(let r of t){let n=e.get(r.source);if(n!==void 0&&n.expectedContent!==r.expectedContent)throw new Error("Result targets refer to different snapshots of the same source.");let o=n??{source:r.source,expectedContent:r.expectedContent,ranges:[],seen:new Set};for(let s of r.ranges){let a=JSON.stringify(s);o.seen.has(a)||(o.seen.add(a),o.ranges.push(structuredClone(s)))}e.set(r.source,o)}return[...e.values()].filter(r=>r.ranges.length>0).map(({seen:r,...n})=>({...n,ranges:n.ranges.sort((o,s)=>o.start.lineNumber-s.start.lineNumber||o.start.column-s.start.column||o.end.lineNumber-s.end.lineNumber||o.end.column-s.end.column)}))}i(te,"combineTargets");function tt(t){let e;if(t.events.emit(fe,{accept:i(o=>{e=o},"accept")}),e!==void 0)return e;let r=new K,n=t.events.on(fe,o=>{o!==null&&typeof o=="object"&&"accept"in o&&typeof o.accept=="function"&&o.accept(r)});return t.on("session_start",()=>{r.clear()}),t.on("session_shutdown",()=>{r.clear(),n()}),r}i(tt,"connectResultTargets");export{_ as a,Se as b,ne as c,M as d,oe as e,se as f,q as g,ie as h,Oe as i,Ne as j,z as k,ce as l,Le as m,$e as n,b as o,B as p,J as q,ue as r,Y as s,w as t,$ as u,X as v,A as w,O as x,V as y,P as z,j as A,Q as B,Z as C,Xe as D,Qe as E,et as F,K as G,ge as H,tt as I};
|
package/dist/chunk-VCGNVTXQ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as A,e as R,f as w,h as g,i as U}from"./chunk-SQKAXYIR.js";import{a as y}from"./chunk-EI7MMDWY.js";import{Type as e}from"typebox";import{Value as D}from"typebox/value";var k=e.Union([e.Literal("pending"),e.Literal("applied"),e.Literal("not-applied"),e.Literal("unknown")]),F=e.Object({source:e.String(),effect:k,action:e.Optional(e.String()),state:e.Optional(e.Union([e.Literal("present"),e.Literal("absent"),e.Literal("unknown")]))},{additionalProperties:!1}),j=e.Object({id:e.String(),operation:e.String(),effect:k,errors:e.Array(A),status:e.Optional(e.Union([e.Literal("success"),e.Literal("error"),e.Literal("warning"),e.Literal("unknown")])),sources:e.Optional(e.Array(e.String())),warnings:e.Optional(e.Array(A))},{additionalProperties:!1}),I=e.Object({operation:e.String(),effect:k,operationId:e.Optional(e.String()),target:e.Optional(e.String({description:"Backend-owned resulting-text scope: replace/insert text, write's whole file, copy/move destinations, or undo's whole restored files. Delete never supplies a live target. Pending handles require a confirmed commit."})),targetUnavailable:e.Optional(e.String({description:"Why a completed mutation could not provide a safe resulting-text target. The write effect is reported separately."})),files:e.Array(F),changes:e.Optional(e.Array(e.Object({source:e.String(),from:e.Integer({description:"Inclusive zero-based UTF-16 offset in the pre-edit snapshot; not a live selector."}),to:e.Integer({description:"Exclusive zero-based UTF-16 offset in the pre-edit snapshot; not a live selector."}),removedText:e.String(),insertedText:e.String()},{additionalProperties:!1}))),changesUnavailable:e.Optional(e.String({description:"Why the exact change record is omitted; applied effects remain reported."})),operations:e.Optional(e.Array(j)),parentToolCallId:e.Optional(e.String()),recovery:e.Optional(e.Array(e.Object({source:e.String(),field:e.String(),anchor:e.String(),total:e.Integer(),candidates:e.Array(e.Object({rank:e.Integer(),range:e.Object({start:e.Object({lineNumber:e.Integer(),column:e.Integer()}),end:e.Object({lineNumber:e.Integer(),column:e.Integer()})})}))}))),action:e.Optional(e.Object({source:e.String(),kind:e.Optional(e.String()),status:e.Optional(e.String()),command:e.Optional(e.String()),deleted:e.Optional(e.Boolean()),session:e.Optional(e.String()),file:e.Optional(e.String()),line:e.Optional(e.Integer()),verified:e.Optional(e.Boolean()),evaluation:e.Optional(e.Object({expression:e.String(),result:e.String(),type:e.Optional(e.String()),variablesReference:e.Integer()},{additionalProperties:!1})),breakpoints:e.Optional(e.Array(e.Object({source:e.String(),file:e.String(),line:e.Integer(),verified:e.Boolean()},{additionalProperties:!1})))},{additionalProperties:!1}))},{additionalProperties:!1}),P=R(I);function s(l){return typeof l=="object"&&l!==null}y(s,"record");function N(l,p,S=[]){let o=l.details,d=s(o)?o:{},O=s(o)&&s(o.nativeEditBatch)?o.nativeEditBatch:void 0;if(O?.state==="accepted")return{status:"success",errors:[],data:{operation:p,effect:"pending",...typeof o.metadata?.resultTarget=="string"?{target:o.metadata.resultTarget}:{},files:typeof d.source=="string"?[{source:d.source,effect:"pending"}]:[],...typeof O.parentToolCallId=="string"?{parentToolCallId:O.parentToolCallId}:{}}};let m=new Set(S.map(r=>r.resourceSource)),a=[],u=[],v=o.results;for(let r of v??[]){let n=r.data,c=[...new Set([...(n.files??[]).map(i=>i.path),...n.path?[n.path]:[]])];for(let i of c)u.push({source:i,...m.has(i)?{state:"present"}:{},effect:m.has(i)||n.ok===!0&&n.files?.some(M=>M.path===i)?"applied":o.effect??"unknown"});for(let i of n.errors??[])a.push({code:i.code??"MUTATION_FAILED",message:i.reason??"Mutation failed",source:i.path});n.ok===!1&&(n.errors?.length??0)===0&&a.push({code:"MUTATION_FAILED",message:"Mutation failed",...n.path?{source:n.path}:{}})}for(let r of m)u.some(n=>n.source===r)||u.push({source:r,effect:"applied",state:"present"});let t=s(o.metadata)&&s(o.metadata.semanticAction)?o.metadata.semanticAction:void 0;if(t){let r=t.effect==="not-applied"||t.effect==="unknown"?t.effect:t.ok===!1?"unknown":"applied",n=typeof t.source=="string"?t.source:void 0;n&&u.push({source:n,...t.kind==="file-operation"&&t.ok===!0?{state:p==="delete"||p==="move"?"absent":"present"}:{},effect:p==="copy"&&typeof t.target=="string"&&t.target!==n?"not-applied":r}),typeof t.target=="string"&&u.push({source:t.target,effect:r,...t.kind==="file-operation"&&t.ok===!0?{state:"present"}:{}}),s(t.error)&&a.push(g(t.error.message,typeof t.error.code=="string"?t.error.code:"MUTATION_FAILED",n)),typeof t.postProcessingError=="string"&&a.push(g(t.postProcessingError,"POST_EDIT_FAILED",n)),t.ok===!1&&a.length===0&&a.push(g("Resource operation failed","MUTATION_FAILED",n))}let f=[...new Map(u.map(r=>[r.source,r])).values()];if(Array.isArray(o.metadata?.resultFileStates))for(let r of o.metadata.resultFileStates){if(!s(r))continue;let n=f.find(c=>c.source===r.source);n&&(r.state==="present"||r.state==="absent")&&(n.state=r.state)}let T=(v??[]).filter(r=>r.data.ok).flatMap(r=>{let n=r.data.path;return n===void 0?[]:(r.data.rawChanges??[]).map(c=>({source:n,from:c.fromA,to:c.toA,removedText:c.removedText,insertedText:c.insertedText}))}),x=Buffer.byteLength(JSON.stringify(T))<=w/2,E=f.some(r=>r.effect==="applied");l.isError&&a.length===0&&a.push({code:"MUTATION_FAILED",message:"Mutation failed"}),(v?.length??0)===0&&!t&&m.size===0&&a.length===0&&o.effect!=="not-applied"&&a.push({code:"UNKNOWN_RESULT",message:"Mutation effects were not reported"});let L=f.some(r=>r.effect==="unknown")||a.some(r=>r.code==="UNKNOWN_RESULT")?"unknown":E?"applied":"not-applied",h=t&&typeof t.source=="string"?{source:t.source,...typeof t.kind=="string"?{kind:t.kind}:{},...typeof t.status=="string"?{status:t.status}:{},...typeof t.command=="string"?{command:t.command}:{},...typeof t.deleted=="boolean"?{deleted:t.deleted}:{},...typeof t.session=="string"?{session:t.session}:{},...typeof t.file=="string"?{file:t.file}:{},...typeof t.line=="number"?{line:t.line}:{},...typeof t.verified=="boolean"?{verified:t.verified}:{},...s(t.evaluation)?{evaluation:{expression:t.evaluation.expression,result:t.evaluation.result,variablesReference:t.evaluation.variablesReference,...typeof t.evaluation.type=="string"?{type:t.evaluation.type}:{}}}:{},...Array.isArray(t.breakpoints)?{breakpoints:t.breakpoints.filter(s).map(r=>({source:r.source,file:r.file,line:r.line,verified:r.verified}))}:{}}:void 0,b=h&&D.Check(I.properties.action,h)?h:void 0;return h&&!b&&a.push(g("Action adapter returned invalid fields","INVALID_STRUCTURED_RESULT")),{status:a.length===0?"success":!t&&E&&f.some(r=>r.effect!=="applied")?"partial":"error",data:{operation:p,effect:L,files:f,...T.length===0?{}:x?{changes:T}:{changesUnavailable:"Exact change record exceeds the 512 KiB receipt budget; it was not clipped."},...typeof o.metadata?.resultTarget=="string"?{target:o.metadata.resultTarget}:{},...typeof o.metadata?.targetUnavailable=="string"?{targetUnavailable:o.metadata.targetUnavailable}:{},...o.anchorRecoveries===void 0?{}:{recovery:o.anchorRecoveries.map(r=>({source:r.path,field:r.field,anchor:r.anchor,total:r.total,candidates:[...r.candidates]}))},...b?{action:b}:{}},errors:a}}y(N,"mutationOutcome");function W(l,p,S=[],o){let d=N(l,p,S);return d.data&&o!==void 0&&(d.data.operationId=o),U(l,I,d)}y(W,"structuredMutation");export{I as a,P as b,N as c,W as d};
|