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

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
@@ -22,9 +22,11 @@ interface IFileSystem {
22
22
  /**
23
23
  * Extract a `.pdpkg` (ZIP) buffer to a flat map of entry-relative path -> UTF-8
24
24
  * content. The SINGLE ZIP-extraction primitive shared by package ingestion
25
- * (MemoryFileSystem.addPackage) and skill install — so hosts never hand-roll their
26
- * own jszip pass. Directories and binary assets are skipped (the consumers store
27
- * text only).
25
+ * (MemoryFileSystem.addPackage), the installer, and skill install — so hosts never
26
+ * hand-roll their own jszip pass. Directories and binary assets are skipped (the
27
+ * consumers store text only). Enforces the same archive-security checks as the CLI:
28
+ * rejects null bytes, path traversal, symlinks, and oversized / decompression-bomb
29
+ * archives.
28
30
  */
29
31
  declare function extractPdpkg(buffer: Uint8Array): Promise<Map<string, string>>;
30
32
  /**
@@ -670,6 +672,13 @@ declare class MemoryPackageResolver implements IPackageResolver {
670
672
  resolvePackage(packageRef: string, options: ResolvePackageOptions): Promise<string>;
671
673
  }
672
674
 
675
+ /** Deploy an installed skill into a tool-native dir (e.g. ~/.claude/skills). Host-only
676
+ * (Node fs); the browser omits it. Injected so core stays Node-free. */
677
+ type ToolDeployHook = (opts: {
678
+ installedPath: string;
679
+ name: string;
680
+ tool: string;
681
+ }) => void | Promise<void>;
673
682
  /**
674
683
  * A writable sink the host injects so installPackage stays FS-/Node-agnostic.
675
684
  * Browser: an adapter over the workspace FileService; CLI/sidecar: over Node fs.
@@ -677,27 +686,34 @@ declare class MemoryPackageResolver implements IPackageResolver {
677
686
  interface PackageStore {
678
687
  /** Write a UTF-8 file, creating parent directories as needed. */
679
688
  writeFile(path: string, content: string): void | Promise<void>;
680
- /** Remove a directory and its contents if present, for a clean reinstall. */
689
+ /** Write raw bytes — required for node-templates (stored as the raw .pdpkg). */
690
+ writeBytes?(path: string, bytes: Uint8Array): void | Promise<void>;
691
+ /** Remove a directory and its contents if present. */
681
692
  removeDir?(path: string): void | Promise<void>;
693
+ /** Remove a single file if present (node-template .pdpkg uninstall). */
694
+ removeFile?(path: string): void | Promise<void>;
695
+ /** Read a UTF-8 file, or null if absent — used to merge the workspace prompd.json. */
696
+ readFile?(path: string): Promise<string | null> | string | null;
697
+ /** List a directory's entry names — used to find a node-template .pdpkg to uninstall. */
698
+ readdir?(path: string): Promise<string[]> | string[];
682
699
  }
683
700
  interface InstallPackageOptions {
684
701
  /** "@scope/name@version" or "@scope/name" (defaults to latest). */
685
702
  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
- */
703
+ /** Type HINT. The package's own manifest `type` wins; this is the fallback. */
704
+ type?: PackageType;
705
+ /** Install root: the open workspace (local) or the home dir (global). */
693
706
  root: string;
694
707
  /** Writable sink for the chosen host. */
695
708
  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
- */
709
+ /** Fetch the .pdpkg bytes for a (name, version). May resolve 'latest'. */
700
710
  download: PackageDownloader;
711
+ /** Global install — skips the workspace prompd.json dependency record (CLI parity). */
712
+ global?: boolean;
713
+ /** Deploy the installed skill to these tools (skills only), via deployTool. */
714
+ tools?: string[];
715
+ /** Host hook performing the per-tool deploy. Required when `tools` is set. */
716
+ deployTool?: ToolDeployHook;
701
717
  }
702
718
  interface InstalledPackage {
703
719
  /** Full scoped name (manifest-authoritative when present), e.g. "@prompd/core". */
@@ -705,41 +721,42 @@ interface InstalledPackage {
705
721
  /** Resolved version (from the package manifest when present). */
706
722
  version: string;
707
723
  scope?: string;
708
- /** Install dir written to: <root>/.prompd/<typeDir>/<name>. */
724
+ /** Resolved type (from the package manifest when present). */
725
+ type: PackageType;
726
+ /** Where it was written: the version dir, or the .pdpkg path for node-templates. */
709
727
  installedPath: string;
710
- /** Entry-relative paths written under installedPath. */
728
+ /** Entry-relative paths written (empty for node-templates). */
711
729
  files: string[];
712
730
  }
713
731
  /**
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.
732
+ * Install a registry artifact, matching the CLI. Resolves the type from the package's
733
+ * own manifest (the `type` option is only a fallback). Standard types extract to
734
+ * <root>/.prompd/<typeDir>/<name>/<version>/ with a `.prmdmeta`; node-templates are
735
+ * stored as the raw .pdpkg. Installs the package's own dependencies recursively,
736
+ * records the dependency in the workspace prompd.json (local installs only), and
737
+ * deploys to any requested tools. Idempotent per version.
720
738
  */
721
739
  declare function installPackage(opts: InstallPackageOptions): Promise<InstalledPackage>;
722
740
  interface UninstallPackageOptions {
723
- /** "@scope/name" (a version suffix is accepted but ignored — one install per name). */
741
+ /** "@scope/name" (a version suffix is accepted but ignored). */
724
742
  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). */
743
+ /** Install root the caller chose. */
728
744
  root: string;
729
- /** Writable sink for the chosen host; removeDir is required to uninstall. */
745
+ /** Writable sink for the chosen host. */
730
746
  store: PackageStore;
747
+ /** Global uninstall — skips the workspace prompd.json dependency removal. */
748
+ global?: boolean;
731
749
  }
732
750
  interface UninstalledPackage {
733
751
  name: string;
734
752
  scope?: string;
735
- /** The directory that was removed: <root>/.prompd/<typeDir>/<name>. */
736
- installedPath: string;
753
+ /** Dirs/files removed. */
754
+ removed: string[];
737
755
  }
738
756
  /**
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.
757
+ * Uninstall by name, matching the CLI: scan EVERY type dir under <root>/.prompd/ and
758
+ * remove the package's dir (all versions); for node-templates, find the .pdpkg whose
759
+ * manifest name matches and remove it. Drops the prompd.json dependency. Idempotent.
743
760
  */
744
761
  declare function uninstallPackage(opts: UninstallPackageOptions): Promise<UninstalledPackage>;
745
762
 
@@ -3036,4 +3053,4 @@ declare function validateWorkflow(workflow: WorkflowFile): ValidationResult;
3036
3053
  */
3037
3054
  declare function validateWorkflowQuick(workflow: WorkflowFile): Pick<ValidationResult, 'isValid'>;
3038
3055
 
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 };
3056
+ 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 ToolDeployHook, 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
@@ -22,9 +22,11 @@ interface IFileSystem {
22
22
  /**
23
23
  * Extract a `.pdpkg` (ZIP) buffer to a flat map of entry-relative path -> UTF-8
24
24
  * content. The SINGLE ZIP-extraction primitive shared by package ingestion
25
- * (MemoryFileSystem.addPackage) and skill install — so hosts never hand-roll their
26
- * own jszip pass. Directories and binary assets are skipped (the consumers store
27
- * text only).
25
+ * (MemoryFileSystem.addPackage), the installer, and skill install — so hosts never
26
+ * hand-roll their own jszip pass. Directories and binary assets are skipped (the
27
+ * consumers store text only). Enforces the same archive-security checks as the CLI:
28
+ * rejects null bytes, path traversal, symlinks, and oversized / decompression-bomb
29
+ * archives.
28
30
  */
29
31
  declare function extractPdpkg(buffer: Uint8Array): Promise<Map<string, string>>;
30
32
  /**
@@ -670,6 +672,13 @@ declare class MemoryPackageResolver implements IPackageResolver {
670
672
  resolvePackage(packageRef: string, options: ResolvePackageOptions): Promise<string>;
671
673
  }
672
674
 
675
+ /** Deploy an installed skill into a tool-native dir (e.g. ~/.claude/skills). Host-only
676
+ * (Node fs); the browser omits it. Injected so core stays Node-free. */
677
+ type ToolDeployHook = (opts: {
678
+ installedPath: string;
679
+ name: string;
680
+ tool: string;
681
+ }) => void | Promise<void>;
673
682
  /**
674
683
  * A writable sink the host injects so installPackage stays FS-/Node-agnostic.
675
684
  * Browser: an adapter over the workspace FileService; CLI/sidecar: over Node fs.
@@ -677,27 +686,34 @@ declare class MemoryPackageResolver implements IPackageResolver {
677
686
  interface PackageStore {
678
687
  /** Write a UTF-8 file, creating parent directories as needed. */
679
688
  writeFile(path: string, content: string): void | Promise<void>;
680
- /** Remove a directory and its contents if present, for a clean reinstall. */
689
+ /** Write raw bytes — required for node-templates (stored as the raw .pdpkg). */
690
+ writeBytes?(path: string, bytes: Uint8Array): void | Promise<void>;
691
+ /** Remove a directory and its contents if present. */
681
692
  removeDir?(path: string): void | Promise<void>;
693
+ /** Remove a single file if present (node-template .pdpkg uninstall). */
694
+ removeFile?(path: string): void | Promise<void>;
695
+ /** Read a UTF-8 file, or null if absent — used to merge the workspace prompd.json. */
696
+ readFile?(path: string): Promise<string | null> | string | null;
697
+ /** List a directory's entry names — used to find a node-template .pdpkg to uninstall. */
698
+ readdir?(path: string): Promise<string[]> | string[];
682
699
  }
683
700
  interface InstallPackageOptions {
684
701
  /** "@scope/name@version" or "@scope/name" (defaults to latest). */
685
702
  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
- */
703
+ /** Type HINT. The package's own manifest `type` wins; this is the fallback. */
704
+ type?: PackageType;
705
+ /** Install root: the open workspace (local) or the home dir (global). */
693
706
  root: string;
694
707
  /** Writable sink for the chosen host. */
695
708
  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
- */
709
+ /** Fetch the .pdpkg bytes for a (name, version). May resolve 'latest'. */
700
710
  download: PackageDownloader;
711
+ /** Global install — skips the workspace prompd.json dependency record (CLI parity). */
712
+ global?: boolean;
713
+ /** Deploy the installed skill to these tools (skills only), via deployTool. */
714
+ tools?: string[];
715
+ /** Host hook performing the per-tool deploy. Required when `tools` is set. */
716
+ deployTool?: ToolDeployHook;
701
717
  }
702
718
  interface InstalledPackage {
703
719
  /** Full scoped name (manifest-authoritative when present), e.g. "@prompd/core". */
@@ -705,41 +721,42 @@ interface InstalledPackage {
705
721
  /** Resolved version (from the package manifest when present). */
706
722
  version: string;
707
723
  scope?: string;
708
- /** Install dir written to: <root>/.prompd/<typeDir>/<name>. */
724
+ /** Resolved type (from the package manifest when present). */
725
+ type: PackageType;
726
+ /** Where it was written: the version dir, or the .pdpkg path for node-templates. */
709
727
  installedPath: string;
710
- /** Entry-relative paths written under installedPath. */
728
+ /** Entry-relative paths written (empty for node-templates). */
711
729
  files: string[];
712
730
  }
713
731
  /**
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.
732
+ * Install a registry artifact, matching the CLI. Resolves the type from the package's
733
+ * own manifest (the `type` option is only a fallback). Standard types extract to
734
+ * <root>/.prompd/<typeDir>/<name>/<version>/ with a `.prmdmeta`; node-templates are
735
+ * stored as the raw .pdpkg. Installs the package's own dependencies recursively,
736
+ * records the dependency in the workspace prompd.json (local installs only), and
737
+ * deploys to any requested tools. Idempotent per version.
720
738
  */
721
739
  declare function installPackage(opts: InstallPackageOptions): Promise<InstalledPackage>;
722
740
  interface UninstallPackageOptions {
723
- /** "@scope/name" (a version suffix is accepted but ignored — one install per name). */
741
+ /** "@scope/name" (a version suffix is accepted but ignored). */
724
742
  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). */
743
+ /** Install root the caller chose. */
728
744
  root: string;
729
- /** Writable sink for the chosen host; removeDir is required to uninstall. */
745
+ /** Writable sink for the chosen host. */
730
746
  store: PackageStore;
747
+ /** Global uninstall — skips the workspace prompd.json dependency removal. */
748
+ global?: boolean;
731
749
  }
732
750
  interface UninstalledPackage {
733
751
  name: string;
734
752
  scope?: string;
735
- /** The directory that was removed: <root>/.prompd/<typeDir>/<name>. */
736
- installedPath: string;
753
+ /** Dirs/files removed. */
754
+ removed: string[];
737
755
  }
738
756
  /**
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.
757
+ * Uninstall by name, matching the CLI: scan EVERY type dir under <root>/.prompd/ and
758
+ * remove the package's dir (all versions); for node-templates, find the .pdpkg whose
759
+ * manifest name matches and remove it. Drops the prompd.json dependency. Idempotent.
743
760
  */
744
761
  declare function uninstallPackage(opts: UninstallPackageOptions): Promise<UninstalledPackage>;
745
762
 
@@ -3036,4 +3053,4 @@ declare function validateWorkflow(workflow: WorkflowFile): ValidationResult;
3036
3053
  */
3037
3054
  declare function validateWorkflowQuick(workflow: WorkflowFile): Pick<ValidationResult, 'isValid'>;
3038
3055
 
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 };
3056
+ 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 ToolDeployHook, 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
@@ -3109,12 +3109,35 @@ function isBinaryAsset(name) {
3109
3109
  const dot = name.lastIndexOf(".");
3110
3110
  return dot >= 0 && BINARY_ASSET_EXT.has(name.slice(dot + 1).toLowerCase());
3111
3111
  }
3112
+ var MAX_FILE_SIZE_IN_ZIP = 10 * 1024 * 1024;
3113
+ var MAX_TOTAL_EXTRACTED_SIZE = 500 * 1024 * 1024;
3114
+ function isSymlinkEntry(perms) {
3115
+ return typeof perms === "number" && (perms & 61440) === 40960;
3116
+ }
3112
3117
  async function extractPdpkg(buffer) {
3113
3118
  const zip = await JSZip.loadAsync(buffer);
3114
3119
  const out = /* @__PURE__ */ new Map();
3120
+ let total = 0;
3115
3121
  for (const entry of Object.values(zip.files)) {
3122
+ if (entry.name.includes("\0")) {
3123
+ throw new Error(`Security violation: null byte in entry name: ${entry.name}`);
3124
+ }
3125
+ if (entry.name.startsWith("/") || /(^|\/)\.\.(\/|$)/.test(entry.name)) {
3126
+ throw new Error(`Security violation: path traversal in entry: ${entry.name}`);
3127
+ }
3128
+ if (isSymlinkEntry(entry.unixPermissions)) {
3129
+ throw new Error(`Security violation: symlink entry in archive: ${entry.name}`);
3130
+ }
3116
3131
  if (entry.dir || isBinaryAsset(entry.name)) continue;
3117
- out.set(entry.name, await entry.async("string"));
3132
+ const bytes = await entry.async("uint8array");
3133
+ if (bytes.length > MAX_FILE_SIZE_IN_ZIP) {
3134
+ throw new Error(`File too large in package: ${entry.name} (${bytes.length} bytes, max ${MAX_FILE_SIZE_IN_ZIP})`);
3135
+ }
3136
+ total += bytes.length;
3137
+ if (total > MAX_TOTAL_EXTRACTED_SIZE) {
3138
+ throw new Error(`Package total decompressed size exceeds limit (${MAX_TOTAL_EXTRACTED_SIZE} bytes). Possible decompression bomb.`);
3139
+ }
3140
+ out.set(entry.name, new TextDecoder().decode(bytes));
3118
3141
  }
3119
3142
  return out;
3120
3143
  }
@@ -3357,11 +3380,55 @@ function normalizeSegments(p) {
3357
3380
  }
3358
3381
  return out.join("/");
3359
3382
  }
3360
- function resolveInstallDir(root, type, name) {
3383
+ function slugify(name) {
3384
+ return name.toLowerCase().replace(/[@/]+/g, "-").replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "");
3385
+ }
3386
+ function resolvePackageDir(root, type, name) {
3361
3387
  return joinPosix3(root, ".prompd", getInstallDirForType(type), name);
3362
3388
  }
3389
+ function resolveInstallDir(root, type, name, version) {
3390
+ return joinPosix3(resolvePackageDir(root, type, name), version);
3391
+ }
3392
+ async function addWorkspaceDependency(store, root, name, version) {
3393
+ if (!store.readFile) return;
3394
+ const manifestPath = joinPosix3(root, "prompd.json");
3395
+ try {
3396
+ const existing = await store.readFile(manifestPath);
3397
+ const manifest = existing && existing.trim() ? JSON.parse(existing) : {};
3398
+ if (!manifest.dependencies || typeof manifest.dependencies !== "object") manifest.dependencies = {};
3399
+ manifest.dependencies[name] = version;
3400
+ await store.writeFile(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
3401
+ } catch {
3402
+ }
3403
+ }
3404
+ async function removeWorkspaceDependency(store, root, name) {
3405
+ if (!store.readFile) return;
3406
+ const manifestPath = joinPosix3(root, "prompd.json");
3407
+ try {
3408
+ const existing = await store.readFile(manifestPath);
3409
+ if (!existing || !existing.trim()) return;
3410
+ const manifest = JSON.parse(existing);
3411
+ const deps = manifest.dependencies;
3412
+ if (!deps || typeof deps !== "object") return;
3413
+ delete deps[name];
3414
+ await store.writeFile(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
3415
+ } catch {
3416
+ }
3417
+ }
3418
+ function readManifest(files) {
3419
+ const raw = files.get("manifest.json") ?? files.get("prompd.json");
3420
+ if (!raw) return {};
3421
+ try {
3422
+ return JSON.parse(raw);
3423
+ } catch {
3424
+ return {};
3425
+ }
3426
+ }
3363
3427
  async function installPackage(opts) {
3364
- const { ref, type, root, store, download } = opts;
3428
+ return installInternal(opts, /* @__PURE__ */ new Set());
3429
+ }
3430
+ async function installInternal(opts, visited) {
3431
+ const { ref, root, store, download, global, tools, deployTool } = opts;
3365
3432
  const parsed = parsePackageReference(ref);
3366
3433
  const bytes = await download(parsed.name, parsed.version);
3367
3434
  if (bytes.length > MAX_PACKAGE_SIZE) {
@@ -3371,41 +3438,77 @@ async function installPackage(opts) {
3371
3438
  if (files.size === 0) {
3372
3439
  throw new Error(`Package "${parsed.name}" contains no installable files.`);
3373
3440
  }
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 {
3441
+ const m = readManifest(files);
3442
+ const name = typeof m.name === "string" && m.name ? m.name : parsed.name;
3443
+ const version = typeof m.version === "string" && m.version ? m.version : parsed.version;
3444
+ const type = typeof m.type === "string" && isValidPackageType(m.type) ? m.type : opts.type && isValidPackageType(opts.type) ? opts.type : "package";
3445
+ visited.add(name);
3446
+ if (m.dependencies && typeof m.dependencies === "object") {
3447
+ for (const [depName, depVersion] of Object.entries(m.dependencies)) {
3448
+ if (depName === name || visited.has(depName)) continue;
3449
+ await installInternal({ ...opts, ref: `${depName}@${depVersion}`, type: void 0 }, visited);
3383
3450
  }
3384
3451
  }
3385
- const installedPath = resolveInstallDir(root, type, name);
3386
- const baseSegments = normalizeSegments(installedPath);
3387
- await store.removeDir?.(installedPath);
3452
+ let installedPath;
3388
3453
  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}`);
3454
+ if (type === "node-template") {
3455
+ if (!store.writeBytes) {
3456
+ throw new Error("Installing a node-template requires a PackageStore with writeBytes (binary). This host does not support it.");
3457
+ }
3458
+ const dir = joinPosix3(root, ".prompd", getInstallDirForType("node-template"));
3459
+ installedPath = joinPosix3(dir, `${slugify(name)}-${version}.pdpkg`);
3460
+ await store.writeBytes(installedPath, bytes);
3461
+ } else {
3462
+ installedPath = resolveInstallDir(root, type, name, version);
3463
+ const base = normalizeSegments(installedPath);
3464
+ await store.removeDir?.(installedPath);
3465
+ for (const [rel, content] of files) {
3466
+ const dest = joinPosix3(installedPath, rel);
3467
+ if (normalizeSegments(dest) !== base && !normalizeSegments(dest).startsWith(base + "/")) {
3468
+ throw new Error(`Security violation: extracted path escapes install directory: ${rel}`);
3469
+ }
3470
+ await store.writeFile(dest, content);
3471
+ written.push(rel);
3472
+ }
3473
+ await store.writeFile(joinPosix3(installedPath, ".prmdmeta"), JSON.stringify(m, null, 2) + "\n");
3474
+ if (tools && tools.length > 0) {
3475
+ if (type !== "skill") throw new Error(`Tool deploy is only valid for skills, but '${name}' is a ${type}.`);
3476
+ if (!deployTool) throw new Error("tools were requested but no deployTool hook was provided.");
3477
+ for (const tool of tools) await deployTool({ installedPath, name, tool });
3394
3478
  }
3395
- await store.writeFile(dest, content);
3396
- written.push(rel);
3397
3479
  }
3398
- return { name, version, scope: parsed.scope, installedPath, files: written };
3480
+ if (!global) await addWorkspaceDependency(store, root, name, version);
3481
+ return { name, version, scope: parsed.scope, type, installedPath, files: written };
3399
3482
  }
3400
3483
  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.");
3484
+ const { root, store, global } = opts;
3485
+ if (!store.removeDir) throw new Error("Uninstall requires a PackageStore with removeDir.");
3486
+ const parsed = parsePackageReference(opts.ref);
3487
+ const name = parsed.name;
3488
+ const removed = [];
3489
+ for (const type of ["package", "workflow", "skill", "node-template"]) {
3490
+ if (type === "node-template") {
3491
+ const dir = joinPosix3(root, ".prompd", getInstallDirForType("node-template"));
3492
+ if (!store.readdir || !store.removeFile) continue;
3493
+ try {
3494
+ const prefix = `${slugify(name)}-`;
3495
+ for (const entry of await store.readdir(dir)) {
3496
+ if (entry.startsWith(prefix) && entry.endsWith(".pdpkg")) {
3497
+ const p = joinPosix3(dir, entry);
3498
+ await store.removeFile(p);
3499
+ removed.push(p);
3500
+ }
3501
+ }
3502
+ } catch {
3503
+ }
3504
+ } else {
3505
+ const dir = resolvePackageDir(root, type, name);
3506
+ await store.removeDir(dir);
3507
+ removed.push(dir);
3508
+ }
3404
3509
  }
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 };
3510
+ if (!global) await removeWorkspaceDependency(store, root, name);
3511
+ return { name, scope: parsed.scope, removed };
3409
3512
  }
3410
3513
 
3411
3514
  // src/lib/compiler/index.ts