@prompd/core 0.5.0-beta.12 → 0.5.0-beta.14

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/index.d.cts CHANGED
@@ -670,6 +670,79 @@ declare class MemoryPackageResolver implements IPackageResolver {
670
670
  resolvePackage(packageRef: string, options: ResolvePackageOptions): Promise<string>;
671
671
  }
672
672
 
673
+ /**
674
+ * A writable sink the host injects so installPackage stays FS-/Node-agnostic.
675
+ * Browser: an adapter over the workspace FileService; CLI/sidecar: over Node fs.
676
+ */
677
+ interface PackageStore {
678
+ /** Write a UTF-8 file, creating parent directories as needed. */
679
+ writeFile(path: string, content: string): void | Promise<void>;
680
+ /** Remove a directory and its contents if present, for a clean reinstall. */
681
+ removeDir?(path: string): void | Promise<void>;
682
+ }
683
+ interface InstallPackageOptions {
684
+ /** "@scope/name@version" or "@scope/name" (defaults to latest). */
685
+ ref: string;
686
+ /** Artifact type — selects the .prompd subdir (packages/skills/workflows/templates). */
687
+ type: PackageType;
688
+ /**
689
+ * Install root the caller chose: the open workspace folder (browser/local) or the
690
+ * home dir for a global install (sidecar/CLI). installPackage NEVER computes '~'
691
+ * itself — core stays Node-free.
692
+ */
693
+ root: string;
694
+ /** Writable sink for the chosen host. */
695
+ store: PackageStore;
696
+ /**
697
+ * Fetch the .pdpkg bytes for a (name, version). Injected: the registry client in
698
+ * the browser, a Node fetch in the CLI. May resolve 'latest' to a concrete version.
699
+ */
700
+ download: PackageDownloader;
701
+ }
702
+ interface InstalledPackage {
703
+ /** Full scoped name (manifest-authoritative when present), e.g. "@prompd/core". */
704
+ name: string;
705
+ /** Resolved version (from the package manifest when present). */
706
+ version: string;
707
+ scope?: string;
708
+ /** Install dir written to: <root>/.prompd/<typeDir>/<name>. */
709
+ installedPath: string;
710
+ /** Entry-relative paths written under installedPath. */
711
+ files: string[];
712
+ }
713
+ /**
714
+ * Install a registry artifact into <root>/.prompd/<typeDir>/<name>/, replacing any
715
+ * prior install (idempotent). The host injects the writable `store` and the
716
+ * `download` fetcher, so the same install runs in the browser and the CLI/sidecar.
717
+ * Returns the resolved name/version (manifest-authoritative when present) and the
718
+ * files written. Rejects entries that escape the install directory (zip-slip) and
719
+ * archives over the size cap.
720
+ */
721
+ declare function installPackage(opts: InstallPackageOptions): Promise<InstalledPackage>;
722
+ interface UninstallPackageOptions {
723
+ /** "@scope/name" (a version suffix is accepted but ignored — one install per name). */
724
+ ref: string;
725
+ /** Artifact type — selects the .prompd subdir. */
726
+ type: PackageType;
727
+ /** Install root the caller chose (the open workspace, or '~' for a global install). */
728
+ root: string;
729
+ /** Writable sink for the chosen host; removeDir is required to uninstall. */
730
+ store: PackageStore;
731
+ }
732
+ interface UninstalledPackage {
733
+ name: string;
734
+ scope?: string;
735
+ /** The directory that was removed: <root>/.prompd/<typeDir>/<name>. */
736
+ installedPath: string;
737
+ }
738
+ /**
739
+ * Uninstall an artifact: remove <root>/.prompd/<typeDir>/<name>/ via the injected
740
+ * store. The symmetric inverse of installPackage, sharing the same install-dir
741
+ * computation. Idempotent — removing an absent install is a no-op (the host's
742
+ * removeDir should swallow not-found). Throws if the store can't remove directories.
743
+ */
744
+ declare function uninstallPackage(opts: UninstallPackageOptions): Promise<UninstalledPackage>;
745
+
673
746
  /**
674
747
  * Language Mapping Utilities
675
748
  *
@@ -2963,4 +3036,4 @@ declare function validateWorkflow(workflow: WorkflowFile): ValidationResult;
2963
3036
  */
2964
3037
  declare function validateWorkflowQuick(workflow: WorkflowFile): Pick<ValidationResult, 'isValid'>;
2965
3038
 
2966
- export { type AgentCheckpointEvent, type AgentCheckpointEventType, type AgentIterationRecord, type AgentNodeData, type AgentTool, AnthropicFormatter, type ApiNodeData, type AsyncFileBackend, BUILTIN_COMMAND_EXECUTABLES, type BaseNodeData, CODE_EXTENSIONS, CONTENT_TYPES, type CallbackNodeData, type ChatAgentCheckpointConfig, type ChatAgentNodeData, type ClaudeCodeNodeData, CodeGenerationStage, type CodeNodeData, type CommandNodeData, CompilationContext, type CompilationDiagnostic, CompilationError, type CompilationOptions, CompilationStage, type CompiledPrompt, CompilerPipeline, type CompilerStage, type CompleteEventData, type ConditionBranch, type ConditionNodeData, type Config, type CustomCommandConfig, type CustomConnectionConfig, type CustomProvider, DEFAULT_SECURITY_CONFIG, DOCKABLE_HANDLES, DOCKABLE_NODE_TYPES, type DatabaseConnectionConfig, type DatabaseQueryNodeData, DependencyResolutionStage, EXTENSION_TO_LANGUAGE, EXTENSION_TO_LANGUAGE_ALIASES, type ErrorEventData, type ErrorHandlerNodeData, type ErrorHandlingConfig, type ExecuteOptions, type ExecutionConfig, type GitHubConnectionConfig, type GuardrailNodeData, type HttpApiConnectionConfig, HybridFileSystem, type IFileSystem, type IPackageResolver, type IterationEventData, type JsonSchema, type LLMResponse, LexicalAnalysisStage, type LoopNodeData, MEMORY_OPERATIONS_BY_MODE, MarkdownFormatter, type McpServerConnectionConfig, type McpToolNodeData, MemoryFileSystem, type MemoryNodeData, type MemoryOperation, MemoryPackageResolver, type MergeNodeData, type NodeExecutionState, type NodeExecutionStatus, OpenAIFormatter, type OutputFormatter, type OutputNodeData, PACKAGE_TYPE_DIRS, PROMPD_EXTENSIONS, type PackageAlias, type PackageDownloader, type PackageType, type ParallelBranch, type ParallelNodeData, ParseError, type ParsedWorkflow, PrompdCompiler, PrompdError, type PrompdFile, PrompdLoader, type PrompdMetadata, type PrompdParameter, PrompdParser, type PromptNodeData, type ProviderConfig, type ProviderNodeData, type RegistryConfig, type ResolvePackageOptions, type ResolvedPackage, type RetryPolicy, type SSHConnectionConfig, type SectionInfo, SectionOverrideProcessor, type SecurityConfig, SecurityError, SemanticAnalysisStage, type SlackConnectionConfig, TOOL_DEPLOY_DIRS, TemplateProcessingStage, type ThinkingEventData, type ToolCallEventData, type ToolCallParserNodeData, type ToolCallRouterNodeData, type ToolNodeData, type TransformerNodeData, type TriggerNodeData, type UserInputNodeData, type UsingPackage, VALID_PACKAGE_TYPES, ValidationError, type ValidationIssue, type ValidationResult, type WebSearchNodeData, type WebSocketConnectionConfig, type WorkflowConnection, type WorkflowConnectionConfig, type WorkflowConnectionStatus, type WorkflowConnectionType, type WorkflowEdge, type WorkflowExecutionError, type WorkflowExecutionState, type WorkflowExecutionStatus, type WorkflowFile, type WorkflowMetadata, type WorkflowNode, type WorkflowNodeData, type WorkflowNodeType, type WorkflowParameter, type WorkflowResult, type WorkflowValidationError, type WorkflowValidationWarning, type WorkflowVariable, basenamePosix, compile, createCoreStages, createEmptyWorkflow, createPrompdEnvironment, createWorkflowNode, dirnamePosix, extname, extractPdpkg, getContentType, getExecutionOrder, getInstallDirForType, getLanguageAliasesForExtension, getLanguageForExtension, isAbsolutePosix, isPrompdFile, isValidPackageReference, isValidPackageType, joinPosix, needsFrontmatterProtection, normalizePosix, parsePackageReference, parsePackageReferenceWithPath, parseWorkflow, resolvePackageFile, resolvePosix, serializeWorkflow, stripFilePath, validateWorkflow, validateWorkflowQuick };
3039
+ export { type AgentCheckpointEvent, type AgentCheckpointEventType, type AgentIterationRecord, type AgentNodeData, type AgentTool, AnthropicFormatter, type ApiNodeData, type AsyncFileBackend, BUILTIN_COMMAND_EXECUTABLES, type BaseNodeData, CODE_EXTENSIONS, CONTENT_TYPES, type CallbackNodeData, type ChatAgentCheckpointConfig, type ChatAgentNodeData, type ClaudeCodeNodeData, CodeGenerationStage, type CodeNodeData, type CommandNodeData, CompilationContext, type CompilationDiagnostic, CompilationError, type CompilationOptions, CompilationStage, type CompiledPrompt, CompilerPipeline, type CompilerStage, type CompleteEventData, type ConditionBranch, type ConditionNodeData, type Config, type CustomCommandConfig, type CustomConnectionConfig, type CustomProvider, DEFAULT_SECURITY_CONFIG, DOCKABLE_HANDLES, DOCKABLE_NODE_TYPES, type DatabaseConnectionConfig, type DatabaseQueryNodeData, DependencyResolutionStage, EXTENSION_TO_LANGUAGE, EXTENSION_TO_LANGUAGE_ALIASES, type ErrorEventData, type ErrorHandlerNodeData, type ErrorHandlingConfig, type ExecuteOptions, type ExecutionConfig, type GitHubConnectionConfig, type GuardrailNodeData, type HttpApiConnectionConfig, HybridFileSystem, type IFileSystem, type IPackageResolver, type InstallPackageOptions, type InstalledPackage, type IterationEventData, type JsonSchema, type LLMResponse, LexicalAnalysisStage, type LoopNodeData, MEMORY_OPERATIONS_BY_MODE, MarkdownFormatter, type McpServerConnectionConfig, type McpToolNodeData, MemoryFileSystem, type MemoryNodeData, type MemoryOperation, MemoryPackageResolver, type MergeNodeData, type NodeExecutionState, type NodeExecutionStatus, OpenAIFormatter, type OutputFormatter, type OutputNodeData, PACKAGE_TYPE_DIRS, PROMPD_EXTENSIONS, type PackageAlias, type PackageDownloader, type PackageStore, type PackageType, type ParallelBranch, type ParallelNodeData, ParseError, type ParsedWorkflow, PrompdCompiler, PrompdError, type PrompdFile, PrompdLoader, type PrompdMetadata, type PrompdParameter, PrompdParser, type PromptNodeData, type ProviderConfig, type ProviderNodeData, type RegistryConfig, type ResolvePackageOptions, type ResolvedPackage, type RetryPolicy, type SSHConnectionConfig, type SectionInfo, SectionOverrideProcessor, type SecurityConfig, SecurityError, SemanticAnalysisStage, type SlackConnectionConfig, TOOL_DEPLOY_DIRS, TemplateProcessingStage, type ThinkingEventData, type ToolCallEventData, type ToolCallParserNodeData, type ToolCallRouterNodeData, type ToolNodeData, type TransformerNodeData, type TriggerNodeData, type UninstallPackageOptions, type UninstalledPackage, type UserInputNodeData, type UsingPackage, VALID_PACKAGE_TYPES, ValidationError, type ValidationIssue, type ValidationResult, type WebSearchNodeData, type WebSocketConnectionConfig, type WorkflowConnection, type WorkflowConnectionConfig, type WorkflowConnectionStatus, type WorkflowConnectionType, type WorkflowEdge, type WorkflowExecutionError, type WorkflowExecutionState, type WorkflowExecutionStatus, type WorkflowFile, type WorkflowMetadata, type WorkflowNode, type WorkflowNodeData, type WorkflowNodeType, type WorkflowParameter, type WorkflowResult, type WorkflowValidationError, type WorkflowValidationWarning, type WorkflowVariable, basenamePosix, compile, createCoreStages, createEmptyWorkflow, createPrompdEnvironment, createWorkflowNode, dirnamePosix, extname, extractPdpkg, getContentType, getExecutionOrder, getInstallDirForType, getLanguageAliasesForExtension, getLanguageForExtension, installPackage, isAbsolutePosix, isPrompdFile, isValidPackageReference, isValidPackageType, joinPosix, needsFrontmatterProtection, normalizePosix, parsePackageReference, parsePackageReferenceWithPath, parseWorkflow, resolvePackageFile, resolvePosix, serializeWorkflow, stripFilePath, uninstallPackage, validateWorkflow, validateWorkflowQuick };
package/dist/index.d.ts CHANGED
@@ -670,6 +670,79 @@ declare class MemoryPackageResolver implements IPackageResolver {
670
670
  resolvePackage(packageRef: string, options: ResolvePackageOptions): Promise<string>;
671
671
  }
672
672
 
673
+ /**
674
+ * A writable sink the host injects so installPackage stays FS-/Node-agnostic.
675
+ * Browser: an adapter over the workspace FileService; CLI/sidecar: over Node fs.
676
+ */
677
+ interface PackageStore {
678
+ /** Write a UTF-8 file, creating parent directories as needed. */
679
+ writeFile(path: string, content: string): void | Promise<void>;
680
+ /** Remove a directory and its contents if present, for a clean reinstall. */
681
+ removeDir?(path: string): void | Promise<void>;
682
+ }
683
+ interface InstallPackageOptions {
684
+ /** "@scope/name@version" or "@scope/name" (defaults to latest). */
685
+ ref: string;
686
+ /** Artifact type — selects the .prompd subdir (packages/skills/workflows/templates). */
687
+ type: PackageType;
688
+ /**
689
+ * Install root the caller chose: the open workspace folder (browser/local) or the
690
+ * home dir for a global install (sidecar/CLI). installPackage NEVER computes '~'
691
+ * itself — core stays Node-free.
692
+ */
693
+ root: string;
694
+ /** Writable sink for the chosen host. */
695
+ store: PackageStore;
696
+ /**
697
+ * Fetch the .pdpkg bytes for a (name, version). Injected: the registry client in
698
+ * the browser, a Node fetch in the CLI. May resolve 'latest' to a concrete version.
699
+ */
700
+ download: PackageDownloader;
701
+ }
702
+ interface InstalledPackage {
703
+ /** Full scoped name (manifest-authoritative when present), e.g. "@prompd/core". */
704
+ name: string;
705
+ /** Resolved version (from the package manifest when present). */
706
+ version: string;
707
+ scope?: string;
708
+ /** Install dir written to: <root>/.prompd/<typeDir>/<name>. */
709
+ installedPath: string;
710
+ /** Entry-relative paths written under installedPath. */
711
+ files: string[];
712
+ }
713
+ /**
714
+ * Install a registry artifact into <root>/.prompd/<typeDir>/<name>/, replacing any
715
+ * prior install (idempotent). The host injects the writable `store` and the
716
+ * `download` fetcher, so the same install runs in the browser and the CLI/sidecar.
717
+ * Returns the resolved name/version (manifest-authoritative when present) and the
718
+ * files written. Rejects entries that escape the install directory (zip-slip) and
719
+ * archives over the size cap.
720
+ */
721
+ declare function installPackage(opts: InstallPackageOptions): Promise<InstalledPackage>;
722
+ interface UninstallPackageOptions {
723
+ /** "@scope/name" (a version suffix is accepted but ignored — one install per name). */
724
+ ref: string;
725
+ /** Artifact type — selects the .prompd subdir. */
726
+ type: PackageType;
727
+ /** Install root the caller chose (the open workspace, or '~' for a global install). */
728
+ root: string;
729
+ /** Writable sink for the chosen host; removeDir is required to uninstall. */
730
+ store: PackageStore;
731
+ }
732
+ interface UninstalledPackage {
733
+ name: string;
734
+ scope?: string;
735
+ /** The directory that was removed: <root>/.prompd/<typeDir>/<name>. */
736
+ installedPath: string;
737
+ }
738
+ /**
739
+ * Uninstall an artifact: remove <root>/.prompd/<typeDir>/<name>/ via the injected
740
+ * store. The symmetric inverse of installPackage, sharing the same install-dir
741
+ * computation. Idempotent — removing an absent install is a no-op (the host's
742
+ * removeDir should swallow not-found). Throws if the store can't remove directories.
743
+ */
744
+ declare function uninstallPackage(opts: UninstallPackageOptions): Promise<UninstalledPackage>;
745
+
673
746
  /**
674
747
  * Language Mapping Utilities
675
748
  *
@@ -2963,4 +3036,4 @@ declare function validateWorkflow(workflow: WorkflowFile): ValidationResult;
2963
3036
  */
2964
3037
  declare function validateWorkflowQuick(workflow: WorkflowFile): Pick<ValidationResult, 'isValid'>;
2965
3038
 
2966
- export { type AgentCheckpointEvent, type AgentCheckpointEventType, type AgentIterationRecord, type AgentNodeData, type AgentTool, AnthropicFormatter, type ApiNodeData, type AsyncFileBackend, BUILTIN_COMMAND_EXECUTABLES, type BaseNodeData, CODE_EXTENSIONS, CONTENT_TYPES, type CallbackNodeData, type ChatAgentCheckpointConfig, type ChatAgentNodeData, type ClaudeCodeNodeData, CodeGenerationStage, type CodeNodeData, type CommandNodeData, CompilationContext, type CompilationDiagnostic, CompilationError, type CompilationOptions, CompilationStage, type CompiledPrompt, CompilerPipeline, type CompilerStage, type CompleteEventData, type ConditionBranch, type ConditionNodeData, type Config, type CustomCommandConfig, type CustomConnectionConfig, type CustomProvider, DEFAULT_SECURITY_CONFIG, DOCKABLE_HANDLES, DOCKABLE_NODE_TYPES, type DatabaseConnectionConfig, type DatabaseQueryNodeData, DependencyResolutionStage, EXTENSION_TO_LANGUAGE, EXTENSION_TO_LANGUAGE_ALIASES, type ErrorEventData, type ErrorHandlerNodeData, type ErrorHandlingConfig, type ExecuteOptions, type ExecutionConfig, type GitHubConnectionConfig, type GuardrailNodeData, type HttpApiConnectionConfig, HybridFileSystem, type IFileSystem, type IPackageResolver, type IterationEventData, type JsonSchema, type LLMResponse, LexicalAnalysisStage, type LoopNodeData, MEMORY_OPERATIONS_BY_MODE, MarkdownFormatter, type McpServerConnectionConfig, type McpToolNodeData, MemoryFileSystem, type MemoryNodeData, type MemoryOperation, MemoryPackageResolver, type MergeNodeData, type NodeExecutionState, type NodeExecutionStatus, OpenAIFormatter, type OutputFormatter, type OutputNodeData, PACKAGE_TYPE_DIRS, PROMPD_EXTENSIONS, type PackageAlias, type PackageDownloader, type PackageType, type ParallelBranch, type ParallelNodeData, ParseError, type ParsedWorkflow, PrompdCompiler, PrompdError, type PrompdFile, PrompdLoader, type PrompdMetadata, type PrompdParameter, PrompdParser, type PromptNodeData, type ProviderConfig, type ProviderNodeData, type RegistryConfig, type ResolvePackageOptions, type ResolvedPackage, type RetryPolicy, type SSHConnectionConfig, type SectionInfo, SectionOverrideProcessor, type SecurityConfig, SecurityError, SemanticAnalysisStage, type SlackConnectionConfig, TOOL_DEPLOY_DIRS, TemplateProcessingStage, type ThinkingEventData, type ToolCallEventData, type ToolCallParserNodeData, type ToolCallRouterNodeData, type ToolNodeData, type TransformerNodeData, type TriggerNodeData, type UserInputNodeData, type UsingPackage, VALID_PACKAGE_TYPES, ValidationError, type ValidationIssue, type ValidationResult, type WebSearchNodeData, type WebSocketConnectionConfig, type WorkflowConnection, type WorkflowConnectionConfig, type WorkflowConnectionStatus, type WorkflowConnectionType, type WorkflowEdge, type WorkflowExecutionError, type WorkflowExecutionState, type WorkflowExecutionStatus, type WorkflowFile, type WorkflowMetadata, type WorkflowNode, type WorkflowNodeData, type WorkflowNodeType, type WorkflowParameter, type WorkflowResult, type WorkflowValidationError, type WorkflowValidationWarning, type WorkflowVariable, basenamePosix, compile, createCoreStages, createEmptyWorkflow, createPrompdEnvironment, createWorkflowNode, dirnamePosix, extname, extractPdpkg, getContentType, getExecutionOrder, getInstallDirForType, getLanguageAliasesForExtension, getLanguageForExtension, isAbsolutePosix, isPrompdFile, isValidPackageReference, isValidPackageType, joinPosix, needsFrontmatterProtection, normalizePosix, parsePackageReference, parsePackageReferenceWithPath, parseWorkflow, resolvePackageFile, resolvePosix, serializeWorkflow, stripFilePath, validateWorkflow, validateWorkflowQuick };
3039
+ export { type AgentCheckpointEvent, type AgentCheckpointEventType, type AgentIterationRecord, type AgentNodeData, type AgentTool, AnthropicFormatter, type ApiNodeData, type AsyncFileBackend, BUILTIN_COMMAND_EXECUTABLES, type BaseNodeData, CODE_EXTENSIONS, CONTENT_TYPES, type CallbackNodeData, type ChatAgentCheckpointConfig, type ChatAgentNodeData, type ClaudeCodeNodeData, CodeGenerationStage, type CodeNodeData, type CommandNodeData, CompilationContext, type CompilationDiagnostic, CompilationError, type CompilationOptions, CompilationStage, type CompiledPrompt, CompilerPipeline, type CompilerStage, type CompleteEventData, type ConditionBranch, type ConditionNodeData, type Config, type CustomCommandConfig, type CustomConnectionConfig, type CustomProvider, DEFAULT_SECURITY_CONFIG, DOCKABLE_HANDLES, DOCKABLE_NODE_TYPES, type DatabaseConnectionConfig, type DatabaseQueryNodeData, DependencyResolutionStage, EXTENSION_TO_LANGUAGE, EXTENSION_TO_LANGUAGE_ALIASES, type ErrorEventData, type ErrorHandlerNodeData, type ErrorHandlingConfig, type ExecuteOptions, type ExecutionConfig, type GitHubConnectionConfig, type GuardrailNodeData, type HttpApiConnectionConfig, HybridFileSystem, type IFileSystem, type IPackageResolver, type InstallPackageOptions, type InstalledPackage, type IterationEventData, type JsonSchema, type LLMResponse, LexicalAnalysisStage, type LoopNodeData, MEMORY_OPERATIONS_BY_MODE, MarkdownFormatter, type McpServerConnectionConfig, type McpToolNodeData, MemoryFileSystem, type MemoryNodeData, type MemoryOperation, MemoryPackageResolver, type MergeNodeData, type NodeExecutionState, type NodeExecutionStatus, OpenAIFormatter, type OutputFormatter, type OutputNodeData, PACKAGE_TYPE_DIRS, PROMPD_EXTENSIONS, type PackageAlias, type PackageDownloader, type PackageStore, type PackageType, type ParallelBranch, type ParallelNodeData, ParseError, type ParsedWorkflow, PrompdCompiler, PrompdError, type PrompdFile, PrompdLoader, type PrompdMetadata, type PrompdParameter, PrompdParser, type PromptNodeData, type ProviderConfig, type ProviderNodeData, type RegistryConfig, type ResolvePackageOptions, type ResolvedPackage, type RetryPolicy, type SSHConnectionConfig, type SectionInfo, SectionOverrideProcessor, type SecurityConfig, SecurityError, SemanticAnalysisStage, type SlackConnectionConfig, TOOL_DEPLOY_DIRS, TemplateProcessingStage, type ThinkingEventData, type ToolCallEventData, type ToolCallParserNodeData, type ToolCallRouterNodeData, type ToolNodeData, type TransformerNodeData, type TriggerNodeData, type UninstallPackageOptions, type UninstalledPackage, type UserInputNodeData, type UsingPackage, VALID_PACKAGE_TYPES, ValidationError, type ValidationIssue, type ValidationResult, type WebSearchNodeData, type WebSocketConnectionConfig, type WorkflowConnection, type WorkflowConnectionConfig, type WorkflowConnectionStatus, type WorkflowConnectionType, type WorkflowEdge, type WorkflowExecutionError, type WorkflowExecutionState, type WorkflowExecutionStatus, type WorkflowFile, type WorkflowMetadata, type WorkflowNode, type WorkflowNodeData, type WorkflowNodeType, type WorkflowParameter, type WorkflowResult, type WorkflowValidationError, type WorkflowValidationWarning, type WorkflowVariable, basenamePosix, compile, createCoreStages, createEmptyWorkflow, createPrompdEnvironment, createWorkflowNode, dirnamePosix, extname, extractPdpkg, getContentType, getExecutionOrder, getInstallDirForType, getLanguageAliasesForExtension, getLanguageForExtension, installPackage, isAbsolutePosix, isPrompdFile, isValidPackageReference, isValidPackageType, joinPosix, needsFrontmatterProtection, normalizePosix, parsePackageReference, parsePackageReferenceWithPath, parseWorkflow, resolvePackageFile, resolvePosix, serializeWorkflow, stripFilePath, uninstallPackage, validateWorkflow, validateWorkflowQuick };
package/dist/index.js CHANGED
@@ -3339,6 +3339,75 @@ var HybridFileSystem = class {
3339
3339
  }
3340
3340
  };
3341
3341
 
3342
+ // src/lib/compiler/install.ts
3343
+ var MAX_PACKAGE_SIZE = 50 * 1024 * 1024;
3344
+ function joinPosix3(...parts) {
3345
+ const joined = parts.filter((p) => p && p !== ".").join("/").replace(/\/{2,}/g, "/");
3346
+ return joined.replace(/\/+$/, "") || "/";
3347
+ }
3348
+ function normalizeSegments(p) {
3349
+ const out = [];
3350
+ for (const seg of p.split("/")) {
3351
+ if (!seg || seg === ".") continue;
3352
+ if (seg === "..") {
3353
+ out.pop();
3354
+ continue;
3355
+ }
3356
+ out.push(seg);
3357
+ }
3358
+ return out.join("/");
3359
+ }
3360
+ function resolveInstallDir(root, type, name) {
3361
+ return joinPosix3(root, ".prompd", getInstallDirForType(type), name);
3362
+ }
3363
+ async function installPackage(opts) {
3364
+ const { ref, type, root, store, download } = opts;
3365
+ const parsed = parsePackageReference(ref);
3366
+ const bytes = await download(parsed.name, parsed.version);
3367
+ if (bytes.length > MAX_PACKAGE_SIZE) {
3368
+ throw new Error(`Package too large: ${bytes.length} bytes (max ${MAX_PACKAGE_SIZE})`);
3369
+ }
3370
+ const files = await extractPdpkg(bytes);
3371
+ if (files.size === 0) {
3372
+ throw new Error(`Package "${parsed.name}" contains no installable files.`);
3373
+ }
3374
+ let name = parsed.name;
3375
+ let version = parsed.version;
3376
+ const manifest = files.get("manifest.json") ?? files.get("prompd.json");
3377
+ if (manifest) {
3378
+ try {
3379
+ const m = JSON.parse(manifest);
3380
+ if (typeof m.name === "string" && m.name) name = m.name;
3381
+ if (typeof m.version === "string" && m.version) version = m.version;
3382
+ } catch {
3383
+ }
3384
+ }
3385
+ const installedPath = resolveInstallDir(root, type, name);
3386
+ const baseSegments = normalizeSegments(installedPath);
3387
+ await store.removeDir?.(installedPath);
3388
+ const written = [];
3389
+ for (const [rel, content] of files) {
3390
+ const dest = joinPosix3(installedPath, rel);
3391
+ const destSegments = normalizeSegments(dest);
3392
+ if (destSegments !== baseSegments && !destSegments.startsWith(baseSegments + "/")) {
3393
+ throw new Error(`Security violation: extracted path escapes install directory: ${rel}`);
3394
+ }
3395
+ await store.writeFile(dest, content);
3396
+ written.push(rel);
3397
+ }
3398
+ return { name, version, scope: parsed.scope, installedPath, files: written };
3399
+ }
3400
+ async function uninstallPackage(opts) {
3401
+ const { ref, type, root, store } = opts;
3402
+ if (!store.removeDir) {
3403
+ throw new Error("Uninstall requires a PackageStore with removeDir.");
3404
+ }
3405
+ const parsed = parsePackageReference(ref);
3406
+ const installedPath = resolveInstallDir(root, type, parsed.name);
3407
+ await store.removeDir(installedPath);
3408
+ return { name: parsed.name, scope: parsed.scope, installedPath };
3409
+ }
3410
+
3342
3411
  // src/lib/compiler/index.ts
3343
3412
  function createCoreStages() {
3344
3413
  return [
@@ -4732,6 +4801,6 @@ function getExecutionOrder(workflow) {
4732
4801
  return order;
4733
4802
  }
4734
4803
 
4735
- export { AnthropicFormatter, BUILTIN_COMMAND_EXECUTABLES, CODE_EXTENSIONS, CONTENT_TYPES, CodeGenerationStage, CompilationContext, CompilationError, CompilationStage, CompilerPipeline, DEFAULT_SECURITY_CONFIG, DOCKABLE_HANDLES, DOCKABLE_NODE_TYPES, DependencyResolutionStage, EXTENSION_TO_LANGUAGE, EXTENSION_TO_LANGUAGE_ALIASES, HybridFileSystem, LexicalAnalysisStage, MEMORY_OPERATIONS_BY_MODE, MarkdownFormatter, MemoryFileSystem, MemoryPackageResolver, OpenAIFormatter, PACKAGE_TYPE_DIRS, PROMPD_EXTENSIONS, ParseError, PrompdCompiler, PrompdError, PrompdLoader, PrompdParser, SectionOverrideProcessor, SecurityError, SemanticAnalysisStage, TOOL_DEPLOY_DIRS, TemplateProcessingStage, VALID_PACKAGE_TYPES, ValidationError, basenamePosix, compile, createCoreStages, createEmptyWorkflow, createPrompdEnvironment, createWorkflowNode, dirnamePosix, extname, extractPdpkg, getContentType, getExecutionOrder, getInstallDirForType, getLanguageAliasesForExtension, getLanguageForExtension, isAbsolutePosix, isPrompdFile, isValidPackageReference, isValidPackageType, joinPosix, needsFrontmatterProtection, normalizePosix, parsePackageReference, parsePackageReferenceWithPath, parseWorkflow, resolvePackageFile, resolvePosix, serializeWorkflow, stripFilePath, validateWorkflow, validateWorkflowQuick };
4804
+ export { AnthropicFormatter, BUILTIN_COMMAND_EXECUTABLES, CODE_EXTENSIONS, CONTENT_TYPES, CodeGenerationStage, CompilationContext, CompilationError, CompilationStage, CompilerPipeline, DEFAULT_SECURITY_CONFIG, DOCKABLE_HANDLES, DOCKABLE_NODE_TYPES, DependencyResolutionStage, EXTENSION_TO_LANGUAGE, EXTENSION_TO_LANGUAGE_ALIASES, HybridFileSystem, LexicalAnalysisStage, MEMORY_OPERATIONS_BY_MODE, MarkdownFormatter, MemoryFileSystem, MemoryPackageResolver, OpenAIFormatter, PACKAGE_TYPE_DIRS, PROMPD_EXTENSIONS, ParseError, PrompdCompiler, PrompdError, PrompdLoader, PrompdParser, SectionOverrideProcessor, SecurityError, SemanticAnalysisStage, TOOL_DEPLOY_DIRS, TemplateProcessingStage, VALID_PACKAGE_TYPES, ValidationError, basenamePosix, compile, createCoreStages, createEmptyWorkflow, createPrompdEnvironment, createWorkflowNode, dirnamePosix, extname, extractPdpkg, getContentType, getExecutionOrder, getInstallDirForType, getLanguageAliasesForExtension, getLanguageForExtension, installPackage, isAbsolutePosix, isPrompdFile, isValidPackageReference, isValidPackageType, joinPosix, needsFrontmatterProtection, normalizePosix, parsePackageReference, parsePackageReferenceWithPath, parseWorkflow, resolvePackageFile, resolvePosix, serializeWorkflow, stripFilePath, uninstallPackage, validateWorkflow, validateWorkflowQuick };
4736
4805
  //# sourceMappingURL=index.js.map
4737
4806
  //# sourceMappingURL=index.js.map