vibe64 0.1.64 → 0.1.66

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 (158) hide show
  1. package/bin/run.js +823 -820
  2. package/bin/server.js +200 -197
  3. package/bin/upgrade-state.js +4192 -4064
  4. package/dist/assets/{GithubBrowserTabs-Cf6ce1lO.js → GithubBrowserTabs-Bf5z_PiF.js} +1 -1
  5. package/dist/assets/{LocalDatabaseServer-0VGIcy5Q.js → LocalDatabaseServer-CcfGbn7H.js} +1 -1
  6. package/dist/assets/{SelectField-RGWl_ms9.js → SelectField-Df50ZFLj.js} +1 -1
  7. package/dist/assets/{ShellOutlet-CdjsJfg9.js → ShellOutlet-DPyl05um.js} +1 -1
  8. package/dist/assets/{StudioErrorNotice-CCT_T6mT.js → StudioErrorNotice-vDR4qneB.js} +1 -1
  9. package/dist/assets/{VAutocomplete-BnpXAJGa.js → VAutocomplete-NpBcbYkR.js} +1 -1
  10. package/dist/assets/VBtn-Com1gNEe.js +1 -0
  11. package/dist/assets/{VCard-BFqQSnAE.js → VCard-DY_DdI8Z.js} +1 -1
  12. package/dist/assets/{VCheckbox-BK0ss4F4.js → VCheckbox-CkezAf4Z.js} +1 -1
  13. package/dist/assets/{VCheckboxBtn-DDlYJnth.js → VCheckboxBtn-8g4R-c2w.js} +1 -1
  14. package/dist/assets/{VChip-D2IukBZw.js → VChip-tORFnf7z.js} +1 -1
  15. package/dist/assets/{VDialog-BCIrX462.js → VDialog-CapFiCqp.js} +1 -1
  16. package/dist/assets/{VExpansionPanels-BHw1Id_o.js → VExpansionPanels-B6U2XdWH.js} +1 -1
  17. package/dist/assets/{VMenu-Bql3E6DV.js → VMenu-CO6B6LWk.js} +1 -1
  18. package/dist/assets/{VOverlay-EPzW7eVB.js → VOverlay-CrfaXCOL.js} +1 -1
  19. package/dist/assets/{VRadioGroup-CL3HTmyT.js → VRadioGroup-BrPW6foD.js} +1 -1
  20. package/dist/assets/{VRow-Dz87sIhY.js → VRow-DHETsEMn.js} +1 -1
  21. package/dist/assets/{VSelect-Ch00dyiM.js → VSelect-gYJ6qrBP.js} +1 -1
  22. package/dist/assets/{VSheet-D5wAuyc2.js → VSheet-_Grtwpfz.js} +1 -1
  23. package/dist/assets/{VSkeletonLoader-Bl9P5wdh.js → VSkeletonLoader-CQXCEJsR.js} +1 -1
  24. package/dist/assets/VSpacer-VLYDmg7o.js +1 -0
  25. package/dist/assets/{VSwitch-DftK1EyR.js → VSwitch-ffi-Y2TU.js} +1 -1
  26. package/dist/assets/{VTable-DHazU0Xx.js → VTable-Cver5Vl3.js} +1 -1
  27. package/dist/assets/{VTextField-B9R7EIjg.js → VTextField-DP6b7Qaf.js} +1 -1
  28. package/dist/assets/{VTextarea-CMgyRNk-.js → VTextarea-7mdIF4I0.js} +1 -1
  29. package/dist/assets/{VToolbar-C8ydxLzq.js → VToolbar-CYz3lneF.js} +1 -1
  30. package/dist/assets/{Vibe64AsyncModuleState-9bN0_H45.js → Vibe64AsyncModuleState-CO1rMrtD.js} +1 -1
  31. package/dist/assets/{Vibe64AuthSettingsButton-BGtVvQq0.js → Vibe64AuthSettingsButton-CxJoeOhz.js} +1 -1
  32. package/dist/assets/{Vibe64ConversationLog-Cv_BE9yH.js → Vibe64ConversationLog-jDb_ZvIF.js} +1 -1
  33. package/dist/assets/{Vibe64DashboardPageHeader-xfRLZ94G.js → Vibe64DashboardPageHeader-CobvMlFm.js} +1 -1
  34. package/dist/assets/{Vibe64DashboardShell-B3TN3NBS.js → Vibe64DashboardShell-Ce1PNB37.js} +1 -1
  35. package/dist/assets/{Vibe64DatabaseWorkspace-CU0jCfP_.js → Vibe64DatabaseWorkspace-DiZDKEpx.js} +1 -1
  36. package/dist/assets/{Vibe64DestinationButton-CdyyK9tj.js → Vibe64DestinationButton-B4Zz4a7J.js} +1 -1
  37. package/dist/assets/{Vibe64FileArea-BWl-q11N.js → Vibe64FileArea-uRnIJ0Vp.js} +1 -1
  38. package/dist/assets/{Vibe64OutputControls-DnfGKZHs.js → Vibe64OutputControls-BF5kh2_h.js} +1 -1
  39. package/dist/assets/{Vibe64RepositoryWorkspace-3UKN_pPs.js → Vibe64RepositoryWorkspace-D6uJCype.js} +1 -1
  40. package/dist/assets/{Vibe64SessionFiles-B1U6XSWQ.js → Vibe64SessionFiles-CxgPB8RR.js} +1 -1
  41. package/dist/assets/{Vibe64SessionSourceEditor-De1QyTOd.js → Vibe64SessionSourceEditor-yaVu279S.js} +1 -1
  42. package/dist/assets/{Vibe64UiStoryboardView-JRGcklim.js → Vibe64UiStoryboardView-DhbHkz8K.js} +1 -1
  43. package/dist/assets/{Vibe64UnavailableSessions-Bd_-gPuL.js → Vibe64UnavailableSessions-MmPF-Db1.js} +1 -1
  44. package/dist/assets/{_pageId_-DIPouI7Z.js → _pageId_-Zif-veil.js} +1 -1
  45. package/dist/assets/{_sessionId_-qH7uIGNl.js → _sessionId_-DOge-7SB.js} +1 -1
  46. package/dist/assets/_slug_-C71iAiR0.js +14 -0
  47. package/dist/assets/_slug_-CF1TPDUv.css +1 -0
  48. package/dist/assets/{access-O4hOM9ov.js → access-DQcblrWN.js} +1 -1
  49. package/dist/assets/{app-CXljwZ0u.js → app-CzApKPmq.js} +1 -1
  50. package/dist/assets/assistantRouting-CqIiQy21.js +3 -0
  51. package/dist/assets/{changes-C5gleyWS.js → changes-cmlEyHug.js} +1 -1
  52. package/dist/assets/{client-DMEf6RSZ.js → client-13v_yX07.js} +1 -1
  53. package/dist/assets/{client-CI-o7ITq.js → client-5JUUGxRd.js} +2 -2
  54. package/dist/assets/{client-4uCr4dYG.js → client-BJBzomgt.js} +1 -1
  55. package/dist/assets/{client-Do8szX_w.js → client-C8ZjqGdQ.js} +2 -2
  56. package/dist/assets/{client-fF-hq8nJ.js → client-Dl6I6IVb.js} +1 -1
  57. package/dist/assets/{client-BRcncaFt.js → client-Dv4scw6i.js} +1 -1
  58. package/dist/assets/{conversation-DiL2PEct.js → conversation-CFJRkeTj.js} +3 -3
  59. package/dist/assets/{conversation-RscSzQxq.css → conversation-COcuIkcD.css} +1 -1
  60. package/dist/assets/conversation-CexAK3Qk.js +1 -0
  61. package/dist/assets/{dashboard-BWlG0Nli.js → dashboard-Dm_xwwqU.js} +1 -1
  62. package/dist/assets/{english-definitions-DcuZfQ4p.js → english-definitions-DwTf_alg.js} +1 -1
  63. package/dist/assets/{env-D3DVC-Gd.js → env-B7wB5nBn.js} +1 -1
  64. package/dist/assets/{error-BQ7r64JO.js → error-CtOws2EC.js} +1 -1
  65. package/dist/assets/{error-BqMxhgpB.js → error-HfzrYwkQ.js} +1 -1
  66. package/dist/assets/errorMessageHelpers-G32Hjqfm.js +1 -0
  67. package/dist/assets/{fileTypes-2k5HCkMT.js → fileTypes-iPZyrJA1.js} +1 -1
  68. package/dist/assets/{health-B9ZoQC78.js → health-DIkOkzPe.js} +1 -1
  69. package/dist/assets/{history-BrWT8DRp.js → history-Ch597NiY.js} +1 -1
  70. package/dist/assets/{httpClient-Bwitq9Xf.js → httpClient-C71X5grL.js} +1 -1
  71. package/dist/assets/{i18n-BuXRXGaO.js → i18n-5EHeMSvt.js} +1 -1
  72. package/dist/assets/{i18n-BkxO7BMl.js → i18n-BSfPKqM3.js} +1 -1
  73. package/dist/assets/{i18n-Dm74yE_M.js → i18n-DcNQE3tT.js} +1 -1
  74. package/dist/assets/index-C-6c5Af1.css +1 -0
  75. package/dist/assets/index-DcKFCaBZ.js +134 -0
  76. package/dist/assets/{integrations-C4p_QTuv.js → integrations-CoNhnGvq.js} +1 -1
  77. package/dist/assets/{issues-KxOOLtSM.js → issues-Cem4Yt47.js} +1 -1
  78. package/dist/assets/{layout-B_cpKP4k.js → layout-DMZV-nbg.js} +1 -1
  79. package/dist/assets/{lazy-vXRXMwYF.js → lazy-mtFmsnct.js} +1 -1
  80. package/dist/assets/{learning-BWqH7wag.js → learning-CU2QyHrj.js} +1 -1
  81. package/dist/assets/{pages-DcNh-g_z.js → pages-BzA58NoR.js} +1 -1
  82. package/dist/assets/{project-files-C3a_vnA4.js → project-files-BBKjl3wZ.js} +1 -1
  83. package/dist/assets/{publish-B1f2baHh.js → publish-UFjblZA3.js} +1 -1
  84. package/dist/assets/{pull-requests-BHq5Yafl.js → pull-requests-DibGk1GB.js} +1 -1
  85. package/dist/assets/{repository-DMBew8kp.js → repository-0EKOcyTL.js} +1 -1
  86. package/dist/assets/{session-B5MoHBVk.js → session-FRkCCzYt.js} +1 -1
  87. package/dist/assets/{settings-DDpgGhWO.js → settings-BjOnPYwD.js} +1 -1
  88. package/dist/assets/{studioGateApi-UqmdV50W.js → studioGateApi-B9EUTtMx.js} +1 -1
  89. package/dist/assets/{studioUrls-k_pQIuPs.js → studioUrls-BR4ZL-TN.js} +1 -1
  90. package/dist/assets/{useArchivedVibe64Sessions-C5Qguyob.js → useArchivedVibe64Sessions-CXKRFR2f.js} +1 -1
  91. package/dist/assets/useAssistantAttachments-C9kAnWqw.js +2 -0
  92. package/dist/assets/useCommand-yOr3U8KF.js +1 -0
  93. package/dist/assets/useEndpointResource-BwGXpV2u.js +1 -0
  94. package/dist/assets/useUiFeedback--0dLsslR.js +1 -0
  95. package/dist/assets/{useVibe64ConversationLog-BZ5g9Jp7.js → useVibe64ConversationLog-BB5tVtkt.js} +2 -2
  96. package/dist/assets/{useVibe64Learning-DiLAIKbI.js → useVibe64Learning-iAAH83uG.js} +1 -1
  97. package/dist/assets/{useVibe64SessionData-D9d4NfDo.js → useVibe64SessionData-BSYF_TgH.js} +1 -1
  98. package/dist/assets/{useVibe64SessionSelection-DT1rJVvx.js → useVibe64SessionSelection-CxZ3uEAf.js} +1 -1
  99. package/dist/assets/{vibe64FileUpload-BDkcaUyk.js → vibe64FileUpload-D_rOa1R8.js} +1 -1
  100. package/dist/assets/vibe64RepositoryRealtime-CRAyGyRD.css +1 -0
  101. package/dist/assets/vibe64RepositoryRealtime-CVGNqwxz.js +1 -0
  102. package/dist/assets/{vibe64SessionFocus-CLtCTOxq.js → vibe64SessionFocus-DGSVXipO.js} +1 -1
  103. package/dist/index.html +45 -45
  104. package/docs/colleague-usage/ai-tasks.md +9 -1
  105. package/docs/colleague-usage/auto-workflow.md +6 -3
  106. package/docs/colleague-usage/coding-agent-goal-pause.md +34 -12
  107. package/docs/colleague-usage/coding-agent-goals.md +46 -23
  108. package/docs/colleague-usage/coding-agent-questions.md +7 -0
  109. package/docs/colleague-usage/coding-agents.md +22 -8
  110. package/docs/colleague-usage/connected-repositories.md +4 -1
  111. package/docs/colleague-usage/github-work.md +36 -3
  112. package/docs/colleague-usage/passes.md +86 -0
  113. package/docs/colleague-usage/project-messages.md +4 -1
  114. package/docs/colleague-usage/ui-pass.md +4 -0
  115. package/docs/colleague-usage/workspace-preparation.md +51 -0
  116. package/node_modules/@jskit-ai/assistant-core/CHANGELOG.md +13 -0
  117. package/node_modules/@jskit-ai/assistant-core/locales/en.json +7 -4
  118. package/node_modules/@jskit-ai/assistant-core/package.json +1 -1
  119. package/node_modules/@jskit-ai/assistant-runtime/CHANGELOG.md +2 -0
  120. package/node_modules/@jskit-ai/assistant-runtime/package.json +1 -1
  121. package/node_modules/@jskit-ai/assistant-voice/package.json +1 -1
  122. package/node_modules/@jskit-ai/connector-google-calendar/package.json +1 -1
  123. package/node_modules/@jskit-ai/connectors-catalog/package.json +1 -1
  124. package/node_modules/@jskit-ai/connectors-core/package.json +1 -1
  125. package/node_modules/@jskit-ai/http-runtime/CHANGELOG.md +1 -0
  126. package/node_modules/@jskit-ai/http-runtime/package.json +1 -1
  127. package/node_modules/@jskit-ai/kernel/CHANGELOG.md +6 -0
  128. package/node_modules/@jskit-ai/kernel/package.json +1 -1
  129. package/node_modules/@jskit-ai/payments-core/package.json +1 -1
  130. package/node_modules/@jskit-ai/realtime/package.json +1 -1
  131. package/node_modules/@jskit-ai/resource-core/package.json +1 -1
  132. package/node_modules/@jskit-ai/uploads-runtime/package.json +1 -1
  133. package/node_modules/@local/vibe64-core/package.json +1 -0
  134. package/node_modules/@local/vibe64-genesis/bin/vibe64-genesis-host-context +914 -773
  135. package/node_modules/@local/vibe64-genesis/src/server/agentSpecs.js +69 -63
  136. package/node_modules/@local/vibe64-genesis/src/server/index.js +450 -440
  137. package/node_modules/@local/vibe64-genesis/src/server/packaging.js +27 -28
  138. package/node_modules/@local/vibe64-genesis/src/server/promptContext.js +63 -55
  139. package/node_modules/@local/vibe64-runtime/src/server/codexAppServerProcess.js +1044 -901
  140. package/node_modules/@local/vibe64-terminals/src/server/opencodeSessionEnvironmentPlugin.js +560 -420
  141. package/node_modules/@local/vibe64-terminals/src/server/sessionWorkOperationCommand.js +453 -450
  142. package/package.json +15 -15
  143. package/server.bundle.mjs +43357 -43007
  144. package/dist/assets/VBtn-2vbH580C.js +0 -1
  145. package/dist/assets/VSpacer-GgPR_AzN.js +0 -1
  146. package/dist/assets/_slug_-CZmGS16g.css +0 -1
  147. package/dist/assets/_slug_-CaHlSQ8I.js +0 -14
  148. package/dist/assets/assistantRouting-BS0ZW5Ki.js +0 -3
  149. package/dist/assets/conversation-D7T_us2O.js +0 -1
  150. package/dist/assets/errorMessageHelpers-BjIt31kK.js +0 -1
  151. package/dist/assets/index-Ctygjyf8.css +0 -1
  152. package/dist/assets/index-HrVsvggI.js +0 -134
  153. package/dist/assets/useAssistantAttachments-DvEl7gX6.js +0 -2
  154. package/dist/assets/useCommand-CNDe8gM-.js +0 -1
  155. package/dist/assets/useEndpointResource-CmMwteuX.js +0 -1
  156. package/dist/assets/useUiFeedback-CWb6o71Z.js +0 -1
  157. package/dist/assets/vibe64RepositoryRealtime-kSshUn2K.js +0 -1
  158. package/dist/assets/vibe64RepositoryRealtime-rnWlv9jw.css +0 -1
@@ -1,293 +1,294 @@
1
1
  import { createRequire as __vibe64CreateRequire } from 'node:module';const require=__vibe64CreateRequire(import.meta.url);
2
- import{execFile as Dn}from"node:child_process";import{fileURLToPath as kn}from"node:url";import zn from"node:path";var qn=Object.freeze(["none","pending","committed","rolledBack","unknown"]);function O(t,{fallback:e=""}={}){return String(t||"").trim()||e}function w(t){return!!(t&&typeof t=="object"&&!Array.isArray(t))}function b(t){return String(t??"").trim()}var Kn=2*1024*1024,Zn=32*1024*1024,Qn=2*1024*1024;function y(t){if(t===null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null||
3
- Kt(e)}function Kt(t){return t!==null&&typeof t=="object"&&Object.getPrototypeOf(t)===null&&Reflect.ownKeys(t).length===0}function ue(t){return t!==null&&typeof t=="object"&&y(t.structure)&&y(t.operations)&&typeof t.validateWith=="function"&&
4
- typeof t.toJsonSchema=="function"&&typeof t.cleanup=="function"}function K(t,e){if(!Object.hasOwn(e,"items"))return null;
5
- let{items:n}=e;if(ue(n))return{kind:"schema",schema:n};if(!y(n)||typeof n.type!="string")throw new Error(`Array field "${t}\
6
- " must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:n}}function J(t,e){
7
- if(!Object.hasOwn(e,"values"))return null;let{values:n}=e;if(ue(n))return{kind:"schema",schema:n};if(!y(n)||typeof n.type!=
8
- "string")throw new Error(`Object field "${t}" must define values as either a Schema instance or a field definition objec\
9
- t.`);return{kind:"definition",definition:n}}function Z(t,e){let n=Object.hasOwn(e,"schema"),r=Object.hasOwn(e,"values"),
10
- o=Object.hasOwn(e,"additionalProperties");if(n&&r)throw new Error(`Object field "${t}" cannot define both schema and val\
11
- ues.`);if(o&&e.additionalProperties!==!0)throw new Error(`Object field "${t}" only supports additionalProperties: true.`);
12
- if(r&&e.additionalProperties===!0)throw new Error(`Object field "${t}" cannot define both values and additionalPropertie\
13
- s: true.`);if(n){if(!ue(e.schema))throw new Error(`Object field "${t}" must define schema as a Schema instance.`);return{
14
- kind:"nested",schema:e.schema,allowAdditionalProperties:e.additionalProperties===!0}}return r?{kind:"map",valuesConfig:J(
15
- t,e)}:e.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}function R(t){return t?.type==="number"||t?.type==="integer"||t?.type==="epochMilliseconds"||t?.type==="epochSeconds"}function de(t,e=""){
16
- if(y(t))for(let[n,r]of Object.entries(t)){if(!y(r))continue;let o=e?`${e}.${n}`:n;for(let i of["minItems","maxItems"]){if(!Object.
2
+ import{execFile as di}from"node:child_process";import{fileURLToPath as fi}from"node:url";import pi from"node:path";var gi=Object.freeze(["none","pending","committed","rolledBack","unknown"]);function y(e,{fallback:t=""}={}){return String(e||"").trim()||t}function j(e,{fallback:t=""}={}){return y(e,{fallback:t}).toLowerCase()}function I(e,{fallback:t={}}={}){return w(e)?e:{...t}}function w(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function ne(e,{fallback:t=0}={}){let n=Number(e);return!Number.isInteger(n)||n<1?t:n}function fe(e,{fallback:t=null}={}){return e==null?t:typeof e=="string"?e.trim()||t:typeof e=="number"?Number.isFinite(e)?
3
+ String(e):t:typeof e=="bigint"?String(e):t}function C(e){return String(e??"").trim()}var _i=2*1024*1024,Ti=32*1024*1024,Pi=2*1024*1024;function O(e){if(e===null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||
4
+ Zr(t)}function Zr(e){return e!==null&&typeof e=="object"&&Object.getPrototypeOf(e)===null&&Reflect.ownKeys(e).length===0}function Te(e){return e!==null&&typeof e=="object"&&O(e.structure)&&O(e.operations)&&typeof e.validateWith=="function"&&
5
+ typeof e.toJsonSchema=="function"&&typeof e.cleanup=="function"}function pe(e,t){if(!Object.hasOwn(t,"items"))return null;
6
+ let{items:n}=t;if(Te(n))return{kind:"schema",schema:n};if(!O(n)||typeof n.type!="string")throw new Error(`Array field "${e}\
7
+ " must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:n}}function oe(e,t){
8
+ if(!Object.hasOwn(t,"values"))return null;let{values:n}=t;if(Te(n))return{kind:"schema",schema:n};if(!O(n)||typeof n.type!=
9
+ "string")throw new Error(`Object field "${e}" must define values as either a Schema instance or a field definition objec\
10
+ t.`);return{kind:"definition",definition:n}}function me(e,t){let n=Object.hasOwn(t,"schema"),r=Object.hasOwn(t,"values"),
11
+ o=Object.hasOwn(t,"additionalProperties");if(n&&r)throw new Error(`Object field "${e}" cannot define both schema and val\
12
+ ues.`);if(o&&t.additionalProperties!==!0)throw new Error(`Object field "${e}" only supports additionalProperties: true.`);
13
+ if(r&&t.additionalProperties===!0)throw new Error(`Object field "${e}" cannot define both values and additionalPropertie\
14
+ s: true.`);if(n){if(!Te(t.schema))throw new Error(`Object field "${e}" must define schema as a Schema instance.`);return{
15
+ kind:"nested",schema:t.schema,allowAdditionalProperties:t.additionalProperties===!0}}return r?{kind:"map",valuesConfig:oe(
16
+ e,t)}:t.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}function q(e){return e?.type==="number"||e?.type==="integer"||e?.type==="epochMilliseconds"||e?.type==="epochSeconds"}function Pe(e,t=""){
17
+ if(O(e))for(let[n,r]of Object.entries(e)){if(!O(r))continue;let o=t?`${t}.${n}`:n;for(let i of["minItems","maxItems"]){if(!Object.
17
18
  hasOwn(r,i))continue;let s=r[i];if(r.type!=="array"||!Number.isInteger(s)||s<0)throw new Error(`Field "${o}" ${i} must b\
18
19
  e a non-negative integer on an array field.`)}if(r.minItems>r.maxItems)throw new Error(`Field "${o}" minItems (${r.minItems}\
19
- ) is above its maxItems (${r.maxItems}).`);r.type==="array"&&y(r.items)&&typeof r.items.type=="string"&&de({"[]":r.items},
20
- o)}}var fe="^(?:0|-?[1-9]\\d*)$",Je="\\d{4}",We="0[1-9]|1[0-2]",Ge="0[1-9]|[12]\\d|3[01]",Ye="[01]\\d|2[0-3]",N="[0-5]\\d",Q=`\
21
- (?:${Ye}):${N}`,Xe=`(?:Z|[+-](?:${Ye}):${N})`,Ke=`(${Je})-(${We})-(${Ge})`,Ze=`${Je}-(?:${We})-(?:${Ge})`,Qe=`^${Ze}$`,Zt=new RegExp(
22
- `^${Ke}$`),Qt=new RegExp(`^${Q}(?::${N}(?:\\.(\\d+))?)?$`),er=new RegExp(`^${Ke}T${Q}:${N}(?:\\.(\\d+))?${Xe}$`),tr=new RegExp(
23
- fe),rr=[31,28,31,30,31,30,31,31,30,31,30,31];function nr(t){return t%4===0&&(t%100!==0||t%400===0)}function or(t,e){return e===
24
- 2?nr(t)?29:28:rr[e-1]}function et(t,e,n){let r=Number(t),o=Number(e),i=Number(n);return o>=1&&o<=12&&i>=1&&i<=or(r,o)}function W(t,e){
25
- let n=t.temporalPrecision;if(n!==void 0){if(!Number.isInteger(n)||n<0)throw new Error(`temporalPrecision for "${e}" must\
26
- be a non-negative integer.`);return n}}function tt(t,e){return t===void 0?!0:e===void 0||t.length<=e}function rt(t){if(typeof t!=
27
- "string")return!1;let e=Zt.exec(t);return e!==null&&et(e[1],e[2],e[3])}function nt(t,e){if(typeof t!="string")return!1;let n=Qt.
28
- exec(t);return n!==null&&tt(n[1],e)}function ot(t,e){if(typeof t!="string")return!1;let n=er.exec(t);return n===null?!1:
29
- et(n[1],n[2],n[3])&&tt(n[4],e)}function it(t){return t===void 0?"(?:\\.\\d+)?":t===0?"":`(?:\\.\\d{1,${t}})?`}function st(t,e){
30
- let n=W(t,e);return`^${Q}(?::${N}${it(n)})?$`}function at(t,e){let n=W(t,e);return`^${Ze}T${Q}:${N}${it(n)}${Xe}$`}function pe(t,e){
31
- let n;if(typeof t=="number")n=t;else if(typeof t=="string"&&tr.test(t))n=Number(t);else return null;return!Number.isSafeInteger(
32
- n)||n<-e||n>e?null:n===0?0:n}var ir=new Set(["__proto__","prototype","constructor"]);function p(t,e,n){Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0})}function sr(t,e){if(ir.
33
- has(t))throw new Error(`${e}() received unsafe path segment "${t}".`)}function ar(t){return typeof t!="string"?t:t.replace(
34
- /\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function me(t,e,{normalize:n=!1,allowEmpty:r=!1}={}){
35
- let o=n?ar(t):t;if(typeof o!="string"||o.trim()===""){if(r&&o==="")return[];throw new Error(`${e}() expects a non-empty \
36
- dotted path string.`)}let i=o.split(".");if(i.some(s=>s===""))throw new Error(`${e}() received an invalid path "${o}".`);
37
- for(let s of i)sr(s,e);return i}var cr="http://json-schema.org/draft-07/schema#",_="x-json-rest-schema",he=["object","array","string","number","boolean"],
38
- ye=Symbol("json-rest-schema.exportContext"),lr=["true","1","yes","y","on"],ur=["false","0","no","n","off"];function ct(t){
39
- return{anyOf:[{type:"integer",minimum:-t,maximum:t},{type:"string",pattern:fe}]}}function A(t,e){return{[_]:{[t]:e}}}var dr={
40
- none:()=>({type:he}),blob:()=>({type:he}),serialize:()=>({type:he}),object:()=>({type:"object"}),array:()=>({type:"array"}),
20
+ ) is above its maxItems (${r.maxItems}).`);r.type==="array"&&O(r.items)&&typeof r.items.type=="string"&&Pe({"[]":r.items},
21
+ o)}}var je="^(?:0|-?[1-9]\\d*)$",St="\\d{4}",At="0[1-9]|1[0-2]",It="0[1-9]|[12]\\d|3[01]",Ct="[01]\\d|2[0-3]",U="[0-5]\\d",he=`\
22
+ (?:${Ct}):${U}`,_t=`(?:Z|[+-](?:${Ct}):${U})`,Tt=`(${St})-(${At})-(${It})`,Pt=`${St}-(?:${At})-(?:${It})`,jt=`^${Pt}$`,Qr=new RegExp(
23
+ `^${Tt}$`),en=new RegExp(`^${he}(?::${U}(?:\\.(\\d+))?)?$`),tn=new RegExp(`^${Tt}T${he}:${U}(?:\\.(\\d+))?${_t}$`),rn=new RegExp(
24
+ je),nn=[31,28,31,30,31,30,31,31,30,31,30,31];function on(e){return e%4===0&&(e%100!==0||e%400===0)}function sn(e,t){return t===
25
+ 2?on(e)?29:28:nn[t-1]}function xt(e,t,n){let r=Number(e),o=Number(t),i=Number(n);return o>=1&&o<=12&&i>=1&&i<=sn(r,o)}function ie(e,t){
26
+ let n=e.temporalPrecision;if(n!==void 0){if(!Number.isInteger(n)||n<0)throw new Error(`temporalPrecision for "${t}" must\
27
+ be a non-negative integer.`);return n}}function Rt(e,t){return e===void 0?!0:t===void 0||e.length<=t}function Nt(e){if(typeof e!=
28
+ "string")return!1;let t=Qr.exec(e);return t!==null&&xt(t[1],t[2],t[3])}function Dt(e,t){if(typeof e!="string")return!1;let n=en.
29
+ exec(e);return n!==null&&Rt(n[1],t)}function Mt(e,t){if(typeof e!="string")return!1;let n=tn.exec(e);return n===null?!1:
30
+ xt(n[1],n[2],n[3])&&Rt(n[4],t)}function zt(e){return e===void 0?"(?:\\.\\d+)?":e===0?"":`(?:\\.\\d{1,${e}})?`}function kt(e,t){
31
+ let n=ie(e,t);return`^${he}(?::${U}${zt(n)})?$`}function Lt(e,t){let n=ie(e,t);return`^${Pt}T${he}:${U}${zt(n)}${_t}$`}function xe(e,t){
32
+ let n;if(typeof e=="number")n=e;else if(typeof e=="string"&&rn.test(e))n=Number(e);else return null;return!Number.isSafeInteger(
33
+ n)||n<-t||n>t?null:n===0?0:n}var an=new Set(["__proto__","prototype","constructor"]);function h(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function cn(e,t){if(an.
34
+ has(e))throw new Error(`${t}() received unsafe path segment "${e}".`)}function un(e){return typeof e!="string"?e:e.replace(
35
+ /\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function Re(e,t,{normalize:n=!1,allowEmpty:r=!1}={}){
36
+ let o=n?un(e):e;if(typeof o!="string"||o.trim()===""){if(r&&o==="")return[];throw new Error(`${t}() expects a non-empty \
37
+ dotted path string.`)}let i=o.split(".");if(i.some(s=>s===""))throw new Error(`${t}() received an invalid path "${o}".`);
38
+ for(let s of i)cn(s,t);return i}var ln="http://json-schema.org/draft-07/schema#",M="x-json-rest-schema",Ne=["object","array","string","number","boolean"],
39
+ De=Symbol("json-rest-schema.exportContext"),dn=["true","1","yes","y","on"],fn=["false","0","no","n","off"];function $t(e){
40
+ return{anyOf:[{type:"integer",minimum:-e,maximum:e},{type:"string",pattern:je}]}}function k(e,t){return{[M]:{[e]:t}}}var pn={
41
+ none:()=>({type:Ne}),blob:()=>({type:Ne}),serialize:()=>({type:Ne}),object:()=>({type:"object"}),array:()=>({type:"array"}),
41
42
  file:()=>({type:"string"}),string:()=>({type:"string"}),number:()=>({type:["number","string"]}),integer:()=>({type:["int\
42
- eger","string"]}),epochMilliseconds:()=>ct(864e13),epochSeconds:()=>ct(864e10),dateTime:({definition:t,fieldName:e})=>({
43
- type:"string",format:"date-time",pattern:at(t,e)}),date:()=>({type:"string",format:"date",pattern:Qe}),time:({definition:t,
44
- fieldName:e})=>({type:"string",pattern:st(t,e)}),boolean:({definition:t})=>{if(t.strictBoolean===!0)return{type:"boolean"};
45
- let e=new Set([...lr,String(t.stringTrueWhen||"true").trim().toLowerCase()]),n=new Set([...ur,String(t.stringFalseWhen||
46
- "false").trim().toLowerCase()]);return{anyOf:[{type:"boolean"},{type:"number",enum:[0,1]},{type:"string",enum:[...n,...e]}]}},
47
- id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},fr={minLength:({definition:t,parameterValue:e})=>t.
48
- type==="string"?{minLength:e}:null,maxLength:({definition:t,parameterValue:e})=>t.type==="string"?{maxLength:e}:null,min:({
49
- definition:t,parameterValue:e})=>R(t)?{minimum:e}:null,max:({definition:t,parameterValue:e})=>R(t)?{maximum:e}:null,pattern:({
50
- definition:t,parameterValue:e})=>t.type==="string"?{pattern:e instanceof RegExp?e.source:e}:null,enum:({parameterValue:t})=>({
51
- enum:t}),minItems:({definition:t,parameterValue:e})=>t.type==="array"?{minItems:e}:null,maxItems:({definition:t,parameterValue:e})=>t.
52
- type==="array"?{maxItems:e}:null,notEmpty:({parameterValue:t,definition:e})=>!t||e.type==="array"?null:{minLength:1},uppercase:({
53
- parameterValue:t})=>t?A("transforms",{uppercase:!0}):null,lowercase:({parameterValue:t})=>t?A("transforms",{lowercase:!0}):
54
- null,length:({parameterValue:t})=>A("transforms",{length:t}),unsigned:({parameterValue:t})=>t?A("metadata",{unsigned:!0}):
55
- null,precision:({parameterValue:t})=>A("metadata",{precision:t}),scale:({parameterValue:t})=>A("metadata",{scale:t}),temporalPrecision:({
56
- parameterValue:t})=>A("metadata",{temporalPrecision:t}),strictBoolean:()=>null,required:()=>null,nullable:()=>null,nullOnEmpty:()=>null,
57
- defaultTo:()=>null};function Ee(t,e){for(let n of Object.keys(e)){let r=e[n],o=t[n];if(r&&o&&typeof r=="object"&&typeof o==
58
- "object"&&!Array.isArray(r)&&!Array.isArray(o)){Ee(o,r);continue}t[n]=r}}function pr(t,e){if(!e||typeof e!="object"||Array.
59
- isArray(e))throw new Error("JSON Schema export hooks must return an object or null.");for(let n of Object.keys(e)){if(n===
60
- _&&t[n]&&typeof t[n]=="object"&&typeof e[n]=="object"&&!Array.isArray(t[n])&&!Array.isArray(e[n])){Ee(t[n],e[n]);continue}
61
- t[n]=e[n]}}function mr(t,e){let r=[...Array.isArray(t.anyOf)&&Object.keys(t).length===1?t.anyOf:[t],...e];return r.length===
62
- 1?t:{anyOf:r}}function hr(t,e){if(!Object.hasOwn(t.types,e.type))throw new Error(`No casting function for type: ${e.type}`);
63
- let n=t.types[e.type];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let r=dr[e.type];if(!r)throw new Error(
64
- `Type '${e.type}' cannot be exported to JSON Schema without a toJsonSchema hook.`);return r}function yr(t,e,n){if(!Object.
65
- hasOwn(t.validators,e))return null;let r=t.validators[e];if(typeof r.toJsonSchema=="function")return r.toJsonSchema;let o=fr[e];
66
- if(o)return o;throw new Error(`Validator '${e}' on field '${n}' cannot be exported to JSON Schema without a toJsonSchema\
67
- hook.`)}function lt(t){if(t===void 0)return"create";if(["create","replace","patch"].includes(t))return t;throw new Error(
68
- `Unsupported JSON Schema export mode '${t}'. Expected 'create', 'replace', or 'patch'.`)}function wr(t,e={}){if(e.mode!==
69
- void 0&&e.operation!==void 0){let n=lt(e.mode);if(n!==e.operation)throw new Error(`Conflicting JSON Schema export option\
70
- s: mode '${n}' does not match operation '${e.operation}'.`)}if(e.operation!==void 0){if(!Object.hasOwn(t.operations,e.operation))
71
- throw new Error(`Unknown JSON Schema export operation '${e.operation}'.`);return e.operation}return lt(e.mode)}function gr(t,e={}){
72
- if(e.operationName!==void 0&&e.operationDescriptor!==void 0)return{operationName:e.operationName,operation:e.operationDescriptor};
73
- let n=wr(t,e);return{operationName:n,operation:t.operations[n]}}function br(t={}){let e={...t};return Object.defineProperty(
74
- e,ye,{value:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null},enumerable:!1}),e}function te(t={}){return t[ye]?
75
- t[ye]:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null}}function Er(t){return String(t).replace(/[^a-zA-Z0-9]+/g,
76
- "_").replace(/^_+|_+$/g,"")||"operation"}function we(t){return y(t)&&Object.keys(t).length===1&&typeof t.$ref=="string"}
77
- function ee(t){return we(t)?{allOf:[t]}:t}function vr(t,e,n,r,o){return t.nodes.find(i=>i.schema===e&&i.operationName===
78
- n&&i.operation===r&&i.additionalProperties===o)||null}function Or(t,e){let n=Er(e),r=`SchemaNode_${t.nextDefinitionId}_${n}`;
79
- return t.nextDefinitionId+=1,r}function ut(t,e,n,r,o,{root:i=!1}={}){let s=te(e),a=vr(s,t,n,r,o);if(a)return i&&(a.pointer=
80
- "#",s.rootNode=a),a;let c={schema:t,operationName:n,operation:r,additionalProperties:o,status:"new",definitionName:i?null:
81
- Or(s,n),pointer:i?"#":null};return i?s.rootNode=c:c.pointer=`#/definitions/${c.definitionName}`,s.nodes.push(c),c}function dt(t,e){
82
- if(t.status==="built")return{$ref:t.pointer};if(t.status==="building")return{$ref:t.pointer};let n=te(e);t.status="build\
83
- ing",t.pointer!=="#"&&(n.definitions[t.definitionName]={});let r=Sr(t.schema,e,t.operationName,t.operation,t.additionalProperties);
84
- return t.status="built",t.pointer==="#"?r:(n.definitions[t.definitionName]=r,{$ref:t.pointer})}function ve(t,e,n,r,o=!1){
85
- let i=te(e),s=ut(t,e,n,r,o);return i.rootNode===s?{$ref:"#"}:dt(s,e)}function G(t,{referenceBacked:e=!1}={}){return{schema:t,
86
- referenceBacked:e}}function Sr(t,e,n,r,o=!1){let i={},s=[];for(let[c,l]of Object.entries(t.structure))p(i,c,Oe(t,c,l,e,n,
87
- r)),r.enforceRequired&&l.required===!0&&s.push(c);let a={type:"object",properties:i,additionalProperties:o};return s.length>
88
- 0&&(a.required=s),a}function Cr(t,e,n,r,o,i){let s=K(e,n);if(!s)return null;if(s.kind==="schema")return{...ee(ve(s.schema,
89
- r,"replace",s.schema.operations.replace,!1)),[_]:{castType:"object"}};let a=n.items.type==="object"&&Object.hasOwn(n.items,
90
- "schema")?"replace":o,c=a==="replace"?t.operations.replace:i;return Oe(t,`${e}[]`,n.items,r,a,c)}function _r(t,e,n,r,o,i){
91
- let s=J(e,n);if(!s)return null;if(s.kind==="schema")return{...ee(ve(s.schema,r,"replace",s.schema.operations.replace,!1)),
92
- [_]:{castType:"object"}};let a=s.definition.type==="object"&&Object.hasOwn(s.definition,"schema")?"replace":o,c=a==="rep\
93
- lace"?t.operations.replace:i;return Oe(t,`${e}.*`,s.definition,r,a,c)}function Tr(t,e,n,r,o,i){if(n.type==="object"){let a=Z(
94
- e,n);if(a.kind==="nested")return G(ve(a.schema,r,o,i,a.allowAdditionalProperties===!0),{referenceBacked:!0});if(a.kind===
95
- "opaque")return G({type:"object",additionalProperties:!0});if(a.kind==="map")return G({type:"object",additionalProperties:_r(
96
- t,e,n,r,o,i)})}let s=hr(t,n)({schema:t,fieldName:e,definition:n,operation:o,mode:o,options:r});if(!s||typeof s!="object"||
97
- Array.isArray(s))throw new Error(`Type '${n.type}' on field '${e}' returned an invalid JSON Schema fragment.`);if(n.type===
98
- "array"){let a=Cr(t,e,n,r,o,i);if(a)return G({...s,items:a},{referenceBacked:we(s)})}return G(s,{referenceBacked:we(s)})}
99
- function Oe(t,e,n,r,o,i){let s={schema:t,fieldName:e,definition:n,operation:o,mode:o,options:r},a=Tr(t,e,n,r,o,i),c=a.referenceBacked?
100
- ee(a.schema):{...a.schema},l={castType:n.type};for(let f of Object.keys(n)){if(f==="type"||!Object.hasOwn(t.validators,f))
101
- continue;let m=yr(t,f,e);if(!m)continue;let h=m({...s,parameterName:f,parameterValue:n[f],fieldSchema:{...c}});h&&pr(c,h)}
102
- c[_]&&(Ee(l,c[_]),delete c[_]);let u=[];n.nullable===!0&&u.push({type:"null"}),n.nullOnEmpty===!0&&u.push({const:""});let d=ee(
103
- mr(c,u));if(n.defaultTo!==void 0&&i.applyDefaults)if(typeof n.defaultTo!="function"){let f=t._normalizeDefault(n,n.defaultTo,
104
- {fieldPath:e,currentObject:{},containerKey:e,objectBeforeCast:{},options:{},settings:t._buildOperationSettings(o,i,{})});
105
- if(Object.keys(f.errors).length>0){let m=Object.values(f.errors)[0];throw new Error(`defaultTo for "${e}" is invalid (${m.
106
- code}).`)}d.default=f.value}else l.defaults={providedByFunction:!0};return d[_]=l,d}function ft(t,e={}){let n=br(e),{operationName:r,
107
- operation:o}=gr(t,n),i=n.additionalProperties===void 0?!1:n.additionalProperties,s=te(n),a=ut(t,n,r,o,i,{root:!0}),c={$schema:cr,
108
- ...dt(a,n)};return Object.keys(s.definitions).length>0&&(c.definitions=s.definitions),c}function pt(t){return t!==null&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}function Ie(t){return t instanceof
109
- k}function Ar(){return{self:!1,children:{}}}function mt(t){return Object.keys(t.children).length>0}function I(t,e){return`${t}\
110
- .${String(e)}`}function Et(t,e){return t===""?String(e):I(t,e)}function ht(t,e){if(t===e)return"";let n=`${e}.`;return t.
111
- startsWith(n)?t.slice(n.length):null}function M(t,e){let n={};for(let r of Object.values(t)){let o=I(e,r.field);p(n,o,{...r,
112
- field:o})}return n}function Te(t){return me(t,"validatePath")}function yt(t){let e={};for(let n of t){let r=Te(n),o=e;for(let i=0;i<
113
- r.length;i++){let s=r[i];Object.hasOwn(o,s)||p(o,s,Ar()),i===r.length-1&&(o[s].self=!0),o=o[s].children}}return e}function Ir(t,e){
114
- let n=t;for(let r of e){if(n==null||typeof n!="object"||!Object.hasOwn(n,r))return;n=n[r]}return n}function re(t){return t===
115
- null?!0:Array.isArray(t)||y(t)?Object.keys(t).length>0:t!==void 0}function wt(t){return[...t].sort((e,n)=>{let r=/^[0-9]+$/.
116
- test(e),o=/^[0-9]+$/.test(n);return r&&o?Number(e)-Number(n):r?-1:o?1:e.localeCompare(n)})}function Pr(t){return/^[0-9]+$/.
117
- test(t)}function jr(t,e=new WeakMap){if(e.has(t))return e.get(t);let n=Object.create(k.prototype);return e.set(t,n),n.structure=
118
- null,n.types=t.types,n.validators=t.validators,n.operations=t.operations,n.structure=oe(ne(t.structure,e)),n._installOperationMethods(),
119
- Object.freeze(n)}function ne(t,e=new WeakMap){if(t===null||typeof t!="object")return t;if(Ie(t))return jr(t,e);if(t instanceof
120
- Date)return new Date(t.getTime());if(t instanceof RegExp){let r=new RegExp(t.source,t.flags);return r.lastIndex=t.lastIndex,
121
- r}if(e.has(t))return e.get(t);if(Array.isArray(t)){let r=[];e.set(t,r);for(let o of t)r.push(ne(o,e));return r}if(!y(t))
122
- return t;let n={};e.set(t,n);for(let[r,o]of Object.entries(t))p(n,r,ne(o,e));return n}function oe(t,e=new WeakSet){if(t===
123
- null||typeof t!="object"||e.has(t)||Ie(t))return t;if(e.add(t),Array.isArray(t))for(let n of t)oe(n,e);else for(let n of Reflect.
124
- ownKeys(t))oe(t[n],e);return Object.freeze(t)}function Se(t){return oe(ne(t))}var Ce=new WeakMap;function Ae(t,e,n=""){if(!Ie(
125
- t)||!Array.isArray(e)||e.length<1)return null;let[r,...o]=e;if(!Object.hasOwn(t.structure,r))return null;let i=t.structure[r];
126
- if(o.length<1)return i;let s=Et(n,r);return vt(t,i,o,s)}function vt(t,e,n,r){if(e?.type==="object"){let o=t._resolveObjectFieldMode(
127
- r,e);return o.kind!=="nested"?null:Ae(o.schema,n,r)}if(e?.type==="array"){let o=t._resolveArrayItemsConfig(r,e);if(!o||n.
128
- length<1)return null;let[i,...s]=n;if(!Pr(i))return null;let a=I(r,i);return o.kind==="schema"?s.length<1?null:Ae(o.schema,
129
- s,a):s.length<1?o.definition:vt(t,o.definition,s,a)}return null}function D(t,e){let n={...t};if(Array.isArray(t.skipFields)){
130
- let r=t.skipFields.map(o=>ht(o,e)).filter(o=>o!==null&&o!=="");r.length>0?n.skipFields=r:delete n.skipFields}if(y(t.skipParams)){
131
- let r={};for(let[o,i]of Object.entries(t.skipParams)){let s=ht(o,e);s===null||s===""||p(r,s,i)}Object.keys(r).length>0?n.
132
- skipParams=r:delete n.skipParams}return n}var xr=Object.freeze({create:Object.freeze({targetFields:"schema",enforceRequired:!0,
43
+ eger","string"]}),epochMilliseconds:()=>$t(864e13),epochSeconds:()=>$t(864e10),dateTime:({definition:e,fieldName:t})=>({
44
+ type:"string",format:"date-time",pattern:Lt(e,t)}),date:()=>({type:"string",format:"date",pattern:jt}),time:({definition:e,
45
+ fieldName:t})=>({type:"string",pattern:kt(e,t)}),boolean:({definition:e})=>{if(e.strictBoolean===!0)return{type:"boolean"};
46
+ let t=new Set([...dn,String(e.stringTrueWhen||"true").trim().toLowerCase()]),n=new Set([...fn,String(e.stringFalseWhen||
47
+ "false").trim().toLowerCase()]);return{anyOf:[{type:"boolean"},{type:"number",enum:[0,1]},{type:"string",enum:[...n,...t]}]}},
48
+ id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},mn={minLength:({definition:e,parameterValue:t})=>e.
49
+ type==="string"?{minLength:t}:null,maxLength:({definition:e,parameterValue:t})=>e.type==="string"?{maxLength:t}:null,min:({
50
+ definition:e,parameterValue:t})=>q(e)?{minimum:t}:null,max:({definition:e,parameterValue:t})=>q(e)?{maximum:t}:null,pattern:({
51
+ definition:e,parameterValue:t})=>e.type==="string"?{pattern:t instanceof RegExp?t.source:t}:null,enum:({parameterValue:e})=>({
52
+ enum:e}),minItems:({definition:e,parameterValue:t})=>e.type==="array"?{minItems:t}:null,maxItems:({definition:e,parameterValue:t})=>e.
53
+ type==="array"?{maxItems:t}:null,notEmpty:({parameterValue:e,definition:t})=>!e||t.type==="array"?null:{minLength:1},uppercase:({
54
+ parameterValue:e})=>e?k("transforms",{uppercase:!0}):null,lowercase:({parameterValue:e})=>e?k("transforms",{lowercase:!0}):
55
+ null,length:({parameterValue:e})=>k("transforms",{length:e}),unsigned:({parameterValue:e})=>e?k("metadata",{unsigned:!0}):
56
+ null,precision:({parameterValue:e})=>k("metadata",{precision:e}),scale:({parameterValue:e})=>k("metadata",{scale:e}),temporalPrecision:({
57
+ parameterValue:e})=>k("metadata",{temporalPrecision:e}),strictBoolean:()=>null,required:()=>null,nullable:()=>null,nullOnEmpty:()=>null,
58
+ defaultTo:()=>null};function Le(e,t){for(let n of Object.keys(t)){let r=t[n],o=e[n];if(r&&o&&typeof r=="object"&&typeof o==
59
+ "object"&&!Array.isArray(r)&&!Array.isArray(o)){Le(o,r);continue}e[n]=r}}function hn(e,t){if(!t||typeof t!="object"||Array.
60
+ isArray(t))throw new Error("JSON Schema export hooks must return an object or null.");for(let n of Object.keys(t)){if(n===
61
+ M&&e[n]&&typeof e[n]=="object"&&typeof t[n]=="object"&&!Array.isArray(e[n])&&!Array.isArray(t[n])){Le(e[n],t[n]);continue}
62
+ e[n]=t[n]}}function yn(e,t){let r=[...Array.isArray(e.anyOf)&&Object.keys(e).length===1?e.anyOf:[e],...t];return r.length===
63
+ 1?e:{anyOf:r}}function wn(e,t){if(!Object.hasOwn(e.types,t.type))throw new Error(`No casting function for type: ${t.type}`);
64
+ let n=e.types[t.type];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let r=pn[t.type];if(!r)throw new Error(
65
+ `Type '${t.type}' cannot be exported to JSON Schema without a toJsonSchema hook.`);return r}function gn(e,t,n){if(!Object.
66
+ hasOwn(e.validators,t))return null;let r=e.validators[t];if(typeof r.toJsonSchema=="function")return r.toJsonSchema;let o=mn[t];
67
+ if(o)return o;throw new Error(`Validator '${t}' on field '${n}' cannot be exported to JSON Schema without a toJsonSchema\
68
+ hook.`)}function Ft(e){if(e===void 0)return"create";if(["create","replace","patch"].includes(e))return e;throw new Error(
69
+ `Unsupported JSON Schema export mode '${e}'. Expected 'create', 'replace', or 'patch'.`)}function bn(e,t={}){if(t.mode!==
70
+ void 0&&t.operation!==void 0){let n=Ft(t.mode);if(n!==t.operation)throw new Error(`Conflicting JSON Schema export option\
71
+ s: mode '${n}' does not match operation '${t.operation}'.`)}if(t.operation!==void 0){if(!Object.hasOwn(e.operations,t.operation))
72
+ throw new Error(`Unknown JSON Schema export operation '${t.operation}'.`);return t.operation}return Ft(t.mode)}function En(e,t={}){
73
+ if(t.operationName!==void 0&&t.operationDescriptor!==void 0)return{operationName:t.operationName,operation:t.operationDescriptor};
74
+ let n=bn(e,t);return{operationName:n,operation:e.operations[n]}}function On(e={}){let t={...e};return Object.defineProperty(
75
+ t,De,{value:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null},enumerable:!1}),t}function we(e={}){return e[De]?
76
+ e[De]:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null}}function vn(e){return String(e).replace(/[^a-zA-Z0-9]+/g,
77
+ "_").replace(/^_+|_+$/g,"")||"operation"}function Me(e){return O(e)&&Object.keys(e).length===1&&typeof e.$ref=="string"}
78
+ function ye(e){return Me(e)?{allOf:[e]}:e}function Sn(e,t,n,r,o){return e.nodes.find(i=>i.schema===t&&i.operationName===
79
+ n&&i.operation===r&&i.additionalProperties===o)||null}function An(e,t){let n=vn(t),r=`SchemaNode_${e.nextDefinitionId}_${n}`;
80
+ return e.nextDefinitionId+=1,r}function qt(e,t,n,r,o,{root:i=!1}={}){let s=we(t),a=Sn(s,e,n,r,o);if(a)return i&&(a.pointer=
81
+ "#",s.rootNode=a),a;let c={schema:e,operationName:n,operation:r,additionalProperties:o,status:"new",definitionName:i?null:
82
+ An(s,n),pointer:i?"#":null};return i?s.rootNode=c:c.pointer=`#/definitions/${c.definitionName}`,s.nodes.push(c),c}function Ut(e,t){
83
+ if(e.status==="built")return{$ref:e.pointer};if(e.status==="building")return{$ref:e.pointer};let n=we(t);e.status="build\
84
+ ing",e.pointer!=="#"&&(n.definitions[e.definitionName]={});let r=In(e.schema,t,e.operationName,e.operation,e.additionalProperties);
85
+ return e.status="built",e.pointer==="#"?r:(n.definitions[e.definitionName]=r,{$ref:e.pointer})}function $e(e,t,n,r,o=!1){
86
+ let i=we(t),s=qt(e,t,n,r,o);return i.rootNode===s?{$ref:"#"}:Ut(s,t)}function se(e,{referenceBacked:t=!1}={}){return{schema:e,
87
+ referenceBacked:t}}function In(e,t,n,r,o=!1){let i={},s=[];for(let[c,u]of Object.entries(e.structure))h(i,c,Fe(e,c,u,t,n,
88
+ r)),r.enforceRequired&&u.required===!0&&s.push(c);let a={type:"object",properties:i,additionalProperties:o};return s.length>
89
+ 0&&(a.required=s),a}function Cn(e,t,n,r,o,i){let s=pe(t,n);if(!s)return null;if(s.kind==="schema")return{...ye($e(s.schema,
90
+ r,"replace",s.schema.operations.replace,!1)),[M]:{castType:"object"}};let a=n.items.type==="object"&&Object.hasOwn(n.items,
91
+ "schema")?"replace":o,c=a==="replace"?e.operations.replace:i;return Fe(e,`${t}[]`,n.items,r,a,c)}function _n(e,t,n,r,o,i){
92
+ let s=oe(t,n);if(!s)return null;if(s.kind==="schema")return{...ye($e(s.schema,r,"replace",s.schema.operations.replace,!1)),
93
+ [M]:{castType:"object"}};let a=s.definition.type==="object"&&Object.hasOwn(s.definition,"schema")?"replace":o,c=a==="rep\
94
+ lace"?e.operations.replace:i;return Fe(e,`${t}.*`,s.definition,r,a,c)}function Tn(e,t,n,r,o,i){if(n.type==="object"){let a=me(
95
+ t,n);if(a.kind==="nested")return se($e(a.schema,r,o,i,a.allowAdditionalProperties===!0),{referenceBacked:!0});if(a.kind===
96
+ "opaque")return se({type:"object",additionalProperties:!0});if(a.kind==="map")return se({type:"object",additionalProperties:_n(
97
+ e,t,n,r,o,i)})}let s=wn(e,n)({schema:e,fieldName:t,definition:n,operation:o,mode:o,options:r});if(!s||typeof s!="object"||
98
+ Array.isArray(s))throw new Error(`Type '${n.type}' on field '${t}' returned an invalid JSON Schema fragment.`);if(n.type===
99
+ "array"){let a=Cn(e,t,n,r,o,i);if(a)return se({...s,items:a},{referenceBacked:Me(s)})}return se(s,{referenceBacked:Me(s)})}
100
+ function Fe(e,t,n,r,o,i){let s={schema:e,fieldName:t,definition:n,operation:o,mode:o,options:r},a=Tn(e,t,n,r,o,i),c=a.referenceBacked?
101
+ ye(a.schema):{...a.schema},u={castType:n.type};for(let f of Object.keys(n)){if(f==="type"||!Object.hasOwn(e.validators,f))
102
+ continue;let p=gn(e,f,t);if(!p)continue;let m=p({...s,parameterName:f,parameterValue:n[f],fieldSchema:{...c}});m&&hn(c,m)}
103
+ c[M]&&(Le(u,c[M]),delete c[M]);let l=[];n.nullable===!0&&l.push({type:"null"}),n.nullOnEmpty===!0&&l.push({const:""});let d=ye(
104
+ yn(c,l));if(n.defaultTo!==void 0&&i.applyDefaults)if(typeof n.defaultTo!="function"){let f=e._normalizeDefault(n,n.defaultTo,
105
+ {fieldPath:t,currentObject:{},containerKey:t,objectBeforeCast:{},options:{},settings:e._buildOperationSettings(o,i,{})});
106
+ if(Object.keys(f.errors).length>0){let p=Object.values(f.errors)[0];throw new Error(`defaultTo for "${t}" is invalid (${p.
107
+ code}).`)}d.default=f.value}else u.defaults={providedByFunction:!0};return d[M]=u,d}function Vt(e,t={}){let n=On(t),{operationName:r,
108
+ operation:o}=En(e,n),i=n.additionalProperties===void 0?!1:n.additionalProperties,s=we(n),a=qt(e,n,r,o,i,{root:!0}),c={$schema:ln,
109
+ ...Ut(a,n)};return Object.keys(s.definitions).length>0&&(c.definitions=s.definitions),c}function Bt(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function Je(e){return e instanceof
110
+ H}function Pn(){return{self:!1,children:{}}}function Ht(e){return Object.keys(e.children).length>0}function L(e,t){return`${e}\
111
+ .${String(t)}`}function Xt(e,t){return e===""?String(t):L(e,t)}function Jt(e,t){if(e===t)return"";let n=`${t}.`;return e.
112
+ startsWith(n)?e.slice(n.length):null}function V(e,t){let n={};for(let r of Object.values(e)){let o=L(t,r.field);h(n,o,{...r,
113
+ field:o})}return n}function Be(e){return Re(e,"validatePath")}function Wt(e){let t={};for(let n of e){let r=Be(n),o=t;for(let i=0;i<
114
+ r.length;i++){let s=r[i];Object.hasOwn(o,s)||h(o,s,Pn()),i===r.length-1&&(o[s].self=!0),o=o[s].children}}return t}function jn(e,t){
115
+ let n=e;for(let r of t){if(n==null||typeof n!="object"||!Object.hasOwn(n,r))return;n=n[r]}return n}function ge(e){return e===
116
+ null?!0:Array.isArray(e)||O(e)?Object.keys(e).length>0:e!==void 0}function Gt(e){return[...e].sort((t,n)=>{let r=/^[0-9]+$/.
117
+ test(t),o=/^[0-9]+$/.test(n);return r&&o?Number(t)-Number(n):r?-1:o?1:t.localeCompare(n)})}function xn(e){return/^[0-9]+$/.
118
+ test(e)}function Rn(e,t=new WeakMap){if(t.has(e))return t.get(e);let n=Object.create(H.prototype);return t.set(e,n),n.structure=
119
+ null,n.types=e.types,n.validators=e.validators,n.operations=e.operations,n.structure=Ee(be(e.structure,t)),n._installOperationMethods(),
120
+ Object.freeze(n)}function be(e,t=new WeakMap){if(e===null||typeof e!="object")return e;if(Je(e))return Rn(e,t);if(e instanceof
121
+ Date)return new Date(e.getTime());if(e instanceof RegExp){let r=new RegExp(e.source,e.flags);return r.lastIndex=e.lastIndex,
122
+ r}if(t.has(e))return t.get(e);if(Array.isArray(e)){let r=[];t.set(e,r);for(let o of e)r.push(be(o,t));return r}if(!O(e))
123
+ return e;let n={};t.set(e,n);for(let[r,o]of Object.entries(e))h(n,r,be(o,t));return n}function Ee(e,t=new WeakSet){if(e===
124
+ null||typeof e!="object"||t.has(e)||Je(e))return e;if(t.add(e),Array.isArray(e))for(let n of e)Ee(n,t);else for(let n of Reflect.
125
+ ownKeys(e))Ee(e[n],t);return Object.freeze(e)}function qe(e){return Ee(be(e))}var Ue=new WeakMap;function He(e,t,n=""){if(!Je(
126
+ e)||!Array.isArray(t)||t.length<1)return null;let[r,...o]=t;if(!Object.hasOwn(e.structure,r))return null;let i=e.structure[r];
127
+ if(o.length<1)return i;let s=Xt(n,r);return Zt(e,i,o,s)}function Zt(e,t,n,r){if(t?.type==="object"){let o=e._resolveObjectFieldMode(
128
+ r,t);return o.kind!=="nested"?null:He(o.schema,n,r)}if(t?.type==="array"){let o=e._resolveArrayItemsConfig(r,t);if(!o||n.
129
+ length<1)return null;let[i,...s]=n;if(!xn(i))return null;let a=L(r,i);return o.kind==="schema"?s.length<1?null:He(o.schema,
130
+ s,a):s.length<1?o.definition:Zt(e,o.definition,s,a)}return null}function B(e,t){let n={...e};if(Array.isArray(e.skipFields)){
131
+ let r=e.skipFields.map(o=>Jt(o,t)).filter(o=>o!==null&&o!=="");r.length>0?n.skipFields=r:delete n.skipFields}if(O(e.skipParams)){
132
+ let r={};for(let[o,i]of Object.entries(e.skipParams)){let s=Jt(o,t);s===null||s===""||h(r,s,i)}Object.keys(r).length>0?n.
133
+ skipParams=r:delete n.skipParams}return n}var Nn=Object.freeze({create:Object.freeze({targetFields:"schema",enforceRequired:!0,
133
134
  applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),replace:Object.freeze({targetFields:"schema",enforceRequired:!0,
134
135
  applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),patch:Object.freeze({targetFields:"input",enforceRequired:!1,
135
- applyDefaults:!1,outputFields:"input",rejectExplicitUndefined:!0})});function gt(t,e,n,r){let o=e[n];if(!r.includes(o))throw new Error(
136
- `Operation "${t}" must define ${n} as one of: ${r.join(", ")}.`)}function _e(t,e,n,r=!0){let o=e[n];if(!(o===void 0&&!r)&&
137
- typeof o!="boolean")throw new Error(`Operation "${t}" must define ${n} as a boolean.`)}function Rr(t,e){if(typeof e!="ob\
138
- ject"||e===null||Array.isArray(e))throw new Error(`Operation "${t}" must be an object.`);return gt(t,e,"targetFields",["\
139
- schema","input"]),_e(t,e,"enforceRequired"),_e(t,e,"applyDefaults"),gt(t,e,"outputFields",["validated","input"]),_e(t,e,
140
- "rejectExplicitUndefined",!1),Object.freeze({targetFields:e.targetFields,enforceRequired:e.enforceRequired,applyDefaults:e.
141
- applyDefaults,outputFields:e.outputFields,rejectExplicitUndefined:e.rejectExplicitUndefined===void 0?!0:e.rejectExplicitUndefined})}
142
- function Nr(t={}){if(typeof t!="object"||t===null||Array.isArray(t))throw new Error("Schema operations must be an object\
143
- .");let e=Object.create(null);for(let[n,r]of Object.entries(xr))p(e,n,r);for(let[n,r]of Object.entries(t))p(e,n,Rr(n,r));
144
- return Object.freeze(e)}function bt(t){let e=Object.create(null);for(let[n,r]of Object.entries(t))p(e,n,r);return Object.
145
- freeze(e)}function Mr(t){let e={...t};return delete e.operation,delete e.mode,e}var k=class{constructor(e,n,r,o={}){de(e),
146
- this.structure=e,this.types=bt(n),this.validators=bt(r),this.operations=Nr(o),this._installOperationMethods()}_typeError(e){
147
- return this._paramError(e,"TYPE_CAST_FAILED","Value could not be cast to the required type.")}_paramError(e,n,r,o={}){let i=new Error(
148
- r);return i.errorObject={field:e,code:n,message:r,params:o},i}_paramToBeSkipped(e,n,r){return typeof n!="object"||n===null?
149
- !1:!!(Array.isArray(n[r])&&n[r].includes(e))}_fieldToBeSkipped(e,n){return Array.isArray(n.skipFields)&&n.skipFields.includes(
150
- e)}_mergeErrors(e,n){for(let[r,o]of Object.entries(n))p(e,r,o)}_singleErrorMap(e){let n={};return p(n,e.field,e),n}_assertSupportedOptions(e={}){
151
- if(Object.hasOwn(e,"onlyObjectValues"))throw new Error("Unsupported validation option `onlyObjectValues`. Call `patch()`\
152
- directly.");if(Object.hasOwn(e,"mode"))throw new Error("Unsupported validation option `mode`. Call `validateWith()` or \
153
- an operation method directly.");if(Object.hasOwn(e,"operation"))throw new Error("Unsupported validation option `operatio\
154
- n`. Call `validateWith()` or an operation method directly.")}_buildOperationSettings(e,n,r){return{operationName:e,operation:n,
136
+ applyDefaults:!1,outputFields:"input",rejectExplicitUndefined:!0})});function Kt(e,t,n,r){let o=t[n];if(!r.includes(o))throw new Error(
137
+ `Operation "${e}" must define ${n} as one of: ${r.join(", ")}.`)}function Ve(e,t,n,r=!0){let o=t[n];if(!(o===void 0&&!r)&&
138
+ typeof o!="boolean")throw new Error(`Operation "${e}" must define ${n} as a boolean.`)}function Dn(e,t){if(typeof t!="ob\
139
+ ject"||t===null||Array.isArray(t))throw new Error(`Operation "${e}" must be an object.`);return Kt(e,t,"targetFields",["\
140
+ schema","input"]),Ve(e,t,"enforceRequired"),Ve(e,t,"applyDefaults"),Kt(e,t,"outputFields",["validated","input"]),Ve(e,t,
141
+ "rejectExplicitUndefined",!1),Object.freeze({targetFields:t.targetFields,enforceRequired:t.enforceRequired,applyDefaults:t.
142
+ applyDefaults,outputFields:t.outputFields,rejectExplicitUndefined:t.rejectExplicitUndefined===void 0?!0:t.rejectExplicitUndefined})}
143
+ function Mn(e={}){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error("Schema operations must be an object\
144
+ .");let t=Object.create(null);for(let[n,r]of Object.entries(Nn))h(t,n,r);for(let[n,r]of Object.entries(e))h(t,n,Dn(n,r));
145
+ return Object.freeze(t)}function Yt(e){let t=Object.create(null);for(let[n,r]of Object.entries(e))h(t,n,r);return Object.
146
+ freeze(t)}function zn(e){let t={...e};return delete t.operation,delete t.mode,t}var H=class{constructor(t,n,r,o={}){Pe(t),
147
+ this.structure=t,this.types=Yt(n),this.validators=Yt(r),this.operations=Mn(o),this._installOperationMethods()}_typeError(t){
148
+ return this._paramError(t,"TYPE_CAST_FAILED","Value could not be cast to the required type.")}_paramError(t,n,r,o={}){let i=new Error(
149
+ r);return i.errorObject={field:t,code:n,message:r,params:o},i}_paramToBeSkipped(t,n,r){return typeof n!="object"||n===null?
150
+ !1:!!(Array.isArray(n[r])&&n[r].includes(t))}_fieldToBeSkipped(t,n){return Array.isArray(n.skipFields)&&n.skipFields.includes(
151
+ t)}_mergeErrors(t,n){for(let[r,o]of Object.entries(n))h(t,r,o)}_singleErrorMap(t){let n={};return h(n,t.field,t),n}_assertSupportedOptions(t={}){
152
+ if(Object.hasOwn(t,"onlyObjectValues"))throw new Error("Unsupported validation option `onlyObjectValues`. Call `patch()`\
153
+ directly.");if(Object.hasOwn(t,"mode"))throw new Error("Unsupported validation option `mode`. Call `validateWith()` or \
154
+ an operation method directly.");if(Object.hasOwn(t,"operation"))throw new Error("Unsupported validation option `operatio\
155
+ n`. Call `validateWith()` or an operation method directly.")}_buildOperationSettings(t,n,r){return{operationName:t,operation:n,
155
156
  targetFieldNames:n.targetFields==="input"?Object.keys(r):Object.keys(this.structure),outputFieldNames:n.outputFields==="\
156
157
  input"?Object.keys(r):Object.keys(this.structure),enforceRequired:n.enforceRequired,applyDefaults:n.applyDefaults,rejectExplicitUndefined:n.
157
- rejectExplicitUndefined,defaultedFields:new Set,isFieldPresent:o=>Object.hasOwn(r,o)}}_assertPlainObjectInput(e,n){if(!y(
158
- n))throw new Error(`${e}() expects a plain object input.`)}_resolvePathValidationRequest(e={}){let n=e.operation??e.mode??
159
- "patch";if(Object.hasOwn(e,"operation")&&Object.hasOwn(e,"mode")&&e.operation!==e.mode)throw new Error("Path validation \
158
+ rejectExplicitUndefined,defaultedFields:new Set,isFieldPresent:o=>Object.hasOwn(r,o)}}_assertPlainObjectInput(t,n){if(!O(
159
+ n))throw new Error(`${t}() expects a plain object input.`)}_resolvePathValidationRequest(t={}){let n=t.operation??t.mode??
160
+ "patch";if(Object.hasOwn(t,"operation")&&Object.hasOwn(t,"mode")&&t.operation!==t.mode)throw new Error("Path validation \
160
161
  options `operation` and `mode` must match when both are provided.");if(!Object.hasOwn(this.operations,n))throw new Error(
161
- `Unknown operation "${n}".`);let r=this.operations[n];return{operationName:n,operation:r,validationOptions:Mr(e)}}_buildOperationResult(e,n,r){
162
+ `Unknown operation "${n}".`);let r=this.operations[n];return{operationName:n,operation:r,validationOptions:zn(t)}}_buildOperationResult(t,n,r){
162
163
  let o={};for(let i of r.outputFieldNames){if(!Object.hasOwn(this.structure,i))continue;let s=r.isFieldPresent(i);(n[i]!==
163
- void 0||s&&e[i]===null||r.defaultedFields.has(i))&&(!s&&!r.defaultedFields.has(i)||p(o,i,n[i]))}return o}_resolveObjectFieldMode(e,n){
164
- return Z(e,n)}_resolveArrayItemsConfig(e,n){return K(e,n)}_resolveObjectValuesConfig(e,n){return J(e,n)}_buildArrayItemSettings(e,n){
165
- return e.type==="object"&&Object.hasOwn(e,"schema")?{...n,operationName:"replace",operation:this.operations.replace}:n}_castValue(e,n,r,o,i,s,a,c){
166
- let l=e.nullable===!0||a.nullable===!0,u=e.nullOnEmpty===!0||a.nullOnEmpty===!0;if(!Object.hasOwn(this.types,e.type))throw new Error(
167
- `No casting function for type: ${e.type}`);let d=this.types[e.type];if(n===null)return l?(p(o,i,null),{errors:{},shouldContinue:!1}):
164
+ void 0||s&&t[i]===null||r.defaultedFields.has(i))&&(!s&&!r.defaultedFields.has(i)||h(o,i,n[i]))}return o}_resolveObjectFieldMode(t,n){
165
+ return me(t,n)}_resolveArrayItemsConfig(t,n){return pe(t,n)}_resolveObjectValuesConfig(t,n){return oe(t,n)}_buildArrayItemSettings(t,n){
166
+ return t.type==="object"&&Object.hasOwn(t,"schema")?{...n,operationName:"replace",operation:this.operations.replace}:n}_castValue(t,n,r,o,i,s,a,c){
167
+ let u=t.nullable===!0||a.nullable===!0,l=t.nullOnEmpty===!0||a.nullOnEmpty===!0;if(!Object.hasOwn(this.types,t.type))throw new Error(
168
+ `No casting function for type: ${t.type}`);let d=this.types[t.type];if(n===null)return u?(h(o,i,null),{errors:{},shouldContinue:!1}):
168
169
  {errors:this._singleErrorMap({field:r,code:"NOT_NULLABLE",message:"Field cannot be null",params:{}}),shouldContinue:!1};
169
- if(n===""&&u)return p(o,i,null),{errors:{},shouldContinue:!1};let f={schema:this,definition:e,value:n,fieldName:r,object:o,
170
+ if(n===""&&l)return h(o,i,null),{errors:{},shouldContinue:!1};let f={schema:this,definition:t,value:n,fieldName:r,object:o,
170
171
  objectBeforeCast:s,valueBeforeCast:n,options:a,mode:c.operationName,operation:c.operationName,fieldPresent:!0,computedOptions:{
171
- nullable:l||u,nullOnEmpty:u},throwTypeError:()=>{throw this._typeError(r)},throwParamError:(m,h,E)=>{throw this._paramError(
172
- r,m,h,E)}};try{let m=d(f);if(pt(m))throw new Error(`Type handler for "${e.type}" must be synchronous.`);m!==void 0&&(p(o,
173
- i,m),f.value=m)}catch(m){if(m.errorObject)return{errors:this._singleErrorMap(m.errorObject),shouldContinue:!1};throw m}return{
174
- errors:{},context:f,shouldContinue:!0}}_runFieldValidators(e,n,r,o,i,s){for(let a of Object.keys(e)){if(a==="type"||this.
172
+ nullable:u||l,nullOnEmpty:l},throwTypeError:()=>{throw this._typeError(r)},throwParamError:(p,m,v)=>{throw this._paramError(
173
+ r,p,m,v)}};try{let p=d(f);if(Bt(p))throw new Error(`Type handler for "${t.type}" must be synchronous.`);p!==void 0&&(h(o,
174
+ i,p),f.value=p)}catch(p){if(p.errorObject)return{errors:this._singleErrorMap(p.errorObject),shouldContinue:!1};throw p}return{
175
+ errors:{},context:f,shouldContinue:!0}}_runFieldValidators(t,n,r,o,i,s){for(let a of Object.keys(t)){if(a==="type"||this.
175
176
  _paramToBeSkipped(a,s.skipParams,n)||!Object.hasOwn(this.validators,a))continue;let c=this.validators[a];try{i.parameterName=
176
- a,i.parameterValue=e[a];let l=c(i);if(pt(l))throw new Error(`Validator handler for "${a}" must be synchronous.`);l!==void 0&&
177
- (p(r,o,l),i.value=l)}catch(l){if(l.errorObject)return this._singleErrorMap(l.errorObject);throw l}}return{}}_normalizeAndValidateValue(e,n,r,o,i,s,a,c){
178
- let l=this._castValue(e,n,r,o,i,s,a,c);if(Object.keys(l.errors).length>0)return l.errors;if(!l.shouldContinue)return{};let{
179
- context:u}=l,d=this._validateNestedValue(e,r,o,i,a,c);return Object.keys(d).length>0?d:(u.value=o[i],this._runFieldValidators(
180
- e,r,o,i,u,a))}_normalizeDefault(e,n,{fieldPath:r,currentObject:o,containerKey:i,objectBeforeCast:s,options:a,settings:c}){
181
- let l={...o};return p(l,i,n),{errors:this._normalizeAndValidateValue(e,n,r,l,i,s,a,c),value:l[i]}}_validateNestedValue(e,n,r,o,i,s){
182
- if(e.type==="object"){let c=this._resolveObjectFieldMode(n,e);return c.kind==="nested"?this._validateNestedObjectSchema(
183
- c,n,r,o,i,s):c.kind==="map"?this._validateObjectValues(n,r,o,c.valuesConfig,i,s):{}}if(e.type!=="array")return{};let a=this.
184
- _resolveArrayItemsConfig(n,e);return a?this._validateArrayItems(n,r,o,a,i,s):{}}_validateNestedObjectSchema(e,n,r,o,i,s){
185
- let a=r[o],c=e.allowAdditionalProperties?this._extractKnownObjectFields(a,e.schema):a,l=e.schema._validateWithOperation(
186
- s.operationName,s.operation,c,D(i,n));return p(r,o,e.allowAdditionalProperties?this._mergeKnownAndPassthroughObjectFields(
187
- a,e.schema,l.validatedObject):l.validatedObject),M(l.errors,n)}_extractKnownObjectFields(e,n){let r={};for(let[o,i]of Object.
188
- entries(e))Object.hasOwn(n.structure,o)&&p(r,o,i);return r}_mergeKnownAndPassthroughObjectFields(e,n,r){let o={};for(let i of Object.
189
- keys(e)){if(!Object.hasOwn(n.structure,i)){p(o,i,e[i]);continue}Object.hasOwn(r,i)&&p(o,i,r[i])}for(let[i,s]of Object.entries(
190
- r))Object.hasOwn(o,i)||p(o,i,s);return o}_validateObjectValues(e,n,r,o,i,s){let a=n[r],c={...a},l={};p(n,r,c);for(let u of Object.
191
- keys(a)){let d=I(e,u);if(this._fieldToBeSkipped(d,i))continue;let f=c[u];if(f===void 0){s.rejectExplicitUndefined?this._mergeErrors(
192
- l,this._singleErrorMap(this._typeError(d).errorObject)):delete c[u];continue}if(o.kind==="schema"){let h=o.schema._validateWithOperation(
193
- "replace",o.schema.operations.replace,f,D(i,d));p(c,u,h.validatedObject),this._mergeErrors(l,M(h.errors,d));continue}let m=this.
194
- _normalizeAndValidateValue(o.definition,f,d,c,u,a,i,this._buildArrayItemSettings(o.definition,s));this._mergeErrors(l,m)}
195
- return l}_validateArrayItems(e,n,r,o,i,s){let a=n[r],c=a.slice(),l={};p(n,r,c);for(let u=0;u<c.length;u++){let d=I(e,u);
196
- if(this._fieldToBeSkipped(d,i))continue;if(!Object.hasOwn(a,u)||c[u]===void 0){s.rejectExplicitUndefined?this._mergeErrors(
197
- l,this._singleErrorMap(this._typeError(d).errorObject)):delete c[u];continue}if(o.kind==="schema"){let m=o.schema._validateWithOperation(
198
- "replace",o.schema.operations.replace,c[u],D(i,d));p(c,u,m.validatedObject),this._mergeErrors(l,M(m.errors,d));continue}
199
- let f=this._normalizeAndValidateValue(o.definition,c[u],d,c,u,a,i,this._buildArrayItemSettings(o.definition,s));this._mergeErrors(
200
- l,f)}return l}_validateField(e,n,r,o,i){if(!Object.hasOwn(this.structure,e))return{};let s=this.structure[e];if(this._fieldToBeSkipped(
201
- e,o))return{};let a=i.isFieldPresent(e),c=n[e],l=c===void 0;return i.enforceRequired&&s.required&&(!a||l)&&!this._paramToBeSkipped(
202
- "required",o.skipParams,e)?this._singleErrorMap({field:e,code:"REQUIRED",message:"Field is required",params:{}}):a?l?i.rejectExplicitUndefined?
203
- this._singleErrorMap(this._typeError(e).errorObject):{}:this._normalizeAndValidateValue(s,c,e,r,e,n,o,i):{}}_validateWithOperation(e,n,r,o){
204
- this._assertSupportedOptions(o);let i={},s={...r},a=this._buildOperationSettings(e,n,r);for(let c of Object.keys(r))Object.
205
- hasOwn(this.structure,c)||p(i,c,{field:c,code:"FIELD_NOT_ALLOWED",message:"Field not allowed",params:{}});for(let c of a.
206
- targetFieldNames){let l=this._validateField(c,r,s,o,a);this._mergeErrors(i,l)}if(a.applyDefaults){for(let c of Object.keys(
207
- this.structure))if(!a.isFieldPresent(c)&&this.structure[c].defaultTo!==void 0){let l=this.structure[c],u=typeof l.defaultTo==
208
- "function"?l.defaultTo():l.defaultTo,d=this._normalizeDefault(l,u,{fieldPath:c,currentObject:s,containerKey:c,objectBeforeCast:r,
209
- options:o,settings:a});if(this._mergeErrors(i,d.errors),Object.keys(d.errors).length>0)continue;p(s,c,d.value),a.defaultedFields.
210
- add(c)}}return{validatedObject:this._buildOperationResult(r,s,a),errors:i}}_validateSelectedTree(e,n,r,o,i=""){let s={},
211
- a={};for(let c of wt(Object.keys(e))){let l=Et(i,c);if(!Object.hasOwn(this.structure,c))throw new Error(`Unknown schema \
212
- path "${l}".`);let u=this._validateSelectedField(c,e[c],n,a,r,o,l);this._mergeErrors(s,u)}return{validatedObject:a,errors:s}}_validateSelectedField(e,n,r,o,i,s,a){
213
- if(!Object.hasOwn(this.structure,e))return{};let c=this.structure[e],l=n.self===!0,u=mt(n);if(this._fieldToBeSkipped(a,i))
214
- return{};let d=Object.hasOwn(r,e),f=r[e],m={};if(!d){if(l&&s.enforceRequired&&c.required&&!this._paramToBeSkipped("requi\
215
- red",i.skipParams,a)&&this._mergeErrors(m,this._singleErrorMap({field:a,code:"REQUIRED",message:"Field is required",params:{}})),
216
- l&&s.applyDefaults&&c.defaultTo!==void 0){let v=typeof c.defaultTo=="function"?c.defaultTo():c.defaultTo,T=this._normalizeDefault(
217
- c,v,{fieldPath:a,currentObject:o,containerKey:e,objectBeforeCast:r,options:i,settings:s});this._mergeErrors(m,T.errors),
218
- Object.keys(T.errors).length===0&&p(o,e,T.value)}return m}if(f===void 0)return l&&s.rejectExplicitUndefined?this._singleErrorMap(
219
- this._typeError(a).errorObject):{};let h={[e]:f};if(l){let v=this._normalizeAndValidateValue(c,f,a,h,e,r,i,s);return Object.
220
- hasOwn(h,e)&&h[e]!==void 0?p(o,e,h[e]):h[e]===null&&p(o,e,null),v}if(!u)return{};let E=this._castValue(c,f,a,h,e,r,i,s);
221
- if(Object.keys(E.errors).length>0)return E.errors;if(!E.shouldContinue)return{};let x=this._validateSelectedDescendants(
222
- c,n.children,a,h,e,i,s);return re(h[e])&&p(o,e,h[e]),x}_validateSelectedDescendants(e,n,r,o,i,s,a){if(e.type==="object"){
223
- let c=this._resolveObjectFieldMode(r,e);if(c.kind!=="nested")throw new Error(`Schema path "${r}" does not support nested\
224
- field selection.`);let l=o[i];if(!y(l))return{};let u=c.schema._validateSelectedTree(n,l,D(s,r),{...a,defaultedFields:new Set});
225
- return p(o,i,u.validatedObject),M(u.errors,r)}if(e.type==="array"){let c=this._resolveArrayItemsConfig(r,e);if(!c)throw new Error(
177
+ a,i.parameterValue=t[a];let u=c(i);if(Bt(u))throw new Error(`Validator handler for "${a}" must be synchronous.`);u!==void 0&&
178
+ (h(r,o,u),i.value=u)}catch(u){if(u.errorObject)return this._singleErrorMap(u.errorObject);throw u}}return{}}_normalizeAndValidateValue(t,n,r,o,i,s,a,c){
179
+ let u=this._castValue(t,n,r,o,i,s,a,c);if(Object.keys(u.errors).length>0)return u.errors;if(!u.shouldContinue)return{};let{
180
+ context:l}=u,d=this._validateNestedValue(t,r,o,i,a,c);return Object.keys(d).length>0?d:(l.value=o[i],this._runFieldValidators(
181
+ t,r,o,i,l,a))}_normalizeDefault(t,n,{fieldPath:r,currentObject:o,containerKey:i,objectBeforeCast:s,options:a,settings:c}){
182
+ let u={...o};return h(u,i,n),{errors:this._normalizeAndValidateValue(t,n,r,u,i,s,a,c),value:u[i]}}_validateNestedValue(t,n,r,o,i,s){
183
+ if(t.type==="object"){let c=this._resolveObjectFieldMode(n,t);return c.kind==="nested"?this._validateNestedObjectSchema(
184
+ c,n,r,o,i,s):c.kind==="map"?this._validateObjectValues(n,r,o,c.valuesConfig,i,s):{}}if(t.type!=="array")return{};let a=this.
185
+ _resolveArrayItemsConfig(n,t);return a?this._validateArrayItems(n,r,o,a,i,s):{}}_validateNestedObjectSchema(t,n,r,o,i,s){
186
+ let a=r[o],c=t.allowAdditionalProperties?this._extractKnownObjectFields(a,t.schema):a,u=t.schema._validateWithOperation(
187
+ s.operationName,s.operation,c,B(i,n));return h(r,o,t.allowAdditionalProperties?this._mergeKnownAndPassthroughObjectFields(
188
+ a,t.schema,u.validatedObject):u.validatedObject),V(u.errors,n)}_extractKnownObjectFields(t,n){let r={};for(let[o,i]of Object.
189
+ entries(t))Object.hasOwn(n.structure,o)&&h(r,o,i);return r}_mergeKnownAndPassthroughObjectFields(t,n,r){let o={};for(let i of Object.
190
+ keys(t)){if(!Object.hasOwn(n.structure,i)){h(o,i,t[i]);continue}Object.hasOwn(r,i)&&h(o,i,r[i])}for(let[i,s]of Object.entries(
191
+ r))Object.hasOwn(o,i)||h(o,i,s);return o}_validateObjectValues(t,n,r,o,i,s){let a=n[r],c={...a},u={};h(n,r,c);for(let l of Object.
192
+ keys(a)){let d=L(t,l);if(this._fieldToBeSkipped(d,i))continue;let f=c[l];if(f===void 0){s.rejectExplicitUndefined?this._mergeErrors(
193
+ u,this._singleErrorMap(this._typeError(d).errorObject)):delete c[l];continue}if(o.kind==="schema"){let m=o.schema._validateWithOperation(
194
+ "replace",o.schema.operations.replace,f,B(i,d));h(c,l,m.validatedObject),this._mergeErrors(u,V(m.errors,d));continue}let p=this.
195
+ _normalizeAndValidateValue(o.definition,f,d,c,l,a,i,this._buildArrayItemSettings(o.definition,s));this._mergeErrors(u,p)}
196
+ return u}_validateArrayItems(t,n,r,o,i,s){let a=n[r],c=a.slice(),u={};h(n,r,c);for(let l=0;l<c.length;l++){let d=L(t,l);
197
+ if(this._fieldToBeSkipped(d,i))continue;if(!Object.hasOwn(a,l)||c[l]===void 0){s.rejectExplicitUndefined?this._mergeErrors(
198
+ u,this._singleErrorMap(this._typeError(d).errorObject)):delete c[l];continue}if(o.kind==="schema"){let p=o.schema._validateWithOperation(
199
+ "replace",o.schema.operations.replace,c[l],B(i,d));h(c,l,p.validatedObject),this._mergeErrors(u,V(p.errors,d));continue}
200
+ let f=this._normalizeAndValidateValue(o.definition,c[l],d,c,l,a,i,this._buildArrayItemSettings(o.definition,s));this._mergeErrors(
201
+ u,f)}return u}_validateField(t,n,r,o,i){if(!Object.hasOwn(this.structure,t))return{};let s=this.structure[t];if(this._fieldToBeSkipped(
202
+ t,o))return{};let a=i.isFieldPresent(t),c=n[t],u=c===void 0;return i.enforceRequired&&s.required&&(!a||u)&&!this._paramToBeSkipped(
203
+ "required",o.skipParams,t)?this._singleErrorMap({field:t,code:"REQUIRED",message:"Field is required",params:{}}):a?u?i.rejectExplicitUndefined?
204
+ this._singleErrorMap(this._typeError(t).errorObject):{}:this._normalizeAndValidateValue(s,c,t,r,t,n,o,i):{}}_validateWithOperation(t,n,r,o){
205
+ this._assertSupportedOptions(o);let i={},s={...r},a=this._buildOperationSettings(t,n,r);for(let c of Object.keys(r))Object.
206
+ hasOwn(this.structure,c)||h(i,c,{field:c,code:"FIELD_NOT_ALLOWED",message:"Field not allowed",params:{}});for(let c of a.
207
+ targetFieldNames){let u=this._validateField(c,r,s,o,a);this._mergeErrors(i,u)}if(a.applyDefaults){for(let c of Object.keys(
208
+ this.structure))if(!a.isFieldPresent(c)&&this.structure[c].defaultTo!==void 0){let u=this.structure[c],l=typeof u.defaultTo==
209
+ "function"?u.defaultTo():u.defaultTo,d=this._normalizeDefault(u,l,{fieldPath:c,currentObject:s,containerKey:c,objectBeforeCast:r,
210
+ options:o,settings:a});if(this._mergeErrors(i,d.errors),Object.keys(d.errors).length>0)continue;h(s,c,d.value),a.defaultedFields.
211
+ add(c)}}return{validatedObject:this._buildOperationResult(r,s,a),errors:i}}_validateSelectedTree(t,n,r,o,i=""){let s={},
212
+ a={};for(let c of Gt(Object.keys(t))){let u=Xt(i,c);if(!Object.hasOwn(this.structure,c))throw new Error(`Unknown schema \
213
+ path "${u}".`);let l=this._validateSelectedField(c,t[c],n,a,r,o,u);this._mergeErrors(s,l)}return{validatedObject:a,errors:s}}_validateSelectedField(t,n,r,o,i,s,a){
214
+ if(!Object.hasOwn(this.structure,t))return{};let c=this.structure[t],u=n.self===!0,l=Ht(n);if(this._fieldToBeSkipped(a,i))
215
+ return{};let d=Object.hasOwn(r,t),f=r[t],p={};if(!d){if(u&&s.enforceRequired&&c.required&&!this._paramToBeSkipped("requi\
216
+ red",i.skipParams,a)&&this._mergeErrors(p,this._singleErrorMap({field:a,code:"REQUIRED",message:"Field is required",params:{}})),
217
+ u&&s.applyDefaults&&c.defaultTo!==void 0){let T=typeof c.defaultTo=="function"?c.defaultTo():c.defaultTo,R=this._normalizeDefault(
218
+ c,T,{fieldPath:a,currentObject:o,containerKey:t,objectBeforeCast:r,options:i,settings:s});this._mergeErrors(p,R.errors),
219
+ Object.keys(R.errors).length===0&&h(o,t,R.value)}return p}if(f===void 0)return u&&s.rejectExplicitUndefined?this._singleErrorMap(
220
+ this._typeError(a).errorObject):{};let m={[t]:f};if(u){let T=this._normalizeAndValidateValue(c,f,a,m,t,r,i,s);return Object.
221
+ hasOwn(m,t)&&m[t]!==void 0?h(o,t,m[t]):m[t]===null&&h(o,t,null),T}if(!l)return{};let v=this._castValue(c,f,a,m,t,r,i,s);
222
+ if(Object.keys(v.errors).length>0)return v.errors;if(!v.shouldContinue)return{};let x=this._validateSelectedDescendants(
223
+ c,n.children,a,m,t,i,s);return ge(m[t])&&h(o,t,m[t]),x}_validateSelectedDescendants(t,n,r,o,i,s,a){if(t.type==="object"){
224
+ let c=this._resolveObjectFieldMode(r,t);if(c.kind!=="nested")throw new Error(`Schema path "${r}" does not support nested\
225
+ field selection.`);let u=o[i];if(!O(u))return{};let l=c.schema._validateSelectedTree(n,u,B(s,r),{...a,defaultedFields:new Set});
226
+ return h(o,i,l.validatedObject),V(l.errors,r)}if(t.type==="array"){let c=this._resolveArrayItemsConfig(r,t);if(!c)throw new Error(
226
227
  `Schema path "${r}" does not define array items for nested selection.`);return this._validateSelectedArrayItems(r,o,i,c,
227
- n,s,a)}throw new Error(`Schema path "${r}" does not support nested field selection.`)}_validateSelectedArrayItems(e,n,r,o,i,s,a){
228
- let c=[],l=n[r],u={};p(n,r,c);for(let d of wt(Object.keys(i))){if(!/^[0-9]+$/.test(d))throw new Error(`Schema path "${I(
229
- e,d)}" is invalid because array segments must use numeric indexes.`);let f=Number(d),m=I(e,f),h=i[d],E=h.self===!0,x=mt(
230
- h);if(this._fieldToBeSkipped(m,s))continue;if(!Object.hasOwn(l,f)){E&&a.rejectExplicitUndefined&&p(u,m,this._typeError(m).
231
- errorObject);continue}let v=l[f];if(v===void 0){E&&a.rejectExplicitUndefined&&p(u,m,this._typeError(m).errorObject);continue}
232
- if(o.kind==="schema"){if(E){let le=o.schema._validateWithOperation("replace",o.schema.operations.replace,v,D(s,m));re(le.
233
- validatedObject)&&p(c,f,le.validatedObject),this._mergeErrors(u,M(le.errors,m));continue}if(!x)continue;let V=o.schema._validateSelectedTree(
234
- h.children,v,D(s,m),{...a,operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});re(V.validatedObject)&&
235
- p(c,f,V.validatedObject),this._mergeErrors(u,M(V.errors,m));continue}let T=this._buildArrayItemSettings(o.definition,a),
236
- S=[v];if(E){let V=this._normalizeAndValidateValue(o.definition,v,m,S,0,l,s,T);Object.hasOwn(S,0)&&S[0]!==void 0?p(c,f,S[0]):
237
- S[0]===null&&p(c,f,null),this._mergeErrors(u,V);continue}if(!x)continue;let ce=this._castValue(o.definition,v,m,S,0,l,s,
238
- T);if(Object.keys(ce.errors).length>0){this._mergeErrors(u,ce.errors);continue}if(!ce.shouldContinue)continue;let Gt=this.
239
- _validateSelectedDescendants(o.definition,h.children,m,S,0,s,T);re(S[0])&&p(c,f,S[0]),this._mergeErrors(u,Gt)}return u}validateWith(e,n,r={}){
240
- if(!Object.hasOwn(this.operations,e))throw new Error(`Unknown operation "${e}".`);let o=this.operations[e];return this._assertPlainObjectInput(
241
- e,n),this._validateWithOperation(e,o,n,r)}validateAt(e,n,r={}){this._assertPlainObjectInput("validateAt",n);let o=Te(e),
242
- {operationName:i,operation:s,validationOptions:a}=this._resolvePathValidationRequest(r),c=this._validateSelectedTree(yt(
243
- [e]),n,a,this._buildOperationSettings(i,s,n));return{validatedValue:Ir(c.validatedObject,o),errors:c.errors}}validatePaths(e,n,r={}){
244
- if(this._assertPlainObjectInput("validatePaths",n),!Array.isArray(e)||e.length===0)throw new Error("validatePaths() expe\
228
+ n,s,a)}throw new Error(`Schema path "${r}" does not support nested field selection.`)}_validateSelectedArrayItems(t,n,r,o,i,s,a){
229
+ let c=[],u=n[r],l={};h(n,r,c);for(let d of Gt(Object.keys(i))){if(!/^[0-9]+$/.test(d))throw new Error(`Schema path "${L(
230
+ t,d)}" is invalid because array segments must use numeric indexes.`);let f=Number(d),p=L(t,f),m=i[d],v=m.self===!0,x=Ht(
231
+ m);if(this._fieldToBeSkipped(p,s))continue;if(!Object.hasOwn(u,f)){v&&a.rejectExplicitUndefined&&h(l,p,this._typeError(p).
232
+ errorObject);continue}let T=u[f];if(T===void 0){v&&a.rejectExplicitUndefined&&h(l,p,this._typeError(p).errorObject);continue}
233
+ if(o.kind==="schema"){if(v){let E=o.schema._validateWithOperation("replace",o.schema.operations.replace,T,B(s,p));ge(E.validatedObject)&&
234
+ h(c,f,E.validatedObject),this._mergeErrors(l,V(E.errors,p));continue}if(!x)continue;let b=o.schema._validateSelectedTree(
235
+ m.children,T,B(s,p),{...a,operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});ge(b.validatedObject)&&
236
+ h(c,f,b.validatedObject),this._mergeErrors(l,V(b.errors,p));continue}let R=this._buildArrayItemSettings(o.definition,a),
237
+ P=[T];if(v){let b=this._normalizeAndValidateValue(o.definition,T,p,P,0,u,s,R);Object.hasOwn(P,0)&&P[0]!==void 0?h(c,f,P[0]):
238
+ P[0]===null&&h(c,f,null),this._mergeErrors(l,b);continue}if(!x)continue;let te=this._castValue(o.definition,T,p,P,0,u,s,
239
+ R);if(Object.keys(te.errors).length>0){this._mergeErrors(l,te.errors);continue}if(!te.shouldContinue)continue;let re=this.
240
+ _validateSelectedDescendants(o.definition,m.children,p,P,0,s,R);ge(P[0])&&h(c,f,P[0]),this._mergeErrors(l,re)}return l}validateWith(t,n,r={}){
241
+ if(!Object.hasOwn(this.operations,t))throw new Error(`Unknown operation "${t}".`);let o=this.operations[t];return this._assertPlainObjectInput(
242
+ t,n),this._validateWithOperation(t,o,n,r)}validateAt(t,n,r={}){this._assertPlainObjectInput("validateAt",n);let o=Be(t),
243
+ {operationName:i,operation:s,validationOptions:a}=this._resolvePathValidationRequest(r),c=this._validateSelectedTree(Wt(
244
+ [t]),n,a,this._buildOperationSettings(i,s,n));return{validatedValue:jn(c.validatedObject,o),errors:c.errors}}validatePaths(t,n,r={}){
245
+ if(this._assertPlainObjectInput("validatePaths",n),!Array.isArray(t)||t.length===0)throw new Error("validatePaths() expe\
245
246
  cts a non-empty array of schema paths.");let{operationName:o,operation:i,validationOptions:s}=this._resolvePathValidationRequest(
246
- r);return this._validateSelectedTree(yt(e),n,s,this._buildOperationSettings(o,i,n))}_installOperationMethods(){for(let e of Object.
247
- keys(this.operations)){if(e in this)throw new Error(`Operation name "${e}" is reserved and cannot be used as a schema me\
248
- thod.`);this[e]=(n,r={})=>this.validateWith(e,n,r)}}toJsonSchema(e={}){return ft(this,e)}getFieldDefinitions(){return Ce.
249
- has(this)||Ce.set(this,Se(this.structure)),Ce.get(this)}getFieldDefinition(e){if(typeof e!="string"||e.trim()==="")throw new Error(
250
- "Field path must be a non-empty string.");let n=Ae(this,Te(e.trim()));return n===null?null:Se(n)}getFieldMessages(e){let n=this.
251
- getFieldDefinition(e);return!n||typeof n.messages!="object"||n.messages===null?Object.freeze({}):Se(n.messages)}cleanup(e,n){
252
- let r={};for(let o of Object.keys(e))Object.hasOwn(this.structure,o)&&this.structure[o][n]&&p(r,o,e[o]);return r}};var{parse:To,stringify:Dr}=JSON,{keys:Ao}=Object,kr=String,zr="string";var Ot="object",Lr=(t,e)=>e;var St=(t,e,n)=>{let r=kr(e.push(n)-1);return t.set(n,r),r};var Ct=(t,e,n)=>{let r=e&&typeof e===Ot?(u,d)=>u===""||-1<e.indexOf(u)?d:void 0:e||Lr,o=new Map,i=[],s=[],a=+St(o,i,r.call(
253
- {"":t},"",t)),c=!a;for(;a<i.length;)c=!0,s[a]=Dr(i[a++],l,n);return"["+s.join(",")+"]";function l(u,d){if(c)return c=!c,
254
- d;let f=r.call(this,u,d);switch(typeof f){case Ot:if(f===null)return f;case zr:return o.get(f)||St(o,i,f)}return f}};var Fr=new Set(["true","1","yes","y","on"]),Ur=new Set(["false","0","no","n","off"]);function qr(t){return t!==null&&(typeof t==
255
- "object"||typeof t=="function")&&typeof t.then=="function"}function _t(t){if(typeof t=="number")return Number.isFinite(t)?
256
- t:null;if(typeof t=="bigint"){let e=Number(t);return Number.isSafeInteger(e)?e:null}if(typeof t=="string"){let e=t.trim();
257
- if(e==="")return null;let n=Number(e);return Number.isFinite(n)?n:null}return null}function Pe(t,e){if(Object.is(t,e))return!0;
258
- if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();if(t instanceof RegExp&&e instanceof RegExp)return t.
259
- source===e.source&&t.flags===e.flags;if(Array.isArray(t)||Array.isArray(e)){if(!Array.isArray(t)||!Array.isArray(e)||t.length!==
260
- e.length)return!1;for(let o=0;o<t.length;o++)if(!Pe(t[o],e[o]))return!1;return!0}if(t===null||e===null||typeof t!="objec\
261
- t"||typeof e!="object"||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;let n=Object.keys(t),r=Object.keys(
262
- e);if(n.length!==r.length)return!1;for(let o of n)if(!Object.hasOwn(e,o)||!Pe(t[o],e[o]))return!1;return!0}var Br={install(t){
263
- let{addType:e,addValidator:n}=t;e("none",r=>r.value),e("file",r=>{let o=r.value;o==null&&r.throwTypeError();let i=typeof o;
247
+ r);return this._validateSelectedTree(Wt(t),n,s,this._buildOperationSettings(o,i,n))}_installOperationMethods(){for(let t of Object.
248
+ keys(this.operations)){if(t in this)throw new Error(`Operation name "${t}" is reserved and cannot be used as a schema me\
249
+ thod.`);this[t]=(n,r={})=>this.validateWith(t,n,r)}}toJsonSchema(t={}){return Vt(this,t)}getFieldDefinitions(){return Ue.
250
+ has(this)||Ue.set(this,qe(this.structure)),Ue.get(this)}getFieldDefinition(t){if(typeof t!="string"||t.trim()==="")throw new Error(
251
+ "Field path must be a non-empty string.");let n=He(this,Be(t.trim()));return n===null?null:qe(n)}getFieldMessages(t){let n=this.
252
+ getFieldDefinition(t);return!n||typeof n.messages!="object"||n.messages===null?Object.freeze({}):qe(n.messages)}cleanup(t,n){
253
+ let r={};for(let o of Object.keys(t))Object.hasOwn(this.structure,o)&&this.structure[o][n]&&h(r,o,t[o]);return r}};var{parse:Xi,stringify:kn}=JSON,{keys:Zi}=Object,Ln=String,$n="string";var Qt="object",Fn=(e,t)=>t;var er=(e,t,n)=>{let r=Ln(t.push(n)-1);return e.set(n,r),r};var tr=(e,t,n)=>{let r=t&&typeof t===Qt?(l,d)=>l===""||-1<t.indexOf(l)?d:void 0:t||Fn,o=new Map,i=[],s=[],a=+er(o,i,r.call(
254
+ {"":e},"",e)),c=!a;for(;a<i.length;)c=!0,s[a]=kn(i[a++],u,n);return"["+s.join(",")+"]";function u(l,d){if(c)return c=!c,
255
+ d;let f=r.call(this,l,d);switch(typeof f){case Qt:if(f===null)return f;case $n:return o.get(f)||er(o,i,f)}return f}};var Un=new Set(["true","1","yes","y","on"]),Vn=new Set(["false","0","no","n","off"]);function Bn(e){return e!==null&&(typeof e==
256
+ "object"||typeof e=="function")&&typeof e.then=="function"}function rr(e){if(typeof e=="number")return Number.isFinite(e)?
257
+ e:null;if(typeof e=="bigint"){let t=Number(e);return Number.isSafeInteger(t)?t:null}if(typeof e=="string"){let t=e.trim();
258
+ if(t==="")return null;let n=Number(t);return Number.isFinite(n)?n:null}return null}function We(e,t){if(Object.is(e,t))return!0;
259
+ if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.
260
+ source===t.source&&e.flags===t.flags;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==
261
+ t.length)return!1;for(let o=0;o<e.length;o++)if(!We(e[o],t[o]))return!1;return!0}if(e===null||t===null||typeof e!="objec\
262
+ t"||typeof t!="object"||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;let n=Object.keys(e),r=Object.keys(
263
+ t);if(n.length!==r.length)return!1;for(let o of n)if(!Object.hasOwn(t,o)||!We(e[o],t[o]))return!1;return!0}var Hn={install(e){
264
+ let{addType:t,addValidator:n}=e;t("none",r=>r.value),t("file",r=>{let o=r.value;o==null&&r.throwTypeError();let i=typeof o;
264
265
  if(i==="string"||i==="number"||i==="boolean"){let s=o.toString();return r.definition.noTrim?s:s.trim()}r.throwTypeError()}),
265
- e("string",r=>{let o=r.value;if(o==null)return"";let i=typeof o;if(i==="string"||i==="number"||i==="boolean"){let s=o.toString();
266
- return r.definition.noTrim?s:s.trim()}r.throwTypeError()}),e("blob",r=>r.value),e("number",r=>{let o=_t(r.value);return o===
267
- null&&r.throwTypeError(),o}),e("integer",r=>{let o=_t(r.value);return(o===null||!Number.isInteger(o))&&r.throwTypeError(),
268
- o}),e("epochMilliseconds",r=>{let o=pe(r.value,864e13);return o===null&&r.throwTypeError(),o}),e("epochSeconds",r=>{let o=pe(
269
- r.value,864e10);return o===null&&r.throwTypeError(),o}),e("dateTime",r=>{let o=W(r.definition,r.fieldName);return ot(r.value,
270
- o)||r.throwTypeError(),r.value}),e("date",r=>(rt(r.value)||r.throwTypeError(),r.value)),e("time",r=>{let o=W(r.definition,
271
- r.fieldName);return nt(r.value,o)||r.throwTypeError(),r.value}),e("array",r=>r.definition.type==="array"&&!Array.isArray(
272
- r.value)?[r.value]:r.value),e("object",r=>(y(r.value)||r.throwTypeError(),r.value)),e("serialize",r=>{try{return JSON.stringify(
273
- r.value)}catch{try{return Ct(r.value)}catch{r.throwTypeError()}}}),e("boolean",r=>{if(typeof r.value=="boolean")return r.
266
+ t("string",r=>{let o=r.value;if(o==null)return"";let i=typeof o;if(i==="string"||i==="number"||i==="boolean"){let s=o.toString();
267
+ return r.definition.noTrim?s:s.trim()}r.throwTypeError()}),t("blob",r=>r.value),t("number",r=>{let o=rr(r.value);return o===
268
+ null&&r.throwTypeError(),o}),t("integer",r=>{let o=rr(r.value);return(o===null||!Number.isInteger(o))&&r.throwTypeError(),
269
+ o}),t("epochMilliseconds",r=>{let o=xe(r.value,864e13);return o===null&&r.throwTypeError(),o}),t("epochSeconds",r=>{let o=xe(
270
+ r.value,864e10);return o===null&&r.throwTypeError(),o}),t("dateTime",r=>{let o=ie(r.definition,r.fieldName);return Mt(r.
271
+ value,o)||r.throwTypeError(),r.value}),t("date",r=>(Nt(r.value)||r.throwTypeError(),r.value)),t("time",r=>{let o=ie(r.definition,
272
+ r.fieldName);return Dt(r.value,o)||r.throwTypeError(),r.value}),t("array",r=>r.definition.type==="array"&&!Array.isArray(
273
+ r.value)?[r.value]:r.value),t("object",r=>(O(r.value)||r.throwTypeError(),r.value)),t("serialize",r=>{try{return JSON.stringify(
274
+ r.value)}catch{try{return tr(r.value)}catch{r.throwTypeError()}}}),t("boolean",r=>{if(typeof r.value=="boolean")return r.
274
275
  value;if(typeof r.value=="number"){if(r.value===1)return!0;if(r.value===0)return!1;r.throwTypeError()}if(typeof r.value==
275
276
  "bigint"){if(r.value===1n)return!0;if(r.value===0n)return!1;r.throwTypeError()}if(typeof r.value=="string"){let o=String(
276
277
  r.definition.stringFalseWhen||"false").trim().toLowerCase(),i=String(r.definition.stringTrueWhen||"true").trim().toLowerCase(),
277
- s=r.value.trim().toLowerCase(),a=new Set([...Ur,o]),c=new Set([...Fr,i]);if(a.has(s))return!1;if(c.has(s))return!0}r.throwTypeError()}),
278
- e("id",r=>{if(typeof r.value=="number"){if(Number.isSafeInteger(r.value)&&r.value>0)return r.value;r.throwTypeError()}if(typeof r.
278
+ s=r.value.trim().toLowerCase(),a=new Set([...Vn,o]),c=new Set([...Un,i]);if(a.has(s))return!1;if(c.has(s))return!0}r.throwTypeError()}),
279
+ t("id",r=>{if(typeof r.value=="number"){if(Number.isSafeInteger(r.value)&&r.value>0)return r.value;r.throwTypeError()}if(typeof r.
279
280
  value=="bigint"){if(r.value>0n&&r.value<=BigInt(Number.MAX_SAFE_INTEGER))return Number(r.value);r.throwTypeError()}if(typeof r.
280
281
  value=="string"){let o=r.value.trim();/^[1-9][0-9]*$/.test(o)||r.throwTypeError();let i=Number(o);return Number.isSafeInteger(
281
282
  i)||r.throwTypeError(),i}r.throwTypeError()}),n("minLength",r=>{r.value!==void 0&&r.definition.type==="string"&&r.value.
282
283
  toString&&r.value.toString().length<r.parameterValue&&r.throwParamError("MIN_LENGTH",`Length must be at least ${r.parameterValue}\
283
- characters.`,{min:r.parameterValue,actual:r.value.toString().length})}),n("min",r=>{r.value!==void 0&&R(r.definition)&&
284
+ characters.`,{min:r.parameterValue,actual:r.value.toString().length})}),n("min",r=>{r.value!==void 0&&q(r.definition)&&
284
285
  typeof r.value=="number"&&r.value<r.parameterValue&&r.throwParamError("MIN_VALUE",`Value must be at least ${r.parameterValue}\
285
286
  .`,{min:r.parameterValue,actual:r.value})}),n("maxLength",r=>{r.value!==void 0&&r.definition.type==="string"&&r.value.toString&&
286
287
  r.value.toString().length>r.parameterValue&&r.throwParamError("MAX_LENGTH",`Length must be no more than ${r.parameterValue}\
287
- characters.`,{max:r.parameterValue,actual:r.value.toString().length})}),n("max",r=>{r.value!==void 0&&R(r.definition)&&
288
+ characters.`,{max:r.parameterValue,actual:r.value.toString().length})}),n("max",r=>{r.value!==void 0&&q(r.definition)&&
288
289
  typeof r.value=="number"&&r.value>r.parameterValue&&r.throwParamError("MAX_VALUE",`Value must be no more than ${r.parameterValue}\
289
290
  .`,{max:r.parameterValue,actual:r.value})}),n("enum",r=>{if(!Array.isArray(r.parameterValue))throw new Error(`Enum for ${r.
290
- fieldName} must be an array.`);r.parameterValue.some(i=>Pe(i,r.value))||r.throwParamError("ENUM_VALUE","Value must match\
291
+ fieldName} must be an array.`);r.parameterValue.some(i=>We(i,r.value))||r.throwParamError("ENUM_VALUE","Value must match\
291
292
  one of the allowed enum values.",{allowed:r.parameterValue})}),n("pattern",r=>{if(r.value===void 0||r.definition.type!==
292
293
  "string"||typeof r.value!="string")return;let o=r.parameterValue,i=o instanceof RegExp?new RegExp(o.source,o.flags):typeof o==
293
294
  "string"?new RegExp(o):null;if(!i)throw new Error(`Pattern for ${r.fieldName} must be a string or RegExp.`);i.test(r.value)||
@@ -295,7 +296,7 @@ r.throwParamError("PATTERN","Value does not match the required pattern.",{patter
295
296
  parameterValue){if(r.definition.type!=="boolean")throw new Error(`strictBoolean can only be used on boolean fields (${r.
296
297
  fieldName}).`);typeof r.valueBeforeCast!="boolean"&&r.throwParamError("STRICT_BOOLEAN","Value must be a boolean.")}}),n(
297
298
  "validator",r=>{if(typeof r.parameterValue!="function")throw new Error(`Validator for ${r.fieldName} must be a function.`);
298
- let o=r.parameterValue(r.value,r.object,r);if(qr(o))throw new Error(`Custom validator for "${r.fieldName}" must be synch\
299
+ let o=r.parameterValue(r.value,r.object,r);if(Bn(o))throw new Error(`Custom validator for "${r.fieldName}" must be synch\
299
300
  ronous.`);typeof o=="string"&&r.throwParamError("CUSTOM_VALIDATOR_FAILED",o)}),n("uppercase",r=>{if(typeof r.value=="str\
300
301
  ing")return r.value.toUpperCase()}),n("lowercase",r=>{if(typeof r.value=="string")return r.value.toLowerCase()}),n("leng\
301
302
  th",r=>{if(typeof r.value=="string")return r.value.substr(0,r.parameterValue);Number.isInteger(Number(r.valueBeforeCast))&&
@@ -307,74 +308,65 @@ r.throwParamError("MAX_ITEMS",`Must have no more than ${r.parameterValue} items.
307
308
  n("notEmpty",r=>{r.parameterValue&&typeof r.value=="string"&&r.value===""&&r.throwParamError("NOT_EMPTY","Field cannot b\
308
309
  e empty.")}),n("required",()=>{}),n("unsigned",()=>{}),n("precision",()=>{}),n("scale",()=>{}),n("temporalPrecision",r=>{
309
310
  if(r.definition.type!=="time"&&r.definition.type!=="dateTime")throw new Error(`temporalPrecision can only be used on tim\
310
- e or dateTime fields (${r.fieldName}).`)}),n("nullable",()=>{}),n("nullOnEmpty",()=>{}),n("defaultTo",()=>{})}},Tt=Br;var jt=new WeakMap,xt=new WeakMap,Rt=Symbol.for("json-rest-schema.registry-metadata"),ie=new WeakSet;function Vr(t,e,n){
311
- if(typeof n!="function")throw new Error(`Type handler for '${e}' must be a function.`);p(t,e,n)}function Hr(t,e,n){if(typeof n!=
312
- "function")throw new Error(`Validator handler for '${e}' must be a function.`);p(t,e,n)}function se(t={}){let e=Object.create(
313
- null);for(let[n,r]of Object.entries(t))p(e,n,r);return e}function At(t,e){if(typeof t.install!="function")throw new Error(
314
- "Plugin must have an install method.");t.install(e)}function It(t,e,n){jt.set(t,e),xt.set(t,n),Object.defineProperty(t,Rt,
315
- {value:Object.freeze({getTypes:()=>e,getValidators:()=>n}),enumerable:!1,configurable:!1,writable:!1})}function Jr(t){if(!t||
316
- typeof t!="object"&&typeof t!="function")return null;let e=jt.get(t),n=xt.get(t);if(e&&n)return{types:e,validators:n};let r=t[Rt];
311
+ e or dateTime fields (${r.fieldName}).`)}),n("nullable",()=>{}),n("nullOnEmpty",()=>{}),n("defaultTo",()=>{})}},nr=Hn;var ar=new WeakMap,cr=new WeakMap,ur=Symbol.for("json-rest-schema.registry-metadata"),Oe=new WeakSet;function Jn(e,t,n){
312
+ if(typeof n!="function")throw new Error(`Type handler for '${t}' must be a function.`);h(e,t,n)}function Wn(e,t,n){if(typeof n!=
313
+ "function")throw new Error(`Validator handler for '${t}' must be a function.`);h(e,t,n)}function ve(e={}){let t=Object.create(
314
+ null);for(let[n,r]of Object.entries(e))h(t,n,r);return t}function or(e,t){if(typeof e.install!="function")throw new Error(
315
+ "Plugin must have an install method.");e.install(t)}function ir(e,t,n){ar.set(e,t),cr.set(e,n),Object.defineProperty(e,ur,
316
+ {value:Object.freeze({getTypes:()=>t,getValidators:()=>n}),enumerable:!1,configurable:!1,writable:!1})}function Gn(e){if(!e||
317
+ typeof e!="object"&&typeof e!="function")return null;let t=ar.get(e),n=cr.get(e);if(t&&n)return{types:t,validators:n};let r=e[ur];
317
318
  return r&&typeof r.getTypes=="function"&&typeof r.getValidators=="function"?{types:r.getTypes(),validators:r.getValidators()}:
318
- typeof t=="object"&&t.types&&typeof t.types=="object"&&t.validators&&typeof t.validators=="object"&&typeof t.create=="fu\
319
- nction"&&typeof t.replace=="function"&&typeof t.patch=="function"&&typeof t.toJsonSchema=="function"?{types:t.types,validators:t.
320
- validators}:null}function Wr(t){return t.length===1&&Array.isArray(t[0])?t[0]:t}function Pt(t,e,n){for(let[r,o]of Object.
321
- entries(e)){if(Object.hasOwn(t,r)&&t[r]!==o){if(ie.has(o))continue;if(!ie.has(t[r]))throw new Error(`Cannot merge schema\
322
- factories with conflicting ${n} "${r}".`)}p(t,r,o)}}function Gr(t,e,n){let r=Wr(n).filter(Boolean);if(r.length<1)return{
323
- types:se(t),validators:se(e)};let o=Object.create(null),i=Object.create(null);for(let s of r){let a=Jr(s);if(!a)throw new Error(
324
- "Factory sources must be schema instances or schema factories created by json-rest-schema.");Pt(o,a.types,"type"),Pt(i,a.
325
- validators,"validator")}return{types:o,validators:i}}function Nt({types:t={},validators:e={},installCore:n=!0}={}){let r=se(
326
- t),o=se(e),i=(s,a={})=>{let c=new k(s,r,o,a.operations);return It(c,r,o),c};return It(i,r,o),i.addType=(s,a)=>{Vr(r,s,a)},
327
- i.addValidator=(s,a)=>{Hr(o,s,a)},i.use=s=>{At(s,{addType:i.addType,addValidator:i.addValidator})},i.createFactory=(...s)=>{
328
- let a=Gr(r,o,s);return Nt({types:a.types,validators:a.validators,installCore:!1})},n&&At(Tt,{addType:(s,a)=>{ie.add(a),i.
329
- addType(s,a)},addValidator:(s,a)=>{ie.add(a),i.addValidator(s,a)}}),i}var C=Nt({installCore:!0});var Go=Object.freeze({schema:C({}),mode:"replace"});var Mt=/^[a-z][a-z0-9_.-]*$/u,Xr=/^[A-Za-z_$][A-Za-z0-9_$]*$/u;function Kr(t){return String(t||"").trim().toLowerCase()}
330
- function Re(t,e){let n=Kr(t);if(!Mt.test(n))throw new TypeError(`${e} must match ${Mt.toString()}.`);return n}function je(t,e){
331
- if(t==null)return Object.freeze({});if(!w(t))throw new TypeError(`${e} must be an object mapping local names to capabili\
332
- ty ids.`);let n={},r=new Set;for(let[o,i]of Object.entries(t)){let s=String(o||"").trim();if(!Xr.test(s))throw new TypeError(
333
- `${e} local name "${s}" must be a JavaScript identifier.`);let a=Re(i,`${e}.${s}`);if(r.has(a))throw new TypeError(`${e}\
334
- declares capability "${a}" more than once.`);r.add(a),n[s]=a}return Object.freeze(n)}function Zr(t,e,n){if(t==null)return Object.
335
- freeze({});if(!w(t))throw new TypeError(`${n}.hints must be an object mapping required capability ids to what to registe\
336
- r.`);let r=new Set(Object.values(e)),o={};for(let[i,s]of Object.entries(t)){let a=Re(i,`${n}.hints key`);if(!r.has(a))throw new TypeError(
337
- `${n}.hints names "${a}", which the provider does not require.`);if(typeof s!="string"||!s.trim())throw new TypeError(`${n}\
338
- .hints["${a}"] must be the text that says what to register.`);o[a]=s.trim()}return Object.freeze(o)}function Qr(t){let e=new Map;
339
- for(let[n,r]of Object.entries(t))for(let o of Object.keys(r)){if(e.has(o))throw new TypeError(`Provider local name "${o}\
340
- " is declared by both ${e.get(o)} and ${n}.`);e.set(o,n)}}function xe(t,e){if(t==null)return null;if(typeof t!="function")
341
- throw new TypeError(`${e} must be a function when provided.`);return t}function ae({id:t,requires:e={},optional:n={},provides:r={},
342
- hints:o={},setup:i,boot:s=null,shutdown:a=null}={}){let c=Re(t,"Provider id"),l=je(e,`${c}.requires`),u=je(n,`${c}.optio\
343
- nal`),d=je(r,`${c}.provides`);Qr({requires:l,optional:u,provides:d});let f=xe(i,`${c}.setup`);if(!f)throw new TypeError(
344
- `${c}.setup is required.`);return Object.freeze({id:c,requires:l,optional:u,provides:d,hints:Zr(o,l,c),setup:f,boot:xe(s,
345
- `${c}.boot`),shutdown:xe(a,`${c}.shutdown`)})}var Dt="public";var en="/api",kt=`${en}/bootstrap`;function Me(){let t=[],e=new Set,n=!1;function r({id:a,order:c=0,contribute:l}={}){if(n)throw new Error("Bootstrap regis\
346
- tration is closed after the first payload is resolved.");let u=O(a);if(!u)throw new TypeError("Bootstrap contributor id \
347
- is required.");if(typeof l!="function")throw new TypeError(`Bootstrap contributor "${u}" requires contribute().`);if(e.has(
348
- u))throw new Error(`Bootstrap contributor "${u}" is duplicated.`);return e.add(u),t.push(Object.freeze({id:u,order:Number.
349
- isFinite(c)?Number(c):0,contribute:l})),s}async function o(a={}){n=!0;let c={},l=t.map((u,d)=>({entry:u,index:d})).sort(
350
- (u,d)=>u.entry.order-d.entry.order||u.index-d.index).map(({entry:u})=>u);for(let u of l){let d=await u.contribute(Object.
351
- freeze({...w(a)?a:{},payload:Object.freeze({...c})}));c={...c,...w(d)?d:{}}}return Object.freeze(c)}function i(){return Object.
352
- freeze({sealed:n,contributorIds:Object.freeze(t.map(a=>a.id).sort())})}let s=Object.freeze({register:r,resolve:o,diagnostics:i});
353
- return s}var tn=ae({id:"runtime.bootstrap",requires:{http:"runtime.http"},provides:{bootstrap:"runtime.bootstrap"},setup({http:t}){
354
- let e=Me();return t.router.register("GET",kt,{auth:Dt,meta:{tags:["bootstrap"],summary:"Resolve app bootstrap payload"}},
355
- async(n,r)=>{r.code(200).send(await e.resolve({request:n,reply:r,query:n.query||{}}))}),{bootstrap:e}}});function rn(t){if(!w(t))throw new TypeError("Event listener must be an object.");let e=String(t.id||"").trim();if(!e)throw new TypeError(
356
- "Event listener id is required.");if(typeof t.handle!="function")throw new TypeError(`Event listener "${e}" requires han\
357
- dle().`);if(t.matches!=null&&typeof t.matches!="function")throw new TypeError(`Event listener "${e}" matches must be a f\
358
- unction when provided.`);return Object.freeze({id:e,handle:t.handle,matches:t.matches??null})}function nn(t){if(!w(t))throw new TypeError(
359
- "Published event must be an object.");let e=String(t.type||"").trim();if(!e)throw new TypeError("Published event type is\
360
- required.");return Object.freeze({...t,type:e})}function De(){let t=[],e=new Set;function n(s){let a=rn(s);if(e.has(a.id))
361
- throw new Error(`Event listener "${a.id}" is duplicated.`);return e.add(a.id),t.push(a),i}async function r(s){let a=nn(s);
362
- for(let c of t)c.matches&&c.matches(a)!==!0||await c.handle(a);return a}function o(){return Object.freeze({listenerIds:Object.
363
- freeze(t.map(s=>s.id))})}let i=Object.freeze({register:n,publish:r,diagnostics:o});return i}var on=ae({id:"runtime.events",provides:{events:"runtime.events"},setup(){return{events:De()}}});function j(t,e=new WeakSet){if(!t||typeof t!="object"||e.has(t))return t;e.add(t);for(let n of Object.getOwnPropertyNames(
364
- t))j(t[n],e);return Object.freeze(t)}var $i=Object.freeze({REQUIRED:{messageKey:"required",code:"kernel.validation.field.required"},TYPE_CAST_FAILED:{messageKey:"\
365
- default",code:"kernel.validation.field.typeCastFailed"},NOT_NULLABLE:{messageKey:"default",code:"kernel.validation.field\
366
- .notNullable"},MIN_LENGTH:{messageKey:"minLength",code:"kernel.validation.field.minLength"},MAX_LENGTH:{messageKey:"maxL\
367
- ength",code:"kernel.validation.field.maxLength"},MIN_ITEMS:{messageKey:"minItems",code:"kernel.validation.field.minItems"},
368
- MAX_ITEMS:{messageKey:"maxItems",code:"kernel.validation.field.maxItems"},MIN_VALUE:{messageKey:"min",code:"kernel.valid\
369
- ation.field.minValue"},MAX_VALUE:{messageKey:"max",code:"kernel.validation.field.maxValue"},PATTERN:{messageKey:"pattern",
370
- code:"kernel.validation.field.pattern"},ENUM_VALUE:{messageKey:"enum",code:"kernel.validation.field.enumValue"},FIELD_NOT_ALLOWED:{
371
- messageKey:"additionalProperties",code:"kernel.validation.field.notAllowed"},CUSTOM_VALIDATOR_FAILED:{messageKey:"valida\
372
- tor",code:""},STRICT_BOOLEAN:{messageKey:"default",code:"kernel.validation.field.strictBoolean"},RANGE_EXCEEDED:{messageKey:"\
373
- default",code:"kernel.validation.field.rangeExceeded"},NOT_EMPTY:{messageKey:"default",code:"kernel.validation.field.not\
374
- Empty"}}),Fi=Object.freeze({code:"kernel.validation.invalid",message:"Invalid value."}),Ui=Object.freeze(["create","repl\
375
- ace","patch","toJsonSchema"]);var ln=C({cursor:{type:"id",required:!1},limit:{type:"number",required:!1,min:1,unsigned:!0}}),un=Object.freeze({schema:ln,
376
- mode:"patch"});var Lt=Object.freeze({type:"string",pattern:"^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d)?$",minLength:5}),dn=Object.freeze(
377
- {...Lt,nullable:!0});var fs=new Map([{keyword:"required",code:"kernel.validation.required"},{keyword:"type",code:"kernel.validation.type"},{keyword:"\
319
+ typeof e=="object"&&e.types&&typeof e.types=="object"&&e.validators&&typeof e.validators=="object"&&typeof e.create=="fu\
320
+ nction"&&typeof e.replace=="function"&&typeof e.patch=="function"&&typeof e.toJsonSchema=="function"?{types:e.types,validators:e.
321
+ validators}:null}function Kn(e){return e.length===1&&Array.isArray(e[0])?e[0]:e}function sr(e,t,n){for(let[r,o]of Object.
322
+ entries(t)){if(Object.hasOwn(e,r)&&e[r]!==o){if(Oe.has(o))continue;if(!Oe.has(e[r]))throw new Error(`Cannot merge schema\
323
+ factories with conflicting ${n} "${r}".`)}h(e,r,o)}}function Yn(e,t,n){let r=Kn(n).filter(Boolean);if(r.length<1)return{
324
+ types:ve(e),validators:ve(t)};let o=Object.create(null),i=Object.create(null);for(let s of r){let a=Gn(s);if(!a)throw new Error(
325
+ "Factory sources must be schema instances or schema factories created by json-rest-schema.");sr(o,a.types,"type"),sr(i,a.
326
+ validators,"validator")}return{types:o,validators:i}}function lr({types:e={},validators:t={},installCore:n=!0}={}){let r=ve(
327
+ e),o=ve(t),i=(s,a={})=>{let c=new H(s,r,o,a.operations);return ir(c,r,o),c};return ir(i,r,o),i.addType=(s,a)=>{Jn(r,s,a)},
328
+ i.addValidator=(s,a)=>{Wn(o,s,a)},i.use=s=>{or(s,{addType:i.addType,addValidator:i.addValidator})},i.createFactory=(...s)=>{
329
+ let a=Yn(r,o,s);return lr({types:a.types,validators:a.validators,installCore:!1})},n&&or(nr,{addType:(s,a)=>{Oe.add(a),i.
330
+ addType(s,a)},addValidator:(s,a)=>{Oe.add(a),i.addValidator(s,a)}}),i}var N=lr({installCore:!0});function $(e,t=new WeakSet){if(!e||typeof e!="object"||t.has(e))return e;t.add(e);for(let n of Object.getOwnPropertyNames(
331
+ e))$(e[n],t);return Object.freeze(e)}var Xn=new Set(["create","replace","patch"]),Zn=Object.freeze({REQUIRED:{messageKey:"required",code:"kernel.validation.f\
332
+ ield.required"},TYPE_CAST_FAILED:{messageKey:"default",code:"kernel.validation.field.typeCastFailed"},NOT_NULLABLE:{messageKey:"\
333
+ default",code:"kernel.validation.field.notNullable"},MIN_LENGTH:{messageKey:"minLength",code:"kernel.validation.field.mi\
334
+ nLength"},MAX_LENGTH:{messageKey:"maxLength",code:"kernel.validation.field.maxLength"},MIN_ITEMS:{messageKey:"minItems",
335
+ code:"kernel.validation.field.minItems"},MAX_ITEMS:{messageKey:"maxItems",code:"kernel.validation.field.maxItems"},MIN_VALUE:{
336
+ messageKey:"min",code:"kernel.validation.field.minValue"},MAX_VALUE:{messageKey:"max",code:"kernel.validation.field.maxV\
337
+ alue"},PATTERN:{messageKey:"pattern",code:"kernel.validation.field.pattern"},ENUM_VALUE:{messageKey:"enum",code:"kernel.\
338
+ validation.field.enumValue"},FIELD_NOT_ALLOWED:{messageKey:"additionalProperties",code:"kernel.validation.field.notAllow\
339
+ ed"},CUSTOM_VALIDATOR_FAILED:{messageKey:"validator",code:""},STRICT_BOOLEAN:{messageKey:"default",code:"kernel.validati\
340
+ on.field.strictBoolean"},RANGE_EXCEEDED:{messageKey:"default",code:"kernel.validation.field.rangeExceeded"},NOT_EMPTY:{messageKey:"\
341
+ default",code:"kernel.validation.field.notEmpty"}}),Qn=Object.freeze({code:"kernel.validation.invalid",message:"Invalid \
342
+ value."}),eo=Object.freeze(["create","replace","patch","toJsonSchema"]);function Se(e){return!!e&&typeof e=="object"&&eo.
343
+ every(t=>typeof e[t]=="function")}function fr(e=null,{defaultMode:t="create",context:n="schema definition.mode"}={}){let r=I(e),o=y(t).toLowerCase()||"cre\
344
+ ate",i=Object.prototype.hasOwnProperty.call(r,"mode")?y(r.mode).toLowerCase():"";if(!i)return o;if(!Xn.has(i))throw new TypeError(
345
+ `${n} must be one of: create, replace, patch.`);return i}function pr(e=null,t=""){let n=y(t);if(!n)return{};let r=I(e);return Se(r.schema)?I(r.schema.getFieldMessages(n)):{}}function to(e=null,t=""){
346
+ let n=y(t).split(".").filter(Boolean);return n.length<2?{}:(n.pop(),pr(e,n.join(".")))}function dr(e,t){let n=t?e[t]:void 0;
347
+ if(typeof n=="string"){let i=y(n);return i?{message:i}:null}if(!w(n))return null;let r=y(n.message);if(!r)return null;let o=y(
348
+ n.code);return o?{message:r,code:o,params:I(n.params)}:{message:r}}function ro(e,t,n=null){let r=y(t?.code).toUpperCase(),
349
+ o=Zn[r]||{},i=I(t?.params),s=pr(n,e),a=r==="FIELD_NOT_ALLOWED"&&Object.keys(s).length<1?to(n,e):s,c=dr(a,o.messageKey)||
350
+ dr(a,"default");if(c)return c.code?{message:c.message,code:c.code,params:{...i,...c.params}}:{message:c.message};let u=y(
351
+ t?.message);if(u)return o.code?{message:u,code:o.code,params:i}:{message:u};let l=y(t?.code);return l?{message:l}:{...Qn,
352
+ params:{}}}function Ge(e={},t=null){let n=I(e),r={},o={};for(let[i,s]of Object.entries(n)){let a=y(i);if(!a)continue;if(typeof s==
353
+ "string"){r[a]=s;continue}let{message:c,code:u,params:l}=ro(a,s,t);r[a]=c,u&&(o[a]={code:u,params:l})}return{fieldErrors:r,
354
+ fieldErrorCodes:o}}function no(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&(Object.prototype.hasOwnProperty.call(e,"schema")||Object.
355
+ prototype.hasOwnProperty.call(e,"mode"))}function J(e,{context:t="schema definition",defaultMode:n=""}={}){if(e==null)return null;
356
+ if(!no(e))throw new TypeError(`${t} must be a schema definition object.`);let r=I(e);if(!Object.prototype.hasOwnProperty.
357
+ call(r,"schema"))throw new TypeError(`${t}.schema is required.`);if(!Se(r.schema))throw new TypeError(`${t}.schema must \
358
+ be a json-rest-schema schema instance.`);let o={schema:r.schema},i=y(n).toLowerCase();return o.mode=fr(r,{defaultMode:i||
359
+ "patch",context:`${t}.mode`}),Object.freeze(o)}function Ke(e,t,{context:n="schema definition",defaultMode:r=""}={}){let o=J(e,{context:n,defaultMode:r});return o?o.schema[o.
360
+ mode](t):null}var oo=N({cursor:{type:"id",required:!1},limit:{type:"number",required:!1,min:1,unsigned:!0}}),io=Object.freeze({schema:oo,
361
+ mode:"patch"});var mr=Object.freeze({type:"string",pattern:"^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d)?$",minLength:5}),so=Object.freeze(
362
+ {...mr,nullable:!0});var hr="Schema validation failed.";function yr({message:e=hr,fieldErrors:t=null,fieldErrorCodes:n=null,errors:r=null,cause:o,
363
+ statusCode:i=null}={}){let s=new Error(e,o?{cause:o}:void 0);if(e===hr&&(s.messageCode="kernel.validation.schemaFailed",
364
+ s.messageParams={}),Number.isInteger(i)&&i>=400&&i<=599&&(s.statusCode=i),w(t)){let a=w(n)&&Object.keys(n).length>0?n:null;
365
+ s.fieldErrors=t,a&&(s.fieldErrorCodes=a),s.details={...s.details||{},fieldErrors:t,...a?{fieldErrorCodes:a}:{}}}else r!=
366
+ null&&(s.details={...s.details||{},errors:r});return s}function ae(e,t,{phase:n="input",context:r="schema definition",statusCode:o=null}={}){
367
+ if(e==null)return t;let i=Ke(e,t,{defaultMode:n==="output"?"replace":"patch",context:r}),{fieldErrors:s,fieldErrorCodes:a}=Ge(
368
+ i.errors,e);if(Object.keys(s).length>0)throw yr({fieldErrors:s,fieldErrorCodes:a,statusCode:o});return i.validatedObject??
369
+ t}var Us=new Map([{keyword:"required",code:"kernel.validation.required"},{keyword:"type",code:"kernel.validation.type"},{keyword:"\
378
370
  minLength",code:"kernel.validation.minLength"},{keyword:"maxLength",code:"kernel.validation.maxLength"},{keyword:"minimu\
379
371
  m",code:"kernel.validation.minimum"},{keyword:"maximum",code:"kernel.validation.maximum"},{keyword:"exclusiveMinimum",code:"\
380
372
  kernel.validation.exclusiveMinimum"},{keyword:"exclusiveMaximum",code:"kernel.validation.exclusiveMaximum"},{keyword:"mu\
@@ -385,107 +377,255 @@ additionalItems",code:"kernel.validation.additionalItems"},{keyword:"uniqueItems
385
377
  {keyword:"minProperties",code:"kernel.validation.minProperties"},{keyword:"maxProperties",code:"kernel.validation.maxPro\
386
378
  perties"},{keyword:"additionalProperties",code:"kernel.validation.additionalProperties"},{keyword:"propertyNames",code:"\
387
379
  kernel.validation.propertyNames"},{keyword:"oneOf",code:"kernel.validation.oneOf"},{keyword:"anyOf",code:"kernel.validat\
388
- ion.anyOf"},{keyword:"not",code:"kernel.validation.not"},{keyword:"if",code:"kernel.validation.if"}].map(({keyword:t,code:e})=>[
389
- t,e]));var $t="^[1-9][0-9]*$",ke=j({type:"string",minLength:1,pattern:$t}),pn=j({...ke,nullable:!0}),mn=j({schema:C({recordId:{
390
- ...ke,required:!0,messages:{pattern:{code:"kernel.validation.recordIdInvalid",message:"Record id must be a canonical pos\
391
- itive integer string."}}}}),mode:"patch"});var Ft=20,aa=32*1024,ca=48*1024,ze=Object.freeze({search:"assistant_action_search",contract:"assistant_action_contract",
392
- execute:"assistant_action_execute"}),Le=Object.freeze({type:"object",additionalProperties:!0}),wn=Object.freeze({type:"o\
380
+ ion.anyOf"},{keyword:"not",code:"kernel.validation.not"},{keyword:"if",code:"kernel.validation.if"}].map(({keyword:e,code:t})=>[
381
+ e,t]));var wr="^[1-9][0-9]*$",Ye=$({type:"string",minLength:1,pattern:wr}),ao=$({...Ye,nullable:!0}),co=$({schema:N({recordId:{
382
+ ...Ye,required:!0,messages:{pattern:{code:"kernel.validation.recordIdInvalid",message:"Record id must be a canonical pos\
383
+ itive integer string."}}}}),mode:"patch"});function z(e){let t=Array.isArray(e)?e:[e],n=new Set;for(let r of t){let o=y(r);o&&n.add(o)}return[...n]}function gr(e=[],t=""){
384
+ let n=y(t);if(!n)return!0;let r=z(e);if(r.includes("*")||r.includes(n))return!0;for(let o of r){if(!o.endsWith(".*"))continue;
385
+ let i=o.slice(0,-2);if(i&&n.startsWith(`${i}.`))return!0}return!1}function Xe(e,t,n){if(e==="all"){let r=t.find(o=>!gr(n,
386
+ o));return r===void 0?null:{permission:r}}return t.some(r=>gr(n,r))?null:{requiredPermissions:t}}var ce=/^[a-z][a-z0-9_.-]*$/u,fo=/^[A-Za-z_$][A-Za-z0-9_$]*$/u;function po(e){return String(e||"").trim().toLowerCase()}
387
+ function Qe(e,t){let n=po(e);if(!ce.test(n))throw new TypeError(`${t} must match ${ce.toString()}.`);return n}function Ae(e,t){
388
+ if(e==null)return Object.freeze({});if(!w(e))throw new TypeError(`${t} must be an object mapping local names to capabili\
389
+ ty ids.`);let n={},r=new Set;for(let[o,i]of Object.entries(e)){let s=String(o||"").trim();if(!fo.test(s))throw new TypeError(
390
+ `${t} local name "${s}" must be a JavaScript identifier.`);let a=Qe(i,`${t}.${s}`);if(r.has(a))throw new TypeError(`${t}\
391
+ declares capability "${a}" more than once.`);r.add(a),n[s]=a}return Object.freeze(n)}function mo(e,t,n){if(e==null)return Object.
392
+ freeze({});if(!w(e))throw new TypeError(`${n}.hints must be an object mapping required capability ids to what to registe\
393
+ r.`);let r=new Set(Object.values(t)),o={};for(let[i,s]of Object.entries(e)){let a=Qe(i,`${n}.hints key`);if(!r.has(a))throw new TypeError(
394
+ `${n}.hints names "${a}", which the provider does not require.`);if(typeof s!="string"||!s.trim())throw new TypeError(`${n}\
395
+ .hints["${a}"] must be the text that says what to register.`);o[a]=s.trim()}return Object.freeze(o)}function ho(e){let t=new Map;
396
+ for(let[n,r]of Object.entries(e))for(let o of Object.keys(r)){if(t.has(o))throw new TypeError(`Provider local name "${o}\
397
+ " is declared by both ${t.get(o)} and ${n}.`);t.set(o,n)}}function yo(e,t,n){for(let r of Object.values(t))for(let[o,i]of Object.
398
+ entries(n))if(Object.values(i).includes(r))throw new TypeError(o==="provides"?`Provider "${e}" cannot late-require capab\
399
+ ility "${r}" that it provides.`:`Provider "${e}" names capability "${r}" under both late and ${o}.`)}function Ze(e,t){if(e==
400
+ null)return null;if(typeof e!="function")throw new TypeError(`${t} must be a function when provided.`);return e}function W({
401
+ id:e,requires:t={},optional:n={},late:r={},provides:o={},hints:i={},setup:s,boot:a=null,shutdown:c=null}={}){let u=Qe(e,
402
+ "Provider id"),l=Ae(t,`${u}.requires`),d=Ae(n,`${u}.optional`),f=Ae(r,`${u}.late`),p=Ae(o,`${u}.provides`);ho({requires:l,
403
+ optional:d,late:f,provides:p}),yo(u,f,{provides:p,requires:l,optional:d});let m=Ze(s,`${u}.setup`);if(!m)throw new TypeError(
404
+ `${u}.setup is required.`);return Object.freeze({id:u,requires:l,optional:d,late:f,provides:p,hints:mo(i,{...l,...f},u),
405
+ setup:m,boot:Ze(a,`${u}.boot`),shutdown:Ze(c,`${u}.shutdown`)})}var et=new WeakSet;function br(e,t){return e===null||typeof e!="object"||et.has(e)||t.has(e)?!0:Object.isFrozen(e)?(t.add(
406
+ e),Reflect.ownKeys(e).every(n=>{let r=Object.getOwnPropertyDescriptor(e,n);return!Object.hasOwn(r,"value")||br(r.value,t)})):
407
+ !1}function Er(e){if(e===null||typeof e!="object"||et.has(e))return!0;if(!Object.isFrozen(e))return!1;let t=new Set;if(!br(
408
+ e,t))return!1;for(let n of t)et.add(n);return!0}var wo=Object.freeze(["query","command","stream"]),Sr=Object.freeze(["none","authenticated","all","any"]),go=new Set(wo),
409
+ bo=new Set(Sr),Ar="create",Ir=Object.freeze({required:!0,defaultMode:Ar,refuseOneOf:!0}),_=class extends Error{constructor(t,n,r={}){
410
+ super(n),this.name="ActionRuntimeError",this.status=Number(t)||500,this.statusCode=this.status,this.code=String(r.code||
411
+ "ACTION_RUNTIME_ERROR"),this.params=r.params&&typeof r.params=="object"?{...r.params}:{},this.details=r.details,this.headers=
412
+ r.headers||{},this.cause=r.cause}};function Cr(e,{context:t="domain"}={}){let n=y(e).toLowerCase();if(!n)throw new Error(
413
+ `${t} is required.`);if(!ce.test(n))throw new Error(`${t} must match ${ce.toString()} (lowercase letters, digits, _, -, \
414
+ .).`);return n}function Or(e,t){let n=Array.isArray(e)?e:[],r=Array.from(new Set(n.map(o=>y(o).toLowerCase()).filter(Boolean)));
415
+ if(r.length<1)throw new Error(`Action definition ${t} must include at least one value.`);return r}function tt(e){return e&&
416
+ typeof e.getFieldDefinitions=="function"?e.getFieldDefinitions():null}var vr=new WeakSet;function rt(e,t,n=""){for(let[r,
417
+ o]of Object.entries(e))nt(o,t,n?`${n}.${r}`:r)}function nt(e,t,n){let r=tt(e);if(r){rt(r,t,n);return}if(w(e)){if(Object.
418
+ hasOwn(e,"oneOf"))throw new Error(`Action definition ${t} field "${n}" declares oneOf, which does not restrict its value\
419
+ ; list the allowed values with enum.`);rt(tt(e.schema)||{},t,n),Object.hasOwn(e,"items")&&nt(e.items,t,`${n}[]`),Object.
420
+ hasOwn(e,"values")&&nt(e.values,t,`${n}.*`)}}function ot(e,t,{required:n=!1,defaultMode:r="",refuseOneOf:o=!1}={}){if(e==
421
+ null){if(!n)return null;throw new Error(`Action definition ${t} is required.`)}if(Array.isArray(e))throw new Error(`Acti\
422
+ on definition ${t} must be a single schema definition.`);if(!w(e))throw new Error(`Action definition ${t} must be a json\
423
+ -rest-schema schema definition.`);let i;try{i=J(e,{context:`Action definition ${t}`,defaultMode:r})}catch(s){throw new Error(
424
+ s?.message||`Action definition ${t} is invalid.`)}return o&&!vr.has(i.schema)&&(rt(tt(i.schema)||{},t),Er(i.schema)&&vr.
425
+ add(i.schema)),i}function Eo(e,t){if(e==null)return Object.freeze({require:"none",permissions:Object.freeze([]),message:"",
426
+ code:""});if(!w(e))throw new Error(`Action definition "${t}" permission must be an object when provided.`);let n=y(e.require||
427
+ "authenticated").toLowerCase();if(!bo.has(n))throw new Error(`Action definition "${t}" permission.require must be one of\
428
+ : ${Sr.join(", ")}.`);return Object.freeze({require:n,permissions:Object.freeze(z(e.permissions)),message:y(e.message),code:y(
429
+ e.code)})}function Oo(e){if(e==null)return Object.freeze({});if(!w(e))throw new Error("Action definition extensions must\
430
+ be an object when provided.");return Object.freeze({...e})}function vo(e,t){if(e==null)return Object.freeze([]);if(!Array.
431
+ isArray(e))throw new Error(`Action definition "${t}" events must be an array.`);return Object.freeze(e.map((n,r)=>{if(typeof n!=
432
+ "function")throw new Error(`Action definition "${t}" events[${r}] must be a function.`);return n}))}function So(e,{contributorId:t="",
433
+ contributorDomain:n=""}={}){let r=e&&typeof e=="object"?e:{},o=y(r.id);if(!o)throw new Error("Action definition id is re\
434
+ quired.");let i=ne(r.version,{fallback:1}),s=Cr(r.domain||n,{context:`Action definition "${o}" domain`}),a=y(r.kind||"co\
435
+ mmand").toLowerCase();if(!go.has(a))throw new Error(`Action definition "${o}" has unsupported kind "${a}".`);let c=Or(r.
436
+ channels,"channels"),u=Or(r.surfaces,"surfaces");if(Object.hasOwn(r,"idempotency"))throw new Error(`Action definition "${o}\
437
+ " declares idempotency. Action definitions no longer declare idempotency.`);if(typeof r.execute!="function")throw new Error(
438
+ `Action definition "${o}" execute handler is required.`);if(r.checkInput!=null&&typeof r.checkInput!="function")throw new Error(
439
+ `Action definition "${o}" checkInput must be a function when provided.`);return Object.freeze({id:o,version:i,domain:s,kind:a,
440
+ channels:c,surfaces:u,input:ot(r.input,"input",Ir),output:ot(r.output,"output",{defaultMode:"replace"}),permission:Eo(r.
441
+ permission,o),extensions:Oo(r.extensions),events:vo(r.events,o),checkInput:r.checkInput??null,execute:r.execute,contributorId:y(
442
+ t)})}function Ao(e){let t=e&&typeof e=="object"?e:{},n=y(t.contributorId);if(!n)throw new Error("Action contributor cont\
443
+ ributorId is required.");let r=Cr(t.domain,{context:`Action contributor "${n}" domain`}),i=(Array.isArray(t.actions)?t.actions:
444
+ []).map(s=>So(s,{contributorId:n,contributorDomain:r}));return Object.freeze({contributorId:n,domain:r,actions:Object.freeze(
445
+ i)})}function Io(e,t){let n=t.input(e);return n===e.input?e:Object.freeze({...e,input:ot(n,"input",Ir)})}function _r(e,t){
446
+ let{contributorId:n,domain:r,actions:o}=Ao(e);return Object.freeze({contributorId:n,domain:r,actions:Object.freeze(o.map(
447
+ i=>Object.freeze({declared:i,definition:Io(i,t)})))})}function it(e,t){return`${y(e)}@v${ne(t,{fallback:1})}`}function Tr(e){return e?.requestMeta?.request||null}function Pr(e,t){let n=t||Tr(e);return e?.actor||n?.user||null}function st(e,t){
448
+ return fe(Pr(e,t)?.id)}var xa=Object.freeze({schema:N({}),mode:"replace"});function jr(e){let t=e.fieldErrorCodes||e.details?.fieldErrorCodes;return{fieldErrors:e.fieldErrors||e.details?.fieldErrors,
449
+ ...w(t)?{fieldErrorCodes:t}:{}}}function at({details:e,cause:t}){return new _(400,"Validation failed.",{code:"ACTION_VAL\
450
+ IDATION_FAILED",details:e,cause:t})}function Rr(e,t){let n=j(t.channel);if(!n||!e.channels.includes(n))throw new _(403,"\
451
+ Forbidden.",{code:"ACTION_CHANNEL_FORBIDDEN",details:{actionId:e.id,channel:n}})}function Nr(e,t){let n=j(t.surface),r=e.
452
+ surfaces;if(!r.includes("*")&&(!n||!r.includes(n)))throw new _(403,"Forbidden.",{code:"ACTION_SURFACE_FORBIDDEN",details:{
453
+ actionId:e.id,surface:n}})}function Dr(e,t){let{permission:n}=e,r=n.require;if(r==="none")return;if(st(t)==null)throw new _(
454
+ 401,n.message||"Authentication required.",{code:n.code||"ACTION_AUTHENTICATION_REQUIRED",details:{actionId:e.id}});if(r===
455
+ "authenticated")return;let i=n.permissions;if(i.length<1)return;let s=Xe(r,i,z(t.permissions));if(s)throw new _(403,n.message||
456
+ "Forbidden.",{code:n.code||"ACTION_PERMISSION_DENIED",details:{actionId:e.id,...s}})}function xr(e){return w(e?.fieldErrors)||
457
+ w(e?.details?.fieldErrors)}async function Mr(e,t){let n;try{n=ae(e.input,t,{phase:"input",context:`Action ${e.id} input`})}catch(r){
458
+ throw xr(r)?at({details:jr(r),cause:r}):r?.code==="ACTION_VALIDATION_FAILED"?r:at({details:{error:String(r?.message||"In\
459
+ valid input.")},cause:r})}if(e.checkInput)try{await e.checkInput(n)}catch(r){throw xr(r)?at({details:jr(r),cause:r}):r}return n}
460
+ async function zr(e,t){if(!e.output)return t;try{return ae(e.output,t,{phase:"output",context:`Action ${e.id} output`})}catch(n){
461
+ throw new Error("Action output validation failed.",{cause:n})}}var Co=Object.freeze(["requestId","commandId","ip","userAgent"]);function kr(e={}){let t=e&&typeof e=="object"?e:{},n={...t,
462
+ request:t.request||null};for(let r of Co)n[r]=y(t[r]);return n}function _o(e){return w(e)?{...e}:null}function To(e){let t=_o(e);return t?(t.id==null&&(t.id=null),t):null}function Po(e){
463
+ let t=e&&typeof e=="object"?e:{};return{now:t.now instanceof Date?t.now:new Date,timezone:y(t.timezone),locale:y(t.locale)}}
464
+ var jo=new Set(["actor","permissions","surface","channel","requestMeta","timeMeta"]);function xo(e={}){let t={...e};for(let n of jo)
465
+ delete t[n];return t}var Ro=Symbol("jskit.actions.unloggedExecution");function ct(e){return!(e&&typeof e=="object"&&e[Ro]===!0)}function No(e){return j(e)||"internal"}function Ie(e={}){let t=e&&
466
+ typeof e=="object"?e:{},n=xo(t);return Object.freeze({...n,actor:To(t.actor),permissions:z(t.permissions),surface:j(t.surface),
467
+ channel:No(t.channel),requestMeta:kr(t.requestMeta),timeMeta:Po(t.timeMeta)})}async function Do(e,t,n){for(let r of t){let o=await r(n),i=Array.isArray(o)?o:[o];for(let s of i)s!=null&&await e.publish(
468
+ s)}}function Lr(e,{definition:t,context:n,outcome:r,startedAt:o,errorCode:i=null}){ct(n)&&e.debug({action:t.id,version:t.
469
+ version,channel:n.channel,surface:n.surface,requestId:n.requestMeta.requestId||null,durationMs:Date.now()-o,outcome:r,errorCode:i},
470
+ "action.execution")}async function ut({definition:e,declared:t,input:n,context:r,deps:o,events:i,logger:s,policy:a}){let c=Ie(
471
+ r),u=Date.now();try{Rr(e,c),Nr(e,c),Dr(e,c);let l=await Mr(e,n),d=await a.execute(Object.freeze({definition:t,input:l,context:c,
472
+ run:(p,m)=>e.execute(p,m,o)})),f=await zr(e,d);return await Do(i,e.events,Object.freeze({definition:e,input:l,result:f,context:c})),
473
+ Lr(s,{definition:e,context:c,outcome:"success",startedAt:u}),f}catch(l){throw Lr(s,{definition:e,context:c,outcome:"fail\
474
+ ure",startedAt:u,errorCode:String(l?.code||"ACTION_EXECUTION_FAILED").trim()}),l}}function dt(e,t){let n=new Map;for(let{definition:r}of t.actions){let o=it(r.id,r.version),i=e.get(o)??n.get(o);if(i)throw new Error(
475
+ `Action definition "${o}" is duplicated between contributors "${i.contributorId}" and "${t.contributorId}".`);n.set(o,r)}
476
+ return n}function Mo(e){let t=[],n=new Map,r=new Map,o=new Map;for(let i of e){for(let[s,a]of dt(n,i))n.set(s,a);for(let{
477
+ definition:s,declared:a}of i.actions)o.set(s,a),t.push(s),r.has(s.id)||r.set(s.id,[]),r.get(s.id).push(s)}for(let i of r.
478
+ values())i.sort((s,a)=>a.version-s.version);return{definitions:Object.freeze(t),byVersionKey:n,byActionId:r,declaredByDefinition:o}}
479
+ function zo(e){let t=Number(e);if(!Number.isInteger(t)||t<1)throw new _(400,"Validation failed.",{code:"ACTION_VERSION_I\
480
+ NVALID",details:{fieldErrors:{version:"version must be an integer >= 1."},fieldErrorCodes:{version:{code:"kernel.action.\
481
+ versionInvalid",params:{}}}}});return t}function lt(e,t,n){let r=String(t||"").trim();if(!r)throw new _(400,"Validation \
482
+ failed.",{code:"ACTION_ID_REQUIRED",details:{fieldErrors:{actionId:"actionId is required."},fieldErrorCodes:{actionId:{code:"\
483
+ kernel.action.idRequired",params:{}}}}});if(n==null){let a=e.byActionId.get(r)||[];if(a.length<1)throw new _(404,"Not fo\
484
+ und.",{code:"ACTION_NOT_FOUND",details:{actionId:r}});return a[0]}let o=zo(n),i=it(r,o),s=e.byVersionKey.get(i);if(!s)throw new _(
485
+ 404,"Not found.",{code:"ACTION_NOT_FOUND",details:{actionId:r,version:o}});return s}function $r({contributors:e,events:t,
486
+ logger:n,policy:r}){let o=Mo(e);async function i({actionId:u,version:l,input:d,context:f,deps:p}){let m=lt(o,u,l);return ut(
487
+ {definition:m,declared:o.declaredByDefinition.get(m),input:d,context:f,deps:p,events:t,logger:n,policy:r})}async function s({
488
+ actionId:u,version:l,input:d,context:f,deps:p}){let m=lt(o,u,l);if(m.kind!=="stream")throw new _(400,"Validation failed.",
489
+ {code:"ACTION_STREAM_KIND_REQUIRED",details:{actionId:m.id,version:m.version,kind:m.kind}});return ut({definition:m,declared:o.
490
+ declaredByDefinition.get(m),input:d,context:f,deps:p,events:t,logger:n,policy:r})}function a(){return o.definitions.slice()}
491
+ function c(u,l=null){return lt(o,u,l)}return Object.freeze({execute:i,executeStream:s,listDefinitions:a,getDefinition:c})}var Ce=Object.freeze({input(e){return e.input},execute({input:e,context:t,run:n}){return n(e,t)}});function ko(e){if(!w(e))throw new TypeError("Event listener must be an object.");let t=String(e.id||"").trim();if(!t)throw new TypeError(
492
+ "Event listener id is required.");if(typeof e.handle!="function")throw new TypeError(`Event listener "${t}" requires han\
493
+ dle().`);if(e.matches!=null&&typeof e.matches!="function")throw new TypeError(`Event listener "${t}" matches must be a f\
494
+ unction when provided.`);return Object.freeze({id:t,handle:e.handle,matches:e.matches??null})}function Lo(e){if(!w(e))throw new TypeError(
495
+ "Published event must be an object.");let t=String(e.type||"").trim();if(!t)throw new TypeError("Published event type is\
496
+ required.");return Object.freeze({...e,type:t})}function ue(){let e=[],t=new Set;function n(s){let a=ko(s);if(t.has(a.id))
497
+ throw new Error(`Event listener "${a.id}" is duplicated.`);return t.add(a.id),e.push(a),i}async function r(s){let a=Lo(s);
498
+ for(let c of e)c.matches&&c.matches(a)!==!0||await c.handle(a);return a}function o(){return Object.freeze({listenerIds:Object.
499
+ freeze(e.map(s=>s.id))})}let i=Object.freeze({register:n,publish:r,diagnostics:o});return i}var Fr=Object.freeze({debug(){},info(){},warn(){},error(){}});function $o(e){if(!w(e))throw new TypeError("Action catalogue registration must be an action contributor object.");return e}
500
+ function ft({events:e=ue(),logger:t=Fr,policy:n=Ce}={}){let r=[],o=[],i=new Set,s=new Map,a=null,c=!1;function u(b){if(c)
501
+ throw new Error("Action catalogue registration is closed after discovery or execution begins.");let E=_r($o(b),n);for(let[
502
+ g,S]of dt(s,E))s.set(g,S);return r.push(E),re}function l({id:b,contribute:E}={}){if(c)throw new Error("Action catalogue \
503
+ registration is closed after discovery or execution begins.");let g=String(b||"").trim();if(!g)throw new TypeError("Acti\
504
+ on context contributor id is required.");if(typeof E!="function")throw new TypeError(`Action context contributor "${g}" \
505
+ requires contribute().`);if(i.has(g))throw new Error(`Action context contributor "${g}" is duplicated.`);return i.add(g),
506
+ o.push(Object.freeze({id:g,contribute:E})),re}function d(){return c=!0,a??=$r({contributors:r,events:e,logger:t,policy:n}),
507
+ a}function f(b,E){let g={...b};for(let[S,D]of Object.entries(w(E)?E:{}))S==="requestMeta"?g.requestMeta={...w(D)?D:{},...w(
508
+ g.requestMeta)?g.requestMeta:{}}:Object.hasOwn(g,S)||(g[S]=D);return g}async function p({definition:b,input:E,context:g}){
509
+ let S={...w(g)?g:{}};for(let D of o){let _e=await D.contribute(Object.freeze({actionId:b?.id??null,version:b?.version??null,
510
+ definition:b,input:Object.freeze({...w(E)?E:{}}),context:Object.freeze({...S})}));S=f(S,_e)}return Object.freeze(S)}function m({
511
+ actionId:b,version:E,input:g,context:S}){return p({definition:d().getDefinition(b,E),input:g,context:S})}async function v({
512
+ input:b,context:E}={}){return c=!0,Ie(await p({definition:null,input:b,context:E}))}async function x(b,E={}){let g=E&&typeof E==
513
+ "object"?E:{},S=g.input&&typeof g.input=="object"?g.input:{},D=g.version==null?null:g.version,_e=await m({actionId:g.actionId,
514
+ version:D,input:S,context:g.context});return d()[b]({actionId:g.actionId,version:D,input:S,context:_e,deps:w(g.deps)?g.deps:
515
+ {}})}function T(b){return x("execute",b)}function R(b){return x("executeStream",b)}function P(){return d().listDefinitions()}
516
+ function te(b,E=null){return d().getDefinition(b,E)}let re=Object.freeze({register:u,registerContextContributor:l,execute:T,
517
+ executeStream:R,contextFor:v,listDefinitions:P,getDefinition:te});return re}var Fo=W({id:"runtime.actions",requires:{events:"runtime.events",logger:"runtime.logger"},optional:{policy:"runtime.acti\
518
+ ons.policy"},provides:{actions:"runtime.actions"},setup({events:e,logger:t,policy:n}){return{actions:ft({events:e,logger:t,
519
+ policy:n??Ce})}}});var qr="public";var Uo="/api",Ur=`${Uo}/bootstrap`;function pt(){let e=[],t=new Set,n=!1;function r({id:a,order:c=0,contribute:u}={}){if(n)throw new Error("Bootstrap regis\
520
+ tration is closed after the first payload is resolved.");let l=y(a);if(!l)throw new TypeError("Bootstrap contributor id \
521
+ is required.");if(typeof u!="function")throw new TypeError(`Bootstrap contributor "${l}" requires contribute().`);if(t.has(
522
+ l))throw new Error(`Bootstrap contributor "${l}" is duplicated.`);return t.add(l),e.push(Object.freeze({id:l,order:Number.
523
+ isFinite(c)?Number(c):0,contribute:u})),s}async function o(a={}){n=!0;let c={},u=e.map((l,d)=>({entry:l,index:d})).sort(
524
+ (l,d)=>l.entry.order-d.entry.order||l.index-d.index).map(({entry:l})=>l);for(let l of u){let d=await l.contribute(Object.
525
+ freeze({...w(a)?a:{},payload:Object.freeze({...c})}));c={...c,...w(d)?d:{}}}return Object.freeze(c)}function i(){return Object.
526
+ freeze({sealed:n,contributorIds:Object.freeze(e.map(a=>a.id).sort())})}let s=Object.freeze({register:r,resolve:o,diagnostics:i});
527
+ return s}var Vo=W({id:"runtime.bootstrap",requires:{http:"runtime.http"},provides:{bootstrap:"runtime.bootstrap"},setup({http:e}){
528
+ let t=pt();return e.router.register("GET",Ur,{auth:qr,meta:{tags:["bootstrap"],summary:"Resolve app bootstrap payload"}},
529
+ async(n,r)=>{r.code(200).send(await t.resolve({request:n,reply:r,query:n.query||{}}))}),{bootstrap:t}}});var Bo=W({id:"runtime.events",provides:{events:"runtime.events"},setup(){return{events:ue()}}});var Jo=8,Au=Object.freeze({notOffered:"This assistant does not keep unsaved tool calls out of what it saves, so it is no\
530
+ t offered here.",discoveryOnly:"Only the discovery tools are offered here, and an unsaved action is never discoverable.",
531
+ directLimit:`At most ${Jo} actions are offered directly beside action discovery.`});var Vr=20,Iu=32*1024,Cu=48*1024,mt=Object.freeze({search:"assistant_action_search",contract:"assistant_action_contract",
532
+ execute:"assistant_action_execute"}),ht=Object.freeze({type:"object",additionalProperties:!0}),Wo=Object.freeze({type:"o\
393
533
  bject",additionalProperties:!1,properties:{query:{type:"string",maxLength:200,description:"Optional literal words or act\
394
534
  ion-id fragments; every word must match. Use short resource or operation terms such as list. Omit query to browse all av\
395
535
  ailable actions."},cursor:{type:"string",maxLength:1e3,description:"Opaque cursor returned by the previous search page."},
396
- limit:{type:"integer",minimum:1,maximum:Ft,description:"Maximum compact matches to return."}}}),gn=Object.freeze({type:"\
397
- object",additionalProperties:!1,required:["items","nextCursor","total"],properties:{items:{type:"array",maxItems:Ft,items:{
536
+ limit:{type:"integer",minimum:1,maximum:Vr,description:"Maximum compact matches to return."}}}),Go=Object.freeze({type:"\
537
+ object",additionalProperties:!1,required:["items","nextCursor","total"],properties:{items:{type:"array",maxItems:Vr,items:{
398
538
  type:"object",additionalProperties:!1,required:["actionId","version","kind","description"],properties:{actionId:{type:"s\
399
539
  tring"},version:{type:"integer",minimum:1},kind:{type:"string"},description:{type:"string"}}}},nextCursor:{anyOf:[{type:"\
400
- string"},{type:"null"}]},total:{type:"integer",minimum:0}}}),bn=Object.freeze({type:"object",additionalProperties:!1,required:[
401
- "actionId"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1}}}),En=Object.
540
+ string"},{type:"null"}]},total:{type:"integer",minimum:0}}}),Ko=Object.freeze({type:"object",additionalProperties:!1,required:[
541
+ "actionId"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1}}}),Yo=Object.
402
542
  freeze({type:"object",additionalProperties:!1,required:["actionId","version","kind","description","inputSchema","outputS\
403
543
  chema"],properties:{actionId:{type:"string"},version:{type:"integer",minimum:1},kind:{type:"string"},description:{type:"\
404
- string"},inputSchema:Le,outputSchema:Le}}),vn=Object.freeze({type:"object",additionalProperties:!1,required:["actionId",
405
- "input"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1},input:Le}}),On=Object.
544
+ string"},inputSchema:ht,outputSchema:ht}}),Xo=Object.freeze({type:"object",additionalProperties:!1,required:["actionId",
545
+ "input"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1},input:ht}}),Zo=Object.
406
546
  freeze({type:"object",additionalProperties:!1,required:["actionId","version","result"],properties:{actionId:{type:"strin\
407
- g"},version:{type:"integer",minimum:1},result:{}}}),Ut=Object.freeze([Object.freeze({name:ze.search,description:"Discove\
547
+ g"},version:{type:"integer",minimum:1},result:{}}}),Br=Object.freeze([Object.freeze({name:mt.search,description:"Discove\
408
548
  r application actions available to the current user and surface, including list, search, and query operations for multip\
409
549
  le records. Search before claiming a capability is unavailable. If terminology does not match, use broader terms or omit\
410
- query to browse. Returns compact paged matches without schemas; follow nextCursor when more discovery is needed.",parameters:wn,
411
- outputSchema:gn}),Object.freeze({name:ze.contract,description:"Load the exact input and output contract for one availabl\
412
- e action before executing it.",parameters:bn,outputSchema:En}),Object.freeze({name:ze.execute,description:"Execute one a\
413
- vailable action after loading its exact contract in this turn. The action result is returned in result.",parameters:vn,outputSchema:On})]);var $e="This conversation has no authorization for that native tool.";import{mkdir as hc,readFile as In,rename as yc,writeFile as wc}from"node:fs/promises";import z from"node:path";function L(t,e={}){if(t?.modelProviderId&&e.model?.providerID!==t.modelProviderId)throw new Error("Assistants must use t\
414
- he session's selected AI account.")}function $(t={},e={}){let n=t.model?.limit?.output,r=Number.isSafeInteger(n)&&n>0?n:
415
- 32e3;Number.isSafeInteger(e.maxOutputTokens)&&e.maxOutputTokens>r&&(e.maxOutputTokens=r)}async function F(t=""){if(!t)return[];
416
- let e=JSON.parse(await In(t,"utf8"));return Array.isArray(e?.sessions)?e.sessions:[]}function Pn(t="",e=""){let n=z.relative(
417
- t,e);return n===""||!n.startsWith("..")&&!z.isAbsolute(n)}function U(t,e=""){let n=z.resolve(b(e)||process.cwd());return t.
418
- filter(r=>b(r?.workdir)&&Pn(z.resolve(r.workdir),n)).sort((r,o)=>z.resolve(o.workdir).length-z.resolve(r.workdir).length)[0]||
419
- null}async function q(t,e="",n=null){let r=new Set,o=b(e);for(;o&&!r.has(o)&&r.size<32;){let i=t.find(a=>b(a?.upstreamSessionId)===
550
+ query to browse. Returns compact paged matches without schemas; follow nextCursor when more discovery is needed.",parameters:Wo,
551
+ outputSchema:Go}),Object.freeze({name:mt.contract,description:"Load the exact input and output contract for one availabl\
552
+ e action before executing it.",parameters:Ko,outputSchema:Yo}),Object.freeze({name:mt.execute,description:"Execute one a\
553
+ vailable action after loading its exact contract in this turn. The action result is returned in result.",parameters:Xo,outputSchema:Zo})]);var yt="This conversation has no authorization for that native tool.";import{mkdir as Nl,readFile as oi,rename as Dl,writeFile as Ml}from"node:fs/promises";import G from"node:path";function K(e,t={}){if(e?.modelProviderId&&t.model?.providerID!==e.modelProviderId)throw new Error("Assistants must use t\
554
+ he session's selected AI account.")}function Y(e={},t={}){let n=e.model?.limit?.output,r=Number.isSafeInteger(n)&&n>0?n:
555
+ 32e3;Number.isSafeInteger(t.maxOutputTokens)&&t.maxOutputTokens>r&&(t.maxOutputTokens=r)}async function X(e=""){if(!e)return[];
556
+ let t=JSON.parse(await oi(e,"utf8"));return Array.isArray(t?.sessions)?t.sessions:[]}function ii(e="",t=""){let n=G.relative(
557
+ e,t);return n===""||!n.startsWith("..")&&!G.isAbsolute(n)}function Z(e,t=""){let n=G.resolve(C(t)||process.cwd());return e.
558
+ filter(r=>C(r?.workdir)&&ii(G.resolve(r.workdir),n)).sort((r,o)=>G.resolve(o.workdir).length-G.resolve(r.workdir).length)[0]||
559
+ null}async function Q(e,t="",n=null){let r=new Set,o=C(t);for(;o&&!r.has(o)&&r.size<32;){let i=e.find(a=>C(a?.upstreamSessionId)===
420
560
  o);if(i)return i;if(!n)return null;r.add(o);let s=await n.session.get({path:{id:o}});if(s.error)throw Object.assign(new Error(
421
- "The subagent's parent session could not be verified."),{code:"assistant_opencode_parent_unverified"});o=b(s.data?.parentID)}
422
- return null}function Be({resolveInstructions:t}){let e=new Map,n=new WeakMap;async function r(a={},c={}){let l=String(a.sessionID||a.
423
- sessionId||"").trim();if(!l)return;let u=await t(l);if(!u)return;if(u.identity!==void 0&&(typeof u.identity!="string"||!u.
424
- identity)||typeof u.read!="function"||![void 0,"append","replace"].includes(u.placement))throw new TypeError("Conversati\
425
- on instructions require read() and an optional non-empty identity.");let d=e.get(l);(u.identity===void 0||d?.identity!==
426
- u.identity)&&(d={identity:u.identity,text:Promise.resolve().then(u.read).then(h=>{if(typeof h!="string"||!h.trim())throw new TypeError(
427
- "Conversation instructions must contain text.");return h})},e.set(l,d),d.text.catch(()=>{e.get(l)===d&&e.delete(l)}));let f=await d.
428
- text;if(e.get(l)!==d)throw Object.assign(new Error("Conversation context changed while reading instructions. Retry befor\
429
- e sending."),{messageCode:"assistant.conversation.contextChangedReadingInstructions",messageParams:{}});let m=n.get(c.system);
430
- if(m!==void 0){let h=c.system.indexOf(m);h>=0&&c.system.splice(h,1)}u.placement==="replace"?c.system.splice(0,c.system.length,
561
+ "The subagent's parent session could not be verified."),{code:"assistant_opencode_parent_unverified"});o=C(s.data?.parentID)}
562
+ return null}function Et({resolveInstructions:e}){let t=new Map,n=new WeakMap;async function r(a={},c={}){let u=String(a.sessionID||a.
563
+ sessionId||"").trim();if(!u)return;let l=await e(u);if(!l)return;if(l.identity!==void 0&&(typeof l.identity!="string"||!l.
564
+ identity)||typeof l.read!="function"||![void 0,"append","replace"].includes(l.placement))throw new TypeError("Conversati\
565
+ on instructions require read() and an optional non-empty identity.");let d=t.get(u);(l.identity===void 0||d?.identity!==
566
+ l.identity)&&(d={identity:l.identity,text:Promise.resolve().then(l.read).then(m=>{if(typeof m!="string"||!m.trim())throw new TypeError(
567
+ "Conversation instructions must contain text.");return m})},t.set(u,d),d.text.catch(()=>{t.get(u)===d&&t.delete(u)}));let f=await d.
568
+ text;if(t.get(u)!==d)throw Object.assign(new Error("Conversation context changed while reading instructions. Retry befor\
569
+ e sending."),{messageCode:"assistant.conversation.contextChangedReadingInstructions",messageParams:{}});let p=n.get(c.system);
570
+ if(p!==void 0){let m=c.system.indexOf(p);m>=0&&c.system.splice(m,1)}l.placement==="replace"?c.system.splice(0,c.system.length,
431
571
  f):c.system.includes(f)||c.system.push(f),n.set(c.system,f)}function o({event:a}={}){if(!["session.compacted","session.d\
432
- eleted"].includes(a?.type))return;let c=String(a.properties?.sessionID||a.properties?.info?.id||"").trim();c&&e.delete(c)}
433
- function i(a){return e.delete(a)}function s(){return e.clear()}return Object.freeze({transformSystem:r,event:o,invalidate:i,
434
- close:s})}import{isAbsolute as jn}from"node:path";var vc=new URL("./../../../../@jskit-ai/assistant-core/src/server/conversation/commandWrapper.js",import.meta.url).href,
435
- Vt=t=>`'${t.replaceAll("'",`'"'"'`)}'`;function xn(t){if(typeof t!="string"||!jn(t)||t.includes("\0"))throw new TypeError(
436
- "host.commandWrapper must name an absolute executable path.")}function Ht(t,e){if(xn(t),typeof e!="string"||!e.trim()||e.
437
- includes("\0"))throw new TypeError("The native shell tool requires valid command text.");return`${Vt(t)} ${Vt(e)}`}async function Y({client:t,registryPath:e=process.env.JSKIT_OPENCODE_ENV_REGISTRY,resolveHostInstructions:n}={}){let r=JSON.
438
- parse(process.env.JSKIT_OPENCODE_TOOL_SCHEMAS||"[]"),o=new Map(r.map(({function:l})=>[l.name,l])),i=()=>F(e);async function s(l){
439
- let u=await q(await i(),l,t);if(!u)throw new Error("This native conversation has no instruction owner.");return u}let a=Be(
440
- {async resolveInstructions(l){let{conversation:u}=await s(l);return u?{identity:u.systemPrompt,placement:"replace",read:()=>u.
441
- systemPrompt}:null}}),c=n?Be({resolveInstructions:async l=>(await n(l))?.instructions}):null;return{"experimental.chat.s\
442
- ystem.transform":c?async(l,u)=>(await n(l.sessionID||l.sessionId))?.conversation?a.transformSystem(l,u):c.transformSystem(
443
- l,u):a.transformSystem,event:c?l=>{c.event(l),a.event(l)}:a.event,"chat.params":async(l,u)=>{let d=await s(l.sessionID);
444
- L(d,l),$(l,u)},"tool.execute.before":async({tool:l,sessionID:u},d)=>{let{conversation:f}=await s(u);if(!(o.has(l)?f?.tools?.
445
- schemas.some(({function:h})=>h.name===l):f?.nativeTools))throw new Error($e);l==="bash"&&f.commandWrapper&&(d.args.command=
446
- Ht(f.commandWrapper,d.args.command))},"shell.env":async({sessionID:l,cwd:u},d)=>{let f=l?await s(l):U(await i(),u);f?.conversation?.
447
- nativeTools&&Object.assign(d.env,f.env)},"tool.definition":({toolID:l},u)=>{let d=o.get(l);d&&(u.jsonSchema=d.parameters)},
448
- tool:Object.fromEntries([...o].map(([l,u])=>[l,{description:u.description,args:u.parameters.properties,async execute(d,f){
449
- if(!f.callID||!f.sessionID||!f.messageID)throw new Error("OpenCode did not supply an application tool identity.");let m=(await s(
450
- f.sessionID)).conversation?.tools;if(!m?.schemas.some(({function:x})=>x.name===l))throw new Error($e);let h=await fetch(
451
- m.url,{method:"POST",signal:f.abort,headers:{authorization:`Bearer ${m.token}`,"content-type":"application/json"},body:JSON.
452
- stringify({sessionId:f.sessionID,messageId:f.messageID,id:f.callID,name:l,input:d})}),E=await h.json();if(!h.ok)throw new Error(
453
- E.error||"The application tool request failed.");return JSON.stringify(E)}}]))}}var Rc=new URL("./../../../../@jskit-ai/assistant-core/src/server/conversation/openCodeProcess.js",import.meta.url).href;var Lc=256*1024;var $c=2*1024*1024;var Mn=Ut.map(({name:t,description:e,parameters:n})=>({type:"function",function:{name:t,description:e,parameters:n}}));import{vibe64Driver as Ln}from"@local/vibe64-genesis/server/promptContext";function g(t=""){return String(t??"").trim()}
454
- async function He(){return F(g(process.env.VIBE64_OPENCODE_SESSION_ENV_REGISTRY))}async function $n(t=""){return U(await He(),
455
- t)}async function B(t="",e=null){try{return await q(await He(),t,e)}catch(n){throw n.code==="assistant_opencode_parent_u\
456
- nverified"?new Error("Vibe64 could not verify the subagent's parent session."):n}}function Ve(t,e){return!!(e?.helperModelId&&
457
- t===`vibe64-helper-${e.modelProviderId}`)}function X(t=""){return`'${String(t??"").replaceAll("'",`'"'"'`)}'`}function Fn(){
572
+ eleted"].includes(a?.type))return;let c=String(a.properties?.sessionID||a.properties?.info?.id||"").trim();c&&t.delete(c)}
573
+ function i(a){return t.delete(a)}function s(){return t.clear()}return Object.freeze({transformSystem:r,event:o,invalidate:i,
574
+ close:s})}import{isAbsolute as si}from"node:path";var $l=new URL("./../../../../@jskit-ai/assistant-core/src/server/conversation/commandWrapper.js",import.meta.url).href,
575
+ Wr=e=>`'${e.replaceAll("'",`'"'"'`)}'`;function ai(e){if(typeof e!="string"||!si(e)||e.includes("\0"))throw new TypeError(
576
+ "host.commandWrapper must name an absolute executable path.")}function Gr(e,t){if(ai(e),typeof t!="string"||!t.trim()||t.
577
+ includes("\0"))throw new TypeError("The native shell tool requires valid command text.");return`${Wr(e)} ${Wr(t)}`}async function le({client:e,registryPath:t=process.env.JSKIT_OPENCODE_ENV_REGISTRY,resolveHostInstructions:n}={}){let r=JSON.
578
+ parse(process.env.JSKIT_OPENCODE_TOOL_SCHEMAS||"[]"),o=new Map(r.map(({function:u})=>[u.name,u])),i=()=>X(t);async function s(u){
579
+ let l=await Q(await i(),u,e);if(!l)throw new Error("This native conversation has no instruction owner.");return l}let a=Et(
580
+ {async resolveInstructions(u){let{conversation:l}=await s(u);return l?{identity:l.systemPrompt,placement:"replace",read:()=>l.
581
+ systemPrompt}:null}}),c=n?Et({resolveInstructions:async u=>(await n(u))?.instructions}):null;return{"experimental.chat.s\
582
+ ystem.transform":c?async(u,l)=>(await n(u.sessionID||u.sessionId))?.conversation?a.transformSystem(u,l):c.transformSystem(
583
+ u,l):a.transformSystem,event:c?u=>{c.event(u),a.event(u)}:a.event,"chat.params":async(u,l)=>{let d=await s(u.sessionID);
584
+ K(d,u),Y(u,l)},"tool.execute.before":async({tool:u,sessionID:l},d)=>{let{conversation:f}=await s(l);if(!(o.has(u)?f?.tools?.
585
+ schemas.some(({function:m})=>m.name===u):f?.nativeTools))throw new Error(yt);u==="bash"&&f.commandWrapper&&(d.args.command=
586
+ Gr(f.commandWrapper,d.args.command))},"shell.env":async({sessionID:u,cwd:l},d)=>{let f=u?await s(u):Z(await i(),l);f?.conversation?.
587
+ nativeTools&&Object.assign(d.env,f.env)},"tool.definition":({toolID:u},l)=>{let d=o.get(u);d&&(l.jsonSchema=d.parameters)},
588
+ tool:Object.fromEntries([...o].map(([u,l])=>[u,{description:l.description,args:l.parameters.properties,async execute(d,f){
589
+ if(!f.callID||!f.sessionID||!f.messageID)throw new Error("OpenCode did not supply an application tool identity.");let p=(await s(
590
+ f.sessionID)).conversation?.tools;if(!p?.schemas.some(({function:x})=>x.name===u))throw new Error(yt);let m=await fetch(
591
+ p.url,{method:"POST",signal:f.abort,headers:{authorization:`Bearer ${p.token}`,"content-type":"application/json"},body:JSON.
592
+ stringify({sessionId:f.sessionID,messageId:f.messageID,id:f.callID,name:u,input:d})}),v=await m.json();if(!m.ok)throw new Error(
593
+ v.error||"The application tool request failed.");return JSON.stringify(v)}}]))}}var Yl=new URL("./../../../../@jskit-ai/assistant-core/src/server/conversation/openCodeProcess.js",import.meta.url).href;var rd=256*1024;var nd=2*1024*1024;var li=Br.map(({name:e,description:t,parameters:n})=>({type:"function",function:{name:e,description:t,parameters:n}}));import{vibe64Driver as mi}from"@local/vibe64-genesis/server/promptContext";function A(e=""){return String(e??"").trim()}
594
+ async function vt(){return X(A(process.env.VIBE64_OPENCODE_SESSION_ENV_REGISTRY))}async function hi(e=""){return Z(await vt(),
595
+ e)}async function ee(e="",t=null){try{return await Q(await vt(),e,t)}catch(n){throw n.code==="assistant_opencode_parent_\
596
+ unverified"?new Error("Vibe64 could not verify the subagent's parent session."):n}}function Ot(e,t){return!!(t?.helperModelId&&
597
+ e===`vibe64-helper-${t.modelProviderId}`)}function de(e=""){return`'${String(e??"").replaceAll("'",`'"'"'`)}'`}function yi(){
458
598
  return"printf '%s\\n' 'vibe64_agent_control_unavailable: Session command control is unavailable. Reconnect the assistant.\
459
- ' >&2; exit 126"}function Jt(t="",e=null){let n=String(t),r=g(e?.env?.VIBE64_WRAPPER);if(!r)return n;let o=`${X(r)} '`;if(!n.
460
- startsWith(o)||!n.endsWith("'"))return n;let i=n.slice(o.length,-1).replaceAll(`'"'"'`,"'");return`${X(r)} ${X(i)}`===n?
461
- i:n}function Wt(t="",e=null){let n=String(t),r=Jt(n,e);for(;r!==n;)n=r,r=Jt(n,e);return n}function Un(t="",e=null){let n=g(
462
- e?.env?.VIBE64_WRAPPER);if(!n)return Fn();let r=Wt(t,e);return[X(n),X(r)].join(" ")}var al=async({client:t}={})=>{let e=await Y(
463
- {client:t,registryPath:g(process.env.VIBE64_OPENCODE_SESSION_ENV_REGISTRY),resolveHostInstructions:async n=>{let r=await B(
464
- n,t);if(!r?.promptContext)return{conversation:r?.conversation,instructions:null};let{workdir:o,promptContext:i}=r;return i.
465
- scope==="ephemeral"?{conversation:r.conversation,instructions:{identity:JSON.stringify(i),placement:"replace",read:()=>Ln(
466
- i)}}:{conversation:r.conversation,instructions:{placement:"append",read:()=>{let s=kn(new URL("../../bin/vibe64-genesis-\
467
- host-context",import.meta.resolve("@local/vibe64-genesis/server/promptContext")));return new Promise((a,c)=>{let l=Dn(s,
468
- ["--instructions"],{cwd:o,timeout:3e4,maxBuffer:262144,encoding:"utf8"},(u,d)=>{u?c(new Error("Project instructions coul\
469
- d not be loaded. Retry the conversation.",{cause:u})):a(d)});l.stdin.on("error",()=>{}),l.stdin.end(JSON.stringify({workdir:o,
470
- promptContext:i}))})}}}}});return{...e,"chat.message":async(n={},r={})=>{if(!g(n.agent).startsWith("vibe64-helper-"))return;
471
- let o=await B(n.sessionID,t);if(!Ve(n.agent,o))throw new Error("This helper is not available through the session's selec\
472
- ted AI account.");r.message.model={providerID:o.modelProviderId,modelID:o.helperModelId}},"chat.params":async(n={},r={})=>{
473
- let o=await B(n.sessionID,t);if(L(o,n),g(n.agent).startsWith("vibe64-helper-")&&(!Ve(n.agent,o)||n.model?.providerID!==o.
474
- modelProviderId||n.model?.id!==o.helperModelId))throw new Error("This helper is not available through the session's sele\
475
- cted AI account.");$(n,r)},"experimental.chat.messages.transform":async(...n)=>{let r=n[1]||{},o=Array.isArray(r.messages)?
476
- r.messages:[],i=await He();r.messages=await Promise.all(o.map(async s=>{let a=i.find(u=>g(u?.upstreamSessionId)===g(s?.info?.
477
- sessionID))||await B(s?.info?.sessionID,t);if(!a||!Array.isArray(s?.parts))return s;let c=!1,l=s.parts.map(u=>{if(u?.type!==
478
- "tool"||!["bash","shell"].includes(g(u.tool).toLowerCase())||typeof u?.state?.input?.command!="string")return u;let d=Wt(
479
- u.state.input.command,a);return d===u.state.input.command?u:(c=!0,{...u,state:{...u.state,input:{...u.state.input,command:d}}})});
480
- return c?{...s,parts:l}:s}))},"shell.env":async(n={},r={})=>{let o=await $n(n.cwd);if(!o)return;if(o.conversation)return e["\
599
+ ' >&2; exit 126"}function Kr(e="",t=null){let n=String(e),r=A(t?.env?.VIBE64_WRAPPER);if(!r)return n;let o=`${de(r)} '`;
600
+ if(!n.startsWith(o)||!n.endsWith("'"))return n;let i=n.slice(o.length,-1).replaceAll(`'"'"'`,"'");return`${de(r)} ${de(i)}`===
601
+ n?i:n}function Yr(e="",t=null){let n=String(e),r=Kr(n,t);for(;r!==n;)n=r,r=Kr(n,t);return n}function wi(e="",t=null){let n=A(
602
+ t?.env?.VIBE64_WRAPPER);if(!n)return yi();let r=Yr(e,t);return[de(n),de(r)].join(" ")}var Id=async({client:e}={})=>{let t=await le(
603
+ {client:e,registryPath:A(process.env.VIBE64_OPENCODE_SESSION_ENV_REGISTRY),resolveHostInstructions:async n=>{let r=await ee(
604
+ n,e);if(!r?.promptContext)return{conversation:r?.conversation,instructions:null};let{workdir:o,promptContext:i}=r;return i.
605
+ scope==="ephemeral"?{conversation:r.conversation,instructions:{identity:JSON.stringify(i),placement:"replace",read:()=>mi(
606
+ i)}}:{conversation:r.conversation,instructions:{placement:"append",read:()=>{let s=fi(new URL("../../bin/vibe64-genesis-\
607
+ host-context",import.meta.resolve("@local/vibe64-genesis/server/promptContext")));return new Promise((a,c)=>{let u=di(s,
608
+ ["--instructions"],{cwd:o,timeout:3e4,maxBuffer:262144,encoding:"utf8"},(l,d)=>{l?c(new Error("Project instructions coul\
609
+ d not be loaded. Retry the conversation.",{cause:l})):a(d)});u.stdin.on("error",()=>{}),u.stdin.end(JSON.stringify({workdir:o,
610
+ promptContext:i}))})}}}}});return{...t,"chat.message":async(n={},r={})=>{if(!A(n.agent).startsWith("vibe64-helper-"))return;
611
+ let o=await ee(n.sessionID,e);if(!Ot(n.agent,o))throw new Error("This helper is not available through the session's sele\
612
+ cted AI account.");r.message.model={providerID:o.modelProviderId,modelID:o.helperModelId}},"chat.params":async(n={},r={})=>{
613
+ let o=await ee(n.sessionID,e);if(K(o,n),A(n.agent).startsWith("vibe64-helper-")&&(!Ot(n.agent,o)||n.model?.providerID!==
614
+ o.modelProviderId||n.model?.id!==o.helperModelId))throw new Error("This helper is not available through the session's se\
615
+ lected AI account.");Y(n,r)},"experimental.chat.messages.transform":async(...n)=>{let r=n[1]||{},o=Array.isArray(r.messages)?
616
+ r.messages:[],i=await vt();r.messages=await Promise.all(o.map(async s=>{let a=i.find(l=>A(l?.upstreamSessionId)===A(s?.info?.
617
+ sessionID))||await ee(s?.info?.sessionID,e);if(!a||!Array.isArray(s?.parts))return s;let c=!1,u=s.parts.map(l=>{if(l?.type!==
618
+ "tool"||!["bash","shell"].includes(A(l.tool).toLowerCase())||typeof l?.state?.input?.command!="string")return l;let d=Yr(
619
+ l.state.input.command,a);return d===l.state.input.command?l:(c=!0,{...l,state:{...l.state,input:{...l.state.input,command:d}}})});
620
+ return c?{...s,parts:u}:s}))},"shell.env":async(n={},r={})=>{let o=await hi(n.cwd);if(!o)return;if(o.conversation)return t["\
481
621
  shell.env"](n,r);let i=o.env&&typeof o.env=="object"&&!Array.isArray(o.env)?o.env:{},s=r.env&&typeof r.env=="object"&&!Array.
482
- isArray(r.env)?r.env:{};r.env=s,Object.assign(s,i);let a=Array.isArray(o.pathEntries)?o.pathEntries.map(g).filter(Boolean):
483
- [];s.PATH=[...a,g(i.PATH),g(process.env.PATH)].filter(Boolean).join(zn.delimiter)},"tool.execute.before":async(n={},r={})=>{
484
- let o=await B(n.sessionID||n.sessionId,t);if(!o)throw new Error("Vibe64 could not verify this conversation's tool access\
485
- . Reconnect the assistant.");if(o.conversation)return e["tool.execute.before"](n,r);if(o.promptContext?.scope==="ephemer\
486
- al")throw new Error("Tools are unavailable in this host conversation. Use only the supplied context.");if(n.tool==="task"){
487
- if(g(r.args?.subagent_type).startsWith("vibe64-helper-")&&!Ve(r.args.subagent_type,o))throw new Error("Choose the helper\
488
- belonging to this session's selected AI account.");if(g(r.args?.task_id)){let s=await B(r.args.task_id,t);if(!o||s?.upstreamSessionId!==
489
- o.upstreamSessionId)throw new Error("This helper conversation does not belong to the current session.")}}if(!["bash","sh\
490
- ell"].includes(g(n.tool).toLowerCase()))return;let i=r.args&&typeof r.args=="object"&&!Array.isArray(r.args)?r.args:null;
491
- !i||typeof i.command!="string"||(i.command=Un(i.command,o))}}};export{al as Vibe64SessionEnvironment};
622
+ isArray(r.env)?r.env:{};r.env=s,Object.assign(s,i);let a=Array.isArray(o.pathEntries)?o.pathEntries.map(A).filter(Boolean):
623
+ [];s.PATH=[...a,A(i.PATH),A(process.env.PATH)].filter(Boolean).join(pi.delimiter)},"tool.execute.before":async(n={},r={})=>{
624
+ let o=await ee(n.sessionID||n.sessionId,e);if(!o)throw new Error("Vibe64 could not verify this conversation's tool acces\
625
+ s. Reconnect the assistant.");if(o.conversation)return t["tool.execute.before"](n,r);if(o.promptContext?.scope==="epheme\
626
+ ral")throw new Error("Tools are unavailable in this host conversation. Use only the supplied context.");if(n.tool==="tas\
627
+ k"){if(A(r.args?.subagent_type).startsWith("vibe64-helper-")&&!Ot(r.args.subagent_type,o))throw new Error("Choose the he\
628
+ lper belonging to this session's selected AI account.");if(A(r.args?.task_id)){let s=await ee(r.args.task_id,e);if(!o||s?.
629
+ upstreamSessionId!==o.upstreamSessionId)throw new Error("This helper conversation does not belong to the current session\
630
+ .")}}if(!["bash","shell"].includes(A(n.tool).toLowerCase()))return;let i=r.args&&typeof r.args=="object"&&!Array.isArray(
631
+ r.args)?r.args:null;!i||typeof i.command!="string"||(i.command=wi(i.command,o))}}};export{Id as Vibe64SessionEnvironment};