noskills 4.1.36 → 4.1.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +208 -50
- package/chunks/{anthropic-GKH6HH6J.js → anthropic-UTLWCK66.js} +1 -1
- package/chunks/approve-GSSSUQWC.js +1 -0
- package/chunks/ask-F4XM2EEC.js +2 -0
- package/chunks/block-LVQNJU4P.js +1 -0
- package/chunks/browser-AXSE2CPY.js +1 -0
- package/chunks/bun-LARHC47N.js +1 -0
- package/chunks/chunk-4BH6CF3J.js +1 -0
- package/chunks/chunk-4XOSXARZ.js +9 -0
- package/chunks/chunk-73EEM3FY.js +1 -0
- package/chunks/{chunk-24SANXOZ.js → chunk-7QFOEK3I.js} +1 -1
- package/chunks/chunk-AGWPQX43.js +31 -0
- package/chunks/{chunk-GSYCN7EG.js → chunk-ALZM4JXG.js} +1 -1
- package/chunks/{chunk-3AZBET4N.js → chunk-BBKSV2RO.js} +1 -1
- package/chunks/chunk-DHMCIRLT.js +1 -0
- package/chunks/{chunk-WUVVLUU5.js → chunk-EMHZF6ZY.js} +59 -59
- package/chunks/{chunk-IR75X4G7.js → chunk-ERX4HONR.js} +1 -1
- package/chunks/chunk-G5OCHQQ2.js +1 -0
- package/chunks/chunk-IAR3DEWR.js +1 -0
- package/chunks/{chunk-XCVAHUBM.js → chunk-KJH7Q57A.js} +1 -1
- package/chunks/chunk-MNEZ5QGX.js +1 -0
- package/chunks/chunk-OTRBRRIO.js +1 -0
- package/chunks/chunk-RYQPPQNO.js +3 -0
- package/chunks/{chunk-42EQ3GZJ.js → chunk-TJZAIUKM.js} +1 -1
- package/chunks/{chunk-O5KQZHIN.js → chunk-VK7L5SMS.js} +1 -1
- package/chunks/{chunk-IVSTITPL.js → chunk-VPXOI7CR.js} +1 -1
- package/chunks/chunk-XADY6SXR.js +67 -0
- package/chunks/{chunk-EZH232V7.js → chunk-Y6AFIAJP.js} +1 -1
- package/chunks/chunk-YK6UG66R.js +1 -0
- package/chunks/claude-code-K3SX5D5F.js +1 -0
- package/chunks/cmd-RST2ZPA6.js +1 -0
- package/chunks/concern-FGNG32KU.js +1 -0
- package/chunks/deno-WQJZSBAW.js +1 -0
- package/chunks/dist-UI3SRKS3.js +12 -0
- package/chunks/done-5IX2F6V7.js +1 -0
- package/chunks/{gemini-Z57NY6WY.js → gemini-YR5KT32S.js} +1 -1
- package/chunks/init-M7SJOVPZ.js +1 -0
- package/chunks/invoke-hook-VXIVDDQG.js +10 -0
- package/chunks/{kiro-MHP573OZ.js → kiro-T5X4D4SC.js} +1 -1
- package/chunks/list-3RK7TPGG.js +1 -0
- package/chunks/mod-KTV64DHD.js +1 -0
- package/chunks/multipart-parser-UVM6CEKF.js +2 -0
- package/chunks/next-GGVR6JM2.js +8 -0
- package/chunks/node-3FTYLC7H.js +67 -0
- package/chunks/node-JJN2TSIE.js +1 -0
- package/chunks/ollama-CNKKUTPX.js +3 -0
- package/chunks/{openai-ZNKOR4CD.js → openai-QGEN33SU.js} +2 -2
- package/chunks/openai-Y74OQTVB.js +23 -0
- package/chunks/opencode-MJO3K6T4.js +1 -0
- package/chunks/purge-6DEK2ZSI.js +4 -0
- package/chunks/reset-JEIUVTWV.js +1 -0
- package/chunks/rule-OVSBPSYO.js +2 -0
- package/chunks/run-7MZATQML.js +3 -0
- package/chunks/sdk-LHBUQS75.js +40 -0
- package/chunks/spec-J7KC4VFM.js +1 -0
- package/chunks/src-GLQPTDNR.js +3 -0
- package/chunks/status-BISV6DFB.js +1 -0
- package/chunks/sync-MWQWXN2C.js +1 -0
- package/chunks/{unstable_chmod-WRDBWEC2.js → unstable_chmod-RZ5DE3XZ.js} +1 -1
- package/chunks/{vertexai-WVENJL2F.js → vertexai-RUXZ24C2.js} +1 -1
- package/chunks/watch-AP5GGXG6.js +8 -0
- package/chunks/workerd-VA2BYLUO.js +1 -0
- package/noskills.js +1 -1
- package/package.json +1 -1
- package/chunks/approve-YXRIBZVV.js +0 -1
- package/chunks/ask-4XOYE32R.js +0 -2
- package/chunks/block-D67USBJS.js +0 -1
- package/chunks/browser-JYFQKVFU.js +0 -1
- package/chunks/bun-KVGAHBUF.js +0 -1
- package/chunks/chunk-3HRRWTVF.js +0 -3
- package/chunks/chunk-4ODVKO5Y.js +0 -1
- package/chunks/chunk-ACQUINWH.js +0 -1
- package/chunks/chunk-AK3OJD4W.js +0 -1
- package/chunks/chunk-DXB73IDG.js +0 -1
- package/chunks/chunk-FDZP7B5Y.js +0 -1
- package/chunks/chunk-FKF2SWQM.js +0 -18
- package/chunks/chunk-GOOD5WBA.js +0 -1
- package/chunks/chunk-IA7GIU76.js +0 -14
- package/chunks/chunk-LG5R766Y.js +0 -1
- package/chunks/chunk-NTKVTLTO.js +0 -1
- package/chunks/chunk-T7K64JD5.js +0 -1
- package/chunks/chunk-UA3VIHYO.js +0 -1
- package/chunks/chunk-UXRWSNVZ.js +0 -1
- package/chunks/chunk-WV3HK5WR.js +0 -1
- package/chunks/chunk-ZQ77HAFD.js +0 -12
- package/chunks/claude-code-6AAAJZKK.js +0 -1
- package/chunks/concern-4GBYLKWP.js +0 -1
- package/chunks/deno-5VR3ZY4Z.js +0 -1
- package/chunks/done-PTJRZ26W.js +0 -1
- package/chunks/fileFromPath-4UEDFJ4U.js +0 -6
- package/chunks/init-PVRN54IZ.js +0 -1
- package/chunks/invoke-hook-5VXI4CPD.js +0 -9
- package/chunks/list-GRXQ2DIM.js +0 -1
- package/chunks/mod-V2Z6HGL6.js +0 -1
- package/chunks/next-BZS3EN33.js +0 -3
- package/chunks/node-MZTU6BAB.js +0 -1
- package/chunks/node-RWYXITVV.js +0 -59
- package/chunks/ollama-24ACY3UB.js +0 -3
- package/chunks/openai-EKIA3VP3.js +0 -19
- package/chunks/opencode-LFWHRZPL.js +0 -1
- package/chunks/purge-JSAHNTXI.js +0 -4
- package/chunks/reset-CWI7K6GC.js +0 -1
- package/chunks/rule-GP665FCC.js +0 -2
- package/chunks/run-WLG5XKTM.js +0 -3
- package/chunks/sdk-5JGXLIO5.js +0 -18
- package/chunks/spec-JET4WJSV.js +0 -1
- package/chunks/status-EOXWE5UM.js +0 -1
- package/chunks/sync-RWNLL4VW.js +0 -1
- package/chunks/watch-5OC7T473.js +0 -8
- package/chunks/workerd-QUMEG65S.js +0 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import"./chunk-OTRBRRIO.js";function l(s,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?s!==e||!n:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(s,t):n?n.value=t:e.set(s,t),t}function i(s,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?s!==e||!r:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(s):r?r.value:e.get(s)}var It=function(){let{crypto:s}=globalThis;if(s?.randomUUID)return It=s.randomUUID.bind(s),s.randomUUID();let e=new Uint8Array(1),t=s?()=>s.getRandomValues(e)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,r=>(+r^t()&15>>+r/4).toString(16))};function $(s){return typeof s=="object"&&s!==null&&("name"in s&&s.name==="AbortError"||"message"in s&&String(s.message).includes("FetchRequestCanceledException"))}var Ee=s=>{if(s instanceof Error)return s;if(typeof s=="object"&&s!==null){try{if(Object.prototype.toString.call(s)==="[object Error]"){let e=new Error(s.message,s.cause?{cause:s.cause}:{});return s.stack&&(e.stack=s.stack),s.cause&&!e.cause&&(e.cause=s.cause),s.name&&(e.name=s.name),e}}catch{}try{return new Error(JSON.stringify(s))}catch{}}return new Error(s)};var h=class extends Error{},x=class s extends h{constructor(e,t,r,n){super(`${s.makeMessage(e,t,r)}`),this.status=e,this.headers=n,this.requestID=n?.get("request-id"),this.error=t}static makeMessage(e,t,r){let n=t?.message?typeof t.message=="string"?t.message:JSON.stringify(t.message):t?JSON.stringify(t):r;return e&&n?`${e} ${n}`:e?`${e} status code (no body)`:n||"(no status code or body)"}static generate(e,t,r,n){if(!e||!n)return new W({message:r,cause:Ee(t)});let o=t;return e===400?new ie(e,o,r,n):e===401?new ae(e,o,r,n):e===403?new ce(e,o,r,n):e===404?new le(e,o,r,n):e===409?new ue(e,o,r,n):e===422?new he(e,o,r,n):e===429?new fe(e,o,r,n):e>=500?new de(e,o,r,n):new s(e,o,r,n)}},k=class extends x{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}},W=class extends x{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}},oe=class extends W{constructor({message:e}={}){super({message:e??"Request timed out."})}},ie=class extends x{},ae=class extends x{},ce=class extends x{},le=class extends x{},ue=class extends x{},he=class extends x{},fe=class extends x{},de=class extends x{};var Zr=/^[a-z][a-z0-9+.-]*:/i,lr=s=>Zr.test(s),Ot=s=>(Ot=Array.isArray,Ot(s)),Bt=Ot;function Ze(s){return typeof s!="object"?{}:s??{}}function Nt(s){if(!s)return!0;for(let e in s)return!1;return!0}function ur(s,e){return Object.prototype.hasOwnProperty.call(s,e)}var hr=(s,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new h(`${s} must be an integer`);if(e<0)throw new h(`${s} must be a positive integer`);return e};var et=s=>{try{return JSON.parse(s)}catch{return}};var fr=s=>new Promise(e=>setTimeout(e,s));var D="0.80.0";var gr=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function es(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}var ts=()=>{let s=es();if(s==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":D,"X-Stainless-OS":pr(Deno.build.os),"X-Stainless-Arch":dr(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":D,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(s==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":D,"X-Stainless-OS":pr(globalThis.process.platform??"unknown"),"X-Stainless-Arch":dr(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let e=rs();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":D,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":D,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function rs(){if(typeof navigator>"u"||!navigator)return null;let s=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:e,pattern:t}of s){let r=t.exec(navigator.userAgent);if(r){let n=r[1]||0,o=r[2]||0,a=r[3]||0;return{browser:e,version:`${n}.${o}.${a}`}}}return null}var dr=s=>s==="x32"?"x32":s==="x86_64"||s==="x64"?"x64":s==="arm"?"arm":s==="aarch64"||s==="arm64"?"arm64":s?`other:${s}`:"unknown",pr=s=>(s=s.toLowerCase(),s.includes("ios")?"iOS":s==="android"?"Android":s==="darwin"?"MacOS":s==="win32"?"Windows":s==="freebsd"?"FreeBSD":s==="openbsd"?"OpenBSD":s==="linux"?"Linux":s?`Other:${s}`:"Unknown"),mr,_r=()=>mr??(mr=ts());function yr(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function Ft(...s){let e=globalThis.ReadableStream;if(typeof e>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new e(...s)}function tt(s){let e=Symbol.asyncIterator in s?s[Symbol.asyncIterator]():s[Symbol.iterator]();return Ft({start(){},async pull(t){let{done:r,value:n}=await e.next();r?t.close():t.enqueue(n)},async cancel(){await e.return?.()}})}function Ae(s){if(s[Symbol.asyncIterator])return s;let e=s.getReader();return{async next(){try{let t=await e.read();return t?.done&&e.releaseLock(),t}catch(t){throw e.releaseLock(),t}},async return(){let t=e.cancel();return e.releaseLock(),await t,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function br(s){if(s===null||typeof s!="object")return;if(s[Symbol.asyncIterator]){await s[Symbol.asyncIterator]().return?.();return}let e=s.getReader(),t=e.cancel();e.releaseLock(),await t}var wr=({headers:s,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)});function xr(s){return Object.entries(s).filter(([e,t])=>typeof t<"u").map(([e,t])=>{if(typeof t=="string"||typeof t=="number"||typeof t=="boolean")return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(t===null)return`${encodeURIComponent(e)}=`;throw new h(`Cannot stringify type ${typeof t}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}function Pr(s){let e=0;for(let n of s)e+=n.length;let t=new Uint8Array(e),r=0;for(let n of s)t.set(n,r),r+=n.length;return t}var Sr;function Te(s){let e;return(Sr??(e=new globalThis.TextEncoder,Sr=e.encode.bind(e)))(s)}var kr;function vt(s){let e;return(kr??(e=new globalThis.TextDecoder,kr=e.decode.bind(e)))(s)}var M,R,L=class{constructor(){M.set(this,void 0),R.set(this,void 0),l(this,M,new Uint8Array,"f"),l(this,R,null,"f")}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?Te(e):e;l(this,M,Pr([i(this,M,"f"),t]),"f");let r=[],n;for(;(n=os(i(this,M,"f"),i(this,R,"f")))!=null;){if(n.carriage&&i(this,R,"f")==null){l(this,R,n.index,"f");continue}if(i(this,R,"f")!=null&&(n.index!==i(this,R,"f")+1||n.carriage)){r.push(vt(i(this,M,"f").subarray(0,i(this,R,"f")-1))),l(this,M,i(this,M,"f").subarray(i(this,R,"f")),"f"),l(this,R,null,"f");continue}let o=i(this,R,"f")!==null?n.preceding-1:n.preceding,a=vt(i(this,M,"f").subarray(0,o));r.push(a),l(this,M,i(this,M,"f").subarray(n.index),"f"),l(this,R,null,"f")}return r}flush(){return i(this,M,"f").length?this.decode(`
|
|
2
|
+
`):[]}};M=new WeakMap,R=new WeakMap;L.NEWLINE_CHARS=new Set([`
|
|
3
|
+
`,"\r"]);L.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function os(s,e){for(let n=e??0;n<s.length;n++){if(s[n]===10)return{preceding:n,index:n+1,carriage:!1};if(s[n]===13)return{preceding:n,index:n+1,carriage:!0}}return null}function Mr(s){for(let r=0;r<s.length-1;r++){if(s[r]===10&&s[r+1]===10||s[r]===13&&s[r+1]===13)return r+2;if(s[r]===13&&s[r+1]===10&&r+3<s.length&&s[r+2]===13&&s[r+3]===10)return r+4}return-1}var st={off:0,error:200,warn:300,info:400,debug:500},$t=(s,e,t)=>{if(s){if(ur(st,s))return s;S(t).warn(`${e} was set to ${JSON.stringify(s)}, expected one of ${JSON.stringify(Object.keys(st))}`)}};function Ie(){}function rt(s,e,t){return!e||st[s]>st[t]?Ie:e[s].bind(e)}var is={error:Ie,warn:Ie,info:Ie,debug:Ie},Rr=new WeakMap;function S(s){let e=s.logger,t=s.logLevel??"off";if(!e)return is;let r=Rr.get(e);if(r&&r[0]===t)return r[1];let n={error:rt("error",e,t),warn:rt("warn",e,t),info:rt("info",e,t),debug:rt("debug",e,t)};return Rr.set(e,[t,n]),n}var j=s=>(s.options&&(s.options={...s.options},delete s.options.headers),s.headers&&(s.headers=Object.fromEntries((s.headers instanceof Headers?[...s.headers]:Object.entries(s.headers)).map(([e,t])=>[e,e.toLowerCase()==="x-api-key"||e.toLowerCase()==="authorization"||e.toLowerCase()==="cookie"||e.toLowerCase()==="set-cookie"?"***":t]))),"retryOfRequestLogID"in s&&(s.retryOfRequestLogID&&(s.retryOf=s.retryOfRequestLogID),delete s.retryOfRequestLogID),s);var Oe,F=class s{constructor(e,t,r){this.iterator=e,Oe.set(this,void 0),this.controller=t,l(this,Oe,r,"f")}static fromSSEResponse(e,t,r){let n=!1,o=r?S(r):console;async function*a(){if(n)throw new h("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");n=!0;let c=!1;try{for await(let u of as(e,t)){if(u.event==="completion")try{yield JSON.parse(u.data)}catch(d){throw o.error("Could not parse message into JSON:",u.data),o.error("From chunk:",u.raw),d}if(u.event==="message_start"||u.event==="message_delta"||u.event==="message_stop"||u.event==="content_block_start"||u.event==="content_block_delta"||u.event==="content_block_stop")try{yield JSON.parse(u.data)}catch(d){throw o.error("Could not parse message into JSON:",u.data),o.error("From chunk:",u.raw),d}if(u.event!=="ping"&&u.event==="error")throw new x(void 0,et(u.data)??u.data,void 0,e.headers)}c=!0}catch(u){if($(u))return;throw u}finally{c||t.abort()}}return new s(a,t,r)}static fromReadableStream(e,t,r){let n=!1;async function*o(){let c=new L,u=Ae(e);for await(let d of u)for(let b of c.decode(d))yield b;for(let d of c.flush())yield d}async function*a(){if(n)throw new h("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");n=!0;let c=!1;try{for await(let u of o())c||u&&(yield JSON.parse(u));c=!0}catch(u){if($(u))return;throw u}finally{c||t.abort()}}return new s(a,t,r)}[(Oe=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let e=[],t=[],r=this.iterator(),n=o=>({next:()=>{if(o.length===0){let a=r.next();e.push(a),t.push(a)}return o.shift()}});return[new s(()=>n(e),this.controller,i(this,Oe,"f")),new s(()=>n(t),this.controller,i(this,Oe,"f"))]}toReadableStream(){let e=this,t;return Ft({async start(){t=e[Symbol.asyncIterator]()},async pull(r){try{let{value:n,done:o}=await t.next();if(o)return r.close();let a=Te(JSON.stringify(n)+`
|
|
4
|
+
`);r.enqueue(a)}catch(n){r.error(n)}},async cancel(){await t.return?.()}})}};async function*as(s,e){if(!s.body)throw e.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new h("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new h("Attempted to iterate over a response with no body");let t=new Lt,r=new L,n=Ae(s.body);for await(let o of cs(n))for(let a of r.decode(o)){let c=t.decode(a);c&&(yield c)}for(let o of r.flush()){let a=t.decode(o);a&&(yield a)}}async function*cs(s){let e=new Uint8Array;for await(let t of s){if(t==null)continue;let r=t instanceof ArrayBuffer?new Uint8Array(t):typeof t=="string"?Te(t):t,n=new Uint8Array(e.length+r.length);n.set(e),n.set(r,e.length),e=n;let o;for(;(o=Mr(e))!==-1;)yield e.slice(0,o),e=e.slice(o)}e.length>0&&(yield e)}var Lt=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let o={event:this.event,data:this.data.join(`
|
|
5
|
+
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],o}if(this.chunks.push(e),e.startsWith(":"))return null;let[t,r,n]=ls(e,":");return n.startsWith(" ")&&(n=n.substring(1)),t==="event"?this.event=n:t==="data"&&this.data.push(n),null}};function ls(s,e){let t=s.indexOf(e);return t!==-1?[s.substring(0,t),e,s.substring(t+e.length)]:[s,"",""]}async function nt(s,e){let{response:t,requestLogID:r,retryOfRequestLogID:n,startTime:o}=e,a=await(async()=>{if(e.options.stream)return S(s).debug("response",t.status,t.url,t.headers,t.body),e.options.__streamClass?e.options.__streamClass.fromSSEResponse(t,e.controller):F.fromSSEResponse(t,e.controller);if(t.status===204)return null;if(e.options.__binaryResponse)return t;let u=t.headers.get("content-type")?.split(";")[0]?.trim();if(u?.includes("application/json")||u?.endsWith("+json")){if(t.headers.get("content-length")==="0")return;let P=await t.json();return jt(P,t)}return await t.text()})();return S(s).debug(`[${r}] response parsed`,j({retryOfRequestLogID:n,url:t.url,status:t.status,body:a,durationMs:Date.now()-o})),a}function jt(s,e){return!s||typeof s!="object"||Array.isArray(s)?s:Object.defineProperty(s,"_request_id",{value:e.headers.get("request-id"),enumerable:!1})}var Be,z=class s extends Promise{constructor(e,t,r=nt){super(n=>{n(null)}),this.responsePromise=t,this.parseResponse=r,Be.set(this,void 0),l(this,Be,e,"f")}_thenUnwrap(e){return new s(i(this,Be,"f"),this.responsePromise,async(t,r)=>jt(e(await this.parseResponse(t,r),r),r.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t,request_id:t.headers.get("request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(i(this,Be,"f"),e))),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}};Be=new WeakMap;var ot,it=class{constructor(e,t,r,n){ot.set(this,void 0),l(this,ot,e,"f"),this.options=n,this.response=t,this.body=r}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){let e=this.nextPageRequestOptions();if(!e)throw new h("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await i(this,ot,"f").requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(ot=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t}},Ne=class extends z{constructor(e,t,r){super(e,t,async(n,o)=>new r(n,o.response,await nt(n,o),o.options))}async*[Symbol.asyncIterator](){let e=await this;for await(let t of e)yield t}},A=class extends it{constructor(e,t,r,n){super(e,t,r,n),this.data=r.data||[],this.has_more=r.has_more||!1,this.first_id=r.first_id||null,this.last_id=r.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){if(this.options.query?.before_id){let t=this.first_id;return t?{...this.options,query:{...Ze(this.options.query),before_id:t}}:null}let e=this.last_id;return e?{...this.options,query:{...Ze(this.options.query),after_id:e}}:null}};var pe=class extends it{constructor(e,t,r,n){super(e,t,r,n),this.data=r.data||[],this.has_more=r.has_more||!1,this.next_page=r.next_page||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){let e=this.next_page;return e?{...this.options,query:{...Ze(this.options.query),page:e}}:null}};var Ut=()=>{if(typeof File>"u"){let{process:s}=globalThis,e=typeof s?.versions?.node=="string"&&parseInt(s.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(e?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function Q(s,e,t){return Ut(),new File(s,e??"unknown_file",t)}function Fe(s,e){let t=typeof s=="object"&&s!==null&&("name"in s&&s.name&&String(s.name)||"url"in s&&s.url&&String(s.url)||"filename"in s&&s.filename&&String(s.filename)||"path"in s&&s.path&&String(s.path))||"";return e?t.split(/[\\/]/).pop()||void 0:t}var Ct=s=>s!=null&&typeof s=="object"&&typeof s[Symbol.asyncIterator]=="function";var me=async(s,e,t=!0)=>({...s,body:await fs(s.body,e,t)}),Er=new WeakMap;function hs(s){let e=typeof s=="function"?s:s.fetch,t=Er.get(e);if(t)return t;let r=(async()=>{try{let n="Response"in e?e.Response:(await e("data:,")).constructor,o=new FormData;return o.toString()!==await new n(o).text()}catch{return!0}})();return Er.set(e,r),r}var fs=async(s,e,t=!0)=>{if(!await hs(e))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");let r=new FormData;return await Promise.all(Object.entries(s||{}).map(([n,o])=>qt(r,n,o,t))),r},ds=s=>s instanceof Blob&&"name"in s;var qt=async(s,e,t,r)=>{if(t!==void 0){if(t==null)throw new TypeError(`Received null for "${e}"; to pass null in FormData, you must use the string 'null'`);if(typeof t=="string"||typeof t=="number"||typeof t=="boolean")s.append(e,String(t));else if(t instanceof Response){let n={},o=t.headers.get("Content-Type");o&&(n={type:o}),s.append(e,Q([await t.blob()],Fe(t,r),n))}else if(Ct(t))s.append(e,Q([await new Response(tt(t)).blob()],Fe(t,r)));else if(ds(t))s.append(e,Q([t],Fe(t,r),{type:t.type}));else if(Array.isArray(t))await Promise.all(t.map(n=>qt(s,e+"[]",n,r)));else if(typeof t=="object")await Promise.all(Object.entries(t).map(([n,o])=>qt(s,`${e}[${n}]`,o,r)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${t} instead`)}};var Ar=s=>s!=null&&typeof s=="object"&&typeof s.size=="number"&&typeof s.type=="string"&&typeof s.text=="function"&&typeof s.slice=="function"&&typeof s.arrayBuffer=="function",ps=s=>s!=null&&typeof s=="object"&&typeof s.name=="string"&&typeof s.lastModified=="number"&&Ar(s),ms=s=>s!=null&&typeof s=="object"&&typeof s.url=="string"&&typeof s.blob=="function";async function at(s,e,t){if(Ut(),s=await s,e||(e=Fe(s,!0)),ps(s))return s instanceof File&&e==null&&t==null?s:Q([await s.arrayBuffer()],e??s.name,{type:s.type,lastModified:s.lastModified,...t});if(ms(s)){let n=await s.blob();return e||(e=new URL(s.url).pathname.split(/[\\/]/).pop()),Q(await Ht(n),e,t)}let r=await Ht(s);if(!t?.type){let n=r.find(o=>typeof o=="object"&&"type"in o&&o.type);typeof n=="string"&&(t={...t,type:n})}return Q(r,e,t)}async function Ht(s){let e=[];if(typeof s=="string"||ArrayBuffer.isView(s)||s instanceof ArrayBuffer)e.push(s);else if(Ar(s))e.push(s instanceof Blob?s:await s.arrayBuffer());else if(Ct(s))for await(let t of s)e.push(...await Ht(t));else{let t=s?.constructor?.name;throw new Error(`Unexpected data type: ${typeof s}${t?`; constructor: ${t}`:""}${gs(s)}`)}return e}function gs(s){return typeof s!="object"||s===null?"":`; props: [${Object.getOwnPropertyNames(s).map(t=>`"${t}"`).join(", ")}]`}var m=class{constructor(e){this._client=e}};var Tr=Symbol.for("brand.privateNullableHeaders");function*ys(s){if(!s)return;if(Tr in s){let{values:r,nulls:n}=s;yield*r.entries();for(let o of n)yield[o,null];return}let e=!1,t;s instanceof Headers?t=s.entries():Bt(s)?t=s:(e=!0,t=Object.entries(s??{}));for(let r of t){let n=r[0];if(typeof n!="string")throw new TypeError("expected header name to be a string");let o=Bt(r[1])?r[1]:[r[1]],a=!1;for(let c of o)c!==void 0&&(e&&!a&&(a=!0,yield[n,null]),yield[n,c])}}var f=s=>{let e=new Headers,t=new Set;for(let r of s){let n=new Set;for(let[o,a]of ys(r)){let c=o.toLowerCase();n.has(c)||(e.delete(o),n.add(c)),a===null?(e.delete(o),t.add(c)):(e.append(o,a),t.delete(c))}}return{[Tr]:!0,values:e,nulls:t}};var ve=Symbol("anthropic.sdk.stainlessHelper");function ct(s){return typeof s=="object"&&s!==null&&ve in s}function Wt(s,e){let t=new Set;if(s)for(let r of s)ct(r)&&t.add(r[ve]);if(e){for(let r of e)if(ct(r)&&t.add(r[ve]),Array.isArray(r.content))for(let n of r.content)ct(n)&&t.add(n[ve])}return Array.from(t)}function lt(s,e){let t=Wt(s,e);return t.length===0?{}:{"x-stainless-helper":t.join(", ")}}function Ir(s){return ct(s)?{"x-stainless-helper":s[ve]}:{}}function Br(s){return s.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var Or=Object.freeze(Object.create(null)),bs=(s=Br)=>function(t,...r){if(t.length===1)return t[0];let n=!1,o=[],a=t.reduce((b,_,P)=>{/[?#]/.test(_)&&(n=!0);let p=r[P],O=(n?encodeURIComponent:s)(""+p);return P!==r.length&&(p==null||typeof p=="object"&&p.toString===Object.getPrototypeOf(Object.getPrototypeOf(p.hasOwnProperty??Or)??Or)?.toString)&&(O=p+"",o.push({start:b.length+_.length,length:O.length,error:`Value of type ${Object.prototype.toString.call(p).slice(8,-1)} is not a valid path parameter`})),b+_+(P===r.length?"":O)},""),c=a.split(/[?#]/,1)[0],u=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,d;for(;(d=u.exec(c))!==null;)o.push({start:d.index,length:d[0].length,error:`Value "${d[0]}" can't be safely passed as a path parameter`});if(o.sort((b,_)=>b.start-_.start),o.length>0){let b=0,_=o.reduce((P,p)=>{let O=" ".repeat(p.start-b),At="^".repeat(p.length);return b=p.start+p.length,P+O+At},"");throw new h(`Path parameters result in path with invalid segments:
|
|
6
|
+
${o.map(P=>P.error).join(`
|
|
7
|
+
`)}
|
|
8
|
+
${a}
|
|
9
|
+
${_}`)}return a},g=bs(Br);var ge=class extends m{list(e={},t){let{betas:r,...n}=e??{};return this._client.getAPIList("/v1/files",A,{query:n,...t,headers:f([{"anthropic-beta":[...r??[],"files-api-2025-04-14"].toString()},t?.headers])})}delete(e,t={},r){let{betas:n}=t??{};return this._client.delete(g`/v1/files/${e}`,{...r,headers:f([{"anthropic-beta":[...n??[],"files-api-2025-04-14"].toString()},r?.headers])})}download(e,t={},r){let{betas:n}=t??{};return this._client.get(g`/v1/files/${e}/content`,{...r,headers:f([{"anthropic-beta":[...n??[],"files-api-2025-04-14"].toString(),Accept:"application/binary"},r?.headers]),__binaryResponse:!0})}retrieveMetadata(e,t={},r){let{betas:n}=t??{};return this._client.get(g`/v1/files/${e}`,{...r,headers:f([{"anthropic-beta":[...n??[],"files-api-2025-04-14"].toString()},r?.headers])})}upload(e,t){let{betas:r,...n}=e;return this._client.post("/v1/files",me({body:n,...t,headers:f([{"anthropic-beta":[...r??[],"files-api-2025-04-14"].toString()},Ir(n.file),t?.headers])},this._client))}};var _e=class extends m{retrieve(e,t={},r){let{betas:n}=t??{};return this._client.get(g`/v1/models/${e}?beta=true`,{...r,headers:f([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},r?.headers])})}list(e={},t){let{betas:r,...n}=e??{};return this._client.getAPIList("/v1/models?beta=true",A,{query:n,...t,headers:f([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},t?.headers])})}};var ut={"claude-opus-4-20250514":8192,"claude-opus-4-0":8192,"claude-4-opus-20250514":8192,"anthropic.claude-opus-4-20250514-v1:0":8192,"claude-opus-4@20250514":8192,"claude-opus-4-1-20250805":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192};function Nr(s){return s?.output_format??s?.output_config?.format}function Dt(s,e,t){let r=Nr(e);return!e||!("parse"in(r??{}))?{...s,content:s.content.map(n=>{if(n.type==="text"){let o=Object.defineProperty({...n},"parsed_output",{value:null,enumerable:!1});return Object.defineProperty(o,"parsed",{get(){return t.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),null},enumerable:!1})}return n}),parsed_output:null}:Jt(s,e,t)}function Jt(s,e,t){let r=null,n=s.content.map(o=>{if(o.type==="text"){let a=Ss(e,o.text);r===null&&(r=a);let c=Object.defineProperty({...o},"parsed_output",{value:a,enumerable:!1});return Object.defineProperty(c,"parsed",{get(){return t.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),a},enumerable:!1})}return o});return{...s,content:n,parsed_output:r}}function Ss(s,e){let t=Nr(s);if(t?.type!=="json_schema")return null;try{return"parse"in t?t.parse(e):JSON.parse(e)}catch(r){throw new h(`Failed to parse structured output: ${r}`)}}var ks=s=>{let e=0,t=[];for(;e<s.length;){let r=s[e];if(r==="\\"){e++;continue}if(r==="{"){t.push({type:"brace",value:"{"}),e++;continue}if(r==="}"){t.push({type:"brace",value:"}"}),e++;continue}if(r==="["){t.push({type:"paren",value:"["}),e++;continue}if(r==="]"){t.push({type:"paren",value:"]"}),e++;continue}if(r===":"){t.push({type:"separator",value:":"}),e++;continue}if(r===","){t.push({type:"delimiter",value:","}),e++;continue}if(r==='"'){let c="",u=!1;for(r=s[++e];r!=='"';){if(e===s.length){u=!0;break}if(r==="\\"){if(e++,e===s.length){u=!0;break}c+=r+s[e],r=s[++e]}else c+=r,r=s[++e]}r=s[++e],u||t.push({type:"string",value:c});continue}if(r&&/\s/.test(r)){e++;continue}let o=/[0-9]/;if(r&&o.test(r)||r==="-"||r==="."){let c="";for(r==="-"&&(c+=r,r=s[++e]);r&&o.test(r)||r===".";)c+=r,r=s[++e];t.push({type:"number",value:c});continue}let a=/[a-z]/i;if(r&&a.test(r)){let c="";for(;r&&a.test(r)&&e!==s.length;)c+=r,r=s[++e];if(c=="true"||c=="false"||c==="null")t.push({type:"name",value:c});else{e++;continue}continue}e++}return t},ye=s=>{if(s.length===0)return s;let e=s[s.length-1];switch(e.type){case"separator":return s=s.slice(0,s.length-1),ye(s);break;case"number":let t=e.value[e.value.length-1];if(t==="."||t==="-")return s=s.slice(0,s.length-1),ye(s);case"string":let r=s[s.length-2];if(r?.type==="delimiter")return s=s.slice(0,s.length-1),ye(s);if(r?.type==="brace"&&r.value==="{")return s=s.slice(0,s.length-1),ye(s);break;case"delimiter":return s=s.slice(0,s.length-1),ye(s);break}return s},Ps=s=>{let e=[];return s.map(t=>{t.type==="brace"&&(t.value==="{"?e.push("}"):e.splice(e.lastIndexOf("}"),1)),t.type==="paren"&&(t.value==="["?e.push("]"):e.splice(e.lastIndexOf("]"),1))}),e.length>0&&e.reverse().map(t=>{t==="}"?s.push({type:"brace",value:"}"}):t==="]"&&s.push({type:"paren",value:"]"})}),s},Ms=s=>{let e="";return s.map(t=>{switch(t.type){case"string":e+='"'+t.value+'"';break;default:e+=t.value;break}}),e},ht=s=>JSON.parse(Ms(Ps(ye(ks(s)))));var T,J,be,$e,ft,Le,je,dt,qe,q,Ue,pt,mt,Y,gt,_t,Ce,Xt,Fr,yt,Kt,Vt,Gt,vr,$r="__json_buf";function Lr(s){return s.type==="tool_use"||s.type==="server_tool_use"||s.type==="mcp_tool_use"}var bt=class s{constructor(e,t){T.add(this),this.messages=[],this.receivedMessages=[],J.set(this,void 0),be.set(this,null),this.controller=new AbortController,$e.set(this,void 0),ft.set(this,()=>{}),Le.set(this,()=>{}),je.set(this,void 0),dt.set(this,()=>{}),qe.set(this,()=>{}),q.set(this,{}),Ue.set(this,!1),pt.set(this,!1),mt.set(this,!1),Y.set(this,!1),gt.set(this,void 0),_t.set(this,void 0),Ce.set(this,void 0),yt.set(this,r=>{if(l(this,pt,!0,"f"),$(r)&&(r=new k),r instanceof k)return l(this,mt,!0,"f"),this._emit("abort",r);if(r instanceof h)return this._emit("error",r);if(r instanceof Error){let n=new h(r.message);return n.cause=r,this._emit("error",n)}return this._emit("error",new h(String(r)))}),l(this,$e,new Promise((r,n)=>{l(this,ft,r,"f"),l(this,Le,n,"f")}),"f"),l(this,je,new Promise((r,n)=>{l(this,dt,r,"f"),l(this,qe,n,"f")}),"f"),i(this,$e,"f").catch(()=>{}),i(this,je,"f").catch(()=>{}),l(this,be,e,"f"),l(this,Ce,t?.logger??console,"f")}get response(){return i(this,gt,"f")}get request_id(){return i(this,_t,"f")}async withResponse(){l(this,Y,!0,"f");let e=await i(this,$e,"f");if(!e)throw new Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get("request-id")}}static fromReadableStream(e){let t=new s(null);return t._run(()=>t._fromReadableStream(e)),t}static createMessage(e,t,r,{logger:n}={}){let o=new s(t,{logger:n});for(let a of t.messages)o._addMessageParam(a);return l(o,be,{...t,stream:!0},"f"),o._run(()=>o._createMessage(e,{...t,stream:!0},{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),o}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},i(this,yt,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit("message",e)}async _createMessage(e,t,r){let n=r?.signal,o;n&&(n.aborted&&this.controller.abort(),o=this.controller.abort.bind(this.controller),n.addEventListener("abort",o));try{i(this,T,"m",Kt).call(this);let{response:a,data:c}=await e.create({...t,stream:!0},{...r,signal:this.controller.signal}).withResponse();this._connected(a);for await(let u of c)i(this,T,"m",Vt).call(this,u);if(c.controller.signal?.aborted)throw new k;i(this,T,"m",Gt).call(this)}finally{n&&o&&n.removeEventListener("abort",o)}}_connected(e){this.ended||(l(this,gt,e,"f"),l(this,_t,e?.headers.get("request-id"),"f"),i(this,ft,"f").call(this,e),this._emit("connect"))}get ended(){return i(this,Ue,"f")}get errored(){return i(this,pt,"f")}get aborted(){return i(this,mt,"f")}abort(){this.controller.abort()}on(e,t){return(i(this,q,"f")[e]||(i(this,q,"f")[e]=[])).push({listener:t}),this}off(e,t){let r=i(this,q,"f")[e];if(!r)return this;let n=r.findIndex(o=>o.listener===t);return n>=0&&r.splice(n,1),this}once(e,t){return(i(this,q,"f")[e]||(i(this,q,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,r)=>{l(this,Y,!0,"f"),e!=="error"&&this.once("error",r),this.once(e,t)})}async done(){l(this,Y,!0,"f"),await i(this,je,"f")}get currentMessage(){return i(this,J,"f")}async finalMessage(){return await this.done(),i(this,T,"m",Xt).call(this)}async finalText(){return await this.done(),i(this,T,"m",Fr).call(this)}_emit(e,...t){if(i(this,Ue,"f"))return;e==="end"&&(l(this,Ue,!0,"f"),i(this,dt,"f").call(this));let r=i(this,q,"f")[e];if(r&&(i(this,q,"f")[e]=r.filter(n=>!n.once),r.forEach(({listener:n})=>n(...t))),e==="abort"){let n=t[0];!i(this,Y,"f")&&!r?.length&&Promise.reject(n),i(this,Le,"f").call(this,n),i(this,qe,"f").call(this,n),this._emit("end");return}if(e==="error"){let n=t[0];!i(this,Y,"f")&&!r?.length&&Promise.reject(n),i(this,Le,"f").call(this,n),i(this,qe,"f").call(this,n),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",i(this,T,"m",Xt).call(this))}async _fromReadableStream(e,t){let r=t?.signal,n;r&&(r.aborted&&this.controller.abort(),n=this.controller.abort.bind(this.controller),r.addEventListener("abort",n));try{i(this,T,"m",Kt).call(this),this._connected(null);let o=F.fromReadableStream(e,this.controller);for await(let a of o)i(this,T,"m",Vt).call(this,a);if(o.controller.signal?.aborted)throw new k;i(this,T,"m",Gt).call(this)}finally{r&&n&&r.removeEventListener("abort",n)}}[(J=new WeakMap,be=new WeakMap,$e=new WeakMap,ft=new WeakMap,Le=new WeakMap,je=new WeakMap,dt=new WeakMap,qe=new WeakMap,q=new WeakMap,Ue=new WeakMap,pt=new WeakMap,mt=new WeakMap,Y=new WeakMap,gt=new WeakMap,_t=new WeakMap,Ce=new WeakMap,yt=new WeakMap,T=new WeakSet,Xt=function(){if(this.receivedMessages.length===0)throw new h("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},Fr=function(){if(this.receivedMessages.length===0)throw new h("stream ended without producing a Message with role=assistant");let t=this.receivedMessages.at(-1).content.filter(r=>r.type==="text").map(r=>r.text);if(t.length===0)throw new h("stream ended without producing a content block with type=text");return t.join(" ")},Kt=function(){this.ended||l(this,J,void 0,"f")},Vt=function(t){if(this.ended)return;let r=i(this,T,"m",vr).call(this,t);switch(this._emit("streamEvent",t,r),t.type){case"content_block_delta":{let n=r.content.at(-1);switch(t.delta.type){case"text_delta":{n.type==="text"&&this._emit("text",t.delta.text,n.text||"");break}case"citations_delta":{n.type==="text"&&this._emit("citation",t.delta.citation,n.citations??[]);break}case"input_json_delta":{Lr(n)&&n.input&&this._emit("inputJson",t.delta.partial_json,n.input);break}case"thinking_delta":{n.type==="thinking"&&this._emit("thinking",t.delta.thinking,n.thinking);break}case"signature_delta":{n.type==="thinking"&&this._emit("signature",n.signature);break}case"compaction_delta":{n.type==="compaction"&&n.content&&this._emit("compaction",n.content);break}default:t.delta}break}case"message_stop":{this._addMessageParam(r),this._addMessage(Dt(r,i(this,be,"f"),{logger:i(this,Ce,"f")}),!0);break}case"content_block_stop":{this._emit("contentBlock",r.content.at(-1));break}case"message_start":{l(this,J,r,"f");break}case"content_block_start":case"message_delta":break}},Gt=function(){if(this.ended)throw new h("stream has ended, this shouldn't happen");let t=i(this,J,"f");if(!t)throw new h("request ended without sending any chunks");return l(this,J,void 0,"f"),Dt(t,i(this,be,"f"),{logger:i(this,Ce,"f")})},vr=function(t){let r=i(this,J,"f");if(t.type==="message_start"){if(r)throw new h(`Unexpected event order, got ${t.type} before receiving "message_stop"`);return t.message}if(!r)throw new h(`Unexpected event order, got ${t.type} before "message_start"`);switch(t.type){case"message_stop":return r;case"message_delta":return r.container=t.delta.container,r.stop_reason=t.delta.stop_reason,r.stop_sequence=t.delta.stop_sequence,r.usage.output_tokens=t.usage.output_tokens,r.context_management=t.context_management,t.usage.input_tokens!=null&&(r.usage.input_tokens=t.usage.input_tokens),t.usage.cache_creation_input_tokens!=null&&(r.usage.cache_creation_input_tokens=t.usage.cache_creation_input_tokens),t.usage.cache_read_input_tokens!=null&&(r.usage.cache_read_input_tokens=t.usage.cache_read_input_tokens),t.usage.server_tool_use!=null&&(r.usage.server_tool_use=t.usage.server_tool_use),t.usage.iterations!=null&&(r.usage.iterations=t.usage.iterations),r;case"content_block_start":return r.content.push(t.content_block),r;case"content_block_delta":{let n=r.content.at(t.index);switch(t.delta.type){case"text_delta":{n?.type==="text"&&(r.content[t.index]={...n,text:(n.text||"")+t.delta.text});break}case"citations_delta":{n?.type==="text"&&(r.content[t.index]={...n,citations:[...n.citations??[],t.delta.citation]});break}case"input_json_delta":{if(n&&Lr(n)){let o=n[$r]||"";o+=t.delta.partial_json;let a={...n};if(Object.defineProperty(a,$r,{value:o,enumerable:!1,writable:!0}),o)try{a.input=ht(o)}catch(c){let u=new h(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${c}. JSON: ${o}`);i(this,yt,"f").call(this,u)}r.content[t.index]=a}break}case"thinking_delta":{n?.type==="thinking"&&(r.content[t.index]={...n,thinking:n.thinking+t.delta.thinking});break}case"signature_delta":{n?.type==="thinking"&&(r.content[t.index]={...n,signature:t.delta.signature});break}case"compaction_delta":{n?.type==="compaction"&&(r.content[t.index]={...n,content:(n.content||"")+t.delta.content});break}default:t.delta}return r}case"content_block_stop":return r}},Symbol.asyncIterator)](){let e=[],t=[],r=!1;return this.on("streamEvent",n=>{let o=t.shift();o?o.resolve(n):e.push(n)}),this.on("end",()=>{r=!0;for(let n of t)n.resolve(void 0);t.length=0}),this.on("abort",n=>{r=!0;for(let o of t)o.reject(n);t.length=0}),this.on("error",n=>{r=!0;for(let o of t)o.reject(n);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:r?{value:void 0,done:!0}:new Promise((o,a)=>t.push({resolve:o,reject:a})).then(o=>o?{value:o,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new F(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}};var Z=class extends Error{constructor(e){let t=typeof e=="string"?e:e.map(r=>r.type==="text"?r.text:`[${r.type}]`).join(" ");super(t),this.name="ToolError",this.content=e}};var jr=`You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:
|
|
10
|
+
1. Task Overview
|
|
11
|
+
The user's core request and success criteria
|
|
12
|
+
Any clarifications or constraints they specified
|
|
13
|
+
2. Current State
|
|
14
|
+
What has been completed so far
|
|
15
|
+
Files created, modified, or analyzed (with paths if relevant)
|
|
16
|
+
Key outputs or artifacts produced
|
|
17
|
+
3. Important Discoveries
|
|
18
|
+
Technical constraints or requirements uncovered
|
|
19
|
+
Decisions made and their rationale
|
|
20
|
+
Errors encountered and how they were resolved
|
|
21
|
+
What approaches were tried that didn't work (and why)
|
|
22
|
+
4. Next Steps
|
|
23
|
+
Specific actions needed to complete the task
|
|
24
|
+
Any blockers or open questions to resolve
|
|
25
|
+
Priority order if multiple steps remain
|
|
26
|
+
5. Context to Preserve
|
|
27
|
+
User preferences or style requirements
|
|
28
|
+
Domain-specific details that aren't obvious
|
|
29
|
+
Any promises made to the user
|
|
30
|
+
Be concise but complete\u2014err on the side of including information that would prevent duplicate work or repeated mistakes. Write in a way that enables immediate resumption of the task.
|
|
31
|
+
Wrap your summary in <summary></summary> tags.`;var He,we,ee,w,We,E,U,X,De,qr,zt;function Ur(){let s,e;return{promise:new Promise((r,n)=>{s=r,e=n}),resolve:s,reject:e}}var xe=class{constructor(e,t,r){He.add(this),this.client=e,we.set(this,!1),ee.set(this,!1),w.set(this,void 0),We.set(this,void 0),E.set(this,void 0),U.set(this,void 0),X.set(this,void 0),De.set(this,0),l(this,w,{params:{...t,messages:structuredClone(t.messages)}},"f");let o=["BetaToolRunner",...Wt(t.tools,t.messages)].join(", ");l(this,We,{...r,headers:f([{"x-stainless-helper":o},r?.headers])},"f"),l(this,X,Ur(),"f")}async*[(we=new WeakMap,ee=new WeakMap,w=new WeakMap,We=new WeakMap,E=new WeakMap,U=new WeakMap,X=new WeakMap,De=new WeakMap,He=new WeakSet,qr=async function(){let t=i(this,w,"f").params.compactionControl;if(!t||!t.enabled)return!1;let r=0;if(i(this,E,"f")!==void 0)try{let d=await i(this,E,"f");r=d.usage.input_tokens+(d.usage.cache_creation_input_tokens??0)+(d.usage.cache_read_input_tokens??0)+d.usage.output_tokens}catch{return!1}let n=t.contextTokenThreshold??1e5;if(r<n)return!1;let o=t.model??i(this,w,"f").params.model,a=t.summaryPrompt??jr,c=i(this,w,"f").params.messages;if(c[c.length-1].role==="assistant"){let d=c[c.length-1];if(Array.isArray(d.content)){let b=d.content.filter(_=>_.type!=="tool_use");b.length===0?c.pop():d.content=b}}let u=await this.client.beta.messages.create({model:o,messages:[...c,{role:"user",content:[{type:"text",text:a}]}],max_tokens:i(this,w,"f").params.max_tokens},{headers:{"x-stainless-helper":"compaction"}});if(u.content[0]?.type!=="text")throw new h("Expected text response for compaction");return i(this,w,"f").params.messages=[{role:"user",content:u.content}],!0},Symbol.asyncIterator)](){var e;if(i(this,we,"f"))throw new h("Cannot iterate over a consumed stream");l(this,we,!0,"f"),l(this,ee,!0,"f"),l(this,U,void 0,"f");try{for(;;){let t;try{if(i(this,w,"f").params.max_iterations&&i(this,De,"f")>=i(this,w,"f").params.max_iterations)break;l(this,ee,!1,"f"),l(this,U,void 0,"f"),l(this,De,(e=i(this,De,"f"),e++,e),"f"),l(this,E,void 0,"f");let{max_iterations:r,compactionControl:n,...o}=i(this,w,"f").params;if(o.stream?(t=this.client.beta.messages.stream({...o},i(this,We,"f")),l(this,E,t.finalMessage(),"f"),i(this,E,"f").catch(()=>{}),yield t):(l(this,E,this.client.beta.messages.create({...o,stream:!1},i(this,We,"f")),"f"),yield i(this,E,"f")),!await i(this,He,"m",qr).call(this)){if(!i(this,ee,"f")){let{role:u,content:d}=await i(this,E,"f");i(this,w,"f").params.messages.push({role:u,content:d})}let c=await i(this,He,"m",zt).call(this,i(this,w,"f").params.messages.at(-1));if(c)i(this,w,"f").params.messages.push(c);else if(!i(this,ee,"f"))break}}finally{t&&t.abort()}}if(!i(this,E,"f"))throw new h("ToolRunner concluded without a message from the server");i(this,X,"f").resolve(await i(this,E,"f"))}catch(t){throw l(this,we,!1,"f"),i(this,X,"f").promise.catch(()=>{}),i(this,X,"f").reject(t),l(this,X,Ur(),"f"),t}}setMessagesParams(e){typeof e=="function"?i(this,w,"f").params=e(i(this,w,"f").params):i(this,w,"f").params=e,l(this,ee,!0,"f"),l(this,U,void 0,"f")}async generateToolResponse(){let e=await i(this,E,"f")??this.params.messages.at(-1);return e?i(this,He,"m",zt).call(this,e):null}done(){return i(this,X,"f").promise}async runUntilDone(){if(!i(this,we,"f"))for await(let e of this);return this.done()}get params(){return i(this,w,"f").params}pushMessages(...e){this.setMessagesParams(t=>({...t,messages:[...t.messages,...e]}))}then(e,t){return this.runUntilDone().then(e,t)}};zt=async function(e){return i(this,U,"f")!==void 0?i(this,U,"f"):(l(this,U,Es(i(this,w,"f").params,e),"f"),i(this,U,"f"))};async function Es(s,e=s.messages.at(-1)){if(!e||e.role!=="assistant"||!e.content||typeof e.content=="string")return null;let t=e.content.filter(n=>n.type==="tool_use");return t.length===0?null:{role:"user",content:await Promise.all(t.map(async n=>{let o=s.tools.find(a=>("name"in a?a.name:a.mcp_server_name)===n.name);if(!o||!("run"in o))return{type:"tool_result",tool_use_id:n.id,content:`Error: Tool '${n.name}' not found`,is_error:!0};try{let a=n.input;"parse"in o&&o.parse&&(a=o.parse(a));let c=await o.run(a);return{type:"tool_result",tool_use_id:n.id,content:c}}catch(a){return{type:"tool_result",tool_use_id:n.id,content:a instanceof Z?a.content:`Error: ${a instanceof Error?a.message:String(a)}`,is_error:!0}}}))}}var Se=class s{constructor(e,t){this.iterator=e,this.controller=t}async*decoder(){let e=new L;for await(let t of this.iterator)for(let r of e.decode(t))yield JSON.parse(r);for(let t of e.flush())yield JSON.parse(t)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse(e,t){if(!e.body)throw t.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new h("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new h("Attempted to iterate over a response with no body");return new s(Ae(e.body),t)}};var ke=class extends m{create(e,t){let{betas:r,...n}=e;return this._client.post("/v1/messages/batches?beta=true",{body:n,...t,headers:f([{"anthropic-beta":[...r??[],"message-batches-2024-09-24"].toString()},t?.headers])})}retrieve(e,t={},r){let{betas:n}=t??{};return this._client.get(g`/v1/messages/batches/${e}?beta=true`,{...r,headers:f([{"anthropic-beta":[...n??[],"message-batches-2024-09-24"].toString()},r?.headers])})}list(e={},t){let{betas:r,...n}=e??{};return this._client.getAPIList("/v1/messages/batches?beta=true",A,{query:n,...t,headers:f([{"anthropic-beta":[...r??[],"message-batches-2024-09-24"].toString()},t?.headers])})}delete(e,t={},r){let{betas:n}=t??{};return this._client.delete(g`/v1/messages/batches/${e}?beta=true`,{...r,headers:f([{"anthropic-beta":[...n??[],"message-batches-2024-09-24"].toString()},r?.headers])})}cancel(e,t={},r){let{betas:n}=t??{};return this._client.post(g`/v1/messages/batches/${e}/cancel?beta=true`,{...r,headers:f([{"anthropic-beta":[...n??[],"message-batches-2024-09-24"].toString()},r?.headers])})}async results(e,t={},r){let n=await this.retrieve(e);if(!n.results_url)throw new h(`No batch \`results_url\`; Has it finished processing? ${n.processing_status} - ${n.id}`);let{betas:o}=t??{};return this._client.get(n.results_url,{...r,headers:f([{"anthropic-beta":[...o??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary"},r?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((a,c)=>Se.fromResponse(c.response,c.controller))}};var Cr={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-3-opus-20240229":"January 5th, 2026","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025","claude-3-7-sonnet-latest":"February 19th, 2026","claude-3-7-sonnet-20250219":"February 19th, 2026"},Ts=["claude-opus-4-6"],C=class extends m{constructor(){super(...arguments),this.batches=new ke(this._client)}create(e,t){let r=Hr(e),{betas:n,...o}=r;o.model in Cr&&console.warn(`The model '${o.model}' is deprecated and will reach end-of-life on ${Cr[o.model]}
|
|
32
|
+
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),o.model in Ts&&o.thinking&&o.thinking.type==="enabled"&&console.warn(`Using Claude with ${o.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let a=this._client._options.timeout;if(!o.stream&&a==null){let u=ut[o.model]??void 0;a=this._client.calculateNonstreamingTimeout(o.max_tokens,u)}let c=lt(o.tools,o.messages);return this._client.post("/v1/messages?beta=true",{body:o,timeout:a??6e5,...t,headers:f([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},c,t?.headers]),stream:r.stream??!1})}parse(e,t){return t={...t,headers:f([{"anthropic-beta":[...e.betas??[],"structured-outputs-2025-12-15"].toString()},t?.headers])},this.create(e,t).then(r=>Jt(r,e,{logger:this._client.logger??console}))}stream(e,t){return bt.createMessage(this,e,t)}countTokens(e,t){let r=Hr(e),{betas:n,...o}=r;return this._client.post("/v1/messages/count_tokens?beta=true",{body:o,...t,headers:f([{"anthropic-beta":[...n??[],"token-counting-2024-11-01"].toString()},t?.headers])})}toolRunner(e,t){return new xe(this._client,e,t)}};function Hr(s){if(!s.output_format)return s;if(s.output_config?.format)throw new h("Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).");let{output_format:e,...t}=s;return{...t,output_config:{...s.output_config,format:e}}}C.Batches=ke;C.BetaToolRunner=xe;C.ToolError=Z;var Pe=class extends m{create(e,t={},r){let{betas:n,...o}=t??{};return this._client.post(g`/v1/skills/${e}/versions?beta=true`,me({body:o,...r,headers:f([{"anthropic-beta":[...n??[],"skills-2025-10-02"].toString()},r?.headers])},this._client))}retrieve(e,t,r){let{skill_id:n,betas:o}=t;return this._client.get(g`/v1/skills/${n}/versions/${e}?beta=true`,{...r,headers:f([{"anthropic-beta":[...o??[],"skills-2025-10-02"].toString()},r?.headers])})}list(e,t={},r){let{betas:n,...o}=t??{};return this._client.getAPIList(g`/v1/skills/${e}/versions?beta=true`,pe,{query:o,...r,headers:f([{"anthropic-beta":[...n??[],"skills-2025-10-02"].toString()},r?.headers])})}delete(e,t,r){let{skill_id:n,betas:o}=t;return this._client.delete(g`/v1/skills/${n}/versions/${e}?beta=true`,{...r,headers:f([{"anthropic-beta":[...o??[],"skills-2025-10-02"].toString()},r?.headers])})}};var te=class extends m{constructor(){super(...arguments),this.versions=new Pe(this._client)}create(e={},t){let{betas:r,...n}=e??{};return this._client.post("/v1/skills?beta=true",me({body:n,...t,headers:f([{"anthropic-beta":[...r??[],"skills-2025-10-02"].toString()},t?.headers])},this._client,!1))}retrieve(e,t={},r){let{betas:n}=t??{};return this._client.get(g`/v1/skills/${e}?beta=true`,{...r,headers:f([{"anthropic-beta":[...n??[],"skills-2025-10-02"].toString()},r?.headers])})}list(e={},t){let{betas:r,...n}=e??{};return this._client.getAPIList("/v1/skills?beta=true",pe,{query:n,...t,headers:f([{"anthropic-beta":[...r??[],"skills-2025-10-02"].toString()},t?.headers])})}delete(e,t={},r){let{betas:n}=t??{};return this._client.delete(g`/v1/skills/${e}?beta=true`,{...r,headers:f([{"anthropic-beta":[...n??[],"skills-2025-10-02"].toString()},r?.headers])})}};te.Versions=Pe;var B=class extends m{constructor(){super(...arguments),this.models=new _e(this._client),this.messages=new C(this._client),this.files=new ge(this._client),this.skills=new te(this._client)}};B.Models=_e;B.Messages=C;B.Files=ge;B.Skills=te;var re=class extends m{create(e,t){let{betas:r,...n}=e;return this._client.post("/v1/complete",{body:n,timeout:this._client._options.timeout??6e5,...t,headers:f([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},t?.headers]),stream:e.stream??!1})}};function Wr(s){return s?.output_config?.format}function Qt(s,e,t){let r=Wr(e);return!e||!("parse"in(r??{}))?{...s,content:s.content.map(n=>n.type==="text"?Object.defineProperty({...n},"parsed_output",{value:null,enumerable:!1}):n),parsed_output:null}:Yt(s,e,t)}function Yt(s,e,t){let r=null,n=s.content.map(o=>{if(o.type==="text"){let a=Ns(e,o.text);return r===null&&(r=a),Object.defineProperty({...o},"parsed_output",{value:a,enumerable:!1})}return o});return{...s,content:n,parsed_output:r}}function Ns(s,e){let t=Wr(s);if(t?.type!=="json_schema")return null;try{return"parse"in t?t.parse(e):JSON.parse(e)}catch(r){throw new h(`Failed to parse structured output: ${r}`)}}var I,K,Me,Je,wt,Xe,Ke,xt,Ve,H,Ge,St,kt,se,Pt,Mt,ze,Zt,Dr,er,tr,rr,sr,Jr,Xr="__json_buf";function Kr(s){return s.type==="tool_use"||s.type==="server_tool_use"}var Rt=class s{constructor(e,t){I.add(this),this.messages=[],this.receivedMessages=[],K.set(this,void 0),Me.set(this,null),this.controller=new AbortController,Je.set(this,void 0),wt.set(this,()=>{}),Xe.set(this,()=>{}),Ke.set(this,void 0),xt.set(this,()=>{}),Ve.set(this,()=>{}),H.set(this,{}),Ge.set(this,!1),St.set(this,!1),kt.set(this,!1),se.set(this,!1),Pt.set(this,void 0),Mt.set(this,void 0),ze.set(this,void 0),er.set(this,r=>{if(l(this,St,!0,"f"),$(r)&&(r=new k),r instanceof k)return l(this,kt,!0,"f"),this._emit("abort",r);if(r instanceof h)return this._emit("error",r);if(r instanceof Error){let n=new h(r.message);return n.cause=r,this._emit("error",n)}return this._emit("error",new h(String(r)))}),l(this,Je,new Promise((r,n)=>{l(this,wt,r,"f"),l(this,Xe,n,"f")}),"f"),l(this,Ke,new Promise((r,n)=>{l(this,xt,r,"f"),l(this,Ve,n,"f")}),"f"),i(this,Je,"f").catch(()=>{}),i(this,Ke,"f").catch(()=>{}),l(this,Me,e,"f"),l(this,ze,t?.logger??console,"f")}get response(){return i(this,Pt,"f")}get request_id(){return i(this,Mt,"f")}async withResponse(){l(this,se,!0,"f");let e=await i(this,Je,"f");if(!e)throw new Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get("request-id")}}static fromReadableStream(e){let t=new s(null);return t._run(()=>t._fromReadableStream(e)),t}static createMessage(e,t,r,{logger:n}={}){let o=new s(t,{logger:n});for(let a of t.messages)o._addMessageParam(a);return l(o,Me,{...t,stream:!0},"f"),o._run(()=>o._createMessage(e,{...t,stream:!0},{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),o}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},i(this,er,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit("message",e)}async _createMessage(e,t,r){let n=r?.signal,o;n&&(n.aborted&&this.controller.abort(),o=this.controller.abort.bind(this.controller),n.addEventListener("abort",o));try{i(this,I,"m",tr).call(this);let{response:a,data:c}=await e.create({...t,stream:!0},{...r,signal:this.controller.signal}).withResponse();this._connected(a);for await(let u of c)i(this,I,"m",rr).call(this,u);if(c.controller.signal?.aborted)throw new k;i(this,I,"m",sr).call(this)}finally{n&&o&&n.removeEventListener("abort",o)}}_connected(e){this.ended||(l(this,Pt,e,"f"),l(this,Mt,e?.headers.get("request-id"),"f"),i(this,wt,"f").call(this,e),this._emit("connect"))}get ended(){return i(this,Ge,"f")}get errored(){return i(this,St,"f")}get aborted(){return i(this,kt,"f")}abort(){this.controller.abort()}on(e,t){return(i(this,H,"f")[e]||(i(this,H,"f")[e]=[])).push({listener:t}),this}off(e,t){let r=i(this,H,"f")[e];if(!r)return this;let n=r.findIndex(o=>o.listener===t);return n>=0&&r.splice(n,1),this}once(e,t){return(i(this,H,"f")[e]||(i(this,H,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,r)=>{l(this,se,!0,"f"),e!=="error"&&this.once("error",r),this.once(e,t)})}async done(){l(this,se,!0,"f"),await i(this,Ke,"f")}get currentMessage(){return i(this,K,"f")}async finalMessage(){return await this.done(),i(this,I,"m",Zt).call(this)}async finalText(){return await this.done(),i(this,I,"m",Dr).call(this)}_emit(e,...t){if(i(this,Ge,"f"))return;e==="end"&&(l(this,Ge,!0,"f"),i(this,xt,"f").call(this));let r=i(this,H,"f")[e];if(r&&(i(this,H,"f")[e]=r.filter(n=>!n.once),r.forEach(({listener:n})=>n(...t))),e==="abort"){let n=t[0];!i(this,se,"f")&&!r?.length&&Promise.reject(n),i(this,Xe,"f").call(this,n),i(this,Ve,"f").call(this,n),this._emit("end");return}if(e==="error"){let n=t[0];!i(this,se,"f")&&!r?.length&&Promise.reject(n),i(this,Xe,"f").call(this,n),i(this,Ve,"f").call(this,n),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",i(this,I,"m",Zt).call(this))}async _fromReadableStream(e,t){let r=t?.signal,n;r&&(r.aborted&&this.controller.abort(),n=this.controller.abort.bind(this.controller),r.addEventListener("abort",n));try{i(this,I,"m",tr).call(this),this._connected(null);let o=F.fromReadableStream(e,this.controller);for await(let a of o)i(this,I,"m",rr).call(this,a);if(o.controller.signal?.aborted)throw new k;i(this,I,"m",sr).call(this)}finally{r&&n&&r.removeEventListener("abort",n)}}[(K=new WeakMap,Me=new WeakMap,Je=new WeakMap,wt=new WeakMap,Xe=new WeakMap,Ke=new WeakMap,xt=new WeakMap,Ve=new WeakMap,H=new WeakMap,Ge=new WeakMap,St=new WeakMap,kt=new WeakMap,se=new WeakMap,Pt=new WeakMap,Mt=new WeakMap,ze=new WeakMap,er=new WeakMap,I=new WeakSet,Zt=function(){if(this.receivedMessages.length===0)throw new h("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},Dr=function(){if(this.receivedMessages.length===0)throw new h("stream ended without producing a Message with role=assistant");let t=this.receivedMessages.at(-1).content.filter(r=>r.type==="text").map(r=>r.text);if(t.length===0)throw new h("stream ended without producing a content block with type=text");return t.join(" ")},tr=function(){this.ended||l(this,K,void 0,"f")},rr=function(t){if(this.ended)return;let r=i(this,I,"m",Jr).call(this,t);switch(this._emit("streamEvent",t,r),t.type){case"content_block_delta":{let n=r.content.at(-1);switch(t.delta.type){case"text_delta":{n.type==="text"&&this._emit("text",t.delta.text,n.text||"");break}case"citations_delta":{n.type==="text"&&this._emit("citation",t.delta.citation,n.citations??[]);break}case"input_json_delta":{Kr(n)&&n.input&&this._emit("inputJson",t.delta.partial_json,n.input);break}case"thinking_delta":{n.type==="thinking"&&this._emit("thinking",t.delta.thinking,n.thinking);break}case"signature_delta":{n.type==="thinking"&&this._emit("signature",n.signature);break}default:t.delta}break}case"message_stop":{this._addMessageParam(r),this._addMessage(Qt(r,i(this,Me,"f"),{logger:i(this,ze,"f")}),!0);break}case"content_block_stop":{this._emit("contentBlock",r.content.at(-1));break}case"message_start":{l(this,K,r,"f");break}case"content_block_start":case"message_delta":break}},sr=function(){if(this.ended)throw new h("stream has ended, this shouldn't happen");let t=i(this,K,"f");if(!t)throw new h("request ended without sending any chunks");return l(this,K,void 0,"f"),Qt(t,i(this,Me,"f"),{logger:i(this,ze,"f")})},Jr=function(t){let r=i(this,K,"f");if(t.type==="message_start"){if(r)throw new h(`Unexpected event order, got ${t.type} before receiving "message_stop"`);return t.message}if(!r)throw new h(`Unexpected event order, got ${t.type} before "message_start"`);switch(t.type){case"message_stop":return r;case"message_delta":return r.stop_reason=t.delta.stop_reason,r.stop_sequence=t.delta.stop_sequence,r.usage.output_tokens=t.usage.output_tokens,t.usage.input_tokens!=null&&(r.usage.input_tokens=t.usage.input_tokens),t.usage.cache_creation_input_tokens!=null&&(r.usage.cache_creation_input_tokens=t.usage.cache_creation_input_tokens),t.usage.cache_read_input_tokens!=null&&(r.usage.cache_read_input_tokens=t.usage.cache_read_input_tokens),t.usage.server_tool_use!=null&&(r.usage.server_tool_use=t.usage.server_tool_use),r;case"content_block_start":return r.content.push({...t.content_block}),r;case"content_block_delta":{let n=r.content.at(t.index);switch(t.delta.type){case"text_delta":{n?.type==="text"&&(r.content[t.index]={...n,text:(n.text||"")+t.delta.text});break}case"citations_delta":{n?.type==="text"&&(r.content[t.index]={...n,citations:[...n.citations??[],t.delta.citation]});break}case"input_json_delta":{if(n&&Kr(n)){let o=n[Xr]||"";o+=t.delta.partial_json;let a={...n};Object.defineProperty(a,Xr,{value:o,enumerable:!1,writable:!0}),o&&(a.input=ht(o)),r.content[t.index]=a}break}case"thinking_delta":{n?.type==="thinking"&&(r.content[t.index]={...n,thinking:n.thinking+t.delta.thinking});break}case"signature_delta":{n?.type==="thinking"&&(r.content[t.index]={...n,signature:t.delta.signature});break}default:t.delta}return r}case"content_block_stop":return r}},Symbol.asyncIterator)](){let e=[],t=[],r=!1;return this.on("streamEvent",n=>{let o=t.shift();o?o.resolve(n):e.push(n)}),this.on("end",()=>{r=!0;for(let n of t)n.resolve(void 0);t.length=0}),this.on("abort",n=>{r=!0;for(let o of t)o.reject(n);t.length=0}),this.on("error",n=>{r=!0;for(let o of t)o.reject(n);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:r?{value:void 0,done:!0}:new Promise((o,a)=>t.push({resolve:o,reject:a})).then(o=>o?{value:o,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new F(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}};var Re=class extends m{create(e,t){return this._client.post("/v1/messages/batches",{body:e,...t})}retrieve(e,t){return this._client.get(g`/v1/messages/batches/${e}`,t)}list(e={},t){return this._client.getAPIList("/v1/messages/batches",A,{query:e,...t})}delete(e,t){return this._client.delete(g`/v1/messages/batches/${e}`,t)}cancel(e,t){return this._client.post(g`/v1/messages/batches/${e}/cancel`,t)}async results(e,t){let r=await this.retrieve(e);if(!r.results_url)throw new h(`No batch \`results_url\`; Has it finished processing? ${r.processing_status} - ${r.id}`);return this._client.get(r.results_url,{...t,headers:f([{Accept:"application/binary"},t?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((n,o)=>Se.fromResponse(o.response,o.controller))}};var V=class extends m{constructor(){super(...arguments),this.batches=new Re(this._client)}create(e,t){e.model in Vr&&console.warn(`The model '${e.model}' is deprecated and will reach end-of-life on ${Vr[e.model]}
|
|
33
|
+
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),e.model in vs&&e.thinking&&e.thinking.type==="enabled"&&console.warn(`Using Claude with ${e.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let r=this._client._options.timeout;if(!e.stream&&r==null){let o=ut[e.model]??void 0;r=this._client.calculateNonstreamingTimeout(e.max_tokens,o)}let n=lt(e.tools,e.messages);return this._client.post("/v1/messages",{body:e,timeout:r??6e5,...t,headers:f([n,t?.headers]),stream:e.stream??!1})}parse(e,t){return this.create(e,t).then(r=>Yt(r,e,{logger:this._client.logger??console}))}stream(e,t){return Rt.createMessage(this,e,t,{logger:this._client.logger??console})}countTokens(e,t){return this._client.post("/v1/messages/count_tokens",{body:e,...t})}},Vr={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-3-opus-20240229":"January 5th, 2026","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025","claude-3-7-sonnet-latest":"February 19th, 2026","claude-3-7-sonnet-20250219":"February 19th, 2026","claude-3-5-haiku-latest":"February 19th, 2026","claude-3-5-haiku-20241022":"February 19th, 2026"},vs=["claude-opus-4-6"];V.Batches=Re;var ne=class extends m{retrieve(e,t={},r){let{betas:n}=t??{};return this._client.get(g`/v1/models/${e}`,{...r,headers:f([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},r?.headers])})}list(e={},t){let{betas:r,...n}=e??{};return this._client.getAPIList("/v1/models",A,{query:n,...t,headers:f([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},t?.headers])})}};var Qe=s=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[s]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(s)?.trim()};var nr,or,Et,Gr,zr="\\n\\nHuman:",Qr="\\n\\nAssistant:",y=class{constructor({baseURL:e=Qe("ANTHROPIC_BASE_URL"),apiKey:t=Qe("ANTHROPIC_API_KEY")??null,authToken:r=Qe("ANTHROPIC_AUTH_TOKEN")??null,...n}={}){nr.add(this),Et.set(this,void 0);let o={apiKey:t,authToken:r,...n,baseURL:e||"https://api.anthropic.com"};if(!o.dangerouslyAllowBrowser&&gr())throw new h(`It looks like you're running in a browser-like environment.
|
|
34
|
+
|
|
35
|
+
This is disabled by default, as it risks exposing your secret API credentials to attackers.
|
|
36
|
+
If you understand the risks and have appropriate mitigations in place,
|
|
37
|
+
you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
38
|
+
|
|
39
|
+
new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
|
|
40
|
+
`);this.baseURL=o.baseURL,this.timeout=o.timeout??or.DEFAULT_TIMEOUT,this.logger=o.logger??console;let a="warn";this.logLevel=a,this.logLevel=$t(o.logLevel,"ClientOptions.logLevel",this)??$t(Qe("ANTHROPIC_LOG"),"process.env['ANTHROPIC_LOG']",this)??a,this.fetchOptions=o.fetchOptions,this.maxRetries=o.maxRetries??2,this.fetch=o.fetch??yr(),l(this,Et,wr,"f"),this._options=o,this.apiKey=typeof t=="string"?t:null,this.authToken=r}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,authToken:this.authToken,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){if(!(e.get("x-api-key")||e.get("authorization"))&&!(this.apiKey&&e.get("x-api-key"))&&!t.has("x-api-key")&&!(this.authToken&&e.get("authorization"))&&!t.has("authorization"))throw new Error('Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted')}async authHeaders(e){return f([await this.apiKeyAuth(e),await this.bearerAuth(e)])}async apiKeyAuth(e){if(this.apiKey!=null)return f([{"X-Api-Key":this.apiKey}])}async bearerAuth(e){if(this.authToken!=null)return f([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(e){return xr(e)}getUserAgent(){return`${this.constructor.name}/JS ${D}`}defaultIdempotencyKey(){return`stainless-node-retry-${It()}`}makeStatusError(e,t,r,n){return x.generate(e,t,r,n)}buildURL(e,t,r){let n=!i(this,nr,"m",Gr).call(this)&&r||this.baseURL,o=lr(e)?new URL(e):new URL(n+(n.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),a=this.defaultQuery(),c=Object.fromEntries(o.searchParams);return(!Nt(a)||!Nt(c))&&(t={...c,...a,...t}),typeof t=="object"&&t&&!Array.isArray(t)&&(o.search=this.stringifyQuery(t)),o.toString()}_calculateNonstreamingTimeout(e){if(3600*e/128e3>600)throw new h("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#streaming-responses for more details");return 600*1e3}async prepareOptions(e){}async prepareRequest(e,{url:t,options:r}){}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,r){return this.request(Promise.resolve(r).then(n=>({method:e,path:t,...n})))}request(e,t=null){return new z(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,r){let n=await e,o=n.maxRetries??this.maxRetries;t==null&&(t=o),await this.prepareOptions(n);let{req:a,url:c,timeout:u}=await this.buildRequest(n,{retryCount:o-t});await this.prepareRequest(a,{url:c,options:n});let d="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),b=r===void 0?"":`, retryOf: ${r}`,_=Date.now();if(S(this).debug(`[${d}] sending request`,j({retryOfRequestLogID:r,method:n.method,url:c,options:n,headers:a.headers})),n.signal?.aborted)throw new k;let P=new AbortController,p=await this.fetchWithTimeout(c,a,u,P).catch(Ee),O=Date.now();if(p instanceof globalThis.Error){let v=`retrying, ${t} attempts remaining`;if(n.signal?.aborted)throw new k;let N=$(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(t)return S(this).info(`[${d}] connection ${N?"timed out":"failed"} - ${v}`),S(this).debug(`[${d}] connection ${N?"timed out":"failed"} (${v})`,j({retryOfRequestLogID:r,url:c,durationMs:O-_,message:p.message})),this.retryRequest(n,t,r??d);throw S(this).info(`[${d}] connection ${N?"timed out":"failed"} - error; no more retries left`),S(this).debug(`[${d}] connection ${N?"timed out":"failed"} (error; no more retries left)`,j({retryOfRequestLogID:r,url:c,durationMs:O-_,message:p.message})),N?new oe:new W({cause:p})}let At=[...p.headers.entries()].filter(([v])=>v==="request-id").map(([v,N])=>", "+v+": "+JSON.stringify(N)).join(""),Tt=`[${d}${b}${At}] ${a.method} ${c} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${O-_}ms`;if(!p.ok){let v=await this.shouldRetry(p);if(t&&v){let Ye=`retrying, ${t} attempts remaining`;return await br(p.body),S(this).info(`${Tt} - ${Ye}`),S(this).debug(`[${d}] response error (${Ye})`,j({retryOfRequestLogID:r,url:p.url,status:p.status,headers:p.headers,durationMs:O-_})),this.retryRequest(n,t,r??d,p.headers)}let N=v?"error; no more retries left":"error; not retryable";S(this).info(`${Tt} - ${N}`);let ir=await p.text().catch(Ye=>Ee(Ye).message),ar=et(ir),cr=ar?void 0:ir;throw S(this).debug(`[${d}] response error (${N})`,j({retryOfRequestLogID:r,url:p.url,status:p.status,headers:p.headers,message:cr,durationMs:Date.now()-_})),this.makeStatusError(p.status,ar,cr,p.headers)}return S(this).info(Tt),S(this).debug(`[${d}] response start`,j({retryOfRequestLogID:r,url:p.url,status:p.status,headers:p.headers,durationMs:O-_})),{response:p,options:n,controller:P,requestLogID:d,retryOfRequestLogID:r,startTime:_}}getAPIList(e,t,r){return this.requestAPIList(t,r&&"then"in r?r.then(n=>({method:"get",path:e,...n})):{method:"get",path:e,...r})}requestAPIList(e,t){let r=this.makeRequest(t,null,void 0);return new Ne(this,r,e)}async fetchWithTimeout(e,t,r,n){let{signal:o,method:a,...c}=t||{},u=this._makeAbort(n);o&&o.addEventListener("abort",u,{once:!0});let d=setTimeout(u,r),b=globalThis.ReadableStream&&c.body instanceof globalThis.ReadableStream||typeof c.body=="object"&&c.body!==null&&Symbol.asyncIterator in c.body,_={signal:n.signal,...b?{duplex:"half"}:{},method:"GET",...c};a&&(_.method=a.toUpperCase());try{return await this.fetch.call(void 0,e,_)}finally{clearTimeout(d)}}async shouldRetry(e){let t=e.headers.get("x-should-retry");return t==="true"?!0:t==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,t,r,n){let o,a=n?.get("retry-after-ms");if(a){let u=parseFloat(a);Number.isNaN(u)||(o=u)}let c=n?.get("retry-after");if(c&&!o){let u=parseFloat(c);Number.isNaN(u)?o=Date.parse(c)-Date.now():o=u*1e3}if(o===void 0){let u=e.maxRetries??this.maxRetries;o=this.calculateDefaultRetryTimeoutMillis(t,u)}return await fr(o),this.makeRequest(e,t-1,r)}calculateDefaultRetryTimeoutMillis(e,t){let o=t-e,a=Math.min(.5*Math.pow(2,o),8),c=1-Math.random()*.25;return a*c*1e3}calculateNonstreamingTimeout(e,t){if(36e5*e/128e3>6e5||t!=null&&e>t)throw new h("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#long-requests for more details");return 6e5}async buildRequest(e,{retryCount:t=0}={}){let r={...e},{method:n,path:o,query:a,defaultBaseURL:c}=r,u=this.buildURL(o,a,c);"timeout"in r&&hr("timeout",r.timeout),r.timeout=r.timeout??this.timeout;let{bodyHeaders:d,body:b}=this.buildBody({options:r}),_=await this.buildHeaders({options:e,method:n,bodyHeaders:d,retryCount:t});return{req:{method:n,headers:_,...r.signal&&{signal:r.signal},...globalThis.ReadableStream&&b instanceof globalThis.ReadableStream&&{duplex:"half"},...b&&{body:b},...this.fetchOptions??{},...r.fetchOptions??{}},url:u,timeout:r.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:r,retryCount:n}){let o={};this.idempotencyHeader&&t!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),o[this.idempotencyHeader]=e.idempotencyKey);let a=f([o,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(n),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},..._r(),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2023-06-01"},await this.authHeaders(e),this._options.defaultHeaders,r,e.headers]);return this.validateHeaders(a),a.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};let r=f([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&r.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:tt(e)}:typeof e=="object"&&r.values.get("content-type")==="application/x-www-form-urlencoded"?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e)}:i(this,Et,"f").call(this,{body:e,headers:r})}};or=y,Et=new WeakMap,nr=new WeakSet,Gr=function(){return this.baseURL!=="https://api.anthropic.com"};y.Anthropic=or;y.HUMAN_PROMPT=zr;y.AI_PROMPT=Qr;y.DEFAULT_TIMEOUT=6e5;y.AnthropicError=h;y.APIError=x;y.APIConnectionError=W;y.APIConnectionTimeoutError=oe;y.APIUserAbortError=k;y.NotFoundError=le;y.ConflictError=ue;y.RateLimitError=fe;y.BadRequestError=ie;y.AuthenticationError=ae;y.InternalServerError=de;y.PermissionDeniedError=ce;y.UnprocessableEntityError=he;y.toFile=at;var G=class extends y{constructor(){super(...arguments),this.completions=new re(this),this.messages=new V(this),this.models=new ne(this),this.beta=new B(this)}};G.Completions=re;G.Messages=V;G.Models=ne;G.Beta=B;export{Qr as AI_PROMPT,W as APIConnectionError,oe as APIConnectionTimeoutError,x as APIError,z as APIPromise,k as APIUserAbortError,G as Anthropic,h as AnthropicError,ae as AuthenticationError,ie as BadRequestError,y as BaseAnthropic,ue as ConflictError,zr as HUMAN_PROMPT,de as InternalServerError,le as NotFoundError,Ne as PagePromise,ce as PermissionDeniedError,fe as RateLimitError,he as UnprocessableEntityError,G as default,at as toFile};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as O,d as z}from"./chunk-TJZAIUKM.js";import{b,c as k}from"./chunk-YK6UG66R.js";import{b as T,k as U}from"./chunk-IAR3DEWR.js";import{d as g,e as E,h as N,i as P,j as A,k as I,l as R,t as L}from"./chunk-EMHZF6ZY.js";import{c as l,d as c,f as m,g as S,h as x,k as C,o as $,q as y,r as D}from"./chunk-Y6AFIAJP.js";import{a as f,b as h}from"./chunk-2N4GTHXQ.js";import{b as u}from"./chunk-MNEZ5QGX.js";import"./chunk-DHMCIRLT.js";import"./chunk-4BH6CF3J.js";import"./chunk-OTRBRRIO.js";var _=async n=>{let e=n?.[0];if(e==="new")return await G(n?.slice(1));if(e==="list")return await B(n?.slice(1));if(e==="switch")return await q(n?.slice(1));let t=b(),r=$({renderer:D.ansi(),sink:y.stdout()});return r.writeln(`Usage: ${t} spec <new "description" | list | switch <name>>`),await r.close(),f(void 0)},G=async n=>{let e=$({renderer:D.ansi(),sink:y.stdout()}),t=u.process.cwd();if(!await L(t))return e.writeln(m("noskills is not initialized.")," Run: ",l(k("init"))),await e.close(),h({exitCode:1});let r=null,i=[];if(n!==void 0)for(let w of n)w.startsWith("--name=")?r=w.slice(7):w.startsWith("-")||i.push(w);let p=i.join(" ");if(p.length===0)return e.writeln(m("Please provide a description: "),l(`${b()} spec new "photo auto-listing"`)),await e.close(),h({exitCode:1});let o=r??W(p),a=await X(t,o),d=`spec/${a}`,s=await E(t);if(s.phase!=="IDLE"&&s.phase!=="DONE")return e.writeln(m(`Cannot start new spec in phase: ${s.phase}`),c(" \u2014 finish or reset the current spec first.")),await e.close(),h({exitCode:1});let v=T(s.phase==="DONE"?U(s):s,a,d);return await u.fs.mkdir(`${t}/${g.specDir(a)}`,{recursive:!0}),await N(t,v),await I(t,a,v),e.writeln(S("\u2714")," Spec started: ",l(a)),e.writeln(" Directory: ",c(g.specDir(a))),e.writeln(" Branch: ",c(d)),e.writeln(" Phase: ",x("DISCOVERY")),e.writeln(""),e.writeln("Run ",l(k("next"))," to begin discovery questions."),await e.close(),f(void 0)},W=n=>n.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,50).replace(/-$/,""),X=async(n,e)=>{let t=`${n}/${g.specsDir}`,r=async i=>{try{return await u.fs.stat(`${t}/${i}`),!0}catch{return!1}};if(!await r(e))return e;for(let i=2;i<=99;i++){let p=`${e}-${i}`;if(!await r(p))return p}return`${e}-${Date.now()}`},B=async n=>{let e=u.process.cwd(),t=O(n),r=await P(e),i=await R(e),p=`${e}/${g.specsDir}`,o=new Set(i.map(s=>s.name)),a=[];for(let s of i)a.push({name:s.name,phase:s.state.phase,iteration:s.state.execution.iteration,active:s.name===r});try{for await(let s of u.fs.readDir(p))s.isDirectory&&!o.has(s.name)&&a.push({name:s.name,phase:"IDLE",iteration:0,active:s.name===r})}catch{}if(t==="json")return await z(a,"json"),f(void 0);let d=$({renderer:D.ansi(),sink:y.stdout()});if(d.writeln(l("Specs")),d.writeln(""),a.length===0)d.writeln(c(" No specs yet."));else for(let s of a){let v=s.active?S("\u25CF"):c("\u25CB"),w=s.active?l(s.name):c(s.name),j=s.phase==="DONE"?S(s.phase):s.phase==="EXECUTING"?C(s.phase):s.phase==="BLOCKED"?m(s.phase):x(s.phase),F=s.phase==="EXECUTING"?c(` iteration ${s.iteration}`):"";d.writeln(" ",v," ",w," ",j,F)}return await d.close(),f(void 0)},q=async n=>{let e=$({renderer:D.ansi(),sink:y.stdout()}),t=u.process.cwd(),r=n?.[0];if(r===void 0||r.length===0)return e.writeln(m("Please provide a spec name: "),l(`${b()} spec switch my-feature`)),await e.close(),h({exitCode:1});let i=await P(t),p=await E(t);i!==null&&p.spec!==null&&await I(t,i,p);let o=await A(t,r),a=await u.fs.stat(`${t}/${g.specDir(r)}`).then(()=>!0).catch(()=>!1);return o.phase==="IDLE"&&!a?(e.writeln(m(`Spec "${r}" not found.`)),e.writeln(c(`Run \`${k("spec list")}\` to see available specs.`)),await e.close(),h({exitCode:1})):(await N(t,o),e.writeln(S("\u2714")," Switched to: ",l(r)," (",C(o.phase),")"),o.phase==="EXECUTING"&&(e.writeln(c(` Iteration: ${o.execution.iteration}`)),o.execution.lastProgress!==null&&e.writeln(c(` Progress: ${o.execution.lastProgress}`))),await e.close(),f(void 0))};export{_ as main};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as j,b as Ie,c as ze,d as I,e as ae,f as fe,g as Ne,h as De,i as Me,j as We,k as Ve}from"./chunk-AGWPQX43.js";import{b as y}from"./chunk-OTRBRRIO.js";function Ge(r){if(!/^data:/i.test(r))throw new TypeError('`uri` does not appear to be a Data URI (must begin with "data:")');r=r.replace(/\r?\n/g,"");let e=r.indexOf(",");if(e===-1||e<=4)throw new TypeError("malformed data: URI");let t=r.substring(5,e).split(";"),n="",o=!1,s=t[0]||"text/plain",i=s;for(let R=1;R<t.length;R++)t[R]==="base64"?o=!0:t[R]&&(i+=`;${t[R]}`,t[R].indexOf("charset=")===0&&(n=t[R].substring(8)));!t[0]&&!n.length&&(i+=";charset=US-ASCII",n="US-ASCII");let c=o?"base64":"ascii",l=unescape(r.substring(e+1)),a=Buffer.from(l,c);return a.type=s,a.typeFull=i,a.charset=n,a}var ce,le=y(()=>{ce=Ge});var U,M=y(()=>{U=class extends Error{constructor(e,t){super(e),Error.captureStackTrace(this,this.constructor),this.type=t}get name(){return this.constructor.name}get[Symbol.toStringTag](){return this.constructor.name}}});var p,q=y(()=>{M();p=class extends U{constructor(e,t,n){super(e,t),n&&(this.code=this.errno=n.code,this.erroredSysCall=n.syscall)}}});var W,ee,z,ue,he,de,V=y(()=>{W=Symbol.toStringTag,ee=r=>typeof r=="object"&&typeof r.append=="function"&&typeof r.delete=="function"&&typeof r.get=="function"&&typeof r.getAll=="function"&&typeof r.has=="function"&&typeof r.set=="function"&&typeof r.sort=="function"&&r[W]==="URLSearchParams",z=r=>r&&typeof r=="object"&&typeof r.arrayBuffer=="function"&&typeof r.type=="string"&&typeof r.stream=="function"&&typeof r.constructor=="function"&&/^(Blob|File)$/.test(r[W]),ue=r=>typeof r=="object"&&(r[W]==="AbortSignal"||r[W]==="EventTarget"),he=(r,e)=>{let t=new URL(e).hostname,n=new URL(r).hostname;return t===n||t.endsWith(`.${n}`)},de=(r,e)=>{let t=new URL(e).protocol,n=new URL(r).protocol;return t===n}});import v,{PassThrough as pe}from"node:stream";import{types as me,deprecate as te,promisify as Ke}from"node:util";import{Buffer as b}from"node:buffer";async function re(r){if(r[m].disturbed)throw new TypeError(`body used already for: ${r.url}`);if(r[m].disturbed=!0,r[m].error)throw r[m].error;let{body:e}=r;if(e===null)return b.alloc(0);if(!(e instanceof v))return b.alloc(0);let t=[],n=0;try{for await(let o of e){if(r.size>0&&n+o.length>r.size){let s=new p(`content size at ${r.url} over limit: ${r.size}`,"max-size");throw e.destroy(s),s}n+=o.length,t.push(o)}}catch(o){throw o instanceof U?o:new p(`Invalid response body while trying to fetch ${r.url}: ${o.message}`,"system",o)}if(e.readableEnded===!0||e._readableState.ended===!0)try{return t.every(o=>typeof o=="string")?b.from(t.join("")):b.concat(t,n)}catch(o){throw new p(`Could not create Buffer from response body for ${r.url}: ${o.message}`,"system",o)}else throw new p(`Premature close of server response while trying to fetch ${r.url}`)}var Ye,m,E,F,Je,G,ye,ge,K=y(()=>{Ie();fe();q();M();V();Ye=Ke(v.pipeline),m=Symbol("Body internals"),E=class{constructor(e,{size:t=0}={}){let n=null;e===null?e=null:ee(e)?e=b.from(e.toString()):z(e)||b.isBuffer(e)||(me.isAnyArrayBuffer(e)?e=b.from(e):ArrayBuffer.isView(e)?e=b.from(e.buffer,e.byteOffset,e.byteLength):e instanceof v||(e instanceof I?(e=ae(e),n=e.type.split("=")[1]):e=b.from(String(e))));let o=e;b.isBuffer(e)?o=v.Readable.from(e):z(e)&&(o=v.Readable.from(e.stream())),this[m]={body:e,stream:o,boundary:n,disturbed:!1,error:null},this.size=t,e instanceof v&&e.on("error",s=>{let i=s instanceof U?s:new p(`Invalid response body while trying to fetch ${this.url}: ${s.message}`,"system",s);this[m].error=i})}get body(){return this[m].stream}get bodyUsed(){return this[m].disturbed}async arrayBuffer(){let{buffer:e,byteOffset:t,byteLength:n}=await re(this);return e.slice(t,t+n)}async formData(){let e=this.headers.get("content-type");if(e.startsWith("application/x-www-form-urlencoded")){let n=new I,o=new URLSearchParams(await this.text());for(let[s,i]of o)n.append(s,i);return n}let{toFormData:t}=await import("./multipart-parser-UVM6CEKF.js");return t(this.body,e)}async blob(){let e=this.headers&&this.headers.get("content-type")||this[m].body&&this[m].body.type||"",t=await this.arrayBuffer();return new j([t],{type:e})}async json(){let e=await this.text();return JSON.parse(e)}async text(){let e=await re(this);return new TextDecoder().decode(e)}buffer(){return re(this)}};E.prototype.buffer=te(E.prototype.buffer,"Please use 'response.arrayBuffer()' instead of 'response.buffer()'","node-fetch#buffer");Object.defineProperties(E.prototype,{body:{enumerable:!0},bodyUsed:{enumerable:!0},arrayBuffer:{enumerable:!0},blob:{enumerable:!0},json:{enumerable:!0},text:{enumerable:!0},data:{get:te(()=>{},"data doesn't exist, use json(), text(), arrayBuffer(), or body instead","https://github.com/node-fetch/node-fetch/issues/1000 (response)")}});F=(r,e)=>{let t,n,{body:o}=r[m];if(r.bodyUsed)throw new Error("cannot clone body after it is used");return o instanceof v&&typeof o.getBoundary!="function"&&(t=new pe({highWaterMark:e}),n=new pe({highWaterMark:e}),o.pipe(t),o.pipe(n),r[m].stream=t,o=n),o},Je=te(r=>r.getBoundary(),"form-data doesn't follow the spec and requires special treatment. Use alternative package","https://github.com/node-fetch/node-fetch/issues/1167"),G=(r,e)=>r===null?null:typeof r=="string"?"text/plain;charset=UTF-8":ee(r)?"application/x-www-form-urlencoded;charset=UTF-8":z(r)?r.type||null:b.isBuffer(r)||me.isAnyArrayBuffer(r)||ArrayBuffer.isView(r)?null:r instanceof I?`multipart/form-data; boundary=${e[m].boundary}`:r&&typeof r.getBoundary=="function"?`multipart/form-data;boundary=${Je(r)}`:r instanceof v?null:"text/plain;charset=UTF-8",ye=r=>{let{body:e}=r[m];return e===null?0:z(e)?e.size:b.isBuffer(e)?e.length:e&&typeof e.getLengthSync=="function"&&e.hasKnownLength&&e.hasKnownLength()?e.getLengthSync():null},ge=async(r,{body:e})=>{e===null?r.end():await Ye(e,r)}});import{types as we}from"node:util";import J from"node:http";function be(r=[]){return new g(r.reduce((e,t,n,o)=>(n%2===0&&e.push(o.slice(n,n+2)),e),[]).filter(([e,t])=>{try{return Y(e),oe(e,String(t)),!0}catch{return!1}}))}var Y,oe,g,_=y(()=>{Y=typeof J.validateHeaderName=="function"?J.validateHeaderName:r=>{if(!/^[\^`\-\w!#$%&'*+.|~]+$/.test(r)){let e=new TypeError(`Header name must be a valid HTTP token [${r}]`);throw Object.defineProperty(e,"code",{value:"ERR_INVALID_HTTP_TOKEN"}),e}},oe=typeof J.validateHeaderValue=="function"?J.validateHeaderValue:(r,e)=>{if(/[^\t\u0020-\u007E\u0080-\u00FF]/.test(e)){let t=new TypeError(`Invalid character in header content ["${r}"]`);throw Object.defineProperty(t,"code",{value:"ERR_INVALID_CHAR"}),t}},g=class r extends URLSearchParams{constructor(e){let t=[];if(e instanceof r){let n=e.raw();for(let[o,s]of Object.entries(n))t.push(...s.map(i=>[o,i]))}else if(e!=null)if(typeof e=="object"&&!we.isBoxedPrimitive(e)){let n=e[Symbol.iterator];if(n==null)t.push(...Object.entries(e));else{if(typeof n!="function")throw new TypeError("Header pairs must be iterable");t=[...e].map(o=>{if(typeof o!="object"||we.isBoxedPrimitive(o))throw new TypeError("Each header pair must be an iterable object");return[...o]}).map(o=>{if(o.length!==2)throw new TypeError("Each header pair must be a name/value tuple");return[...o]})}}else throw new TypeError("Failed to construct 'Headers': The provided value is not of type '(sequence<sequence<ByteString>> or record<ByteString, ByteString>)");return t=t.length>0?t.map(([n,o])=>(Y(n),oe(n,String(o)),[String(n).toLowerCase(),String(o)])):void 0,super(t),new Proxy(this,{get(n,o,s){switch(o){case"append":case"set":return(i,c)=>(Y(i),oe(i,String(c)),URLSearchParams.prototype[o].call(n,String(i).toLowerCase(),String(c)));case"delete":case"has":case"getAll":return i=>(Y(i),URLSearchParams.prototype[o].call(n,String(i).toLowerCase()));case"keys":return()=>(n.sort(),new Set(URLSearchParams.prototype.keys.call(n)).keys());default:return Reflect.get(n,o,s)}}})}get[Symbol.toStringTag](){return this.constructor.name}toString(){return Object.prototype.toString.call(this)}get(e){let t=this.getAll(e);if(t.length===0)return null;let n=t.join(", ");return/^content-encoding$/i.test(e)&&(n=n.toLowerCase()),n}forEach(e,t=void 0){for(let n of this.keys())Reflect.apply(e,t,[this.get(n),n,this])}*values(){for(let e of this.keys())yield this.get(e)}*entries(){for(let e of this.keys())yield[e,this.get(e)]}[Symbol.iterator](){return this.entries()}raw(){return[...this.keys()].reduce((e,t)=>(e[t]=this.getAll(t),e),{})}[Symbol.for("nodejs.util.inspect.custom")](){return[...this.keys()].reduce((e,t)=>{let n=this.getAll(t);return t==="host"?e[t]=n[0]:e[t]=n.length>1?n:n[0],e},{})}};Object.defineProperties(g.prototype,["get","entries","forEach","values"].reduce((r,e)=>(r[e]={enumerable:!0},r),{}))});var _e,Z,ne=y(()=>{_e=new Set([301,302,303,307,308]),Z=r=>_e.has(r)});var T,S,Se=y(()=>{_();K();ne();T=Symbol("Response internals"),S=class r extends E{constructor(e=null,t={}){super(e,t);let n=t.status!=null?t.status:200,o=new g(t.headers);if(e!==null&&!o.has("Content-Type")){let s=G(e,this);s&&o.append("Content-Type",s)}this[T]={type:"default",url:t.url,status:n,statusText:t.statusText||"",headers:o,counter:t.counter,highWaterMark:t.highWaterMark}}get type(){return this[T].type}get url(){return this[T].url||""}get status(){return this[T].status}get ok(){return this[T].status>=200&&this[T].status<300}get redirected(){return this[T].counter>0}get statusText(){return this[T].statusText}get headers(){return this[T].headers}get highWaterMark(){return this[T].highWaterMark}clone(){return new r(F(this,this.highWaterMark),{type:this.type,url:this.url,status:this.status,statusText:this.statusText,headers:this.headers,ok:this.ok,redirected:this.redirected,size:this.size,highWaterMark:this.highWaterMark})}static redirect(e,t=302){if(!Z(t))throw new RangeError('Failed to execute "redirect" on "response": Invalid status code');return new r(null,{headers:{location:new URL(e).toString()},status:t})}static error(){let e=new r(null,{status:0,statusText:""});return e[T].type="error",e}static json(e=void 0,t={}){let n=JSON.stringify(e);if(n===void 0)throw new TypeError("data is not JSON serializable");let o=new g(t&&t.headers);return o.has("content-type")||o.set("content-type","application/json"),new r(n,{...t,headers:o})}get[Symbol.toStringTag](){return"Response"}};Object.defineProperties(S.prototype,{type:{enumerable:!0},url:{enumerable:!0},status:{enumerable:!0},ok:{enumerable:!0},redirected:{enumerable:!0},statusText:{enumerable:!0},headers:{enumerable:!0},clone:{enumerable:!0}})});var Te,Re=y(()=>{Te=r=>{if(r.search)return r.search;let e=r.href.length-1,t=r.hash||(r.href[e]==="#"?"#":"");return r.href[e-t.length]==="?"?"?":""}});import{isIP as Ze}from"node:net";function xe(r,e=!1){return r==null||(r=new URL(r),/^(about|blob|data):$/.test(r.protocol))?"no-referrer":(r.username="",r.password="",r.hash="",e&&(r.pathname="",r.search=""),r)}function Le(r){if(!Ee.has(r))throw new TypeError(`Invalid referrerPolicy: ${r}`);return r}function Qe(r){if(/^(http|ws)s:$/.test(r.protocol))return!0;let e=r.host.replace(/(^\[)|(]$)/g,""),t=Ze(e);return t===4&&/^127\./.test(e)||t===6&&/^(((0+:){7})|(::(0+:){0,6}))0*1$/.test(e)?!0:r.host==="localhost"||r.host.endsWith(".localhost")?!1:r.protocol==="file:"}function k(r){return/^about:(blank|srcdoc)$/.test(r)||r.protocol==="data:"||/^(blob|filesystem):$/.test(r.protocol)?!0:Qe(r)}function Ue(r,{referrerURLCallback:e,referrerOriginCallback:t}={}){if(r.referrer==="no-referrer"||r.referrerPolicy==="")return null;let n=r.referrerPolicy;if(r.referrer==="about:client")return"no-referrer";let o=r.referrer,s=xe(o),i=xe(o,!0);s.toString().length>4096&&(s=i),e&&(s=e(s)),t&&(i=t(i));let c=new URL(r.url);switch(n){case"no-referrer":return"no-referrer";case"origin":return i;case"unsafe-url":return s;case"strict-origin":return k(s)&&!k(c)?"no-referrer":i.toString();case"strict-origin-when-cross-origin":return s.origin===c.origin?s:k(s)&&!k(c)?"no-referrer":i;case"same-origin":return s.origin===c.origin?s:"no-referrer";case"origin-when-cross-origin":return s.origin===c.origin?s:i;case"no-referrer-when-downgrade":return k(s)&&!k(c)?"no-referrer":s;default:throw new TypeError(`Invalid referrerPolicy: ${n}`)}}function ve(r){let e=(r.get("referrer-policy")||"").split(/[,\s]+/),t="";for(let n of e)n&&Ee.has(n)&&(t=n);return t}var Ee,Pe,se=y(()=>{Ee=new Set(["","no-referrer","no-referrer-when-downgrade","same-origin","origin","strict-origin","origin-when-cross-origin","strict-origin-when-cross-origin","unsafe-url"]),Pe="strict-origin-when-cross-origin"});import{format as Xe}from"node:url";import{deprecate as je}from"node:util";var u,N,qe,C,Be,Ae=y(()=>{_();K();V();Re();se();u=Symbol("Request internals"),N=r=>typeof r=="object"&&typeof r[u]=="object",qe=je(()=>{},".data is not a valid RequestInit property, use .body instead","https://github.com/node-fetch/node-fetch/issues/1000 (request)"),C=class r extends E{constructor(e,t={}){let n;if(N(e)?n=new URL(e.url):(n=new URL(e),e={}),n.username!==""||n.password!=="")throw new TypeError(`${n} is an url with embedded credentials.`);let o=t.method||e.method||"GET";if(/^(delete|get|head|options|post|put)$/i.test(o)&&(o=o.toUpperCase()),!N(t)&&"data"in t&&qe(),(t.body!=null||N(e)&&e.body!==null)&&(o==="GET"||o==="HEAD"))throw new TypeError("Request with GET/HEAD method cannot have body");let s=t.body?t.body:N(e)&&e.body!==null?F(e):null;super(s,{size:t.size||e.size||0});let i=new g(t.headers||e.headers||{});if(s!==null&&!i.has("Content-Type")){let a=G(s,this);a&&i.set("Content-Type",a)}let c=N(e)?e.signal:null;if("signal"in t&&(c=t.signal),c!=null&&!ue(c))throw new TypeError("Expected signal to be an instanceof AbortSignal or EventTarget");let l=t.referrer==null?e.referrer:t.referrer;if(l==="")l="no-referrer";else if(l){let a=new URL(l);l=/^about:(\/\/)?client$/.test(a)?"client":a}else l=void 0;this[u]={method:o,redirect:t.redirect||e.redirect||"follow",headers:i,parsedURL:n,signal:c,referrer:l},this.follow=t.follow===void 0?e.follow===void 0?20:e.follow:t.follow,this.compress=t.compress===void 0?e.compress===void 0?!0:e.compress:t.compress,this.counter=t.counter||e.counter||0,this.agent=t.agent||e.agent,this.highWaterMark=t.highWaterMark||e.highWaterMark||16384,this.insecureHTTPParser=t.insecureHTTPParser||e.insecureHTTPParser||!1,this.referrerPolicy=t.referrerPolicy||e.referrerPolicy||""}get method(){return this[u].method}get url(){return Xe(this[u].parsedURL)}get headers(){return this[u].headers}get redirect(){return this[u].redirect}get signal(){return this[u].signal}get referrer(){if(this[u].referrer==="no-referrer")return"";if(this[u].referrer==="client")return"about:client";if(this[u].referrer)return this[u].referrer.toString()}get referrerPolicy(){return this[u].referrerPolicy}set referrerPolicy(e){this[u].referrerPolicy=Le(e)}clone(){return new r(this)}get[Symbol.toStringTag](){return"Request"}};Object.defineProperties(C.prototype,{method:{enumerable:!0},url:{enumerable:!0},headers:{enumerable:!0},redirect:{enumerable:!0},clone:{enumerable:!0},signal:{enumerable:!0},referrer:{enumerable:!0},referrerPolicy:{enumerable:!0}});Be=r=>{let{parsedURL:e}=r[u],t=new g(r[u].headers);t.has("Accept")||t.set("Accept","*/*");let n=null;if(r.body===null&&/^(post|put)$/i.test(r.method)&&(n="0"),r.body!==null){let c=ye(r);typeof c=="number"&&!Number.isNaN(c)&&(n=String(c))}n&&t.set("Content-Length",n),r.referrerPolicy===""&&(r.referrerPolicy=Pe),r.referrer&&r.referrer!=="no-referrer"?r[u].referrer=Ue(r):r[u].referrer="no-referrer",r[u].referrer instanceof URL&&t.set("Referer",r.referrer),t.has("User-Agent")||t.set("User-Agent","node-fetch"),r.compress&&!t.has("Accept-Encoding")&&t.set("Accept-Encoding","gzip, deflate, br");let{agent:o}=r;typeof o=="function"&&(o=o(e));let s=Te(e),i={path:e.pathname+s,method:r.method,headers:t[Symbol.for("nodejs.util.inspect.custom")](),insecureHTTPParser:r.insecureHTTPParser,agent:o};return{parsedURL:e,options:i}}});var Q,Ce=y(()=>{M();Q=class extends U{constructor(e,t="aborted"){super(e,t)}}});import er from"node:http";import rr from"node:https";import O from"node:zlib";import $e,{PassThrough as Fe,pipeline as H}from"node:stream";import{Buffer as X}from"node:buffer";async function ke(r,e){return new Promise((t,n)=>{let o=new C(r,e),{parsedURL:s,options:i}=Be(o);if(!tr.has(s.protocol))throw new TypeError(`node-fetch cannot load ${r}. URL scheme "${s.protocol.replace(/:$/,"")}" is not supported.`);if(s.protocol==="data:"){let f=ce(o.url),P=new S(f,{headers:{"Content-Type":f.typeFull}});t(P);return}let c=(s.protocol==="https:"?rr:er).request,{signal:l}=o,a=null,R=()=>{let f=new Q("The operation was aborted.");n(f),o.body&&o.body instanceof $e.Readable&&o.body.destroy(f),!(!a||!a.body)&&a.body.emit("error",f)};if(l&&l.aborted){R();return}let D=()=>{R(),A()},B=c(s.toString(),i);l&&l.addEventListener("abort",D);let A=()=>{B.abort(),l&&l.removeEventListener("abort",D)};B.on("error",f=>{n(new p(`request to ${o.url} failed, reason: ${f.message}`,"system",f)),A()}),or(B,f=>{a&&a.body&&a.body.destroy(f)}),process.version<"v14"&&B.on("socket",f=>{let P;f.prependListener("end",()=>{P=f._eventsCount}),f.prependListener("close",h=>{if(a&&P<f._eventsCount&&!h){let L=new Error("Premature close");L.code="ERR_STREAM_PREMATURE_CLOSE",a.body.emit("error",L)}})}),B.on("response",f=>{B.setTimeout(0);let P=be(f.rawHeaders);if(Z(f.statusCode)){let d=P.get("Location"),x=null;try{x=d===null?null:new URL(d,o.url)}catch{if(o.redirect!=="manual"){n(new p(`uri requested responds with an invalid redirect URL: ${d}`,"invalid-redirect")),A();return}}switch(o.redirect){case"error":n(new p(`uri requested responds with a redirect, redirect mode is set to error: ${o.url}`,"no-redirect")),A();return;case"manual":break;case"follow":{if(x===null)break;if(o.counter>=o.follow){n(new p(`maximum redirect reached at: ${o.url}`,"max-redirect")),A();return}let w={headers:new g(o.headers),follow:o.follow,counter:o.counter+1,agent:o.agent,compress:o.compress,method:o.method,body:F(o),signal:o.signal,size:o.size,referrer:o.referrer,referrerPolicy:o.referrerPolicy};if(!he(o.url,x)||!de(o.url,x))for(let He of["authorization","www-authenticate","cookie","cookie2"])w.headers.delete(He);if(f.statusCode!==303&&o.body&&e.body instanceof $e.Readable){n(new p("Cannot follow redirect with body being a readable stream","unsupported-redirect")),A();return}(f.statusCode===303||(f.statusCode===301||f.statusCode===302)&&o.method==="POST")&&(w.method="GET",w.body=void 0,w.headers.delete("content-length"));let ie=ve(P);ie&&(w.referrerPolicy=ie),t(ke(new C(x,w))),A();return}default:return n(new TypeError(`Redirect option '${o.redirect}' is not a valid value of RequestRedirect`))}}l&&f.once("end",()=>{l.removeEventListener("abort",D)});let h=H(f,new Fe,d=>{d&&n(d)});process.version<"v12.10"&&f.on("aborted",D);let L={url:o.url,status:f.statusCode,statusText:f.statusMessage,headers:P,size:o.size,counter:o.counter,highWaterMark:o.highWaterMark},$=P.get("Content-Encoding");if(!o.compress||o.method==="HEAD"||$===null||f.statusCode===204||f.statusCode===304){a=new S(h,L),t(a);return}let Oe={flush:O.Z_SYNC_FLUSH,finishFlush:O.Z_SYNC_FLUSH};if($==="gzip"||$==="x-gzip"){h=H(h,O.createGunzip(Oe),d=>{d&&n(d)}),a=new S(h,L),t(a);return}if($==="deflate"||$==="x-deflate"){let d=H(f,new Fe,x=>{x&&n(x)});d.once("data",x=>{(x[0]&15)===8?h=H(h,O.createInflate(),w=>{w&&n(w)}):h=H(h,O.createInflateRaw(),w=>{w&&n(w)}),a=new S(h,L),t(a)}),d.once("end",()=>{a||(a=new S(h,L),t(a))});return}if($==="br"){h=H(h,O.createBrotliDecompress(),d=>{d&&n(d)}),a=new S(h,L),t(a);return}a=new S(h,L),t(a)}),ge(B,o).catch(n)})}function or(r,e){let t=X.from(`0\r
|
|
2
|
+
\r
|
|
3
|
+
`),n=!1,o=!1,s;r.on("response",i=>{let{headers:c}=i;n=c["transfer-encoding"]==="chunked"&&!c["content-length"]}),r.on("socket",i=>{let c=()=>{if(n&&!o){let a=new Error("Premature close");a.code="ERR_STREAM_PREMATURE_CLOSE",e(a)}},l=a=>{o=X.compare(a.slice(-5),t)===0,!o&&s&&(o=X.compare(s.slice(-3),t.slice(0,3))===0&&X.compare(a.slice(-2),t.slice(3))===0),s=a};i.prependListener("close",c),i.on("data",l),r.on("close",()=>{i.removeListener("close",c),i.removeListener("data",l)})})}var tr,nr=y(()=>{le();K();Se();_();Ae();q();Ce();ne();fe();V();se();Ve();tr=new Set(["data:","http:","https:"])});nr();export{Q as AbortError,j as Blob,p as FetchError,ze as File,I as FormData,g as Headers,C as Request,S as Response,De as blobFrom,Ne as blobFromSync,ke as default,Me as fileFrom,We as fileFromSync,Z as isRedirect};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as f,d as S}from"./chunk-4XOSXARZ.js";import"./chunk-2WH262CW.js";import{a as k}from"./chunk-XADY6SXR.js";import{a as v,d as w}from"./chunk-TJZAIUKM.js";import{c as h}from"./chunk-YK6UG66R.js";import{f as y,g as I,m as D,q as O,t as R}from"./chunk-EMHZF6ZY.js";import{c as i,d as r,f as c,g as b,h as p,k as x,o as d,q as m,r as u}from"./chunk-Y6AFIAJP.js";import{a as l,b as E}from"./chunk-2N4GTHXQ.js";import{b as C}from"./chunk-MNEZ5QGX.js";import"./chunk-DHMCIRLT.js";import"./chunk-4BH6CF3J.js";import"./chunk-OTRBRRIO.js";var L=async g=>{let n=C.process.cwd(),o=v(g);if(!await R(n)){if(o==="json")await w({error:"noskills is not initialized"},o);else{let s=d({renderer:u.ansi(),sink:m.stdout()});s.writeln(c("noskills is not initialized.")," Run: ",i(h("init"))),await s.close()}return E({exitCode:1})}let P=I(g),e=await y(n,P),t=await D(n),V={phase:e.phase,spec:e.spec,branch:e.branch,discovery:e.phase==="DISCOVERY"||e.phase==="DISCOVERY_REVIEW"?{answered:e.discovery.answers.length,total:f.length}:void 0,execution:e.phase==="EXECUTING"||e.phase==="BLOCKED"?{iteration:e.execution.iteration,lastProgress:e.execution.lastProgress,debt:e.execution.debt?.items.length??0,verificationPassed:e.execution.lastVerification?.passed??null}:void 0,concerns:t?.concerns??[],tools:t?.tools??[],decisions:e.decisions.length};if(o==="json"){let a=(await O(n)).filter(F=>t!==null&&t.concerns.includes(F.id)),$=await k(n),j=S(e,a,$,t);return await w({...V,...j},"json"),l(void 0)}{let s=d({renderer:u.ansi(),sink:m.stdout()});s.writeln(i(`${h("status")}`)),s.writeln("");let a=e.phase==="DONE"?b(e.phase):e.phase==="BLOCKED"?c(e.phase):e.phase==="EXECUTING"?x(e.phase):p(e.phase);s.writeln(" Phase: ",a),e.spec!==null&&s.writeln(" Spec: ",i(e.spec)),e.branch!==null&&s.writeln(" Branch: ",e.branch),(e.phase==="DISCOVERY"||e.phase==="DISCOVERY_REVIEW")&&s.writeln(` Discovery: ${e.discovery.answers.length}/${f.length} questions answered`),e.phase==="EXECUTING"&&(s.writeln(` Iteration: ${e.execution.iteration}`),e.execution.lastProgress!==null&&s.writeln(" Progress: ",r(e.execution.lastProgress)),e.execution.debt!==null&&s.writeln(p(` Debt: ${e.execution.debt.items.length} items`))),t!==null&&(s.writeln(""),t.concerns.length>0&&s.writeln(" Concerns: ",r(t.concerns.join(", "))),t.tools.length>0&&s.writeln(" Tools: ",r(t.tools.join(", ")))),e.decisions.length>0&&(s.writeln(""),s.writeln(` Decisions: ${e.decisions.length}`)),await s.close()}return l(void 0)};export{L as main};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as w}from"./chunk-XADY6SXR.js";import{c as g}from"./chunk-YK6UG66R.js";import{m as u}from"./chunk-EMHZF6ZY.js";import{c as m,d as r,f as c,g as n,o as p,q as d,r as f}from"./chunk-Y6AFIAJP.js";import{a as o,b as a}from"./chunk-2N4GTHXQ.js";import{b as l}from"./chunk-MNEZ5QGX.js";import"./chunk-DHMCIRLT.js";import"./chunk-4BH6CF3J.js";import"./chunk-OTRBRRIO.js";var v=async h=>{let s=p({renderer:f.ansi(),sink:d.stdout()}),t=l.process.cwd(),e=await u(t);if(e===null)return s.writeln(c("noskills is not initialized.")," Run: ",m(g("init"))),await s.close(),a({exitCode:1});s.writeln(r("Syncing tool files..."));let i=await w(t,e.tools,e);for(let y of i)s.writeln(" ",n("\u2714"),` ${y}`);return i.length===0&&s.writeln(r(" No tools configured.")),s.writeln(""),s.writeln(n("Done.")),await s.close(),o(void 0)};export{v as main};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-
|
|
1
|
+
import"./chunk-OTRBRRIO.js";var r=globalThis.navigator?.userAgent?.includes("Deno");function s(){return globalThis.process.getBuiltinModule("node:fs")}var c=r?Deno.errors.AlreadyExists:class extends Error{},d=r?Deno.errors.BadResource:class extends Error{},E=r?Deno.errors.BrokenPipe:class extends Error{},y=r?Deno.errors.Busy:class extends Error{},B=r?Deno.errors.Interrupted:class extends Error{},T=r?Deno.errors.InvalidData:class extends Error{},a=r?Deno.errors.NotFound:class extends Error{},P=r?Deno.errors.PermissionDenied:class extends Error{},F=r?Deno.errors.TimedOut:class extends Error{},S=r?Deno.errors.UnexpectedEof:class extends Error{},O=r?Deno.errors.WriteZero:class extends Error{};function n(e){return o=>Object.assign(new e(o.message),{stack:o.stack})}var l={EEXIST:n(c),ENOENT:n(a),EBADF:n(d)};function p(e){return e instanceof Error&&"code"in e}function i(e){return p(e)&&l[e.code]?.(e)||e}async function W(e,o){if(r)await Deno.chmod(e,o);else try{await s().promises.chmod(e,o)}catch(t){throw i(t)}}function Z(e,o){if(r)Deno.chmodSync(e,o);else try{s().chmodSync(e,o)}catch(t){throw i(t)}}export{W as chmod,Z as chmodSync};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as y,b as h,c as k,d as T}from"./chunk-SWYX6WYQ.js";import"./chunk-5MN3MWQN.js";import{a as m,e as p}from"./chunk-OLM5RTFK.js";import"./chunk-
|
|
1
|
+
import{a as y,b as h,c as k,d as T}from"./chunk-SWYX6WYQ.js";import"./chunk-5MN3MWQN.js";import{a as m,e as p}from"./chunk-OLM5RTFK.js";import"./chunk-OTRBRRIO.js";var c=class{capabilities=["text_generation","streaming","tool_calling","vision","audio","structured_output","reasoning"];provider="vertexai";modelId;client;config;constructor(e,t){this.client=e,this.config=t,this.modelId=t.model}async generateText(e,t){let r=x(this.config,e);try{let o=await this.client.models.generateContent({model:this.config.model,...r,config:{...r.config,httpOptions:t!==void 0?{signal:t}:void 0}});return k(o,this.modelId)}catch(o){throw v(o)}}async*streamText(e,t){let r=x(this.config,e);try{let o=await this.client.models.generateContentStream({model:this.config.model,...r,config:{...r.config,httpOptions:t!==void 0?{signal:t}:void 0}}),a=0,s=0;for await(let l of o){let g=l?.candidates??[];if(g.length>0){let f=g[0],C=f?.content?.parts??[];for(let i of C)i.text!==void 0&&(yield{kind:"content_delta",textDelta:i.text}),i.functionCall!==void 0&&(yield{kind:"tool_call_delta",toolCall:{id:i.functionCall.name,name:i.functionCall.name,arguments:i.functionCall.args??{}}});let d=f?.finishReason;if(d!=null){let i=l?.usageMetadata;a=i?.promptTokenCount??a,s=i?.candidatesTokenCount??s;let u="end_turn";d==="MAX_TOKENS"&&(u="max_tokens"),yield{kind:"message_done",stopReason:u,usage:{inputTokens:a,outputTokens:s,totalTokens:a+s}}}}}}catch(o){yield{kind:"error",error:v(o)}}}async close(){}getRawClient(){return this.client}},w={provider:"vertexai",async createModel(n){let{GoogleGenAI:e}=await import("./node-3FTYLC7H.js"),t={vertexai:!0,project:n.projectId,location:n.location??"us-central1"};n.apiKey!==void 0&&(t.apiKey=n.apiKey);let r=new e(t);return new c(r,n)}},x=(n,e)=>{let{contents:t,systemInstruction:r}=y(e.messages),o={maxOutputTokens:e.maxTokens??n.maxTokens};e.temperature!==void 0&&(o.temperature=e.temperature),e.topP!==void 0&&(o.topP=e.topP),e.stopWords!==void 0&&(o.stopSequences=e.stopWords),e.responseFormat!==void 0&&e.responseFormat.type==="json_schema"&&(o.responseMimeType="application/json",o.responseSchema=e.responseFormat.jsonSchema),e.thinkingBudget!==void 0&&(o.thinkingConfig={thinkingBudget:e.thinkingBudget});let a={contents:t,config:o},s=e.system??r;return s!=null&&(a.systemInstruction=s),e.tools!==void 0&&(a.tools=h(e.tools)),e.safetySettings!==void 0&&(a.safetySettings=e.safetySettings),a},v=n=>{if(n instanceof m)return n;let e=n instanceof Error?n:new Error(String(n)),t=T(n);return p("vertexai",t,e)};export{c as VertexAIModel,w as vertexaiFactory};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{a as C,c as E}from"./chunk-TJZAIUKM.js";import{a as M,c as S}from"./chunk-VPXOI7CR.js";import{e as T,m as y,t as b}from"./chunk-EMHZF6ZY.js";import{a as x,b as k}from"./chunk-2N4GTHXQ.js";import{b as m}from"./chunk-MNEZ5QGX.js";import"./chunk-DHMCIRLT.js";import"./chunk-4BH6CF3J.js";import"./chunk-OTRBRRIO.js";var D=async e=>{let s=await T(e),l=await y(e),d=await I(e),o=null,h=null,a=0,c=0;if(s.spec!==null){let i=await M(e,s.spec);if(i!==null){a=i.tasks.length,c=s.execution.completedTasks.length;let n=S(i.tasks,s.execution.completedTasks);n!==null&&(o=n.id,h=n.title)}}let $=null;return s.lastCalledAt!==null&&($=Math.floor((Date.now()-new Date(s.lastCalledAt).getTime())/1e3)),{spec:s.spec,phase:s.phase,iteration:s.execution.iteration,activeTaskId:o,activeTaskTitle:h,totalTasks:a,completedTaskCount:c,lastProgress:s.execution.lastProgress,lastCalledAt:s.lastCalledAt,modifiedFiles:s.execution.modifiedFiles,debt:s.execution.debt,concerns:l?.concerns??[],maxIterations:l?.maxIterationsBeforeRestart??15,awaitingStatusReport:s.execution.awaitingStatusReport,verificationPassed:s.execution.lastVerification?.passed??null,decisionsCount:s.decisions.length,discoveryAnswered:s.discovery.answers.length,discoveryTotal:6,trackedFiles:d,timeSinceUpdate:$}},I=async e=>{let s=`${e}/.eser/.state/files-changed.jsonl`;try{let d=(await m.fs.readTextFile(s)).trim().split(`
|
|
2
|
+
`).filter(Boolean),o=[];for(let h of d)try{let a=JSON.parse(h);o.includes(a.file)||o.push(a.file)}catch{}return o}catch{return[]}},L="\x1B[2J\x1B[H",F="\x1B[1m",r="\x1B[2m",t="\x1B[0m",p="\x1B[32m",f="\x1B[33m",w="\x1B[31m",P="\x1B[36m",O=e=>{switch(e){case"DONE":return p;case"BLOCKED":return w;case"EXECUTING":return P;default:return f}},R=(e,s,l)=>{if(s===0)return"\u2591".repeat(l);let d=Math.min(e/s,1),o=Math.round(d*l);return"\u2588".repeat(o)+"\u2591".repeat(l-o)},v=e=>e===null?"never":e<60?`${e}s ago`:e<3600?`${Math.floor(e/60)}m ago`:`${Math.floor(e/3600)}h ago`,A=e=>{let s=[],d="\u2500".repeat(52);s.push(`${r}\u256D${d}\u256E${t}`),s.push(`${r}\u2502${t} ${F}noskills watch${t} \u2014 ${e.spec??"no active spec"}${r}${" ".repeat(Math.max(0,34-(e.spec?.length??15)))}\u2502${t}`);let o=O(e.phase);if(s.push(`${r}\u2502${t} Phase: ${o}${e.phase}${t}${" ".repeat(Math.max(0,42-e.phase.length))}${r}\u2502${t}`),e.phase==="DISCOVERY"||e.phase==="DISCOVERY_REVIEW")s.push(`${r}\u2502${t} Discovery: ${e.discoveryAnswered}/${e.discoveryTotal} questions answered${" ".repeat(Math.max(0,14))}${r}\u2502${t}`);else if(e.phase==="SPEC_DRAFT")s.push(`${r}\u2502${t} ${f}Awaiting approval${t}${" ".repeat(Math.max(0,33))}${r}\u2502${t}`);else if(e.phase==="EXECUTING"||e.phase==="BLOCKED"){let a=R(e.completedTaskCount,e.totalTasks,12),c=e.totalTasks>0?Math.round(e.completedTaskCount/e.totalTasks*100):0,$=`${a} ${e.completedTaskCount}/${e.totalTasks} tasks (${c}%)`;if(s.push(`${r}\u2502${t} Progress: ${p}${$}${t}${" ".repeat(Math.max(0,40-$.length))}${r}\u2502${t}`),s.push(`${r}\u2502${t} Iteration: ${e.iteration}${" ".repeat(Math.max(0,38-String(e.iteration).length))}${r}\u2502${t}`),e.activeTaskId!==null){let n=`${e.activeTaskId}${e.activeTaskTitle!==null?` (${e.activeTaskTitle})`:""}`.slice(0,36);s.push(`${r}\u2502${t} Active task: ${P}${n}${t}${" ".repeat(Math.max(0,36-n.length))}${r}\u2502${t}`)}if(e.phase==="BLOCKED"){let i=(e.lastProgress??"unknown").replace(/^BLOCKED:\s*/,"");s.push(`${r}\u2502${t} ${w}BLOCKED: ${i.slice(0,40)}${t}${" ".repeat(Math.max(0,40-i.slice(0,40).length))}${r}\u2502${t}`),s.push(`${r}\u2502${t} ${f}Human input needed${t}${" ".repeat(Math.max(0,32))}${r}\u2502${t}`)}}else e.phase==="DONE"&&s.push(`${r}\u2502${t} ${p}Complete!${t} ${e.iteration} iterations, ${e.decisionsCount} decisions${" ".repeat(Math.max(0,17-String(e.iteration).length-String(e.decisionsCount).length))}${r}\u2502${t}`);if(s.push(`${r}\u2502${"".padEnd(52)}\u2502${t}`),s.push(`${r}\u2502${t} Last update: ${v(e.timeSinceUpdate)}${" ".repeat(Math.max(0,36-v(e.timeSinceUpdate).length))}${r}\u2502${t}`),e.lastProgress!==null){let a=e.lastProgress.slice(0,48);s.push(`${r}\u2502${t} ${r}${a}${t}${" ".repeat(Math.max(0,50-a.length))}${r}\u2502${t}`)}if(e.awaitingStatusReport&&s.push(`${r}\u2502${t} ${f}Status report pending${t}${" ".repeat(Math.max(0,29))}${r}\u2502${t}`),e.verificationPassed===!1&&s.push(`${r}\u2502${t} ${w}Verification failed${t}${" ".repeat(Math.max(0,31))}${r}\u2502${t}`),s.push(`${r}\u2502${"".padEnd(52)}\u2502${t}`),e.debt!==null&&e.debt.items.length>0){s.push(`${r}\u2502${t} Debt: ${e.debt.items.length} item(s)${" ".repeat(Math.max(0,34))}${r}\u2502${t}`);for(let a of e.debt.items.slice(0,3)){let c=a.text.slice(0,44);s.push(`${r}\u2502${t} \u2514\u2500 ${c}${" ".repeat(Math.max(0,46-c.length))}${r}\u2502${t}`)}e.debt.items.length>3&&s.push(`${r}\u2502${t} \u2514\u2500 ... and ${e.debt.items.length-3} more${" ".repeat(Math.max(0,32))}${r}\u2502${t}`)}if(e.trackedFiles.length>0||e.modifiedFiles.length>0){let a=e.trackedFiles.length>0?e.trackedFiles:e.modifiedFiles;s.push(`${r}\u2502${t} Files changed: ${a.length}${" ".repeat(Math.max(0,34-String(a.length).length))}${r}\u2502${t}`);for(let c of a.slice(0,5)){let $=c.length>44?"..."+c.slice(-41):c;s.push(`${r}\u2502${t} \u2514\u2500 ${$}${" ".repeat(Math.max(0,46-$.length))}${r}\u2502${t}`)}a.length>5&&s.push(`${r}\u2502${t} \u2514\u2500 ... and ${a.length-5} more${" ".repeat(Math.max(0,32))}${r}\u2502${t}`)}if(s.push(`${r}\u2502${"".padEnd(52)}\u2502${t}`),e.concerns.length>0){let a=e.concerns.join(", ").slice(0,38);s.push(`${r}\u2502${t} Concerns: ${a}${" ".repeat(Math.max(0,40-a.length))}${r}\u2502${t}`)}let h=e.iteration>=e.maxIterations?`${w}RESTART RECOMMENDED${t}`:`${p}ok${t} (${e.iteration}/${e.maxIterations})`;return s.push(`${r}\u2502${t} Context: ${h}${" ".repeat(Math.max(0,41-h.replace(/\x1b\[[0-9;]*m/g,"").length))}${r}\u2502${t}`),s.push(`${r}\u2570${d}\u256F${t}`),s.push(` ${r}watching .eser/.state/ for changes... (ctrl+c to stop)${t}`),s.join(`
|
|
3
|
+
`)},W=e=>JSON.stringify({ts:new Date().toISOString(),phase:e.phase,spec:e.spec,iteration:e.iteration,activeTask:e.activeTaskId,tasks:{completed:e.completedTaskCount,total:e.totalTasks},progress:e.lastProgress,debt:e.debt?.items.length??0,filesChanged:e.trackedFiles.length>0?e.trackedFiles:e.modifiedFiles,timeSinceUpdate:e.timeSinceUpdate,verificationPassed:e.verificationPassed}),V=async e=>{let s=m.process.cwd(),l=C(e);if(!await b(s)){let i=new TextEncoder,n=m.process.stdout.getWriter();return await n.write(i.encode(`noskills not initialized.
|
|
4
|
+
`)),n.releaseLock(),k({exitCode:1})}let d=`${s}/.eser/.state`,o="",h=async()=>{let i=await D(s),n=l==="json"?W(i):l==="markdown"?E(i,"markdown"):A(i);if(l==="json"){let g=new TextEncoder,u=m.process.stdout.getWriter();await u.write(g.encode(n+`
|
|
5
|
+
`)),u.releaseLock()}else if(l==="markdown"){let g=new TextEncoder,u=m.process.stdout.getWriter();await u.write(g.encode(n+`
|
|
6
|
+
---
|
|
7
|
+
`)),u.releaseLock()}else if(n!==o){let g=new TextEncoder,u=m.process.stdout.getWriter();await u.write(g.encode(L+n+`
|
|
8
|
+
`)),u.releaseLock(),o=n}return i.phase==="DONE"};if(await h())return x(void 0);let c=1e3,$=0;for(;;){await new Promise(i=>setTimeout(i,c));try{let n=(await m.fs.stat(`${d}/state.json`)).mtime?.getTime()??0;if(n>$&&($=n,await new Promise(u=>setTimeout(u,100)),await h()))break}catch{}}return x(void 0)};export{D as buildSnapshot,V as main,W as renderJsonLine,A as renderTerminal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d}from"./chunk-DHMCIRLT.js";import"./chunk-4BH6CF3J.js";import"./chunk-OTRBRRIO.js";export{a as WORKERD_CAPABILITIES,c as clearEnv,d as createWorkerdRuntime,b as populateEnvFromContext};
|
package/noskills.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as t}from"./chunks/chunk-
|
|
2
|
+
import{a as t}from"./chunks/chunk-ALZM4JXG.js";import{c as o}from"./chunks/chunk-2N4GTHXQ.js";import{b as s}from"./chunks/chunk-MNEZ5QGX.js";import"./chunks/chunk-DHMCIRLT.js";import"./chunks/chunk-4BH6CF3J.js";import"./chunks/chunk-OTRBRRIO.js";var i=new t({description:"noskills \u2014 state-machine orchestrator for AI agents",modules:{init:{description:"Initialize noskills in project",load:()=>import("./chunks/init-M7SJOVPZ.js")},status:{description:"Show current state",load:()=>import("./chunks/status-BISV6DFB.js")},spec:{description:"Manage specs (new, list)",load:()=>import("./chunks/spec-J7KC4VFM.js")},next:{description:"Get next instruction for agent",load:()=>import("./chunks/next-GGVR6JM2.js")},approve:{description:"Approve phase transition",load:()=>import("./chunks/approve-GSSSUQWC.js")},block:{description:"Mark spec as blocked",load:()=>import("./chunks/block-LVQNJU4P.js")},reset:{description:"Reset current spec state",load:()=>import("./chunks/reset-JEIUVTWV.js")},done:{description:"Mark spec execution as complete",load:()=>import("./chunks/done-5IX2F6V7.js")},concern:{description:"Manage concerns (add, remove, list)",load:()=>import("./chunks/concern-FGNG32KU.js")},run:{description:"Autonomous execution loop (Ralph loop)",load:()=>import("./chunks/run-7MZATQML.js")},watch:{description:"Live dashboard for monitoring agent progress",load:()=>import("./chunks/watch-AP5GGXG6.js")},sync:{description:"Regenerate tool-specific files",load:()=>import("./chunks/sync-MWQWXN2C.js")},purge:{description:"Remove all noskills content (specs, rules, concerns, hooks)",load:()=>import("./chunks/purge-6DEK2ZSI.js")},"invoke-hook":{description:"Internal hook handlers (called by agents)",load:()=>import("./chunks/invoke-hook-VXIVDDQG.js")},rule:{description:"Manage rules (add, list, promote)",load:()=>import("./chunks/rule-OVSBPSYO.js")}}});var r={name:"@eser/noskills",version:"4.1.39",type:"module",exports:{".":"./main.ts","./mod":"./mod.ts","./module":"./module.ts"},dependencies:{"@eser/ai":"workspace:*","@eser/primitives":"workspace:*","@eser/shell":"workspace:*","@eser/standards":"workspace:*","@eser/streams":"workspace:*",yaml:"^2"},devDependencies:{"@std/assert":"npm:@jsr/std__assert@^1.0.16","@std/testing":"npm:@jsr/std__testing@^1.0.16"}};var p=i.toCommand("noskills",r.version),d=async()=>await p.parse();if(import.meta.main){let n=await d();o(n,{ok:()=>{},fail:e=>{e.message!==void 0&&console.error(e.message),s.process.setExitCode(e.exitCode)}})}export{d as main};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as C}from"./chunk-3HRRWTVF.js";import"./chunk-IVSTITPL.js";import{a as P,d as R}from"./chunk-XCVAHUBM.js";import{e as y}from"./chunk-4ODVKO5Y.js";import{a as p}from"./chunk-UXRWSNVZ.js";import{e as h,f as S,k as g,o as v}from"./chunk-WUVVLUU5.js";import{c as n,d as c,f as l,g as m,k as d,o as f,q as u,r as w}from"./chunk-EZH232V7.js";import{a as i}from"./chunk-2N4GTHXQ.js";import{b as o}from"./chunk-UA3VIHYO.js";import"./chunk-WV3HK5WR.js";import"./chunk-FDZP7B5Y.js";import"./chunk-ACQUINWH.js";import"./chunk-DXB73IDG.js";var $=async E=>{let r=f({renderer:w.ansi(),sink:u.stdout()}),s=o.process.cwd(),e=await h(s),a=await g(s);if(e.phase==="SPEC_DRAFT"){if(e.classification===null&&e.spec!==null){let A=(await v(s)).filter(D=>a?.concerns.includes(D.id)??!1);try{await C(s,e,A)}catch{}}let t=y(e);await S(s,t),t.spec!==null&&(await P(s,t.spec,"approved"),await R(s,t.spec,"approved")),r.writeln(m("\u2714")," Spec approved. Phase: ",d("SPEC_APPROVED")),r.writeln("When ready, run ",n(`${p('next --answer="start"',a)}`)," to begin execution.")}else e.phase==="DISCOVERY"&&e.discovery.completed?(r.writeln(c("Discovery complete. Spec draft already generated.")),r.writeln("Review the spec and run ",n(p("approve",a))," again when in SPEC_DRAFT phase.")):r.writeln(l(`Cannot approve in phase: ${e.phase}`));return await r.close(),i(void 0)};export{$ as main};
|
package/chunks/ask-4XOYE32R.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as Ee,b as Ie}from"./chunk-AGPCY6XP.js";import{a as te,b as C,c as M,d as G,f as L,g as Ae,h as be,j as ke,k as re,l as Pe,o as ne,p as Re,q as oe,r as _e}from"./chunk-EZH232V7.js";import{a as Fe}from"./chunk-5MN3MWQN.js";import"./chunk-OLM5RTFK.js";import{a as Le,b as D}from"./chunk-2N4GTHXQ.js";import{d as ie}from"./chunk-3AZBET4N.js";import{b as T}from"./chunk-UA3VIHYO.js";import"./chunk-WV3HK5WR.js";import"./chunk-FDZP7B5Y.js";import"./chunk-ACQUINWH.js";import{d as ee}from"./chunk-DXB73IDG.js";var Ne=e=>({rawMessage:e.rawMessage??e.message,args:e.args??[],datetime:e.datetime??new Date,properties:e.properties??{},context:e.context??{},...e});var d=e=>typeof e=="string"?e.split(".").filter(Boolean):e,V=(e,t=".")=>e.join(t),w=e=>e.join("\0");var Oe=(e,t)=>e.length<t.length?!1:t.every((r,n)=>e[n]===r);var De=(e,t)=>{let r=[];for(let n of t.values()){let i=d(n.category);Oe(e,i)&&r.push(n)}return r.sort((n,i)=>{let o=d(n.category).length;return d(i.category).length-o}),r};var j=(e,t)=>{let r=typeof t=="string"?[t]:t;return[...e,...r]};var K={};ee(K,{configure:()=>Tt,configureSync:()=>Ct,getEffectiveConfig:()=>ue,getFilterNames:()=>Rt,getLoggerCategories:()=>_t,getRegistryState:()=>St,getSinkNames:()=>Pt,isConfigured:()=>ht,registerFilter:()=>At,registerLogger:()=>kt,registerLoggerCacheClear:()=>le,registerSink:()=>wt,reset:()=>ze,resetSync:()=>Ke,unregisterFilter:()=>bt,unregisterSink:()=>Lt});var g={Trace:1,Debug:5,Info:9,Notice:10,Warning:13,Error:17,Critical:21,Alert:22,Emergency:23},Me={[g.Trace]:"Trace",[g.Debug]:"Debug",[g.Info]:"Info",[g.Notice]:"Notice",[g.Warning]:"Warning",[g.Error]:"Error",[g.Critical]:"Critical",[g.Alert]:"Alert",[g.Emergency]:"Emergency"};var $,z,pt=()=>{if($===void 0)try{let e=globalThis.AsyncLocalStorage??globalThis.require?.("async_hooks")?.AsyncLocalStorage;e&&($=new e)}catch{}return $},mt=()=>{if(z===void 0)try{let e=globalThis.AsyncLocalStorage??globalThis.require?.("async_hooks")?.AsyncLocalStorage;e&&(z=new e)}catch{}return z},Ge,Ve,R=e=>{Ge=e},se=e=>{Ve=e},ge=()=>{$=void 0,z=void 0},dt=()=>Ge??pt(),yt=()=>Ve??mt();var je=()=>{let e=dt();return e?e.getStore()??{}:{}};var xt=()=>{let e=yt();return e?e.getStore()??[]:[]},$e=e=>{let t=xt();return t.length===0?e:j(t,e)};var ce=null,le=e=>{ce=e},u=null,y=new Map,St=()=>u,ht=()=>u!==null,Tt=async e=>{(e.reset||u===null)&&await ze(),u={sinks:new Map(Object.entries(e.sinks)),filters:new Map(Object.entries(e.filters??{})),loggers:new Map,contextLocalStorage:e.contextLocalStorage};for(let t of e.loggers){let r=d(t.category),n=w(r);u.loggers.set(n,{...t,category:r})}e.contextLocalStorage&&R(e.contextLocalStorage),y.clear()},Ct=e=>{(e.reset||u===null)&&Ke(),u={sinks:new Map(Object.entries(e.sinks)),filters:new Map(Object.entries(e.filters??{})),loggers:new Map,contextLocalStorage:e.contextLocalStorage};for(let t of e.loggers){let r=d(t.category),n=w(r);u.loggers.set(n,{...t,category:r})}e.contextLocalStorage&&R(e.contextLocalStorage),y.clear()},ze=async()=>{if(u)for(let e of u.sinks.values()){let t=e;typeof t.dispose=="function"?await t.dispose():typeof t[Symbol.asyncDispose]=="function"&&await t[Symbol.asyncDispose]()}u=null,y.clear(),ce?.(),R(void 0),se(void 0),ge()},Ke=()=>{if(u)for(let e of u.sinks.values()){let t=e;typeof t.disposeSync=="function"?t.disposeSync():typeof t[Symbol.dispose]=="function"&&t[Symbol.dispose]()}u=null,y.clear(),ce?.(),R(void 0),se(void 0),ge()},ue=e=>{let t=w(e),r=y.get(t);if(r)return r;let n={sinks:[],filters:[],lowestLevel:g.Info};if(!u)return n;let i=De(e,u.loggers),o=new Set,a=new Set,l=!1;for(let s of i){if(s.sinks&&s.sinks.length>0){s.parentSinks==="override"&&o.clear();for(let c of s.sinks)o.add(c)}if(s.filters)for(let c of s.filters)a.add(c);!l&&s.lowestLevel!==void 0&&(n.lowestLevel=s.lowestLevel,l=!0)}for(let s of o){let c=u.sinks.get(s);c&&n.sinks.push(c)}for(let s of a){let c=u.filters.get(s);c&&n.filters.push(c)}return y.set(t,n),n},wt=(e,t)=>{if(!u)throw new Error("Logging not configured. Call configure() first.");u.sinks.set(e,t),y.clear()},Lt=e=>{u&&(u.sinks.delete(e),y.clear())},At=(e,t)=>{if(!u)throw new Error("Logging not configured. Call configure() first.");u.filters.set(e,t),y.clear()},bt=e=>{u&&(u.filters.delete(e),y.clear())},kt=e=>{if(!u)throw new Error("Logging not configured. Call configure() first.");let t=d(e.category),r=w(t);u.loggers.set(r,{...e,category:t}),y.clear()},Pt=()=>u?Array.from(u.sinks.keys()):[],Rt=()=>u?Array.from(u.filters.keys()):[],_t=()=>u?Array.from(u.loggers.values()).map(e=>d(e.category)):[];var W={};ee(W,{DEFAULT_LEVEL:()=>Ft,Logger:()=>_,clearLoggerCache:()=>We,current:()=>It,getLogger:()=>Et});var Ft=g.Info,_=class e{category;parent;#e;#t=null;constructor(t,r=null,n={}){this.category=d(t),this.parent=r,this.#e=n}#r(){return this.#t===null&&(this.#t=ue(this.category)),this.#t}getChild(t){let r=j(this.category,d(t));return new e(r,this,this.#e)}with(t){return new e(this.category,this.parent,{...this.#e,...t})}get loggerName(){return V(this.category)}asString(t,r=!1){return typeof t=="string"?r?`"${t}"`:t:t===null||typeof t=="number"||typeof t=="bigint"||typeof t=="boolean"||typeof t>"u"||typeof t=="symbol"?String(t):t instanceof Error?t.stack:t!==null&&typeof t=="object"?Array.isArray(t)?JSON.stringify(t):`{${Object.entries(t).map(([n,i])=>`"${n}":${this.asString(i,!0)}`).join(",")}}`:"undefined"}async log(t,r,...n){let i=this.#r();if(t<i.lowestLevel)return r instanceof Function?void 0:r;let o,a;r instanceof Function?(o=r(),a=this.asString(o)):a=this.asString(r);let l=je(),s=Ne({message:a,rawMessage:a,args:n,datetime:new Date,severity:t,category:this.category,properties:this.#e,context:l});for(let c of i.filters)if(!c(s))return r instanceof Function?o:r;return i.sinks.length>0&&await Promise.all(i.sinks.map(c=>c(s))),r instanceof Function?o:r}debug(t,...r){return this.log(g.Debug,t,...r)}info(t,...r){return this.log(g.Info,t,...r)}warn(t,...r){return this.log(g.Warning,t,...r)}error(t,...r){return this.log(g.Error,t,...r)}critical(t,...r){return this.log(g.Critical,t,...r)}emergency(t,...r){return this.log(g.Emergency,t,...r)}alert(t,...r){return this.log(g.Alert,t,...r)}notice(t,...r){return this.log(g.Notice,t,...r)}trace(t,...r){return this.log(g.Trace,t,...r)}},fe=new Map,Et=e=>{let t=$e(d(e)),r=w(t),n=fe.get(r);return n||(n=new _(t),fe.set(r,n)),n},We=()=>{fe.clear()};le(We);var It=new _(["default"]);var B={};ee(B,{fingersCrossedSink:()=>Kt,getBufferedSink:()=>zt,getOutputSink:()=>jt,getRecordCollectorSink:()=>Ue,getTestSink:()=>Wt,withFilter:()=>$t});var Nt={[g.Trace]:"TRCE",[g.Debug]:"DBUG",[g.Info]:"INFO",[g.Notice]:"NOTC",[g.Warning]:"WARN",[g.Error]:"ERRO",[g.Critical]:"CRIT",[g.Alert]:"ALRT",[g.Emergency]:"EMRG"};var Ot=(e,t)=>{if(t==="none")return"";if(typeof t=="function")return t(e);let r=e.toISOString(),n=r.slice(0,10),i=r.slice(11,19),o=r.slice(19);switch(t){case"rfc3339":return r;case"date-time-timezone":case void 0:return`${n} ${i}${o}`;case"date-time":return`${n} ${i}`;case"time-timezone":return`${i}${o}`;case"time":return i;case"date":return n}},Dt=e=>{try{return JSON.stringify(e)}catch{return String(e)}},Mt=(e,t)=>{let r={...t,...e},n=Object.entries(r);return n.length===0?"":" "+n.map(([i,o])=>{let a=typeof o=="string"?o:Dt(o);return`${i}=${a}`}).join(" ")};var Gt=(e,t)=>{switch(e){case g.Trace:return G(ke(t));case g.Debug:return Pe(t);case g.Info:return Ae(t);case g.Notice:return re(t);case g.Warning:return be(t);case g.Error:return L(t);case g.Critical:return M(L(t));case g.Alert:return M(L(t));case g.Emergency:return M(L(t));default:return C(t)}},Be=e=>{let t=Ot(e.datetime,"date-time-timezone"),r=Nt[e.severity]??"????",n=e.category.length>0?V(e.category):"",i=Mt(e.properties,e.context),o=[];return t&&o.push(G(t),C(" ")),o.push(Gt(e.severity,r),C(" ")),n&&o.push(re(`[${n}]`),C(" ")),e.severity>=g.Error?o.push(L(e.message)):o.push(C(e.message)),i.trim()&&o.push(C(" "),G(i.trim())),o};var jt=(e,t)=>{let r=t?.formatter??Be;return n=>{let i=r(n);e.writeln(...i)}},$t=(e,t)=>r=>{if(t(r))return e(r)},zt=(e,t={})=>{let{maxSize:r=100,flushIntervalMs:n=5e3}=t,i=[],o=null,a=async()=>{if(i.length===0)return;let c=i;i=[],o&&(clearTimeout(o),o=null),await Promise.all(c.map(p=>e(p)))},l=()=>{o===null&&(o=setTimeout(()=>{o=null,a().catch(()=>{})},n))},s=async c=>{i.push(c),i.length>=r?await a():l()};return s.flush=a,s},Kt=(e,t={})=>{let{triggerLevel:r=17,maxBufferSize:n=1e3}=t,i=[],o=!1,a=async()=>{let c=i;i=[],o=!0,await Promise.all(c.map(p=>e(p)))},l=()=>{i=[],o=!1},s=async c=>{if(o){await e(c);return}if(c.severity>=r){i.push(c),await a();return}i.push(c),i.length>n&&i.shift()};return s.flush=a,s.clear=l,s},Ue=()=>{let e=[];return{sink:r=>{e.push(r)},records:e}},Wt=Ue;var Ye=typeof globalThis=="object"?globalThis:global;var v="1.9.0";var Xe=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function Ut(e){var t=new Set([e]),r=new Set,n=e.match(Xe);if(!n)return function(){return!1};var i={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(i.prerelease!=null)return function(s){return s===e};function o(l){return r.add(l),!1}function a(l){return t.add(l),!0}return function(s){if(t.has(s))return!0;if(r.has(s))return!1;var c=s.match(Xe);if(!c)return o(s);var p={major:+c[1],minor:+c[2],patch:+c[3],prerelease:c[4]};return p.prerelease!=null||i.major!==p.major?o(s):i.major===0?i.minor===p.minor&&i.patch<=p.patch?a(s):o(s):i.minor<=p.minor?a(s):o(s)}}var qe=Ut(v);var Yt=v.split(".")[0],F=Symbol.for("opentelemetry.js.api."+Yt),E=Ye;function A(e,t,r,n){var i;n===void 0&&(n=!1);var o=E[F]=(i=E[F])!==null&&i!==void 0?i:{version:v};if(!n&&o[e]){var a=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+e);return r.error(a.stack||a.message),!1}if(o.version!==v){var a=new Error("@opentelemetry/api: Registration of version v"+o.version+" for "+e+" does not match previously registered API v"+v);return r.error(a.stack||a.message),!1}return o[e]=t,r.debug("@opentelemetry/api: Registered a global for "+e+" v"+v+"."),!0}function S(e){var t,r,n=(t=E[F])===null||t===void 0?void 0:t.version;if(!(!n||!qe(n)))return(r=E[F])===null||r===void 0?void 0:r[e]}function b(e,t){t.debug("@opentelemetry/api: Unregistering a global for "+e+" v"+v+".");var r=E[F];r&&delete r[e]}var Xt=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],a;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(l){a={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return o},qt=function(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,o;n<i;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))},He=function(){function e(t){this._namespace=t.namespace||"DiagComponentLogger"}return e.prototype.debug=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return I("debug",this._namespace,t)},e.prototype.error=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return I("error",this._namespace,t)},e.prototype.info=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return I("info",this._namespace,t)},e.prototype.warn=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return I("warn",this._namespace,t)},e.prototype.verbose=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return I("verbose",this._namespace,t)},e}();function I(e,t,r){var n=S("diag");if(n)return r.unshift(t),n[e].apply(n,qt([],Xt(r),!1))}var m;(function(e){e[e.NONE=0]="NONE",e[e.ERROR=30]="ERROR",e[e.WARN=50]="WARN",e[e.INFO=60]="INFO",e[e.DEBUG=70]="DEBUG",e[e.VERBOSE=80]="VERBOSE",e[e.ALL=9999]="ALL"})(m||(m={}));function Je(e,t){e<m.NONE?e=m.NONE:e>m.ALL&&(e=m.ALL),t=t||{};function r(n,i){var o=t[n];return typeof o=="function"&&e>=i?o.bind(t):function(){}}return{error:r("error",m.ERROR),warn:r("warn",m.WARN),info:r("info",m.INFO),debug:r("debug",m.DEBUG),verbose:r("verbose",m.VERBOSE)}}var Ht=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],a;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(l){a={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return o},Jt=function(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,o;n<i;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))},Qt="diag",k=function(){function e(){function t(i){return function(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];var l=S("diag");if(l)return l[i].apply(l,Jt([],Ht(o),!1))}}var r=this,n=function(i,o){var a,l,s;if(o===void 0&&(o={logLevel:m.INFO}),i===r){var c=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((a=c.stack)!==null&&a!==void 0?a:c.message),!1}typeof o=="number"&&(o={logLevel:o});var p=S("diag"),f=Je((l=o.logLevel)!==null&&l!==void 0?l:m.INFO,i);if(p&&!o.suppressOverrideMessage){var x=(s=new Error().stack)!==null&&s!==void 0?s:"<failed to generate stacktrace>";p.warn("Current logger will be overwritten from "+x),f.warn("Current logger will overwrite one already registered from "+x)}return A("diag",f,r,!0)};r.setLogger=n,r.disable=function(){b(Qt,r)},r.createComponentLogger=function(i){return new He(i)},r.verbose=t("verbose"),r.debug=t("debug"),r.info=t("info"),r.warn=t("warn"),r.error=t("error")}return e.instance=function(){return this._instance||(this._instance=new e),this._instance},e}();function Qe(e){return Symbol.for(e)}var Zt=function(){function e(t){var r=this;r._currentContext=t?new Map(t):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,i){var o=new e(r._currentContext);return o._currentContext.set(n,i),o},r.deleteValue=function(n){var i=new e(r._currentContext);return i._currentContext.delete(n),i}}return e}(),Ze=new Zt;var er=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],a;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(l){a={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return o},tr=function(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,o;n<i;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))},et=function(){function e(){}return e.prototype.active=function(){return Ze},e.prototype.with=function(t,r,n){for(var i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];return r.call.apply(r,tr([n],er(i),!1))},e.prototype.bind=function(t,r){return r},e.prototype.enable=function(){return this},e.prototype.disable=function(){return this},e}();var rr=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],a;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(l){a={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return o},nr=function(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,o;n<i;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))},pe="context",or=new et,U=function(){function e(){}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalContextManager=function(t){return A(pe,t,k.instance())},e.prototype.active=function(){return this._getContextManager().active()},e.prototype.with=function(t,r,n){for(var i,o=[],a=3;a<arguments.length;a++)o[a-3]=arguments[a];return(i=this._getContextManager()).with.apply(i,nr([t,r,n],rr(o),!1))},e.prototype.bind=function(t,r){return this._getContextManager().bind(t,r)},e.prototype._getContextManager=function(){return S(pe)||or},e.prototype.disable=function(){this._getContextManager().disable(),b(pe,k.instance())},e}();var Y;(function(e){e[e.NONE=0]="NONE",e[e.SAMPLED=1]="SAMPLED"})(Y||(Y={}));var me="0000000000000000",de="00000000000000000000000000000000",tt={traceId:de,spanId:me,traceFlags:Y.NONE};var h=function(){function e(t){t===void 0&&(t=tt),this._spanContext=t}return e.prototype.spanContext=function(){return this._spanContext},e.prototype.setAttribute=function(t,r){return this},e.prototype.setAttributes=function(t){return this},e.prototype.addEvent=function(t,r){return this},e.prototype.addLink=function(t){return this},e.prototype.addLinks=function(t){return this},e.prototype.setStatus=function(t){return this},e.prototype.updateName=function(t){return this},e.prototype.end=function(t){},e.prototype.isRecording=function(){return!1},e.prototype.recordException=function(t,r){},e}();var ye=Qe("OpenTelemetry Context Key SPAN");function X(e){return e.getValue(ye)||void 0}function rt(){return X(U.getInstance().active())}function N(e,t){return e.setValue(ye,t)}function nt(e){return e.deleteValue(ye)}function ot(e,t){return N(e,new h(t))}function q(e){var t;return(t=X(e))===null||t===void 0?void 0:t.spanContext()}var ir=/^([0-9a-f]{32})$/i,ar=/^[0-9a-f]{16}$/i;function sr(e){return ir.test(e)&&e!==de}function gr(e){return ar.test(e)&&e!==me}function H(e){return sr(e.traceId)&&gr(e.spanId)}function it(e){return new h(e)}var xe=U.getInstance(),J=function(){function e(){}return e.prototype.startSpan=function(t,r,n){n===void 0&&(n=xe.active());var i=!!r?.root;if(i)return new h;var o=n&&q(n);return cr(o)&&H(o)?new h(o):new h},e.prototype.startActiveSpan=function(t,r,n,i){var o,a,l;if(!(arguments.length<2)){arguments.length===2?l=r:arguments.length===3?(o=r,l=n):(o=r,a=n,l=i);var s=a??xe.active(),c=this.startSpan(t,o,s),p=N(s,c);return xe.with(p,l,void 0,c)}},e}();function cr(e){return typeof e=="object"&&typeof e.spanId=="string"&&typeof e.traceId=="string"&&typeof e.traceFlags=="number"}var lr=new J,at=function(){function e(t,r,n,i){this._provider=t,this.name=r,this.version=n,this.options=i}return e.prototype.startSpan=function(t,r,n){return this._getTracer().startSpan(t,r,n)},e.prototype.startActiveSpan=function(t,r,n,i){var o=this._getTracer();return Reflect.apply(o.startActiveSpan,o,arguments)},e.prototype._getTracer=function(){if(this._delegate)return this._delegate;var t=this._provider.getDelegateTracer(this.name,this.version,this.options);return t?(this._delegate=t,this._delegate):lr},e}();var st=function(){function e(){}return e.prototype.getTracer=function(t,r,n){return new J},e}();var ur=new st,ve=function(){function e(){}return e.prototype.getTracer=function(t,r,n){var i;return(i=this.getDelegateTracer(t,r,n))!==null&&i!==void 0?i:new at(this,t,r,n)},e.prototype.getDelegate=function(){var t;return(t=this._delegate)!==null&&t!==void 0?t:ur},e.prototype.setDelegate=function(t){this._delegate=t},e.prototype.getDelegateTracer=function(t,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getTracer(t,r,n)},e}();var Se="trace",gt=function(){function e(){this._proxyTracerProvider=new ve,this.wrapSpanContext=it,this.isSpanContextValid=H,this.deleteSpan=nt,this.getSpan=X,this.getActiveSpan=rt,this.getSpanContext=q,this.setSpan=N,this.setSpanContext=ot}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalTracerProvider=function(t){var r=A(Se,this._proxyTracerProvider,k.instance());return r&&this._proxyTracerProvider.setDelegate(t),r},e.prototype.getTracerProvider=function(){return S(Se)||this._proxyTracerProvider},e.prototype.getTracer=function(t,r){return this.getTracerProvider().getTracer(t,r)},e.prototype.disable=function(){b(Se,k.instance()),this._proxyTracerProvider=new ve},e}();var he=gt.getInstance();var Yn=he.getTracer("@eser/logging");var Te=(e,t,r)=>{let n=e.streamText(t,r);return{name:`ai-text/${e.provider}/${e.modelId}`,readable:new ReadableStream({async start(i){try{for await(let o of n)o.kind==="content_delta"&&i.enqueue(te(o.textDelta));i.close()}catch(o){i.error(o)}}})}};var dr={cc:"claude-code",ol:"ollama",oc:"opencode",oai:"openai",ant:"anthropic",gem:"gemini",vtx:"vertexai"},yr={"claude-code":"Claude Code",ollama:"Ollama",opencode:"OpenCode",kiro:"Kiro",anthropic:"Anthropic API",openai:"OpenAI API",gemini:"Gemini API",vertexai:"Vertex AI"},xr=e=>dr[e]??e,vr=async e=>{if(e){let t=T.process.stderr.getWriter(),r=ne({renderer:_e.ansi(),sink:oe.writable(new WritableStream({async write(n){await t.write(new TextEncoder().encode(String(n.data)))},close(){t.releaseLock()}}))});await K.configure({sinks:{stderr:B.getOutputSink(r)},loggers:[{category:["ai"],lowestLevel:g.Debug,sinks:["stderr"]}]})}return W.getLogger(["ai","ask"])},Sr=async e=>{await e.info("Auto-detecting AI provider...");try{if(await ie`which claude`.noThrow().code()===0)return await e.info("Claude Code detected."),"claude-code"}catch{}try{if((await fetch("http://localhost:11434/api/version",{signal:AbortSignal.timeout(1e3)})).ok)return await e.info("Ollama detected at localhost:11434."),"ollama"}catch{}try{if(await ie`which opencode`.noThrow().code()===0)return await e.info("OpenCode detected."),"opencode"}catch{}if(T.capabilities.env){if(T.env.has("ANTHROPIC_API_KEY"))return await e.info("Anthropic API key detected."),"anthropic";if(T.env.has("OPENAI_API_KEY"))return await e.info("OpenAI API key detected."),"openai"}throw new Error("No AI provider detected. Install claude, ollama, or set ANTHROPIC_API_KEY / OPENAI_API_KEY.")},hr=async e=>{switch(e){case"claude-code":return(await import("./claude-code-6AAAJZKK.js")).claudeCodeFactory;case"ollama":return(await import("./ollama-24ACY3UB.js")).ollamaFactory;case"opencode":return(await import("./opencode-LFWHRZPL.js")).openCodeFactory;case"kiro":return(await import("./kiro-MHP573OZ.js")).kiroFactory;case"anthropic":return(await import("./anthropic-GKH6HH6J.js")).anthropicFactory;case"openai":return(await import("./openai-ZNKOR4CD.js")).openaiFactory;case"gemini":return(await import("./gemini-Z57NY6WY.js")).geminiFactory;case"vertexai":return(await import("./vertexai-WVENJL2F.js")).vertexaiFactory;default:throw new Error(`Unknown provider: ${e}`)}},lo=async e=>{let t=e??[],r=null,n=null,i=null,o=!1,a=!1,l=[],s=0;for(;s<t.length;){let f=t[s];if(f==="-p"||f==="--provider"){r=t[s+1]??null,s+=2;continue}if(f==="-m"||f==="--model"){n=t[s+1]??null,s+=2;continue}if(f==="--max-tokens"){let x=t[s+1];x!==void 0&&(i=Number(x)),s+=2;continue}if(f==="--json"){o=!0,s+=1;continue}if(f==="-v"||f==="--verbose"){a=!0,s+=1;continue}f.startsWith("-")||l.push(f),s+=1}let c=l.join(" ");if(c.length===0)return D({message:'Usage: ai ask "your prompt" [-p provider] [-m model] [--verbose]',exitCode:1});let p=await vr(a);try{let f=r!==null?xr(r):await Sr(p),x=yr[f]??f,Ce=n??Lr(f);await p.info(`Using ${x} (${Ce})`);let lt=await hr(f),Q=new Ie({factories:[lt]});await Q.addModel("default",{provider:f,model:Ce});let Z=Q.getDefault();if(Z===null)return D({message:"Failed to initialize model",exitCode:1});let we=[Fe("user",c)];if(await p.info(`Sending prompt (${c.length} chars)...`),o){let O=await Z.generateText({messages:we,maxTokens:i??void 0});await p.info(`Response received (${Ee(O).length} chars)`);let P=ne({sink:oe.stdout()});P.writeln(JSON.stringify(O,null,2)),await P.close()}else{let O=Te(Z,{messages:we,maxTokens:i??void 0});await Re().from(O).to(wr()).run();let P=T.process.stdout.getWriter();await P.write(new TextEncoder().encode(`
|
|
2
|
-
`)),P.releaseLock()}return await Q.close(),Le(void 0)}catch(f){let x=f instanceof Error?f.message:String(f);return await p.error(x),a&&f instanceof Error&&f.cause!==void 0&&await p.debug(`Cause: ${String(f.cause)}`),D({message:x,exitCode:1})}},Tr=12,Cr=e=>new Promise(t=>setTimeout(t,e)),wr=(e=Tr)=>{let t=new TextEncoder;return{name:"typewriter",writable:new WritableStream({async write(r){let n=String(r.data),i=T.process.stdout.getWriter();for(let o of n)await i.write(t.encode(o)),await Cr(e);i.releaseLock()}})}},Lr=e=>{switch(e){case"claude-code":return"claude-sonnet-4-20250514";case"ollama":return"llama3";case"opencode":return"default";case"kiro":return"default";case"anthropic":return"claude-sonnet-4-20250514";case"openai":return"gpt-4o";case"gemini":return"gemini-2.0-flash";case"vertexai":return"gemini-2.0-flash";default:return"default"}};export{lo as main};
|
package/chunks/block-D67USBJS.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{g as k}from"./chunk-4ODVKO5Y.js";import{a as g}from"./chunk-UXRWSNVZ.js";import{e as w,f,k as h}from"./chunk-WUVVLUU5.js";import{c as i,d as m,f as l,h as c,o as p,q as d,r as u}from"./chunk-EZH232V7.js";import{a as o,b as n}from"./chunk-2N4GTHXQ.js";import{b as a}from"./chunk-UA3VIHYO.js";import"./chunk-WV3HK5WR.js";import"./chunk-FDZP7B5Y.js";import"./chunk-ACQUINWH.js";import"./chunk-DXB73IDG.js";var $=async b=>{let e=p({renderer:u.ansi(),sink:d.stdout()}),s=a.process.cwd(),r=b?.join(" ")??"No reason given",t=await w(s),x=await h(s);if(t.phase!=="EXECUTING")return e.writeln(l(`Cannot block in phase: ${t.phase}`)),await e.close(),n({exitCode:1});let y=k(t,r);return await f(s,y),e.writeln(c("\u26A0")," Spec blocked: ",m(r)),e.writeln("Resolve with: ",i(`${g('next --answer="resolution"',x)}`)),await e.close(),o(void 0)};export{$ as main};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as s}from"./chunk-FDZP7B5Y.js";import{a as r}from"./chunk-ACQUINWH.js";import"./chunk-DXB73IDG.js";var o={fs:!1,fsSync:!1,exec:!1,process:!1,env:!1,stdin:!1,stdout:!1,kv:!1},t=e=>()=>{throw new r(e,"browser")},n=()=>{let e=t("fs");return{readFile:e,readTextFile:e,writeFile:e,writeTextFile:e,exists:e,stat:e,lstat:e,mkdir:e,ensureDir:e,remove:e,readDir:e,copyFile:e,rename:e,makeTempDir:e,realPath:e,watch:e,walk:e,chmod:e}},i=()=>{let e=t("exec");return{spawn:e,exec:e,execJson:e,spawnChild:e}},a=()=>{let e=t("process");return{exit:e,setExitCode:e,cwd:e,chdir:e,hostname:e,execPath:e,get args(){throw new r("process","browser")},get pid(){throw new r("process","browser")},get stdin(){throw new r("process","browser")},get stdout(){throw new r("process","browser")},get stderr(){throw new r("process","browser")},isTerminal(){return!1},setStdinRaw(){throw new r("process","browser")}}},c=()=>({get:()=>{},set:()=>{},delete:()=>{},has:()=>!1,toObject:()=>({})}),l=()=>({name:"browser",version:globalThis.navigator?.userAgent??"unknown",capabilities:o,fs:n(),path:s,exec:i(),env:c(),process:a()});export{o as BROWSER_CAPABILITIES,l as createBrowserRuntime};
|
package/chunks/bun-KVGAHBUF.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as F}from"./chunk-T7K64JD5.js";import{b as v,d as b}from"./chunk-ACQUINWH.js";import"./chunk-DXB73IDG.js";import*as n from"node:fs/promises";import*as O from"node:fs";import*as o from"node:path";import*as w from"node:os";import d from"node:process";import{Readable as x,Writable as k}from"node:stream";var R={fs:!0,fsSync:!0,exec:!0,process:!0,env:!0,stdin:!0,stdout:!0,kv:!1},E=()=>{let r=e=>({isFile:e.isFile(),isDirectory:e.isDirectory(),isSymlink:e.isSymbolicLink(),size:e.size,mtime:e.mtime,atime:e.atime,birthtime:e.birthtime}),a=(e,t)=>{throw e instanceof Error&&"code"in e&&e.code==="ENOENT"?new v(t):e};return{async readFile(e,t){try{let s=await n.readFile(e,{signal:t?.signal});return new Uint8Array(s)}catch(s){return a(s,e)}},async readTextFile(e,t){try{return await n.readFile(e,{encoding:"utf-8",signal:t?.signal})}catch(s){return a(s,e)}},async writeFile(e,t,s){let u=s?.append?"a":"w";await n.writeFile(e,t,{signal:s?.signal,mode:s?.mode,flag:u})},async writeTextFile(e,t,s){let u=s?.append?"a":"w";await n.writeFile(e,t,{encoding:"utf-8",signal:s?.signal,mode:s?.mode,flag:u})},async exists(e){try{return await n.access(e),!0}catch{return!1}},async stat(e){try{let t=await n.stat(e);return r(t)}catch(t){return a(t,e)}},async lstat(e){try{let t=await n.lstat(e);return r(t)}catch(t){return a(t,e)}},async mkdir(e,t){await n.mkdir(e,{recursive:t?.recursive??!1,mode:t?.mode})},async ensureDir(e){await n.mkdir(e,{recursive:!0})},async remove(e,t){try{await n.rm(e,{recursive:t?.recursive??!1,force:!1})}catch(s){a(s,e)}},async*readDir(e){try{let t=await n.readdir(e,{withFileTypes:!0});for(let s of t)yield{name:s.name,isFile:s.isFile(),isDirectory:s.isDirectory(),isSymlink:s.isSymbolicLink()}}catch(t){a(t,e)}},async copyFile(e,t){await n.copyFile(e,t)},async rename(e,t){await n.rename(e,t)},async makeTempDir(e){let t=e?.dir??w.tmpdir(),s=e?.prefix??"",u=e?.suffix??"",i=await n.mkdtemp(o.join(t,s));if(u){let c=i+u;return await n.rename(i,c),c}return i},async realPath(e){try{return await n.realpath(e)}catch(t){throw t instanceof Error&&"code"in t&&t.code==="ENOENT"?new v(e):t}},watch(e,t){let s=t?.recursive??!0,u=[],i=[],c=[],l=!1,P=m=>{l||(c.length>0?c.shift()({value:m,done:!1}):i.push(m))};for(let m of e)try{let h=O.watch(m,{recursive:s},(y,f)=>{f!==null&&P({kind:y==="rename"?"create":"modify",paths:[o.join(m,f)]})});u.push(h)}catch{}return{close:()=>{l=!0;for(let m of u)m.close();for(let m of c)m({value:void 0,done:!0});c=[]},[Symbol.asyncIterator]:()=>({next:()=>l?Promise.resolve({value:void 0,done:!0}):i.length>0?Promise.resolve({value:i.shift(),done:!1}):new Promise(m=>{c.push(m)})})}},async chmod(e,t){await n.chmod(e,t)},async*walk(e,t){let s=t?.includeDirs??!0,u=t?.includeFiles??!0,i=t?.exts,c=t?.skip,l=async function*(P){let m=await n.readdir(P,{withFileTypes:!0});for(let h of m){let y=o.join(P,h.name);if(c?.some(p=>p.test(y)))continue;let f=h.isSymbolicLink();if(h.isDirectory())s&&(yield{path:y,name:h.name,isFile:!1,isDirectory:!0,isSymlink:f}),yield*l(y);else if(h.isFile()||f){if(!u||i&&!i.some(p=>h.name.endsWith(p.startsWith(".")?p:`.${p}`)))continue;yield{path:y,name:h.name,isFile:h.isFile(),isDirectory:!1,isSymlink:f}}}};yield*l(e)}}},S=()=>({join:o.join,resolve:o.resolve,dirname:o.dirname,basename:o.basename,extname:o.extname,normalize:o.normalize,isAbsolute:o.isAbsolute,relative:o.relative,parse:o.parse,format:o.format,sep:o.sep,delimiter:o.delimiter}),g=async r=>{if(!r)return new Uint8Array(0);let a=[],e=r.getReader();try{for(;;){let{done:i,value:c}=await e.read();if(i)break;a.push(c)}}finally{e.releaseLock()}let t=a.reduce((i,c)=>i+c.length,0),s=new Uint8Array(t),u=0;for(let i of a)s.set(i,u),u+=i.length;return s},A=()=>({async spawn(r,a=[],e){let[t,s,u]=F(e),i=Bun.spawn([r,...a],{cwd:e?.cwd,env:e?.env,stdin:t,stdout:s,stderr:u}),[c,l,P]=await Promise.all([i.exited,g(i.stdout),g(i.stderr)]);return{success:c===0,code:c,stdout:l,stderr:P}},async exec(r,a=[],e){let t=await this.spawn(r,a,e);if(!t.success){let s=new TextDecoder().decode(t.stderr);throw new b(r,t.code,s)}return new TextDecoder().decode(t.stdout).trim()},async execJson(r,a=[],e){let t=await this.exec(r,a,e);return JSON.parse(t)},spawnChild(r,a=[],e){let[t,s,u]=F(e),i=Bun.spawn([r,...a],{cwd:e?.cwd,env:e?.env,stdin:t,stdout:s,stderr:u}),c=i.exited.then(l=>({success:l===0,code:l,signal:void 0}));return{pid:i.pid,stdin:i.stdin,stdout:i.stdout,stderr:i.stderr,status:c,output:async()=>{let[l,P,m]=await Promise.all([c,g(i.stdout),g(i.stderr)]);return{success:l.success,code:l.code,stdout:P,stderr:m}},kill:l=>{i.kill(l)}}}}),T=()=>({get(r){return d.env[r]},set(r,a){d.env[r]=a},delete(r){delete d.env[r]},has(r){return r in d.env},toObject(){let r={};for(let[a,e]of Object.entries(d.env))e!==void 0&&(r[a]=e);return r}}),W=()=>({exit(r){d.exit(r)},setExitCode(r){d.exitCode=r},cwd(){return d.cwd()},chdir(r){d.chdir(r)},hostname(){return w.hostname()},execPath(){return d.execPath},args:d.argv.slice(2),pid:d.pid,stdin:x.toWeb(d.stdin),stdout:k.toWeb(d.stdout),stderr:k.toWeb(d.stderr),isTerminal(r){switch(r){case"stdin":return d.stdin.isTTY===!0;case"stdout":return d.stdout.isTTY===!0;case"stderr":return d.stderr.isTTY===!0}},setStdinRaw(r){d.stdin.setRawMode(r)}}),M=()=>{let r=E(),a=S(),e=A(),t=T(),s=W();return{name:"bun",version:Bun.version,capabilities:R,fs:r,path:a,exec:e,env:t,process:s}};export{R as BUN_CAPABILITIES,M as createBunRuntime};
|
package/chunks/chunk-3HRRWTVF.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{b as m}from"./chunk-IVSTITPL.js";import{d}from"./chunk-WUVVLUU5.js";import{b as l}from"./chunk-UA3VIHYO.js";var h=c=>{let n=c.split(/\n/).flatMap(i=>i.trim().length>0?[i.trim()]:[]);return n.length>1?n:c.split(/\.\s+|;\s+/).map(i=>i.trim()).filter(i=>i.length>5)},v=c=>{let n=[],i=c.find(t=>t.questionId==="ambition");if(i!==void 0){let t=i.answer,e=t.match(/10[- ]?star[:\s]+(.+)/i),r=e!==null?e[1].trim():t.length>120?t.slice(0,120)+"...":t,p=r.charAt(0).toUpperCase()+r.slice(1);n.push(p)}let o=c.find(t=>t.questionId==="verification");if(o!==void 0){let t=h(o.answer);for(let e of t){let r=e.toLowerCase();r.startsWith("run ")||r.startsWith("check ")?n.push(`Test: ${e}`):n.push(e)}}return n.length===0&&n.push("_Tasks need to be defined before execution. Add tasks manually or run discovery with more detail._"),n},w=(c,n)=>{let i={};if(n===null){for(let o of c.specSections)i[o]=!1;return i}for(let o of c.specSections){let t=o.toLowerCase();t.includes("design")||t.includes("mobile")||t.includes("layout")||t.includes("interaction")?i[o]=n.involvesUI:t.includes("contributor")||t.includes("public api")||t.includes("api surface")?i[o]=n.involvesPublicAPI:t.includes("migration")||t.includes("deprecation")||t.includes("backward")||t.includes("compatibility")?i[o]=n.involvesMigration:t.includes("audit")||t.includes("access control")||t.includes("data handling")?i[o]=n.involvesDataHandling:i[o]=!0}return i},g=(c,n,i,o,t)=>{let e=[];e.push(`# Spec: ${c}`),e.push(""),e.push("## Status: draft"),e.push(""),i.length>0&&(e.push(`## Concerns: ${i.map(s=>s.id).join(", ")}`),e.push("")),e.push("## Discovery Answers"),e.push("");for(let s of n)e.push(`### ${s.questionId}`),e.push(""),e.push(s.answer),e.push("");for(let s of i)if(s.specSections.length>0){let a=w(s,t??null);for(let f of s.specSections)a[f]!==!1&&(e.push(`## ${f} (${s.id})`),e.push(""),e.push("_To be addressed during execution._"),e.push(""))}if(o.length>0){e.push("## Decisions"),e.push(""),e.push("| # | Decision | Choice | Promoted |"),e.push("|---|----------|--------|----------|");for(let s=0;s<o.length;s++){let a=o[s];e.push(`| ${s+1} | ${a.question} | ${a.choice} | ${a.promoted?"yes":"no"} |`)}e.push("")}let r=n.find(s=>s.questionId==="scope_boundary");if(r!==void 0){e.push("## Out of Scope"),e.push("");let s=h(r.answer);for(let a of s)e.push(`- ${a}`);e.push("")}let p=v(n);e.push("## Tasks"),e.push("");for(let s=0;s<p.length;s++)e.push(`- [ ] task-${s+1}: ${p[s]}`);e.push("");let u=n.find(s=>s.questionId==="verification");if(e.push("## Verification"),e.push(""),u!==void 0){let s=h(u.answer);for(let a of s)e.push(`- ${a}`)}else e.push("_To be defined._");return e.push(""),e.join(`
|
|
2
|
-
`)};var k=async(c,n,i)=>{if(n.spec===null)throw new Error("No active spec");let o=`${c}/${d.specDir(n.spec)}`,t=`${c}/${d.specFile(n.spec)}`;await l.fs.mkdir(o,{recursive:!0});let e=g(n.spec,n.discovery.answers,i,n.decisions,n.classification);await l.fs.writeTextFile(t,e);let r=m(n.spec,e),p=`${o}/progress.json`,u={spec:n.spec,status:"draft",tasks:r.tasks.map(s=>({id:s.id,title:s.title,status:"pending"})),decisions:n.decisions.map(s=>({question:s.question,choice:s.choice,promoted:s.promoted})),debt:[],updatedAt:new Date().toISOString()};return await l.fs.writeTextFile(p,JSON.stringify(u,null,2)+`
|
|
3
|
-
`),t};export{k as a};
|
package/chunks/chunk-4ODVKO5Y.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as i}from"./chunk-WUVVLUU5.js";var n={UNINITIALIZED:["IDLE"],IDLE:["DISCOVERY"],DISCOVERY:["SPEC_DRAFT"],SPEC_DRAFT:["SPEC_APPROVED"],SPEC_APPROVED:["EXECUTING"],EXECUTING:["DONE","BLOCKED"],BLOCKED:["EXECUTING"],DONE:["IDLE"]},c=(e,s)=>n[e].includes(s),t=(e,s)=>{if(!c(e,s))throw new Error(`Invalid phase transition: ${e} \u2192 ${s}. Allowed: ${n[e].join(", ")}`)},h=(e,s)=>(t(e.phase,s),{...e,phase:s}),d=(e,s,a)=>(t(e.phase,"DISCOVERY"),{...e,phase:"DISCOVERY",spec:s,branch:a,discovery:{answers:[],completed:!1},specState:{path:null,status:"none"},execution:{iteration:0,lastProgress:null,modifiedFiles:[],lastVerification:null,awaitingStatusReport:!1,debt:null,completedTasks:[]},decisions:[]}),E=(e,s,a)=>{if(e.phase!=="DISCOVERY")throw new Error(`Cannot add discovery answer in phase: ${e.phase}`);let o=[...e.discovery.answers.filter(r=>r.questionId!==s),{questionId:s,answer:a}];return{...e,discovery:{answers:o,completed:e.discovery.completed}}},u=e=>{if(e.phase!=="DISCOVERY")throw new Error(`Cannot complete discovery in phase: ${e.phase}`);return{...e,phase:"SPEC_DRAFT",discovery:{...e.discovery,completed:!0},specState:{path:i.specFile(e.spec),status:"draft"}}},m=e=>(t(e.phase,"SPEC_APPROVED"),{...e,phase:"SPEC_APPROVED",specState:{...e.specState,status:"approved"}}),S=e=>(t(e.phase,"EXECUTING"),{...e,phase:"EXECUTING",discovery:{answers:[],completed:!0},execution:{iteration:0,lastProgress:null,modifiedFiles:[],lastVerification:null,awaitingStatusReport:!1,debt:null,completedTasks:[]}});var D=(e,s)=>(t(e.phase,"BLOCKED"),{...e,phase:"BLOCKED",execution:{...e.execution,lastProgress:`BLOCKED: ${s}`}}),C=(e,s)=>({...e,decisions:[...e.decisions,s]}),F=e=>({...e,phase:"IDLE",spec:null,branch:null,discovery:{answers:[],completed:!1},specState:{path:null,status:"none"},execution:{iteration:0,lastProgress:null,modifiedFiles:[],lastVerification:null,awaitingStatusReport:!1,debt:null,completedTasks:[]},decisions:[],pendingClear:!1,classification:null});export{h as a,d as b,E as c,u as d,m as e,S as f,D as g,C as h,F as i};
|
package/chunks/chunk-ACQUINWH.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var i=class extends Error{capability;runtimeName;constructor(e,r){super(`Capability "${e}" is not available on runtime "${r}"`),this.name="RuntimeCapabilityError",this.capability=e,this.runtimeName=r}},o=class extends Error{path;constructor(e){super(`No such file or directory: ${e}`),this.name="NotFoundError",this.path=e}},s=class extends Error{path;constructor(e){super(`File or directory already exists: ${e}`),this.name="AlreadyExistsError",this.path=e}},a=class extends Error{cmd;code;stderr;constructor(e,r,n){super(`Command "${e}" failed with exit code ${r}: ${n}`),this.name="ProcessError",this.cmd=e,this.code=r,this.stderr=n}};export{i as a,o as b,s as c,a as d};
|