@xenosystem/agent-sdk 0.8.12

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.
Files changed (175) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +511 -0
  3. package/dist/agents/index.cjs +17 -0
  4. package/dist/agents/index.d.cts +244 -0
  5. package/dist/agents/index.d.ts +244 -0
  6. package/dist/agents/index.js +17 -0
  7. package/dist/agents/metafile-cjs.json +1 -0
  8. package/dist/agents/metafile-esm.json +1 -0
  9. package/dist/artifacts/browser.cjs +1 -0
  10. package/dist/artifacts/browser.d.cts +8 -0
  11. package/dist/artifacts/browser.d.ts +8 -0
  12. package/dist/artifacts/browser.js +1 -0
  13. package/dist/artifacts/diff-artifact-C2tQZWcs.d.cts +354 -0
  14. package/dist/artifacts/diff-artifact-C2tQZWcs.d.ts +354 -0
  15. package/dist/artifacts/index.cjs +10 -0
  16. package/dist/artifacts/index.d.cts +588 -0
  17. package/dist/artifacts/index.d.ts +588 -0
  18. package/dist/artifacts/index.js +10 -0
  19. package/dist/artifacts/metafile-cjs.json +1 -0
  20. package/dist/artifacts/metafile-esm.json +1 -0
  21. package/dist/automation/index.cjs +438 -0
  22. package/dist/automation/index.d.cts +878 -0
  23. package/dist/automation/index.d.ts +878 -0
  24. package/dist/automation/index.js +438 -0
  25. package/dist/automation/metafile-cjs.json +1 -0
  26. package/dist/automation/metafile-esm.json +1 -0
  27. package/dist/control-plane/index.cjs +7 -0
  28. package/dist/control-plane/index.d.cts +403 -0
  29. package/dist/control-plane/index.d.ts +403 -0
  30. package/dist/control-plane/index.js +7 -0
  31. package/dist/control-plane/metafile-cjs.json +1 -0
  32. package/dist/control-plane/metafile-esm.json +1 -0
  33. package/dist/control-room/index.cjs +1 -0
  34. package/dist/control-room/index.d.cts +216 -0
  35. package/dist/control-room/index.d.ts +216 -0
  36. package/dist/control-room/index.js +1 -0
  37. package/dist/control-room/metafile-cjs.json +1 -0
  38. package/dist/control-room/metafile-esm.json +1 -0
  39. package/dist/electron/index.cjs +1476 -0
  40. package/dist/electron/index.d.cts +1583 -0
  41. package/dist/electron/index.d.ts +1583 -0
  42. package/dist/electron/index.js +1476 -0
  43. package/dist/electron/metafile-cjs.json +1 -0
  44. package/dist/electron/metafile-esm.json +1 -0
  45. package/dist/governance/index.cjs +33 -0
  46. package/dist/governance/index.d.cts +397 -0
  47. package/dist/governance/index.d.ts +397 -0
  48. package/dist/governance/index.js +33 -0
  49. package/dist/governance/metafile-cjs.json +1 -0
  50. package/dist/governance/metafile-esm.json +1 -0
  51. package/dist/hooks/index.cjs +9 -0
  52. package/dist/hooks/index.d.cts +198 -0
  53. package/dist/hooks/index.d.ts +198 -0
  54. package/dist/hooks/index.js +9 -0
  55. package/dist/hooks/metafile-cjs.json +1 -0
  56. package/dist/hooks/metafile-esm.json +1 -0
  57. package/dist/hosted/index.cjs +1 -0
  58. package/dist/hosted/index.d.cts +490 -0
  59. package/dist/hosted/index.d.ts +490 -0
  60. package/dist/hosted/index.js +1 -0
  61. package/dist/hosted/metafile-cjs.json +1 -0
  62. package/dist/hosted/metafile-esm.json +1 -0
  63. package/dist/index.cjs +2161 -0
  64. package/dist/index.d.cts +12259 -0
  65. package/dist/index.d.ts +12259 -0
  66. package/dist/index.js +2161 -0
  67. package/dist/intelligence/index.cjs +10 -0
  68. package/dist/intelligence/index.d.cts +220 -0
  69. package/dist/intelligence/index.d.ts +220 -0
  70. package/dist/intelligence/index.js +10 -0
  71. package/dist/intelligence/metafile-cjs.json +1 -0
  72. package/dist/intelligence/metafile-esm.json +1 -0
  73. package/dist/mcp/index.cjs +28 -0
  74. package/dist/mcp/index.d.cts +960 -0
  75. package/dist/mcp/index.d.ts +960 -0
  76. package/dist/mcp/index.js +28 -0
  77. package/dist/mcp/metafile-cjs.json +1 -0
  78. package/dist/mcp/metafile-esm.json +1 -0
  79. package/dist/metafile-cjs.json +1 -0
  80. package/dist/metafile-esm.json +1 -0
  81. package/dist/oracle/index.cjs +1 -0
  82. package/dist/oracle/index.d.cts +310 -0
  83. package/dist/oracle/index.d.ts +310 -0
  84. package/dist/oracle/index.js +1 -0
  85. package/dist/oracle/metafile-cjs.json +1 -0
  86. package/dist/oracle/metafile-esm.json +1 -0
  87. package/dist/providers/index.cjs +11 -0
  88. package/dist/providers/index.d.cts +462 -0
  89. package/dist/providers/index.d.ts +462 -0
  90. package/dist/providers/index.js +11 -0
  91. package/dist/providers/metafile-cjs.json +1 -0
  92. package/dist/providers/metafile-esm.json +1 -0
  93. package/dist/recipes/index.cjs +2 -0
  94. package/dist/recipes/index.d.cts +86 -0
  95. package/dist/recipes/index.d.ts +86 -0
  96. package/dist/recipes/index.js +2 -0
  97. package/dist/recipes/metafile-cjs.json +1 -0
  98. package/dist/recipes/metafile-esm.json +1 -0
  99. package/dist/research/index.cjs +3 -0
  100. package/dist/research/index.d.cts +285 -0
  101. package/dist/research/index.d.ts +285 -0
  102. package/dist/research/index.js +3 -0
  103. package/dist/research/metafile-cjs.json +1 -0
  104. package/dist/research/metafile-esm.json +1 -0
  105. package/dist/session/index.cjs +56 -0
  106. package/dist/session/index.d.cts +523 -0
  107. package/dist/session/index.d.ts +523 -0
  108. package/dist/session/index.js +56 -0
  109. package/dist/session/metafile-cjs.json +1 -0
  110. package/dist/session/metafile-esm.json +1 -0
  111. package/dist/sharing/index.cjs +4 -0
  112. package/dist/sharing/index.d.cts +272 -0
  113. package/dist/sharing/index.d.ts +272 -0
  114. package/dist/sharing/index.js +4 -0
  115. package/dist/sharing/metafile-cjs.json +1 -0
  116. package/dist/sharing/metafile-esm.json +1 -0
  117. package/dist/skills/index.cjs +6 -0
  118. package/dist/skills/index.d.cts +277 -0
  119. package/dist/skills/index.d.ts +277 -0
  120. package/dist/skills/index.js +6 -0
  121. package/dist/skills/metafile-cjs.json +1 -0
  122. package/dist/skills/metafile-esm.json +1 -0
  123. package/dist/soul/index.cjs +32 -0
  124. package/dist/soul/index.d.cts +138 -0
  125. package/dist/soul/index.d.ts +138 -0
  126. package/dist/soul/index.js +32 -0
  127. package/dist/soul/metafile-cjs.json +1 -0
  128. package/dist/soul/metafile-esm.json +1 -0
  129. package/dist/terminal/index.cjs +4 -0
  130. package/dist/terminal/index.d.cts +55 -0
  131. package/dist/terminal/index.d.ts +55 -0
  132. package/dist/terminal/index.js +4 -0
  133. package/dist/terminal/metafile-cjs.json +1 -0
  134. package/dist/terminal/metafile-esm.json +1 -0
  135. package/dist/ui/index.cjs +35 -0
  136. package/dist/ui/index.d.cts +298 -0
  137. package/dist/ui/index.d.ts +298 -0
  138. package/dist/ui/index.js +35 -0
  139. package/dist/ui/metafile-cjs.json +1 -0
  140. package/dist/ui/metafile-esm.json +1 -0
  141. package/dist/utils/index.cjs +23 -0
  142. package/dist/utils/index.d.cts +245 -0
  143. package/dist/utils/index.d.ts +245 -0
  144. package/dist/utils/index.js +23 -0
  145. package/dist/utils/metafile-cjs.json +1 -0
  146. package/dist/utils/metafile-esm.json +1 -0
  147. package/native/mxc/LICENSE.microsoft-mxc-sdk.md +21 -0
  148. package/native/mxc/README.md +25 -0
  149. package/native/mxc/bin/arm64/lxc-exec +0 -0
  150. package/native/mxc/bin/arm64/mxc-exec-mac +0 -0
  151. package/native/mxc/bin/arm64/wxc-exec.exe +0 -0
  152. package/native/mxc/bin/arm64/wxc-host-prep.exe +0 -0
  153. package/native/mxc/bin/x64/lxc-exec +0 -0
  154. package/native/mxc/bin/x64/wxc-exec.exe +0 -0
  155. package/native/mxc/bin/x64/wxc-host-prep.exe +0 -0
  156. package/native/mxc/package.json +58 -0
  157. package/ownership/CLEAN_ROOM_CONTRIBUTOR_GUIDE.md +63 -0
  158. package/ownership/audit.mjs +727 -0
  159. package/ownership/evidence/PROPRIETARY-COMMAND-1/implementation-record.md +77 -0
  160. package/ownership/evidence/PROPRIETARY-COMMAND-1/provenance-review.md +51 -0
  161. package/ownership/evidence/PROPRIETARY-MEDIA-1/implementation-record.md +131 -0
  162. package/ownership/evidence/PROPRIETARY-MEDIA-1/provenance-review.md +50 -0
  163. package/ownership/evidence/PROPRIETARY-PTY-1/implementation-record.md +86 -0
  164. package/ownership/evidence/PROPRIETARY-PTY-1/provenance-review.md +52 -0
  165. package/ownership/evidence/PROPRIETARY-RUNTIME-1/implementation-record.md +68 -0
  166. package/ownership/evidence/PROPRIETARY-RUNTIME-1/provenance-review.md +32 -0
  167. package/ownership/evidence/PROPRIETARY-TOOLCHAIN-1/implementation-record.md +53 -0
  168. package/ownership/evidence/PROPRIETARY-TOOLCHAIN-1/provenance-review.md +32 -0
  169. package/ownership/evidence/PROPRIETARY-UI-1/implementation-record.md +96 -0
  170. package/ownership/evidence/PROPRIETARY-UI-1/provenance-review.md +46 -0
  171. package/ownership/ownership-policy.json +232 -0
  172. package/ownership/ownership-policy.schema.json +192 -0
  173. package/ownership/templates/clean-room-implementation-record.md +70 -0
  174. package/ownership/templates/provenance-review.md +51 -0
  175. package/package.json +209 -0
@@ -0,0 +1,3 @@
1
+ "use strict";var g=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var C=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},$=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of k(t))!T.call(e,o)&&o!==n&&g(e,o,{get:()=>t[o],enumerable:!(i=x(t,o))||i.enumerable});return e};var N=e=>$(g({},"__esModule",{value:!0}),e);var K={};C(K,{XENO_SOURCE_RESEARCH_SCHEMA_VERSION:()=>I,XenoSourceResearchValidationError:()=>c,assertValidXenoSourceResearchReport:()=>h,createXenoSourceResearchExcerpt:()=>D,createXenoSourceResearchReport:()=>O,normalizeSourceText:()=>l,xenoArtifactToSourceResearchReport:()=>L,xenoSourceResearchReportToArtifact:()=>F});module.exports=N(K);var A=require("node:crypto");var R=require("node:crypto");function s(e){return{algorithm:"sha256",value:(0,R.createHash)("sha256").update(e).digest("hex")}}function d(e){return JSON.stringify(v(e,new Set))}function f(e){return s(d(e))}function v(e,t){if(e===null||typeof e!="object"){if(typeof e=="number"&&!Number.isFinite(e))throw new TypeError("Artifact JSON cannot contain non-finite numbers");return e}if(t.has(e))throw new TypeError("Artifact JSON cannot contain cycles");if(t.add(e),Array.isArray(e)){let i=e.map(o=>v(o,t));return t.delete(e),i}let n={};for(let i of Object.keys(e).sort((o,r)=>o.localeCompare(r))){let o=e[i];if(o===void 0)throw new TypeError(`Artifact JSON property ${i} is undefined`);n[i]=v(o,t)}return t.delete(e),n}var V="[\\u0000-\\u001f\\u007f]",ne=new RegExp(V);var Ee=64*1024*1024;var ke=16*1024*1024;function X(e,t={}){for(let n of e){let i=n.codePointAt(0);if(i===127)return!0;if(!(i>31)&&!(i===9&&t.allowTab===!0)&&!((i===10||i===13)&&t.allowLineBreaks===!0))return!0}return!1}var I="xeno.source-research-report.v1",c=class extends Error{constructor(n){super(`XENO source-research report is invalid: ${n.join("; ")}`);this.issues=n;this.name="XenoSourceResearchValidationError"}issues;code="XENO_SOURCE_RESEARCH_INVALID"};function O(e){let t={schemaVersion:I,reportId:e.reportId??`research_${(0,A.randomUUID)()}`,runId:e.runId??`research_run_${(0,A.randomUUID)()}`,query:e.query.trim(),queryHash:_(e.query.trim()),repository:structuredClone(e.repository),collectedAt:e.collectedAt,completedAt:e.completedAt??new Date().toISOString(),model:structuredClone(e.model),files:structuredClone(e.files),excerpts:structuredClone(e.excerpts),answer:e.answer.trim(),answerExcerptIds:[...new Set(e.answerExcerptIds)],publicRationale:e.publicRationale.trim(),findings:structuredClone(e.findings),limitations:[...new Set((e.limitations??[]).map(n=>n.trim()).filter(Boolean))],usage:{inputTokens:S(e.usage?.inputTokens),outputTokens:S(e.usage?.outputTokens)}};return h(t),t}function D(e){return{excerptId:e.excerptId,path:e.path,startLine:e.startLine,endLine:e.endLine,text:l(e.text),contentHash:_(l(e.text)),sourceContentHash:structuredClone(e.sourceContentHash)}}function h(e){let t=[];e?.schemaVersion!==I&&t.push("schemaVersion must be xeno.source-research-report.v1"),p(e?.reportId,"reportId",t),p(e?.runId,"runId",t),a(e?.query,"query",t,128e3),m(e?.queryHash,"queryHash",t),typeof e?.query=="string"&&e.queryHash?.value!==s(e.query).value&&t.push("queryHash does not match query"),H(e?.repository,t),E(e?.collectedAt,"collectedAt",t),E(e?.completedAt,"completedAt",t),Date.parse(e?.completedAt)<Date.parse(e?.collectedAt)&&t.push("completedAt cannot precede collectedAt"),q(e?.model,t),a(e?.answer,"answer",t,512e3),a(e?.publicRationale,"publicRationale",t,256e3),J(e?.usage,t),(!Array.isArray(e?.files)||e.files.length<1||e.files.length>256)&&t.push("files must contain 1 through 256 source records");let n=new Map;for(let r of e?.files??[])M(r,t),n.has(r.path)&&t.push(`duplicate source file ${r.path}`),n.set(r.path,r);(!Array.isArray(e?.excerpts)||e.excerpts.length>1024)&&t.push("excerpts must contain at most 1024 records");let i=new Map;for(let r of e?.excerpts??[])j(r,n,t),i.has(r.excerptId)&&t.push(`duplicate excerpt ${r.excerptId}`),i.set(r.excerptId,r);(!Array.isArray(e?.answerExcerptIds)||e.answerExcerptIds.length<1)&&t.push("answerExcerptIds must cite at least one source excerpt");for(let r of e?.answerExcerptIds??[])i.has(r)||t.push(`answer references unknown excerpt ${r}`);(!Array.isArray(e?.findings)||e.findings.length>512)&&t.push("findings must contain at most 512 records");let o=new Set;for(let r of e?.findings??[]){p(r?.findingId,"findingId",t),o.has(r.findingId)&&t.push(`duplicate finding ${r.findingId}`),o.add(r.findingId),a(r?.title,`finding ${r.findingId} title`,t,2e3),a(r?.summary,`finding ${r.findingId} summary`,t,64e3),G(r?.severity)||t.push(`finding ${r.findingId} severity is invalid`),W(r?.confidence)||t.push(`finding ${r.findingId} confidence must be between 0 and 1`),(!Array.isArray(r?.excerptIds)||r.excerptIds.length<1)&&t.push(`finding ${r.findingId} requires source excerpts`);for(let w of r?.excerptIds??[])i.has(w)||t.push(`finding ${r.findingId} references unknown excerpt ${w}`)}(!Array.isArray(e?.limitations)||e.limitations.length>256)&&t.push("limitations must contain at most 256 records");for(let r of e?.limitations??[])a(r,"limitation",t,16e3);if(t.length>0)throw new c([...new Set(t)])}function F(e,t){h(e);let n=t.createdAt??e.completedAt,i=d(e);return{schemaVersion:1,artifactId:t.artifactId??`research_${s(`${e.runId}:${e.repository.commit}:${e.queryHash.value}`).value.slice(0,24)}`,revision:1,kind:"custom:source-research-report",title:`Source research: ${e.repository.repository}`,description:e.answer.slice(0,1e3),state:"pending_review",createdAt:n,mediaType:"application/vnd.xeno.source-research-report+json",sensitivity:t.sensitivity??"internal",identity:{...t.identity,runId:t.identity?.runId??e.runId,repositoryId:t.identity?.repositoryId??`${e.repository.provider}:${e.repository.repository}`},content:{hash:f(e),sizeBytes:Buffer.byteLength(i,"utf8"),storage:{type:"inline",text:i},encoding:"utf8",redactedPreview:e.answer.slice(0,2e3)},provenance:{producer:structuredClone(t.producer),attributes:{"xeno.research.provider":e.repository.provider,"xeno.research.repository":e.repository.repository,"xeno.research.commit":e.repository.commit,"xeno.research.model":`${e.model.providerId}/${e.model.model}`,"xeno.research.fileCount":e.files.length,"xeno.research.findingCount":e.findings.length}},anchors:e.excerpts.map(o=>({kind:"source-line",path:o.path,startLine:o.startLine,endLine:o.endLine,repositoryId:`${e.repository.provider}:${e.repository.repository}`,commit:e.repository.commit}))}}function L(e){if(e.kind!=="custom:source-research-report"||e.mediaType!=="application/vnd.xeno.source-research-report+json")throw new c([`Artifact ${e.artifactId} is not a source-research report`]);if(e.content.storage.type!=="inline"||typeof e.content.storage.text!="string")throw new c(["Source-research reports require inline JSON content"]);let t;try{t=JSON.parse(e.content.storage.text)}catch{throw new c(["Source-research artifact content is invalid JSON"])}if(h(t),f(t).value!==e.content.hash.value)throw new c(["Source-research content hash does not match the artifact"]);return structuredClone(t)}function l(e){return e.replace(/\r\n?/gu,`
2
+ `)}function H(e,t){e?.provider!=="github"&&e?.provider!=="gitlab"&&t.push("repository provider must be github or gitlab"),B(e?.host,"repository host",t),z(e?.repository,t),a(e?.ref,"repository ref",t,512),(typeof e?.commit!="string"||!/^[a-f0-9]{7,64}$/u.test(e.commit))&&t.push("repository commit must be a lowercase hexadecimal object ID"),U(e?.url,"repository url",t)}function M(e,t){b(e?.path,"source file path",t),m(e?.contentHash,`source file ${e?.path} contentHash`,t),(!Number.isSafeInteger(e?.sizeBytes)||e.sizeBytes<0||e.sizeBytes>8*1024*1024)&&t.push(`source file ${e?.path} sizeBytes is invalid`),(!Number.isSafeInteger(e?.lineCount)||e.lineCount<1||e.lineCount>1e6)&&t.push(`source file ${e?.path} lineCount is invalid`),e?.blobId!==void 0&&a(e.blobId,`source file ${e.path} blobId`,t,256),e?.language!==void 0&&a(e.language,`source file ${e.path} language`,t,128)}function j(e,t,n){p(e?.excerptId,"excerptId",n),b(e?.path,`excerpt ${e?.excerptId} path`,n);let i=t.get(e?.path);i||n.push(`excerpt ${e?.excerptId} references unknown source file ${e?.path}`),(!Number.isSafeInteger(e?.startLine)||e.startLine<1)&&n.push(`excerpt ${e?.excerptId} startLine is invalid`),(!Number.isSafeInteger(e?.endLine)||e.endLine<e.startLine)&&n.push(`excerpt ${e?.excerptId} endLine is invalid`),i&&e.endLine>i.lineCount&&n.push(`excerpt ${e?.excerptId} exceeds source line count`),a(e?.text,`excerpt ${e?.excerptId} text`,n,256e3),m(e?.contentHash,`excerpt ${e?.excerptId} contentHash`,n),m(e?.sourceContentHash,`excerpt ${e?.excerptId} sourceContentHash`,n);let o=typeof e?.text=="string"?l(e.text):"";e?.contentHash?.value!==s(o).value&&n.push(`excerpt ${e?.excerptId} contentHash does not match text`),i&&e?.sourceContentHash?.value!==i.contentHash.value&&n.push(`excerpt ${e?.excerptId} is bound to a different source hash`),o&&o.split(`
3
+ `).length!==e.endLine-e.startLine+1&&n.push(`excerpt ${e?.excerptId} line span does not match text`)}function q(e,t){p(e?.providerId,"model providerId",t),a(e?.model,"model",t,512),e?.connectionId!==void 0&&p(e.connectionId,"model connectionId",t)}function J(e,t){(!Number.isSafeInteger(e?.inputTokens)||e.inputTokens<0)&&t.push("usage.inputTokens must be a non-negative integer"),(!Number.isSafeInteger(e?.outputTokens)||e.outputTokens<0)&&t.push("usage.outputTokens must be a non-negative integer")}function m(e,t,n){(e?.algorithm!=="sha256"||!/^[a-f0-9]{64}$/u.test(e?.value??""))&&n.push(`${t} must be a lowercase SHA-256 digest`)}function p(e,t,n){(typeof e!="string"||!/^[A-Za-z0-9][A-Za-z0-9._:@/-]{0,255}$/u.test(e))&&n.push(`${t} is invalid`)}function a(e,t,n,i){(typeof e!="string"||!e.trim()||e.length>i||X(e,{allowTab:!0,allowLineBreaks:!0}))&&n.push(`${t} must be non-empty bounded text`)}function E(e,t,n){(typeof e!="string"||!Number.isFinite(Date.parse(e))||new Date(e).toISOString()!==e)&&n.push(`${t} must be an ISO-8601 UTC timestamp`)}function B(e,t,n){(typeof e!="string"||e.length>253||!/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/u.test(e))&&n.push(`${t} is invalid`)}function z(e,t){(typeof e!="string"||e.length>2048||e.startsWith("/")||e.endsWith("/")||e.split("/").some(n=>!n||n==="."||n===".."))&&t.push("repository name is invalid")}function b(e,t,n){(typeof e!="string"||e.length>4096||e.startsWith("/")||/^[A-Za-z]:[\\/]/u.test(e)||e.includes("\\")||e.split("/").some(i=>!i||i==="."||i===".."))&&n.push(`${t} must be repository-relative`)}function U(e,t,n){try{let i=new URL(String(e));(i.protocol!=="https:"||i.username||i.password)&&n.push(`${t} must be credential-free HTTPS`)}catch{n.push(`${t} is invalid`)}}function S(e){return Number.isSafeInteger(e)&&(e??-1)>=0?e:0}function _(e){return{algorithm:"sha256",value:s(e).value}}function W(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1}function G(e){return e==="info"||e==="low"||e==="medium"||e==="high"||e==="critical"}0&&(module.exports={XENO_SOURCE_RESEARCH_SCHEMA_VERSION,XenoSourceResearchValidationError,assertValidXenoSourceResearchReport,createXenoSourceResearchExcerpt,createXenoSourceResearchReport,normalizeSourceText,xenoArtifactToSourceResearchReport,xenoSourceResearchReportToArtifact});
@@ -0,0 +1,285 @@
1
+ declare const XENO_ARTIFACT_SCHEMA_VERSION: 1;
2
+ type XenoJsonPrimitive = string | number | boolean | null;
3
+ type XenoJsonValue = XenoJsonPrimitive | XenoJsonObject | XenoJsonValue[];
4
+ interface XenoJsonObject {
5
+ [key: string]: XenoJsonValue;
6
+ }
7
+ type XenoArtifactKind = "plan" | "requirements" | "design" | "task-graph" | "patch" | "diff" | "file" | "document" | "diagram" | "screenshot" | "recording" | "browser-snapshot" | "test-report" | "review-report" | "security-report" | "performance-report" | "release-report" | "sbom" | "provenance" | "attestation" | `custom:${string}`;
8
+ type XenoArtifactState = "draft" | "pending_review" | "approved" | "rejected" | "superseded" | "archived";
9
+ type XenoArtifactSensitivity = "public" | "internal" | "confidential" | "restricted";
10
+ interface XenoContentHash {
11
+ algorithm: "sha256" | `custom:${string}`;
12
+ value: string;
13
+ }
14
+ type XenoArtifactStorageReference = {
15
+ type: "inline";
16
+ text?: string;
17
+ base64?: string;
18
+ } | {
19
+ type: "file";
20
+ path: string;
21
+ } | {
22
+ type: "blob";
23
+ uri: string;
24
+ } | {
25
+ type: "git";
26
+ commit: string;
27
+ path: string;
28
+ repositoryId?: string;
29
+ } | {
30
+ type: "url";
31
+ url: string;
32
+ expiresAt?: string;
33
+ } | {
34
+ type: "external";
35
+ provider: string;
36
+ locator: string;
37
+ };
38
+ interface XenoArtifactContent {
39
+ hash: XenoContentHash;
40
+ sizeBytes: number;
41
+ storage: XenoArtifactStorageReference;
42
+ encoding?: "utf8" | "base64" | "binary" | `custom:${string}`;
43
+ redactedPreview?: string;
44
+ }
45
+ interface XenoArtifactIdentity {
46
+ runId?: string;
47
+ sessionId?: string;
48
+ turnId?: string;
49
+ taskId?: string;
50
+ agentId?: string;
51
+ workspaceId?: string;
52
+ repositoryId?: string;
53
+ }
54
+ type XenoArtifactActorKind = "agent" | "tool" | "user" | "system" | "integration";
55
+ interface XenoArtifactActor {
56
+ kind: XenoArtifactActorKind;
57
+ id: string;
58
+ displayName?: string;
59
+ profileFingerprint?: string;
60
+ }
61
+ interface XenoArtifactProvenance {
62
+ producer: XenoArtifactActor;
63
+ eventId?: string;
64
+ toolCallId?: string;
65
+ operationId?: string;
66
+ executionContractFingerprint?: string;
67
+ capabilityLeaseIds?: string[];
68
+ sourceArtifactIds?: string[];
69
+ attributes?: XenoJsonObject;
70
+ }
71
+ type XenoEvidenceNodeType = "requirement" | "design-decision" | "risk" | "task" | "agent" | "run" | "tool-call" | "edit" | "commit" | "test-case" | "test-run" | "finding" | "approval" | "artifact" | "release" | "claim" | `custom:${string}`;
72
+ type XenoEvidenceEdgeType = "decomposes" | "depends_on" | "implements" | "changes" | "tests" | "verifies" | "finds" | "fixes" | "reviews" | "approves" | "rejects" | "supersedes" | "derived_from" | "produced_by" | "supports_claim" | "contradicts_claim" | "released_as" | `custom:${string}`;
73
+ interface XenoEvidenceReference {
74
+ type: XenoEvidenceNodeType;
75
+ id: string;
76
+ revision?: number;
77
+ }
78
+ interface XenoArtifactRelationship {
79
+ relation: XenoEvidenceEdgeType;
80
+ target: XenoEvidenceReference;
81
+ description?: string;
82
+ attributes?: XenoJsonObject;
83
+ }
84
+ type XenoArtifactAnchor = {
85
+ kind: "file";
86
+ path: string;
87
+ repositoryId?: string;
88
+ commit?: string;
89
+ } | {
90
+ kind: "source-line";
91
+ path: string;
92
+ startLine: number;
93
+ endLine?: number;
94
+ repositoryId?: string;
95
+ commit?: string;
96
+ } | {
97
+ kind: "diff-hunk";
98
+ path: string;
99
+ hunkId: string;
100
+ artifactId?: string;
101
+ revision?: number;
102
+ } | {
103
+ kind: "symbol";
104
+ path: string;
105
+ symbol: string;
106
+ repositoryId?: string;
107
+ commit?: string;
108
+ } | {
109
+ kind: "dom-node";
110
+ pageId: string;
111
+ selector?: string;
112
+ accessibilityId?: string;
113
+ snapshotArtifactId?: string;
114
+ } | {
115
+ kind: "timeline";
116
+ startMs: number;
117
+ endMs?: number;
118
+ recordingArtifactId: string;
119
+ } | {
120
+ kind: "region";
121
+ x: number;
122
+ y: number;
123
+ width: number;
124
+ height: number;
125
+ mediaArtifactId: string;
126
+ } | {
127
+ kind: "artifact";
128
+ artifactId: string;
129
+ revision?: number;
130
+ } | {
131
+ kind: `custom:${string}`;
132
+ data: XenoJsonObject;
133
+ };
134
+ interface XenoArtifactRetention {
135
+ policyId?: string;
136
+ retainUntil?: string;
137
+ legalHold?: boolean;
138
+ }
139
+ interface XenoArtifactEnvelope {
140
+ schemaVersion: typeof XENO_ARTIFACT_SCHEMA_VERSION;
141
+ artifactId: string;
142
+ revision: number;
143
+ kind: XenoArtifactKind;
144
+ title: string;
145
+ description?: string;
146
+ state: XenoArtifactState;
147
+ createdAt: string;
148
+ updatedAt?: string;
149
+ mediaType: string;
150
+ sensitivity: XenoArtifactSensitivity;
151
+ identity?: XenoArtifactIdentity;
152
+ content: XenoArtifactContent;
153
+ provenance: XenoArtifactProvenance;
154
+ relationships?: XenoArtifactRelationship[];
155
+ anchors?: XenoArtifactAnchor[];
156
+ predecessorRevision?: number;
157
+ accessPolicyId?: string;
158
+ retention?: XenoArtifactRetention;
159
+ extensions?: Record<string, XenoJsonValue>;
160
+ }
161
+ declare const XENO_SOURCE_RESEARCH_SCHEMA_VERSION: "xeno.source-research-report.v1";
162
+ type XenoRemoteSourceProvider = "github" | "gitlab";
163
+ type XenoSourceResearchSeverity = "info" | "low" | "medium" | "high" | "critical";
164
+ interface XenoRemoteRepositoryIdentity {
165
+ provider: XenoRemoteSourceProvider;
166
+ host: string;
167
+ repository: string;
168
+ ref: string;
169
+ commit: string;
170
+ url: string;
171
+ }
172
+ interface XenoRemoteSourceFile {
173
+ path: string;
174
+ contentHash: {
175
+ algorithm: "sha256";
176
+ value: string;
177
+ };
178
+ sizeBytes: number;
179
+ lineCount: number;
180
+ blobId?: string;
181
+ language?: string;
182
+ truncated?: boolean;
183
+ }
184
+ interface XenoSourceResearchExcerpt {
185
+ excerptId: string;
186
+ path: string;
187
+ startLine: number;
188
+ endLine: number;
189
+ text: string;
190
+ contentHash: {
191
+ algorithm: "sha256";
192
+ value: string;
193
+ };
194
+ sourceContentHash: {
195
+ algorithm: "sha256";
196
+ value: string;
197
+ };
198
+ }
199
+ interface XenoSourceResearchFinding {
200
+ findingId: string;
201
+ title: string;
202
+ summary: string;
203
+ severity: XenoSourceResearchSeverity;
204
+ confidence: number;
205
+ excerptIds: string[];
206
+ }
207
+ interface XenoSourceResearchModelIdentity {
208
+ providerId: string;
209
+ model: string;
210
+ connectionId?: string;
211
+ }
212
+ interface XenoSourceResearchReport {
213
+ schemaVersion: typeof XENO_SOURCE_RESEARCH_SCHEMA_VERSION;
214
+ reportId: string;
215
+ runId: string;
216
+ query: string;
217
+ queryHash: {
218
+ algorithm: "sha256";
219
+ value: string;
220
+ };
221
+ repository: XenoRemoteRepositoryIdentity;
222
+ collectedAt: string;
223
+ completedAt: string;
224
+ model: XenoSourceResearchModelIdentity;
225
+ files: XenoRemoteSourceFile[];
226
+ excerpts: XenoSourceResearchExcerpt[];
227
+ answer: string;
228
+ answerExcerptIds: string[];
229
+ publicRationale: string;
230
+ findings: XenoSourceResearchFinding[];
231
+ limitations: string[];
232
+ usage: {
233
+ inputTokens: number;
234
+ outputTokens: number;
235
+ };
236
+ }
237
+ interface CreateXenoSourceResearchReportInput {
238
+ reportId?: string;
239
+ runId?: string;
240
+ query: string;
241
+ repository: XenoRemoteRepositoryIdentity;
242
+ collectedAt: string;
243
+ completedAt?: string;
244
+ model: XenoSourceResearchModelIdentity;
245
+ files: XenoRemoteSourceFile[];
246
+ excerpts: XenoSourceResearchExcerpt[];
247
+ answer: string;
248
+ answerExcerptIds: string[];
249
+ publicRationale: string;
250
+ findings: XenoSourceResearchFinding[];
251
+ limitations?: string[];
252
+ usage?: {
253
+ inputTokens?: number;
254
+ outputTokens?: number;
255
+ };
256
+ }
257
+ interface XenoSourceResearchArtifactContext {
258
+ artifactId?: string;
259
+ producer: XenoArtifactActor;
260
+ identity?: XenoArtifactIdentity;
261
+ sensitivity?: XenoArtifactSensitivity;
262
+ createdAt?: string;
263
+ }
264
+ declare class XenoSourceResearchValidationError extends Error {
265
+ readonly issues: string[];
266
+ readonly code = "XENO_SOURCE_RESEARCH_INVALID";
267
+ constructor(issues: string[]);
268
+ }
269
+ declare function createXenoSourceResearchReport(input: CreateXenoSourceResearchReportInput): XenoSourceResearchReport;
270
+ declare function createXenoSourceResearchExcerpt(input: {
271
+ excerptId: string;
272
+ path: string;
273
+ startLine: number;
274
+ endLine: number;
275
+ text: string;
276
+ sourceContentHash: {
277
+ algorithm: "sha256";
278
+ value: string;
279
+ };
280
+ }): XenoSourceResearchExcerpt;
281
+ declare function assertValidXenoSourceResearchReport(report: XenoSourceResearchReport): void;
282
+ declare function xenoSourceResearchReportToArtifact(report: XenoSourceResearchReport, context: XenoSourceResearchArtifactContext): XenoArtifactEnvelope;
283
+ declare function xenoArtifactToSourceResearchReport(artifact: XenoArtifactEnvelope): XenoSourceResearchReport;
284
+ declare function normalizeSourceText(value: string): string;
285
+ export { type CreateXenoSourceResearchReportInput, XENO_SOURCE_RESEARCH_SCHEMA_VERSION, type XenoRemoteRepositoryIdentity, type XenoRemoteSourceFile, type XenoRemoteSourceProvider, type XenoSourceResearchArtifactContext, type XenoSourceResearchExcerpt, type XenoSourceResearchFinding, type XenoSourceResearchModelIdentity, type XenoSourceResearchReport, type XenoSourceResearchSeverity, XenoSourceResearchValidationError, assertValidXenoSourceResearchReport, createXenoSourceResearchExcerpt, createXenoSourceResearchReport, normalizeSourceText, xenoArtifactToSourceResearchReport, xenoSourceResearchReportToArtifact };
@@ -0,0 +1,285 @@
1
+ declare const XENO_ARTIFACT_SCHEMA_VERSION: 1;
2
+ type XenoJsonPrimitive = string | number | boolean | null;
3
+ type XenoJsonValue = XenoJsonPrimitive | XenoJsonObject | XenoJsonValue[];
4
+ interface XenoJsonObject {
5
+ [key: string]: XenoJsonValue;
6
+ }
7
+ type XenoArtifactKind = "plan" | "requirements" | "design" | "task-graph" | "patch" | "diff" | "file" | "document" | "diagram" | "screenshot" | "recording" | "browser-snapshot" | "test-report" | "review-report" | "security-report" | "performance-report" | "release-report" | "sbom" | "provenance" | "attestation" | `custom:${string}`;
8
+ type XenoArtifactState = "draft" | "pending_review" | "approved" | "rejected" | "superseded" | "archived";
9
+ type XenoArtifactSensitivity = "public" | "internal" | "confidential" | "restricted";
10
+ interface XenoContentHash {
11
+ algorithm: "sha256" | `custom:${string}`;
12
+ value: string;
13
+ }
14
+ type XenoArtifactStorageReference = {
15
+ type: "inline";
16
+ text?: string;
17
+ base64?: string;
18
+ } | {
19
+ type: "file";
20
+ path: string;
21
+ } | {
22
+ type: "blob";
23
+ uri: string;
24
+ } | {
25
+ type: "git";
26
+ commit: string;
27
+ path: string;
28
+ repositoryId?: string;
29
+ } | {
30
+ type: "url";
31
+ url: string;
32
+ expiresAt?: string;
33
+ } | {
34
+ type: "external";
35
+ provider: string;
36
+ locator: string;
37
+ };
38
+ interface XenoArtifactContent {
39
+ hash: XenoContentHash;
40
+ sizeBytes: number;
41
+ storage: XenoArtifactStorageReference;
42
+ encoding?: "utf8" | "base64" | "binary" | `custom:${string}`;
43
+ redactedPreview?: string;
44
+ }
45
+ interface XenoArtifactIdentity {
46
+ runId?: string;
47
+ sessionId?: string;
48
+ turnId?: string;
49
+ taskId?: string;
50
+ agentId?: string;
51
+ workspaceId?: string;
52
+ repositoryId?: string;
53
+ }
54
+ type XenoArtifactActorKind = "agent" | "tool" | "user" | "system" | "integration";
55
+ interface XenoArtifactActor {
56
+ kind: XenoArtifactActorKind;
57
+ id: string;
58
+ displayName?: string;
59
+ profileFingerprint?: string;
60
+ }
61
+ interface XenoArtifactProvenance {
62
+ producer: XenoArtifactActor;
63
+ eventId?: string;
64
+ toolCallId?: string;
65
+ operationId?: string;
66
+ executionContractFingerprint?: string;
67
+ capabilityLeaseIds?: string[];
68
+ sourceArtifactIds?: string[];
69
+ attributes?: XenoJsonObject;
70
+ }
71
+ type XenoEvidenceNodeType = "requirement" | "design-decision" | "risk" | "task" | "agent" | "run" | "tool-call" | "edit" | "commit" | "test-case" | "test-run" | "finding" | "approval" | "artifact" | "release" | "claim" | `custom:${string}`;
72
+ type XenoEvidenceEdgeType = "decomposes" | "depends_on" | "implements" | "changes" | "tests" | "verifies" | "finds" | "fixes" | "reviews" | "approves" | "rejects" | "supersedes" | "derived_from" | "produced_by" | "supports_claim" | "contradicts_claim" | "released_as" | `custom:${string}`;
73
+ interface XenoEvidenceReference {
74
+ type: XenoEvidenceNodeType;
75
+ id: string;
76
+ revision?: number;
77
+ }
78
+ interface XenoArtifactRelationship {
79
+ relation: XenoEvidenceEdgeType;
80
+ target: XenoEvidenceReference;
81
+ description?: string;
82
+ attributes?: XenoJsonObject;
83
+ }
84
+ type XenoArtifactAnchor = {
85
+ kind: "file";
86
+ path: string;
87
+ repositoryId?: string;
88
+ commit?: string;
89
+ } | {
90
+ kind: "source-line";
91
+ path: string;
92
+ startLine: number;
93
+ endLine?: number;
94
+ repositoryId?: string;
95
+ commit?: string;
96
+ } | {
97
+ kind: "diff-hunk";
98
+ path: string;
99
+ hunkId: string;
100
+ artifactId?: string;
101
+ revision?: number;
102
+ } | {
103
+ kind: "symbol";
104
+ path: string;
105
+ symbol: string;
106
+ repositoryId?: string;
107
+ commit?: string;
108
+ } | {
109
+ kind: "dom-node";
110
+ pageId: string;
111
+ selector?: string;
112
+ accessibilityId?: string;
113
+ snapshotArtifactId?: string;
114
+ } | {
115
+ kind: "timeline";
116
+ startMs: number;
117
+ endMs?: number;
118
+ recordingArtifactId: string;
119
+ } | {
120
+ kind: "region";
121
+ x: number;
122
+ y: number;
123
+ width: number;
124
+ height: number;
125
+ mediaArtifactId: string;
126
+ } | {
127
+ kind: "artifact";
128
+ artifactId: string;
129
+ revision?: number;
130
+ } | {
131
+ kind: `custom:${string}`;
132
+ data: XenoJsonObject;
133
+ };
134
+ interface XenoArtifactRetention {
135
+ policyId?: string;
136
+ retainUntil?: string;
137
+ legalHold?: boolean;
138
+ }
139
+ interface XenoArtifactEnvelope {
140
+ schemaVersion: typeof XENO_ARTIFACT_SCHEMA_VERSION;
141
+ artifactId: string;
142
+ revision: number;
143
+ kind: XenoArtifactKind;
144
+ title: string;
145
+ description?: string;
146
+ state: XenoArtifactState;
147
+ createdAt: string;
148
+ updatedAt?: string;
149
+ mediaType: string;
150
+ sensitivity: XenoArtifactSensitivity;
151
+ identity?: XenoArtifactIdentity;
152
+ content: XenoArtifactContent;
153
+ provenance: XenoArtifactProvenance;
154
+ relationships?: XenoArtifactRelationship[];
155
+ anchors?: XenoArtifactAnchor[];
156
+ predecessorRevision?: number;
157
+ accessPolicyId?: string;
158
+ retention?: XenoArtifactRetention;
159
+ extensions?: Record<string, XenoJsonValue>;
160
+ }
161
+ declare const XENO_SOURCE_RESEARCH_SCHEMA_VERSION: "xeno.source-research-report.v1";
162
+ type XenoRemoteSourceProvider = "github" | "gitlab";
163
+ type XenoSourceResearchSeverity = "info" | "low" | "medium" | "high" | "critical";
164
+ interface XenoRemoteRepositoryIdentity {
165
+ provider: XenoRemoteSourceProvider;
166
+ host: string;
167
+ repository: string;
168
+ ref: string;
169
+ commit: string;
170
+ url: string;
171
+ }
172
+ interface XenoRemoteSourceFile {
173
+ path: string;
174
+ contentHash: {
175
+ algorithm: "sha256";
176
+ value: string;
177
+ };
178
+ sizeBytes: number;
179
+ lineCount: number;
180
+ blobId?: string;
181
+ language?: string;
182
+ truncated?: boolean;
183
+ }
184
+ interface XenoSourceResearchExcerpt {
185
+ excerptId: string;
186
+ path: string;
187
+ startLine: number;
188
+ endLine: number;
189
+ text: string;
190
+ contentHash: {
191
+ algorithm: "sha256";
192
+ value: string;
193
+ };
194
+ sourceContentHash: {
195
+ algorithm: "sha256";
196
+ value: string;
197
+ };
198
+ }
199
+ interface XenoSourceResearchFinding {
200
+ findingId: string;
201
+ title: string;
202
+ summary: string;
203
+ severity: XenoSourceResearchSeverity;
204
+ confidence: number;
205
+ excerptIds: string[];
206
+ }
207
+ interface XenoSourceResearchModelIdentity {
208
+ providerId: string;
209
+ model: string;
210
+ connectionId?: string;
211
+ }
212
+ interface XenoSourceResearchReport {
213
+ schemaVersion: typeof XENO_SOURCE_RESEARCH_SCHEMA_VERSION;
214
+ reportId: string;
215
+ runId: string;
216
+ query: string;
217
+ queryHash: {
218
+ algorithm: "sha256";
219
+ value: string;
220
+ };
221
+ repository: XenoRemoteRepositoryIdentity;
222
+ collectedAt: string;
223
+ completedAt: string;
224
+ model: XenoSourceResearchModelIdentity;
225
+ files: XenoRemoteSourceFile[];
226
+ excerpts: XenoSourceResearchExcerpt[];
227
+ answer: string;
228
+ answerExcerptIds: string[];
229
+ publicRationale: string;
230
+ findings: XenoSourceResearchFinding[];
231
+ limitations: string[];
232
+ usage: {
233
+ inputTokens: number;
234
+ outputTokens: number;
235
+ };
236
+ }
237
+ interface CreateXenoSourceResearchReportInput {
238
+ reportId?: string;
239
+ runId?: string;
240
+ query: string;
241
+ repository: XenoRemoteRepositoryIdentity;
242
+ collectedAt: string;
243
+ completedAt?: string;
244
+ model: XenoSourceResearchModelIdentity;
245
+ files: XenoRemoteSourceFile[];
246
+ excerpts: XenoSourceResearchExcerpt[];
247
+ answer: string;
248
+ answerExcerptIds: string[];
249
+ publicRationale: string;
250
+ findings: XenoSourceResearchFinding[];
251
+ limitations?: string[];
252
+ usage?: {
253
+ inputTokens?: number;
254
+ outputTokens?: number;
255
+ };
256
+ }
257
+ interface XenoSourceResearchArtifactContext {
258
+ artifactId?: string;
259
+ producer: XenoArtifactActor;
260
+ identity?: XenoArtifactIdentity;
261
+ sensitivity?: XenoArtifactSensitivity;
262
+ createdAt?: string;
263
+ }
264
+ declare class XenoSourceResearchValidationError extends Error {
265
+ readonly issues: string[];
266
+ readonly code = "XENO_SOURCE_RESEARCH_INVALID";
267
+ constructor(issues: string[]);
268
+ }
269
+ declare function createXenoSourceResearchReport(input: CreateXenoSourceResearchReportInput): XenoSourceResearchReport;
270
+ declare function createXenoSourceResearchExcerpt(input: {
271
+ excerptId: string;
272
+ path: string;
273
+ startLine: number;
274
+ endLine: number;
275
+ text: string;
276
+ sourceContentHash: {
277
+ algorithm: "sha256";
278
+ value: string;
279
+ };
280
+ }): XenoSourceResearchExcerpt;
281
+ declare function assertValidXenoSourceResearchReport(report: XenoSourceResearchReport): void;
282
+ declare function xenoSourceResearchReportToArtifact(report: XenoSourceResearchReport, context: XenoSourceResearchArtifactContext): XenoArtifactEnvelope;
283
+ declare function xenoArtifactToSourceResearchReport(artifact: XenoArtifactEnvelope): XenoSourceResearchReport;
284
+ declare function normalizeSourceText(value: string): string;
285
+ export { type CreateXenoSourceResearchReportInput, XENO_SOURCE_RESEARCH_SCHEMA_VERSION, type XenoRemoteRepositoryIdentity, type XenoRemoteSourceFile, type XenoRemoteSourceProvider, type XenoSourceResearchArtifactContext, type XenoSourceResearchExcerpt, type XenoSourceResearchFinding, type XenoSourceResearchModelIdentity, type XenoSourceResearchReport, type XenoSourceResearchSeverity, XenoSourceResearchValidationError, assertValidXenoSourceResearchReport, createXenoSourceResearchExcerpt, createXenoSourceResearchReport, normalizeSourceText, xenoArtifactToSourceResearchReport, xenoSourceResearchReportToArtifact };
@@ -0,0 +1,3 @@
1
+ import{randomUUID as I}from"node:crypto";import{createHash as b}from"node:crypto";function s(e){return{algorithm:"sha256",value:b("sha256").update(e).digest("hex")}}function c(e){return JSON.stringify(m(e,new Set))}function d(e){return s(c(e))}function m(e,t){if(e===null||typeof e!="object"){if(typeof e=="number"&&!Number.isFinite(e))throw new TypeError("Artifact JSON cannot contain non-finite numbers");return e}if(t.has(e))throw new TypeError("Artifact JSON cannot contain cycles");if(t.add(e),Array.isArray(e)){let r=e.map(o=>m(o,t));return t.delete(e),r}let n={};for(let r of Object.keys(e).sort((o,i)=>o.localeCompare(i))){let o=e[r];if(o===void 0)throw new TypeError(`Artifact JSON property ${r} is undefined`);n[r]=m(o,t)}return t.delete(e),n}var _="[\\u0000-\\u001f\\u007f]",J=new RegExp(_);var pe=64*1024*1024;var ve=16*1024*1024;function A(e,t={}){for(let n of e){let r=n.codePointAt(0);if(r===127)return!0;if(!(r>31)&&!(r===9&&t.allowTab===!0)&&!((r===10||r===13)&&t.allowLineBreaks===!0))return!0}return!1}var X="xeno.source-research-report.v1",f=class extends Error{constructor(n){super(`XENO source-research report is invalid: ${n.join("; ")}`);this.issues=n;this.name="XenoSourceResearchValidationError"}issues;code="XENO_SOURCE_RESEARCH_INVALID"};function et(e){let t={schemaVersion:X,reportId:e.reportId??`research_${I()}`,runId:e.runId??`research_run_${I()}`,query:e.query.trim(),queryHash:S(e.query.trim()),repository:structuredClone(e.repository),collectedAt:e.collectedAt,completedAt:e.completedAt??new Date().toISOString(),model:structuredClone(e.model),files:structuredClone(e.files),excerpts:structuredClone(e.excerpts),answer:e.answer.trim(),answerExcerptIds:[...new Set(e.answerExcerptIds)],publicRationale:e.publicRationale.trim(),findings:structuredClone(e.findings),limitations:[...new Set((e.limitations??[]).map(n=>n.trim()).filter(Boolean))],usage:{inputTokens:R(e.usage?.inputTokens),outputTokens:R(e.usage?.outputTokens)}};return v(t),t}function tt(e){return{excerptId:e.excerptId,path:e.path,startLine:e.startLine,endLine:e.endLine,text:g(e.text),contentHash:S(g(e.text)),sourceContentHash:structuredClone(e.sourceContentHash)}}function v(e){let t=[];e?.schemaVersion!==X&&t.push("schemaVersion must be xeno.source-research-report.v1"),p(e?.reportId,"reportId",t),p(e?.runId,"runId",t),a(e?.query,"query",t,128e3),l(e?.queryHash,"queryHash",t),typeof e?.query=="string"&&e.queryHash?.value!==s(e.query).value&&t.push("queryHash does not match query"),k(e?.repository,t),w(e?.collectedAt,"collectedAt",t),w(e?.completedAt,"completedAt",t),Date.parse(e?.completedAt)<Date.parse(e?.collectedAt)&&t.push("completedAt cannot precede collectedAt"),$(e?.model,t),a(e?.answer,"answer",t,512e3),a(e?.publicRationale,"publicRationale",t,256e3),N(e?.usage,t),(!Array.isArray(e?.files)||e.files.length<1||e.files.length>256)&&t.push("files must contain 1 through 256 source records");let n=new Map;for(let i of e?.files??[])T(i,t),n.has(i.path)&&t.push(`duplicate source file ${i.path}`),n.set(i.path,i);(!Array.isArray(e?.excerpts)||e.excerpts.length>1024)&&t.push("excerpts must contain at most 1024 records");let r=new Map;for(let i of e?.excerpts??[])C(i,n,t),r.has(i.excerptId)&&t.push(`duplicate excerpt ${i.excerptId}`),r.set(i.excerptId,i);(!Array.isArray(e?.answerExcerptIds)||e.answerExcerptIds.length<1)&&t.push("answerExcerptIds must cite at least one source excerpt");for(let i of e?.answerExcerptIds??[])r.has(i)||t.push(`answer references unknown excerpt ${i}`);(!Array.isArray(e?.findings)||e.findings.length>512)&&t.push("findings must contain at most 512 records");let o=new Set;for(let i of e?.findings??[]){p(i?.findingId,"findingId",t),o.has(i.findingId)&&t.push(`duplicate finding ${i.findingId}`),o.add(i.findingId),a(i?.title,`finding ${i.findingId} title`,t,2e3),a(i?.summary,`finding ${i.findingId} summary`,t,64e3),F(i?.severity)||t.push(`finding ${i.findingId} severity is invalid`),D(i?.confidence)||t.push(`finding ${i.findingId} confidence must be between 0 and 1`),(!Array.isArray(i?.excerptIds)||i.excerptIds.length<1)&&t.push(`finding ${i.findingId} requires source excerpts`);for(let y of i?.excerptIds??[])r.has(y)||t.push(`finding ${i.findingId} references unknown excerpt ${y}`)}(!Array.isArray(e?.limitations)||e.limitations.length>256)&&t.push("limitations must contain at most 256 records");for(let i of e?.limitations??[])a(i,"limitation",t,16e3);if(t.length>0)throw new f([...new Set(t)])}function nt(e,t){v(e);let n=t.createdAt??e.completedAt,r=c(e);return{schemaVersion:1,artifactId:t.artifactId??`research_${s(`${e.runId}:${e.repository.commit}:${e.queryHash.value}`).value.slice(0,24)}`,revision:1,kind:"custom:source-research-report",title:`Source research: ${e.repository.repository}`,description:e.answer.slice(0,1e3),state:"pending_review",createdAt:n,mediaType:"application/vnd.xeno.source-research-report+json",sensitivity:t.sensitivity??"internal",identity:{...t.identity,runId:t.identity?.runId??e.runId,repositoryId:t.identity?.repositoryId??`${e.repository.provider}:${e.repository.repository}`},content:{hash:d(e),sizeBytes:Buffer.byteLength(r,"utf8"),storage:{type:"inline",text:r},encoding:"utf8",redactedPreview:e.answer.slice(0,2e3)},provenance:{producer:structuredClone(t.producer),attributes:{"xeno.research.provider":e.repository.provider,"xeno.research.repository":e.repository.repository,"xeno.research.commit":e.repository.commit,"xeno.research.model":`${e.model.providerId}/${e.model.model}`,"xeno.research.fileCount":e.files.length,"xeno.research.findingCount":e.findings.length}},anchors:e.excerpts.map(o=>({kind:"source-line",path:o.path,startLine:o.startLine,endLine:o.endLine,repositoryId:`${e.repository.provider}:${e.repository.repository}`,commit:e.repository.commit}))}}function it(e){if(e.kind!=="custom:source-research-report"||e.mediaType!=="application/vnd.xeno.source-research-report+json")throw new f([`Artifact ${e.artifactId} is not a source-research report`]);if(e.content.storage.type!=="inline"||typeof e.content.storage.text!="string")throw new f(["Source-research reports require inline JSON content"]);let t;try{t=JSON.parse(e.content.storage.text)}catch{throw new f(["Source-research artifact content is invalid JSON"])}if(v(t),d(t).value!==e.content.hash.value)throw new f(["Source-research content hash does not match the artifact"]);return structuredClone(t)}function g(e){return e.replace(/\r\n?/gu,`
2
+ `)}function k(e,t){e?.provider!=="github"&&e?.provider!=="gitlab"&&t.push("repository provider must be github or gitlab"),V(e?.host,"repository host",t),P(e?.repository,t),a(e?.ref,"repository ref",t,512),(typeof e?.commit!="string"||!/^[a-f0-9]{7,64}$/u.test(e.commit))&&t.push("repository commit must be a lowercase hexadecimal object ID"),O(e?.url,"repository url",t)}function T(e,t){E(e?.path,"source file path",t),l(e?.contentHash,`source file ${e?.path} contentHash`,t),(!Number.isSafeInteger(e?.sizeBytes)||e.sizeBytes<0||e.sizeBytes>8*1024*1024)&&t.push(`source file ${e?.path} sizeBytes is invalid`),(!Number.isSafeInteger(e?.lineCount)||e.lineCount<1||e.lineCount>1e6)&&t.push(`source file ${e?.path} lineCount is invalid`),e?.blobId!==void 0&&a(e.blobId,`source file ${e.path} blobId`,t,256),e?.language!==void 0&&a(e.language,`source file ${e.path} language`,t,128)}function C(e,t,n){p(e?.excerptId,"excerptId",n),E(e?.path,`excerpt ${e?.excerptId} path`,n);let r=t.get(e?.path);r||n.push(`excerpt ${e?.excerptId} references unknown source file ${e?.path}`),(!Number.isSafeInteger(e?.startLine)||e.startLine<1)&&n.push(`excerpt ${e?.excerptId} startLine is invalid`),(!Number.isSafeInteger(e?.endLine)||e.endLine<e.startLine)&&n.push(`excerpt ${e?.excerptId} endLine is invalid`),r&&e.endLine>r.lineCount&&n.push(`excerpt ${e?.excerptId} exceeds source line count`),a(e?.text,`excerpt ${e?.excerptId} text`,n,256e3),l(e?.contentHash,`excerpt ${e?.excerptId} contentHash`,n),l(e?.sourceContentHash,`excerpt ${e?.excerptId} sourceContentHash`,n);let o=typeof e?.text=="string"?g(e.text):"";e?.contentHash?.value!==s(o).value&&n.push(`excerpt ${e?.excerptId} contentHash does not match text`),r&&e?.sourceContentHash?.value!==r.contentHash.value&&n.push(`excerpt ${e?.excerptId} is bound to a different source hash`),o&&o.split(`
3
+ `).length!==e.endLine-e.startLine+1&&n.push(`excerpt ${e?.excerptId} line span does not match text`)}function $(e,t){p(e?.providerId,"model providerId",t),a(e?.model,"model",t,512),e?.connectionId!==void 0&&p(e.connectionId,"model connectionId",t)}function N(e,t){(!Number.isSafeInteger(e?.inputTokens)||e.inputTokens<0)&&t.push("usage.inputTokens must be a non-negative integer"),(!Number.isSafeInteger(e?.outputTokens)||e.outputTokens<0)&&t.push("usage.outputTokens must be a non-negative integer")}function l(e,t,n){(e?.algorithm!=="sha256"||!/^[a-f0-9]{64}$/u.test(e?.value??""))&&n.push(`${t} must be a lowercase SHA-256 digest`)}function p(e,t,n){(typeof e!="string"||!/^[A-Za-z0-9][A-Za-z0-9._:@/-]{0,255}$/u.test(e))&&n.push(`${t} is invalid`)}function a(e,t,n,r){(typeof e!="string"||!e.trim()||e.length>r||A(e,{allowTab:!0,allowLineBreaks:!0}))&&n.push(`${t} must be non-empty bounded text`)}function w(e,t,n){(typeof e!="string"||!Number.isFinite(Date.parse(e))||new Date(e).toISOString()!==e)&&n.push(`${t} must be an ISO-8601 UTC timestamp`)}function V(e,t,n){(typeof e!="string"||e.length>253||!/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/u.test(e))&&n.push(`${t} is invalid`)}function P(e,t){(typeof e!="string"||e.length>2048||e.startsWith("/")||e.endsWith("/")||e.split("/").some(n=>!n||n==="."||n===".."))&&t.push("repository name is invalid")}function E(e,t,n){(typeof e!="string"||e.length>4096||e.startsWith("/")||/^[A-Za-z]:[\\/]/u.test(e)||e.includes("\\")||e.split("/").some(r=>!r||r==="."||r===".."))&&n.push(`${t} must be repository-relative`)}function O(e,t,n){try{let r=new URL(String(e));(r.protocol!=="https:"||r.username||r.password)&&n.push(`${t} must be credential-free HTTPS`)}catch{n.push(`${t} is invalid`)}}function R(e){return Number.isSafeInteger(e)&&(e??-1)>=0?e:0}function S(e){return{algorithm:"sha256",value:s(e).value}}function D(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1}function F(e){return e==="info"||e==="low"||e==="medium"||e==="high"||e==="critical"}export{X as XENO_SOURCE_RESEARCH_SCHEMA_VERSION,f as XenoSourceResearchValidationError,v as assertValidXenoSourceResearchReport,tt as createXenoSourceResearchExcerpt,et as createXenoSourceResearchReport,g as normalizeSourceText,it as xenoArtifactToSourceResearchReport,nt as xenoSourceResearchReportToArtifact};
@@ -0,0 +1 @@
1
+ {"inputs":{"src/artifacts/types.ts":{"bytes":9397,"imports":[],"format":"esm"},"src/artifacts/hash.ts":{"bytes":1530,"imports":[{"path":"node:crypto","kind":"import-statement","external":true}],"format":"esm"},"src/artifacts/validation.ts":{"bytes":25931,"imports":[{"path":"node:buffer","kind":"import-statement","external":true},{"path":"src/artifacts/hash.ts","kind":"import-statement","original":"./hash.js"},{"path":"src/artifacts/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/artifacts/evidence-graph.ts":{"bytes":9299,"imports":[{"path":"src/artifacts/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/artifacts/repository.ts":{"bytes":30001,"imports":[{"path":"src/artifacts/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/artifacts/validation.ts","kind":"import-statement","original":"./validation.js"}],"format":"esm"},"src/control-plane/lock.ts":{"bytes":2591,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/version.ts":{"bytes":38,"imports":[],"format":"esm"},"src/artifacts/file-repository.ts":{"bytes":16811,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/control-plane/lock.ts","kind":"import-statement","original":"../control-plane/lock.js"},{"path":"src/version.ts","kind":"import-statement","original":"../version.js"},{"path":"src/artifacts/hash.ts","kind":"import-statement","original":"./hash.js"},{"path":"src/artifacts/repository.ts","kind":"import-statement","original":"./repository.js"},{"path":"src/artifacts/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/artifacts/diff-artifact.ts":{"bytes":18491,"imports":[{"path":"node:buffer","kind":"import-statement","external":true},{"path":"src/artifacts/hash.ts","kind":"import-statement","original":"./hash.js"},{"path":"src/artifacts/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/artifacts/validation.ts","kind":"import-statement","original":"./validation.js"}],"format":"esm"},"src/artifacts/review-service.ts":{"bytes":8903,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/artifacts/diff-artifact.ts","kind":"import-statement","original":"./diff-artifact.js"},{"path":"src/artifacts/repository.ts","kind":"import-statement","original":"./repository.js"}],"format":"esm"},"src/artifacts/spec-lifecycle.ts":{"bytes":31787,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/artifacts/hash.ts","kind":"import-statement","original":"./hash.js"},{"path":"src/artifacts/review-service.ts","kind":"import-statement","original":"./review-service.js"},{"path":"src/artifacts/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/artifacts/multi-agent-review.ts":{"bytes":30924,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/artifacts/hash.ts","kind":"import-statement","original":"./hash.js"},{"path":"src/artifacts/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/artifacts/validation.ts","kind":"import-statement","original":"./validation.js"}],"format":"esm"},"src/artifacts/legacy-adapters.ts":{"bytes":11181,"imports":[{"path":"node:buffer","kind":"import-statement","external":true},{"path":"src/artifacts/hash.ts","kind":"import-statement","original":"./hash.js"},{"path":"src/artifacts/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/artifacts/validation.ts","kind":"import-statement","original":"./validation.js"},{"path":"src/artifacts/diff-artifact.ts","kind":"import-statement","original":"./diff-artifact.js"}],"format":"esm"},"src/artifacts/index.ts":{"bytes":396,"imports":[{"path":"src/artifacts/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/artifacts/validation.ts","kind":"import-statement","original":"./validation.js"},{"path":"src/artifacts/hash.ts","kind":"import-statement","original":"./hash.js"},{"path":"src/artifacts/evidence-graph.ts","kind":"import-statement","original":"./evidence-graph.js"},{"path":"src/artifacts/repository.ts","kind":"import-statement","original":"./repository.js"},{"path":"src/artifacts/file-repository.ts","kind":"import-statement","original":"./file-repository.js"},{"path":"src/artifacts/diff-artifact.ts","kind":"import-statement","original":"./diff-artifact.js"},{"path":"src/artifacts/review-service.ts","kind":"import-statement","original":"./review-service.js"},{"path":"src/artifacts/spec-lifecycle.ts","kind":"import-statement","original":"./spec-lifecycle.js"},{"path":"src/artifacts/multi-agent-review.ts","kind":"import-statement","original":"./multi-agent-review.js"},{"path":"src/artifacts/legacy-adapters.ts","kind":"import-statement","original":"./legacy-adapters.js"}],"format":"esm"},"src/utils/text-security.ts":{"bytes":833,"imports":[],"format":"esm"},"src/research/source-research.ts":{"bytes":19344,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/artifacts/index.ts","kind":"import-statement","original":"../artifacts/index.js"},{"path":"src/utils/text-security.ts","kind":"import-statement","original":"../utils/text-security.js"}],"format":"esm"},"src/research/index.ts":{"bytes":39,"imports":[{"path":"src/research/source-research.ts","kind":"import-statement","original":"./source-research.js"}],"format":"esm"}},"outputs":{"dist/research/index.cjs":{"imports":[{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/research/index.ts","inputs":{"src/research/index.ts":{"bytesInOutput":343},"src/research/source-research.ts":{"bytesInOutput":9356},"src/artifacts/index.ts":{"bytesInOutput":0},"src/artifacts/hash.ts":{"bytesInOutput":715},"src/artifacts/validation.ts":{"bytesInOutput":50},"src/artifacts/file-repository.ts":{"bytesInOutput":20},"src/artifacts/diff-artifact.ts":{"bytesInOutput":20},"src/utils/text-security.ts":{"bytesInOutput":179}},"bytes":11390}}}