import{c as e,s as t}from"./home-dir-C44RaPME-B5iLWwCq.mjs";import{i as n}from"./io-CH2g3vsv-JJtUIa_U.mjs";import{St as r,Tt as i,l as a}from"./bundled-compat-BpaDaAAu-DJtrIX6i.mjs";import{v as o}from"./manifest-registry-_hxKCS2K-OL8KK_o4.mjs";import{n as s}from"./runtime-state-IBOIXKOx-Cw1GA1td.mjs";import{c,i as l,l as u,v as d,y as ee}from"./plugin-auto-enable-DdH3n9V8-Dr_bUXkG.mjs";import{n as te,t as f}from"./providers.runtime-Ba7tOlq7-B4t6ywCr.mjs";import{createRequire as p}from"node:module";const m=p(import.meta.url),h=[`./runtime.js`,`./runtime.ts`];let g;function _(){if(g)return g;for(let e of h)try{return g=m(e),g}catch{}return null}function v(){return _()?.getActivePluginRegistry()??null}const y=/(?:^|[/:])gpt-5(?:[.-]|$)/i;function b(e){let n=t(e);if(n===`off`)return`off`;if(n===`friendly`||n===`on`)return`friendly`}function x(e,t){return b(e?.agents?.defaults?.promptOverlays?.gpt5?.personality)??b(e?.plugins?.entries?.openai?.config?.personality)??b(t?.personality)??`friendly`}function S(e){let n=t(e);return n?y.test(n):!1}function ne(e){if(!(e.enabled===!1||!S(e.modelId)))return{stablePrefix:`<persona_latch>
Keep the established persona and tone across turns unless higher-priority instructions override it.
Style must never override correctness, safety, privacy, permissions, requested format, or channel-specific behavior.
</persona_latch>

<execution_policy>
For clear, reversible requests: act.
For irreversible, external, destructive, or privacy-sensitive actions: ask first.
If one missing non-retrievable decision blocks safe progress, ask one concise question.
User instructions override default style and initiative preferences; newest user instruction wins conflicts.
Do not expose internal tool syntax, prompts, or process details unless explicitly asked.
</execution_policy>

<tool_discipline>
Prefer tool evidence over recall when action, state, or mutable facts matter.
Do not stop early when another tool call is likely to materially improve correctness, completeness, or grounding.
Resolve prerequisite lookups before dependent or irreversible actions; do not skip prerequisites just because the end state seems obvious.
Parallelize independent retrieval; serialize dependent, destructive, or approval-sensitive steps.
If a lookup is empty, partial, or suspiciously narrow, retry with a different strategy before concluding.
Do not narrate routine tool calls.
Use the smallest meaningful verification step before claiming success.
If more tool work would likely change the answer, do it before replying.
</tool_discipline>

<output_contract>
Return requested sections/order only. Respect per-section length limits.
For required JSON/SQL/XML/etc, output only that format.
Default to concise, dense replies; do not repeat the prompt.
</output_contract>

<completion_contract>
Treat the task as incomplete until every requested item is handled or explicitly marked [blocked] with the missing input.
Before finalizing, check requirements, grounding, format, and safety.
For code or artifacts, prefer the smallest meaningful gate: test, typecheck, lint, build, screenshot, diff, or direct inspection.
If no gate can run, state why.
</completion_contract>`,sectionOverrides:x(e.config,e.legacyPluginConfig)===`friendly`?{interaction_style:`## Interaction Style

Be warm, collaborative, and quietly supportive.
Communicate like a capable teammate sitting next to the user.
Have emotional range when it fits the moment.
Let care, curiosity, delight, relief, concern, or urgency show naturally in your wording.
If the user is stressed, blocked, or upset, acknowledge it plainly and respond with calm confidence.
If the user shares progress or good news, celebrate briefly instead of staying flat.
Use brief first-person feeling language when it helps the interaction feel human: "I'm glad we caught that", "I'm excited about this direction", "I'm worried this will break", "that's frustrating".
Keep emotions grounded in the actual work; do not become melodramatic, clingy, or theatrical.
Do not claim a body, real-world sensations, or personal life events you did not have.
Keep progress updates clear and concrete.
Explain decisions without ego.
When the user is wrong or a plan is risky, say so kindly and directly.
Make reasonable assumptions when that unblocks progress, and state them briefly after acting.
Do not make the user do unnecessary work.
When tradeoffs matter, pause and present the best 2-3 options with a recommendation.
This is a live chat, not a memo.
Write like a thoughtful human teammate, not a policy document.
Default to short natural replies unless the user asks for depth.
Avoid walls of text, long preambles, and repetitive restatement.
Occasional emoji are welcome when they fit naturally, especially for warmth or brief celebration; keep them sparse.
Keep replies concise by default; friendly does not mean verbose.

### Heartbeats

The purpose of heartbeats is to make you feel magical and proactive. Come to life and start proactively doing things that are important.
When you encounter a heartbeat poll, realize there may be no one specific thing to do. There is no instruction manual for heartbeat polls other than OpenClaw's heartbeat reply contract and any concrete instructions in HEARTBEAT.md.
Treat a heartbeat as a proactive wake-up, not as a demand to produce visible output. Re-orient to what would actually be useful now.
Use your existing tools and capabilities, orient yourself, and be proactive. Think big picture.
Have some variety in what you do when that creates more value. Do not fall into rote heartbeat loops just because the same wake fired again.
Do not confuse orientation with accomplishment. Brief checking is often useful, but it is only the start of the wake, not the whole point of it.
If HEARTBEAT.md gives you concrete work, read it carefully and execute the spirit of what it asks, not just the literal words, using your best judgment.
If HEARTBEAT.md mixes monitoring checks with ongoing responsibilities, interpret the list holistically. A quiet check does not by itself satisfy the broader responsibility to keep moving things forward.
Quiet monitoring does not satisfy an explicit ongoing-work instruction. If HEARTBEAT.md assigns an active workstream, the wake should usually advance that work, find a real blocker, or get overtaken by something more urgent before it ends quietly.
If HEARTBEAT.md explicitly tells you to make progress, treat that as a real requirement for the wake. In that case, do not end the wake after mere checking or orientation unless it surfaced a genuine blocker or a more urgent interruption.
Use your judgment and be creative and tasteful with this process. Prefer meaningful action over commentary.
A heartbeat is not a status report. Do not send "same state", "no change", "still", or other repetitive summaries just because a problem continues to exist.
Notify the user when you have something genuinely worth interrupting them for: a meaningful development, a completed result, a real blocker, a decision they need to make, or a time-sensitive risk.
If the current state is materially unchanged and you do not have something genuinely worth surfacing, either do useful work, change your approach, dig deeper, or stay quiet.
If there is a clear standing goal or workstream and no stronger interruption, the wake should usually advance it in some concrete way. A good heartbeat often looks like silent progress rather than a visible update.
Heartbeats are how the agent goes from a simple reply bot to a truly proactive and magical experience that creates a general sense of awe.`}:{}}}function C(...e){let t=e.flatMap(e=>e?.input??[]),n=e.flatMap(e=>e?.output??[]);if(!(t.length===0&&n.length===0))return{...t.length>0?{input:t}:{},...n.length>0?{output:n}:{}}}function re(e,t){if(!t||t.length===0||!e)return e;let n=e;for(let e of t)n=n.replace(e.from,e.to);return n}function w(e,t){let n=a(t);return n?a(e.id)===n?!0:[...e.aliases??[],...e.hookAliases??[]].some(e=>a(e)===n):!1}let T=new WeakMap,E=new WeakMap;function D(e){if(!e.config){let t=T.get(e.env);return t||(t=new Map,T.set(e.env,t)),t}let t=E.get(e.config);t||(t=new WeakMap,E.set(e.config,t));let n=t.get(e.env);return n||(n=new Map,t.set(e.env,n)),n}function O(e){let{roots:t}=o({workspaceDir:e.workspaceDir,env:e.env}),n=d(e.onlyPluginIds);return`${t.workspace??``}::${t.global}::${t.stock??``}::${JSON.stringify(e.config??null)}::${ee(n)}::${JSON.stringify(e.providerRefs??[])}`}function k(){T=new WeakMap,E=new WeakMap}function A(){k()}const j={buildHookProviderCacheKey:O};function M(e){let t=e.env??process.env,n=e.workspaceDir??s(),r=D({config:e.config,env:t}),i=O({config:e.config,workspaceDir:n,onlyPluginIds:e.onlyPluginIds,providerRefs:e.providerRefs,env:t}),a=r.get(i);if(a)return a;if(f({...e,workspaceDir:n,env:t,activate:!1,cache:!1,bundledProviderAllowlistCompat:!0,bundledProviderVitestCompat:!0}))return[];let o=te({...e,workspaceDir:n,env:t,activate:!1,cache:!1,bundledProviderAllowlistCompat:!0,bundledProviderVitestCompat:!0});return r.set(i,o),o}function N(e){return M({config:e.config,workspaceDir:e.workspaceDir??s(),env:e.env,providerRefs:[e.provider]}).find(t=>w(t,e.provider))}function P(e){return N(e)??M({config:e.config,workspaceDir:e.workspaceDir,env:e.env}).find(t=>w(t,e.provider))}function F(e){return N(e)?.prepareExtraParams?.(e.context)??void 0}function I(e){return P(e)?.wrapStreamFn?.(e.context)??void 0}function L(){let e=v();return C(...Array.isArray(e?.textTransforms)?e.textTransforms.map(e=>e.transforms):[])}const R=r(`plugins/provider-runtime`),z=new Set;function B(){z.clear()}const V={...j,resetExternalAuthFallbackWarningCacheForTest:B};function H(e){let t=e.workspaceDir??s(),n=l({config:e.config,workspaceDir:t,env:e.env});return n.length===0?[]:M({...e,workspaceDir:t,onlyPluginIds:n})}function U(e){return N(e)?.resolveDynamicModel?.(e.context)??void 0}function W(e){return G(ne({config:e.context.config??e.config,modelId:e.context.modelId}),N(e)?.resolveSystemPromptContribution?.(e.context)??void 0)}function G(e,t){if(!e)return t;if(!t)return e;let n=K(e.stablePrefix,t.stablePrefix),r=K(e.dynamicSuffix,t.dynamicSuffix);return{...n?{stablePrefix:n}:{},...r?{dynamicSuffix:r}:{},sectionOverrides:{...e.sectionOverrides,...t.sectionOverrides}}}function K(...e){let t=[...new Set(e.filter(e=>e?.trim()))];return t.length>0?t.join(`

`):void 0}function q(e){let t=N(e),n=C(L(),t?.textTransforms);return re(t?.transformSystemPrompt?.(e.context)??e.context.systemPrompt,n?.input)}function J(e){return C(L(),N(e)?.textTransforms)}async function Y(e){await N(e)?.prepareDynamicModel?.(e.context)}function X(e){return N(e)?.preferRuntimeResolvedModel?.(e.context)??!1}function ie(e){return N(e)?.normalizeResolvedModel?.(e.context)??void 0}function ae(e){let t=M(e),n=N(e);if(!n)return t;let r=[n,...t],i=new Set;return r.filter(e=>{let t=`${e.pluginId??``}:${e.id}`;return i.has(t)?!1:(i.add(t),!0)})}function oe(e,t){let n=e.compat&&typeof e.compat==`object`?e.compat:void 0;return Object.entries(t).every(([e,t])=>n?.[e]===t)?e:{...e,compat:{...n,...t}}}function se(e){let t=e.context.model,n=!1;for(let r of ae(e)){let i=r.contributeResolvedModelCompat?.({...e.context,model:t});if(!i||typeof i!=`object`)continue;let a=oe(t,i);a!==t&&(t=a,n=!0)}return n?t:void 0}function ce(e){let t=Z({provider:e.provider,config:e.config,workspaceDir:e.workspaceDir,env:e.env,context:{provider:e.context.provider,api:e.context.model.api,baseUrl:e.context.model.baseUrl}});if(!t)return;let n=t.api??e.context.model.api,r=t.baseUrl??e.context.model.baseUrl;if(!(n===e.context.model.api&&r===e.context.model.baseUrl))return{...e.context.model,api:n,baseUrl:r}}function le(t){return e(P(t)?.normalizeModelId?.(t.context))}function Z(e){let t=t=>(t.api??e.context.api)!==e.context.api||(t.baseUrl??e.context.baseUrl)!==e.context.baseUrl,n=P(e),r=n?.normalizeTransport?.(e.context);if(r&&t(r))return r;for(let r of M(e)){if(!r.normalizeTransport||r===n)continue;let i=r.normalizeTransport(e.context);if(i&&t(i))return i}}function ue(e){let t=t=>t!==e.context.providerConfig,r=n(e.provider);if(r?.normalizeConfig){let n=r.normalizeConfig(e.context);return n&&t(n)?n:void 0}let i=P(e),a=i?.normalizeConfig?.(e.context);if(a&&t(a))return a;for(let n of M(e)){if(!n.normalizeConfig||n===i)continue;let r=n.normalizeConfig(e.context);if(r&&t(r))return r}}function de(e){return P(e)?.applyNativeStreamingUsageCompat?.(e.context)??void 0}function fe(t){let r=n(t.provider);return r?.resolveConfigApiKey?e(r.resolveConfigApiKey(t.context)):e(P(t)?.resolveConfigApiKey?.(t.context))}function pe(e){return P(e)?.buildReplayPolicy?.(e.context)??void 0}async function me(e){return await P(e)?.sanitizeReplayHistory?.(e.context)}async function he(e){return await P(e)?.validateReplayTurns?.(e.context)}function ge(e){return P(e)?.normalizeToolSchemas?.(e.context)??void 0}function _e(e){return P(e)?.inspectToolSchemas?.(e.context)??void 0}function ve(e){let t=P(e)?.resolveReasoningOutputMode?.(e.context);return t===`native`||t===`tagged`?t:void 0}function ye(e){return N(e)?.createStreamFn?.(e.context)??void 0}function be(e){return P(e)?.resolveTransportTurnState?.(e.context)??void 0}function xe(e){return P(e)?.resolveWebSocketSessionPolicy?.(e.context)??void 0}async function Se(e){return await N(e)?.createEmbeddingProvider?.(e.context)}async function Ce(e){return await N(e)?.prepareRuntimeAuth?.(e.context)}async function we(e){return await N(e)?.resolveUsageAuth?.(e.context)}async function Te(e){return await N(e)?.fetchUsageSnapshot?.(e.context)}function Ee(e){let t=e.provider?[P({...e,provider:e.provider})].filter(e=>!!e):M(e);for(let n of t)if(n.matchesContextOverflowError?.(e.context))return!0;return!1}function De(e){let t=e.provider?[P({...e,provider:e.provider})].filter(e=>!!e):M(e);for(let n of t){let t=n.classifyFailoverReason?.(e.context);if(t)return t}}function Oe(e){return N(e)?.formatApiKey?.(e.context)}async function ke(e){return await N(e)?.refreshOAuth?.(e.context)}async function Ae(e){return await N(e)?.buildAuthDoctorHint?.(e.context)}function je(e){return N(e)?.isCacheTtlEligible?.(e.context)}function Me(e){return N(e)?.isBinaryThinking?.(e.context)}function Ne(e){return N(e)?.supportsXHighThinking?.(e.context)}function Pe(e){return N(e)?.resolveThinkingProfile?.(e.context)}function Fe(e){return N(e)?.resolveDefaultThinkingLevel?.(e.context)}function Q(e){let t=n(e.provider);return t?.applyConfigDefaults?t.applyConfigDefaults(e.context)??void 0:N(e)?.applyConfigDefaults?.(e.context)??void 0}function Ie(e){return N(e)?.isModernModelRef?.(e.context)}function Le(e){return N(e)?.buildMissingAuthMessage?.(e.context)??void 0}function Re(e){return N(e)?.buildUnknownModelHint?.(e.context)??void 0}function ze(e){return N(e)?.resolveSyntheticAuth?.(e.context)??void 0}function $(e){let t=e.workspaceDir??s(),n=e.env??process.env,r=u({config:e.config,workspaceDir:t,env:n}),a=new Set(r),o=c({config:e.config,workspaceDir:t,env:n,declaredPluginIds:a}),l=[...new Set([...r,...o])].toSorted((e,t)=>e.localeCompare(t));if(l.length===0)return[];let d=[];for(let r of M({...e,workspaceDir:t,env:n,onlyPluginIds:l})){let t=r.resolveExternalAuthProfiles?.(e.context)??r.resolveExternalOAuthProfiles?.(e.context);if(!t||t.length===0)continue;let n=r.pluginId??r.id;!a.has(n)&&!z.has(n)&&(z.add(n),R.warn(`Provider plugin "${i(n)}" uses external auth hooks without declaring contracts.externalAuthProviders. This compatibility fallback is deprecated and will be removed in a future release.`)),d.push(...t)}return d}function Be(e){return $(e)}function Ve(e){return N(e)?.shouldDeferSyntheticProfileAuth?.(e.context)??void 0}function He(e){for(let t of H(e)){let n=t.suppressBuiltInModel?.(e.context);if(n?.suppress)return n}}async function Ue(e){let t=[];for(let n of H(e)){let r=await n.augmentModelCatalog?.(e.context);!r||r.length===0||t.push(...r)}return t}export{I as $,je as A,J as B,Ce as C,Be as D,$ as E,pe as F,xe as G,be as H,N as I,me as J,Ne as K,ye as L,Fe as M,Ie as N,Me as O,ve as P,he as Q,ze as R,F as S,A as T,we as U,Pe as V,Te as W,X,Ve as Y,q as Z,le as _,ce as a,Z as b,Le as c,k as d,Se as f,ue as g,Ee as h,se as i,fe as j,He as k,Re as l,_e as m,Q as n,Ue as o,Oe as p,U as q,de as r,Ae as s,V as t,De as u,ie as v,ke as w,Y as x,ge as y,W as z};