@humain/humain-code 0.8.1 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/dist/bundle/chunks/{chunk-E7OBH44W.js → chunk-2XD7TLKB.js} +6 -6
- package/dist/bundle/chunks/{chunk-3CGMVKHA.js → chunk-3E37CJCE.js} +1 -1
- package/dist/bundle/chunks/{chunk-ROFZVEFN.js → chunk-4GB7A76U.js} +77 -72
- package/dist/bundle/chunks/{chunk-P2Y2H7SD.js → chunk-6JTCRCNF.js} +2 -2
- package/dist/bundle/chunks/{chunk-6TTMNQXI.js → chunk-7LSTTCSC.js} +145 -120
- package/dist/bundle/chunks/{chunk-QRRVZYTG.js → chunk-AW24RHGJ.js} +2 -2
- package/dist/bundle/chunks/{chunk-7X6DNT45.js → chunk-B3ZLWVDA.js} +8 -6
- package/dist/bundle/chunks/{chunk-APNPBT7Y.js → chunk-BRSLXHED.js} +1 -1
- package/dist/bundle/chunks/{chunk-KONLZKPL.js → chunk-E4VUW4RI.js} +1 -1
- package/dist/bundle/chunks/{chunk-NICPFMOP.js → chunk-JKX5EGOT.js} +1 -1
- package/dist/bundle/chunks/{chunk-D3KYOSQY.js → chunk-JSHKS7VH.js} +1 -1
- package/dist/bundle/chunks/{chunk-SXOIQWNX.js → chunk-JX6YIPNK.js} +1 -1
- package/dist/bundle/chunks/{chunk-WBSGWISD.js → chunk-M5TVWJ5T.js} +5 -4
- package/dist/bundle/chunks/{chunk-XZ7FTBXS.js → chunk-MUN4ZZZP.js} +1189 -1195
- package/dist/bundle/chunks/{chunk-CQ2CE3RB.js → chunk-QFDZEUFU.js} +2 -2
- package/dist/bundle/chunks/{chunk-DD5UT56Y.js → chunk-R2KD2HFT.js} +67 -66
- package/dist/bundle/chunks/chunk-S2US54IU.js +37 -0
- package/dist/bundle/chunks/{chunk-IMUFBWEK.js → chunk-T2ZGMEMV.js} +42 -41
- package/dist/bundle/chunks/{chunk-FQ4KS5S4.js → chunk-UZOIHLNU.js} +1 -1
- package/dist/bundle/chunks/{chunk-6YVORXTX.js → chunk-VSXVZVBE.js} +253 -232
- package/dist/bundle/chunks/{chunk-P42E6YY6.js → chunk-ZAHVC5V2.js} +206 -194
- package/dist/bundle/chunks/{chunk-DJG2WUNM.js → chunk-ZSWU5KKA.js} +1 -1
- package/dist/bundle/chunks/{compat-SRCNS6OQ.js → compat-4ILE5BEC.js} +1 -1
- package/dist/bundle/chunks/{dist-TRAK7EXI.js → dist-I6CI3CG5.js} +6 -6
- package/dist/bundle/chunks/{dist-4OMLHRJE.js → dist-NXHRL2KY.js} +1 -1
- package/dist/bundle/chunks/{easter-egg-3d-VVUF3C3X.js → easter-egg-3d-VZC5WOYV.js} +1 -1
- package/dist/bundle/chunks/{entry-SRYLSS5P.js → entry-6XDR2IDE.js} +1 -1
- package/dist/bundle/chunks/{execute-I3WGGPWL.js → execute-6MEJJF2T.js} +2 -2
- package/dist/bundle/chunks/{flow-implementer-4KO3Q4B5.js → flow-implementer-XOP4MG5X.js} +4 -4
- package/dist/bundle/chunks/{inprocess-TOBRVK4C.js → inprocess-MBKFGDM2.js} +4 -4
- package/dist/bundle/chunks/{interactive-mode-BJJKPBXD.js → interactive-mode-3322RQEH.js} +2 -2
- package/dist/bundle/chunks/{session-picker-4JQEGLDD.js → session-picker-EYKCMFQR.js} +1 -1
- package/dist/bundle/chunks/{startup-ui-AKTA4NDP.js → startup-ui-7ODOR34R.js} +2 -2
- package/dist/bundle/chunks/{trace-command-7ORDQ3JS.js → trace-command-VM7FBWPE.js} +4 -4
- package/dist/bundle/chunks/{virtual-modules-3CT5BMBA.js → virtual-modules-47MGUPYN.js} +8 -8
- package/dist/bundle/cli-runtime.js +3 -3
- package/dist/bundle/index.js +8 -8
- package/dist/bundle/rpc-entry.js +3 -3
- package/dist/coordination/adapter/delivery.d.ts +27 -0
- package/dist/coordination/adapter/delivery.d.ts.map +1 -1
- package/dist/coordination/adapter/delivery.js +164 -4
- package/dist/coordination/adapter/delivery.js.map +1 -1
- package/dist/coordination/adapter/index.d.ts.map +1 -1
- package/dist/coordination/adapter/index.js +31 -5
- package/dist/coordination/adapter/index.js.map +1 -1
- package/dist/coordination/adapter/presence.d.ts +5 -0
- package/dist/coordination/adapter/presence.d.ts.map +1 -1
- package/dist/coordination/adapter/presence.js +25 -3
- package/dist/coordination/adapter/presence.js.map +1 -1
- package/dist/coordination/adapter/question-routing.d.ts +7 -0
- package/dist/coordination/adapter/question-routing.d.ts.map +1 -0
- package/dist/coordination/adapter/question-routing.js +40 -0
- package/dist/coordination/adapter/question-routing.js.map +1 -0
- package/dist/coordination/adapter/receipts.d.ts +7 -0
- package/dist/coordination/adapter/receipts.d.ts.map +1 -1
- package/dist/coordination/adapter/receipts.js +25 -2
- package/dist/coordination/adapter/receipts.js.map +1 -1
- package/dist/coordination/adapter/tool.d.ts +19 -3
- package/dist/coordination/adapter/tool.d.ts.map +1 -1
- package/dist/coordination/adapter/tool.js +93 -19
- package/dist/coordination/adapter/tool.js.map +1 -1
- package/dist/coordination/client/client.d.ts +2 -2
- package/dist/coordination/client/client.d.ts.map +1 -1
- package/dist/coordination/client/client.js +4 -0
- package/dist/coordination/client/client.js.map +1 -1
- package/dist/coordination/transport/protocol.d.ts.map +1 -1
- package/dist/coordination/transport/protocol.js +23 -0
- package/dist/coordination/transport/protocol.js.map +1 -1
- package/dist/coordination/transport/types.d.ts +11 -1
- package/dist/coordination/transport/types.d.ts.map +1 -1
- package/dist/coordination/transport/types.js.map +1 -1
- package/dist/core/model-resolver.js +2 -2
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +14 -8
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/oauth-account-pool.d.ts +14 -0
- package/dist/core/oauth-account-pool.d.ts.map +1 -1
- package/dist/core/oauth-account-pool.js +166 -14
- package/dist/core/oauth-account-pool.js.map +1 -1
- package/dist/core/run-outcome.d.ts +1 -1
- package/dist/core/run-outcome.d.ts.map +1 -1
- package/dist/core/run-outcome.js +2 -2
- package/dist/core/run-outcome.js.map +1 -1
- package/dist/core/run-preflight.d.ts.map +1 -1
- package/dist/core/run-preflight.js +15 -8
- package/dist/core/run-preflight.js.map +1 -1
- package/dist/core/settings-manager.d.ts +4 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +17 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-schema.d.ts +2 -0
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +10 -0
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/extensions/usage/index.js +5 -5
- package/dist/extensions/usage/index.js.map +1 -1
- package/dist/humain/gateway/client.d.ts.map +1 -1
- package/dist/humain/gateway/client.js +36 -9
- package/dist/humain/gateway/client.js.map +1 -1
- package/dist/humain/gateway/http.d.ts.map +1 -1
- package/dist/humain/gateway/http.js +26 -6
- package/dist/humain/gateway/http.js.map +1 -1
- package/dist/humain/gateway/provider.d.ts.map +1 -1
- package/dist/humain/gateway/provider.js +9 -2
- package/dist/humain/gateway/provider.js.map +1 -1
- package/dist/humain/hcode/facade.d.ts +12 -1
- package/dist/humain/hcode/facade.d.ts.map +1 -1
- package/dist/humain/hcode/facade.js +35 -8
- package/dist/humain/hcode/facade.js.map +1 -1
- package/dist/humain/hcode/login-copy.d.ts.map +1 -1
- package/dist/humain/hcode/login-copy.js +10 -0
- package/dist/humain/hcode/login-copy.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +2 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +6 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +26 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +35 -1
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +179 -3
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/working-indicator-engine.d.ts +32 -0
- package/dist/modes/interactive/components/working-indicator-engine.d.ts.map +1 -0
- package/dist/modes/interactive/components/working-indicator-engine.js +112 -0
- package/dist/modes/interactive/components/working-indicator-engine.js.map +1 -0
- package/dist/modes/interactive/fullscreen.d.ts +13 -0
- package/dist/modes/interactive/fullscreen.d.ts.map +1 -0
- package/dist/modes/interactive/fullscreen.js +25 -0
- package/dist/modes/interactive/fullscreen.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +4 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +117 -19
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/humain-dark.json +5 -4
- package/dist/modes/interactive/theme/humain-light.json +6 -5
- package/docs/cli.md +6 -0
- package/docs/coordination.md +16 -4
- package/docs/development.md +7 -0
- package/docs/environment-variables.md +2 -1
- package/docs/providers.md +19 -5
- package/docs/settings.md +20 -0
- package/docs/usage.md +2 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/schemas/settings.schema.json +29 -0
- package/dist/bundle/chunks/chunk-UEW6TUSP.js +0 -36
- package/dist/bundle/chunks/chunk-YPZPCHNV.js +0 -3
|
@@ -197,47 +197,48 @@ parsed))throw new Error("Invalid settings object");let currentFileSettings=_Sett
|
|
|
197
197
|
for(let nestedKey of nestedModified)if(field==="oauthAccounts"&&nestedKey==="providers"){let providers=isMergeableObject(baseNested.providers)?{...baseNested.providers}:{};for(let[provider,policy]of Object.entries(snapshotSettings.oauthAccounts?.providers??{}))providers[provider]={...isMergeableObject(providers[provider])?providers[provider]:{},...policy};mergedNested.providers=providers}else mergedNested[nestedKey]=inMemoryNested[nestedKey];mergedSettings[field]=mergedNested}else mergedSettings[field]=
|
|
198
198
|
value}return JSON.stringify(mergedSettings,null,2)},{write:!0})}save(){if(this.settings=deepMergeSettings(this.globalSettings,this.projectSettings),this.globalSettingsLoadError)return;let snapshotGlobalSettings=structuredClone(this.globalSettings),modifiedFields=new Set(this.modifiedFields),modifiedNestedFields=this.cloneModifiedNestedFields(this.modifiedNestedFields);this.enqueueWrite("global",()=>{this.persistScopedSettings("global",snapshotGlobalSettings,modifiedFields,modifiedNestedFields)})}saveProjectSettings(settings){
|
|
199
199
|
if(this.assertProjectTrustedForWrite(),this.projectSettings=structuredClone(settings),this.settings=deepMergeSettings(this.globalSettings,this.projectSettings),this.projectSettingsLoadError)return;let snapshotProjectSettings=structuredClone(this.projectSettings),modifiedFields=new Set(this.modifiedProjectFields),modifiedNestedFields=this.cloneModifiedNestedFields(this.modifiedProjectNestedFields);this.enqueueWrite("project",()=>{this.persistScopedSettings("project",snapshotProjectSettings,modifiedFields,
|
|
200
|
-
modifiedNestedFields)})}updateProjectSettings(field,update){this.assertProjectTrustedForWrite();let projectSettings=structuredClone(this.projectSettings);update(projectSettings),this.markProjectModified(field),this.saveProjectSettings(projectSettings)}async flush(){await this.writeQueue}drainErrors(){let drained=[...this.errors];return this.errors=[],drained}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
this.globalSettings.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
setting: ${String(override)}. Expected ${range2}.`);return override??ordinary}getCompactionReserveTokens(model){return this.
|
|
212
|
-
|
|
213
|
-
model,
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
SETTINGS_DEFAULTS.
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
this.globalSettings.
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
(this.
|
|
234
|
-
markModified("
|
|
235
|
-
|
|
236
|
-
this.globalSettings.
|
|
237
|
-
|
|
238
|
-
terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.
|
|
239
|
-
|
|
240
|
-
|
|
200
|
+
modifiedNestedFields)})}updateProjectSettings(field,update){this.assertProjectTrustedForWrite();let projectSettings=structuredClone(this.projectSettings);update(projectSettings),this.markProjectModified(field),this.saveProjectSettings(projectSettings)}async flush(){await this.writeQueue}drainErrors(){let drained=[...this.errors];return this.errors=[],drained}getWorkingIndicator(){let value=this.settings.workingIndicator;return value==="classic"||value==="life"||value==="rain"||value==="decode"?value:
|
|
201
|
+
"rotate"}setWorkingIndicator(value){this.globalSettings.workingIndicator=value,this.markModified("workingIndicator"),this.save()}getReducedMotion(){return this.settings.reducedMotion===!0}setReducedMotion(value){this.globalSettings.reducedMotion=value,this.markModified("reducedMotion"),this.save()}getLastChangelogVersion(){return this.settings.lastChangelogVersion}setLastChangelogVersion(version){this.globalSettings.lastChangelogVersion=version,this.markModified("lastChangelogVersion"),this.save()}getExtensionChangelogVersion(key){
|
|
202
|
+
return this.settings.extensionChangelogVersions?.[key]}setExtensionChangelogVersion(key,version){this.globalSettings.extensionChangelogVersions={...this.globalSettings.extensionChangelogVersions??{},[key]:version},this.markModified("extensionChangelogVersions",key),this.save()}getSessionDir(){let sessionDir=this.settings.sessionDir;return sessionDir&&normalizePath(sessionDir)}getDefaultProvider(){return this.settings.defaultProvider}getDefaultModel(){return this.settings.defaultModel}setDefaultProvider(provider){
|
|
203
|
+
this.globalSettings.defaultProvider=provider,this.markModified("defaultProvider"),this.save()}setDefaultModel(modelId){this.globalSettings.defaultModel=modelId,this.markModified("defaultModel"),this.save()}setDefaultModelAndProvider(provider,modelId){this.globalSettings.defaultProvider=provider,this.globalSettings.defaultModel=modelId,this.markModified("defaultProvider"),this.markModified("defaultModel"),this.save()}getModelProfiles(){return this.settings.modelProfiles??[]}setModelProfiles(profiles){
|
|
204
|
+
this.globalSettings.modelProfiles=structuredClone(profiles),this.markModified("modelProfiles"),this.save()}getSteeringMode(){return this.settings.steeringMode||SETTINGS_DEFAULTS.steeringMode}setSteeringMode(mode){this.globalSettings.steeringMode=mode,this.markModified("steeringMode"),this.save()}getFollowUpMode(){return this.settings.followUpMode||SETTINGS_DEFAULTS.followUpMode}setFollowUpMode(mode){this.globalSettings.followUpMode=mode,this.markModified("followUpMode"),this.save()}getThemeSetting(){
|
|
205
|
+
let value=this.settings.theme;if(typeof value=="string")return value}getTheme(){let theme=this.getThemeSetting();return theme?.includes("/")?void 0:theme}setTheme(theme){this.globalSettings.theme=theme,this.markModified("theme"),this.save()}getDefaultThinkingLevel(){return this.settings.defaultThinkingLevel}setDefaultThinkingLevel(level){this.globalSettings.defaultThinkingLevel=level,this.markModified("defaultThinkingLevel"),this.save()}getModelThinkingLevel(provider,modelId){return this.settings.
|
|
206
|
+
modelThinkingLevels?.[`${provider}/${modelId}`]}getAllModelThinkingLevels(){return{...this.settings.modelThinkingLevels??{}}}setModelThinkingLevel(provider,modelId,level){this.globalSettings.modelThinkingLevels||(this.globalSettings.modelThinkingLevels={}),this.globalSettings.modelThinkingLevels[`${provider}/${modelId}`]=level,this.markModified("modelThinkingLevels"),this.save()}removeModelThinkingLevel(provider,modelId){this.globalSettings.modelThinkingLevels&&(delete this.globalSettings.modelThinkingLevels[`${provider}\
|
|
207
|
+
/${modelId}`],Object.keys(this.globalSettings.modelThinkingLevels).length===0&&delete this.globalSettings.modelThinkingLevels,this.markModified("modelThinkingLevels"),this.save())}getTransport(){return this.settings.transport??SETTINGS_DEFAULTS.transport}setTransport(transport){this.globalSettings.transport=transport,this.markModified("transport"),this.save()}getAutoSessionNamerEnabled(){return this.settings.autoSessionNamer?.enabled!==!1}setAutoSessionNamerEnabled(enabled){this.globalSettings.autoSessionNamer=
|
|
208
|
+
{...this.globalSettings.autoSessionNamer,enabled},this.markModified("autoSessionNamer","enabled"),this.save()}getAutoEffortEnabled(){return this.settings.autoEffort?.enabled===!0}setAutoEffortEnabled(enabled){this.globalSettings.autoEffort={...this.globalSettings.autoEffort,enabled},this.markModified("autoEffort","enabled"),this.save()}getSessionShareDestination(){let destination=this.settings.sessionShareDestination;return destination==="gist"||destination==="radius"?destination:SETTINGS_DEFAULTS.
|
|
209
|
+
sessionShareDestination}setSessionShareDestination(destination){this.globalSettings.sessionShareDestination=destination,this.markModified("sessionShareDestination"),this.save()}getCompactionEnabled(){return this.settings.compaction?.enabled??SETTINGS_DEFAULTS.compaction.enabled}setCompactionEnabled(enabled){this.globalSettings.compaction||(this.globalSettings.compaction={}),this.globalSettings.compaction.enabled=enabled,this.markModified("compaction","enabled"),this.save()}getExplicitCompactionSetting(field,model){
|
|
210
|
+
let{min,max}=COMPACTION_SETTING_RANGES[field],range2=min===0&&max===Number.MAX_SAFE_INTEGER?"a non-negative safe integer":`an integer from ${min} to ${max}`,isValid=value=>typeof value=="number"&&Number.isSafeInteger(value)&&value>=min&&value<=max,compaction=this.settings.compaction,ordinary=compaction?.[field];if(ordinary!==void 0&&!isValid(ordinary))throw new Error(`Invalid compaction.${field} setting: ${String(ordinary)}. Expected ${range2}.`);let modelKey=model?`${model.provider}/${model.id}`:
|
|
211
|
+
void 0,entry=modelKey!==void 0?compaction?.modelOverrides?.[modelKey]:void 0;if(entry!==void 0&&!isMergeableObject(entry))throw new Error(`Invalid compaction.modelOverrides["${modelKey}"] setting: ${String(entry)}. Expected an object.`);let override=entry?.[field];if(override!==void 0&&!isValid(override))throw new Error(`Invalid compaction.modelOverrides["${modelKey}"].${field} setting: ${String(override)}. Expected ${range2}.`);return override??ordinary}getCompactionReserveTokens(model){return this.
|
|
212
|
+
getExplicitCompactionSetting("reserveTokens",model)??SETTINGS_DEFAULTS.compaction.reserveTokens}getCompactionKeepRecentTokens(model,contextWindow=model?.contextWindow??0){return this.getExplicitCompactionSetting("keepRecentTokens",model)??Math.max(SETTINGS_DEFAULTS.compaction.keepRecentTokens,Math.floor(Math.max(contextWindow,0)*KEEP_RECENT_WINDOW_PERCENT/100))}getCompactionSettings(model,contextWindow=model?.contextWindow??0){let explicitReserveTokens=this.getExplicitCompactionSetting("reserveT\
|
|
213
|
+
okens",model),thresholdPercent=this.getExplicitCompactionSetting("thresholdPercent",model)??(explicitReserveTokens===void 0?SETTINGS_DEFAULTS.compaction.thresholdPercent:void 0),summaryMaxTokens=this.getExplicitCompactionSetting("summaryMaxTokens",model);return{enabled:this.getCompactionEnabled(),reserveTokens:explicitReserveTokens??SETTINGS_DEFAULTS.compaction.reserveTokens,keepRecentTokens:this.getCompactionKeepRecentTokens(model,contextWindow),...thresholdPercent===void 0?{}:{thresholdPercent},
|
|
214
|
+
...summaryMaxTokens===void 0?{}:{summaryMaxTokens},...explicitReserveTokens===void 0&&summaryMaxTokens===void 0?{scaleSummaryWithContextWindow:!0}:{}}}getBranchSummarySettings(){return{reserveTokens:this.settings.branchSummary?.reserveTokens??SETTINGS_DEFAULTS.branchSummary.reserveTokens,skipPrompt:this.settings.branchSummary?.skipPrompt??SETTINGS_DEFAULTS.branchSummary.skipPrompt}}getBranchSummarySkipPrompt(){return this.settings.branchSummary?.skipPrompt??SETTINGS_DEFAULTS.branchSummary.skipPrompt}getRetryEnabled(){
|
|
215
|
+
return this.settings.retry?.enabled??SETTINGS_DEFAULTS.retry.enabled}setRetryEnabled(enabled){this.globalSettings.retry||(this.globalSettings.retry={}),this.globalSettings.retry.enabled=enabled,this.markModified("retry","enabled"),this.save()}getRetrySettings(){return{enabled:this.getRetryEnabled(),maxRetries:this.settings.retry?.maxRetries??SETTINGS_DEFAULTS.retry.maxRetries,baseDelayMs:this.settings.retry?.baseDelayMs??SETTINGS_DEFAULTS.retry.baseDelayMs,maxAgentDelayMs:this.settings.retry?.maxAgentDelayMs??
|
|
216
|
+
SETTINGS_DEFAULTS.retry.maxAgentDelayMs}}getOAuthAccountsAutoSwitch(providerId){let providers=this.settings.oauthAccounts?.providers,override=providerId&&providers&&Object.hasOwn(providers,providerId)?providers[providerId]?.autoSwitch:void 0,value=override===void 0?this.settings.oauthAccounts?.autoSwitch:override;return value===void 0?!0:value===!0}getOAuthAccountApiKeyFallback(providerId){let providers=this.globalSettings.oauthAccounts?.providers,key=providers&&Object.hasOwn(providers,providerId)?
|
|
217
|
+
providers[providerId]?.apiKeyFallback:void 0;return typeof key=="string"&&key.trim()&&key.length<=320&&!/[\p{Cc}\p{Cf}]/u.test(key)&&!(key in Object.prototype)?key:void 0}readOAuthAccountActivationPolicy(providerId){let loaded=_SettingsManager.tryLoadFromStorage(this.storage,"global");if(loaded.error)throw this.recordError("global",loaded.error),new Error("Could not read account policy");let accounts=loaded.settings.oauthAccounts,stored=accounts?.providers&&Object.hasOwn(accounts.providers,providerId)?
|
|
218
|
+
accounts.providers[providerId]:void 0,flag=stored?.autoSwitch===void 0?accounts?.autoSwitch:stored.autoSwitch,autoSwitch=(flag===void 0||flag===!0)&&this.getOAuthAccountsAutoSwitch(providerId),apiKeyFallback=this.getOAuthAccountApiKeyFallback(providerId);stored?.apiKeyFallback!==apiKeyFallback&&(apiKeyFallback=void 0);for(let pending of this.pendingAccountPolicies)pending.providerId===providerId&&(pending.policy.autoSwitch===!1&&(autoSwitch=!1),Object.hasOwn(pending.policy,"apiKeyFallback")&&pending.
|
|
219
|
+
policy.apiKeyFallback!==apiKeyFallback&&(apiKeyFallback=void 0));return{autoSwitch,apiKeyFallback}}setOAuthAccountProviderPolicy(providerId,policy){if(!providerId.trim()||providerId in Object.prototype||/[\p{Cc}\p{Cf}]/u.test(providerId))throw new Error("Invalid account policy provider");if(policy.autoSwitch!==void 0&&typeof policy.autoSwitch!="boolean")throw new Error("Invalid account auto-switch policy");let key=policy.apiKeyFallback;if(key!=null&&(typeof key!="string"||!key.trim()||key.length>
|
|
220
|
+
320||/[\p{Cc}\p{Cf}]/u.test(key)||key in Object.prototype))throw new Error("Invalid account fallback target");if(this.globalSettingsLoadError)throw new Error("Could not save account policy");let changes={...Object.hasOwn(policy,"autoSwitch")?{autoSwitch:policy.autoSwitch}:{},...Object.hasOwn(policy,"apiKeyFallback")?{apiKeyFallback:policy.apiKeyFallback}:{}},snapshot={oauthAccounts:{providers:{[providerId]:changes}}},pending={providerId,policy:changes};return this.pendingAccountPolicies.add(pending),
|
|
221
|
+
this.enqueueWrite("global",()=>{this.globalSettings.oauthAccounts??={};let accounts=this.globalSettings.oauthAccounts;accounts.providers??={};let providers=accounts.providers,previous=providers[providerId];providers[providerId]={...previous,...changes};try{this.persistScopedSettings("global",snapshot,new Set(["oauthAccounts"]),new Map([["oauthAccounts",new Set(["providers"])]]))}catch(error){let stored=_SettingsManager.tryLoadFromStorage(this.storage,"global"),restored=stored.error?previous:stored.
|
|
222
|
+
settings.oauthAccounts?.providers?.[providerId];throw restored===void 0?delete providers[providerId]:providers[providerId]=restored,error}finally{this.settings=deepMergeSettings(this.globalSettings,this.projectSettings)}},!1).then(failure=>{if(failure)throw new Error("Could not save account policy")}).finally(()=>{this.pendingAccountPolicies.delete(pending)})}getExplicitNoProgressTimeoutMs(){let value=this.settings.noProgressTimeoutMs;return value===void 0?void 0:validateNoProgressTimeoutMs(value)}getNoProgressTimeoutMs(){
|
|
223
|
+
return this.getExplicitNoProgressTimeoutMs()??SETTINGS_DEFAULTS.noProgressTimeoutMs}setNoProgressTimeoutMs(timeoutMs){this.globalSettings.noProgressTimeoutMs=validateNoProgressTimeoutMs(timeoutMs),this.markModified("noProgressTimeoutMs"),this.save()}getHttpIdleTimeoutMs(){return parseTimeoutSetting(this.settings.httpIdleTimeoutMs,"httpIdleTimeoutMs")??DEFAULT_HTTP_IDLE_TIMEOUT_MS}setHttpIdleTimeoutMs(timeoutMs){if(!Number.isFinite(timeoutMs)||timeoutMs<0)throw new Error(`Invalid httpIdleTimeoutM\
|
|
224
|
+
s setting: ${String(timeoutMs)}`);this.globalSettings.httpIdleTimeoutMs=Math.floor(timeoutMs),this.markModified("httpIdleTimeoutMs"),this.save()}getCacheWarmingMode(){let mode=this.globalSettings.cacheWarming;return mode!==void 0&&CACHE_WARMING_MODES.includes(mode)?mode:SETTINGS_DEFAULTS.cacheWarming}setCacheWarmingMode(mode){this.globalSettings.cacheWarming=mode,this.markModified("cacheWarming"),this.save()}getProviderRetrySettings(){return{timeoutMs:this.settings.retry?.provider?.timeoutMs,maxRetries:this.
|
|
225
|
+
settings.retry?.provider?.maxRetries,maxRetryDelayMs:this.settings.retry?.provider?.maxRetryDelayMs??SETTINGS_DEFAULTS.retry.provider.maxRetryDelayMs}}getWebSocketConnectTimeoutMs(){return parseTimeoutSetting(this.settings.websocketConnectTimeoutMs,"websocketConnectTimeoutMs")}getHideThinkingBlock(){return this.settings.hideThinkingBlock??SETTINGS_DEFAULTS.hideThinkingBlock}getShowCacheMissNotices(){return this.settings.showCacheMissNotices??SETTINGS_DEFAULTS.showCacheMissNotices}getExternalEditorCommand(){
|
|
226
|
+
let configuredEditor=this.settings.externalEditor;if(typeof configuredEditor=="string"&&configuredEditor.trim()!=="")return configuredEditor;let environmentEditor=process.env.VISUAL||process.env.EDITOR;return environmentEditor||(process.platform==="win32"?"notepad":"nano")}setHideThinkingBlock(hide){this.globalSettings.hideThinkingBlock=hide,this.markModified("hideThinkingBlock"),this.save()}setShowCacheMissNotices(show2){this.globalSettings.showCacheMissNotices=show2,this.markModified("showCach\
|
|
227
|
+
eMissNotices"),this.save()}getShellPath(){let shellPath=this.settings.shellPath;return shellPath&&normalizePath(shellPath)}setShellPath(path2){this.globalSettings.shellPath=path2,this.markModified("shellPath"),this.save()}getQuietStartup(){let value=this.settings.quietStartup;return value===!0||value==="header"?value:SETTINGS_DEFAULTS.quietStartup}getAgentMonitorEnabled(){return this.settings.agentMonitor?.enabled!==!1}getCoordinationEnabled(){return this.settings.coordination?.enabled!==!1}getCoordinationPeerWakeLimit(){
|
|
228
|
+
let limit=this.settings.coordination?.peerWakeLimit;return typeof limit!="number"||!Number.isFinite(limit)?6:Math.min(60,Math.max(0,Math.floor(limit)))}setQuietStartup(quiet){this.globalSettings.quietStartup=quiet,this.markModified("quietStartup"),this.save()}getDefaultProjectTrust(){let value=this.globalSettings.defaultProjectTrust;return value==="always"||value==="never"?value:SETTINGS_DEFAULTS.defaultProjectTrust}setDefaultProjectTrust(defaultProjectTrust){this.globalSettings.defaultProjectTrust=
|
|
229
|
+
defaultProjectTrust,this.markModified("defaultProjectTrust"),this.save()}getBashOutputHeadTail(){let value=this.settings.bashOutputHeadTail;return typeof value=="boolean"?value:SETTINGS_DEFAULTS.bashOutputHeadTail}getBashOutputCleanup(){let value=this.settings.bashOutputCleanup;return typeof value=="boolean"?value:SETTINGS_DEFAULTS.bashOutputCleanup}getShellCommandPrefix(){return this.settings.shellCommandPrefix}setShellCommandPrefix(prefix2){this.globalSettings.shellCommandPrefix=prefix2,this.markModified(
|
|
230
|
+
"shellCommandPrefix"),this.save()}getNpmCommand(){return this.settings.npmCommand?[...this.settings.npmCommand]:void 0}setNpmCommand(command){this.globalSettings.npmCommand=command?[...command]:void 0,this.markModified("npmCommand"),this.save()}getCollapseChangelog(){return this.settings.collapseChangelog??SETTINGS_DEFAULTS.collapseChangelog}setCollapseChangelog(collapse){this.globalSettings.collapseChangelog=collapse,this.markModified("collapseChangelog"),this.save()}getEnableInstallTelemetry(){
|
|
231
|
+
return this.settings.enableInstallTelemetry??SETTINGS_DEFAULTS.enableInstallTelemetry}setEnableInstallTelemetry(enabled){this.globalSettings.enableInstallTelemetry=enabled,this.markModified("enableInstallTelemetry"),this.save()}getHcodeMetadataDisclosureVersion(){return this.globalSettings.hcodeMetadataDisclosureVersion===1?1:void 0}async acknowledgeHcodeMetadataDisclosure(theme){if(this.globalSettingsLoadError)throw new Error("Could not save metadata disclosure acknowledgment");let snapshot={hcodeMetadataDisclosureVersion:1},
|
|
232
|
+
fields=new Set(["hcodeMetadataDisclosureVersion"]);if(theme!==void 0&&(snapshot.theme=theme,fields.add("theme")),await this.enqueueWrite("global",()=>{this.persistScopedSettings("global",snapshot,fields,new Map),Object.assign(this.globalSettings,snapshot),this.settings=deepMergeSettings(this.globalSettings,this.projectSettings)},!1))throw new Error("Could not save metadata disclosure acknowledgment")}async acknowledgeHcodeMetadataDisclosureAfterNotice(notice){let snapshot={hcodeMetadataDisclosureVersion:1};
|
|
233
|
+
if(await this.enqueueWrite("global",()=>{this.persistScopedSettings("global",snapshot,new Set(["hcodeMetadataDisclosureVersion"]),new Map,stored=>stored.hcodeMetadataDisclosureVersion===1?!1:(notice(),!0)),Object.assign(this.globalSettings,snapshot),this.settings=deepMergeSettings(this.globalSettings,this.projectSettings)},!1))throw new Error("Could not save metadata disclosure acknowledgment")}getOrCreateDeviceId(){return this.globalSettings.deviceId||(this.globalSettings.deviceId=randomUUID(),
|
|
234
|
+
this.markModified("deviceId"),this.save()),this.globalSettings.deviceId}getPackages(){return[...this.settings.packages??[]]}setPackages(packages){this.globalSettings.packages=packages,this.markModified("packages"),this.save()}setProjectPackages(packages){this.updateProjectSettings("packages",settings=>{settings.packages=packages})}getExtensionPaths(){return[...this.settings.extensions??[]]}setExtensionPaths(paths){this.globalSettings.extensions=paths,this.markModified("extensions"),this.save()}setProjectExtensionPaths(paths){
|
|
235
|
+
this.updateProjectSettings("extensions",settings=>{settings.extensions=paths})}getSkillPaths(){return[...this.settings.skills??[]]}setSkillPaths(paths){this.globalSettings.skills=paths,this.markModified("skills"),this.save()}setProjectSkillPaths(paths){this.updateProjectSettings("skills",settings=>{settings.skills=paths})}getPromptTemplatePaths(){return[...this.settings.prompts??[]]}setPromptTemplatePaths(paths){this.globalSettings.prompts=paths,this.markModified("prompts"),this.save()}setProjectPromptTemplatePaths(paths){
|
|
236
|
+
this.updateProjectSettings("prompts",settings=>{settings.prompts=paths})}getThemePaths(){return[...this.settings.themes??[]]}setThemePaths(paths){this.globalSettings.themes=paths,this.markModified("themes"),this.save()}setProjectThemePaths(paths){this.updateProjectSettings("themes",settings=>{settings.themes=paths})}getEnableSkillCommands(){return this.settings.enableSkillCommands??SETTINGS_DEFAULTS.enableSkillCommands}setEnableSkillCommands(enabled){this.globalSettings.enableSkillCommands=enabled,
|
|
237
|
+
this.markModified("enableSkillCommands"),this.save()}getThinkingBudgets(){return this.settings.thinkingBudgets}getTerminalCapabilityOverrides(){let terminal=this.settings.terminal,images=terminal?.images;return{...images==="kitty"||images==="iterm2"?{images}:images===!1?{images:null}:{},...typeof terminal?.trueColor=="boolean"?{trueColor:terminal.trueColor}:{},...typeof terminal?.hyperlinks=="boolean"?{hyperlinks:terminal.hyperlinks}:{}}}getShowImages(){return this.settings.terminal?.showImages??
|
|
238
|
+
SETTINGS_DEFAULTS.terminal.showImages}setShowImages(show2){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.showImages=show2,this.markModified("terminal","showImages"),this.save()}getImageWidthCells(){let width=this.settings.terminal?.imageWidthCells;return typeof width!="number"||!Number.isFinite(width)?SETTINGS_DEFAULTS.terminal.imageWidthCells:Math.max(1,Math.floor(width))}setImageWidthCells(width){this.globalSettings.terminal||(this.globalSettings.
|
|
239
|
+
terminal={}),this.globalSettings.terminal.imageWidthCells=Math.max(1,Math.floor(width)),this.markModified("terminal","imageWidthCells"),this.save()}getClearOnShrink(){return this.settings.terminal?.clearOnShrink!==void 0?this.settings.terminal.clearOnShrink:process.env.PI_CLEAR_ON_SHRINK==="1"?!0:SETTINGS_DEFAULTS.terminal.clearOnShrink}setClearOnShrink(enabled){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.clearOnShrink=enabled,this.markModified("t\
|
|
240
|
+
erminal","clearOnShrink"),this.save()}getShowTerminalProgress(){return this.settings.terminal?.showTerminalProgress??SETTINGS_DEFAULTS.terminal.showTerminalProgress}setShowTerminalProgress(enabled){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.showTerminalProgress=enabled,this.markModified("terminal","showTerminalProgress"),this.save()}getTuiMode(){return this.settings.tuiMode==="regular"?"regular":SETTINGS_DEFAULTS.tuiMode}setTuiMode(mode){this.globalSettings.
|
|
241
|
+
tuiMode=mode,this.markModified("tuiMode"),this.save()}getFullscreenExitOutput(){return this.settings.fullscreenExitOutput==="resume-hint"?"resume-hint":SETTINGS_DEFAULTS.fullscreenExitOutput}setFullscreenExitOutput(output){this.globalSettings.fullscreenExitOutput=output,this.markModified("fullscreenExitOutput"),this.save()}getFullscreenScrollbar(){let mode=this.settings.fullscreenScrollbar;return mode==="always"||mode==="hidden"?mode:SETTINGS_DEFAULTS.fullscreenScrollbar}setFullscreenScrollbar(mode){
|
|
241
242
|
this.globalSettings.fullscreenScrollbar=mode,this.markModified("fullscreenScrollbar"),this.save()}getFullscreenCopyOnSelect(){return this.settings.fullscreenCopyOnSelect??SETTINGS_DEFAULTS.fullscreenCopyOnSelect}setFullscreenCopyOnSelect(enabled){this.globalSettings.fullscreenCopyOnSelect=enabled,this.markModified("fullscreenCopyOnSelect"),this.save()}getFullscreenWheelScrollLines(){let lines=this.settings.fullscreenWheelScrollLines;return typeof lines=="number"&&Number.isFinite(lines)?Math.max(
|
|
242
243
|
1,Math.min(100,Math.floor(lines))):SETTINGS_DEFAULTS.fullscreenWheelScrollLines}setFullscreenWheelScrollLines(lines){this.globalSettings.fullscreenWheelScrollLines=lines==="auto"?lines:Math.max(1,Math.min(100,Math.floor(lines))),this.markModified("fullscreenWheelScrollLines"),this.save()}getImageAutoResize(){return this.settings.images?.autoResize??SETTINGS_DEFAULTS.images.autoResize}setImageAutoResize(enabled){this.globalSettings.images||(this.globalSettings.images={}),this.globalSettings.images.
|
|
243
244
|
autoResize=enabled,this.markModified("images","autoResize"),this.save()}getBlockImages(){return this.settings.images?.blockImages??SETTINGS_DEFAULTS.images.blockImages}setBlockImages(blocked){this.globalSettings.images||(this.globalSettings.images={}),this.globalSettings.images.blockImages=blocked,this.markModified("images","blockImages"),this.save()}getEnabledModels(){return this.settings.enabledModels}getDefaultTools(){let tools=this.settings.defaultTools;if(tools!==void 0)return resolveDefaultTools(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
import{theme}from"./chunk-
|
|
2
|
+
import{theme}from"./chunk-E4VUW4RI.js";import{Key,KeybindingsManager,TUI_KEYBINDINGS}from"./chunk-M5TVWJ5T.js";import{Compile}from"./chunk-VCMXBP5S.js";import{typebox_exports}from"./chunk-VEGJT52D.js";import{getAgentDir,stripBom}from"./chunk-VFLVWPLZ.js";function areExperimentalFeaturesEnabled(){return process.env.PI_EXPERIMENTAL==="1"}import{existsSync,readFileSync}from"fs";import{join}from"path";var modifiers=["ctrl","shift","alt","super"],baseKeyPattern=`(?:[a-z0-9]|${Object.values(Key).flatMap(value=>typeof value=="string"?[value.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&")]:[]).join("|")})`,duplicateModifierPattern=modifiers.map(modifier=>`${modifier}\\+.*${modifier}\\+`).join("|"),KeyIdSchema=typebox_exports.Unsafe(typebox_exports.String({pattern:`^(?!.*(?:${duplicateModifierPattern}))(?:(?:${modifiers.join("|")})\\+){0,4}${baseKeyPattern}$`,description:"Key identifier with optional ctrl, \
|
|
3
3
|
shift, alt, or super modifiers."}));function keybindingValueSchema(options){return typebox_exports.Union([KeyIdSchema,typebox_exports.Array(KeyIdSchema)],options)}var KeybindingValueSchema=keybindingValueSchema();function useWindowsKeybindings(platform=process.platform,env=process.env){return platform==="win32"||platform==="linux"&&!!(env.WSL_DISTRO_NAME||env.WSL_INTEROP)}var windowsKeybindings=useWindowsKeybindings(),APP_KEYBINDINGS={"app.interrupt":{defaultKeys:"escape",description:"Cancel or abort"},"app.clear":{defaultKeys:"ctrl+c",description:"Clear editor"},"app.exit":{defaultKeys:"ctrl+d",description:"Exit when editor is empty"},"app.suspend":{defaultKeys:process.platform==="win32"?[]:"ctrl+z",description:"\
|
|
4
4
|
Suspend to background"},"app.thinking.cycle":{defaultKeys:"shift+tab",description:"Cycle thinking level"},"app.thinking.save":{defaultKeys:"ctrl+s",description:"Save thinking level"},"app.model.cycleForward":{defaultKeys:"ctrl+p",description:"Cycle to next model"},"app.model.cycleBackward":{defaultKeys:windowsKeybindings?"alt+p":"shift+ctrl+p",description:"Cycle to previous model"},"app.model.select":{defaultKeys:"ctrl+l",description:"Open model selector"},"app.tools.expand":{defaultKeys:"ctrl+o",
|
|
5
5
|
description:"Toggle tool output"},"app.select.upAlternate":{defaultKeys:"k",description:"Alternate up key in Trust and Extension selectors"},"app.select.downAlternate":{defaultKeys:"j",description:"Alternate down key in Trust and Extension selectors"},"app.usage.nextTab":{defaultKeys:["tab","right"],description:"Next usage account"},"app.usage.previousTab":{defaultKeys:["shift+tab","left"],description:"Previous usage account"},"app.usage.showAccounts":{defaultKeys:"a",description:"Show subscript\
|