principles-disciple 1.219.1 → 1.220.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle.js CHANGED
@@ -988,7 +988,7 @@ CONSTRAINTS:
988
988
  contains no evidence at all.
989
989
  ${c}${u}`}var m5=class{adapter;schema;constructor(t={}){this.adapter=t.adapter??new $p,this.schema=t.schema??Pl}buildRootCauseInstruction(t={}){return a8t({adapter:t.adapter??this.adapter,schema:t.schema??this.schema,outputLanguage:t.outputLanguage,coreGrounding:t.coreGrounding,intentGrounding:t.intentGrounding,evidenceFirstAttribution:t.evidenceFirstAttribution})}buildPrompt(t,r={}){let n=r.limits??zMe,{outputLanguage:o,coreGrounding:i,intentGrounding:a,intentDoc:s,evidenceFirstAttribution:c}=r,u=[],l=t.conversationWindow,d=l.slice(0,n.maxConversationEntries);l.length>n.maxConversationEntries&&u.push(`conversationWindow truncated from ${l.length} to ${n.maxConversationEntries} entries`);let p=d.map(S=>S.text&&S.text.length>n.maxEntryTextChars?{...S,text:S.text.slice(0,n.maxEntryTextChars)+"...[truncated]"}:S),m={...t,conversationWindow:p},f=this.buildRootCauseInstruction({outputLanguage:o,coreGrounding:i,intentGrounding:a,evidenceFirstAttribution:c}),g={taskId:t.taskId,contextHash:t.contextHash,diagnosisTarget:t.diagnosisTarget,conversationWindow:p,sourceRefs:t.sourceRefs,context:m,diagnosticInstruction:f,...u.length>0?{truncationWarnings:u}:{},...a&&s?{intentDoc:s}:{}},y=JSON.stringify(g);if(y.length>n.maxMessageChars){let S=y.length-n.maxMessageChars,x=f,w=Math.max(200,x.length-S-100),D=x.slice(0,w)+`
990
990
 
991
- [OUTPUT FORMAT section is REQUIRED; other sections may be summarized if needed]`;g.diagnosticInstruction=D,g.truncationWarnings=[...u,`diagnosticInstruction truncated due to size (${y.length} > ${n.maxMessageChars})`],y=JSON.stringify(g)}return{message:y,promptInput:g}}};oc();var Og=["core","quiet","gone","legacy_retire"],NR=["openclaw","pi-ai"],Xc=["diagnostician","dreamer","philosopher","scribe","artificer","evaluator","rolloutReviewer","correctionObserver","empathyObserver","signalCollector"],hb=["simple","advanced"],f5=["low","medium","high"],h5=["realtime","async"],LR=["smoke","unit","full"],TN=["full","summary","off"],ts=new Set(["__proto__","constructor","prototype"]);var g5=[{id:"prompt",category:"core",enabled:!0,since:"2026-05-24",description:"Prompt injection for principle application"},{id:"code_tool_hook",category:"core",enabled:!0,since:"2026-05-24",description:"Code tool hook for rule host enforcement"},{id:"rulecode_safety_controls",category:"core",enabled:!0,since:"2026-08-21",description:"Durable RuleCode safety isolation authority. Default ON; emergency enforcement shutdown remains the code_tool_hook core flag."},{id:"rulecode_owner_live_decision",category:"core",enabled:!0,since:"2026-08-21",description:"Owner-reviewed RuleCode shadow-to-live decision authority. Default ON after the readiness, authenticated Console, CLI, audit, and rollback rollout gates passed; flag-off refuses promotion."},{id:"defer_archive",category:"core",enabled:!0,since:"2026-05-24",description:"Defer/archive activation writer"},{id:"correction_observer",category:"quiet",enabled:!1,since:"2026-06-02",description:"Optional LLM optimization service for correction keywords; synchronous correction detection remains active independently"},{id:"signal_collector",category:"quiet",enabled:!1,since:"2026-06-30",description:"Unified signal collection host (correction + empathy upstream merge). NOTE: keyword detection (high-precision phrases) runs regardless of this flag; this flag only gates the LLM deep-judgment path (ambiguous terms / missed keywords). Quiet flag: dogfood-only until validated."},{id:"internalization_auto_consumer",category:"quiet",enabled:!0,since:"2026-06-13",description:"Bounded auto-consumer for dreamer internalization tasks \u2014 prevents ready tasks from pending forever (PRI-381; quiet flag, default on, disableable via config)"},{id:"internalization_full_chain",category:"core",enabled:!0,since:"2026-08-12",description:"PRI-419 amendment: auto-consumer advances dreamer\u2192\u2026\u2192evaluator\u2192rollout_reviewer (full chain) so artifacts reach validated and the approval queue is populated unattended. The human gate is the approval queue (Console), not the rollout_reviewer CLI trigger. Default ON; flag-off = dreamer-only."},{id:"story_a_approval_completion",category:"quiet",enabled:!0,since:"2026-06-18",description:"Story A approval-completion orchestrator (PRI-408) \u2014 formal service replacing demo direct-writer activation; quiet flag, default on, disableable via config"},{id:"feedback_channel",category:"quiet",enabled:!0,since:"2026-06-01",description:"MVP seed feedback channel \u2014 privacy-preserving report drafts. PRI-543: flag scope extended to also cover the feedback SUBMIT ladder (ingest relay / gh CLI / mailto / export-file channels + submit endpoints). Flag-off = submit endpoints 403 + submit UI hidden; config `feedback:` segment and channel parameters still available."},{id:"gfi",category:"quiet",enabled:!1,since:"2026-05-24",description:"Global Friction Index session scoring"},{id:"evolution_worker",category:"quiet",enabled:!1,since:"2026-06-01",description:"Legacy evolution worker heartbeat (MVP-Quiet per ADR-0014 \xA72.5)"},{id:"empathy_observer",category:"quiet",enabled:!1,since:"2026-06-02",description:"Empathy observer service for sentiment checking (MVP-Quiet)"},{id:"painEvidenceAdmission",category:"quiet",enabled:!0,since:"2026-06-06",description:"Pre-diagnosis evidence triage for pain signals (PEAT-B1). PRI-454: default-on, Gate B is primary gate."},{id:"pain_evidence_admission",category:"quiet",enabled:!0,since:"2026-06-15",description:"Snake-case alias for painEvidenceAdmission \u2014 same functionality, matches config.yaml key convention. PRI-454: default-on."},{id:"painEvidenceAdmissionDefault",category:"quiet",enabled:!0,since:"2026-06-24",description:"PRI-454: Global kill switch for Gate B migration. When ON (default), Gate B (TriggerController) owns admission. When OFF (rollback), Gate A (PainDiagnosticGate) is re-activated."},{id:"pain_evidence_admission_default",category:"quiet",enabled:!0,since:"2026-06-24",description:"PRI-454: Snake-case alias for painEvidenceAdmissionDefault \u2014 global kill switch, matches config.yaml key convention"},{id:"diagnostician_async_cli",category:"quiet",enabled:!1,since:"2026-06-11",description:"Async pain-record CLI \u2014 submit and return immediately, diagnosis runs in background. Default: false until orchestrator exists."},{id:"diagnostician_core_grounding",category:"quiet",enabled:!0,since:"2026-06-11",description:"Core principle grounding in diagnostician prompt (Arm 2)"},{id:"internalization_core_grounding",category:"quiet",enabled:!0,since:"2026-06-16",description:"Core principle grounding in internalization prompt builders (dreamer, philosopher, scribe)"},{id:"diagnostician_split_pipeline",category:"quiet",enabled:!0,since:"2026-06-11",description:"3-stage split diagnostician pipeline (RootCause\u2192Distiller\u2192Router)"},{id:"diagnostician_llm_degradation",category:"quiet",enabled:!1,since:"2026-07-03",description:"Diagnostician LLM rate-limit graceful degradation \u2014 on persistent rate-limit, emit diag_llm_rate_limit_degraded telemetry + rate_limit errorCategory instead of max_attempts_exceeded (ADR-0019). Default off; flag-off = hard fail (legacy behavior)."},{id:"l2_dreamer",category:"quiet",enabled:!1,since:"2026-06-16",description:"L2 multi-turn agent loop for the dreamer runner (PRI-419) \u2014 read-only tools + submit_output, scoped to dreamer only"},{id:"code_rule_capability",category:"core",enabled:!0,since:"2026-06-18",description:"Code-rule capability (atomic: ArtificerL2 + Evaluator) for RuleHost pipeline \u2014 MVP-Core, default ON (PRI-435)"},{id:"intent_engineering",category:"quiet",enabled:!1,since:"2026-06-25",description:"INTENT.md-grounded constructive friction and Stage-A intent tension diagnosis (PRI-465). Default off; flag-off = no INTENT read, no prompt injection, no intentTension."},{id:"rulecode_context_v2",category:"quiet",enabled:!1,since:"2026-06-27",description:"RuleContext v2 \u2014 rule-code context vision (PRI-479). Foundation flag; default off, v1 rule behavior unchanged. See docs/superpowers/specs/2026-06-27-rulecode-context-vision-design.md"},{id:"failed_tasks_observability",category:"quiet",enabled:!0,since:"2026-07-04",description:"Failed tasks observability \u2014 list/view failed pipeline tasks"},{id:"evaluator_artificer_repair_loop",category:"quiet",enabled:!0,since:"2026-07-04",description:"PRI-509/P0-D: Evaluator\u2192Artificer repair loop \u2014 auto-seed artificer repair on needs_revision (2-round cap \u2192 needs_human_review). Default ON (INV-02 liveness); production-wired in auto-consumer since 2026-08-18."},{id:"artificer_output_retry",category:"quiet",enabled:!1,since:"2026-08-20",description:"Issue 2: retry Artificer `output_invalid` (malformed LLM output, e.g. missed submit_rulecode) via the base retry policy (max 3 attempts) instead of permanent failure. Default off; flag-off = output_invalid permanent (legacy)."},{id:"artifact_summary_redundancy",category:"quiet",enabled:!1,since:"2026-07-26",description:"Internalization progressive disclosure Layer 0 \u2014 writer-side ArtifactSummary + predecessorSummary envelope on all 8 SummaryRunnerKind stages. Default off; flag-off = current contentJson shape unchanged."},{id:"context_manifest_budget",category:"quiet",enabled:!1,since:"2026-07-26",description:"Internalization progressive disclosure Layer 1 \u2014 manifest + budget-driven context injection with information-floor fallback. Default off; flag-off = existing buildContext assembly unchanged."},{id:"progressive_evaluator",category:"quiet",enabled:!1,since:"2026-07-26",description:"Internalization progressive disclosure Layer 2 \u2014 two-stage evaluation with flagged criteria + painCoverage/compressionFidelity output fields. Default off; flag-off = single-stage evaluation unchanged."},{id:"host.codex",category:"core",enabled:!0,since:"2026-08-11",description:"ADR-0020: Codex CLI host adapter. Default ON (flipped 2026-08-12 after PRI-282 E2E). Flag-off = pd-hook.js outputs {} + exit 0 + SystemLogger records skip (rc-9). Disable via .pd/config.yaml: host.codex: { enabled: false }."},{id:"abstraction_layer_v1",category:"quiet",enabled:!1,since:"2026-08-13",description:"PRI-523 shared host-runtime cutover for OpenClaw. Default OFF preserves the legacy route; enable only for controlled parity validation."},{id:"principle_receipt_block_copy",category:"quiet",enabled:!1,since:"2026-08-15",description:"Principle Receipt P0 \u2014 enriched RuleHost block copy with principle attribution (title/approval date/source summary, PRI-530). Default off; flag-off = generic block template unchanged."},{id:"principle_receipt_ledger",category:"quiet",enabled:!1,since:"2026-08-15",description:"Principle Receipt ledger \u2014 durable principle_applications history (effect/presence two-level semantics, PRI-531). Default off; flag-off = no ledger writes."},{id:"principle_receipt_self_report",category:"quiet",enabled:!1,since:"2026-08-16",description:"Principle Receipt P1-a \u2014 agent self-report \u{1F4CC} line (injection instruction + capture, PRI-532). Default off; flag-off = directive template unchanged, no capture."},{id:"principle_governance_projection_v2",category:"quiet",enabled:!1,since:"2026-08-20",description:"Read-only per-principle Owner governance projection (PRI-549). Default off; flag-off preserves the existing Principle Detail experience."},{id:"failed_task_recovery_console",category:"quiet",enabled:!0,since:"2026-08-23",description:"Governance Recovery Actions v1 \u2014 Owner-triggered recovery of failed / needs_human_review tasks from Console (failed\u2192pending via RecoverySweepService; needs_human_review\u2192pending via owner authority reset). Default on (2026-08-24 owner decision); flag-off = Console read-only."},{id:"pain_diagnosis_persistence",category:"quiet",enabled:!1,since:"2026-08-23",description:"Persist diagnostician root-cause attribution to pain_diagnoses (state.db, keyed by canonical pain_id) + Evidence First attribution rules in the Stage A prompt. Default off; flag-off = no writes, prompt byte-identical."},{id:"nocturnal",category:"gone",enabled:!1,since:"2026-05-24",description:"Nocturnal trinity pipeline (retired)"},{id:"idle_trigger",category:"gone",enabled:!1,since:"2026-05-24",description:"Idle trigger for background processing (retired)"},{id:"new_user_onboarding",category:"core",enabled:!0,since:"2026-07-01",description:"New user onboarding wizard \u2014 first-visit redirect to /welcome + demo story-a trigger endpoint. Maintainer-approved MVP-Core (2026-07-01): default-on; emergency disable via .pd/config.yaml: new_user_onboarding: { enabled: false }."}];var My={};for(let e of g5)My[e.id]={category:e.category,enabled:e.enabled};var s8t="pd.default",c8t={type:"pi-ai",provider:"",model:"",apiKeyEnv:""},WMe="openclaw.default",qMe={type:"openclaw",source:"default"},Ly=WMe,_5=qMe,u8t={diagnostician:!0,dreamer:!0,philosopher:!1,scribe:!0,artificer:!0,evaluator:!1,rolloutReviewer:!1,correctionObserver:!1,empathyObserver:!1,signalCollector:!1};function EN(){let e={};for(let t of Xc)e[t]={enabled:u8t[t],runtimeProfile:Ly};return{defaultRuntime:Ly,agents:e}}var RN={diagnostics:{mode:"simple"}},$u={thinkingOs:!1,projectFocus:"off",evolutionContext:{enabled:!0,maxMessages:4,maxCharsPerMessage:200}};function y5(){return{version:1,features:{...My},runtimeProfiles:{[s8t]:{...c8t},[WMe]:{...qMe}},internalAgents:EN(),ui:{...RN},principles:{outputLanguage:void 0},contextInjection:void 0}}var Tte=["prompt","code_tool_hook","defer_archive"];function li(e){let{config:t}=e,r=[],n={};for(let[i,a]of Object.entries(My))n[i]={id:i,category:a.category,enabled:a.enabled};for(let[i,a]of Object.entries(t.features))if(!ts.has(i)&&a)if(Object.hasOwn(n,i)){let s=n[i];if(!s)continue;if(s.category==="gone"&&a.enabled){r.push(`feature '${i}': gone flag cannot be re-enabled`);continue}if(s.category==="core"&&!a.enabled){r.push(`feature '${i}': core flag explicitly disabled via config (emergency disable)`),n[i]={id:i,category:s.category,enabled:!1};continue}n[i]={id:i,category:a.category,enabled:a.enabled}}else{if(!Og.includes(a.category)){r.push(`feature '${i}': invalid category '${a.category}', ignored`);continue}n[i]={id:i,category:a.category,enabled:a.enabled},r.push(`feature '${i}': unknown flag accepted`)}let o=[];for(let i of Tte){let a=n[i];a&&a.enabled&&o.push(i)}return{flags:n,enabledChannels:o,warnings:r}}function Sa(e,t){return Object.hasOwn(e.flags,t)?e.flags[t]?.enabled??!1:!1}var S5="<redacted-path>",zf="[REDACTED]";var l8t=/(?:[A-Za-z]:[\\/](?:[^\\\s/:*?"<>|]+[\\/])+[^\\\s/:*?"<>|]*)/g,p8t=/(?<![a-zA-Z0-9_.])[\\/](?:usr|home|Users|var|opt|etc|tmp|root|run|mnt|media|srv|boot|dev|proc|sys)(?:[\\/][^\\\s/:*?"<>|]+)+/g;function Wf(e){return typeof e!="string"?e:e.replace(l8t,S5).replace(p8t,S5)}var d8t=/\bsk-(?:ant-)?[A-Za-z0-9_-]{16,}\b/g,m8t=/\bgh[pousr]_[A-Za-z0-9_]{16,}\b/g,f8t=/\blin_api_[A-Za-z0-9_-]{16,}\b/g,h8t=/(Authorization\s*:\s*)(["'])?([A-Za-z]+\s+)?([^\s"';,]+)/gi,g8t=/(\$env:\s*[A-Z_][A-Z0-9_]{2,}\s*=\s*")([^"]*)(")/gi,_8t=/\b(api[_-]?key|token|secret|password|auth(?:_?token)?)\s*[:=]\s*['"]?([^\s'",}{]+)['"]?/gi,y8t=/\bBearer\s+[A-Za-z0-9._\-+/=]{8,}\b/g;function qf(e){return typeof e!="string"?e:e.replace(d8t,zf).replace(m8t,zf).replace(f8t,zf).replace(h8t,"$1$2$3[REDACTED]").replace(g8t,"$1[REDACTED]$3").replace(y8t,zf).replace(_8t,(t,r)=>`${r}=${zf}`)}var S8t=/\b([A-Z_][A-Z0-9_]{2,})\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s,;}{]+))/g;function jf(e){return typeof e!="string"?e:e.replace(S8t,(t,r)=>`${r}=${zf}`)}function Pg(e){if(typeof e!="string")return e;let t=Wf(e);return t=qf(t),t=jf(t),t}var x8t=new Set(["password","passwd","secret","token","api","apikey","authorization","auth","credential","credentials","private","key"]);function b8t(e){return e.toLowerCase().split(/[_\-.]/g).filter(t=>t.length>0)}function jMe(e){let t=b8t(e);if(t.length===0)return!1;for(let r of t)if(x8t.has(r))return!0;return!1}var v8t=6,GMe=100,Ete=2e3;function x5(e,t){if(e===null)return{ok:!0,value:null,notes:[]};if(e===void 0)return{ok:!0,value:void 0,notes:[]};let r=typeof e;if(r==="string"){let o=e,i=o;return o=Wf(o),o=qf(o),o=jf(o),o!==i&&t.notes.push("string value redacted (path/token/env)"),o.length>Ete&&(o=o.slice(0,Ete)+"\u2026",t.notes.push(`string truncated to ${Ete} chars`)),{ok:!0,value:o,notes:t.notes}}if(r==="bigint")return{ok:!0,value:`<bigint:${e.toString()}>`,notes:[]};if(r!=="object")return{ok:!0,value:e,notes:[]};if(t.depth>=v8t)return{ok:!0,value:"<deep>",notes:[]};let n=e;if(t.seen.has(n))return t.notes.push("circular reference detected"),{ok:!0,value:"<circular>",notes:[]};t.seen.add(n);try{if(Array.isArray(e)){let s=[];for(let c=0;c<e.length;c++){let u=x5(e[c],{seen:t.seen,depth:t.depth+1,notes:t.notes});if(!u.ok)return u;s.push(u.value)}return{ok:!0,value:s,notes:[]}}let o=e,i={},a=Object.keys(o).slice(0,GMe);for(let s of a){if(jMe(s)){i[s]=zf,t.notes.push(`field "${s}" redacted`);continue}let c=o[s];if(c!==null&&typeof c=="object"&&t.seen.has(c)){t.notes.push(`circular reference detected at "${s}"`),i[s]="<circular>";continue}let u=x5(c,{seen:t.seen,depth:t.depth+1,notes:t.notes});if(!u.ok)return u;i[s]=u.value}return{ok:!0,value:i,notes:[]}}finally{t.seen.delete(n)}}function T8t(e){let t=[],r=[],n={seen:new WeakSet,depth:0,notes:t};n.seen.add(e);for(let o=0;o<e.length;o++){let i=e[o];if(i!==null&&typeof i=="object"&&n.seen.has(i)){t.push("circular reference detected in array"),r.push("<circular>");continue}let a=x5(i,n);if(!a.ok)return a;r.push(a.value)}return{ok:!0,value:r,notes:t}}function E8t(e){let t=e,r=[],n={seen:new WeakSet,depth:0,notes:r};n.seen.add(e);let o={},i=Object.keys(t).slice(0,GMe);for(let a of i){if(jMe(a)){o[a]=zf,r.push(`field "${a}" redacted`);continue}let s=t[a];if(s!==null&&typeof s=="object"&&n.seen.has(s)){r.push(`circular reference detected at "${a}"`),o[a]="<circular>";continue}let c=x5(s,n);if(!c.ok)return c;o[a]=c.value}return{ok:!0,value:o,notes:r}}function wN(e){if(e===null)return{ok:!1,error:"redactSensitiveFields: null is not a redactable object",nextAction:"pass a JSON object or array; null carries no fields to redact"};if(e===void 0)return{ok:!1,error:"redactSensitiveFields: undefined is not a redactable object",nextAction:"pass a JSON object or array; undefined carries no fields to redact"};let t=typeof e;return t!=="object"?{ok:!1,error:`redactSensitiveFields: top-level value must be an object or array (got ${t})`,nextAction:"pass a JSON object or array; for primitive values use redactTokenLikeValues / redactEnvLikeValues / redactAbsolutePaths"}:Array.isArray(e)?T8t(e):E8t(e)}var BMe="\u2026[canonical-json-truncated]";function IN(e,t=new WeakSet){if(e===null)return"null";let r=typeof e;if(r==="string")return JSON.stringify(e);if(r==="number")return Number.isFinite(e)?String(e):"null";if(r==="boolean")return String(e);if(r==="bigint")return JSON.stringify(`${String(e)}n`);if(r==="undefined"||r==="function"||r==="symbol")return"null";if(Array.isArray(e)){if(t.has(e))return'"[Circular]"';t.add(e);let n=e.map(o=>IN(o,t));return t.delete(e),`[${n.join(",")}]`}if(e instanceof Date)return JSON.stringify(Number.isNaN(e.getTime())?null:e.toISOString());if(e instanceof Map){if(t.has(e))return'"[Circular]"';t.add(e);let o=[...e.entries()].map(([i,a])=>[String(i),a]).sort(([i],[a])=>i<a?-1:i>a?1:0).map(([i,a])=>`${JSON.stringify(i)}:${IN(a,t)}`).join(",");return t.delete(e),`{${o}}`}if(e instanceof Set){if(t.has(e))return'"[Circular]"';t.add(e);let n=[...e.values()].map(o=>IN(o,t));return t.delete(e),`[${n.join(",")}]`}if(r==="object"){let n=e;if(t.has(n))return'"[Circular]"';t.add(n);let o=Object.keys(n).sort((a,s)=>a<s?-1:a>s?1:0),i=[];for(let a of o){let s=IN(n[a],t),c=n[a],u=typeof c;c===void 0||u==="function"||u==="symbol"||i.push(`${JSON.stringify(a)}:${s}`)}return t.delete(n),`{${i.join(",")}}`}return'"[Unserializable]"'}function R8t(e){let t=IN(e);if(t.length<=262144)return{text:t,truncated:!1};let r=262144-BMe.length;return{text:`${t.slice(0,Math.max(0,r))}${BMe}`,truncated:!0}}function Rte(e,t){return t(R8t(e).text)}var T5=["diag_rootcause","diag_distiller","diag_router","dreamer","philosopher","scribe","artificer","evaluator"],E5=1,wte=200,w8t=600;function gb(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function I8t(e){return T5.includes(e)}function qa(e,t){if(!gb(e)||!Object.hasOwn(e,t))return null;let r=e[t];return typeof r!="string"||r.trim()===""?null:r}function kN(e,t){if(!gb(e)||!Object.hasOwn(e,t))return null;let r=e[t];return gb(r)?r:null}function MR(e,t){if(!gb(e)||!Object.hasOwn(e,t))return null;let r=e[t];return Array.isArray(r)?r:null}function b5(e,t){let r=MR(e,t);if(r===null)return null;let n=r.filter(o=>typeof o=="string"&&o.trim()!=="");return n.length===0?null:n.join(" / ")}function k8t(e,t){if(!gb(e)||!Object.hasOwn(e,t))return null;let r=e[t];return typeof r=="number"&&Number.isFinite(r)?String(r):null}function A8t(e,t){if(!gb(e)||!Object.hasOwn(e,t))return null;let r=e[t];return typeof r=="boolean"?String(r):null}function v5(e,t){return e.length<=t?e:`${e.slice(0,t-1)}\u2026`}function AN(e){let r=/^[\s\S]*?[。;;.]/.exec(e)?.[0]??e;return v5(r.trim(),wte)}function Ite(e){let t=e.filter(r=>r!==null&&r.trim()!=="");return t.length===0?null:v5(t.join("; "),wte)}function C8t(e){let t=qa(e,"rootCause");return{headlineSource:t===null?null:AN(t),resolved:{rootSymptom:qa(e,"summary"),category:qa(e,"rootCauseCategory"),severity:null,rootCause:t}}}function O8t(e){let t=qa(e,"abstractedPrinciple");return{headlineSource:t===null?null:AN(t),resolved:{rootCause:qa(e,"rationale"),affectedComponents:null,category:qa(e,"scope"),severity:null}}}function P8t(e){let t=qa(e,"summary"),n=(MR(e,"violatedPrinciples")??[]).map(a=>qa(a,"principleId")).filter(a=>a!==null),o=MR(e,"recommendations")??[],i=o.length>0?qa(o[0],"kind"):null;return{headlineSource:Ite([t,i]),resolved:{rootCause:qa(e,"rootCause"),affectedComponents:n.length>0?n.join(" / "):null,rootSymptom:t,category:i,severity:null}}}function N8t(e){let t=MR(e,"candidates")??[],r=t.length>0?t[0]:null,n=qa(r,"betterDecision");return{headlineSource:n===null?null:AN(n),resolved:{badDecision:qa(r,"badDecision"),betterDecision:n,rationale:qa(r,"rationale"),riskLevel:qa(r,"riskLevel"),strategicPerspective:qa(r,"strategicPerspective")}}}function L8t(e){let t=kN(e,"principleCandidate"),r=qa(t,"title");return{headlineSource:r,resolved:{thesis:qa(e,"thesis"),principleTitle:r,principleScope:qa(t,"scope"),principleConfidence:k8t(t,"confidence")}}}function M8t(e){let t=kN(e,"principleDraft"),r=qa(t,"statement");return{headlineSource:r===null?null:AN(r),resolved:{principleText:r,scope:b5(t,"applicability"),exceptions:b5(t,"antiPatterns")}}}function D8t(e){let t=b5(e,"affectedTools"),r=qa(e,"implementationSummary"),n=MR(e,"affectedTools")?.length??null;return{headlineSource:Ite([n!==null?`${n} affected tools`:null,r===null?null:AN(r)]),resolved:{changedFiles:t,apiSurface:r,risks:b5(e,"risks")}}}function U8t(e){let t=kN(e,"evaluation"),r=qa(t,"decision"),n=MR(t,"concerns"),o=n===null?null:String(n.length),i=kN(e,"codeReview"),a=kN(i,"intentConsistency");return{headlineSource:Ite([r===null?null:`verdict=${r}`,o===null?null:`concerns=${o}`]),resolved:{verdict:r,concernCount:o,intentConsistency:A8t(a,"aligned")}}}var $8t={diag_rootcause:C8t,diag_distiller:O8t,diag_router:P8t,dreamer:N8t,philosopher:L8t,scribe:M8t,artificer:D8t,evaluator:U8t};function kte(e,t){if(!I8t(e))return{ok:!1,reason:"unsupported_runner_kind",detail:`Unsupported SummaryRunnerKind: ${String(e)}`};if(!gb(t))return{ok:!1,reason:"output_not_object",detail:`validatedOutput for runnerKind "${e}" is not a non-null object`};let r=$8t[e],{headlineSource:n,resolved:o}=r(t),i={},a=[];for(let[s,c]of Object.entries(o))c!==null?i[s]=v5(c,w8t):a.push(s);return n===null&&Object.keys(i).length===0?{ok:!1,reason:"no_derivable_field",detail:`No derivable headline or field for runnerKind "${e}" from the given output`}:{ok:!0,value:{schemaVersion:E5,runnerKind:e,headline:n===null?"":v5(n,wte),fields:i,derivedFrom:"structured_output",omittedFields:a}}}function F8t(e){if(e===null||typeof e!="object"||Array.isArray(e)||!Object.hasOwn(e,"summary"))return null;let{summary:t}=e;if(t===null||typeof t!="object"||Array.isArray(t))return null;let r=t;if(!Object.hasOwn(r,"schemaVersion")||r.schemaVersion!==E5||!Object.hasOwn(r,"runnerKind")||typeof r.runnerKind!="string"||!T5.includes(r.runnerKind)||!Object.hasOwn(r,"headline")||typeof r.headline!="string"||!Object.hasOwn(r,"fields")||r.fields===null||typeof r.fields!="object"||Array.isArray(r.fields))return null;let n=r.fields;return!Object.values(n).every(o=>typeof o=="string")||!Object.hasOwn(r,"derivedFrom")||r.derivedFrom!=="structured_output"||!Object.hasOwn(r,"omittedFields")||!Array.isArray(r.omittedFields)||!r.omittedFields.every(o=>typeof o=="string")?null:{schemaVersion:E5,runnerKind:r.runnerKind,headline:r.headline,fields:n,derivedFrom:"structured_output",omittedFields:r.omittedFields}}function VMe(e,t,r,n,o){let i=kte(e,t);if(!i.ok)return o({type:"artifact_summary_skipped",runnerKind:e,reason:i.reason}),{};let a={summary:i.value};if(r===null)return o({type:"artifact_summary_predecessor_absent",runnerKind:e,reason:"no_predecessor_in_context"}),a;let s=F8t(r.contentJson);if(s===null){let c=kte(r.runnerKind,r.contentJson);if(!c.ok)return o({type:"artifact_summary_predecessor_skipped",runnerKind:e,reason:c.reason}),a;s=c.value}return{...a,predecessorSummary:{artifactId:r.artifactId,runnerKind:r.runnerKind,contentHash:Rte(r.contentJson,n),summary:s}}}var CN={betterDecision:"required",rationale:"required",riskLevel:"required",badDecision:"optional",strategicPerspective:"excluded"},wYn=Object.entries(CN).filter(([,e])=>e==="required").map(([e])=>e),KMe=["badDecision","betterDecision","rationale","riskLevel","strategicPerspective"];function z8t(e){if(Object.hasOwn(CN,e))return CN[e]}function HMe(e){return z8t(e)==="required"}var ON=1;function JMe(e){let t=new Set,r=[];for(let n of e)t.has(n)||(t.add(n),r.push(n));return r}var AYn=KMe.filter(e=>CN[e]!=="excluded");function XMe(e,t){let r=t.priority.indexOf(e);if(r>=0)return r;let n=JMe([...t.tier0,...t.tier1,...t.tier2]).indexOf(e),o=n>=0?n:0;return t.priority.length+o}function DR(e){return JMe([...e.tier0,...e.tier1,...e.tier2])}function W8t(e){return Math.ceil(e.length/4)}var q8t=600,j8t=8,YMe="\u2026[budget-truncated]";function QMe(e,t,r){let n=DR(e),o=[],i=[];for(let u of n){if(!t.has(u)){i.push(u);continue}let l=da(t.get(u),q8t);o.push({path:u,text:l,tokens:W8t(l),rank:XMe(u,e)})}o.sort((u,l)=>u.rank-l.rank||(u.path<l.path?-1:u.path>l.path?1:0));let a={},s=[],c=e.budgetTokens;for(let u of o)if(u.tokens<=c)a[u.path]=u.text,c-=u.tokens;else if(c>j8t){let l=Math.max(0,c*4-YMe.length),d=u.text.slice(0,l)+YMe;a[u.path]=d;let p={fieldPath:u.path,reason:"partially_truncated",remainingBudgetTokens:c,keptChars:d.length,droppedChars:u.text.length-d.length};s.push(p),r({type:"context_truncated",runnerKind:e.runnerKind,manifestId:e.manifestId,fieldPath:u.path,reason:p.reason,remainingBudgetTokens:c}),c=0}else{let l={fieldPath:u.path,reason:"budget_exceeded",remainingBudgetTokens:c,keptChars:0,droppedChars:u.text.length};s.push(l),r({type:"context_truncated",runnerKind:e.runnerKind,manifestId:e.manifestId,fieldPath:u.path,reason:l.reason,remainingBudgetTokens:c})}return{manifestId:e.manifestId,fields:a,truncated:s,absent:i,usedTokens:e.budgetTokens-c,budgetTokens:e.budgetTokens}}var G8t=.5;function ZMe(e,t,r){let n=QMe(e,t,l=>r(l)),i=DR(e).length,a=n.absent.length,s=i>0?a/i:1,c=()=>({type:"manifest_resolution_insufficient",runnerKind:e.runnerKind,manifestId:e.manifestId,absentCount:a,declaredCount:i,absentRatio:s,fallback:"full_predecessor_injection"});return Object.keys(n.fields).length===0?(r(c()),{kind:"fallback",allocated:n,fellBack:!0,reason:"empty_allocation",absentRatio:s}):e.tier1.length>0&&e.tier1.every(l=>n.absent.includes(l))?(r(c()),{kind:"fallback",allocated:n,fellBack:!0,reason:"tier1_all_absent",absentRatio:s}):s>G8t?(r(c()),{kind:"fallback",allocated:n,fellBack:!0,reason:"absent_ratio_exceeded",absentRatio:s}):{kind:"focused",allocated:n,fellBack:!1}}function PN(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function e1e(e,t){if(!PN(e)||!Object.hasOwn(e,"summary"))return;let{summary:r}=e;if(!PN(r))return;if(t==="headline")return Object.hasOwn(r,"headline")?r.headline:void 0;let n=Object.hasOwn(r,"fields")?r.fields:void 0;if(PN(n)&&Object.hasOwn(n,t))return n[t];if(Object.hasOwn(r,t))return r[t]}function B8t(e,t){if(!PN(e)||!Object.hasOwn(e,"predecessorSummary"))return;let{predecessorSummary:r}=e;if(!(!PN(r)||!Object.hasOwn(r,"summary")))return e1e(r,t)}function V8t(e,t){let r=e.indexOf("summary."),n=e.indexOf("predecessorSummary."),o=e.indexOf("raw.");if(!(o>=0&&(r<0||o<r)&&(n<0||o<n))){if(n>=0&&(r<0||n<r)){let i=e.slice(n+19);return B8t(t,i)}if(r>=0){let i=e.slice(r+8);return e1e(t,i)}}}function t1e(e,t){let r=new Map;for(let n of e){let o=V8t(n,t);o!==void 0&&r.set(n,o)}return r}var Ate={pollIntervalMs:5e3,timeoutMs:3e5,defaultMaxAttempts:3,agentId:"peer-runner",coreGrounding:!0};function K8t(e,t){return{pollIntervalMs:e.pollIntervalMs??Ate.pollIntervalMs,timeoutMs:e.timeoutMs??Ate.timeoutMs,defaultMaxAttempts:e.defaultMaxAttempts??Ate.defaultMaxAttempts,owner:e.owner,runtimeKind:e.runtimeKind,agentId:e.agentId??t,outputLanguage:e.outputLanguage,coreGrounding:e.coreGrounding??!0}}function H8t(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function J8t(e){if(typeof e!="string"||e.length===0)return null;let t;try{t=JSON.parse(e)}catch{return null}if(!H8t(t)||!Object.hasOwn(t,"sourcePainId"))return null;let{sourcePainId:r}=t;return typeof r!="string"||r.length===0?null:r}var pi=class{stateManager;runtimeAdapter;eventEmitter;artifactStore;resolvedOptions;config;pendingAgentDraftStore;contentHashFn;phase=co.Idle;constructor(t,r,n){this.stateManager=t.stateManager,this.runtimeAdapter=t.runtimeAdapter,this.eventEmitter=t.eventEmitter,this.artifactStore=t.artifactStore,this.pendingAgentDraftStore=t.pendingAgentDraftStore,this.contentHashFn=t.contentHashFn,this.config=n,this.resolvedOptions=K8t(r,n.defaultAgentId)}get currentPhase(){return this.phase}getRuntimeKind(){return typeof this.runtimeAdapter.kind=="function"?this.runtimeAdapter.kind():this.resolvedOptions.runtimeKind}async maybeResumePendingIntent(t,r){return null}emitSuccessTelemetry(t,r,n){}checkLineageIntegrity(t,r,n){}postFetchTransform(t,r,n){typeof r=="object"&&r!==null&&!Array.isArray(r)&&Reflect.set(r,"generatedAt",new Date().toISOString())}async run(t){this.phase=co.Idle;let r=this.getRuntimeKind(),n;try{n=await this.stateManager.acquireLease({taskId:t,owner:this.resolvedOptions.owner,runtimeKind:r})}catch(i){return await this.handleLeaseOrPhaseError(t,i)}if(n.taskKind!==this.config.expectedTaskKind)return this.emitEvent("wrong_task_kind",t,{expectedKind:this.config.expectedTaskKind,actualKind:n.taskKind}),await this.stateManager.markTaskFailed(t,"input_invalid"),{status:"failed",taskId:t,errorCategory:"input_invalid",failureReason:`Task kind must be '${this.config.expectedTaskKind}', got '${n.taskKind}'`,attemptCount:n.attemptCount};this.emitEvent("task_leased",t,{taskKind:this.config.expectedTaskKind,attemptCount:n.attemptCount});let o=await this.maybeResumePendingIntent(t,n);if(o)return this.phase=co.Completed,o;try{let i=await this.resolveStoreRunId(t);this.phase=co.BuildingContext;let a=await this.buildContext(t);this.emitEvent("context_built",t,{contextHash:a.contextHash}),this.phase=co.Invoking;let s=await this.invokeRuntime(t,a);this.emitEvent("run_started",t,{runtimeKind:r}),this.phase=co.Polling;let c=await this.pollUntilTerminal(s);if(c.status!=="succeeded")return await this.handleRuntimeFailure(t,n,c);this.phase=co.FetchingOutput;let u=await this.fetchAndParseOutput(s.runId,t);this.postFetchTransform(t,u,a),this.phase=co.Validating;let l=await this.validateOutput(u,t,a);if(!l.valid)return await this.handleValidationError({taskId:t,task:n,errors:l.errors,errorCategory:l.errorCategory});let d=u;this.emitEvent("output_validated",t,{}),this.checkLineageIntegrity(t,d,a),this.emitSuccessTelemetry(t,d,a);let p=await this.succeedTask(t,i,d,n,a.contextHash,a);return p.status==="succeeded"&&(this.phase=co.Completed),p}catch(i){return await this.handlePostLeaseError(t,n,i)}}emitEvent(t,r,n){this.eventEmitter.emitTelemetry({eventType:`${this.config.runnerName}_${t}`,traceId:r,timestamp:new Date().toISOString(),sessionId:this.resolvedOptions.owner,agentId:this.resolvedOptions.agentId,payload:n})}async pollUntilTerminal(t){let r=Date.now()+this.resolvedOptions.timeoutMs,n=["succeeded","failed","timed_out","cancelled"];for(;Date.now()<r;){let a=await this.runtimeAdapter.pollRun(t.runId);if(n.includes(a.status))return a;await this.sleep(this.resolvedOptions.pollIntervalMs)}try{let a=await this.runtimeAdapter.pollRun(t.runId);if(n.includes(a.status))return a}catch{}let o=!1;try{await this.runtimeAdapter.cancelRun(t.runId)}catch(a){o=!0,this.emitEvent("cancel_run_failed",t.runId,{runId:t.runId,errorMessage:a instanceof Error?a.message:String(a)})}let i=o?" (cancelRun also failed)":"";throw new Ie("timeout",`Run ${t.runId} timed out after ${this.resolvedOptions.timeoutMs}ms${i}`)}async fetchAndParseOutput(t,r){let n;try{n=await this.runtimeAdapter.fetchOutput(t)}catch(i){throw this.emitEvent("output_extraction_failed",r,{runId:t,stage:"fetchOutput",errorMessage:i instanceof Error?i.message:String(i)}),i}if(!n||!n.payload)throw this.emitEvent("output_extraction_failed",r,{runId:t,stage:"payload_missing",errorMessage:`No output available for run ${t}`}),new Ie("output_invalid",`No output available for run ${t}`);let{payload:o}=n;if(typeof o!="object"||o===null)throw this.emitEvent("output_extraction_failed",r,{runId:t,stage:"payload_not_object",errorMessage:`Output payload is not an object for run ${t}`}),new Ie("output_invalid",`Output payload is not an object for run ${t}`);return o}async resolveLineageArtifactIds(t){let{hydratePITaskRecord:r}=await Promise.resolve().then(()=>($s(),cMe)),n=await this.stateManager.getTask(t);if(!n)return{ids:[],hasRejected:!1};let i=r(n)?.dependencyTaskIds??[];if(i.length===0)return{ids:[],hasRejected:!1};let a=[],s=!1,c=await Promise.allSettled(i.map(u=>this.artifactStore.listBySourceTaskId(u)));for(let u of c)if(u.status==="fulfilled")for(let l of u.value)a.push(l.artifactId);else s=!0;return{ids:a,hasRejected:s}}async resolveStoreRunId(t){let{runs:r,degradedRuns:n}=await this.stateManager.getValidRunsByTaskTolerant(t);n.length>0&&this.eventEmitter.emitTelemetry({eventType:"degradation_triggered",traceId:t,timestamp:new Date().toISOString(),sessionId:this.resolvedOptions.owner,agentId:this.resolvedOptions.agentId,payload:{component:"BasePeerRunner",runnerName:this.config.runnerName,trigger:"malformed_historical_run_rows",degradedCount:n.length,runIds:n.map(i=>i.runId),errors:n.map(i=>i.error),nextAction:"Quarantine malformed run rows: pd runtime internalization integrity-repair --confirm"}});let o=r[r.length-1];if(!o)throw new Ie("execution_failed",`No valid run records found for task ${t} after lease acquisition. If historical runs are malformed, quarantine them first: pd runtime internalization integrity-repair --confirm`);return o.runId}static hashContextRefs(t){if(t.length===0)return"empty";let r=t.join("|"),n=0;for(let o=0;o<r.length;o++)n=Math.imul(31,n)+r.charCodeAt(o)|0;return`ctx-${Math.abs(n).toString(16)}`}async handleLeaseOrPhaseError(t,r){let n=this.classifyError(r);if(n.category==="lease_conflict")return this.emitEvent("run_failed",t,{errorCategory:"lease_conflict",errorMessage:n.message}),{status:"failed",taskId:t,errorCategory:"lease_conflict",failureReason:n.message,attemptCount:1};this.emitEvent("run_failed",t,{errorCategory:n.category,errorMessage:n.message});let o={taskId:t,taskKind:this.config.expectedTaskKind,status:"leased",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),attemptCount:1,maxAttempts:this.resolvedOptions.defaultMaxAttempts};return n.details&&Object.keys(n.details).length>0&&await this.persistOutputFailureDetails(t,void 0,{errorCategory:n.category,errorMessage:n.message,...n.details}),this.retryOrFail({taskId:t,task:o,errorCategory:n.category,failureReason:n.message})}async handlePostLeaseError(t,r,n){let o=this.classifyError(n);return this.emitEvent("run_failed",t,{errorCategory:o.category,errorMessage:o.message}),o.details&&Object.keys(o.details).length>0&&await this.persistOutputFailureDetails(t,r.diagnosticJson,{errorCategory:o.category,errorMessage:o.message,...o.details}),this.retryOrFail({taskId:t,task:r,errorCategory:o.category,failureReason:o.message})}async handleRuntimeFailure(t,r,n){let o=this.mapRunStatusToErrorCategory(n.status,n.reason);return this.emitEvent("run_failed",t,{runStatus:n.status,errorCategory:o}),this.retryOrFail({taskId:t,task:r,errorCategory:o,failureReason:n.reason?`Runtime execution ended with status: ${n.status}. Reason: ${n.reason}`:`Runtime execution ended with status: ${n.status}`})}async handleValidationError(t){let r=t.errorCategory??"output_invalid";return this.emitEvent("output_invalid",t.taskId,{errorCount:t.errors.length,errorCategory:r}),await this.persistOutputFailureDetails(t.taskId,t.task.diagnosticJson,{errorCategory:r,validatorErrors:[...t.errors],errorCount:t.errors.length}),this.retryOrFail({taskId:t.taskId,task:t.task,errorCategory:r,failureReason:`Validation failed: ${t.errors.join("; ")}`})}async retryOrFail(t){if(this.permanentErrorCategories.has(t.errorCategory)){try{await this.stateManager.markTaskFailed(t.taskId,t.errorCategory,t.failureReason)}catch(n){return this.emitEvent("mark_failed_error",t.taskId,{errorCategory:"storage_unavailable",attemptCount:t.task.attemptCount,errorMessage:n instanceof Error?n.message:String(n)}),{status:"failed",taskId:t.taskId,errorCategory:"storage_unavailable",failureReason:`State manager error: ${t.failureReason}`,attemptCount:t.task.attemptCount}}return this.emitEvent("task_failed",t.taskId,{errorCategory:t.errorCategory,attemptCount:t.task.attemptCount,failureReason:t.failureReason}),this.phase=co.Failed,this.injectAgentDraftOnPermanentFailure(t),{status:"failed",taskId:t.taskId,errorCategory:t.errorCategory,failureReason:t.failureReason,attemptCount:t.task.attemptCount}}if(t.errorCategory==="rate_limit"&&this.isDegradationEnabled()){try{await this.stateManager.markTaskFailed(t.taskId,"rate_limit",`LLM rate limit degraded: ${t.failureReason}`)}catch(n){return this.emitEvent("mark_failed_error",t.taskId,{errorCategory:"storage_unavailable",attemptCount:t.task.attemptCount,errorMessage:n instanceof Error?n.message:String(n)}),{status:"failed",taskId:t.taskId,errorCategory:"storage_unavailable",failureReason:`State manager error: ${t.failureReason}`,attemptCount:t.task.attemptCount}}return this.emitEvent("diag_llm_rate_limit_degraded",t.taskId,{errorCategory:"rate_limit",attemptCount:t.task.attemptCount,failureReason:t.failureReason,nextAction:"Retry diagnosis manually with `pd pain retry` when rate limit clears, or enable fallback provider."}),this.phase=co.Failed,{status:"failed",taskId:t.taskId,errorCategory:"rate_limit",failureReason:`LLM rate limit degraded: ${t.failureReason}`,attemptCount:t.task.attemptCount}}if(this.stateManager.getRetryPolicy().shouldRetry(t.task)){try{await this.stateManager.markTaskRetryWait(t.taskId,t.errorCategory,t.failureReason)}catch(n){return this.emitEvent("mark_retry_error",t.taskId,{errorCategory:"storage_unavailable",attemptCount:t.task.attemptCount,errorMessage:n instanceof Error?n.message:String(n)}),{status:"failed",taskId:t.taskId,errorCategory:"storage_unavailable",failureReason:`State manager error: ${t.failureReason}`,attemptCount:t.task.attemptCount}}return this.emitEvent("task_retried",t.taskId,{errorCategory:t.errorCategory,attemptCount:t.task.attemptCount}),this.phase=co.RetryWaiting,{status:"retried",taskId:t.taskId,errorCategory:t.errorCategory,failureReason:t.failureReason,attemptCount:t.task.attemptCount}}try{await this.stateManager.markTaskFailed(t.taskId,"max_attempts_exceeded",`Max attempts exceeded: ${t.failureReason}`)}catch(n){return this.emitEvent("mark_failed_error",t.taskId,{errorCategory:"storage_unavailable",attemptCount:t.task.attemptCount,errorMessage:n instanceof Error?n.message:String(n)}),{status:"failed",taskId:t.taskId,errorCategory:"storage_unavailable",failureReason:`State manager error: ${t.failureReason}`,attemptCount:t.task.attemptCount}}return this.emitEvent("task_failed",t.taskId,{errorCategory:"max_attempts_exceeded",attemptCount:t.task.attemptCount,failureReason:`Max attempts exceeded: ${t.failureReason}`}),this.phase=co.Failed,{status:"failed",taskId:t.taskId,errorCategory:"max_attempts_exceeded",failureReason:`Max attempts exceeded: ${t.failureReason}`,attemptCount:t.task.attemptCount}}classifyError(t){return t instanceof Ie?{category:t.category,message:t.message,details:t.details}:t instanceof Error?{category:"execution_failed",message:t.message}:{category:"execution_failed",message:String(t)}}async persistOutputFailureDetails(t,r,n){try{let o={};if(r){let i=JSON.parse(r);typeof i=="object"&&i!==null&&!Array.isArray(i)&&(o=i)}o.output_failure_details={recordedAt:new Date().toISOString(),...n},await this.stateManager.updateTask(t,{diagnosticJson:JSON.stringify(o)})}catch(o){this.emitEvent("mark_failed_error",t,{errorCategory:"storage_unavailable",errorMessage:`persistOutputFailureDetails failed: ${o instanceof Error?o.message:String(o)}`})}}mapRunStatusToErrorCategory(t,r){switch(t){case"failed":return"execution_failed";case"timed_out":return"timeout";case"cancelled":return"cancelled";default:return"execution_failed"}}sleep(t){return new Promise(r=>setTimeout(r,t))}isDegradationEnabled(){let{effectiveConfig:t}=this.config;if(!t)return!1;let r=li(t);return Sa(r,"diagnostician_llm_degradation")}isArtifactSummaryEnabled(){let{effectiveConfig:t}=this.config;if(!t)return!1;let r=li(t);return Sa(r,"artifact_summary_redundancy")}buildArtifactContentJson(t,r,n,o){if(!this.isArtifactSummaryEnabled())return JSON.stringify(n);try{let i=this.contentHashFn,a=i?o:null;!i&&o!==null&&this.emitEvent("artifact_summary_predecessor_skipped",t,{runnerKind:r,reason:"content_hash_fn_not_injected",nextAction:"Inject contentHashFn into PeerRunnerDeps (plugin/CLI layer) to enable predecessorSummary."});let s=VMe(r,n,a,i??(l=>l),l=>{this.emitEvent(l.type,t,{runnerKind:l.runnerKind,reason:l.reason})});if(s.summary===void 0||n===null||typeof n!="object"||Array.isArray(n))return JSON.stringify(n);let c=n,u=Object.hasOwn(c,"summary");return u&&this.emitEvent("artifact_summary_skipped",t,{runnerKind:r,reason:"output_summary_key_collision",nextAction:"Runner output already declares a top-level `summary` field; the Layer 0 envelope summary key is skipped to avoid overwriting it. predecessorSummary is still attached."}),JSON.stringify({...c,...u?{}:{summary:s.summary},...s.predecessorSummary!==void 0?{predecessorSummary:s.predecessorSummary}:{}})}catch(i){return this.emitEvent("artifact_summary_skipped",t,{runnerKind:r,reason:"unexpected_error",errorMessage:i instanceof Error?i.message:String(i)}),JSON.stringify(n)}}isContextManifestBudgetEnabled(){let{effectiveConfig:t}=this.config;if(!t)return!1;let r=li(t);return Sa(r,"context_manifest_budget")}isProgressiveEvaluatorEnabled(){let{effectiveConfig:t}=this.config;if(!t)return!1;let r=li(t);return Sa(r,"progressive_evaluator")}async runSingleEvaluation(t,r){let n=this.getRuntimeKind(),o=await this.runtimeAdapter.startRun({agentSpec:{agentId:this.resolvedOptions.agentId,schemaVersion:"v1"},taskRef:{taskId:t},inputPayload:r,contextItems:[],outputSchemaRef:this.config.resultRefPrefix.includes("evaluator")?"evaluator-output-v1":`${this.config.expectedTaskKind}-output-v1`,timeoutMs:this.resolvedOptions.timeoutMs});this.emitEvent("run_started",t,{runtimeKind:n,stage:"progressive_evaluation"});let i=await this.pollUntilTerminal(o);if(i.status!=="succeeded")throw new Ie(i.status==="timed_out"?"timeout":"execution_failed",`Progressive evaluation run ${o.runId} ended with status ${i.status}`);return this.fetchAndParseOutput(o.runId,t)}resolveContextInjection(t,r,n){if(!this.isContextManifestBudgetEnabled())return{mode:"disabled"};let o=DR(r),i=t1e(o,n),s=ZMe(r,i,c=>{c.type==="manifest_resolution_insufficient"?this.emitEvent("manifest_resolution_insufficient",t,{runnerKind:c.runnerKind,manifestId:c.manifestId,absentCount:c.absentCount,declaredCount:c.declaredCount,absentRatio:c.absentRatio,fallback:c.fallback}):this.emitEvent("context_truncated",t,{runnerKind:c.runnerKind,manifestId:c.manifestId,fieldPath:c.fieldPath,reason:c.reason,remainingBudgetTokens:c.remainingBudgetTokens})});return s.kind==="focused"?{mode:"focused",fields:s.allocated.fields}:{mode:"fallback"}}injectAgentDraftOnPermanentFailure(t){if(!this.pendingAgentDraftStore)return;let{taskKind:r}=t.task,{errorCategory:n}=t,o=t.failureReason,i=jf(Wf(qf(o))),a={summary:`${r} failed with category=${n} at ${new Date().toISOString()}`,observedFailure:i},s=J8t(t.task.diagnosticJson);try{let c=this.pendingAgentDraftStore.insertPendingDraft({taskId:t.taskId,painId:s??void 0,agentDraft:a});if(!c.ok){this.emitEvent("agent_draft_insert_failed",t.taskId,{errorCategory:n,attemptCount:t.task.attemptCount,errorMessage:c.error,nextAction:"Inspect pending_agent_drafts table integrity; draft will be retried on next permanent failure of the same taskId (idempotent UPDATE)."});return}this.emitEvent("agent_draft_inserted",t.taskId,{errorCategory:n,attemptCount:t.task.attemptCount,draftId:c.id,painIdLinked:s!==null})}catch(c){this.emitEvent("agent_draft_insert_failed",t.taskId,{errorCategory:n,attemptCount:t.task.attemptCount,errorMessage:c instanceof Error?c.message:String(c),nextAction:"PendingAgentDraftStore.insertPendingDraft threw unexpectedly; inspect the store implementation."})}}};var NN=class extends pi{validator;contextAssembler;effectiveConfig;intentDocReader;constructor(t,r){super(t,r,{runnerName:"diag_rootcause",expectedTaskKind:"diag_rootcause",defaultAgentId:"main",resultRefPrefix:"diag-rootcause",effectiveConfig:r.effectiveConfig}),this.validator=t.validator,this.contextAssembler=t.contextAssembler,this.effectiveConfig=r.effectiveConfig,this.intentDocReader=t.intentDocReader}get permanentErrorCategories(){return new Set(["storage_unavailable","workspace_invalid","capability_missing","cancelled","input_invalid"])}async buildContext(t){let r=await this.stateManager.getTask(t);if(!r)throw new Ie("input_invalid",`Task ${t} not found`);let n=r.inputRef||t,o=await this.contextAssembler.assemble(n),a=Pr(r)?.dependencyTaskIds??[],s=[...o.sourceRefs];if(a.length>0){let u=await Promise.allSettled(a.map(l=>this.stateManager.getTask(l)));for(let l=0;l<u.length;l++){let d=u[l],p=a[l];if(!(!d||p===void 0)&&d.status==="fulfilled"&&d.value){d.value.resultRef&&s.push(d.value.resultRef);let m=d.value?Pr(d.value):null;m?.outputArtifactRefs&&s.push(...m.outputArtifactRefs.map(f=>f.ref))}}}return{contextHash:pi.hashContextRefs(s),contextRefs:s,painPayload:o}}async invokeRuntime(t,r){let n=!1,o=!1,i=!1;if(this.effectiveConfig){let u=li(this.effectiveConfig);n=Sa(u,"diagnostician_core_grounding"),o=Sa(u,"intent_engineering"),i=Sa(u,"pain_diagnosis_persistence")}let a;if(o&&!this.intentDocReader)o=!1;else if(o&&this.intentDocReader){let u=this.intentDocReader.readIntentDoc();u.ok&&u.doc?a={raw:u.doc.raw,contentHash:u.doc.contentHash,path:u.doc.path}:(this.emitEvent("intent_doc_read_failed",t,{reason:u.reason??"unknown",nextAction:u.nextAction??"Check INTENT.md configuration.",flagEnabled:u.flagEnabled,found:u.found}),o=!1)}let s=new m5,{message:c}=s.buildPrompt(r.painPayload,{outputLanguage:this.resolvedOptions.outputLanguage,coreGrounding:n,intentGrounding:o,intentDoc:a,evidenceFirstAttribution:i});return this.runtimeAdapter.startRun({agentSpec:{agentId:this.resolvedOptions.agentId,schemaVersion:"v1"},taskRef:{taskId:t},inputPayload:c,contextItems:[],outputSchemaRef:"diag-rootcause-output-v1",timeoutMs:this.resolvedOptions.timeoutMs})}async validateOutput(t,r,n){let o=await this.validator.validate(t,r);return{valid:o.valid,errors:o.errors,errorCategory:o.errorCategory,warnings:o.warnings}}async succeedTask(t,r,n,o,i,a){try{await this.stateManager.updateRunOutput(r,JSON.stringify(n))}catch(p){throw this.emitEvent("update_output_failed",t,{runId:r,errorMessage:p instanceof Error?p.message:String(p)}),p}let s=[],c=!1;try{let p=await this.resolveLineageArtifactIds(t);s=p.ids,c=p.hasRejected}catch(p){this.emitEvent("lineage_resolve_failed",t,{runId:r,errorMessage:p instanceof Error?p.message:String(p)})}c&&this.emitEvent("lineage_partial",t,{runId:r,resolvedCount:s.length,warning:"Some dependency artifact queries were rejected; lineage may be incomplete"});let u=`pi-art-${t}-${r}`,l=new Date().toISOString();try{await this.artifactStore.upsertArtifact({artifactId:u,artifactKind:"principle",sourceTaskId:t,lineageArtifactIds:s,validationStatus:"pending",contentJson:this.buildArtifactContentJson(t,"diag_rootcause",n,null),createdAt:l,updatedAt:l})}catch(p){return this.emitEvent("artifact_write_failed",t,{runId:r,errorMessage:p instanceof Error?p.message:String(p)}),this.retryOrFail({taskId:t,task:o,errorCategory:"artifact_commit_failed",failureReason:`PIArtifact write failed: ${p instanceof Error?p.message:String(p)}`})}let d=`${this.config.resultRefPrefix}://${r}`;try{await this.stateManager.markTaskSucceeded(t,d)}catch(p){throw this.emitEvent("mark_succeeded_failed",t,{taskId:t,runId:r,errorMessage:p instanceof Error?p.message:String(p)}),p}return this.emitEvent("task_succeeded",t,{attemptCount:o.attemptCount,resultRef:d,rootCauseCategory:n.rootCauseCategory,causalChainDepth:n.causalChain.length}),{status:"succeeded",taskId:t,runId:r,artifactId:u,resultRef:d,contextHash:i,output:n,attemptCount:o.attemptCount}}postFetchTransform(t,r){pb(r,"taskId",t)}emitSuccessTelemetry(t,r,n){this.emitEvent("rootcause_completed",t,{rootCauseCategory:r.rootCauseCategory,causalChainDepth:r.causalChain.length})}};$s();var X8t=h.Union([h.Literal("general"),h.Literal("domain"),h.Literal("scenario")]),Gf=h.Object({valid:h.Boolean(),taskId:h.String({minLength:1}),sourceRootCauseArtifactId:h.String({minLength:1,description:"Lineage consistency check \u2014 must match the artifact ID from Stage A"}),abstractedPrinciple:h.String({minLength:1,maxLength:200,description:"Highly abstracted, cross-scenario principle (\u2264200 chars)"}),rationale:h.String({minLength:1,description:"Why this principle addresses the root cause"}),groundedOnCorePrincipleIds:h.Array(h.String({minLength:1}),{description:"Subset of T-01..T-10. Validated against registry \u2014 fabricated IDs cause validation failure."}),scope:X8t,confidence:h.Number({minimum:0,maximum:1}),ambiguityNotes:h.Optional(h.Array(h.String()))}),LN=class{async validate(t,r){let n=[],o=[];if(typeof t!="object"||t===null)return{valid:!1,errors:["Output is not an object"],errorCategory:"output_invalid"};let i=t;if(typeof i.taskId!="string"||i.taskId!==r){let a=["diag_rootcause-","diag_distiller-","diag_router-"],s=l=>{for(let d of a)if(l.startsWith(d))return l.slice(d.length);return l},c=s(r),u=typeof i.taskId=="string"?s(i.taskId):"";if(u!==""&&u===c){let l=i.taskId;i.taskId=r,o.push(`taskId re-injected: LLM output "${l}", corrected to "${r}" (ERR-008)`)}else n.push(`taskId mismatch: expected ${r}, got ${String(i.taskId)}`)}if(!wr.Check(Gf,t)){let s=[...wr.Errors(Gf,t)].map(c=>`${c.path}: ${c.message}`);n.push(...s)}if(Array.isArray(i.groundedOnCorePrincipleIds))for(let a of i.groundedOnCorePrincipleIds)typeof a=="string"&&!PR(a)&&n.push(`Fabricated axiom ID ${a} not in core principle registry`);return n.length>0?{valid:!1,errors:n,errorCategory:"output_invalid"}:{valid:!0,errors:[],warnings:o}}};function Y8t(e={}){let t=e.adapter??new $p,r=e.schema??Gf,{outputLanguage:n,coreGrounding:o}=e,i=t.generateExample(r),a=t.generateConstraints(r),s=Cg(n);return`You are a principle distiller. Your job is to abstract a specific root cause into a general, cross-scenario principle.
991
+ [OUTPUT FORMAT section is REQUIRED; other sections may be summarized if needed]`;g.diagnosticInstruction=D,g.truncationWarnings=[...u,`diagnosticInstruction truncated due to size (${y.length} > ${n.maxMessageChars})`],y=JSON.stringify(g)}return{message:y,promptInput:g}}};oc();var Og=["core","quiet","gone","legacy_retire"],NR=["openclaw","pi-ai"],Xc=["diagnostician","dreamer","philosopher","scribe","artificer","evaluator","rolloutReviewer","correctionObserver","empathyObserver","signalCollector"],hb=["simple","advanced"],f5=["low","medium","high"],h5=["realtime","async"],LR=["smoke","unit","full"],TN=["full","summary","off"],ts=new Set(["__proto__","constructor","prototype"]);var g5=[{id:"prompt",category:"core",enabled:!0,since:"2026-05-24",description:"Prompt injection for principle application"},{id:"code_tool_hook",category:"core",enabled:!0,since:"2026-05-24",description:"Code tool hook for rule host enforcement"},{id:"rulecode_safety_controls",category:"core",enabled:!0,since:"2026-08-21",description:"Durable RuleCode safety isolation authority. Default ON; emergency enforcement shutdown remains the code_tool_hook core flag."},{id:"rulecode_owner_live_decision",category:"core",enabled:!0,since:"2026-08-21",description:"Owner-reviewed RuleCode shadow-to-live decision authority. Default ON after the readiness, authenticated Console, CLI, audit, and rollback rollout gates passed; flag-off refuses promotion."},{id:"defer_archive",category:"core",enabled:!0,since:"2026-05-24",description:"Defer/archive activation writer"},{id:"correction_observer",category:"quiet",enabled:!1,since:"2026-06-02",description:"Optional LLM optimization service for correction keywords; synchronous correction detection remains active independently"},{id:"signal_collector",category:"quiet",enabled:!1,since:"2026-06-30",description:"Unified signal collection host (correction + empathy upstream merge). NOTE: keyword detection (high-precision phrases) runs regardless of this flag; this flag only gates the LLM deep-judgment path (ambiguous terms / missed keywords). Quiet flag: dogfood-only until validated."},{id:"internalization_auto_consumer",category:"quiet",enabled:!0,since:"2026-06-13",description:"Bounded auto-consumer for dreamer internalization tasks \u2014 prevents ready tasks from pending forever (PRI-381; quiet flag, default on, disableable via config)"},{id:"internalization_full_chain",category:"core",enabled:!0,since:"2026-08-12",description:"PRI-419 amendment: auto-consumer advances dreamer\u2192\u2026\u2192evaluator\u2192rollout_reviewer (full chain) so artifacts reach validated and the approval queue is populated unattended. The human gate is the approval queue (Console), not the rollout_reviewer CLI trigger. Default ON; flag-off = dreamer-only."},{id:"story_a_approval_completion",category:"quiet",enabled:!0,since:"2026-06-18",description:"Story A approval-completion orchestrator (PRI-408) \u2014 formal service replacing demo direct-writer activation; quiet flag, default on, disableable via config"},{id:"feedback_channel",category:"quiet",enabled:!0,since:"2026-06-01",description:"MVP seed feedback channel \u2014 privacy-preserving report drafts. PRI-543: flag scope extended to also cover the feedback SUBMIT ladder (ingest relay / gh CLI / mailto / export-file channels + submit endpoints). Flag-off = submit endpoints 403 + submit UI hidden; config `feedback:` segment and channel parameters still available."},{id:"gfi",category:"quiet",enabled:!1,since:"2026-05-24",description:"Global Friction Index session scoring"},{id:"evolution_worker",category:"quiet",enabled:!1,since:"2026-06-01",description:"Legacy evolution worker heartbeat (MVP-Quiet per ADR-0014 \xA72.5)"},{id:"empathy_observer",category:"quiet",enabled:!1,since:"2026-06-02",description:"Empathy observer service for sentiment checking (MVP-Quiet)"},{id:"painEvidenceAdmission",category:"quiet",enabled:!0,since:"2026-06-06",description:"Pre-diagnosis evidence triage for pain signals (PEAT-B1). PRI-454: default-on, Gate B is primary gate."},{id:"pain_evidence_admission",category:"quiet",enabled:!0,since:"2026-06-15",description:"Snake-case alias for painEvidenceAdmission \u2014 same functionality, matches config.yaml key convention. PRI-454: default-on."},{id:"painEvidenceAdmissionDefault",category:"quiet",enabled:!0,since:"2026-06-24",description:"PRI-454: Global kill switch for Gate B migration. When ON (default), Gate B (TriggerController) owns admission. When OFF (rollback), Gate A (PainDiagnosticGate) is re-activated."},{id:"pain_evidence_admission_default",category:"quiet",enabled:!0,since:"2026-06-24",description:"PRI-454: Snake-case alias for painEvidenceAdmissionDefault \u2014 global kill switch, matches config.yaml key convention"},{id:"diagnostician_async_cli",category:"quiet",enabled:!1,since:"2026-06-11",description:"Async pain-record CLI \u2014 submit and return immediately, diagnosis runs in background. Default: false until orchestrator exists."},{id:"diagnostician_core_grounding",category:"quiet",enabled:!0,since:"2026-06-11",description:"Core principle grounding in diagnostician prompt (Arm 2)"},{id:"internalization_core_grounding",category:"quiet",enabled:!0,since:"2026-06-16",description:"Core principle grounding in internalization prompt builders (dreamer, philosopher, scribe)"},{id:"diagnostician_split_pipeline",category:"quiet",enabled:!0,since:"2026-06-11",description:"3-stage split diagnostician pipeline (RootCause\u2192Distiller\u2192Router)"},{id:"diagnostician_llm_degradation",category:"quiet",enabled:!0,since:"2026-07-03",description:"Diagnostician LLM rate-limit graceful degradation \u2014 on persistent rate-limit, emit diag_llm_rate_limit_degraded telemetry + rate_limit errorCategory instead of max_attempts_exceeded (ADR-0019). Default ON (graduated PRI-571, 2026-08-24); flag-off = hard fail (legacy behavior)."},{id:"l2_dreamer",category:"quiet",enabled:!1,since:"2026-06-16",description:"L2 multi-turn agent loop for the dreamer runner (PRI-419) \u2014 read-only tools + submit_output, scoped to dreamer only"},{id:"code_rule_capability",category:"core",enabled:!0,since:"2026-06-18",description:"Code-rule capability (atomic: ArtificerL2 + Evaluator) for RuleHost pipeline \u2014 MVP-Core, default ON (PRI-435)"},{id:"intent_engineering",category:"quiet",enabled:!1,since:"2026-06-25",description:"INTENT.md-grounded constructive friction and Stage-A intent tension diagnosis (PRI-465). Default off; flag-off = no INTENT read, no prompt injection, no intentTension."},{id:"rulecode_context_v2",category:"quiet",enabled:!1,since:"2026-06-27",description:"RuleContext v2 \u2014 rule-code context vision (PRI-479). Foundation flag; default off, v1 rule behavior unchanged. See docs/superpowers/specs/2026-06-27-rulecode-context-vision-design.md"},{id:"failed_tasks_observability",category:"quiet",enabled:!0,since:"2026-07-04",description:"Failed tasks observability \u2014 list/view failed pipeline tasks"},{id:"evaluator_artificer_repair_loop",category:"quiet",enabled:!0,since:"2026-07-04",description:"PRI-509/P0-D: Evaluator\u2192Artificer repair loop \u2014 auto-seed artificer repair on needs_revision (2-round cap \u2192 needs_human_review). Default ON (INV-02 liveness); production-wired in auto-consumer since 2026-08-18."},{id:"artificer_output_retry",category:"quiet",enabled:!1,since:"2026-08-20",description:"Issue 2: retry Artificer `output_invalid` (malformed LLM output, e.g. missed submit_rulecode) via the base retry policy (max 3 attempts) instead of permanent failure. Default off; flag-off = output_invalid permanent (legacy)."},{id:"artifact_summary_redundancy",category:"quiet",enabled:!1,since:"2026-07-26",description:"Internalization progressive disclosure Layer 0 \u2014 writer-side ArtifactSummary + predecessorSummary envelope on all 8 SummaryRunnerKind stages. Default off; flag-off = current contentJson shape unchanged."},{id:"context_manifest_budget",category:"quiet",enabled:!1,since:"2026-07-26",description:"Internalization progressive disclosure Layer 1 \u2014 manifest + budget-driven context injection with information-floor fallback. Default off; flag-off = existing buildContext assembly unchanged."},{id:"progressive_evaluator",category:"quiet",enabled:!1,since:"2026-07-26",description:"Internalization progressive disclosure Layer 2 \u2014 two-stage evaluation with flagged criteria + painCoverage/compressionFidelity output fields. Default off; flag-off = single-stage evaluation unchanged."},{id:"host.codex",category:"core",enabled:!0,since:"2026-08-11",description:"ADR-0020: Codex CLI host adapter. Default ON (flipped 2026-08-12 after PRI-282 E2E). Flag-off = pd-hook.js outputs {} + exit 0 + SystemLogger records skip (rc-9). Disable via .pd/config.yaml: host.codex: { enabled: false }."},{id:"abstraction_layer_v1",category:"quiet",enabled:!1,since:"2026-08-13",description:"PRI-523 shared host-runtime cutover for OpenClaw. Default OFF preserves the legacy route; enable only for controlled parity validation."},{id:"principle_receipt_block_copy",category:"quiet",enabled:!0,since:"2026-08-15",description:"Principle Receipt P0 \u2014 enriched RuleHost block copy with principle attribution (title/approval date/source summary, PRI-530). Default ON (graduated PRI-571, 2026-08-24); flag-off = generic block template unchanged."},{id:"principle_receipt_ledger",category:"quiet",enabled:!0,since:"2026-08-15",description:"Principle Receipt ledger \u2014 durable principle_applications history (effect/presence two-level semantics, PRI-531). Default ON (graduated PRI-571, 2026-08-24); flag-off = no ledger writes."},{id:"principle_receipt_self_report",category:"quiet",enabled:!1,since:"2026-08-16",description:"Principle Receipt P1-a \u2014 agent self-report \u{1F4CC} line (injection instruction + capture, PRI-532). Default off; flag-off = directive template unchanged, no capture."},{id:"principle_governance_projection_v2",category:"quiet",enabled:!0,since:"2026-08-20",description:"Read-only per-principle Owner governance projection (PRI-549). Default ON (graduated PRI-571, 2026-08-24); flag-off preserves the pre-projection Principle Detail experience."},{id:"failed_task_recovery_console",category:"quiet",enabled:!0,since:"2026-08-23",description:"Governance Recovery Actions v1 \u2014 Owner-triggered recovery of failed / needs_human_review tasks from Console (failed\u2192pending via RecoverySweepService; needs_human_review\u2192pending via owner authority reset). Default on (2026-08-24 owner decision); flag-off = Console read-only."},{id:"pain_diagnosis_persistence",category:"quiet",enabled:!1,since:"2026-08-23",description:"Persist diagnostician root-cause attribution to pain_diagnoses (state.db, keyed by canonical pain_id) + Evidence First attribution rules in the Stage A prompt. Default off; flag-off = no writes, prompt byte-identical."},{id:"nocturnal",category:"gone",enabled:!1,since:"2026-05-24",description:"Nocturnal trinity pipeline (retired)"},{id:"idle_trigger",category:"gone",enabled:!1,since:"2026-05-24",description:"Idle trigger for background processing (retired)"},{id:"new_user_onboarding",category:"core",enabled:!0,since:"2026-07-01",description:"New user onboarding wizard \u2014 first-visit redirect to /welcome + demo story-a trigger endpoint. Maintainer-approved MVP-Core (2026-07-01): default-on; emergency disable via .pd/config.yaml: new_user_onboarding: { enabled: false }."}];var My={};for(let e of g5)My[e.id]={category:e.category,enabled:e.enabled};var s8t="pd.default",c8t={type:"pi-ai",provider:"",model:"",apiKeyEnv:""},WMe="openclaw.default",qMe={type:"openclaw",source:"default"},Ly=WMe,_5=qMe,u8t={diagnostician:!0,dreamer:!0,philosopher:!1,scribe:!0,artificer:!0,evaluator:!1,rolloutReviewer:!1,correctionObserver:!1,empathyObserver:!1,signalCollector:!1};function EN(){let e={};for(let t of Xc)e[t]={enabled:u8t[t],runtimeProfile:Ly};return{defaultRuntime:Ly,agents:e}}var RN={diagnostics:{mode:"simple"}},$u={thinkingOs:!1,projectFocus:"off",evolutionContext:{enabled:!0,maxMessages:4,maxCharsPerMessage:200}};function y5(){return{version:1,features:{...My},runtimeProfiles:{[s8t]:{...c8t},[WMe]:{...qMe}},internalAgents:EN(),ui:{...RN},principles:{outputLanguage:void 0},contextInjection:void 0}}var Tte=["prompt","code_tool_hook","defer_archive"];function li(e){let{config:t}=e,r=[],n={};for(let[i,a]of Object.entries(My))n[i]={id:i,category:a.category,enabled:a.enabled};for(let[i,a]of Object.entries(t.features))if(!ts.has(i)&&a)if(Object.hasOwn(n,i)){let s=n[i];if(!s)continue;if(s.category==="gone"&&a.enabled){r.push(`feature '${i}': gone flag cannot be re-enabled`);continue}if(s.category==="core"&&!a.enabled){r.push(`feature '${i}': core flag explicitly disabled via config (emergency disable)`),n[i]={id:i,category:s.category,enabled:!1};continue}n[i]={id:i,category:a.category,enabled:a.enabled}}else{if(!Og.includes(a.category)){r.push(`feature '${i}': invalid category '${a.category}', ignored`);continue}n[i]={id:i,category:a.category,enabled:a.enabled},r.push(`feature '${i}': unknown flag accepted`)}let o=[];for(let i of Tte){let a=n[i];a&&a.enabled&&o.push(i)}return{flags:n,enabledChannels:o,warnings:r}}function Sa(e,t){return Object.hasOwn(e.flags,t)?e.flags[t]?.enabled??!1:!1}var S5="<redacted-path>",zf="[REDACTED]";var l8t=/(?:[A-Za-z]:[\\/](?:[^\\\s/:*?"<>|]+[\\/])+[^\\\s/:*?"<>|]*)/g,p8t=/(?<![a-zA-Z0-9_.])[\\/](?:usr|home|Users|var|opt|etc|tmp|root|run|mnt|media|srv|boot|dev|proc|sys)(?:[\\/][^\\\s/:*?"<>|]+)+/g;function Wf(e){return typeof e!="string"?e:e.replace(l8t,S5).replace(p8t,S5)}var d8t=/\bsk-(?:ant-)?[A-Za-z0-9_-]{16,}\b/g,m8t=/\bgh[pousr]_[A-Za-z0-9_]{16,}\b/g,f8t=/\blin_api_[A-Za-z0-9_-]{16,}\b/g,h8t=/(Authorization\s*:\s*)(["'])?([A-Za-z]+\s+)?([^\s"';,]+)/gi,g8t=/(\$env:\s*[A-Z_][A-Z0-9_]{2,}\s*=\s*")([^"]*)(")/gi,_8t=/\b(api[_-]?key|token|secret|password|auth(?:_?token)?)\s*[:=]\s*['"]?([^\s'",}{]+)['"]?/gi,y8t=/\bBearer\s+[A-Za-z0-9._\-+/=]{8,}\b/g;function qf(e){return typeof e!="string"?e:e.replace(d8t,zf).replace(m8t,zf).replace(f8t,zf).replace(h8t,"$1$2$3[REDACTED]").replace(g8t,"$1[REDACTED]$3").replace(y8t,zf).replace(_8t,(t,r)=>`${r}=${zf}`)}var S8t=/\b([A-Z_][A-Z0-9_]{2,})\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s,;}{]+))/g;function jf(e){return typeof e!="string"?e:e.replace(S8t,(t,r)=>`${r}=${zf}`)}function Pg(e){if(typeof e!="string")return e;let t=Wf(e);return t=qf(t),t=jf(t),t}var x8t=new Set(["password","passwd","secret","token","api","apikey","authorization","auth","credential","credentials","private","key"]);function b8t(e){return e.toLowerCase().split(/[_\-.]/g).filter(t=>t.length>0)}function jMe(e){let t=b8t(e);if(t.length===0)return!1;for(let r of t)if(x8t.has(r))return!0;return!1}var v8t=6,GMe=100,Ete=2e3;function x5(e,t){if(e===null)return{ok:!0,value:null,notes:[]};if(e===void 0)return{ok:!0,value:void 0,notes:[]};let r=typeof e;if(r==="string"){let o=e,i=o;return o=Wf(o),o=qf(o),o=jf(o),o!==i&&t.notes.push("string value redacted (path/token/env)"),o.length>Ete&&(o=o.slice(0,Ete)+"\u2026",t.notes.push(`string truncated to ${Ete} chars`)),{ok:!0,value:o,notes:t.notes}}if(r==="bigint")return{ok:!0,value:`<bigint:${e.toString()}>`,notes:[]};if(r!=="object")return{ok:!0,value:e,notes:[]};if(t.depth>=v8t)return{ok:!0,value:"<deep>",notes:[]};let n=e;if(t.seen.has(n))return t.notes.push("circular reference detected"),{ok:!0,value:"<circular>",notes:[]};t.seen.add(n);try{if(Array.isArray(e)){let s=[];for(let c=0;c<e.length;c++){let u=x5(e[c],{seen:t.seen,depth:t.depth+1,notes:t.notes});if(!u.ok)return u;s.push(u.value)}return{ok:!0,value:s,notes:[]}}let o=e,i={},a=Object.keys(o).slice(0,GMe);for(let s of a){if(jMe(s)){i[s]=zf,t.notes.push(`field "${s}" redacted`);continue}let c=o[s];if(c!==null&&typeof c=="object"&&t.seen.has(c)){t.notes.push(`circular reference detected at "${s}"`),i[s]="<circular>";continue}let u=x5(c,{seen:t.seen,depth:t.depth+1,notes:t.notes});if(!u.ok)return u;i[s]=u.value}return{ok:!0,value:i,notes:[]}}finally{t.seen.delete(n)}}function T8t(e){let t=[],r=[],n={seen:new WeakSet,depth:0,notes:t};n.seen.add(e);for(let o=0;o<e.length;o++){let i=e[o];if(i!==null&&typeof i=="object"&&n.seen.has(i)){t.push("circular reference detected in array"),r.push("<circular>");continue}let a=x5(i,n);if(!a.ok)return a;r.push(a.value)}return{ok:!0,value:r,notes:t}}function E8t(e){let t=e,r=[],n={seen:new WeakSet,depth:0,notes:r};n.seen.add(e);let o={},i=Object.keys(t).slice(0,GMe);for(let a of i){if(jMe(a)){o[a]=zf,r.push(`field "${a}" redacted`);continue}let s=t[a];if(s!==null&&typeof s=="object"&&n.seen.has(s)){r.push(`circular reference detected at "${a}"`),o[a]="<circular>";continue}let c=x5(s,n);if(!c.ok)return c;o[a]=c.value}return{ok:!0,value:o,notes:r}}function wN(e){if(e===null)return{ok:!1,error:"redactSensitiveFields: null is not a redactable object",nextAction:"pass a JSON object or array; null carries no fields to redact"};if(e===void 0)return{ok:!1,error:"redactSensitiveFields: undefined is not a redactable object",nextAction:"pass a JSON object or array; undefined carries no fields to redact"};let t=typeof e;return t!=="object"?{ok:!1,error:`redactSensitiveFields: top-level value must be an object or array (got ${t})`,nextAction:"pass a JSON object or array; for primitive values use redactTokenLikeValues / redactEnvLikeValues / redactAbsolutePaths"}:Array.isArray(e)?T8t(e):E8t(e)}var BMe="\u2026[canonical-json-truncated]";function IN(e,t=new WeakSet){if(e===null)return"null";let r=typeof e;if(r==="string")return JSON.stringify(e);if(r==="number")return Number.isFinite(e)?String(e):"null";if(r==="boolean")return String(e);if(r==="bigint")return JSON.stringify(`${String(e)}n`);if(r==="undefined"||r==="function"||r==="symbol")return"null";if(Array.isArray(e)){if(t.has(e))return'"[Circular]"';t.add(e);let n=e.map(o=>IN(o,t));return t.delete(e),`[${n.join(",")}]`}if(e instanceof Date)return JSON.stringify(Number.isNaN(e.getTime())?null:e.toISOString());if(e instanceof Map){if(t.has(e))return'"[Circular]"';t.add(e);let o=[...e.entries()].map(([i,a])=>[String(i),a]).sort(([i],[a])=>i<a?-1:i>a?1:0).map(([i,a])=>`${JSON.stringify(i)}:${IN(a,t)}`).join(",");return t.delete(e),`{${o}}`}if(e instanceof Set){if(t.has(e))return'"[Circular]"';t.add(e);let n=[...e.values()].map(o=>IN(o,t));return t.delete(e),`[${n.join(",")}]`}if(r==="object"){let n=e;if(t.has(n))return'"[Circular]"';t.add(n);let o=Object.keys(n).sort((a,s)=>a<s?-1:a>s?1:0),i=[];for(let a of o){let s=IN(n[a],t),c=n[a],u=typeof c;c===void 0||u==="function"||u==="symbol"||i.push(`${JSON.stringify(a)}:${s}`)}return t.delete(n),`{${i.join(",")}}`}return'"[Unserializable]"'}function R8t(e){let t=IN(e);if(t.length<=262144)return{text:t,truncated:!1};let r=262144-BMe.length;return{text:`${t.slice(0,Math.max(0,r))}${BMe}`,truncated:!0}}function Rte(e,t){return t(R8t(e).text)}var T5=["diag_rootcause","diag_distiller","diag_router","dreamer","philosopher","scribe","artificer","evaluator"],E5=1,wte=200,w8t=600;function gb(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function I8t(e){return T5.includes(e)}function qa(e,t){if(!gb(e)||!Object.hasOwn(e,t))return null;let r=e[t];return typeof r!="string"||r.trim()===""?null:r}function kN(e,t){if(!gb(e)||!Object.hasOwn(e,t))return null;let r=e[t];return gb(r)?r:null}function MR(e,t){if(!gb(e)||!Object.hasOwn(e,t))return null;let r=e[t];return Array.isArray(r)?r:null}function b5(e,t){let r=MR(e,t);if(r===null)return null;let n=r.filter(o=>typeof o=="string"&&o.trim()!=="");return n.length===0?null:n.join(" / ")}function k8t(e,t){if(!gb(e)||!Object.hasOwn(e,t))return null;let r=e[t];return typeof r=="number"&&Number.isFinite(r)?String(r):null}function A8t(e,t){if(!gb(e)||!Object.hasOwn(e,t))return null;let r=e[t];return typeof r=="boolean"?String(r):null}function v5(e,t){return e.length<=t?e:`${e.slice(0,t-1)}\u2026`}function AN(e){let r=/^[\s\S]*?[。;;.]/.exec(e)?.[0]??e;return v5(r.trim(),wte)}function Ite(e){let t=e.filter(r=>r!==null&&r.trim()!=="");return t.length===0?null:v5(t.join("; "),wte)}function C8t(e){let t=qa(e,"rootCause");return{headlineSource:t===null?null:AN(t),resolved:{rootSymptom:qa(e,"summary"),category:qa(e,"rootCauseCategory"),severity:null,rootCause:t}}}function O8t(e){let t=qa(e,"abstractedPrinciple");return{headlineSource:t===null?null:AN(t),resolved:{rootCause:qa(e,"rationale"),affectedComponents:null,category:qa(e,"scope"),severity:null}}}function P8t(e){let t=qa(e,"summary"),n=(MR(e,"violatedPrinciples")??[]).map(a=>qa(a,"principleId")).filter(a=>a!==null),o=MR(e,"recommendations")??[],i=o.length>0?qa(o[0],"kind"):null;return{headlineSource:Ite([t,i]),resolved:{rootCause:qa(e,"rootCause"),affectedComponents:n.length>0?n.join(" / "):null,rootSymptom:t,category:i,severity:null}}}function N8t(e){let t=MR(e,"candidates")??[],r=t.length>0?t[0]:null,n=qa(r,"betterDecision");return{headlineSource:n===null?null:AN(n),resolved:{badDecision:qa(r,"badDecision"),betterDecision:n,rationale:qa(r,"rationale"),riskLevel:qa(r,"riskLevel"),strategicPerspective:qa(r,"strategicPerspective")}}}function L8t(e){let t=kN(e,"principleCandidate"),r=qa(t,"title");return{headlineSource:r,resolved:{thesis:qa(e,"thesis"),principleTitle:r,principleScope:qa(t,"scope"),principleConfidence:k8t(t,"confidence")}}}function M8t(e){let t=kN(e,"principleDraft"),r=qa(t,"statement");return{headlineSource:r===null?null:AN(r),resolved:{principleText:r,scope:b5(t,"applicability"),exceptions:b5(t,"antiPatterns")}}}function D8t(e){let t=b5(e,"affectedTools"),r=qa(e,"implementationSummary"),n=MR(e,"affectedTools")?.length??null;return{headlineSource:Ite([n!==null?`${n} affected tools`:null,r===null?null:AN(r)]),resolved:{changedFiles:t,apiSurface:r,risks:b5(e,"risks")}}}function U8t(e){let t=kN(e,"evaluation"),r=qa(t,"decision"),n=MR(t,"concerns"),o=n===null?null:String(n.length),i=kN(e,"codeReview"),a=kN(i,"intentConsistency");return{headlineSource:Ite([r===null?null:`verdict=${r}`,o===null?null:`concerns=${o}`]),resolved:{verdict:r,concernCount:o,intentConsistency:A8t(a,"aligned")}}}var $8t={diag_rootcause:C8t,diag_distiller:O8t,diag_router:P8t,dreamer:N8t,philosopher:L8t,scribe:M8t,artificer:D8t,evaluator:U8t};function kte(e,t){if(!I8t(e))return{ok:!1,reason:"unsupported_runner_kind",detail:`Unsupported SummaryRunnerKind: ${String(e)}`};if(!gb(t))return{ok:!1,reason:"output_not_object",detail:`validatedOutput for runnerKind "${e}" is not a non-null object`};let r=$8t[e],{headlineSource:n,resolved:o}=r(t),i={},a=[];for(let[s,c]of Object.entries(o))c!==null?i[s]=v5(c,w8t):a.push(s);return n===null&&Object.keys(i).length===0?{ok:!1,reason:"no_derivable_field",detail:`No derivable headline or field for runnerKind "${e}" from the given output`}:{ok:!0,value:{schemaVersion:E5,runnerKind:e,headline:n===null?"":v5(n,wte),fields:i,derivedFrom:"structured_output",omittedFields:a}}}function F8t(e){if(e===null||typeof e!="object"||Array.isArray(e)||!Object.hasOwn(e,"summary"))return null;let{summary:t}=e;if(t===null||typeof t!="object"||Array.isArray(t))return null;let r=t;if(!Object.hasOwn(r,"schemaVersion")||r.schemaVersion!==E5||!Object.hasOwn(r,"runnerKind")||typeof r.runnerKind!="string"||!T5.includes(r.runnerKind)||!Object.hasOwn(r,"headline")||typeof r.headline!="string"||!Object.hasOwn(r,"fields")||r.fields===null||typeof r.fields!="object"||Array.isArray(r.fields))return null;let n=r.fields;return!Object.values(n).every(o=>typeof o=="string")||!Object.hasOwn(r,"derivedFrom")||r.derivedFrom!=="structured_output"||!Object.hasOwn(r,"omittedFields")||!Array.isArray(r.omittedFields)||!r.omittedFields.every(o=>typeof o=="string")?null:{schemaVersion:E5,runnerKind:r.runnerKind,headline:r.headline,fields:n,derivedFrom:"structured_output",omittedFields:r.omittedFields}}function VMe(e,t,r,n,o){let i=kte(e,t);if(!i.ok)return o({type:"artifact_summary_skipped",runnerKind:e,reason:i.reason}),{};let a={summary:i.value};if(r===null)return o({type:"artifact_summary_predecessor_absent",runnerKind:e,reason:"no_predecessor_in_context"}),a;let s=F8t(r.contentJson);if(s===null){let c=kte(r.runnerKind,r.contentJson);if(!c.ok)return o({type:"artifact_summary_predecessor_skipped",runnerKind:e,reason:c.reason}),a;s=c.value}return{...a,predecessorSummary:{artifactId:r.artifactId,runnerKind:r.runnerKind,contentHash:Rte(r.contentJson,n),summary:s}}}var CN={betterDecision:"required",rationale:"required",riskLevel:"required",badDecision:"optional",strategicPerspective:"excluded"},wYn=Object.entries(CN).filter(([,e])=>e==="required").map(([e])=>e),KMe=["badDecision","betterDecision","rationale","riskLevel","strategicPerspective"];function z8t(e){if(Object.hasOwn(CN,e))return CN[e]}function HMe(e){return z8t(e)==="required"}var ON=1;function JMe(e){let t=new Set,r=[];for(let n of e)t.has(n)||(t.add(n),r.push(n));return r}var AYn=KMe.filter(e=>CN[e]!=="excluded");function XMe(e,t){let r=t.priority.indexOf(e);if(r>=0)return r;let n=JMe([...t.tier0,...t.tier1,...t.tier2]).indexOf(e),o=n>=0?n:0;return t.priority.length+o}function DR(e){return JMe([...e.tier0,...e.tier1,...e.tier2])}function W8t(e){return Math.ceil(e.length/4)}var q8t=600,j8t=8,YMe="\u2026[budget-truncated]";function QMe(e,t,r){let n=DR(e),o=[],i=[];for(let u of n){if(!t.has(u)){i.push(u);continue}let l=da(t.get(u),q8t);o.push({path:u,text:l,tokens:W8t(l),rank:XMe(u,e)})}o.sort((u,l)=>u.rank-l.rank||(u.path<l.path?-1:u.path>l.path?1:0));let a={},s=[],c=e.budgetTokens;for(let u of o)if(u.tokens<=c)a[u.path]=u.text,c-=u.tokens;else if(c>j8t){let l=Math.max(0,c*4-YMe.length),d=u.text.slice(0,l)+YMe;a[u.path]=d;let p={fieldPath:u.path,reason:"partially_truncated",remainingBudgetTokens:c,keptChars:d.length,droppedChars:u.text.length-d.length};s.push(p),r({type:"context_truncated",runnerKind:e.runnerKind,manifestId:e.manifestId,fieldPath:u.path,reason:p.reason,remainingBudgetTokens:c}),c=0}else{let l={fieldPath:u.path,reason:"budget_exceeded",remainingBudgetTokens:c,keptChars:0,droppedChars:u.text.length};s.push(l),r({type:"context_truncated",runnerKind:e.runnerKind,manifestId:e.manifestId,fieldPath:u.path,reason:l.reason,remainingBudgetTokens:c})}return{manifestId:e.manifestId,fields:a,truncated:s,absent:i,usedTokens:e.budgetTokens-c,budgetTokens:e.budgetTokens}}var G8t=.5;function ZMe(e,t,r){let n=QMe(e,t,l=>r(l)),i=DR(e).length,a=n.absent.length,s=i>0?a/i:1,c=()=>({type:"manifest_resolution_insufficient",runnerKind:e.runnerKind,manifestId:e.manifestId,absentCount:a,declaredCount:i,absentRatio:s,fallback:"full_predecessor_injection"});return Object.keys(n.fields).length===0?(r(c()),{kind:"fallback",allocated:n,fellBack:!0,reason:"empty_allocation",absentRatio:s}):e.tier1.length>0&&e.tier1.every(l=>n.absent.includes(l))?(r(c()),{kind:"fallback",allocated:n,fellBack:!0,reason:"tier1_all_absent",absentRatio:s}):s>G8t?(r(c()),{kind:"fallback",allocated:n,fellBack:!0,reason:"absent_ratio_exceeded",absentRatio:s}):{kind:"focused",allocated:n,fellBack:!1}}function PN(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function e1e(e,t){if(!PN(e)||!Object.hasOwn(e,"summary"))return;let{summary:r}=e;if(!PN(r))return;if(t==="headline")return Object.hasOwn(r,"headline")?r.headline:void 0;let n=Object.hasOwn(r,"fields")?r.fields:void 0;if(PN(n)&&Object.hasOwn(n,t))return n[t];if(Object.hasOwn(r,t))return r[t]}function B8t(e,t){if(!PN(e)||!Object.hasOwn(e,"predecessorSummary"))return;let{predecessorSummary:r}=e;if(!(!PN(r)||!Object.hasOwn(r,"summary")))return e1e(r,t)}function V8t(e,t){let r=e.indexOf("summary."),n=e.indexOf("predecessorSummary."),o=e.indexOf("raw.");if(!(o>=0&&(r<0||o<r)&&(n<0||o<n))){if(n>=0&&(r<0||n<r)){let i=e.slice(n+19);return B8t(t,i)}if(r>=0){let i=e.slice(r+8);return e1e(t,i)}}}function t1e(e,t){let r=new Map;for(let n of e){let o=V8t(n,t);o!==void 0&&r.set(n,o)}return r}var Ate={pollIntervalMs:5e3,timeoutMs:3e5,defaultMaxAttempts:3,agentId:"peer-runner",coreGrounding:!0};function K8t(e,t){return{pollIntervalMs:e.pollIntervalMs??Ate.pollIntervalMs,timeoutMs:e.timeoutMs??Ate.timeoutMs,defaultMaxAttempts:e.defaultMaxAttempts??Ate.defaultMaxAttempts,owner:e.owner,runtimeKind:e.runtimeKind,agentId:e.agentId??t,outputLanguage:e.outputLanguage,coreGrounding:e.coreGrounding??!0}}function H8t(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function J8t(e){if(typeof e!="string"||e.length===0)return null;let t;try{t=JSON.parse(e)}catch{return null}if(!H8t(t)||!Object.hasOwn(t,"sourcePainId"))return null;let{sourcePainId:r}=t;return typeof r!="string"||r.length===0?null:r}var pi=class{stateManager;runtimeAdapter;eventEmitter;artifactStore;resolvedOptions;config;pendingAgentDraftStore;contentHashFn;phase=co.Idle;constructor(t,r,n){this.stateManager=t.stateManager,this.runtimeAdapter=t.runtimeAdapter,this.eventEmitter=t.eventEmitter,this.artifactStore=t.artifactStore,this.pendingAgentDraftStore=t.pendingAgentDraftStore,this.contentHashFn=t.contentHashFn,this.config=n,this.resolvedOptions=K8t(r,n.defaultAgentId)}get currentPhase(){return this.phase}getRuntimeKind(){return typeof this.runtimeAdapter.kind=="function"?this.runtimeAdapter.kind():this.resolvedOptions.runtimeKind}async maybeResumePendingIntent(t,r){return null}emitSuccessTelemetry(t,r,n){}checkLineageIntegrity(t,r,n){}postFetchTransform(t,r,n){typeof r=="object"&&r!==null&&!Array.isArray(r)&&Reflect.set(r,"generatedAt",new Date().toISOString())}async run(t){this.phase=co.Idle;let r=this.getRuntimeKind(),n;try{n=await this.stateManager.acquireLease({taskId:t,owner:this.resolvedOptions.owner,runtimeKind:r})}catch(i){return await this.handleLeaseOrPhaseError(t,i)}if(n.taskKind!==this.config.expectedTaskKind)return this.emitEvent("wrong_task_kind",t,{expectedKind:this.config.expectedTaskKind,actualKind:n.taskKind}),await this.stateManager.markTaskFailed(t,"input_invalid"),{status:"failed",taskId:t,errorCategory:"input_invalid",failureReason:`Task kind must be '${this.config.expectedTaskKind}', got '${n.taskKind}'`,attemptCount:n.attemptCount};this.emitEvent("task_leased",t,{taskKind:this.config.expectedTaskKind,attemptCount:n.attemptCount});let o=await this.maybeResumePendingIntent(t,n);if(o)return this.phase=co.Completed,o;try{let i=await this.resolveStoreRunId(t);this.phase=co.BuildingContext;let a=await this.buildContext(t);this.emitEvent("context_built",t,{contextHash:a.contextHash}),this.phase=co.Invoking;let s=await this.invokeRuntime(t,a);this.emitEvent("run_started",t,{runtimeKind:r}),this.phase=co.Polling;let c=await this.pollUntilTerminal(s);if(c.status!=="succeeded")return await this.handleRuntimeFailure(t,n,c);this.phase=co.FetchingOutput;let u=await this.fetchAndParseOutput(s.runId,t);this.postFetchTransform(t,u,a),this.phase=co.Validating;let l=await this.validateOutput(u,t,a);if(!l.valid)return await this.handleValidationError({taskId:t,task:n,errors:l.errors,errorCategory:l.errorCategory});let d=u;this.emitEvent("output_validated",t,{}),this.checkLineageIntegrity(t,d,a),this.emitSuccessTelemetry(t,d,a);let p=await this.succeedTask(t,i,d,n,a.contextHash,a);return p.status==="succeeded"&&(this.phase=co.Completed),p}catch(i){return await this.handlePostLeaseError(t,n,i)}}emitEvent(t,r,n){this.eventEmitter.emitTelemetry({eventType:`${this.config.runnerName}_${t}`,traceId:r,timestamp:new Date().toISOString(),sessionId:this.resolvedOptions.owner,agentId:this.resolvedOptions.agentId,payload:n})}async pollUntilTerminal(t){let r=Date.now()+this.resolvedOptions.timeoutMs,n=["succeeded","failed","timed_out","cancelled"];for(;Date.now()<r;){let a=await this.runtimeAdapter.pollRun(t.runId);if(n.includes(a.status))return a;await this.sleep(this.resolvedOptions.pollIntervalMs)}try{let a=await this.runtimeAdapter.pollRun(t.runId);if(n.includes(a.status))return a}catch{}let o=!1;try{await this.runtimeAdapter.cancelRun(t.runId)}catch(a){o=!0,this.emitEvent("cancel_run_failed",t.runId,{runId:t.runId,errorMessage:a instanceof Error?a.message:String(a)})}let i=o?" (cancelRun also failed)":"";throw new Ie("timeout",`Run ${t.runId} timed out after ${this.resolvedOptions.timeoutMs}ms${i}`)}async fetchAndParseOutput(t,r){let n;try{n=await this.runtimeAdapter.fetchOutput(t)}catch(i){throw this.emitEvent("output_extraction_failed",r,{runId:t,stage:"fetchOutput",errorMessage:i instanceof Error?i.message:String(i)}),i}if(!n||!n.payload)throw this.emitEvent("output_extraction_failed",r,{runId:t,stage:"payload_missing",errorMessage:`No output available for run ${t}`}),new Ie("output_invalid",`No output available for run ${t}`);let{payload:o}=n;if(typeof o!="object"||o===null)throw this.emitEvent("output_extraction_failed",r,{runId:t,stage:"payload_not_object",errorMessage:`Output payload is not an object for run ${t}`}),new Ie("output_invalid",`Output payload is not an object for run ${t}`);return o}async resolveLineageArtifactIds(t){let{hydratePITaskRecord:r}=await Promise.resolve().then(()=>($s(),cMe)),n=await this.stateManager.getTask(t);if(!n)return{ids:[],hasRejected:!1};let i=r(n)?.dependencyTaskIds??[];if(i.length===0)return{ids:[],hasRejected:!1};let a=[],s=!1,c=await Promise.allSettled(i.map(u=>this.artifactStore.listBySourceTaskId(u)));for(let u of c)if(u.status==="fulfilled")for(let l of u.value)a.push(l.artifactId);else s=!0;return{ids:a,hasRejected:s}}async resolveStoreRunId(t){let{runs:r,degradedRuns:n}=await this.stateManager.getValidRunsByTaskTolerant(t);n.length>0&&this.eventEmitter.emitTelemetry({eventType:"degradation_triggered",traceId:t,timestamp:new Date().toISOString(),sessionId:this.resolvedOptions.owner,agentId:this.resolvedOptions.agentId,payload:{component:"BasePeerRunner",runnerName:this.config.runnerName,trigger:"malformed_historical_run_rows",degradedCount:n.length,runIds:n.map(i=>i.runId),errors:n.map(i=>i.error),nextAction:"Quarantine malformed run rows: pd runtime internalization integrity-repair --confirm"}});let o=r[r.length-1];if(!o)throw new Ie("execution_failed",`No valid run records found for task ${t} after lease acquisition. If historical runs are malformed, quarantine them first: pd runtime internalization integrity-repair --confirm`);return o.runId}static hashContextRefs(t){if(t.length===0)return"empty";let r=t.join("|"),n=0;for(let o=0;o<r.length;o++)n=Math.imul(31,n)+r.charCodeAt(o)|0;return`ctx-${Math.abs(n).toString(16)}`}async handleLeaseOrPhaseError(t,r){let n=this.classifyError(r);if(n.category==="lease_conflict")return this.emitEvent("run_failed",t,{errorCategory:"lease_conflict",errorMessage:n.message}),{status:"failed",taskId:t,errorCategory:"lease_conflict",failureReason:n.message,attemptCount:1};this.emitEvent("run_failed",t,{errorCategory:n.category,errorMessage:n.message});let o={taskId:t,taskKind:this.config.expectedTaskKind,status:"leased",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),attemptCount:1,maxAttempts:this.resolvedOptions.defaultMaxAttempts};return n.details&&Object.keys(n.details).length>0&&await this.persistOutputFailureDetails(t,void 0,{errorCategory:n.category,errorMessage:n.message,...n.details}),this.retryOrFail({taskId:t,task:o,errorCategory:n.category,failureReason:n.message})}async handlePostLeaseError(t,r,n){let o=this.classifyError(n);return this.emitEvent("run_failed",t,{errorCategory:o.category,errorMessage:o.message}),o.details&&Object.keys(o.details).length>0&&await this.persistOutputFailureDetails(t,r.diagnosticJson,{errorCategory:o.category,errorMessage:o.message,...o.details}),this.retryOrFail({taskId:t,task:r,errorCategory:o.category,failureReason:o.message})}async handleRuntimeFailure(t,r,n){let o=this.mapRunStatusToErrorCategory(n.status,n.reason);return this.emitEvent("run_failed",t,{runStatus:n.status,errorCategory:o}),this.retryOrFail({taskId:t,task:r,errorCategory:o,failureReason:n.reason?`Runtime execution ended with status: ${n.status}. Reason: ${n.reason}`:`Runtime execution ended with status: ${n.status}`})}async handleValidationError(t){let r=t.errorCategory??"output_invalid";return this.emitEvent("output_invalid",t.taskId,{errorCount:t.errors.length,errorCategory:r}),await this.persistOutputFailureDetails(t.taskId,t.task.diagnosticJson,{errorCategory:r,validatorErrors:[...t.errors],errorCount:t.errors.length}),this.retryOrFail({taskId:t.taskId,task:t.task,errorCategory:r,failureReason:`Validation failed: ${t.errors.join("; ")}`})}async retryOrFail(t){if(this.permanentErrorCategories.has(t.errorCategory)){try{await this.stateManager.markTaskFailed(t.taskId,t.errorCategory,t.failureReason)}catch(n){return this.emitEvent("mark_failed_error",t.taskId,{errorCategory:"storage_unavailable",attemptCount:t.task.attemptCount,errorMessage:n instanceof Error?n.message:String(n)}),{status:"failed",taskId:t.taskId,errorCategory:"storage_unavailable",failureReason:`State manager error: ${t.failureReason}`,attemptCount:t.task.attemptCount}}return this.emitEvent("task_failed",t.taskId,{errorCategory:t.errorCategory,attemptCount:t.task.attemptCount,failureReason:t.failureReason}),this.phase=co.Failed,this.injectAgentDraftOnPermanentFailure(t),{status:"failed",taskId:t.taskId,errorCategory:t.errorCategory,failureReason:t.failureReason,attemptCount:t.task.attemptCount}}if(t.errorCategory==="rate_limit"&&this.isDegradationEnabled()){try{await this.stateManager.markTaskFailed(t.taskId,"rate_limit",`LLM rate limit degraded: ${t.failureReason}`)}catch(n){return this.emitEvent("mark_failed_error",t.taskId,{errorCategory:"storage_unavailable",attemptCount:t.task.attemptCount,errorMessage:n instanceof Error?n.message:String(n)}),{status:"failed",taskId:t.taskId,errorCategory:"storage_unavailable",failureReason:`State manager error: ${t.failureReason}`,attemptCount:t.task.attemptCount}}return this.emitEvent("diag_llm_rate_limit_degraded",t.taskId,{errorCategory:"rate_limit",attemptCount:t.task.attemptCount,failureReason:t.failureReason,nextAction:"Retry diagnosis manually with `pd pain retry` when rate limit clears, or enable fallback provider."}),this.phase=co.Failed,{status:"failed",taskId:t.taskId,errorCategory:"rate_limit",failureReason:`LLM rate limit degraded: ${t.failureReason}`,attemptCount:t.task.attemptCount}}if(this.stateManager.getRetryPolicy().shouldRetry(t.task)){try{await this.stateManager.markTaskRetryWait(t.taskId,t.errorCategory,t.failureReason)}catch(n){return this.emitEvent("mark_retry_error",t.taskId,{errorCategory:"storage_unavailable",attemptCount:t.task.attemptCount,errorMessage:n instanceof Error?n.message:String(n)}),{status:"failed",taskId:t.taskId,errorCategory:"storage_unavailable",failureReason:`State manager error: ${t.failureReason}`,attemptCount:t.task.attemptCount}}return this.emitEvent("task_retried",t.taskId,{errorCategory:t.errorCategory,attemptCount:t.task.attemptCount}),this.phase=co.RetryWaiting,{status:"retried",taskId:t.taskId,errorCategory:t.errorCategory,failureReason:t.failureReason,attemptCount:t.task.attemptCount}}try{await this.stateManager.markTaskFailed(t.taskId,"max_attempts_exceeded",`Max attempts exceeded: ${t.failureReason}`)}catch(n){return this.emitEvent("mark_failed_error",t.taskId,{errorCategory:"storage_unavailable",attemptCount:t.task.attemptCount,errorMessage:n instanceof Error?n.message:String(n)}),{status:"failed",taskId:t.taskId,errorCategory:"storage_unavailable",failureReason:`State manager error: ${t.failureReason}`,attemptCount:t.task.attemptCount}}return this.emitEvent("task_failed",t.taskId,{errorCategory:"max_attempts_exceeded",attemptCount:t.task.attemptCount,failureReason:`Max attempts exceeded: ${t.failureReason}`}),this.phase=co.Failed,{status:"failed",taskId:t.taskId,errorCategory:"max_attempts_exceeded",failureReason:`Max attempts exceeded: ${t.failureReason}`,attemptCount:t.task.attemptCount}}classifyError(t){return t instanceof Ie?{category:t.category,message:t.message,details:t.details}:t instanceof Error?{category:"execution_failed",message:t.message}:{category:"execution_failed",message:String(t)}}async persistOutputFailureDetails(t,r,n){try{let o={};if(r){let i=JSON.parse(r);typeof i=="object"&&i!==null&&!Array.isArray(i)&&(o=i)}o.output_failure_details={recordedAt:new Date().toISOString(),...n},await this.stateManager.updateTask(t,{diagnosticJson:JSON.stringify(o)})}catch(o){this.emitEvent("mark_failed_error",t,{errorCategory:"storage_unavailable",errorMessage:`persistOutputFailureDetails failed: ${o instanceof Error?o.message:String(o)}`})}}mapRunStatusToErrorCategory(t,r){switch(t){case"failed":return"execution_failed";case"timed_out":return"timeout";case"cancelled":return"cancelled";default:return"execution_failed"}}sleep(t){return new Promise(r=>setTimeout(r,t))}isDegradationEnabled(){let{effectiveConfig:t}=this.config;if(!t)return!1;let r=li(t);return Sa(r,"diagnostician_llm_degradation")}isArtifactSummaryEnabled(){let{effectiveConfig:t}=this.config;if(!t)return!1;let r=li(t);return Sa(r,"artifact_summary_redundancy")}buildArtifactContentJson(t,r,n,o){if(!this.isArtifactSummaryEnabled())return JSON.stringify(n);try{let i=this.contentHashFn,a=i?o:null;!i&&o!==null&&this.emitEvent("artifact_summary_predecessor_skipped",t,{runnerKind:r,reason:"content_hash_fn_not_injected",nextAction:"Inject contentHashFn into PeerRunnerDeps (plugin/CLI layer) to enable predecessorSummary."});let s=VMe(r,n,a,i??(l=>l),l=>{this.emitEvent(l.type,t,{runnerKind:l.runnerKind,reason:l.reason})});if(s.summary===void 0||n===null||typeof n!="object"||Array.isArray(n))return JSON.stringify(n);let c=n,u=Object.hasOwn(c,"summary");return u&&this.emitEvent("artifact_summary_skipped",t,{runnerKind:r,reason:"output_summary_key_collision",nextAction:"Runner output already declares a top-level `summary` field; the Layer 0 envelope summary key is skipped to avoid overwriting it. predecessorSummary is still attached."}),JSON.stringify({...c,...u?{}:{summary:s.summary},...s.predecessorSummary!==void 0?{predecessorSummary:s.predecessorSummary}:{}})}catch(i){return this.emitEvent("artifact_summary_skipped",t,{runnerKind:r,reason:"unexpected_error",errorMessage:i instanceof Error?i.message:String(i)}),JSON.stringify(n)}}isContextManifestBudgetEnabled(){let{effectiveConfig:t}=this.config;if(!t)return!1;let r=li(t);return Sa(r,"context_manifest_budget")}isProgressiveEvaluatorEnabled(){let{effectiveConfig:t}=this.config;if(!t)return!1;let r=li(t);return Sa(r,"progressive_evaluator")}async runSingleEvaluation(t,r){let n=this.getRuntimeKind(),o=await this.runtimeAdapter.startRun({agentSpec:{agentId:this.resolvedOptions.agentId,schemaVersion:"v1"},taskRef:{taskId:t},inputPayload:r,contextItems:[],outputSchemaRef:this.config.resultRefPrefix.includes("evaluator")?"evaluator-output-v1":`${this.config.expectedTaskKind}-output-v1`,timeoutMs:this.resolvedOptions.timeoutMs});this.emitEvent("run_started",t,{runtimeKind:n,stage:"progressive_evaluation"});let i=await this.pollUntilTerminal(o);if(i.status!=="succeeded")throw new Ie(i.status==="timed_out"?"timeout":"execution_failed",`Progressive evaluation run ${o.runId} ended with status ${i.status}`);return this.fetchAndParseOutput(o.runId,t)}resolveContextInjection(t,r,n){if(!this.isContextManifestBudgetEnabled())return{mode:"disabled"};let o=DR(r),i=t1e(o,n),s=ZMe(r,i,c=>{c.type==="manifest_resolution_insufficient"?this.emitEvent("manifest_resolution_insufficient",t,{runnerKind:c.runnerKind,manifestId:c.manifestId,absentCount:c.absentCount,declaredCount:c.declaredCount,absentRatio:c.absentRatio,fallback:c.fallback}):this.emitEvent("context_truncated",t,{runnerKind:c.runnerKind,manifestId:c.manifestId,fieldPath:c.fieldPath,reason:c.reason,remainingBudgetTokens:c.remainingBudgetTokens})});return s.kind==="focused"?{mode:"focused",fields:s.allocated.fields}:{mode:"fallback"}}injectAgentDraftOnPermanentFailure(t){if(!this.pendingAgentDraftStore)return;let{taskKind:r}=t.task,{errorCategory:n}=t,o=t.failureReason,i=jf(Wf(qf(o))),a={summary:`${r} failed with category=${n} at ${new Date().toISOString()}`,observedFailure:i},s=J8t(t.task.diagnosticJson);try{let c=this.pendingAgentDraftStore.insertPendingDraft({taskId:t.taskId,painId:s??void 0,agentDraft:a});if(!c.ok){this.emitEvent("agent_draft_insert_failed",t.taskId,{errorCategory:n,attemptCount:t.task.attemptCount,errorMessage:c.error,nextAction:"Inspect pending_agent_drafts table integrity; draft will be retried on next permanent failure of the same taskId (idempotent UPDATE)."});return}this.emitEvent("agent_draft_inserted",t.taskId,{errorCategory:n,attemptCount:t.task.attemptCount,draftId:c.id,painIdLinked:s!==null})}catch(c){this.emitEvent("agent_draft_insert_failed",t.taskId,{errorCategory:n,attemptCount:t.task.attemptCount,errorMessage:c instanceof Error?c.message:String(c),nextAction:"PendingAgentDraftStore.insertPendingDraft threw unexpectedly; inspect the store implementation."})}}};var NN=class extends pi{validator;contextAssembler;effectiveConfig;intentDocReader;constructor(t,r){super(t,r,{runnerName:"diag_rootcause",expectedTaskKind:"diag_rootcause",defaultAgentId:"main",resultRefPrefix:"diag-rootcause",effectiveConfig:r.effectiveConfig}),this.validator=t.validator,this.contextAssembler=t.contextAssembler,this.effectiveConfig=r.effectiveConfig,this.intentDocReader=t.intentDocReader}get permanentErrorCategories(){return new Set(["storage_unavailable","workspace_invalid","capability_missing","cancelled","input_invalid"])}async buildContext(t){let r=await this.stateManager.getTask(t);if(!r)throw new Ie("input_invalid",`Task ${t} not found`);let n=r.inputRef||t,o=await this.contextAssembler.assemble(n),a=Pr(r)?.dependencyTaskIds??[],s=[...o.sourceRefs];if(a.length>0){let u=await Promise.allSettled(a.map(l=>this.stateManager.getTask(l)));for(let l=0;l<u.length;l++){let d=u[l],p=a[l];if(!(!d||p===void 0)&&d.status==="fulfilled"&&d.value){d.value.resultRef&&s.push(d.value.resultRef);let m=d.value?Pr(d.value):null;m?.outputArtifactRefs&&s.push(...m.outputArtifactRefs.map(f=>f.ref))}}}return{contextHash:pi.hashContextRefs(s),contextRefs:s,painPayload:o}}async invokeRuntime(t,r){let n=!1,o=!1,i=!1;if(this.effectiveConfig){let u=li(this.effectiveConfig);n=Sa(u,"diagnostician_core_grounding"),o=Sa(u,"intent_engineering"),i=Sa(u,"pain_diagnosis_persistence")}let a;if(o&&!this.intentDocReader)o=!1;else if(o&&this.intentDocReader){let u=this.intentDocReader.readIntentDoc();u.ok&&u.doc?a={raw:u.doc.raw,contentHash:u.doc.contentHash,path:u.doc.path}:(this.emitEvent("intent_doc_read_failed",t,{reason:u.reason??"unknown",nextAction:u.nextAction??"Check INTENT.md configuration.",flagEnabled:u.flagEnabled,found:u.found}),o=!1)}let s=new m5,{message:c}=s.buildPrompt(r.painPayload,{outputLanguage:this.resolvedOptions.outputLanguage,coreGrounding:n,intentGrounding:o,intentDoc:a,evidenceFirstAttribution:i});return this.runtimeAdapter.startRun({agentSpec:{agentId:this.resolvedOptions.agentId,schemaVersion:"v1"},taskRef:{taskId:t},inputPayload:c,contextItems:[],outputSchemaRef:"diag-rootcause-output-v1",timeoutMs:this.resolvedOptions.timeoutMs})}async validateOutput(t,r,n){let o=await this.validator.validate(t,r);return{valid:o.valid,errors:o.errors,errorCategory:o.errorCategory,warnings:o.warnings}}async succeedTask(t,r,n,o,i,a){try{await this.stateManager.updateRunOutput(r,JSON.stringify(n))}catch(p){throw this.emitEvent("update_output_failed",t,{runId:r,errorMessage:p instanceof Error?p.message:String(p)}),p}let s=[],c=!1;try{let p=await this.resolveLineageArtifactIds(t);s=p.ids,c=p.hasRejected}catch(p){this.emitEvent("lineage_resolve_failed",t,{runId:r,errorMessage:p instanceof Error?p.message:String(p)})}c&&this.emitEvent("lineage_partial",t,{runId:r,resolvedCount:s.length,warning:"Some dependency artifact queries were rejected; lineage may be incomplete"});let u=`pi-art-${t}-${r}`,l=new Date().toISOString();try{await this.artifactStore.upsertArtifact({artifactId:u,artifactKind:"principle",sourceTaskId:t,lineageArtifactIds:s,validationStatus:"pending",contentJson:this.buildArtifactContentJson(t,"diag_rootcause",n,null),createdAt:l,updatedAt:l})}catch(p){return this.emitEvent("artifact_write_failed",t,{runId:r,errorMessage:p instanceof Error?p.message:String(p)}),this.retryOrFail({taskId:t,task:o,errorCategory:"artifact_commit_failed",failureReason:`PIArtifact write failed: ${p instanceof Error?p.message:String(p)}`})}let d=`${this.config.resultRefPrefix}://${r}`;try{await this.stateManager.markTaskSucceeded(t,d)}catch(p){throw this.emitEvent("mark_succeeded_failed",t,{taskId:t,runId:r,errorMessage:p instanceof Error?p.message:String(p)}),p}return this.emitEvent("task_succeeded",t,{attemptCount:o.attemptCount,resultRef:d,rootCauseCategory:n.rootCauseCategory,causalChainDepth:n.causalChain.length}),{status:"succeeded",taskId:t,runId:r,artifactId:u,resultRef:d,contextHash:i,output:n,attemptCount:o.attemptCount}}postFetchTransform(t,r){pb(r,"taskId",t)}emitSuccessTelemetry(t,r,n){this.emitEvent("rootcause_completed",t,{rootCauseCategory:r.rootCauseCategory,causalChainDepth:r.causalChain.length})}};$s();var X8t=h.Union([h.Literal("general"),h.Literal("domain"),h.Literal("scenario")]),Gf=h.Object({valid:h.Boolean(),taskId:h.String({minLength:1}),sourceRootCauseArtifactId:h.String({minLength:1,description:"Lineage consistency check \u2014 must match the artifact ID from Stage A"}),abstractedPrinciple:h.String({minLength:1,maxLength:200,description:"Highly abstracted, cross-scenario principle (\u2264200 chars)"}),rationale:h.String({minLength:1,description:"Why this principle addresses the root cause"}),groundedOnCorePrincipleIds:h.Array(h.String({minLength:1}),{description:"Subset of T-01..T-10. Validated against registry \u2014 fabricated IDs cause validation failure."}),scope:X8t,confidence:h.Number({minimum:0,maximum:1}),ambiguityNotes:h.Optional(h.Array(h.String()))}),LN=class{async validate(t,r){let n=[],o=[];if(typeof t!="object"||t===null)return{valid:!1,errors:["Output is not an object"],errorCategory:"output_invalid"};let i=t;if(typeof i.taskId!="string"||i.taskId!==r){let a=["diag_rootcause-","diag_distiller-","diag_router-"],s=l=>{for(let d of a)if(l.startsWith(d))return l.slice(d.length);return l},c=s(r),u=typeof i.taskId=="string"?s(i.taskId):"";if(u!==""&&u===c){let l=i.taskId;i.taskId=r,o.push(`taskId re-injected: LLM output "${l}", corrected to "${r}" (ERR-008)`)}else n.push(`taskId mismatch: expected ${r}, got ${String(i.taskId)}`)}if(!wr.Check(Gf,t)){let s=[...wr.Errors(Gf,t)].map(c=>`${c.path}: ${c.message}`);n.push(...s)}if(Array.isArray(i.groundedOnCorePrincipleIds))for(let a of i.groundedOnCorePrincipleIds)typeof a=="string"&&!PR(a)&&n.push(`Fabricated axiom ID ${a} not in core principle registry`);return n.length>0?{valid:!1,errors:n,errorCategory:"output_invalid"}:{valid:!0,errors:[],warnings:o}}};function Y8t(e={}){let t=e.adapter??new $p,r=e.schema??Gf,{outputLanguage:n,coreGrounding:o}=e,i=t.generateExample(r),a=t.generateConstraints(r),s=Cg(n);return`You are a principle distiller. Your job is to abstract a specific root cause into a general, cross-scenario principle.
992
992
 
993
993
  INPUT:
994
994
  You will receive the Stage A root cause output as structured data. This contains:
@@ -2,7 +2,7 @@
2
2
  "id": "principles-disciple",
3
3
  "name": "Principles Disciple",
4
4
  "description": "Principles Disciple is an AI Agent Governance System. Stop correcting the same AI behavior across sessions. Turn repeated Agent corrections into Owner-approved, observable, reversible behavior principles.",
5
- "version": "1.219.1",
5
+ "version": "1.220.0",
6
6
  "activation": {
7
7
  "onCapabilities": [
8
8
  "hook"
@@ -2,7 +2,7 @@
2
2
  "id": "principles-disciple",
3
3
  "name": "Principles Disciple",
4
4
  "description": "Principles Disciple is an AI Agent Governance System. Stop correcting the same AI behavior across sessions. Turn repeated Agent corrections into Owner-approved, observable, reversible behavior principles.",
5
- "version": "1.219.1",
5
+ "version": "1.220.0",
6
6
  "activation": {
7
7
  "onCapabilities": [
8
8
  "hook"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "principles-disciple",
3
- "version": "1.219.1",
3
+ "version": "1.220.0",
4
4
  "description": "Principles Disciple is an AI Agent Governance System. Stop correcting the same AI behavior across sessions. Turn repeated Agent corrections into Owner-approved, observable, reversible behavior principles.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",