fleetlens 0.6.2 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/apps/web/.next/BUILD_ID +1 -1
- package/app/apps/web/.next/build-manifest.json +3 -3
- package/app/apps/web/.next/prerender-manifest.json +3 -3
- package/app/apps/web/.next/server/app/_global-error.html +1 -1
- package/app/apps/web/.next/server/app/_global-error.rsc +1 -1
- package/app/apps/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/app/apps/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/app/apps/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/app/apps/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/app/apps/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app/apps/web/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/digest/day/[date]/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/digest/month/[yearMonth]/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/digest/month-index/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/digest/week/[startDate]/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/digest/week-index/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/jobs/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/runs/[runId]/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/runs/[runId]/stream/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/settings/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/day/[date]/page.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/day/page.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/digest/[date]/page.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/digest/page.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/insights/[key]/page.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/insights/page.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/page.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/parallelism/page.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/projects/[slug]/page.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/projects/page.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/runs/page.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/sessions/[id]/page.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/sessions/page.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/settings/page.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/usage/page.js.nft.json +1 -1
- package/app/apps/web/.next/server/chunks/packages_entries_dist_node_0bckr7-.js +10 -10
- package/app/apps/web/.next/server/chunks/packages_parser_dist_fs_0bc7ptm.js +1 -1
- package/app/apps/web/.next/server/chunks/ssr/[root-of-the-server]__0-1_njm._.js +1 -1
- package/app/apps/web/.next/server/chunks/ssr/_0xu2pvc._.js +1 -1
- package/app/apps/web/.next/server/chunks/ssr/packages_entries_dist_node_0_271yr.js +1 -1
- package/app/apps/web/.next/server/chunks/ssr/packages_parser_dist_0-jvt~a._.js +1 -1
- package/app/apps/web/.next/server/middleware-build-manifest.js +3 -3
- package/app/apps/web/.next/server/pages/500.html +1 -1
- package/app/apps/web/.next/server/server-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/server-reference-manifest.json +1 -1
- package/app/apps/web/app/insights/page.tsx +5 -3
- package/app/apps/web/package.json +1 -1
- package/app/apps/web/tsconfig.tsbuildinfo +1 -1
- package/dist/daemon-worker.js +82 -48
- package/dist/index.js +102 -102
- package/package.json +1 -1
- package/app/apps/web/lib/auto-week-fire.ts +0 -1
- /package/app/apps/web/.next/static/{MLK3PKEm3q_E_QuKH5kOz → 2jcMG-92q2XKei8dN7BMd}/_buildManifest.js +0 -0
- /package/app/apps/web/.next/static/{MLK3PKEm3q_E_QuKH5kOz → 2jcMG-92q2XKei8dN7BMd}/_clientMiddlewareManifest.js +0 -0
- /package/app/apps/web/.next/static/{MLK3PKEm3q_E_QuKH5kOz → 2jcMG-92q2XKei8dN7BMd}/_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:/,r=/^<command-name>|^<local-command-stdout>/;function a(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(a),n=s.filter(e=>"reviewer"===e).length,r=s.filter(e=>"implementer"===e).length,i=s.filter(e=>"explorer"===e||"researcher"===e).length,o=t.some(e=>e.background);if(r>=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===r){let e=new Set;for(let n=0;n<t.length;n++){if("reviewer"!==s[n])continue;let r=t[n].description.toLowerCase().replace(/[^a-z0-9 ]/g,"").split(/\s+/).filter(e=>e.length>2).slice(0,3).join("|");e.add(r)}if(e.size>=3)return"reviewer-triad"}if(n>=2)return"spec-review-loop";if(i>=2||i>=1&&r>=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 u=/^(superpowers|mcp__|frontend-design|code-review|codex|claude-code-guide|claude-api):/i;function d(e){return e.startsWith("(ToolSearch:")?"infra":u.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),(tg=tk||(tk={})).assertEqual=e=>{},tg.assertIs=function(e){},tg.assertNever=function(e){throw Error()},tg.arrayToEnum=e=>{let t={};for(let s of e)t[s]=s;return t},tg.getValidEnumValues=e=>{let t=tg.objectKeys(e).filter(t=>"number"!=typeof e[e[t]]),s={};for(let n of t)s[n]=e[n];return tg.objectValues(s)},tg.objectValues=e=>tg.objectKeys(e).map(function(t){return e[t]}),tg.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},tg.find=(e,t)=>{for(let s of e)if(t(s))return s},tg.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,tg.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},tg.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 f 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 r of e.issues)if("invalid_union"===r.code)r.unionErrors.map(n);else if("invalid_return_type"===r.code)n(r.returnTypeError);else if("invalid_arguments"===r.code)n(r.argumentsError);else if(0===r.path.length)s._errors.push(t(r));else{let e=s,n=0;for(;n<r.path.length;){let s=r.path[n];n===r.path.length-1?(e[s]=e[s]||{_errors:[]},e[s]._errors.push(t(r))):e[s]=e[s]||{_errors:[]},e=e[s],n++}}};return n(this),s}static assert(e){if(!(e instanceof f))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()}}f.create=e=>new f(e),e.s(["ZodError",0,f,"ZodIssueCode",0,m,"quotelessJson",0,_],15235);let g=(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=g;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,g,"getErrorMap",0,k,"setErrorMap",0,v],76733),e.i(76733);let w=e=>{let{data:t,path:s,errorMaps:n,issueData:r}=e,a=[...s,...r.path||[]],i={...r,path:a};if(void 0!==r.message)return{...r,path:a,message:r.message};let o="";for(let e of n.filter(e=>!!e).slice().reverse())o=e(i,{data:t,defaultError:o}).message;return{...r,path:a,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===g?void 0:g].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:r}=n;if("aborted"===t.status||"aborted"===r.status)return $;"dirty"===t.status&&e.dirty(),"dirty"===r.status&&e.dirty(),"__proto__"!==t.value&&(void 0!==r.value||n.alwaysSet)&&(s[t.value]=r.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,E=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,E,"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 A{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 f(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:r}=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:r}:{errorMap:(t,r)=>{let{message:a}=e;return"invalid_enum_value"===t.code?{message:a??r.defaultError}:void 0===r.data?{message:a??n??r.defaultError}:"invalid_type"!==t.code?{message:r.defaultError}:{message:a??s??r.defaultError}},description:r}}class P{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(E(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 (E(n)?n:Promise.resolve(n)))}refine(e,t){return this._refinement((s,n)=>{let r=e(s),a=()=>n.addIssue({code:m.custom,..."string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(s):t});return"u">typeof Promise&&r instanceof Promise?r.then(e=>!!e||(a(),!1)):!!r||(a(),!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 eE.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 eg.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 eA({...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 eI.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,I=/^[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,F=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Y=/^[-+]?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 P{_parse(e){var s,n,r,a;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)I.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?Y.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(!F.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,"="),r=JSON.parse(atob(n));if("object"!=typeof r||null===r||"typ"in r&&r?.typ!=="JWT"||!r.alg||t&&r.alg!==t)return!1;return!0}catch{return!1}}(e.data,l.alg)&&(x(i=this._getOrReturnCtx(e,i),{validation:"jwt",code:m.invalid_string,message:l.message}),o.dirty()):"cidr"===l.kind?(r=e.data,!(("v4"===(a=l.version)||!a)&&B.test(r)||("v6"===a||!a)&&H.test(r))&&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 P{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){let t;if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==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,r=s>n?s:n;return Number.parseInt(e.toFixed(r).replace(".",""))%Number.parseInt(t.toFixed(r).replace(".",""))/10**r}(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 P{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){let t;if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==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 P{_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 er extends P{_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 er({...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}}er.create=e=>new er({checks:[],coerce:e?.coerce||!1,typeName:tx.ZodDate,...C(e)});class ea extends P{_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)}}ea.create=e=>new ea({typeName:tx.ZodSymbol,...C(e)});class ei extends P{_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 P{_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 P{constructor(){super(...arguments),this._any=!0}_parse(e){return N(e.data)}}el.create=e=>new el({typeName:tx.ZodAny,...C(e)});class eu extends P{constructor(){super(...arguments),this._unknown=!0}_parse(e){return N(e.data)}}eu.create=e=>new eu({typeName:tx.ZodUnknown,...C(e)});class ed extends P{_parse(e){let t=this._getOrReturnCtx(e);return x(t,{code:m.invalid_type,expected:p.never,received:t.parsedType}),$}}ed.create=e=>new ed({typeName:tx.ZodNever,...C(e)});class ec extends P{_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 P{_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,r=t.data.length<n.exactLength.value;(e||r)&&(x(t,{code:e?m.too_big:m.too_small,minimum:r?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 A(t,e,t.path,s)))).then(e=>S.mergeArray(s,e));let r=[...t.data].map((e,s)=>n.type._parseSync(new A(t,e,t.path,s)));return S.mergeArray(s,r)}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 P{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;let e=this._def.shape(),t=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:r}=this._getCached(),a=[];if(!(this._def.catchall instanceof ed&&"strip"===this._def.unknownKeys))for(let e in s.data)r.includes(e)||a.push(e);let i=[];for(let e of r){let t=n[e],r=s.data[e];i.push({key:{status:"valid",value:e},value:t._parse(new A(s,r,s.path,e)),alwaysSet:e in s.data})}if(this._def.catchall instanceof ed){let e=this._def.unknownKeys;if("passthrough"===e)for(let e of a)i.push({key:{status:"valid",value:e},value:{status:"valid",value:s.data[e]}});else if("strict"===e)a.length>0&&(x(s,{code:m.unrecognized_keys,keys:a}),t.dirty());else if("strip"===e);else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let e=this._def.catchall;for(let t of a){let n=s.data[t];i.push({key:{status:"valid",value:t},value:e._parse(new A(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 r=t.shape[n];s[n]=eM.create(e(r))}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 eE)return eE.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:ed.create(),typeName:tx.ZodObject,...C(t)}),eh.strictCreate=(e,t)=>new eh({shape:()=>e,unknownKeys:"strict",catchall:ed.create(),typeName:tx.ZodObject,...C(t)}),eh.lazycreate=(e,t)=>new eh({shape:e,unknownKeys:"strip",catchall:ed.create(),typeName:tx.ZodObject,...C(t)});class em extends P{_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 f(e.ctx.common.issues));return x(t,{code:m.invalid_union,unionErrors:s}),$});{let e,n=[];for(let r of s){let s={...t,common:{...t.common,issues:[]},parent:null},a=r._parseSync({data:t.data,path:t.path,parent:s});if("valid"===a.status)return a;"dirty"!==a.status||e||(e={result:a,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 r=n.map(e=>new f(e));return x(t,{code:m.invalid_union,unionErrors:r}),$}}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 eA)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 eE)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 ef extends P{_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],r=this.optionsMap.get(n);return r?t.common.async?r._parseAsync({data:t.data,path:t.path,parent:t}):r._parseSync({data:t.data,path:t.path,parent:t}):(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 r of t){if(n.has(r))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(r)}`);n.set(r,s)}}return new ef({typeName:tx.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...C(s)})}}class eg extends P{_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=(e,n)=>{if(j(e)||j(n))return $;let r=function e(t,s){let n=h(t),r=h(s);if(t===s)return{valid:!0,data:t};if(n===p.object&&r===p.object){let n=tk.objectKeys(s),r=tk.objectKeys(t).filter(e=>-1!==n.indexOf(e)),a={...t,...s};for(let n of r){let r=e(t[n],s[n]);if(!r.valid)return{valid:!1};a[n]=r.data}return{valid:!0,data:a}}if(n===p.array&&r===p.array){if(t.length!==s.length)return{valid:!1};let n=[];for(let r=0;r<t.length;r++){let a=e(t[r],s[r]);if(!a.valid)return{valid:!1};n.push(a.data)}return{valid:!0,data:n}}if(n===p.date&&r===p.date&&+t==+s)return{valid:!0,data:t};return{valid:!1}}(e.value,n.value);return r.valid?((O(e)||O(n))&&t.dirty(),{status:t.value,value:r.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}))}}eg.create=(e,t,s)=>new eg({left:e,right:t,typeName:tx.ZodIntersection,...C(s)});class ey extends P{_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 A(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 P{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=[],r=this._def.keyType,a=this._def.valueType;for(let e in s.data)n.push({key:r._parse(new A(s,e,s.path,e)),value:a._parse(new A(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 P?{keyType:e,valueType:t,typeName:tx.ZodRecord,...C(s)}:{keyType:ee.create(),valueType:e,typeName:tx.ZodRecord,...C(t)})}}class ek extends P{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,r=this._def.valueType,a=[...s.data.entries()].map(([e,t],a)=>({key:n._parse(new A(s,e,s.path,[a,"key"])),value:r._parse(new A(s,t,s.path,[a,"value"]))}));if(s.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let s of a){let n=await s.key,r=await s.value;if("aborted"===n.status||"aborted"===r.status)return $;("dirty"===n.status||"dirty"===r.status)&&t.dirty(),e.set(n.value,r.value)}return{status:t.value,value:e}})}{let e=new Map;for(let s of a){let n=s.key,r=s.value;if("aborted"===n.status||"aborted"===r.status)return $;("dirty"===n.status||"dirty"===r.status)&&t.dirty(),e.set(n.value,r.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 P{_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 r=this._def.valueType;function a(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)=>r._parse(new A(s,e,s.path,t)));return s.common.async?Promise.all(i).then(e=>a(e)):a(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 P{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(),g].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(),g].filter(e=>!!e),issueData:{code:m.invalid_return_type,returnTypeError:s}})}let r={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof ej){let e=this;return N(async function(...t){let i=new f([]),o=await e._def.args.parseAsync(t,r).catch(e=>{throw i.addIssue(s(t,e)),i}),l=await Reflect.apply(a,this,o);return await e._def.returns._def.type.parseAsync(l,r).catch(e=>{throw i.addIssue(n(l,e)),i})})}{let e=this;return N(function(...t){let i=e._def.args.safeParse(t,r);if(!i.success)throw new f([s(t,i.error)]);let o=Reflect.apply(a,this,i.data),l=e._def.returns.safeParse(o,r);if(!l.success)throw new f([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(eu.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(eu.create()),returns:t||eu.create(),typeName:tx.ZodFunction,...C(s)})}}class ex extends P{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ex.create=(e,t)=>new ex({getter:e,typeName:tx.ZodLazy,...C(t)});class eS extends P{_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 P{_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 P{_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 P{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 P{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,r={addIssue:e=>{x(s,e),e.fatal?t.abort():t.dirty()},get path(){return s.path}};if(r.addIssue=r.addIssue.bind(r),"preprocess"===n.type){let e=n.transform(s.data,r);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,r);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,r)).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 a=n.transform(e.value,r);if(a instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}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 P{_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 eE extends P{_parse(e){return this._getType(e)===p.null?N(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}eE.create=(e,t)=>new eE({innerType:e,typeName:tx.ZodNullable,...C(t)});class eA extends P{_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}}eA.create=(e,t)=>new eA({innerType:e,typeName:tx.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...C(t)});class eZ extends P{_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 E(n)?n.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new f(s.common.issues)},input:s.data})})):{status:"valid",value:"valid"===n.status?n.value:this._def.catchValue({get error(){return new f(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 P{_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 eP=Symbol("zod_brand");class eD extends P{_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 eI extends P{_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 eI({in:e,out:t,typeName:tx.ZodPipeline})}}class eL extends P{_parse(e){let t=this._def.innerType._parse(e),s=e=>(M(e)&&(e.value=Object.freeze(e.value)),e);return E(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,r)=>{let a=e(n);if(a instanceof Promise)return a.then(e=>{if(!e){let e=eR(t,n),a=e.fatal??s??!0;r.addIssue({code:"custom",...e,fatal:a})}});if(!a){let e=eR(t,n),a=e.fatal??s??!0;r.addIssue({code:"custom",...e,fatal:a})}}):el.create()}eL.create=(e,t)=>new eL({innerType:e,typeName:tx.ZodReadonly,...C(t)});let eF={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 eY=(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=er.create,eq=ea.create,eK=ei.create,eG=eo.create,eX=el.create,eQ=eu.create,e0=ed.create,e1=ec.create,e2=ep.create,e4=eh.create,e9=eh.strictCreate,e5=em.create,e3=ef.create,e7=eg.create,e6=ey.create,e8=ev.create,te=ek.create,tt=ew.create,ts=eb.create,tn=ex.create,tr=eS.create,ta=eT.create,ti=eN.create,to=ej.create,tl=eO.create,tu=eM.create,td=eE.create,tc=eO.createWithPreprocess,tp=eI.create,th=()=>eW().optional(),tm=()=>ez().optional(),t_=()=>eH().optional(),tf={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=>er.create({...e,coerce:!0})};e.s(["BRAND",0,eP,"NEVER",0,$,"Schema",0,P,"ZodAny",0,el,"ZodArray",0,ep,"ZodBigInt",0,es,"ZodBoolean",0,en,"ZodBranded",0,eD,"ZodCatch",0,eZ,"ZodDate",0,er,"ZodDefault",0,eA,"ZodDiscriminatedUnion",0,ef,"ZodEffects",0,eO,"ZodEnum",0,eT,"ZodFirstPartyTypeKind",0,tx,"ZodFunction",0,eb,"ZodIntersection",0,eg,"ZodLazy",0,ex,"ZodLiteral",0,eS,"ZodMap",0,ek,"ZodNaN",0,eC,"ZodNativeEnum",0,eN,"ZodNever",0,ed,"ZodNull",0,eo,"ZodNullable",0,eE,"ZodNumber",0,et,"ZodObject",0,eh,"ZodOptional",0,eM,"ZodPipeline",0,eI,"ZodPromise",0,ej,"ZodReadonly",0,eL,"ZodRecord",0,ev,"ZodSchema",0,P,"ZodSet",0,ew,"ZodString",0,ee,"ZodSymbol",0,ea,"ZodTransformer",0,eO,"ZodTuple",0,ey,"ZodType",0,P,"ZodUndefined",0,ei,"ZodUnion",0,em,"ZodUnknown",0,eu,"ZodVoid",0,ec,"any",0,eX,"array",0,e2,"bigint",0,eV,"boolean",0,eH,"coerce",0,tf,"custom",0,eU,"date",0,eJ,"datetimeRegex",0,Q,"discriminatedUnion",0,e3,"effect",0,tl,"enum",0,ta,"function",0,ts,"instanceof",0,eY,"intersection",0,e7,"late",0,eF,"lazy",0,tn,"literal",0,tr,"map",0,te,"nan",0,eB,"nativeEnum",0,ti,"never",0,e0,"null",0,eG,"nullable",0,td,"number",0,ez,"object",0,e4,"oboolean",0,t_,"onumber",0,tm,"optional",0,tu,"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,eP,"DIRTY",0,T,"EMPTY_PATH",0,b,"INVALID",0,$,"NEVER",0,$,"OK",0,N,"ParseStatus",0,S,"Schema",0,P,"ZodAny",0,el,"ZodArray",0,ep,"ZodBigInt",0,es,"ZodBoolean",0,en,"ZodBranded",0,eD,"ZodCatch",0,eZ,"ZodDate",0,er,"ZodDefault",0,eA,"ZodDiscriminatedUnion",0,ef,"ZodEffects",0,eO,"ZodEnum",0,eT,"ZodError",0,f,"ZodFirstPartyTypeKind",0,tx,"ZodFunction",0,eb,"ZodIntersection",0,eg,"ZodIssueCode",0,m,"ZodLazy",0,ex,"ZodLiteral",0,eS,"ZodMap",0,ek,"ZodNaN",0,eC,"ZodNativeEnum",0,eN,"ZodNever",0,ed,"ZodNull",0,eo,"ZodNullable",0,eE,"ZodNumber",0,et,"ZodObject",0,eh,"ZodOptional",0,eM,"ZodParsedType",0,p,"ZodPipeline",0,eI,"ZodPromise",0,ej,"ZodReadonly",0,eL,"ZodRecord",0,ev,"ZodSchema",0,P,"ZodSet",0,ew,"ZodString",0,ee,"ZodSymbol",0,ea,"ZodTransformer",0,eO,"ZodTuple",0,ey,"ZodType",0,P,"ZodUndefined",0,ei,"ZodUnion",0,em,"ZodUnknown",0,eu,"ZodVoid",0,ec,"addIssueToContext",0,x,"any",0,eX,"array",0,e2,"bigint",0,eV,"boolean",0,eH,"coerce",0,tf,"custom",0,eU,"date",0,eJ,"datetimeRegex",0,Q,"defaultErrorMap",0,g,"discriminatedUnion",0,e3,"effect",0,tl,"enum",0,ta,"function",0,ts,"getErrorMap",0,k,"getParsedType",0,h,"instanceof",0,eY,"intersection",0,e7,"isAborted",0,j,"isAsync",0,E,"isDirty",0,O,"isValid",0,M,"late",0,eF,"lazy",0,tn,"literal",0,tr,"makeIssue",0,w,"map",0,te,"nan",0,eB,"nativeEnum",0,ti,"never",0,e0,"null",0,eG,"nullable",0,td,"number",0,ez,"object",0,e4,"objectUtil",0,tw,"oboolean",0,t_,"onumber",0,tm,"optional",0,tu,"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 tg,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,s=/^<teammate-message\b/,n=/^Base directory for this skill:/,r=/^<command-name>|^<local-command-stdout>/;function a(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(a),n=s.filter(e=>"reviewer"===e).length,r=s.filter(e=>"implementer"===e).length,i=s.filter(e=>"explorer"===e||"researcher"===e).length,o=t.some(e=>e.background);if(r>=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===r){let e=new Set;for(let n=0;n<t.length;n++){if("reviewer"!==s[n])continue;let r=t[n].description.toLowerCase().replace(/[^a-z0-9 ]/g,"").split(/\s+/).filter(e=>e.length>2).slice(0,3).join("|");e.add(r)}if(e.size>=3)return"reviewer-triad"}if(n>=2)return"spec-review-loop";if(i>=2||i>=1&&r>=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 u=/^(superpowers|mcp__|frontend-design|code-review|codex|claude-code-guide|claude-api):/i;function d(e){return e.startsWith("(ToolSearch:")?"infra":u.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),(tg=tk||(tk={})).assertEqual=e=>{},tg.assertIs=function(e){},tg.assertNever=function(e){throw Error()},tg.arrayToEnum=e=>{let t={};for(let s of e)t[s]=s;return t},tg.getValidEnumValues=e=>{let t=tg.objectKeys(e).filter(t=>"number"!=typeof e[e[t]]),s={};for(let n of t)s[n]=e[n];return tg.objectValues(s)},tg.objectValues=e=>tg.objectKeys(e).map(function(t){return e[t]}),tg.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},tg.find=(e,t)=>{for(let s of e)if(t(s))return s},tg.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,tg.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},tg.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 f 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 r of e.issues)if("invalid_union"===r.code)r.unionErrors.map(n);else if("invalid_return_type"===r.code)n(r.returnTypeError);else if("invalid_arguments"===r.code)n(r.argumentsError);else if(0===r.path.length)s._errors.push(t(r));else{let e=s,n=0;for(;n<r.path.length;){let s=r.path[n];n===r.path.length-1?(e[s]=e[s]||{_errors:[]},e[s]._errors.push(t(r))):e[s]=e[s]||{_errors:[]},e=e[s],n++}}};return n(this),s}static assert(e){if(!(e instanceof f))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()}}f.create=e=>new f(e),e.s(["ZodError",0,f,"ZodIssueCode",0,m,"quotelessJson",0,_],15235);let g=(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=g;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,g,"getErrorMap",0,k,"setErrorMap",0,v],76733),e.i(76733);let w=e=>{let{data:t,path:s,errorMaps:n,issueData:r}=e,a=[...s,...r.path||[]],i={...r,path:a};if(void 0!==r.message)return{...r,path:a,message:r.message};let o="";for(let e of n.filter(e=>!!e).slice().reverse())o=e(i,{data:t,defaultError:o}).message;return{...r,path:a,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===g?void 0:g].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:r}=n;if("aborted"===t.status||"aborted"===r.status)return $;"dirty"===t.status&&e.dirty(),"dirty"===r.status&&e.dirty(),"__proto__"!==t.value&&(void 0!==r.value||n.alwaysSet)&&(s[t.value]=r.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,E=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,E,"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 A{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 f(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:r}=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:r}:{errorMap:(t,r)=>{let{message:a}=e;return"invalid_enum_value"===t.code?{message:a??r.defaultError}:void 0===r.data?{message:a??n??r.defaultError}:"invalid_type"!==t.code?{message:r.defaultError}:{message:a??s??r.defaultError}},description:r}}class P{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(E(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 (E(n)?n:Promise.resolve(n)))}refine(e,t){return this._refinement((s,n)=>{let r=e(s),a=()=>n.addIssue({code:m.custom,..."string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(s):t});return"u">typeof Promise&&r instanceof Promise?r.then(e=>!!e||(a(),!1)):!!r||(a(),!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 eE.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 eg.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 eA({...C(this._def),innerType:this,defaultValue:"function"==typeof e?e:()=>e,typeName:tx.ZodDefault})}brand(){return new eI({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 eD.create(this,e)}readonly(){return eL.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}let I=/^c[^\s-]{8,}$/i,D=/^[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,F=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Y=/^[-+]?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 P{_parse(e){var s,n,r,a;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)I.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)D.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?Y.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(!F.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,"="),r=JSON.parse(atob(n));if("object"!=typeof r||null===r||"typ"in r&&r?.typ!=="JWT"||!r.alg||t&&r.alg!==t)return!1;return!0}catch{return!1}}(e.data,l.alg)&&(x(i=this._getOrReturnCtx(e,i),{validation:"jwt",code:m.invalid_string,message:l.message}),o.dirty()):"cidr"===l.kind?(r=e.data,!(("v4"===(a=l.version)||!a)&&B.test(r)||("v6"===a||!a)&&H.test(r))&&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 P{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){let t;if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==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,r=s>n?s:n;return Number.parseInt(e.toFixed(r).replace(".",""))%Number.parseInt(t.toFixed(r).replace(".",""))/10**r}(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 P{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){let t;if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==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 P{_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 er extends P{_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 er({...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}}er.create=e=>new er({checks:[],coerce:e?.coerce||!1,typeName:tx.ZodDate,...C(e)});class ea extends P{_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)}}ea.create=e=>new ea({typeName:tx.ZodSymbol,...C(e)});class ei extends P{_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 P{_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 P{constructor(){super(...arguments),this._any=!0}_parse(e){return N(e.data)}}el.create=e=>new el({typeName:tx.ZodAny,...C(e)});class eu extends P{constructor(){super(...arguments),this._unknown=!0}_parse(e){return N(e.data)}}eu.create=e=>new eu({typeName:tx.ZodUnknown,...C(e)});class ed extends P{_parse(e){let t=this._getOrReturnCtx(e);return x(t,{code:m.invalid_type,expected:p.never,received:t.parsedType}),$}}ed.create=e=>new ed({typeName:tx.ZodNever,...C(e)});class ec extends P{_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 P{_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,r=t.data.length<n.exactLength.value;(e||r)&&(x(t,{code:e?m.too_big:m.too_small,minimum:r?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 A(t,e,t.path,s)))).then(e=>S.mergeArray(s,e));let r=[...t.data].map((e,s)=>n.type._parseSync(new A(t,e,t.path,s)));return S.mergeArray(s,r)}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 P{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;let e=this._def.shape(),t=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:r}=this._getCached(),a=[];if(!(this._def.catchall instanceof ed&&"strip"===this._def.unknownKeys))for(let e in s.data)r.includes(e)||a.push(e);let i=[];for(let e of r){let t=n[e],r=s.data[e];i.push({key:{status:"valid",value:e},value:t._parse(new A(s,r,s.path,e)),alwaysSet:e in s.data})}if(this._def.catchall instanceof ed){let e=this._def.unknownKeys;if("passthrough"===e)for(let e of a)i.push({key:{status:"valid",value:e},value:{status:"valid",value:s.data[e]}});else if("strict"===e)a.length>0&&(x(s,{code:m.unrecognized_keys,keys:a}),t.dirty());else if("strip"===e);else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let e=this._def.catchall;for(let t of a){let n=s.data[t];i.push({key:{status:"valid",value:t},value:e._parse(new A(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 r=t.shape[n];s[n]=eM.create(e(r))}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 eE)return eE.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:ed.create(),typeName:tx.ZodObject,...C(t)}),eh.strictCreate=(e,t)=>new eh({shape:()=>e,unknownKeys:"strict",catchall:ed.create(),typeName:tx.ZodObject,...C(t)}),eh.lazycreate=(e,t)=>new eh({shape:e,unknownKeys:"strip",catchall:ed.create(),typeName:tx.ZodObject,...C(t)});class em extends P{_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 f(e.ctx.common.issues));return x(t,{code:m.invalid_union,unionErrors:s}),$});{let e,n=[];for(let r of s){let s={...t,common:{...t.common,issues:[]},parent:null},a=r._parseSync({data:t.data,path:t.path,parent:s});if("valid"===a.status)return a;"dirty"!==a.status||e||(e={result:a,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 r=n.map(e=>new f(e));return x(t,{code:m.invalid_union,unionErrors:r}),$}}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 eA)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 eE)return[null,...e_(e.unwrap())];else if(e instanceof eI)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 ef extends P{_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],r=this.optionsMap.get(n);return r?t.common.async?r._parseAsync({data:t.data,path:t.path,parent:t}):r._parseSync({data:t.data,path:t.path,parent:t}):(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 r of t){if(n.has(r))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(r)}`);n.set(r,s)}}return new ef({typeName:tx.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...C(s)})}}class eg extends P{_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=(e,n)=>{if(j(e)||j(n))return $;let r=function e(t,s){let n=h(t),r=h(s);if(t===s)return{valid:!0,data:t};if(n===p.object&&r===p.object){let n=tk.objectKeys(s),r=tk.objectKeys(t).filter(e=>-1!==n.indexOf(e)),a={...t,...s};for(let n of r){let r=e(t[n],s[n]);if(!r.valid)return{valid:!1};a[n]=r.data}return{valid:!0,data:a}}if(n===p.array&&r===p.array){if(t.length!==s.length)return{valid:!1};let n=[];for(let r=0;r<t.length;r++){let a=e(t[r],s[r]);if(!a.valid)return{valid:!1};n.push(a.data)}return{valid:!0,data:n}}if(n===p.date&&r===p.date&&+t==+s)return{valid:!0,data:t};return{valid:!1}}(e.value,n.value);return r.valid?((O(e)||O(n))&&t.dirty(),{status:t.value,value:r.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}))}}eg.create=(e,t,s)=>new eg({left:e,right:t,typeName:tx.ZodIntersection,...C(s)});class ey extends P{_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 A(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 P{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=[],r=this._def.keyType,a=this._def.valueType;for(let e in s.data)n.push({key:r._parse(new A(s,e,s.path,e)),value:a._parse(new A(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 P?{keyType:e,valueType:t,typeName:tx.ZodRecord,...C(s)}:{keyType:ee.create(),valueType:e,typeName:tx.ZodRecord,...C(t)})}}class ek extends P{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,r=this._def.valueType,a=[...s.data.entries()].map(([e,t],a)=>({key:n._parse(new A(s,e,s.path,[a,"key"])),value:r._parse(new A(s,t,s.path,[a,"value"]))}));if(s.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let s of a){let n=await s.key,r=await s.value;if("aborted"===n.status||"aborted"===r.status)return $;("dirty"===n.status||"dirty"===r.status)&&t.dirty(),e.set(n.value,r.value)}return{status:t.value,value:e}})}{let e=new Map;for(let s of a){let n=s.key,r=s.value;if("aborted"===n.status||"aborted"===r.status)return $;("dirty"===n.status||"dirty"===r.status)&&t.dirty(),e.set(n.value,r.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 P{_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 r=this._def.valueType;function a(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)=>r._parse(new A(s,e,s.path,t)));return s.common.async?Promise.all(i).then(e=>a(e)):a(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 P{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(),g].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(),g].filter(e=>!!e),issueData:{code:m.invalid_return_type,returnTypeError:s}})}let r={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof ej){let e=this;return N(async function(...t){let i=new f([]),o=await e._def.args.parseAsync(t,r).catch(e=>{throw i.addIssue(s(t,e)),i}),l=await Reflect.apply(a,this,o);return await e._def.returns._def.type.parseAsync(l,r).catch(e=>{throw i.addIssue(n(l,e)),i})})}{let e=this;return N(function(...t){let i=e._def.args.safeParse(t,r);if(!i.success)throw new f([s(t,i.error)]);let o=Reflect.apply(a,this,i.data),l=e._def.returns.safeParse(o,r);if(!l.success)throw new f([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(eu.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(eu.create()),returns:t||eu.create(),typeName:tx.ZodFunction,...C(s)})}}class ex extends P{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ex.create=(e,t)=>new ex({getter:e,typeName:tx.ZodLazy,...C(t)});class eS extends P{_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 P{_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 P{_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 P{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 P{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,r={addIssue:e=>{x(s,e),e.fatal?t.abort():t.dirty()},get path(){return s.path}};if(r.addIssue=r.addIssue.bind(r),"preprocess"===n.type){let e=n.transform(s.data,r);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,r);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,r)).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 a=n.transform(e.value,r);if(a instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}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 P{_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 eE extends P{_parse(e){return this._getType(e)===p.null?N(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}eE.create=(e,t)=>new eE({innerType:e,typeName:tx.ZodNullable,...C(t)});class eA extends P{_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}}eA.create=(e,t)=>new eA({innerType:e,typeName:tx.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...C(t)});class eZ extends P{_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 E(n)?n.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new f(s.common.issues)},input:s.data})})):{status:"valid",value:"valid"===n.status?n.value:this._def.catchValue({get error(){return new f(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 P{_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 eP=Symbol("zod_brand");class eI extends P{_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 P{_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 eD({in:e,out:t,typeName:tx.ZodPipeline})}}class eL extends P{_parse(e){let t=this._def.innerType._parse(e),s=e=>(M(e)&&(e.value=Object.freeze(e.value)),e);return E(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,r)=>{let a=e(n);if(a instanceof Promise)return a.then(e=>{if(!e){let e=eR(t,n),a=e.fatal??s??!0;r.addIssue({code:"custom",...e,fatal:a})}});if(!a){let e=eR(t,n),a=e.fatal??s??!0;r.addIssue({code:"custom",...e,fatal:a})}}):el.create()}eL.create=(e,t)=>new eL({innerType:e,typeName:tx.ZodReadonly,...C(t)});let eF={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 eY=(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=er.create,eq=ea.create,eK=ei.create,eG=eo.create,eX=el.create,eQ=eu.create,e0=ed.create,e1=ec.create,e2=ep.create,e4=eh.create,e9=eh.strictCreate,e5=em.create,e3=ef.create,e7=eg.create,e6=ey.create,e8=ev.create,te=ek.create,tt=ew.create,ts=eb.create,tn=ex.create,tr=eS.create,ta=eT.create,ti=eN.create,to=ej.create,tl=eO.create,tu=eM.create,td=eE.create,tc=eO.createWithPreprocess,tp=eD.create,th=()=>eW().optional(),tm=()=>ez().optional(),t_=()=>eH().optional(),tf={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=>er.create({...e,coerce:!0})};e.s(["BRAND",0,eP,"NEVER",0,$,"Schema",0,P,"ZodAny",0,el,"ZodArray",0,ep,"ZodBigInt",0,es,"ZodBoolean",0,en,"ZodBranded",0,eI,"ZodCatch",0,eZ,"ZodDate",0,er,"ZodDefault",0,eA,"ZodDiscriminatedUnion",0,ef,"ZodEffects",0,eO,"ZodEnum",0,eT,"ZodFirstPartyTypeKind",0,tx,"ZodFunction",0,eb,"ZodIntersection",0,eg,"ZodLazy",0,ex,"ZodLiteral",0,eS,"ZodMap",0,ek,"ZodNaN",0,eC,"ZodNativeEnum",0,eN,"ZodNever",0,ed,"ZodNull",0,eo,"ZodNullable",0,eE,"ZodNumber",0,et,"ZodObject",0,eh,"ZodOptional",0,eM,"ZodPipeline",0,eD,"ZodPromise",0,ej,"ZodReadonly",0,eL,"ZodRecord",0,ev,"ZodSchema",0,P,"ZodSet",0,ew,"ZodString",0,ee,"ZodSymbol",0,ea,"ZodTransformer",0,eO,"ZodTuple",0,ey,"ZodType",0,P,"ZodUndefined",0,ei,"ZodUnion",0,em,"ZodUnknown",0,eu,"ZodVoid",0,ec,"any",0,eX,"array",0,e2,"bigint",0,eV,"boolean",0,eH,"coerce",0,tf,"custom",0,eU,"date",0,eJ,"datetimeRegex",0,Q,"discriminatedUnion",0,e3,"effect",0,tl,"enum",0,ta,"function",0,ts,"instanceof",0,eY,"intersection",0,e7,"late",0,eF,"lazy",0,tn,"literal",0,tr,"map",0,te,"nan",0,eB,"nativeEnum",0,ti,"never",0,e0,"null",0,eG,"nullable",0,td,"number",0,ez,"object",0,e4,"oboolean",0,t_,"onumber",0,tm,"optional",0,tu,"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,eP,"DIRTY",0,T,"EMPTY_PATH",0,b,"INVALID",0,$,"NEVER",0,$,"OK",0,N,"ParseStatus",0,S,"Schema",0,P,"ZodAny",0,el,"ZodArray",0,ep,"ZodBigInt",0,es,"ZodBoolean",0,en,"ZodBranded",0,eI,"ZodCatch",0,eZ,"ZodDate",0,er,"ZodDefault",0,eA,"ZodDiscriminatedUnion",0,ef,"ZodEffects",0,eO,"ZodEnum",0,eT,"ZodError",0,f,"ZodFirstPartyTypeKind",0,tx,"ZodFunction",0,eb,"ZodIntersection",0,eg,"ZodIssueCode",0,m,"ZodLazy",0,ex,"ZodLiteral",0,eS,"ZodMap",0,ek,"ZodNaN",0,eC,"ZodNativeEnum",0,eN,"ZodNever",0,ed,"ZodNull",0,eo,"ZodNullable",0,eE,"ZodNumber",0,et,"ZodObject",0,eh,"ZodOptional",0,eM,"ZodParsedType",0,p,"ZodPipeline",0,eD,"ZodPromise",0,ej,"ZodReadonly",0,eL,"ZodRecord",0,ev,"ZodSchema",0,P,"ZodSet",0,ew,"ZodString",0,ee,"ZodSymbol",0,ea,"ZodTransformer",0,eO,"ZodTuple",0,ey,"ZodType",0,P,"ZodUndefined",0,ei,"ZodUnion",0,em,"ZodUnknown",0,eu,"ZodVoid",0,ec,"addIssueToContext",0,x,"any",0,eX,"array",0,e2,"bigint",0,eV,"boolean",0,eH,"coerce",0,tf,"custom",0,eU,"date",0,eJ,"datetimeRegex",0,Q,"defaultErrorMap",0,g,"discriminatedUnion",0,e3,"effect",0,tl,"enum",0,ta,"function",0,ts,"getErrorMap",0,k,"getParsedType",0,h,"instanceof",0,eY,"intersection",0,e7,"isAborted",0,j,"isAsync",0,E,"isDirty",0,O,"isValid",0,M,"late",0,eF,"lazy",0,tn,"literal",0,tr,"makeIssue",0,w,"map",0,te,"nan",0,eB,"nativeEnum",0,ti,"never",0,e0,"null",0,eG,"nullable",0,td,"number",0,ez,"object",0,e4,"objectUtil",0,tw,"oboolean",0,t_,"onumber",0,tm,"optional",0,tu,"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 tg,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.
|
|
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 tE=e.i(74533),tA=e.i(2157),tZ=e.i(60526),tC=e.i(50227),tP=e.i(66680);let
|
|
46
|
+
}`;var tE=e.i(74533),tA=e.i(2157),tZ=e.i(60526),tC=e.i(50227),tP=e.i(66680);let tI=(0,tC.join)((0,tZ.homedir)(),".cclens","llm-runs");function tD(e,t){try{(0,tA.appendFileSync)(e,t)}catch{}}function tL(e){return new Promise((t,s)=>{let n,r,a;if(!(0,tA.existsSync)(tI))try{(0,tA.mkdirSync)(tI,{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=(r=new Date().toISOString().replace(/[:.]/g,"-"),a=(0,tP.randomUUID)().slice(0,8),`${r}_${i}_${a}`),l=(0,tC.join)(tI,`${o}.jsonl`),u=new Date().toISOString();var d=JSON.stringify({_meta:{type:"start",run_id:o,kind:i,model:e.model,ts:u,user_prompt_chars:e.userPrompt.length,reminder_chars:e.reminder?.length??0}})+"\n";try{(0,tA.writeFileSync)(l,d)}catch{}tD(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,tE.spawn)("claude",c,{stdio:["pipe","pipe","pipe"],env:{...process.env}});tD(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,f=0,g=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){
|
|
50
|
+
${e.reminder}`:e.userPrompt;p.stdin.write(h),p.stdin.end();let m="",_=0,f=0,g=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){tD(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 r=t?.model;r&&(g=r)}if("result"===s.type){let e=s.usage;e&&(_=e.input_tokens??0,f=e.output_tokens??0)}}catch{}}}}),p.stderr.on("data",e=>{y+=e.toString("utf8")}),p.on("close",e=>{let n=Date.now()-v;(tD(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:f,model_used:g,stderr_tail:y?y.trim().slice(-500):null}})+"\n"),0===e||m)?t({content:m,input_tokens:_,output_tokens:f,model:g}):s(Error(`claude exited ${e}: ${y.trim().slice(0,300)}`))}),p.on("error",e=>{tD(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 tF(e){return tL({systemPrompt:tM,model:e.model,userPrompt:e.userPrompt,reminder:e.reminder,onProgress:e.onProgress})}function tY(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 r=tO.safeParse(t);return r.success?{ok:!0,value:r.data}:{ok:!1,error:"schema validation failed: "+r.error.message}}async function tW(e,t={}){let a,i,o=t.model??"sonnet",l=t.callLLM??tF,u=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":r.test(e)?"slash_command":"human":"human"))}(e),d=(a={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=u.slice(0,8).map((e,t)=>`${t+1}. ${e.length<=300?e:e.slice(0,299)+"…"}`).join("\n"),`SLICE FACTS:
|
|
51
51
|
${JSON.stringify(a,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,f="",g=!0;try{let s=await l({model:o,userPrompt:d,onProgress:t.onProgress});m=!0,p+=s.input_tokens,h+=s.output_tokens,_=s.model;let n=tY(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(f=n.error,n.rateLimited||(g=!1),!n.rateLimited){let s=await l({model:o,userPrompt:d,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=tY(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}}}f=n.error,n.rateLimited||(g=!1)}}catch(e){f=e.message||"unknown LLM error",g=!1}let y=tU(_,p,h);return{entry:function(e,t,s,n,r,a=!1){if(a){let a={...e.enrichment,status:"pending",generated_at:r,model:s,cost_usd:n,error:t};return{...e,enrichment:a}}let i={...e.enrichment,status:"error",generated_at:r,model:s,cost_usd:n,error:t,retry_count:(e.enrichment.retry_count??0)+1};return{...e,enrichment:i}}(e,f,_,y,c,g),usage:m?{input_tokens:p,output_tokens:h}:null}}function tz(e,t,s,n,r){let a={...e.enrichment,status:"done",generated_at:r,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:a}}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,tA.mkdirSync)((0,tC.dirname)(t),{recursive:!0}),(0,tA.appendFileSync)(t,JSON.stringify(e)+"\n",{encoding:"utf8"})}function tJ(e=new Date){let t=tV();if(!(0,tA.existsSync)(t))return 0;let s=e.getUTCFullYear(),n=e.getUTCMonth(),r=0;for(let e of(0,tA.readFileSync)(t,"utf8").split("\n")){let t;if(!e)continue;try{t=JSON.parse(e)}catch{continue}let a=new Date(t.ts);Number.isNaN(a.getTime())||a.getUTCFullYear()===s&&a.getUTCMonth()===n&&(r+=t.cost_usd)}return r}e.s(["appendSpend",0,tH,"monthToDateSpend",0,tJ],78325);var tq=e.i(5737);let tK=null;function
|
|
54
|
+
${i||"(none — the user text was filtered out as non-human)"}`),c=new Date().toISOString(),p=0,h=0,m=!1,_=o,f="",g=!0;try{let s=await l({model:o,userPrompt:d,onProgress:t.onProgress});m=!0,p+=s.input_tokens,h+=s.output_tokens,_=s.model;let n=tY(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(f=n.error,n.rateLimited||(g=!1),!n.rateLimited){let s=await l({model:o,userPrompt:d,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=tY(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}}}f=n.error,n.rateLimited||(g=!1)}}catch(e){f=e.message||"unknown LLM error",g=!1}let y=tU(_,p,h);return{entry:function(e,t,s,n,r,a=!1){if(a){let a={...e.enrichment,status:"pending",generated_at:r,model:s,cost_usd:n,error:t};return{...e,enrichment:a}}let i={...e.enrichment,status:"error",generated_at:r,model:s,cost_usd:n,error:t,retry_count:(e.enrichment.retry_count??0)+1};return{...e,enrichment:i}}(e,f,_,y,c,g),usage:m?{input_tokens:p,output_tokens:h}:null}}function tz(e,t,s,n,r){let a={...e.enrichment,status:"done",generated_at:r,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:a}}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,tA.mkdirSync)((0,tC.dirname)(t),{recursive:!0}),(0,tA.appendFileSync)(t,JSON.stringify(e)+"\n",{encoding:"utf8"})}function tJ(e=new Date){let t=tV();if(!(0,tA.existsSync)(t))return 0;let s=e.getUTCFullYear(),n=e.getUTCMonth(),r=0;for(let e of(0,tA.readFileSync)(t,"utf8").split("\n")){let t;if(!e)continue;try{t=JSON.parse(e)}catch{continue}let a=new Date(t.ts);Number.isNaN(a.getTime())||a.getUTCFullYear()===s&&a.getUTCMonth()===n&&(r+=t.cost_usd)}return r}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,tA.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,tA.unlinkSync)(tX())}catch{}}let t2={ai_features:{enabled:!0,model:"sonnet",monthlyBudgetUsd:null,autoBackfillLastWeek:!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,tA.existsSync)(e))return t2;try{let t,s=(0,tA.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}}}catch{return t2}},"writeSettings",0,function(e){let t=t9();(0,tA.mkdirSync)((0,tC.dirname)(t),{recursive:!0});let s=`${t}.tmp`;(0,tA.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}},null,2),{encoding:"utf8"}),(0,tA.chmodSync)(s,384),(0,tA.renameSync)(s,t)}],56614);var tS=tS;let t5=tS.object({headline:tS.string().min(1).max(80),body:tS.string().min(1).max(300)}),t3=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:t5.nullable(),day_signature:tS.string().max(160).nullable().optional()}).passthrough(),t7=`You are synthesizing a developer's Claude Code activity for a single local day into a short, honest narrative digest.
|
|
55
55
|
|
|
56
56
|
Input is:
|
|
57
57
|
- DAY FACTS: deterministic aggregates (agent_min, projects, shipped PRs, concurrency_peak, top_flags, top_goal_categories)
|
|
@@ -115,7 +115,7 @@ RESPOND WITH ONLY VALID JSON (no prose, no code fence):
|
|
|
115
115
|
"what_hit_friction": "..." | null,
|
|
116
116
|
"suggestion": { "headline": "...", "body": "..." } | null,
|
|
117
117
|
"day_signature": "..." | null
|
|
118
|
-
}`;function
|
|
118
|
+
}`;function t6(e,t){return e.length<=t?e:e.slice(0,t-1)+"…"}function t8(e){let t=e.split("/").filter(Boolean);return t[t.length-1]??e}function se(e){let t=e.split("/").filter(Boolean);return t[t.length-1]??e}function st(e,t){return e.length<=t?e:e.slice(0,t-1).trimEnd()+"…"}function ss(e){let t=e.map(e=>{var t;let s,n,r,i,u,d,p;return e.signals??(n=(t=(s=e.first_user||"").length)<100?"short":t<500?"medium":t<2e3?"long":"very_long",r=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)),u=s.trim().toLowerCase(),d=l(s),p=/^continue\b/.test(u)||"continue."===u?"literal-continue":d.includes("handoff-prose")?"handoff-prose":"none",{working_shape:o(e),prompt_frames:d,subagent_roles:(e.subagents??[]).map(a),verbosity:n,external_refs:r?[r]:[],brainstorm_warmup:i,continuation_kind:p})}),s=e.reduce((e,t)=>e+t.numbers.active_min,0),n=new Map,r={};for(let s=0;s<e.length;s++){let a=t[s].working_shape;a&&(n.set(a,(n.get(a)??0)+e[s].numbers.active_min),r[a]=(r[a]??0)+1)}let u=null;if(n.size>0&&s>0){let e=[...n.entries()].sort((e,t)=>t[1]-e[1])[0];u=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:d(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 f;if(f=e.type,i.test(f))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 g=[..._.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:st(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],r=t[s];for(let e of((n.first_user??"").length>0&&(k[r.verbosity]+=1),r.external_refs))w.push({session_id:n.session_id,kind:e.kind,preview:st(e.preview,200)});let a=n.numbers.interrupts??0;b+=a,x+=n.satisfaction_signals?.frustrated??0,S+=n.satisfaction_signals?.dissatisfied??0,a>=2&&($+=1)}let T=t.filter(e=>e.brainstorm_warmup).length;return{dominant_shape:u,shape_distribution:r,skills_loaded:h,user_authored_skills_used:m,user_authored_subagents_used:g,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 sn(e,t,s={}){let n=t.reduce((e,t)=>e+t.numbers.active_min,0),r=new Map;for(let e of t){let t=r.get(e.project)??{minutes:0,entry_count:0};t.minutes+=e.numbers.active_min,t.entry_count+=1,r.set(e.project,t)}let a=[...r.entries()].sort((e,t)=>t[1].minutes-e[1].minutes).map(([e,t])=>({name:e,display_name:se(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:se(e.project),session_id:e.session_id}))),o=new Map;for(let e of t)for(let t of e.flags)o.set(t,(o.get(t)??0)+1);let l=[...o.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({flag:e,count:t})),u=new Map;for(let e of t)if("done"===e.enrichment.status)for(let[t,s]of Object.entries(e.enrichment.goal_categories??{}))u.set(t,(u.get(t)??0)+(s??0));let d=[...u.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({category:e,minutes:t})),c={start:`${e}T00:00:00`,end:`${e}T23:59:59`};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:a,shipped:i,top_flags:l,top_goal_categories:d,concurrency_peak:s.concurrencyPeak??0,agent_min:n,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 r=t.get(e)??0;r>n&&(s=e,n=r)}return s}(t),day_signals:t.length>0?ss(t):void 0,headline:null,narrative:null,what_went_well:null,what_hit_friction:null,suggestion:null,day_signature:null}}let sr=e=>tL({...e,systemPrompt:t7});async function sa(e,t,s={}){let n,r,a,i,o,l,u,d=sn(e,t,{concurrencyPeak:s.concurrencyPeak});if(0===t.filter(e=>"done"===e.enrichment.status).length)return{digest:d,usage:null};let c=s.model??"sonnet",p=s.callLLM??sr,h=(r=(n=t.filter(e=>"done"===e.enrichment.status)).slice(0,12).map(e=>`- (${t8(e.project)}, ${Math.round(e.numbers.active_min)}m) ${t6(e.enrichment.brief_summary??"",240)}`).join("\n"),a=n.map(e=>e.enrichment.friction_detail).filter(e=>!!e).slice(0,6).map((e,t)=>`${t+1}. ${t6(e,240)}`).join("\n"),i=n.flatMap(e=>e.enrichment.user_instructions).slice(0,10).map((e,t)=>`${t+1}. ${t6(e,240)}`).join("\n"),o=t.map(e=>({project:t8(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,brief_summary:"done"===e.enrichment.status?e.enrichment.brief_summary:null,friction_detail:"done"===e.enrichment.status?e.enrichment.friction_detail:null})),l={date:d.key,agent_min:d.agent_min,project_count:d.projects.length,projects:d.projects.map(e=>({name:e.display_name,share_pct:e.share_pct,entry_count:e.entry_count})),shipped:d.shipped.map(e=>({title:e.title,project:e.project})),concurrency_peak:d.concurrency_peak,top_flags:d.top_flags,top_goal_categories:d.top_goal_categories,per_entry:o},u=d.day_signals?`
|
|
119
119
|
|
|
120
120
|
DAY SIGNALS:
|
|
121
121
|
${JSON.stringify(d.day_signals,null,2)}`:"",`DAY FACTS:
|
|
@@ -128,7 +128,7 @@ FRICTION LINES (up to 6):
|
|
|
128
128
|
${a||"(none — smooth day)"}
|
|
129
129
|
|
|
130
130
|
USER INSTRUCTIONS (up to 10 load-bearing asks):
|
|
131
|
-
${i||"(none)"}`),m=0,_=0,f=c;try{let t,n,r=await p({model:c,userPrompt:h,onProgress:s.onProgress});m+=r.input_tokens,_+=r.output_tokens,f=r.model;let a=(t=r.content,tR(t,
|
|
131
|
+
${i||"(none)"}`),m=0,_=0,f=c;try{let t,n,r=await p({model:c,userPrompt:h,onProgress:s.onProgress});m+=r.input_tokens,_+=r.output_tokens,f=r.model;let a=(t=r.content,tR(t,t3));if(a.ok)return{digest:{...d,model:f,cost_usd:tU(f,m,_),headline:a.value.headline,narrative:a.value.narrative,what_went_well:a.value.what_went_well,what_hit_friction:a.value.what_hit_friction,suggestion:a.value.suggestion,day_signature:a.value.day_signature??null},usage:{input_tokens:m,output_tokens:_}};let i=await p({model:c,userPrompt:h,reminder:"Your previous response was not valid JSON or did not match the required schema. Return ONLY the JSON object with the six required fields — no prose, no code fence.",onProgress:s.onProgress});m+=i.input_tokens,_+=i.output_tokens,f=i.model;let o=(n=i.content,tR(n,t3));if(o.ok)return{digest:{...d,model:f,cost_usd:tU(f,m,_),headline:o.value.headline,narrative:o.value.narrative,what_went_well:o.value.what_went_well,what_hit_friction:o.value.what_hit_friction,suggestion:o.value.suggestion,day_signature:o.value.day_signature??null},usage:{input_tokens:m,output_tokens:_}};return console.warn(`[digest-day] ${e}: LLM response failed validation after retry (${o.error})`),{digest:d,usage:{input_tokens:m,output_tokens:_}}}catch(t){return console.warn(`[digest-day] ${e}: LLM invocation failed (${t.message})`),{digest:d,usage:m>0?{input_tokens:m,output_tokens:_}:null}}}var si=e.i(76956),so=e.i(66536),sl=e.i(79357),su=e.i(30212);async function sd(e){try{let t=await (0,so.listSessions)({limit:1e4}),s=(0,sl.computeBurstsFromSessions)(t),[n,r,a]=e.split("-").map(Number),i=new Date(n,r-1,a,0,0,0,0),o=new Date(n,r-1,a,23,59,59,999);return(0,su.aggregateConcurrency)(s,{start:i,end:o}).peak}catch{return 0}}async function*sc(e,t){let s=t.now??(()=>Date.now()),n=e===t.todayLocalDay,r=t.settings.enabled;if(!n&&!t.force){let t=(0,si.readDayDigest)(e);if(t)return void(yield{type:"digest",digest:t})}if(n&&!t.force){let t=(0,si.getTodayDigestFromCache)(e,s());if(t)return void(yield{type:"digest",digest:t})}let a=(0,tq.listEntriesForDay)(e);if(0===a.length)return void(yield{type:"error",message:`no entries for date ${e}`});r&&t0();try{let i;if(r){if(t.force){for(let e of a)if("error"===e.enrichment.status&&(e.enrichment.retry_count??0)>=3){let t={...e,enrichment:{...e.enrichment,status:"pending",retry_count:0,error:null}};(0,tq.writeEntry)(t)}}let n=(t.force?(0,tq.listEntriesForDay)(e):a).filter(e=>{if("pending"!==e.enrichment.status&&"error"!==e.enrichment.status||(e.enrichment.retry_count??0)>=3||e.local_day===t.todayLocalDay)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,r=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 a=n.slice(e,e+3);for(let e of(await Promise.all(a.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(r++,!e.ok){yield{type:"entry",session_id:e.entry.session_id,index:r,total:n.length,status:"error",cost_usd:0};continue}let{result:s,usage:a}=e;(0,tq.writeEntry)(s),a&&tH({ts:new Date().toISOString(),caller:t.caller??"web",model:s.enrichment.model??t.settings.model,input_tokens:a.input_tokens,output_tokens:a.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:r,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 sd(e);if(r){yield{type:"status",phase:"synth",text:"Synthesizing day narrative"};let s=[],n=sa(e,o,{model:t.settings.model,callLLM:t.callLLM,concurrencyPeak:l,onProgress:e=>{s.push({bytes:e.bytes,elapsed_ms:e.elapsedMs})}}),r=[],a=!1;for(n.finally(()=>{a=!0});!a;){for(await new Promise(e=>setTimeout(e,500));s.length>0;)r.push(s.shift());if(r.length>0){let e=r[r.length-1];yield{type:"progress",phase:"synth",bytes:e.bytes,elapsed_ms:e.elapsed_ms},r.length=0}}let u=await n;i=u.digest,u.usage&&tH({ts:new Date().toISOString(),caller:t.caller??"web",model:i.model??t.settings.model,input_tokens:u.usage.input_tokens,output_tokens:u.usage.output_tokens,cost_usd:i.cost_usd??0,kind:"day_digest",ref:e})}else i=sn(e,o,{concurrencyPeak:l});n?(0,si.setTodayDigestInCache)(e,i,s()):((0,si.writeDayDigest)(i),yield{type:"saved",path:`~/.cclens/digests/day/${e}.json`}),yield{type:"digest",digest:i}}finally{r&&t1()}}e.s(["runDayDigestPipeline",0,sc],20441);var tS=tS;let sp=/^\d{4}-\d{2}-\d{2}$/,sh=tS.object({display_name:tS.string().min(1),description:tS.string().min(1).max(600)}),sm=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(sp),quote:tS.string().min(1).max(400)})}),s_=sm.extend({surprise_kind:tS.enum(["outlier","novel-use","user-built-tool","cross-week-contrast"])}),sf=sm.extend({lean_kind:tS.enum(["claude-md","skill","hook","harness","decision"]),copyable:tS.string().max(2e3).nullable()}),sg=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(sp),line:tS.string().min(1).max(280)})).min(1),standout_days:tS.array(tS.object({date:tS.string().regex(sp),why:tS.string().min(1).max(500)})).min(1).max(2),project_areas:tS.array(sh).min(1),what_worked:tS.array(sm).min(1).max(6),what_stalled:tS.array(sm).max(5),what_surprised:tS.array(s_).max(4),where_to_lean:tS.array(sf).min(1).max(7)}).passthrough(),sy=`You are the weekly retrospective writer for Fleetlens, a dashboard for Claude Code sessions.
|
|
132
132
|
|
|
133
133
|
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, and counts. Your job is to take that texture and tell a coherent story about WHO this user is as a Claude Code operator THIS WEEK and what they should do next.
|
|
134
134
|
|
|
@@ -271,7 +271,7 @@ VOCABULARY RULES:
|
|
|
271
271
|
- 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.
|
|
272
272
|
- Prefer naming the actual subagent type ("\`general-purpose\` dispatches", "\`superpowers:code-reviewer\`") over abstract "subagents" when the type is load-bearing.
|
|
273
273
|
- "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.
|
|
274
|
-
`,sg=["shipped","partial","blocked","exploratory","trivial","idle"];function sy(e){let t=e.split("/").filter(Boolean);return t[t.length-1]??e}function sv(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 sk(e,t){return e.length<=t?e:e.slice(0,t-1).trimEnd()+"…"}function sw(e,t){return e.day_signals??se(t)}let sb=["spec-review-loop","chunk-implementation","reviewer-triad","research-then-build","background-coordinated","solo-continuation","solo-design","solo-build"];function sx(e,t,s={}){let n=sv(e),r=new Map;for(let e of t)r.set(e.key,e);let a=t.reduce((e,t)=>e+t.agent_min,0),i=new Map;for(let e of t)for(let t of e.projects){let 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,r=i.get(n)??{agent_min:0,shipped_count:0};r.shipped_count+=1,i.set(n,r)}let u=[...i.entries()].sort((e,t)=>t[1].agent_min-e[1].agent_min).map(([e,t])=>({name:e,display_name:sy(e),agent_min:t.agent_min,share_pct:a>0?t.agent_min/a*100:0,shipped_count:t.shipped_count,description:null})),d=[];for(let e of t)for(let t of e.shipped)d.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=r.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 f=[..._.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 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?se(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:sy(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 r=new Map;for(let s of e){let e=t.get(s.key)??[];for(let t of Object.keys(sw(s,e).shape_distribution)){let n=r.get(t)??[];n.push({dd:s,entries:e}),r.set(t,n)}}let a=[];for(let e of sb){let t=r.get(e);if(!t||0===t.length)continue;let i=t.sort((e,t)=>e.dd.key.localeCompare(t.dd.key)).map(({dd:t,entries:r})=>{let a=r.filter(t=>(t.signals?.working_shape??o(t))===e),i=a.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]??a[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:sk(e.prompt_preview,200)}}let u=i?sy(i.project):t.projects[0]?.display_name??"";return{date:t.key,session_id:i?.session_id??"",project_display:u,outcome:s.get(t.key)??null,helpfulness:n.get(t.key)??null,evidence_subagent:l,evidence_first_user:i?.first_user?sk(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);a.push({shape:e,occurrences:i,outcome_distribution:l})}return a}(t,y):null,$=t.length>0?function(e,t=new Map){let s=new Set,n=new Map,r=new Map,a=new Map,i={short:0,medium:0,long:0,very_long:0},o=[],u=0,d=0,c=0,p=0,h=0,m=new Set;for(let l of e){let e=l.key,_=sw(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=r.get(t.skill)??{count:0,days:new Set};s.count+=t.count,s.days.add(e),r.set(t.skill,s)}for(let t of _.user_authored_subagents_used){let s=a.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),a.set(t.type,s)}let f=_.comm_style.verbosity_distribution;for(let t of(i.short+=f.short,i.medium+=f.medium,i.long+=f.long,i.very_long+=f.very_long,_.comm_style.external_refs))o.push({date:e,session_id:t.session_id,ref_kind:t.kind,preview:sk(t.preview,200)});u+=_.comm_style.steering.interrupts,d+=_.comm_style.steering.frustrated,c+=_.comm_style.steering.dissatisfied,p+=_.comm_style.steering.sessions_with_mid_run_redirect}let _=new Map,f=0,g=0;for(let[,e]of t)for(let t of e){f+=t.numbers.turn_count??0,g+=t.numbers.exit_plan_calls??0;let e=_.get(t.session_id)??[];e.push(t),_.set(t.session_id,e)}let y=[];for(let[e,t]of _.entries()){if(new Set(t.map(e=>e.local_day)).size<2)continue;t.sort((e,t)=>e.local_day.localeCompare(t.local_day));let 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:sy(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 r.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:[...r.entries()].sort((e,t)=>t[1].count-e[1].count).map(([e,t])=>({skill:e,count:t.count,days:[...t.days].sort()})),skill_families:k,user_authored_subagents:[...a.entries()].sort((e,t)=>t[1].count-e[1].count).map(([e,t])=>({type:e,count:t.count,days:[...t.days].sort(),sample_description:t.sample_description,sample_prompt_preview:sk(t.sample_prompt_preview,200)})),threads:y,communication_style:{verbosity_distribution:i,external_context_refs:o,steering:{total_interrupts:u,total_frustrated:d,total_dissatisfied:c,sessions_with_mid_run_redirect:p,total_turns:f}},todo_ops_total:h,plan_mode:{exit_plan_calls:g,days_with_plan:m.size}}}(t,y):null,T=w.length>0?function(e){let t=new Map,s=new Map,n=new Map,r=new Set,a=0,i=0,o=0,l=0,u=0,d=0,c=0,p=new Map,h=new Map;for(let m of e){let e=m.local_day;for(let h of(a+=m.numbers.subagent_calls,o+=m.numbers.skill_calls,i+=m.numbers.task_ops,l+=m.numbers.exit_plan_calls,u+=m.numbers.interrupts,d+=m.numbers.tools_total,c+=m.numbers.turn_count,m.numbers.subagent_calls>0&&t.set(e,(t.get(e)??0)+m.numbers.subagent_calls),m.numbers.skill_calls>0&&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")&&r.add(e),m.subagents))p.set(h.type,(p.get(h.type)??0)+1);for(let[e,t]of Object.entries(m.skills))h.set(e,(h.get(e)??0)+t)}let m=[...p.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({type:e,count:t})),_=[...h.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({skill:e,count:t})),f=[],g=new Set,y=[];for(let t of e)for(let e of t.subagents)y.push({entry:t,sa:e});for(let{entry:e,sa:t}of(y.sort((e,t)=>t.sa.prompt_preview.length-e.sa.prompt_preview.length),y)){if(f.length>=3)break;g.has(t.type)||(g.add(t.type),f.push({date:e.local_day,project_display:sy(e.project),type:t.type,prompt_preview:sk(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:sk(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:sy(w.project),active_min:w.numbers.active_min,top_tools:w.top_tools.slice(0,5),first_user_preview:sk(w.first_user,200)}:null,x=c>0?d/c:0;return{orchestration:{subagent_calls:a,task_ops:i,days_with_subagents:t.size,top_types:m,examples:f},skill_use:{skill_calls:o,days_with_skills: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:u,long_autonomous_days:r.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:a,projects:u,shipped:d,outcome_mix:c,helpfulness_sparkline:p,top_flags:m,top_goal_categories:f,concurrency_peak_day:g,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 sS=e=>tL({...e,systemPrompt:sf});function s$(e){return e.toLowerCase().replace(/\s+/g," ").trim()}function sT(e,t,s,n){let r=s$(n),a=new Map;for(let e of t){let t=[e.headline,e.what_went_well,e.what_hit_friction].filter(e=>!!e);a.set(e.key,s$(t.join(" \n ")))}for(let e of s){let t=e.local_day,s=a.get(t)??"",n=[e.first_user,e.final_agent,...(e.subagents??[]).flatMap(e=>[e.description,e.prompt_preview])].filter(e=>!!e).join(" \n ");a.set(t,s$(s+" \n "+n))}let i=e=>{let t=s$(e.evidence.quote);if(r.includes(t))return!0;let s=a.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 sN(e,t,s={}){let n=sx(e,t,{entriesByDay:s.entriesByDay});if(t.filter(e=>null!==e.headline).length<2)return{digest:n,usage:null};let r=s.model??"sonnet",a=s.callLLM??sS,i=function(e,t){let s=[],n=(e="")=>s.push(e),r=new Map;for(let e of t)for(let t of e.shipped){let s=r.get(t.project)??[];s.push({title:t.title,date:e.key}),r.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 a={shipped:0,partial:0,blocked:0,exploratory:0,trivial:0,idle:0};for(let t of sg)a[t]=e.outcome_mix[t]??0;let i=sg.filter(e=>a[e]>0).map(e=>`${e}=${a[e]}`).join(", ");for(let t of(n(`Outcome mix: ${i||"(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=(r.get(e)??[]).slice(0,8),a=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(a)}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 o=e.working_shapes??[];if(0===o.length)n("(none — no day reached the threshold for shape classification)");else for(let e of o){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 l=e.interaction_grammar;if(l){if(l.brainstorming_warmup_days?.length&&n(`- Brainstorm-warmup days (${l.brainstorming_warmup_days.length}): ${l.brainstorming_warmup_days.join(", ")}`),l.prompt_frames?.length){let e=l.prompt_frames.map(e=>`${e.frame}(${e.origin})\xd7${e.count}`).join(", ");n(`- Prompt frames: ${e}`)}if(l.user_authored_skills?.length){let e=l.user_authored_skills.map(e=>`${e.skill}\xd7${e.count}`).join(", ");n(`- User-authored skills: ${e}`)}if(l.skill_families?.length){let e=l.skill_families.map(e=>`${e.family}(${e.members.length} members, ${e.total_count} uses)`).join(", ");n(`- Skill families: ${e}`)}if(l.user_authored_subagents?.length){let e=l.user_authored_subagents.map(e=>`${e.type}\xd7${e.count}`).join(", ");n(`- User-authored subagent types: ${e}`)}l.threads?.length&&n(`- Multi-day threads: ${l.threads.length} (total ${l.threads.reduce((e,t)=>e+t.total_active_min,0)}m active)`);let e=l.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 r=e.steering;n(`- Steering: ${r.total_interrupts} interrupts, ${r.total_frustrated} frustrated, ${r.total_dissatisfied} dissatisfied, ${r.sessions_with_mid_run_redirect} mid-run redirects, across ${r.total_turns} turns`)}n(`- TodoWrite ops total: ${l.todo_ops_total}`),l.plan_mode&&n(`- Plan Mode: ${l.plan_mode.exit_plan_calls} exit_plan calls, ${l.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 d;n();let t=e.top_flags.slice(0,5).map(e=>`${e.flag}(${e.count})`).join(", "),s=e.day_signals?.dominant_shape??null,r=s?` \xb7 shape: ${s}`:"";n(`### ${(d=e.key,new Date(`${d}T12:00:00`).toLocaleDateString("en-US",{weekday:"short"}))} ${e.key} — ${Math.round(e.agent_min)}m active \xb7 outcome: ${e.outcome_day}${r}`),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 a=e.day_signals;if(a){let e=Object.entries(a.shape_distribution??{}).filter(([,e])=>e>0).map(([e,t])=>`${e}:${t}`).join(", ");if(e&&n(`Shape distribution: ${e}`),a.skills_loaded.length){let e=a.skills_loaded.slice(0,6).map(e=>`${e.skill}(${e.origin})${e.count>1?`\xd7${e.count}`:""}`).join(", ");n(`Skills loaded: ${e}`)}if(a.user_authored_subagents_used.length){let e=a.user_authored_subagents_used.slice(0,4).map(e=>`${e.type}${e.count>1?`\xd7${e.count}`:""}`).join(", ");n(`User-authored subagents: ${e}`)}if(a.prompt_frames.length){let e=a.prompt_frames.map(e=>`${e.frame}(${e.origin})${e.count>1?`\xd7${e.count}`:""}`).join(", ");n(`Prompt frames: ${e}`)}let t=a.comm_style.verbosity_distribution;n(`Verbosity: short=${t.short}, medium=${t.medium}, long=${t.long}, very_long=${t.very_long}`);let s=a.comm_style.steering;n(`Steering: ${s.interrupts} interrupts, ${s.frustrated} frustrated, ${s.dissatisfied} dissatisfied, ${s.sessions_with_mid_run_redirect} mid-run redirects`),a.brainstorm_warmup_session_count>0&&n(`Brainstorm-warmup sessions: ${a.brainstorm_warmup_session_count}`),a.plan_mode_used&&n("Plan Mode: used"),a.todo_ops_total>0&&n(`TodoWrite ops: ${a.todo_ops_total}`)}}return s.join("\n")}(n,t),o=0,l=0,u=r,d=[];for(let e of(s.entriesByDay??new Map).values())d.push(...e);function c(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:u,cost_usd:tU(u,o,l),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 p,h,m=await a({model:r,userPrompt:i,onProgress:s.onProgress});o+=m.input_tokens,l+=m.output_tokens,u=m.model;let _=(p=m.content,tR(p,s_));if(_.ok)return{digest:c(sT(_.value,t,d,i)),usage:{input_tokens:o,output_tokens:l}};let f=await a({model:r,userPrompt:i,reminder:"Your previous response was not valid JSON or did not match the required schema. Return ONLY the JSON object with all required fields — no prose, no code fence.",onProgress:s.onProgress});o+=f.input_tokens,l+=f.output_tokens,u=f.model;let g=(h=f.content,tR(h,s_));if(g.ok)return{digest:c(sT(g.value,t,d,i)),usage:{input_tokens:o,output_tokens:l}};return console.warn(`[digest-week] ${e}: LLM response failed validation after retry (${g.error})`),{digest:n,usage:{input_tokens:o,output_tokens:l}}}catch(t){return console.warn(`[digest-week] ${e}: LLM invocation failed (${t.message})`),{digest:n,usage:o>0?{input_tokens:o,output_tokens:l}:null}}}var tS=tS;let sj=/^\d{4}-\d{2}-\d{2}$/,sO=tS.object({headline:tS.string().min(1).max(120),body:tS.string().min(1).max(800)}),sM=tS.object({headline:tS.string().min(1).max(160),trajectory:tS.array(tS.object({week_start:tS.string().regex(sj),line:tS.string().min(1).max(280)})).min(1),standout_weeks:tS.array(tS.object({week_start:tS.string().regex(sj),why:tS.string().min(1).max(400)})).min(1).max(2),friction_themes:tS.string().max(800),suggestion:sO}).passthrough(),sE=`You are the monthly digest writer for Fleetlens.
|
|
274
|
+
`,sv=["shipped","partial","blocked","exploratory","trivial","idle"];function sk(e){let t=e.split("/").filter(Boolean);return t[t.length-1]??e}function sw(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 sb(e,t){return e.length<=t?e:e.slice(0,t-1).trimEnd()+"…"}function sx(e,t){return e.day_signals??ss(t)}let sS=["spec-review-loop","chunk-implementation","reviewer-triad","research-then-build","background-coordinated","solo-continuation","solo-design","solo-build"];function s$(e,t,s={}){let n=sw(e),r=new Map;for(let e of t)r.set(e.key,e);let a=t.reduce((e,t)=>e+t.agent_min,0),i=new Map;for(let e of t)for(let t of e.projects){let 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,r=i.get(n)??{agent_min:0,shipped_count:0};r.shipped_count+=1,i.set(n,r)}let u=[...i.entries()].sort((e,t)=>t[1].agent_min-e[1].agent_min).map(([e,t])=>({name:e,display_name:sk(e),agent_min:t.agent_min,share_pct:a>0?t.agent_min/a*100:0,shipped_count:t.shipped_count,description:null})),d=[];for(let e of t)for(let t of e.shipped)d.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=r.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 f=[..._.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 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?ss(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:sk(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 r=new Map;for(let s of e){let e=t.get(s.key)??[];for(let t of Object.keys(sx(s,e).shape_distribution)){let n=r.get(t)??[];n.push({dd:s,entries:e}),r.set(t,n)}}let a=[];for(let e of sS){let t=r.get(e);if(!t||0===t.length)continue;let i=t.sort((e,t)=>e.dd.key.localeCompare(t.dd.key)).map(({dd:t,entries:r})=>{let a=r.filter(t=>(t.signals?.working_shape??o(t))===e),i=a.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]??a[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:sb(e.prompt_preview,200)}}let u=i?sk(i.project):t.projects[0]?.display_name??"";return{date:t.key,session_id:i?.session_id??"",project_display:u,outcome:s.get(t.key)??null,helpfulness:n.get(t.key)??null,evidence_subagent:l,evidence_first_user:i?.first_user?sb(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);a.push({shape:e,occurrences:i,outcome_distribution:l})}return a}(t,y):null,$=t.length>0?function(e,t=new Map){let s=new Set,n=new Map,r=new Map,a=new Map,i={short:0,medium:0,long:0,very_long:0},o=[],u=0,d=0,c=0,p=0,h=0,m=new Set;for(let l of e){let e=l.key,_=sx(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=r.get(t.skill)??{count:0,days:new Set};s.count+=t.count,s.days.add(e),r.set(t.skill,s)}for(let t of _.user_authored_subagents_used){let s=a.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),a.set(t.type,s)}let f=_.comm_style.verbosity_distribution;for(let t of(i.short+=f.short,i.medium+=f.medium,i.long+=f.long,i.very_long+=f.very_long,_.comm_style.external_refs))o.push({date:e,session_id:t.session_id,ref_kind:t.kind,preview:sb(t.preview,200)});u+=_.comm_style.steering.interrupts,d+=_.comm_style.steering.frustrated,c+=_.comm_style.steering.dissatisfied,p+=_.comm_style.steering.sessions_with_mid_run_redirect}let _=new Map,f=0,g=0;for(let[,e]of t)for(let t of e){f+=t.numbers.turn_count??0,g+=t.numbers.exit_plan_calls??0;let e=_.get(t.session_id)??[];e.push(t),_.set(t.session_id,e)}let y=[];for(let[e,t]of _.entries()){if(new Set(t.map(e=>e.local_day)).size<2)continue;t.sort((e,t)=>e.local_day.localeCompare(t.local_day));let 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:sk(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 r.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:[...r.entries()].sort((e,t)=>t[1].count-e[1].count).map(([e,t])=>({skill:e,count:t.count,days:[...t.days].sort()})),skill_families:k,user_authored_subagents:[...a.entries()].sort((e,t)=>t[1].count-e[1].count).map(([e,t])=>({type:e,count:t.count,days:[...t.days].sort(),sample_description:t.sample_description,sample_prompt_preview:sb(t.sample_prompt_preview,200)})),threads:y,communication_style:{verbosity_distribution:i,external_context_refs:o,steering:{total_interrupts:u,total_frustrated:d,total_dissatisfied:c,sessions_with_mid_run_redirect:p,total_turns:f}},todo_ops_total:h,plan_mode:{exit_plan_calls:g,days_with_plan:m.size}}}(t,y):null,T=w.length>0?function(e){let t=new Map,s=new Map,n=new Map,r=new Set,a=0,i=0,o=0,l=0,u=0,d=0,c=0,p=new Map,h=new Map;for(let m of e){let e=m.local_day;for(let h of(a+=m.numbers.subagent_calls,o+=m.numbers.skill_calls,i+=m.numbers.task_ops,l+=m.numbers.exit_plan_calls,u+=m.numbers.interrupts,d+=m.numbers.tools_total,c+=m.numbers.turn_count,m.numbers.subagent_calls>0&&t.set(e,(t.get(e)??0)+m.numbers.subagent_calls),m.numbers.skill_calls>0&&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")&&r.add(e),m.subagents))p.set(h.type,(p.get(h.type)??0)+1);for(let[e,t]of Object.entries(m.skills))h.set(e,(h.get(e)??0)+t)}let m=[...p.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({type:e,count:t})),_=[...h.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({skill:e,count:t})),f=[],g=new Set,y=[];for(let t of e)for(let e of t.subagents)y.push({entry:t,sa:e});for(let{entry:e,sa:t}of(y.sort((e,t)=>t.sa.prompt_preview.length-e.sa.prompt_preview.length),y)){if(f.length>=3)break;g.has(t.type)||(g.add(t.type),f.push({date:e.local_day,project_display:sk(e.project),type:t.type,prompt_preview:sb(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:sb(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:sk(w.project),active_min:w.numbers.active_min,top_tools:w.top_tools.slice(0,5),first_user_preview:sb(w.first_user,200)}:null,x=c>0?d/c:0;return{orchestration:{subagent_calls:a,task_ops:i,days_with_subagents:t.size,top_types:m,examples:f},skill_use:{skill_calls:o,days_with_skills: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:u,long_autonomous_days:r.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:a,projects:u,shipped:d,outcome_mix:c,helpfulness_sparkline:p,top_flags:m,top_goal_categories:f,concurrency_peak_day:g,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 sT=e=>tL({...e,systemPrompt:sy});function sN(e){return e.toLowerCase().replace(/\s+/g," ").trim()}function sj(e,t,s,n){let r=sN(n),a=new Map;for(let e of t){let t=[e.headline,e.what_went_well,e.what_hit_friction].filter(e=>!!e);a.set(e.key,sN(t.join(" \n ")))}for(let e of s){let t=e.local_day,s=a.get(t)??"",n=[e.first_user,e.final_agent,...(e.subagents??[]).flatMap(e=>[e.description,e.prompt_preview])].filter(e=>!!e).join(" \n ");a.set(t,sN(s+" \n "+n))}let i=e=>{let t=sN(e.evidence.quote);if(r.includes(t))return!0;let s=a.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 sO(e,t,s={}){let n=s$(e,t,{entriesByDay:s.entriesByDay});if(t.filter(e=>null!==e.headline).length<2)return{digest:n,usage:null};let r=s.model??"sonnet",a=s.callLLM??sT,i=function(e,t){let s=[],n=(e="")=>s.push(e),r=new Map;for(let e of t)for(let t of e.shipped){let s=r.get(t.project)??[];s.push({title:t.title,date:e.key}),r.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 a={shipped:0,partial:0,blocked:0,exploratory:0,trivial:0,idle:0};for(let t of sv)a[t]=e.outcome_mix[t]??0;let i=sv.filter(e=>a[e]>0).map(e=>`${e}=${a[e]}`).join(", ");for(let t of(n(`Outcome mix: ${i||"(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=(r.get(e)??[]).slice(0,8),a=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(a)}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 o=e.working_shapes??[];if(0===o.length)n("(none — no day reached the threshold for shape classification)");else for(let e of o){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 l=e.interaction_grammar;if(l){if(l.brainstorming_warmup_days?.length&&n(`- Brainstorm-warmup days (${l.brainstorming_warmup_days.length}): ${l.brainstorming_warmup_days.join(", ")}`),l.prompt_frames?.length){let e=l.prompt_frames.map(e=>`${e.frame}(${e.origin})\xd7${e.count}`).join(", ");n(`- Prompt frames: ${e}`)}if(l.user_authored_skills?.length){let e=l.user_authored_skills.map(e=>`${e.skill}\xd7${e.count}`).join(", ");n(`- User-authored skills: ${e}`)}if(l.skill_families?.length){let e=l.skill_families.map(e=>`${e.family}(${e.members.length} members, ${e.total_count} uses)`).join(", ");n(`- Skill families: ${e}`)}if(l.user_authored_subagents?.length){let e=l.user_authored_subagents.map(e=>`${e.type}\xd7${e.count}`).join(", ");n(`- User-authored subagent types: ${e}`)}l.threads?.length&&n(`- Multi-day threads: ${l.threads.length} (total ${l.threads.reduce((e,t)=>e+t.total_active_min,0)}m active)`);let e=l.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 r=e.steering;n(`- Steering: ${r.total_interrupts} interrupts, ${r.total_frustrated} frustrated, ${r.total_dissatisfied} dissatisfied, ${r.sessions_with_mid_run_redirect} mid-run redirects, across ${r.total_turns} turns`)}n(`- TodoWrite ops total: ${l.todo_ops_total}`),l.plan_mode&&n(`- Plan Mode: ${l.plan_mode.exit_plan_calls} exit_plan calls, ${l.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 d;n();let t=e.top_flags.slice(0,5).map(e=>`${e.flag}(${e.count})`).join(", "),s=e.day_signals?.dominant_shape??null,r=s?` \xb7 shape: ${s}`:"";n(`### ${(d=e.key,new Date(`${d}T12:00:00`).toLocaleDateString("en-US",{weekday:"short"}))} ${e.key} — ${Math.round(e.agent_min)}m active \xb7 outcome: ${e.outcome_day}${r}`),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 a=e.day_signals;if(a){let e=Object.entries(a.shape_distribution??{}).filter(([,e])=>e>0).map(([e,t])=>`${e}:${t}`).join(", ");if(e&&n(`Shape distribution: ${e}`),a.skills_loaded.length){let e=a.skills_loaded.slice(0,6).map(e=>`${e.skill}(${e.origin})${e.count>1?`\xd7${e.count}`:""}`).join(", ");n(`Skills loaded: ${e}`)}if(a.user_authored_subagents_used.length){let e=a.user_authored_subagents_used.slice(0,4).map(e=>`${e.type}${e.count>1?`\xd7${e.count}`:""}`).join(", ");n(`User-authored subagents: ${e}`)}if(a.prompt_frames.length){let e=a.prompt_frames.map(e=>`${e.frame}(${e.origin})${e.count>1?`\xd7${e.count}`:""}`).join(", ");n(`Prompt frames: ${e}`)}let t=a.comm_style.verbosity_distribution;n(`Verbosity: short=${t.short}, medium=${t.medium}, long=${t.long}, very_long=${t.very_long}`);let s=a.comm_style.steering;n(`Steering: ${s.interrupts} interrupts, ${s.frustrated} frustrated, ${s.dissatisfied} dissatisfied, ${s.sessions_with_mid_run_redirect} mid-run redirects`),a.brainstorm_warmup_session_count>0&&n(`Brainstorm-warmup sessions: ${a.brainstorm_warmup_session_count}`),a.plan_mode_used&&n("Plan Mode: used"),a.todo_ops_total>0&&n(`TodoWrite ops: ${a.todo_ops_total}`)}}return s.join("\n")}(n,t),o=0,l=0,u=r,d=[];for(let e of(s.entriesByDay??new Map).values())d.push(...e);function c(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:u,cost_usd:tU(u,o,l),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 p,h,m=await a({model:r,userPrompt:i,onProgress:s.onProgress});o+=m.input_tokens,l+=m.output_tokens,u=m.model;let _=(p=m.content,tR(p,sg));if(_.ok)return{digest:c(sj(_.value,t,d,i)),usage:{input_tokens:o,output_tokens:l}};let f=await a({model:r,userPrompt:i,reminder:"Your previous response was not valid JSON or did not match the required schema. Return ONLY the JSON object with all required fields — no prose, no code fence.",onProgress:s.onProgress});o+=f.input_tokens,l+=f.output_tokens,u=f.model;let g=(h=f.content,tR(h,sg));if(g.ok)return{digest:c(sj(g.value,t,d,i)),usage:{input_tokens:o,output_tokens:l}};return console.warn(`[digest-week] ${e}: LLM response failed validation after retry (${g.error})`),{digest:n,usage:{input_tokens:o,output_tokens:l}}}catch(t){return console.warn(`[digest-week] ${e}: LLM invocation failed (${t.message})`),{digest:n,usage:o>0?{input_tokens:o,output_tokens:l}:null}}}var tS=tS;let sM=/^\d{4}-\d{2}-\d{2}$/,sE=tS.object({headline:tS.string().min(1).max(120),body:tS.string().min(1).max(800)}),sA=tS.object({headline:tS.string().min(1).max(160),trajectory:tS.array(tS.object({week_start:tS.string().regex(sM),line:tS.string().min(1).max(280)})).min(1),standout_weeks:tS.array(tS.object({week_start:tS.string().regex(sM),why:tS.string().min(1).max(400)})).min(1).max(2),friction_themes:tS.string().max(800),suggestion:sE}).passthrough(),sZ=`You are the monthly digest writer for Fleetlens.
|
|
275
275
|
|
|
276
276
|
You receive a JSON payload describing one calendar month, summarised through its 4–5 weekly digests.
|
|
277
277
|
Your job: produce a 5-field JSON object capturing the shape of the month.
|
|
@@ -309,9 +309,9 @@ RULES:
|
|
|
309
309
|
2. Trajectory lines name the dominant work of each week — projects shipped, themes that ran across multiple days, blockers that persisted.
|
|
310
310
|
3. Standout weeks are weeks that shipped disproportionately, were unusually blocked, or shifted the trajectory of the month.
|
|
311
311
|
4. Friction themes look at recurrence — friction that appeared in 2+ weeks deserves naming; one-week friction usually doesn't.
|
|
312
|
-
5. Strict JSON.`,
|
|
312
|
+
5. Strict JSON.`,sC=["shipped","partial","blocked","exploratory","trivial","idle"];function sP(e){let[t,s]=e.split("-"),n=Number(t),r=Number(s),a=[],i=(8-new Date(n,r-1,1).getDay())%7,o=new Date(new Date(n,r-1,1+i));for(;o.getMonth()===r-1;)a.push(sI(o)),o.setDate(o.getDate()+7);return a}function sI(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 sD(e,t){let s=sP(e),n=new Map;for(let e of t)n.set(e.key,e);let r=t.reduce((e,t)=>e+t.agent_min_total,0),a=new Map;for(let e of t)for(let t of e.projects){let e=a.get(t.name)??{agent_min:0,shipped_count:0};e.agent_min+=t.agent_min,e.shipped_count+=t.shipped_count,a.set(t.name,e)}let i=[...a.entries()].sort((e,t)=>t[1].agent_min-e[1].agent_min).map(([e,t])=>{let s;return{name:e,display_name:(s=e.split("/").filter(Boolean))[s.length-1]??e,agent_min:t.agent_min,share_pct:r>0?t.agent_min/r*100:0,shipped_count:t.shipped_count}}),o=[];for(let e of t)for(let t of e.shipped)o.push({title:t.title,project:t.project,date:t.date,session_id:t.session_id});let l={};for(let e of t)for(let[t,s]of Object.entries(e.outcome_mix))l[t]=(l[t]??0)+s;let u=s.map(e=>{let t=n.get(e);return{week_start:e,helpfulness:t?t.helpfulness_sparkline.find(e=>null!==e)??null:null}}),d=new Map;for(let e of t)for(let t of e.top_flags)d.set(t.flag,(d.get(t.flag)??0)+t.count);let c=[...d.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({flag:e,count:t})),p=new Map;for(let e of t)for(let t of e.top_goal_categories)p.set(t.category,(p.get(t.category)??0)+t.minutes);let h=[...p.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({category:e,minutes:t})),m=null;for(let e of t){let t=e.concurrency_peak_day?.peak??0;t>0&&(!m||t>m.peak)&&(m={week_start:e.key,peak:t})}let[_,f]=e.split("-"),g=Number(_),y=Number(f),v=`${e}-01`,k=sI(new Date(g,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:r,projects:i,shipped:o,outcome_mix:l,helpfulness_by_week:u,top_flags:c,top_goal_categories:h,concurrency_peak_week:m,headline:null,trajectory:null,standout_weeks:null,friction_themes:null,suggestion:null}}let sL=e=>tL({...e,systemPrompt:sZ});async function sR(e,t,s={}){let n=sD(e,t);if(t.filter(e=>null!==e.headline).length<2)return{digest:n,usage:null};let r=s.model??"sonnet",a=s.callLLM??sL,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],r=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:r,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 sC)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,u=r;try{let t,d,c=await a({model:r,userPrompt:i,onProgress:s.onProgress});o+=c.input_tokens,l+=c.output_tokens,u=c.model;let p=(t=c.content,tR(t,sA));if(p.ok)return{digest:{...n,model:u,cost_usd:tU(u,o,l),headline:p.value.headline,trajectory:p.value.trajectory,standout_weeks:p.value.standout_weeks,friction_themes:p.value.friction_themes,suggestion:p.value.suggestion},usage:{input_tokens:o,output_tokens:l}};let h=await a({model:r,userPrompt:i,reminder:"Your previous response was not valid JSON or did not match the required schema. Return ONLY the JSON object with the five required fields — no prose, no code fence.",onProgress:s.onProgress});o+=h.input_tokens,l+=h.output_tokens,u=h.model;let m=(d=h.content,tR(d,sA));if(m.ok)return{digest:{...n,model:u,cost_usd:tU(u,o,l),headline:m.value.headline,trajectory:m.value.trajectory,standout_weeks:m.value.standout_weeks,friction_themes:m.value.friction_themes,suggestion:m.value.suggestion},usage:{input_tokens:o,output_tokens:l}};return console.warn(`[digest-month] ${e}: LLM response failed validation after retry (${m.error})`),{digest: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 sU(e){return Math.round(e/1e3/60*10)/10}function sF(e,t){return e?e.length<=2*t+60?{chars:e.length,preview:e}:{chars:e.length,preview:e.slice(0,t)+`
|
|
313
313
|
[…truncated ${e.length-2*t} chars…]
|
|
314
|
-
`+e.slice(-t)}:null}function
|
|
314
|
+
`+e.slice(-t)}:null}function sY(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 sW=new Set(["sudo","time","nohup","nice","env","exec"]),sz=/\[request interrupted|interrupted by user/i,sB=/--title\s+["']([^"']+)["']/,sV=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)+"..."})}),sH=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(sV).min(2).max(6)}).passthrough(),sJ=`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.
|
|
315
315
|
|
|
316
316
|
INPUT shape (transcript-style markdown, NOT JSON):
|
|
317
317
|
The user prompt is a markdown document with these sections:
|
|
@@ -374,6 +374,6 @@ VOCABULARY:
|
|
|
374
374
|
- Internal flag tokens (loop_suspected, long_autonomous, fast_ship) — forbidden in labels
|
|
375
375
|
- "Plan Mode" specifically means /plan tool calls
|
|
376
376
|
- Avoid identity claims ("you're a Plan Mode person"). Stick to observed action.
|
|
377
|
-
`,sH=e=>tL({...e,systemPrompt:sV});async function sJ(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",r=t.callLLM??sH,a=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 r=e.steering;for(let t of(s("## Steering"),s(`${r.user_msg_count} user messages (median ${r.median_user_msg_chars} chars, ${r.long_user_msg_count} long, ${r.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 u,d,c=await r({model:n,userPrompt:a,onProgress:t.onProgress});i+=c.input_tokens,o+=c.output_tokens,c.model;let p=(u=c.content,tR(u,sB));if(p.ok)return{topSession:l(p.value),usage:{input_tokens:i,output_tokens:o}};let h=await r({model:n,userPrompt:a,reminder:"Your previous response was not valid JSON or did not match the required schema. Return ONLY the JSON object with session_summary + steering_summary + pins (3-5 items, each with start_min/kind/label) — no prose, no code fence.",onProgress:t.onProgress});i+=h.input_tokens,o+=h.output_tokens,h.model;let m=(d=h.content,tR(d,sB));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*sq(e,t){let s=t.now??(()=>Date.now()),n=e===t.currentWeekMonday,r=t.settings.enabled;if(!n&&!t.force){let t=(0,sr.readWeekDigest)(e);if(t)return void(yield{type:"digest",digest:t})}if(n&&!t.force){let t=(0,sr.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 a=sv(e),l=[];for(let e of a){if(e>t.todayLocalDay){yield{type:"dependency",kind:"day",key:e,status:"cached"};continue}let s=e===t.todayLocalDay,n=s?null:(0,sr.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:!1,callLLM:t.callLLM,now:t.now,todayLocalDay:t.todayLocalDay,caller:t.caller},n=null,r=!1;for await(let t of su(e,s))if("digest"===t.type&&"day"===t.digest.scope&&(n=t.digest),"error"===t.type){r=!0;break}n?(l.push(n),yield{type:"dependency",kind:"day",key:e,status:"cached"}):r&&(yield{type:"dependency",kind:"day",key:e,status:"failed"});continue}let r={settings:t.settings,force:!1,callLLM:t.callLLM,now:t.now,todayLocalDay:t.todayLocalDay,caller:t.caller},a=null,i=!1;for await(let t of su(e,r)){if("digest"===t.type){"day"===t.digest.scope&&(a=t.digest);continue}if("saved"!==t.type){if("error"===t.type){i=!0;continue}yield t}}a?(l.push(a),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 u=new Map;for(let e of a)e>t.todayLocalDay||u.set(e,(0,tq.listEntriesForDay)(e));r&&tX();try{let a,c=new Map(l.map(e=>[e.key,e])),p=r?function(e){let t=[];for(let s of e.values())t.push(...s);let s=t.filter(e=>e.numbers.active_min>=20||e.numbers.turn_count>=10||e.pr_titles.length>=1).map(e=>({entry:e,score:e.numbers.active_min*(1+.5*e.numbers.subagent_calls+5*e.pr_titles.length)})).sort((e,t)=>t.score-e.score),n=new Set,r=[];for(let{entry:e}of s)if(!n.has(e.project)&&(n.add(e.project),r.push(e),r.length>=3))break;return r}(u):[],h=(await Promise.all(p.map(async e=>{try{let t=await (0,sa.getSession)(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,r;let a,l=Date.parse(e.start_iso),{turns:u,sliceStartMs:c,sliceEndMs:p}=function(e,t,s){let n=[];for(let r of e){if(!r.timestamp)continue;let e=Date.parse(r.timestamp);!Number.isNaN(e)&&(e<t||e>s||n.push({...r,_ts:e}))}if(0===n.length)return{turns:[],sliceStartMs:t,sliceEndMs:s};n.sort((e,t)=>e._ts-t._ts);let r=n[0]._ts,a=n[n.length-1]._ts,i=[],o=null;for(let e of n){let t=e.raw,s=t?.message?.content;if("user"===e.rawType)if(Array.isArray(s)&&s.length>0&&s.every(e=>e&&"object"==typeof e&&"tool_result"===e.type))o&&(o.events.push(e),o.timestamps.push(e._ts));else{let t=(Array.isArray(s)?s.filter(e=>!!e&&"object"==typeof e&&"text"===e.type&&"string"==typeof e.text).map(e=>e.text).join(" "):"")||("string"==typeof s?s:""),n=sY.test(t);o&&n&&(o.interrupts+=1),o&&i.push(o),o={events:[e],user_text:t,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("assistant"===e.rawType){if(!o)continue;if(o.events.push(e),o.timestamps.push(e._ts),Array.isArray(s)){for(let e of s)if(e&&"object"==typeof e){if("text"===e.type&&e.text)o.agent_blocks.push(e.text);else if("tool_use"===e.type){let t=e.name??"unknown";if(o.tools_count.set(t,(o.tools_count.get(t)??0)+1),"Skill"===t){let t=String(e.input?.skill??"unknown");o.skills.set(t,(o.skills.get(t)??0)+1)}else if("Agent"===t){let t=e.input??{};o.subagents.push({type:String(t.subagent_type??"general-purpose"),description:String(t.description??"").slice(0,80),prompt_preview:String(t.prompt??"").slice(0,240),background:!!t.run_in_background})}else if("ExitPlanMode"===t)o.exit_plan_calls+=1;else if("TodoWrite"===t||"TaskCreate"===t||"TaskUpdate"===t)o.todo_ops+=1;else if("Bash"===t){let t=String(e.input?.command??""),s=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&&sF.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,"")||"?"}(t);if(o.bash_verbs.set(s,(o.bash_verbs.get(s)??0)+1),/\bgh\s+pr\s+create\b/.test(t)){let e=t.match(sW);o.pr_created=e?.[1]??t.slice(0,120)}}}}}}}return o&&i.push(o),{turns:i,sliceStartMs:r,sliceEndMs:a}}(t,l,Date.parse(e.end_iso)),h=u.flatMap(e=>e.timestamps),m=p-c,_=sU(h),f=[...h].sort((e,t)=>e-t),g=[];if(f.length>0){let e=f[0],t=f[0];for(let s=1;s<f.length;s++)f[s]-t>=18e4&&(g.push({start_min:sL(e-c),end_min:sL(t-c)}),e=f[s]),t=f[s];g.push({start_min:sL(e-c),end_min:sL(t-c)})}let y=[],v=c,k=[],w=0;u.forEach((e,t)=>{let s=Math.min(...e.timestamps),n=Math.max(...e.timestamps),r=sU(e.timestamps),a=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,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 d={turn:t+1,start_min:sL(s-c),end_min:sL(n-c),wall_min:sL(n-s),active_min:sL(r),idle_before_min:sL(a),start_iso:new Date(s).toISOString(),user:e.user_text?sR(e.user_text,0===t?400:150):null,tools:u};l?d.agent=sR(i,200):(d.first_agent=i?sR(i,150):null,d.last_agent=o?sR(o,200):null),e.skills.size>0&&(d.skills_loaded=[...e.skills.entries()].map(([e,t])=>t>1?`${e}\xd7${t}`:e)),e.subagents.length>0&&(d.subagents_dispatched=e.subagents.map(e=>({type:e.type,description:e.description,prompt_preview:e.prompt_preview}))),e.exit_plan_calls>0&&(d.exit_plan_calls=e.exit_plan_calls),e.todo_ops>0&&(d.todo_ops=e.todo_ops),e.interrupts>0&&(d.interrupts=e.interrupts),e.pr_created&&(d.pr_created=e.pr_created),r>=12e5&&0===e.interrupts&&(d.long_autonomous_run=!0),y.push(d)});let b=new Map,x=new Map,S=new Map,$=new Map,T=0;for(let e of u){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=d(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)],E=[];for(let e of y)e.user?.chars&&e.user.chars>=800&&E.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&&E.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&&E.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&&E.push({start_min:e.start_min,kind:"plan-mode",context:{turn:e.turn}}),e.pr_created&&E.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&&E.push({start_min:e.start_min,kind:"harness-chain",context:{skills:e.skills_loaded,turn:e.turn}}),e.interrupts&&e.interrupts>0&&E.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=(r=e.project).split("/").filter(Boolean))[a.length-1]??r,start_iso:new Date(c).toISOString(),wall_min:sL(m),active_min:sL(_),idle_min:sL(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:g,turns:y,candidate_pins:E}}(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(r){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=[],n=sN(e,l,{model:t.settings.model,callLLM:t.callLLM,entriesByDay:u,onProgress:e=>{s.push({bytes:e.bytes,elapsed_ms:e.elapsedMs})}}),r=Promise.all(h.map(({entry:e,slice:s})=>sJ(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)))),i=!1,o=!1;for(n.finally(()=>{i=!0}),r.finally(()=>{o=!0});!i||!o;)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 d=await n,c=await r;a=d.digest,d.usage&&tH({ts:new Date().toISOString(),caller:t.caller??"web",model:a.model??t.settings.model,input_tokens:d.usage.input_tokens,output_tokens:d.usage.output_tokens,cost_usd:a.cost_usd??0,kind:"week_digest",ref:e});let p=[];for(let s of c)s&&(p.push(s.topSession),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}`}));a.headline&&p.length>0&&(a.top_sessions=p)}else a=sx(e,l,{entriesByDay:u});n?(a.is_live=!0,(0,sr.setCurrentWeekDigestInCache)(e,a,s())):((0,sr.writeWeekDigest)(a),yield{type:"saved",path:`~/.cclens/digests/week/${e}.json`}),yield{type:"digest",digest:a}}finally{r&&tQ()}}async function*sK(e,t){let s=t.now??(()=>Date.now()),n=e===t.currentYearMonth,r=t.settings.enabled;if(!n&&!t.force){let t=(0,sr.readMonthDigest)(e);if(t)return void(yield{type:"digest",digest:t})}if(n&&!t.force){let t=(0,sr.getCurrentMonthDigestFromCache)(e,s());if(t)return void(yield{type:"digest",digest:t})}yield{type:"status",phase:"load_dependencies",text:`Loading weeks for ${e}`};let a=sZ(e),i=[];for(let e of a){if(e>t.currentWeekMonday){yield{type:"dependency",kind:"week",key:e,status:"cached"};continue}let s=e===t.currentWeekMonday,n=s?null:(0,sr.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,r=!1;for await(let t of sq(e,s))if("digest"===t.type&&"week"===t.digest.scope&&(n=t.digest),"error"===t.type){r=!0;break}n?(i.push(n),yield{type:"dependency",kind:"week",key:e,status:"cached"}):r&&(yield{type:"dependency",kind:"week",key:e,status:"failed"});continue}let r={settings:t.settings,force:!1,callLLM:t.callLLM,now:t.now,currentWeekMonday:t.currentWeekMonday,todayLocalDay:t.todayLocalDay,caller:t.caller},a=null,o=!1;for await(let t of sq(e,r)){if("digest"===t.type){"week"===t.digest.scope&&(a=t.digest);continue}if("saved"!==t.type){if("error"===t.type){o=!0;continue}yield t}}a?(i.push(a),yield{type:"dependency",kind:"week",key:e,status:"generated"}):o&&(yield{type:"dependency",kind:"week",key:e,status:"failed"})}if(0===i.length)return void(yield{type:"error",message:`no week digests available for ${e}`});r&&tX();try{let a;if(r){yield{type:"status",phase:"synth",text:"Synthesizing month narrative"};let s=[],n=sI(e,i,{model:t.settings.model,callLLM:t.callLLM,onProgress:e=>{s.push({bytes:e.bytes,elapsed_ms:e.elapsedMs})}}),r=!1;for(n.finally(()=>{r=!0});!r;)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;a=o.digest,o.usage&&tH({ts:new Date().toISOString(),caller:t.caller??"web",model:a.model??t.settings.model,input_tokens:o.usage.input_tokens,output_tokens:o.usage.output_tokens,cost_usd:a.cost_usd??0,kind:"month_digest",ref:e})}else a=sP(e,i);n?(a.is_live=!0,(0,sr.setCurrentMonthDigestInCache)(e,a,s())):((0,sr.writeMonthDigest)(a),yield{type:"saved",path:`~/.cclens/digests/month/${e}.json`}),yield{type:"digest",digest:a}}finally{r&&tQ()}}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(),r=String(t.getMonth()+1).padStart(2,"0"),a=String(t.getDate()).padStart(2,"0");return`${n}-${r}-${a}`},"runWeekDigestPipeline",0,sq],77242),e.s(["runMonthDigestPipeline",0,sK],21628),e.s([],82111)}];
|
|
377
|
+
`,sq=e=>tL({...e,systemPrompt:sJ});async function sK(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",r=t.callLLM??sq,a=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 r=e.steering;for(let t of(s("## Steering"),s(`${r.user_msg_count} user messages (median ${r.median_user_msg_chars} chars, ${r.long_user_msg_count} long, ${r.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 u,d,c=await r({model:n,userPrompt:a,onProgress:t.onProgress});i+=c.input_tokens,o+=c.output_tokens,c.model;let p=(u=c.content,tR(u,sH));if(p.ok)return{topSession:l(p.value),usage:{input_tokens:i,output_tokens:o}};let h=await r({model:n,userPrompt:a,reminder:"Your previous response was not valid JSON or did not match the required schema. Return ONLY the JSON object with session_summary + steering_summary + pins (3-5 items, each with start_min/kind/label) — no prose, no code fence.",onProgress:t.onProgress});i+=h.input_tokens,o+=h.output_tokens,h.model;let m=(d=h.content,tR(d,sH));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*sG(e,t){let s=t.now??(()=>Date.now()),n=e===t.currentWeekMonday,r=t.settings.enabled;if(!n&&!t.force){let t=(0,si.readWeekDigest)(e);if(t)return void(yield{type:"digest",digest:t})}if(n&&!t.force){let t=(0,si.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 a=sw(e),l=[];for(let e of a){if(e>t.todayLocalDay){yield{type:"dependency",kind:"day",key:e,status:"cached"};continue}let s=e===t.todayLocalDay,n=s?null:(0,si.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:!1,callLLM:t.callLLM,now:t.now,todayLocalDay:t.todayLocalDay,caller:t.caller},n=null,r=!1;for await(let t of sc(e,s))if("digest"===t.type&&"day"===t.digest.scope&&(n=t.digest),"error"===t.type){r=!0;break}n?(l.push(n),yield{type:"dependency",kind:"day",key:e,status:"cached"}):r&&(yield{type:"dependency",kind:"day",key:e,status:"failed"});continue}let r={settings:t.settings,force:!1,callLLM:t.callLLM,now:t.now,todayLocalDay:t.todayLocalDay,caller:t.caller},a=null,i=!1;for await(let t of sc(e,r)){if("digest"===t.type){"day"===t.digest.scope&&(a=t.digest);continue}if("saved"!==t.type){if("error"===t.type){i=!0;continue}yield t}}a?(l.push(a),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 u=new Map;for(let e of a)e>t.todayLocalDay||u.set(e,(0,tq.listEntriesForDay)(e));r&&t0();try{let a,c=new Map(l.map(e=>[e.key,e])),p=r?function(e){let t=[];for(let s of e.values())t.push(...s);let s=t.filter(e=>e.numbers.active_min>=20||e.numbers.turn_count>=10||e.pr_titles.length>=1).map(e=>({entry:e,score:e.numbers.active_min*(1+.5*e.numbers.subagent_calls+5*e.pr_titles.length)})).sort((e,t)=>t.score-e.score),n=new Set,r=[];for(let{entry:e}of s)if(!n.has(e.project)&&(n.add(e.project),r.push(e),r.length>=3))break;return r}(u):[],h=(await Promise.all(p.map(async e=>{try{let t=await (0,so.getSession)(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,r;let a,l=Date.parse(e.start_iso),{turns:u,sliceStartMs:c,sliceEndMs:p}=function(e,t,s){let n=[];for(let r of e){if(!r.timestamp)continue;let e=Date.parse(r.timestamp);!Number.isNaN(e)&&(e<t||e>s||n.push({...r,_ts:e}))}if(0===n.length)return{turns:[],sliceStartMs:t,sliceEndMs:s};n.sort((e,t)=>e._ts-t._ts);let r=n[0]._ts,a=n[n.length-1]._ts,i=[],o=null;for(let e of n){let t=e.raw,s=t?.message?.content;if("user"===e.rawType)if(Array.isArray(s)&&s.length>0&&s.every(e=>e&&"object"==typeof e&&"tool_result"===e.type))o&&(o.events.push(e),o.timestamps.push(e._ts));else{let t=(Array.isArray(s)?s.filter(e=>!!e&&"object"==typeof e&&"text"===e.type&&"string"==typeof e.text).map(e=>e.text).join(" "):"")||("string"==typeof s?s:""),n=sz.test(t);o&&n&&(o.interrupts+=1),o&&i.push(o),o={events:[e],user_text:t,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("assistant"===e.rawType){if(!o)continue;if(o.events.push(e),o.timestamps.push(e._ts),Array.isArray(s)){for(let e of s)if(e&&"object"==typeof e){if("text"===e.type&&e.text)o.agent_blocks.push(e.text);else if("tool_use"===e.type){let t=e.name??"unknown";if(o.tools_count.set(t,(o.tools_count.get(t)??0)+1),"Skill"===t){let t=String(e.input?.skill??"unknown");o.skills.set(t,(o.skills.get(t)??0)+1)}else if("Agent"===t){let t=e.input??{};o.subagents.push({type:String(t.subagent_type??"general-purpose"),description:String(t.description??"").slice(0,80),prompt_preview:String(t.prompt??"").slice(0,240),background:!!t.run_in_background})}else if("ExitPlanMode"===t)o.exit_plan_calls+=1;else if("TodoWrite"===t||"TaskCreate"===t||"TaskUpdate"===t)o.todo_ops+=1;else if("Bash"===t){let t=String(e.input?.command??""),s=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&&sW.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,"")||"?"}(t);if(o.bash_verbs.set(s,(o.bash_verbs.get(s)??0)+1),/\bgh\s+pr\s+create\b/.test(t)){let e=t.match(sB);o.pr_created=e?.[1]??t.slice(0,120)}}}}}}}return o&&i.push(o),{turns:i,sliceStartMs:r,sliceEndMs:a}}(t,l,Date.parse(e.end_iso)),h=u.flatMap(e=>e.timestamps),m=p-c,_=sY(h),f=[...h].sort((e,t)=>e-t),g=[];if(f.length>0){let e=f[0],t=f[0];for(let s=1;s<f.length;s++)f[s]-t>=18e4&&(g.push({start_min:sU(e-c),end_min:sU(t-c)}),e=f[s]),t=f[s];g.push({start_min:sU(e-c),end_min:sU(t-c)})}let y=[],v=c,k=[],w=0;u.forEach((e,t)=>{let s=Math.min(...e.timestamps),n=Math.max(...e.timestamps),r=sY(e.timestamps),a=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,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 d={turn:t+1,start_min:sU(s-c),end_min:sU(n-c),wall_min:sU(n-s),active_min:sU(r),idle_before_min:sU(a),start_iso:new Date(s).toISOString(),user:e.user_text?sF(e.user_text,0===t?400:150):null,tools:u};l?d.agent=sF(i,200):(d.first_agent=i?sF(i,150):null,d.last_agent=o?sF(o,200):null),e.skills.size>0&&(d.skills_loaded=[...e.skills.entries()].map(([e,t])=>t>1?`${e}\xd7${t}`:e)),e.subagents.length>0&&(d.subagents_dispatched=e.subagents.map(e=>({type:e.type,description:e.description,prompt_preview:e.prompt_preview}))),e.exit_plan_calls>0&&(d.exit_plan_calls=e.exit_plan_calls),e.todo_ops>0&&(d.todo_ops=e.todo_ops),e.interrupts>0&&(d.interrupts=e.interrupts),e.pr_created&&(d.pr_created=e.pr_created),r>=12e5&&0===e.interrupts&&(d.long_autonomous_run=!0),y.push(d)});let b=new Map,x=new Map,S=new Map,$=new Map,T=0;for(let e of u){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=d(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)],E=[];for(let e of y)e.user?.chars&&e.user.chars>=800&&E.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&&E.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&&E.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&&E.push({start_min:e.start_min,kind:"plan-mode",context:{turn:e.turn}}),e.pr_created&&E.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&&E.push({start_min:e.start_min,kind:"harness-chain",context:{skills:e.skills_loaded,turn:e.turn}}),e.interrupts&&e.interrupts>0&&E.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=(r=e.project).split("/").filter(Boolean))[a.length-1]??r,start_iso:new Date(c).toISOString(),wall_min:sU(m),active_min:sU(_),idle_min:sU(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:g,turns:y,candidate_pins:E}}(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(r){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=[],n=sO(e,l,{model:t.settings.model,callLLM:t.callLLM,entriesByDay:u,onProgress:e=>{s.push({bytes:e.bytes,elapsed_ms:e.elapsedMs})}}),r=Promise.all(h.map(({entry:e,slice:s})=>sK(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)))),i=!1,o=!1;for(n.finally(()=>{i=!0}),r.finally(()=>{o=!0});!i||!o;)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 d=await n,c=await r;a=d.digest,d.usage&&tH({ts:new Date().toISOString(),caller:t.caller??"web",model:a.model??t.settings.model,input_tokens:d.usage.input_tokens,output_tokens:d.usage.output_tokens,cost_usd:a.cost_usd??0,kind:"week_digest",ref:e});let p=[];for(let s of c)s&&(p.push(s.topSession),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}`}));a.headline&&p.length>0&&(a.top_sessions=p)}else a=s$(e,l,{entriesByDay:u});n?(a.is_live=!0,(0,si.setCurrentWeekDigestInCache)(e,a,s())):((0,si.writeWeekDigest)(a),yield{type:"saved",path:`~/.cclens/digests/week/${e}.json`}),yield{type:"digest",digest:a}}finally{r&&t1()}}async function*sX(e,t){let s=t.now??(()=>Date.now()),n=e===t.currentYearMonth,r=t.settings.enabled;if(!n&&!t.force){let t=(0,si.readMonthDigest)(e);if(t)return void(yield{type:"digest",digest:t})}if(n&&!t.force){let t=(0,si.getCurrentMonthDigestFromCache)(e,s());if(t)return void(yield{type:"digest",digest:t})}yield{type:"status",phase:"load_dependencies",text:`Loading weeks for ${e}`};let a=sP(e),i=[];for(let e of a){if(e>t.currentWeekMonday){yield{type:"dependency",kind:"week",key:e,status:"cached"};continue}let s=e===t.currentWeekMonday,n=s?null:(0,si.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,r=!1;for await(let t of sG(e,s))if("digest"===t.type&&"week"===t.digest.scope&&(n=t.digest),"error"===t.type){r=!0;break}n?(i.push(n),yield{type:"dependency",kind:"week",key:e,status:"cached"}):r&&(yield{type:"dependency",kind:"week",key:e,status:"failed"});continue}let r={settings:t.settings,force:!1,callLLM:t.callLLM,now:t.now,currentWeekMonday:t.currentWeekMonday,todayLocalDay:t.todayLocalDay,caller:t.caller},a=null,o=!1;for await(let t of sG(e,r)){if("digest"===t.type){"week"===t.digest.scope&&(a=t.digest);continue}if("saved"!==t.type){if("error"===t.type){o=!0;continue}yield t}}a?(i.push(a),yield{type:"dependency",kind:"week",key:e,status:"generated"}):o&&(yield{type:"dependency",kind:"week",key:e,status:"failed"})}if(0===i.length)return void(yield{type:"error",message:`no week digests available for ${e}`});r&&t0();try{let a;if(r){yield{type:"status",phase:"synth",text:"Synthesizing month narrative"};let s=[],n=sR(e,i,{model:t.settings.model,callLLM:t.callLLM,onProgress:e=>{s.push({bytes:e.bytes,elapsed_ms:e.elapsedMs})}}),r=!1;for(n.finally(()=>{r=!0});!r;)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;a=o.digest,o.usage&&tH({ts:new Date().toISOString(),caller:t.caller??"web",model:a.model??t.settings.model,input_tokens:o.usage.input_tokens,output_tokens:o.usage.output_tokens,cost_usd:a.cost_usd??0,kind:"month_digest",ref:e})}else a=sD(e,i);n?(a.is_live=!0,(0,si.setCurrentMonthDigestInCache)(e,a,s())):((0,si.writeMonthDigest)(a),yield{type:"saved",path:`~/.cclens/digests/month/${e}.json`}),yield{type:"digest",digest:a}}finally{r&&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(),r=String(t.getMonth()+1).padStart(2,"0"),a=String(t.getDate()).padStart(2,"0");return`${n}-${r}-${a}`},"runWeekDigestPipeline",0,sG],77242),e.s(["runMonthDigestPipeline",0,sX],21628),e.s([],82111)}];
|
|
378
378
|
|
|
379
379
|
//# sourceMappingURL=packages_entries_dist_node_0bckr7-.js.map
|