@maxmo74/pi-coding-agent 1.5.0-max.6 → 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/dist/bundle/chunks/{chunk-KZW44KNK.js → chunk-HK6CSLVH.js} +1 -1
- package/dist/bundle/chunks/{chunk-RVQPMSKJ.js → chunk-MFRYL6YI.js} +14 -14
- package/dist/bundle/chunks/{virtual-modules-KHAOYCUO.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/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-KZW44KNK.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-RVQPMSKJ.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,CAAC;QACJ,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;QACzC,MAAM,KAAK,GAAG,QAAQ,CA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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,gBAAgB,EAChB,kBAAkB,EAClB,wBAAwB,GACxB,MAAM,wBAAwB,CAAC;AAEhC,SAAS,UAAU,CAAC,IAAY;IAC/B,MAAM,EAAE,GAAG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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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maxmo74/pi-coding-agent",
|
|
3
|
-
"version": "1.5.0-max.
|
|
3
|
+
"version": "1.5.0-max.7",
|
|
4
4
|
"description": "Unofficial pi fork by maxmo74. Adds a move action to the /resume picker, so a session recorded under another directory opens here without copying files, and refuses to open a session another pi process already holds, which silently forks its history (reported upstream as #11684 and declined). Builds are cut from upstream release tags. Not affiliated with pi.dev.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"piConfig": {
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
},
|
|
89
89
|
"piFork": {
|
|
90
90
|
"upstreamVersion": "1.5.0",
|
|
91
|
-
"sourceCommit": "
|
|
92
|
-
"builtAt": "2026-11-
|
|
91
|
+
"sourceCommit": "cbcde1a504fe52698ffce39497b05be66f205957",
|
|
92
|
+
"builtAt": "2026-11-09T08:49:40.427Z"
|
|
93
93
|
}
|
|
94
94
|
}
|