dal-code 1.0.29 → 1.0.31

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 (155) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
  3. package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
  4. package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
  5. package/dist/node_modules/@dalcode/dal-guard/src/index.js +1 -1
  6. package/dist/node_modules/@dalcode/dal-guard/src/mode.js +2 -2
  7. package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
  8. package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
  9. package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
  10. package/dist/node_modules/@dalcode/dal-lsp/package.json +3 -3
  11. package/dist/node_modules/@dalcode/dal-mcp/package.json +5 -5
  12. package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
  13. package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +2 -2
  14. package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
  15. package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +2 -2
  16. package/dist/node_modules/@dalcode/dal-plugins/package.json +2 -2
  17. package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
  18. package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
  19. package/dist/node_modules/@dalcode/dal-router/package.json +4 -4
  20. package/dist/node_modules/@dalcode/dal-skills/package.json +4 -3
  21. package/dist/node_modules/@dalcode/dal-skills/src/catalog.js +2 -0
  22. package/dist/node_modules/@dalcode/dal-skills/src/index.js +12 -11
  23. package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
  24. package/dist/node_modules/@dalcode/dal-telemetry/package.json +2 -2
  25. package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
  26. package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
  27. package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
  28. package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
  29. package/dist/node_modules/@dalcode/dal-workflow/src/todo.js +2 -2
  30. package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
  31. package/dist/node_modules/@earendil-works/chord/package.json +1 -1
  32. package/dist/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
  33. package/dist/node_modules/@earendil-works/pi-ai/dist/cli.js +0 -0
  34. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  35. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  36. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  37. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/google-vertex.json +1 -1
  38. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
  39. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/meta.json +1 -1
  40. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
  41. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  42. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  43. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
  44. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  45. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.js +1 -1
  46. package/dist/node_modules/@earendil-works/pi-ai/package.json +2 -2
  47. package/dist/node_modules/@earendil-works/pi-client/package.json +3 -3
  48. package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
  49. package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
  50. package/dist/node_modules/@earendil-works/pi-mcp/package.json +1 -1
  51. package/dist/node_modules/@earendil-works/pi-protocol/package.json +2 -2
  52. package/dist/node_modules/@earendil-works/pi-server/package.json +3 -3
  53. package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  54. package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
  55. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  56. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  57. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  58. package/examples/extensions/gondolin/package-lock.json +2 -2
  59. package/examples/extensions/gondolin/package.json +1 -1
  60. package/examples/extensions/sandbox/package-lock.json +2 -2
  61. package/examples/extensions/sandbox/package.json +1 -1
  62. package/examples/extensions/with-deps/package-lock.json +2 -2
  63. package/examples/extensions/with-deps/package.json +1 -1
  64. package/npm-shrinkwrap.json +2 -2
  65. package/package.json +1 -1
  66. package/dist/bundle/chunks/anthropic-messages-AZKHNVAG.js +0 -5
  67. package/dist/bundle/chunks/anthropic.js +0 -74
  68. package/dist/bundle/chunks/azure-openai-responses-LA3FYF3J.js +0 -1
  69. package/dist/bundle/chunks/bedrock-converse-stream.js +0 -82
  70. package/dist/bundle/chunks/chunk-4HEMJ3PG.js +0 -1140
  71. package/dist/bundle/chunks/chunk-4L3WN2XY.js +0 -1
  72. package/dist/bundle/chunks/chunk-4UTLMBZZ.js +0 -13
  73. package/dist/bundle/chunks/chunk-4XT6IQQ6.js +0 -1
  74. package/dist/bundle/chunks/chunk-5M7W2EDY.js +0 -3
  75. package/dist/bundle/chunks/chunk-5ULSWE2O.js +0 -43
  76. package/dist/bundle/chunks/chunk-6CYCI3EJ.js +0 -11
  77. package/dist/bundle/chunks/chunk-7ZC4UXSL.js +0 -1
  78. package/dist/bundle/chunks/chunk-ABVPQ2YN.js +0 -14
  79. package/dist/bundle/chunks/chunk-DRQDKNXA.js +0 -1
  80. package/dist/bundle/chunks/chunk-F5ZABL6Z.js +0 -19
  81. package/dist/bundle/chunks/chunk-GYI2XXNW.js +0 -10
  82. package/dist/bundle/chunks/chunk-H3QXYIF7.js +0 -30
  83. package/dist/bundle/chunks/chunk-HC56T2OZ.js +0 -134
  84. package/dist/bundle/chunks/chunk-HMFU7ZIF.js +0 -1
  85. package/dist/bundle/chunks/chunk-JEMNLK2O.js +0 -10
  86. package/dist/bundle/chunks/chunk-L2ZPNLYD.js +0 -1
  87. package/dist/bundle/chunks/chunk-LPXNMA2W.js +0 -1
  88. package/dist/bundle/chunks/chunk-PGXDEOVV.js +0 -1
  89. package/dist/bundle/chunks/chunk-PJACZCIR.js +0 -1
  90. package/dist/bundle/chunks/chunk-PMRZO46Y.js +0 -1
  91. package/dist/bundle/chunks/chunk-PRRNXB7S.js +0 -1
  92. package/dist/bundle/chunks/chunk-PRXLTI3Y.js +0 -81
  93. package/dist/bundle/chunks/chunk-Q6IMZXWD.js +0 -129
  94. package/dist/bundle/chunks/chunk-R4YWRKK4.js +0 -7
  95. package/dist/bundle/chunks/chunk-RDZVAGPR.js +0 -1
  96. package/dist/bundle/chunks/chunk-S3GGRYIO.js +0 -5
  97. package/dist/bundle/chunks/chunk-TEPMHNKQ.js +0 -1
  98. package/dist/bundle/chunks/chunk-TRDNDS6A.js +0 -3
  99. package/dist/bundle/chunks/chunk-USJZMAIR.js +0 -1
  100. package/dist/bundle/chunks/chunk-UTB4DTYQ.js +0 -1
  101. package/dist/bundle/chunks/chunk-WXULTH2D.js +0 -1
  102. package/dist/bundle/chunks/chunk-YKF7PQCJ.js +0 -1
  103. package/dist/bundle/chunks/chunk-YTERFI73.js +0 -1
  104. package/dist/bundle/chunks/chunk-ZBURYEWF.js +0 -1
  105. package/dist/bundle/chunks/chunk-ZKDITC7J.js +0 -35
  106. package/dist/bundle/chunks/cli-2LJMKSUZ.js +0 -50
  107. package/dist/bundle/chunks/cloudflare-workers-ai-system-one-6WEJUIW2.js +0 -1
  108. package/dist/bundle/chunks/codemode-worker.js +0 -470
  109. package/dist/bundle/chunks/dist-37IE4EWG.js +0 -10
  110. package/dist/bundle/chunks/easter-egg-3d-GHWWTBZN.js +0 -1
  111. package/dist/bundle/chunks/execute-JU22LJZT.js +0 -489
  112. package/dist/bundle/chunks/github-copilot.js +0 -1
  113. package/dist/bundle/chunks/google-generative-ai-RFPHNE43.js +0 -1
  114. package/dist/bundle/chunks/google-vertex-QDNCMHLE.js +0 -1
  115. package/dist/bundle/chunks/http-proxy-6TR4MP55.js +0 -1
  116. package/dist/bundle/chunks/https-proxy-agent-2VXB7436.js +0 -12
  117. package/dist/bundle/chunks/image-resize-worker.js +0 -1
  118. package/dist/bundle/chunks/jiti-loader-C3NU2SDH.js +0 -20
  119. package/dist/bundle/chunks/jiti-static-loader-E6ANQD5T.js +0 -1
  120. package/dist/bundle/chunks/kimi-coding.js +0 -1
  121. package/dist/bundle/chunks/lib-TEDK3E5I.js +0 -8
  122. package/dist/bundle/chunks/llama-cpp-classify-FYN623RH.js +0 -21
  123. package/dist/bundle/chunks/meta.js +0 -1
  124. package/dist/bundle/chunks/mistral-conversations-YHX5TRKG.js +0 -4
  125. package/dist/bundle/chunks/multipart-parser-SQ6GDJL7.js +0 -2
  126. package/dist/bundle/chunks/node-N5BSDOA5.js +0 -15
  127. package/dist/bundle/chunks/node-TWVVAGPO.js +0 -1
  128. package/dist/bundle/chunks/openai-chatgpt.js +0 -74
  129. package/dist/bundle/chunks/openai-codex-responses-UZEMMAYZ.js +0 -9
  130. package/dist/bundle/chunks/openai-codex.js +0 -74
  131. package/dist/bundle/chunks/openai-completions-H6WMELZZ.js +0 -6
  132. package/dist/bundle/chunks/openai-decisions-URHWCZPN.js +0 -4
  133. package/dist/bundle/chunks/openai-responses-7X65PCAB.js +0 -2
  134. package/dist/bundle/chunks/openrouter-images-DUPG5DZO.js +0 -1
  135. package/dist/bundle/chunks/openrouter.js +0 -74
  136. package/dist/bundle/chunks/pi-messages-YHKPQIHC.js +0 -7
  137. package/dist/bundle/chunks/radius.js +0 -74
  138. package/dist/bundle/chunks/runtime-LLITCT4N.js +0 -1
  139. package/dist/bundle/chunks/src-UK77SYZE.js +0 -3
  140. package/dist/bundle/chunks/typesafe-system-one-N7PKHI2N.js +0 -1
  141. package/dist/bundle/chunks/virtual-modules-H32OTUCD.js +0 -1
  142. package/dist/bundle/chunks/xai.js +0 -1
  143. package/dist/bundle/cli-runtime.js +0 -2
  144. package/dist/bundle/cli.js +0 -2
  145. package/dist/bundle/index.js +0 -1
  146. package/dist/bundle/rpc-entry.js +0 -2
  147. package/dist/core/key-id-schema.js +0 -1
  148. package/dist/core/keybindings-schema.js +0 -1
  149. package/dist/core/settings-defaults.js +0 -1
  150. package/dist/core/settings-schema.js +0 -1
  151. package/dist/modes/interactive/components/daxnuts.js +0 -1
  152. package/dist/modes/interactive/theme/theme-schema.js +0 -12
  153. package/dist/modes/interactive/theme/theme-tokens.js +0 -1
  154. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.js +0 -1
  155. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.js +0 -1
@@ -1 +0,0 @@
1
- var c=Object.defineProperty;var o=(e,r)=>c(e,"name",{value:r,configurable:!0});import{createRequire as i}from"node:module";const p=i(import.meta.url);var y=Object.create,_=Object.defineProperty,s=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,f=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty,P=(e=>typeof p<"u"?p:typeof Proxy<"u"?new Proxy(e,{get:o((r,t)=>(typeof p<"u"?p:r)[t],"get")}):e)(function(e){if(typeof p<"u")return p.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),l=o((e,r,t)=>function(){if(t)throw t[0];try{return e&&(r=(0,e[n(e)[0]])(e=0)),r}catch(a){throw t=[a],a}},"__esm"),v=o((e,r)=>function(){try{return r||(0,e[n(e)[0]])((r={exports:{}}).exports,r),r.exports}catch(t){throw r=0,t}},"__commonJS"),w=o((e,r)=>{for(var t in r)_(e,t,{get:r[t],enumerable:!0})},"__export"),b=o((e,r,t,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let u of n(r))!O.call(e,u)&&u!==t&&_(e,u,{get:o(()=>r[u],"get"),enumerable:!(a=s(r,u))||a.enumerable});return e},"__copyProps"),h=o((e,r,t)=>(t=e!=null?y(f(e)):{},b(r||!e||!e.__esModule?_(t,"default",{value:e,enumerable:!0}):t,e)),"__toESM");export{v as __commonJS,l as __esm,w as __export,P as __require,h as __toESM};
@@ -1,13 +0,0 @@
1
- var u=Object.defineProperty;var s=(a,d)=>u(a,"name",{value:d,configurable:!0});import{createRequire as c}from"node:module";const b=c(import.meta.url);import{createServer as h}from"node:http";import{request as m}from"node:http";import{request as T}from"node:https";import{connect as v}from"node:net";import{URL as f}from"node:url";function o(a,d){if(!process.env.SRT_DEBUG)return;let t=d?.level||"info",e="[SandboxDebug]";switch(t){case"error":console.error(`${e} ${a}`);break;case"warn":console.warn(`${e} ${a}`);break;default:console.error(`${e} ${a}`)}}s(o,"logForDebugging");function w(a){let d=h();return d.on("connect",async(t,e)=>{e.on("error",r=>{o(`Client socket error: ${r.message}`,{level:"error"})});try{let[r,p]=t.url.split(":"),i=p===void 0?void 0:parseInt(p,10);if(!r||!i){o(`Invalid CONNECT request: ${t.url}`,{level:"error"}),e.end(`HTTP/1.1 400 Bad Request\r
2
- \r
3
- `);return}if(!await a.filter(i,r,e)){o(`Connection blocked to ${r}:${i}`,{level:"error"}),e.end(`HTTP/1.1 403 Forbidden\r
4
- Content-Type: text/plain\r
5
- X-Proxy-Error: blocked-by-allowlist\r
6
- \r
7
- Connection blocked by network allowlist`);return}let n=v(i,r,()=>{e.write(`HTTP/1.1 200 Connection Established\r
8
- \r
9
- `),n.pipe(e),e.pipe(n)});n.on("error",l=>{o(`CONNECT tunnel failed: ${l.message}`,{level:"error"}),e.end(`HTTP/1.1 502 Bad Gateway\r
10
- \r
11
- `)}),e.on("error",l=>{o(`Client socket error: ${l.message}`,{level:"error"}),n.destroy()}),e.on("end",()=>n.end()),n.on("end",()=>e.end())}catch(r){o(`Error handling CONNECT: ${r}`,{level:"error"}),e.end(`HTTP/1.1 500 Internal Server Error\r
12
- \r
13
- `)}}),d.on("request",async(t,e)=>{try{let r=new f(t.url),p=r.hostname,i=r.port?parseInt(r.port,10):r.protocol==="https:"?443:80;if(!await a.filter(i,p,t.socket)){o(`HTTP request blocked to ${p}:${i}`,{level:"error"}),e.writeHead(403,{"Content-Type":"text/plain","X-Proxy-Error":"blocked-by-allowlist"}),e.end("Connection blocked by network allowlist");return}let n=(r.protocol==="https:"?T:m)({hostname:p,port:i,path:r.pathname+r.search,method:t.method,headers:{...t.headers,host:r.host}},l=>{e.writeHead(l.statusCode,l.headers),l.pipe(e)});n.on("error",l=>{o(`Proxy request failed: ${l.message}`,{level:"error"}),e.headersSent||(e.writeHead(502,{"Content-Type":"text/plain"}),e.end("Bad Gateway"))}),t.pipe(n)}catch(r){o(`Error handling HTTP request: ${r}`,{level:"error"}),e.writeHead(500,{"Content-Type":"text/plain"}),e.end("Internal Server Error")}}),d}s(w,"createHttpProxyServer");export{w as createHttpProxyServer,o as logForDebugging};
@@ -1 +0,0 @@
1
- var J=Object.defineProperty;var o=(e,r)=>J(e,"name",{value:r,configurable:!0});import{createRequire as L}from"node:module";const ye=L(import.meta.url);import{clampThinkingLevel as G,getSystemMessageText as B}from"./chunk-GYI2XXNW.js";function U(){return typeof process>"u"||!(process.versions?.node||process.versions?.bun)?null:process.getBuiltinModule?.("node:os")??null}o(U,"loadNodeOs");var T=U();function W(){return T?`dal (${T.platform()} ${T.release()}; ${T.arch()})`:"dal (browser)"}o(W,"getPiUserAgent");var f=class extends Error{static{o(this,"UnsupportedStrictJsonSchemaError")}},H=["$ref","$defs","definitions","allOf","oneOf","patternProperties","dependentSchemas","dependencies","unevaluatedProperties","propertyNames","contains","prefixItems","not","if","then","else"];function h(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}o(h,"isJsonSchemaObject");function F(e){if(!h(e))return!1;let r=typeof e.type=="string"?[e.type]:Array.isArray(e.type)?e.type:[];return r.includes("object")||r.includes("array")||e.properties!==void 0||e.items!==void 0}o(F,"isStructuredSchema");function I(e){return h(e)?e.type==="null"||Array.isArray(e.type)&&e.type.includes("null")||e.const===null||Array.isArray(e.enum)&&e.enum.includes(null)?!0:Array.isArray(e.anyOf)&&e.anyOf.some(r=>I(r)):!1}o(I,"schemaAllowsNull");function S(e,r){if(!h(e))throw new f("boolean schemas are unsupported");for(let a of H)if(e[a]!==void 0)throw new f(`${a} schemas are unsupported`);if(r){for(let[a,d]of Object.entries(e))if(r(a,d))throw new f(`${a}: ${JSON.stringify(d)} is unsupported`)}if(e.anyOf!==void 0){if(!Array.isArray(e.anyOf)||e.anyOf.length===0)throw new f("anyOf must contain at least one schema");for(let a of e.anyOf){if(F(a))throw new f("object and array unions are unsupported");S(a,r)}}if(e.items!==void 0){if(Array.isArray(e.items))throw new f("tuple schemas are unsupported");S(e.items,r)}let t=e.type==="object";if(e.properties!==void 0&&!t)throw new f("properties require type object");if(!t)return;if(e.additionalProperties!==void 0&&e.additionalProperties!==!1)throw new f("schema-valued or true additionalProperties is unsupported");if(e.properties!==void 0&&!h(e.properties))throw new f("object properties must be a schema map");if(e.required!==void 0&&(!Array.isArray(e.required)||e.required.some(a=>typeof a!="string")))throw new f("object required must be a string array");let n=e.properties??{},i=Object.keys(n),s=new Set(Array.isArray(e.required)?e.required:[]);if([...s].some(a=>!i.includes(a)))throw new f("required contains an unknown property");for(let[a,d]of Object.entries(n))S(d,r),!s.has(a)&&!I(d)&&(n[a]={anyOf:[d,{type:"null"}]});e.required=i,e.additionalProperties=!1}o(S,"makeJsonSchemaNodeStrict");function O(e,r){let t=structuredClone(e);if(!h(t))throw new f("root schema must have type object");if(S(t,r),t.type!=="object")throw new f("root schema must have type object");return t}o(O,"makeStrictJsonSchema");function z(e,r){return r===!0?O(e.parameters):e.parameters}o(z,"getJsonSchemaToolParameters");function K(e,r,t){let n=r[t];if(typeof n!="string")throw new Error(`Grammar tool call "${e}" requires argument "${t}" to be a string.`);return n}o(K,"getGrammarToolInput");function V(e,r,t,n){if(e.closed){if(n&&t===e.input)return;throw new Error(`grammar tool input for property "${r}" changed after it was closed`)}if(!t.startsWith(e.input))throw new Error(`grammar tool input for property "${r}" changed non-monotonically`);let i=t.slice(e.input.length);if(!n&&i.length===0)return;let s="";return e.started||(s+=`{${JSON.stringify(r)}:"`,e.started=!0),s+=JSON.stringify(i).slice(1,-1),e.input=t,n&&(s+='"}',e.closed=!0),s}o(V,"appendGrammarToolInputJsonDelta");function Y(e){let r=e.parameters;if(r.type!=="object")throw new Error("grammar constrained sampling requires an object parameter schema");if(!Array.isArray(r.required)||r.required.length!==1||typeof r.required[0]!="string")throw new Error("grammar constrained sampling requires exactly one required string property");let t=r.required[0];if(!r.properties?.[t])throw new Error(`grammar constrained sampling requires a properties entry for ${t}`);if(r.properties[t]?.type!=="string")throw new Error(`grammar constrained sampling property ${t} must have type string`);return t}o(Y,"inferGrammarInputProperty");function X(e,r,t){let n=e.constrainedSampling;if(!(!n||n.type!=="json_schema")){if(r)try{return O(e.parameters,t),!0}catch(i){if(!(i instanceof f))throw i;if(n.strict!=="require")return;throw new Error(`Tool "${e.name}" requires JSON-schema constrained sampling, but ${i.message}.`)}if(n.strict==="require")throw new Error(`Tool "${e.name}" requires JSON-schema constrained sampling, but strict tools are unsupported.`)}}o(X,"resolveJsonSchemaStrictSampling");function M(e,r){let t=e.constrainedSampling;if(!t||t.type!=="grammar"||!r)return;let n=t.variants.openai_lark,i=t.variants.openai_regex,s=typeof n=="string"&&n.trim().length>0,a=typeof i=="string"&&i.trim().length>0;if(!s&&!a)throw new Error(`Tool "${e.name}" cannot use grammar constrained sampling: no supported grammar variant was provided.`);try{return{format:s?"lark":"regex",definition:s?n:i,inputProperty:Y(e)}}catch(d){let c=d instanceof Error?d.message:String(d);throw new Error(`Tool "${e.name}" cannot use grammar constrained sampling: ${c}.`)}}o(M,"resolveGrammarConstrainedSampling");function Q(e,r){let t=new Map;for(let n of e??[]){let i=M(n,r);i&&t.set(n.name,i.inputProperty)}return t}o(Q,"createGrammarToolInputProperties");var E=3.5,Z=4800;function k(e){return e.totalTokens||e.input+e.output+e.cacheRead+e.cacheWrite}o(k,"calculateContextTokens");function N(e){try{return JSON.stringify(e)??"undefined"}catch{return"[unserializable]"}}o(N,"safeJsonStringify");function ee(e){if(typeof e=="string")return e.length;let r=0;for(let t of e)r+=t.type==="text"?t.text.length:Z;return r}o(ee,"estimateTextAndImageContentChars");function R(e){return Math.ceil(e.length/E)}o(R,"estimateTextTokens");function te(e){return Math.ceil(ee(e)/E)}o(te,"estimateTextAndImageContentTokens");function C(e){let r=0;if(e.role==="system")return R(B(e))+P(e.toolsAdded)+P(e.toolsRemoved);if(e.role==="user"||e.role==="toolResult")return te(e.content);for(let t of e.content)t.type==="text"?r+=t.text.length:t.type==="thinking"?r+=t.thinking.length:r+=t.name.length+N(t.arguments).length;return Math.ceil(r/E)}o(C,"estimateMessageTokens");function re(e){let r=Number.NEGATIVE_INFINITY,t;for(let n=0;n<e.length;n++){let i=e[n];if(i.role==="assistant"){let s=i;s.timestamp>=r&&s.stopReason!=="aborted"&&s.stopReason!=="error"&&k(s.usage)>0&&(t={usage:s.usage,index:n})}r=Math.max(r,i.timestamp)}return t}o(re,"getLastAssistantUsageInfo");function ne(e){let r="messages"in e?e.messages:e,t=re(r);if(t){let i=k(t.usage),s=0;for(let a=t.index+1;a<r.length;a++)s+=C(r[a]);return{tokens:i+s,usageTokens:i,trailingTokens:s,lastUsageIndex:t.index}}let n=0;for(let i of r)n+=C(i);return{tokens:n,usageTokens:0,trailingTokens:n,lastUsageIndex:null}}o(ne,"estimateContextTokens");function P(e){return!e||e.length===0?0:R(N(e))}o(P,"estimateToolsTokens");var ie=4096,_=1;function q(e,r,t){if(e.contextWindow<=0)return Math.max(_,t);let n=e.contextWindow-ne(r).tokens-ie;return Math.min(t,Math.max(_,n))}o(q,"clampMaxTokensToContext");function $(e,r,t){let n=G(e,r),i=e.samplingParamsByThinkingLevel?.[n];return e.samplingParams||i||t?{...e.samplingParams,...i,...t}:void 0}o($,"resolveSamplingParams");function oe(e,r,t,n){let i=$(e,t?.reasoning??"off",t?.samplingParams);return{temperature:t?.temperature,samplingParams:i,maxTokens:q(e,r,t?.maxTokens??e.maxTokens),signal:t?.signal,telemetryContext:t?.telemetryContext,apiKey:n||t?.apiKey,fetch:t?.fetch,transport:t?.transport,cacheRetention:t?.cacheRetention,sessionId:t?.sessionId,headers:t?.headers,onPayload:t?.onPayload,onResponse:t?.onResponse,onProviderStreamEvent:t?.onProviderStreamEvent,timeoutMs:t?.timeoutMs,websocketConnectTimeoutMs:t?.websocketConnectTimeoutMs,maxRetries:t?.maxRetries,maxRetryDelayMs:t?.maxRetryDelayMs,metadata:t?.metadata,env:t?.env}}o(oe,"buildBaseOptions");var ae=1024,se={minimal:1024,low:2048,medium:8192,high:16384};function le(e){return e==="xhigh"||e==="max"?"high":e}o(le,"clampReasoning");function j(e,r){let t={...se,...r},n=le(e);return t[n]}o(j,"thinkingBudgetForLevel");function b(e,r){return Math.min(e,Math.max(0,r-ae))}o(b,"clampThinkingBudgetToAnswerRoom");function ue(e,r,t,n){let i=j(t,n),s=e===void 0?r:Math.min(e+i,r);return s<=i&&(i=b(i,s)),{maxTokens:s,thinkingBudget:i}}o(ue,"adjustMaxTokensForThinking");var pe="(image omitted: model does not support images)",de="(tool image omitted: model does not support images)";function D(e,r){let t=[],n=!1;for(let i of e){if(i.type==="image"){n||t.push({type:"text",text:r}),n=!0;continue}t.push(i),n=i.text===r}return t}o(D,"replaceImagesWithPlaceholder");function fe(e,r){return r.input.includes("image")?e:e.map(t=>t.role==="user"&&Array.isArray(t.content)?{...t,content:D(t.content,pe)}:t.role==="toolResult"?{...t,content:D(t.content,de)}:t)}o(fe,"downgradeUnsupportedImages");function me(e,r,t){let n=new Map,i=e.map(l=>l.content==null?{...l,content:[]}:l),s=fe(i,r).map(l=>{if(l.role==="system"||l.role==="user")return l;if(l.role==="toolResult"){let u=n.get(l.toolCallId);return u&&u!==l.toolCallId?{...l,toolCallId:u}:l}if(l.role==="assistant"){let u=l,m=u.provider===r.provider&&u.api===r.api&&u.model===r.id,w=u.content.flatMap(p=>{if(p.type==="thinking")return p.redacted?m?p:[]:m&&p.thinkingSignature?p:!p.thinking||p.thinking.trim()===""?[]:m?p:{type:"text",text:p.thinking};if(p.type==="text")return m?p:{type:"text",text:p.text};if(p.type==="toolCall"){let g=p,y=g;if(!m&&g.thoughtSignature&&(y={...g},delete y.thoughtSignature),!m&&t){let A=t(g.id,r,u);A!==g.id&&(n.set(g.id,A),y={...y,id:A})}return y}return p});return{...u,content:w}}return l}),a=[],d=[],c=new Set,v=[],x=o(()=>{if(d.length>0){for(let l of d)c.has(l.id)||a.push({role:"toolResult",toolCallId:l.id,toolName:l.name,content:[{type:"text",text:"No result provided"}],isError:!0,timestamp:Date.now()});d=[],c=new Set}a.push(...v),v.length=0},"closePendingToolCalls");for(let l=0;l<s.length;l++){let u=s[l];if(u.role==="assistant"){x();let m=u;if(m.stopReason==="error"||m.stopReason==="aborted")continue;let w=m.content.filter(p=>p.type==="toolCall");w.length>0&&(d=w,c=new Set),a.push(u)}else u.role==="toolResult"?(c.add(u.toolCallId),a.push(u)):u.role==="system"?d.length>0?v.push(u):a.push(u):(u.role==="user"&&x(),a.push(u))}return x(),a}o(me,"transformMessages");export{ue as adjustMaxTokensForThinking,V as appendGrammarToolInputJsonDelta,oe as buildBaseOptions,q as clampMaxTokensToContext,b as clampThinkingBudgetToAnswerRoom,Q as createGrammarToolInputProperties,K as getGrammarToolInput,z as getJsonSchemaToolParameters,W as getPiUserAgent,M as resolveGrammarConstrainedSampling,X as resolveJsonSchemaStrictSampling,$ as resolveSamplingParams,j as thinkingBudgetForLevel,me as transformMessages};
@@ -1,3 +0,0 @@
1
- var z=Object.defineProperty;var a=(e,r)=>z(e,"name",{value:r,configurable:!0});import{createRequire as Y}from"node:module";const $e=Y(import.meta.url);import{mcpNamespace as $,require_proper_lockfile as B,validateMcpServerConfig as _}from"./chunk-ABVPQ2YN.js";import{CONFIG_DIR_NAME as g,SHARED_SKILL_CONFIG_DIRS as D,canonicalizePath as b,getAgentDir as Q,resolvePath as k,stripBom as Z}from"./chunk-HC56T2OZ.js";import{__toESM as V}from"./chunk-4L3WN2XY.js";import{existsSync as P,readFileSync as T}from"node:fs";import{basename as x,join as p}from"node:path";var y=".dalcode",N=60;function R(e,r=Q()){return[{scope:"user",path:p(r,"hooks.json"),kind:"hooks"},{scope:"project",path:p(e,g,"hooks.json"),kind:"hooks"},{scope:"project",path:p(e,y,"hooks.json"),kind:"hooks"},{scope:"project",path:p(e,y,"settings.json"),kind:"settings"}]}a(R,"dalHookSourceFiles");var F=[p(g,"hooks.json"),p(y,"hooks.json"),p(y,"settings.json")];function A(e){if(!P(e))return!1;if(x(e)!=="settings.json")return!0;try{let r=JSON.parse(T(e,"utf8")),t=h(r)?r.hooks:void 0;return h(t)&&Object.keys(t).length>0}catch{return!1}}a(A,"projectFileDeclaresHooks");function h(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(h,"isRecord");var W=new Set(["node","bun","deno","tsx","npx","python","python3","ruby","perl","bash","sh","zsh","pwsh","powershell","exec","env","run"]),X=new Set(["-e","-c","--eval","-p","--print","-Command"]);function M(e){let r=e.trim().split(/\s+/),t;for(let n of r){let s=n.replace(/^["']|["']$/g,"");if(t&&X.has(s))return t;if(!s||s.startsWith("-")||/^[A-Z_][A-Z0-9_]*=/.test(s))continue;if(W.has(s)){t??=s;continue}let i=x(s.replace(/["']/g,""));if(i)return i.length>40?`${i.slice(0,39)}\u2026`:i}let o=e.replace(/\s+/g," ").trim();return o.length>40?`${o.slice(0,39)}\u2026`:o}a(M,"deriveHookName");function ee(e){try{return{value:JSON.parse(T(e,"utf8"))}}catch(r){return{error:r instanceof Error?r.message:String(r)}}}a(ee,"readJson");function te(e,r){if(h(e))return h(e.hooks)?e.hooks:r==="hooks"?e:void 0}a(te,"eventMapOf");function re(e,r,t){let o=te(r,e.kind);if(!o)return e.kind==="hooks"&&t.push({path:e.path,message:"not a JSON object of hook events"}),[];let n=[];for(let[s,i]of Object.entries(o)){if(!Array.isArray(i)){t.push({path:e.path,event:s,message:"event value must be an array of matcher groups"});continue}for(let u of i){if(!h(u)||!Array.isArray(u.hooks)){t.push({path:e.path,event:s,message:"matcher group must have a `hooks` array"});continue}let c=typeof u.matcher=="string"&&u.matcher.trim()!==""&&u.matcher.trim()!=="*"?u.matcher.trim():void 0;for(let l of u.hooks){if(!h(l)){t.push({path:e.path,event:s,message:"hook entry must be an object"});continue}let d=l.type;if(d===void 0){t.push({path:e.path,event:s,message:'hook has no `type` (expected "command")'});continue}if(d!=="command"){t.push({path:e.path,event:s,message:`hook type "${String(d)}" is not supported; only "command" hooks run`});continue}if(typeof l.command!="string"||l.command.trim()===""){t.push({path:e.path,event:s,message:"command hook has no `command`"});continue}let E=typeof l.timeout=="number"&&Number.isFinite(l.timeout)&&l.timeout>0?l.timeout:N;n.push({event:s,matcher:c,command:l.command,timeoutSeconds:E,name:typeof l.name=="string"&&l.name.trim()!==""?l.name.trim():M(l.command),scope:e.scope,sourcePath:e.path})}}}return n}a(re,"parseSource");function oe(e){let r=[],t=[],o=[];for(let n of R(e.cwd,e.agentDir)){let s=P(n.path);if(!s){t.push({scope:n.scope,path:n.path,exists:s,loaded:!1,hookCount:0});continue}if(n.scope==="project"&&!e.projectTrusted){t.push({scope:n.scope,path:n.path,exists:s,loaded:!1,skippedReason:"untrusted",hookCount:0});continue}let{value:i,error:u}=ee(n.path);if(u!==void 0){o.push({path:n.path,message:`invalid JSON: ${u}`}),t.push({scope:n.scope,path:n.path,exists:s,loaded:!1,skippedReason:"invalid",hookCount:0});continue}let c=re(n,i,o);r.push(...c),t.push({scope:n.scope,path:n.path,exists:s,loaded:!0,hookCount:c.length})}return{hooks:r,sources:t,problems:o,projectTrusted:e.projectTrusted}}a(oe,"loadDalHooks");var ne=V(B(),1);import{existsSync as O,mkdirSync as I,readFileSync as se,writeFileSync as ie}from"node:fs";import{homedir as ae}from"node:os";import{dirname as S,join as m}from"node:path";var ue=["settings.json","mcp.json","extensions","mcp.json","lsp.json","skills","prompts","themes","SYSTEM.md","APPEND_SYSTEM.md"];function j(e){return b(k(e))}a(j,"normalizeCwd");function le(e,r){let t=j(r);for(;;){let o=e[t];if(o===!0||o===!1)return{path:t,decision:o};let n=S(t);if(n===t)return null;t=n}}a(le,"findNearestTrustEntry");function ce(e){let r=j(e),t=S(r);return t===r?void 0:t}a(ce,"getProjectTrustParentPath");function de(e,r){let t=j(e),o=[{label:"Trust",trusted:!0,updates:[{path:t,decision:!0}],savedPath:t}],n=ce(e);return n!==void 0&&o.push({label:`Trust parent folder (${n})`,trusted:!0,updates:[{path:n,decision:!0},{path:t,decision:null}],savedPath:n}),r?.includeSessionOnly&&o.push({label:"Trust (this session only)",trusted:!0,updates:[]}),o.push({label:"Do not trust",trusted:!1,updates:[{path:t,decision:!1}],savedPath:t}),r?.includeSessionOnly&&o.push({label:"Do not trust (this session only)",trusted:!1,updates:[]}),o}a(de,"getProjectTrustOptions");function J(e){if(!O(e))return{};let r;try{r=JSON.parse(Z(se(e,"utf-8")))}catch(o){let n=o instanceof Error?o.message:String(o);throw new Error(`Failed to read trust store ${e}: ${n}`)}if(typeof r!="object"||r===null||Array.isArray(r))throw new Error(`Invalid trust store ${e}: expected an object`);let t={};for(let[o,n]of Object.entries(r)){if(n!==!0&&n!==!1&&n!==null)throw new Error(`Invalid trust store ${e}: value for ${JSON.stringify(o)} must be true, false, or null`);t[o]=n}return t}a(J,"readTrustFile");function pe(e,r){let t={};for(let o of Object.keys(r).sort()){let n=r[o];(n===!0||n===!1||n===null)&&(t[o]=n)}I(S(e),{recursive:!0}),ie(e,`${JSON.stringify(t,null,2)}
2
- `,"utf-8")}a(pe,"writeTrustFile");function fe(e){let r=S(e);I(r,{recursive:!0});let t=10,o=20,n;for(let s=1;s<=t;s++)try{return ne.default.lockSync(r,{realpath:!1,lockfilePath:`${e}.lock`})}catch(i){if((typeof i=="object"&&i!==null&&"code"in i?String(i.code):void 0)!=="ELOCKED"||s===t)throw i;n=i;let u=Date.now();for(;Date.now()-u<o;);}throw n instanceof Error?n:new Error("Failed to acquire trust store lock")}a(fe,"acquireTrustLockSync");function L(e,r){let t=fe(e);try{return r()}finally{t()}}a(L,"withTrustFileLock");function he(e){let r=b(k(process.env.HOME||ae())),t=new Set(D.map(s=>m(r,s,"skills"))),o=b(k(e)),n=m(o,g);if(ue.some(s=>O(m(n,s)))||F.some(s=>A(m(o,s))))return!0;for(;;){for(let i of D){let u=m(o,i,"skills");if(!t.has(u)&&O(u))return!0}let s=S(o);if(s===o)return!1;o=s}}a(he,"hasTrustRequiringProjectResources");var me=class{static{a(this,"ProjectTrustStore")}trustPath;constructor(e){this.trustPath=m(k(e),"trust.json")}get(e){return this.getEntry(e)?.decision??null}getEntry(e){return L(this.trustPath,()=>{let r=J(this.trustPath);return le(r,e)})}set(e,r){this.setMany([{path:e,decision:r}])}setMany(e){L(this.trustPath,()=>{let r=J(this.trustPath);for(let{path:t,decision:o}of e){let n=j(t);o===null?delete r[n]:r[n]=o}pe(this.trustPath,r)})}};import{spawn as ve}from"node:child_process";function ye(e){let[r,t]=process.platform==="darwin"?["open",[e]]:process.platform==="win32"?["rundll32",["url.dll,FileProtocolHandler",e]]:["xdg-open",[e]];ve(r,t,{stdio:"ignore",detached:!0}).on("error",()=>{}).unref()}a(ye,"openBrowser");import{existsSync as w,mkdirSync as Se,readFileSync as H,writeFileSync as ge}from"node:fs";import{dirname as ke,join as U}from"node:path";var q=["enabled","exposure","toolExposure"];function G(e){return e.command===void 0&&e.url===void 0&&e.type===void 0}a(G,"isOverride");function f(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(f,"isRecord2");function K(e,r,t){let{servers:o,errors:n}=t;if(!w(e))return;let s;try{s=JSON.parse(H(e,"utf8"))}catch(i){n.push(`${e}: ${i instanceof Error?i.message:String(i)}`);return}if(!f(s)||s.mcpServers!==void 0&&!f(s.mcpServers)){n.push(`${e}: expected an object with an "mcpServers" object`);return}typeof s.autoEnableCodemode=="boolean"?t.autoEnableCodemode=s.autoEnableCodemode:s.autoEnableCodemode!==void 0&&n.push(`${e}: autoEnableCodemode must be a boolean`);for(let[i,u]of Object.entries(s.mcpServers??{})){if(r==="project"&&f(u)&&G(u)){let d=o.get(i),E=Object.keys(u).filter(v=>!q.includes(v));if(!d)n.push(`${e}: server "${i}" needs "command" or "url", or a global server to override`);else if(E.length>0)n.push(`${e}: server "${i}": an override can only set ${q.join(", ")}`);else{let v=_(i,{...d.config,...u});typeof v=="string"?n.push(`${e}: ${v}`):o.set(i,{...d,config:v,override:e})}continue}let c=_(i,u);if(typeof c=="string"){n.push(`${e}: ${c}`);continue}let l=[...o.keys()].find(d=>d!==i&&$(d)===$(i));if(l){n.push(`${e}: server "${i}" conflicts with "${l}"`);continue}if(r==="project"&&"url"in c&&c.auth){n.push(`${e}: server "${i}": auth is only allowed in the global mcp.json`);continue}o.set(i,{name:i,config:c,source:e,scope:r})}}a(K,"readConfigFile");function je(e){let r={servers:new Map,errors:[]};K(U(e.agentDir,"mcp.json"),"global",r);let t=e.projectTrusted?U(e.cwd,g,"mcp.json"):void 0;return t&&K(t,"project",r),{servers:[...r.servers.values()],...r.autoEnableCodemode===void 0?{}:{autoEnableCodemode:r.autoEnableCodemode},errors:r.errors,...t?{projectConfig:t}:{}}}a(je,"loadMcpConfig");function Ee(e,r,t,o={}){C(e,(n,s)=>{let i=n?.[r];if(i===void 0&&o.override&&(i={},s.mcpServers={...n,[r]:i}),!f(i))throw new Error(`${e} does not define MCP server "${r}"`);let u=G(i);return t.enabled!==void 0&&(t.enabled&&!u?delete i.enabled:i.enabled=t.enabled),t.exposure!==void 0&&(t.exposure==="codemode"&&!u?delete i.exposure:i.exposure=t.exposure),!0})}a(Ee,"updateMcpServerConfig");function be(e,r,t){let o=!1;return C(e,(n,s)=>{let i=n??{};return o=i[r]!==void 0,i[r]=t,s.mcpServers=i,!0}),o}a(be,"addMcpServerConfig");function Oe(e,r){if(!w(e))return!1;let t=!1;return C(e,o=>!o||o[r]===void 0?!1:(delete o[r],t=!0,!0)),t}a(Oe,"removeMcpServerConfig");function C(e,r){let t=w(e)?H(e,"utf8"):void 0,o=t===void 0?{}:JSON.parse(t);if(!f(o)||o.mcpServers!==void 0&&!f(o.mcpServers))throw new Error(`${e}: expected an object with an "mcpServers" object`);let n=f(o.mcpServers)?o.mcpServers:void 0;if(!r(n,o))return;let s=t&&/^([ \t]+)\S/m.exec(t)?.[1]||" ";Se(ke(e),{recursive:!0}),ge(e,`${JSON.stringify(o,null,s)}
3
- `)}a(C,"editMcpServers");export{y as DALCODE_PROJECT_DIR_NAME,N as DEFAULT_HOOK_TIMEOUT_SECONDS,me as ProjectTrustStore,F as TRUST_REQUIRING_PROJECT_HOOK_FILES,be as addMcpServerConfig,R as dalHookSourceFiles,M as deriveHookName,de as getProjectTrustOptions,he as hasTrustRequiringProjectResources,oe as loadDalHooks,je as loadMcpConfig,ye as openBrowser,A as projectFileDeclaresHooks,Oe as removeMcpServerConfig,Ee as updateMcpServerConfig};