fleetlens 0.7.1 → 0.10.0

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 (130) 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.js.nft.json +1 -1
  12. package/app/apps/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  13. package/app/apps/web/.next/server/app/api/ask/route.js +1 -1
  14. package/app/apps/web/.next/server/app/api/ask/route.js.nft.json +1 -1
  15. package/app/apps/web/.next/server/app/api/digest/day/[date]/route.js +3 -3
  16. package/app/apps/web/.next/server/app/api/digest/day/[date]/route.js.nft.json +1 -1
  17. package/app/apps/web/.next/server/app/api/digest/month/[yearMonth]/route.js +3 -3
  18. package/app/apps/web/.next/server/app/api/digest/month/[yearMonth]/route.js.nft.json +1 -1
  19. package/app/apps/web/.next/server/app/api/digest/month-index/route.js +2 -2
  20. package/app/apps/web/.next/server/app/api/digest/month-index/route.js.nft.json +1 -1
  21. package/app/apps/web/.next/server/app/api/digest/week/[startDate]/route.js +3 -3
  22. package/app/apps/web/.next/server/app/api/digest/week/[startDate]/route.js.nft.json +1 -1
  23. package/app/apps/web/.next/server/app/api/digest/week-index/route.js +2 -2
  24. package/app/apps/web/.next/server/app/api/digest/week-index/route.js.nft.json +1 -1
  25. package/app/apps/web/.next/server/app/api/events/route.js +1 -1
  26. package/app/apps/web/.next/server/app/api/events/route.js.nft.json +1 -1
  27. package/app/apps/web/.next/server/app/api/jobs/route.js.nft.json +1 -1
  28. package/app/apps/web/.next/server/app/api/runs/[runId]/route.js.nft.json +1 -1
  29. package/app/apps/web/.next/server/app/api/runs/[runId]/stream/route.js.nft.json +1 -1
  30. package/app/apps/web/.next/server/app/api/settings/route.js +4 -4
  31. package/app/apps/web/.next/server/app/api/settings/route.js.nft.json +1 -1
  32. package/app/apps/web/.next/server/app/changelog/page.js.nft.json +1 -1
  33. package/app/apps/web/.next/server/app/changelog/page_client-reference-manifest.js +1 -1
  34. package/app/apps/web/.next/server/app/day/[date]/page.js.nft.json +1 -1
  35. package/app/apps/web/.next/server/app/day/[date]/page_client-reference-manifest.js +1 -1
  36. package/app/apps/web/.next/server/app/day/page.js.nft.json +1 -1
  37. package/app/apps/web/.next/server/app/day/page_client-reference-manifest.js +1 -1
  38. package/app/apps/web/.next/server/app/digest/[date]/page.js.nft.json +1 -1
  39. package/app/apps/web/.next/server/app/digest/[date]/page_client-reference-manifest.js +1 -1
  40. package/app/apps/web/.next/server/app/digest/page.js.nft.json +1 -1
  41. package/app/apps/web/.next/server/app/digest/page_client-reference-manifest.js +1 -1
  42. package/app/apps/web/.next/server/app/insights/[key]/page.js.nft.json +1 -1
  43. package/app/apps/web/.next/server/app/insights/[key]/page_client-reference-manifest.js +1 -1
  44. package/app/apps/web/.next/server/app/insights/page.js.nft.json +1 -1
  45. package/app/apps/web/.next/server/app/insights/page_client-reference-manifest.js +1 -1
  46. package/app/apps/web/.next/server/app/page.js.nft.json +1 -1
  47. package/app/apps/web/.next/server/app/page_client-reference-manifest.js +1 -1
  48. package/app/apps/web/.next/server/app/parallelism/page.js.nft.json +1 -1
  49. package/app/apps/web/.next/server/app/parallelism/page_client-reference-manifest.js +1 -1
  50. package/app/apps/web/.next/server/app/projects/[slug]/page.js.nft.json +1 -1
  51. package/app/apps/web/.next/server/app/projects/[slug]/page_client-reference-manifest.js +1 -1
  52. package/app/apps/web/.next/server/app/projects/page.js.nft.json +1 -1
  53. package/app/apps/web/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  54. package/app/apps/web/.next/server/app/runs/page.js.nft.json +1 -1
  55. package/app/apps/web/.next/server/app/runs/page_client-reference-manifest.js +1 -1
  56. package/app/apps/web/.next/server/app/sessions/[id]/page.js.nft.json +1 -1
  57. package/app/apps/web/.next/server/app/sessions/[id]/page_client-reference-manifest.js +1 -1
  58. package/app/apps/web/.next/server/app/sessions/page.js.nft.json +1 -1
  59. package/app/apps/web/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
  60. package/app/apps/web/.next/server/app/settings/page.js.nft.json +1 -1
  61. package/app/apps/web/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  62. package/app/apps/web/.next/server/app/usage/page.js.nft.json +1 -1
  63. package/app/apps/web/.next/server/app/usage/page_client-reference-manifest.js +1 -1
  64. package/app/apps/web/.next/server/chunks/[root-of-the-server]__07qxzx4._.js +9 -0
  65. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0fu2xfy._.js +5 -0
  66. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0gfd42k._.js +9 -0
  67. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0i.m8y0._.js +3 -0
  68. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0iy5aqy._.js +9 -0
  69. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0nh7-nf._.js +3 -0
  70. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0nvdffv._.js +3 -0
  71. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0s2~c3g._.js +3 -0
  72. package/app/apps/web/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_0ck.78s.js +3 -3
  73. package/app/apps/web/.next/server/chunks/packages_09wmnv.._.js +3 -0
  74. package/app/apps/web/.next/server/chunks/packages_0o6.gpk._.js +3 -0
  75. package/app/apps/web/.next/server/chunks/packages_entries_dist_node_0bckr7-.js +13 -13
  76. package/app/apps/web/.next/server/chunks/packages_parser_dist_fs_122oe0-.js +1 -1
  77. package/app/apps/web/.next/server/chunks/ssr/[root-of-the-server]__0d~2~le._.js +1 -1
  78. package/app/apps/web/.next/server/chunks/ssr/[root-of-the-server]__0r4tks8._.js +1 -1
  79. package/app/apps/web/.next/server/chunks/ssr/[root-of-the-server]__0s4dg1y._.js +3 -0
  80. package/app/apps/web/.next/server/chunks/ssr/[root-of-the-server]__0tejjy_._.js +1 -1
  81. package/app/apps/web/.next/server/chunks/ssr/[root-of-the-server]__0w52fbc._.js +3 -3
  82. package/app/apps/web/.next/server/chunks/ssr/_0jw2sm7._.js +1 -1
  83. package/app/apps/web/.next/server/chunks/ssr/_0xu2pvc._.js +1 -1
  84. package/app/apps/web/.next/server/chunks/ssr/apps_web_components_0ly1xes._.js +1 -1
  85. package/app/apps/web/.next/server/chunks/ssr/apps_web_components_0txtsv5._.js +1 -1
  86. package/app/apps/web/.next/server/chunks/ssr/apps_web_components_usage-charts-dashboard_tsx_0bgr_uv._.js +1 -1
  87. package/app/apps/web/.next/server/chunks/ssr/apps_web_lib_0m67-xi._.js +1 -1
  88. package/app/apps/web/.next/server/chunks/ssr/packages_entries_dist_node_0_271yr.js +1 -1
  89. package/app/apps/web/.next/server/chunks/ssr/packages_parser_dist_10_oegc._.js +1 -1
  90. package/app/apps/web/.next/server/middleware-build-manifest.js +3 -3
  91. package/app/apps/web/.next/server/pages/500.html +1 -1
  92. package/app/apps/web/.next/server/server-reference-manifest.js +1 -1
  93. package/app/apps/web/.next/server/server-reference-manifest.json +1 -1
  94. package/app/apps/web/.next/static/chunks/04a36uhu~p_z-.css +1 -0
  95. package/app/apps/web/.next/static/chunks/{0q2vd~aj.1hpz.js → 09--oejbzw3q-.js} +3 -3
  96. package/app/apps/web/.next/static/chunks/0l3ck.awv~4t7.js +1 -0
  97. package/app/apps/web/.next/static/chunks/{171za22fv684..js → 0lxuac2v0_gdl.js} +2 -2
  98. package/app/apps/web/.next/static/chunks/0n0n.0279ot6c.js +1 -0
  99. package/app/apps/web/.next/static/chunks/0qcu452dr~edz.js +14 -0
  100. package/app/apps/web/.next/static/chunks/0uev~g~qvbjv9.js +4 -0
  101. package/app/apps/web/components/previous-cycles-trend.tsx +26 -11
  102. package/app/apps/web/components/usage-chart.tsx +35 -37
  103. package/app/apps/web/components/usage-gauges.tsx +18 -12
  104. package/app/apps/web/components/usage-sidebar.tsx +23 -12
  105. package/app/apps/web/lib/changelog-data.generated.ts +1 -1
  106. package/app/apps/web/lib/utilization-tone.ts +74 -0
  107. package/app/apps/web/package.json +1 -1
  108. package/app/apps/web/tsconfig.tsbuildinfo +1 -1
  109. package/dist/daemon-worker.js +694 -67
  110. package/dist/index.js +1449 -823
  111. package/package.json +1 -1
  112. package/app/apps/web/.next/server/chunks/[externals]__0fpbr8-._.js +0 -3
  113. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0-vgrh1._.js +0 -3
  114. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0.z48ue._.js +0 -3
  115. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0_8zh-i._.js +0 -9
  116. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0dctov1._.js +0 -5
  117. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0e8n_x4._.js +0 -3
  118. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0ej_p3s._.js +0 -9
  119. package/app/apps/web/.next/server/chunks/[root-of-the-server]__0jprdks._.js +0 -9
  120. package/app/apps/web/.next/server/chunks/packages_09hmrqx._.js +0 -3
  121. package/app/apps/web/.next/server/chunks/packages_118y1lp._.js +0 -3
  122. package/app/apps/web/.next/server/chunks/ssr/[root-of-the-server]__0ytdqxt._.js +0 -3
  123. package/app/apps/web/.next/static/chunks/05m.oz3kmf1p7.js +0 -1
  124. package/app/apps/web/.next/static/chunks/07-fq4im3pmjp.js +0 -4
  125. package/app/apps/web/.next/static/chunks/0o9ayt8sknubd.js +0 -1
  126. package/app/apps/web/.next/static/chunks/0wfbj5zr~az.z.css +0 -1
  127. package/app/apps/web/.next/static/chunks/179_t_igg8ghh.js +0 -14
  128. /package/app/apps/web/.next/static/{tiK9aMHXkgnKLNmxj9J1P → L0Dy1hOQrZjV9l0TNulvk}/_buildManifest.js +0 -0
  129. /package/app/apps/web/.next/static/{tiK9aMHXkgnKLNmxj9J1P → L0Dy1hOQrZjV9l0TNulvk}/_clientMiddlewareManifest.js +0 -0
  130. /package/app/apps/web/.next/static/{tiK9aMHXkgnKLNmxj9J1P → L0Dy1hOQrZjV9l0TNulvk}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- module.exports=[82111,78325,56614,20441,77242,21628,e=>{"use strict";let t,s=/^<teammate-message\b/,n=/^Base directory for this skill:/,a=/^<command-name>|^<local-command-stdout>/;function r(e){let t=`${e.description} ${e.prompt_preview}`.toLowerCase();return/\b(re-?review|review[s]?|verify|audit|spec[- ]review|code[- ]quality|code[- ]reuse|efficiency review|sanity check|quick test)\b/.test(t)?"reviewer":/\b(implement|build chunk|build task|initialize|create the|add the)\b/.test(t)?"implementer":/\bexplore\b|\binventory\b|\bmap\b.*\b(codebase|repo|branch)\b|\baudit\b.*coverage/.test(t)?"explorer":/\b(investigate|research|reverse[- ]engineer|study|analy[sz]e|look up|tell me|brief me on|find out)\b/.test(t)?"researcher":/\b(env(?:ironment)? setup|configure|setup|bootstrap)\b/.test(t)?"env-setup":/\b(polish|cleanup|fix|refactor)\b/.test(t)?"polish":"other"}let i=/^(general-purpose|Explore|Plan|claude-code-guide|playwright-qa-verifier|statusline-setup|frontend-design:|code-review:|code-simplifier:|codex:|superpowers:)/;function o(e){if(e.numbers.turn_count<2)return null;let t=e.subagents??[],s=t.map(r),n=s.filter(e=>"reviewer"===e).length,a=s.filter(e=>"implementer"===e).length,i=s.filter(e=>"explorer"===e||"researcher"===e).length,o=t.some(e=>e.background);if(a>=2&&t.filter(e=>/\b(chunk|task)\s*\d+/i.test(`${e.description} ${e.prompt_preview}`)).length>=2)return"chunk-implementation";if(n>=3&&0===a){let e=new Set;for(let n=0;n<t.length;n++){if("reviewer"!==s[n])continue;let a=t[n].description.toLowerCase().replace(/[^a-z0-9 ]/g,"").split(/\s+/).filter(e=>e.length>2).slice(0,3).join("|");e.add(a)}if(e.size>=3)return"reviewer-triad"}if(n>=2)return"spec-review-loop";if(i>=2||i>=1&&a>=1)return"research-then-build";if(o&&t.length>=1)return"background-coordinated";if(0===t.length){let t=(e.first_user||"").trim().toLowerCase();if(/^continue\b/.test(t)||"continue."===t)return"solo-continuation";if(Object.keys(e.skills??{}).some(e=>/brainstorm|writing-plans|brainstorming/i.test(e)))return"solo-design"}return"solo-build"}function l(e){if(!e)return[];let t=[];return/<teammate-message\b/i.test(e)&&t.push("teammate"),/<task-notification\b/i.test(e)&&t.push("task-notification"),/<local-command-caveat\b/i.test(e)&&t.push("local-command-caveat"),/<command-(message|name)\b/i.test(e)&&t.push("slash-command"),/\[Image #\d+\]/.test(e)&&t.push("image-attached"),(/\b(here'?s the (handoff|handover) prompt|session-close summary|wrap-up summary|all wrapped up|all captured\.)\b/i.test(e)||/^##? (Wrap-up|Session conclusion|Handoff)\b/m.test(e)||/^# Handoff:/m.test(e))&&t.push("handoff-prose"),t}let d=/^(superpowers|mcp__|frontend-design|code-review|codex|claude-code-guide|claude-api):/i;function u(e){return e.startsWith("(ToolSearch:")?"infra":d.test(e)||"using-superpowers"===e?"stock":"user"}let c=[{kind:"linear-kip",re:/\bKIP-\d+\b/i},{kind:"github-issue-pr",re:/\b(issue|pr|pull request)\s*#\d+\b|github\.com\/[^\s]+\/(issues|pull)\/\d+/i},{kind:"branch-ref",re:/\b(branch|feat|fix|chore|refactor)[/:]\s*[\w./-]+|on `[\w./-]+`/i},{kind:"url",re:/https?:\/\/\S+/}];e.s([],54033),e.i(54033),(tf=tk||(tk={})).assertEqual=e=>{},tf.assertIs=function(e){},tf.assertNever=function(e){throw Error()},tf.arrayToEnum=e=>{let t={};for(let s of e)t[s]=s;return t},tf.getValidEnumValues=e=>{let t=tf.objectKeys(e).filter(t=>"number"!=typeof e[e[t]]),s={};for(let n of t)s[n]=e[n];return tf.objectValues(s)},tf.objectValues=e=>tf.objectKeys(e).map(function(t){return e[t]}),tf.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{let t=[];for(let s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.push(s);return t},tf.find=(e,t)=>{for(let s of e)if(t(s))return s},tf.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,tf.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},tf.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(tw||(tw={})).mergeShapes=(e,t)=>({...e,...t});let p=tk.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),h=e=>{switch(typeof e){case"undefined":return p.undefined;case"string":return p.string;case"number":return Number.isNaN(e)?p.nan:p.number;case"boolean":return p.boolean;case"function":return p.function;case"bigint":return p.bigint;case"symbol":return p.symbol;case"object":if(Array.isArray(e))return p.array;if(null===e)return p.null;if(e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch)return p.promise;if("u">typeof Map&&e instanceof Map)return p.map;if("u">typeof Set&&e instanceof Set)return p.set;if("u">typeof Date&&e instanceof Date)return p.date;return p.object;default:return p.unknown}};e.s(["ZodParsedType",0,p,"getParsedType",0,h,"objectUtil",0,tw,"util",0,tk],42944);let m=tk.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"]),_=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class g 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},s={_errors:[]},n=e=>{for(let a of e.issues)if("invalid_union"===a.code)a.unionErrors.map(n);else if("invalid_return_type"===a.code)n(a.returnTypeError);else if("invalid_arguments"===a.code)n(a.argumentsError);else if(0===a.path.length)s._errors.push(t(a));else{let e=s,n=0;for(;n<a.path.length;){let s=a.path[n];n===a.path.length-1?(e[s]=e[s]||{_errors:[]},e[s]._errors.push(t(a))):e[s]=e[s]||{_errors:[]},e=e[s],n++}}};return n(this),s}static assert(e){if(!(e instanceof g))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,tk.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){let t={},s=[];for(let n of this.issues)if(n.path.length>0){let s=n.path[0];t[s]=t[s]||[],t[s].push(e(n))}else s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}g.create=e=>new g(e),e.s(["ZodError",0,g,"ZodIssueCode",0,m,"quotelessJson",0,_],15235);let f=(e,t)=>{let s;switch(e.code){case m.invalid_type:s=e.received===p.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case m.invalid_literal:s=`Invalid literal value, expected ${JSON.stringify(e.expected,tk.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:s=`Unrecognized key(s) in object: ${tk.joinValues(e.keys,", ")}`;break;case m.invalid_union:s="Invalid input";break;case m.invalid_union_discriminator:s=`Invalid discriminator value. Expected ${tk.joinValues(e.options)}`;break;case m.invalid_enum_value:s=`Invalid enum value. Expected ${tk.joinValues(e.options)}, received '${e.received}'`;break;case m.invalid_arguments:s="Invalid function arguments";break;case m.invalid_return_type:s="Invalid function return type";break;case m.invalid_date:s="Invalid date";break;case m.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(s=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(s=`${s} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?s=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?s=`Invalid input: must end with "${e.validation.endsWith}"`:tk.assertNever(e.validation):s="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case m.too_small:s="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 m.too_big:s="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 m.custom:s="Invalid input";break;case m.invalid_intersection_types:s="Intersection results could not be merged";break;case m.not_multiple_of:s=`Number must be a multiple of ${e.multipleOf}`;break;case m.not_finite:s="Number must be finite";break;default:s=t.defaultError,tk.assertNever(e)}return{message:s}},y=f;function v(e){y=e}function k(){return y}e.s(["getErrorMap",0,k,"setErrorMap",0,v],85676),e.i(85676),e.s(["defaultErrorMap",0,f,"getErrorMap",0,k,"setErrorMap",0,v],76733),e.i(76733);let w=e=>{let{data:t,path:s,errorMaps:n,issueData:a}=e,r=[...s,...a.path||[]],i={...a,path:r};if(void 0!==a.message)return{...a,path:r,message:a.message};let o="";for(let e of n.filter(e=>!!e).slice().reverse())o=e(i,{data:t,defaultError:o}).message;return{...a,path:r,message:o}},b=[];function x(e,t){let s=k(),n=w({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,s,s===f?void 0:f].filter(e=>!!e)});e.common.issues.push(n)}class S{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){let s=[];for(let n of t){if("aborted"===n.status)return $;"dirty"===n.status&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){let s=[];for(let e of t){let t=await e.key,n=await e.value;s.push({key:t,value:n})}return S.mergeObjectSync(e,s)}static mergeObjectSync(e,t){let s={};for(let n of t){let{key:t,value:a}=n;if("aborted"===t.status||"aborted"===a.status)return $;"dirty"===t.status&&e.dirty(),"dirty"===a.status&&e.dirty(),"__proto__"!==t.value&&(void 0!==a.value||n.alwaysSet)&&(s[t.value]=a.value)}return{status:e.value,value:s}}}let $=Object.freeze({status:"aborted"}),T=e=>({status:"dirty",value:e}),N=e=>({status:"valid",value:e}),j=e=>"aborted"===e.status,O=e=>"dirty"===e.status,M=e=>"valid"===e.status,A=e=>"u">typeof Promise&&e instanceof Promise;e.s(["DIRTY",0,T,"EMPTY_PATH",0,b,"INVALID",0,$,"OK",0,N,"ParseStatus",0,S,"addIssueToContext",0,x,"isAborted",0,j,"isAsync",0,A,"isDirty",0,O,"isValid",0,M,"makeIssue",0,w],84488),e.i(84488),e.s([],91316),e.i(91316),e.i(42944),(ty=tb||(tb={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},ty.toString=e=>"string"==typeof e?e:e?.message;class E{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}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 Z=(e,t)=>{if(M(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 g(e.common.issues);return this._error=t,this._error}}};function C(e){if(!e)return{};let{errorMap:t,invalid_type_error:s,required_error:n,description:a}=e;if(t&&(s||n))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??n??a.defaultError}:"invalid_type"!==t.code?{message:a.defaultError}:{message:r??s??a.defaultError}},description:a}}class I{get description(){return this._def.description}_getType(e){return h(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:h(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new S,ctx:{common:e.parent.common,data:e.data,parsedType:h(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(A(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){return Promise.resolve(this._parse(e))}parse(e,t){let s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){let s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:h(e)},n=this._parseSync({data:e,path:s.path,parent:s});return Z(s,n)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:h(e)};if(!this["~standard"].async)try{let s=this._parseSync({data:e,path:[],parent:t});return M(s)?{value:s.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=>M(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){let s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:h(e)},n=this._parse({data:e,path:s.path,parent:s});return Z(s,await (A(n)?n:Promise.resolve(n)))}refine(e,t){return this._refinement((s,n)=>{let a=e(s),r=()=>n.addIssue({code:m.custom,..."string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(s):t});return"u">typeof Promise&&a instanceof Promise?a.then(e=>!!e||(r(),!1)):!!a||(r(),!1)})}refinement(e,t){return this._refinement((s,n)=>!!e(s)||(n.addIssue("function"==typeof t?t(s,n):t),!1))}_refinement(e){return new eO({schema:this,typeName:tx.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 eM.create(this,this._def)}nullable(){return eA.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ep.create(this)}promise(){return ej.create(this,this._def)}or(e){return em.create([this,e],this._def)}and(e){return ef.create(this,e,this._def)}transform(e){return new eO({...C(this._def),schema:this,typeName:tx.ZodEffects,effect:{type:"transform",transform:e}})}default(e){return new eE({...C(this._def),innerType:this,defaultValue:"function"==typeof e?e:()=>e,typeName:tx.ZodDefault})}brand(){return new eD({typeName:tx.ZodBranded,type:this,...C(this._def)})}catch(e){return new eZ({...C(this._def),innerType:this,catchValue:"function"==typeof e?e:()=>e,typeName:tx.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return eP.create(this,e)}readonly(){return eL.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}let D=/^c[^\s-]{8,}$/i,P=/^[0-9a-z]+$/,L=/^[0-9A-HJKMNP-TV-Z]{26}$/i,R=/^[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,U=/^[a-z0-9_-]{21}$/i,Y=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,F=/^[-+]?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)?)??$/,W=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,z=/^(?:(?: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])$/,B=/^(?:(?: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])$/,V=/^(([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]))$/,H=/^(([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}=))?$/,q=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,K="((\\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])))",G=RegExp(`^${K}$`);function X(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);let s=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${s}`}function Q(e){let t=`${K}T${X(e)}`,s=[];return s.push(e.local?"Z?":"Z"),e.offset&&s.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${s.join("|")})`,RegExp(`^${t}$`)}class ee extends I{_parse(e){var s,n,a,r;let i;if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){let t=this._getOrReturnCtx(e);return x(t,{code:m.invalid_type,expected:p.string,received:t.parsedType}),$}let o=new S;for(let l of this._def.checks)if("min"===l.kind)e.data.length<l.value&&(x(i=this._getOrReturnCtx(e,i),{code:m.too_small,minimum:l.value,type:"string",inclusive:!0,exact:!1,message:l.message}),o.dirty());else if("max"===l.kind)e.data.length>l.value&&(x(i=this._getOrReturnCtx(e,i),{code:m.too_big,maximum:l.value,type:"string",inclusive:!0,exact:!1,message:l.message}),o.dirty());else if("length"===l.kind){let t=e.data.length>l.value,s=e.data.length<l.value;(t||s)&&(i=this._getOrReturnCtx(e,i),t?x(i,{code:m.too_big,maximum:l.value,type:"string",inclusive:!0,exact:!0,message:l.message}):s&&x(i,{code:m.too_small,minimum:l.value,type:"string",inclusive:!0,exact:!0,message:l.message}),o.dirty())}else if("email"===l.kind)W.test(e.data)||(x(i=this._getOrReturnCtx(e,i),{validation:"email",code:m.invalid_string,message:l.message}),o.dirty());else if("emoji"===l.kind)t||(t=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),t.test(e.data)||(x(i=this._getOrReturnCtx(e,i),{validation:"emoji",code:m.invalid_string,message:l.message}),o.dirty());else if("uuid"===l.kind)R.test(e.data)||(x(i=this._getOrReturnCtx(e,i),{validation:"uuid",code:m.invalid_string,message:l.message}),o.dirty());else if("nanoid"===l.kind)U.test(e.data)||(x(i=this._getOrReturnCtx(e,i),{validation:"nanoid",code:m.invalid_string,message:l.message}),o.dirty());else if("cuid"===l.kind)D.test(e.data)||(x(i=this._getOrReturnCtx(e,i),{validation:"cuid",code:m.invalid_string,message:l.message}),o.dirty());else if("cuid2"===l.kind)P.test(e.data)||(x(i=this._getOrReturnCtx(e,i),{validation:"cuid2",code:m.invalid_string,message:l.message}),o.dirty());else if("ulid"===l.kind)L.test(e.data)||(x(i=this._getOrReturnCtx(e,i),{validation:"ulid",code:m.invalid_string,message:l.message}),o.dirty());else if("url"===l.kind)try{new URL(e.data)}catch{x(i=this._getOrReturnCtx(e,i),{validation:"url",code:m.invalid_string,message:l.message}),o.dirty()}else"regex"===l.kind?(l.regex.lastIndex=0,l.regex.test(e.data)||(x(i=this._getOrReturnCtx(e,i),{validation:"regex",code:m.invalid_string,message:l.message}),o.dirty())):"trim"===l.kind?e.data=e.data.trim():"includes"===l.kind?e.data.includes(l.value,l.position)||(x(i=this._getOrReturnCtx(e,i),{code:m.invalid_string,validation:{includes:l.value,position:l.position},message:l.message}),o.dirty()):"toLowerCase"===l.kind?e.data=e.data.toLowerCase():"toUpperCase"===l.kind?e.data=e.data.toUpperCase():"startsWith"===l.kind?e.data.startsWith(l.value)||(x(i=this._getOrReturnCtx(e,i),{code:m.invalid_string,validation:{startsWith:l.value},message:l.message}),o.dirty()):"endsWith"===l.kind?e.data.endsWith(l.value)||(x(i=this._getOrReturnCtx(e,i),{code:m.invalid_string,validation:{endsWith:l.value},message:l.message}),o.dirty()):"datetime"===l.kind?Q(l).test(e.data)||(x(i=this._getOrReturnCtx(e,i),{code:m.invalid_string,validation:"datetime",message:l.message}),o.dirty()):"date"===l.kind?G.test(e.data)||(x(i=this._getOrReturnCtx(e,i),{code:m.invalid_string,validation:"date",message:l.message}),o.dirty()):"time"===l.kind?RegExp(`^${X(l)}$`).test(e.data)||(x(i=this._getOrReturnCtx(e,i),{code:m.invalid_string,validation:"time",message:l.message}),o.dirty()):"duration"===l.kind?F.test(e.data)||(x(i=this._getOrReturnCtx(e,i),{validation:"duration",code:m.invalid_string,message:l.message}),o.dirty()):"ip"===l.kind?(s=e.data,!(("v4"===(n=l.version)||!n)&&z.test(s)||("v6"===n||!n)&&V.test(s))&&1&&(x(i=this._getOrReturnCtx(e,i),{validation:"ip",code:m.invalid_string,message:l.message}),o.dirty())):"jwt"===l.kind?!function(e,t){if(!Y.test(e))return!1;try{let[s]=e.split(".");if(!s)return!1;let n=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(s.length+(4-s.length%4)%4,"="),a=JSON.parse(atob(n));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,l.alg)&&(x(i=this._getOrReturnCtx(e,i),{validation:"jwt",code:m.invalid_string,message:l.message}),o.dirty()):"cidr"===l.kind?(a=e.data,!(("v4"===(r=l.version)||!r)&&B.test(a)||("v6"===r||!r)&&H.test(a))&&1&&(x(i=this._getOrReturnCtx(e,i),{validation:"cidr",code:m.invalid_string,message:l.message}),o.dirty())):"base64"===l.kind?J.test(e.data)||(x(i=this._getOrReturnCtx(e,i),{validation:"base64",code:m.invalid_string,message:l.message}),o.dirty()):"base64url"===l.kind?q.test(e.data)||(x(i=this._getOrReturnCtx(e,i),{validation:"base64url",code:m.invalid_string,message:l.message}),o.dirty()):tk.assertNever(l);return{status:o.value,value:e.data}}_regex(e,t,s){return this.refinement(t=>e.test(t),{validation:t,code:m.invalid_string,...tb.errToObj(s)})}_addCheck(e){return new ee({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...tb.errToObj(e)})}url(e){return this._addCheck({kind:"url",...tb.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...tb.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...tb.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...tb.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...tb.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...tb.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...tb.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...tb.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...tb.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...tb.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...tb.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...tb.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,...tb.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,...tb.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...tb.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...tb.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...tb.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...tb.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...tb.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...tb.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...tb.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...tb.errToObj(t)})}nonempty(e){return this.min(1,tb.errToObj(e))}trim(){return new ee({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ee({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ee({...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}}ee.create=e=>new ee({checks:[],typeName:tx.ZodString,coerce:e?.coerce??!1,...C(e)});class et extends I{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)!==p.number){let t=this._getOrReturnCtx(e);return x(t,{code:m.invalid_type,expected:p.number,received:t.parsedType}),$}let s=new S;for(let n of this._def.checks)"int"===n.kind?tk.isInteger(e.data)||(x(t=this._getOrReturnCtx(e,t),{code:m.invalid_type,expected:"integer",received:"float",message:n.message}),s.dirty()):"min"===n.kind?(n.inclusive?e.data<n.value:e.data<=n.value)&&(x(t=this._getOrReturnCtx(e,t),{code:m.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):"max"===n.kind?(n.inclusive?e.data>n.value:e.data>=n.value)&&(x(t=this._getOrReturnCtx(e,t),{code:m.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):"multipleOf"===n.kind?0!==function(e,t){let s=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,a=s>n?s:n;return Number.parseInt(e.toFixed(a).replace(".",""))%Number.parseInt(t.toFixed(a).replace(".",""))/10**a}(e.data,n.value)&&(x(t=this._getOrReturnCtx(e,t),{code:m.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):"finite"===n.kind?Number.isFinite(e.data)||(x(t=this._getOrReturnCtx(e,t),{code:m.not_finite,message:n.message}),s.dirty()):tk.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,tb.toString(t))}gt(e,t){return this.setLimit("min",e,!1,tb.toString(t))}lte(e,t){return this.setLimit("max",e,!0,tb.toString(t))}lt(e,t){return this.setLimit("max",e,!1,tb.toString(t))}setLimit(e,t,s,n){return new et({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:tb.toString(n)}]})}_addCheck(e){return new et({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:tb.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:tb.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:tb.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:tb.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:tb.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:tb.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:tb.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:tb.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:tb.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&&tk.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let s of this._def.checks)if("finite"===s.kind||"int"===s.kind||"multipleOf"===s.kind)return!0;else"min"===s.kind?(null===t||s.value>t)&&(t=s.value):"max"===s.kind&&(null===e||s.value<e)&&(e=s.value);return Number.isFinite(t)&&Number.isFinite(e)}}et.create=e=>new et({checks:[],typeName:tx.ZodNumber,coerce:e?.coerce||!1,...C(e)});class es extends I{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)!==p.bigint)return this._getInvalidInput(e);let s=new S;for(let n of this._def.checks)"min"===n.kind?(n.inclusive?e.data<n.value:e.data<=n.value)&&(x(t=this._getOrReturnCtx(e,t),{code:m.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):"max"===n.kind?(n.inclusive?e.data>n.value:e.data>=n.value)&&(x(t=this._getOrReturnCtx(e,t),{code:m.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):"multipleOf"===n.kind?e.data%n.value!==BigInt(0)&&(x(t=this._getOrReturnCtx(e,t),{code:m.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):tk.assertNever(n);return{status:s.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return x(t,{code:m.invalid_type,expected:p.bigint,received:t.parsedType}),$}gte(e,t){return this.setLimit("min",e,!0,tb.toString(t))}gt(e,t){return this.setLimit("min",e,!1,tb.toString(t))}lte(e,t){return this.setLimit("max",e,!0,tb.toString(t))}lt(e,t){return this.setLimit("max",e,!1,tb.toString(t))}setLimit(e,t,s,n){return new es({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:tb.toString(n)}]})}_addCheck(e){return new es({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:tb.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:tb.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:tb.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:tb.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:tb.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}}es.create=e=>new es({checks:[],typeName:tx.ZodBigInt,coerce:e?.coerce??!1,...C(e)});class en extends I{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){let t=this._getOrReturnCtx(e);return x(t,{code:m.invalid_type,expected:p.boolean,received:t.parsedType}),$}return N(e.data)}}en.create=e=>new en({typeName:tx.ZodBoolean,coerce:e?.coerce||!1,...C(e)});class ea extends I{_parse(e){let t;if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==p.date){let t=this._getOrReturnCtx(e);return x(t,{code:m.invalid_type,expected:p.date,received:t.parsedType}),$}if(Number.isNaN(e.data.getTime()))return x(this._getOrReturnCtx(e),{code:m.invalid_date}),$;let s=new S;for(let n of this._def.checks)"min"===n.kind?e.data.getTime()<n.value&&(x(t=this._getOrReturnCtx(e,t),{code:m.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),s.dirty()):"max"===n.kind?e.data.getTime()>n.value&&(x(t=this._getOrReturnCtx(e,t),{code:m.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),s.dirty()):tk.assertNever(n);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ea({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:tb.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:tb.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}}ea.create=e=>new ea({checks:[],coerce:e?.coerce||!1,typeName:tx.ZodDate,...C(e)});class er extends I{_parse(e){if(this._getType(e)!==p.symbol){let t=this._getOrReturnCtx(e);return x(t,{code:m.invalid_type,expected:p.symbol,received:t.parsedType}),$}return N(e.data)}}er.create=e=>new er({typeName:tx.ZodSymbol,...C(e)});class ei extends I{_parse(e){if(this._getType(e)!==p.undefined){let t=this._getOrReturnCtx(e);return x(t,{code:m.invalid_type,expected:p.undefined,received:t.parsedType}),$}return N(e.data)}}ei.create=e=>new ei({typeName:tx.ZodUndefined,...C(e)});class eo extends I{_parse(e){if(this._getType(e)!==p.null){let t=this._getOrReturnCtx(e);return x(t,{code:m.invalid_type,expected:p.null,received:t.parsedType}),$}return N(e.data)}}eo.create=e=>new eo({typeName:tx.ZodNull,...C(e)});class el extends I{constructor(){super(...arguments),this._any=!0}_parse(e){return N(e.data)}}el.create=e=>new el({typeName:tx.ZodAny,...C(e)});class ed extends I{constructor(){super(...arguments),this._unknown=!0}_parse(e){return N(e.data)}}ed.create=e=>new ed({typeName:tx.ZodUnknown,...C(e)});class eu extends I{_parse(e){let t=this._getOrReturnCtx(e);return x(t,{code:m.invalid_type,expected:p.never,received:t.parsedType}),$}}eu.create=e=>new eu({typeName:tx.ZodNever,...C(e)});class ec extends I{_parse(e){if(this._getType(e)!==p.undefined){let t=this._getOrReturnCtx(e);return x(t,{code:m.invalid_type,expected:p.void,received:t.parsedType}),$}return N(e.data)}}ec.create=e=>new ec({typeName:tx.ZodVoid,...C(e)});class ep extends I{_parse(e){let{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==p.array)return x(t,{code:m.invalid_type,expected:p.array,received:t.parsedType}),$;if(null!==n.exactLength){let e=t.data.length>n.exactLength.value,a=t.data.length<n.exactLength.value;(e||a)&&(x(t,{code:e?m.too_big:m.too_small,minimum:a?n.exactLength.value:void 0,maximum:e?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(null!==n.minLength&&t.data.length<n.minLength.value&&(x(t,{code:m.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),null!==n.maxLength&&t.data.length>n.maxLength.value&&(x(t,{code:m.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((e,s)=>n.type._parseAsync(new E(t,e,t.path,s)))).then(e=>S.mergeArray(s,e));let a=[...t.data].map((e,s)=>n.type._parseSync(new E(t,e,t.path,s)));return S.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new ep({...this._def,minLength:{value:e,message:tb.toString(t)}})}max(e,t){return new ep({...this._def,maxLength:{value:e,message:tb.toString(t)}})}length(e,t){return new ep({...this._def,exactLength:{value:e,message:tb.toString(t)}})}nonempty(e){return this.min(1,e)}}ep.create=(e,t)=>new ep({type:e,minLength:null,maxLength:null,exactLength:null,typeName:tx.ZodArray,...C(t)});class eh extends I{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=tk.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==p.object){let t=this._getOrReturnCtx(e);return x(t,{code:m.invalid_type,expected:p.object,received:t.parsedType}),$}let{status:t,ctx:s}=this._processInputParams(e),{shape:n,keys:a}=this._getCached(),r=[];if(!(this._def.catchall instanceof eu&&"strip"===this._def.unknownKeys))for(let e in s.data)a.includes(e)||r.push(e);let i=[];for(let e of a){let t=n[e],a=s.data[e];i.push({key:{status:"valid",value:e},value:t._parse(new E(s,a,s.path,e)),alwaysSet:e in s.data})}if(this._def.catchall instanceof eu){let e=this._def.unknownKeys;if("passthrough"===e)for(let e of r)i.push({key:{status:"valid",value:e},value:{status:"valid",value:s.data[e]}});else if("strict"===e)r.length>0&&(x(s,{code:m.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 n=s.data[t];i.push({key:{status:"valid",value:t},value:e._parse(new E(s,n,s.path,t)),alwaysSet:t in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of i){let s=await t.key,n=await t.value;e.push({key:s,value:n,alwaysSet:t.alwaysSet})}return e}).then(e=>S.mergeObjectSync(t,e)):S.mergeObjectSync(t,i)}get shape(){return this._def.shape()}strict(e){return tb.errToObj,new eh({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,s)=>{let n=this._def.errorMap?.(t,s).message??s.defaultError;return"unrecognized_keys"===t.code?{message:tb.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new eh({...this._def,unknownKeys:"strip"})}passthrough(){return new eh({...this._def,unknownKeys:"passthrough"})}extend(e){return new eh({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new eh({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:tx.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new eh({...this._def,catchall:e})}pick(e){let t={};for(let s of tk.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new eh({...this._def,shape:()=>t})}omit(e){let t={};for(let s of tk.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new eh({...this._def,shape:()=>t})}deepPartial(){return function e(t){if(t instanceof eh){let s={};for(let n in t.shape){let a=t.shape[n];s[n]=eM.create(e(a))}return new eh({...t._def,shape:()=>s})}if(t instanceof ep)return new ep({...t._def,type:e(t.element)});if(t instanceof eM)return eM.create(e(t.unwrap()));if(t instanceof eA)return eA.create(e(t.unwrap()));if(t instanceof ey)return ey.create(t.items.map(t=>e(t)));else return t}(this)}partial(e){let t={};for(let s of tk.objectKeys(this.shape)){let n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}return new eh({...this._def,shape:()=>t})}required(e){let t={};for(let s of tk.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let e=this.shape[s];for(;e instanceof eM;)e=e._def.innerType;t[s]=e}return new eh({...this._def,shape:()=>t})}keyof(){return e$(tk.objectKeys(this.shape))}}eh.create=(e,t)=>new eh({shape:()=>e,unknownKeys:"strip",catchall:eu.create(),typeName:tx.ZodObject,...C(t)}),eh.strictCreate=(e,t)=>new eh({shape:()=>e,unknownKeys:"strict",catchall:eu.create(),typeName:tx.ZodObject,...C(t)}),eh.lazycreate=(e,t)=>new eh({shape:e,unknownKeys:"strip",catchall:eu.create(),typeName:tx.ZodObject,...C(t)});class em extends I{_parse(e){let{ctx:t}=this._processInputParams(e),s=this._def.options;if(t.common.async)return Promise.all(s.map(async e=>{let s={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:s}),ctx:s}})).then(function(e){for(let t of e)if("valid"===t.result.status)return t.result;for(let s of e)if("dirty"===s.result.status)return t.common.issues.push(...s.ctx.common.issues),s.result;let s=e.map(e=>new g(e.ctx.common.issues));return x(t,{code:m.invalid_union,unionErrors:s}),$});{let e,n=[];for(let a of s){let s={...t,common:{...t.common,issues:[]},parent:null},r=a._parseSync({data:t.data,path:t.path,parent:s});if("valid"===r.status)return r;"dirty"!==r.status||e||(e={result:r,ctx:s}),s.common.issues.length&&n.push(s.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let a=n.map(e=>new g(e));return x(t,{code:m.invalid_union,unionErrors:a}),$}}get options(){return this._def.options}}em.create=(e,t)=>new em({options:e,typeName:tx.ZodUnion,...C(t)});let e_=e=>{if(e instanceof ex)return e_(e.schema);if(e instanceof eO)return e_(e.innerType());if(e instanceof eS)return[e.value];if(e instanceof eT)return e.options;if(e instanceof eN)return tk.objectValues(e.enum);else if(e instanceof eE)return e_(e._def.innerType);else if(e instanceof ei)return[void 0];else if(e instanceof eo)return[null];else if(e instanceof eM)return[void 0,...e_(e.unwrap())];else if(e instanceof eA)return[null,...e_(e.unwrap())];else if(e instanceof eD)return e_(e.unwrap());else if(e instanceof eL)return e_(e.unwrap());else if(e instanceof eZ)return e_(e._def.innerType);else return[]};class eg extends I{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.object)return x(t,{code:m.invalid_type,expected:p.object,received:t.parsedType}),$;let s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);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}):(x(t,{code:m.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),$)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){let n=new Map;for(let s of t){let t=e_(s.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(n.has(a))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);n.set(a,s)}}return new eg({typeName:tx.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...C(s)})}}class ef extends I{_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=(e,n)=>{if(j(e)||j(n))return $;let a=function e(t,s){let n=h(t),a=h(s);if(t===s)return{valid:!0,data:t};if(n===p.object&&a===p.object){let n=tk.objectKeys(s),a=tk.objectKeys(t).filter(e=>-1!==n.indexOf(e)),r={...t,...s};for(let n of a){let a=e(t[n],s[n]);if(!a.valid)return{valid:!1};r[n]=a.data}return{valid:!0,data:r}}if(n===p.array&&a===p.array){if(t.length!==s.length)return{valid:!1};let n=[];for(let a=0;a<t.length;a++){let r=e(t[a],s[a]);if(!r.valid)return{valid:!1};n.push(r.data)}return{valid:!0,data:n}}if(n===p.date&&a===p.date&&+t==+s)return{valid:!0,data:t};return{valid:!1}}(e.value,n.value);return a.valid?((O(e)||O(n))&&t.dirty(),{status:t.value,value:a.data}):(x(s,{code:m.invalid_intersection_types}),$)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([e,t])=>n(e,t)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}ef.create=(e,t,s)=>new ef({left:e,right:t,typeName:tx.ZodIntersection,...C(s)});class ey extends I{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.array)return x(s,{code:m.invalid_type,expected:p.array,received:s.parsedType}),$;if(s.data.length<this._def.items.length)return x(s,{code:m.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),$;!this._def.rest&&s.data.length>this._def.items.length&&(x(s,{code:m.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let n=[...s.data].map((e,t)=>{let n=this._def.items[t]||this._def.rest;return n?n._parse(new E(s,e,s.path,t)):null}).filter(e=>!!e);return s.common.async?Promise.all(n).then(e=>S.mergeArray(t,e)):S.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new ey({...this._def,rest:e})}}ey.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new ey({items:e,typeName:tx.ZodTuple,rest:null,...C(t)})};class ev extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.object)return x(s,{code:m.invalid_type,expected:p.object,received:s.parsedType}),$;let n=[],a=this._def.keyType,r=this._def.valueType;for(let e in s.data)n.push({key:a._parse(new E(s,e,s.path,e)),value:r._parse(new E(s,s.data[e],s.path,e)),alwaysSet:e in s.data});return s.common.async?S.mergeObjectAsync(t,n):S.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return new ev(t instanceof I?{keyType:e,valueType:t,typeName:tx.ZodRecord,...C(s)}:{keyType:ee.create(),valueType:e,typeName:tx.ZodRecord,...C(t)})}}class ek extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.map)return x(s,{code:m.invalid_type,expected:p.map,received:s.parsedType}),$;let n=this._def.keyType,a=this._def.valueType,r=[...s.data.entries()].map(([e,t],r)=>({key:n._parse(new E(s,e,s.path,[r,"key"])),value:a._parse(new E(s,t,s.path,[r,"value"]))}));if(s.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let s of r){let n=await s.key,a=await s.value;if("aborted"===n.status||"aborted"===a.status)return $;("dirty"===n.status||"dirty"===a.status)&&t.dirty(),e.set(n.value,a.value)}return{status:t.value,value:e}})}{let e=new Map;for(let s of r){let n=s.key,a=s.value;if("aborted"===n.status||"aborted"===a.status)return $;("dirty"===n.status||"dirty"===a.status)&&t.dirty(),e.set(n.value,a.value)}return{status:t.value,value:e}}}}ek.create=(e,t,s)=>new ek({valueType:t,keyType:e,typeName:tx.ZodMap,...C(s)});class ew extends I{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.set)return x(s,{code:m.invalid_type,expected:p.set,received:s.parsedType}),$;let n=this._def;null!==n.minSize&&s.data.size<n.minSize.value&&(x(s,{code:m.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),null!==n.maxSize&&s.data.size>n.maxSize.value&&(x(s,{code:m.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());let a=this._def.valueType;function r(e){let s=new Set;for(let n of e){if("aborted"===n.status)return $;"dirty"===n.status&&t.dirty(),s.add(n.value)}return{status:t.value,value:s}}let i=[...s.data.values()].map((e,t)=>a._parse(new E(s,e,s.path,t)));return s.common.async?Promise.all(i).then(e=>r(e)):r(i)}min(e,t){return new ew({...this._def,minSize:{value:e,message:tb.toString(t)}})}max(e,t){return new ew({...this._def,maxSize:{value:e,message:tb.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ew.create=(e,t)=>new ew({valueType:e,minSize:null,maxSize:null,typeName:tx.ZodSet,...C(t)});class eb extends I{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.function)return x(t,{code:m.invalid_type,expected:p.function,received:t.parsedType}),$;function s(e,s){return w({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,k(),f].filter(e=>!!e),issueData:{code:m.invalid_arguments,argumentsError:s}})}function n(e,s){return w({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,k(),f].filter(e=>!!e),issueData:{code:m.invalid_return_type,returnTypeError:s}})}let a={errorMap:t.common.contextualErrorMap},r=t.data;if(this._def.returns instanceof ej){let e=this;return N(async function(...t){let i=new g([]),o=await e._def.args.parseAsync(t,a).catch(e=>{throw i.addIssue(s(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(n(l,e)),i})})}{let e=this;return N(function(...t){let i=e._def.args.safeParse(t,a);if(!i.success)throw new g([s(t,i.error)]);let o=Reflect.apply(r,this,i.data),l=e._def.returns.safeParse(o,a);if(!l.success)throw new g([n(o,l.error)]);return l.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new eb({...this._def,args:ey.create(e).rest(ed.create())})}returns(e){return new eb({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new eb({args:e||ey.create([]).rest(ed.create()),returns:t||ed.create(),typeName:tx.ZodFunction,...C(s)})}}class ex extends I{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})}}ex.create=(e,t)=>new ex({getter:e,typeName:tx.ZodLazy,...C(t)});class eS extends I{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return x(t,{received:t.data,code:m.invalid_literal,expected:this._def.value}),$}return{status:"valid",value:e.data}}get value(){return this._def.value}}function e$(e,t){return new eT({values:e,typeName:tx.ZodEnum,...C(t)})}eS.create=(e,t)=>new eS({value:e,typeName:tx.ZodLiteral,...C(t)});class eT extends I{_parse(e){if("string"!=typeof e.data){let t=this._getOrReturnCtx(e),s=this._def.values;return x(t,{expected:tk.joinValues(s),received:t.parsedType,code:m.invalid_type}),$}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),s=this._def.values;return x(t,{received:t.data,code:m.invalid_enum_value,options:s}),$}return N(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 eT.create(e,{...this._def,...t})}exclude(e,t=this._def){return eT.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}eT.create=e$;class eN extends I{_parse(e){let t=tk.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==p.string&&s.parsedType!==p.number){let e=tk.objectValues(t);return x(s,{expected:tk.joinValues(e),received:s.parsedType,code:m.invalid_type}),$}if(this._cache||(this._cache=new Set(tk.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let e=tk.objectValues(t);return x(s,{received:s.data,code:m.invalid_enum_value,options:e}),$}return N(e.data)}get enum(){return this._def.values}}eN.create=(e,t)=>new eN({values:e,typeName:tx.ZodNativeEnum,...C(t)});class ej extends I{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==p.promise&&!1===t.common.async?(x(t,{code:m.invalid_type,expected:p.promise,received:t.parsedType}),$):N((t.parsedType===p.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ej.create=(e,t)=>new ej({type:e,typeName:tx.ZodPromise,...C(t)});class eO extends I{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===tx.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:e=>{x(s,e),e.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),"preprocess"===n.type){let e=n.transform(s.data,a);if(s.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return $;let n=await this._def.schema._parseAsync({data:e,path:s.path,parent:s});return"aborted"===n.status?$:"dirty"===n.status||"dirty"===t.value?T(n.value):n});{if("aborted"===t.value)return $;let n=this._def.schema._parseSync({data:e,path:s.path,parent:s});return"aborted"===n.status?$:"dirty"===n.status||"dirty"===t.value?T(n.value):n}}if("refinement"===n.type){let e=e=>{let t=n.refinement(e,a);if(s.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!==s.common.async)return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(s=>"aborted"===s.status?$:("dirty"===s.status&&t.dirty(),e(s.value).then(()=>({status:t.value,value:s.value}))));{let n=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return"aborted"===n.status?$:("dirty"===n.status&&t.dirty(),e(n.value),{status:t.value,value:n.value})}}if("transform"===n.type)if(!1!==s.common.async)return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(e=>M(e)?Promise.resolve(n.transform(e.value,a)).then(e=>({status:t.value,value:e})):$);else{let e=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!M(e))return $;let r=n.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}}tk.assertNever(n)}}eO.create=(e,t,s)=>new eO({schema:e,typeName:tx.ZodEffects,effect:t,...C(s)}),eO.createWithPreprocess=(e,t,s)=>new eO({schema:t,effect:{type:"preprocess",transform:e},typeName:tx.ZodEffects,...C(s)});class eM extends I{_parse(e){return this._getType(e)===p.undefined?N(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}eM.create=(e,t)=>new eM({innerType:e,typeName:tx.ZodOptional,...C(t)});class eA extends I{_parse(e){return this._getType(e)===p.null?N(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}eA.create=(e,t)=>new eA({innerType:e,typeName:tx.ZodNullable,...C(t)});class eE extends I{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return t.parsedType===p.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}eE.create=(e,t)=>new eE({innerType:e,typeName:tx.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...C(t)});class eZ extends I{_parse(e){let{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return A(n)?n.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new g(s.common.issues)},input:s.data})})):{status:"valid",value:"valid"===n.status?n.value:this._def.catchValue({get error(){return new g(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}eZ.create=(e,t)=>new eZ({innerType:e,typeName:tx.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...C(t)});class eC extends I{_parse(e){if(this._getType(e)!==p.nan){let t=this._getOrReturnCtx(e);return x(t,{code:m.invalid_type,expected:p.nan,received:t.parsedType}),$}return{status:"valid",value:e.data}}}eC.create=e=>new eC({typeName:tx.ZodNaN,...C(e)});let eI=Symbol("zod_brand");class eD extends I{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class eP extends I{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?$:"dirty"===e.status?(t.dirty(),T(e.value)):this._def.out._parseAsync({data:e.value,path:s.path,parent:s})})();{let e=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?$:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:s.path,parent:s})}}static create(e,t){return new eP({in:e,out:t,typeName:tx.ZodPipeline})}}class eL extends I{_parse(e){let t=this._def.innerType._parse(e),s=e=>(M(e)&&(e.value=Object.freeze(e.value)),e);return A(t)?t.then(e=>s(e)):s(t)}unwrap(){return this._def.innerType}}function eR(e,t){let s="function"==typeof e?e(t):"string"==typeof e?{message:e}:e;return"string"==typeof s?{message:s}:s}function eU(e,t={},s){return e?el.create().superRefine((n,a)=>{let r=e(n);if(r instanceof Promise)return r.then(e=>{if(!e){let e=eR(t,n),r=e.fatal??s??!0;a.addIssue({code:"custom",...e,fatal:r})}});if(!r){let e=eR(t,n),r=e.fatal??s??!0;a.addIssue({code:"custom",...e,fatal:r})}}):el.create()}eL.create=(e,t)=>new eL({innerType:e,typeName:tx.ZodReadonly,...C(t)});let eY={object:eh.lazycreate};(tv=tx||(tx={})).ZodString="ZodString",tv.ZodNumber="ZodNumber",tv.ZodNaN="ZodNaN",tv.ZodBigInt="ZodBigInt",tv.ZodBoolean="ZodBoolean",tv.ZodDate="ZodDate",tv.ZodSymbol="ZodSymbol",tv.ZodUndefined="ZodUndefined",tv.ZodNull="ZodNull",tv.ZodAny="ZodAny",tv.ZodUnknown="ZodUnknown",tv.ZodNever="ZodNever",tv.ZodVoid="ZodVoid",tv.ZodArray="ZodArray",tv.ZodObject="ZodObject",tv.ZodUnion="ZodUnion",tv.ZodDiscriminatedUnion="ZodDiscriminatedUnion",tv.ZodIntersection="ZodIntersection",tv.ZodTuple="ZodTuple",tv.ZodRecord="ZodRecord",tv.ZodMap="ZodMap",tv.ZodSet="ZodSet",tv.ZodFunction="ZodFunction",tv.ZodLazy="ZodLazy",tv.ZodLiteral="ZodLiteral",tv.ZodEnum="ZodEnum",tv.ZodEffects="ZodEffects",tv.ZodNativeEnum="ZodNativeEnum",tv.ZodOptional="ZodOptional",tv.ZodNullable="ZodNullable",tv.ZodDefault="ZodDefault",tv.ZodCatch="ZodCatch",tv.ZodPromise="ZodPromise",tv.ZodBranded="ZodBranded",tv.ZodPipeline="ZodPipeline",tv.ZodReadonly="ZodReadonly";let eF=(e,t={message:`Input not instance of ${e.name}`})=>eU(t=>t instanceof e,t),eW=ee.create,ez=et.create,eB=eC.create,eV=es.create,eH=en.create,eJ=ea.create,eq=er.create,eK=ei.create,eG=eo.create,eX=el.create,eQ=ed.create,e0=eu.create,e1=ec.create,e2=ep.create,e4=eh.create,e9=eh.strictCreate,e5=em.create,e3=eg.create,e7=ef.create,e6=ey.create,e8=ev.create,te=ek.create,tt=ew.create,ts=eb.create,tn=ex.create,ta=eS.create,tr=eT.create,ti=eN.create,to=ej.create,tl=eO.create,td=eM.create,tu=eA.create,tc=eO.createWithPreprocess,tp=eP.create,th=()=>eW().optional(),tm=()=>ez().optional(),t_=()=>eH().optional(),tg={string:e=>ee.create({...e,coerce:!0}),number:e=>et.create({...e,coerce:!0}),boolean:e=>en.create({...e,coerce:!0}),bigint:e=>es.create({...e,coerce:!0}),date:e=>ea.create({...e,coerce:!0})};e.s(["BRAND",0,eI,"NEVER",0,$,"Schema",0,I,"ZodAny",0,el,"ZodArray",0,ep,"ZodBigInt",0,es,"ZodBoolean",0,en,"ZodBranded",0,eD,"ZodCatch",0,eZ,"ZodDate",0,ea,"ZodDefault",0,eE,"ZodDiscriminatedUnion",0,eg,"ZodEffects",0,eO,"ZodEnum",0,eT,"ZodFirstPartyTypeKind",0,tx,"ZodFunction",0,eb,"ZodIntersection",0,ef,"ZodLazy",0,ex,"ZodLiteral",0,eS,"ZodMap",0,ek,"ZodNaN",0,eC,"ZodNativeEnum",0,eN,"ZodNever",0,eu,"ZodNull",0,eo,"ZodNullable",0,eA,"ZodNumber",0,et,"ZodObject",0,eh,"ZodOptional",0,eM,"ZodPipeline",0,eP,"ZodPromise",0,ej,"ZodReadonly",0,eL,"ZodRecord",0,ev,"ZodSchema",0,I,"ZodSet",0,ew,"ZodString",0,ee,"ZodSymbol",0,er,"ZodTransformer",0,eO,"ZodTuple",0,ey,"ZodType",0,I,"ZodUndefined",0,ei,"ZodUnion",0,em,"ZodUnknown",0,ed,"ZodVoid",0,ec,"any",0,eX,"array",0,e2,"bigint",0,eV,"boolean",0,eH,"coerce",0,tg,"custom",0,eU,"date",0,eJ,"datetimeRegex",0,Q,"discriminatedUnion",0,e3,"effect",0,tl,"enum",0,tr,"function",0,ts,"instanceof",0,eF,"intersection",0,e7,"late",0,eY,"lazy",0,tn,"literal",0,ta,"map",0,te,"nan",0,eB,"nativeEnum",0,ti,"never",0,e0,"null",0,eG,"nullable",0,tu,"number",0,ez,"object",0,e4,"oboolean",0,t_,"onumber",0,tm,"optional",0,td,"ostring",0,th,"pipeline",0,tp,"preprocess",0,tc,"promise",0,to,"record",0,e8,"set",0,tt,"strictObject",0,e9,"string",0,eW,"symbol",0,eq,"transformer",0,tl,"tuple",0,e6,"undefined",0,eK,"union",0,e5,"unknown",0,eQ,"void",0,e1],17958),e.i(17958),e.i(15235),e.s(["BRAND",0,eI,"DIRTY",0,T,"EMPTY_PATH",0,b,"INVALID",0,$,"NEVER",0,$,"OK",0,N,"ParseStatus",0,S,"Schema",0,I,"ZodAny",0,el,"ZodArray",0,ep,"ZodBigInt",0,es,"ZodBoolean",0,en,"ZodBranded",0,eD,"ZodCatch",0,eZ,"ZodDate",0,ea,"ZodDefault",0,eE,"ZodDiscriminatedUnion",0,eg,"ZodEffects",0,eO,"ZodEnum",0,eT,"ZodError",0,g,"ZodFirstPartyTypeKind",0,tx,"ZodFunction",0,eb,"ZodIntersection",0,ef,"ZodIssueCode",0,m,"ZodLazy",0,ex,"ZodLiteral",0,eS,"ZodMap",0,ek,"ZodNaN",0,eC,"ZodNativeEnum",0,eN,"ZodNever",0,eu,"ZodNull",0,eo,"ZodNullable",0,eA,"ZodNumber",0,et,"ZodObject",0,eh,"ZodOptional",0,eM,"ZodParsedType",0,p,"ZodPipeline",0,eP,"ZodPromise",0,ej,"ZodReadonly",0,eL,"ZodRecord",0,ev,"ZodSchema",0,I,"ZodSet",0,ew,"ZodString",0,ee,"ZodSymbol",0,er,"ZodTransformer",0,eO,"ZodTuple",0,ey,"ZodType",0,I,"ZodUndefined",0,ei,"ZodUnion",0,em,"ZodUnknown",0,ed,"ZodVoid",0,ec,"addIssueToContext",0,x,"any",0,eX,"array",0,e2,"bigint",0,eV,"boolean",0,eH,"coerce",0,tg,"custom",0,eU,"date",0,eJ,"datetimeRegex",0,Q,"defaultErrorMap",0,f,"discriminatedUnion",0,e3,"effect",0,tl,"enum",0,tr,"function",0,ts,"getErrorMap",0,k,"getParsedType",0,h,"instanceof",0,eF,"intersection",0,e7,"isAborted",0,j,"isAsync",0,A,"isDirty",0,O,"isValid",0,M,"late",0,eY,"lazy",0,tn,"literal",0,ta,"makeIssue",0,w,"map",0,te,"nan",0,eB,"nativeEnum",0,ti,"never",0,e0,"null",0,eG,"nullable",0,tu,"number",0,ez,"object",0,e4,"objectUtil",0,tw,"oboolean",0,t_,"onumber",0,tm,"optional",0,td,"ostring",0,th,"pipeline",0,tp,"preprocess",0,tc,"promise",0,to,"quotelessJson",0,_,"record",0,e8,"set",0,tt,"setErrorMap",0,v,"strictObject",0,e9,"string",0,eW,"symbol",0,eq,"transformer",0,tl,"tuple",0,e6,"undefined",0,eK,"union",0,e5,"unknown",0,eQ,"util",0,tk,"void",0,e1],35907);var tf,ty,tv,tk,tw,tb,tx,tS=e.i(35907),tS=tS,t$=e.i(54853);let tT=tS.enum(t$.GOAL_CATEGORIES),tN=tS.enum(["shipped","partial","exploratory","blocked","trivial"]),tj=tS.enum(["essential","helpful","neutral","unhelpful"]),tO=tS.object({brief_summary:tS.string().min(1),underlying_goal:tS.string().min(1),friction_detail:tS.string().nullable(),user_instructions:tS.array(tS.string()),goal_categories:tS.record(tT,tS.number().nonnegative()),outcome:tN,claude_helpfulness:tj}).passthrough(),tM=`You are analyzing one (session \xd7 local-day) slice of a developer's Claude Code work.
1
+ module.exports=[82111,78325,56614,20441,77242,21628,e=>{"use strict";let t;var s,n,a,r,i,o,l,d=e.i(91530);e.s([],54033),e.i(54033),(s=r||(r={})).assertEqual=e=>{},s.assertIs=function(e){},s.assertNever=function(e){throw Error()},s.arrayToEnum=e=>{let t={};for(let s of e)t[s]=s;return t},s.getValidEnumValues=e=>{let t=s.objectKeys(e).filter(t=>"number"!=typeof e[e[t]]),n={};for(let s of t)n[s]=e[s];return s.objectValues(n)},s.objectValues=e=>s.objectKeys(e).map(function(t){return e[t]}),s.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{let t=[];for(let s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.push(s);return t},s.find=(e,t)=>{for(let s of e)if(t(s))return s},s.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,s.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},s.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(i||(i={})).mergeShapes=(e,t)=>({...e,...t});let u=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 u.undefined;case"string":return u.string;case"number":return Number.isNaN(e)?u.nan:u.number;case"boolean":return u.boolean;case"function":return u.function;case"bigint":return u.bigint;case"symbol":return u.symbol;case"object":if(Array.isArray(e))return u.array;if(null===e)return u.null;if(e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch)return u.promise;if("u">typeof Map&&e instanceof Map)return u.map;if("u">typeof Set&&e instanceof Set)return u.set;if("u">typeof Date&&e instanceof Date)return u.date;return u.object;default:return u.unknown}};e.s(["ZodParsedType",0,u,"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},s={_errors:[]},n=e=>{for(let a of e.issues)if("invalid_union"===a.code)a.unionErrors.map(n);else if("invalid_return_type"===a.code)n(a.returnTypeError);else if("invalid_arguments"===a.code)n(a.argumentsError);else if(0===a.path.length)s._errors.push(t(a));else{let e=s,n=0;for(;n<a.path.length;){let s=a.path[n];n===a.path.length-1?(e[s]=e[s]||{_errors:[]},e[s]._errors.push(t(a))):e[s]=e[s]||{_errors:[]},e=e[s],n++}}};return n(this),s}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={},s=[];for(let n of this.issues)if(n.path.length>0){let s=n.path[0];t[s]=t[s]||[],t[s].push(e(n))}else s.push(e(n));return{formErrors:s,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 s;switch(e.code){case p.invalid_type:s=e.received===u.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case p.invalid_literal:s=`Invalid literal value, expected ${JSON.stringify(e.expected,r.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:s=`Unrecognized key(s) in object: ${r.joinValues(e.keys,", ")}`;break;case p.invalid_union:s="Invalid input";break;case p.invalid_union_discriminator:s=`Invalid discriminator value. Expected ${r.joinValues(e.options)}`;break;case p.invalid_enum_value:s=`Invalid enum value. Expected ${r.joinValues(e.options)}, received '${e.received}'`;break;case p.invalid_arguments:s="Invalid function arguments";break;case p.invalid_return_type:s="Invalid function return type";break;case p.invalid_date:s="Invalid date";break;case p.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(s=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(s=`${s} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?s=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?s=`Invalid input: must end with "${e.validation.endsWith}"`:r.assertNever(e.validation):s="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case p.too_small:s="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:s="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:s="Invalid input";break;case p.invalid_intersection_types:s="Intersection results could not be merged";break;case p.not_multiple_of:s=`Number must be a multiple of ${e.multipleOf}`;break;case p.not_finite:s="Number must be finite";break;default:s=t.defaultError,r.assertNever(e)}return{message:s}},g=_;function f(e){g=e}function y(){return g}e.s(["getErrorMap",0,y,"setErrorMap",0,f],85676),e.i(85676),e.s(["defaultErrorMap",0,_,"getErrorMap",0,y,"setErrorMap",0,f],76733),e.i(76733);let v=e=>{let{data:t,path:s,errorMaps:n,issueData:a}=e,r=[...s,...a.path||[]],i={...a,path:r};if(void 0!==a.message)return{...a,path:r,message:a.message};let o="";for(let e of n.filter(e=>!!e).slice().reverse())o=e(i,{data:t,defaultError:o}).message;return{...a,path:r,message:o}},k=[];function w(e,t){let s=y(),n=v({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,s,s===_?void 0:_].filter(e=>!!e)});e.common.issues.push(n)}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 s=[];for(let n of t){if("aborted"===n.status)return x;"dirty"===n.status&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){let s=[];for(let e of t){let t=await e.key,n=await e.value;s.push({key:t,value:n})}return b.mergeObjectSync(e,s)}static mergeObjectSync(e,t){let s={};for(let n of t){let{key:t,value:a}=n;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||n.alwaysSet)&&(s[t.value]=a.value)}return{status:e.value,value:s}}}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,k,"INVALID",0,x,"OK",0,$,"ParseStatus",0,b,"addIssueToContext",0,w,"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),(n=o||(o={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},n.toString=e=>"string"==typeof e?e:e?.message;class M{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}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 A=(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 E(e){if(!e)return{};let{errorMap:t,invalid_type_error:s,required_error:n,description:a}=e;if(t&&(s||n))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??n??a.defaultError}:"invalid_type"!==t.code?{message:a.defaultError}:{message:r??s??a.defaultError}},description:a}}class Z{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 s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){let s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:c(e)},n=this._parseSync({data:e,path:s.path,parent:s});return A(s,n)}"~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 s=this._parseSync({data:e,path:[],parent:t});return j(s)?{value:s.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 s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){let s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:c(e)},n=this._parse({data:e,path:s.path,parent:s});return A(s,await (O(n)?n:Promise.resolve(n)))}refine(e,t){return this._refinement((s,n)=>{let a=e(s),r=()=>n.addIssue({code:p.custom,..."string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(s):t});return"u">typeof Promise&&a instanceof Promise?a.then(e=>!!e||(r(),!1)):!!a||(r(),!1)})}refinement(e,t){return this._refinement((s,n)=>!!e(s)||(n.addIssue("function"==typeof t?t(s,n):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 eu.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({...E(this._def),schema:this,typeName:l.ZodEffects,effect:{type:"transform",transform:e}})}default(e){return new eM({...E(this._def),innerType:this,defaultValue:"function"==typeof e?e:()=>e,typeName:l.ZodDefault})}brand(){return new eC({typeName:l.ZodBranded,type:this,...E(this._def)})}catch(e){return new eA({...E(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 C=/^c[^\s-]{8,}$/i,D=/^[0-9a-z]+$/,I=/^[0-9A-HJKMNP-TV-Z]{26}$/i,P=/^[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)?)??$/,Y=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,F=/^(?:(?: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])$/,V=/^([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}(=)?))?$/,J="((\\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(`^${J}$`);function G(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);let s=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${s}`}function K(e){let t=`${J}T${G(e)}`,s=[];return s.push(e.local?"Z?":"Z"),e.offset&&s.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${s.join("|")})`,RegExp(`^${t}$`)}class X extends Z{_parse(e){var s,n,a,i;let o;if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==u.string){let t=this._getOrReturnCtx(e);return w(t,{code:p.invalid_type,expected:u.string,received:t.parsedType}),x}let l=new b;for(let d of this._def.checks)if("min"===d.kind)e.data.length<d.value&&(w(o=this._getOrReturnCtx(e,o),{code:p.too_small,minimum:d.value,type:"string",inclusive:!0,exact:!1,message:d.message}),l.dirty());else if("max"===d.kind)e.data.length>d.value&&(w(o=this._getOrReturnCtx(e,o),{code:p.too_big,maximum:d.value,type:"string",inclusive:!0,exact:!1,message:d.message}),l.dirty());else if("length"===d.kind){let t=e.data.length>d.value,s=e.data.length<d.value;(t||s)&&(o=this._getOrReturnCtx(e,o),t?w(o,{code:p.too_big,maximum:d.value,type:"string",inclusive:!0,exact:!0,message:d.message}):s&&w(o,{code:p.too_small,minimum:d.value,type:"string",inclusive:!0,exact:!0,message:d.message}),l.dirty())}else if("email"===d.kind)Y.test(e.data)||(w(o=this._getOrReturnCtx(e,o),{validation:"email",code:p.invalid_string,message:d.message}),l.dirty());else if("emoji"===d.kind)t||(t=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),t.test(e.data)||(w(o=this._getOrReturnCtx(e,o),{validation:"emoji",code:p.invalid_string,message:d.message}),l.dirty());else if("uuid"===d.kind)P.test(e.data)||(w(o=this._getOrReturnCtx(e,o),{validation:"uuid",code:p.invalid_string,message:d.message}),l.dirty());else if("nanoid"===d.kind)L.test(e.data)||(w(o=this._getOrReturnCtx(e,o),{validation:"nanoid",code:p.invalid_string,message:d.message}),l.dirty());else if("cuid"===d.kind)C.test(e.data)||(w(o=this._getOrReturnCtx(e,o),{validation:"cuid",code:p.invalid_string,message:d.message}),l.dirty());else if("cuid2"===d.kind)D.test(e.data)||(w(o=this._getOrReturnCtx(e,o),{validation:"cuid2",code:p.invalid_string,message:d.message}),l.dirty());else if("ulid"===d.kind)I.test(e.data)||(w(o=this._getOrReturnCtx(e,o),{validation:"ulid",code:p.invalid_string,message:d.message}),l.dirty());else if("url"===d.kind)try{new URL(e.data)}catch{w(o=this._getOrReturnCtx(e,o),{validation:"url",code:p.invalid_string,message:d.message}),l.dirty()}else"regex"===d.kind?(d.regex.lastIndex=0,d.regex.test(e.data)||(w(o=this._getOrReturnCtx(e,o),{validation:"regex",code:p.invalid_string,message:d.message}),l.dirty())):"trim"===d.kind?e.data=e.data.trim():"includes"===d.kind?e.data.includes(d.value,d.position)||(w(o=this._getOrReturnCtx(e,o),{code:p.invalid_string,validation:{includes:d.value,position:d.position},message:d.message}),l.dirty()):"toLowerCase"===d.kind?e.data=e.data.toLowerCase():"toUpperCase"===d.kind?e.data=e.data.toUpperCase():"startsWith"===d.kind?e.data.startsWith(d.value)||(w(o=this._getOrReturnCtx(e,o),{code:p.invalid_string,validation:{startsWith:d.value},message:d.message}),l.dirty()):"endsWith"===d.kind?e.data.endsWith(d.value)||(w(o=this._getOrReturnCtx(e,o),{code:p.invalid_string,validation:{endsWith:d.value},message:d.message}),l.dirty()):"datetime"===d.kind?K(d).test(e.data)||(w(o=this._getOrReturnCtx(e,o),{code:p.invalid_string,validation:"datetime",message:d.message}),l.dirty()):"date"===d.kind?q.test(e.data)||(w(o=this._getOrReturnCtx(e,o),{code:p.invalid_string,validation:"date",message:d.message}),l.dirty()):"time"===d.kind?RegExp(`^${G(d)}$`).test(e.data)||(w(o=this._getOrReturnCtx(e,o),{code:p.invalid_string,validation:"time",message:d.message}),l.dirty()):"duration"===d.kind?U.test(e.data)||(w(o=this._getOrReturnCtx(e,o),{validation:"duration",code:p.invalid_string,message:d.message}),l.dirty()):"ip"===d.kind?(s=e.data,!(("v4"===(n=d.version)||!n)&&F.test(s)||("v6"===n||!n)&&z.test(s))&&1&&(w(o=this._getOrReturnCtx(e,o),{validation:"ip",code:p.invalid_string,message:d.message}),l.dirty())):"jwt"===d.kind?!function(e,t){if(!R.test(e))return!1;try{let[s]=e.split(".");if(!s)return!1;let n=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(s.length+(4-s.length%4)%4,"="),a=JSON.parse(atob(n));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,d.alg)&&(w(o=this._getOrReturnCtx(e,o),{validation:"jwt",code:p.invalid_string,message:d.message}),l.dirty()):"cidr"===d.kind?(a=e.data,!(("v4"===(i=d.version)||!i)&&W.test(a)||("v6"===i||!i)&&B.test(a))&&1&&(w(o=this._getOrReturnCtx(e,o),{validation:"cidr",code:p.invalid_string,message:d.message}),l.dirty())):"base64"===d.kind?V.test(e.data)||(w(o=this._getOrReturnCtx(e,o),{validation:"base64",code:p.invalid_string,message:d.message}),l.dirty()):"base64url"===d.kind?H.test(e.data)||(w(o=this._getOrReturnCtx(e,o),{validation:"base64url",code:p.invalid_string,message:d.message}),l.dirty()):r.assertNever(d);return{status:l.value,value:e.data}}_regex(e,t,s){return this.refinement(t=>e.test(t),{validation:t,code:p.invalid_string,...o.errToObj(s)})}_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,...E(e)});class Q extends Z{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)!==u.number){let t=this._getOrReturnCtx(e);return w(t,{code:p.invalid_type,expected:u.number,received:t.parsedType}),x}let s=new b;for(let n of this._def.checks)"int"===n.kind?r.isInteger(e.data)||(w(t=this._getOrReturnCtx(e,t),{code:p.invalid_type,expected:"integer",received:"float",message:n.message}),s.dirty()):"min"===n.kind?(n.inclusive?e.data<n.value:e.data<=n.value)&&(w(t=this._getOrReturnCtx(e,t),{code:p.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):"max"===n.kind?(n.inclusive?e.data>n.value:e.data>=n.value)&&(w(t=this._getOrReturnCtx(e,t),{code:p.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):"multipleOf"===n.kind?0!==function(e,t){let s=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,a=s>n?s:n;return Number.parseInt(e.toFixed(a).replace(".",""))%Number.parseInt(t.toFixed(a).replace(".",""))/10**a}(e.data,n.value)&&(w(t=this._getOrReturnCtx(e,t),{code:p.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):"finite"===n.kind?Number.isFinite(e.data)||(w(t=this._getOrReturnCtx(e,t),{code:p.not_finite,message:n.message}),s.dirty()):r.assertNever(n);return{status:s.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,s,n){return new Q({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:o.toString(n)}]})}_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 s of this._def.checks)if("finite"===s.kind||"int"===s.kind||"multipleOf"===s.kind)return!0;else"min"===s.kind?(null===t||s.value>t)&&(t=s.value):"max"===s.kind&&(null===e||s.value<e)&&(e=s.value);return Number.isFinite(t)&&Number.isFinite(e)}}Q.create=e=>new Q({checks:[],typeName:l.ZodNumber,coerce:e?.coerce||!1,...E(e)});class ee extends Z{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)!==u.bigint)return this._getInvalidInput(e);let s=new b;for(let n of this._def.checks)"min"===n.kind?(n.inclusive?e.data<n.value:e.data<=n.value)&&(w(t=this._getOrReturnCtx(e,t),{code:p.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):"max"===n.kind?(n.inclusive?e.data>n.value:e.data>=n.value)&&(w(t=this._getOrReturnCtx(e,t),{code:p.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):"multipleOf"===n.kind?e.data%n.value!==BigInt(0)&&(w(t=this._getOrReturnCtx(e,t),{code:p.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):r.assertNever(n);return{status:s.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return w(t,{code:p.invalid_type,expected:u.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,s,n){return new ee({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:o.toString(n)}]})}_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,...E(e)});class et extends Z{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==u.boolean){let t=this._getOrReturnCtx(e);return w(t,{code:p.invalid_type,expected:u.boolean,received:t.parsedType}),x}return $(e.data)}}et.create=e=>new et({typeName:l.ZodBoolean,coerce:e?.coerce||!1,...E(e)});class es extends Z{_parse(e){let t;if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==u.date){let t=this._getOrReturnCtx(e);return w(t,{code:p.invalid_type,expected:u.date,received:t.parsedType}),x}if(Number.isNaN(e.data.getTime()))return w(this._getOrReturnCtx(e),{code:p.invalid_date}),x;let s=new b;for(let n of this._def.checks)"min"===n.kind?e.data.getTime()<n.value&&(w(t=this._getOrReturnCtx(e,t),{code:p.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),s.dirty()):"max"===n.kind?e.data.getTime()>n.value&&(w(t=this._getOrReturnCtx(e,t),{code:p.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),s.dirty()):r.assertNever(n);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new es({...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}}es.create=e=>new es({checks:[],coerce:e?.coerce||!1,typeName:l.ZodDate,...E(e)});class en extends Z{_parse(e){if(this._getType(e)!==u.symbol){let t=this._getOrReturnCtx(e);return w(t,{code:p.invalid_type,expected:u.symbol,received:t.parsedType}),x}return $(e.data)}}en.create=e=>new en({typeName:l.ZodSymbol,...E(e)});class ea extends Z{_parse(e){if(this._getType(e)!==u.undefined){let t=this._getOrReturnCtx(e);return w(t,{code:p.invalid_type,expected:u.undefined,received:t.parsedType}),x}return $(e.data)}}ea.create=e=>new ea({typeName:l.ZodUndefined,...E(e)});class er extends Z{_parse(e){if(this._getType(e)!==u.null){let t=this._getOrReturnCtx(e);return w(t,{code:p.invalid_type,expected:u.null,received:t.parsedType}),x}return $(e.data)}}er.create=e=>new er({typeName:l.ZodNull,...E(e)});class ei extends Z{constructor(){super(...arguments),this._any=!0}_parse(e){return $(e.data)}}ei.create=e=>new ei({typeName:l.ZodAny,...E(e)});class eo extends Z{constructor(){super(...arguments),this._unknown=!0}_parse(e){return $(e.data)}}eo.create=e=>new eo({typeName:l.ZodUnknown,...E(e)});class el extends Z{_parse(e){let t=this._getOrReturnCtx(e);return w(t,{code:p.invalid_type,expected:u.never,received:t.parsedType}),x}}el.create=e=>new el({typeName:l.ZodNever,...E(e)});class ed extends Z{_parse(e){if(this._getType(e)!==u.undefined){let t=this._getOrReturnCtx(e);return w(t,{code:p.invalid_type,expected:u.void,received:t.parsedType}),x}return $(e.data)}}ed.create=e=>new ed({typeName:l.ZodVoid,...E(e)});class eu extends Z{_parse(e){let{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==u.array)return w(t,{code:p.invalid_type,expected:u.array,received:t.parsedType}),x;if(null!==n.exactLength){let e=t.data.length>n.exactLength.value,a=t.data.length<n.exactLength.value;(e||a)&&(w(t,{code:e?p.too_big:p.too_small,minimum:a?n.exactLength.value:void 0,maximum:e?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(null!==n.minLength&&t.data.length<n.minLength.value&&(w(t,{code:p.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),null!==n.maxLength&&t.data.length>n.maxLength.value&&(w(t,{code:p.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((e,s)=>n.type._parseAsync(new M(t,e,t.path,s)))).then(e=>b.mergeArray(s,e));let a=[...t.data].map((e,s)=>n.type._parseSync(new M(t,e,t.path,s)));return b.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new eu({...this._def,minLength:{value:e,message:o.toString(t)}})}max(e,t){return new eu({...this._def,maxLength:{value:e,message:o.toString(t)}})}length(e,t){return new eu({...this._def,exactLength:{value:e,message:o.toString(t)}})}nonempty(e){return this.min(1,e)}}eu.create=(e,t)=>new eu({type:e,minLength:null,maxLength:null,exactLength:null,typeName:l.ZodArray,...E(t)});class ec extends Z{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)!==u.object){let t=this._getOrReturnCtx(e);return w(t,{code:p.invalid_type,expected:u.object,received:t.parsedType}),x}let{status:t,ctx:s}=this._processInputParams(e),{shape:n,keys:a}=this._getCached(),r=[];if(!(this._def.catchall instanceof el&&"strip"===this._def.unknownKeys))for(let e in s.data)a.includes(e)||r.push(e);let i=[];for(let e of a){let t=n[e],a=s.data[e];i.push({key:{status:"valid",value:e},value:t._parse(new M(s,a,s.path,e)),alwaysSet:e in s.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:s.data[e]}});else if("strict"===e)r.length>0&&(w(s,{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 n=s.data[t];i.push({key:{status:"valid",value:t},value:e._parse(new M(s,n,s.path,t)),alwaysSet:t in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of i){let s=await t.key,n=await t.value;e.push({key:s,value:n,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,s)=>{let n=this._def.errorMap?.(t,s).message??s.defaultError;return"unrecognized_keys"===t.code?{message:o.errToObj(e).message??n}:{message:n}}}:{}})}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 s of r.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new ec({...this._def,shape:()=>t})}omit(e){let t={};for(let s of r.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new ec({...this._def,shape:()=>t})}deepPartial(){return function e(t){if(t instanceof ec){let s={};for(let n in t.shape){let a=t.shape[n];s[n]=ej.create(e(a))}return new ec({...t._def,shape:()=>s})}if(t instanceof eu)return new eu({...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 eg)return eg.create(t.items.map(t=>e(t)));else return t}(this)}partial(e){let t={};for(let s of r.objectKeys(this.shape)){let n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}return new ec({...this._def,shape:()=>t})}required(e){let t={};for(let s of r.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let e=this.shape[s];for(;e instanceof ej;)e=e._def.innerType;t[s]=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,...E(t)}),ec.strictCreate=(e,t)=>new ec({shape:()=>e,unknownKeys:"strict",catchall:el.create(),typeName:l.ZodObject,...E(t)}),ec.lazycreate=(e,t)=>new ec({shape:e,unknownKeys:"strip",catchall:el.create(),typeName:l.ZodObject,...E(t)});class ep extends Z{_parse(e){let{ctx:t}=this._processInputParams(e),s=this._def.options;if(t.common.async)return Promise.all(s.map(async e=>{let s={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:s}),ctx:s}})).then(function(e){for(let t of e)if("valid"===t.result.status)return t.result;for(let s of e)if("dirty"===s.result.status)return t.common.issues.push(...s.ctx.common.issues),s.result;let s=e.map(e=>new m(e.ctx.common.issues));return w(t,{code:p.invalid_union,unionErrors:s}),x});{let e,n=[];for(let a of s){let s={...t,common:{...t.common,issues:[]},parent:null},r=a._parseSync({data:t.data,path:t.path,parent:s});if("valid"===r.status)return r;"dirty"!==r.status||e||(e={result:r,ctx:s}),s.common.issues.length&&n.push(s.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let a=n.map(e=>new m(e));return w(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,...E(t)});let eh=e=>{if(e instanceof ew)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 eC)return eh(e.unwrap());else if(e instanceof eI)return eh(e.unwrap());else if(e instanceof eA)return eh(e._def.innerType);else return[]};class em extends Z{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==u.object)return w(t,{code:p.invalid_type,expected:u.object,received:t.parsedType}),x;let s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);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}):(w(t,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),x)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){let n=new Map;for(let s of t){let t=eh(s.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(n.has(a))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);n.set(a,s)}}return new em({typeName:l.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...E(s)})}}class e_ extends Z{_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=(e,n)=>{if(T(e)||T(n))return x;let a=function e(t,s){let n=c(t),a=c(s);if(t===s)return{valid:!0,data:t};if(n===u.object&&a===u.object){let n=r.objectKeys(s),a=r.objectKeys(t).filter(e=>-1!==n.indexOf(e)),i={...t,...s};for(let n of a){let a=e(t[n],s[n]);if(!a.valid)return{valid:!1};i[n]=a.data}return{valid:!0,data:i}}if(n===u.array&&a===u.array){if(t.length!==s.length)return{valid:!1};let n=[];for(let a=0;a<t.length;a++){let r=e(t[a],s[a]);if(!r.valid)return{valid:!1};n.push(r.data)}return{valid:!0,data:n}}if(n===u.date&&a===u.date&&+t==+s)return{valid:!0,data:t};return{valid:!1}}(e.value,n.value);return a.valid?((N(e)||N(n))&&t.dirty(),{status:t.value,value:a.data}):(w(s,{code:p.invalid_intersection_types}),x)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([e,t])=>n(e,t)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}e_.create=(e,t,s)=>new e_({left:e,right:t,typeName:l.ZodIntersection,...E(s)});class eg extends Z{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==u.array)return w(s,{code:p.invalid_type,expected:u.array,received:s.parsedType}),x;if(s.data.length<this._def.items.length)return w(s,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),x;!this._def.rest&&s.data.length>this._def.items.length&&(w(s,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let n=[...s.data].map((e,t)=>{let n=this._def.items[t]||this._def.rest;return n?n._parse(new M(s,e,s.path,t)):null}).filter(e=>!!e);return s.common.async?Promise.all(n).then(e=>b.mergeArray(t,e)):b.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new eg({...this._def,rest:e})}}eg.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new eg({items:e,typeName:l.ZodTuple,rest:null,...E(t)})};class ef extends Z{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==u.object)return w(s,{code:p.invalid_type,expected:u.object,received:s.parsedType}),x;let n=[],a=this._def.keyType,r=this._def.valueType;for(let e in s.data)n.push({key:a._parse(new M(s,e,s.path,e)),value:r._parse(new M(s,s.data[e],s.path,e)),alwaysSet:e in s.data});return s.common.async?b.mergeObjectAsync(t,n):b.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return new ef(t instanceof Z?{keyType:e,valueType:t,typeName:l.ZodRecord,...E(s)}:{keyType:X.create(),valueType:e,typeName:l.ZodRecord,...E(t)})}}class ey extends Z{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==u.map)return w(s,{code:p.invalid_type,expected:u.map,received:s.parsedType}),x;let n=this._def.keyType,a=this._def.valueType,r=[...s.data.entries()].map(([e,t],r)=>({key:n._parse(new M(s,e,s.path,[r,"key"])),value:a._parse(new M(s,t,s.path,[r,"value"]))}));if(s.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let s of r){let n=await s.key,a=await s.value;if("aborted"===n.status||"aborted"===a.status)return x;("dirty"===n.status||"dirty"===a.status)&&t.dirty(),e.set(n.value,a.value)}return{status:t.value,value:e}})}{let e=new Map;for(let s of r){let n=s.key,a=s.value;if("aborted"===n.status||"aborted"===a.status)return x;("dirty"===n.status||"dirty"===a.status)&&t.dirty(),e.set(n.value,a.value)}return{status:t.value,value:e}}}}ey.create=(e,t,s)=>new ey({valueType:t,keyType:e,typeName:l.ZodMap,...E(s)});class ev extends Z{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==u.set)return w(s,{code:p.invalid_type,expected:u.set,received:s.parsedType}),x;let n=this._def;null!==n.minSize&&s.data.size<n.minSize.value&&(w(s,{code:p.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),null!==n.maxSize&&s.data.size>n.maxSize.value&&(w(s,{code:p.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());let a=this._def.valueType;function r(e){let s=new Set;for(let n of e){if("aborted"===n.status)return x;"dirty"===n.status&&t.dirty(),s.add(n.value)}return{status:t.value,value:s}}let i=[...s.data.values()].map((e,t)=>a._parse(new M(s,e,s.path,t)));return s.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,...E(t)});class ek extends Z{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==u.function)return w(t,{code:p.invalid_type,expected:u.function,received:t.parsedType}),x;function s(e,s){return v({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,y(),_].filter(e=>!!e),issueData:{code:p.invalid_arguments,argumentsError:s}})}function n(e,s){return v({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,y(),_].filter(e=>!!e),issueData:{code:p.invalid_return_type,returnTypeError:s}})}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(s(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(n(l,e)),i})})}{let e=this;return $(function(...t){let i=e._def.args.safeParse(t,a);if(!i.success)throw new m([s(t,i.error)]);let o=Reflect.apply(r,this,i.data),l=e._def.returns.safeParse(o,a);if(!l.success)throw new m([n(o,l.error)]);return l.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ek({...this._def,args:eg.create(e).rest(eo.create())})}returns(e){return new ek({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new ek({args:e||eg.create([]).rest(eo.create()),returns:t||eo.create(),typeName:l.ZodFunction,...E(s)})}}class ew extends Z{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})}}ew.create=(e,t)=>new ew({getter:e,typeName:l.ZodLazy,...E(t)});class eb extends Z{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return w(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,...E(t)})}eb.create=(e,t)=>new eb({value:e,typeName:l.ZodLiteral,...E(t)});class eS extends Z{_parse(e){if("string"!=typeof e.data){let t=this._getOrReturnCtx(e),s=this._def.values;return w(t,{expected:r.joinValues(s),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),s=this._def.values;return w(t,{received:t.data,code:p.invalid_enum_value,options:s}),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 Z{_parse(e){let t=r.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==u.string&&s.parsedType!==u.number){let e=r.objectValues(t);return w(s,{expected:r.joinValues(e),received:s.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 w(s,{received:s.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,...E(t)});class eT extends Z{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==u.promise&&!1===t.common.async?(w(t,{code:p.invalid_type,expected:u.promise,received:t.parsedType}),x):$((t.parsedType===u.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,...E(t)});class eN extends Z{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:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:e=>{w(s,e),e.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),"preprocess"===n.type){let e=n.transform(s.data,a);if(s.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return x;let n=await this._def.schema._parseAsync({data:e,path:s.path,parent:s});return"aborted"===n.status?x:"dirty"===n.status||"dirty"===t.value?S(n.value):n});{if("aborted"===t.value)return x;let n=this._def.schema._parseSync({data:e,path:s.path,parent:s});return"aborted"===n.status?x:"dirty"===n.status||"dirty"===t.value?S(n.value):n}}if("refinement"===n.type){let e=e=>{let t=n.refinement(e,a);if(s.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!==s.common.async)return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(s=>"aborted"===s.status?x:("dirty"===s.status&&t.dirty(),e(s.value).then(()=>({status:t.value,value:s.value}))));{let n=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return"aborted"===n.status?x:("dirty"===n.status&&t.dirty(),e(n.value),{status:t.value,value:n.value})}}if("transform"===n.type)if(!1!==s.common.async)return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(e=>j(e)?Promise.resolve(n.transform(e.value,a)).then(e=>({status:t.value,value:e})):x);else{let e=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!j(e))return x;let r=n.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(n)}}eN.create=(e,t,s)=>new eN({schema:e,typeName:l.ZodEffects,effect:t,...E(s)}),eN.createWithPreprocess=(e,t,s)=>new eN({schema:t,effect:{type:"preprocess",transform:e},typeName:l.ZodEffects,...E(s)});class ej extends Z{_parse(e){return this._getType(e)===u.undefined?$(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ej.create=(e,t)=>new ej({innerType:e,typeName:l.ZodOptional,...E(t)});class eO extends Z{_parse(e){return this._getType(e)===u.null?$(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}eO.create=(e,t)=>new eO({innerType:e,typeName:l.ZodNullable,...E(t)});class eM extends Z{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return t.parsedType===u.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,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,...E(t)});class eA extends Z{_parse(e){let{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return O(n)?n.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new m(s.common.issues)},input:s.data})})):{status:"valid",value:"valid"===n.status?n.value:this._def.catchValue({get error(){return new m(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}eA.create=(e,t)=>new eA({innerType:e,typeName:l.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...E(t)});class eE extends Z{_parse(e){if(this._getType(e)!==u.nan){let t=this._getOrReturnCtx(e);return w(t,{code:p.invalid_type,expected:u.nan,received:t.parsedType}),x}return{status:"valid",value:e.data}}}eE.create=e=>new eE({typeName:l.ZodNaN,...E(e)});let eZ=Symbol("zod_brand");class eC extends Z{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class eD extends Z{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?x:"dirty"===e.status?(t.dirty(),S(e.value)):this._def.out._parseAsync({data:e.value,path:s.path,parent:s})})();{let e=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?x:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:s.path,parent:s})}}static create(e,t){return new eD({in:e,out:t,typeName:l.ZodPipeline})}}class eI extends Z{_parse(e){let t=this._def.innerType._parse(e),s=e=>(j(e)&&(e.value=Object.freeze(e.value)),e);return O(t)?t.then(e=>s(e)):s(t)}unwrap(){return this._def.innerType}}function eP(e,t){let s="function"==typeof e?e(t):"string"==typeof e?{message:e}:e;return"string"==typeof s?{message:s}:s}function eL(e,t={},s){return e?ei.create().superRefine((n,a)=>{let r=e(n);if(r instanceof Promise)return r.then(e=>{if(!e){let e=eP(t,n),r=e.fatal??s??!0;a.addIssue({code:"custom",...e,fatal:r})}});if(!r){let e=eP(t,n),r=e.fatal??s??!0;a.addIssue({code:"custom",...e,fatal:r})}}):ei.create()}eI.create=(e,t)=>new eI({innerType:e,typeName:l.ZodReadonly,...E(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),eY=X.create,eF=Q.create,eW=eE.create,ez=ee.create,eB=et.create,eV=es.create,eH=en.create,eJ=ea.create,eq=er.create,eG=ei.create,eK=eo.create,eX=el.create,eQ=ed.create,e0=eu.create,e1=ec.create,e2=ec.strictCreate,e4=ep.create,e9=em.create,e5=e_.create,e3=eg.create,e7=ef.create,e6=ey.create,e8=ev.create,te=ek.create,tt=ew.create,ts=eb.create,tn=eS.create,ta=e$.create,tr=eT.create,ti=eN.create,to=ej.create,tl=eO.create,td=eN.createWithPreprocess,tu=eD.create,tc=()=>eY().optional(),tp=()=>eF().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=>es.create({...e,coerce:!0})};e.s(["BRAND",0,eZ,"NEVER",0,x,"Schema",0,Z,"ZodAny",0,ei,"ZodArray",0,eu,"ZodBigInt",0,ee,"ZodBoolean",0,et,"ZodBranded",0,eC,"ZodCatch",0,eA,"ZodDate",0,es,"ZodDefault",0,eM,"ZodDiscriminatedUnion",0,em,"ZodEffects",0,eN,"ZodEnum",0,eS,"ZodFirstPartyTypeKind",0,l,"ZodFunction",0,ek,"ZodIntersection",0,e_,"ZodLazy",0,ew,"ZodLiteral",0,eb,"ZodMap",0,ey,"ZodNaN",0,eE,"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,ef,"ZodSchema",0,Z,"ZodSet",0,ev,"ZodString",0,X,"ZodSymbol",0,en,"ZodTransformer",0,eN,"ZodTuple",0,eg,"ZodType",0,Z,"ZodUndefined",0,ea,"ZodUnion",0,ep,"ZodUnknown",0,eo,"ZodVoid",0,ed,"any",0,eG,"array",0,e0,"bigint",0,ez,"boolean",0,eB,"coerce",0,tm,"custom",0,eL,"date",0,eV,"datetimeRegex",0,K,"discriminatedUnion",0,e9,"effect",0,ti,"enum",0,tn,"function",0,te,"instanceof",0,eU,"intersection",0,e5,"late",0,eR,"lazy",0,tt,"literal",0,ts,"map",0,e6,"nan",0,eW,"nativeEnum",0,ta,"never",0,eX,"null",0,eq,"nullable",0,tl,"number",0,eF,"object",0,e1,"oboolean",0,th,"onumber",0,tp,"optional",0,to,"ostring",0,tc,"pipeline",0,tu,"preprocess",0,td,"promise",0,tr,"record",0,e7,"set",0,e8,"strictObject",0,e2,"string",0,eY,"symbol",0,eH,"transformer",0,ti,"tuple",0,e3,"undefined",0,eJ,"union",0,e4,"unknown",0,eK,"void",0,eQ],17958),e.i(17958),e.i(15235),e.s(["BRAND",0,eZ,"DIRTY",0,S,"EMPTY_PATH",0,k,"INVALID",0,x,"NEVER",0,x,"OK",0,$,"ParseStatus",0,b,"Schema",0,Z,"ZodAny",0,ei,"ZodArray",0,eu,"ZodBigInt",0,ee,"ZodBoolean",0,et,"ZodBranded",0,eC,"ZodCatch",0,eA,"ZodDate",0,es,"ZodDefault",0,eM,"ZodDiscriminatedUnion",0,em,"ZodEffects",0,eN,"ZodEnum",0,eS,"ZodError",0,m,"ZodFirstPartyTypeKind",0,l,"ZodFunction",0,ek,"ZodIntersection",0,e_,"ZodIssueCode",0,p,"ZodLazy",0,ew,"ZodLiteral",0,eb,"ZodMap",0,ey,"ZodNaN",0,eE,"ZodNativeEnum",0,e$,"ZodNever",0,el,"ZodNull",0,er,"ZodNullable",0,eO,"ZodNumber",0,Q,"ZodObject",0,ec,"ZodOptional",0,ej,"ZodParsedType",0,u,"ZodPipeline",0,eD,"ZodPromise",0,eT,"ZodReadonly",0,eI,"ZodRecord",0,ef,"ZodSchema",0,Z,"ZodSet",0,ev,"ZodString",0,X,"ZodSymbol",0,en,"ZodTransformer",0,eN,"ZodTuple",0,eg,"ZodType",0,Z,"ZodUndefined",0,ea,"ZodUnion",0,ep,"ZodUnknown",0,eo,"ZodVoid",0,ed,"addIssueToContext",0,w,"any",0,eG,"array",0,e0,"bigint",0,ez,"boolean",0,eB,"coerce",0,tm,"custom",0,eL,"date",0,eV,"datetimeRegex",0,K,"defaultErrorMap",0,_,"discriminatedUnion",0,e9,"effect",0,ti,"enum",0,tn,"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,ts,"makeIssue",0,v,"map",0,e6,"nan",0,eW,"nativeEnum",0,ta,"never",0,eX,"null",0,eq,"nullable",0,tl,"number",0,eF,"object",0,e1,"objectUtil",0,i,"oboolean",0,th,"onumber",0,tp,"optional",0,to,"ostring",0,tc,"pipeline",0,tu,"preprocess",0,td,"promise",0,tr,"quotelessJson",0,h,"record",0,e7,"set",0,e8,"setErrorMap",0,f,"strictObject",0,e2,"string",0,eY,"symbol",0,eH,"transformer",0,ti,"tuple",0,e3,"undefined",0,eJ,"union",0,e4,"unknown",0,eK,"util",0,r,"void",0,eQ],35907);var t_=e.i(35907),t_=t_,tg=e.i(54853);let tf=t_.enum(tg.GOAL_CATEGORIES),ty=t_.enum(["shipped","partial","exploratory","blocked","trivial"]),tv=t_.enum(["essential","helpful","neutral","unhelpful"]),tk=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(tf,t_.number().nonnegative()),outcome:ty,claude_helpfulness:tv}).passthrough(),tw=`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,15 +43,15 @@ 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 tA=e.i(74533),tE=e.i(2157),tZ=e.i(60526),tC=e.i(50227),tI=e.i(66680);let tD=(0,tC.join)((0,tZ.homedir)(),".cclens","llm-runs");function tP(e,t){try{(0,tE.appendFileSync)(e,t)}catch{}}function tL(e){return new Promise((t,s)=>{let n,a,r;if(!(0,tE.existsSync)(tD))try{(0,tE.mkdirSync)(tD,{recursive:!0})}catch{}let i=(n=e.systemPrompt.slice(0,600).toLowerCase()).includes("weekly retrospective writer")?"week_digest":n.includes("editorial perception layer for one session")?"top_session":n.includes("single local day into a short, honest narrative")?"day_digest":n.includes("month")&&n.includes("digest")?"month_digest":n.includes("session × local-day")||n.includes("(session × local-day)")||n.includes("brief_summary")||n.includes("per-entry")||n.includes("per entry")?"entry_enrich":"unknown",o=(a=new Date().toISOString().replace(/[:.]/g,"-"),r=(0,tI.randomUUID)().slice(0,8),`${a}_${i}_${r}`),l=(0,tC.join)(tD,`${o}.jsonl`),d=new Date().toISOString();var u=JSON.stringify({_meta:{type:"start",run_id:o,kind:i,model:e.model,ts:d,user_prompt_chars:e.userPrompt.length,reminder_chars:e.reminder?.length??0}})+"\n";try{(0,tE.writeFileSync)(l,u)}catch{}tP(l,JSON.stringify({_meta:{type:"payload",run_id:o,system_prompt:e.systemPrompt,user_prompt:e.userPrompt,reminder:e.reminder??null}})+"\n");let c=["-p","--output-format","stream-json","--verbose","--model",e.model,"--tools","","--disable-slash-commands","--no-session-persistence","--setting-sources","","--strict-mcp-config","--mcp-config",'{"mcpServers":{}}',"--effort","medium","--append-system-prompt",e.systemPrompt],p=(0,tA.spawn)("claude",c,{stdio:["pipe","pipe","pipe"],env:{...process.env}});tP(l,JSON.stringify({_meta:{type:"spawned",run_id:o,pid:p.pid}})+"\n");let h=e.reminder?`${e.userPrompt}
46
+ }`;var tb=e.i(74533),tx=e.i(2157),tS=e.i(60526),t$=e.i(50227),tT=e.i(66680);let tN=(0,t$.join)((0,tS.homedir)(),".cclens","llm-runs");function tj(e,t){try{(0,tx.appendFileSync)(e,t)}catch{}}function tO(e){return new Promise((t,s)=>{let n,a,r;if(!(0,tx.existsSync)(tN))try{(0,tx.mkdirSync)(tN,{recursive:!0})}catch{}let i=(n=e.systemPrompt.slice(0,600).toLowerCase()).includes("weekly retrospective writer")?"week_digest":n.includes("editorial perception layer for one session")?"top_session":n.includes("single local day into a short, honest narrative")?"day_digest":n.includes("month")&&n.includes("digest")?"month_digest":n.includes("session × local-day")||n.includes("(session × local-day)")||n.includes("brief_summary")||n.includes("per-entry")||n.includes("per entry")?"entry_enrich":"unknown",o=(a=new Date().toISOString().replace(/[:.]/g,"-"),r=(0,tT.randomUUID)().slice(0,8),`${a}_${i}_${r}`),l=(0,t$.join)(tN,`${o}.jsonl`),d=new Date().toISOString();var u=JSON.stringify({_meta:{type:"start",run_id:o,kind:i,model:e.model,ts:d,user_prompt_chars:e.userPrompt.length,reminder_chars:e.reminder?.length??0}})+"\n";try{(0,tx.writeFileSync)(l,u)}catch{}tj(l,JSON.stringify({_meta:{type:"payload",run_id:o,system_prompt:e.systemPrompt,user_prompt:e.userPrompt,reminder:e.reminder??null}})+"\n");let c=["-p","--output-format","stream-json","--verbose","--model",e.model,"--tools","","--disable-slash-commands","--no-session-persistence","--setting-sources","","--strict-mcp-config","--mcp-config",'{"mcpServers":{}}',"--effort","medium","--append-system-prompt",e.systemPrompt],p=(0,tb.spawn)("claude",c,{stdio:["pipe","pipe","pipe"],env:{...process.env}});tj(l,JSON.stringify({_meta:{type:"spawned",run_id:o,pid:p.pid}})+"\n");let h=e.reminder?`${e.userPrompt}
47
47
 
48
48
  ---
49
49
 
50
- ${e.reminder}`:e.userPrompt;p.stdin.write(h),p.stdin.end();let m="",_=0,g=0,f=e.model,y="",v=Date.now(),k=-1;p.stdout.on("data",t=>{for(let s of t.toString("utf8").split("\n")){let t=s.trim();if(t){tP(l,t+"\n");try{let s=JSON.parse(t);if("assistant"===s.type){let t=s.message,n=t?.content;if(Array.isArray(n)){for(let t of n)if("text"===t.type&&"string"==typeof t.text&&(m+=t.text,e.onProgress)){let t=Math.floor(m.length/1024);t>k&&(k=t,e.onProgress({bytes:m.length,elapsedMs:Date.now()-v}))}}let a=t?.model;a&&(f=a)}if("result"===s.type){let e=s.usage;e&&(_=e.input_tokens??0,g=e.output_tokens??0)}}catch{}}}}),p.stderr.on("data",e=>{y+=e.toString("utf8")}),p.on("close",e=>{let n=Date.now()-v;(tP(l,JSON.stringify({_meta:{type:"end",run_id:o,ts:new Date().toISOString(),elapsed_ms:n,exit_code:e,content_chars:m.length,input_tokens:_,output_tokens:g,model_used:f,stderr_tail:y?y.trim().slice(-500):null}})+"\n"),0===e||m)?t({content:m,input_tokens:_,output_tokens:g,model:f}):s(Error(`claude exited ${e}: ${y.trim().slice(0,300)}`))}),p.on("error",e=>{tP(l,JSON.stringify({_meta:{type:"spawn_error",run_id:o,ts:new Date().toISOString(),error:e.message}})+"\n"),s(Error(`Failed to spawn claude: ${e.message}`))})})}function tR(e,t){let s=e.trim().replace(/^```(?:json)?\n?/,"").replace(/\n?```\s*$/,"").trim();try{let e=JSON.parse(s),n=t.safeParse(e);if(n.success)return{ok:!0,value:n.data};return{ok:!1,error:"schema: "+n.error.message}}catch(e){return{ok:!1,error:"json: "+e.message}}}function tU(e,t,s){let n;if(e.includes("opus"))n={input:15,output:75};else if(e.includes("sonnet"))n={input:3,output:15};else{if(!e.includes("haiku"))return 0;n={input:1,output:5}}return(t*n.input+s*n.output)/1e6}function tY(e){return tL({systemPrompt:tM,model:e.model,userPrompt:e.userPrompt,reminder:e.reminder,onProgress:e.onProgress})}function tF(e){let t,s,n=e.trim().replace(/^```(?:json)?\n?/,"").replace(/\n?```\s*$/,"").trim();if((s=n.trim().slice(0,200).toLowerCase()).startsWith("you've hit")||s.startsWith("you have hit")||s.startsWith("you have reached")||s.startsWith("rate limit")||s.includes("5-hour limit")||s.includes("weekly limit")||s.includes("usage limit"))return{ok:!1,error:"rate-limited: "+n.slice(0,160),rateLimited:!0};try{t=JSON.parse(n)}catch(e){return{ok:!1,error:"JSON parse failed: "+e.message}}let a=tO.safeParse(t);return a.success?{ok:!0,value:a.data}:{ok:!1,error:"schema validation failed: "+a.error.message}}async function tW(e,t={}){let r,i,o=t.model??"sonnet",l=t.callLLM??tY,d=function(e){let t=[];for(let s of(e.first_user&&t.push(e.first_user),e.enrichment.user_instructions))t.push(s);return t.filter(e=>"human"==(e?s.test(e)?"teammate":n.test(e)?"skill_load":a.test(e)?"slash_command":"human":"human"))}(e),u=(r={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},i=d.slice(0,8).map((e,t)=>`${t+1}. ${e.length<=300?e:e.slice(0,299)+"…"}`).join("\n"),`SLICE FACTS:
51
- ${JSON.stringify(r,null,2)}
50
+ ${e.reminder}`:e.userPrompt;p.stdin.write(h),p.stdin.end();let m="",_=0,g=0,f=e.model,y="",v=Date.now(),k=-1;p.stdout.on("data",t=>{for(let s of t.toString("utf8").split("\n")){let t=s.trim();if(t){tj(l,t+"\n");try{let s=JSON.parse(t);if("assistant"===s.type){let t=s.message,n=t?.content;if(Array.isArray(n)){for(let t of n)if("text"===t.type&&"string"==typeof t.text&&(m+=t.text,e.onProgress)){let t=Math.floor(m.length/1024);t>k&&(k=t,e.onProgress({bytes:m.length,elapsedMs:Date.now()-v}))}}let a=t?.model;a&&(f=a)}if("result"===s.type){let e=s.usage;e&&(_=e.input_tokens??0,g=e.output_tokens??0)}}catch{}}}}),p.stderr.on("data",e=>{y+=e.toString("utf8")}),p.on("close",e=>{let n=Date.now()-v;(tj(l,JSON.stringify({_meta:{type:"end",run_id:o,ts:new Date().toISOString(),elapsed_ms:n,exit_code:e,content_chars:m.length,input_tokens:_,output_tokens:g,model_used:f,stderr_tail:y?y.trim().slice(-500):null}})+"\n"),0===e||m)?t({content:m,input_tokens:_,output_tokens:g,model:f}):s(Error(`claude exited ${e}: ${y.trim().slice(0,300)}`))}),p.on("error",e=>{tj(l,JSON.stringify({_meta:{type:"spawn_error",run_id:o,ts:new Date().toISOString(),error:e.message}})+"\n"),s(Error(`Failed to spawn claude: ${e.message}`))})})}function tM(e,t){let s=e.trim().replace(/^```(?:json)?\n?/,"").replace(/\n?```\s*$/,"").trim();try{let e=JSON.parse(s),n=t.safeParse(e);if(n.success)return{ok:!0,value:n.data};return{ok:!1,error:"schema: "+n.error.message}}catch(e){return{ok:!1,error:"json: "+e.message}}}function tA(e,t,s){let n;if(e.includes("opus"))n={input:15,output:75};else if(e.includes("sonnet"))n={input:3,output:15};else{if(!e.includes("haiku"))return 0;n={input:1,output:5}}return(t*n.input+s*n.output)/1e6}function tE(e){return tO({systemPrompt:tw,model:e.model,userPrompt:e.userPrompt,reminder:e.reminder,onProgress:e.onProgress})}function tZ(e){let t,s,n=e.trim().replace(/^```(?:json)?\n?/,"").replace(/\n?```\s*$/,"").trim();if((s=n.trim().slice(0,200).toLowerCase()).startsWith("you've hit")||s.startsWith("you have hit")||s.startsWith("you have reached")||s.startsWith("rate limit")||s.includes("5-hour limit")||s.includes("weekly limit")||s.includes("usage limit"))return{ok:!1,error:"rate-limited: "+n.slice(0,160),rateLimited:!0};try{t=JSON.parse(n)}catch(e){return{ok:!1,error:"JSON parse failed: "+e.message}}let a=tk.safeParse(t);return a.success?{ok:!0,value:a.data}:{ok:!1,error:"schema validation failed: "+a.error.message}}async function tC(e,t={}){let s,n,a=t.model??"sonnet",r=t.callLLM??tE,i=function(e){let t=[];for(let s of(e.first_user&&t.push(e.first_user),e.enrichment.user_instructions))t.push(s);return t.filter(e=>"human"===(0,d.classifyUserInputSource)(e))}(e),o=(s={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},n=i.slice(0,8).map((e,t)=>`${t+1}. ${e.length<=300?e:e.slice(0,299)+"…"}`).join("\n"),`SLICE FACTS:
51
+ ${JSON.stringify(s,null,2)}
52
52
 
53
53
  HUMAN TURNS (up to 8, each truncated to 300 chars):
54
- ${i||"(none — the user text was filtered out as non-human)"}`),c=new Date().toISOString(),p=0,h=0,m=!1,_=o,g="",f=!0;try{let s=await l({model:o,userPrompt:u,onProgress:t.onProgress});m=!0,p+=s.input_tokens,h+=s.output_tokens,_=s.model;let n=tF(s.content);if(n.ok){let t=tU(_,p,h);return{entry:tz(e,n.value,_,t,c),usage:{input_tokens:p,output_tokens:h}}}if(g=n.error,n.rateLimited||(f=!1),!n.rateLimited){let s=await l({model:o,userPrompt:u,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});p+=s.input_tokens,h+=s.output_tokens,_=s.model;let n=tF(s.content);if(n.ok){let t=tU(_,p,h);return{entry:tz(e,n.value,_,t,c),usage:{input_tokens:p,output_tokens:h}}}g=n.error,n.rateLimited||(f=!1)}}catch(e){g=e.message||"unknown LLM error",f=!1}let y=tU(_,p,h);return{entry:function(e,t,s,n,a,r=!1){if(r){let r={...e.enrichment,status:"pending",generated_at:a,model:s,cost_usd:n,error:t};return{...e,enrichment:r}}let i={...e.enrichment,status:"error",generated_at:a,model:s,cost_usd:n,error:t,retry_count:(e.enrichment.retry_count??0)+1};return{...e,enrichment:i}}(e,g,_,y,c,f),usage:m?{input_tokens:p,output_tokens:h}:null}}function tz(e,t,s,n,a){let r={...e.enrichment,status:"done",generated_at:a,model:s,cost_usd:n,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}}let tB=null;function tV(){return tB||(tB=(0,tC.join)((0,tZ.homedir)(),".cclens","llm-spend.jsonl"))}function tH(e){let t=tV();(0,tE.mkdirSync)((0,tC.dirname)(t),{recursive:!0}),(0,tE.appendFileSync)(t,JSON.stringify(e)+"\n",{encoding:"utf8"})}function tJ(e=new Date){let t=tV();if(!(0,tE.existsSync)(t))return 0;let s=e.getUTCFullYear(),n=e.getUTCMonth(),a=0;for(let e of(0,tE.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()===s&&r.getUTCMonth()===n&&(a+=t.cost_usd)}return a}e.s(["appendSpend",0,tH,"monthToDateSpend",0,tJ],78325);var tq=e.i(5737);let tK=null,tG=null;function tX(){return tK||(tK=(0,tC.join)((0,tZ.homedir)(),".cclens","llm-interactive.lock"))}function tQ(){(0,tE.writeFileSync)(tX(),String(process.pid),"utf8")}function t0(){tQ(),tG&&clearInterval(tG),tG=setInterval(()=>{try{tQ()}catch{}},3e4),tG.unref?.()}function t1(){tG&&(clearInterval(tG),tG=null);try{(0,tE.unlinkSync)(tX())}catch{}}let t2={ai_features:{enabled:!0,model:"sonnet",monthlyBudgetUsd:null,autoBackfillLastWeek:!0,autoBackfillYesterday:!0}},t4=null;function t9(){return t4||(t4=(0,tC.join)((0,tZ.homedir)(),".cclens","settings.json"))}e.s(["readSettings",0,function(){let e=t9();if(!(0,tE.existsSync)(e))return t2;try{let t,s=(0,tE.readFileSync)(e,"utf8");return{ai_features:{enabled:(t=JSON.parse(s).ai_features??{}).enabled??t2.ai_features.enabled,model:t.model??t2.ai_features.model,monthlyBudgetUsd:t.monthly_budget_usd??null,autoBackfillLastWeek:t.auto_backfill_last_week??t2.ai_features.autoBackfillLastWeek,autoBackfillYesterday:t.auto_backfill_yesterday??t2.ai_features.autoBackfillYesterday}}}catch{return t2}},"writeSettings",0,function(e){let t=t9();(0,tE.mkdirSync)((0,tC.dirname)(t),{recursive:!0});let s=`${t}.tmp`;(0,tE.writeFileSync)(s,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,tE.chmodSync)(s,384),(0,tE.renameSync)(s,t)}],56614);var tS=tS;e.i(27174);var t5=e.i(39587);let t3=t5.agentMetadata.map(e=>` - agent="${e.kind}" → render as "${e.displayName}"`).join("\n"),t7=tS.object({headline:tS.string().min(1).max(80),body:tS.string().min(1).max(300)}),t6=tS.object({headline:tS.string().min(1).max(160),narrative:tS.string().max(1200).nullable(),what_went_well:tS.string().max(400).nullable(),what_hit_friction:tS.string().max(400).nullable(),suggestion:t7.nullable(),day_signature:tS.string().max(160).nullable().optional()}).passthrough(),t8=`You are synthesizing a developer's coding-agent activity for a single local day into a short, honest narrative digest.
54
+ ${n||"(none — the user text was filtered out as non-human)"}`),l=new Date().toISOString(),u=0,c=0,p=!1,h=a,m="",_=!0;try{let s=await r({model:a,userPrompt:o,onProgress:t.onProgress});p=!0,u+=s.input_tokens,c+=s.output_tokens,h=s.model;let n=tZ(s.content);if(n.ok){let t=tA(h,u,c);return{entry:tD(e,n.value,h,t,l),usage:{input_tokens:u,output_tokens:c}}}if(m=n.error,n.rateLimited||(_=!1),!n.rateLimited){let s=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});u+=s.input_tokens,c+=s.output_tokens,h=s.model;let n=tZ(s.content);if(n.ok){let t=tA(h,u,c);return{entry:tD(e,n.value,h,t,l),usage:{input_tokens:u,output_tokens:c}}}m=n.error,n.rateLimited||(_=!1)}}catch(e){m=e.message||"unknown LLM error",_=!1}let g=tA(h,u,c);return{entry:function(e,t,s,n,a,r=!1){if(r){let r={...e.enrichment,status:"pending",generated_at:a,model:s,cost_usd:n,error:t};return{...e,enrichment:r}}let i={...e.enrichment,status:"error",generated_at:a,model:s,cost_usd:n,error:t,retry_count:(e.enrichment.retry_count??0)+1};return{...e,enrichment:i}}(e,m,h,g,l,_),usage:p?{input_tokens:u,output_tokens:c}:null}}function tD(e,t,s,n,a){let r={...e.enrichment,status:"done",generated_at:a,model:s,cost_usd:n,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}}let tI=null;function tP(){return tI||(tI=(0,t$.join)((0,tS.homedir)(),".cclens","llm-spend.jsonl"))}function tL(e){let t=tP();(0,tx.mkdirSync)((0,t$.dirname)(t),{recursive:!0}),(0,tx.appendFileSync)(t,JSON.stringify(e)+"\n",{encoding:"utf8"})}function tR(e=new Date){let t=tP();if(!(0,tx.existsSync)(t))return 0;let s=e.getUTCFullYear(),n=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()===s&&r.getUTCMonth()===n&&(a+=t.cost_usd)}return a}e.s(["appendSpend",0,tL,"monthToDateSpend",0,tR],78325);var tU=e.i(5737);let tY=null,tF=null;function tW(){return tY||(tY=(0,t$.join)((0,tS.homedir)(),".cclens","llm-interactive.lock"))}function tz(){(0,tx.writeFileSync)(tW(),String(process.pid),"utf8")}function tB(){tz(),tF&&clearInterval(tF),tF=setInterval(()=>{try{tz()}catch{}},3e4),tF.unref?.()}function tV(){tF&&(clearInterval(tF),tF=null);try{(0,tx.unlinkSync)(tW())}catch{}}let tH={ai_features:{enabled:!0,model:"sonnet",monthlyBudgetUsd:null,autoBackfillLastWeek:!0,autoBackfillYesterday:!0}},tJ=null;function tq(){return tJ||(tJ=(0,t$.join)((0,tS.homedir)(),".cclens","settings.json"))}e.s(["readSettings",0,function(){let e=tq();if(!(0,tx.existsSync)(e))return tH;try{let t,s=(0,tx.readFileSync)(e,"utf8");return{ai_features:{enabled:(t=JSON.parse(s).ai_features??{}).enabled??tH.ai_features.enabled,model:t.model??tH.ai_features.model,monthlyBudgetUsd:t.monthly_budget_usd??null,autoBackfillLastWeek:t.auto_backfill_last_week??tH.ai_features.autoBackfillLastWeek,autoBackfillYesterday:t.auto_backfill_yesterday??tH.ai_features.autoBackfillYesterday}}}catch{return tH}},"writeSettings",0,function(e){let t=tq();(0,tx.mkdirSync)((0,t$.dirname)(t),{recursive:!0});let s=`${t}.tmp`;(0,tx.writeFileSync)(s,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)(s,384),(0,tx.renameSync)(s,t)}],56614);var t_=t_;e.i(27174);var tG=e.i(39587);let tK=tG.agentMetadata.map(e=>` - agent="${e.kind}" → render as "${e.displayName}"`).join("\n"),tX=t_.object({headline:t_.string().min(1).max(80),body:t_.string().min(1).max(300)}),tQ=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:tX.nullable(),day_signature:t_.string().max(160).nullable().optional()}).passthrough(),t0=`You are synthesizing a developer's coding-agent activity for a single local day into a short, honest narrative digest.
55
55
 
56
56
  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.
57
57
 
@@ -96,7 +96,7 @@ CRITICAL RULES:
96
96
  - Second-person ("you ..."), not third-person.
97
97
  - Copy the user's phrasings where useful; do not invent features or outcomes not in the input.
98
98
  - **When DAY FACTS.agent_breakdown has more than one agent, the narrative MUST name them.** Render each agent kind with its canonical display name:
99
- ${t3}
99
+ ${tK}
100
100
  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.
101
101
  - 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.
102
102
  - **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.
@@ -120,7 +120,7 @@ RESPOND WITH ONLY VALID JSON (no prose, no code fence):
120
120
  "what_hit_friction": "..." | null,
121
121
  "suggestion": { "headline": "...", "body": "..." } | null,
122
122
  "day_signature": "..." | null
123
- }`;function se(e,t){return e.length<=t?e:e.slice(0,t-1)+"…"}function st(e){let t=e.split("/").filter(Boolean);return t[t.length-1]??e}function ss(e){let t=e.split("/").filter(Boolean);return t[t.length-1]??e}function sn(e,t){return e.length<=t?e:e.slice(0,t-1).trimEnd()+"…"}function sa(e){let t=e.map(e=>{var t;let s,n,a,i,d,u,p;return e.signals??(n=(t=(s=e.first_user||"").length)<100?"short":t<500?"medium":t<2e3?"long":"very_long",a=function(e){if(!e||/<teammate-message|<task-notification|<local-command-caveat/i.test(e.slice(0,400)))return null;for(let{kind:t,re:s}of c)if(e.match(s))return{kind:t,preview:e.slice(0,160)};return null}(s),i=Object.keys(e.skills??{}).some(e=>/brainstorm|writing-plans/i.test(e)),d=s.trim().toLowerCase(),u=l(s),p=/^continue\b/.test(d)||"continue."===d?"literal-continue":u.includes("handoff-prose")?"handoff-prose":"none",{working_shape:o(e),prompt_frames:u,subagent_roles:(e.subagents??[]).map(r),verbosity:n,external_refs:a?[a]:[],brainstorm_warmup:i,continuation_kind:p})}),s=e.reduce((e,t)=>e+t.numbers.active_min,0),n=new Map,a={};for(let s=0;s<e.length;s++){let r=t[s].working_shape;r&&(n.set(r,(n.get(r)??0)+e[s].numbers.active_min),a[r]=(a[r]??0)+1)}let d=null;if(n.size>0&&s>0){let e=[...n.entries()].sort((e,t)=>t[1]-e[1])[0];d=e[1]/s>=.6?e[0]:"mixed"}let p=new Map;for(let t of e)for(let[e,s]of Object.entries(t.skills??{}))p.set(e,(p.get(e)??0)+s);let h=[...p.entries()].sort((e,t)=>t[1]-e[1]).map(([e,t])=>({skill:e,origin:u(e),count:t})),m=h.filter(e=>"user"===e.origin).map(e=>e.skill),_=new Map;for(let t of e)for(let e of t.subagents??[]){var g;if(g=e.type,i.test(g))continue;let t=_.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),_.set(e.type,t)}let f=[..._.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:sn(t.sample_prompt_preview,200)})),y=new Map;for(let e of t)for(let t of e.prompt_frames)y.set(t,(y.get(t)??0)+1);let v=[...y.entries()].sort((e,t)=>t[1]-e[1]).map(([e,t])=>({frame:e,origin:t$.PROMPT_FRAME_ORIGIN[e],count:t})),k={short:0,medium:0,long:0,very_long:0},w=[],b=0,x=0,S=0,$=0;for(let s=0;s<e.length;s++){let n=e[s],a=t[s];for(let e of((n.first_user??"").length>0&&(k[a.verbosity]+=1),a.external_refs))w.push({session_id:n.session_id,kind:e.kind,preview:sn(e.preview,200)});let r=n.numbers.interrupts??0;b+=r,x+=n.satisfaction_signals?.frustrated??0,S+=n.satisfaction_signals?.dissatisfied??0,r>=2&&($+=1)}let T=t.filter(e=>e.brainstorm_warmup).length;return{dominant_shape:d,shape_distribution:a,skills_loaded:h,user_authored_skills_used:m,user_authored_subagents_used:f,prompt_frames:v,comm_style:{verbosity_distribution:k,external_refs:w,steering:{interrupts:b,frustrated:x,dissatisfied:S,sessions_with_mid_run_redirect:$}},brainstorm_warmup_session_count:T,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 sr(e,t,s={}){let n=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:ss(e),share_pct:n>0?t.minutes/n*100:0,entry_count:t.entry_count})),i=t.flatMap(e=>e.pr_titles.map(t=>({title:t,project:ss(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})),d=new Map;for(let e of t)if("done"===e.enrichment.status)for(let[t,s]of Object.entries(e.enrichment.goal_categories??{}))d.set(t,(d.get(t)??0)+(s??0));let u=[...d.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",s=p.get(t)??{sessions:0,active_min:0,tools_total:0};s.sessions+=1,s.active_min+=e.numbers.active_min,s.tools_total+=e.numbers.tools_total,p.set(t,s)}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:t$.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:u,concurrency_peak:s.concurrencyPeak??0,agent_min:n,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 s of e){let e=s.enrichment.claude_helpfulness;e&&t.set(e,(t.get(e)??0)+1)}if(0===t.size)return null;let s=null,n=0;for(let e of["unhelpful","neutral","helpful","essential"]){let a=t.get(e)??0;a>n&&(s=e,n=a)}return s}(t),day_signals:t.length>0?sa(t):void 0,headline:null,narrative:null,what_went_well:null,what_hit_friction:null,suggestion:null,day_signature:null}}let si=e=>tL({...e,systemPrompt:t8});async function so(e,t,s={}){let n,a,r,i,o,l,d,u=sr(e,t,{concurrencyPeak:s.concurrencyPeak});if(0===t.filter(e=>"done"===e.enrichment.status).length)return{digest:u,usage:null};let c=s.model??"sonnet",p=s.callLLM??si,h=(a=(n=t.filter(e=>"done"===e.enrichment.status)).slice(0,12).map(e=>`- (${st(e.project)}, ${Math.round(e.numbers.active_min)}m) ${se(e.enrichment.brief_summary??"",240)}`).join("\n"),r=n.map(e=>e.enrichment.friction_detail).filter(e=>!!e).slice(0,6).map((e,t)=>`${t+1}. ${se(e,240)}`).join("\n"),i=n.flatMap(e=>e.enrichment.user_instructions).slice(0,10).map((e,t)=>`${t+1}. ${se(e,240)}`).join("\n"),o=t.map(e=>({agent:e.agent??"claude-code",project:st(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:u.key,agent_min:u.agent_min,agent_breakdown:u.agent_breakdown??[],project_count:u.projects.length,projects:u.projects.map(e=>({name:e.display_name,share_pct:e.share_pct,entry_count:e.entry_count})),shipped:u.shipped.map(e=>({title:e.title,project:e.project})),concurrency_peak:u.concurrency_peak,top_flags:u.top_flags,top_goal_categories:u.top_goal_categories,per_entry:o},d=u.day_signals?`
123
+ }`;function t1(e,t){return e.length<=t?e:e.slice(0,t-1)+"…"}function t2(e){let t=e.split("/").filter(Boolean);return t[t.length-1]??e}function t4(e){let t=e.split("/").filter(Boolean);return t[t.length-1]??e}function t9(e,t){return e.length<=t?e:e.slice(0,t-1).trimEnd()+"…"}function t5(e){let t=e.map(e=>e.signals??(0,d.computeEntrySignals)(e)),s=e.reduce((e,t)=>e+t.numbers.active_min,0),n=new Map,a={};for(let s=0;s<e.length;s++){let r=t[s].working_shape;r&&(n.set(r,(n.get(r)??0)+e[s].numbers.active_min),a[r]=(a[r]??0)+1)}let r=null;if(n.size>0&&s>0){let e=[...n.entries()].sort((e,t)=>t[1]-e[1])[0];r=e[1]/s>=.6?e[0]:"mixed"}let i=new Map;for(let t of e)for(let[e,s]of Object.entries(t.skills??{}))i.set(e,(i.get(e)??0)+s);let o=[...i.entries()].sort((e,t)=>t[1]-e[1]).map(([e,t])=>({skill:e,origin:(0,d.classifySkill)(e),count:t})),l=o.filter(e=>"user"===e.origin).map(e=>e.skill),u=new Map;for(let t of e)for(let e of t.subagents??[]){if((0,d.isStockSubagentType)(e.type))continue;let t=u.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),u.set(e.type,t)}let c=[...u.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:t9(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:tg.PROMPT_FRAME_ORIGIN[e],count:t})),m={short:0,medium:0,long:0,very_long:0},_=[],g=0,f=0,y=0,v=0;for(let s=0;s<e.length;s++){let n=e[s],a=t[s];for(let e of((n.first_user??"").length>0&&(m[a.verbosity]+=1),a.external_refs))_.push({session_id:n.session_id,kind:e.kind,preview:t9(e.preview,200)});let r=n.numbers.interrupts??0;g+=r,f+=n.satisfaction_signals?.frustrated??0,y+=n.satisfaction_signals?.dissatisfied??0,r>=2&&(v+=1)}let k=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:g,frustrated:f,dissatisfied:y,sessions_with_mid_run_redirect:v}},brainstorm_warmup_session_count:k,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 t3(e,t,s={}){let n=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:t4(e),share_pct:n>0?t.minutes/n*100:0,entry_count:t.entry_count})),i=t.flatMap(e=>e.pr_titles.map(t=>({title:t,project:t4(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})),d=new Map;for(let e of t)if("done"===e.enrichment.status)for(let[t,s]of Object.entries(e.enrichment.goal_categories??{}))d.set(t,(d.get(t)??0)+(s??0));let u=[...d.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",s=p.get(t)??{sessions:0,active_min:0,tools_total:0};s.sessions+=1,s.active_min+=e.numbers.active_min,s.tools_total+=e.numbers.tools_total,p.set(t,s)}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:tg.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:u,concurrency_peak:s.concurrencyPeak??0,agent_min:n,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 s of e){let e=s.enrichment.claude_helpfulness;e&&t.set(e,(t.get(e)??0)+1)}if(0===t.size)return null;let s=null,n=0;for(let e of["unhelpful","neutral","helpful","essential"]){let a=t.get(e)??0;a>n&&(s=e,n=a)}return s}(t),day_signals:t.length>0?t5(t):void 0,headline:null,narrative:null,what_went_well:null,what_hit_friction:null,suggestion:null,day_signature:null}}let t7=e=>tO({...e,systemPrompt:t0});async function t6(e,t,s={}){let n,a,r,i,o,l,d,u=t3(e,t,{concurrencyPeak:s.concurrencyPeak});if(0===t.filter(e=>"done"===e.enrichment.status).length)return{digest:u,usage:null};let c=s.model??"sonnet",p=s.callLLM??t7,h=(a=(n=t.filter(e=>"done"===e.enrichment.status)).slice(0,12).map(e=>`- (${t2(e.project)}, ${Math.round(e.numbers.active_min)}m) ${t1(e.enrichment.brief_summary??"",240)}`).join("\n"),r=n.map(e=>e.enrichment.friction_detail).filter(e=>!!e).slice(0,6).map((e,t)=>`${t+1}. ${t1(e,240)}`).join("\n"),i=n.flatMap(e=>e.enrichment.user_instructions).slice(0,10).map((e,t)=>`${t+1}. ${t1(e,240)}`).join("\n"),o=t.map(e=>({agent:e.agent??"claude-code",project:t2(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:u.key,agent_min:u.agent_min,agent_breakdown:u.agent_breakdown??[],project_count:u.projects.length,projects:u.projects.map(e=>({name:e.display_name,share_pct:e.share_pct,entry_count:e.entry_count})),shipped:u.shipped.map(e=>({title:e.title,project:e.project})),concurrency_peak:u.concurrency_peak,top_flags:u.top_flags,top_goal_categories:u.top_goal_categories,per_entry:o},d=u.day_signals?`
124
124
 
125
125
  DAY SIGNALS:
126
126
  ${JSON.stringify(u.day_signals,null,2)}`:"",`DAY FACTS:
@@ -133,12 +133,12 @@ FRICTION LINES (up to 6):
133
133
  ${r||"(none — smooth day)"}
134
134
 
135
135
  USER INSTRUCTIONS (up to 10 load-bearing asks):
136
- ${i||"(none)"}`),m=0,_=0,g=c;try{let t,n,a=await p({model:c,userPrompt:h,onProgress:s.onProgress});m+=a.input_tokens,_+=a.output_tokens,g=a.model;let r=(t=a.content,tR(t,t6));if(r.ok)return{digest:{...u,model:g,cost_usd:tU(g,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:s.onProgress});m+=i.input_tokens,_+=i.output_tokens,g=i.model;let o=(n=i.content,tR(n,t6));if(o.ok)return{digest:{...u,model:g,cost_usd:tU(g,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:u,usage:{input_tokens:m,output_tokens:_}}}catch(t){return console.warn(`[digest-day] ${e}: LLM invocation failed (${t.message})`),{digest:u,usage:m>0?{input_tokens:m,output_tokens:_}:null}}}var sl=e.i(76956),sd=e.i(43427),su=e.i(20629),sc=e.i(79357),sp=e.i(30212);async function sh(e){try{let t=await (0,su.listSessions)({limit:1e4}),s=(0,sc.computeBurstsFromSessions)(t),[n,a,r]=e.split("-").map(Number),i=new Date(n,a-1,r,0,0,0,0),o=new Date(n,a-1,r,23,59,59,999);return(0,sp.aggregateConcurrency)(s,{start:i,end:o}).peak}catch{return 0}}async function*sm(e,t){let s=t.now??(()=>Date.now()),n=e===t.todayLocalDay,a=t.settings.enabled;if(!n&&!t.force){let t=(0,sl.readDayDigest)(e);if(t)return void(yield{type:"digest",digest:t})}if(n&&!t.force){let t=(0,sl.getTodayDigestFromCache)(e,s());if(t)return void(yield{type:"digest",digest:t})}let r=(0,tq.listEntriesForDay)(e);if(0===r.length)return void(yield{type:"error",message:`no entries for date ${e}`});a&&t0();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,tq.writeEntry)(t)}}let n=(t.force?(0,tq.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 n=Date.parse(e.end_iso);return!(!Number.isNaN(n)&&s()-n<18e5)});if(n.length>0){yield{type:"status",phase:"enrich",text:`Enriching ${n.length} entries for ${e}`};let s=t.settings.monthlyBudgetUsd??1/0,a=0;for(let e=0;e<n.length;e+=3){if(tJ()>=s){yield{type:"status",phase:"enrich",text:"budget cap reached — stopping enrichment"};break}let r=n.slice(e,e+3);for(let e of(await Promise.all(r.map(e=>tW(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:n.length,status:"error",cost_usd:0};continue}let{result:s,usage:r}=e;(0,tq.writeEntry)(s),r&&tH({ts:new Date().toISOString(),caller:t.caller??"web",model:s.enrichment.model??t.settings.model,input_tokens:r.input_tokens,output_tokens:r.output_tokens,cost_usd:s.enrichment.cost_usd??0,kind:"entry_enrich",ref:`${s.session_id}__${s.local_day}`}),yield{type:"entry",session_id:s.session_id,index:a,total:n.length,status:s.enrichment.status,cost_usd:s.enrichment.cost_usd}}if(tJ()>=s){yield{type:"status",phase:"enrich",text:"budget cap reached — stopping enrichment"};break}}}}let o=(0,tq.listEntriesForDay)(e),l=await sh(e);if(a){yield{type:"status",phase:"synth",text:"Synthesizing day narrative"};let s=[],n=so(e,o,{model:t.settings.model,callLLM:t.callLLM,concurrencyPeak:l,onProgress:e=>{s.push({bytes:e.bytes,elapsed_ms:e.elapsedMs})}}),a=[],r=!1;for(n.finally(()=>{r=!0});!r;){for(await new Promise(e=>setTimeout(e,500));s.length>0;)a.push(s.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 d=await n;i=d.digest,d.usage&&tH({ts:new Date().toISOString(),caller:t.caller??"web",model:i.model??t.settings.model,input_tokens:d.usage.input_tokens,output_tokens:d.usage.output_tokens,cost_usd:i.cost_usd??0,kind:"day_digest",ref:e})}else i=sr(e,o,{concurrencyPeak:l});n?(0,sl.setTodayDigestInCache)(e,i,s()):((0,sl.writeDayDigest)(i),yield{type:"saved",path:`~/.cclens/digests/day/${e}.json`}),yield{type:"digest",digest:i}}finally{a&&t1()}}e.s(["runDayDigestPipeline",0,sm],20441);var tS=tS;let s_=t5.agentMetadata.map(e=>` - agent="${e.kind}" → render as "${e.displayName}"`).join("\n"),sg=/^\d{4}-\d{2}-\d{2}$/,sf=tS.object({display_name:tS.string().min(1),description:tS.string().min(1).max(600)}),sy=tS.object({title:tS.string().min(1).max(120),detail:tS.string().min(1).max(700),anchor:tS.string().min(1).max(80),evidence:tS.object({date:tS.string().regex(sg),quote:tS.string().min(1).max(400)})}),sv=sy.extend({surprise_kind:tS.enum(["outlier","novel-use","user-built-tool","cross-week-contrast"])}),sk=sy.extend({lean_kind:tS.enum(["claude-md","skill","hook","harness","decision"]),copyable:tS.string().max(2e3).nullable()}),sw=tS.object({headline:tS.string().min(1).max(180),key_pattern:tS.string().min(1).max(280),trajectory:tS.array(tS.object({date:tS.string().regex(sg),line:tS.string().min(1).max(280)})).min(1),standout_days:tS.array(tS.object({date:tS.string().regex(sg),why:tS.string().min(1).max(500)})).min(1).max(2),project_areas:tS.array(sf).min(1),what_worked:tS.array(sy).min(1).max(6),what_stalled:tS.array(sy).max(5),what_surprised:tS.array(sv).max(4),where_to_lean:tS.array(sk).min(1).max(7)}).passthrough(),sb=`You are the weekly retrospective writer for Fleetlens, a dashboard for multi-agent coding fleets (Claude Code, OpenAI Codex CLI, and possibly more).
136
+ ${i||"(none)"}`),m=0,_=0,g=c;try{let t,n,a=await p({model:c,userPrompt:h,onProgress:s.onProgress});m+=a.input_tokens,_+=a.output_tokens,g=a.model;let r=(t=a.content,tM(t,tQ));if(r.ok)return{digest:{...u,model:g,cost_usd:tA(g,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:s.onProgress});m+=i.input_tokens,_+=i.output_tokens,g=i.model;let o=(n=i.content,tM(n,tQ));if(o.ok)return{digest:{...u,model:g,cost_usd:tA(g,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:u,usage:{input_tokens:m,output_tokens:_}}}catch(t){return console.warn(`[digest-day] ${e}: LLM invocation failed (${t.message})`),{digest:u,usage:m>0?{input_tokens:m,output_tokens:_}:null}}}var t8=e.i(76956),se=e.i(43427),st=e.i(20629),ss=e.i(79357),sn=e.i(30212);async function sa(e){try{let t=await (0,st.listSessions)({limit:1e4}),s=(0,ss.computeBurstsFromSessions)(t),[n,a,r]=e.split("-").map(Number),i=new Date(n,a-1,r,0,0,0,0),o=new Date(n,a-1,r,23,59,59,999);return(0,sn.aggregateConcurrency)(s,{start:i,end:o}).peak}catch{return 0}}async function*sr(e,t){let s=t.now??(()=>Date.now()),n=e===t.todayLocalDay,a=t.settings.enabled;if(!n&&!t.force){let t=(0,t8.readDayDigest)(e);if(t)return void(yield{type:"digest",digest:t})}if(n&&!t.force){let t=(0,t8.getTodayDigestFromCache)(e,s());if(t)return void(yield{type:"digest",digest:t})}let r=(0,tU.listEntriesForDay)(e);if(0===r.length)return void(yield{type:"error",message:`no entries for date ${e}`});a&&tB();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,tU.writeEntry)(t)}}let n=(t.force?(0,tU.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 n=Date.parse(e.end_iso);return!(!Number.isNaN(n)&&s()-n<18e5)});if(n.length>0){yield{type:"status",phase:"enrich",text:`Enriching ${n.length} entries for ${e}`};let s=t.settings.monthlyBudgetUsd??1/0,a=0;for(let e=0;e<n.length;e+=3){if(tR()>=s){yield{type:"status",phase:"enrich",text:"budget cap reached — stopping enrichment"};break}let r=n.slice(e,e+3);for(let e of(await Promise.all(r.map(e=>tC(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:n.length,status:"error",cost_usd:0};continue}let{result:s,usage:r}=e;(0,tU.writeEntry)(s),r&&tL({ts:new Date().toISOString(),caller:t.caller??"web",model:s.enrichment.model??t.settings.model,input_tokens:r.input_tokens,output_tokens:r.output_tokens,cost_usd:s.enrichment.cost_usd??0,kind:"entry_enrich",ref:`${s.session_id}__${s.local_day}`}),yield{type:"entry",session_id:s.session_id,index:a,total:n.length,status:s.enrichment.status,cost_usd:s.enrichment.cost_usd}}if(tR()>=s){yield{type:"status",phase:"enrich",text:"budget cap reached — stopping enrichment"};break}}}}let o=(0,tU.listEntriesForDay)(e),l=await sa(e);if(a){yield{type:"status",phase:"synth",text:"Synthesizing day narrative"};let s=[],n=t6(e,o,{model:t.settings.model,callLLM:t.callLLM,concurrencyPeak:l,onProgress:e=>{s.push({bytes:e.bytes,elapsed_ms:e.elapsedMs})}}),a=[],r=!1;for(n.finally(()=>{r=!0});!r;){for(await new Promise(e=>setTimeout(e,500));s.length>0;)a.push(s.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 d=await n;i=d.digest,d.usage&&tL({ts:new Date().toISOString(),caller:t.caller??"web",model:i.model??t.settings.model,input_tokens:d.usage.input_tokens,output_tokens:d.usage.output_tokens,cost_usd:i.cost_usd??0,kind:"day_digest",ref:e})}else i=t3(e,o,{concurrencyPeak:l});n?(0,t8.setTodayDigestInCache)(e,i,s()):((0,t8.writeDayDigest)(i),yield{type:"saved",path:`~/.cclens/digests/day/${e}.json`}),yield{type:"digest",digest:i}}finally{a&&tV()}}e.s(["runDayDigestPipeline",0,sr],20441);var t_=t_;let si=tG.agentMetadata.map(e=>` - agent="${e.kind}" → render as "${e.displayName}"`).join("\n"),so=/^\d{4}-\d{2}-\d{2}$/,sl=t_.object({display_name:t_.string().min(1),description:t_.string().min(1).max(600)}),sd=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(so),quote:t_.string().min(1).max(400)})}),su=sd.extend({surprise_kind:t_.enum(["outlier","novel-use","user-built-tool","cross-week-contrast"])}),sc=sd.extend({lean_kind:t_.enum(["claude-md","skill","hook","harness","decision"]),copyable:t_.string().max(2e3).nullable()}),sp=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(so),line:t_.string().min(1).max(280)})).min(1),standout_days:t_.array(t_.object({date:t_.string().regex(so),why:t_.string().min(1).max(500)})).min(1).max(2),project_areas:t_.array(sl).min(1),what_worked:t_.array(sd).min(1).max(6),what_stalled:t_.array(sd).max(5),what_surprised:t_.array(su).max(4),where_to_lean:t_.array(sc).min(1).max(7)}).passthrough(),sh=`You are the weekly retrospective writer for Fleetlens, a dashboard for multi-agent coding fleets (Claude Code, OpenAI Codex CLI, and possibly more).
137
137
 
138
138
  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.
139
139
 
140
140
  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:
141
- ${s_}
141
+ ${si}
142
142
  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).
143
143
 
144
144
  The reader sees, before reading your prose:
@@ -280,7 +280,7 @@ VOCABULARY RULES:
280
280
  - 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.
281
281
  - Prefer naming the actual subagent type ("\`general-purpose\` dispatches", "\`superpowers:code-reviewer\`") over abstract "subagents" when the type is load-bearing.
282
282
  - "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.
283
- `,sx=["shipped","partial","blocked","exploratory","trivial","idle"];function sS(e){let t=e.split("/").filter(Boolean);return t[t.length-1]??e}function s$(e){let t=new Date(`${e}T00:00:00`),s=[];for(let e=0;e<7;e++){let n=new Date(t);n.setDate(t.getDate()+e),s.push(function(e){let t=e.getFullYear(),s=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${t}-${s}-${n}`}(n))}return s}function sT(e,t){return e.length<=t?e:e.slice(0,t-1).trimEnd()+"…"}function sN(e,t){return e.day_signals??sa(t)}let sj=["spec-review-loop","chunk-implementation","reviewer-triad","research-then-build","background-coordinated","solo-continuation","solo-design","solo-build"];function sO(e,t,s={}){let n=s$(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 s=i.get(t.name)??{agent_min:0,shipped_count:0};s.agent_min+=t.share_pct/100*e.agent_min,i.set(t.name,s)}for(let e of t)for(let t of e.shipped){let s=e.projects.find(e=>e.display_name===t.project),n=s?s.name:t.project,a=i.get(n)??{agent_min:0,shipped_count:0};a.shipped_count+=1,i.set(n,a)}let d=[...i.entries()].sort((e,t)=>t[1].agent_min-e[1].agent_min).map(([e,t])=>({name:e,display_name:sS(e),agent_min:t.agent_min,share_pct:r>0?t.agent_min/r*100:0,shipped_count:t.shipped_count,description:null})),u=[];for(let e of t)for(let t of e.shipped)u.push({title:t.title,project:t.project,date:e.key,session_id:t.session_id});let c={};for(let e of t)c[e.outcome_day]=(c[e.outcome_day]??0)+1;let p=n.map(e=>{let t=a.get(e);return t?t.helpfulness_day:null}),h=new Map;for(let e of t)for(let t of e.top_flags)h.set(t.flag,(h.get(t.flag)??0)+t.count);let m=[...h.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({flag:e,count:t})),_=new Map;for(let e of t)for(let t of e.top_goal_categories)_.set(t.category,(_.get(t.category)??0)+t.minutes);let g=[..._.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 y=s.entriesByDay??new Map,v=t.filter(e=>e.agent_min>0).sort((e,t)=>e.key.localeCompare(t.key)).map(e=>{let t=y.get(e.key)??[],s=e.day_signals??(t.length>0?sa(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:s?.dominant_shape??null}}),k=null;for(let e of v)(!k||e.agent_min>k.agent_min)&&(k={date:e.date,agent_min:e.agent_min,shipped_count:e.shipped_count});let w=[];for(let e of y.values())w.push(...e);let b=null,x=Array(24).fill(0);for(let e of w){(!b||e.numbers.active_min>b.active_min)&&(b={session_id:e.session_id,date:e.local_day,project_display:sS(e.project),active_min:e.numbers.active_min});let t=Date.parse(e.start_iso);if(!Number.isNaN(t)){let s=new Date(t).getHours();x[s]=(x[s]??0)+e.numbers.active_min}}let S=t.length>0?function(e,t=new Map){let s=new Map,n=new Map;for(let t of e)s.set(t.key,t.outcome_day),n.set(t.key,t.helpfulness_day);let a=new Map;for(let s of e){let e=t.get(s.key)??[];for(let t of Object.keys(sN(s,e).shape_distribution)){let n=a.get(t)??[];n.push({dd:s,entries:e}),a.set(t,n)}}let r=[];for(let e of sj){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??o(t))===e),i=r.sort((e,t)=>{let s=(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)-s})[0]??r[0]??null,l=null;if(i?.subagents&&i.subagents.length>0){let e=[...i.subagents].sort((e,t)=>t.prompt_preview.length-e.prompt_preview.length)[0];l={type:e.type,description:e.description,prompt_preview:sT(e.prompt_preview,200)}}let d=i?sS(i.project):t.projects[0]?.display_name??"";return{date:t.key,session_id:i?.session_id??"",project_display:d,outcome:s.get(t.key)??null,helpfulness:n.get(t.key)??null,evidence_subagent:l,evidence_first_user:i?.first_user?sT(i.first_user,200):null,day_signature:t.day_signature??null}}),l={};for(let e of i)e.outcome&&(l[e.outcome]=(l[e.outcome]??0)+1);r.push({shape:e,occurrences:i,outcome_distribution:l})}return r}(t,y):null,$=t.length>0?function(e,t=new Map){let s=new Set,n=new Map,a=new Map,r=new Map,i={short:0,medium:0,long:0,very_long:0},o=[],d=0,u=0,c=0,p=0,h=0,m=new Set;for(let l of e){let e=l.key,_=sN(l,t.get(e)??[]);for(let t of(_.brainstorm_warmup_session_count>0&&s.add(e),h+=_.todo_ops_total,_.plan_mode_used&&m.add(e),_.prompt_frames)){let s=n.get(t.frame)??{count:0,days:new Set};s.count+=t.count,s.days.add(e),n.set(t.frame,s)}for(let t of _.skills_loaded){if("user"!==t.origin)continue;let s=a.get(t.skill)??{count:0,days:new Set};s.count+=t.count,s.days.add(e),a.set(t.skill,s)}for(let t of _.user_authored_subagents_used){let s=r.get(t.type)??{count:0,days:new Set,sample_description:t.sample_description,sample_prompt_preview:t.sample_prompt_preview};s.count+=t.count,s.days.add(e),t.sample_prompt_preview.length>s.sample_prompt_preview.length&&(s.sample_description=t.sample_description,s.sample_prompt_preview=t.sample_prompt_preview),r.set(t.type,s)}let g=_.comm_style.verbosity_distribution;for(let t of(i.short+=g.short,i.medium+=g.medium,i.long+=g.long,i.very_long+=g.very_long,_.comm_style.external_refs))o.push({date:e,session_id:t.session_id,ref_kind:t.kind,preview:sT(t.preview,200)});d+=_.comm_style.steering.interrupts,u+=_.comm_style.steering.frustrated,c+=_.comm_style.steering.dissatisfied,p+=_.comm_style.steering.sessions_with_mid_run_redirect}let _=new Map,g=0,f=0;for(let[,e]of t)for(let t of e){g+=t.numbers.turn_count??0,f+=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 s=t.reduce((e,t)=>e+t.numbers.active_min,0),n=t[t.length-1];y.push({thread_id:e,entries:t.map(e=>({date:e.local_day,session_id:e.session_id,project_display:sS(e.project),has_handoff_frame:l(e.first_user).includes("handoff-prose")})),total_active_min:s,outcome:n.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 s=e.includes("-")?e.split("-")[0]:e,n=v.get(s)??{members:new Set,total_count:0,days:new Set};for(let s of(n.members.add(e),n.total_count+=t.count,t.days))n.days.add(s);v.set(s,n)}let k=[...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:[...s].sort(),prompt_frames:[...n.entries()].sort((e,t)=>t[1].count-e[1].count).map(([e,t])=>({frame:e,origin:t$.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:k,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:sT(t.sample_prompt_preview,200)})),threads:y,communication_style:{verbosity_distribution:i,external_context_refs:o,steering:{total_interrupts:d,total_frustrated:u,total_dissatisfied:c,sessions_with_mid_run_redirect:p,total_turns:g}},todo_ops_total:h,plan_mode:{exit_plan_calls:f,days_with_plan:m.size}}}(t,y):null,T=w.length>0?function(e){let t=new Map,s=new Map,n=new Map,a=new Set,r=0,i=0,o=0,l=0,d=0,u=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,d+=m.numbers.interrupts,u+=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&&s.set(e,(s.get(e)??0)+m.numbers.skill_calls),(m.numbers.exit_plan_calls>0||m.flags.includes("plan_used"))&&n.set(e,(n.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})),g=[],f=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(g.length>=3)break;f.has(t.type)||(f.add(t.type),g.push({date:e.local_day,project_display:sS(e.project),type:t.type,prompt_preview:sT(t.prompt_preview,200)}))}let v=[],k=new Set;for(let t of e)for(let e of Object.keys(t.skills)){if(v.length>=3)break;k.has(e)||t.first_user&&!(t.first_user.length<8)&&(k.add(e),v.push({date:t.local_day,skill:e,first_user_preview:sT(t.first_user,200)}))}let w=null;for(let t of e)t.flags.includes("long_autonomous")&&(!w||t.numbers.active_min>w.numbers.active_min)&&(w=t);let b=w?{date:w.local_day,project_display:sS(w.project),active_min:w.numbers.active_min,top_tools:w.top_tools.slice(0,5),first_user_preview:sT(w.first_user,200)}:null,x=c>0?u/c:0;return{orchestration:{subagent_calls:r,task_ops:i,days_with_subagents:t.size,top_types:m,examples:g},skill_use:{skill_calls:o,days_with_skills:s.size,top_skills:_,examples:v},plan_gating:{exit_plan_calls:l,days_with_plan:n.size},turn_shape:{tools_per_turn:Math.round(10*x)/10,interrupts:d,long_autonomous_days:a.size,label:x<5?"rapid":x<15?"mixed":"batch",longest_turn:b}}}(w):null,N=n[6],j={start:`${e}T00:00:00`,end:`${N}T23:59:59`};return{version:t$.CURRENT_WEEK_DIGEST_SCHEMA_VERSION,scope:"week",key:e,window:j,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:d,shipped:u,outcome_mix:c,helpfulness_sparkline:p,top_flags:m,top_goal_categories:g,concurrency_peak_day:f,days_active:v,busiest_day:k,longest_run:b,hours_distribution:x,interaction_modes:T,working_shapes:S,interaction_grammar:$,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 sM=e=>tL({...e,systemPrompt:sb});function sA(e){return e.toLowerCase().replace(/\s+/g," ").trim()}function sE(e,t,s,n){let a=sA(n),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,sA(t.join(" \n ")))}for(let e of s){let t=e.local_day,s=r.get(t)??"",n=[e.first_user,e.final_agent,...(e.subagents??[]).flatMap(e=>[e.description,e.prompt_preview])].filter(e=>!!e).join(" \n ");r.set(t,sA(s+" \n "+n))}let i=e=>{let t=sA(e.evidence.quote);if(a.includes(t))return!0;let s=r.get(e.evidence.date);return!!s&&s.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 sZ(e,t,s={}){let n=sO(e,t,{entriesByDay:s.entriesByDay}),a=t.filter(e=>null!==e.headline),r=s.allowSingleDay?1:2;if(a.length<r)return{digest:n,usage:null};let i=s.model??"sonnet",o=s.callLLM??sM,l=function(e,t){let s=[],n=(e="")=>s.push(e),a=new Map;for(let e of t)for(let t of e.shipped){let s=a.get(t.project)??[];s.push({title:t.title,date:e.key}),a.set(t.project,s)}n(`# Week ${e.key} (${e.window.start} → ${e.window.end})`),n(),n(`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(", ");n(`Per-agent week breakdown: ${e}.`)}let i={shipped:0,partial:0,blocked:0,exploratory:0,trivial:0,idle:0};for(let t of sx)i[t]=e.outcome_mix[t]??0;let o=sx.filter(e=>i[e]>0).map(e=>`${e}=${i[e]}`).join(", ");for(let t of(n(`Outcome mix: ${o||"(empty)"}.`),n(`Helpfulness sparkline (Mon→Sun): ${e.helpfulness_sparkline.map(e=>e??"·").join(" ")}`),e.concurrency_peak_day&&n(`Concurrency peak day: ${e.concurrency_peak_day}.`),n(),n("## 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),s=(a.get(e)??[]).slice(0,8),r=s.length>0?s.map(e=>` - "${e.title}" (${e.date})`).join("\n"):" - (no PRs shipped)";n(`- ${e} — ${Math.round(t.agent_min)}m, ${Math.round(10*t.share_pct)/10}% share, ${t.shipped_count} PR${1===t.shipped_count?"":"s"}`),n(r)}n(),e.top_flags.length>0&&n(`Top flags: ${e.top_flags.map(e=>`${e.flag}(${e.count})`).join(", ")}`),e.top_goal_categories.length>0&&n(`Goal-category minutes: ${e.top_goal_categories.map(e=>`${e.category}=${e.minutes}m`).join(", ")}`),n(),n("## Working shapes (deterministic, already classified)");let l=e.working_shapes??[];if(0===l.length)n("(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(),s=Object.entries(e.outcome_distribution??{}).filter(([,e])=>e>0).map(([e,t])=>`${e}:${t}`).join(", ");n(`- ${e.shape} — ${e.occurrences.length} occurrence(s) on [${t.join(", ")}]${s?`; outcomes ${s}`:""}`)}n(),n("## Interaction grammar");let d=e.interaction_grammar;if(d){if(d.brainstorming_warmup_days?.length&&n(`- Brainstorm-warmup days (${d.brainstorming_warmup_days.length}): ${d.brainstorming_warmup_days.join(", ")}`),d.prompt_frames?.length){let e=d.prompt_frames.map(e=>`${e.frame}(${e.origin})\xd7${e.count}`).join(", ");n(`- Prompt frames: ${e}`)}if(d.user_authored_skills?.length){let e=d.user_authored_skills.map(e=>`${e.skill}\xd7${e.count}`).join(", ");n(`- User-authored skills: ${e}`)}if(d.skill_families?.length){let e=d.skill_families.map(e=>`${e.family}(${e.members.length} members, ${e.total_count} uses)`).join(", ");n(`- Skill families: ${e}`)}if(d.user_authored_subagents?.length){let e=d.user_authored_subagents.map(e=>`${e.type}\xd7${e.count}`).join(", ");n(`- User-authored subagent types: ${e}`)}d.threads?.length&&n(`- Multi-day threads: ${d.threads.length} (total ${d.threads.reduce((e,t)=>e+t.total_active_min,0)}m active)`);let e=d.communication_style;if(e){let t=e.verbosity_distribution;n(`- Verbosity: short=${t.short}, medium=${t.medium}, long=${t.long}, very_long=${t.very_long}`);let s=e.external_context_refs;s.length&&n(`- External-ref openings (${s.length}): ${s.slice(0,5).map(e=>`${e.ref_kind}@${e.date}`).join(", ")}`);let a=e.steering;n(`- 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`)}n(`- TodoWrite ops total: ${d.todo_ops_total}`),d.plan_mode&&n(`- Plan Mode: ${d.plan_mode.exit_plan_calls} exit_plan calls, ${d.plan_mode.days_with_plan} day(s) with plan use`)}else n("(none)");let u=t.slice().sort((e,t)=>e.key.localeCompare(t.key));for(let e of(n(),n("## Day summaries"),u)){var c;n();let t=e.top_flags.slice(0,5).map(e=>`${e.flag}(${e.count})`).join(", "),s=e.day_signals?.dominant_shape??null,a=s?` \xb7 shape: ${s}`:"";if(n(`### ${(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(", ");n(`Agent breakdown: ${t}`)}e.headline&&n(`Headline: ${e.headline}`),e.day_signature&&n(`Signature: ${e.day_signature}`),e.what_went_well&&n(`Went well: ${e.what_went_well}`),e.what_hit_friction&&n(`Hit friction: ${e.what_hit_friction}`),e.suggestion&&n(`Suggestion: ${e.suggestion.headline} — ${e.suggestion.body}`),t&&n(`Flags: ${t}`),null!==e.helpfulness_day&&void 0!==e.helpfulness_day&&n(`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&&n(`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(", ");n(`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(", ");n(`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(", ");n(`Prompt frames: ${e}`)}let t=r.comm_style.verbosity_distribution;n(`Verbosity: short=${t.short}, medium=${t.medium}, long=${t.long}, very_long=${t.very_long}`);let s=r.comm_style.steering;n(`Steering: ${s.interrupts} interrupts, ${s.frustrated} frustrated, ${s.dissatisfied} dissatisfied, ${s.sessions_with_mid_run_redirect} mid-run redirects`),r.brainstorm_warmup_session_count>0&&n(`Brainstorm-warmup sessions: ${r.brainstorm_warmup_session_count}`),r.plan_mode_used&&n("Plan Mode: used"),r.todo_ops_total>0&&n(`TodoWrite ops: ${r.todo_ops_total}`)}}return s.join("\n")}(n,t),d=0,u=0,c=i,p=[];for(let e of(s.entriesByDay??new Map).values())p.push(...e);function h(e){let t=n.projects.map(t=>{let s=e.project_areas.find(e=>e.display_name===t.display_name);return s?{...t,description:s.description}:t});return{...n,projects:t,model:c,cost_usd:tU(c,d,u),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:s.onProgress});d+=m.input_tokens,u+=m.output_tokens,c=m.model;let _=(a=m.content,tR(a,sw));if(_.ok)return{digest:h(sE(_.value,t,p,l)),usage:{input_tokens:d,output_tokens:u}};let g=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:s.onProgress});d+=g.input_tokens,u+=g.output_tokens,c=g.model;let f=(r=g.content,tR(r,sw));if(f.ok)return{digest:h(sE(f.value,t,p,l)),usage:{input_tokens:d,output_tokens:u}};return console.warn(`[digest-week] ${e}: LLM response failed validation after retry (${f.error})`),{digest:n,usage:{input_tokens:d,output_tokens:u}}}catch(t){return console.warn(`[digest-week] ${e}: LLM invocation failed (${t.message})`),{digest:n,usage:d>0?{input_tokens:d,output_tokens:u}:null}}}var tS=tS;let sC=/^\d{4}-\d{2}-\d{2}$/,sI=tS.object({headline:tS.string().min(1).max(120),body:tS.string().min(1).max(800)}),sD=tS.object({headline:tS.string().min(1).max(160),trajectory:tS.array(tS.object({week_start:tS.string().regex(sC),line:tS.string().min(1).max(280)})).min(1),standout_weeks:tS.array(tS.object({week_start:tS.string().regex(sC),why:tS.string().min(1).max(400)})).min(1).max(2),friction_themes:tS.string().max(800),suggestion:sI}).passthrough(),sP=`You are the monthly digest writer for Fleetlens.
283
+ `,sm=["shipped","partial","blocked","exploratory","trivial","idle"];function s_(e){let t=e.split("/").filter(Boolean);return t[t.length-1]??e}function sg(e){let t=new Date(`${e}T00:00:00`),s=[];for(let e=0;e<7;e++){let n=new Date(t);n.setDate(t.getDate()+e),s.push(function(e){let t=e.getFullYear(),s=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${t}-${s}-${n}`}(n))}return s}function sf(e,t){return e.length<=t?e:e.slice(0,t-1).trimEnd()+"…"}function sy(e,t){return e.day_signals??t5(t)}let sv=["spec-review-loop","chunk-implementation","reviewer-triad","research-then-build","background-coordinated","solo-continuation","solo-design","solo-build"];function sk(e,t,s={}){let n=sg(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 s=i.get(t.name)??{agent_min:0,shipped_count:0};s.agent_min+=t.share_pct/100*e.agent_min,i.set(t.name,s)}for(let e of t)for(let t of e.shipped){let s=e.projects.find(e=>e.display_name===t.project),n=s?s.name:t.project,a=i.get(n)??{agent_min:0,shipped_count:0};a.shipped_count+=1,i.set(n,a)}let o=[...i.entries()].sort((e,t)=>t[1].agent_min-e[1].agent_min).map(([e,t])=>({name:e,display_name:s_(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 u={};for(let e of t)u[e.outcome_day]=(u[e.outcome_day]??0)+1;let c=n.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})),g=null;for(let e of t)e.concurrency_peak>0&&(!g||e.concurrency_peak>g.peak)&&(g={date:e.key,peak:e.concurrency_peak});let f=s.entriesByDay??new Map,y=t.filter(e=>e.agent_min>0).sort((e,t)=>e.key.localeCompare(t.key)).map(e=>{let t=f.get(e.key)??[],s=e.day_signals??(t.length>0?t5(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:s?.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 k=[];for(let e of f.values())k.push(...e);let w=null,b=Array(24).fill(0);for(let e of k){(!w||e.numbers.active_min>w.active_min)&&(w={session_id:e.session_id,date:e.local_day,project_display:s_(e.project),active_min:e.numbers.active_min});let t=Date.parse(e.start_iso);if(!Number.isNaN(t)){let s=new Date(t).getHours();b[s]=(b[s]??0)+e.numbers.active_min}}let x=t.length>0?function(e,t=new Map){let s=new Map,n=new Map;for(let t of e)s.set(t.key,t.outcome_day),n.set(t.key,t.helpfulness_day);let a=new Map;for(let s of e){let e=t.get(s.key)??[];for(let t of Object.keys(sy(s,e).shape_distribution)){let n=a.get(t)??[];n.push({dd:s,entries:e}),a.set(t,n)}}let r=[];for(let e of sv){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,d.inferWorkingShape)(t))===e),i=r.sort((e,t)=>{let s=(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)-s})[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:sf(e.prompt_preview,200)}}let l=i?s_(i.project):t.projects[0]?.display_name??"";return{date:t.key,session_id:i?.session_id??"",project_display:l,outcome:s.get(t.key)??null,helpfulness:n.get(t.key)??null,evidence_subagent:o,evidence_first_user:i?.first_user?sf(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,f):null,S=t.length>0?function(e,t=new Map){let s=new Set,n=new Map,a=new Map,r=new Map,i={short:0,medium:0,long:0,very_long:0},o=[],l=0,u=0,c=0,p=0,h=0,m=new Set;for(let d of e){let e=d.key,_=sy(d,t.get(e)??[]);for(let t of(_.brainstorm_warmup_session_count>0&&s.add(e),h+=_.todo_ops_total,_.plan_mode_used&&m.add(e),_.prompt_frames)){let s=n.get(t.frame)??{count:0,days:new Set};s.count+=t.count,s.days.add(e),n.set(t.frame,s)}for(let t of _.skills_loaded){if("user"!==t.origin)continue;let s=a.get(t.skill)??{count:0,days:new Set};s.count+=t.count,s.days.add(e),a.set(t.skill,s)}for(let t of _.user_authored_subagents_used){let s=r.get(t.type)??{count:0,days:new Set,sample_description:t.sample_description,sample_prompt_preview:t.sample_prompt_preview};s.count+=t.count,s.days.add(e),t.sample_prompt_preview.length>s.sample_prompt_preview.length&&(s.sample_description=t.sample_description,s.sample_prompt_preview=t.sample_prompt_preview),r.set(t.type,s)}let g=_.comm_style.verbosity_distribution;for(let t of(i.short+=g.short,i.medium+=g.medium,i.long+=g.long,i.very_long+=g.very_long,_.comm_style.external_refs))o.push({date:e,session_id:t.session_id,ref_kind:t.kind,preview:sf(t.preview,200)});l+=_.comm_style.steering.interrupts,u+=_.comm_style.steering.frustrated,c+=_.comm_style.steering.dissatisfied,p+=_.comm_style.steering.sessions_with_mid_run_redirect}let _=new Map,g=0,f=0;for(let[,e]of t)for(let t of e){g+=t.numbers.turn_count??0,f+=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 s=t.reduce((e,t)=>e+t.numbers.active_min,0),n=t[t.length-1];y.push({thread_id:e,entries:t.map(e=>({date:e.local_day,session_id:e.session_id,project_display:s_(e.project),has_handoff_frame:(0,d.detectPromptFrames)(e.first_user).includes("handoff-prose")})),total_active_min:s,outcome:n.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 s=e.includes("-")?e.split("-")[0]:e,n=v.get(s)??{members:new Set,total_count:0,days:new Set};for(let s of(n.members.add(e),n.total_count+=t.count,t.days))n.days.add(s);v.set(s,n)}let k=[...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:[...s].sort(),prompt_frames:[...n.entries()].sort((e,t)=>t[1].count-e[1].count).map(([e,t])=>({frame:e,origin:tg.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:k,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:sf(t.sample_prompt_preview,200)})),threads:y,communication_style:{verbosity_distribution:i,external_context_refs:o,steering:{total_interrupts:l,total_frustrated:u,total_dissatisfied:c,sessions_with_mid_run_redirect:p,total_turns:g}},todo_ops_total:h,plan_mode:{exit_plan_calls:f,days_with_plan:m.size}}}(t,f):null,$=k.length>0?function(e){let t=new Map,s=new Map,n=new Map,a=new Set,r=0,i=0,o=0,l=0,d=0,u=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,d+=m.numbers.interrupts,u+=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&&s.set(e,(s.get(e)??0)+m.numbers.skill_calls),(m.numbers.exit_plan_calls>0||m.flags.includes("plan_used"))&&n.set(e,(n.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})),g=[],f=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(g.length>=3)break;f.has(t.type)||(f.add(t.type),g.push({date:e.local_day,project_display:s_(e.project),type:t.type,prompt_preview:sf(t.prompt_preview,200)}))}let v=[],k=new Set;for(let t of e)for(let e of Object.keys(t.skills)){if(v.length>=3)break;k.has(e)||t.first_user&&!(t.first_user.length<8)&&(k.add(e),v.push({date:t.local_day,skill:e,first_user_preview:sf(t.first_user,200)}))}let w=null;for(let t of e)t.flags.includes("long_autonomous")&&(!w||t.numbers.active_min>w.numbers.active_min)&&(w=t);let b=w?{date:w.local_day,project_display:s_(w.project),active_min:w.numbers.active_min,top_tools:w.top_tools.slice(0,5),first_user_preview:sf(w.first_user,200)}:null,x=c>0?u/c:0;return{orchestration:{subagent_calls:r,task_ops:i,days_with_subagents:t.size,top_types:m,examples:g},skill_use:{skill_calls:o,days_with_skills:s.size,top_skills:_,examples:v},plan_gating:{exit_plan_calls:l,days_with_plan:n.size},turn_shape:{tools_per_turn:Math.round(10*x)/10,interrupts:d,long_autonomous_days:a.size,label:x<5?"rapid":x<15?"mixed":"batch",longest_turn:b}}}(k):null,T=n[6],N={start:`${e}T00:00:00`,end:`${T}T23:59:59`};return{version:tg.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:u,helpfulness_sparkline:c,top_flags:h,top_goal_categories:_,concurrency_peak_day:g,days_active:y,busiest_day:v,longest_run:w,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 sw=e=>tO({...e,systemPrompt:sh});function sb(e){return e.toLowerCase().replace(/\s+/g," ").trim()}function sx(e,t,s,n){let a=sb(n),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,sb(t.join(" \n ")))}for(let e of s){let t=e.local_day,s=r.get(t)??"",n=[e.first_user,e.final_agent,...(e.subagents??[]).flatMap(e=>[e.description,e.prompt_preview])].filter(e=>!!e).join(" \n ");r.set(t,sb(s+" \n "+n))}let i=e=>{let t=sb(e.evidence.quote);if(a.includes(t))return!0;let s=r.get(e.evidence.date);return!!s&&s.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 sS(e,t,s={}){let n=sk(e,t,{entriesByDay:s.entriesByDay}),a=t.filter(e=>null!==e.headline),r=s.allowSingleDay?1:2;if(a.length<r)return{digest:n,usage:null};let i=s.model??"sonnet",o=s.callLLM??sw,l=function(e,t){let s=[],n=(e="")=>s.push(e),a=new Map;for(let e of t)for(let t of e.shipped){let s=a.get(t.project)??[];s.push({title:t.title,date:e.key}),a.set(t.project,s)}n(`# Week ${e.key} (${e.window.start} → ${e.window.end})`),n(),n(`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(", ");n(`Per-agent week breakdown: ${e}.`)}let i={shipped:0,partial:0,blocked:0,exploratory:0,trivial:0,idle:0};for(let t of sm)i[t]=e.outcome_mix[t]??0;let o=sm.filter(e=>i[e]>0).map(e=>`${e}=${i[e]}`).join(", ");for(let t of(n(`Outcome mix: ${o||"(empty)"}.`),n(`Helpfulness sparkline (Mon→Sun): ${e.helpfulness_sparkline.map(e=>e??"·").join(" ")}`),e.concurrency_peak_day&&n(`Concurrency peak day: ${e.concurrency_peak_day}.`),n(),n("## 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),s=(a.get(e)??[]).slice(0,8),r=s.length>0?s.map(e=>` - "${e.title}" (${e.date})`).join("\n"):" - (no PRs shipped)";n(`- ${e} — ${Math.round(t.agent_min)}m, ${Math.round(10*t.share_pct)/10}% share, ${t.shipped_count} PR${1===t.shipped_count?"":"s"}`),n(r)}n(),e.top_flags.length>0&&n(`Top flags: ${e.top_flags.map(e=>`${e.flag}(${e.count})`).join(", ")}`),e.top_goal_categories.length>0&&n(`Goal-category minutes: ${e.top_goal_categories.map(e=>`${e.category}=${e.minutes}m`).join(", ")}`),n(),n("## Working shapes (deterministic, already classified)");let l=e.working_shapes??[];if(0===l.length)n("(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(),s=Object.entries(e.outcome_distribution??{}).filter(([,e])=>e>0).map(([e,t])=>`${e}:${t}`).join(", ");n(`- ${e.shape} — ${e.occurrences.length} occurrence(s) on [${t.join(", ")}]${s?`; outcomes ${s}`:""}`)}n(),n("## Interaction grammar");let d=e.interaction_grammar;if(d){if(d.brainstorming_warmup_days?.length&&n(`- Brainstorm-warmup days (${d.brainstorming_warmup_days.length}): ${d.brainstorming_warmup_days.join(", ")}`),d.prompt_frames?.length){let e=d.prompt_frames.map(e=>`${e.frame}(${e.origin})\xd7${e.count}`).join(", ");n(`- Prompt frames: ${e}`)}if(d.user_authored_skills?.length){let e=d.user_authored_skills.map(e=>`${e.skill}\xd7${e.count}`).join(", ");n(`- User-authored skills: ${e}`)}if(d.skill_families?.length){let e=d.skill_families.map(e=>`${e.family}(${e.members.length} members, ${e.total_count} uses)`).join(", ");n(`- Skill families: ${e}`)}if(d.user_authored_subagents?.length){let e=d.user_authored_subagents.map(e=>`${e.type}\xd7${e.count}`).join(", ");n(`- User-authored subagent types: ${e}`)}d.threads?.length&&n(`- Multi-day threads: ${d.threads.length} (total ${d.threads.reduce((e,t)=>e+t.total_active_min,0)}m active)`);let e=d.communication_style;if(e){let t=e.verbosity_distribution;n(`- Verbosity: short=${t.short}, medium=${t.medium}, long=${t.long}, very_long=${t.very_long}`);let s=e.external_context_refs;s.length&&n(`- External-ref openings (${s.length}): ${s.slice(0,5).map(e=>`${e.ref_kind}@${e.date}`).join(", ")}`);let a=e.steering;n(`- 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`)}n(`- TodoWrite ops total: ${d.todo_ops_total}`),d.plan_mode&&n(`- Plan Mode: ${d.plan_mode.exit_plan_calls} exit_plan calls, ${d.plan_mode.days_with_plan} day(s) with plan use`)}else n("(none)");let u=t.slice().sort((e,t)=>e.key.localeCompare(t.key));for(let e of(n(),n("## Day summaries"),u)){var c;n();let t=e.top_flags.slice(0,5).map(e=>`${e.flag}(${e.count})`).join(", "),s=e.day_signals?.dominant_shape??null,a=s?` \xb7 shape: ${s}`:"";if(n(`### ${(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(", ");n(`Agent breakdown: ${t}`)}e.headline&&n(`Headline: ${e.headline}`),e.day_signature&&n(`Signature: ${e.day_signature}`),e.what_went_well&&n(`Went well: ${e.what_went_well}`),e.what_hit_friction&&n(`Hit friction: ${e.what_hit_friction}`),e.suggestion&&n(`Suggestion: ${e.suggestion.headline} — ${e.suggestion.body}`),t&&n(`Flags: ${t}`),null!==e.helpfulness_day&&void 0!==e.helpfulness_day&&n(`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&&n(`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(", ");n(`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(", ");n(`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(", ");n(`Prompt frames: ${e}`)}let t=r.comm_style.verbosity_distribution;n(`Verbosity: short=${t.short}, medium=${t.medium}, long=${t.long}, very_long=${t.very_long}`);let s=r.comm_style.steering;n(`Steering: ${s.interrupts} interrupts, ${s.frustrated} frustrated, ${s.dissatisfied} dissatisfied, ${s.sessions_with_mid_run_redirect} mid-run redirects`),r.brainstorm_warmup_session_count>0&&n(`Brainstorm-warmup sessions: ${r.brainstorm_warmup_session_count}`),r.plan_mode_used&&n("Plan Mode: used"),r.todo_ops_total>0&&n(`TodoWrite ops: ${r.todo_ops_total}`)}}return s.join("\n")}(n,t),d=0,u=0,c=i,p=[];for(let e of(s.entriesByDay??new Map).values())p.push(...e);function h(e){let t=n.projects.map(t=>{let s=e.project_areas.find(e=>e.display_name===t.display_name);return s?{...t,description:s.description}:t});return{...n,projects:t,model:c,cost_usd:tA(c,d,u),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:s.onProgress});d+=m.input_tokens,u+=m.output_tokens,c=m.model;let _=(a=m.content,tM(a,sp));if(_.ok)return{digest:h(sx(_.value,t,p,l)),usage:{input_tokens:d,output_tokens:u}};let g=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:s.onProgress});d+=g.input_tokens,u+=g.output_tokens,c=g.model;let f=(r=g.content,tM(r,sp));if(f.ok)return{digest:h(sx(f.value,t,p,l)),usage:{input_tokens:d,output_tokens:u}};return console.warn(`[digest-week] ${e}: LLM response failed validation after retry (${f.error})`),{digest:n,usage:{input_tokens:d,output_tokens:u}}}catch(t){return console.warn(`[digest-week] ${e}: LLM invocation failed (${t.message})`),{digest:n,usage:d>0?{input_tokens:d,output_tokens:u}:null}}}var t_=t_;let s$=/^\d{4}-\d{2}-\d{2}$/,sT=t_.object({headline:t_.string().min(1).max(120),body:t_.string().min(1).max(800)}),sN=t_.object({headline:t_.string().min(1).max(160),trajectory:t_.array(t_.object({week_start:t_.string().regex(s$),line:t_.string().min(1).max(280)})).min(1),standout_weeks:t_.array(t_.object({week_start:t_.string().regex(s$),why:t_.string().min(1).max(400)})).min(1).max(2),friction_themes:t_.string().max(800),suggestion:sT}).passthrough(),sj=`You are the monthly digest writer for Fleetlens.
284
284
 
285
285
  You receive a JSON payload describing one calendar month, summarised through its 4–5 weekly digests.
286
286
  Your job: produce a 5-field JSON object capturing the shape of the month.
@@ -318,9 +318,9 @@ RULES:
318
318
  2. Trajectory lines name the dominant work of each week — projects shipped, themes that ran across multiple days, blockers that persisted.
319
319
  3. Standout weeks are weeks that shipped disproportionately, were unusually blocked, or shifted the trajectory of the month.
320
320
  4. Friction themes look at recurrence — friction that appeared in 2+ weeks deserves naming; one-week friction usually doesn't.
321
- 5. Strict JSON.`,sL=["shipped","partial","blocked","exploratory","trivial","idle"];function sR(e){let[t,s]=e.split("-"),n=Number(t),a=Number(s),r=[],i=(8-new Date(n,a-1,1).getDay())%7,o=new Date(new Date(n,a-1,1+i));for(;o.getMonth()===a-1;)r.push(sU(o)),o.setDate(o.getDate()+7);return r}function sU(e){let t=e.getFullYear(),s=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${t}-${s}-${n}`}function sY(e,t){let s=sR(e),n=new Map;for(let e of t)n.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 s;return{name:e,display_name:(s=e.split("/").filter(Boolean))[s.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,s]of Object.entries(e.outcome_mix))l[t]=(l[t]??0)+s;let d=s.map(e=>{let t=n.get(e);return{week_start:e,helpfulness:t?t.helpfulness_sparkline.find(e=>null!==e)??null:null}}),u=new Map;for(let e of t)for(let t of e.top_flags)u.set(t.flag,(u.get(t.flag)??0)+t.count);let c=[...u.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[_,g]=e.split("-"),f=Number(_),y=Number(g),v=`${e}-01`,k=sU(new Date(f,y,0)),w={start:`${v}T00:00:00`,end:`${k}T23:59:59`};return{version:t$.CURRENT_MONTH_DIGEST_SCHEMA_VERSION,scope:"month",key:e,window:w,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:d,top_flags:c,top_goal_categories:h,concurrency_peak_week:m,headline:null,trajectory:null,standout_weeks:null,friction_themes:null,suggestion:null}}let sF=e=>tL({...e,systemPrompt:sP});async function sW(e,t,s={}){let n=sY(e,t);if(t.filter(e=>null!==e.headline).length<2)return{digest:n,usage:null};let a=s.model??"sonnet",r=s.callLLM??sF,i=function(e,t){let s=t.slice().sort((e,t)=>e.key.localeCompare(t.key)).map(e=>{let t=e.helpfulness_sparkline.find(e=>null!==e)??null,s=e.friction_categories&&e.friction_categories.length>0?e.friction_categories.map(e=>`${e.category}: ${e.description}`).join(" "):null,n=e.suggestions?.usage_patterns?.[0],a=n?{headline:n.title,body:n.suggestion}:null;return{week_start:e.key,headline:e.headline,trajectory:e.trajectory,standout_days:e.standout_days,friction_themes:s,suggestion:a,agent_min:Math.round(e.agent_min_total),helpfulness_week:t}}),n={shipped:0,partial:0,blocked:0,exploratory:0,trivial:0,idle:0};for(let t of sL)n[t]=e.outcome_mix[t]??0;return JSON.stringify({period:{start:e.window.start,end:e.window.end,label:function(e){let[t,s]=e.split("-");return t&&s?new Date(Number(t),Number(s)-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:s.length},outcome_mix:n,helpfulness_by_week:e.helpfulness_by_week,projects:e.projects.slice(0,5).map(e=>{var t;let s;return{display_name:e.display_name??(s=(t=e.name).split("/").filter(Boolean))[s.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:s},null,2)}(n,t),o=0,l=0,d=a;try{let t,u,c=await r({model:a,userPrompt:i,onProgress:s.onProgress});o+=c.input_tokens,l+=c.output_tokens,d=c.model;let p=(t=c.content,tR(t,sD));if(p.ok)return{digest:{...n,model:d,cost_usd:tU(d,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:s.onProgress});o+=h.input_tokens,l+=h.output_tokens,d=h.model;let m=(u=h.content,tR(u,sD));if(m.ok)return{digest:{...n,model:d,cost_usd:tU(d,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:n,usage:{input_tokens:o,output_tokens:l}}}catch(t){return console.warn(`[digest-month] ${e}: LLM invocation failed (${t.message})`),{digest:n,usage:o>0?{input_tokens:o,output_tokens:l}:null}}}var tS=tS;function sz(e){return Math.round(e/1e3/60*10)/10}function sB(e,t){return e?e.length<=2*t+60?{chars:e.length,preview:e}:{chars:e.length,preview:e.slice(0,t)+`
321
+ 5. Strict JSON.`,sO=["shipped","partial","blocked","exploratory","trivial","idle"];function sM(e){let[t,s]=e.split("-"),n=Number(t),a=Number(s),r=[],i=(8-new Date(n,a-1,1).getDay())%7,o=new Date(new Date(n,a-1,1+i));for(;o.getMonth()===a-1;)r.push(sA(o)),o.setDate(o.getDate()+7);return r}function sA(e){let t=e.getFullYear(),s=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${t}-${s}-${n}`}function sE(e,t){let s=sM(e),n=new Map;for(let e of t)n.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 s;return{name:e,display_name:(s=e.split("/").filter(Boolean))[s.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,s]of Object.entries(e.outcome_mix))l[t]=(l[t]??0)+s;let d=s.map(e=>{let t=n.get(e);return{week_start:e,helpfulness:t?t.helpfulness_sparkline.find(e=>null!==e)??null:null}}),u=new Map;for(let e of t)for(let t of e.top_flags)u.set(t.flag,(u.get(t.flag)??0)+t.count);let c=[...u.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[_,g]=e.split("-"),f=Number(_),y=Number(g),v=`${e}-01`,k=sA(new Date(f,y,0)),w={start:`${v}T00:00:00`,end:`${k}T23:59:59`};return{version:tg.CURRENT_MONTH_DIGEST_SCHEMA_VERSION,scope:"month",key:e,window:w,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:d,top_flags:c,top_goal_categories:h,concurrency_peak_week:m,headline:null,trajectory:null,standout_weeks:null,friction_themes:null,suggestion:null}}let sZ=e=>tO({...e,systemPrompt:sj});async function sC(e,t,s={}){let n=sE(e,t);if(t.filter(e=>null!==e.headline).length<2)return{digest:n,usage:null};let a=s.model??"sonnet",r=s.callLLM??sZ,i=function(e,t){let s=t.slice().sort((e,t)=>e.key.localeCompare(t.key)).map(e=>{let t=e.helpfulness_sparkline.find(e=>null!==e)??null,s=e.friction_categories&&e.friction_categories.length>0?e.friction_categories.map(e=>`${e.category}: ${e.description}`).join(" "):null,n=e.suggestions?.usage_patterns?.[0],a=n?{headline:n.title,body:n.suggestion}:null;return{week_start:e.key,headline:e.headline,trajectory:e.trajectory,standout_days:e.standout_days,friction_themes:s,suggestion:a,agent_min:Math.round(e.agent_min_total),helpfulness_week:t}}),n={shipped:0,partial:0,blocked:0,exploratory:0,trivial:0,idle:0};for(let t of sO)n[t]=e.outcome_mix[t]??0;return JSON.stringify({period:{start:e.window.start,end:e.window.end,label:function(e){let[t,s]=e.split("-");return t&&s?new Date(Number(t),Number(s)-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:s.length},outcome_mix:n,helpfulness_by_week:e.helpfulness_by_week,projects:e.projects.slice(0,5).map(e=>{var t;let s;return{display_name:e.display_name??(s=(t=e.name).split("/").filter(Boolean))[s.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:s},null,2)}(n,t),o=0,l=0,d=a;try{let t,u,c=await r({model:a,userPrompt:i,onProgress:s.onProgress});o+=c.input_tokens,l+=c.output_tokens,d=c.model;let p=(t=c.content,tM(t,sN));if(p.ok)return{digest:{...n,model:d,cost_usd:tA(d,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:s.onProgress});o+=h.input_tokens,l+=h.output_tokens,d=h.model;let m=(u=h.content,tM(u,sN));if(m.ok)return{digest:{...n,model:d,cost_usd:tA(d,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:n,usage:{input_tokens:o,output_tokens:l}}}catch(t){return console.warn(`[digest-month] ${e}: LLM invocation failed (${t.message})`),{digest:n,usage:o>0?{input_tokens:o,output_tokens:l}:null}}}var t_=t_;function sD(e){return Math.round(e/1e3/60*10)/10}function sI(e,t){return e?e.length<=2*t+60?{chars:e.length,preview:e}:{chars:e.length,preview:e.slice(0,t)+`
322
322
  […truncated ${e.length-2*t} chars…]
323
- `+e.slice(-t)}:null}function sV(e){let t=[...e].sort((e,t)=>e-t),s=0;for(let e=1;e<t.length;e++){let n=t[e]-t[e-1];n<18e4&&(s+=n)}return s}let sH=new Set(["sudo","time","nohup","nice","env","exec"]),sJ=/\[request interrupted|interrupted by user/i,sq=/--title\s+["']([^"']+)["']/,sK=tS.object({start_min:tS.number(),end_min:tS.number().optional(),kind:tS.enum(["user-steering","subagent-burst","long-autonomous","plan-mode","pr-ship","harness-chain","interrupt","brainstorm-loop","agent-loop"]),label:tS.string().min(1).transform(e=>{if(e.length<=320)return e;let t=317,s=e.charCodeAt(t-1);return s>=55296&&s<=56319&&(t-=1),e.slice(0,t)+"..."})}),sG=tS.object({why_picked:tS.string().min(1).max(280),session_summary:tS.string().min(1).max(400),what_worked:tS.string().max(280).nullable(),what_hit_friction:tS.string().max(280).nullable(),steering_summary:tS.string().min(1).max(280),pins:tS.array(sK).min(2).max(6)}).passthrough(),sX=`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.
323
+ `+e.slice(-t)}:null}function sP(e){let t=[...e].sort((e,t)=>e-t),s=0;for(let e=1;e<t.length;e++){let n=t[e]-t[e-1];n<18e4&&(s+=n)}return s}let sL=new Set(["sudo","time","nohup","nice","env","exec"]),sR=/\[request interrupted|interrupted by user/i,sU=/--title\s+["']([^"']+)["']/,sY=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,s=e.charCodeAt(t-1);return s>=55296&&s<=56319&&(t-=1),e.slice(0,t)+"..."})}),sF=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(sY).min(2).max(6)}).passthrough(),sW=`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.
324
324
 
325
325
  INPUT shape (transcript-style markdown, NOT JSON):
326
326
  The user prompt is a markdown document with these sections:
@@ -383,6 +383,6 @@ VOCABULARY:
383
383
  - Internal flag tokens (loop_suspected, long_autonomous, fast_ship) — forbidden in labels
384
384
  - "Plan Mode" specifically means /plan tool calls
385
385
  - Avoid identity claims ("you're a Plan Mode person"). Stick to observed action.
386
- `,sQ=e=>tL({...e,systemPrompt:sX});async function s0(e,t={}){let s={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:s,usage:null};let n=t.model??"sonnet",a=t.callLLM??sQ,r=function(e){let t=[],s=(e="")=>t.push(e);s(`# Session ${e.session_id}`),s(`Project: ${e.project_display} \xb7 Date: ${e.date} \xb7 Started: ${e.start_iso}`),s(`Wall: ${e.wall_min}m \xb7 Active: ${e.active_min}m \xb7 Idle: ${e.idle_min}m \xb7 Turns: ${e.turn_count}`);let n=[];if(e.outcome&&n.push(`Outcome: ${e.outcome}`),e.working_shape&&n.push(`Working shape: ${e.working_shape}`),n.length&&s(n.join(" · ")),e.day_signature&&s(`Day signature: "${e.day_signature}"`),e.shipped_prs.length)for(let t of(s(`Shipped PRs (${e.shipped_prs.length}):`),e.shipped_prs))s(` - "${t}"`);if(s(),s("## Harness"),s(`- 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(", ");s(`- User-authored subagents: ${t}`)}s(`- Stock skills loaded: ${e.stock_skills.length?e.stock_skills.join(", "):"(none)"}`),s(`- Top tools: ${e.top_tools.length?e.top_tools.join(", "):"(none)"}`),s();let a=e.steering;for(let t of(s("## Steering"),s(`${a.user_msg_count} user messages (median ${a.median_user_msg_chars} chars, ${a.long_user_msg_count} long, ${a.interrupts} interrupts)`),s(),s(`## Turns (${e.turns.length})`),e.turns)){s();let e=t.idle_before_min>0?` \xb7 ${t.idle_before_min}m idle before`:"";if(s(`### Turn ${t.turn} — ${t.start_min}m–${t.end_min}m (${t.wall_min}m wall, ${t.active_min}m active${e})`),t.user&&s(`USER (${t.user.chars}c): ${t.user.preview}`),t.first_agent&&s(`FIRST_AGENT (${t.first_agent.chars}c): ${t.first_agent.preview}`),t.last_agent&&s(`LAST_AGENT (${t.last_agent.chars}c): ${t.last_agent.preview}`),!t.agent||t.first_agent||t.last_agent||s(`AGENT (${t.agent.chars}c): ${t.agent.preview}`),t.tools.length&&s(`Tools: ${t.tools.join(", ")}`),t.skills_loaded?.length&&s(`Skills loaded this turn: ${t.skills_loaded.join(", ")}`),t.subagents_dispatched?.length)for(let e of t.subagents_dispatched)s(`Subagent dispatched: ${e.type} — ${e.description}`),e.prompt_preview&&s(` prompt: ${e.prompt_preview}`);let n=[];t.exit_plan_calls&&n.push(`exit_plan\xd7${t.exit_plan_calls}`),t.todo_ops&&n.push(`TodoWrite ops: ${t.todo_ops}`),t.interrupts&&n.push(`interrupts: ${t.interrupts}`),t.pr_created&&n.push(`PR created: "${t.pr_created}"`),t.long_autonomous_run&&n.push("LONG-AUTONOMOUS RUN"),n.length&&s(`Signals: ${n.join(" · ")}`)}if(s(),s('## Candidate pins (deterministic — pick + label the most editorial 3-6 of these for your "pins" output)'),0===e.candidate_pins.length)s("(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`,n=[];for(let[e,s]of Object.entries(t.context??{}))null!=s&&("string"==typeof s?n.push(`${e}="${s.length>200?s.slice(0,197)+"...":s}"`):Array.isArray(s)?n.push(`${e}=[${s.length} items]`):"object"==typeof s?n.push(`${e}={...}`):n.push(`${e}=${s}`));s(`- [${e}] ${t.kind}${n.length?` — ${n.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{...s,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 d,u,c=await a({model:n,userPrompt:r,onProgress:t.onProgress});i+=c.input_tokens,o+=c.output_tokens,c.model;let p=(d=c.content,tR(d,sG));if(p.ok)return{topSession:l(p.value),usage:{input_tokens:i,output_tokens:o}};let h=await a({model:n,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=(u=h.content,tR(u,sG));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:s,usage:{input_tokens:i,output_tokens:o}}}catch(t){return console.warn(`[top-session] ${e.session_id}: LLM invocation failed (${t.message})`),{topSession:s,usage:i>0?{input_tokens:i,output_tokens:o}:null}}finally{}}async function*s1(e,t){let s=t.now??(()=>Date.now()),n=e===t.currentWeekMonday,a=t.settings.enabled;if(!n&&!t.force){let t=(0,sl.readWeekDigest)(e);if(t)return void(yield{type:"digest",digest:t})}if(n&&!t.force){let t=(0,sl.getCurrentWeekDigestFromCache)(e,s());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=s$(e),l=[];for(let e of r){if(e>t.todayLocalDay){yield{type:"dependency",kind:"day",key:e,status:"cached"};continue}let s=e===t.todayLocalDay,n=s?null:(0,sl.readDayDigest)(e);if(n){l.push(n),yield{type:"dependency",kind:"day",key:e,status:"cached"};continue}if(s){let s={settings:t.settings,force:t.force??!1,callLLM:t.callLLM,now:t.now,todayLocalDay:t.todayLocalDay,caller:t.caller},n=null,a=!1;for await(let t of sm(e,s))if("digest"===t.type&&"day"===t.digest.scope&&(n=t.digest),"error"===t.type){a=!0;break}n?(l.push(n),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,i=!1;for await(let t of sm(e,a)){if("digest"===t.type){"day"===t.digest.scope&&(r=t.digest);continue}if("saved"!==t.type){if("error"===t.type){i=!0;continue}yield t}}r?(l.push(r),yield{type:"dependency",kind:"day",key:e,status:"generated"}):i&&(yield{type:"dependency",kind:"day",key:e,status:"failed"})}if(0===l.length)return void(yield{type:"error",message:`no day digests available for week of ${e}`});let d=new Map;for(let e of r)e>t.todayLocalDay||d.set(e,(0,tq.listEntriesForDay)(e));a&&t0();try{let r,c=new Map(l.map(e=>[e.key,e])),p=a?function(e){let t=[];for(let s of e.values())t.push(...s);let s=e=>e.numbers.active_min*(1+.5*e.numbers.subagent_calls+5*e.pr_titles.length),n=t.filter(e=>e.numbers.active_min>=20||e.numbers.turn_count>=10||e.pr_titles.length>=1).map(e=>({entry:e,score:s(e)})).sort((e,t)=>t.score-e.score),a=new Set,r=[];for(let{entry:e}of n)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:s(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}(d):[],h=(await Promise.all(p.map(async e=>{try{let t=await (0,sd.getAnySession)(e.session_id);if(!t)return null;let s=t.events,n=c.get(e.local_day);return{entry:e,slice:function(e,t,s){var n,a;let r,l=Date.parse(e.start_iso),{turns:d,sliceStartMs:c,sliceEndMs:p}=function(e,t,s){let n=[];for(let a of e){if(!a.timestamp)continue;let e=Date.parse(a.timestamp);!Number.isNaN(e)&&(e<t||e>s||n.push({...a,_ts:e}))}if(0===n.length)return{turns:[],sliceStartMs:t,sliceEndMs:s};n.sort((e,t)=>e._ts-t._ts);let a=n[0]._ts,r=n[n.length-1]._ts,i=[],o=null;for(let e of n){let t=e.blocks??[],s="user"===e.role||"tool-result"===e.role,n="agent"===e.role||"agent-thinking"===e.role||"tool-call"===e.role;if(s)if(t.length>0&&t.every(e=>"tool_result"===e.type))o&&(o.events.push(e),o.timestamps.push(e._ts));else{let s=t.filter(e=>"text"===e.type).map(e=>e.text).join(" "),n=sJ.test(s);o&&n&&(o.interrupts+=1),o&&i.push(o),o={events:[e],user_text:s,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(n){if(!o)continue;for(let s of(o.events.push(e),o.timestamps.push(e._ts),t))if(s&&"object"==typeof s){if("text"===s.type&&s.text)o.agent_blocks.push(s.text);else if("tool_use"===s.type){let e=s.name??"unknown";if(o.tools_count.set(e,(o.tools_count.get(e)??0)+1),"Skill"===e){let e=String(s.input?.skill??"unknown");o.skills.set(e,(o.skills.get(e)??0)+1)}else if("Agent"===e){let e=s.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(s.input?.command??""),t=function(e){if(!e)return"?";let t=e.split(/\|\||&&|;|\|/,1)[0].trim();if(t.startsWith("cd ")){let s=e.split(/&&|;/,3);s.length>=2&&(t=s[1].trim())}let s=t.split(/\s+/).filter(Boolean);for(;s.length&&sH.has(s[0]);)s.shift();if(!s.length)return"?";let n=s[0];if(n.includes("=")&&!n.startsWith("/")){if(s.shift(),!s.length)return"?";n=s[0]}return n.includes("/")&&!n.startsWith("./")&&(n=n.replace(/\/+$/,"").split("/").pop()),n.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(sq);o.pr_created=t?.[1]??e.slice(0,120)}}}}}}return o&&i.push(o),{turns:i,sliceStartMs:a,sliceEndMs:r}}(t,l,Date.parse(e.end_iso)),h=d.flatMap(e=>e.timestamps),m=p-c,_=sV(h),g=[...h].sort((e,t)=>e-t),f=[];if(g.length>0){let e=g[0],t=g[0];for(let s=1;s<g.length;s++)g[s]-t>=18e4&&(f.push({start_min:sz(e-c),end_min:sz(t-c)}),e=g[s]),t=g[s];f.push({start_min:sz(e-c),end_min:sz(t-c)})}let y=[],v=c,k=[],w=0;d.forEach((e,t)=>{let s=Math.min(...e.timestamps),n=Math.max(...e.timestamps),a=sV(e.timestamps),r=0===t?0:Math.max(0,s-v);v=n,e.user_text&&(k.push(e.user_text.length),e.user_text.length>=800&&w++);let i=null,o=null;e.agent_blocks.length>0&&(i=e.agent_blocks[0],o=e.agent_blocks.reduce((e,t)=>t.length>e.length?t:e));let l=null!==i&&i===o,d=[];for(let[t,s]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${s} (${t})`)}else d.push(s>1?`${t}\xd7${s}`:t);let u={turn:t+1,start_min:sz(s-c),end_min:sz(n-c),wall_min:sz(n-s),active_min:sz(a),idle_before_min:sz(r),start_iso:new Date(s).toISOString(),user:e.user_text?sB(e.user_text,0===t?400:150):null,tools:d};l?u.agent=sB(i,200):(u.first_agent=i?sB(i,150):null,u.last_agent=o?sB(o,200):null),e.skills.size>0&&(u.skills_loaded=[...e.skills.entries()].map(([e,t])=>t>1?`${e}\xd7${t}`:e)),e.subagents.length>0&&(u.subagents_dispatched=e.subagents.map(e=>({type:e.type,description:e.description,prompt_preview:e.prompt_preview}))),e.exit_plan_calls>0&&(u.exit_plan_calls=e.exit_plan_calls),e.todo_ops>0&&(u.todo_ops=e.todo_ops),e.interrupts>0&&(u.interrupts=e.interrupts),e.pr_created&&(u.pr_created=e.pr_created),a>=12e5&&0===e.interrupts&&(u.long_autonomous_run=!0),y.push(u)});let b=new Map,x=new Map,S=new Map,$=new Map,T=0;for(let e of d){for(let[t,s]of e.skills)b.set(t,(b.get(t)??0)+s);for(let t of e.subagents)n=t.type,i.test(n)||x.set(t.type,(x.get(t.type)??0)+1);for(let[t,s]of e.tools_count)S.set(t,(S.get(t)??0)+s);for(let[t,s]of e.bash_verbs)$.set(t,($.get(t)??0)+s);T+=e.interrupts}let N=[],j=[];for(let e of b.keys()){let t=u(e);"user"===t?N.push(e):"stock"===t&&j.push(e)}let O=[];for(let[e,t]of[...S.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5))if("Bash"===e&&$.size>0){let e=[...$.entries()].sort((e,t)=>t[1]-e[1]).slice(0,3).map(([e,t])=>t>1?`${e}\xd7${t}`:e).join(", ");O.push(`Bash\xd7${t} (${e})`)}else O.push(`${e}\xd7${t}`);k.sort((e,t)=>e-t);let M=0===k.length?0:k[Math.floor(k.length/2)],A=[];for(let e of y)e.user?.chars&&e.user.chars>=800&&A.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&&A.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&&A.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&&A.push({start_min:e.start_min,kind:"plan-mode",context:{turn:e.turn}}),e.pr_created&&A.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&&A.push({start_min:e.start_min,kind:"harness-chain",context:{skills:e.skills_loaded,turn:e.turn}}),e.interrupts&&e.interrupts>0&&A.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=(a=e.project).split("/").filter(Boolean))[r.length-1]??a,start_iso:new Date(c).toISOString(),wall_min:sz(m),active_min:sz(_),idle_min:sz(m-_),turn_count:y.length,outcome:e.enrichment.outcome,shipped_prs:e.pr_titles,working_shape:e.signals?.working_shape??o(e),day_signature:s,user_authored_skills:N,user_authored_subagents:[...x.entries()].sort((e,t)=>t[1]-e[1]).map(([e,t])=>({type:e,count:t})),stock_skills:j,top_tools:O,steering:{user_msg_count:k.length,long_user_msg_count:w,median_user_msg_chars:M,interrupts:T},active_intervals:f,turns:y,candidate_pins:A}}(e,s,n?.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:h.length>0?`Synthesizing week narrative + diving into ${h.length} top session${1===h.length?"":"s"} in parallel`:"Synthesizing week narrative"};let s=[],a=sZ(e,l,{model:t.settings.model,callLLM:t.callLLM,entriesByDay:d,allowSingleDay:!0===t.force&&n,onProgress:e=>{s.push({bytes:e.bytes,elapsed_ms:e.elapsedMs})}}),i=Promise.all(h.map(({entry:e,slice:s})=>s0(s,{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)))),o=!1,u=!1;for(a.finally(()=>{o=!0}),i.finally(()=>{u=!0});!o||!u;)if(await new Promise(e=>setTimeout(e,500)),s.length>0){let e=s[s.length-1];yield{type:"progress",phase:"synth",bytes:e.bytes,elapsed_ms:e.elapsed_ms},s.length=0}let c=await a,p=await i;r=c.digest,c.usage&&tH({ts:new Date().toISOString(),caller:t.caller??"web",model:r.model??t.settings.model,input_tokens:c.usage.input_tokens,output_tokens:c.usage.output_tokens,cost_usd:r.cost_usd??0,kind:"week_digest",ref:e});let m=[];for(let s of p)s&&(m.push({...s.topSession,agent:s.entry.agent}),s.usage&&tH({ts:new Date().toISOString(),caller:t.caller??"web",model:t.settings.model,input_tokens:s.usage.input_tokens,output_tokens:s.usage.output_tokens,cost_usd:tU(t.settings.model,s.usage.input_tokens,s.usage.output_tokens),kind:"top_session",ref:`${e}/${s.entry.session_id}`}));r.headline&&m.length>0&&(r.top_sessions=m)}else r=sO(e,l,{entriesByDay:d});n?(r.is_live=!0,(0,sl.setCurrentWeekDigestInCache)(e,r,s()),!0===t.force&&((0,sl.writeWeekDigest)(r),yield{type:"saved",path:`~/.cclens/digests/week/${e}.json`})):((0,sl.writeWeekDigest)(r),yield{type:"saved",path:`~/.cclens/digests/week/${e}.json`}),yield{type:"digest",digest:r}}finally{a&&t1()}}async function*s2(e,t){let s=t.now??(()=>Date.now()),n=e===t.currentYearMonth,a=t.settings.enabled;if(!n&&!t.force){let t=(0,sl.readMonthDigest)(e);if(t)return void(yield{type:"digest",digest:t})}if(n&&!t.force){let t=(0,sl.getCurrentMonthDigestFromCache)(e,s());if(t)return void(yield{type:"digest",digest:t})}yield{type:"status",phase:"load_dependencies",text:`Loading weeks for ${e}`};let r=sR(e),i=[];for(let e of r){if(e>t.currentWeekMonday){yield{type:"dependency",kind:"week",key:e,status:"cached"};continue}let s=e===t.currentWeekMonday,n=s?null:(0,sl.readWeekDigest)(e);if(n){i.push(n),yield{type:"dependency",kind:"week",key:e,status:"cached"};continue}if(s){let s={settings:t.settings,force:!1,callLLM:t.callLLM,now:t.now,currentWeekMonday:t.currentWeekMonday,todayLocalDay:t.todayLocalDay,caller:t.caller},n=null,a=!1;for await(let t of s1(e,s))if("digest"===t.type&&"week"===t.digest.scope&&(n=t.digest),"error"===t.type){a=!0;break}n?(i.push(n),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 s1(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&&t0();try{let r;if(a){yield{type:"status",phase:"synth",text:"Synthesizing month narrative"};let s=[],n=sW(e,i,{model:t.settings.model,callLLM:t.callLLM,onProgress:e=>{s.push({bytes:e.bytes,elapsed_ms:e.elapsedMs})}}),a=!1;for(n.finally(()=>{a=!0});!a;)if(await new Promise(e=>setTimeout(e,500)),s.length>0){let e=s[s.length-1];yield{type:"progress",phase:"synth",bytes:e.bytes,elapsed_ms:e.elapsed_ms},s.length=0}let o=await n;r=o.digest,o.usage&&tH({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=sY(e,i);n?(r.is_live=!0,(0,sl.setCurrentMonthDigestInCache)(e,r,s())):((0,sl.writeMonthDigest)(r),yield{type:"saved",path:`~/.cclens/digests/month/${e}.json`}),yield{type:"digest",digest:r}}finally{a&&t1()}}e.s(["mondayFor",0,function(e){let t=new Date(`${e}T00:00:00`),s=t.getDay();t.setDate(t.getDate()+(0===s?-6:1-s));let n=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${n}-${a}-${r}`},"runWeekDigestPipeline",0,s1],77242),e.s(["runMonthDigestPipeline",0,s2],21628),e.s([],82111)}];
386
+ `,sz=e=>tO({...e,systemPrompt:sW});async function sB(e,t={}){let s={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:s,usage:null};let n=t.model??"sonnet",a=t.callLLM??sz,r=function(e){let t=[],s=(e="")=>t.push(e);s(`# Session ${e.session_id}`),s(`Project: ${e.project_display} \xb7 Date: ${e.date} \xb7 Started: ${e.start_iso}`),s(`Wall: ${e.wall_min}m \xb7 Active: ${e.active_min}m \xb7 Idle: ${e.idle_min}m \xb7 Turns: ${e.turn_count}`);let n=[];if(e.outcome&&n.push(`Outcome: ${e.outcome}`),e.working_shape&&n.push(`Working shape: ${e.working_shape}`),n.length&&s(n.join(" · ")),e.day_signature&&s(`Day signature: "${e.day_signature}"`),e.shipped_prs.length)for(let t of(s(`Shipped PRs (${e.shipped_prs.length}):`),e.shipped_prs))s(` - "${t}"`);if(s(),s("## Harness"),s(`- 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(", ");s(`- User-authored subagents: ${t}`)}s(`- Stock skills loaded: ${e.stock_skills.length?e.stock_skills.join(", "):"(none)"}`),s(`- Top tools: ${e.top_tools.length?e.top_tools.join(", "):"(none)"}`),s();let a=e.steering;for(let t of(s("## Steering"),s(`${a.user_msg_count} user messages (median ${a.median_user_msg_chars} chars, ${a.long_user_msg_count} long, ${a.interrupts} interrupts)`),s(),s(`## Turns (${e.turns.length})`),e.turns)){s();let e=t.idle_before_min>0?` \xb7 ${t.idle_before_min}m idle before`:"";if(s(`### Turn ${t.turn} — ${t.start_min}m–${t.end_min}m (${t.wall_min}m wall, ${t.active_min}m active${e})`),t.user&&s(`USER (${t.user.chars}c): ${t.user.preview}`),t.first_agent&&s(`FIRST_AGENT (${t.first_agent.chars}c): ${t.first_agent.preview}`),t.last_agent&&s(`LAST_AGENT (${t.last_agent.chars}c): ${t.last_agent.preview}`),!t.agent||t.first_agent||t.last_agent||s(`AGENT (${t.agent.chars}c): ${t.agent.preview}`),t.tools.length&&s(`Tools: ${t.tools.join(", ")}`),t.skills_loaded?.length&&s(`Skills loaded this turn: ${t.skills_loaded.join(", ")}`),t.subagents_dispatched?.length)for(let e of t.subagents_dispatched)s(`Subagent dispatched: ${e.type} — ${e.description}`),e.prompt_preview&&s(` prompt: ${e.prompt_preview}`);let n=[];t.exit_plan_calls&&n.push(`exit_plan\xd7${t.exit_plan_calls}`),t.todo_ops&&n.push(`TodoWrite ops: ${t.todo_ops}`),t.interrupts&&n.push(`interrupts: ${t.interrupts}`),t.pr_created&&n.push(`PR created: "${t.pr_created}"`),t.long_autonomous_run&&n.push("LONG-AUTONOMOUS RUN"),n.length&&s(`Signals: ${n.join(" · ")}`)}if(s(),s('## Candidate pins (deterministic — pick + label the most editorial 3-6 of these for your "pins" output)'),0===e.candidate_pins.length)s("(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`,n=[];for(let[e,s]of Object.entries(t.context??{}))null!=s&&("string"==typeof s?n.push(`${e}="${s.length>200?s.slice(0,197)+"...":s}"`):Array.isArray(s)?n.push(`${e}=[${s.length} items]`):"object"==typeof s?n.push(`${e}={...}`):n.push(`${e}=${s}`));s(`- [${e}] ${t.kind}${n.length?` — ${n.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{...s,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 d,u,c=await a({model:n,userPrompt:r,onProgress:t.onProgress});i+=c.input_tokens,o+=c.output_tokens,c.model;let p=(d=c.content,tM(d,sF));if(p.ok)return{topSession:l(p.value),usage:{input_tokens:i,output_tokens:o}};let h=await a({model:n,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=(u=h.content,tM(u,sF));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:s,usage:{input_tokens:i,output_tokens:o}}}catch(t){return console.warn(`[top-session] ${e.session_id}: LLM invocation failed (${t.message})`),{topSession:s,usage:i>0?{input_tokens:i,output_tokens:o}:null}}finally{}}async function*sV(e,t){let s=t.now??(()=>Date.now()),n=e===t.currentWeekMonday,a=t.settings.enabled;if(!n&&!t.force){let t=(0,t8.readWeekDigest)(e);if(t)return void(yield{type:"digest",digest:t})}if(n&&!t.force){let t=(0,t8.getCurrentWeekDigestFromCache)(e,s());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=sg(e),i=[];for(let e of r){if(e>t.todayLocalDay){yield{type:"dependency",kind:"day",key:e,status:"cached"};continue}let s=e===t.todayLocalDay,n=s?null:(0,t8.readDayDigest)(e);if(n){i.push(n),yield{type:"dependency",kind:"day",key:e,status:"cached"};continue}if(s){let s={settings:t.settings,force:t.force??!1,callLLM:t.callLLM,now:t.now,todayLocalDay:t.todayLocalDay,caller:t.caller},n=null,a=!1;for await(let t of sr(e,s))if("digest"===t.type&&"day"===t.digest.scope&&(n=t.digest),"error"===t.type){a=!0;break}n?(i.push(n),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 sr(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,tU.listEntriesForDay)(e));a&&tB();try{let r,l=new Map(i.map(e=>[e.key,e])),u=a?function(e){let t=[];for(let s of e.values())t.push(...s);let s=e=>e.numbers.active_min*(1+.5*e.numbers.subagent_calls+5*e.pr_titles.length),n=t.filter(e=>e.numbers.active_min>=20||e.numbers.turn_count>=10||e.pr_titles.length>=1).map(e=>({entry:e,score:s(e)})).sort((e,t)=>t.score-e.score),a=new Set,r=[];for(let{entry:e}of n)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:s(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(u.map(async e=>{try{let t=await (0,se.getAnySession)(e.session_id);if(!t)return null;let s=t.events,n=l.get(e.local_day);return{entry:e,slice:function(e,t,s){var n;let a,r=Date.parse(e.start_iso),{turns:i,sliceStartMs:o,sliceEndMs:l}=function(e,t,s){let n=[];for(let a of e){if(!a.timestamp)continue;let e=Date.parse(a.timestamp);!Number.isNaN(e)&&(e<t||e>s||n.push({...a,_ts:e}))}if(0===n.length)return{turns:[],sliceStartMs:t,sliceEndMs:s};n.sort((e,t)=>e._ts-t._ts);let a=n[0]._ts,r=n[n.length-1]._ts,i=[],o=null;for(let e of n){let t=e.blocks??[],s="user"===e.role||"tool-result"===e.role,n="agent"===e.role||"agent-thinking"===e.role||"tool-call"===e.role;if(s)if(t.length>0&&t.every(e=>"tool_result"===e.type))o&&(o.events.push(e),o.timestamps.push(e._ts));else{let s=t.filter(e=>"text"===e.type).map(e=>e.text).join(" "),n=sR.test(s);o&&n&&(o.interrupts+=1),o&&i.push(o),o={events:[e],user_text:s,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(n){if(!o)continue;for(let s of(o.events.push(e),o.timestamps.push(e._ts),t))if(s&&"object"==typeof s){if("text"===s.type&&s.text)o.agent_blocks.push(s.text);else if("tool_use"===s.type){let e=s.name??"unknown";if(o.tools_count.set(e,(o.tools_count.get(e)??0)+1),"Skill"===e){let e=String(s.input?.skill??"unknown");o.skills.set(e,(o.skills.get(e)??0)+1)}else if("Agent"===e){let e=s.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(s.input?.command??""),t=function(e){if(!e)return"?";let t=e.split(/\|\||&&|;|\|/,1)[0].trim();if(t.startsWith("cd ")){let s=e.split(/&&|;/,3);s.length>=2&&(t=s[1].trim())}let s=t.split(/\s+/).filter(Boolean);for(;s.length&&sL.has(s[0]);)s.shift();if(!s.length)return"?";let n=s[0];if(n.includes("=")&&!n.startsWith("/")){if(s.shift(),!s.length)return"?";n=s[0]}return n.includes("/")&&!n.startsWith("./")&&(n=n.replace(/\/+$/,"").split("/").pop()),n.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(sU);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)),u=i.flatMap(e=>e.timestamps),c=l-o,p=sP(u),h=[...u].sort((e,t)=>e-t),m=[];if(h.length>0){let e=h[0],t=h[0];for(let s=1;s<h.length;s++)h[s]-t>=18e4&&(m.push({start_min:sD(e-o),end_min:sD(t-o)}),e=h[s]),t=h[s];m.push({start_min:sD(e-o),end_min:sD(t-o)})}let _=[],g=o,f=[],y=0;i.forEach((e,t)=>{let s=Math.min(...e.timestamps),n=Math.max(...e.timestamps),a=sP(e.timestamps),r=0===t?0:Math.max(0,s-g);g=n,e.user_text&&(f.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 d=null!==i&&i===l,u=[];for(let[t,s]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(", ");u.push(`Bash\xd7${s} (${t})`)}else u.push(s>1?`${t}\xd7${s}`:t);let c={turn:t+1,start_min:sD(s-o),end_min:sD(n-o),wall_min:sD(n-s),active_min:sD(a),idle_before_min:sD(r),start_iso:new Date(s).toISOString(),user:e.user_text?sI(e.user_text,0===t?400:150):null,tools:u};d?c.agent=sI(i,200):(c.first_agent=i?sI(i,150):null,c.last_agent=l?sI(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,k=new Map,w=new Map,b=new Map,x=0;for(let e of i){for(let[t,s]of e.skills)v.set(t,(v.get(t)??0)+s);for(let t of e.subagents)(0,d.isStockSubagentType)(t.type)||k.set(t.type,(k.get(t.type)??0)+1);for(let[t,s]of e.tools_count)w.set(t,(w.get(t)??0)+s);for(let[t,s]of e.bash_verbs)b.set(t,(b.get(t)??0)+s);x+=e.interrupts}let S=[],$=[];for(let e of v.keys()){let t=(0,d.classifySkill)(e);"user"===t?S.push(e):"stock"===t&&$.push(e)}let T=[];for(let[e,t]of[...w.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}`);f.sort((e,t)=>e-t);let N=0===f.length?0:f[Math.floor(f.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=(n=e.project).split("/").filter(Boolean))[a.length-1]??n,start_iso:new Date(o).toISOString(),wall_min:sD(c),active_min:sD(p),idle_min:sD(c-p),turn_count:_.length,outcome:e.enrichment.outcome,shipped_prs:e.pr_titles,working_shape:e.signals?.working_shape??(0,d.inferWorkingShape)(e),day_signature:s,user_authored_skills:S,user_authored_subagents:[...k.entries()].sort((e,t)=>t[1]-e[1]).map(([e,t])=>({type:e,count:t})),stock_skills:$,top_tools:T,steering:{user_msg_count:f.length,long_user_msg_count:y,median_user_msg_chars:N,interrupts:x},active_intervals:m,turns:_,candidate_pins:j}}(e,s,n?.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 s=[],a=sS(e,i,{model:t.settings.model,callLLM:t.callLLM,entriesByDay:o,allowSingleDay:!0===t.force&&n,onProgress:e=>{s.push({bytes:e.bytes,elapsed_ms:e.elapsedMs})}}),l=Promise.all(c.map(({entry:e,slice:s})=>sB(s,{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)))),d=!1,u=!1;for(a.finally(()=>{d=!0}),l.finally(()=>{u=!0});!d||!u;)if(await new Promise(e=>setTimeout(e,500)),s.length>0){let e=s[s.length-1];yield{type:"progress",phase:"synth",bytes:e.bytes,elapsed_ms:e.elapsed_ms},s.length=0}let p=await a,h=await l;r=p.digest,p.usage&&tL({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 s of h)s&&(m.push({...s.topSession,agent:s.entry.agent}),s.usage&&tL({ts:new Date().toISOString(),caller:t.caller??"web",model:t.settings.model,input_tokens:s.usage.input_tokens,output_tokens:s.usage.output_tokens,cost_usd:tA(t.settings.model,s.usage.input_tokens,s.usage.output_tokens),kind:"top_session",ref:`${e}/${s.entry.session_id}`}));r.headline&&m.length>0&&(r.top_sessions=m)}else r=sk(e,i,{entriesByDay:o});n?(r.is_live=!0,(0,t8.setCurrentWeekDigestInCache)(e,r,s()),!0===t.force&&((0,t8.writeWeekDigest)(r),yield{type:"saved",path:`~/.cclens/digests/week/${e}.json`})):((0,t8.writeWeekDigest)(r),yield{type:"saved",path:`~/.cclens/digests/week/${e}.json`}),yield{type:"digest",digest:r}}finally{a&&tV()}}async function*sH(e,t){let s=t.now??(()=>Date.now()),n=e===t.currentYearMonth,a=t.settings.enabled;if(!n&&!t.force){let t=(0,t8.readMonthDigest)(e);if(t)return void(yield{type:"digest",digest:t})}if(n&&!t.force){let t=(0,t8.getCurrentMonthDigestFromCache)(e,s());if(t)return void(yield{type:"digest",digest:t})}yield{type:"status",phase:"load_dependencies",text:`Loading weeks for ${e}`};let r=sM(e),i=[];for(let e of r){if(e>t.currentWeekMonday){yield{type:"dependency",kind:"week",key:e,status:"cached"};continue}let s=e===t.currentWeekMonday,n=s?null:(0,t8.readWeekDigest)(e);if(n){i.push(n),yield{type:"dependency",kind:"week",key:e,status:"cached"};continue}if(s){let s={settings:t.settings,force:!1,callLLM:t.callLLM,now:t.now,currentWeekMonday:t.currentWeekMonday,todayLocalDay:t.todayLocalDay,caller:t.caller},n=null,a=!1;for await(let t of sV(e,s))if("digest"===t.type&&"week"===t.digest.scope&&(n=t.digest),"error"===t.type){a=!0;break}n?(i.push(n),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 sV(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&&tB();try{let r;if(a){yield{type:"status",phase:"synth",text:"Synthesizing month narrative"};let s=[],n=sC(e,i,{model:t.settings.model,callLLM:t.callLLM,onProgress:e=>{s.push({bytes:e.bytes,elapsed_ms:e.elapsedMs})}}),a=!1;for(n.finally(()=>{a=!0});!a;)if(await new Promise(e=>setTimeout(e,500)),s.length>0){let e=s[s.length-1];yield{type:"progress",phase:"synth",bytes:e.bytes,elapsed_ms:e.elapsed_ms},s.length=0}let o=await n;r=o.digest,o.usage&&tL({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=sE(e,i);n?(r.is_live=!0,(0,t8.setCurrentMonthDigestInCache)(e,r,s())):((0,t8.writeMonthDigest)(r),yield{type:"saved",path:`~/.cclens/digests/month/${e}.json`}),yield{type:"digest",digest:r}}finally{a&&tV()}}e.s(["mondayFor",0,function(e){let t=new Date(`${e}T00:00:00`),s=t.getDay();t.setDate(t.getDate()+(0===s?-6:1-s));let n=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${n}-${a}-${r}`},"runWeekDigestPipeline",0,sV],77242),e.s(["runMonthDigestPipeline",0,sH],21628),e.s([],82111)}];
387
387
 
388
388
  //# sourceMappingURL=packages_entries_dist_node_0bckr7-.js.map