fleetlens 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/app/apps/web/.next/BUILD_ID +1 -1
  2. package/app/apps/web/.next/build-manifest.json +3 -3
  3. package/app/apps/web/.next/prerender-manifest.json +3 -3
  4. package/app/apps/web/.next/server/app/_global-error.html +1 -1
  5. package/app/apps/web/.next/server/app/_global-error.rsc +1 -1
  6. package/app/apps/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  7. package/app/apps/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/app/apps/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  9. package/app/apps/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  10. package/app/apps/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  11. package/app/apps/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  12. package/app/apps/web/.next/server/app/agent/page_client-reference-manifest.js +1 -1
  13. package/app/apps/web/.next/server/app/api/agent/chats/[id]/events/route.js +3 -1
  14. package/app/apps/web/.next/server/app/api/agent/chats/[id]/events/route.js.nft.json +1 -1
  15. package/app/apps/web/.next/server/app/api/agent/chats/[id]/messages/route.js +1 -1
  16. package/app/apps/web/.next/server/app/api/agent/chats/[id]/messages/route.js.nft.json +1 -1
  17. package/app/apps/web/.next/server/app/api/agent/chats/[id]/route.js +3 -1
  18. package/app/apps/web/.next/server/app/api/agent/chats/[id]/route.js.nft.json +1 -1
  19. package/app/apps/web/.next/server/app/api/agent/chats/[id]/stop/route.js +3 -1
  20. package/app/apps/web/.next/server/app/api/agent/chats/[id]/stop/route.js.nft.json +1 -1
  21. package/app/apps/web/.next/server/app/api/agent/chats/route.js +3 -1
  22. package/app/apps/web/.next/server/app/api/agent/chats/route.js.nft.json +1 -1
  23. package/app/apps/web/.next/server/app/api/agent/index/route.js +1 -1
  24. package/app/apps/web/.next/server/app/api/agent/index/route.js.nft.json +1 -1
  25. package/app/apps/web/.next/server/app/api/agent/mcp/route.js +1 -1
  26. package/app/apps/web/.next/server/app/api/agent/mcp/route.js.nft.json +1 -1
  27. package/app/apps/web/.next/server/app/api/agent/suggestions/route.js +1 -1
  28. package/app/apps/web/.next/server/app/api/agent/suggestions/route.js.nft.json +1 -1
  29. package/app/apps/web/.next/server/app/api/ask/route.js +1 -1
  30. package/app/apps/web/.next/server/app/api/ask/route.js.nft.json +1 -1
  31. package/app/apps/web/.next/server/app/api/digest/day/[date]/route.js +1 -1
  32. package/app/apps/web/.next/server/app/api/digest/day/[date]/route.js.nft.json +1 -1
  33. package/app/apps/web/.next/server/app/api/digest/month/[yearMonth]/route.js +1 -1
  34. package/app/apps/web/.next/server/app/api/digest/month/[yearMonth]/route.js.nft.json +1 -1
  35. package/app/apps/web/.next/server/app/api/digest/month-index/route.js +1 -1
  36. package/app/apps/web/.next/server/app/api/digest/month-index/route.js.nft.json +1 -1
  37. package/app/apps/web/.next/server/app/api/digest/week/[startDate]/route.js +1 -1
  38. package/app/apps/web/.next/server/app/api/digest/week/[startDate]/route.js.nft.json +1 -1
  39. package/app/apps/web/.next/server/app/api/digest/week-index/route.js +1 -1
  40. package/app/apps/web/.next/server/app/api/digest/week-index/route.js.nft.json +1 -1
  41. package/app/apps/web/.next/server/app/api/pdf/[key]/route.js +1 -1
  42. package/app/apps/web/.next/server/app/api/pdf/[key]/route.js.nft.json +1 -1
  43. package/app/apps/web/.next/server/app/api/projects/open-folder/route.js +1 -1
  44. package/app/apps/web/.next/server/app/api/projects/open-folder/route.js.nft.json +1 -1
  45. package/app/apps/web/.next/server/app/api/settings/credentials/route.js +1 -1
  46. package/app/apps/web/.next/server/app/api/settings/credentials/route.js.nft.json +1 -1
  47. package/app/apps/web/.next/server/app/api/settings/route.js +1 -1
  48. package/app/apps/web/.next/server/app/api/settings/route.js.nft.json +1 -1
  49. package/app/apps/web/.next/server/app/api/team/onboarding/start/route.js +1 -1
  50. package/app/apps/web/.next/server/app/api/team/onboarding/start/route.js.nft.json +1 -1
  51. package/app/apps/web/.next/server/app/api/team/sync-projects/route.js +1 -1
  52. package/app/apps/web/.next/server/app/api/team/sync-projects/route.js.nft.json +1 -1
  53. package/app/apps/web/.next/server/app/changelog/page_client-reference-manifest.js +1 -1
  54. package/app/apps/web/.next/server/app/day/[date]/page_client-reference-manifest.js +1 -1
  55. package/app/apps/web/.next/server/app/day/page_client-reference-manifest.js +1 -1
  56. package/app/apps/web/.next/server/app/digest/[date]/page_client-reference-manifest.js +1 -1
  57. package/app/apps/web/.next/server/app/digest/page_client-reference-manifest.js +1 -1
  58. package/app/apps/web/.next/server/app/insights/[key]/page_client-reference-manifest.js +1 -1
  59. package/app/apps/web/.next/server/app/insights/page_client-reference-manifest.js +1 -1
  60. package/app/apps/web/.next/server/app/page_client-reference-manifest.js +1 -1
  61. package/app/apps/web/.next/server/app/parallelism/page_client-reference-manifest.js +1 -1
  62. package/app/apps/web/.next/server/app/print/[key]/page_client-reference-manifest.js +1 -1
  63. package/app/apps/web/.next/server/app/projects/[slug]/page_client-reference-manifest.js +1 -1
  64. package/app/apps/web/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  65. package/app/apps/web/.next/server/app/runs/page_client-reference-manifest.js +1 -1
  66. package/app/apps/web/.next/server/app/sessions/[id]/page_client-reference-manifest.js +1 -1
  67. package/app/apps/web/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
  68. package/app/apps/web/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  69. package/app/apps/web/.next/server/app/team/onboarding/page_client-reference-manifest.js +1 -1
  70. package/app/apps/web/.next/server/app/team/page_client-reference-manifest.js +1 -1
  71. package/app/apps/web/.next/server/app/usage/page_client-reference-manifest.js +1 -1
  72. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__038-.1r._.js → [root-of-the-server]__0-09rjv._.js} +2 -2
  73. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__0_5tf-2._.js → [root-of-the-server]__01oercw._.js} +5 -5
  74. package/app/apps/web/.next/server/chunks/[root-of-the-server]__02.51sr._.js +1 -1
  75. package/app/apps/web/.next/server/chunks/[root-of-the-server]__057w7kr._.js +28 -0
  76. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__0pirsh0._.js → [root-of-the-server]__07b5796._.js} +2 -2
  77. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__02puo0u._.js → [root-of-the-server]__07xaqv3._.js} +2 -2
  78. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__06xto5z._.js → [root-of-the-server]__08c24et._.js} +2 -2
  79. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__0mvl0qn._.js → [root-of-the-server]__08m2h38._.js} +2 -2
  80. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__0mx_9mb._.js → [root-of-the-server]__0c7ght_._.js} +2 -2
  81. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__12iid50._.js → [root-of-the-server]__0l5i8nk._.js} +2 -2
  82. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__04g-b-m._.js → [root-of-the-server]__0mcer3z._.js} +2 -2
  83. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0o9lsie._.js +30 -0
  84. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__0367vbv._.js → [root-of-the-server]__0ozooam._.js} +2 -2
  85. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0uf_ch4._.js +28 -0
  86. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0uiom2m._.js +28 -0
  87. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__096_llw._.js → [root-of-the-server]__0usaajs._.js} +2 -2
  88. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__06irs4z._.js → [root-of-the-server]__0zyh554._.js} +2 -2
  89. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__0gvw6dk._.js → [root-of-the-server]__0~4wgaf._.js} +2 -2
  90. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0~~bpcw._.js +3 -0
  91. package/app/apps/web/.next/server/chunks/{[root-of-the-server]__01~cgp8._.js → [root-of-the-server]__10.g-w1._.js} +2 -2
  92. package/app/apps/web/.next/server/chunks/[root-of-the-server]__12vjv4c._.js +28 -0
  93. package/app/apps/web/.next/server/chunks/packages_entries_dist_node_0bckr7-.js +19 -19
  94. package/app/apps/web/.next/server/chunks/ssr/_0k8yioi._.js +1 -1
  95. package/app/apps/web/.next/server/chunks/ssr/apps_web_lib_changelog_ts_0n7_p1d._.js +1 -1
  96. package/app/apps/web/.next/server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js +1 -1
  97. package/app/apps/web/.next/server/middleware-build-manifest.js +3 -3
  98. package/app/apps/web/.next/server/middleware-manifest.json +5 -5
  99. package/app/apps/web/.next/server/pages/500.html +1 -1
  100. package/app/apps/web/.next/server/server-reference-manifest.js +1 -1
  101. package/app/apps/web/.next/server/server-reference-manifest.json +1 -1
  102. package/app/apps/web/.next/static/chunks/0ntt~a0712~pv.js +14 -0
  103. package/app/apps/web/app/api/ask/route.ts +8 -2
  104. package/app/apps/web/lib/agent/run.ts +11 -2
  105. package/app/apps/web/lib/changelog-data.generated.ts +1 -1
  106. package/app/apps/web/package.json +1 -1
  107. package/app/apps/web/tsconfig.tsbuildinfo +1 -1
  108. package/dist/daemon-worker.js +104 -55
  109. package/dist/index.js +174 -113
  110. package/menubar/Fleetlens.app/Contents/Info.plist +2 -2
  111. package/menubar/Fleetlens.app/Contents/MacOS/FleetlensMenubar +0 -0
  112. package/package.json +1 -1
  113. package/app/apps/web/.next/server/chunks/[root-of-the-server]__02faosk._.js +0 -30
  114. package/app/apps/web/.next/server/chunks/[root-of-the-server]__02petpy._.js +0 -3
  115. package/app/apps/web/.next/server/chunks/[root-of-the-server]__09cgmam._.js +0 -28
  116. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0tk8p3d._.js +0 -28
  117. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0u6pamj._.js +0 -28
  118. package/app/apps/web/.next/server/chunks/[root-of-the-server]__12jomao._.js +0 -28
  119. package/app/apps/web/.next/static/chunks/0dqhn7-3.038l.js +0 -14
  120. /package/app/apps/web/.next/static/{zyhoVMC9iNC5vofPFRY6z → Shk_TH0B6lHs9cBZekkf5}/_buildManifest.js +0 -0
  121. /package/app/apps/web/.next/static/{zyhoVMC9iNC5vofPFRY6z → Shk_TH0B6lHs9cBZekkf5}/_clientMiddlewareManifest.js +0 -0
  122. /package/app/apps/web/.next/static/{zyhoVMC9iNC5vofPFRY6z → Shk_TH0B6lHs9cBZekkf5}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- module.exports=[82111,95549,90555,78325,86291,56614,20441,77242,21628,54832,e=>{"use strict";let t;var n,s,a,r,i,o,l,u=e.i(91530);e.s([],54033),e.i(54033),(n=r||(r={})).assertEqual=e=>{},n.assertIs=function(e){},n.assertNever=function(e){throw Error()},n.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},n.getValidEnumValues=e=>{let t=n.objectKeys(e).filter(t=>"number"!=typeof e[e[t]]),s={};for(let n of t)s[n]=e[n];return n.objectValues(s)},n.objectValues=e=>n.objectKeys(e).map(function(t){return e[t]}),n.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},n.find=(e,t)=>{for(let n of e)if(t(n))return n},n.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,n.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},n.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(i||(i={})).mergeShapes=(e,t)=>({...e,...t});let d=r.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),c=e=>{switch(typeof e){case"undefined":return d.undefined;case"string":return d.string;case"number":return Number.isNaN(e)?d.nan:d.number;case"boolean":return d.boolean;case"function":return d.function;case"bigint":return d.bigint;case"symbol":return d.symbol;case"object":if(Array.isArray(e))return d.array;if(null===e)return d.null;if(e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch)return d.promise;if("u">typeof Map&&e instanceof Map)return d.map;if("u">typeof Set&&e instanceof Set)return d.set;if("u">typeof Date&&e instanceof Date)return d.date;return d.object;default:return d.unknown}};e.s(["ZodParsedType",0,d,"getParsedType",0,c,"objectUtil",0,i,"util",0,r],42944);let p=r.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),h=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class m extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},s=e=>{for(let a of e.issues)if("invalid_union"===a.code)a.unionErrors.map(s);else if("invalid_return_type"===a.code)s(a.returnTypeError);else if("invalid_arguments"===a.code)s(a.argumentsError);else if(0===a.path.length)n._errors.push(t(a));else{let e=n,s=0;for(;s<a.path.length;){let n=a.path[s];s===a.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(a))):e[n]=e[n]||{_errors:[]},e=e[n],s++}}};return s(this),n}static assert(e){if(!(e instanceof m))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,r.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){let t={},n=[];for(let s of this.issues)if(s.path.length>0){let n=s.path[0];t[n]=t[n]||[],t[n].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}m.create=e=>new m(e),e.s(["ZodError",0,m,"ZodIssueCode",0,p,"quotelessJson",0,h],15235);let _=(e,t)=>{let n;switch(e.code){case p.invalid_type:n=e.received===d.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case p.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,r.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:n=`Unrecognized key(s) in object: ${r.joinValues(e.keys,", ")}`;break;case p.invalid_union:n="Invalid input";break;case p.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${r.joinValues(e.options)}`;break;case p.invalid_enum_value:n=`Invalid enum value. Expected ${r.joinValues(e.options)}, received '${e.received}'`;break;case p.invalid_arguments:n="Invalid function arguments";break;case p.invalid_return_type:n="Invalid function return type";break;case p.invalid_date:n="Invalid date";break;case p.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:r.assertNever(e.validation):n="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case p.too_small:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case p.too_big:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case p.custom:n="Invalid input";break;case p.invalid_intersection_types:n="Intersection results could not be merged";break;case p.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case p.not_finite:n="Number must be finite";break;default:n=t.defaultError,r.assertNever(e)}return{message:n}},f=_;function g(e){f=e}function y(){return f}e.s(["getErrorMap",0,y,"setErrorMap",0,g],85676),e.i(85676),e.s(["defaultErrorMap",0,_,"getErrorMap",0,y,"setErrorMap",0,g],76733),e.i(76733);let v=e=>{let{data:t,path:n,errorMaps:s,issueData:a}=e,r=[...n,...a.path||[]],i={...a,path:r};if(void 0!==a.message)return{...a,path:r,message:a.message};let o="";for(let e of s.filter(e=>!!e).slice().reverse())o=e(i,{data:t,defaultError:o}).message;return{...a,path:r,message:o}},w=[];function k(e,t){let n=y(),s=v({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===_?void 0:_].filter(e=>!!e)});e.common.issues.push(s)}class b{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){let n=[];for(let s of t){if("aborted"===s.status)return x;"dirty"===s.status&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let e of t){let t=await e.key,s=await e.value;n.push({key:t,value:s})}return b.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let s of t){let{key:t,value:a}=s;if("aborted"===t.status||"aborted"===a.status)return x;"dirty"===t.status&&e.dirty(),"dirty"===a.status&&e.dirty(),"__proto__"!==t.value&&(void 0!==a.value||s.alwaysSet)&&(n[t.value]=a.value)}return{status:e.value,value:n}}}let x=Object.freeze({status:"aborted"}),S=e=>({status:"dirty",value:e}),$=e=>({status:"valid",value:e}),T=e=>"aborted"===e.status,N=e=>"dirty"===e.status,j=e=>"valid"===e.status,O=e=>"u">typeof Promise&&e instanceof Promise;e.s(["DIRTY",0,S,"EMPTY_PATH",0,w,"INVALID",0,x,"OK",0,$,"ParseStatus",0,b,"addIssueToContext",0,k,"isAborted",0,T,"isAsync",0,O,"isDirty",0,N,"isValid",0,j,"makeIssue",0,v],84488),e.i(84488),e.s([],91316),e.i(91316),e.i(42944),(s=o||(o={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},s.toString=e=>"string"==typeof e?e:e?.message;class M{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}let E=(e,t)=>{if(j(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new m(e.common.issues);return this._error=t,this._error}}};function A(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:s,description:a}=e;if(t&&(n||s))throw Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:a}:{errorMap:(t,a)=>{let{message:r}=e;return"invalid_enum_value"===t.code?{message:r??a.defaultError}:void 0===a.data?{message:r??s??a.defaultError}:"invalid_type"!==t.code?{message:a.defaultError}:{message:r??n??a.defaultError}},description:a}}class P{get description(){return this._def.description}_getType(e){return c(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:c(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new b,ctx:{common:e.parent.common,data:e.data,parsedType:c(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(O(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){return Promise.resolve(this._parse(e))}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:c(e)},s=this._parseSync({data:e,path:n.path,parent:n});return E(n,s)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:c(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:t});return j(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>j(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:c(e)},s=this._parse({data:e,path:n.path,parent:n});return E(n,await (O(s)?s:Promise.resolve(s)))}refine(e,t){return this._refinement((n,s)=>{let a=e(n),r=()=>s.addIssue({code:p.custom,..."string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(n):t});return"u">typeof Promise&&a instanceof Promise?a.then(e=>!!e||(r(),!1)):!!a||(r(),!1)})}refinement(e,t){return this._refinement((n,s)=>!!e(n)||(s.addIssue("function"==typeof t?t(n,s):t),!1))}_refinement(e){return new eN({schema:this,typeName:l.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return ej.create(this,this._def)}nullable(){return eO.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ed.create(this)}promise(){return eT.create(this,this._def)}or(e){return ep.create([this,e],this._def)}and(e){return e_.create(this,e,this._def)}transform(e){return new eN({...A(this._def),schema:this,typeName:l.ZodEffects,effect:{type:"transform",transform:e}})}default(e){return new eM({...A(this._def),innerType:this,defaultValue:"function"==typeof e?e:()=>e,typeName:l.ZodDefault})}brand(){return new eZ({typeName:l.ZodBranded,type:this,...A(this._def)})}catch(e){return new eE({...A(this._def),innerType:this,catchValue:"function"==typeof e?e:()=>e,typeName:l.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return eD.create(this,e)}readonly(){return eI.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}let Z=/^c[^\s-]{8,}$/i,D=/^[0-9a-z]+$/,I=/^[0-9A-HJKMNP-TV-Z]{26}$/i,C=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,L=/^[a-z0-9_-]{21}$/i,R=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,U=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,F=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Y=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,W=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,z=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,B=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,J=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,V=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,H="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",q=RegExp(`^${H}$`);function K(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);let n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function G(e){let t=`${H}T${K(e)}`,n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,RegExp(`^${t}$`)}class X extends P{_parse(e){var n,s,a,i;let o;if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==d.string){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.string,received:t.parsedType}),x}let l=new b;for(let u of this._def.checks)if("min"===u.kind)e.data.length<u.value&&(k(o=this._getOrReturnCtx(e,o),{code:p.too_small,minimum:u.value,type:"string",inclusive:!0,exact:!1,message:u.message}),l.dirty());else if("max"===u.kind)e.data.length>u.value&&(k(o=this._getOrReturnCtx(e,o),{code:p.too_big,maximum:u.value,type:"string",inclusive:!0,exact:!1,message:u.message}),l.dirty());else if("length"===u.kind){let t=e.data.length>u.value,n=e.data.length<u.value;(t||n)&&(o=this._getOrReturnCtx(e,o),t?k(o,{code:p.too_big,maximum:u.value,type:"string",inclusive:!0,exact:!0,message:u.message}):n&&k(o,{code:p.too_small,minimum:u.value,type:"string",inclusive:!0,exact:!0,message:u.message}),l.dirty())}else if("email"===u.kind)F.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{validation:"email",code:p.invalid_string,message:u.message}),l.dirty());else if("emoji"===u.kind)t||(t=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),t.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{validation:"emoji",code:p.invalid_string,message:u.message}),l.dirty());else if("uuid"===u.kind)C.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{validation:"uuid",code:p.invalid_string,message:u.message}),l.dirty());else if("nanoid"===u.kind)L.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{validation:"nanoid",code:p.invalid_string,message:u.message}),l.dirty());else if("cuid"===u.kind)Z.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{validation:"cuid",code:p.invalid_string,message:u.message}),l.dirty());else if("cuid2"===u.kind)D.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{validation:"cuid2",code:p.invalid_string,message:u.message}),l.dirty());else if("ulid"===u.kind)I.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{validation:"ulid",code:p.invalid_string,message:u.message}),l.dirty());else if("url"===u.kind)try{new URL(e.data)}catch{k(o=this._getOrReturnCtx(e,o),{validation:"url",code:p.invalid_string,message:u.message}),l.dirty()}else"regex"===u.kind?(u.regex.lastIndex=0,u.regex.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{validation:"regex",code:p.invalid_string,message:u.message}),l.dirty())):"trim"===u.kind?e.data=e.data.trim():"includes"===u.kind?e.data.includes(u.value,u.position)||(k(o=this._getOrReturnCtx(e,o),{code:p.invalid_string,validation:{includes:u.value,position:u.position},message:u.message}),l.dirty()):"toLowerCase"===u.kind?e.data=e.data.toLowerCase():"toUpperCase"===u.kind?e.data=e.data.toUpperCase():"startsWith"===u.kind?e.data.startsWith(u.value)||(k(o=this._getOrReturnCtx(e,o),{code:p.invalid_string,validation:{startsWith:u.value},message:u.message}),l.dirty()):"endsWith"===u.kind?e.data.endsWith(u.value)||(k(o=this._getOrReturnCtx(e,o),{code:p.invalid_string,validation:{endsWith:u.value},message:u.message}),l.dirty()):"datetime"===u.kind?G(u).test(e.data)||(k(o=this._getOrReturnCtx(e,o),{code:p.invalid_string,validation:"datetime",message:u.message}),l.dirty()):"date"===u.kind?q.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{code:p.invalid_string,validation:"date",message:u.message}),l.dirty()):"time"===u.kind?RegExp(`^${K(u)}$`).test(e.data)||(k(o=this._getOrReturnCtx(e,o),{code:p.invalid_string,validation:"time",message:u.message}),l.dirty()):"duration"===u.kind?U.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{validation:"duration",code:p.invalid_string,message:u.message}),l.dirty()):"ip"===u.kind?(n=e.data,!(("v4"===(s=u.version)||!s)&&Y.test(n)||("v6"===s||!s)&&z.test(n))&&1&&(k(o=this._getOrReturnCtx(e,o),{validation:"ip",code:p.invalid_string,message:u.message}),l.dirty())):"jwt"===u.kind?!function(e,t){if(!R.test(e))return!1;try{let[n]=e.split(".");if(!n)return!1;let s=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),a=JSON.parse(atob(s));if("object"!=typeof a||null===a||"typ"in a&&a?.typ!=="JWT"||!a.alg||t&&a.alg!==t)return!1;return!0}catch{return!1}}(e.data,u.alg)&&(k(o=this._getOrReturnCtx(e,o),{validation:"jwt",code:p.invalid_string,message:u.message}),l.dirty()):"cidr"===u.kind?(a=e.data,!(("v4"===(i=u.version)||!i)&&W.test(a)||("v6"===i||!i)&&B.test(a))&&1&&(k(o=this._getOrReturnCtx(e,o),{validation:"cidr",code:p.invalid_string,message:u.message}),l.dirty())):"base64"===u.kind?J.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{validation:"base64",code:p.invalid_string,message:u.message}),l.dirty()):"base64url"===u.kind?V.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{validation:"base64url",code:p.invalid_string,message:u.message}),l.dirty()):r.assertNever(u);return{status:l.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:p.invalid_string,...o.errToObj(n)})}_addCheck(e){return new X({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...o.errToObj(e)})}url(e){return this._addCheck({kind:"url",...o.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...o.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...o.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...o.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...o.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...o.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...o.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...o.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...o.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...o.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...o.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...o.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...o.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...o.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...o.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...o.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...o.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...o.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...o.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...o.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...o.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...o.errToObj(t)})}nonempty(e){return this.min(1,o.errToObj(e))}trim(){return new X({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new X({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new X({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}X.create=e=>new X({checks:[],typeName:l.ZodString,coerce:e?.coerce??!1,...A(e)});class Q extends P{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){let t;if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==d.number){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.number,received:t.parsedType}),x}let n=new b;for(let s of this._def.checks)"int"===s.kind?r.isInteger(e.data)||(k(t=this._getOrReturnCtx(e,t),{code:p.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty()):"min"===s.kind?(s.inclusive?e.data<s.value:e.data<=s.value)&&(k(t=this._getOrReturnCtx(e,t),{code:p.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):"max"===s.kind?(s.inclusive?e.data>s.value:e.data>=s.value)&&(k(t=this._getOrReturnCtx(e,t),{code:p.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):"multipleOf"===s.kind?0!==function(e,t){let n=(e.toString().split(".")[1]||"").length,s=(t.toString().split(".")[1]||"").length,a=n>s?n:s;return Number.parseInt(e.toFixed(a).replace(".",""))%Number.parseInt(t.toFixed(a).replace(".",""))/10**a}(e.data,s.value)&&(k(t=this._getOrReturnCtx(e,t),{code:p.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):"finite"===s.kind?Number.isFinite(e.data)||(k(t=this._getOrReturnCtx(e,t),{code:p.not_finite,message:s.message}),n.dirty()):r.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,o.toString(t))}gt(e,t){return this.setLimit("min",e,!1,o.toString(t))}lte(e,t){return this.setLimit("max",e,!0,o.toString(t))}lt(e,t){return this.setLimit("max",e,!1,o.toString(t))}setLimit(e,t,n,s){return new Q({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:o.toString(s)}]})}_addCheck(e){return new Q({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:o.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:o.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:o.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:o.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:o.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:o.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:o.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:o.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:o.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>"int"===e.kind||"multipleOf"===e.kind&&r.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if("finite"===n.kind||"int"===n.kind||"multipleOf"===n.kind)return!0;else"min"===n.kind?(null===t||n.value>t)&&(t=n.value):"max"===n.kind&&(null===e||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}}Q.create=e=>new Q({checks:[],typeName:l.ZodNumber,coerce:e?.coerce||!1,...A(e)});class ee extends P{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){let t;if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==d.bigint)return this._getInvalidInput(e);let n=new b;for(let s of this._def.checks)"min"===s.kind?(s.inclusive?e.data<s.value:e.data<=s.value)&&(k(t=this._getOrReturnCtx(e,t),{code:p.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):"max"===s.kind?(s.inclusive?e.data>s.value:e.data>=s.value)&&(k(t=this._getOrReturnCtx(e,t),{code:p.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):"multipleOf"===s.kind?e.data%s.value!==BigInt(0)&&(k(t=this._getOrReturnCtx(e,t),{code:p.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):r.assertNever(s);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.bigint,received:t.parsedType}),x}gte(e,t){return this.setLimit("min",e,!0,o.toString(t))}gt(e,t){return this.setLimit("min",e,!1,o.toString(t))}lte(e,t){return this.setLimit("max",e,!0,o.toString(t))}lt(e,t){return this.setLimit("max",e,!1,o.toString(t))}setLimit(e,t,n,s){return new ee({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:o.toString(s)}]})}_addCheck(e){return new ee({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:o.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:o.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:o.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:o.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:o.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}ee.create=e=>new ee({checks:[],typeName:l.ZodBigInt,coerce:e?.coerce??!1,...A(e)});class et extends P{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==d.boolean){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.boolean,received:t.parsedType}),x}return $(e.data)}}et.create=e=>new et({typeName:l.ZodBoolean,coerce:e?.coerce||!1,...A(e)});class en extends P{_parse(e){let t;if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==d.date){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.date,received:t.parsedType}),x}if(Number.isNaN(e.data.getTime()))return k(this._getOrReturnCtx(e),{code:p.invalid_date}),x;let n=new b;for(let s of this._def.checks)"min"===s.kind?e.data.getTime()<s.value&&(k(t=this._getOrReturnCtx(e,t),{code:p.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):"max"===s.kind?e.data.getTime()>s.value&&(k(t=this._getOrReturnCtx(e,t),{code:p.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):r.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new en({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:o.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:o.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}en.create=e=>new en({checks:[],coerce:e?.coerce||!1,typeName:l.ZodDate,...A(e)});class es extends P{_parse(e){if(this._getType(e)!==d.symbol){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.symbol,received:t.parsedType}),x}return $(e.data)}}es.create=e=>new es({typeName:l.ZodSymbol,...A(e)});class ea extends P{_parse(e){if(this._getType(e)!==d.undefined){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.undefined,received:t.parsedType}),x}return $(e.data)}}ea.create=e=>new ea({typeName:l.ZodUndefined,...A(e)});class er extends P{_parse(e){if(this._getType(e)!==d.null){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.null,received:t.parsedType}),x}return $(e.data)}}er.create=e=>new er({typeName:l.ZodNull,...A(e)});class ei extends P{constructor(){super(...arguments),this._any=!0}_parse(e){return $(e.data)}}ei.create=e=>new ei({typeName:l.ZodAny,...A(e)});class eo extends P{constructor(){super(...arguments),this._unknown=!0}_parse(e){return $(e.data)}}eo.create=e=>new eo({typeName:l.ZodUnknown,...A(e)});class el extends P{_parse(e){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.never,received:t.parsedType}),x}}el.create=e=>new el({typeName:l.ZodNever,...A(e)});class eu extends P{_parse(e){if(this._getType(e)!==d.undefined){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.void,received:t.parsedType}),x}return $(e.data)}}eu.create=e=>new eu({typeName:l.ZodVoid,...A(e)});class ed extends P{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==d.array)return k(t,{code:p.invalid_type,expected:d.array,received:t.parsedType}),x;if(null!==s.exactLength){let e=t.data.length>s.exactLength.value,a=t.data.length<s.exactLength.value;(e||a)&&(k(t,{code:e?p.too_big:p.too_small,minimum:a?s.exactLength.value:void 0,maximum:e?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(null!==s.minLength&&t.data.length<s.minLength.value&&(k(t,{code:p.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),null!==s.maxLength&&t.data.length>s.maxLength.value&&(k(t,{code:p.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>s.type._parseAsync(new M(t,e,t.path,n)))).then(e=>b.mergeArray(n,e));let a=[...t.data].map((e,n)=>s.type._parseSync(new M(t,e,t.path,n)));return b.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new ed({...this._def,minLength:{value:e,message:o.toString(t)}})}max(e,t){return new ed({...this._def,maxLength:{value:e,message:o.toString(t)}})}length(e,t){return new ed({...this._def,exactLength:{value:e,message:o.toString(t)}})}nonempty(e){return this.min(1,e)}}ed.create=(e,t)=>new ed({type:e,minLength:null,maxLength:null,exactLength:null,typeName:l.ZodArray,...A(t)});class ec extends P{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;let e=this._def.shape(),t=r.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==d.object){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.object,received:t.parsedType}),x}let{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),r=[];if(!(this._def.catchall instanceof el&&"strip"===this._def.unknownKeys))for(let e in n.data)a.includes(e)||r.push(e);let i=[];for(let e of a){let t=s[e],a=n.data[e];i.push({key:{status:"valid",value:e},value:t._parse(new M(n,a,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof el){let e=this._def.unknownKeys;if("passthrough"===e)for(let e of r)i.push({key:{status:"valid",value:e},value:{status:"valid",value:n.data[e]}});else if("strict"===e)r.length>0&&(k(n,{code:p.unrecognized_keys,keys:r}),t.dirty());else if("strip"===e);else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let e=this._def.catchall;for(let t of r){let s=n.data[t];i.push({key:{status:"valid",value:t},value:e._parse(new M(n,s,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of i){let n=await t.key,s=await t.value;e.push({key:n,value:s,alwaysSet:t.alwaysSet})}return e}).then(e=>b.mergeObjectSync(t,e)):b.mergeObjectSync(t,i)}get shape(){return this._def.shape()}strict(e){return o.errToObj,new ec({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,n)=>{let s=this._def.errorMap?.(t,n).message??n.defaultError;return"unrecognized_keys"===t.code?{message:o.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new ec({...this._def,unknownKeys:"strip"})}passthrough(){return new ec({...this._def,unknownKeys:"passthrough"})}extend(e){return new ec({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ec({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:l.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ec({...this._def,catchall:e})}pick(e){let t={};for(let n of r.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new ec({...this._def,shape:()=>t})}omit(e){let t={};for(let n of r.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new ec({...this._def,shape:()=>t})}deepPartial(){return function e(t){if(t instanceof ec){let n={};for(let s in t.shape){let a=t.shape[s];n[s]=ej.create(e(a))}return new ec({...t._def,shape:()=>n})}if(t instanceof ed)return new ed({...t._def,type:e(t.element)});if(t instanceof ej)return ej.create(e(t.unwrap()));if(t instanceof eO)return eO.create(e(t.unwrap()));if(t instanceof ef)return ef.create(t.items.map(t=>e(t)));else return t}(this)}partial(e){let t={};for(let n of r.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}return new ec({...this._def,shape:()=>t})}required(e){let t={};for(let n of r.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let e=this.shape[n];for(;e instanceof ej;)e=e._def.innerType;t[n]=e}return new ec({...this._def,shape:()=>t})}keyof(){return ex(r.objectKeys(this.shape))}}ec.create=(e,t)=>new ec({shape:()=>e,unknownKeys:"strip",catchall:el.create(),typeName:l.ZodObject,...A(t)}),ec.strictCreate=(e,t)=>new ec({shape:()=>e,unknownKeys:"strict",catchall:el.create(),typeName:l.ZodObject,...A(t)}),ec.lazycreate=(e,t)=>new ec({shape:e,unknownKeys:"strip",catchall:el.create(),typeName:l.ZodObject,...A(t)});class ep extends P{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(function(e){for(let t of e)if("valid"===t.result.status)return t.result;for(let n of e)if("dirty"===n.result.status)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new m(e.ctx.common.issues));return k(t,{code:p.invalid_union,unionErrors:n}),x});{let e,s=[];for(let a of n){let n={...t,common:{...t.common,issues:[]},parent:null},r=a._parseSync({data:t.data,path:t.path,parent:n});if("valid"===r.status)return r;"dirty"!==r.status||e||(e={result:r,ctx:n}),n.common.issues.length&&s.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let a=s.map(e=>new m(e));return k(t,{code:p.invalid_union,unionErrors:a}),x}}get options(){return this._def.options}}ep.create=(e,t)=>new ep({options:e,typeName:l.ZodUnion,...A(t)});let eh=e=>{if(e instanceof ek)return eh(e.schema);if(e instanceof eN)return eh(e.innerType());if(e instanceof eb)return[e.value];if(e instanceof eS)return e.options;if(e instanceof e$)return r.objectValues(e.enum);else if(e instanceof eM)return eh(e._def.innerType);else if(e instanceof ea)return[void 0];else if(e instanceof er)return[null];else if(e instanceof ej)return[void 0,...eh(e.unwrap())];else if(e instanceof eO)return[null,...eh(e.unwrap())];else if(e instanceof eZ)return eh(e.unwrap());else if(e instanceof eI)return eh(e.unwrap());else if(e instanceof eE)return eh(e._def.innerType);else return[]};class em extends P{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==d.object)return k(t,{code:p.invalid_type,expected:d.object,received:t.parsedType}),x;let n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(k(t,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),x)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let s=new Map;for(let n of t){let t=eh(n.shape[e]);if(!t.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of t){if(s.has(a))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,n)}}return new em({typeName:l.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...A(n)})}}class e_ extends P{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=(e,s)=>{if(T(e)||T(s))return x;let a=function e(t,n){let s=c(t),a=c(n);if(t===n)return{valid:!0,data:t};if(s===d.object&&a===d.object){let s=r.objectKeys(n),a=r.objectKeys(t).filter(e=>-1!==s.indexOf(e)),i={...t,...n};for(let s of a){let a=e(t[s],n[s]);if(!a.valid)return{valid:!1};i[s]=a.data}return{valid:!0,data:i}}if(s===d.array&&a===d.array){if(t.length!==n.length)return{valid:!1};let s=[];for(let a=0;a<t.length;a++){let r=e(t[a],n[a]);if(!r.valid)return{valid:!1};s.push(r.data)}return{valid:!0,data:s}}if(s===d.date&&a===d.date&&+t==+n)return{valid:!0,data:t};return{valid:!1}}(e.value,s.value);return a.valid?((N(e)||N(s))&&t.dirty(),{status:t.value,value:a.data}):(k(n,{code:p.invalid_intersection_types}),x)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>s(e,t)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}e_.create=(e,t,n)=>new e_({left:e,right:t,typeName:l.ZodIntersection,...A(n)});class ef extends P{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==d.array)return k(n,{code:p.invalid_type,expected:d.array,received:n.parsedType}),x;if(n.data.length<this._def.items.length)return k(n,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),x;!this._def.rest&&n.data.length>this._def.items.length&&(k(n,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let s=[...n.data].map((e,t)=>{let s=this._def.items[t]||this._def.rest;return s?s._parse(new M(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(s).then(e=>b.mergeArray(t,e)):b.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new ef({...this._def,rest:e})}}ef.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new ef({items:e,typeName:l.ZodTuple,rest:null,...A(t)})};class eg extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==d.object)return k(n,{code:p.invalid_type,expected:d.object,received:n.parsedType}),x;let s=[],a=this._def.keyType,r=this._def.valueType;for(let e in n.data)s.push({key:a._parse(new M(n,e,n.path,e)),value:r._parse(new M(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?b.mergeObjectAsync(t,s):b.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return new eg(t instanceof P?{keyType:e,valueType:t,typeName:l.ZodRecord,...A(n)}:{keyType:X.create(),valueType:e,typeName:l.ZodRecord,...A(t)})}}class ey extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==d.map)return k(n,{code:p.invalid_type,expected:d.map,received:n.parsedType}),x;let s=this._def.keyType,a=this._def.valueType,r=[...n.data.entries()].map(([e,t],r)=>({key:s._parse(new M(n,e,n.path,[r,"key"])),value:a._parse(new M(n,t,n.path,[r,"value"]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of r){let s=await n.key,a=await n.value;if("aborted"===s.status||"aborted"===a.status)return x;("dirty"===s.status||"dirty"===a.status)&&t.dirty(),e.set(s.value,a.value)}return{status:t.value,value:e}})}{let e=new Map;for(let n of r){let s=n.key,a=n.value;if("aborted"===s.status||"aborted"===a.status)return x;("dirty"===s.status||"dirty"===a.status)&&t.dirty(),e.set(s.value,a.value)}return{status:t.value,value:e}}}}ey.create=(e,t,n)=>new ey({valueType:t,keyType:e,typeName:l.ZodMap,...A(n)});class ev extends P{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==d.set)return k(n,{code:p.invalid_type,expected:d.set,received:n.parsedType}),x;let s=this._def;null!==s.minSize&&n.data.size<s.minSize.value&&(k(n,{code:p.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),null!==s.maxSize&&n.data.size>s.maxSize.value&&(k(n,{code:p.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());let a=this._def.valueType;function r(e){let n=new Set;for(let s of e){if("aborted"===s.status)return x;"dirty"===s.status&&t.dirty(),n.add(s.value)}return{status:t.value,value:n}}let i=[...n.data.values()].map((e,t)=>a._parse(new M(n,e,n.path,t)));return n.common.async?Promise.all(i).then(e=>r(e)):r(i)}min(e,t){return new ev({...this._def,minSize:{value:e,message:o.toString(t)}})}max(e,t){return new ev({...this._def,maxSize:{value:e,message:o.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ev.create=(e,t)=>new ev({valueType:e,minSize:null,maxSize:null,typeName:l.ZodSet,...A(t)});class ew extends P{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==d.function)return k(t,{code:p.invalid_type,expected:d.function,received:t.parsedType}),x;function n(e,n){return v({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,y(),_].filter(e=>!!e),issueData:{code:p.invalid_arguments,argumentsError:n}})}function s(e,n){return v({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,y(),_].filter(e=>!!e),issueData:{code:p.invalid_return_type,returnTypeError:n}})}let a={errorMap:t.common.contextualErrorMap},r=t.data;if(this._def.returns instanceof eT){let e=this;return $(async function(...t){let i=new m([]),o=await e._def.args.parseAsync(t,a).catch(e=>{throw i.addIssue(n(t,e)),i}),l=await Reflect.apply(r,this,o);return await e._def.returns._def.type.parseAsync(l,a).catch(e=>{throw i.addIssue(s(l,e)),i})})}{let e=this;return $(function(...t){let i=e._def.args.safeParse(t,a);if(!i.success)throw new m([n(t,i.error)]);let o=Reflect.apply(r,this,i.data),l=e._def.returns.safeParse(o,a);if(!l.success)throw new m([s(o,l.error)]);return l.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ew({...this._def,args:ef.create(e).rest(eo.create())})}returns(e){return new ew({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new ew({args:e||ef.create([]).rest(eo.create()),returns:t||eo.create(),typeName:l.ZodFunction,...A(n)})}}class ek extends P{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ek.create=(e,t)=>new ek({getter:e,typeName:l.ZodLazy,...A(t)});class eb extends P{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return k(t,{received:t.data,code:p.invalid_literal,expected:this._def.value}),x}return{status:"valid",value:e.data}}get value(){return this._def.value}}function ex(e,t){return new eS({values:e,typeName:l.ZodEnum,...A(t)})}eb.create=(e,t)=>new eb({value:e,typeName:l.ZodLiteral,...A(t)});class eS extends P{_parse(e){if("string"!=typeof e.data){let t=this._getOrReturnCtx(e),n=this._def.values;return k(t,{expected:r.joinValues(n),received:t.parsedType,code:p.invalid_type}),x}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return k(t,{received:t.data,code:p.invalid_enum_value,options:n}),x}return $(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return eS.create(e,{...this._def,...t})}exclude(e,t=this._def){return eS.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}eS.create=ex;class e$ extends P{_parse(e){let t=r.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==d.string&&n.parsedType!==d.number){let e=r.objectValues(t);return k(n,{expected:r.joinValues(e),received:n.parsedType,code:p.invalid_type}),x}if(this._cache||(this._cache=new Set(r.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let e=r.objectValues(t);return k(n,{received:n.data,code:p.invalid_enum_value,options:e}),x}return $(e.data)}get enum(){return this._def.values}}e$.create=(e,t)=>new e$({values:e,typeName:l.ZodNativeEnum,...A(t)});class eT extends P{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==d.promise&&!1===t.common.async?(k(t,{code:p.invalid_type,expected:d.promise,received:t.parsedType}),x):$((t.parsedType===d.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}eT.create=(e,t)=>new eT({type:e,typeName:l.ZodPromise,...A(t)});class eN extends P{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===l.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:e=>{k(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),"preprocess"===s.type){let e=s.transform(n.data,a);if(n.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return x;let s=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return"aborted"===s.status?x:"dirty"===s.status||"dirty"===t.value?S(s.value):s});{if("aborted"===t.value)return x;let s=this._def.schema._parseSync({data:e,path:n.path,parent:n});return"aborted"===s.status?x:"dirty"===s.status||"dirty"===t.value?S(s.value):s}}if("refinement"===s.type){let e=e=>{let t=s.refinement(e,a);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1!==n.common.async)return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>"aborted"===n.status?x:("dirty"===n.status&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))));{let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===s.status?x:("dirty"===s.status&&t.dirty(),e(s.value),{status:t.value,value:s.value})}}if("transform"===s.type)if(!1!==n.common.async)return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>j(e)?Promise.resolve(s.transform(e.value,a)).then(e=>({status:t.value,value:e})):x);else{let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!j(e))return x;let r=s.transform(e.value,a);if(r instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:r}}r.assertNever(s)}}eN.create=(e,t,n)=>new eN({schema:e,typeName:l.ZodEffects,effect:t,...A(n)}),eN.createWithPreprocess=(e,t,n)=>new eN({schema:t,effect:{type:"preprocess",transform:e},typeName:l.ZodEffects,...A(n)});class ej extends P{_parse(e){return this._getType(e)===d.undefined?$(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ej.create=(e,t)=>new ej({innerType:e,typeName:l.ZodOptional,...A(t)});class eO extends P{_parse(e){return this._getType(e)===d.null?$(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}eO.create=(e,t)=>new eO({innerType:e,typeName:l.ZodNullable,...A(t)});class eM extends P{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===d.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}eM.create=(e,t)=>new eM({innerType:e,typeName:l.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...A(t)});class eE extends P{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return O(s)?s.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new m(n.common.issues)},input:n.data})})):{status:"valid",value:"valid"===s.status?s.value:this._def.catchValue({get error(){return new m(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}eE.create=(e,t)=>new eE({innerType:e,typeName:l.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...A(t)});class eA extends P{_parse(e){if(this._getType(e)!==d.nan){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.nan,received:t.parsedType}),x}return{status:"valid",value:e.data}}}eA.create=e=>new eA({typeName:l.ZodNaN,...A(e)});let eP=Symbol("zod_brand");class eZ extends P{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class eD extends P{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?x:"dirty"===e.status?(t.dirty(),S(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?x:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(e,t){return new eD({in:e,out:t,typeName:l.ZodPipeline})}}class eI extends P{_parse(e){let t=this._def.innerType._parse(e),n=e=>(j(e)&&(e.value=Object.freeze(e.value)),e);return O(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}}function eC(e,t){let n="function"==typeof e?e(t):"string"==typeof e?{message:e}:e;return"string"==typeof n?{message:n}:n}function eL(e,t={},n){return e?ei.create().superRefine((s,a)=>{let r=e(s);if(r instanceof Promise)return r.then(e=>{if(!e){let e=eC(t,s),r=e.fatal??n??!0;a.addIssue({code:"custom",...e,fatal:r})}});if(!r){let e=eC(t,s),r=e.fatal??n??!0;a.addIssue({code:"custom",...e,fatal:r})}}):ei.create()}eI.create=(e,t)=>new eI({innerType:e,typeName:l.ZodReadonly,...A(t)});let eR={object:ec.lazycreate};(a=l||(l={})).ZodString="ZodString",a.ZodNumber="ZodNumber",a.ZodNaN="ZodNaN",a.ZodBigInt="ZodBigInt",a.ZodBoolean="ZodBoolean",a.ZodDate="ZodDate",a.ZodSymbol="ZodSymbol",a.ZodUndefined="ZodUndefined",a.ZodNull="ZodNull",a.ZodAny="ZodAny",a.ZodUnknown="ZodUnknown",a.ZodNever="ZodNever",a.ZodVoid="ZodVoid",a.ZodArray="ZodArray",a.ZodObject="ZodObject",a.ZodUnion="ZodUnion",a.ZodDiscriminatedUnion="ZodDiscriminatedUnion",a.ZodIntersection="ZodIntersection",a.ZodTuple="ZodTuple",a.ZodRecord="ZodRecord",a.ZodMap="ZodMap",a.ZodSet="ZodSet",a.ZodFunction="ZodFunction",a.ZodLazy="ZodLazy",a.ZodLiteral="ZodLiteral",a.ZodEnum="ZodEnum",a.ZodEffects="ZodEffects",a.ZodNativeEnum="ZodNativeEnum",a.ZodOptional="ZodOptional",a.ZodNullable="ZodNullable",a.ZodDefault="ZodDefault",a.ZodCatch="ZodCatch",a.ZodPromise="ZodPromise",a.ZodBranded="ZodBranded",a.ZodPipeline="ZodPipeline",a.ZodReadonly="ZodReadonly";let eU=(e,t={message:`Input not instance of ${e.name}`})=>eL(t=>t instanceof e,t),eF=X.create,eY=Q.create,eW=eA.create,ez=ee.create,eB=et.create,eJ=en.create,eV=es.create,eH=ea.create,eq=er.create,eK=ei.create,eG=eo.create,eX=el.create,eQ=eu.create,e0=ed.create,e1=ec.create,e2=ec.strictCreate,e4=ep.create,e9=em.create,e5=e_.create,e3=ef.create,e7=eg.create,e8=ey.create,e6=ev.create,te=ew.create,tt=ek.create,tn=eb.create,ts=eS.create,ta=e$.create,tr=eT.create,ti=eN.create,to=ej.create,tl=eO.create,tu=eN.createWithPreprocess,td=eD.create,tc=()=>eF().optional(),tp=()=>eY().optional(),th=()=>eB().optional(),tm={string:e=>X.create({...e,coerce:!0}),number:e=>Q.create({...e,coerce:!0}),boolean:e=>et.create({...e,coerce:!0}),bigint:e=>ee.create({...e,coerce:!0}),date:e=>en.create({...e,coerce:!0})};e.s(["BRAND",0,eP,"NEVER",0,x,"Schema",0,P,"ZodAny",0,ei,"ZodArray",0,ed,"ZodBigInt",0,ee,"ZodBoolean",0,et,"ZodBranded",0,eZ,"ZodCatch",0,eE,"ZodDate",0,en,"ZodDefault",0,eM,"ZodDiscriminatedUnion",0,em,"ZodEffects",0,eN,"ZodEnum",0,eS,"ZodFirstPartyTypeKind",0,l,"ZodFunction",0,ew,"ZodIntersection",0,e_,"ZodLazy",0,ek,"ZodLiteral",0,eb,"ZodMap",0,ey,"ZodNaN",0,eA,"ZodNativeEnum",0,e$,"ZodNever",0,el,"ZodNull",0,er,"ZodNullable",0,eO,"ZodNumber",0,Q,"ZodObject",0,ec,"ZodOptional",0,ej,"ZodPipeline",0,eD,"ZodPromise",0,eT,"ZodReadonly",0,eI,"ZodRecord",0,eg,"ZodSchema",0,P,"ZodSet",0,ev,"ZodString",0,X,"ZodSymbol",0,es,"ZodTransformer",0,eN,"ZodTuple",0,ef,"ZodType",0,P,"ZodUndefined",0,ea,"ZodUnion",0,ep,"ZodUnknown",0,eo,"ZodVoid",0,eu,"any",0,eK,"array",0,e0,"bigint",0,ez,"boolean",0,eB,"coerce",0,tm,"custom",0,eL,"date",0,eJ,"datetimeRegex",0,G,"discriminatedUnion",0,e9,"effect",0,ti,"enum",0,ts,"function",0,te,"instanceof",0,eU,"intersection",0,e5,"late",0,eR,"lazy",0,tt,"literal",0,tn,"map",0,e8,"nan",0,eW,"nativeEnum",0,ta,"never",0,eX,"null",0,eq,"nullable",0,tl,"number",0,eY,"object",0,e1,"oboolean",0,th,"onumber",0,tp,"optional",0,to,"ostring",0,tc,"pipeline",0,td,"preprocess",0,tu,"promise",0,tr,"record",0,e7,"set",0,e6,"strictObject",0,e2,"string",0,eF,"symbol",0,eV,"transformer",0,ti,"tuple",0,e3,"undefined",0,eH,"union",0,e4,"unknown",0,eG,"void",0,eQ],17958),e.i(17958),e.i(15235),e.s(["BRAND",0,eP,"DIRTY",0,S,"EMPTY_PATH",0,w,"INVALID",0,x,"NEVER",0,x,"OK",0,$,"ParseStatus",0,b,"Schema",0,P,"ZodAny",0,ei,"ZodArray",0,ed,"ZodBigInt",0,ee,"ZodBoolean",0,et,"ZodBranded",0,eZ,"ZodCatch",0,eE,"ZodDate",0,en,"ZodDefault",0,eM,"ZodDiscriminatedUnion",0,em,"ZodEffects",0,eN,"ZodEnum",0,eS,"ZodError",0,m,"ZodFirstPartyTypeKind",0,l,"ZodFunction",0,ew,"ZodIntersection",0,e_,"ZodIssueCode",0,p,"ZodLazy",0,ek,"ZodLiteral",0,eb,"ZodMap",0,ey,"ZodNaN",0,eA,"ZodNativeEnum",0,e$,"ZodNever",0,el,"ZodNull",0,er,"ZodNullable",0,eO,"ZodNumber",0,Q,"ZodObject",0,ec,"ZodOptional",0,ej,"ZodParsedType",0,d,"ZodPipeline",0,eD,"ZodPromise",0,eT,"ZodReadonly",0,eI,"ZodRecord",0,eg,"ZodSchema",0,P,"ZodSet",0,ev,"ZodString",0,X,"ZodSymbol",0,es,"ZodTransformer",0,eN,"ZodTuple",0,ef,"ZodType",0,P,"ZodUndefined",0,ea,"ZodUnion",0,ep,"ZodUnknown",0,eo,"ZodVoid",0,eu,"addIssueToContext",0,k,"any",0,eK,"array",0,e0,"bigint",0,ez,"boolean",0,eB,"coerce",0,tm,"custom",0,eL,"date",0,eJ,"datetimeRegex",0,G,"defaultErrorMap",0,_,"discriminatedUnion",0,e9,"effect",0,ti,"enum",0,ts,"function",0,te,"getErrorMap",0,y,"getParsedType",0,c,"instanceof",0,eU,"intersection",0,e5,"isAborted",0,T,"isAsync",0,O,"isDirty",0,N,"isValid",0,j,"late",0,eR,"lazy",0,tt,"literal",0,tn,"makeIssue",0,v,"map",0,e8,"nan",0,eW,"nativeEnum",0,ta,"never",0,eX,"null",0,eq,"nullable",0,tl,"number",0,eY,"object",0,e1,"objectUtil",0,i,"oboolean",0,th,"onumber",0,tp,"optional",0,to,"ostring",0,tc,"pipeline",0,td,"preprocess",0,tu,"promise",0,tr,"quotelessJson",0,h,"record",0,e7,"set",0,e6,"setErrorMap",0,g,"strictObject",0,e2,"string",0,eF,"symbol",0,eV,"transformer",0,ti,"tuple",0,e3,"undefined",0,eH,"union",0,e4,"unknown",0,eG,"util",0,r,"void",0,eQ],35907);var t_=e.i(35907),t_=t_,tf=e.i(54853);let tg=t_.enum(tf.GOAL_CATEGORIES),ty=t_.enum(["shipped","partial","exploratory","blocked","trivial"]),tv=t_.enum(["essential","helpful","neutral","unhelpful"]),tw=t_.object({brief_summary:t_.string().min(1),underlying_goal:t_.string().min(1),friction_detail:t_.string().nullable(),user_instructions:t_.array(t_.string()),goal_categories:t_.record(tg,t_.number().nonnegative()),outcome:ty,claude_helpfulness:tv}).passthrough(),tk=`You are analyzing one (session \xd7 local-day) slice of a developer's Claude Code work.
1
+ module.exports=[82111,81454,95549,90555,78325,86291,56614,20441,77242,21628,54832,e=>{"use strict";let t;var n,s,r,a,i,o,l,u=e.i(91530);e.s([],54033),e.i(54033),(n=a||(a={})).assertEqual=e=>{},n.assertIs=function(e){},n.assertNever=function(e){throw Error()},n.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},n.getValidEnumValues=e=>{let t=n.objectKeys(e).filter(t=>"number"!=typeof e[e[t]]),s={};for(let n of t)s[n]=e[n];return n.objectValues(s)},n.objectValues=e=>n.objectKeys(e).map(function(t){return e[t]}),n.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},n.find=(e,t)=>{for(let n of e)if(t(n))return n},n.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,n.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},n.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(i||(i={})).mergeShapes=(e,t)=>({...e,...t});let d=a.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),c=e=>{switch(typeof e){case"undefined":return d.undefined;case"string":return d.string;case"number":return Number.isNaN(e)?d.nan:d.number;case"boolean":return d.boolean;case"function":return d.function;case"bigint":return d.bigint;case"symbol":return d.symbol;case"object":if(Array.isArray(e))return d.array;if(null===e)return d.null;if(e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch)return d.promise;if("u">typeof Map&&e instanceof Map)return d.map;if("u">typeof Set&&e instanceof Set)return d.set;if("u">typeof Date&&e instanceof Date)return d.date;return d.object;default:return d.unknown}};e.s(["ZodParsedType",0,d,"getParsedType",0,c,"objectUtil",0,i,"util",0,a],42944);let p=a.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),h=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class m extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},s=e=>{for(let r of e.issues)if("invalid_union"===r.code)r.unionErrors.map(s);else if("invalid_return_type"===r.code)s(r.returnTypeError);else if("invalid_arguments"===r.code)s(r.argumentsError);else if(0===r.path.length)n._errors.push(t(r));else{let e=n,s=0;for(;s<r.path.length;){let n=r.path[s];s===r.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(r))):e[n]=e[n]||{_errors:[]},e=e[n],s++}}};return s(this),n}static assert(e){if(!(e instanceof m))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,a.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){let t={},n=[];for(let s of this.issues)if(s.path.length>0){let n=s.path[0];t[n]=t[n]||[],t[n].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}m.create=e=>new m(e),e.s(["ZodError",0,m,"ZodIssueCode",0,p,"quotelessJson",0,h],15235);let _=(e,t)=>{let n;switch(e.code){case p.invalid_type:n=e.received===d.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case p.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,a.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:n=`Unrecognized key(s) in object: ${a.joinValues(e.keys,", ")}`;break;case p.invalid_union:n="Invalid input";break;case p.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${a.joinValues(e.options)}`;break;case p.invalid_enum_value:n=`Invalid enum value. Expected ${a.joinValues(e.options)}, received '${e.received}'`;break;case p.invalid_arguments:n="Invalid function arguments";break;case p.invalid_return_type:n="Invalid function return type";break;case p.invalid_date:n="Invalid date";break;case p.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:a.assertNever(e.validation):n="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case p.too_small:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case p.too_big:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case p.custom:n="Invalid input";break;case p.invalid_intersection_types:n="Intersection results could not be merged";break;case p.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case p.not_finite:n="Number must be finite";break;default:n=t.defaultError,a.assertNever(e)}return{message:n}},f=_;function g(e){f=e}function y(){return f}e.s(["getErrorMap",0,y,"setErrorMap",0,g],85676),e.i(85676),e.s(["defaultErrorMap",0,_,"getErrorMap",0,y,"setErrorMap",0,g],76733),e.i(76733);let v=e=>{let{data:t,path:n,errorMaps:s,issueData:r}=e,a=[...n,...r.path||[]],i={...r,path:a};if(void 0!==r.message)return{...r,path:a,message:r.message};let o="";for(let e of s.filter(e=>!!e).slice().reverse())o=e(i,{data:t,defaultError:o}).message;return{...r,path:a,message:o}},w=[];function k(e,t){let n=y(),s=v({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===_?void 0:_].filter(e=>!!e)});e.common.issues.push(s)}class b{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){let n=[];for(let s of t){if("aborted"===s.status)return x;"dirty"===s.status&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let e of t){let t=await e.key,s=await e.value;n.push({key:t,value:s})}return b.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let s of t){let{key:t,value:r}=s;if("aborted"===t.status||"aborted"===r.status)return x;"dirty"===t.status&&e.dirty(),"dirty"===r.status&&e.dirty(),"__proto__"!==t.value&&(void 0!==r.value||s.alwaysSet)&&(n[t.value]=r.value)}return{status:e.value,value:n}}}let x=Object.freeze({status:"aborted"}),S=e=>({status:"dirty",value:e}),$=e=>({status:"valid",value:e}),T=e=>"aborted"===e.status,N=e=>"dirty"===e.status,j=e=>"valid"===e.status,O=e=>"u">typeof Promise&&e instanceof Promise;e.s(["DIRTY",0,S,"EMPTY_PATH",0,w,"INVALID",0,x,"OK",0,$,"ParseStatus",0,b,"addIssueToContext",0,k,"isAborted",0,T,"isAsync",0,O,"isDirty",0,N,"isValid",0,j,"makeIssue",0,v],84488),e.i(84488),e.s([],91316),e.i(91316),e.i(42944),(s=o||(o={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},s.toString=e=>"string"==typeof e?e:e?.message;class M{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}let E=(e,t)=>{if(j(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new m(e.common.issues);return this._error=t,this._error}}};function A(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:s,description:r}=e;if(t&&(n||s))throw Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:r}:{errorMap:(t,r)=>{let{message:a}=e;return"invalid_enum_value"===t.code?{message:a??r.defaultError}:void 0===r.data?{message:a??s??r.defaultError}:"invalid_type"!==t.code?{message:r.defaultError}:{message:a??n??r.defaultError}},description:r}}class P{get description(){return this._def.description}_getType(e){return c(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:c(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new b,ctx:{common:e.parent.common,data:e.data,parsedType:c(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(O(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){return Promise.resolve(this._parse(e))}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:c(e)},s=this._parseSync({data:e,path:n.path,parent:n});return E(n,s)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:c(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:t});return j(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>j(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:c(e)},s=this._parse({data:e,path:n.path,parent:n});return E(n,await (O(s)?s:Promise.resolve(s)))}refine(e,t){return this._refinement((n,s)=>{let r=e(n),a=()=>s.addIssue({code:p.custom,..."string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(n):t});return"u">typeof Promise&&r instanceof Promise?r.then(e=>!!e||(a(),!1)):!!r||(a(),!1)})}refinement(e,t){return this._refinement((n,s)=>!!e(n)||(s.addIssue("function"==typeof t?t(n,s):t),!1))}_refinement(e){return new eN({schema:this,typeName:l.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return ej.create(this,this._def)}nullable(){return eO.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ed.create(this)}promise(){return eT.create(this,this._def)}or(e){return ep.create([this,e],this._def)}and(e){return e_.create(this,e,this._def)}transform(e){return new eN({...A(this._def),schema:this,typeName:l.ZodEffects,effect:{type:"transform",transform:e}})}default(e){return new eM({...A(this._def),innerType:this,defaultValue:"function"==typeof e?e:()=>e,typeName:l.ZodDefault})}brand(){return new eZ({typeName:l.ZodBranded,type:this,...A(this._def)})}catch(e){return new eE({...A(this._def),innerType:this,catchValue:"function"==typeof e?e:()=>e,typeName:l.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return eD.create(this,e)}readonly(){return eC.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}let Z=/^c[^\s-]{8,}$/i,D=/^[0-9a-z]+$/,C=/^[0-9A-HJKMNP-TV-Z]{26}$/i,I=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,L=/^[a-z0-9_-]{21}$/i,R=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,U=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,F=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Y=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,W=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,z=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,B=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,J=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,H=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,V="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",q=RegExp(`^${V}$`);function K(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);let n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function G(e){let t=`${V}T${K(e)}`,n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,RegExp(`^${t}$`)}class X extends P{_parse(e){var n,s,r,i;let o;if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==d.string){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.string,received:t.parsedType}),x}let l=new b;for(let u of this._def.checks)if("min"===u.kind)e.data.length<u.value&&(k(o=this._getOrReturnCtx(e,o),{code:p.too_small,minimum:u.value,type:"string",inclusive:!0,exact:!1,message:u.message}),l.dirty());else if("max"===u.kind)e.data.length>u.value&&(k(o=this._getOrReturnCtx(e,o),{code:p.too_big,maximum:u.value,type:"string",inclusive:!0,exact:!1,message:u.message}),l.dirty());else if("length"===u.kind){let t=e.data.length>u.value,n=e.data.length<u.value;(t||n)&&(o=this._getOrReturnCtx(e,o),t?k(o,{code:p.too_big,maximum:u.value,type:"string",inclusive:!0,exact:!0,message:u.message}):n&&k(o,{code:p.too_small,minimum:u.value,type:"string",inclusive:!0,exact:!0,message:u.message}),l.dirty())}else if("email"===u.kind)F.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{validation:"email",code:p.invalid_string,message:u.message}),l.dirty());else if("emoji"===u.kind)t||(t=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),t.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{validation:"emoji",code:p.invalid_string,message:u.message}),l.dirty());else if("uuid"===u.kind)I.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{validation:"uuid",code:p.invalid_string,message:u.message}),l.dirty());else if("nanoid"===u.kind)L.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{validation:"nanoid",code:p.invalid_string,message:u.message}),l.dirty());else if("cuid"===u.kind)Z.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{validation:"cuid",code:p.invalid_string,message:u.message}),l.dirty());else if("cuid2"===u.kind)D.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{validation:"cuid2",code:p.invalid_string,message:u.message}),l.dirty());else if("ulid"===u.kind)C.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{validation:"ulid",code:p.invalid_string,message:u.message}),l.dirty());else if("url"===u.kind)try{new URL(e.data)}catch{k(o=this._getOrReturnCtx(e,o),{validation:"url",code:p.invalid_string,message:u.message}),l.dirty()}else"regex"===u.kind?(u.regex.lastIndex=0,u.regex.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{validation:"regex",code:p.invalid_string,message:u.message}),l.dirty())):"trim"===u.kind?e.data=e.data.trim():"includes"===u.kind?e.data.includes(u.value,u.position)||(k(o=this._getOrReturnCtx(e,o),{code:p.invalid_string,validation:{includes:u.value,position:u.position},message:u.message}),l.dirty()):"toLowerCase"===u.kind?e.data=e.data.toLowerCase():"toUpperCase"===u.kind?e.data=e.data.toUpperCase():"startsWith"===u.kind?e.data.startsWith(u.value)||(k(o=this._getOrReturnCtx(e,o),{code:p.invalid_string,validation:{startsWith:u.value},message:u.message}),l.dirty()):"endsWith"===u.kind?e.data.endsWith(u.value)||(k(o=this._getOrReturnCtx(e,o),{code:p.invalid_string,validation:{endsWith:u.value},message:u.message}),l.dirty()):"datetime"===u.kind?G(u).test(e.data)||(k(o=this._getOrReturnCtx(e,o),{code:p.invalid_string,validation:"datetime",message:u.message}),l.dirty()):"date"===u.kind?q.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{code:p.invalid_string,validation:"date",message:u.message}),l.dirty()):"time"===u.kind?RegExp(`^${K(u)}$`).test(e.data)||(k(o=this._getOrReturnCtx(e,o),{code:p.invalid_string,validation:"time",message:u.message}),l.dirty()):"duration"===u.kind?U.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{validation:"duration",code:p.invalid_string,message:u.message}),l.dirty()):"ip"===u.kind?(n=e.data,!(("v4"===(s=u.version)||!s)&&Y.test(n)||("v6"===s||!s)&&z.test(n))&&1&&(k(o=this._getOrReturnCtx(e,o),{validation:"ip",code:p.invalid_string,message:u.message}),l.dirty())):"jwt"===u.kind?!function(e,t){if(!R.test(e))return!1;try{let[n]=e.split(".");if(!n)return!1;let s=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),r=JSON.parse(atob(s));if("object"!=typeof r||null===r||"typ"in r&&r?.typ!=="JWT"||!r.alg||t&&r.alg!==t)return!1;return!0}catch{return!1}}(e.data,u.alg)&&(k(o=this._getOrReturnCtx(e,o),{validation:"jwt",code:p.invalid_string,message:u.message}),l.dirty()):"cidr"===u.kind?(r=e.data,!(("v4"===(i=u.version)||!i)&&W.test(r)||("v6"===i||!i)&&B.test(r))&&1&&(k(o=this._getOrReturnCtx(e,o),{validation:"cidr",code:p.invalid_string,message:u.message}),l.dirty())):"base64"===u.kind?J.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{validation:"base64",code:p.invalid_string,message:u.message}),l.dirty()):"base64url"===u.kind?H.test(e.data)||(k(o=this._getOrReturnCtx(e,o),{validation:"base64url",code:p.invalid_string,message:u.message}),l.dirty()):a.assertNever(u);return{status:l.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:p.invalid_string,...o.errToObj(n)})}_addCheck(e){return new X({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...o.errToObj(e)})}url(e){return this._addCheck({kind:"url",...o.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...o.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...o.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...o.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...o.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...o.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...o.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...o.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...o.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...o.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...o.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...o.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...o.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...o.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...o.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...o.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...o.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...o.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...o.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...o.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...o.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...o.errToObj(t)})}nonempty(e){return this.min(1,o.errToObj(e))}trim(){return new X({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new X({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new X({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}X.create=e=>new X({checks:[],typeName:l.ZodString,coerce:e?.coerce??!1,...A(e)});class Q extends P{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){let t;if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==d.number){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.number,received:t.parsedType}),x}let n=new b;for(let s of this._def.checks)"int"===s.kind?a.isInteger(e.data)||(k(t=this._getOrReturnCtx(e,t),{code:p.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty()):"min"===s.kind?(s.inclusive?e.data<s.value:e.data<=s.value)&&(k(t=this._getOrReturnCtx(e,t),{code:p.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):"max"===s.kind?(s.inclusive?e.data>s.value:e.data>=s.value)&&(k(t=this._getOrReturnCtx(e,t),{code:p.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):"multipleOf"===s.kind?0!==function(e,t){let n=(e.toString().split(".")[1]||"").length,s=(t.toString().split(".")[1]||"").length,r=n>s?n:s;return Number.parseInt(e.toFixed(r).replace(".",""))%Number.parseInt(t.toFixed(r).replace(".",""))/10**r}(e.data,s.value)&&(k(t=this._getOrReturnCtx(e,t),{code:p.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):"finite"===s.kind?Number.isFinite(e.data)||(k(t=this._getOrReturnCtx(e,t),{code:p.not_finite,message:s.message}),n.dirty()):a.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,o.toString(t))}gt(e,t){return this.setLimit("min",e,!1,o.toString(t))}lte(e,t){return this.setLimit("max",e,!0,o.toString(t))}lt(e,t){return this.setLimit("max",e,!1,o.toString(t))}setLimit(e,t,n,s){return new Q({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:o.toString(s)}]})}_addCheck(e){return new Q({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:o.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:o.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:o.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:o.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:o.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:o.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:o.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:o.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:o.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>"int"===e.kind||"multipleOf"===e.kind&&a.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if("finite"===n.kind||"int"===n.kind||"multipleOf"===n.kind)return!0;else"min"===n.kind?(null===t||n.value>t)&&(t=n.value):"max"===n.kind&&(null===e||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}}Q.create=e=>new Q({checks:[],typeName:l.ZodNumber,coerce:e?.coerce||!1,...A(e)});class ee extends P{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){let t;if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==d.bigint)return this._getInvalidInput(e);let n=new b;for(let s of this._def.checks)"min"===s.kind?(s.inclusive?e.data<s.value:e.data<=s.value)&&(k(t=this._getOrReturnCtx(e,t),{code:p.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):"max"===s.kind?(s.inclusive?e.data>s.value:e.data>=s.value)&&(k(t=this._getOrReturnCtx(e,t),{code:p.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):"multipleOf"===s.kind?e.data%s.value!==BigInt(0)&&(k(t=this._getOrReturnCtx(e,t),{code:p.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):a.assertNever(s);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.bigint,received:t.parsedType}),x}gte(e,t){return this.setLimit("min",e,!0,o.toString(t))}gt(e,t){return this.setLimit("min",e,!1,o.toString(t))}lte(e,t){return this.setLimit("max",e,!0,o.toString(t))}lt(e,t){return this.setLimit("max",e,!1,o.toString(t))}setLimit(e,t,n,s){return new ee({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:o.toString(s)}]})}_addCheck(e){return new ee({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:o.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:o.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:o.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:o.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:o.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}ee.create=e=>new ee({checks:[],typeName:l.ZodBigInt,coerce:e?.coerce??!1,...A(e)});class et extends P{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==d.boolean){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.boolean,received:t.parsedType}),x}return $(e.data)}}et.create=e=>new et({typeName:l.ZodBoolean,coerce:e?.coerce||!1,...A(e)});class en extends P{_parse(e){let t;if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==d.date){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.date,received:t.parsedType}),x}if(Number.isNaN(e.data.getTime()))return k(this._getOrReturnCtx(e),{code:p.invalid_date}),x;let n=new b;for(let s of this._def.checks)"min"===s.kind?e.data.getTime()<s.value&&(k(t=this._getOrReturnCtx(e,t),{code:p.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):"max"===s.kind?e.data.getTime()>s.value&&(k(t=this._getOrReturnCtx(e,t),{code:p.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):a.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new en({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:o.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:o.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}en.create=e=>new en({checks:[],coerce:e?.coerce||!1,typeName:l.ZodDate,...A(e)});class es extends P{_parse(e){if(this._getType(e)!==d.symbol){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.symbol,received:t.parsedType}),x}return $(e.data)}}es.create=e=>new es({typeName:l.ZodSymbol,...A(e)});class er extends P{_parse(e){if(this._getType(e)!==d.undefined){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.undefined,received:t.parsedType}),x}return $(e.data)}}er.create=e=>new er({typeName:l.ZodUndefined,...A(e)});class ea extends P{_parse(e){if(this._getType(e)!==d.null){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.null,received:t.parsedType}),x}return $(e.data)}}ea.create=e=>new ea({typeName:l.ZodNull,...A(e)});class ei extends P{constructor(){super(...arguments),this._any=!0}_parse(e){return $(e.data)}}ei.create=e=>new ei({typeName:l.ZodAny,...A(e)});class eo extends P{constructor(){super(...arguments),this._unknown=!0}_parse(e){return $(e.data)}}eo.create=e=>new eo({typeName:l.ZodUnknown,...A(e)});class el extends P{_parse(e){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.never,received:t.parsedType}),x}}el.create=e=>new el({typeName:l.ZodNever,...A(e)});class eu extends P{_parse(e){if(this._getType(e)!==d.undefined){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.void,received:t.parsedType}),x}return $(e.data)}}eu.create=e=>new eu({typeName:l.ZodVoid,...A(e)});class ed extends P{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==d.array)return k(t,{code:p.invalid_type,expected:d.array,received:t.parsedType}),x;if(null!==s.exactLength){let e=t.data.length>s.exactLength.value,r=t.data.length<s.exactLength.value;(e||r)&&(k(t,{code:e?p.too_big:p.too_small,minimum:r?s.exactLength.value:void 0,maximum:e?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(null!==s.minLength&&t.data.length<s.minLength.value&&(k(t,{code:p.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),null!==s.maxLength&&t.data.length>s.maxLength.value&&(k(t,{code:p.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>s.type._parseAsync(new M(t,e,t.path,n)))).then(e=>b.mergeArray(n,e));let r=[...t.data].map((e,n)=>s.type._parseSync(new M(t,e,t.path,n)));return b.mergeArray(n,r)}get element(){return this._def.type}min(e,t){return new ed({...this._def,minLength:{value:e,message:o.toString(t)}})}max(e,t){return new ed({...this._def,maxLength:{value:e,message:o.toString(t)}})}length(e,t){return new ed({...this._def,exactLength:{value:e,message:o.toString(t)}})}nonempty(e){return this.min(1,e)}}ed.create=(e,t)=>new ed({type:e,minLength:null,maxLength:null,exactLength:null,typeName:l.ZodArray,...A(t)});class ec extends P{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;let e=this._def.shape(),t=a.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==d.object){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.object,received:t.parsedType}),x}let{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:r}=this._getCached(),a=[];if(!(this._def.catchall instanceof el&&"strip"===this._def.unknownKeys))for(let e in n.data)r.includes(e)||a.push(e);let i=[];for(let e of r){let t=s[e],r=n.data[e];i.push({key:{status:"valid",value:e},value:t._parse(new M(n,r,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof el){let e=this._def.unknownKeys;if("passthrough"===e)for(let e of a)i.push({key:{status:"valid",value:e},value:{status:"valid",value:n.data[e]}});else if("strict"===e)a.length>0&&(k(n,{code:p.unrecognized_keys,keys:a}),t.dirty());else if("strip"===e);else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let e=this._def.catchall;for(let t of a){let s=n.data[t];i.push({key:{status:"valid",value:t},value:e._parse(new M(n,s,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of i){let n=await t.key,s=await t.value;e.push({key:n,value:s,alwaysSet:t.alwaysSet})}return e}).then(e=>b.mergeObjectSync(t,e)):b.mergeObjectSync(t,i)}get shape(){return this._def.shape()}strict(e){return o.errToObj,new ec({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,n)=>{let s=this._def.errorMap?.(t,n).message??n.defaultError;return"unrecognized_keys"===t.code?{message:o.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new ec({...this._def,unknownKeys:"strip"})}passthrough(){return new ec({...this._def,unknownKeys:"passthrough"})}extend(e){return new ec({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ec({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:l.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ec({...this._def,catchall:e})}pick(e){let t={};for(let n of a.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new ec({...this._def,shape:()=>t})}omit(e){let t={};for(let n of a.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new ec({...this._def,shape:()=>t})}deepPartial(){return function e(t){if(t instanceof ec){let n={};for(let s in t.shape){let r=t.shape[s];n[s]=ej.create(e(r))}return new ec({...t._def,shape:()=>n})}if(t instanceof ed)return new ed({...t._def,type:e(t.element)});if(t instanceof ej)return ej.create(e(t.unwrap()));if(t instanceof eO)return eO.create(e(t.unwrap()));if(t instanceof ef)return ef.create(t.items.map(t=>e(t)));else return t}(this)}partial(e){let t={};for(let n of a.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}return new ec({...this._def,shape:()=>t})}required(e){let t={};for(let n of a.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let e=this.shape[n];for(;e instanceof ej;)e=e._def.innerType;t[n]=e}return new ec({...this._def,shape:()=>t})}keyof(){return ex(a.objectKeys(this.shape))}}ec.create=(e,t)=>new ec({shape:()=>e,unknownKeys:"strip",catchall:el.create(),typeName:l.ZodObject,...A(t)}),ec.strictCreate=(e,t)=>new ec({shape:()=>e,unknownKeys:"strict",catchall:el.create(),typeName:l.ZodObject,...A(t)}),ec.lazycreate=(e,t)=>new ec({shape:e,unknownKeys:"strip",catchall:el.create(),typeName:l.ZodObject,...A(t)});class ep extends P{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(function(e){for(let t of e)if("valid"===t.result.status)return t.result;for(let n of e)if("dirty"===n.result.status)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new m(e.ctx.common.issues));return k(t,{code:p.invalid_union,unionErrors:n}),x});{let e,s=[];for(let r of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=r._parseSync({data:t.data,path:t.path,parent:n});if("valid"===a.status)return a;"dirty"!==a.status||e||(e={result:a,ctx:n}),n.common.issues.length&&s.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let r=s.map(e=>new m(e));return k(t,{code:p.invalid_union,unionErrors:r}),x}}get options(){return this._def.options}}ep.create=(e,t)=>new ep({options:e,typeName:l.ZodUnion,...A(t)});let eh=e=>{if(e instanceof ek)return eh(e.schema);if(e instanceof eN)return eh(e.innerType());if(e instanceof eb)return[e.value];if(e instanceof eS)return e.options;if(e instanceof e$)return a.objectValues(e.enum);else if(e instanceof eM)return eh(e._def.innerType);else if(e instanceof er)return[void 0];else if(e instanceof ea)return[null];else if(e instanceof ej)return[void 0,...eh(e.unwrap())];else if(e instanceof eO)return[null,...eh(e.unwrap())];else if(e instanceof eZ)return eh(e.unwrap());else if(e instanceof eC)return eh(e.unwrap());else if(e instanceof eE)return eh(e._def.innerType);else return[]};class em extends P{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==d.object)return k(t,{code:p.invalid_type,expected:d.object,received:t.parsedType}),x;let n=this.discriminator,s=t.data[n],r=this.optionsMap.get(s);return r?t.common.async?r._parseAsync({data:t.data,path:t.path,parent:t}):r._parseSync({data:t.data,path:t.path,parent:t}):(k(t,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),x)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let s=new Map;for(let n of t){let t=eh(n.shape[e]);if(!t.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let r of t){if(s.has(r))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(r)}`);s.set(r,n)}}return new em({typeName:l.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...A(n)})}}class e_ extends P{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=(e,s)=>{if(T(e)||T(s))return x;let r=function e(t,n){let s=c(t),r=c(n);if(t===n)return{valid:!0,data:t};if(s===d.object&&r===d.object){let s=a.objectKeys(n),r=a.objectKeys(t).filter(e=>-1!==s.indexOf(e)),i={...t,...n};for(let s of r){let r=e(t[s],n[s]);if(!r.valid)return{valid:!1};i[s]=r.data}return{valid:!0,data:i}}if(s===d.array&&r===d.array){if(t.length!==n.length)return{valid:!1};let s=[];for(let r=0;r<t.length;r++){let a=e(t[r],n[r]);if(!a.valid)return{valid:!1};s.push(a.data)}return{valid:!0,data:s}}if(s===d.date&&r===d.date&&+t==+n)return{valid:!0,data:t};return{valid:!1}}(e.value,s.value);return r.valid?((N(e)||N(s))&&t.dirty(),{status:t.value,value:r.data}):(k(n,{code:p.invalid_intersection_types}),x)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>s(e,t)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}e_.create=(e,t,n)=>new e_({left:e,right:t,typeName:l.ZodIntersection,...A(n)});class ef extends P{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==d.array)return k(n,{code:p.invalid_type,expected:d.array,received:n.parsedType}),x;if(n.data.length<this._def.items.length)return k(n,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),x;!this._def.rest&&n.data.length>this._def.items.length&&(k(n,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let s=[...n.data].map((e,t)=>{let s=this._def.items[t]||this._def.rest;return s?s._parse(new M(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(s).then(e=>b.mergeArray(t,e)):b.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new ef({...this._def,rest:e})}}ef.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new ef({items:e,typeName:l.ZodTuple,rest:null,...A(t)})};class eg extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==d.object)return k(n,{code:p.invalid_type,expected:d.object,received:n.parsedType}),x;let s=[],r=this._def.keyType,a=this._def.valueType;for(let e in n.data)s.push({key:r._parse(new M(n,e,n.path,e)),value:a._parse(new M(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?b.mergeObjectAsync(t,s):b.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return new eg(t instanceof P?{keyType:e,valueType:t,typeName:l.ZodRecord,...A(n)}:{keyType:X.create(),valueType:e,typeName:l.ZodRecord,...A(t)})}}class ey extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==d.map)return k(n,{code:p.invalid_type,expected:d.map,received:n.parsedType}),x;let s=this._def.keyType,r=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:s._parse(new M(n,e,n.path,[a,"key"])),value:r._parse(new M(n,t,n.path,[a,"value"]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let s=await n.key,r=await n.value;if("aborted"===s.status||"aborted"===r.status)return x;("dirty"===s.status||"dirty"===r.status)&&t.dirty(),e.set(s.value,r.value)}return{status:t.value,value:e}})}{let e=new Map;for(let n of a){let s=n.key,r=n.value;if("aborted"===s.status||"aborted"===r.status)return x;("dirty"===s.status||"dirty"===r.status)&&t.dirty(),e.set(s.value,r.value)}return{status:t.value,value:e}}}}ey.create=(e,t,n)=>new ey({valueType:t,keyType:e,typeName:l.ZodMap,...A(n)});class ev extends P{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==d.set)return k(n,{code:p.invalid_type,expected:d.set,received:n.parsedType}),x;let s=this._def;null!==s.minSize&&n.data.size<s.minSize.value&&(k(n,{code:p.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),null!==s.maxSize&&n.data.size>s.maxSize.value&&(k(n,{code:p.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());let r=this._def.valueType;function a(e){let n=new Set;for(let s of e){if("aborted"===s.status)return x;"dirty"===s.status&&t.dirty(),n.add(s.value)}return{status:t.value,value:n}}let i=[...n.data.values()].map((e,t)=>r._parse(new M(n,e,n.path,t)));return n.common.async?Promise.all(i).then(e=>a(e)):a(i)}min(e,t){return new ev({...this._def,minSize:{value:e,message:o.toString(t)}})}max(e,t){return new ev({...this._def,maxSize:{value:e,message:o.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ev.create=(e,t)=>new ev({valueType:e,minSize:null,maxSize:null,typeName:l.ZodSet,...A(t)});class ew extends P{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==d.function)return k(t,{code:p.invalid_type,expected:d.function,received:t.parsedType}),x;function n(e,n){return v({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,y(),_].filter(e=>!!e),issueData:{code:p.invalid_arguments,argumentsError:n}})}function s(e,n){return v({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,y(),_].filter(e=>!!e),issueData:{code:p.invalid_return_type,returnTypeError:n}})}let r={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof eT){let e=this;return $(async function(...t){let i=new m([]),o=await e._def.args.parseAsync(t,r).catch(e=>{throw i.addIssue(n(t,e)),i}),l=await Reflect.apply(a,this,o);return await e._def.returns._def.type.parseAsync(l,r).catch(e=>{throw i.addIssue(s(l,e)),i})})}{let e=this;return $(function(...t){let i=e._def.args.safeParse(t,r);if(!i.success)throw new m([n(t,i.error)]);let o=Reflect.apply(a,this,i.data),l=e._def.returns.safeParse(o,r);if(!l.success)throw new m([s(o,l.error)]);return l.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ew({...this._def,args:ef.create(e).rest(eo.create())})}returns(e){return new ew({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new ew({args:e||ef.create([]).rest(eo.create()),returns:t||eo.create(),typeName:l.ZodFunction,...A(n)})}}class ek extends P{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ek.create=(e,t)=>new ek({getter:e,typeName:l.ZodLazy,...A(t)});class eb extends P{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return k(t,{received:t.data,code:p.invalid_literal,expected:this._def.value}),x}return{status:"valid",value:e.data}}get value(){return this._def.value}}function ex(e,t){return new eS({values:e,typeName:l.ZodEnum,...A(t)})}eb.create=(e,t)=>new eb({value:e,typeName:l.ZodLiteral,...A(t)});class eS extends P{_parse(e){if("string"!=typeof e.data){let t=this._getOrReturnCtx(e),n=this._def.values;return k(t,{expected:a.joinValues(n),received:t.parsedType,code:p.invalid_type}),x}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return k(t,{received:t.data,code:p.invalid_enum_value,options:n}),x}return $(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return eS.create(e,{...this._def,...t})}exclude(e,t=this._def){return eS.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}eS.create=ex;class e$ extends P{_parse(e){let t=a.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==d.string&&n.parsedType!==d.number){let e=a.objectValues(t);return k(n,{expected:a.joinValues(e),received:n.parsedType,code:p.invalid_type}),x}if(this._cache||(this._cache=new Set(a.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let e=a.objectValues(t);return k(n,{received:n.data,code:p.invalid_enum_value,options:e}),x}return $(e.data)}get enum(){return this._def.values}}e$.create=(e,t)=>new e$({values:e,typeName:l.ZodNativeEnum,...A(t)});class eT extends P{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==d.promise&&!1===t.common.async?(k(t,{code:p.invalid_type,expected:d.promise,received:t.parsedType}),x):$((t.parsedType===d.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}eT.create=(e,t)=>new eT({type:e,typeName:l.ZodPromise,...A(t)});class eN extends P{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===l.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,r={addIssue:e=>{k(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(r.addIssue=r.addIssue.bind(r),"preprocess"===s.type){let e=s.transform(n.data,r);if(n.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return x;let s=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return"aborted"===s.status?x:"dirty"===s.status||"dirty"===t.value?S(s.value):s});{if("aborted"===t.value)return x;let s=this._def.schema._parseSync({data:e,path:n.path,parent:n});return"aborted"===s.status?x:"dirty"===s.status||"dirty"===t.value?S(s.value):s}}if("refinement"===s.type){let e=e=>{let t=s.refinement(e,r);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1!==n.common.async)return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>"aborted"===n.status?x:("dirty"===n.status&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))));{let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===s.status?x:("dirty"===s.status&&t.dirty(),e(s.value),{status:t.value,value:s.value})}}if("transform"===s.type)if(!1!==n.common.async)return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>j(e)?Promise.resolve(s.transform(e.value,r)).then(e=>({status:t.value,value:e})):x);else{let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!j(e))return x;let a=s.transform(e.value,r);if(a instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}a.assertNever(s)}}eN.create=(e,t,n)=>new eN({schema:e,typeName:l.ZodEffects,effect:t,...A(n)}),eN.createWithPreprocess=(e,t,n)=>new eN({schema:t,effect:{type:"preprocess",transform:e},typeName:l.ZodEffects,...A(n)});class ej extends P{_parse(e){return this._getType(e)===d.undefined?$(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ej.create=(e,t)=>new ej({innerType:e,typeName:l.ZodOptional,...A(t)});class eO extends P{_parse(e){return this._getType(e)===d.null?$(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}eO.create=(e,t)=>new eO({innerType:e,typeName:l.ZodNullable,...A(t)});class eM extends P{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===d.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}eM.create=(e,t)=>new eM({innerType:e,typeName:l.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...A(t)});class eE extends P{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return O(s)?s.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new m(n.common.issues)},input:n.data})})):{status:"valid",value:"valid"===s.status?s.value:this._def.catchValue({get error(){return new m(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}eE.create=(e,t)=>new eE({innerType:e,typeName:l.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...A(t)});class eA extends P{_parse(e){if(this._getType(e)!==d.nan){let t=this._getOrReturnCtx(e);return k(t,{code:p.invalid_type,expected:d.nan,received:t.parsedType}),x}return{status:"valid",value:e.data}}}eA.create=e=>new eA({typeName:l.ZodNaN,...A(e)});let eP=Symbol("zod_brand");class eZ extends P{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class eD extends P{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?x:"dirty"===e.status?(t.dirty(),S(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?x:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(e,t){return new eD({in:e,out:t,typeName:l.ZodPipeline})}}class eC extends P{_parse(e){let t=this._def.innerType._parse(e),n=e=>(j(e)&&(e.value=Object.freeze(e.value)),e);return O(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}}function eI(e,t){let n="function"==typeof e?e(t):"string"==typeof e?{message:e}:e;return"string"==typeof n?{message:n}:n}function eL(e,t={},n){return e?ei.create().superRefine((s,r)=>{let a=e(s);if(a instanceof Promise)return a.then(e=>{if(!e){let e=eI(t,s),a=e.fatal??n??!0;r.addIssue({code:"custom",...e,fatal:a})}});if(!a){let e=eI(t,s),a=e.fatal??n??!0;r.addIssue({code:"custom",...e,fatal:a})}}):ei.create()}eC.create=(e,t)=>new eC({innerType:e,typeName:l.ZodReadonly,...A(t)});let eR={object:ec.lazycreate};(r=l||(l={})).ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly";let eU=(e,t={message:`Input not instance of ${e.name}`})=>eL(t=>t instanceof e,t),eF=X.create,eY=Q.create,eW=eA.create,ez=ee.create,eB=et.create,eJ=en.create,eH=es.create,eV=er.create,eq=ea.create,eK=ei.create,eG=eo.create,eX=el.create,eQ=eu.create,e0=ed.create,e1=ec.create,e2=ec.strictCreate,e4=ep.create,e9=em.create,e5=e_.create,e3=ef.create,e8=eg.create,e7=ey.create,e6=ev.create,te=ew.create,tt=ek.create,tn=eb.create,ts=eS.create,tr=e$.create,ta=eT.create,ti=eN.create,to=ej.create,tl=eO.create,tu=eN.createWithPreprocess,td=eD.create,tc=()=>eF().optional(),tp=()=>eY().optional(),th=()=>eB().optional(),tm={string:e=>X.create({...e,coerce:!0}),number:e=>Q.create({...e,coerce:!0}),boolean:e=>et.create({...e,coerce:!0}),bigint:e=>ee.create({...e,coerce:!0}),date:e=>en.create({...e,coerce:!0})};e.s(["BRAND",0,eP,"NEVER",0,x,"Schema",0,P,"ZodAny",0,ei,"ZodArray",0,ed,"ZodBigInt",0,ee,"ZodBoolean",0,et,"ZodBranded",0,eZ,"ZodCatch",0,eE,"ZodDate",0,en,"ZodDefault",0,eM,"ZodDiscriminatedUnion",0,em,"ZodEffects",0,eN,"ZodEnum",0,eS,"ZodFirstPartyTypeKind",0,l,"ZodFunction",0,ew,"ZodIntersection",0,e_,"ZodLazy",0,ek,"ZodLiteral",0,eb,"ZodMap",0,ey,"ZodNaN",0,eA,"ZodNativeEnum",0,e$,"ZodNever",0,el,"ZodNull",0,ea,"ZodNullable",0,eO,"ZodNumber",0,Q,"ZodObject",0,ec,"ZodOptional",0,ej,"ZodPipeline",0,eD,"ZodPromise",0,eT,"ZodReadonly",0,eC,"ZodRecord",0,eg,"ZodSchema",0,P,"ZodSet",0,ev,"ZodString",0,X,"ZodSymbol",0,es,"ZodTransformer",0,eN,"ZodTuple",0,ef,"ZodType",0,P,"ZodUndefined",0,er,"ZodUnion",0,ep,"ZodUnknown",0,eo,"ZodVoid",0,eu,"any",0,eK,"array",0,e0,"bigint",0,ez,"boolean",0,eB,"coerce",0,tm,"custom",0,eL,"date",0,eJ,"datetimeRegex",0,G,"discriminatedUnion",0,e9,"effect",0,ti,"enum",0,ts,"function",0,te,"instanceof",0,eU,"intersection",0,e5,"late",0,eR,"lazy",0,tt,"literal",0,tn,"map",0,e7,"nan",0,eW,"nativeEnum",0,tr,"never",0,eX,"null",0,eq,"nullable",0,tl,"number",0,eY,"object",0,e1,"oboolean",0,th,"onumber",0,tp,"optional",0,to,"ostring",0,tc,"pipeline",0,td,"preprocess",0,tu,"promise",0,ta,"record",0,e8,"set",0,e6,"strictObject",0,e2,"string",0,eF,"symbol",0,eH,"transformer",0,ti,"tuple",0,e3,"undefined",0,eV,"union",0,e4,"unknown",0,eG,"void",0,eQ],17958),e.i(17958),e.i(15235),e.s(["BRAND",0,eP,"DIRTY",0,S,"EMPTY_PATH",0,w,"INVALID",0,x,"NEVER",0,x,"OK",0,$,"ParseStatus",0,b,"Schema",0,P,"ZodAny",0,ei,"ZodArray",0,ed,"ZodBigInt",0,ee,"ZodBoolean",0,et,"ZodBranded",0,eZ,"ZodCatch",0,eE,"ZodDate",0,en,"ZodDefault",0,eM,"ZodDiscriminatedUnion",0,em,"ZodEffects",0,eN,"ZodEnum",0,eS,"ZodError",0,m,"ZodFirstPartyTypeKind",0,l,"ZodFunction",0,ew,"ZodIntersection",0,e_,"ZodIssueCode",0,p,"ZodLazy",0,ek,"ZodLiteral",0,eb,"ZodMap",0,ey,"ZodNaN",0,eA,"ZodNativeEnum",0,e$,"ZodNever",0,el,"ZodNull",0,ea,"ZodNullable",0,eO,"ZodNumber",0,Q,"ZodObject",0,ec,"ZodOptional",0,ej,"ZodParsedType",0,d,"ZodPipeline",0,eD,"ZodPromise",0,eT,"ZodReadonly",0,eC,"ZodRecord",0,eg,"ZodSchema",0,P,"ZodSet",0,ev,"ZodString",0,X,"ZodSymbol",0,es,"ZodTransformer",0,eN,"ZodTuple",0,ef,"ZodType",0,P,"ZodUndefined",0,er,"ZodUnion",0,ep,"ZodUnknown",0,eo,"ZodVoid",0,eu,"addIssueToContext",0,k,"any",0,eK,"array",0,e0,"bigint",0,ez,"boolean",0,eB,"coerce",0,tm,"custom",0,eL,"date",0,eJ,"datetimeRegex",0,G,"defaultErrorMap",0,_,"discriminatedUnion",0,e9,"effect",0,ti,"enum",0,ts,"function",0,te,"getErrorMap",0,y,"getParsedType",0,c,"instanceof",0,eU,"intersection",0,e5,"isAborted",0,T,"isAsync",0,O,"isDirty",0,N,"isValid",0,j,"late",0,eR,"lazy",0,tt,"literal",0,tn,"makeIssue",0,v,"map",0,e7,"nan",0,eW,"nativeEnum",0,tr,"never",0,eX,"null",0,eq,"nullable",0,tl,"number",0,eY,"object",0,e1,"objectUtil",0,i,"oboolean",0,th,"onumber",0,tp,"optional",0,to,"ostring",0,tc,"pipeline",0,td,"preprocess",0,tu,"promise",0,ta,"quotelessJson",0,h,"record",0,e8,"set",0,e6,"setErrorMap",0,g,"strictObject",0,e2,"string",0,eF,"symbol",0,eH,"transformer",0,ti,"tuple",0,e3,"undefined",0,eV,"union",0,e4,"unknown",0,eG,"util",0,a,"void",0,eQ],35907);var t_=e.i(35907),t_=t_,tf=e.i(54853);let tg=t_.enum(tf.GOAL_CATEGORIES),ty=t_.enum(["shipped","partial","exploratory","blocked","trivial"]),tv=t_.enum(["essential","helpful","neutral","unhelpful"]),tw=t_.object({brief_summary:t_.string().min(1),underlying_goal:t_.string().min(1),friction_detail:t_.string().nullable(),user_instructions:t_.array(t_.string()),goal_categories:t_.record(tg,t_.number().nonnegative()),outcome:ty,claude_helpfulness:tv}).passthrough(),tk=`You are analyzing one (session \xd7 local-day) slice of a developer's Claude Code work.
2
2
 
3
3
  Given deterministic facts + up to 8 human-filtered turns, extract structured facets.
4
4
 
@@ -43,29 +43,29 @@ RESPOND WITH ONLY VALID JSON (no prose, no code fence):
43
43
  "goal_categories": {"build": N, "plan": N, ...},
44
44
  "outcome": "shipped" | "partial" | "exploratory" | "blocked" | "trivial",
45
45
  "claude_helpfulness": "essential" | "helpful" | "neutral" | "unhelpful"
46
- }`;var tb=e.i(74533),tx=e.i(2157),tS=e.i(50227),t$=e.i(66680),tT=e.i(43427),tN=e.i(60526);class tj extends Error{constructor(e){super(e),this.name="TmuxUnavailableError"}}class tO extends Error{constructor(e){super(e),this.name="TmuxRunError"}}function tM(e){let t=(0,tb.spawnSync)("/usr/bin/env",["which",e],{encoding:"utf8"});if(0===t.status)return t.stdout.trim()||void 0}function tE(){return tM("tmux")?tM("claude")?{ok:!0}:{ok:!1,reason:"claude not on PATH"}:{ok:!1,reason:"tmux not on PATH"}}let tA=Promise.resolve();function tP(e){let t=tA.then(()=>tZ(e));return tA=t.catch(()=>void 0),t}async function tZ(e){let t,n,s=e.tmuxBin??tM("tmux");if(!s)throw new tj("tmux not on PATH");let a=e.claudeBin??tM("claude");if(!a)throw new tj("claude not on PATH");if(e.signal?.aborted)throw new tO("aborted before spawn");let r=(n=(0,tS.join)((0,tN.homedir)(),".cclens","runtime"),(0,tx.existsSync)(n)||(0,tx.mkdirSync)(n,{recursive:!0}),(0,tx.realpathSync)(n));!function(e){let t,n=(0,tS.join)((0,tN.homedir)(),".claude.json");try{t=JSON.parse((0,tx.readFileSync)(n,"utf8"))}catch{return}let s=t.projects??{},a=s[e];if(a&&!0===a.hasTrustDialogAccepted)return;s[e]={...a??{},hasTrustDialogAccepted:!0},t.projects=s;let r=`${n}.cclens-tmp-${process.pid}`;try{(0,tx.writeFileSync)(r,JSON.stringify(t,null,2)),(0,tx.renameSync)(r,n)}catch{try{(0,tx.unlinkSync)(r)}catch{}}}(r);let i=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,o=`cclens-${i}`,l=(0,tS.join)(r,`system-${i}.txt`),u=(0,tS.join)(r,`user-${i}.txt`),d=(0,tS.join)(r,`run-${i}.sh`);(0,tx.writeFileSync)(l,e.systemPrompt),(0,tx.writeFileSync)(u,e.reminder?`${e.userPrompt}
46
+ }`;var tb=e.i(74533),tx=e.i(2157),tS=e.i(50227),t$=e.i(66680),tT=e.i(43427),tN=e.i(60526);function tj(e={}){let t=e.env??process.env,n=e.home??(0,tN.homedir)(),s=e.execPath??process.execPath,r=e.exists??tx.existsSync;for(let e of(t.PATH??"").split(tS.delimiter)){if(!e)continue;let t=(0,tS.join)(e,"claude");if(r(t))return t}return[(0,tS.join)(n,".local","bin","claude"),(0,tS.join)(n,".claude","local","claude"),(0,tS.join)((0,tS.dirname)(s),"claude"),"/opt/homebrew/bin/claude","/usr/local/bin/claude"].find(r)}function tO(e,t=process.env,n=process.execPath){let s=(t.PATH??"").split(tS.delimiter).filter(Boolean);for(let t of[(0,tS.dirname)(n),(0,tS.dirname)(e)])s.includes(t)||s.unshift(t);return{...t,PATH:s.join(tS.delimiter)}}class tM extends Error{constructor(){super("claude CLI not found. Looked on PATH and in ~/.local/bin, ~/.claude/local, the npm global bin, homebrew, and /usr/local/bin. Install it, or if Fleetlens was started at login, restart it from a terminal: fleetlens stop && fleetlens start"),this.name="ClaudeBinNotFoundError"}}e.s(["ClaudeBinNotFoundError",0,tM,"claudeSpawnEnv",0,tO,"resolveClaudeBin",0,tj],81454);class tE extends Error{constructor(e){super(e),this.name="TmuxUnavailableError"}}class tA extends Error{constructor(e){super(e),this.name="TmuxRunError"}}function tP(e){let t=(0,tb.spawnSync)("/usr/bin/env",["which",e],{encoding:"utf8"});if(0===t.status)return t.stdout.trim()||void 0}function tZ(){return tP("tmux")?tj()?{ok:!0}:{ok:!1,reason:"claude CLI not found"}:{ok:!1,reason:"tmux not on PATH"}}let tD=Promise.resolve();function tC(e){let t=tD.then(()=>tI(e));return tD=t.catch(()=>void 0),t}async function tI(e){let t,n,s=e.tmuxBin??tP("tmux");if(!s)throw new tE("tmux not on PATH");let r=e.claudeBin??tj();if(!r)throw new tE("claude CLI not found");if(e.signal?.aborted)throw new tA("aborted before spawn");let a=(n=(0,tS.join)((0,tN.homedir)(),".cclens","runtime"),(0,tx.existsSync)(n)||(0,tx.mkdirSync)(n,{recursive:!0}),(0,tx.realpathSync)(n));!function(e){let t,n=(0,tS.join)((0,tN.homedir)(),".claude.json");try{t=JSON.parse((0,tx.readFileSync)(n,"utf8"))}catch{return}let s=t.projects??{},r=s[e];if(r&&!0===r.hasTrustDialogAccepted)return;s[e]={...r??{},hasTrustDialogAccepted:!0},t.projects=s;let a=`${n}.cclens-tmp-${process.pid}`;try{(0,tx.writeFileSync)(a,JSON.stringify(t,null,2)),(0,tx.renameSync)(a,n)}catch{try{(0,tx.unlinkSync)(a)}catch{}}}(a);let i=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,o=`cclens-${i}`,l=(0,tS.join)(a,`system-${i}.txt`),u=(0,tS.join)(a,`user-${i}.txt`),d=(0,tS.join)(a,`run-${i}.sh`);(0,tx.writeFileSync)(l,e.systemPrompt),(0,tx.writeFileSync)(u,e.reminder?`${e.userPrompt}
47
47
 
48
48
  ---
49
49
 
50
50
  ${e.reminder}`:e.userPrompt),(0,tx.writeFileSync)(d,`#!/bin/bash
51
- SYS="$(cat ${tU(l)})"
52
- USR="$(cat ${tU(u)})"
53
- exec ${tU(a)} \\
54
- --model ${tU(e.model)} \\
51
+ SYS="$(cat ${tW(l)})"
52
+ USR="$(cat ${tW(u)})"
53
+ exec ${tW(r)} \\
54
+ --model ${tW(e.model)} \\
55
55
  --strict-mcp-config --mcp-config '{"mcpServers":{}}' \\
56
56
  --disable-slash-commands \\
57
57
  --effort medium \\
58
58
  --append-system-prompt "$SYS" \\
59
59
  "$USR"
60
- `,{mode:493});let c=function(){let e,t=new Set,n=tC();try{e=(0,tx.readdirSync)(n)}catch{return t}for(let s of e){let e,a=(0,tS.join)(n,s);try{e=(0,tx.readdirSync)(a)}catch{continue}for(let n of e)n.endsWith(".jsonl")&&t.add((0,tS.join)(a,n))}return t}(),p=(0,tb.spawnSync)(s,["new-session","-d","-s",o,"-x","140","-y","50","-c",r,d],{encoding:"utf8"});if(0!==p.status)throw tR(r,i,s,o),new tO(`tmux new-session failed: ${p.stderr.trim()}`);let h=()=>{try{(0,tb.spawnSync)(s,["kill-session","-t",o],{stdio:"ignore"})}catch{}};e.signal?.addEventListener("abort",h,{once:!0});let m=Date.now(),_=e.timeoutMs??12e4,f=-1,g=0;try{for(t=await tL(r,c,m,_,e.signal);Date.now()-m<_;){if(e.signal?.aborted)throw new tO("aborted");let{assembled:n,inputTokens:s,outputTokens:a,modelUsed:r,done:i}=function(e,t){let n;try{n=(0,tx.readFileSync)(e,"utf8")}catch{return{assembled:"",inputTokens:0,outputTokens:0,modelUsed:t,done:!1}}let s="",a=0,r=0,i=t,o=!1;for(let e of n.split("\n")){let t,n=e.trim();if(!n)continue;try{t=JSON.parse(n)}catch{continue}if("assistant"!==t.type)continue;let l=t.message;if(!l)continue;let u=l.model;u&&(i=u);let d=l.content;if(Array.isArray(d))for(let e of d)"text"===e.type&&"string"==typeof e.text&&(s+=e.text);let c=l.usage;c&&(a=tD(c.input_tokens)+tD(c.cache_creation_input_tokens)+tD(c.cache_read_input_tokens),r=tD(c.output_tokens)),"end_turn"===l.stop_reason&&(o=!0)}return{assembled:s,inputTokens:a,outputTokens:r,modelUsed:i,done:o}}(t,e.model);if(e.onProgress){let t=Math.floor(n.length/1024);t>f&&(f=t,e.onProgress({bytes:n.length,elapsedMs:Date.now()-m}))}if(e.onDelta&&n.length>g){let t=n.slice(g);g=n.length;try{e.onDelta(t)}catch{}}if(i&&n.length>0)return{content:n,input_tokens:s,output_tokens:a,model:r};await tI(500)}throw new tO(`timeout after ${_}ms waiting for assistant turn`)}finally{e.signal?.removeEventListener("abort",h),tR(r,i,s,o,t)}}function tD(e){return"number"==typeof e?e:0}function tI(e){return new Promise(t=>setTimeout(t,e))}let tC=()=>(0,tS.join)((0,tN.homedir)(),".claude","projects");async function tL(e,t,n,s,a){for(;Date.now()-n<s;){let n;if(a?.aborted)throw new tO("aborted");let s=tC();try{n=(0,tx.readdirSync)(s)}catch{n=[]}for(let a of n){let n,r=(0,tS.join)(s,a);try{n=(0,tx.readdirSync)(r)}catch{continue}for(let s of n){if(!s.endsWith(".jsonl"))continue;let n=(0,tS.join)(r,s);if(!t.has(n)&&function(e,t=8){let n;try{n=(0,tx.readFileSync)(e,"utf8")}catch{return}let s=0;for(let e of n.split("\n")){let n=e.trim();if(n){s++;try{let e=JSON.parse(n);if("string"==typeof e.cwd)return e.cwd}catch{}if(s>=t)break}}}(n)===e)return n}}await tI(300)}throw new tO(`timeout waiting for claude to create the session transcript (cwd: ${e})`)}function tR(e,t,n,s,a){try{(0,tb.spawnSync)(n,["kill-session","-t",s],{stdio:"ignore"})}catch{}if("1"!==process.env.FLEETLENS_TMUX_KEEP_WRAPPER){if(a)try{(0,tx.unlinkSync)(a)}catch{}for(let n of[`system-${t}.txt`,`user-${t}.txt`,`run-${t}.sh`])try{(0,tx.unlinkSync)((0,tS.join)(e,n))}catch{}}}function tU(e){return/^[A-Za-z0-9_./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\"'\"'")}'`}e.s(["TmuxRunError",0,tO,"TmuxUnavailableError",0,tj,"runClaudeUnderTmux",0,tP,"tmuxRunnerAvailable",0,tE],95549);let tF=(0,tT.cclensPath)("llm-runs");function tY(){if(!(0,tx.existsSync)(tF))try{(0,tx.mkdirSync)(tF,{recursive:!0})}catch{}}function tW(e){let t=e.slice(0,600).toLowerCase();return t.includes("weekly retrospective writer")?"week_digest":t.includes("editorial perception layer for one session")?"top_session":t.includes("single local day into a short, honest narrative")?"day_digest":t.includes("month")&&t.includes("digest")?"month_digest":t.includes("session × local-day")||t.includes("(session × local-day)")||t.includes("brief_summary")||t.includes("per-entry")||t.includes("per entry")?"entry_enrich":"unknown"}function tz(e){let t=new Date().toISOString().replace(/[:.]/g,"-"),n=(0,t$.randomUUID)().slice(0,8);return`${t}_${e}_${n}`}function tB(e){return(0,tS.join)(tF,`${e}.jsonl`)}function tJ(e,t){try{(0,tx.appendFileSync)(e,t)}catch{}}function tV(e,t){try{(0,tx.writeFileSync)(e,t)}catch{}}async function tH(e){var t;if("1"!==process.env.FLEETLENS_FORCE_PRINT_MODE&&tE().ok){let t=new Date().toISOString(),n=tW(e.systemPrompt),s=tz(n),a=tB(s);tY(),tV(a,JSON.stringify({_meta:{type:"start",run_id:s,kind:n,model:e.model,ts:t,runtime:"tmux",user_prompt_chars:e.userPrompt.length,reminder_chars:e.reminder?.length??0}})+"\n"),tJ(a,JSON.stringify({_meta:{type:"payload",run_id:s,system_prompt:e.systemPrompt,user_prompt:e.userPrompt,reminder:e.reminder??null}})+"\n");try{let t=Date.now(),n=await tP({systemPrompt:e.systemPrompt,model:e.model,userPrompt:e.userPrompt,reminder:e.reminder,onProgress:e.onProgress});return tJ(a,JSON.stringify({_meta:{type:"end",run_id:s,runtime:"tmux",ts:new Date().toISOString(),elapsed_ms:Date.now()-t,exit_code:0,content_chars:n.content.length,input_tokens:n.input_tokens,output_tokens:n.output_tokens,model_used:n.model}})+"\n"),n}catch(t){let e=t instanceof tj||t instanceof tO;tJ(a,JSON.stringify({_meta:{type:"tmux_fallback",run_id:s,ts:new Date().toISOString(),error:t.message,expected:e}})+"\n")}}return t=e,new Promise((e,n)=>{tY();let s=tW(t.systemPrompt),a=tz(s),r=tB(a),i=new Date().toISOString();tV(r,JSON.stringify({_meta:{type:"start",run_id:a,kind:s,model:t.model,ts:i,user_prompt_chars:t.userPrompt.length,reminder_chars:t.reminder?.length??0}})+"\n"),tJ(r,JSON.stringify({_meta:{type:"payload",run_id:a,system_prompt:t.systemPrompt,user_prompt:t.userPrompt,reminder:t.reminder??null}})+"\n");let o=["-p","--output-format","stream-json","--verbose","--model",t.model,"--tools","","--disable-slash-commands","--no-session-persistence","--setting-sources","","--strict-mcp-config","--mcp-config",'{"mcpServers":{}}',"--effort","medium","--append-system-prompt",t.systemPrompt],l=(0,tb.spawn)("claude",o,{stdio:["pipe","pipe","pipe"],env:{...process.env}});tJ(r,JSON.stringify({_meta:{type:"spawned",run_id:a,pid:l.pid}})+"\n");let u=t.reminder?`${t.userPrompt}
60
+ `,{mode:493});let c=function(){let e,t=new Set,n=tU();try{e=(0,tx.readdirSync)(n)}catch{return t}for(let s of e){let e,r=(0,tS.join)(n,s);try{e=(0,tx.readdirSync)(r)}catch{continue}for(let n of e)n.endsWith(".jsonl")&&t.add((0,tS.join)(r,n))}return t}(),p=(0,tb.spawnSync)(s,["new-session","-d","-s",o,"-x","140","-y","50","-c",a,d],{encoding:"utf8"});if(0!==p.status)throw tY(a,i,s,o),new tA(`tmux new-session failed: ${p.stderr.trim()}`);let h=()=>{try{(0,tb.spawnSync)(s,["kill-session","-t",o],{stdio:"ignore"})}catch{}};e.signal?.addEventListener("abort",h,{once:!0});let m=Date.now(),_=e.timeoutMs??12e4,f=-1,g=0;try{for(t=await tF(a,c,m,_,e.signal);Date.now()-m<_;){if(e.signal?.aborted)throw new tA("aborted");let{assembled:n,inputTokens:s,outputTokens:r,modelUsed:a,done:i}=function(e,t){let n;try{n=(0,tx.readFileSync)(e,"utf8")}catch{return{assembled:"",inputTokens:0,outputTokens:0,modelUsed:t,done:!1}}let s="",r=0,a=0,i=t,o=!1;for(let e of n.split("\n")){let t,n=e.trim();if(!n)continue;try{t=JSON.parse(n)}catch{continue}if("assistant"!==t.type)continue;let l=t.message;if(!l)continue;let u=l.model;u&&(i=u);let d=l.content;if(Array.isArray(d))for(let e of d)"text"===e.type&&"string"==typeof e.text&&(s+=e.text);let c=l.usage;c&&(r=tL(c.input_tokens)+tL(c.cache_creation_input_tokens)+tL(c.cache_read_input_tokens),a=tL(c.output_tokens)),"end_turn"===l.stop_reason&&(o=!0)}return{assembled:s,inputTokens:r,outputTokens:a,modelUsed:i,done:o}}(t,e.model);if(e.onProgress){let t=Math.floor(n.length/1024);t>f&&(f=t,e.onProgress({bytes:n.length,elapsedMs:Date.now()-m}))}if(e.onDelta&&n.length>g){let t=n.slice(g);g=n.length;try{e.onDelta(t)}catch{}}if(i&&n.length>0)return{content:n,input_tokens:s,output_tokens:r,model:a};await tR(500)}throw new tA(`timeout after ${_}ms waiting for assistant turn`)}finally{e.signal?.removeEventListener("abort",h),tY(a,i,s,o,t)}}function tL(e){return"number"==typeof e?e:0}function tR(e){return new Promise(t=>setTimeout(t,e))}let tU=()=>(0,tS.join)((0,tN.homedir)(),".claude","projects");async function tF(e,t,n,s,r){for(;Date.now()-n<s;){let n;if(r?.aborted)throw new tA("aborted");let s=tU();try{n=(0,tx.readdirSync)(s)}catch{n=[]}for(let r of n){let n,a=(0,tS.join)(s,r);try{n=(0,tx.readdirSync)(a)}catch{continue}for(let s of n){if(!s.endsWith(".jsonl"))continue;let n=(0,tS.join)(a,s);if(!t.has(n)&&function(e,t=8){let n;try{n=(0,tx.readFileSync)(e,"utf8")}catch{return}let s=0;for(let e of n.split("\n")){let n=e.trim();if(n){s++;try{let e=JSON.parse(n);if("string"==typeof e.cwd)return e.cwd}catch{}if(s>=t)break}}}(n)===e)return n}}await tR(300)}throw new tA(`timeout waiting for claude to create the session transcript (cwd: ${e})`)}function tY(e,t,n,s,r){try{(0,tb.spawnSync)(n,["kill-session","-t",s],{stdio:"ignore"})}catch{}if("1"!==process.env.FLEETLENS_TMUX_KEEP_WRAPPER){if(r)try{(0,tx.unlinkSync)(r)}catch{}for(let n of[`system-${t}.txt`,`user-${t}.txt`,`run-${t}.sh`])try{(0,tx.unlinkSync)((0,tS.join)(e,n))}catch{}}}function tW(e){return/^[A-Za-z0-9_./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\"'\"'")}'`}e.s(["TmuxRunError",0,tA,"TmuxUnavailableError",0,tE,"runClaudeUnderTmux",0,tC,"tmuxRunnerAvailable",0,tZ],95549);let tz=(0,tT.cclensPath)("llm-runs");function tB(){if(!(0,tx.existsSync)(tz))try{(0,tx.mkdirSync)(tz,{recursive:!0})}catch{}}function tJ(e){let t=e.slice(0,600).toLowerCase();return t.includes("weekly retrospective writer")?"week_digest":t.includes("editorial perception layer for one session")?"top_session":t.includes("single local day into a short, honest narrative")?"day_digest":t.includes("month")&&t.includes("digest")?"month_digest":t.includes("session × local-day")||t.includes("(session × local-day)")||t.includes("brief_summary")||t.includes("per-entry")||t.includes("per entry")?"entry_enrich":"unknown"}function tH(e){let t=new Date().toISOString().replace(/[:.]/g,"-"),n=(0,t$.randomUUID)().slice(0,8);return`${t}_${e}_${n}`}function tV(e){return(0,tS.join)(tz,`${e}.jsonl`)}function tq(e,t){try{(0,tx.appendFileSync)(e,t)}catch{}}function tK(e,t){try{(0,tx.writeFileSync)(e,t)}catch{}}async function tG(e){var t;if("1"!==process.env.FLEETLENS_FORCE_PRINT_MODE&&tZ().ok){let t=new Date().toISOString(),n=tJ(e.systemPrompt),s=tH(n),r=tV(s);tB(),tK(r,JSON.stringify({_meta:{type:"start",run_id:s,kind:n,model:e.model,ts:t,runtime:"tmux",user_prompt_chars:e.userPrompt.length,reminder_chars:e.reminder?.length??0}})+"\n"),tq(r,JSON.stringify({_meta:{type:"payload",run_id:s,system_prompt:e.systemPrompt,user_prompt:e.userPrompt,reminder:e.reminder??null}})+"\n");try{let t=Date.now(),n=await tC({systemPrompt:e.systemPrompt,model:e.model,userPrompt:e.userPrompt,reminder:e.reminder,onProgress:e.onProgress});return tq(r,JSON.stringify({_meta:{type:"end",run_id:s,runtime:"tmux",ts:new Date().toISOString(),elapsed_ms:Date.now()-t,exit_code:0,content_chars:n.content.length,input_tokens:n.input_tokens,output_tokens:n.output_tokens,model_used:n.model}})+"\n"),n}catch(t){let e=t instanceof tE||t instanceof tA;tq(r,JSON.stringify({_meta:{type:"tmux_fallback",run_id:s,ts:new Date().toISOString(),error:t.message,expected:e}})+"\n")}}return t=e,new Promise((e,n)=>{tB();let s=tJ(t.systemPrompt),r=tH(s),a=tV(r),i=new Date().toISOString();tK(a,JSON.stringify({_meta:{type:"start",run_id:r,kind:s,model:t.model,ts:i,user_prompt_chars:t.userPrompt.length,reminder_chars:t.reminder?.length??0}})+"\n"),tq(a,JSON.stringify({_meta:{type:"payload",run_id:r,system_prompt:t.systemPrompt,user_prompt:t.userPrompt,reminder:t.reminder??null}})+"\n");let o=["-p","--output-format","stream-json","--verbose","--model",t.model,"--tools","","--disable-slash-commands","--no-session-persistence","--setting-sources","","--strict-mcp-config","--mcp-config",'{"mcpServers":{}}',"--effort","medium","--append-system-prompt",t.systemPrompt],l=tj();if(!l){let e=new tM;tq(a,JSON.stringify({_meta:{type:"spawn_error",run_id:r,ts:new Date().toISOString(),error:e.message}})+"\n"),n(e);return}let u=(0,tb.spawn)(l,o,{stdio:["pipe","pipe","pipe"],env:tO(l)});tq(a,JSON.stringify({_meta:{type:"spawned",run_id:r,pid:u.pid}})+"\n");let d=t.reminder?`${t.userPrompt}
61
61
 
62
62
  ---
63
63
 
64
- ${t.reminder}`:t.userPrompt;l.stdin.write(u),l.stdin.end();let d="",c=0,p=0,h=t.model,m="",_=Date.now(),f=-1;l.stdout.on("data",e=>{for(let n of e.toString("utf8").split("\n")){let e=n.trim();if(e){tJ(r,e+"\n");try{let n=JSON.parse(e);if("assistant"===n.type){let e=n.message,s=e?.content;if(Array.isArray(s)){for(let e of s)if("text"===e.type&&"string"==typeof e.text&&(d+=e.text,t.onProgress)){let e=Math.floor(d.length/1024);e>f&&(f=e,t.onProgress({bytes:d.length,elapsedMs:Date.now()-_}))}}let a=e?.model;a&&(h=a)}if("result"===n.type){let e=n.usage;e&&(c=e.input_tokens??0,p=e.output_tokens??0)}}catch{}}}}),l.stderr.on("data",e=>{m+=e.toString("utf8")}),l.on("close",t=>{let s=Date.now()-_;(tJ(r,JSON.stringify({_meta:{type:"end",run_id:a,ts:new Date().toISOString(),elapsed_ms:s,exit_code:t,content_chars:d.length,input_tokens:c,output_tokens:p,model_used:h,stderr_tail:m?m.trim().slice(-500):null}})+"\n"),0===t||d)?e({content:d,input_tokens:c,output_tokens:p,model:h}):n(Error(`claude exited ${t}: ${m.trim().slice(0,300)}`))}),l.on("error",e=>{tJ(r,JSON.stringify({_meta:{type:"spawn_error",run_id:a,ts:new Date().toISOString(),error:e.message}})+"\n"),n(Error(`Failed to spawn claude: ${e.message}`))})})}function tq(e,t){let n=e.trim().replace(/^```(?:json)?\n?/,"").replace(/\n?```\s*$/,"").trim();try{let e=JSON.parse(n),s=t.safeParse(e);if(s.success)return{ok:!0,value:s.data};return{ok:!1,error:"schema: "+s.error.message}}catch(e){return{ok:!1,error:"json: "+e.message}}}function tK(e,t,n){let s;if(e.includes("opus"))s={input:15,output:75};else if(e.includes("sonnet"))s={input:3,output:15};else{if(!e.includes("haiku"))return 0;s={input:1,output:5}}return(t*s.input+n*s.output)/1e6}function tG(e){return tH({systemPrompt:tk,model:e.model,userPrompt:e.userPrompt,reminder:e.reminder,onProgress:e.onProgress})}function tX(e){let t,n,s=e.trim().replace(/^```(?:json)?\n?/,"").replace(/\n?```\s*$/,"").trim();if((n=s.trim().slice(0,200).toLowerCase()).startsWith("you've hit")||n.startsWith("you have hit")||n.startsWith("you have reached")||n.startsWith("rate limit")||n.includes("5-hour limit")||n.includes("weekly limit")||n.includes("usage limit"))return{ok:!1,error:"rate-limited: "+s.slice(0,160),rateLimited:!0};try{t=JSON.parse(s)}catch(e){return{ok:!1,error:"JSON parse failed: "+e.message}}let a=tw.safeParse(t);return a.success?{ok:!0,value:a.data}:{ok:!1,error:"schema validation failed: "+a.error.message}}async function tQ(e,t={}){let n,s,a=t.model??"sonnet",r=t.callLLM??tG,i=function(e){let t=[];for(let n of(e.first_user&&t.push(e.first_user),e.enrichment.user_instructions))t.push(n);return t.filter(e=>"human"===(0,u.classifyUserInputSource)(e))}(e),o=(n={active_min:e.numbers.active_min,turn_count:e.numbers.turn_count,tools_total:e.numbers.tools_total,subagent_calls:e.numbers.subagent_calls,skill_calls:e.numbers.skill_calls,flags:e.flags,primary_model:e.primary_model,pr_titles:e.pr_titles,top_tools:e.top_tools,first_user:e.first_user,final_agent:e.final_agent,satisfaction_signals:e.satisfaction_signals,user_input_sources:e.user_input_sources},s=i.slice(0,8).map((e,t)=>`${t+1}. ${e.length<=300?e:e.slice(0,299)+"…"}`).join("\n"),`SLICE FACTS:
64
+ ${t.reminder}`:t.userPrompt;u.stdin.write(d),u.stdin.end();let c="",p=0,h=0,m=t.model,_="",f=Date.now(),g=-1;u.stdout.on("data",e=>{for(let n of e.toString("utf8").split("\n")){let e=n.trim();if(e){tq(a,e+"\n");try{let n=JSON.parse(e);if("assistant"===n.type){let e=n.message,s=e?.content;if(Array.isArray(s)){for(let e of s)if("text"===e.type&&"string"==typeof e.text&&(c+=e.text,t.onProgress)){let e=Math.floor(c.length/1024);e>g&&(g=e,t.onProgress({bytes:c.length,elapsedMs:Date.now()-f}))}}let r=e?.model;r&&(m=r)}if("result"===n.type){let e=n.usage;e&&(p=e.input_tokens??0,h=e.output_tokens??0)}}catch{}}}}),u.stderr.on("data",e=>{_+=e.toString("utf8")}),u.on("close",t=>{let s=Date.now()-f;(tq(a,JSON.stringify({_meta:{type:"end",run_id:r,ts:new Date().toISOString(),elapsed_ms:s,exit_code:t,content_chars:c.length,input_tokens:p,output_tokens:h,model_used:m,stderr_tail:_?_.trim().slice(-500):null}})+"\n"),0===t||c)?e({content:c,input_tokens:p,output_tokens:h,model:m}):n(Error(`claude exited ${t}: ${_.trim().slice(0,300)}`))}),u.on("error",e=>{tq(a,JSON.stringify({_meta:{type:"spawn_error",run_id:r,ts:new Date().toISOString(),error:e.message}})+"\n"),n(Error(`Failed to spawn claude: ${e.message}`))})})}function tX(e,t){let n=e.trim().replace(/^```(?:json)?\n?/,"").replace(/\n?```\s*$/,"").trim();try{let e=JSON.parse(n),s=t.safeParse(e);if(s.success)return{ok:!0,value:s.data};return{ok:!1,error:"schema: "+s.error.message}}catch(e){return{ok:!1,error:"json: "+e.message}}}function tQ(e,t,n){let s;if(e.includes("opus"))s={input:15,output:75};else if(e.includes("sonnet"))s={input:3,output:15};else{if(!e.includes("haiku"))return 0;s={input:1,output:5}}return(t*s.input+n*s.output)/1e6}function t0(e){return tG({systemPrompt:tk,model:e.model,userPrompt:e.userPrompt,reminder:e.reminder,onProgress:e.onProgress})}function t1(e){let t,n,s=e.trim().replace(/^```(?:json)?\n?/,"").replace(/\n?```\s*$/,"").trim();if((n=s.trim().slice(0,200).toLowerCase()).startsWith("you've hit")||n.startsWith("you have hit")||n.startsWith("you have reached")||n.startsWith("rate limit")||n.includes("5-hour limit")||n.includes("weekly limit")||n.includes("usage limit"))return{ok:!1,error:"rate-limited: "+s.slice(0,160),rateLimited:!0};try{t=JSON.parse(s)}catch(e){return{ok:!1,error:"JSON parse failed: "+e.message}}let r=tw.safeParse(t);return r.success?{ok:!0,value:r.data}:{ok:!1,error:"schema validation failed: "+r.error.message}}async function t2(e,t={}){let n,s,r=t.model??"sonnet",a=t.callLLM??t0,i=function(e){let t=[];for(let n of(e.first_user&&t.push(e.first_user),e.enrichment.user_instructions))t.push(n);return t.filter(e=>"human"===(0,u.classifyUserInputSource)(e))}(e),o=(n={active_min:e.numbers.active_min,turn_count:e.numbers.turn_count,tools_total:e.numbers.tools_total,subagent_calls:e.numbers.subagent_calls,skill_calls:e.numbers.skill_calls,flags:e.flags,primary_model:e.primary_model,pr_titles:e.pr_titles,top_tools:e.top_tools,first_user:e.first_user,final_agent:e.final_agent,satisfaction_signals:e.satisfaction_signals,user_input_sources:e.user_input_sources},s=i.slice(0,8).map((e,t)=>`${t+1}. ${e.length<=300?e:e.slice(0,299)+"…"}`).join("\n"),`SLICE FACTS:
65
65
  ${JSON.stringify(n,null,2)}
66
66
 
67
67
  HUMAN TURNS (up to 8, each truncated to 300 chars):
68
- ${s||"(none — the user text was filtered out as non-human)"}`),l=new Date().toISOString(),d=0,c=0,p=!1,h=a,m="",_=!0;try{let n=await r({model:a,userPrompt:o,onProgress:t.onProgress});p=!0,d+=n.input_tokens,c+=n.output_tokens,h=n.model;let s=tX(n.content);if(s.ok){let t=tK(h,d,c);return{entry:t0(e,s.value,h,t,l),usage:{input_tokens:d,output_tokens:c}}}if(m=s.error,s.rateLimited||(_=!1),!s.rateLimited){let n=await r({model:a,userPrompt:o,reminder:"Your previous response was not valid JSON or did not match the required schema. Return ONLY the JSON object with the seven required fields — no prose, no code fence.",onProgress:t.onProgress});d+=n.input_tokens,c+=n.output_tokens,h=n.model;let s=tX(n.content);if(s.ok){let t=tK(h,d,c);return{entry:t0(e,s.value,h,t,l),usage:{input_tokens:d,output_tokens:c}}}m=s.error,s.rateLimited||(_=!1)}}catch(e){m=e.message||"unknown LLM error",_=!1}let f=tK(h,d,c);return{entry:function(e,t,n,s,a,r=!1){if(r){let r={...e.enrichment,status:"pending",generated_at:a,model:n,cost_usd:s,error:t};return{...e,enrichment:r}}let i={...e.enrichment,status:"error",generated_at:a,model:n,cost_usd:s,error:t,retry_count:(e.enrichment.retry_count??0)+1};return{...e,enrichment:i}}(e,m,h,f,l,_),usage:p?{input_tokens:d,output_tokens:c}:null}}function t0(e,t,n,s,a){let r={...e.enrichment,status:"done",generated_at:a,model:n,cost_usd:s,error:null,brief_summary:t.brief_summary,underlying_goal:t.underlying_goal,friction_detail:t.friction_detail,user_instructions:t.user_instructions,goal_categories:t.goal_categories,outcome:t.outcome,claude_helpfulness:t.claude_helpfulness};return{...e,enrichment:r}}e.s(["parseAndValidate",0,tq,"runClaudeSubprocess",0,tH],90555);let t1=null;function t2(){return t1||(t1=(0,tT.cclensPath)("llm-spend.jsonl"))}function t4(e){let t=t2();(0,tx.mkdirSync)((0,tS.dirname)(t),{recursive:!0}),(0,tx.appendFileSync)(t,JSON.stringify(e)+"\n",{encoding:"utf8"})}function t9(e=new Date){let t=t2();if(!(0,tx.existsSync)(t))return 0;let n=e.getUTCFullYear(),s=e.getUTCMonth(),a=0;for(let e of(0,tx.readFileSync)(t,"utf8").split("\n")){let t;if(!e)continue;try{t=JSON.parse(e)}catch{continue}let r=new Date(t.ts);Number.isNaN(r.getTime())||r.getUTCFullYear()===n&&r.getUTCMonth()===s&&(a+=t.cost_usd)}return a}e.s(["appendSpend",0,t4,"monthToDateSpend",0,t9],78325);var t5=e.i(5737);let t3=null,t7=null;function t8(){return t3||(t3=(0,tT.cclensPath)("llm-interactive.lock"))}function t6(){(0,tx.writeFileSync)(t8(),String(process.pid),"utf8")}function ne(){t6(),t7&&clearInterval(t7),t7=setInterval(()=>{try{t6()}catch{}},3e4),t7.unref?.()}function nt(){t7&&(clearInterval(t7),t7=null);try{(0,tx.unlinkSync)(t8())}catch{}}e.s(["interactiveLockFresh",0,function(e){let t=t8();if(!(0,tx.existsSync)(t))return!1;try{let n=(0,tx.statSync)(t).mtimeMs;if(e-n>6e4)return!1;let s=Number((0,tx.readFileSync)(t,"utf8").trim());if(!Number.isFinite(s)||s<=0||!function(e){try{return process.kill(e,0),!0}catch{return!1}}(s))return!1;return!0}catch{return!1}},"removeInteractiveLock",0,nt,"writeInteractiveLock",0,ne],86291);let nn={ai_features:{enabled:!0,model:"sonnet",monthlyBudgetUsd:null,autoBackfillLastWeek:!0,autoBackfillYesterday:!0}},ns=null;function na(){return ns||(ns=(0,tT.cclensPath)("settings.json"))}e.s(["readSettings",0,function(){let e=na();if(!(0,tx.existsSync)(e))return nn;try{let t,n=(0,tx.readFileSync)(e,"utf8");return{ai_features:{enabled:(t=JSON.parse(n).ai_features??{}).enabled??nn.ai_features.enabled,model:t.model??nn.ai_features.model,monthlyBudgetUsd:t.monthly_budget_usd??null,autoBackfillLastWeek:t.auto_backfill_last_week??nn.ai_features.autoBackfillLastWeek,autoBackfillYesterday:t.auto_backfill_yesterday??nn.ai_features.autoBackfillYesterday}}}catch{return nn}},"writeSettings",0,function(e){let t=na();(0,tx.mkdirSync)((0,tS.dirname)(t),{recursive:!0});let n=`${t}.tmp`;(0,tx.writeFileSync)(n,JSON.stringify({ai_features:{enabled:e.ai_features.enabled,model:e.ai_features.model,monthly_budget_usd:e.ai_features.monthlyBudgetUsd,auto_backfill_last_week:e.ai_features.autoBackfillLastWeek,auto_backfill_yesterday:e.ai_features.autoBackfillYesterday}},null,2),{encoding:"utf8"}),(0,tx.chmodSync)(n,384),(0,tx.renameSync)(n,t)}],56614);var t_=t_;e.i(27174);var nr=e.i(39587);let ni=nr.agentMetadata.map(e=>` - agent="${e.kind}" → render as "${e.displayName}"`).join("\n"),no=t_.object({headline:t_.string().min(1).max(80),body:t_.string().min(1).max(300)}),nl=t_.object({headline:t_.string().min(1).max(160),narrative:t_.string().max(1200).nullable(),what_went_well:t_.string().max(400).nullable(),what_hit_friction:t_.string().max(400).nullable(),suggestion:no.nullable(),day_signature:t_.string().max(160).nullable().optional()}).passthrough(),nu=`You are synthesizing a developer's coding-agent activity for a single local day into a short, honest narrative digest.
68
+ ${s||"(none — the user text was filtered out as non-human)"}`),l=new Date().toISOString(),d=0,c=0,p=!1,h=r,m="",_=!0;try{let n=await a({model:r,userPrompt:o,onProgress:t.onProgress});p=!0,d+=n.input_tokens,c+=n.output_tokens,h=n.model;let s=t1(n.content);if(s.ok){let t=tQ(h,d,c);return{entry:t4(e,s.value,h,t,l),usage:{input_tokens:d,output_tokens:c}}}if(m=s.error,s.rateLimited||(_=!1),!s.rateLimited){let n=await a({model:r,userPrompt:o,reminder:"Your previous response was not valid JSON or did not match the required schema. Return ONLY the JSON object with the seven required fields — no prose, no code fence.",onProgress:t.onProgress});d+=n.input_tokens,c+=n.output_tokens,h=n.model;let s=t1(n.content);if(s.ok){let t=tQ(h,d,c);return{entry:t4(e,s.value,h,t,l),usage:{input_tokens:d,output_tokens:c}}}m=s.error,s.rateLimited||(_=!1)}}catch(e){m=e.message||"unknown LLM error",_=!1}let f=tQ(h,d,c);return{entry:function(e,t,n,s,r,a=!1){if(a){let a={...e.enrichment,status:"pending",generated_at:r,model:n,cost_usd:s,error:t};return{...e,enrichment:a}}let i={...e.enrichment,status:"error",generated_at:r,model:n,cost_usd:s,error:t,retry_count:(e.enrichment.retry_count??0)+1};return{...e,enrichment:i}}(e,m,h,f,l,_),usage:p?{input_tokens:d,output_tokens:c}:null}}function t4(e,t,n,s,r){let a={...e.enrichment,status:"done",generated_at:r,model:n,cost_usd:s,error:null,brief_summary:t.brief_summary,underlying_goal:t.underlying_goal,friction_detail:t.friction_detail,user_instructions:t.user_instructions,goal_categories:t.goal_categories,outcome:t.outcome,claude_helpfulness:t.claude_helpfulness};return{...e,enrichment:a}}e.s(["parseAndValidate",0,tX,"runClaudeSubprocess",0,tG],90555);let t9=null;function t5(){return t9||(t9=(0,tT.cclensPath)("llm-spend.jsonl"))}function t3(e){let t=t5();(0,tx.mkdirSync)((0,tS.dirname)(t),{recursive:!0}),(0,tx.appendFileSync)(t,JSON.stringify(e)+"\n",{encoding:"utf8"})}function t8(e=new Date){let t=t5();if(!(0,tx.existsSync)(t))return 0;let n=e.getUTCFullYear(),s=e.getUTCMonth(),r=0;for(let e of(0,tx.readFileSync)(t,"utf8").split("\n")){let t;if(!e)continue;try{t=JSON.parse(e)}catch{continue}let a=new Date(t.ts);Number.isNaN(a.getTime())||a.getUTCFullYear()===n&&a.getUTCMonth()===s&&(r+=t.cost_usd)}return r}e.s(["appendSpend",0,t3,"monthToDateSpend",0,t8],78325);var t7=e.i(5737);let t6=null,ne=null;function nt(){return t6||(t6=(0,tT.cclensPath)("llm-interactive.lock"))}function nn(){(0,tx.writeFileSync)(nt(),String(process.pid),"utf8")}function ns(){nn(),ne&&clearInterval(ne),ne=setInterval(()=>{try{nn()}catch{}},3e4),ne.unref?.()}function nr(){ne&&(clearInterval(ne),ne=null);try{(0,tx.unlinkSync)(nt())}catch{}}e.s(["interactiveLockFresh",0,function(e){let t=nt();if(!(0,tx.existsSync)(t))return!1;try{let n=(0,tx.statSync)(t).mtimeMs;if(e-n>6e4)return!1;let s=Number((0,tx.readFileSync)(t,"utf8").trim());if(!Number.isFinite(s)||s<=0||!function(e){try{return process.kill(e,0),!0}catch{return!1}}(s))return!1;return!0}catch{return!1}},"removeInteractiveLock",0,nr,"writeInteractiveLock",0,ns],86291);let na={ai_features:{enabled:!0,model:"sonnet",monthlyBudgetUsd:null,autoBackfillLastWeek:!0,autoBackfillYesterday:!0}},ni=null;function no(){return ni||(ni=(0,tT.cclensPath)("settings.json"))}e.s(["readSettings",0,function(){let e=no();if(!(0,tx.existsSync)(e))return na;try{let t,n=(0,tx.readFileSync)(e,"utf8");return{ai_features:{enabled:(t=JSON.parse(n).ai_features??{}).enabled??na.ai_features.enabled,model:t.model??na.ai_features.model,monthlyBudgetUsd:t.monthly_budget_usd??null,autoBackfillLastWeek:t.auto_backfill_last_week??na.ai_features.autoBackfillLastWeek,autoBackfillYesterday:t.auto_backfill_yesterday??na.ai_features.autoBackfillYesterday}}}catch{return na}},"writeSettings",0,function(e){let t=no();(0,tx.mkdirSync)((0,tS.dirname)(t),{recursive:!0});let n=`${t}.tmp`;(0,tx.writeFileSync)(n,JSON.stringify({ai_features:{enabled:e.ai_features.enabled,model:e.ai_features.model,monthly_budget_usd:e.ai_features.monthlyBudgetUsd,auto_backfill_last_week:e.ai_features.autoBackfillLastWeek,auto_backfill_yesterday:e.ai_features.autoBackfillYesterday}},null,2),{encoding:"utf8"}),(0,tx.chmodSync)(n,384),(0,tx.renameSync)(n,t)}],56614);var t_=t_;e.i(27174);var nl=e.i(39587);let nu=nl.agentMetadata.map(e=>` - agent="${e.kind}" → render as "${e.displayName}"`).join("\n"),nd=t_.object({headline:t_.string().min(1).max(80),body:t_.string().min(1).max(300)}),nc=t_.object({headline:t_.string().min(1).max(160),narrative:t_.string().max(1200).nullable(),what_went_well:t_.string().max(400).nullable(),what_hit_friction:t_.string().max(400).nullable(),suggestion:nd.nullable(),day_signature:t_.string().max(160).nullable().optional()}).passthrough(),np=`You are synthesizing a developer's coding-agent activity for a single local day into a short, honest narrative digest.
69
69
 
70
70
  The user runs MULTIPLE coding agents (Claude Code, OpenAI Codex CLI, possibly more). The day's input may include sessions from any registered agent — they all merge into one fleet view. When the day spans more than one agent (see DAY FACTS.agent_breakdown and per_entry.agent), the narrative SHOULD name the agents explicitly so the reader sees how the fleet was used.
71
71
 
@@ -110,7 +110,7 @@ CRITICAL RULES:
110
110
  - Second-person ("you ..."), not third-person.
111
111
  - Copy the user's phrasings where useful; do not invent features or outcomes not in the input.
112
112
  - **When DAY FACTS.agent_breakdown has more than one agent, the narrative MUST name them.** Render each agent kind with its canonical display name:
113
- ${ni}
113
+ ${nu}
114
114
  Treat the per-agent split as a load-bearing signal — if the user delegated specific work to a non-default agent, that distinction belongs in headline / narrative / what_went_well / what_hit_friction.
115
115
  - Do not mention a project unless it's in DAY FACTS.projects AND that project has a non-trivial entry (outcome != "trivial") in per_entry.
116
116
  - **Attribute every PR to its correct project using the per_entry list** — never join a PR title with a project from a different entry. If a project only has a trivial/warmup entry, do NOT describe any deliverable as happening in it.
@@ -134,25 +134,25 @@ RESPOND WITH ONLY VALID JSON (no prose, no code fence):
134
134
  "what_hit_friction": "..." | null,
135
135
  "suggestion": { "headline": "...", "body": "..." } | null,
136
136
  "day_signature": "..." | null
137
- }`;function nd(e,t){return e.length<=t?e:e.slice(0,t-1)+"…"}function nc(e){let t=e.split("/").filter(Boolean);return t[t.length-1]??e}function np(e){let t=e.split("/").filter(Boolean);return t[t.length-1]??e}function nh(e,t){return e.length<=t?e:e.slice(0,t-1).trimEnd()+"…"}function nm(e){let t=e.map(e=>e.signals??(0,u.computeEntrySignals)(e)),n=e.reduce((e,t)=>e+t.numbers.active_min,0),s=new Map,a={};for(let n=0;n<e.length;n++){let r=t[n].working_shape;r&&(s.set(r,(s.get(r)??0)+e[n].numbers.active_min),a[r]=(a[r]??0)+1)}let r=null;if(s.size>0&&n>0){let e=[...s.entries()].sort((e,t)=>t[1]-e[1])[0];r=e[1]/n>=.6?e[0]:"mixed"}let i=new Map;for(let t of e)for(let[e,n]of Object.entries(t.skills??{}))i.set(e,(i.get(e)??0)+n);let o=[...i.entries()].sort((e,t)=>t[1]-e[1]).map(([e,t])=>({skill:e,origin:(0,u.classifySkill)(e),count:t})),l=o.filter(e=>"user"===e.origin).map(e=>e.skill),d=new Map;for(let t of e)for(let e of t.subagents??[]){if((0,u.isStockSubagentType)(e.type))continue;let t=d.get(e.type)??{count:0,sample_description:e.description,sample_prompt_preview:e.prompt_preview};t.count+=1,e.prompt_preview.length>t.sample_prompt_preview.length&&(t.sample_description=e.description,t.sample_prompt_preview=e.prompt_preview),d.set(e.type,t)}let c=[...d.entries()].sort((e,t)=>t[1].count-e[1].count).map(([e,t])=>({type:e,count:t.count,sample_description:t.sample_description,sample_prompt_preview:nh(t.sample_prompt_preview,200)})),p=new Map;for(let e of t)for(let t of e.prompt_frames)p.set(t,(p.get(t)??0)+1);let h=[...p.entries()].sort((e,t)=>t[1]-e[1]).map(([e,t])=>({frame:e,origin:tf.PROMPT_FRAME_ORIGIN[e],count:t})),m={short:0,medium:0,long:0,very_long:0},_=[],f=0,g=0,y=0,v=0;for(let n=0;n<e.length;n++){let s=e[n],a=t[n];for(let e of((s.first_user??"").length>0&&(m[a.verbosity]+=1),a.external_refs))_.push({session_id:s.session_id,kind:e.kind,preview:nh(e.preview,200)});let r=s.numbers.interrupts??0;f+=r,g+=s.satisfaction_signals?.frustrated??0,y+=s.satisfaction_signals?.dissatisfied??0,r>=2&&(v+=1)}let w=t.filter(e=>e.brainstorm_warmup).length;return{dominant_shape:r,shape_distribution:a,skills_loaded:o,user_authored_skills_used:l,user_authored_subagents_used:c,prompt_frames:h,comm_style:{verbosity_distribution:m,external_refs:_,steering:{interrupts:f,frustrated:g,dissatisfied:y,sessions_with_mid_run_redirect:v}},brainstorm_warmup_session_count:w,todo_ops_total:e.reduce((e,t)=>e+(t.numbers.task_ops??0),0),plan_mode_used:e.some(e=>(e.numbers.exit_plan_calls??0)>0||(e.flags??[]).includes("plan_used"))}}function n_(e,t,n={}){let s=t.reduce((e,t)=>e+t.numbers.active_min,0),a=new Map;for(let e of t){let t=a.get(e.project)??{minutes:0,entry_count:0};t.minutes+=e.numbers.active_min,t.entry_count+=1,a.set(e.project,t)}let r=[...a.entries()].sort((e,t)=>t[1].minutes-e[1].minutes).map(([e,t])=>({name:e,display_name:np(e),share_pct:s>0?t.minutes/s*100:0,entry_count:t.entry_count})),i=t.flatMap(e=>e.pr_titles.map(t=>({title:t,project:np(e.project),session_id:e.session_id}))),o=new Map;for(let e of t)for(let t of e.flags)o.set(t,(o.get(t)??0)+1);let l=[...o.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({flag:e,count:t})),u=new Map;for(let e of t)if("done"===e.enrichment.status)for(let[t,n]of Object.entries(e.enrichment.goal_categories??{}))u.set(t,(u.get(t)??0)+(n??0));let d=[...u.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({category:e,minutes:t})),c={start:`${e}T00:00:00`,end:`${e}T23:59:59`},p=new Map;for(let e of t){let t=e.agent??"claude-code",n=p.get(t)??{sessions:0,active_min:0,tools_total:0};n.sessions+=1,n.active_min+=e.numbers.active_min,n.tools_total+=e.numbers.tools_total,p.set(t,n)}let h=0===p.size?void 0:Array.from(p.entries()).map(([e,t])=>({agent:e,sessions:t.sessions,active_min:Math.round(10*t.active_min)/10,tools_total:t.tools_total})).sort((e,t)=>t.active_min-e.active_min);return{version:tf.CURRENT_DAY_DIGEST_SCHEMA_VERSION,scope:"day",key:e,window:c,entry_refs:t.map(e=>`${e.session_id}__${e.local_day}`),generated_at:new Date().toISOString(),is_live:!1,model:null,cost_usd:null,projects:r,shipped:i,top_flags:l,top_goal_categories:d,concurrency_peak:n.concurrencyPeak??0,agent_min:s,agent_breakdown:h,outcome_day:function(e){if(0===e.length)return"idle";let t=new Set(e.map(e=>e.enrichment.outcome).filter(Boolean));return t.has("shipped")?"shipped":t.has("partial")?"partial":t.has("blocked")?"blocked":t.has("exploratory")?"exploratory":"trivial"}(t),helpfulness_day:function(e){let t=new Map;for(let n of e){let e=n.enrichment.claude_helpfulness;e&&t.set(e,(t.get(e)??0)+1)}if(0===t.size)return null;let n=null,s=0;for(let e of["unhelpful","neutral","helpful","essential"]){let a=t.get(e)??0;a>s&&(n=e,s=a)}return n}(t),day_signals:t.length>0?nm(t):void 0,headline:null,narrative:null,what_went_well:null,what_hit_friction:null,suggestion:null,day_signature:null}}let nf=e=>tH({...e,systemPrompt:nu});async function ng(e,t,n={}){let s,a,r,i,o,l,u,d=n_(e,t,{concurrencyPeak:n.concurrencyPeak});if(0===t.filter(e=>"done"===e.enrichment.status).length)return{digest:d,usage:null};let c=n.model??"sonnet",p=n.callLLM??nf,h=(a=(s=t.filter(e=>"done"===e.enrichment.status)).slice(0,12).map(e=>`- (${nc(e.project)}, ${Math.round(e.numbers.active_min)}m) ${nd(e.enrichment.brief_summary??"",240)}`).join("\n"),r=s.map(e=>e.enrichment.friction_detail).filter(e=>!!e).slice(0,6).map((e,t)=>`${t+1}. ${nd(e,240)}`).join("\n"),i=s.flatMap(e=>e.enrichment.user_instructions).slice(0,10).map((e,t)=>`${t+1}. ${nd(e,240)}`).join("\n"),o=t.map(e=>({agent:e.agent??"claude-code",project:nc(e.project),active_min:Math.round(10*e.numbers.active_min)/10,outcome:e.enrichment.outcome??"pending",pr_titles:e.pr_titles,flags:e.flags,primary_model:e.primary_model,brief_summary:"done"===e.enrichment.status?e.enrichment.brief_summary:null,friction_detail:"done"===e.enrichment.status?e.enrichment.friction_detail:null})),l={date:d.key,agent_min:d.agent_min,agent_breakdown:d.agent_breakdown??[],project_count:d.projects.length,projects:d.projects.map(e=>({name:e.display_name,share_pct:e.share_pct,entry_count:e.entry_count})),shipped:d.shipped.map(e=>({title:e.title,project:e.project})),concurrency_peak:d.concurrency_peak,top_flags:d.top_flags,top_goal_categories:d.top_goal_categories,per_entry:o},u=d.day_signals?`
137
+ }`;function nh(e,t){return e.length<=t?e:e.slice(0,t-1)+"…"}function nm(e){let t=e.split("/").filter(Boolean);return t[t.length-1]??e}function n_(e){let t=e.split("/").filter(Boolean);return t[t.length-1]??e}function nf(e,t){return e.length<=t?e:e.slice(0,t-1).trimEnd()+"…"}function ng(e){let t=e.map(e=>e.signals??(0,u.computeEntrySignals)(e)),n=e.reduce((e,t)=>e+t.numbers.active_min,0),s=new Map,r={};for(let n=0;n<e.length;n++){let a=t[n].working_shape;a&&(s.set(a,(s.get(a)??0)+e[n].numbers.active_min),r[a]=(r[a]??0)+1)}let a=null;if(s.size>0&&n>0){let e=[...s.entries()].sort((e,t)=>t[1]-e[1])[0];a=e[1]/n>=.6?e[0]:"mixed"}let i=new Map;for(let t of e)for(let[e,n]of Object.entries(t.skills??{}))i.set(e,(i.get(e)??0)+n);let o=[...i.entries()].sort((e,t)=>t[1]-e[1]).map(([e,t])=>({skill:e,origin:(0,u.classifySkill)(e),count:t})),l=o.filter(e=>"user"===e.origin).map(e=>e.skill),d=new Map;for(let t of e)for(let e of t.subagents??[]){if((0,u.isStockSubagentType)(e.type))continue;let t=d.get(e.type)??{count:0,sample_description:e.description,sample_prompt_preview:e.prompt_preview};t.count+=1,e.prompt_preview.length>t.sample_prompt_preview.length&&(t.sample_description=e.description,t.sample_prompt_preview=e.prompt_preview),d.set(e.type,t)}let c=[...d.entries()].sort((e,t)=>t[1].count-e[1].count).map(([e,t])=>({type:e,count:t.count,sample_description:t.sample_description,sample_prompt_preview:nf(t.sample_prompt_preview,200)})),p=new Map;for(let e of t)for(let t of e.prompt_frames)p.set(t,(p.get(t)??0)+1);let h=[...p.entries()].sort((e,t)=>t[1]-e[1]).map(([e,t])=>({frame:e,origin:tf.PROMPT_FRAME_ORIGIN[e],count:t})),m={short:0,medium:0,long:0,very_long:0},_=[],f=0,g=0,y=0,v=0;for(let n=0;n<e.length;n++){let s=e[n],r=t[n];for(let e of((s.first_user??"").length>0&&(m[r.verbosity]+=1),r.external_refs))_.push({session_id:s.session_id,kind:e.kind,preview:nf(e.preview,200)});let a=s.numbers.interrupts??0;f+=a,g+=s.satisfaction_signals?.frustrated??0,y+=s.satisfaction_signals?.dissatisfied??0,a>=2&&(v+=1)}let w=t.filter(e=>e.brainstorm_warmup).length;return{dominant_shape:a,shape_distribution:r,skills_loaded:o,user_authored_skills_used:l,user_authored_subagents_used:c,prompt_frames:h,comm_style:{verbosity_distribution:m,external_refs:_,steering:{interrupts:f,frustrated:g,dissatisfied:y,sessions_with_mid_run_redirect:v}},brainstorm_warmup_session_count:w,todo_ops_total:e.reduce((e,t)=>e+(t.numbers.task_ops??0),0),plan_mode_used:e.some(e=>(e.numbers.exit_plan_calls??0)>0||(e.flags??[]).includes("plan_used"))}}function ny(e,t,n={}){let s=t.reduce((e,t)=>e+t.numbers.active_min,0),r=new Map;for(let e of t){let t=r.get(e.project)??{minutes:0,entry_count:0};t.minutes+=e.numbers.active_min,t.entry_count+=1,r.set(e.project,t)}let a=[...r.entries()].sort((e,t)=>t[1].minutes-e[1].minutes).map(([e,t])=>({name:e,display_name:n_(e),share_pct:s>0?t.minutes/s*100:0,entry_count:t.entry_count})),i=t.flatMap(e=>e.pr_titles.map(t=>({title:t,project:n_(e.project),session_id:e.session_id}))),o=new Map;for(let e of t)for(let t of e.flags)o.set(t,(o.get(t)??0)+1);let l=[...o.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({flag:e,count:t})),u=new Map;for(let e of t)if("done"===e.enrichment.status)for(let[t,n]of Object.entries(e.enrichment.goal_categories??{}))u.set(t,(u.get(t)??0)+(n??0));let d=[...u.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({category:e,minutes:t})),c={start:`${e}T00:00:00`,end:`${e}T23:59:59`},p=new Map;for(let e of t){let t=e.agent??"claude-code",n=p.get(t)??{sessions:0,active_min:0,tools_total:0};n.sessions+=1,n.active_min+=e.numbers.active_min,n.tools_total+=e.numbers.tools_total,p.set(t,n)}let h=0===p.size?void 0:Array.from(p.entries()).map(([e,t])=>({agent:e,sessions:t.sessions,active_min:Math.round(10*t.active_min)/10,tools_total:t.tools_total})).sort((e,t)=>t.active_min-e.active_min);return{version:tf.CURRENT_DAY_DIGEST_SCHEMA_VERSION,scope:"day",key:e,window:c,entry_refs:t.map(e=>`${e.session_id}__${e.local_day}`),generated_at:new Date().toISOString(),is_live:!1,model:null,cost_usd:null,projects:a,shipped:i,top_flags:l,top_goal_categories:d,concurrency_peak:n.concurrencyPeak??0,agent_min:s,agent_breakdown:h,outcome_day:function(e){if(0===e.length)return"idle";let t=new Set(e.map(e=>e.enrichment.outcome).filter(Boolean));return t.has("shipped")?"shipped":t.has("partial")?"partial":t.has("blocked")?"blocked":t.has("exploratory")?"exploratory":"trivial"}(t),helpfulness_day:function(e){let t=new Map;for(let n of e){let e=n.enrichment.claude_helpfulness;e&&t.set(e,(t.get(e)??0)+1)}if(0===t.size)return null;let n=null,s=0;for(let e of["unhelpful","neutral","helpful","essential"]){let r=t.get(e)??0;r>s&&(n=e,s=r)}return n}(t),day_signals:t.length>0?ng(t):void 0,headline:null,narrative:null,what_went_well:null,what_hit_friction:null,suggestion:null,day_signature:null}}let nv=e=>tG({...e,systemPrompt:np});async function nw(e,t,n={}){let s,r,a,i,o,l,u,d=ny(e,t,{concurrencyPeak:n.concurrencyPeak});if(0===t.filter(e=>"done"===e.enrichment.status).length)return{digest:d,usage:null};let c=n.model??"sonnet",p=n.callLLM??nv,h=(r=(s=t.filter(e=>"done"===e.enrichment.status)).slice(0,12).map(e=>`- (${nm(e.project)}, ${Math.round(e.numbers.active_min)}m) ${nh(e.enrichment.brief_summary??"",240)}`).join("\n"),a=s.map(e=>e.enrichment.friction_detail).filter(e=>!!e).slice(0,6).map((e,t)=>`${t+1}. ${nh(e,240)}`).join("\n"),i=s.flatMap(e=>e.enrichment.user_instructions).slice(0,10).map((e,t)=>`${t+1}. ${nh(e,240)}`).join("\n"),o=t.map(e=>({agent:e.agent??"claude-code",project:nm(e.project),active_min:Math.round(10*e.numbers.active_min)/10,outcome:e.enrichment.outcome??"pending",pr_titles:e.pr_titles,flags:e.flags,primary_model:e.primary_model,brief_summary:"done"===e.enrichment.status?e.enrichment.brief_summary:null,friction_detail:"done"===e.enrichment.status?e.enrichment.friction_detail:null})),l={date:d.key,agent_min:d.agent_min,agent_breakdown:d.agent_breakdown??[],project_count:d.projects.length,projects:d.projects.map(e=>({name:e.display_name,share_pct:e.share_pct,entry_count:e.entry_count})),shipped:d.shipped.map(e=>({title:e.title,project:e.project})),concurrency_peak:d.concurrency_peak,top_flags:d.top_flags,top_goal_categories:d.top_goal_categories,per_entry:o},u=d.day_signals?`
138
138
 
139
139
  DAY SIGNALS:
140
140
  ${JSON.stringify(d.day_signals,null,2)}`:"",`DAY FACTS:
141
141
  ${JSON.stringify(l,null,2)}${u}
142
142
 
143
143
  ENTRY SUMMARIES (up to 12, most significant first):
144
- ${a||"(none — no enriched entries)"}
144
+ ${r||"(none — no enriched entries)"}
145
145
 
146
146
  FRICTION LINES (up to 6):
147
- ${r||"(none — smooth day)"}
147
+ ${a||"(none — smooth day)"}
148
148
 
149
149
  USER INSTRUCTIONS (up to 10 load-bearing asks):
150
- ${i||"(none)"}`),m=0,_=0,f=c;try{let t,s,a=await p({model:c,userPrompt:h,onProgress:n.onProgress});m+=a.input_tokens,_+=a.output_tokens,f=a.model;let r=(t=a.content,tq(t,nl));if(r.ok)return{digest:{...d,model:f,cost_usd:tK(f,m,_),headline:r.value.headline,narrative:r.value.narrative,what_went_well:r.value.what_went_well,what_hit_friction:r.value.what_hit_friction,suggestion:r.value.suggestion,day_signature:r.value.day_signature??null},usage:{input_tokens:m,output_tokens:_}};let i=await p({model:c,userPrompt:h,reminder:"Your previous response was not valid JSON or did not match the required schema. Return ONLY the JSON object with the six required fields — no prose, no code fence.",onProgress:n.onProgress});m+=i.input_tokens,_+=i.output_tokens,f=i.model;let o=(s=i.content,tq(s,nl));if(o.ok)return{digest:{...d,model:f,cost_usd:tK(f,m,_),headline:o.value.headline,narrative:o.value.narrative,what_went_well:o.value.what_went_well,what_hit_friction:o.value.what_hit_friction,suggestion:o.value.suggestion,day_signature:o.value.day_signature??null},usage:{input_tokens:m,output_tokens:_}};return console.warn(`[digest-day] ${e}: LLM response failed validation after retry (${o.error})`),{digest:d,usage:{input_tokens:m,output_tokens:_}}}catch(t){return console.warn(`[digest-day] ${e}: LLM invocation failed (${t.message})`),{digest:d,usage:m>0?{input_tokens:m,output_tokens:_}:null}}}var ny=e.i(76956),nv=e.i(20629),nw=e.i(79357),nk=e.i(30212);async function nb(e){try{let t=await (0,nv.listSessions)({limit:1e4}),n=(0,nw.computeBurstsFromSessions)(t),[s,a,r]=e.split("-").map(Number),i=new Date(s,a-1,r,0,0,0,0),o=new Date(s,a-1,r,23,59,59,999);return(0,nk.aggregateConcurrency)(n,{start:i,end:o}).peak}catch{return 0}}async function*nx(e,t){let n=t.now??(()=>Date.now()),s=e===t.todayLocalDay,a=t.settings.enabled;if(!s&&!t.force){let t=(0,ny.readDayDigest)(e);if(t)return void(yield{type:"digest",digest:t})}if(s&&!t.force){let t=(0,ny.getTodayDigestFromCache)(e,n());if(t)return void(yield{type:"digest",digest:t})}let r=(0,t5.listEntriesForDay)(e);if(0===r.length)return void(yield{type:"error",message:`no entries for date ${e}`});a&&ne();try{let i;if(a){if(t.force){for(let e of r)if("error"===e.enrichment.status&&(e.enrichment.retry_count??0)>=3){let t={...e,enrichment:{...e.enrichment,status:"pending",retry_count:0,error:null}};(0,t5.writeEntry)(t)}}let s=(t.force?(0,t5.listEntriesForDay)(e):r).filter(e=>{if("pending"!==e.enrichment.status&&"error"!==e.enrichment.status||(e.enrichment.retry_count??0)>=3||e.local_day===t.todayLocalDay&&!t.force)return!1;let s=Date.parse(e.end_iso);return!(!Number.isNaN(s)&&n()-s<18e5)});if(s.length>0){yield{type:"status",phase:"enrich",text:`Enriching ${s.length} entries for ${e}`};let n=t.settings.monthlyBudgetUsd??1/0,a=0;for(let e=0;e<s.length;e+=3){if(t9()>=n){yield{type:"status",phase:"enrich",text:"budget cap reached — stopping enrichment"};break}let r=s.slice(e,e+3);for(let e of(await Promise.all(r.map(e=>tQ(e,{model:t.settings.model,callLLM:t.callLLM}).then(t=>({ok:!0,entry:e,result:t.entry,usage:t.usage})).catch(t=>(console.warn(`[enrich] ${e.session_id} failed: ${t.message}`),{ok:!1,entry:e,error:t.message})))))){if(a++,!e.ok){yield{type:"entry",session_id:e.entry.session_id,index:a,total:s.length,status:"error",cost_usd:0};continue}let{result:n,usage:r}=e;(0,t5.writeEntry)(n),r&&t4({ts:new Date().toISOString(),caller:t.caller??"web",model:n.enrichment.model??t.settings.model,input_tokens:r.input_tokens,output_tokens:r.output_tokens,cost_usd:n.enrichment.cost_usd??0,kind:"entry_enrich",ref:`${n.session_id}__${n.local_day}`}),yield{type:"entry",session_id:n.session_id,index:a,total:s.length,status:n.enrichment.status,cost_usd:n.enrichment.cost_usd}}if(t9()>=n){yield{type:"status",phase:"enrich",text:"budget cap reached — stopping enrichment"};break}}}}let o=(0,t5.listEntriesForDay)(e),l=await nb(e);if(a){yield{type:"status",phase:"synth",text:"Synthesizing day narrative"};let n=[],s=ng(e,o,{model:t.settings.model,callLLM:t.callLLM,concurrencyPeak:l,onProgress:e=>{n.push({bytes:e.bytes,elapsed_ms:e.elapsedMs})}}),a=[],r=!1;for(s.finally(()=>{r=!0});!r;){for(await new Promise(e=>setTimeout(e,500));n.length>0;)a.push(n.shift());if(a.length>0){let e=a[a.length-1];yield{type:"progress",phase:"synth",bytes:e.bytes,elapsed_ms:e.elapsed_ms},a.length=0}}let u=await s;i=u.digest,u.usage&&t4({ts:new Date().toISOString(),caller:t.caller??"web",model:i.model??t.settings.model,input_tokens:u.usage.input_tokens,output_tokens:u.usage.output_tokens,cost_usd:i.cost_usd??0,kind:"day_digest",ref:e})}else i=n_(e,o,{concurrencyPeak:l});s?(0,ny.setTodayDigestInCache)(e,i,n()):((0,ny.writeDayDigest)(i),yield{type:"saved",path:`~/.cclens/digests/day/${e}.json`}),yield{type:"digest",digest:i}}finally{a&&nt()}}e.s(["runDayDigestPipeline",0,nx],20441);var t_=t_;let nS=nr.agentMetadata.map(e=>` - agent="${e.kind}" → render as "${e.displayName}"`).join("\n"),n$=/^\d{4}-\d{2}-\d{2}$/,nT=t_.object({display_name:t_.string().min(1),description:t_.string().min(1).max(600)}),nN=t_.object({title:t_.string().min(1).max(120),detail:t_.string().min(1).max(700),anchor:t_.string().min(1).max(80),evidence:t_.object({date:t_.string().regex(n$),quote:t_.string().min(1).max(400)})}),nj=nN.extend({surprise_kind:t_.enum(["outlier","novel-use","user-built-tool","cross-week-contrast"])}),nO=nN.extend({lean_kind:t_.enum(["claude-md","skill","hook","harness","decision"]),copyable:t_.string().max(2e3).nullable()}),nM=t_.object({headline:t_.string().min(1).max(180),key_pattern:t_.string().min(1).max(280),trajectory:t_.array(t_.object({date:t_.string().regex(n$),line:t_.string().min(1).max(280)})).min(1),standout_days:t_.array(t_.object({date:t_.string().regex(n$),why:t_.string().min(1).max(500)})).min(1).max(2),project_areas:t_.array(nT).min(1),what_worked:t_.array(nN).min(1).max(6),what_stalled:t_.array(nN).max(5),what_surprised:t_.array(nj).max(4),where_to_lean:t_.array(nO).min(1).max(7)}).passthrough(),nE=`You are the weekly retrospective writer for Fleetlens, a dashboard for multi-agent coding fleets (Claude Code, OpenAI Codex CLI, and possibly more).
150
+ ${i||"(none)"}`),m=0,_=0,f=c;try{let t,s,r=await p({model:c,userPrompt:h,onProgress:n.onProgress});m+=r.input_tokens,_+=r.output_tokens,f=r.model;let a=(t=r.content,tX(t,nc));if(a.ok)return{digest:{...d,model:f,cost_usd:tQ(f,m,_),headline:a.value.headline,narrative:a.value.narrative,what_went_well:a.value.what_went_well,what_hit_friction:a.value.what_hit_friction,suggestion:a.value.suggestion,day_signature:a.value.day_signature??null},usage:{input_tokens:m,output_tokens:_}};let i=await p({model:c,userPrompt:h,reminder:"Your previous response was not valid JSON or did not match the required schema. Return ONLY the JSON object with the six required fields — no prose, no code fence.",onProgress:n.onProgress});m+=i.input_tokens,_+=i.output_tokens,f=i.model;let o=(s=i.content,tX(s,nc));if(o.ok)return{digest:{...d,model:f,cost_usd:tQ(f,m,_),headline:o.value.headline,narrative:o.value.narrative,what_went_well:o.value.what_went_well,what_hit_friction:o.value.what_hit_friction,suggestion:o.value.suggestion,day_signature:o.value.day_signature??null},usage:{input_tokens:m,output_tokens:_}};return console.warn(`[digest-day] ${e}: LLM response failed validation after retry (${o.error})`),{digest:d,usage:{input_tokens:m,output_tokens:_}}}catch(t){return console.warn(`[digest-day] ${e}: LLM invocation failed (${t.message})`),{digest:d,usage:m>0?{input_tokens:m,output_tokens:_}:null}}}var nk=e.i(76956),nb=e.i(20629),nx=e.i(79357),nS=e.i(30212);async function n$(e){try{let t=await (0,nb.listSessions)({limit:1e4}),n=(0,nx.computeBurstsFromSessions)(t),[s,r,a]=e.split("-").map(Number),i=new Date(s,r-1,a,0,0,0,0),o=new Date(s,r-1,a,23,59,59,999);return(0,nS.aggregateConcurrency)(n,{start:i,end:o}).peak}catch{return 0}}async function*nT(e,t){let n=t.now??(()=>Date.now()),s=e===t.todayLocalDay,r=t.settings.enabled;if(!s&&!t.force){let t=(0,nk.readDayDigest)(e);if(t)return void(yield{type:"digest",digest:t})}if(s&&!t.force){let t=(0,nk.getTodayDigestFromCache)(e,n());if(t)return void(yield{type:"digest",digest:t})}let a=(0,t7.listEntriesForDay)(e);if(0===a.length)return void(yield{type:"error",message:`no entries for date ${e}`});r&&ns();try{let i;if(r){if(t.force){for(let e of a)if("error"===e.enrichment.status&&(e.enrichment.retry_count??0)>=3){let t={...e,enrichment:{...e.enrichment,status:"pending",retry_count:0,error:null}};(0,t7.writeEntry)(t)}}let s=(t.force?(0,t7.listEntriesForDay)(e):a).filter(e=>{if("pending"!==e.enrichment.status&&"error"!==e.enrichment.status||(e.enrichment.retry_count??0)>=3||e.local_day===t.todayLocalDay&&!t.force)return!1;let s=Date.parse(e.end_iso);return!(!Number.isNaN(s)&&n()-s<18e5)});if(s.length>0){yield{type:"status",phase:"enrich",text:`Enriching ${s.length} entries for ${e}`};let n=t.settings.monthlyBudgetUsd??1/0,r=0;for(let e=0;e<s.length;e+=3){if(t8()>=n){yield{type:"status",phase:"enrich",text:"budget cap reached — stopping enrichment"};break}let a=s.slice(e,e+3);for(let e of(await Promise.all(a.map(e=>t2(e,{model:t.settings.model,callLLM:t.callLLM}).then(t=>({ok:!0,entry:e,result:t.entry,usage:t.usage})).catch(t=>(console.warn(`[enrich] ${e.session_id} failed: ${t.message}`),{ok:!1,entry:e,error:t.message})))))){if(r++,!e.ok){yield{type:"entry",session_id:e.entry.session_id,index:r,total:s.length,status:"error",cost_usd:0};continue}let{result:n,usage:a}=e;(0,t7.writeEntry)(n),a&&t3({ts:new Date().toISOString(),caller:t.caller??"web",model:n.enrichment.model??t.settings.model,input_tokens:a.input_tokens,output_tokens:a.output_tokens,cost_usd:n.enrichment.cost_usd??0,kind:"entry_enrich",ref:`${n.session_id}__${n.local_day}`}),yield{type:"entry",session_id:n.session_id,index:r,total:s.length,status:n.enrichment.status,cost_usd:n.enrichment.cost_usd}}if(t8()>=n){yield{type:"status",phase:"enrich",text:"budget cap reached — stopping enrichment"};break}}}}let o=(0,t7.listEntriesForDay)(e),l=await n$(e);if(r){yield{type:"status",phase:"synth",text:"Synthesizing day narrative"};let n=[],s=nw(e,o,{model:t.settings.model,callLLM:t.callLLM,concurrencyPeak:l,onProgress:e=>{n.push({bytes:e.bytes,elapsed_ms:e.elapsedMs})}}),r=[],a=!1;for(s.finally(()=>{a=!0});!a;){for(await new Promise(e=>setTimeout(e,500));n.length>0;)r.push(n.shift());if(r.length>0){let e=r[r.length-1];yield{type:"progress",phase:"synth",bytes:e.bytes,elapsed_ms:e.elapsed_ms},r.length=0}}let u=await s;i=u.digest,u.usage&&t3({ts:new Date().toISOString(),caller:t.caller??"web",model:i.model??t.settings.model,input_tokens:u.usage.input_tokens,output_tokens:u.usage.output_tokens,cost_usd:i.cost_usd??0,kind:"day_digest",ref:e})}else i=ny(e,o,{concurrencyPeak:l});s?(0,nk.setTodayDigestInCache)(e,i,n()):((0,nk.writeDayDigest)(i),yield{type:"saved",path:`~/.cclens/digests/day/${e}.json`}),yield{type:"digest",digest:i}}finally{r&&nr()}}e.s(["runDayDigestPipeline",0,nT],20441);var t_=t_;let nN=nl.agentMetadata.map(e=>` - agent="${e.kind}" → render as "${e.displayName}"`).join("\n"),nj=/^\d{4}-\d{2}-\d{2}$/,nO=t_.object({display_name:t_.string().min(1),description:t_.string().min(1).max(600)}),nM=t_.object({title:t_.string().min(1).max(120),detail:t_.string().min(1).max(700),anchor:t_.string().min(1).max(80),evidence:t_.object({date:t_.string().regex(nj),quote:t_.string().min(1).max(400)})}),nE=nM.extend({surprise_kind:t_.enum(["outlier","novel-use","user-built-tool","cross-week-contrast"])}),nA=nM.extend({lean_kind:t_.enum(["claude-md","skill","hook","harness","decision"]),copyable:t_.string().max(2e3).nullable()}),nP=t_.object({headline:t_.string().min(1).max(180),key_pattern:t_.string().min(1).max(280),trajectory:t_.array(t_.object({date:t_.string().regex(nj),line:t_.string().min(1).max(280)})).min(1),standout_days:t_.array(t_.object({date:t_.string().regex(nj),why:t_.string().min(1).max(500)})).min(1).max(2),project_areas:t_.array(nO).min(1),what_worked:t_.array(nM).min(1).max(6),what_stalled:t_.array(nM).max(5),what_surprised:t_.array(nE).max(4),where_to_lean:t_.array(nA).min(1).max(7)}).passthrough(),nZ=`You are the weekly retrospective writer for Fleetlens, a dashboard for multi-agent coding fleets (Claude Code, OpenAI Codex CLI, and possibly more).
151
151
 
152
152
  Your unique advantage: you receive both **already-synthesized day digests** AND a **per-week classification of how the user drove agents** — named orchestration shapes, the user's interaction grammar, counts, and a per-source-agent breakdown. Your job is to take that texture and tell a coherent story about WHO this user is as a multi-agent operator THIS WEEK and what they should do next.
153
153
 
154
154
  When the week's input includes more than one source agent (see "Per-agent week breakdown" in the input AND per-day "Agent breakdown" lines), the narrative MUST name them. Render each agent kind with its canonical display name:
155
- ${nS}
155
+ ${nN}
156
156
  The headline, key_pattern, project_areas and at least one of what_worked / what_stalled / what_surprised should make the multi-agent split visible — readers want to see how a secondary agent was blended into the dominant agent's week (or vice versa).
157
157
 
158
158
  The reader sees, before reading your prose:
@@ -294,7 +294,7 @@ VOCABULARY RULES:
294
294
  - Working-shape names (spec-review-loop, chunk-implementation, etc.) ARE allowed and ENCOURAGED in prose — they're the named patterns the reader sees in the report's first section.
295
295
  - Prefer naming the actual subagent type ("\`general-purpose\` dispatches", "\`superpowers:code-reviewer\`") over abstract "subagents" when the type is load-bearing.
296
296
  - "Plan Mode" specifically refers to the canonical /plan tool. "spec-review subagents" is the user's actual planning approach when that's what the data shows.
297
- `,nA=["shipped","partial","blocked","exploratory","trivial","idle"];function nP(e){let t=e.split("/").filter(Boolean);return t[t.length-1]??e}function nZ(e){let t=new Date(`${e}T00:00:00`),n=[];for(let e=0;e<7;e++){let s=new Date(t);s.setDate(t.getDate()+e),n.push(function(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${s}`}(s))}return n}function nD(e,t){return e.length<=t?e:e.slice(0,t-1).trimEnd()+"…"}function nI(e,t){return e.day_signals??nm(t)}let nC=["spec-review-loop","chunk-implementation","reviewer-triad","research-then-build","background-coordinated","solo-continuation","solo-design","solo-build"];function nL(e,t,n={}){let s=nZ(e),a=new Map;for(let e of t)a.set(e.key,e);let r=t.reduce((e,t)=>e+t.agent_min,0),i=new Map;for(let e of t)for(let t of e.projects){let n=i.get(t.name)??{agent_min:0,shipped_count:0};n.agent_min+=t.share_pct/100*e.agent_min,i.set(t.name,n)}for(let e of t)for(let t of e.shipped){let n=e.projects.find(e=>e.display_name===t.project),s=n?n.name:t.project,a=i.get(s)??{agent_min:0,shipped_count:0};a.shipped_count+=1,i.set(s,a)}let o=[...i.entries()].sort((e,t)=>t[1].agent_min-e[1].agent_min).map(([e,t])=>({name:e,display_name:nP(e),agent_min:t.agent_min,share_pct:r>0?t.agent_min/r*100:0,shipped_count:t.shipped_count,description:null})),l=[];for(let e of t)for(let t of e.shipped)l.push({title:t.title,project:t.project,date:e.key,session_id:t.session_id});let d={};for(let e of t)d[e.outcome_day]=(d[e.outcome_day]??0)+1;let c=s.map(e=>{let t=a.get(e);return t?t.helpfulness_day:null}),p=new Map;for(let e of t)for(let t of e.top_flags)p.set(t.flag,(p.get(t.flag)??0)+t.count);let h=[...p.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({flag:e,count:t})),m=new Map;for(let e of t)for(let t of e.top_goal_categories)m.set(t.category,(m.get(t.category)??0)+t.minutes);let _=[...m.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({category:e,minutes:t})),f=null;for(let e of t)e.concurrency_peak>0&&(!f||e.concurrency_peak>f.peak)&&(f={date:e.key,peak:e.concurrency_peak});let g=n.entriesByDay??new Map,y=t.filter(e=>e.agent_min>0).sort((e,t)=>e.key.localeCompare(t.key)).map(e=>{let t=g.get(e.key)??[],n=e.day_signals??(t.length>0?nm(t):null);return{date:e.key,agent_min:e.agent_min,shipped_count:e.shipped.length,outcome_day:e.outcome_day,helpfulness_day:e.helpfulness_day,dominant_shape:n?.dominant_shape??null}}),v=null;for(let e of y)(!v||e.agent_min>v.agent_min)&&(v={date:e.date,agent_min:e.agent_min,shipped_count:e.shipped_count});let w=[];for(let e of g.values())w.push(...e);let k=null,b=Array(24).fill(0);for(let e of w){(!k||e.numbers.active_min>k.active_min)&&(k={session_id:e.session_id,date:e.local_day,project_display:nP(e.project),active_min:e.numbers.active_min});let t=Date.parse(e.start_iso);if(!Number.isNaN(t)){let n=new Date(t).getHours();b[n]=(b[n]??0)+e.numbers.active_min}}let x=t.length>0?function(e,t=new Map){let n=new Map,s=new Map;for(let t of e)n.set(t.key,t.outcome_day),s.set(t.key,t.helpfulness_day);let a=new Map;for(let n of e){let e=t.get(n.key)??[];for(let t of Object.keys(nI(n,e).shape_distribution)){let s=a.get(t)??[];s.push({dd:n,entries:e}),a.set(t,s)}}let r=[];for(let e of nC){let t=a.get(e);if(!t||0===t.length)continue;let i=t.sort((e,t)=>e.dd.key.localeCompare(t.dd.key)).map(({dd:t,entries:a})=>{let r=a.filter(t=>(t.signals?.working_shape??(0,u.inferWorkingShape)(t))===e),i=r.sort((e,t)=>{let n=(e.subagents??[]).reduce((e,t)=>Math.max(e,t.prompt_preview.length),0);return(t.subagents??[]).reduce((e,t)=>Math.max(e,t.prompt_preview.length),0)-n})[0]??r[0]??null,o=null;if(i?.subagents&&i.subagents.length>0){let e=[...i.subagents].sort((e,t)=>t.prompt_preview.length-e.prompt_preview.length)[0];o={type:e.type,description:e.description,prompt_preview:nD(e.prompt_preview,200)}}let l=i?nP(i.project):t.projects[0]?.display_name??"";return{date:t.key,session_id:i?.session_id??"",project_display:l,outcome:n.get(t.key)??null,helpfulness:s.get(t.key)??null,evidence_subagent:o,evidence_first_user:i?.first_user?nD(i.first_user,200):null,day_signature:t.day_signature??null}}),o={};for(let e of i)e.outcome&&(o[e.outcome]=(o[e.outcome]??0)+1);r.push({shape:e,occurrences:i,outcome_distribution:o})}return r}(t,g):null,S=t.length>0?function(e,t=new Map){let n=new Set,s=new Map,a=new Map,r=new Map,i={short:0,medium:0,long:0,very_long:0},o=[],l=0,d=0,c=0,p=0,h=0,m=new Set;for(let u of e){let e=u.key,_=nI(u,t.get(e)??[]);for(let t of(_.brainstorm_warmup_session_count>0&&n.add(e),h+=_.todo_ops_total,_.plan_mode_used&&m.add(e),_.prompt_frames)){let n=s.get(t.frame)??{count:0,days:new Set};n.count+=t.count,n.days.add(e),s.set(t.frame,n)}for(let t of _.skills_loaded){if("user"!==t.origin)continue;let n=a.get(t.skill)??{count:0,days:new Set};n.count+=t.count,n.days.add(e),a.set(t.skill,n)}for(let t of _.user_authored_subagents_used){let n=r.get(t.type)??{count:0,days:new Set,sample_description:t.sample_description,sample_prompt_preview:t.sample_prompt_preview};n.count+=t.count,n.days.add(e),t.sample_prompt_preview.length>n.sample_prompt_preview.length&&(n.sample_description=t.sample_description,n.sample_prompt_preview=t.sample_prompt_preview),r.set(t.type,n)}let f=_.comm_style.verbosity_distribution;for(let t of(i.short+=f.short,i.medium+=f.medium,i.long+=f.long,i.very_long+=f.very_long,_.comm_style.external_refs))o.push({date:e,session_id:t.session_id,ref_kind:t.kind,preview:nD(t.preview,200)});l+=_.comm_style.steering.interrupts,d+=_.comm_style.steering.frustrated,c+=_.comm_style.steering.dissatisfied,p+=_.comm_style.steering.sessions_with_mid_run_redirect}let _=new Map,f=0,g=0;for(let[,e]of t)for(let t of e){f+=t.numbers.turn_count??0,g+=t.numbers.exit_plan_calls??0;let e=_.get(t.session_id)??[];e.push(t),_.set(t.session_id,e)}let y=[];for(let[e,t]of _.entries()){if(new Set(t.map(e=>e.local_day)).size<2)continue;t.sort((e,t)=>e.local_day.localeCompare(t.local_day));let n=t.reduce((e,t)=>e+t.numbers.active_min,0),s=t[t.length-1];y.push({thread_id:e,entries:t.map(e=>({date:e.local_day,session_id:e.session_id,project_display:nP(e.project),has_handoff_frame:(0,u.detectPromptFrames)(e.first_user).includes("handoff-prose")})),total_active_min:n,outcome:s.enrichment?.outcome??null})}y.sort((e,t)=>t.total_active_min-e.total_active_min);let v=new Map;for(let[e,t]of a.entries()){let n=e.includes("-")?e.split("-")[0]:e,s=v.get(n)??{members:new Set,total_count:0,days:new Set};for(let n of(s.members.add(e),s.total_count+=t.count,t.days))s.days.add(n);v.set(n,s)}let w=[...v.entries()].filter(([,e])=>e.members.size>=2||e.total_count>=3).sort((e,t)=>t[1].total_count-e[1].total_count).map(([e,t])=>({family:e,members:[...t.members].sort(),total_count:t.total_count,days:[...t.days].sort()}));return{brainstorming_warmup_days:[...n].sort(),prompt_frames:[...s.entries()].sort((e,t)=>t[1].count-e[1].count).map(([e,t])=>({frame:e,origin:tf.PROMPT_FRAME_ORIGIN[e],count:t.count,days:[...t.days].sort()})),user_authored_skills:[...a.entries()].sort((e,t)=>t[1].count-e[1].count).map(([e,t])=>({skill:e,count:t.count,days:[...t.days].sort()})),skill_families:w,user_authored_subagents:[...r.entries()].sort((e,t)=>t[1].count-e[1].count).map(([e,t])=>({type:e,count:t.count,days:[...t.days].sort(),sample_description:t.sample_description,sample_prompt_preview:nD(t.sample_prompt_preview,200)})),threads:y,communication_style:{verbosity_distribution:i,external_context_refs:o,steering:{total_interrupts:l,total_frustrated:d,total_dissatisfied:c,sessions_with_mid_run_redirect:p,total_turns:f}},todo_ops_total:h,plan_mode:{exit_plan_calls:g,days_with_plan:m.size}}}(t,g):null,$=w.length>0?function(e){let t=new Map,n=new Map,s=new Map,a=new Set,r=0,i=0,o=0,l=0,u=0,d=0,c=0,p=new Map,h=new Map;for(let m of e){let e=m.local_day;for(let h of(r+=m.numbers.subagent_calls,o+=m.numbers.skill_calls,i+=m.numbers.task_ops,l+=m.numbers.exit_plan_calls,u+=m.numbers.interrupts,d+=m.numbers.tools_total,c+=m.numbers.turn_count,m.numbers.subagent_calls>0&&t.set(e,(t.get(e)??0)+m.numbers.subagent_calls),m.numbers.skill_calls>0&&n.set(e,(n.get(e)??0)+m.numbers.skill_calls),(m.numbers.exit_plan_calls>0||m.flags.includes("plan_used"))&&s.set(e,(s.get(e)??0)+m.numbers.exit_plan_calls),m.flags.includes("long_autonomous")&&a.add(e),m.subagents))p.set(h.type,(p.get(h.type)??0)+1);for(let[e,t]of Object.entries(m.skills))h.set(e,(h.get(e)??0)+t)}let m=[...p.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({type:e,count:t})),_=[...h.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({skill:e,count:t})),f=[],g=new Set,y=[];for(let t of e)for(let e of t.subagents)y.push({entry:t,sa:e});for(let{entry:e,sa:t}of(y.sort((e,t)=>t.sa.prompt_preview.length-e.sa.prompt_preview.length),y)){if(f.length>=3)break;g.has(t.type)||(g.add(t.type),f.push({date:e.local_day,project_display:nP(e.project),type:t.type,prompt_preview:nD(t.prompt_preview,200)}))}let v=[],w=new Set;for(let t of e)for(let e of Object.keys(t.skills)){if(v.length>=3)break;w.has(e)||t.first_user&&!(t.first_user.length<8)&&(w.add(e),v.push({date:t.local_day,skill:e,first_user_preview:nD(t.first_user,200)}))}let k=null;for(let t of e)t.flags.includes("long_autonomous")&&(!k||t.numbers.active_min>k.numbers.active_min)&&(k=t);let b=k?{date:k.local_day,project_display:nP(k.project),active_min:k.numbers.active_min,top_tools:k.top_tools.slice(0,5),first_user_preview:nD(k.first_user,200)}:null,x=c>0?d/c:0;return{orchestration:{subagent_calls:r,task_ops:i,days_with_subagents:t.size,top_types:m,examples:f},skill_use:{skill_calls:o,days_with_skills:n.size,top_skills:_,examples:v},plan_gating:{exit_plan_calls:l,days_with_plan:s.size},turn_shape:{tools_per_turn:Math.round(10*x)/10,interrupts:u,long_autonomous_days:a.size,label:x<5?"rapid":x<15?"mixed":"batch",longest_turn:b}}}(w):null,T=s[6],N={start:`${e}T00:00:00`,end:`${T}T23:59:59`};return{version:tf.CURRENT_WEEK_DIGEST_SCHEMA_VERSION,scope:"week",key:e,window:N,day_refs:t.map(e=>e.key).sort(),generated_at:new Date().toISOString(),is_live:!1,model:null,cost_usd:null,agent_min_total:r,projects:o,shipped:l,outcome_mix:d,helpfulness_sparkline:c,top_flags:h,top_goal_categories:_,concurrency_peak_day:f,days_active:y,busiest_day:v,longest_run:k,hours_distribution:b,interaction_modes:$,working_shapes:x,interaction_grammar:S,headline:null,key_pattern:null,trajectory:null,standout_days:null,what_worked:null,what_stalled:null,what_surprised:null,where_to_lean:null,recurring_themes:null,outcome_correlations:null,friction_categories:null,suggestions:null,on_the_horizon:null,fun_ending:null}}let nR=e=>tH({...e,systemPrompt:nE});function nU(e){return e.toLowerCase().replace(/\s+/g," ").trim()}function nF(e,t,n,s){let a=nU(s),r=new Map;for(let e of t){let t=[e.headline,e.what_went_well,e.what_hit_friction].filter(e=>!!e);r.set(e.key,nU(t.join(" \n ")))}for(let e of n){let t=e.local_day,n=r.get(t)??"",s=[e.first_user,e.final_agent,...(e.subagents??[]).flatMap(e=>[e.description,e.prompt_preview])].filter(e=>!!e).join(" \n ");r.set(t,nU(n+" \n "+s))}let i=e=>{let t=nU(e.evidence.quote);if(a.includes(t))return!0;let n=r.get(e.evidence.date);return!!n&&n.includes(t)};return{...e,what_worked:(e.what_worked??[]).filter(i),what_stalled:(e.what_stalled??[]).filter(i),what_surprised:(e.what_surprised??[]).filter(i)}}async function nY(e,t,n={}){let s=nL(e,t,{entriesByDay:n.entriesByDay}),a=t.filter(e=>null!==e.headline),r=n.allowSingleDay?1:2;if(a.length<r)return{digest:s,usage:null};let i=n.model??"sonnet",o=n.callLLM??nR,l=function(e,t){let n=[],s=(e="")=>n.push(e),a=new Map;for(let e of t)for(let t of e.shipped){let n=a.get(t.project)??[];n.push({title:t.title,date:e.key}),a.set(t.project,n)}s(`# Week ${e.key} (${e.window.start} → ${e.window.end})`),s(),s(`Total agent time: ${Math.round(e.agent_min_total)} min across ${t.length} day(s) with data.`);let r=new Map;for(let e of t)for(let t of e.agent_breakdown??[]){let e=r.get(t.agent)??{sessions:0,active_min:0,tools_total:0};e.sessions+=t.sessions,e.active_min+=t.active_min,e.tools_total+=t.tools_total,r.set(t.agent,e)}if(r.size>0){let e=Array.from(r.entries()).sort((e,t)=>t[1].active_min-e[1].active_min).map(([e,t])=>`${e}=${t.sessions} session${1===t.sessions?"":"s"}/${Math.round(t.active_min)}m active/${t.tools_total} tool calls`).join(", ");s(`Per-agent week breakdown: ${e}.`)}let i={shipped:0,partial:0,blocked:0,exploratory:0,trivial:0,idle:0};for(let t of nA)i[t]=e.outcome_mix[t]??0;let o=nA.filter(e=>i[e]>0).map(e=>`${e}=${i[e]}`).join(", ");for(let t of(s(`Outcome mix: ${o||"(empty)"}.`),s(`Helpfulness sparkline (Mon→Sun): ${e.helpfulness_sparkline.map(e=>e??"·").join(" ")}`),e.concurrency_peak_day&&s(`Concurrency peak day: ${e.concurrency_peak_day}.`),s(),s("## Projects (top by agent_min)"),e.projects.slice(0,8))){let e=t.display_name??function(e){let t=e.split("/").filter(Boolean);return t[t.length-1]??e}(t.name),n=(a.get(e)??[]).slice(0,8),r=n.length>0?n.map(e=>` - "${e.title}" (${e.date})`).join("\n"):" - (no PRs shipped)";s(`- ${e} — ${Math.round(t.agent_min)}m, ${Math.round(10*t.share_pct)/10}% share, ${t.shipped_count} PR${1===t.shipped_count?"":"s"}`),s(r)}s(),e.top_flags.length>0&&s(`Top flags: ${e.top_flags.map(e=>`${e.flag}(${e.count})`).join(", ")}`),e.top_goal_categories.length>0&&s(`Goal-category minutes: ${e.top_goal_categories.map(e=>`${e.category}=${e.minutes}m`).join(", ")}`),s(),s("## Working shapes (deterministic, already classified)");let l=e.working_shapes??[];if(0===l.length)s("(none — no day reached the threshold for shape classification)");else for(let e of l){let t=[...new Set(e.occurrences.map(e=>e.date))].sort(),n=Object.entries(e.outcome_distribution??{}).filter(([,e])=>e>0).map(([e,t])=>`${e}:${t}`).join(", ");s(`- ${e.shape} — ${e.occurrences.length} occurrence(s) on [${t.join(", ")}]${n?`; outcomes ${n}`:""}`)}s(),s("## Interaction grammar");let u=e.interaction_grammar;if(u){if(u.brainstorming_warmup_days?.length&&s(`- Brainstorm-warmup days (${u.brainstorming_warmup_days.length}): ${u.brainstorming_warmup_days.join(", ")}`),u.prompt_frames?.length){let e=u.prompt_frames.map(e=>`${e.frame}(${e.origin})\xd7${e.count}`).join(", ");s(`- Prompt frames: ${e}`)}if(u.user_authored_skills?.length){let e=u.user_authored_skills.map(e=>`${e.skill}\xd7${e.count}`).join(", ");s(`- User-authored skills: ${e}`)}if(u.skill_families?.length){let e=u.skill_families.map(e=>`${e.family}(${e.members.length} members, ${e.total_count} uses)`).join(", ");s(`- Skill families: ${e}`)}if(u.user_authored_subagents?.length){let e=u.user_authored_subagents.map(e=>`${e.type}\xd7${e.count}`).join(", ");s(`- User-authored subagent types: ${e}`)}u.threads?.length&&s(`- Multi-day threads: ${u.threads.length} (total ${u.threads.reduce((e,t)=>e+t.total_active_min,0)}m active)`);let e=u.communication_style;if(e){let t=e.verbosity_distribution;s(`- Verbosity: short=${t.short}, medium=${t.medium}, long=${t.long}, very_long=${t.very_long}`);let n=e.external_context_refs;n.length&&s(`- External-ref openings (${n.length}): ${n.slice(0,5).map(e=>`${e.ref_kind}@${e.date}`).join(", ")}`);let a=e.steering;s(`- Steering: ${a.total_interrupts} interrupts, ${a.total_frustrated} frustrated, ${a.total_dissatisfied} dissatisfied, ${a.sessions_with_mid_run_redirect} mid-run redirects, across ${a.total_turns} turns`)}s(`- TodoWrite ops total: ${u.todo_ops_total}`),u.plan_mode&&s(`- Plan Mode: ${u.plan_mode.exit_plan_calls} exit_plan calls, ${u.plan_mode.days_with_plan} day(s) with plan use`)}else s("(none)");let d=t.slice().sort((e,t)=>e.key.localeCompare(t.key));for(let e of(s(),s("## Day summaries"),d)){var c;s();let t=e.top_flags.slice(0,5).map(e=>`${e.flag}(${e.count})`).join(", "),n=e.day_signals?.dominant_shape??null,a=n?` \xb7 shape: ${n}`:"";if(s(`### ${(c=e.key,new Date(`${c}T12:00:00`).toLocaleDateString("en-US",{weekday:"short"}))} ${e.key} — ${Math.round(e.agent_min)}m active \xb7 outcome: ${e.outcome_day}${a}`),e.agent_breakdown&&e.agent_breakdown.length>1){let t=e.agent_breakdown.map(e=>`${e.agent}=${e.sessions}/${Math.round(e.active_min)}m`).join(", ");s(`Agent breakdown: ${t}`)}e.headline&&s(`Headline: ${e.headline}`),e.day_signature&&s(`Signature: ${e.day_signature}`),e.what_went_well&&s(`Went well: ${e.what_went_well}`),e.what_hit_friction&&s(`Hit friction: ${e.what_hit_friction}`),e.suggestion&&s(`Suggestion: ${e.suggestion.headline} — ${e.suggestion.body}`),t&&s(`Flags: ${t}`),null!==e.helpfulness_day&&void 0!==e.helpfulness_day&&s(`Helpfulness: ${e.helpfulness_day}`);let r=e.day_signals;if(r){let e=Object.entries(r.shape_distribution??{}).filter(([,e])=>e>0).map(([e,t])=>`${e}:${t}`).join(", ");if(e&&s(`Shape distribution: ${e}`),r.skills_loaded.length){let e=r.skills_loaded.slice(0,6).map(e=>`${e.skill}(${e.origin})${e.count>1?`\xd7${e.count}`:""}`).join(", ");s(`Skills loaded: ${e}`)}if(r.user_authored_subagents_used.length){let e=r.user_authored_subagents_used.slice(0,4).map(e=>`${e.type}${e.count>1?`\xd7${e.count}`:""}`).join(", ");s(`User-authored subagents: ${e}`)}if(r.prompt_frames.length){let e=r.prompt_frames.map(e=>`${e.frame}(${e.origin})${e.count>1?`\xd7${e.count}`:""}`).join(", ");s(`Prompt frames: ${e}`)}let t=r.comm_style.verbosity_distribution;s(`Verbosity: short=${t.short}, medium=${t.medium}, long=${t.long}, very_long=${t.very_long}`);let n=r.comm_style.steering;s(`Steering: ${n.interrupts} interrupts, ${n.frustrated} frustrated, ${n.dissatisfied} dissatisfied, ${n.sessions_with_mid_run_redirect} mid-run redirects`),r.brainstorm_warmup_session_count>0&&s(`Brainstorm-warmup sessions: ${r.brainstorm_warmup_session_count}`),r.plan_mode_used&&s("Plan Mode: used"),r.todo_ops_total>0&&s(`TodoWrite ops: ${r.todo_ops_total}`)}}return n.join("\n")}(s,t),u=0,d=0,c=i,p=[];for(let e of(n.entriesByDay??new Map).values())p.push(...e);function h(e){let t=s.projects.map(t=>{let n=e.project_areas.find(e=>e.display_name===t.display_name);return n?{...t,description:n.description}:t});return{...s,projects:t,model:c,cost_usd:tK(c,u,d),headline:e.headline,key_pattern:e.key_pattern,trajectory:e.trajectory,standout_days:e.standout_days,what_worked:e.what_worked,what_stalled:e.what_stalled,what_surprised:e.what_surprised,where_to_lean:e.where_to_lean,recurring_themes:null,outcome_correlations:null,friction_categories:null,suggestions:null,on_the_horizon:null,fun_ending:null}}try{let a,r,m=await o({model:i,userPrompt:l,onProgress:n.onProgress});u+=m.input_tokens,d+=m.output_tokens,c=m.model;let _=(a=m.content,tq(a,nM));if(_.ok)return{digest:h(nF(_.value,t,p,l)),usage:{input_tokens:u,output_tokens:d}};let f=await o({model:i,userPrompt:l,reminder:"Your previous response was not valid JSON or did not match the required schema. Return ONLY the JSON object with all required fields — no prose, no code fence.",onProgress:n.onProgress});u+=f.input_tokens,d+=f.output_tokens,c=f.model;let g=(r=f.content,tq(r,nM));if(g.ok)return{digest:h(nF(g.value,t,p,l)),usage:{input_tokens:u,output_tokens:d}};return console.warn(`[digest-week] ${e}: LLM response failed validation after retry (${g.error})`),{digest:s,usage:{input_tokens:u,output_tokens:d}}}catch(t){return console.warn(`[digest-week] ${e}: LLM invocation failed (${t.message})`),{digest:s,usage:u>0?{input_tokens:u,output_tokens:d}:null}}}var t_=t_;let nW=/^\d{4}-\d{2}-\d{2}$/,nz=t_.object({headline:t_.string().min(1).max(120),body:t_.string().min(1).max(800)}),nB=t_.object({headline:t_.string().min(1).max(160),trajectory:t_.array(t_.object({week_start:t_.string().regex(nW),line:t_.string().min(1).max(280)})).min(1),standout_weeks:t_.array(t_.object({week_start:t_.string().regex(nW),why:t_.string().min(1).max(400)})).min(1).max(2),friction_themes:t_.string().max(800),suggestion:nz}).passthrough(),nJ=`You are the monthly digest writer for Fleetlens.
297
+ `,nD=["shipped","partial","blocked","exploratory","trivial","idle"];function nC(e){let t=e.split("/").filter(Boolean);return t[t.length-1]??e}function nI(e){let t=new Date(`${e}T00:00:00`),n=[];for(let e=0;e<7;e++){let s=new Date(t);s.setDate(t.getDate()+e),n.push(function(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${s}`}(s))}return n}function nL(e,t){return e.length<=t?e:e.slice(0,t-1).trimEnd()+"…"}function nR(e,t){return e.day_signals??ng(t)}let nU=["spec-review-loop","chunk-implementation","reviewer-triad","research-then-build","background-coordinated","solo-continuation","solo-design","solo-build"];function nF(e,t,n={}){let s=nI(e),r=new Map;for(let e of t)r.set(e.key,e);let a=t.reduce((e,t)=>e+t.agent_min,0),i=new Map;for(let e of t)for(let t of e.projects){let n=i.get(t.name)??{agent_min:0,shipped_count:0};n.agent_min+=t.share_pct/100*e.agent_min,i.set(t.name,n)}for(let e of t)for(let t of e.shipped){let n=e.projects.find(e=>e.display_name===t.project),s=n?n.name:t.project,r=i.get(s)??{agent_min:0,shipped_count:0};r.shipped_count+=1,i.set(s,r)}let o=[...i.entries()].sort((e,t)=>t[1].agent_min-e[1].agent_min).map(([e,t])=>({name:e,display_name:nC(e),agent_min:t.agent_min,share_pct:a>0?t.agent_min/a*100:0,shipped_count:t.shipped_count,description:null})),l=[];for(let e of t)for(let t of e.shipped)l.push({title:t.title,project:t.project,date:e.key,session_id:t.session_id});let d={};for(let e of t)d[e.outcome_day]=(d[e.outcome_day]??0)+1;let c=s.map(e=>{let t=r.get(e);return t?t.helpfulness_day:null}),p=new Map;for(let e of t)for(let t of e.top_flags)p.set(t.flag,(p.get(t.flag)??0)+t.count);let h=[...p.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({flag:e,count:t})),m=new Map;for(let e of t)for(let t of e.top_goal_categories)m.set(t.category,(m.get(t.category)??0)+t.minutes);let _=[...m.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({category:e,minutes:t})),f=null;for(let e of t)e.concurrency_peak>0&&(!f||e.concurrency_peak>f.peak)&&(f={date:e.key,peak:e.concurrency_peak});let g=n.entriesByDay??new Map,y=t.filter(e=>e.agent_min>0).sort((e,t)=>e.key.localeCompare(t.key)).map(e=>{let t=g.get(e.key)??[],n=e.day_signals??(t.length>0?ng(t):null);return{date:e.key,agent_min:e.agent_min,shipped_count:e.shipped.length,outcome_day:e.outcome_day,helpfulness_day:e.helpfulness_day,dominant_shape:n?.dominant_shape??null}}),v=null;for(let e of y)(!v||e.agent_min>v.agent_min)&&(v={date:e.date,agent_min:e.agent_min,shipped_count:e.shipped_count});let w=[];for(let e of g.values())w.push(...e);let k=null,b=Array(24).fill(0);for(let e of w){(!k||e.numbers.active_min>k.active_min)&&(k={session_id:e.session_id,date:e.local_day,project_display:nC(e.project),active_min:e.numbers.active_min});let t=Date.parse(e.start_iso);if(!Number.isNaN(t)){let n=new Date(t).getHours();b[n]=(b[n]??0)+e.numbers.active_min}}let x=t.length>0?function(e,t=new Map){let n=new Map,s=new Map;for(let t of e)n.set(t.key,t.outcome_day),s.set(t.key,t.helpfulness_day);let r=new Map;for(let n of e){let e=t.get(n.key)??[];for(let t of Object.keys(nR(n,e).shape_distribution)){let s=r.get(t)??[];s.push({dd:n,entries:e}),r.set(t,s)}}let a=[];for(let e of nU){let t=r.get(e);if(!t||0===t.length)continue;let i=t.sort((e,t)=>e.dd.key.localeCompare(t.dd.key)).map(({dd:t,entries:r})=>{let a=r.filter(t=>(t.signals?.working_shape??(0,u.inferWorkingShape)(t))===e),i=a.sort((e,t)=>{let n=(e.subagents??[]).reduce((e,t)=>Math.max(e,t.prompt_preview.length),0);return(t.subagents??[]).reduce((e,t)=>Math.max(e,t.prompt_preview.length),0)-n})[0]??a[0]??null,o=null;if(i?.subagents&&i.subagents.length>0){let e=[...i.subagents].sort((e,t)=>t.prompt_preview.length-e.prompt_preview.length)[0];o={type:e.type,description:e.description,prompt_preview:nL(e.prompt_preview,200)}}let l=i?nC(i.project):t.projects[0]?.display_name??"";return{date:t.key,session_id:i?.session_id??"",project_display:l,outcome:n.get(t.key)??null,helpfulness:s.get(t.key)??null,evidence_subagent:o,evidence_first_user:i?.first_user?nL(i.first_user,200):null,day_signature:t.day_signature??null}}),o={};for(let e of i)e.outcome&&(o[e.outcome]=(o[e.outcome]??0)+1);a.push({shape:e,occurrences:i,outcome_distribution:o})}return a}(t,g):null,S=t.length>0?function(e,t=new Map){let n=new Set,s=new Map,r=new Map,a=new Map,i={short:0,medium:0,long:0,very_long:0},o=[],l=0,d=0,c=0,p=0,h=0,m=new Set;for(let u of e){let e=u.key,_=nR(u,t.get(e)??[]);for(let t of(_.brainstorm_warmup_session_count>0&&n.add(e),h+=_.todo_ops_total,_.plan_mode_used&&m.add(e),_.prompt_frames)){let n=s.get(t.frame)??{count:0,days:new Set};n.count+=t.count,n.days.add(e),s.set(t.frame,n)}for(let t of _.skills_loaded){if("user"!==t.origin)continue;let n=r.get(t.skill)??{count:0,days:new Set};n.count+=t.count,n.days.add(e),r.set(t.skill,n)}for(let t of _.user_authored_subagents_used){let n=a.get(t.type)??{count:0,days:new Set,sample_description:t.sample_description,sample_prompt_preview:t.sample_prompt_preview};n.count+=t.count,n.days.add(e),t.sample_prompt_preview.length>n.sample_prompt_preview.length&&(n.sample_description=t.sample_description,n.sample_prompt_preview=t.sample_prompt_preview),a.set(t.type,n)}let f=_.comm_style.verbosity_distribution;for(let t of(i.short+=f.short,i.medium+=f.medium,i.long+=f.long,i.very_long+=f.very_long,_.comm_style.external_refs))o.push({date:e,session_id:t.session_id,ref_kind:t.kind,preview:nL(t.preview,200)});l+=_.comm_style.steering.interrupts,d+=_.comm_style.steering.frustrated,c+=_.comm_style.steering.dissatisfied,p+=_.comm_style.steering.sessions_with_mid_run_redirect}let _=new Map,f=0,g=0;for(let[,e]of t)for(let t of e){f+=t.numbers.turn_count??0,g+=t.numbers.exit_plan_calls??0;let e=_.get(t.session_id)??[];e.push(t),_.set(t.session_id,e)}let y=[];for(let[e,t]of _.entries()){if(new Set(t.map(e=>e.local_day)).size<2)continue;t.sort((e,t)=>e.local_day.localeCompare(t.local_day));let n=t.reduce((e,t)=>e+t.numbers.active_min,0),s=t[t.length-1];y.push({thread_id:e,entries:t.map(e=>({date:e.local_day,session_id:e.session_id,project_display:nC(e.project),has_handoff_frame:(0,u.detectPromptFrames)(e.first_user).includes("handoff-prose")})),total_active_min:n,outcome:s.enrichment?.outcome??null})}y.sort((e,t)=>t.total_active_min-e.total_active_min);let v=new Map;for(let[e,t]of r.entries()){let n=e.includes("-")?e.split("-")[0]:e,s=v.get(n)??{members:new Set,total_count:0,days:new Set};for(let n of(s.members.add(e),s.total_count+=t.count,t.days))s.days.add(n);v.set(n,s)}let w=[...v.entries()].filter(([,e])=>e.members.size>=2||e.total_count>=3).sort((e,t)=>t[1].total_count-e[1].total_count).map(([e,t])=>({family:e,members:[...t.members].sort(),total_count:t.total_count,days:[...t.days].sort()}));return{brainstorming_warmup_days:[...n].sort(),prompt_frames:[...s.entries()].sort((e,t)=>t[1].count-e[1].count).map(([e,t])=>({frame:e,origin:tf.PROMPT_FRAME_ORIGIN[e],count:t.count,days:[...t.days].sort()})),user_authored_skills:[...r.entries()].sort((e,t)=>t[1].count-e[1].count).map(([e,t])=>({skill:e,count:t.count,days:[...t.days].sort()})),skill_families:w,user_authored_subagents:[...a.entries()].sort((e,t)=>t[1].count-e[1].count).map(([e,t])=>({type:e,count:t.count,days:[...t.days].sort(),sample_description:t.sample_description,sample_prompt_preview:nL(t.sample_prompt_preview,200)})),threads:y,communication_style:{verbosity_distribution:i,external_context_refs:o,steering:{total_interrupts:l,total_frustrated:d,total_dissatisfied:c,sessions_with_mid_run_redirect:p,total_turns:f}},todo_ops_total:h,plan_mode:{exit_plan_calls:g,days_with_plan:m.size}}}(t,g):null,$=w.length>0?function(e){let t=new Map,n=new Map,s=new Map,r=new Set,a=0,i=0,o=0,l=0,u=0,d=0,c=0,p=new Map,h=new Map;for(let m of e){let e=m.local_day;for(let h of(a+=m.numbers.subagent_calls,o+=m.numbers.skill_calls,i+=m.numbers.task_ops,l+=m.numbers.exit_plan_calls,u+=m.numbers.interrupts,d+=m.numbers.tools_total,c+=m.numbers.turn_count,m.numbers.subagent_calls>0&&t.set(e,(t.get(e)??0)+m.numbers.subagent_calls),m.numbers.skill_calls>0&&n.set(e,(n.get(e)??0)+m.numbers.skill_calls),(m.numbers.exit_plan_calls>0||m.flags.includes("plan_used"))&&s.set(e,(s.get(e)??0)+m.numbers.exit_plan_calls),m.flags.includes("long_autonomous")&&r.add(e),m.subagents))p.set(h.type,(p.get(h.type)??0)+1);for(let[e,t]of Object.entries(m.skills))h.set(e,(h.get(e)??0)+t)}let m=[...p.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({type:e,count:t})),_=[...h.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({skill:e,count:t})),f=[],g=new Set,y=[];for(let t of e)for(let e of t.subagents)y.push({entry:t,sa:e});for(let{entry:e,sa:t}of(y.sort((e,t)=>t.sa.prompt_preview.length-e.sa.prompt_preview.length),y)){if(f.length>=3)break;g.has(t.type)||(g.add(t.type),f.push({date:e.local_day,project_display:nC(e.project),type:t.type,prompt_preview:nL(t.prompt_preview,200)}))}let v=[],w=new Set;for(let t of e)for(let e of Object.keys(t.skills)){if(v.length>=3)break;w.has(e)||t.first_user&&!(t.first_user.length<8)&&(w.add(e),v.push({date:t.local_day,skill:e,first_user_preview:nL(t.first_user,200)}))}let k=null;for(let t of e)t.flags.includes("long_autonomous")&&(!k||t.numbers.active_min>k.numbers.active_min)&&(k=t);let b=k?{date:k.local_day,project_display:nC(k.project),active_min:k.numbers.active_min,top_tools:k.top_tools.slice(0,5),first_user_preview:nL(k.first_user,200)}:null,x=c>0?d/c:0;return{orchestration:{subagent_calls:a,task_ops:i,days_with_subagents:t.size,top_types:m,examples:f},skill_use:{skill_calls:o,days_with_skills:n.size,top_skills:_,examples:v},plan_gating:{exit_plan_calls:l,days_with_plan:s.size},turn_shape:{tools_per_turn:Math.round(10*x)/10,interrupts:u,long_autonomous_days:r.size,label:x<5?"rapid":x<15?"mixed":"batch",longest_turn:b}}}(w):null,T=s[6],N={start:`${e}T00:00:00`,end:`${T}T23:59:59`};return{version:tf.CURRENT_WEEK_DIGEST_SCHEMA_VERSION,scope:"week",key:e,window:N,day_refs:t.map(e=>e.key).sort(),generated_at:new Date().toISOString(),is_live:!1,model:null,cost_usd:null,agent_min_total:a,projects:o,shipped:l,outcome_mix:d,helpfulness_sparkline:c,top_flags:h,top_goal_categories:_,concurrency_peak_day:f,days_active:y,busiest_day:v,longest_run:k,hours_distribution:b,interaction_modes:$,working_shapes:x,interaction_grammar:S,headline:null,key_pattern:null,trajectory:null,standout_days:null,what_worked:null,what_stalled:null,what_surprised:null,where_to_lean:null,recurring_themes:null,outcome_correlations:null,friction_categories:null,suggestions:null,on_the_horizon:null,fun_ending:null}}let nY=e=>tG({...e,systemPrompt:nZ});function nW(e){return e.toLowerCase().replace(/\s+/g," ").trim()}function nz(e,t,n,s){let r=nW(s),a=new Map;for(let e of t){let t=[e.headline,e.what_went_well,e.what_hit_friction].filter(e=>!!e);a.set(e.key,nW(t.join(" \n ")))}for(let e of n){let t=e.local_day,n=a.get(t)??"",s=[e.first_user,e.final_agent,...(e.subagents??[]).flatMap(e=>[e.description,e.prompt_preview])].filter(e=>!!e).join(" \n ");a.set(t,nW(n+" \n "+s))}let i=e=>{let t=nW(e.evidence.quote);if(r.includes(t))return!0;let n=a.get(e.evidence.date);return!!n&&n.includes(t)};return{...e,what_worked:(e.what_worked??[]).filter(i),what_stalled:(e.what_stalled??[]).filter(i),what_surprised:(e.what_surprised??[]).filter(i)}}async function nB(e,t,n={}){let s=nF(e,t,{entriesByDay:n.entriesByDay}),r=t.filter(e=>null!==e.headline),a=n.allowSingleDay?1:2;if(r.length<a)return{digest:s,usage:null};let i=n.model??"sonnet",o=n.callLLM??nY,l=function(e,t){let n=[],s=(e="")=>n.push(e),r=new Map;for(let e of t)for(let t of e.shipped){let n=r.get(t.project)??[];n.push({title:t.title,date:e.key}),r.set(t.project,n)}s(`# Week ${e.key} (${e.window.start} → ${e.window.end})`),s(),s(`Total agent time: ${Math.round(e.agent_min_total)} min across ${t.length} day(s) with data.`);let a=new Map;for(let e of t)for(let t of e.agent_breakdown??[]){let e=a.get(t.agent)??{sessions:0,active_min:0,tools_total:0};e.sessions+=t.sessions,e.active_min+=t.active_min,e.tools_total+=t.tools_total,a.set(t.agent,e)}if(a.size>0){let e=Array.from(a.entries()).sort((e,t)=>t[1].active_min-e[1].active_min).map(([e,t])=>`${e}=${t.sessions} session${1===t.sessions?"":"s"}/${Math.round(t.active_min)}m active/${t.tools_total} tool calls`).join(", ");s(`Per-agent week breakdown: ${e}.`)}let i={shipped:0,partial:0,blocked:0,exploratory:0,trivial:0,idle:0};for(let t of nD)i[t]=e.outcome_mix[t]??0;let o=nD.filter(e=>i[e]>0).map(e=>`${e}=${i[e]}`).join(", ");for(let t of(s(`Outcome mix: ${o||"(empty)"}.`),s(`Helpfulness sparkline (Mon→Sun): ${e.helpfulness_sparkline.map(e=>e??"·").join(" ")}`),e.concurrency_peak_day&&s(`Concurrency peak day: ${e.concurrency_peak_day}.`),s(),s("## Projects (top by agent_min)"),e.projects.slice(0,8))){let e=t.display_name??function(e){let t=e.split("/").filter(Boolean);return t[t.length-1]??e}(t.name),n=(r.get(e)??[]).slice(0,8),a=n.length>0?n.map(e=>` - "${e.title}" (${e.date})`).join("\n"):" - (no PRs shipped)";s(`- ${e} — ${Math.round(t.agent_min)}m, ${Math.round(10*t.share_pct)/10}% share, ${t.shipped_count} PR${1===t.shipped_count?"":"s"}`),s(a)}s(),e.top_flags.length>0&&s(`Top flags: ${e.top_flags.map(e=>`${e.flag}(${e.count})`).join(", ")}`),e.top_goal_categories.length>0&&s(`Goal-category minutes: ${e.top_goal_categories.map(e=>`${e.category}=${e.minutes}m`).join(", ")}`),s(),s("## Working shapes (deterministic, already classified)");let l=e.working_shapes??[];if(0===l.length)s("(none — no day reached the threshold for shape classification)");else for(let e of l){let t=[...new Set(e.occurrences.map(e=>e.date))].sort(),n=Object.entries(e.outcome_distribution??{}).filter(([,e])=>e>0).map(([e,t])=>`${e}:${t}`).join(", ");s(`- ${e.shape} — ${e.occurrences.length} occurrence(s) on [${t.join(", ")}]${n?`; outcomes ${n}`:""}`)}s(),s("## Interaction grammar");let u=e.interaction_grammar;if(u){if(u.brainstorming_warmup_days?.length&&s(`- Brainstorm-warmup days (${u.brainstorming_warmup_days.length}): ${u.brainstorming_warmup_days.join(", ")}`),u.prompt_frames?.length){let e=u.prompt_frames.map(e=>`${e.frame}(${e.origin})\xd7${e.count}`).join(", ");s(`- Prompt frames: ${e}`)}if(u.user_authored_skills?.length){let e=u.user_authored_skills.map(e=>`${e.skill}\xd7${e.count}`).join(", ");s(`- User-authored skills: ${e}`)}if(u.skill_families?.length){let e=u.skill_families.map(e=>`${e.family}(${e.members.length} members, ${e.total_count} uses)`).join(", ");s(`- Skill families: ${e}`)}if(u.user_authored_subagents?.length){let e=u.user_authored_subagents.map(e=>`${e.type}\xd7${e.count}`).join(", ");s(`- User-authored subagent types: ${e}`)}u.threads?.length&&s(`- Multi-day threads: ${u.threads.length} (total ${u.threads.reduce((e,t)=>e+t.total_active_min,0)}m active)`);let e=u.communication_style;if(e){let t=e.verbosity_distribution;s(`- Verbosity: short=${t.short}, medium=${t.medium}, long=${t.long}, very_long=${t.very_long}`);let n=e.external_context_refs;n.length&&s(`- External-ref openings (${n.length}): ${n.slice(0,5).map(e=>`${e.ref_kind}@${e.date}`).join(", ")}`);let r=e.steering;s(`- Steering: ${r.total_interrupts} interrupts, ${r.total_frustrated} frustrated, ${r.total_dissatisfied} dissatisfied, ${r.sessions_with_mid_run_redirect} mid-run redirects, across ${r.total_turns} turns`)}s(`- TodoWrite ops total: ${u.todo_ops_total}`),u.plan_mode&&s(`- Plan Mode: ${u.plan_mode.exit_plan_calls} exit_plan calls, ${u.plan_mode.days_with_plan} day(s) with plan use`)}else s("(none)");let d=t.slice().sort((e,t)=>e.key.localeCompare(t.key));for(let e of(s(),s("## Day summaries"),d)){var c;s();let t=e.top_flags.slice(0,5).map(e=>`${e.flag}(${e.count})`).join(", "),n=e.day_signals?.dominant_shape??null,r=n?` \xb7 shape: ${n}`:"";if(s(`### ${(c=e.key,new Date(`${c}T12:00:00`).toLocaleDateString("en-US",{weekday:"short"}))} ${e.key} — ${Math.round(e.agent_min)}m active \xb7 outcome: ${e.outcome_day}${r}`),e.agent_breakdown&&e.agent_breakdown.length>1){let t=e.agent_breakdown.map(e=>`${e.agent}=${e.sessions}/${Math.round(e.active_min)}m`).join(", ");s(`Agent breakdown: ${t}`)}e.headline&&s(`Headline: ${e.headline}`),e.day_signature&&s(`Signature: ${e.day_signature}`),e.what_went_well&&s(`Went well: ${e.what_went_well}`),e.what_hit_friction&&s(`Hit friction: ${e.what_hit_friction}`),e.suggestion&&s(`Suggestion: ${e.suggestion.headline} — ${e.suggestion.body}`),t&&s(`Flags: ${t}`),null!==e.helpfulness_day&&void 0!==e.helpfulness_day&&s(`Helpfulness: ${e.helpfulness_day}`);let a=e.day_signals;if(a){let e=Object.entries(a.shape_distribution??{}).filter(([,e])=>e>0).map(([e,t])=>`${e}:${t}`).join(", ");if(e&&s(`Shape distribution: ${e}`),a.skills_loaded.length){let e=a.skills_loaded.slice(0,6).map(e=>`${e.skill}(${e.origin})${e.count>1?`\xd7${e.count}`:""}`).join(", ");s(`Skills loaded: ${e}`)}if(a.user_authored_subagents_used.length){let e=a.user_authored_subagents_used.slice(0,4).map(e=>`${e.type}${e.count>1?`\xd7${e.count}`:""}`).join(", ");s(`User-authored subagents: ${e}`)}if(a.prompt_frames.length){let e=a.prompt_frames.map(e=>`${e.frame}(${e.origin})${e.count>1?`\xd7${e.count}`:""}`).join(", ");s(`Prompt frames: ${e}`)}let t=a.comm_style.verbosity_distribution;s(`Verbosity: short=${t.short}, medium=${t.medium}, long=${t.long}, very_long=${t.very_long}`);let n=a.comm_style.steering;s(`Steering: ${n.interrupts} interrupts, ${n.frustrated} frustrated, ${n.dissatisfied} dissatisfied, ${n.sessions_with_mid_run_redirect} mid-run redirects`),a.brainstorm_warmup_session_count>0&&s(`Brainstorm-warmup sessions: ${a.brainstorm_warmup_session_count}`),a.plan_mode_used&&s("Plan Mode: used"),a.todo_ops_total>0&&s(`TodoWrite ops: ${a.todo_ops_total}`)}}return n.join("\n")}(s,t),u=0,d=0,c=i,p=[];for(let e of(n.entriesByDay??new Map).values())p.push(...e);function h(e){let t=s.projects.map(t=>{let n=e.project_areas.find(e=>e.display_name===t.display_name);return n?{...t,description:n.description}:t});return{...s,projects:t,model:c,cost_usd:tQ(c,u,d),headline:e.headline,key_pattern:e.key_pattern,trajectory:e.trajectory,standout_days:e.standout_days,what_worked:e.what_worked,what_stalled:e.what_stalled,what_surprised:e.what_surprised,where_to_lean:e.where_to_lean,recurring_themes:null,outcome_correlations:null,friction_categories:null,suggestions:null,on_the_horizon:null,fun_ending:null}}try{let r,a,m=await o({model:i,userPrompt:l,onProgress:n.onProgress});u+=m.input_tokens,d+=m.output_tokens,c=m.model;let _=(r=m.content,tX(r,nP));if(_.ok)return{digest:h(nz(_.value,t,p,l)),usage:{input_tokens:u,output_tokens:d}};let f=await o({model:i,userPrompt:l,reminder:"Your previous response was not valid JSON or did not match the required schema. Return ONLY the JSON object with all required fields — no prose, no code fence.",onProgress:n.onProgress});u+=f.input_tokens,d+=f.output_tokens,c=f.model;let g=(a=f.content,tX(a,nP));if(g.ok)return{digest:h(nz(g.value,t,p,l)),usage:{input_tokens:u,output_tokens:d}};return console.warn(`[digest-week] ${e}: LLM response failed validation after retry (${g.error})`),{digest:s,usage:{input_tokens:u,output_tokens:d}}}catch(t){return console.warn(`[digest-week] ${e}: LLM invocation failed (${t.message})`),{digest:s,usage:u>0?{input_tokens:u,output_tokens:d}:null}}}var t_=t_;let nJ=/^\d{4}-\d{2}-\d{2}$/,nH=t_.object({headline:t_.string().min(1).max(120),body:t_.string().min(1).max(800)}),nV=t_.object({headline:t_.string().min(1).max(160),trajectory:t_.array(t_.object({week_start:t_.string().regex(nJ),line:t_.string().min(1).max(280)})).min(1),standout_weeks:t_.array(t_.object({week_start:t_.string().regex(nJ),why:t_.string().min(1).max(400)})).min(1).max(2),friction_themes:t_.string().max(800),suggestion:nH}).passthrough(),nq=`You are the monthly digest writer for Fleetlens.
298
298
 
299
299
  You receive a JSON payload describing one calendar month, summarised through its 4–5 weekly digests.
300
300
  Your job: produce a 5-field JSON object capturing the shape of the month.
@@ -332,9 +332,9 @@ RULES:
332
332
  2. Trajectory lines name the dominant work of each week — projects shipped, themes that ran across multiple days, blockers that persisted.
333
333
  3. Standout weeks are weeks that shipped disproportionately, were unusually blocked, or shifted the trajectory of the month.
334
334
  4. Friction themes look at recurrence — friction that appeared in 2+ weeks deserves naming; one-week friction usually doesn't.
335
- 5. Strict JSON.`,nV=["shipped","partial","blocked","exploratory","trivial","idle"];function nH(e){let[t,n]=e.split("-"),s=Number(t),a=Number(n),r=[],i=(8-new Date(s,a-1,1).getDay())%7,o=new Date(new Date(s,a-1,1+i));for(;o.getMonth()===a-1;)r.push(nq(o)),o.setDate(o.getDate()+7);return r}function nq(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${s}`}function nK(e,t){let n=nH(e),s=new Map;for(let e of t)s.set(e.key,e);let a=t.reduce((e,t)=>e+t.agent_min_total,0),r=new Map;for(let e of t)for(let t of e.projects){let e=r.get(t.name)??{agent_min:0,shipped_count:0};e.agent_min+=t.agent_min,e.shipped_count+=t.shipped_count,r.set(t.name,e)}let i=[...r.entries()].sort((e,t)=>t[1].agent_min-e[1].agent_min).map(([e,t])=>{let n;return{name:e,display_name:(n=e.split("/").filter(Boolean))[n.length-1]??e,agent_min:t.agent_min,share_pct:a>0?t.agent_min/a*100:0,shipped_count:t.shipped_count}}),o=[];for(let e of t)for(let t of e.shipped)o.push({title:t.title,project:t.project,date:t.date,session_id:t.session_id});let l={};for(let e of t)for(let[t,n]of Object.entries(e.outcome_mix))l[t]=(l[t]??0)+n;let u=n.map(e=>{let t=s.get(e);return{week_start:e,helpfulness:t?t.helpfulness_sparkline.find(e=>null!==e)??null:null}}),d=new Map;for(let e of t)for(let t of e.top_flags)d.set(t.flag,(d.get(t.flag)??0)+t.count);let c=[...d.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({flag:e,count:t})),p=new Map;for(let e of t)for(let t of e.top_goal_categories)p.set(t.category,(p.get(t.category)??0)+t.minutes);let h=[...p.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({category:e,minutes:t})),m=null;for(let e of t){let t=e.concurrency_peak_day?.peak??0;t>0&&(!m||t>m.peak)&&(m={week_start:e.key,peak:t})}let[_,f]=e.split("-"),g=Number(_),y=Number(f),v=`${e}-01`,w=nq(new Date(g,y,0)),k={start:`${v}T00:00:00`,end:`${w}T23:59:59`};return{version:tf.CURRENT_MONTH_DIGEST_SCHEMA_VERSION,scope:"month",key:e,window:k,week_refs:t.map(e=>e.key).sort(),generated_at:new Date().toISOString(),is_live:!1,model:null,cost_usd:null,agent_min_total:a,projects:i,shipped:o,outcome_mix:l,helpfulness_by_week:u,top_flags:c,top_goal_categories:h,concurrency_peak_week:m,headline:null,trajectory:null,standout_weeks:null,friction_themes:null,suggestion:null}}let nG=e=>tH({...e,systemPrompt:nJ});async function nX(e,t,n={}){let s=nK(e,t);if(t.filter(e=>null!==e.headline).length<2)return{digest:s,usage:null};let a=n.model??"sonnet",r=n.callLLM??nG,i=function(e,t){let n=t.slice().sort((e,t)=>e.key.localeCompare(t.key)).map(e=>{let t=e.helpfulness_sparkline.find(e=>null!==e)??null,n=e.friction_categories&&e.friction_categories.length>0?e.friction_categories.map(e=>`${e.category}: ${e.description}`).join(" "):null,s=e.suggestions?.usage_patterns?.[0],a=s?{headline:s.title,body:s.suggestion}:null;return{week_start:e.key,headline:e.headline,trajectory:e.trajectory,standout_days:e.standout_days,friction_themes:n,suggestion:a,agent_min:Math.round(e.agent_min_total),helpfulness_week:t}}),s={shipped:0,partial:0,blocked:0,exploratory:0,trivial:0,idle:0};for(let t of nV)s[t]=e.outcome_mix[t]??0;return JSON.stringify({period:{start:e.window.start,end:e.window.end,label:function(e){let[t,n]=e.split("-");return t&&n?new Date(Number(t),Number(n)-1,1).toLocaleDateString("en-US",{month:"long",year:"numeric"}):e}(e.key)},totals:{agent_min_total:Math.round(e.agent_min_total),week_count_with_data:n.length},outcome_mix:s,helpfulness_by_week:e.helpfulness_by_week,projects:e.projects.slice(0,5).map(e=>{var t;let n;return{display_name:e.display_name??(n=(t=e.name).split("/").filter(Boolean))[n.length-1]??t,agent_min:Math.round(e.agent_min),share_pct:Math.round(10*e.share_pct)/10,shipped_count:e.shipped_count}}),shipped:e.shipped.map(e=>({title:e.title,project:e.project,date:e.date})),top_flags:e.top_flags,top_goal_categories:e.top_goal_categories,concurrency_peak_week:e.concurrency_peak_week,week_summaries:n},null,2)}(s,t),o=0,l=0,u=a;try{let t,d,c=await r({model:a,userPrompt:i,onProgress:n.onProgress});o+=c.input_tokens,l+=c.output_tokens,u=c.model;let p=(t=c.content,tq(t,nB));if(p.ok)return{digest:{...s,model:u,cost_usd:tK(u,o,l),headline:p.value.headline,trajectory:p.value.trajectory,standout_weeks:p.value.standout_weeks,friction_themes:p.value.friction_themes,suggestion:p.value.suggestion},usage:{input_tokens:o,output_tokens:l}};let h=await r({model:a,userPrompt:i,reminder:"Your previous response was not valid JSON or did not match the required schema. Return ONLY the JSON object with the five required fields — no prose, no code fence.",onProgress:n.onProgress});o+=h.input_tokens,l+=h.output_tokens,u=h.model;let m=(d=h.content,tq(d,nB));if(m.ok)return{digest:{...s,model:u,cost_usd:tK(u,o,l),headline:m.value.headline,trajectory:m.value.trajectory,standout_weeks:m.value.standout_weeks,friction_themes:m.value.friction_themes,suggestion:m.value.suggestion},usage:{input_tokens:o,output_tokens:l}};return console.warn(`[digest-month] ${e}: LLM response failed validation after retry (${m.error})`),{digest:s,usage:{input_tokens:o,output_tokens:l}}}catch(t){return console.warn(`[digest-month] ${e}: LLM invocation failed (${t.message})`),{digest:s,usage:o>0?{input_tokens:o,output_tokens:l}:null}}}var t_=t_;function nQ(e){return Math.round(e/1e3/60*10)/10}function n0(e,t){return e?e.length<=2*t+60?{chars:e.length,preview:e}:{chars:e.length,preview:e.slice(0,t)+`
335
+ 5. Strict JSON.`,nK=["shipped","partial","blocked","exploratory","trivial","idle"];function nG(e){let[t,n]=e.split("-"),s=Number(t),r=Number(n),a=[],i=(8-new Date(s,r-1,1).getDay())%7,o=new Date(new Date(s,r-1,1+i));for(;o.getMonth()===r-1;)a.push(nX(o)),o.setDate(o.getDate()+7);return a}function nX(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${s}`}function nQ(e,t){let n=nG(e),s=new Map;for(let e of t)s.set(e.key,e);let r=t.reduce((e,t)=>e+t.agent_min_total,0),a=new Map;for(let e of t)for(let t of e.projects){let e=a.get(t.name)??{agent_min:0,shipped_count:0};e.agent_min+=t.agent_min,e.shipped_count+=t.shipped_count,a.set(t.name,e)}let i=[...a.entries()].sort((e,t)=>t[1].agent_min-e[1].agent_min).map(([e,t])=>{let n;return{name:e,display_name:(n=e.split("/").filter(Boolean))[n.length-1]??e,agent_min:t.agent_min,share_pct:r>0?t.agent_min/r*100:0,shipped_count:t.shipped_count}}),o=[];for(let e of t)for(let t of e.shipped)o.push({title:t.title,project:t.project,date:t.date,session_id:t.session_id});let l={};for(let e of t)for(let[t,n]of Object.entries(e.outcome_mix))l[t]=(l[t]??0)+n;let u=n.map(e=>{let t=s.get(e);return{week_start:e,helpfulness:t?t.helpfulness_sparkline.find(e=>null!==e)??null:null}}),d=new Map;for(let e of t)for(let t of e.top_flags)d.set(t.flag,(d.get(t.flag)??0)+t.count);let c=[...d.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({flag:e,count:t})),p=new Map;for(let e of t)for(let t of e.top_goal_categories)p.set(t.category,(p.get(t.category)??0)+t.minutes);let h=[...p.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({category:e,minutes:t})),m=null;for(let e of t){let t=e.concurrency_peak_day?.peak??0;t>0&&(!m||t>m.peak)&&(m={week_start:e.key,peak:t})}let[_,f]=e.split("-"),g=Number(_),y=Number(f),v=`${e}-01`,w=nX(new Date(g,y,0)),k={start:`${v}T00:00:00`,end:`${w}T23:59:59`};return{version:tf.CURRENT_MONTH_DIGEST_SCHEMA_VERSION,scope:"month",key:e,window:k,week_refs:t.map(e=>e.key).sort(),generated_at:new Date().toISOString(),is_live:!1,model:null,cost_usd:null,agent_min_total:r,projects:i,shipped:o,outcome_mix:l,helpfulness_by_week:u,top_flags:c,top_goal_categories:h,concurrency_peak_week:m,headline:null,trajectory:null,standout_weeks:null,friction_themes:null,suggestion:null}}let n0=e=>tG({...e,systemPrompt:nq});async function n1(e,t,n={}){let s=nQ(e,t);if(t.filter(e=>null!==e.headline).length<2)return{digest:s,usage:null};let r=n.model??"sonnet",a=n.callLLM??n0,i=function(e,t){let n=t.slice().sort((e,t)=>e.key.localeCompare(t.key)).map(e=>{let t=e.helpfulness_sparkline.find(e=>null!==e)??null,n=e.friction_categories&&e.friction_categories.length>0?e.friction_categories.map(e=>`${e.category}: ${e.description}`).join(" "):null,s=e.suggestions?.usage_patterns?.[0],r=s?{headline:s.title,body:s.suggestion}:null;return{week_start:e.key,headline:e.headline,trajectory:e.trajectory,standout_days:e.standout_days,friction_themes:n,suggestion:r,agent_min:Math.round(e.agent_min_total),helpfulness_week:t}}),s={shipped:0,partial:0,blocked:0,exploratory:0,trivial:0,idle:0};for(let t of nK)s[t]=e.outcome_mix[t]??0;return JSON.stringify({period:{start:e.window.start,end:e.window.end,label:function(e){let[t,n]=e.split("-");return t&&n?new Date(Number(t),Number(n)-1,1).toLocaleDateString("en-US",{month:"long",year:"numeric"}):e}(e.key)},totals:{agent_min_total:Math.round(e.agent_min_total),week_count_with_data:n.length},outcome_mix:s,helpfulness_by_week:e.helpfulness_by_week,projects:e.projects.slice(0,5).map(e=>{var t;let n;return{display_name:e.display_name??(n=(t=e.name).split("/").filter(Boolean))[n.length-1]??t,agent_min:Math.round(e.agent_min),share_pct:Math.round(10*e.share_pct)/10,shipped_count:e.shipped_count}}),shipped:e.shipped.map(e=>({title:e.title,project:e.project,date:e.date})),top_flags:e.top_flags,top_goal_categories:e.top_goal_categories,concurrency_peak_week:e.concurrency_peak_week,week_summaries:n},null,2)}(s,t),o=0,l=0,u=r;try{let t,d,c=await a({model:r,userPrompt:i,onProgress:n.onProgress});o+=c.input_tokens,l+=c.output_tokens,u=c.model;let p=(t=c.content,tX(t,nV));if(p.ok)return{digest:{...s,model:u,cost_usd:tQ(u,o,l),headline:p.value.headline,trajectory:p.value.trajectory,standout_weeks:p.value.standout_weeks,friction_themes:p.value.friction_themes,suggestion:p.value.suggestion},usage:{input_tokens:o,output_tokens:l}};let h=await a({model:r,userPrompt:i,reminder:"Your previous response was not valid JSON or did not match the required schema. Return ONLY the JSON object with the five required fields — no prose, no code fence.",onProgress:n.onProgress});o+=h.input_tokens,l+=h.output_tokens,u=h.model;let m=(d=h.content,tX(d,nV));if(m.ok)return{digest:{...s,model:u,cost_usd:tQ(u,o,l),headline:m.value.headline,trajectory:m.value.trajectory,standout_weeks:m.value.standout_weeks,friction_themes:m.value.friction_themes,suggestion:m.value.suggestion},usage:{input_tokens:o,output_tokens:l}};return console.warn(`[digest-month] ${e}: LLM response failed validation after retry (${m.error})`),{digest:s,usage:{input_tokens:o,output_tokens:l}}}catch(t){return console.warn(`[digest-month] ${e}: LLM invocation failed (${t.message})`),{digest:s,usage:o>0?{input_tokens:o,output_tokens:l}:null}}}var t_=t_;function n2(e){return Math.round(e/1e3/60*10)/10}function n4(e,t){return e?e.length<=2*t+60?{chars:e.length,preview:e}:{chars:e.length,preview:e.slice(0,t)+`
336
336
  […truncated ${e.length-2*t} chars…]
337
- `+e.slice(-t)}:null}function n1(e){let t=[...e].sort((e,t)=>e-t),n=0;for(let e=1;e<t.length;e++){let s=t[e]-t[e-1];s<18e4&&(n+=s)}return n}let n2=new Set(["sudo","time","nohup","nice","env","exec"]),n4=/\[request interrupted|interrupted by user/i,n9=/--title\s+["']([^"']+)["']/,n5=t_.object({start_min:t_.number(),end_min:t_.number().optional(),kind:t_.enum(["user-steering","subagent-burst","long-autonomous","plan-mode","pr-ship","harness-chain","interrupt","brainstorm-loop","agent-loop"]),label:t_.string().min(1).transform(e=>{if(e.length<=320)return e;let t=317,n=e.charCodeAt(t-1);return n>=55296&&n<=56319&&(t-=1),e.slice(0,t)+"..."})}),n3=t_.object({why_picked:t_.string().min(1).max(280),session_summary:t_.string().min(1).max(400),what_worked:t_.string().max(280).nullable(),what_hit_friction:t_.string().max(280).nullable(),steering_summary:t_.string().min(1).max(280),pins:t_.array(n5).min(2).max(6)}).passthrough(),n7=`You are writing the editorial perception layer for ONE session in a developer's weekly report. The reader sees a timeline minimap of this session with annotated pin markers; your job is to write a structured deep-dive that surfaces what made this session worth examining.
337
+ `+e.slice(-t)}:null}function n9(e){let t=[...e].sort((e,t)=>e-t),n=0;for(let e=1;e<t.length;e++){let s=t[e]-t[e-1];s<18e4&&(n+=s)}return n}let n5=new Set(["sudo","time","nohup","nice","env","exec"]),n3=/\[request interrupted|interrupted by user/i,n8=/--title\s+["']([^"']+)["']/,n7=t_.object({start_min:t_.number(),end_min:t_.number().optional(),kind:t_.enum(["user-steering","subagent-burst","long-autonomous","plan-mode","pr-ship","harness-chain","interrupt","brainstorm-loop","agent-loop"]),label:t_.string().min(1).transform(e=>{if(e.length<=320)return e;let t=317,n=e.charCodeAt(t-1);return n>=55296&&n<=56319&&(t-=1),e.slice(0,t)+"..."})}),n6=t_.object({why_picked:t_.string().min(1).max(280),session_summary:t_.string().min(1).max(400),what_worked:t_.string().max(280).nullable(),what_hit_friction:t_.string().max(280).nullable(),steering_summary:t_.string().min(1).max(280),pins:t_.array(n7).min(2).max(6)}).passthrough(),se=`You are writing the editorial perception layer for ONE session in a developer's weekly report. The reader sees a timeline minimap of this session with annotated pin markers; your job is to write a structured deep-dive that surfaces what made this session worth examining.
338
338
 
339
339
  INPUT shape (transcript-style markdown, NOT JSON):
340
340
  The user prompt is a markdown document with these sections:
@@ -397,6 +397,6 @@ VOCABULARY:
397
397
  - Internal flag tokens (loop_suspected, long_autonomous, fast_ship) — forbidden in labels
398
398
  - "Plan Mode" specifically means /plan tool calls
399
399
  - Avoid identity claims ("you're a Plan Mode person"). Stick to observed action.
400
- `,n8=e=>tH({...e,systemPrompt:n7});async function n6(e,t={}){let n={session_id:e.session_id,date:e.date,project:e.project,project_display:e.project_display,start_iso:e.start_iso,wall_min:e.wall_min,active_min:e.active_min,idle_min:e.idle_min,turn_count:e.turn_count,outcome:e.outcome??null,shipped_prs:e.shipped_prs,working_shape:e.working_shape,day_signature:e.day_signature,user_authored_skills:e.user_authored_skills,user_authored_subagents:e.user_authored_subagents,stock_skills:e.stock_skills,top_tools:e.top_tools,steering:e.steering,timeline:{duration_min:e.wall_min,active_intervals:e.active_intervals},session_summary:null,steering_summary:null,why_picked:null,what_worked:null,what_hit_friction:null,pins:[]};if(0===e.candidate_pins.length)return{topSession:n,usage:null};let s=t.model??"sonnet",a=t.callLLM??n8,r=function(e){let t=[],n=(e="")=>t.push(e);n(`# Session ${e.session_id}`),n(`Project: ${e.project_display} \xb7 Date: ${e.date} \xb7 Started: ${e.start_iso}`),n(`Wall: ${e.wall_min}m \xb7 Active: ${e.active_min}m \xb7 Idle: ${e.idle_min}m \xb7 Turns: ${e.turn_count}`);let s=[];if(e.outcome&&s.push(`Outcome: ${e.outcome}`),e.working_shape&&s.push(`Working shape: ${e.working_shape}`),s.length&&n(s.join(" · ")),e.day_signature&&n(`Day signature: "${e.day_signature}"`),e.shipped_prs.length)for(let t of(n(`Shipped PRs (${e.shipped_prs.length}):`),e.shipped_prs))n(` - "${t}"`);if(n(),n("## Harness"),n(`- User-authored skills: ${e.user_authored_skills.length?e.user_authored_skills.join(", "):"(none)"}`),e.user_authored_subagents.length){let t=e.user_authored_subagents.map(e=>`${e.type}\xd7${e.count}`).join(", ");n(`- User-authored subagents: ${t}`)}n(`- Stock skills loaded: ${e.stock_skills.length?e.stock_skills.join(", "):"(none)"}`),n(`- Top tools: ${e.top_tools.length?e.top_tools.join(", "):"(none)"}`),n();let a=e.steering;for(let t of(n("## Steering"),n(`${a.user_msg_count} user messages (median ${a.median_user_msg_chars} chars, ${a.long_user_msg_count} long, ${a.interrupts} interrupts)`),n(),n(`## Turns (${e.turns.length})`),e.turns)){n();let e=t.idle_before_min>0?` \xb7 ${t.idle_before_min}m idle before`:"";if(n(`### Turn ${t.turn} — ${t.start_min}m–${t.end_min}m (${t.wall_min}m wall, ${t.active_min}m active${e})`),t.user&&n(`USER (${t.user.chars}c): ${t.user.preview}`),t.first_agent&&n(`FIRST_AGENT (${t.first_agent.chars}c): ${t.first_agent.preview}`),t.last_agent&&n(`LAST_AGENT (${t.last_agent.chars}c): ${t.last_agent.preview}`),!t.agent||t.first_agent||t.last_agent||n(`AGENT (${t.agent.chars}c): ${t.agent.preview}`),t.tools.length&&n(`Tools: ${t.tools.join(", ")}`),t.skills_loaded?.length&&n(`Skills loaded this turn: ${t.skills_loaded.join(", ")}`),t.subagents_dispatched?.length)for(let e of t.subagents_dispatched)n(`Subagent dispatched: ${e.type} — ${e.description}`),e.prompt_preview&&n(` prompt: ${e.prompt_preview}`);let s=[];t.exit_plan_calls&&s.push(`exit_plan\xd7${t.exit_plan_calls}`),t.todo_ops&&s.push(`TodoWrite ops: ${t.todo_ops}`),t.interrupts&&s.push(`interrupts: ${t.interrupts}`),t.pr_created&&s.push(`PR created: "${t.pr_created}"`),t.long_autonomous_run&&s.push("LONG-AUTONOMOUS RUN"),s.length&&n(`Signals: ${s.join(" · ")}`)}if(n(),n('## Candidate pins (deterministic — pick + label the most editorial 3-6 of these for your "pins" output)'),0===e.candidate_pins.length)n("(none — sparse session)");else for(let t of e.candidate_pins){let e=void 0!==t.end_min?`${t.start_min}m–${t.end_min}m`:`${t.start_min}m`,s=[];for(let[e,n]of Object.entries(t.context??{}))null!=n&&("string"==typeof n?s.push(`${e}="${n.length>200?n.slice(0,197)+"...":n}"`):Array.isArray(n)?s.push(`${e}=[${n.length} items]`):"object"==typeof n?s.push(`${e}={...}`):s.push(`${e}=${n}`));n(`- [${e}] ${t.kind}${s.length?` — ${s.join(", ")}`:""}`)}return t.join("\n")}(e),i=0,o=0;function l(e){let t=e.pins.map(e=>({start_min:e.start_min,end_min:e.end_min,kind:e.kind,label:e.label}));return{...n,session_summary:e.session_summary,steering_summary:e.steering_summary,why_picked:e.why_picked,what_worked:e.what_worked,what_hit_friction:e.what_hit_friction,pins:t}}try{let u,d,c=await a({model:s,userPrompt:r,onProgress:t.onProgress});i+=c.input_tokens,o+=c.output_tokens,c.model;let p=(u=c.content,tq(u,n3));if(p.ok)return{topSession:l(p.value),usage:{input_tokens:i,output_tokens:o}};let h=await a({model:s,userPrompt:r,reminder:"Your previous response was not valid JSON or did not match the required schema. Return ONLY the JSON object with session_summary + steering_summary + pins (3-5 items, each with start_min/kind/label) — no prose, no code fence.",onProgress:t.onProgress});i+=h.input_tokens,o+=h.output_tokens,h.model;let m=(d=h.content,tq(d,n3));if(m.ok)return{topSession:l(m.value),usage:{input_tokens:i,output_tokens:o}};return console.warn(`[top-session] ${e.session_id}: LLM validation failed after retry (${m.error})`),{topSession:n,usage:{input_tokens:i,output_tokens:o}}}catch(t){return console.warn(`[top-session] ${e.session_id}: LLM invocation failed (${t.message})`),{topSession:n,usage:i>0?{input_tokens:i,output_tokens:o}:null}}finally{}}async function*se(e,t){let n=t.now??(()=>Date.now()),s=e===t.currentWeekMonday,a=t.settings.enabled;if(!s&&!t.force){let t=(0,ny.readWeekDigest)(e);if(t)return void(yield{type:"digest",digest:t})}if(s&&!t.force){let t=(0,ny.getCurrentWeekDigestFromCache)(e,n());if(t)return void(yield{type:"digest",digest:t})}yield{type:"status",phase:"load_dependencies",text:`Loading 7 days for week of ${e}`};let r=nZ(e),i=[];for(let e of r){if(e>t.todayLocalDay){yield{type:"dependency",kind:"day",key:e,status:"cached"};continue}let n=e===t.todayLocalDay,s=n?null:(0,ny.readDayDigest)(e);if(s){i.push(s),yield{type:"dependency",kind:"day",key:e,status:"cached"};continue}if(n){let n={settings:t.settings,force:t.force??!1,callLLM:t.callLLM,now:t.now,todayLocalDay:t.todayLocalDay,caller:t.caller},s=null,a=!1;for await(let t of nx(e,n))if("digest"===t.type&&"day"===t.digest.scope&&(s=t.digest),"error"===t.type){a=!0;break}s?(i.push(s),yield{type:"dependency",kind:"day",key:e,status:"cached"}):a&&(yield{type:"dependency",kind:"day",key:e,status:"failed"});continue}let a={settings:t.settings,force:!1,callLLM:t.callLLM,now:t.now,todayLocalDay:t.todayLocalDay,caller:t.caller},r=null,o=!1;for await(let t of nx(e,a)){if("digest"===t.type){"day"===t.digest.scope&&(r=t.digest);continue}if("saved"!==t.type){if("error"===t.type){o=!0;continue}yield t}}r?(i.push(r),yield{type:"dependency",kind:"day",key:e,status:"generated"}):o&&(yield{type:"dependency",kind:"day",key:e,status:"failed"})}if(0===i.length)return void(yield{type:"error",message:`no day digests available for week of ${e}`});let o=new Map;for(let e of r)e>t.todayLocalDay||o.set(e,(0,t5.listEntriesForDay)(e));a&&ne();try{let r,l=new Map(i.map(e=>[e.key,e])),d=a?function(e){let t=[];for(let n of e.values())t.push(...n);let n=e=>e.numbers.active_min*(1+.5*e.numbers.subagent_calls+5*e.pr_titles.length),s=t.filter(e=>e.numbers.active_min>=20||e.numbers.turn_count>=10||e.pr_titles.length>=1).map(e=>({entry:e,score:n(e)})).sort((e,t)=>t.score-e.score),a=new Set,r=[];for(let{entry:e}of s)if(!a.has(e.project)&&(a.add(e.project),r.push(e),r.length>=3))break;let i=t.some(e=>(e.agent??"claude-code")!=="claude-code"),o=r.some(e=>(e.agent??"claude-code")!=="claude-code");if(i&&!o){let e=t.filter(e=>(e.agent??"claude-code")!=="claude-code").filter(e=>e.numbers.active_min>=3||e.numbers.tools_total>=10||e.numbers.turn_count>=3).map(e=>({entry:e,score:n(e)+1e-4*e.numbers.tools_total})).sort((e,t)=>t.score-e.score).find(e=>!a.has(e.entry.project));e&&(r.length>=3&&r.pop(),r.push(e.entry))}return r}(o):[],c=(await Promise.all(d.map(async e=>{try{let t=await (0,tT.getAnySession)(e.session_id);if(!t)return null;let n=t.events,s=l.get(e.local_day);return{entry:e,slice:function(e,t,n){var s;let a,r=Date.parse(e.start_iso),{turns:i,sliceStartMs:o,sliceEndMs:l}=function(e,t,n){let s=[];for(let a of e){if(!a.timestamp)continue;let e=Date.parse(a.timestamp);!Number.isNaN(e)&&(e<t||e>n||s.push({...a,_ts:e}))}if(0===s.length)return{turns:[],sliceStartMs:t,sliceEndMs:n};s.sort((e,t)=>e._ts-t._ts);let a=s[0]._ts,r=s[s.length-1]._ts,i=[],o=null;for(let e of s){let t=e.blocks??[],n="user"===e.role||"tool-result"===e.role,s="agent"===e.role||"agent-thinking"===e.role||"tool-call"===e.role;if(n)if(t.length>0&&t.every(e=>"tool_result"===e.type))o&&(o.events.push(e),o.timestamps.push(e._ts));else{let n=t.filter(e=>"text"===e.type).map(e=>e.text).join(" "),s=n4.test(n);o&&s&&(o.interrupts+=1),o&&i.push(o),o={events:[e],user_text:n,agent_blocks:[],tools_count:new Map,bash_verbs:new Map,skills:new Map,subagents:[],exit_plan_calls:0,todo_ops:0,interrupts:0,pr_created:null,timestamps:[e._ts]}}else if(s){if(!o)continue;for(let n of(o.events.push(e),o.timestamps.push(e._ts),t))if(n&&"object"==typeof n){if("text"===n.type&&n.text)o.agent_blocks.push(n.text);else if("tool_use"===n.type){let e=n.name??"unknown";if(o.tools_count.set(e,(o.tools_count.get(e)??0)+1),"Skill"===e){let e=String(n.input?.skill??"unknown");o.skills.set(e,(o.skills.get(e)??0)+1)}else if("Agent"===e){let e=n.input??{};o.subagents.push({type:String(e.subagent_type??"general-purpose"),description:String(e.description??"").slice(0,80),prompt_preview:String(e.prompt??"").slice(0,240),background:!!e.run_in_background})}else if("ExitPlanMode"===e)o.exit_plan_calls+=1;else if("TodoWrite"===e||"TaskCreate"===e||"TaskUpdate"===e)o.todo_ops+=1;else if("Bash"===e){let e=String(n.input?.command??""),t=function(e){if(!e)return"?";let t=e.split(/\|\||&&|;|\|/,1)[0].trim();if(t.startsWith("cd ")){let n=e.split(/&&|;/,3);n.length>=2&&(t=n[1].trim())}let n=t.split(/\s+/).filter(Boolean);for(;n.length&&n2.has(n[0]);)n.shift();if(!n.length)return"?";let s=n[0];if(s.includes("=")&&!s.startsWith("/")){if(n.shift(),!n.length)return"?";s=n[0]}return s.includes("/")&&!s.startsWith("./")&&(s=s.replace(/\/+$/,"").split("/").pop()),s.replace(/^["']|["']$/g,"")||"?"}(e);if(o.bash_verbs.set(t,(o.bash_verbs.get(t)??0)+1),/\bgh\s+pr\s+create\b/.test(e)){let t=e.match(n9);o.pr_created=t?.[1]??e.slice(0,120)}}}}}}return o&&i.push(o),{turns:i,sliceStartMs:a,sliceEndMs:r}}(t,r,Date.parse(e.end_iso)),d=i.flatMap(e=>e.timestamps),c=l-o,p=n1(d),h=[...d].sort((e,t)=>e-t),m=[];if(h.length>0){let e=h[0],t=h[0];for(let n=1;n<h.length;n++)h[n]-t>=18e4&&(m.push({start_min:nQ(e-o),end_min:nQ(t-o)}),e=h[n]),t=h[n];m.push({start_min:nQ(e-o),end_min:nQ(t-o)})}let _=[],f=o,g=[],y=0;i.forEach((e,t)=>{let n=Math.min(...e.timestamps),s=Math.max(...e.timestamps),a=n1(e.timestamps),r=0===t?0:Math.max(0,n-f);f=s,e.user_text&&(g.push(e.user_text.length),e.user_text.length>=800&&y++);let i=null,l=null;e.agent_blocks.length>0&&(i=e.agent_blocks[0],l=e.agent_blocks.reduce((e,t)=>t.length>e.length?t:e));let u=null!==i&&i===l,d=[];for(let[t,n]of[...e.tools_count.entries()].sort((e,t)=>t[1]-e[1]))if("Bash"===t&&e.bash_verbs.size>0){let t=[...e.bash_verbs.entries()].sort((e,t)=>t[1]-e[1]).slice(0,3).map(([e,t])=>t>1?`${e}\xd7${t}`:e).join(", ");d.push(`Bash\xd7${n} (${t})`)}else d.push(n>1?`${t}\xd7${n}`:t);let c={turn:t+1,start_min:nQ(n-o),end_min:nQ(s-o),wall_min:nQ(s-n),active_min:nQ(a),idle_before_min:nQ(r),start_iso:new Date(n).toISOString(),user:e.user_text?n0(e.user_text,0===t?400:150):null,tools:d};u?c.agent=n0(i,200):(c.first_agent=i?n0(i,150):null,c.last_agent=l?n0(l,200):null),e.skills.size>0&&(c.skills_loaded=[...e.skills.entries()].map(([e,t])=>t>1?`${e}\xd7${t}`:e)),e.subagents.length>0&&(c.subagents_dispatched=e.subagents.map(e=>({type:e.type,description:e.description,prompt_preview:e.prompt_preview}))),e.exit_plan_calls>0&&(c.exit_plan_calls=e.exit_plan_calls),e.todo_ops>0&&(c.todo_ops=e.todo_ops),e.interrupts>0&&(c.interrupts=e.interrupts),e.pr_created&&(c.pr_created=e.pr_created),a>=12e5&&0===e.interrupts&&(c.long_autonomous_run=!0),_.push(c)});let v=new Map,w=new Map,k=new Map,b=new Map,x=0;for(let e of i){for(let[t,n]of e.skills)v.set(t,(v.get(t)??0)+n);for(let t of e.subagents)(0,u.isStockSubagentType)(t.type)||w.set(t.type,(w.get(t.type)??0)+1);for(let[t,n]of e.tools_count)k.set(t,(k.get(t)??0)+n);for(let[t,n]of e.bash_verbs)b.set(t,(b.get(t)??0)+n);x+=e.interrupts}let S=[],$=[];for(let e of v.keys()){let t=(0,u.classifySkill)(e);"user"===t?S.push(e):"stock"===t&&$.push(e)}let T=[];for(let[e,t]of[...k.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5))if("Bash"===e&&b.size>0){let e=[...b.entries()].sort((e,t)=>t[1]-e[1]).slice(0,3).map(([e,t])=>t>1?`${e}\xd7${t}`:e).join(", ");T.push(`Bash\xd7${t} (${e})`)}else T.push(`${e}\xd7${t}`);g.sort((e,t)=>e-t);let N=0===g.length?0:g[Math.floor(g.length/2)],j=[];for(let e of _)e.user?.chars&&e.user.chars>=800&&j.push({start_min:e.start_min,kind:"user-steering",context:{chars:e.user.chars,turn:e.turn,format:e.user.chars>=5e3?"long-paste":"long-prose"}}),e.subagents_dispatched&&e.subagents_dispatched.length>=3&&j.push({start_min:e.start_min,kind:"subagent-burst",context:{count:e.subagents_dispatched.length,types:e.subagents_dispatched.map(e=>e.type),turn:e.turn}}),e.long_autonomous_run&&j.push({start_min:e.start_min,end_min:e.end_min,kind:"long-autonomous",context:{duration_min:e.active_min,turn:e.turn}}),e.exit_plan_calls&&e.exit_plan_calls>0&&j.push({start_min:e.start_min,kind:"plan-mode",context:{turn:e.turn}}),e.pr_created&&j.push({start_min:e.start_min,kind:"pr-ship",context:{pr_title:e.pr_created,turn:e.turn}}),e.skills_loaded&&e.skills_loaded.length>=2&&j.push({start_min:e.start_min,kind:"harness-chain",context:{skills:e.skills_loaded,turn:e.turn}}),e.interrupts&&e.interrupts>0&&j.push({start_min:e.start_min,kind:"interrupt",context:{count:e.interrupts,turn:e.turn}});return{session_id:e.session_id,date:e.local_day,project:e.project,project_display:(a=(s=e.project).split("/").filter(Boolean))[a.length-1]??s,start_iso:new Date(o).toISOString(),wall_min:nQ(c),active_min:nQ(p),idle_min:nQ(c-p),turn_count:_.length,outcome:e.enrichment.outcome,shipped_prs:e.pr_titles,working_shape:e.signals?.working_shape??(0,u.inferWorkingShape)(e),day_signature:n,user_authored_skills:S,user_authored_subagents:[...w.entries()].sort((e,t)=>t[1]-e[1]).map(([e,t])=>({type:e,count:t})),stock_skills:$,top_tools:T,steering:{user_msg_count:g.length,long_user_msg_count:y,median_user_msg_chars:N,interrupts:x},active_intervals:m,turns:_,candidate_pins:j}}(e,n,s?.day_signature??null)}}catch(t){return console.warn(`[top-session] slice prep failed for ${e.session_id}: ${t.message}`),null}}))).filter(e=>null!==e);if(a){yield{type:"status",phase:"synth",text:c.length>0?`Synthesizing week narrative + diving into ${c.length} top session${1===c.length?"":"s"} in parallel`:"Synthesizing week narrative"};let n=[],a=nY(e,i,{model:t.settings.model,callLLM:t.callLLM,entriesByDay:o,allowSingleDay:!0===t.force&&s,onProgress:e=>{n.push({bytes:e.bytes,elapsed_ms:e.elapsedMs})}}),l=Promise.all(c.map(({entry:e,slice:n})=>n6(n,{model:t.settings.model,callLLM:t.callLLM}).then(t=>({entry:e,...t})).catch(t=>(console.warn(`[top-session] LLM failed for ${e.session_id}: ${t.message}`),null)))),u=!1,d=!1;for(a.finally(()=>{u=!0}),l.finally(()=>{d=!0});!u||!d;)if(await new Promise(e=>setTimeout(e,500)),n.length>0){let e=n[n.length-1];yield{type:"progress",phase:"synth",bytes:e.bytes,elapsed_ms:e.elapsed_ms},n.length=0}let p=await a,h=await l;r=p.digest,p.usage&&t4({ts:new Date().toISOString(),caller:t.caller??"web",model:r.model??t.settings.model,input_tokens:p.usage.input_tokens,output_tokens:p.usage.output_tokens,cost_usd:r.cost_usd??0,kind:"week_digest",ref:e});let m=[];for(let n of h)n&&(m.push({...n.topSession,agent:n.entry.agent}),n.usage&&t4({ts:new Date().toISOString(),caller:t.caller??"web",model:t.settings.model,input_tokens:n.usage.input_tokens,output_tokens:n.usage.output_tokens,cost_usd:tK(t.settings.model,n.usage.input_tokens,n.usage.output_tokens),kind:"top_session",ref:`${e}/${n.entry.session_id}`}));r.headline&&m.length>0&&(r.top_sessions=m)}else r=nL(e,i,{entriesByDay:o});s?(r.is_live=!0,(0,ny.setCurrentWeekDigestInCache)(e,r,n()),!0===t.force&&((0,ny.writeWeekDigest)(r),yield{type:"saved",path:`~/.cclens/digests/week/${e}.json`})):((0,ny.writeWeekDigest)(r),yield{type:"saved",path:`~/.cclens/digests/week/${e}.json`}),yield{type:"digest",digest:r}}finally{a&&nt()}}async function*st(e,t){let n=t.now??(()=>Date.now()),s=e===t.currentYearMonth,a=t.settings.enabled;if(!s&&!t.force){let t=(0,ny.readMonthDigest)(e);if(t)return void(yield{type:"digest",digest:t})}if(s&&!t.force){let t=(0,ny.getCurrentMonthDigestFromCache)(e,n());if(t)return void(yield{type:"digest",digest:t})}yield{type:"status",phase:"load_dependencies",text:`Loading weeks for ${e}`};let r=nH(e),i=[];for(let e of r){if(e>t.currentWeekMonday){yield{type:"dependency",kind:"week",key:e,status:"cached"};continue}let n=e===t.currentWeekMonday,s=n?null:(0,ny.readWeekDigest)(e);if(s){i.push(s),yield{type:"dependency",kind:"week",key:e,status:"cached"};continue}if(n){let n={settings:t.settings,force:!1,callLLM:t.callLLM,now:t.now,currentWeekMonday:t.currentWeekMonday,todayLocalDay:t.todayLocalDay,caller:t.caller},s=null,a=!1;for await(let t of se(e,n))if("digest"===t.type&&"week"===t.digest.scope&&(s=t.digest),"error"===t.type){a=!0;break}s?(i.push(s),yield{type:"dependency",kind:"week",key:e,status:"cached"}):a&&(yield{type:"dependency",kind:"week",key:e,status:"failed"});continue}let a={settings:t.settings,force:!1,callLLM:t.callLLM,now:t.now,currentWeekMonday:t.currentWeekMonday,todayLocalDay:t.todayLocalDay,caller:t.caller},r=null,o=!1;for await(let t of se(e,a)){if("digest"===t.type){"week"===t.digest.scope&&(r=t.digest);continue}if("saved"!==t.type){if("error"===t.type){o=!0;continue}yield t}}r?(i.push(r),yield{type:"dependency",kind:"week",key:e,status:"generated"}):o&&(yield{type:"dependency",kind:"week",key:e,status:"failed"})}if(0===i.length)return void(yield{type:"error",message:`no week digests available for ${e}`});a&&ne();try{let r;if(a){yield{type:"status",phase:"synth",text:"Synthesizing month narrative"};let n=[],s=nX(e,i,{model:t.settings.model,callLLM:t.callLLM,onProgress:e=>{n.push({bytes:e.bytes,elapsed_ms:e.elapsedMs})}}),a=!1;for(s.finally(()=>{a=!0});!a;)if(await new Promise(e=>setTimeout(e,500)),n.length>0){let e=n[n.length-1];yield{type:"progress",phase:"synth",bytes:e.bytes,elapsed_ms:e.elapsed_ms},n.length=0}let o=await s;r=o.digest,o.usage&&t4({ts:new Date().toISOString(),caller:t.caller??"web",model:r.model??t.settings.model,input_tokens:o.usage.input_tokens,output_tokens:o.usage.output_tokens,cost_usd:r.cost_usd??0,kind:"month_digest",ref:e})}else r=nK(e,i);s?(r.is_live=!0,(0,ny.setCurrentMonthDigestInCache)(e,r,n()),!0===t.force&&((0,ny.writeMonthDigest)(r),yield{type:"saved",path:`~/.cclens/digests/month/${e}.json`})):((0,ny.writeMonthDigest)(r),yield{type:"saved",path:`~/.cclens/digests/month/${e}.json`}),yield{type:"digest",digest:r}}finally{a&&nt()}}async function sn(e){let t=e.trim();if(!t)throw Error("empty key");let n=await fetch("https://api.z.ai/api/monitor/usage/quota/limit",{headers:{Authorization:t,"Accept-Language":"en-US,en"}});if(!n.ok)throw Error(`Z.ai rejected the key (${n.status} ${n.statusText})`);let s=await n.json().catch(()=>{throw Error("Z.ai returned an unparseable response")});if(void 0!==s.code&&200!==s.code)throw Error(`Z.ai rejected the key (code ${s.code})`);if(!1===s.success)throw Error("Z.ai rejected the key");let a=s.data?.limits??[],r=null,i=null,o=null;for(let e of a){let t=e.type;if("TIME_LIMIT"===t){let t="number"==typeof e.percentage?e.percentage:null;o={used:t,limit:null!==t?100:null};continue}if("TOKENS_LIMIT"!==t)continue;let n=e.unit,s={utilization:"number"==typeof e.percentage?e.percentage:null,resets_at:"number"==typeof e.nextResetTime?new Date(e.nextResetTime).toISOString():null};6===n?i=i??s:r=r??s}return{captured_at:new Date().toISOString(),agent:"zai",five_hour:r??{utilization:null,resets_at:null},seven_day:i??{utilization:null,resets_at:null},seven_day_opus:null,seven_day_sonnet:null,seven_day_oauth_apps:null,seven_day_cowork:null,extra_usage:null,plan_type:s.data?.level??null,web_search_quota:o??null}}async function ss(e){let t=await sn(e);return(0,tT.appendUsageSnapshot)(t),t}function sa(){return(0,tT.cclensPath)("credentials.json")}function sr(){let e=sa();if(!(0,tx.existsSync)(e))return{};try{let t=(0,tx.readFileSync)(e,"utf8");return JSON.parse(t)}catch{return{}}}function si(){let e=sr();delete e.zai;let t=sa();if(0===Object.keys(e).length){try{(0,tx.unlinkSync)(t)}catch{}return}let n=`${t}.tmp`;(0,tx.writeFileSync)(n,JSON.stringify(e,null,2),{encoding:"utf8"}),(0,tx.chmodSync)(n,384),(0,tx.renameSync)(n,t)}e.s(["mondayFor",0,function(e){let t=new Date(`${e}T00:00:00`),n=t.getDay();t.setDate(t.getDate()+(0===n?-6:1-n));let s=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${s}-${a}-${r}`},"runWeekDigestPipeline",0,se],77242),e.s(["runMonthDigestPipeline",0,st],21628),e.s(["deleteZaiKeyAndPrune",0,function(){si(),(0,tT.pruneUsageAgent)("zai")},"readCredentialsMasked",0,function(){let e=sr();if(!e.zai?.apiKey)return{};let t=e.zai.apiKey;return{zai:{configured:!0,hint:t.length>12?`${t.slice(0,6)}…${t.slice(-6)}`:`${t.slice(0,6)}…`}}},"validateAndSnapshotZaiKey",0,ss,"writeZaiKey",0,function(e){if(!(e=e.trim()))return void si();let t=sr();t.zai={...t.zai??{},apiKey:e};let n=sa();(0,tx.mkdirSync)((0,tS.dirname)(n),{recursive:!0});let s=`${n}.tmp`;(0,tx.writeFileSync)(s,JSON.stringify(t,null,2),{encoding:"utf8"}),(0,tx.chmodSync)(s,384),(0,tx.renameSync)(s,n)}],54832),e.s([],82111)}];
400
+ `,st=e=>tG({...e,systemPrompt:se});async function sn(e,t={}){let n={session_id:e.session_id,date:e.date,project:e.project,project_display:e.project_display,start_iso:e.start_iso,wall_min:e.wall_min,active_min:e.active_min,idle_min:e.idle_min,turn_count:e.turn_count,outcome:e.outcome??null,shipped_prs:e.shipped_prs,working_shape:e.working_shape,day_signature:e.day_signature,user_authored_skills:e.user_authored_skills,user_authored_subagents:e.user_authored_subagents,stock_skills:e.stock_skills,top_tools:e.top_tools,steering:e.steering,timeline:{duration_min:e.wall_min,active_intervals:e.active_intervals},session_summary:null,steering_summary:null,why_picked:null,what_worked:null,what_hit_friction:null,pins:[]};if(0===e.candidate_pins.length)return{topSession:n,usage:null};let s=t.model??"sonnet",r=t.callLLM??st,a=function(e){let t=[],n=(e="")=>t.push(e);n(`# Session ${e.session_id}`),n(`Project: ${e.project_display} \xb7 Date: ${e.date} \xb7 Started: ${e.start_iso}`),n(`Wall: ${e.wall_min}m \xb7 Active: ${e.active_min}m \xb7 Idle: ${e.idle_min}m \xb7 Turns: ${e.turn_count}`);let s=[];if(e.outcome&&s.push(`Outcome: ${e.outcome}`),e.working_shape&&s.push(`Working shape: ${e.working_shape}`),s.length&&n(s.join(" · ")),e.day_signature&&n(`Day signature: "${e.day_signature}"`),e.shipped_prs.length)for(let t of(n(`Shipped PRs (${e.shipped_prs.length}):`),e.shipped_prs))n(` - "${t}"`);if(n(),n("## Harness"),n(`- User-authored skills: ${e.user_authored_skills.length?e.user_authored_skills.join(", "):"(none)"}`),e.user_authored_subagents.length){let t=e.user_authored_subagents.map(e=>`${e.type}\xd7${e.count}`).join(", ");n(`- User-authored subagents: ${t}`)}n(`- Stock skills loaded: ${e.stock_skills.length?e.stock_skills.join(", "):"(none)"}`),n(`- Top tools: ${e.top_tools.length?e.top_tools.join(", "):"(none)"}`),n();let r=e.steering;for(let t of(n("## Steering"),n(`${r.user_msg_count} user messages (median ${r.median_user_msg_chars} chars, ${r.long_user_msg_count} long, ${r.interrupts} interrupts)`),n(),n(`## Turns (${e.turns.length})`),e.turns)){n();let e=t.idle_before_min>0?` \xb7 ${t.idle_before_min}m idle before`:"";if(n(`### Turn ${t.turn} — ${t.start_min}m–${t.end_min}m (${t.wall_min}m wall, ${t.active_min}m active${e})`),t.user&&n(`USER (${t.user.chars}c): ${t.user.preview}`),t.first_agent&&n(`FIRST_AGENT (${t.first_agent.chars}c): ${t.first_agent.preview}`),t.last_agent&&n(`LAST_AGENT (${t.last_agent.chars}c): ${t.last_agent.preview}`),!t.agent||t.first_agent||t.last_agent||n(`AGENT (${t.agent.chars}c): ${t.agent.preview}`),t.tools.length&&n(`Tools: ${t.tools.join(", ")}`),t.skills_loaded?.length&&n(`Skills loaded this turn: ${t.skills_loaded.join(", ")}`),t.subagents_dispatched?.length)for(let e of t.subagents_dispatched)n(`Subagent dispatched: ${e.type} — ${e.description}`),e.prompt_preview&&n(` prompt: ${e.prompt_preview}`);let s=[];t.exit_plan_calls&&s.push(`exit_plan\xd7${t.exit_plan_calls}`),t.todo_ops&&s.push(`TodoWrite ops: ${t.todo_ops}`),t.interrupts&&s.push(`interrupts: ${t.interrupts}`),t.pr_created&&s.push(`PR created: "${t.pr_created}"`),t.long_autonomous_run&&s.push("LONG-AUTONOMOUS RUN"),s.length&&n(`Signals: ${s.join(" · ")}`)}if(n(),n('## Candidate pins (deterministic — pick + label the most editorial 3-6 of these for your "pins" output)'),0===e.candidate_pins.length)n("(none — sparse session)");else for(let t of e.candidate_pins){let e=void 0!==t.end_min?`${t.start_min}m–${t.end_min}m`:`${t.start_min}m`,s=[];for(let[e,n]of Object.entries(t.context??{}))null!=n&&("string"==typeof n?s.push(`${e}="${n.length>200?n.slice(0,197)+"...":n}"`):Array.isArray(n)?s.push(`${e}=[${n.length} items]`):"object"==typeof n?s.push(`${e}={...}`):s.push(`${e}=${n}`));n(`- [${e}] ${t.kind}${s.length?` — ${s.join(", ")}`:""}`)}return t.join("\n")}(e),i=0,o=0;function l(e){let t=e.pins.map(e=>({start_min:e.start_min,end_min:e.end_min,kind:e.kind,label:e.label}));return{...n,session_summary:e.session_summary,steering_summary:e.steering_summary,why_picked:e.why_picked,what_worked:e.what_worked,what_hit_friction:e.what_hit_friction,pins:t}}try{let u,d,c=await r({model:s,userPrompt:a,onProgress:t.onProgress});i+=c.input_tokens,o+=c.output_tokens,c.model;let p=(u=c.content,tX(u,n6));if(p.ok)return{topSession:l(p.value),usage:{input_tokens:i,output_tokens:o}};let h=await r({model:s,userPrompt:a,reminder:"Your previous response was not valid JSON or did not match the required schema. Return ONLY the JSON object with session_summary + steering_summary + pins (3-5 items, each with start_min/kind/label) — no prose, no code fence.",onProgress:t.onProgress});i+=h.input_tokens,o+=h.output_tokens,h.model;let m=(d=h.content,tX(d,n6));if(m.ok)return{topSession:l(m.value),usage:{input_tokens:i,output_tokens:o}};return console.warn(`[top-session] ${e.session_id}: LLM validation failed after retry (${m.error})`),{topSession:n,usage:{input_tokens:i,output_tokens:o}}}catch(t){return console.warn(`[top-session] ${e.session_id}: LLM invocation failed (${t.message})`),{topSession:n,usage:i>0?{input_tokens:i,output_tokens:o}:null}}finally{}}async function*ss(e,t){let n=t.now??(()=>Date.now()),s=e===t.currentWeekMonday,r=t.settings.enabled;if(!s&&!t.force){let t=(0,nk.readWeekDigest)(e);if(t)return void(yield{type:"digest",digest:t})}if(s&&!t.force){let t=(0,nk.getCurrentWeekDigestFromCache)(e,n());if(t)return void(yield{type:"digest",digest:t})}yield{type:"status",phase:"load_dependencies",text:`Loading 7 days for week of ${e}`};let a=nI(e),i=[];for(let e of a){if(e>t.todayLocalDay){yield{type:"dependency",kind:"day",key:e,status:"cached"};continue}let n=e===t.todayLocalDay,s=n?null:(0,nk.readDayDigest)(e);if(s){i.push(s),yield{type:"dependency",kind:"day",key:e,status:"cached"};continue}if(n){let n={settings:t.settings,force:t.force??!1,callLLM:t.callLLM,now:t.now,todayLocalDay:t.todayLocalDay,caller:t.caller},s=null,r=!1;for await(let t of nT(e,n))if("digest"===t.type&&"day"===t.digest.scope&&(s=t.digest),"error"===t.type){r=!0;break}s?(i.push(s),yield{type:"dependency",kind:"day",key:e,status:"cached"}):r&&(yield{type:"dependency",kind:"day",key:e,status:"failed"});continue}let r={settings:t.settings,force:!1,callLLM:t.callLLM,now:t.now,todayLocalDay:t.todayLocalDay,caller:t.caller},a=null,o=!1;for await(let t of nT(e,r)){if("digest"===t.type){"day"===t.digest.scope&&(a=t.digest);continue}if("saved"!==t.type){if("error"===t.type){o=!0;continue}yield t}}a?(i.push(a),yield{type:"dependency",kind:"day",key:e,status:"generated"}):o&&(yield{type:"dependency",kind:"day",key:e,status:"failed"})}if(0===i.length)return void(yield{type:"error",message:`no day digests available for week of ${e}`});let o=new Map;for(let e of a)e>t.todayLocalDay||o.set(e,(0,t7.listEntriesForDay)(e));r&&ns();try{let a,l=new Map(i.map(e=>[e.key,e])),d=r?function(e){let t=[];for(let n of e.values())t.push(...n);let n=e=>e.numbers.active_min*(1+.5*e.numbers.subagent_calls+5*e.pr_titles.length),s=t.filter(e=>e.numbers.active_min>=20||e.numbers.turn_count>=10||e.pr_titles.length>=1).map(e=>({entry:e,score:n(e)})).sort((e,t)=>t.score-e.score),r=new Set,a=[];for(let{entry:e}of s)if(!r.has(e.project)&&(r.add(e.project),a.push(e),a.length>=3))break;let i=t.some(e=>(e.agent??"claude-code")!=="claude-code"),o=a.some(e=>(e.agent??"claude-code")!=="claude-code");if(i&&!o){let e=t.filter(e=>(e.agent??"claude-code")!=="claude-code").filter(e=>e.numbers.active_min>=3||e.numbers.tools_total>=10||e.numbers.turn_count>=3).map(e=>({entry:e,score:n(e)+1e-4*e.numbers.tools_total})).sort((e,t)=>t.score-e.score).find(e=>!r.has(e.entry.project));e&&(a.length>=3&&a.pop(),a.push(e.entry))}return a}(o):[],c=(await Promise.all(d.map(async e=>{try{let t=await (0,tT.getAnySession)(e.session_id);if(!t)return null;let n=t.events,s=l.get(e.local_day);return{entry:e,slice:function(e,t,n){var s;let r,a=Date.parse(e.start_iso),{turns:i,sliceStartMs:o,sliceEndMs:l}=function(e,t,n){let s=[];for(let r of e){if(!r.timestamp)continue;let e=Date.parse(r.timestamp);!Number.isNaN(e)&&(e<t||e>n||s.push({...r,_ts:e}))}if(0===s.length)return{turns:[],sliceStartMs:t,sliceEndMs:n};s.sort((e,t)=>e._ts-t._ts);let r=s[0]._ts,a=s[s.length-1]._ts,i=[],o=null;for(let e of s){let t=e.blocks??[],n="user"===e.role||"tool-result"===e.role,s="agent"===e.role||"agent-thinking"===e.role||"tool-call"===e.role;if(n)if(t.length>0&&t.every(e=>"tool_result"===e.type))o&&(o.events.push(e),o.timestamps.push(e._ts));else{let n=t.filter(e=>"text"===e.type).map(e=>e.text).join(" "),s=n3.test(n);o&&s&&(o.interrupts+=1),o&&i.push(o),o={events:[e],user_text:n,agent_blocks:[],tools_count:new Map,bash_verbs:new Map,skills:new Map,subagents:[],exit_plan_calls:0,todo_ops:0,interrupts:0,pr_created:null,timestamps:[e._ts]}}else if(s){if(!o)continue;for(let n of(o.events.push(e),o.timestamps.push(e._ts),t))if(n&&"object"==typeof n){if("text"===n.type&&n.text)o.agent_blocks.push(n.text);else if("tool_use"===n.type){let e=n.name??"unknown";if(o.tools_count.set(e,(o.tools_count.get(e)??0)+1),"Skill"===e){let e=String(n.input?.skill??"unknown");o.skills.set(e,(o.skills.get(e)??0)+1)}else if("Agent"===e){let e=n.input??{};o.subagents.push({type:String(e.subagent_type??"general-purpose"),description:String(e.description??"").slice(0,80),prompt_preview:String(e.prompt??"").slice(0,240),background:!!e.run_in_background})}else if("ExitPlanMode"===e)o.exit_plan_calls+=1;else if("TodoWrite"===e||"TaskCreate"===e||"TaskUpdate"===e)o.todo_ops+=1;else if("Bash"===e){let e=String(n.input?.command??""),t=function(e){if(!e)return"?";let t=e.split(/\|\||&&|;|\|/,1)[0].trim();if(t.startsWith("cd ")){let n=e.split(/&&|;/,3);n.length>=2&&(t=n[1].trim())}let n=t.split(/\s+/).filter(Boolean);for(;n.length&&n5.has(n[0]);)n.shift();if(!n.length)return"?";let s=n[0];if(s.includes("=")&&!s.startsWith("/")){if(n.shift(),!n.length)return"?";s=n[0]}return s.includes("/")&&!s.startsWith("./")&&(s=s.replace(/\/+$/,"").split("/").pop()),s.replace(/^["']|["']$/g,"")||"?"}(e);if(o.bash_verbs.set(t,(o.bash_verbs.get(t)??0)+1),/\bgh\s+pr\s+create\b/.test(e)){let t=e.match(n8);o.pr_created=t?.[1]??e.slice(0,120)}}}}}}return o&&i.push(o),{turns:i,sliceStartMs:r,sliceEndMs:a}}(t,a,Date.parse(e.end_iso)),d=i.flatMap(e=>e.timestamps),c=l-o,p=n9(d),h=[...d].sort((e,t)=>e-t),m=[];if(h.length>0){let e=h[0],t=h[0];for(let n=1;n<h.length;n++)h[n]-t>=18e4&&(m.push({start_min:n2(e-o),end_min:n2(t-o)}),e=h[n]),t=h[n];m.push({start_min:n2(e-o),end_min:n2(t-o)})}let _=[],f=o,g=[],y=0;i.forEach((e,t)=>{let n=Math.min(...e.timestamps),s=Math.max(...e.timestamps),r=n9(e.timestamps),a=0===t?0:Math.max(0,n-f);f=s,e.user_text&&(g.push(e.user_text.length),e.user_text.length>=800&&y++);let i=null,l=null;e.agent_blocks.length>0&&(i=e.agent_blocks[0],l=e.agent_blocks.reduce((e,t)=>t.length>e.length?t:e));let u=null!==i&&i===l,d=[];for(let[t,n]of[...e.tools_count.entries()].sort((e,t)=>t[1]-e[1]))if("Bash"===t&&e.bash_verbs.size>0){let t=[...e.bash_verbs.entries()].sort((e,t)=>t[1]-e[1]).slice(0,3).map(([e,t])=>t>1?`${e}\xd7${t}`:e).join(", ");d.push(`Bash\xd7${n} (${t})`)}else d.push(n>1?`${t}\xd7${n}`:t);let c={turn:t+1,start_min:n2(n-o),end_min:n2(s-o),wall_min:n2(s-n),active_min:n2(r),idle_before_min:n2(a),start_iso:new Date(n).toISOString(),user:e.user_text?n4(e.user_text,0===t?400:150):null,tools:d};u?c.agent=n4(i,200):(c.first_agent=i?n4(i,150):null,c.last_agent=l?n4(l,200):null),e.skills.size>0&&(c.skills_loaded=[...e.skills.entries()].map(([e,t])=>t>1?`${e}\xd7${t}`:e)),e.subagents.length>0&&(c.subagents_dispatched=e.subagents.map(e=>({type:e.type,description:e.description,prompt_preview:e.prompt_preview}))),e.exit_plan_calls>0&&(c.exit_plan_calls=e.exit_plan_calls),e.todo_ops>0&&(c.todo_ops=e.todo_ops),e.interrupts>0&&(c.interrupts=e.interrupts),e.pr_created&&(c.pr_created=e.pr_created),r>=12e5&&0===e.interrupts&&(c.long_autonomous_run=!0),_.push(c)});let v=new Map,w=new Map,k=new Map,b=new Map,x=0;for(let e of i){for(let[t,n]of e.skills)v.set(t,(v.get(t)??0)+n);for(let t of e.subagents)(0,u.isStockSubagentType)(t.type)||w.set(t.type,(w.get(t.type)??0)+1);for(let[t,n]of e.tools_count)k.set(t,(k.get(t)??0)+n);for(let[t,n]of e.bash_verbs)b.set(t,(b.get(t)??0)+n);x+=e.interrupts}let S=[],$=[];for(let e of v.keys()){let t=(0,u.classifySkill)(e);"user"===t?S.push(e):"stock"===t&&$.push(e)}let T=[];for(let[e,t]of[...k.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5))if("Bash"===e&&b.size>0){let e=[...b.entries()].sort((e,t)=>t[1]-e[1]).slice(0,3).map(([e,t])=>t>1?`${e}\xd7${t}`:e).join(", ");T.push(`Bash\xd7${t} (${e})`)}else T.push(`${e}\xd7${t}`);g.sort((e,t)=>e-t);let N=0===g.length?0:g[Math.floor(g.length/2)],j=[];for(let e of _)e.user?.chars&&e.user.chars>=800&&j.push({start_min:e.start_min,kind:"user-steering",context:{chars:e.user.chars,turn:e.turn,format:e.user.chars>=5e3?"long-paste":"long-prose"}}),e.subagents_dispatched&&e.subagents_dispatched.length>=3&&j.push({start_min:e.start_min,kind:"subagent-burst",context:{count:e.subagents_dispatched.length,types:e.subagents_dispatched.map(e=>e.type),turn:e.turn}}),e.long_autonomous_run&&j.push({start_min:e.start_min,end_min:e.end_min,kind:"long-autonomous",context:{duration_min:e.active_min,turn:e.turn}}),e.exit_plan_calls&&e.exit_plan_calls>0&&j.push({start_min:e.start_min,kind:"plan-mode",context:{turn:e.turn}}),e.pr_created&&j.push({start_min:e.start_min,kind:"pr-ship",context:{pr_title:e.pr_created,turn:e.turn}}),e.skills_loaded&&e.skills_loaded.length>=2&&j.push({start_min:e.start_min,kind:"harness-chain",context:{skills:e.skills_loaded,turn:e.turn}}),e.interrupts&&e.interrupts>0&&j.push({start_min:e.start_min,kind:"interrupt",context:{count:e.interrupts,turn:e.turn}});return{session_id:e.session_id,date:e.local_day,project:e.project,project_display:(r=(s=e.project).split("/").filter(Boolean))[r.length-1]??s,start_iso:new Date(o).toISOString(),wall_min:n2(c),active_min:n2(p),idle_min:n2(c-p),turn_count:_.length,outcome:e.enrichment.outcome,shipped_prs:e.pr_titles,working_shape:e.signals?.working_shape??(0,u.inferWorkingShape)(e),day_signature:n,user_authored_skills:S,user_authored_subagents:[...w.entries()].sort((e,t)=>t[1]-e[1]).map(([e,t])=>({type:e,count:t})),stock_skills:$,top_tools:T,steering:{user_msg_count:g.length,long_user_msg_count:y,median_user_msg_chars:N,interrupts:x},active_intervals:m,turns:_,candidate_pins:j}}(e,n,s?.day_signature??null)}}catch(t){return console.warn(`[top-session] slice prep failed for ${e.session_id}: ${t.message}`),null}}))).filter(e=>null!==e);if(r){yield{type:"status",phase:"synth",text:c.length>0?`Synthesizing week narrative + diving into ${c.length} top session${1===c.length?"":"s"} in parallel`:"Synthesizing week narrative"};let n=[],r=nB(e,i,{model:t.settings.model,callLLM:t.callLLM,entriesByDay:o,allowSingleDay:!0===t.force&&s,onProgress:e=>{n.push({bytes:e.bytes,elapsed_ms:e.elapsedMs})}}),l=Promise.all(c.map(({entry:e,slice:n})=>sn(n,{model:t.settings.model,callLLM:t.callLLM}).then(t=>({entry:e,...t})).catch(t=>(console.warn(`[top-session] LLM failed for ${e.session_id}: ${t.message}`),null)))),u=!1,d=!1;for(r.finally(()=>{u=!0}),l.finally(()=>{d=!0});!u||!d;)if(await new Promise(e=>setTimeout(e,500)),n.length>0){let e=n[n.length-1];yield{type:"progress",phase:"synth",bytes:e.bytes,elapsed_ms:e.elapsed_ms},n.length=0}let p=await r,h=await l;a=p.digest,p.usage&&t3({ts:new Date().toISOString(),caller:t.caller??"web",model:a.model??t.settings.model,input_tokens:p.usage.input_tokens,output_tokens:p.usage.output_tokens,cost_usd:a.cost_usd??0,kind:"week_digest",ref:e});let m=[];for(let n of h)n&&(m.push({...n.topSession,agent:n.entry.agent}),n.usage&&t3({ts:new Date().toISOString(),caller:t.caller??"web",model:t.settings.model,input_tokens:n.usage.input_tokens,output_tokens:n.usage.output_tokens,cost_usd:tQ(t.settings.model,n.usage.input_tokens,n.usage.output_tokens),kind:"top_session",ref:`${e}/${n.entry.session_id}`}));a.headline&&m.length>0&&(a.top_sessions=m)}else a=nF(e,i,{entriesByDay:o});s?(a.is_live=!0,(0,nk.setCurrentWeekDigestInCache)(e,a,n()),!0===t.force&&((0,nk.writeWeekDigest)(a),yield{type:"saved",path:`~/.cclens/digests/week/${e}.json`})):((0,nk.writeWeekDigest)(a),yield{type:"saved",path:`~/.cclens/digests/week/${e}.json`}),yield{type:"digest",digest:a}}finally{r&&nr()}}async function*sr(e,t){let n=t.now??(()=>Date.now()),s=e===t.currentYearMonth,r=t.settings.enabled;if(!s&&!t.force){let t=(0,nk.readMonthDigest)(e);if(t)return void(yield{type:"digest",digest:t})}if(s&&!t.force){let t=(0,nk.getCurrentMonthDigestFromCache)(e,n());if(t)return void(yield{type:"digest",digest:t})}yield{type:"status",phase:"load_dependencies",text:`Loading weeks for ${e}`};let a=nG(e),i=[];for(let e of a){if(e>t.currentWeekMonday){yield{type:"dependency",kind:"week",key:e,status:"cached"};continue}let n=e===t.currentWeekMonday,s=n?null:(0,nk.readWeekDigest)(e);if(s){i.push(s),yield{type:"dependency",kind:"week",key:e,status:"cached"};continue}if(n){let n={settings:t.settings,force:!1,callLLM:t.callLLM,now:t.now,currentWeekMonday:t.currentWeekMonday,todayLocalDay:t.todayLocalDay,caller:t.caller},s=null,r=!1;for await(let t of ss(e,n))if("digest"===t.type&&"week"===t.digest.scope&&(s=t.digest),"error"===t.type){r=!0;break}s?(i.push(s),yield{type:"dependency",kind:"week",key:e,status:"cached"}):r&&(yield{type:"dependency",kind:"week",key:e,status:"failed"});continue}let r={settings:t.settings,force:!1,callLLM:t.callLLM,now:t.now,currentWeekMonday:t.currentWeekMonday,todayLocalDay:t.todayLocalDay,caller:t.caller},a=null,o=!1;for await(let t of ss(e,r)){if("digest"===t.type){"week"===t.digest.scope&&(a=t.digest);continue}if("saved"!==t.type){if("error"===t.type){o=!0;continue}yield t}}a?(i.push(a),yield{type:"dependency",kind:"week",key:e,status:"generated"}):o&&(yield{type:"dependency",kind:"week",key:e,status:"failed"})}if(0===i.length)return void(yield{type:"error",message:`no week digests available for ${e}`});r&&ns();try{let a;if(r){yield{type:"status",phase:"synth",text:"Synthesizing month narrative"};let n=[],s=n1(e,i,{model:t.settings.model,callLLM:t.callLLM,onProgress:e=>{n.push({bytes:e.bytes,elapsed_ms:e.elapsedMs})}}),r=!1;for(s.finally(()=>{r=!0});!r;)if(await new Promise(e=>setTimeout(e,500)),n.length>0){let e=n[n.length-1];yield{type:"progress",phase:"synth",bytes:e.bytes,elapsed_ms:e.elapsed_ms},n.length=0}let o=await s;a=o.digest,o.usage&&t3({ts:new Date().toISOString(),caller:t.caller??"web",model:a.model??t.settings.model,input_tokens:o.usage.input_tokens,output_tokens:o.usage.output_tokens,cost_usd:a.cost_usd??0,kind:"month_digest",ref:e})}else a=nQ(e,i);s?(a.is_live=!0,(0,nk.setCurrentMonthDigestInCache)(e,a,n()),!0===t.force&&((0,nk.writeMonthDigest)(a),yield{type:"saved",path:`~/.cclens/digests/month/${e}.json`})):((0,nk.writeMonthDigest)(a),yield{type:"saved",path:`~/.cclens/digests/month/${e}.json`}),yield{type:"digest",digest:a}}finally{r&&nr()}}async function sa(e){let t=e.trim();if(!t)throw Error("empty key");let n=await fetch("https://api.z.ai/api/monitor/usage/quota/limit",{headers:{Authorization:t,"Accept-Language":"en-US,en"}});if(!n.ok)throw Error(`Z.ai rejected the key (${n.status} ${n.statusText})`);let s=await n.json().catch(()=>{throw Error("Z.ai returned an unparseable response")});if(void 0!==s.code&&200!==s.code)throw Error(`Z.ai rejected the key (code ${s.code})`);if(!1===s.success)throw Error("Z.ai rejected the key");let r=s.data?.limits??[],a=null,i=null,o=null;for(let e of r){let t=e.type;if("TIME_LIMIT"===t){let t="number"==typeof e.percentage?e.percentage:null;o={used:t,limit:null!==t?100:null};continue}if("TOKENS_LIMIT"!==t)continue;let n=e.unit,s={utilization:"number"==typeof e.percentage?e.percentage:null,resets_at:"number"==typeof e.nextResetTime?new Date(e.nextResetTime).toISOString():null};6===n?i=i??s:a=a??s}return{captured_at:new Date().toISOString(),agent:"zai",five_hour:a??{utilization:null,resets_at:null},seven_day:i??{utilization:null,resets_at:null},seven_day_opus:null,seven_day_sonnet:null,seven_day_oauth_apps:null,seven_day_cowork:null,extra_usage:null,plan_type:s.data?.level??null,web_search_quota:o??null}}async function si(e){let t=await sa(e);return(0,tT.appendUsageSnapshot)(t),t}function so(){return(0,tT.cclensPath)("credentials.json")}function sl(){let e=so();if(!(0,tx.existsSync)(e))return{};try{let t=(0,tx.readFileSync)(e,"utf8");return JSON.parse(t)}catch{return{}}}function su(){let e=sl();delete e.zai;let t=so();if(0===Object.keys(e).length){try{(0,tx.unlinkSync)(t)}catch{}return}let n=`${t}.tmp`;(0,tx.writeFileSync)(n,JSON.stringify(e,null,2),{encoding:"utf8"}),(0,tx.chmodSync)(n,384),(0,tx.renameSync)(n,t)}e.s(["mondayFor",0,function(e){let t=new Date(`${e}T00:00:00`),n=t.getDay();t.setDate(t.getDate()+(0===n?-6:1-n));let s=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),a=String(t.getDate()).padStart(2,"0");return`${s}-${r}-${a}`},"runWeekDigestPipeline",0,ss],77242),e.s(["runMonthDigestPipeline",0,sr],21628),e.s(["deleteZaiKeyAndPrune",0,function(){su(),(0,tT.pruneUsageAgent)("zai")},"readCredentialsMasked",0,function(){let e=sl();if(!e.zai?.apiKey)return{};let t=e.zai.apiKey;return{zai:{configured:!0,hint:t.length>12?`${t.slice(0,6)}…${t.slice(-6)}`:`${t.slice(0,6)}…`}}},"validateAndSnapshotZaiKey",0,si,"writeZaiKey",0,function(e){if(!(e=e.trim()))return void su();let t=sl();t.zai={...t.zai??{},apiKey:e};let n=so();(0,tx.mkdirSync)((0,tS.dirname)(n),{recursive:!0});let s=`${n}.tmp`;(0,tx.writeFileSync)(s,JSON.stringify(t,null,2),{encoding:"utf8"}),(0,tx.chmodSync)(s,384),(0,tx.renameSync)(s,n)}],54832),e.s([],82111)}];
401
401
 
402
402
  //# sourceMappingURL=packages_entries_dist_node_0bckr7-.js.map