@maxmo74/pi-coding-agent 1.5.0-max.5 → 1.5.0-max.7
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/README.md +14 -39
- package/dist/bundle/chunks/{chunk-PQ22D246.js → chunk-HK6CSLVH.js} +1 -1
- package/dist/bundle/chunks/{chunk-7TW5OBDP.js → chunk-MFRYL6YI.js} +14 -14
- package/dist/bundle/chunks/{virtual-modules-YF6U6HAK.js → virtual-modules-GVBCPTET.js} +1 -1
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/core/session-move.d.ts.map +1 -1
- package/dist/core/session-move.js +22 -3
- package/dist/core/session-move.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +32 -9
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/package.json +3 -3
|
@@ -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-PQ22D246.js";import{all_exports,anthropicMessagesApi,azureOpenAIResponsesApi,bedrockConverseStreamApi,compile_exports,complete,completeSimple,createFauxCore,dist_exports as dist_exports2,envApiKeyAuth,fauxAssistantMessage,fauxProvider,fauxText,fauxThinking,fauxToolCall,generateImages,generateImagesOpenRouter,getApiProvider,getApiProviders,getImageModel,getImageModels,getImageProviders,getImagesApiProvider,getModel,getModels,getOverflowPatterns,getProviders,googleGenerativeAIApi,googleVertexApi,isContextOverflow,isRecoverableLength,lazyOAuth,mistralConversationsApi,openAICodexResponsesApi,openAICompletionsApi,openAIResponsesApi,piMessagesApi,registerApiProvider,registerBuiltInApiProviders,registerBuiltInImagesApiProviders,registerFauxProvider,registerImagesApiProvider,resetApiProviders,setBedrockProviderModule,stream,streamAnthropic,streamAzureOpenAIResponses,streamGoogle,streamGoogleVertex,streamMistral,streamOpenAICodexResponses,streamOpenAICompletions,streamOpenAIResponses,streamSimple,streamSimpleAnthropic,streamSimpleAzureOpenAIResponses,streamSimpleGoogle,streamSimpleGoogleVertex,streamSimpleMistral,streamSimpleOpenAICodexResponses,streamSimpleOpenAICompletions,streamSimpleOpenAIResponses,unregisterApiProviders,validateToolArguments,validateToolCall,value_exports}from"./chunk-7TW5OBDP.js";import{DEFAULT_MAX_AGENT_RETRY_DELAY_MS,build_exports,isRetryableAssistantError,retryAssistantCall,retryDelayMs,typebox_exports}from"./chunk-62VOPMLK.js";import"./chunk-3TGLJEWK.js";import{dist_exports}from"./chunk-4EYXVSA5.js";import"./chunk-NZY7EIPA.js";import"./chunk-R2EGYMOO.js";import"./chunk-YZKQS34S.js";import"./chunk-6QGV3IWD.js";import"./chunk-36QC74V4.js";import{cleanupSessionResources,registerSessionResourceCleanup,uuidv7}from"./chunk-USJZMAIR.js";import"./chunk-5AGIVGSV.js";import{ANTHROPIC_API_KEY_ENV,ANTHROPIC_AUTH_TOKEN_ENV,ANTHROPIC_FEDERATION_RULE_ID_ENV,ANTHROPIC_IDENTITY_TOKEN_FILE_ENV,ANTHROPIC_OAUTH_TOKEN_ENV,ANTHROPIC_ORGANIZATION_ID_ENV,ANTHROPIC_SERVICE_ACCOUNT_ID_ENV,ANTHROPIC_WORKSPACE_ID_ENV,findEnvKeys,getEnvApiKey}from"./chunk-UKVNB6C4.js";import"./chunk-TMTOQ7H7.js";import"./chunk-7DDKXS2Q.js";import{StreamingJsonParser,ToolCallArgumentsStream,parseJsonWithRepair,parseStreamingJson,parseToolCallArguments,repairJson}from"./chunk-FFMDRXC4.js";import{AI_TELEMETRY_SCHEMA,InMemoryCredentialStore,InMemoryModelsStore,ModelsError,calculateCost,clampThinkingLevel,collapseSystemMessages,createInitialSystemMessage,createModels,createProvider,declarationsEqual,defaultProviderAuthContext,getCurrentSystemMessage,getCurrentSystemPrompt,getCurrentTools,getDeclaredTools,getInitialSystemMessage,getModelType,getSupportedThinkingLevels,getToolStateChanges,hasApi,hasNonAdditiveToolChanges,hasToolRedefinitions,isModelType,lazyApi,lazyStream,modelsAreEqual,models_exports,normalizeContext,resolveTranscript,resolveTranscriptTools,toToolDeclaration,withoutInitialSystemMessage}from"./chunk-NL4X6LBY.js";import{AssistantMessageEventStream,EventStream,appendAssistantMessageDiagnostic,createAssistantMessageDiagnostic,createAssistantMessageEventStream,extractDiagnosticError,formatThrownValue}from"./chunk-LPXNMA2W.js";import{PI_AI_VERSION,PI_ATTRIBUTION,contentText,formatUserAgent,getAttributionHeaders,getClientVersion,getIdentityHeaders,getOpenCodeSessionHeaders,getSystemMessageText,mergeClientIdentity,renderSystemMessageUpdate,withClientIdentity}from"./chunk-V6KH5QG4.js";import{__export}from"./chunk-JXWJOIH4.js";var oauth_exports={};var pi_ai_extension_view_exports={};__export(pi_ai_extension_view_exports,{AI_TELEMETRY_SCHEMA:()=>AI_TELEMETRY_SCHEMA,ANTHROPIC_API_KEY_ENV:()=>ANTHROPIC_API_KEY_ENV,ANTHROPIC_AUTH_TOKEN_ENV:()=>ANTHROPIC_AUTH_TOKEN_ENV,ANTHROPIC_FEDERATION_RULE_ID_ENV:()=>ANTHROPIC_FEDERATION_RULE_ID_ENV,ANTHROPIC_IDENTITY_TOKEN_FILE_ENV:()=>ANTHROPIC_IDENTITY_TOKEN_FILE_ENV,ANTHROPIC_OAUTH_TOKEN_ENV:()=>ANTHROPIC_OAUTH_TOKEN_ENV,ANTHROPIC_ORGANIZATION_ID_ENV:()=>ANTHROPIC_ORGANIZATION_ID_ENV,ANTHROPIC_SERVICE_ACCOUNT_ID_ENV:()=>ANTHROPIC_SERVICE_ACCOUNT_ID_ENV,ANTHROPIC_WORKSPACE_ID_ENV:()=>ANTHROPIC_WORKSPACE_ID_ENV,AssistantMessageEventStream:()=>AssistantMessageEventStream,DEFAULT_MAX_AGENT_RETRY_DELAY_MS:()=>DEFAULT_MAX_AGENT_RETRY_DELAY_MS,EventStream:()=>EventStream,InMemoryCredentialStore:()=>InMemoryCredentialStore,InMemoryModelsStore:()=>InMemoryModelsStore,ModelsError:()=>ModelsError,PI_AI_VERSION:()=>PI_AI_VERSION,PI_ATTRIBUTION:()=>PI_ATTRIBUTION,StreamingJsonParser:()=>StreamingJsonParser,StringEnum:()=>StringEnum,ToolCallArgumentsStream:()=>ToolCallArgumentsStream,Type:()=>typebox_exports,anthropicMessagesApi:()=>anthropicMessagesApi,appendAssistantMessageDiagnostic:()=>appendAssistantMessageDiagnostic,azureOpenAIResponsesApi:()=>azureOpenAIResponsesApi,bedrockConverseStreamApi:()=>bedrockConverseStreamApi,calculateCost:()=>calculateCost,clampThinkingLevel:()=>clampThinkingLevel,cleanupSessionResources:()=>cleanupSessionResources,collapseSystemMessages:()=>collapseSystemMessages,complete:()=>complete,completeSimple:()=>completeSimple,contentText:()=>contentText,createAssistantMessageDiagnostic:()=>createAssistantMessageDiagnostic,createAssistantMessageEventStream:()=>createAssistantMessageEventStream,createFauxCore:()=>createFauxCore,createInitialSystemMessage:()=>createInitialSystemMessage,createModels:()=>createModels,createProvider:()=>createProvider,declarationsEqual:()=>declarationsEqual,defaultProviderAuthContext:()=>defaultProviderAuthContext,envApiKeyAuth:()=>envApiKeyAuth,extractDiagnosticError:()=>extractDiagnosticError,fauxAssistantMessage:()=>fauxAssistantMessage,fauxProvider:()=>fauxProvider,fauxText:()=>fauxText,fauxThinking:()=>fauxThinking,fauxToolCall:()=>fauxToolCall,findEnvKeys:()=>findEnvKeys,formatThrownValue:()=>formatThrownValue,formatUserAgent:()=>formatUserAgent,generateImages:()=>generateImages,generateImagesOpenRouter:()=>generateImagesOpenRouter,getApiProvider:()=>getApiProvider,getApiProviders:()=>getApiProviders,getAttributionHeaders:()=>getAttributionHeaders,getClientVersion:()=>getClientVersion,getCurrentSystemMessage:()=>getCurrentSystemMessage,getCurrentSystemPrompt:()=>getCurrentSystemPrompt,getCurrentTools:()=>getCurrentTools,getDeclaredTools:()=>getDeclaredTools,getEnvApiKey:()=>getEnvApiKey,getIdentityHeaders:()=>getIdentityHeaders,getImageModel:()=>getImageModel,getImageModels:()=>getImageModels,getImageProviders:()=>getImageProviders,getImagesApiProvider:()=>getImagesApiProvider,getInitialSystemMessage:()=>getInitialSystemMessage,getModel:()=>getModel,getModelType:()=>getModelType,getModels:()=>getModels,getOpenCodeSessionHeaders:()=>getOpenCodeSessionHeaders,getOverflowPatterns:()=>getOverflowPatterns,getProviders:()=>getProviders,getSupportedThinkingLevels:()=>getSupportedThinkingLevels,getSystemMessageText:()=>getSystemMessageText,getToolStateChanges:()=>getToolStateChanges,googleGenerativeAIApi:()=>googleGenerativeAIApi,googleVertexApi:()=>googleVertexApi,hasApi:()=>hasApi,hasNonAdditiveToolChanges:()=>hasNonAdditiveToolChanges,hasToolRedefinitions:()=>hasToolRedefinitions,isContextOverflow:()=>isContextOverflow,isModelType:()=>isModelType,isRecoverableLength:()=>isRecoverableLength,isRetryableAssistantError:()=>isRetryableAssistantError,lazyApi:()=>lazyApi,lazyOAuth:()=>lazyOAuth,lazyStream:()=>lazyStream,mergeClientIdentity:()=>mergeClientIdentity,mistralConversationsApi:()=>mistralConversationsApi,modelsAreEqual:()=>modelsAreEqual,normalizeContext:()=>normalizeContext,openAICodexResponsesApi:()=>openAICodexResponsesApi,openAICompletionsApi:()=>openAICompletionsApi,openAIResponsesApi:()=>openAIResponsesApi,parseJsonWithRepair:()=>parseJsonWithRepair,parseStreamingJson:()=>parseStreamingJson,parseToolCallArguments:()=>parseToolCallArguments,piMessagesApi:()=>piMessagesApi,registerApiProvider:()=>registerApiProvider,registerBuiltInApiProviders:()=>registerBuiltInApiProviders,registerBuiltInImagesApiProviders:()=>registerBuiltInImagesApiProviders,registerFauxProvider:()=>registerFauxProvider,registerImagesApiProvider:()=>registerImagesApiProvider,registerSessionResourceCleanup:()=>registerSessionResourceCleanup,renderSystemMessageUpdate:()=>renderSystemMessageUpdate,repairJson:()=>repairJson,resetApiProviders:()=>resetApiProviders,resolveTranscript:()=>resolveTranscript,resolveTranscriptTools:()=>resolveTranscriptTools,retryAssistantCall:()=>retryAssistantCall,retryDelayMs:()=>retryDelayMs,setBedrockProviderModule:()=>setBedrockProviderModule,stream:()=>stream,streamAnthropic:()=>streamAnthropic,streamAzureOpenAIResponses:()=>streamAzureOpenAIResponses,streamGoogle:()=>streamGoogle,streamGoogleVertex:()=>streamGoogleVertex,streamMistral:()=>streamMistral,streamOpenAICodexResponses:()=>streamOpenAICodexResponses,streamOpenAICompletions:()=>streamOpenAICompletions,streamOpenAIResponses:()=>streamOpenAIResponses,streamSimple:()=>streamSimple,streamSimpleAnthropic:()=>streamSimpleAnthropic,streamSimpleAzureOpenAIResponses:()=>streamSimpleAzureOpenAIResponses,streamSimpleGoogle:()=>streamSimpleGoogle,streamSimpleGoogleVertex:()=>streamSimpleGoogleVertex,streamSimpleMistral:()=>streamSimpleMistral,streamSimpleOpenAICodexResponses:()=>streamSimpleOpenAICodexResponses,streamSimpleOpenAICompletions:()=>streamSimpleOpenAICompletions,streamSimpleOpenAIResponses:()=>streamSimpleOpenAIResponses,toToolDeclaration:()=>toToolDeclaration,unregisterApiProviders:()=>unregisterApiProviders,uuidv7:()=>uuidv7,validateToolArguments:()=>validateToolArguments,validateToolCall:()=>validateToolCall,withClientIdentity:()=>withClientIdentity,withoutInitialSystemMessage:()=>withoutInitialSystemMessage});function StringEnum(values,options){return typebox_exports.Unsafe({type:"string",enum:values,...options?.description&&{description:options.description},...options?.default&&{default:options.default}})}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":pi_ai_extension_view_exports,"@earendil-works/pi-ai/compat":pi_ai_extension_view_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":pi_ai_extension_view_exports,"@mariozechner/pi-ai/compat":pi_ai_extension_view_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-HK6CSLVH.js";import{all_exports,anthropicMessagesApi,azureOpenAIResponsesApi,bedrockConverseStreamApi,compile_exports,complete,completeSimple,createFauxCore,dist_exports as dist_exports2,envApiKeyAuth,fauxAssistantMessage,fauxProvider,fauxText,fauxThinking,fauxToolCall,generateImages,generateImagesOpenRouter,getApiProvider,getApiProviders,getImageModel,getImageModels,getImageProviders,getImagesApiProvider,getModel,getModels,getOverflowPatterns,getProviders,googleGenerativeAIApi,googleVertexApi,isContextOverflow,isRecoverableLength,lazyOAuth,mistralConversationsApi,openAICodexResponsesApi,openAICompletionsApi,openAIResponsesApi,piMessagesApi,registerApiProvider,registerBuiltInApiProviders,registerBuiltInImagesApiProviders,registerFauxProvider,registerImagesApiProvider,resetApiProviders,setBedrockProviderModule,stream,streamAnthropic,streamAzureOpenAIResponses,streamGoogle,streamGoogleVertex,streamMistral,streamOpenAICodexResponses,streamOpenAICompletions,streamOpenAIResponses,streamSimple,streamSimpleAnthropic,streamSimpleAzureOpenAIResponses,streamSimpleGoogle,streamSimpleGoogleVertex,streamSimpleMistral,streamSimpleOpenAICodexResponses,streamSimpleOpenAICompletions,streamSimpleOpenAIResponses,unregisterApiProviders,validateToolArguments,validateToolCall,value_exports}from"./chunk-MFRYL6YI.js";import{DEFAULT_MAX_AGENT_RETRY_DELAY_MS,build_exports,isRetryableAssistantError,retryAssistantCall,retryDelayMs,typebox_exports}from"./chunk-62VOPMLK.js";import"./chunk-3TGLJEWK.js";import{dist_exports}from"./chunk-4EYXVSA5.js";import"./chunk-NZY7EIPA.js";import"./chunk-R2EGYMOO.js";import"./chunk-YZKQS34S.js";import"./chunk-6QGV3IWD.js";import"./chunk-36QC74V4.js";import{cleanupSessionResources,registerSessionResourceCleanup,uuidv7}from"./chunk-USJZMAIR.js";import"./chunk-5AGIVGSV.js";import{ANTHROPIC_API_KEY_ENV,ANTHROPIC_AUTH_TOKEN_ENV,ANTHROPIC_FEDERATION_RULE_ID_ENV,ANTHROPIC_IDENTITY_TOKEN_FILE_ENV,ANTHROPIC_OAUTH_TOKEN_ENV,ANTHROPIC_ORGANIZATION_ID_ENV,ANTHROPIC_SERVICE_ACCOUNT_ID_ENV,ANTHROPIC_WORKSPACE_ID_ENV,findEnvKeys,getEnvApiKey}from"./chunk-UKVNB6C4.js";import"./chunk-TMTOQ7H7.js";import"./chunk-7DDKXS2Q.js";import{StreamingJsonParser,ToolCallArgumentsStream,parseJsonWithRepair,parseStreamingJson,parseToolCallArguments,repairJson}from"./chunk-FFMDRXC4.js";import{AI_TELEMETRY_SCHEMA,InMemoryCredentialStore,InMemoryModelsStore,ModelsError,calculateCost,clampThinkingLevel,collapseSystemMessages,createInitialSystemMessage,createModels,createProvider,declarationsEqual,defaultProviderAuthContext,getCurrentSystemMessage,getCurrentSystemPrompt,getCurrentTools,getDeclaredTools,getInitialSystemMessage,getModelType,getSupportedThinkingLevels,getToolStateChanges,hasApi,hasNonAdditiveToolChanges,hasToolRedefinitions,isModelType,lazyApi,lazyStream,modelsAreEqual,models_exports,normalizeContext,resolveTranscript,resolveTranscriptTools,toToolDeclaration,withoutInitialSystemMessage}from"./chunk-NL4X6LBY.js";import{AssistantMessageEventStream,EventStream,appendAssistantMessageDiagnostic,createAssistantMessageDiagnostic,createAssistantMessageEventStream,extractDiagnosticError,formatThrownValue}from"./chunk-LPXNMA2W.js";import{PI_AI_VERSION,PI_ATTRIBUTION,contentText,formatUserAgent,getAttributionHeaders,getClientVersion,getIdentityHeaders,getOpenCodeSessionHeaders,getSystemMessageText,mergeClientIdentity,renderSystemMessageUpdate,withClientIdentity}from"./chunk-V6KH5QG4.js";import{__export}from"./chunk-JXWJOIH4.js";var oauth_exports={};var pi_ai_extension_view_exports={};__export(pi_ai_extension_view_exports,{AI_TELEMETRY_SCHEMA:()=>AI_TELEMETRY_SCHEMA,ANTHROPIC_API_KEY_ENV:()=>ANTHROPIC_API_KEY_ENV,ANTHROPIC_AUTH_TOKEN_ENV:()=>ANTHROPIC_AUTH_TOKEN_ENV,ANTHROPIC_FEDERATION_RULE_ID_ENV:()=>ANTHROPIC_FEDERATION_RULE_ID_ENV,ANTHROPIC_IDENTITY_TOKEN_FILE_ENV:()=>ANTHROPIC_IDENTITY_TOKEN_FILE_ENV,ANTHROPIC_OAUTH_TOKEN_ENV:()=>ANTHROPIC_OAUTH_TOKEN_ENV,ANTHROPIC_ORGANIZATION_ID_ENV:()=>ANTHROPIC_ORGANIZATION_ID_ENV,ANTHROPIC_SERVICE_ACCOUNT_ID_ENV:()=>ANTHROPIC_SERVICE_ACCOUNT_ID_ENV,ANTHROPIC_WORKSPACE_ID_ENV:()=>ANTHROPIC_WORKSPACE_ID_ENV,AssistantMessageEventStream:()=>AssistantMessageEventStream,DEFAULT_MAX_AGENT_RETRY_DELAY_MS:()=>DEFAULT_MAX_AGENT_RETRY_DELAY_MS,EventStream:()=>EventStream,InMemoryCredentialStore:()=>InMemoryCredentialStore,InMemoryModelsStore:()=>InMemoryModelsStore,ModelsError:()=>ModelsError,PI_AI_VERSION:()=>PI_AI_VERSION,PI_ATTRIBUTION:()=>PI_ATTRIBUTION,StreamingJsonParser:()=>StreamingJsonParser,StringEnum:()=>StringEnum,ToolCallArgumentsStream:()=>ToolCallArgumentsStream,Type:()=>typebox_exports,anthropicMessagesApi:()=>anthropicMessagesApi,appendAssistantMessageDiagnostic:()=>appendAssistantMessageDiagnostic,azureOpenAIResponsesApi:()=>azureOpenAIResponsesApi,bedrockConverseStreamApi:()=>bedrockConverseStreamApi,calculateCost:()=>calculateCost,clampThinkingLevel:()=>clampThinkingLevel,cleanupSessionResources:()=>cleanupSessionResources,collapseSystemMessages:()=>collapseSystemMessages,complete:()=>complete,completeSimple:()=>completeSimple,contentText:()=>contentText,createAssistantMessageDiagnostic:()=>createAssistantMessageDiagnostic,createAssistantMessageEventStream:()=>createAssistantMessageEventStream,createFauxCore:()=>createFauxCore,createInitialSystemMessage:()=>createInitialSystemMessage,createModels:()=>createModels,createProvider:()=>createProvider,declarationsEqual:()=>declarationsEqual,defaultProviderAuthContext:()=>defaultProviderAuthContext,envApiKeyAuth:()=>envApiKeyAuth,extractDiagnosticError:()=>extractDiagnosticError,fauxAssistantMessage:()=>fauxAssistantMessage,fauxProvider:()=>fauxProvider,fauxText:()=>fauxText,fauxThinking:()=>fauxThinking,fauxToolCall:()=>fauxToolCall,findEnvKeys:()=>findEnvKeys,formatThrownValue:()=>formatThrownValue,formatUserAgent:()=>formatUserAgent,generateImages:()=>generateImages,generateImagesOpenRouter:()=>generateImagesOpenRouter,getApiProvider:()=>getApiProvider,getApiProviders:()=>getApiProviders,getAttributionHeaders:()=>getAttributionHeaders,getClientVersion:()=>getClientVersion,getCurrentSystemMessage:()=>getCurrentSystemMessage,getCurrentSystemPrompt:()=>getCurrentSystemPrompt,getCurrentTools:()=>getCurrentTools,getDeclaredTools:()=>getDeclaredTools,getEnvApiKey:()=>getEnvApiKey,getIdentityHeaders:()=>getIdentityHeaders,getImageModel:()=>getImageModel,getImageModels:()=>getImageModels,getImageProviders:()=>getImageProviders,getImagesApiProvider:()=>getImagesApiProvider,getInitialSystemMessage:()=>getInitialSystemMessage,getModel:()=>getModel,getModelType:()=>getModelType,getModels:()=>getModels,getOpenCodeSessionHeaders:()=>getOpenCodeSessionHeaders,getOverflowPatterns:()=>getOverflowPatterns,getProviders:()=>getProviders,getSupportedThinkingLevels:()=>getSupportedThinkingLevels,getSystemMessageText:()=>getSystemMessageText,getToolStateChanges:()=>getToolStateChanges,googleGenerativeAIApi:()=>googleGenerativeAIApi,googleVertexApi:()=>googleVertexApi,hasApi:()=>hasApi,hasNonAdditiveToolChanges:()=>hasNonAdditiveToolChanges,hasToolRedefinitions:()=>hasToolRedefinitions,isContextOverflow:()=>isContextOverflow,isModelType:()=>isModelType,isRecoverableLength:()=>isRecoverableLength,isRetryableAssistantError:()=>isRetryableAssistantError,lazyApi:()=>lazyApi,lazyOAuth:()=>lazyOAuth,lazyStream:()=>lazyStream,mergeClientIdentity:()=>mergeClientIdentity,mistralConversationsApi:()=>mistralConversationsApi,modelsAreEqual:()=>modelsAreEqual,normalizeContext:()=>normalizeContext,openAICodexResponsesApi:()=>openAICodexResponsesApi,openAICompletionsApi:()=>openAICompletionsApi,openAIResponsesApi:()=>openAIResponsesApi,parseJsonWithRepair:()=>parseJsonWithRepair,parseStreamingJson:()=>parseStreamingJson,parseToolCallArguments:()=>parseToolCallArguments,piMessagesApi:()=>piMessagesApi,registerApiProvider:()=>registerApiProvider,registerBuiltInApiProviders:()=>registerBuiltInApiProviders,registerBuiltInImagesApiProviders:()=>registerBuiltInImagesApiProviders,registerFauxProvider:()=>registerFauxProvider,registerImagesApiProvider:()=>registerImagesApiProvider,registerSessionResourceCleanup:()=>registerSessionResourceCleanup,renderSystemMessageUpdate:()=>renderSystemMessageUpdate,repairJson:()=>repairJson,resetApiProviders:()=>resetApiProviders,resolveTranscript:()=>resolveTranscript,resolveTranscriptTools:()=>resolveTranscriptTools,retryAssistantCall:()=>retryAssistantCall,retryDelayMs:()=>retryDelayMs,setBedrockProviderModule:()=>setBedrockProviderModule,stream:()=>stream,streamAnthropic:()=>streamAnthropic,streamAzureOpenAIResponses:()=>streamAzureOpenAIResponses,streamGoogle:()=>streamGoogle,streamGoogleVertex:()=>streamGoogleVertex,streamMistral:()=>streamMistral,streamOpenAICodexResponses:()=>streamOpenAICodexResponses,streamOpenAICompletions:()=>streamOpenAICompletions,streamOpenAIResponses:()=>streamOpenAIResponses,streamSimple:()=>streamSimple,streamSimpleAnthropic:()=>streamSimpleAnthropic,streamSimpleAzureOpenAIResponses:()=>streamSimpleAzureOpenAIResponses,streamSimpleGoogle:()=>streamSimpleGoogle,streamSimpleGoogleVertex:()=>streamSimpleGoogleVertex,streamSimpleMistral:()=>streamSimpleMistral,streamSimpleOpenAICodexResponses:()=>streamSimpleOpenAICodexResponses,streamSimpleOpenAICompletions:()=>streamSimpleOpenAICompletions,streamSimpleOpenAIResponses:()=>streamSimpleOpenAIResponses,toToolDeclaration:()=>toToolDeclaration,unregisterApiProviders:()=>unregisterApiProviders,uuidv7:()=>uuidv7,validateToolArguments:()=>validateToolArguments,validateToolCall:()=>validateToolCall,withClientIdentity:()=>withClientIdentity,withoutInitialSystemMessage:()=>withoutInitialSystemMessage});function StringEnum(values,options){return typebox_exports.Unsafe({type:"string",enum:values,...options?.description&&{description:options.description},...options?.default&&{default:options.default}})}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":pi_ai_extension_view_exports,"@earendil-works/pi-ai/compat":pi_ai_extension_view_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":pi_ai_extension_view_exports,"@mariozechner/pi-ai/compat":pi_ai_extension_view_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-
|
|
3
|
+
import{configureHttpDispatcher,main}from"./chunks/chunk-MFRYL6YI.js";import"./chunks/chunk-62VOPMLK.js";import"./chunks/chunk-3TGLJEWK.js";import"./chunks/chunk-4EYXVSA5.js";import"./chunks/chunk-NZY7EIPA.js";import"./chunks/chunk-R2EGYMOO.js";import"./chunks/chunk-YZKQS34S.js";import"./chunks/chunk-6QGV3IWD.js";import{APP_NAME}from"./chunks/chunk-36QC74V4.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-FFMDRXC4.js";import"./chunks/chunk-NL4X6LBY.js";import"./chunks/chunk-LPXNMA2W.js";import"./chunks/chunk-V6KH5QG4.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));
|
package/dist/bundle/index.js
CHANGED
|
@@ -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-
|
|
2
|
+
import{ShowImagesSelectorComponent,ThemeSelectorComponent}from"./chunks/chunk-HK6CSLVH.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,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createLocalBashOperations,createLocalPowerShellOperations,createLsTool,createLsToolDefinition,createMcpExtension,createPowerShellTool,createPowerShellToolDefinition,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,isPowerShellToolResult,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-MFRYL6YI.js";import{DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,formatReadLineRange,formatSize,truncateHead,truncateLine,truncateTail,truncateToVisualLines}from"./chunks/chunk-62VOPMLK.js";import{ArminComponent}from"./chunks/chunk-3TGLJEWK.js";import{Theme,getLanguageFromPath,getMarkdownTheme,getSelectListTheme,getSettingsListTheme,highlightCode,initTheme,keyHint,keyText,rawKeyHint}from"./chunks/chunk-4EYXVSA5.js";import{ProjectTrustStore,hasTrustRequiringProjectResources}from"./chunks/chunk-NZY7EIPA.js";import{readStoredCredential}from"./chunks/chunk-R2EGYMOO.js";import{getPowerShellConfig,getShellConfig}from"./chunks/chunk-YZKQS34S.js";import"./chunks/chunk-6QGV3IWD.js";import{CONFIG_DIR_NAME,VERSION,getAgentDir,getDocsPath,getExamplesPath,getPackageDir,getReadmePath}from"./chunks/chunk-36QC74V4.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-FFMDRXC4.js";import"./chunks/chunk-NL4X6LBY.js";import"./chunks/chunk-LPXNMA2W.js";import"./chunks/chunk-V6KH5QG4.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,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createLocalBashOperations,createLocalPowerShellOperations,createLsTool,createLsToolDefinition,createMcpExtension,createPowerShellTool,createPowerShellToolDefinition,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,getPowerShellConfig,getReadmePath,getSelectListTheme,getSettingsListTheme,getShellConfig,hasTrustRequiringProjectResources,highlightCode,initTheme,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isPowerShellToolResult,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};
|
package/dist/bundle/rpc-entry.js
CHANGED
|
@@ -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-
|
|
3
|
+
import{configureHttpDispatcher,main}from"./chunks/chunk-MFRYL6YI.js";import"./chunks/chunk-62VOPMLK.js";import"./chunks/chunk-3TGLJEWK.js";import"./chunks/chunk-4EYXVSA5.js";import"./chunks/chunk-NZY7EIPA.js";import"./chunks/chunk-R2EGYMOO.js";import"./chunks/chunk-YZKQS34S.js";import"./chunks/chunk-6QGV3IWD.js";import{APP_NAME}from"./chunks/chunk-36QC74V4.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-FFMDRXC4.js";import"./chunks/chunk-NL4X6LBY.js";import"./chunks/chunk-LPXNMA2W.js";import"./chunks/chunk-V6KH5QG4.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)]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-move.d.ts","sourceRoot":"","sources":["../../src/core/session-move.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session-move.d.ts","sourceRoot":"","sources":["../../src/core/session-move.ts"],"names":[],"mappings":"AAyDA,yGAAyG;AACzG,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,SAAgB,GAAG,MAAM,CAqGvG"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Relocate an inactive session without rewriting its conversation history.
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
|
-
import { closeSync, fsyncSync, linkSync, lstatSync, mkdirSync, openSync, readdirSync, readFileSync, readSync, realpathSync, statSync, unlinkSync, writeFileSync, } from "node:fs";
|
|
3
|
+
import { closeSync, fsyncSync, linkSync, lstatSync, mkdirSync, openSync, readdirSync, readFileSync, readSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, } from "node:fs";
|
|
4
4
|
import { basename, dirname, join, resolve } from "node:path";
|
|
5
5
|
import { getAgentDir } from "../config.js";
|
|
6
6
|
import { canonicalizePath } from "../utils/paths.js";
|
|
@@ -78,8 +78,12 @@ export function moveSessionHere(sourcePath, targetCwd, agentDir = getAgentDir())
|
|
|
78
78
|
original.subarray(newline + 1),
|
|
79
79
|
]);
|
|
80
80
|
const destination = join(getDefaultSessionDir(target, agentDir), basename(source));
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
// A session can be stored under one folder while its header names another. The picker lists sessions by
|
|
82
|
+
// storage directory and labels them by the header, so such a session appears under the current folder
|
|
83
|
+
// wearing another folder's name, and asking to move it there lands here: the destination is the source.
|
|
84
|
+
// Nothing needs moving and nothing can be linked over an existing name, so relabel it in place instead
|
|
85
|
+
// of refusing -- the header is the only thing that disagrees with reality.
|
|
86
|
+
const inPlace = resolve(destination) === source;
|
|
83
87
|
const backupDir = join(agentDir, "session-move-backups");
|
|
84
88
|
mkdirSync(backupDir, { recursive: true, mode: 0o700 });
|
|
85
89
|
const backup = join(backupDir, `${randomUUID()}.jsonl`);
|
|
@@ -103,6 +107,21 @@ export function moveSessionHere(sourcePath, targetCwd, agentDir = getAgentDir())
|
|
|
103
107
|
finally {
|
|
104
108
|
closeSync(fd);
|
|
105
109
|
}
|
|
110
|
+
if (inPlace) {
|
|
111
|
+
try {
|
|
112
|
+
if (!readFileSync(temporary).equals(output))
|
|
113
|
+
throw new Error("Relabelled session verification failed.");
|
|
114
|
+
// rename replaces the destination, which is what an in-place relabel needs; the hard link below
|
|
115
|
+
// deliberately cannot replace anything, which is what makes a real move safe against a name that
|
|
116
|
+
// already exists. The backup written above holds the bytes being overwritten either way.
|
|
117
|
+
renameSync(temporary, destination);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
rmSync(temporary, { force: true });
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
return destination;
|
|
124
|
+
}
|
|
106
125
|
let published = false;
|
|
107
126
|
let marked = false;
|
|
108
127
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-move.js","sourceRoot":"","sources":["../../src/core/session-move.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,SAAS,EACT,SAAS,EACT,QAAQ,EACR,SAAS,EACT,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,aAAa,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAsB,MAAM,sBAAsB,CAAC;AAChF,OAAO,EACN,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,wBAAwB,GACxB,MAAM,wBAAwB,CAAC;AAEhC,SAAS,UAAU,CAAC,IAAY;IAC/B,MAAM,EAAE,GAAG,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC/B,IAAI,CA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B,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC;YACJ,8EAA8E;YAC9E,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;YACjC,SAAS,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;YACnG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;YAC/F,gBAAgB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YACtC,MAAM,GAAG,IAAI,CAAC;YACd,UAAU,CAAC,MAAM,CAAC,CAAC;QACpB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,MAAM;gBAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC;YACvC,IAAI,SAAS;gBAAE,UAAU,CAAC,WAAW,CAAC,CAAC;YACvC,MAAM,KAAK,CAAC;QACb,CAAC;gBAAS,CAAC;YACV,UAAU,CAAC,SAAS,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,WAAW,CAAC;IACpB,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Relocate an inactive session without rewriting its conversation history.\nimport { randomUUID } from \"node:crypto\";\nimport {\n\tcloseSync,\n\tfsyncSync,\n\tlinkSync,\n\tlstatSync,\n\tmkdirSync,\n\topenSync,\n\treaddirSync,\n\treadFileSync,\n\treadSync,\n\trealpathSync,\n\tstatSync,\n\tunlinkSync,\n\twriteFileSync,\n} from \"node:fs\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { getAgentDir } from \"../config.ts\";\nimport { canonicalizePath } from \"../utils/paths.ts\";\nimport { getDefaultSessionDir, type SessionHeader } from \"./session-manager.ts\";\nimport {\n\tassertSessionUnused,\n\tmarkSessionMoved,\n\tunmarkSessionMoved,\n\twithSessionOwnershipGate,\n} from \"./session-ownership.ts\";\n\nfunction readHeader(path: string): SessionHeader {\n\tconst fd = openSync(path, \"r\");\n\ttry {\n\t\tconst buffer = Buffer.alloc(1024 * 1024);\n\t\tconst count = readSync(fd, buffer, 0, buffer.length, 0);\n\t\tconst newline = buffer.subarray(0, count).indexOf(10);\n\t\tif (newline < 0) throw new Error(`Missing or oversized session header: ${path}`);\n\t\tconst value = JSON.parse(buffer.subarray(0, newline).toString(\"utf8\"));\n\t\tif (value?.type !== \"session\" || typeof value.id !== \"string\" || typeof value.cwd !== \"string\") {\n\t\t\tthrow new Error(`Invalid session header: ${path}`);\n\t\t}\n\t\treturn value as SessionHeader;\n\t} finally {\n\t\tcloseSync(fd);\n\t}\n}\n\nfunction writeDurableFile(path: string, content: Buffer | string): void {\n\tconst fd = openSync(path, \"wx\", 0o600);\n\ttry {\n\t\twriteFileSync(fd, content);\n\t\tfsyncSync(fd);\n\t} finally {\n\t\tcloseSync(fd);\n\t}\n}\n\n/** Move a default-storage session; retain a backup and refuse uncertain ownership or linked children. */\nexport function moveSessionHere(sourcePath: string, targetCwd: string, agentDir = getAgentDir()): string {\n\treturn withSessionOwnershipGate(() => {\n\t\tconst source = realpathSync(sourcePath);\n\t\tif (lstatSync(sourcePath).isSymbolicLink()) throw new Error(\"Moving symlinked session files is not supported.\");\n\t\tif (statSync(source).nlink !== 1) throw new Error(\"Moving hard-linked session files is not supported.\");\n\t\tconst target = realpathSync(targetCwd);\n\t\tif (!statSync(target).isDirectory()) throw new Error(\"Move destination must be a directory.\");\n\t\tconst header = readHeader(source);\n\t\tif (canonicalizePath(header.cwd) === target) throw new Error(\"Session already belongs to this directory.\");\n\t\tconst sessionsRoot = realpathSync(join(agentDir, \"sessions\"));\n\t\tif (dirname(dirname(source)) !== sessionsRoot)\n\t\t\tthrow new Error(\"Only default session storage is supported for now.\");\n\t\tassertSessionUnused(source);\n\n\t\t// Changing child headers would require a multi-file transaction. Do not silently break ancestry.\n\t\tfor (const directory of readdirSync(sessionsRoot, { withFileTypes: true })) {\n\t\t\tif (directory.isSymbolicLink())\n\t\t\t\tthrow new Error(\"Symlinked session storage needs manual review before moving.\");\n\t\t\tif (!directory.isDirectory()) continue;\n\t\t\tfor (const file of readdirSync(join(sessionsRoot, directory.name))) {\n\t\t\t\tif (!file.endsWith(\".jsonl\")) continue;\n\t\t\t\tconst child = readHeader(join(sessionsRoot, directory.name, file));\n\t\t\t\tif (child.parentSession && canonicalizePath(child.parentSession) === source) {\n\t\t\t\t\tthrow new Error(\"Session has forks or clones referencing its path; moving it is not supported yet.\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst original = readFileSync(source);\n\t\tconst newline = original.indexOf(10);\n\t\t// Validate every JSONL record, but preserve all bytes after the header, including unknown entry types.\n\t\tfor (const line of original.toString(\"utf8\").split(\"\\n\")) if (line.trim()) JSON.parse(line);\n\t\tconst output = Buffer.concat([\n\t\t\tBuffer.from(`${JSON.stringify({ ...header, cwd: target })}\\n`),\n\t\t\toriginal.subarray(newline + 1),\n\t\t]);\n\t\tconst destination = join(getDefaultSessionDir(target, agentDir), basename(source));\n\t\tif (resolve(destination) === source) throw new Error(\"Source and destination storage paths are identical.\");\n\t\tconst backupDir = join(agentDir, \"session-move-backups\");\n\t\tmkdirSync(backupDir, { recursive: true, mode: 0o700 });\n\t\tconst backup = join(backupDir, `${randomUUID()}.jsonl`);\n\t\twriteDurableFile(backup, original);\n\t\tif (!readFileSync(backup).equals(original)) throw new Error(`Backup verification failed: ${backup}`);\n\t\twriteDurableFile(\n\t\t\t`${backup}.metadata.json`,\n\t\t\t`${JSON.stringify({ source, destination, sessionId: header.id, created: new Date().toISOString() }, null, 2)}\\n`,\n\t\t);\n\t\tconst backupDirectoryFd = openSync(backupDir, \"r\");\n\t\ttry {\n\t\t\tfsyncSync(backupDirectoryFd);\n\t\t} finally {\n\t\t\tcloseSync(backupDirectoryFd);\n\t\t}\n\t\tconst temporary = `${destination}.${randomUUID()}.tmp`;\n\t\tconst fd = openSync(temporary, \"wx\", 0o600);\n\t\ttry {\n\t\t\twriteFileSync(fd, output);\n\t\t\tfsyncSync(fd);\n\t\t} finally {\n\t\t\tcloseSync(fd);\n\t\t}\n\t\tlet published = false;\n\t\tlet marked = false;\n\t\ttry {\n\t\t\t// Hard-link publication is atomic and never replaces an existing destination.\n\t\t\tlinkSync(temporary, destination);\n\t\t\tpublished = true;\n\t\t\tif (!readFileSync(destination).equals(output)) throw new Error(\"Destination verification failed.\");\n\t\t\tif (!readFileSync(source).equals(original)) throw new Error(\"Source changed during the move.\");\n\t\t\tmarkSessionMoved(source, destination);\n\t\t\tmarked = true;\n\t\t\tunlinkSync(source);\n\t\t} catch (error) {\n\t\t\tif (marked) unmarkSessionMoved(source);\n\t\t\tif (published) unlinkSync(destination);\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tunlinkSync(temporary);\n\t\t}\n\t\treturn destination;\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"session-move.js","sourceRoot":"","sources":["../../src/core/session-move.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,SAAS,EACT,SAAS,EACT,QAAQ,EACR,SAAS,EACT,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,MAAM,EACN,QAAQ,EACR,UAAU,EACV,aAAa,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAsB,MAAM,sBAAsB,CAAC;AAChF,OAAO,EACN,mBAAmB,EACnB,gBA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I,MAAM;gBAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC;YACvC,IAAI,SAAS;gBAAE,UAAU,CAAC,WAAW,CAAC,CAAC;YACvC,MAAM,KAAK,CAAC;QACb,CAAC;gBAAS,CAAC;YACV,UAAU,CAAC,SAAS,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,WAAW,CAAC;IACpB,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Relocate an inactive session without rewriting its conversation history.\nimport { randomUUID } from \"node:crypto\";\nimport {\n\tcloseSync,\n\tfsyncSync,\n\tlinkSync,\n\tlstatSync,\n\tmkdirSync,\n\topenSync,\n\treaddirSync,\n\treadFileSync,\n\treadSync,\n\trealpathSync,\n\trenameSync,\n\trmSync,\n\tstatSync,\n\tunlinkSync,\n\twriteFileSync,\n} from \"node:fs\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { getAgentDir } from \"../config.ts\";\nimport { canonicalizePath } from \"../utils/paths.ts\";\nimport { getDefaultSessionDir, type SessionHeader } from \"./session-manager.ts\";\nimport {\n\tassertSessionUnused,\n\tmarkSessionMoved,\n\tunmarkSessionMoved,\n\twithSessionOwnershipGate,\n} from \"./session-ownership.ts\";\n\nfunction readHeader(path: string): SessionHeader {\n\tconst fd = openSync(path, \"r\");\n\ttry {\n\t\tconst buffer = Buffer.alloc(1024 * 1024);\n\t\tconst count = readSync(fd, buffer, 0, buffer.length, 0);\n\t\tconst newline = buffer.subarray(0, count).indexOf(10);\n\t\tif (newline < 0) throw new Error(`Missing or oversized session header: ${path}`);\n\t\tconst value = JSON.parse(buffer.subarray(0, newline).toString(\"utf8\"));\n\t\tif (value?.type !== \"session\" || typeof value.id !== \"string\" || typeof value.cwd !== \"string\") {\n\t\t\tthrow new Error(`Invalid session header: ${path}`);\n\t\t}\n\t\treturn value as SessionHeader;\n\t} finally {\n\t\tcloseSync(fd);\n\t}\n}\n\nfunction writeDurableFile(path: string, content: Buffer | string): void {\n\tconst fd = openSync(path, \"wx\", 0o600);\n\ttry {\n\t\twriteFileSync(fd, content);\n\t\tfsyncSync(fd);\n\t} finally {\n\t\tcloseSync(fd);\n\t}\n}\n\n/** Move a default-storage session; retain a backup and refuse uncertain ownership or linked children. */\nexport function moveSessionHere(sourcePath: string, targetCwd: string, agentDir = getAgentDir()): string {\n\treturn withSessionOwnershipGate(() => {\n\t\tconst source = realpathSync(sourcePath);\n\t\tif (lstatSync(sourcePath).isSymbolicLink()) throw new Error(\"Moving symlinked session files is not supported.\");\n\t\tif (statSync(source).nlink !== 1) throw new Error(\"Moving hard-linked session files is not supported.\");\n\t\tconst target = realpathSync(targetCwd);\n\t\tif (!statSync(target).isDirectory()) throw new Error(\"Move destination must be a directory.\");\n\t\tconst header = readHeader(source);\n\t\tif (canonicalizePath(header.cwd) === target) throw new Error(\"Session already belongs to this directory.\");\n\t\tconst sessionsRoot = realpathSync(join(agentDir, \"sessions\"));\n\t\tif (dirname(dirname(source)) !== sessionsRoot)\n\t\t\tthrow new Error(\"Only default session storage is supported for now.\");\n\t\tassertSessionUnused(source);\n\n\t\t// Changing child headers would require a multi-file transaction. Do not silently break ancestry.\n\t\tfor (const directory of readdirSync(sessionsRoot, { withFileTypes: true })) {\n\t\t\tif (directory.isSymbolicLink())\n\t\t\t\tthrow new Error(\"Symlinked session storage needs manual review before moving.\");\n\t\t\tif (!directory.isDirectory()) continue;\n\t\t\tfor (const file of readdirSync(join(sessionsRoot, directory.name))) {\n\t\t\t\tif (!file.endsWith(\".jsonl\")) continue;\n\t\t\t\tconst child = readHeader(join(sessionsRoot, directory.name, file));\n\t\t\t\tif (child.parentSession && canonicalizePath(child.parentSession) === source) {\n\t\t\t\t\tthrow new Error(\"Session has forks or clones referencing its path; moving it is not supported yet.\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst original = readFileSync(source);\n\t\tconst newline = original.indexOf(10);\n\t\t// Validate every JSONL record, but preserve all bytes after the header, including unknown entry types.\n\t\tfor (const line of original.toString(\"utf8\").split(\"\\n\")) if (line.trim()) JSON.parse(line);\n\t\tconst output = Buffer.concat([\n\t\t\tBuffer.from(`${JSON.stringify({ ...header, cwd: target })}\\n`),\n\t\t\toriginal.subarray(newline + 1),\n\t\t]);\n\t\tconst destination = join(getDefaultSessionDir(target, agentDir), basename(source));\n\t\t// A session can be stored under one folder while its header names another. The picker lists sessions by\n\t\t// storage directory and labels them by the header, so such a session appears under the current folder\n\t\t// wearing another folder's name, and asking to move it there lands here: the destination is the source.\n\t\t// Nothing needs moving and nothing can be linked over an existing name, so relabel it in place instead\n\t\t// of refusing -- the header is the only thing that disagrees with reality.\n\t\tconst inPlace = resolve(destination) === source;\n\t\tconst backupDir = join(agentDir, \"session-move-backups\");\n\t\tmkdirSync(backupDir, { recursive: true, mode: 0o700 });\n\t\tconst backup = join(backupDir, `${randomUUID()}.jsonl`);\n\t\twriteDurableFile(backup, original);\n\t\tif (!readFileSync(backup).equals(original)) throw new Error(`Backup verification failed: ${backup}`);\n\t\twriteDurableFile(\n\t\t\t`${backup}.metadata.json`,\n\t\t\t`${JSON.stringify({ source, destination, sessionId: header.id, created: new Date().toISOString() }, null, 2)}\\n`,\n\t\t);\n\t\tconst backupDirectoryFd = openSync(backupDir, \"r\");\n\t\ttry {\n\t\t\tfsyncSync(backupDirectoryFd);\n\t\t} finally {\n\t\t\tcloseSync(backupDirectoryFd);\n\t\t}\n\t\tconst temporary = `${destination}.${randomUUID()}.tmp`;\n\t\tconst fd = openSync(temporary, \"wx\", 0o600);\n\t\ttry {\n\t\t\twriteFileSync(fd, output);\n\t\t\tfsyncSync(fd);\n\t\t} finally {\n\t\t\tcloseSync(fd);\n\t\t}\n\n\t\tif (inPlace) {\n\t\t\ttry {\n\t\t\t\tif (!readFileSync(temporary).equals(output)) throw new Error(\"Relabelled session verification failed.\");\n\t\t\t\t// rename replaces the destination, which is what an in-place relabel needs; the hard link below\n\t\t\t\t// deliberately cannot replace anything, which is what makes a real move safe against a name that\n\t\t\t\t// already exists. The backup written above holds the bytes being overwritten either way.\n\t\t\t\trenameSync(temporary, destination);\n\t\t\t} catch (error) {\n\t\t\t\trmSync(temporary, { force: true });\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\treturn destination;\n\t\t}\n\n\t\tlet published = false;\n\t\tlet marked = false;\n\t\ttry {\n\t\t\t// Hard-link publication is atomic and never replaces an existing destination.\n\t\t\tlinkSync(temporary, destination);\n\t\t\tpublished = true;\n\t\t\tif (!readFileSync(destination).equals(output)) throw new Error(\"Destination verification failed.\");\n\t\t\tif (!readFileSync(source).equals(original)) throw new Error(\"Source changed during the move.\");\n\t\t\tmarkSessionMoved(source, destination);\n\t\t\tmarked = true;\n\t\t\tunlinkSync(source);\n\t\t} catch (error) {\n\t\t\tif (marked) unmarkSessionMoved(source);\n\t\t\tif (published) unlinkSync(destination);\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tunlinkSync(temporary);\n\t\t}\n\t\treturn destination;\n\t});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-selector.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/session-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,SAAS,EACd,SAAS,EACT,KAAK,SAAS,EAOd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAMzF,OAAO,EAAyC,KAAK,UAAU,EAAE,KAAK,QAAQ,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"session-selector.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/session-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,SAAS,EACd,SAAS,EACT,KAAK,SAAS,EAOd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,OA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ACxF,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,WAAW,CAAC,EAAE,kBAAkB,CAAC;QACjC,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;KACzD,EACD,sBAAsB,CAAC,EAAE,MAAM,EA8H/B;IAED,OAAO,CAAC,WAAW;IAanB,OAAO,CAAC,eAAe;IAuBvB,OAAO,CAAC,cAAc;YASR,aAAa;YAwBb,SAAS;IAoEvB,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,gBAAgB;YAOV,4BAA4B;IAO1C,OAAO,CAAC,WAAW;IAWnB,cAAc,IAAI,WAAW,CAE5B;CACD"}
|
|
@@ -97,8 +97,7 @@ class SessionSelectorHeader {
|
|
|
97
97
|
}
|
|
98
98
|
invalidate() { }
|
|
99
99
|
render(width) {
|
|
100
|
-
const
|
|
101
|
-
const leftText = theme.bold(title);
|
|
100
|
+
const targetDir = shortenHomePath(this.moveTarget);
|
|
102
101
|
const sortLabel = this.sortMode === "threaded" ? "Threaded" : this.sortMode === "recent" ? "Recent" : "Fuzzy";
|
|
103
102
|
const sortText = theme.fg("muted", "Sort: ") + theme.fg("accent", sortLabel);
|
|
104
103
|
const nameLabel = this.nameFilter === "all" ? "All" : "Named";
|
|
@@ -116,6 +115,17 @@ class SessionSelectorHeader {
|
|
|
116
115
|
}
|
|
117
116
|
const rightText = truncateToWidth(`${scopeText} ${nameText} ${sortText}`, width, "");
|
|
118
117
|
const availableLeft = Math.max(0, width - visibleWidth(rightText) - 1);
|
|
118
|
+
// The directory Pi was started in, spelled out where the header otherwise says only "Current Folder",
|
|
119
|
+
// so it is legible while browsing rather than first in the move confirmation, after the key that starts
|
|
120
|
+
// a move is pressed. The readout on the right is fixed text, so the path gives way first: it loses
|
|
121
|
+
// leading segments and keeps its tail, because the last segment is what tells one project directory
|
|
122
|
+
// from another. When even that will not fit, the path moves to the hint line, which has the whole
|
|
123
|
+
// terminal width -- the folder is always on screen, in exactly one of the two places.
|
|
124
|
+
const label = this.scope === "current" ? "Current Folder" : "All";
|
|
125
|
+
const joiner = this.scope === "current" ? ": " : " · → ";
|
|
126
|
+
const fitted = fitPathTail(targetDir, availableLeft - visibleWidth(`Resume Session (${label}${joiner})`));
|
|
127
|
+
const title = fitted === undefined ? `Resume Session (${label})` : `Resume Session (${label}${joiner}${fitted})`;
|
|
128
|
+
const leftText = theme.bold(title);
|
|
119
129
|
const left = truncateToWidth(leftText, availableLeft, "");
|
|
120
130
|
const spacing = Math.max(0, width - visibleWidth(left) - visibleWidth(rightText));
|
|
121
131
|
// Build hint lines - changes based on state (all branches truncate to width)
|
|
@@ -138,13 +148,8 @@ class SessionSelectorHeader {
|
|
|
138
148
|
else {
|
|
139
149
|
const pathState = this.showPath ? "(on)" : "(off)";
|
|
140
150
|
const sep = theme.fg("muted", " · ");
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
// path was cut before it started. Without this the destination first appears in the move confirmation,
|
|
144
|
-
// which is after the key that starts the move has already been pressed.
|
|
145
|
-
const targetHint = theme.fg("muted", `→ ${shortenHomePath(this.moveTarget)}`);
|
|
146
|
-
const hint1 = targetHint +
|
|
147
|
-
sep +
|
|
151
|
+
const fallbackPath = fitted === undefined ? theme.fg("muted", `→ ${targetDir}`) + sep : "";
|
|
152
|
+
const hint1 = fallbackPath +
|
|
148
153
|
keyHint("tui.input.tab", "scope") +
|
|
149
154
|
sep +
|
|
150
155
|
theme.fg("muted", 're:<pattern> regex · "phrase" exact');
|
|
@@ -166,6 +171,24 @@ class SessionSelectorHeader {
|
|
|
166
171
|
return [`${left}${" ".repeat(spacing)}${rightText}`, hintLine1, hintLine2];
|
|
167
172
|
}
|
|
168
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Fit a path into `budget` columns by dropping leading segments and keeping the tail, marked
|
|
176
|
+
* with a leading ellipsis. Returns undefined when even `…/<last segment>` will not fit, so the
|
|
177
|
+
* caller can leave the path out instead of showing a fragment that identifies nothing.
|
|
178
|
+
*/
|
|
179
|
+
function fitPathTail(path, budget) {
|
|
180
|
+
if (budget <= 0)
|
|
181
|
+
return undefined;
|
|
182
|
+
if (visibleWidth(path) <= budget)
|
|
183
|
+
return path;
|
|
184
|
+
const segments = path.split(/[/\\]/).filter((segment) => segment.length > 0);
|
|
185
|
+
for (let start = 1; start < segments.length; start++) {
|
|
186
|
+
const candidate = `…/${segments.slice(start).join("/")}`;
|
|
187
|
+
if (visibleWidth(candidate) <= budget)
|
|
188
|
+
return candidate;
|
|
189
|
+
}
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
169
192
|
/**
|
|
170
193
|
* Build a tree structure from sessions based on parentSessionPath.
|
|
171
194
|
* Returns root nodes sorted by modified date (descending).
|