@averyyy/pi-coding-agent 1.4.0-piclient.17 → 1.4.0-piclient.18

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.
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
- import{dist_exports as dist_exports3}from"./chunk-4ZUZUPZU.js";import{all_exports,compat_exports,compile_exports,dist_exports as dist_exports2,value_exports}from"./chunk-5EGM76TX.js";import{build_exports}from"./chunk-BRYV63PL.js";import"./chunk-3EGEEHMN.js";import{dist_exports}from"./chunk-H2UJDH5M.js";import"./chunk-PG7P2LUM.js";import"./chunk-VYYRESZJ.js";import"./chunk-H2AI7MFJ.js";import"./chunk-6QGV3IWD.js";import"./chunk-3LTMO2WY.js";import"./chunk-USJZMAIR.js";import"./chunk-5AGIVGSV.js";import"./chunk-UKVNB6C4.js";import"./chunk-TMTOQ7H7.js";import"./chunk-7DDKXS2Q.js";import"./chunk-3V45WARH.js";import{models_exports}from"./chunk-4G2HOZFC.js";import"./chunk-LPXNMA2W.js";import"./chunk-ZADMB3XG.js";import"./chunk-JXWJOIH4.js";var oauth_exports={};var VIRTUAL_MODULES={typebox:build_exports,"typebox/compile":compile_exports,"typebox/value":value_exports,"@sinclair/typebox":build_exports,"@sinclair/typebox/compile":compile_exports,"@sinclair/typebox/value":value_exports,"@earendil-works/pi-agent-core":dist_exports2,"@earendil-works/pi-tui":dist_exports,"@earendil-works/pi-ai":compat_exports,"@earendil-works/pi-ai/compat":compat_exports,"@earendil-works/pi-ai/models":models_exports,"@earendil-works/pi-ai/oauth":oauth_exports,"@earendil-works/pi-ai/providers/all":all_exports,"@earendil-works/pi-coding-agent":dist_exports3,"@mariozechner/pi-agent-core":dist_exports2,"@mariozechner/pi-tui":dist_exports,"@mariozechner/pi-ai":compat_exports,"@mariozechner/pi-ai/compat":compat_exports,"@mariozechner/pi-ai/models":models_exports,"@mariozechner/pi-ai/oauth":oauth_exports,"@mariozechner/pi-ai/providers/all":all_exports,"@mariozechner/pi-coding-agent":dist_exports3};export{VIRTUAL_MODULES};
2
+ import{dist_exports as dist_exports3}from"./chunk-PMRZTEST.js";import{all_exports,compat_exports,compile_exports,dist_exports as dist_exports2,value_exports}from"./chunk-WYPX6IZ6.js";import{build_exports}from"./chunk-BRYV63PL.js";import"./chunk-3EGEEHMN.js";import{dist_exports}from"./chunk-H2UJDH5M.js";import"./chunk-PG7P2LUM.js";import"./chunk-VYYRESZJ.js";import"./chunk-H2AI7MFJ.js";import"./chunk-6QGV3IWD.js";import"./chunk-3LTMO2WY.js";import"./chunk-USJZMAIR.js";import"./chunk-5AGIVGSV.js";import"./chunk-UKVNB6C4.js";import"./chunk-TMTOQ7H7.js";import"./chunk-7DDKXS2Q.js";import"./chunk-3V45WARH.js";import{models_exports}from"./chunk-4G2HOZFC.js";import"./chunk-LPXNMA2W.js";import"./chunk-ZADMB3XG.js";import"./chunk-JXWJOIH4.js";var oauth_exports={};var VIRTUAL_MODULES={typebox:build_exports,"typebox/compile":compile_exports,"typebox/value":value_exports,"@sinclair/typebox":build_exports,"@sinclair/typebox/compile":compile_exports,"@sinclair/typebox/value":value_exports,"@earendil-works/pi-agent-core":dist_exports2,"@earendil-works/pi-tui":dist_exports,"@earendil-works/pi-ai":compat_exports,"@earendil-works/pi-ai/compat":compat_exports,"@earendil-works/pi-ai/models":models_exports,"@earendil-works/pi-ai/oauth":oauth_exports,"@earendil-works/pi-ai/providers/all":all_exports,"@earendil-works/pi-coding-agent":dist_exports3,"@mariozechner/pi-agent-core":dist_exports2,"@mariozechner/pi-tui":dist_exports,"@mariozechner/pi-ai":compat_exports,"@mariozechner/pi-ai/compat":compat_exports,"@mariozechner/pi-ai/models":models_exports,"@mariozechner/pi-ai/oauth":oauth_exports,"@mariozechner/pi-ai/providers/all":all_exports,"@mariozechner/pi-coding-agent":dist_exports3};export{VIRTUAL_MODULES};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
3
- import{configureHttpDispatcher,main}from"./chunks/chunk-5EGM76TX.js";import"./chunks/chunk-BRYV63PL.js";import"./chunks/chunk-3EGEEHMN.js";import"./chunks/chunk-H2UJDH5M.js";import"./chunks/chunk-PG7P2LUM.js";import"./chunks/chunk-VYYRESZJ.js";import"./chunks/chunk-H2AI7MFJ.js";import"./chunks/chunk-6QGV3IWD.js";import{APP_NAME}from"./chunks/chunk-3LTMO2WY.js";import"./chunks/chunk-USJZMAIR.js";import"./chunks/chunk-5AGIVGSV.js";import"./chunks/chunk-UKVNB6C4.js";import"./chunks/chunk-TMTOQ7H7.js";import"./chunks/chunk-7DDKXS2Q.js";import"./chunks/chunk-3V45WARH.js";import"./chunks/chunk-4G2HOZFC.js";import"./chunks/chunk-LPXNMA2W.js";import"./chunks/chunk-ZADMB3XG.js";import"./chunks/chunk-JXWJOIH4.js";function setupCli(){process.title=APP_NAME,process.env.PI_CODING_AGENT="true",process.env.AI_AGENT="pi",process.emitWarning=(()=>{}),configureHttpDispatcher()}setupCli();main(process.argv.slice(2));
3
+ import{configureHttpDispatcher,main}from"./chunks/chunk-WYPX6IZ6.js";import"./chunks/chunk-BRYV63PL.js";import"./chunks/chunk-3EGEEHMN.js";import"./chunks/chunk-H2UJDH5M.js";import"./chunks/chunk-PG7P2LUM.js";import"./chunks/chunk-VYYRESZJ.js";import"./chunks/chunk-H2AI7MFJ.js";import"./chunks/chunk-6QGV3IWD.js";import{APP_NAME}from"./chunks/chunk-3LTMO2WY.js";import"./chunks/chunk-USJZMAIR.js";import"./chunks/chunk-5AGIVGSV.js";import"./chunks/chunk-UKVNB6C4.js";import"./chunks/chunk-TMTOQ7H7.js";import"./chunks/chunk-7DDKXS2Q.js";import"./chunks/chunk-3V45WARH.js";import"./chunks/chunk-4G2HOZFC.js";import"./chunks/chunk-LPXNMA2W.js";import"./chunks/chunk-ZADMB3XG.js";import"./chunks/chunk-JXWJOIH4.js";function setupCli(){process.title=APP_NAME,process.env.PI_CODING_AGENT="true",process.env.AI_AGENT="pi",process.emitWarning=(()=>{}),configureHttpDispatcher()}setupCli();main(process.argv.slice(2));
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
- import{ShowImagesSelectorComponent,ThemeSelectorComponent}from"./chunks/chunk-4ZUZUPZU.js";import{AgentSession,AgentSessionRuntime,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CURRENT_SESSION_VERSION,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DefaultPackageManager,DefaultResourceLoader,DynamicBorder,ExtensionEditorComponent,ExtensionInputComponent,ExtensionRunner,ExtensionSelectorComponent,FooterComponent,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,RpcClient,SessionManager,SessionSelectorComponent,SettingsManager,SettingsSelectorComponent,SkillInvocationMessageComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageComponent,UserMessageSelectorComponent,VIRTUAL_MODEL_STATE_ENTRY,buildContextEntries,buildSessionContext,buildSessionProjection,calculateContextTokens,collectEntriesForBranchSummary,compact,convertToLlm,convertToPng,copyToClipboard,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodemodeExtension,createCodingToolDefinitions,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createLocalBashOperations,createLsTool,createLsToolDefinition,createMcpExtension,createReadOnlyToolDefinitions,createReadOnlyTools,createReadTool,createReadToolDefinition,createSyntheticSourceInfo,createToolSearchExtension,createWriteTool,createWriteToolDefinition,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,estimateTokens,findCutPoint,findTurnStartIndex,formatDimensionNote,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getLastAssistantUsage,getLatestCompactionEntry,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isReadToolResult,isToolCallEventType,isWriteToolResult,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,migrateSessionEntries,parseArgs,parseFrontmatter,parseSessionEntries,parseSkillBlock,prepareBranchEntries,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runPrintMode,runRpcMode,serializeConversation,sessionEntryToContextMessages,shouldCompact,stripFrontmatter,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools}from"./chunks/chunk-5EGM76TX.js";import{DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,formatReadLineRange,formatSize,truncateHead,truncateLine,truncateTail,truncateToVisualLines}from"./chunks/chunk-BRYV63PL.js";import{ArminComponent}from"./chunks/chunk-3EGEEHMN.js";import{Theme,getLanguageFromPath,getMarkdownTheme,getSelectListTheme,getSettingsListTheme,highlightCode,initTheme,keyHint,keyText,rawKeyHint}from"./chunks/chunk-H2UJDH5M.js";import{ProjectTrustStore,hasTrustRequiringProjectResources}from"./chunks/chunk-PG7P2LUM.js";import{readStoredCredential}from"./chunks/chunk-VYYRESZJ.js";import{getShellConfig}from"./chunks/chunk-H2AI7MFJ.js";import"./chunks/chunk-6QGV3IWD.js";import{CONFIG_DIR_NAME,VERSION,getAgentDir,getDocsPath,getExamplesPath,getPackageDir,getReadmePath}from"./chunks/chunk-3LTMO2WY.js";import"./chunks/chunk-USJZMAIR.js";import"./chunks/chunk-5AGIVGSV.js";import"./chunks/chunk-UKVNB6C4.js";import"./chunks/chunk-TMTOQ7H7.js";import"./chunks/chunk-7DDKXS2Q.js";import"./chunks/chunk-3V45WARH.js";import"./chunks/chunk-4G2HOZFC.js";import"./chunks/chunk-LPXNMA2W.js";import"./chunks/chunk-ZADMB3XG.js";import"./chunks/chunk-JXWJOIH4.js";export{AgentSession,AgentSessionRuntime,ArminComponent,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CONFIG_DIR_NAME,CURRENT_SESSION_VERSION,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,DefaultPackageManager,DefaultResourceLoader,DynamicBorder,ExtensionEditorComponent,ExtensionInputComponent,ExtensionRunner,ExtensionSelectorComponent,FooterComponent,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,ProjectTrustStore,RpcClient,SessionManager,SessionSelectorComponent,SettingsManager,SettingsSelectorComponent,ShowImagesSelectorComponent,SkillInvocationMessageComponent,Theme,ThemeSelectorComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageComponent,UserMessageSelectorComponent,VERSION,VIRTUAL_MODEL_STATE_ENTRY,buildContextEntries,buildSessionContext,buildSessionProjection,calculateContextTokens,collectEntriesForBranchSummary,compact,convertToLlm,convertToPng,copyToClipboard,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodemodeExtension,createCodingToolDefinitions,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createLocalBashOperations,createLsTool,createLsToolDefinition,createMcpExtension,createReadOnlyToolDefinitions,createReadOnlyTools,createReadTool,createReadToolDefinition,createSyntheticSourceInfo,createToolSearchExtension,createWriteTool,createWriteToolDefinition,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,estimateTokens,findCutPoint,findTurnStartIndex,formatDimensionNote,formatReadLineRange,formatSize,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getAgentDir,getDocsPath,getExamplesPath,getLanguageFromPath,getLastAssistantUsage,getLatestCompactionEntry,getMarkdownTheme,getPackageDir,getReadmePath,getSelectListTheme,getSettingsListTheme,getShellConfig,hasTrustRequiringProjectResources,highlightCode,initTheme,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isReadToolResult,isToolCallEventType,isWriteToolResult,keyHint,keyText,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,migrateSessionEntries,parseArgs,parseFrontmatter,parseSessionEntries,parseSkillBlock,prepareBranchEntries,rawKeyHint,readStoredCredential,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runPrintMode,runRpcMode,serializeConversation,sessionEntryToContextMessages,shouldCompact,stripFrontmatter,truncateHead,truncateLine,truncateTail,truncateToVisualLines,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools};
2
+ import{ShowImagesSelectorComponent,ThemeSelectorComponent}from"./chunks/chunk-PMRZTEST.js";import{AgentSession,AgentSessionRuntime,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CURRENT_SESSION_VERSION,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DefaultPackageManager,DefaultResourceLoader,DynamicBorder,ExtensionEditorComponent,ExtensionInputComponent,ExtensionRunner,ExtensionSelectorComponent,FooterComponent,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,RpcClient,SessionManager,SessionSelectorComponent,SettingsManager,SettingsSelectorComponent,SkillInvocationMessageComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageComponent,UserMessageSelectorComponent,VIRTUAL_MODEL_STATE_ENTRY,buildContextEntries,buildSessionContext,buildSessionProjection,calculateContextTokens,collectEntriesForBranchSummary,compact,convertToLlm,convertToPng,copyToClipboard,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodemodeExtension,createCodingToolDefinitions,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createLocalBashOperations,createLsTool,createLsToolDefinition,createMcpExtension,createReadOnlyToolDefinitions,createReadOnlyTools,createReadTool,createReadToolDefinition,createSyntheticSourceInfo,createToolSearchExtension,createWriteTool,createWriteToolDefinition,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,estimateTokens,findCutPoint,findTurnStartIndex,formatDimensionNote,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getLastAssistantUsage,getLatestCompactionEntry,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isReadToolResult,isToolCallEventType,isWriteToolResult,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,migrateSessionEntries,parseArgs,parseFrontmatter,parseSessionEntries,parseSkillBlock,prepareBranchEntries,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runPrintMode,runRpcMode,serializeConversation,sessionEntryToContextMessages,shouldCompact,stripFrontmatter,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools}from"./chunks/chunk-WYPX6IZ6.js";import{DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,formatReadLineRange,formatSize,truncateHead,truncateLine,truncateTail,truncateToVisualLines}from"./chunks/chunk-BRYV63PL.js";import{ArminComponent}from"./chunks/chunk-3EGEEHMN.js";import{Theme,getLanguageFromPath,getMarkdownTheme,getSelectListTheme,getSettingsListTheme,highlightCode,initTheme,keyHint,keyText,rawKeyHint}from"./chunks/chunk-H2UJDH5M.js";import{ProjectTrustStore,hasTrustRequiringProjectResources}from"./chunks/chunk-PG7P2LUM.js";import{readStoredCredential}from"./chunks/chunk-VYYRESZJ.js";import{getShellConfig}from"./chunks/chunk-H2AI7MFJ.js";import"./chunks/chunk-6QGV3IWD.js";import{CONFIG_DIR_NAME,VERSION,getAgentDir,getDocsPath,getExamplesPath,getPackageDir,getReadmePath}from"./chunks/chunk-3LTMO2WY.js";import"./chunks/chunk-USJZMAIR.js";import"./chunks/chunk-5AGIVGSV.js";import"./chunks/chunk-UKVNB6C4.js";import"./chunks/chunk-TMTOQ7H7.js";import"./chunks/chunk-7DDKXS2Q.js";import"./chunks/chunk-3V45WARH.js";import"./chunks/chunk-4G2HOZFC.js";import"./chunks/chunk-LPXNMA2W.js";import"./chunks/chunk-ZADMB3XG.js";import"./chunks/chunk-JXWJOIH4.js";export{AgentSession,AgentSessionRuntime,ArminComponent,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CONFIG_DIR_NAME,CURRENT_SESSION_VERSION,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,DefaultPackageManager,DefaultResourceLoader,DynamicBorder,ExtensionEditorComponent,ExtensionInputComponent,ExtensionRunner,ExtensionSelectorComponent,FooterComponent,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,ProjectTrustStore,RpcClient,SessionManager,SessionSelectorComponent,SettingsManager,SettingsSelectorComponent,ShowImagesSelectorComponent,SkillInvocationMessageComponent,Theme,ThemeSelectorComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageComponent,UserMessageSelectorComponent,VERSION,VIRTUAL_MODEL_STATE_ENTRY,buildContextEntries,buildSessionContext,buildSessionProjection,calculateContextTokens,collectEntriesForBranchSummary,compact,convertToLlm,convertToPng,copyToClipboard,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodemodeExtension,createCodingToolDefinitions,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createLocalBashOperations,createLsTool,createLsToolDefinition,createMcpExtension,createReadOnlyToolDefinitions,createReadOnlyTools,createReadTool,createReadToolDefinition,createSyntheticSourceInfo,createToolSearchExtension,createWriteTool,createWriteToolDefinition,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,estimateTokens,findCutPoint,findTurnStartIndex,formatDimensionNote,formatReadLineRange,formatSize,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getAgentDir,getDocsPath,getExamplesPath,getLanguageFromPath,getLastAssistantUsage,getLatestCompactionEntry,getMarkdownTheme,getPackageDir,getReadmePath,getSelectListTheme,getSettingsListTheme,getShellConfig,hasTrustRequiringProjectResources,highlightCode,initTheme,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isReadToolResult,isToolCallEventType,isWriteToolResult,keyHint,keyText,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,migrateSessionEntries,parseArgs,parseFrontmatter,parseSessionEntries,parseSkillBlock,prepareBranchEntries,rawKeyHint,readStoredCredential,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runPrintMode,runRpcMode,serializeConversation,sessionEntryToContextMessages,shouldCompact,stripFrontmatter,truncateHead,truncateLine,truncateTail,truncateToVisualLines,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
3
- import{configureHttpDispatcher,main}from"./chunks/chunk-5EGM76TX.js";import"./chunks/chunk-BRYV63PL.js";import"./chunks/chunk-3EGEEHMN.js";import"./chunks/chunk-H2UJDH5M.js";import"./chunks/chunk-PG7P2LUM.js";import"./chunks/chunk-VYYRESZJ.js";import"./chunks/chunk-H2AI7MFJ.js";import"./chunks/chunk-6QGV3IWD.js";import{APP_NAME}from"./chunks/chunk-3LTMO2WY.js";import"./chunks/chunk-USJZMAIR.js";import"./chunks/chunk-5AGIVGSV.js";import"./chunks/chunk-UKVNB6C4.js";import"./chunks/chunk-TMTOQ7H7.js";import"./chunks/chunk-7DDKXS2Q.js";import"./chunks/chunk-3V45WARH.js";import"./chunks/chunk-4G2HOZFC.js";import"./chunks/chunk-LPXNMA2W.js";import"./chunks/chunk-ZADMB3XG.js";import"./chunks/chunk-JXWJOIH4.js";process.title=`${APP_NAME}-rpc`;process.env.PI_CODING_AGENT="true";process.env.AI_AGENT="pi";process.emitWarning=(()=>{});configureHttpDispatcher();main(["--mode","rpc",...process.argv.slice(2)]);
3
+ import{configureHttpDispatcher,main}from"./chunks/chunk-WYPX6IZ6.js";import"./chunks/chunk-BRYV63PL.js";import"./chunks/chunk-3EGEEHMN.js";import"./chunks/chunk-H2UJDH5M.js";import"./chunks/chunk-PG7P2LUM.js";import"./chunks/chunk-VYYRESZJ.js";import"./chunks/chunk-H2AI7MFJ.js";import"./chunks/chunk-6QGV3IWD.js";import{APP_NAME}from"./chunks/chunk-3LTMO2WY.js";import"./chunks/chunk-USJZMAIR.js";import"./chunks/chunk-5AGIVGSV.js";import"./chunks/chunk-UKVNB6C4.js";import"./chunks/chunk-TMTOQ7H7.js";import"./chunks/chunk-7DDKXS2Q.js";import"./chunks/chunk-3V45WARH.js";import"./chunks/chunk-4G2HOZFC.js";import"./chunks/chunk-LPXNMA2W.js";import"./chunks/chunk-ZADMB3XG.js";import"./chunks/chunk-JXWJOIH4.js";process.title=`${APP_NAME}-rpc`;process.env.PI_CODING_AGENT="true";process.env.AI_AGENT="pi";process.emitWarning=(()=>{});configureHttpDispatcher();main(["--mode","rpc",...process.argv.slice(2)]);
@@ -12,8 +12,9 @@ export type PersonalizeCatalog = (catalog: readonly AnyModel[], context: Refresh
12
12
  /** Add a persisted pi.dev catalog overlay to a static built-in provider. */
13
13
  export declare function withRemoteCatalog(provider: Provider, catalogBaseUrl?: string, localGeneratedAt?: number): Provider;
14
14
  /**
15
- * Like `withRemoteCatalog`, but on each network refresh the catalog (built-in models plus a newer
16
- * pi.dev catalog) is passed through `personalize` and the result is saved. The saved entry holds
15
+ * Like `withRemoteCatalog`, but on each network refresh the catalog is passed through `personalize`
16
+ * and the result is saved. Server catalogs overlay built-in models regardless of generation time;
17
+ * local Pi applies only newer pi.dev catalogs. The saved entry holds
17
18
  * the personalized list, not the pi.dev catalog, and replaces the catalog, including offline.
18
19
  * The refresh interval and etag revalidation are skipped. An empty list (nothing saved yet, or an
19
20
  * empty catalog saved by an older pi after a failed or missing pi.dev catalog) falls back to the
@@ -1 +1 @@
1
- {"version":3,"file":"remote-catalog-provider.d.ts","sourceRoot":"","sources":["../../src/core/remote-catalog-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,QAAQ,EAIb,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,oBAAoB,EACzB,MAAM,uBAAuB,CAAC;AAQ/B,eAAO,MAAM,kCAAkC,QAAqB,CAAC;AACrE;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,SAAS,EAAoC,CAAC;AAqFhG,kEAAkE;AAClE,MAAM,MAAM,kBAAkB,GAAG,CAChC,OAAO,EAAE,SAAS,QAAQ,EAAE,EAC5B,OAAO,EAAE,oBAAoB,KACzB,OAAO,CAAC,SAAS,QAAQ,EAAE,CAAC,CAAC;AAElC,4EAA4E;AAC5E,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,QAAQ,EAClB,cAAc,GAAE,MAAiC,EACjD,gBAAgB,CAAC,EAAE,MAAM,GACvB,QAAQ,CA+EV;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACtC,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,kBAAkB,EAC/B,cAAc,GAAE,MAAiC,EACjD,gBAAgB,CAAC,EAAE,MAAM,GACvB,QAAQ,CA4CV"}
1
+ {"version":3,"file":"remote-catalog-provider.d.ts","sourceRoot":"","sources":["../../src/core/remote-catalog-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,QAAQ,EAIb,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,oBAAoB,EACzB,MAAM,uBAAuB,CAAC;AAQ/B,eAAO,MAAM,kCAAkC,QAAqB,CAAC;AACrE;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,SAAS,EAAoC,CAAC;AAqFhG,kEAAkE;AAClE,MAAM,MAAM,kBAAkB,GAAG,CAChC,OAAO,EAAE,SAAS,QAAQ,EAAE,EAC5B,OAAO,EAAE,oBAAoB,KACzB,OAAO,CAAC,SAAS,QAAQ,EAAE,CAAC,CAAC;AAElC,4EAA4E;AAC5E,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,QAAQ,EAClB,cAAc,GAAE,MAAiC,EACjD,gBAAgB,CAAC,EAAE,MAAM,GACvB,QAAQ,CAgFV;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACtC,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,kBAAkB,EAC/B,cAAc,GAAE,MAAiC,EACjD,gBAAgB,CAAC,EAAE,MAAM,GACvB,QAAQ,CA6CV"}
@@ -75,6 +75,7 @@ function requestCatalog(providerId, catalogBaseUrl, signal, validator, force) {
75
75
  }
76
76
  /** Add a persisted pi.dev catalog overlay to a static built-in provider. */
77
77
  export function withRemoteCatalog(provider, catalogBaseUrl = DEFAULT_CATALOG_BASE_URL, localGeneratedAt) {
78
+ const catalogGeneratedAt = process.env.PI_SERVER_MODE === "true" ? undefined : localGeneratedAt;
78
79
  let dynamicModels = [];
79
80
  return {
80
81
  ...provider,
@@ -83,7 +84,7 @@ export function withRemoteCatalog(provider, catalogBaseUrl = DEFAULT_CATALOG_BAS
83
84
  getAllModels: () => mergeModels(provider.getAllModels?.() ?? provider.getModels(), dynamicModels),
84
85
  refreshModels: async (context) => {
85
86
  const stored = context.stored;
86
- const restored = remoteModels(stored, localGeneratedAt).filter((model) => model.provider === provider.id);
87
+ const restored = remoteModels(stored, catalogGeneratedAt).filter((model) => model.provider === provider.id);
87
88
  if (!(await context.publish({
88
89
  update: () => {
89
90
  dynamicModels = restored;
@@ -137,7 +138,7 @@ export function withRemoteCatalog(provider, catalogBaseUrl = DEFAULT_CATALOG_BAS
137
138
  if (context.signal.aborted)
138
139
  return;
139
140
  const entry = { ...catalog, checkedAt };
140
- const published = remoteModels(entry, localGeneratedAt);
141
+ const published = remoteModels(entry, catalogGeneratedAt);
141
142
  await context.publish({
142
143
  persist: entry,
143
144
  update: () => {
@@ -148,14 +149,16 @@ export function withRemoteCatalog(provider, catalogBaseUrl = DEFAULT_CATALOG_BAS
148
149
  };
149
150
  }
150
151
  /**
151
- * Like `withRemoteCatalog`, but on each network refresh the catalog (built-in models plus a newer
152
- * pi.dev catalog) is passed through `personalize` and the result is saved. The saved entry holds
152
+ * Like `withRemoteCatalog`, but on each network refresh the catalog is passed through `personalize`
153
+ * and the result is saved. Server catalogs overlay built-in models regardless of generation time;
154
+ * local Pi applies only newer pi.dev catalogs. The saved entry holds
153
155
  * the personalized list, not the pi.dev catalog, and replaces the catalog, including offline.
154
156
  * The refresh interval and etag revalidation are skipped. An empty list (nothing saved yet, or an
155
157
  * empty catalog saved by an older pi after a failed or missing pi.dev catalog) falls back to the
156
158
  * built-in models.
157
159
  */
158
160
  export function withPersonalizedCatalog(provider, personalize, catalogBaseUrl = DEFAULT_CATALOG_BASE_URL, localGeneratedAt) {
161
+ const catalogGeneratedAt = process.env.PI_SERVER_MODE === "true" ? undefined : localGeneratedAt;
159
162
  let personalModels = [];
160
163
  const builtinModels = () => provider.getAllModels?.() ?? provider.getModels();
161
164
  const getAllModels = () => (personalModels.length > 0 ? personalModels : builtinModels());
@@ -185,7 +188,7 @@ export function withPersonalizedCatalog(provider, personalize, catalogBaseUrl =
185
188
  throw new Error(`${source} request failed for ${provider.id}: ${response.status}`);
186
189
  }
187
190
  const catalog = await readCatalog(provider.id, response);
188
- if (isNewer(catalog.lastModified, localGeneratedAt))
191
+ if (isNewer(catalog.lastModified, catalogGeneratedAt))
189
192
  remote = catalog.models;
190
193
  }
191
194
  const personalized = await personalize(mergeModels(builtinModels(), remote), context);
@@ -1 +1 @@
1
- {"version":3,"file":"remote-catalog-provider.js","sourceRoot":"","sources":["../../src/core/remote-catalog-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,YAAY,EACZ,WAAW,GAKX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,MAAM,wBAAwB,GAAG,gBAAgB,CAAC;AAClD,MAAM,iCAAiC,GAAG,KAAK,CAAC;AAChD,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACrE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAyB,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;AAEhG,SAAS,oBAAoB,CAAC,KAAyB;IACtD,OAAO,CACN,KAAK,CAAC,IAAI,KAAK,SAAS;QACxB,CAAC,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,0BAA0B,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAiB,CAAC,CAAC,CAChG,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAA0B,QAA2B,EAAE,OAA0B;IACpG,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,KAAK,MAAM,KAAK,IAAI,CAAC,GAAG,QAAQ,EAAE,GAAG,OAAO,CAAC;QAAE,MAAM,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,KA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,GAAG,EAAE,EAAE;gBACxD,MAAM,EAAE,GAAG,EAAE;oBACZ,cAAc,GAAG,YAAY,CAAC;gBAC/B,CAAC;aACD,CAAC,CAAC;QACJ,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import {\n\ttype AnyModel,\n\tgetModelType,\n\tisModelType,\n\ttype ModelsStoreEntry,\n\ttype ModelType,\n\ttype Provider,\n\ttype RefreshModelsContext,\n} from \"@earendil-works/pi-ai\";\nimport { VERSION } from \"../config.ts\";\nimport { fetchWithRetry } from \"../utils/management-http.ts\";\nimport { getPiUserAgent } from \"../utils/pi-user-agent.ts\";\nimport { ChunkRequest } from \"./pi-server-request.ts\";\n\nconst DEFAULT_CATALOG_BASE_URL = \"https://pi.dev\";\nconst REMOTE_CATALOG_ATTEMPT_TIMEOUT_MS = 4_000;\nexport const REMOTE_CATALOG_REFRESH_INTERVAL_MS = 4 * 60 * 60 * 1000;\n/**\n * Model types this client can consume. Sent as `?types=` so the catalog server\n * returns the full-type shard instead of the chat-only one served to clients\n * that predate model types. A server that ignores the parameter still returns\n * the chat-only shard, which this client handles unchanged.\n */\nexport const REMOTE_CATALOG_MODEL_TYPES: readonly ModelType[] = [\"chat\", \"image\", \"classifier\"];\n\nfunction isSupportedModelType(model: { type?: unknown }): boolean {\n\treturn (\n\t\tmodel.type === undefined ||\n\t\t(typeof model.type === \"string\" && REMOTE_CATALOG_MODEL_TYPES.includes(model.type as ModelType))\n\t);\n}\n\nfunction mergeModels<TModel extends AnyModel>(baseline: readonly TModel[], dynamic: readonly TModel[]): TModel[] {\n\tconst merged = new Map<string, TModel>();\n\tfor (const model of [...baseline, ...dynamic]) merged.set(`${getModelType(model)}\\0${model.id}`, model);\n\treturn [...merged.values()];\n}\n\nfunction parseCatalog(providerId: string, value: unknown): AnyModel[] {\n\tconst entries = Array.isArray(value)\n\t\t? value\n\t\t: typeof value === \"object\" && value !== null && \"models\" in value && Array.isArray(value.models)\n\t\t\t? value.models\n\t\t\t: typeof value === \"object\" && value !== null\n\t\t\t\t? Object.values(value)\n\t\t\t\t: undefined;\n\tif (!entries) throw new Error(`Invalid model catalog for provider \"${providerId}\"`);\n\treturn entries\n\t\t.filter((entry): entry is Record<string, unknown> => typeof entry === \"object\" && entry !== null && \"id\" in entry)\n\t\t.filter(isSupportedModelType)\n\t\t.map((model) => ({ ...model, provider: providerId }) as AnyModel);\n}\n\n/** Read a successful pi.dev catalog response. A missing or invalid Last-Modified header is 0. */\nasync function readCatalog(\n\tproviderId: string,\n\tresponse: Response,\n): Promise<{ models: AnyModel[]; lastModified: number; etag: string | undefined }> {\n\tconst lastModified = Date.parse(response.headers.get(\"last-modified\") ?? \"\");\n\treturn {\n\t\tmodels: parseCatalog(providerId, await response.json()),\n\t\tlastModified: Number.isNaN(lastModified) ? 0 : lastModified,\n\t\tetag: response.headers.get(\"etag\") ?? undefined,\n\t};\n}\n\n/** Whether a pi.dev catalog is newer than the model data shipped with pi. */\nfunction isNewer(lastModified: number | undefined, localGeneratedAt: number | undefined): boolean {\n\treturn localGeneratedAt === undefined || (lastModified !== undefined && lastModified > localGeneratedAt);\n}\n\nfunction remoteModels(entry: ModelsStoreEntry | undefined, localGeneratedAt: number | undefined): readonly AnyModel[] {\n\treturn entry && isNewer(entry.lastModified, localGeneratedAt) ? entry.models : [];\n}\n\nfunction requestCatalog(\n\tproviderId: string,\n\tcatalogBaseUrl: string,\n\tsignal: AbortSignal,\n\tvalidator?: string,\n\tforce?: boolean,\n): Promise<Response> {\n\tif (process.env.PI_SERVER_MODE === \"true\") {\n\t\treturn new ChunkRequest({\n\t\t\tserverUrl: process.env.PI_SERVER_URL ?? \"http://127.0.0.1:4217\",\n\t\t\tauthToken: process.env.PI_SERVER_AUTH_TOKEN ?? \"\",\n\t\t\tsignal,\n\t\t}).getJson(\n\t\t\t`/api/model-catalog/providers/${encodeURIComponent(providerId)}?pi-version=${encodeURIComponent(VERSION)}${force ? \"&force=true\" : \"\"}`,\n\t\t\tvalidator ? { \"if-none-match\": validator } : undefined,\n\t\t);\n\t}\n\tconst url = new URL(`/api/models/providers/${encodeURIComponent(providerId)}`, catalogBaseUrl);\n\turl.searchParams.set(\"types\", REMOTE_CATALOG_MODEL_TYPES.join(\",\"));\n\treturn fetchWithRetry(\n\t\turl,\n\t\t{\n\t\t\theaders: {\n\t\t\t\taccept: \"application/json\",\n\t\t\t\t\"User-Agent\": getPiUserAgent(VERSION),\n\t\t\t\t...(validator ? { \"if-none-match\": validator } : {}),\n\t\t\t},\n\t\t\tsignal,\n\t\t},\n\t\t{ attemptTimeoutMs: REMOTE_CATALOG_ATTEMPT_TIMEOUT_MS },\n\t);\n}\n\n/** Replaces the catalog with a credential-specific model list. */\nexport type PersonalizeCatalog = (\n\tcatalog: readonly AnyModel[],\n\tcontext: RefreshModelsContext,\n) => Promise<readonly AnyModel[]>;\n\n/** Add a persisted pi.dev catalog overlay to a static built-in provider. */\nexport function withRemoteCatalog(\n\tprovider: Provider,\n\tcatalogBaseUrl: string = DEFAULT_CATALOG_BASE_URL,\n\tlocalGeneratedAt?: number,\n): Provider {\n\tlet dynamicModels: readonly AnyModel[] = [];\n\n\treturn {\n\t\t...provider,\n\t\tmodelCatalogAuth: \"none\",\n\t\tgetModels: () =>\n\t\t\tmergeModels(\n\t\t\t\tprovider.getModels(),\n\t\t\t\tdynamicModels.filter((model) => isModelType(model, \"chat\")),\n\t\t\t),\n\t\tgetAllModels: () => mergeModels(provider.getAllModels?.() ?? provider.getModels(), dynamicModels),\n\t\trefreshModels: async (context) => {\n\t\t\tconst stored = context.stored;\n\t\t\tconst restored = remoteModels(stored, localGeneratedAt).filter((model) => model.provider === provider.id);\n\t\t\tif (\n\t\t\t\t!(await context.publish({\n\t\t\t\t\tupdate: () => {\n\t\t\t\t\t\tdynamicModels = restored;\n\t\t\t\t\t},\n\t\t\t\t}))\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!context.allowNetwork || context.signal.aborted) return;\n\t\t\t// Skip the request if pi.dev was checked less than REMOTE_CATALOG_REFRESH_INTERVAL_MS ago.\n\t\t\t// An entry without lastModified (saved by an older pi, or after a failed first request) is\n\t\t\t// always refetched: remoteModels() ignores it, so waiting would leave the overlay empty.\n\t\t\tif (\n\t\t\t\tprocess.env.PI_SERVER_MODE !== \"true\" &&\n\t\t\t\t!context.force &&\n\t\t\t\tstored?.checkedAt !== undefined &&\n\t\t\t\tstored.lastModified !== undefined &&\n\t\t\t\tDate.now() - stored.checkedAt < REMOTE_CATALOG_REFRESH_INTERVAL_MS\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Only revalidate when a cached body backs the validator, so a 304 can never\n\t\t\t// leave the overlay empty.\n\t\t\tconst validator = stored && stored.models.length > 0 ? stored.etag : undefined;\n\t\t\tconst response = await requestCatalog(provider.id, catalogBaseUrl, context.signal, validator, context.force);\n\t\t\tif (context.signal.aborted) return;\n\t\t\tconst checkedAt = Date.now();\n\t\t\t// Unchanged: dynamicModels already holds the stored overlay, so only the\n\t\t\t// freshness window moves.\n\t\t\tif (response.status === 304 && stored) {\n\t\t\t\tawait context.publish({ persist: { ...stored, checkedAt } });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (process.env.PI_SERVER_MODE !== \"true\" && (response.status === 404 || response.status === 501)) {\n\t\t\t\tawait context.publish({\n\t\t\t\t\tpersist: {\n\t\t\t\t\t\t...(stored ?? { models: [] }),\n\t\t\t\t\t\tcheckedAt,\n\t\t\t\t\t\tlastModified: 0,\n\t\t\t\t\t\tetag: undefined,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!response.ok || (process.env.PI_SERVER_MODE === \"true\" && response.status !== 200)) {\n\t\t\t\t// Transient failure: the cached body and its validator stay valid, so keep the\n\t\t\t\t// etag and let the next refresh revalidate instead of downloading the catalog.\n\t\t\t\tconst source = process.env.PI_SERVER_MODE === \"true\" ? \"pi-server model catalog\" : \"Model catalog\";\n\t\t\t\tthrow new Error(`${source} request failed for ${provider.id}: ${response.status}`);\n\t\t\t}\n\t\t\tconst catalog = await readCatalog(provider.id, response);\n\t\t\tif (context.signal.aborted) return;\n\t\t\tconst entry: ModelsStoreEntry = { ...catalog, checkedAt };\n\t\t\tconst published = remoteModels(entry, localGeneratedAt);\n\t\t\tawait context.publish({\n\t\t\t\tpersist: entry,\n\t\t\t\tupdate: () => {\n\t\t\t\t\tdynamicModels = published;\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t};\n}\n\n/**\n * Like `withRemoteCatalog`, but on each network refresh the catalog (built-in models plus a newer\n * pi.dev catalog) is passed through `personalize` and the result is saved. The saved entry holds\n * the personalized list, not the pi.dev catalog, and replaces the catalog, including offline.\n * The refresh interval and etag revalidation are skipped. An empty list (nothing saved yet, or an\n * empty catalog saved by an older pi after a failed or missing pi.dev catalog) falls back to the\n * built-in models.\n */\nexport function withPersonalizedCatalog(\n\tprovider: Provider,\n\tpersonalize: PersonalizeCatalog,\n\tcatalogBaseUrl: string = DEFAULT_CATALOG_BASE_URL,\n\tlocalGeneratedAt?: number,\n): Provider {\n\tlet personalModels: readonly AnyModel[] = [];\n\tconst builtinModels = (): readonly AnyModel[] => provider.getAllModels?.() ?? provider.getModels();\n\tconst getAllModels = (): readonly AnyModel[] => (personalModels.length > 0 ? personalModels : builtinModels());\n\n\treturn {\n\t\t...provider,\n\t\tmodelCatalogAuth: \"provider\",\n\t\tgetModels: () => getAllModels().filter((model) => isModelType(model, \"chat\")),\n\t\tgetAllModels,\n\t\trefreshModels: async (context) => {\n\t\t\tconst restored = (context.stored?.models ?? []).filter((model) => model.provider === provider.id);\n\t\t\tif (\n\t\t\t\t!(await context.publish({\n\t\t\t\t\tupdate: () => {\n\t\t\t\t\t\tpersonalModels = restored;\n\t\t\t\t\t},\n\t\t\t\t}))\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!context.allowNetwork || context.signal.aborted) return;\n\n\t\t\tconst response = await requestCatalog(provider.id, catalogBaseUrl, context.signal, undefined, context.force);\n\t\t\tif (context.signal.aborted) return;\n\t\t\tlet remote: readonly AnyModel[] = [];\n\t\t\tif (process.env.PI_SERVER_MODE === \"true\" || (response.status !== 404 && response.status !== 501)) {\n\t\t\t\tif (!response.ok || (process.env.PI_SERVER_MODE === \"true\" && response.status !== 200)) {\n\t\t\t\t\tconst source = process.env.PI_SERVER_MODE === \"true\" ? \"pi-server model catalog\" : \"Model catalog\";\n\t\t\t\t\tthrow new Error(`${source} request failed for ${provider.id}: ${response.status}`);\n\t\t\t\t}\n\t\t\t\tconst catalog = await readCatalog(provider.id, response);\n\t\t\t\tif (isNewer(catalog.lastModified, localGeneratedAt)) remote = catalog.models;\n\t\t\t}\n\t\t\tconst personalized = await personalize(mergeModels(builtinModels(), remote), context);\n\t\t\tif (context.signal.aborted) return;\n\t\t\tawait context.publish({\n\t\t\t\tpersist: { models: personalized, checkedAt: Date.now() },\n\t\t\t\tupdate: () => {\n\t\t\t\t\tpersonalModels = personalized;\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"remote-catalog-provider.js","sourceRoot":"","sources":["../../src/core/remote-catalog-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,YAAY,EACZ,WAAW,GAKX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,MAAM,wBAAwB,GAAG,gBAAgB,CAAC;AAClD,MAAM,iCAAiC,GAAG,KAAK,CAAC;AAChD,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACrE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0BA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M,KAAK,GAAG,CAAC,EAAE,CAAC;oBACxF,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,MAAM,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,eAAe,CAAC;oBACnG,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,uBAAuB,QAAQ,CAAC,EAAE,KAAK,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;gBACpF,CAAC;gBACD,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;gBACzD,IAAI,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,kBAAkB,CAAC;oBAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAChF,CAAC;YACD,MAAM,YAAY,GAAG,MAAM,WAAW,CAAC,WAAW,CAAC,aAAa,EAAE,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;YACtF,IAAI,OAAO,CAAC,MAAM,CAAC,OAAO;gBAAE,OAAO;YACnC,MAAM,OAAO,CAAC,OAAO,CAAC;gBACrB,OAAO,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE;gBACxD,MAAM,EAAE,GAAG,EAAE;oBACZ,cAAc,GAAG,YAAY,CAAC;gBAC/B,CAAC;aACD,CAAC,CAAC;QACJ,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import {\n\ttype AnyModel,\n\tgetModelType,\n\tisModelType,\n\ttype ModelsStoreEntry,\n\ttype ModelType,\n\ttype Provider,\n\ttype RefreshModelsContext,\n} from \"@earendil-works/pi-ai\";\nimport { VERSION } from \"../config.ts\";\nimport { fetchWithRetry } from \"../utils/management-http.ts\";\nimport { getPiUserAgent } from \"../utils/pi-user-agent.ts\";\nimport { ChunkRequest } from \"./pi-server-request.ts\";\n\nconst DEFAULT_CATALOG_BASE_URL = \"https://pi.dev\";\nconst REMOTE_CATALOG_ATTEMPT_TIMEOUT_MS = 4_000;\nexport const REMOTE_CATALOG_REFRESH_INTERVAL_MS = 4 * 60 * 60 * 1000;\n/**\n * Model types this client can consume. Sent as `?types=` so the catalog server\n * returns the full-type shard instead of the chat-only one served to clients\n * that predate model types. A server that ignores the parameter still returns\n * the chat-only shard, which this client handles unchanged.\n */\nexport const REMOTE_CATALOG_MODEL_TYPES: readonly ModelType[] = [\"chat\", \"image\", \"classifier\"];\n\nfunction isSupportedModelType(model: { type?: unknown }): boolean {\n\treturn (\n\t\tmodel.type === undefined ||\n\t\t(typeof model.type === \"string\" && REMOTE_CATALOG_MODEL_TYPES.includes(model.type as ModelType))\n\t);\n}\n\nfunction mergeModels<TModel extends AnyModel>(baseline: readonly TModel[], dynamic: readonly TModel[]): TModel[] {\n\tconst merged = new Map<string, TModel>();\n\tfor (const model of [...baseline, ...dynamic]) merged.set(`${getModelType(model)}\\0${model.id}`, model);\n\treturn [...merged.values()];\n}\n\nfunction parseCatalog(providerId: string, value: unknown): AnyModel[] {\n\tconst entries = Array.isArray(value)\n\t\t? value\n\t\t: typeof value === \"object\" && value !== null && \"models\" in value && Array.isArray(value.models)\n\t\t\t? value.models\n\t\t\t: typeof value === \"object\" && value !== null\n\t\t\t\t? Object.values(value)\n\t\t\t\t: undefined;\n\tif (!entries) throw new Error(`Invalid model catalog for provider \"${providerId}\"`);\n\treturn entries\n\t\t.filter((entry): entry is Record<string, unknown> => typeof entry === \"object\" && entry !== null && \"id\" in entry)\n\t\t.filter(isSupportedModelType)\n\t\t.map((model) => ({ ...model, provider: providerId }) as AnyModel);\n}\n\n/** Read a successful pi.dev catalog response. A missing or invalid Last-Modified header is 0. */\nasync function readCatalog(\n\tproviderId: string,\n\tresponse: Response,\n): Promise<{ models: AnyModel[]; lastModified: number; etag: string | undefined }> {\n\tconst lastModified = Date.parse(response.headers.get(\"last-modified\") ?? \"\");\n\treturn {\n\t\tmodels: parseCatalog(providerId, await response.json()),\n\t\tlastModified: Number.isNaN(lastModified) ? 0 : lastModified,\n\t\tetag: response.headers.get(\"etag\") ?? undefined,\n\t};\n}\n\n/** Whether a pi.dev catalog is newer than the model data shipped with pi. */\nfunction isNewer(lastModified: number | undefined, localGeneratedAt: number | undefined): boolean {\n\treturn localGeneratedAt === undefined || (lastModified !== undefined && lastModified > localGeneratedAt);\n}\n\nfunction remoteModels(entry: ModelsStoreEntry | undefined, localGeneratedAt: number | undefined): readonly AnyModel[] {\n\treturn entry && isNewer(entry.lastModified, localGeneratedAt) ? entry.models : [];\n}\n\nfunction requestCatalog(\n\tproviderId: string,\n\tcatalogBaseUrl: string,\n\tsignal: AbortSignal,\n\tvalidator?: string,\n\tforce?: boolean,\n): Promise<Response> {\n\tif (process.env.PI_SERVER_MODE === \"true\") {\n\t\treturn new ChunkRequest({\n\t\t\tserverUrl: process.env.PI_SERVER_URL ?? \"http://127.0.0.1:4217\",\n\t\t\tauthToken: process.env.PI_SERVER_AUTH_TOKEN ?? \"\",\n\t\t\tsignal,\n\t\t}).getJson(\n\t\t\t`/api/model-catalog/providers/${encodeURIComponent(providerId)}?pi-version=${encodeURIComponent(VERSION)}${force ? \"&force=true\" : \"\"}`,\n\t\t\tvalidator ? { \"if-none-match\": validator } : undefined,\n\t\t);\n\t}\n\tconst url = new URL(`/api/models/providers/${encodeURIComponent(providerId)}`, catalogBaseUrl);\n\turl.searchParams.set(\"types\", REMOTE_CATALOG_MODEL_TYPES.join(\",\"));\n\treturn fetchWithRetry(\n\t\turl,\n\t\t{\n\t\t\theaders: {\n\t\t\t\taccept: \"application/json\",\n\t\t\t\t\"User-Agent\": getPiUserAgent(VERSION),\n\t\t\t\t...(validator ? { \"if-none-match\": validator } : {}),\n\t\t\t},\n\t\t\tsignal,\n\t\t},\n\t\t{ attemptTimeoutMs: REMOTE_CATALOG_ATTEMPT_TIMEOUT_MS },\n\t);\n}\n\n/** Replaces the catalog with a credential-specific model list. */\nexport type PersonalizeCatalog = (\n\tcatalog: readonly AnyModel[],\n\tcontext: RefreshModelsContext,\n) => Promise<readonly AnyModel[]>;\n\n/** Add a persisted pi.dev catalog overlay to a static built-in provider. */\nexport function withRemoteCatalog(\n\tprovider: Provider,\n\tcatalogBaseUrl: string = DEFAULT_CATALOG_BASE_URL,\n\tlocalGeneratedAt?: number,\n): Provider {\n\tconst catalogGeneratedAt = process.env.PI_SERVER_MODE === \"true\" ? undefined : localGeneratedAt;\n\tlet dynamicModels: readonly AnyModel[] = [];\n\n\treturn {\n\t\t...provider,\n\t\tmodelCatalogAuth: \"none\",\n\t\tgetModels: () =>\n\t\t\tmergeModels(\n\t\t\t\tprovider.getModels(),\n\t\t\t\tdynamicModels.filter((model) => isModelType(model, \"chat\")),\n\t\t\t),\n\t\tgetAllModels: () => mergeModels(provider.getAllModels?.() ?? provider.getModels(), dynamicModels),\n\t\trefreshModels: async (context) => {\n\t\t\tconst stored = context.stored;\n\t\t\tconst restored = remoteModels(stored, catalogGeneratedAt).filter((model) => model.provider === provider.id);\n\t\t\tif (\n\t\t\t\t!(await context.publish({\n\t\t\t\t\tupdate: () => {\n\t\t\t\t\t\tdynamicModels = restored;\n\t\t\t\t\t},\n\t\t\t\t}))\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!context.allowNetwork || context.signal.aborted) return;\n\t\t\t// Skip the request if pi.dev was checked less than REMOTE_CATALOG_REFRESH_INTERVAL_MS ago.\n\t\t\t// An entry without lastModified (saved by an older pi, or after a failed first request) is\n\t\t\t// always refetched: remoteModels() ignores it, so waiting would leave the overlay empty.\n\t\t\tif (\n\t\t\t\tprocess.env.PI_SERVER_MODE !== \"true\" &&\n\t\t\t\t!context.force &&\n\t\t\t\tstored?.checkedAt !== undefined &&\n\t\t\t\tstored.lastModified !== undefined &&\n\t\t\t\tDate.now() - stored.checkedAt < REMOTE_CATALOG_REFRESH_INTERVAL_MS\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Only revalidate when a cached body backs the validator, so a 304 can never\n\t\t\t// leave the overlay empty.\n\t\t\tconst validator = stored && stored.models.length > 0 ? stored.etag : undefined;\n\t\t\tconst response = await requestCatalog(provider.id, catalogBaseUrl, context.signal, validator, context.force);\n\t\t\tif (context.signal.aborted) return;\n\t\t\tconst checkedAt = Date.now();\n\t\t\t// Unchanged: dynamicModels already holds the stored overlay, so only the\n\t\t\t// freshness window moves.\n\t\t\tif (response.status === 304 && stored) {\n\t\t\t\tawait context.publish({ persist: { ...stored, checkedAt } });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (process.env.PI_SERVER_MODE !== \"true\" && (response.status === 404 || response.status === 501)) {\n\t\t\t\tawait context.publish({\n\t\t\t\t\tpersist: {\n\t\t\t\t\t\t...(stored ?? { models: [] }),\n\t\t\t\t\t\tcheckedAt,\n\t\t\t\t\t\tlastModified: 0,\n\t\t\t\t\t\tetag: undefined,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!response.ok || (process.env.PI_SERVER_MODE === \"true\" && response.status !== 200)) {\n\t\t\t\t// Transient failure: the cached body and its validator stay valid, so keep the\n\t\t\t\t// etag and let the next refresh revalidate instead of downloading the catalog.\n\t\t\t\tconst source = process.env.PI_SERVER_MODE === \"true\" ? \"pi-server model catalog\" : \"Model catalog\";\n\t\t\t\tthrow new Error(`${source} request failed for ${provider.id}: ${response.status}`);\n\t\t\t}\n\t\t\tconst catalog = await readCatalog(provider.id, response);\n\t\t\tif (context.signal.aborted) return;\n\t\t\tconst entry: ModelsStoreEntry = { ...catalog, checkedAt };\n\t\t\tconst published = remoteModels(entry, catalogGeneratedAt);\n\t\t\tawait context.publish({\n\t\t\t\tpersist: entry,\n\t\t\t\tupdate: () => {\n\t\t\t\t\tdynamicModels = published;\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t};\n}\n\n/**\n * Like `withRemoteCatalog`, but on each network refresh the catalog is passed through `personalize`\n * and the result is saved. Server catalogs overlay built-in models regardless of generation time;\n * local Pi applies only newer pi.dev catalogs. The saved entry holds\n * the personalized list, not the pi.dev catalog, and replaces the catalog, including offline.\n * The refresh interval and etag revalidation are skipped. An empty list (nothing saved yet, or an\n * empty catalog saved by an older pi after a failed or missing pi.dev catalog) falls back to the\n * built-in models.\n */\nexport function withPersonalizedCatalog(\n\tprovider: Provider,\n\tpersonalize: PersonalizeCatalog,\n\tcatalogBaseUrl: string = DEFAULT_CATALOG_BASE_URL,\n\tlocalGeneratedAt?: number,\n): Provider {\n\tconst catalogGeneratedAt = process.env.PI_SERVER_MODE === \"true\" ? undefined : localGeneratedAt;\n\tlet personalModels: readonly AnyModel[] = [];\n\tconst builtinModels = (): readonly AnyModel[] => provider.getAllModels?.() ?? provider.getModels();\n\tconst getAllModels = (): readonly AnyModel[] => (personalModels.length > 0 ? personalModels : builtinModels());\n\n\treturn {\n\t\t...provider,\n\t\tmodelCatalogAuth: \"provider\",\n\t\tgetModels: () => getAllModels().filter((model) => isModelType(model, \"chat\")),\n\t\tgetAllModels,\n\t\trefreshModels: async (context) => {\n\t\t\tconst restored = (context.stored?.models ?? []).filter((model) => model.provider === provider.id);\n\t\t\tif (\n\t\t\t\t!(await context.publish({\n\t\t\t\t\tupdate: () => {\n\t\t\t\t\t\tpersonalModels = restored;\n\t\t\t\t\t},\n\t\t\t\t}))\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!context.allowNetwork || context.signal.aborted) return;\n\n\t\t\tconst response = await requestCatalog(provider.id, catalogBaseUrl, context.signal, undefined, context.force);\n\t\t\tif (context.signal.aborted) return;\n\t\t\tlet remote: readonly AnyModel[] = [];\n\t\t\tif (process.env.PI_SERVER_MODE === \"true\" || (response.status !== 404 && response.status !== 501)) {\n\t\t\t\tif (!response.ok || (process.env.PI_SERVER_MODE === \"true\" && response.status !== 200)) {\n\t\t\t\t\tconst source = process.env.PI_SERVER_MODE === \"true\" ? \"pi-server model catalog\" : \"Model catalog\";\n\t\t\t\t\tthrow new Error(`${source} request failed for ${provider.id}: ${response.status}`);\n\t\t\t\t}\n\t\t\t\tconst catalog = await readCatalog(provider.id, response);\n\t\t\t\tif (isNewer(catalog.lastModified, catalogGeneratedAt)) remote = catalog.models;\n\t\t\t}\n\t\t\tconst personalized = await personalize(mergeModels(builtinModels(), remote), context);\n\t\t\tif (context.signal.aborted) return;\n\t\t\tawait context.publish({\n\t\t\t\tpersist: { models: personalized, checkedAt: Date.now() },\n\t\t\t\tupdate: () => {\n\t\t\t\t\tpersonalModels = personalized;\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t};\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@averyyy/pi-coding-agent",
3
- "version": "1.4.0-piclient.17",
3
+ "version": "1.4.0-piclient.18",
4
4
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "piConfig": {
@@ -48,11 +48,11 @@
48
48
  "prepublishOnly": "npm run clean && npm run build"
49
49
  },
50
50
  "dependencies": {
51
- "@earendil-works/pi-agent-core": "npm:@averyyy/pi-agent-core@1.4.0-piclient.17",
52
- "@earendil-works/pi-ai": "npm:@averyyy/pi-ai@1.4.0-piclient.17",
51
+ "@earendil-works/pi-agent-core": "npm:@averyyy/pi-agent-core@1.4.0-piclient.18",
52
+ "@earendil-works/pi-ai": "npm:@averyyy/pi-ai@1.4.0-piclient.18",
53
53
  "@earendil-works/pi-codemode": "1.4.0",
54
54
  "@earendil-works/pi-mcp": "1.4.0",
55
- "@earendil-works/pi-tui": "npm:@averyyy/pi-tui@1.4.0-piclient.17",
55
+ "@earendil-works/pi-tui": "npm:@averyyy/pi-tui@1.4.0-piclient.18",
56
56
  "@silvia-odwyer/photon-node": "0.3.4",
57
57
  "brace-expansion": "5.0.12",
58
58
  "chalk": "6.0.0",