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

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
@@ -1,13 +1,5 @@
1
1
  import * as nunjucks from 'nunjucks';
2
2
 
3
- /**
4
- * File System Abstraction (core, environment-agnostic).
5
- *
6
- * Defines the IFileSystem interface and the in-memory implementation used for
7
- * browser + server compilation. The Node-backed NodeFileSystem and the adm-zip
8
- * .pdpkg helpers live in @prompd/cli (they need Node APIs). Path operations here
9
- * are inlined as POSIX so this module has zero Node imports.
10
- */
11
3
  /**
12
4
  * File system interface that can be implemented for different storage backends.
13
5
  */
@@ -27,11 +19,21 @@ interface IFileSystem {
27
19
  /** Join path segments. */
28
20
  join(...pathSegments: string[]): string;
29
21
  }
22
+ /**
23
+ * Extract a `.pdpkg` (ZIP) buffer to a flat map of entry-relative path -> UTF-8
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).
28
+ */
29
+ declare function extractPdpkg(buffer: Uint8Array): Promise<Map<string, string>>;
30
30
  /**
31
31
  * In-memory file system for browser + server-side compilation.
32
32
  * Files are provided as a map of path -> content.
33
33
  */
34
34
  declare class MemoryFileSystem implements IFileSystem {
35
+ /** Cap on an ingested package buffer (defends against a hostile/huge .pdpkg). */
36
+ private static readonly MAX_PACKAGE_SIZE;
35
37
  private files;
36
38
  constructor(files?: Record<string, string>);
37
39
  /** Add or update a file in the in-memory file system. */
@@ -47,6 +49,17 @@ declare class MemoryFileSystem implements IFileSystem {
47
49
  join(...pathSegments: string[]): string;
48
50
  /** Get the virtual file system path for a package. */
49
51
  getPackagePath(packageName: string, version: string): string;
52
+ /**
53
+ * Extract a `.pdpkg` (ZIP) buffer into memory under getPackagePath(name, ver).
54
+ *
55
+ * Uses JSZip — isomorphic (browser + Node) — so this is the SINGLE package-ingest
56
+ * path for every host (replacing the CLI's Node-only adm-zip subclass and the
57
+ * skill installer's ad-hoc unzip). Text files only: binary assets aren't
58
+ * representable in the string-backed FS, so they're skipped (a `using:` package's
59
+ * .prmd/.md/.json/.yaml is what matters for compilation). Validates entry paths
60
+ * can't escape the package directory.
61
+ */
62
+ addPackage(packageName: string, version: string, packageBuffer: Uint8Array): Promise<void>;
50
63
  /** Get all files under an optional base path. */
51
64
  getAllFiles(basePath?: string): Map<string, string>;
52
65
  /** Calculate total size (bytes) and file count under a base path. */
@@ -102,6 +115,11 @@ declare class HybridFileSystem implements IFileSystem {
102
115
  addFile(filePath: string, content: string): void;
103
116
  /** Add multiple in-memory files at once. */
104
117
  addFiles(files: Record<string, string>): void;
118
+ /** Virtual path where a package's files live (delegates to the memory layer). */
119
+ getPackagePath(packageName: string, version: string): string;
120
+ /** Ingest a `.pdpkg` (ZIP) buffer into the in-memory layer, so package files are
121
+ * served synchronously alongside the workspace sources. */
122
+ addPackage(packageName: string, version: string, packageBuffer: Uint8Array): Promise<void>;
105
123
  exists(filePath: string): boolean | Promise<boolean>;
106
124
  readFile(filePath: string): string | Promise<string>;
107
125
  isDirectory(filePath: string): boolean | Promise<boolean>;
@@ -601,6 +619,7 @@ declare class CompilerPipeline {
601
619
  * (`resolvePackage`, base-dir lookups) lives in @prompd/cli and is injected via
602
620
  * IPackageResolver. Path operations are inlined as POSIX so this stays node-free.
603
621
  */
622
+
604
623
  /**
605
624
  * Strip a file path suffix from a package reference.
606
625
  * @example "@ns/pkg@1.0.0/prompts/file.prmd" -> "@ns/pkg@1.0.0"
@@ -632,6 +651,24 @@ declare function isValidPackageReference(packageRef: string): boolean;
632
651
  * Resolve a file path within a package (POSIX, path-traversal safe).
633
652
  */
634
653
  declare function resolvePackageFile(packagePath: string, filePath: string): string;
654
+ /** Fetch the raw `.pdpkg` (ZIP) bytes for a package@version. The host injects it —
655
+ * the browser with `fetch`, the Node CLI with its registry client — so the resolver
656
+ * itself stays environment-agnostic. */
657
+ type PackageDownloader = (name: string, version: string) => Promise<Uint8Array>;
658
+ /**
659
+ * The environment-agnostic package resolver: loads `using:`/`inherits:` packages
660
+ * into an in-memory FS via an injected registry download. This is the ONE resolver
661
+ * for every host that compiles in memory (the browser, and Node when not using the
662
+ * disk cache) — so the download/unzip/cache logic isn't duplicated per host.
663
+ *
664
+ * `resolvePackage` returns the in-memory directory path; the compiler then reads
665
+ * the referenced file from `options.fileSystem` via resolvePackageFile.
666
+ */
667
+ declare class MemoryPackageResolver implements IPackageResolver {
668
+ private readonly download;
669
+ constructor(download: PackageDownloader);
670
+ resolvePackage(packageRef: string, options: ResolvePackageOptions): Promise<string>;
671
+ }
635
672
 
636
673
  /**
637
674
  * Language Mapping Utilities
@@ -2926,4 +2963,4 @@ declare function validateWorkflow(workflow: WorkflowFile): ValidationResult;
2926
2963
  */
2927
2964
  declare function validateWorkflowQuick(workflow: WorkflowFile): Pick<ValidationResult, 'isValid'>;
2928
2965
 
2929
- 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, type MergeNodeData, type NodeExecutionState, type NodeExecutionStatus, OpenAIFormatter, type OutputFormatter, type OutputNodeData, PACKAGE_TYPE_DIRS, PROMPD_EXTENSIONS, type PackageAlias, 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, getContentType, getExecutionOrder, getInstallDirForType, getLanguageAliasesForExtension, getLanguageForExtension, isAbsolutePosix, isPrompdFile, isValidPackageReference, isValidPackageType, joinPosix, needsFrontmatterProtection, normalizePosix, parsePackageReference, parsePackageReferenceWithPath, parseWorkflow, resolvePackageFile, resolvePosix, serializeWorkflow, stripFilePath, validateWorkflow, validateWorkflowQuick };
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 };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,5 @@
1
1
  import * as nunjucks from 'nunjucks';
2
2
 
3
- /**
4
- * File System Abstraction (core, environment-agnostic).
5
- *
6
- * Defines the IFileSystem interface and the in-memory implementation used for
7
- * browser + server compilation. The Node-backed NodeFileSystem and the adm-zip
8
- * .pdpkg helpers live in @prompd/cli (they need Node APIs). Path operations here
9
- * are inlined as POSIX so this module has zero Node imports.
10
- */
11
3
  /**
12
4
  * File system interface that can be implemented for different storage backends.
13
5
  */
@@ -27,11 +19,21 @@ interface IFileSystem {
27
19
  /** Join path segments. */
28
20
  join(...pathSegments: string[]): string;
29
21
  }
22
+ /**
23
+ * Extract a `.pdpkg` (ZIP) buffer to a flat map of entry-relative path -> UTF-8
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).
28
+ */
29
+ declare function extractPdpkg(buffer: Uint8Array): Promise<Map<string, string>>;
30
30
  /**
31
31
  * In-memory file system for browser + server-side compilation.
32
32
  * Files are provided as a map of path -> content.
33
33
  */
34
34
  declare class MemoryFileSystem implements IFileSystem {
35
+ /** Cap on an ingested package buffer (defends against a hostile/huge .pdpkg). */
36
+ private static readonly MAX_PACKAGE_SIZE;
35
37
  private files;
36
38
  constructor(files?: Record<string, string>);
37
39
  /** Add or update a file in the in-memory file system. */
@@ -47,6 +49,17 @@ declare class MemoryFileSystem implements IFileSystem {
47
49
  join(...pathSegments: string[]): string;
48
50
  /** Get the virtual file system path for a package. */
49
51
  getPackagePath(packageName: string, version: string): string;
52
+ /**
53
+ * Extract a `.pdpkg` (ZIP) buffer into memory under getPackagePath(name, ver).
54
+ *
55
+ * Uses JSZip — isomorphic (browser + Node) — so this is the SINGLE package-ingest
56
+ * path for every host (replacing the CLI's Node-only adm-zip subclass and the
57
+ * skill installer's ad-hoc unzip). Text files only: binary assets aren't
58
+ * representable in the string-backed FS, so they're skipped (a `using:` package's
59
+ * .prmd/.md/.json/.yaml is what matters for compilation). Validates entry paths
60
+ * can't escape the package directory.
61
+ */
62
+ addPackage(packageName: string, version: string, packageBuffer: Uint8Array): Promise<void>;
50
63
  /** Get all files under an optional base path. */
51
64
  getAllFiles(basePath?: string): Map<string, string>;
52
65
  /** Calculate total size (bytes) and file count under a base path. */
@@ -102,6 +115,11 @@ declare class HybridFileSystem implements IFileSystem {
102
115
  addFile(filePath: string, content: string): void;
103
116
  /** Add multiple in-memory files at once. */
104
117
  addFiles(files: Record<string, string>): void;
118
+ /** Virtual path where a package's files live (delegates to the memory layer). */
119
+ getPackagePath(packageName: string, version: string): string;
120
+ /** Ingest a `.pdpkg` (ZIP) buffer into the in-memory layer, so package files are
121
+ * served synchronously alongside the workspace sources. */
122
+ addPackage(packageName: string, version: string, packageBuffer: Uint8Array): Promise<void>;
105
123
  exists(filePath: string): boolean | Promise<boolean>;
106
124
  readFile(filePath: string): string | Promise<string>;
107
125
  isDirectory(filePath: string): boolean | Promise<boolean>;
@@ -601,6 +619,7 @@ declare class CompilerPipeline {
601
619
  * (`resolvePackage`, base-dir lookups) lives in @prompd/cli and is injected via
602
620
  * IPackageResolver. Path operations are inlined as POSIX so this stays node-free.
603
621
  */
622
+
604
623
  /**
605
624
  * Strip a file path suffix from a package reference.
606
625
  * @example "@ns/pkg@1.0.0/prompts/file.prmd" -> "@ns/pkg@1.0.0"
@@ -632,6 +651,24 @@ declare function isValidPackageReference(packageRef: string): boolean;
632
651
  * Resolve a file path within a package (POSIX, path-traversal safe).
633
652
  */
634
653
  declare function resolvePackageFile(packagePath: string, filePath: string): string;
654
+ /** Fetch the raw `.pdpkg` (ZIP) bytes for a package@version. The host injects it —
655
+ * the browser with `fetch`, the Node CLI with its registry client — so the resolver
656
+ * itself stays environment-agnostic. */
657
+ type PackageDownloader = (name: string, version: string) => Promise<Uint8Array>;
658
+ /**
659
+ * The environment-agnostic package resolver: loads `using:`/`inherits:` packages
660
+ * into an in-memory FS via an injected registry download. This is the ONE resolver
661
+ * for every host that compiles in memory (the browser, and Node when not using the
662
+ * disk cache) — so the download/unzip/cache logic isn't duplicated per host.
663
+ *
664
+ * `resolvePackage` returns the in-memory directory path; the compiler then reads
665
+ * the referenced file from `options.fileSystem` via resolvePackageFile.
666
+ */
667
+ declare class MemoryPackageResolver implements IPackageResolver {
668
+ private readonly download;
669
+ constructor(download: PackageDownloader);
670
+ resolvePackage(packageRef: string, options: ResolvePackageOptions): Promise<string>;
671
+ }
635
672
 
636
673
  /**
637
674
  * Language Mapping Utilities
@@ -2926,4 +2963,4 @@ declare function validateWorkflow(workflow: WorkflowFile): ValidationResult;
2926
2963
  */
2927
2964
  declare function validateWorkflowQuick(workflow: WorkflowFile): Pick<ValidationResult, 'isValid'>;
2928
2965
 
2929
- 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, type MergeNodeData, type NodeExecutionState, type NodeExecutionStatus, OpenAIFormatter, type OutputFormatter, type OutputNodeData, PACKAGE_TYPE_DIRS, PROMPD_EXTENSIONS, type PackageAlias, 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, getContentType, getExecutionOrder, getInstallDirForType, getLanguageAliasesForExtension, getLanguageForExtension, isAbsolutePosix, isPrompdFile, isValidPackageReference, isValidPackageType, joinPosix, needsFrontmatterProtection, normalizePosix, parsePackageReference, parsePackageReferenceWithPath, parseWorkflow, resolvePackageFile, resolvePosix, serializeWorkflow, stripFilePath, validateWorkflow, validateWorkflowQuick };
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 };
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as yaml from 'yaml';
2
2
  import semver from 'semver';
3
3
  import * as nunjucks from 'nunjucks';
4
+ import JSZip from 'jszip';
4
5
 
5
6
  // src/lib/parser.ts
6
7
  var PrompdParser = class {
@@ -546,6 +547,30 @@ function resolvePackageFile(packagePath, filePath) {
546
547
  }
547
548
  return resolvedPath;
548
549
  }
550
+ function isPackageCapable(fs) {
551
+ const f = fs;
552
+ return !!f && typeof f.getPackagePath === "function" && typeof f.addPackage === "function" && typeof f.isDirectory === "function";
553
+ }
554
+ var MemoryPackageResolver = class {
555
+ constructor(download) {
556
+ this.download = download;
557
+ }
558
+ async resolvePackage(packageRef, options) {
559
+ const fs = options.fileSystem;
560
+ if (!isPackageCapable(fs)) {
561
+ throw new Error("MemoryPackageResolver requires a package-capable in-memory file system (MemoryFileSystem or HybridFileSystem)");
562
+ }
563
+ if (!isValidPackageReference(packageRef)) {
564
+ throw new SecurityError(`Invalid package reference format: ${packageRef}`);
565
+ }
566
+ const { name, version } = parsePackageReference(packageRef);
567
+ const packagePath = fs.getPackagePath(name, version);
568
+ if (await fs.isDirectory(packagePath)) return packagePath;
569
+ const buffer = await this.download(name, version);
570
+ await fs.addPackage(name, version, buffer);
571
+ return packagePath;
572
+ }
573
+ };
549
574
 
550
575
  // src/lib/compiler/path-utils.ts
551
576
  function normalizePosix(p) {
@@ -3045,8 +3070,54 @@ var CodeGenerationStage = class {
3045
3070
  return "Code Generation";
3046
3071
  }
3047
3072
  };
3048
-
3049
- // src/lib/compiler/file-system.ts
3073
+ var BINARY_ASSET_EXT = /* @__PURE__ */ new Set([
3074
+ "png",
3075
+ "jpg",
3076
+ "jpeg",
3077
+ "gif",
3078
+ "webp",
3079
+ "svg",
3080
+ "ico",
3081
+ "bmp",
3082
+ "tiff",
3083
+ "pdf",
3084
+ "xlsx",
3085
+ "xls",
3086
+ "docx",
3087
+ "doc",
3088
+ "pptx",
3089
+ "ppt",
3090
+ "zip",
3091
+ "pdpkg",
3092
+ "gz",
3093
+ "tar",
3094
+ "wasm",
3095
+ "woff",
3096
+ "woff2",
3097
+ "ttf",
3098
+ "otf",
3099
+ "eot",
3100
+ "mp3",
3101
+ "mp4",
3102
+ "wav",
3103
+ "ogg",
3104
+ "webm",
3105
+ "mov",
3106
+ "avi"
3107
+ ]);
3108
+ function isBinaryAsset(name) {
3109
+ const dot = name.lastIndexOf(".");
3110
+ return dot >= 0 && BINARY_ASSET_EXT.has(name.slice(dot + 1).toLowerCase());
3111
+ }
3112
+ async function extractPdpkg(buffer) {
3113
+ const zip = await JSZip.loadAsync(buffer);
3114
+ const out = /* @__PURE__ */ new Map();
3115
+ for (const entry of Object.values(zip.files)) {
3116
+ if (entry.dir || isBinaryAsset(entry.name)) continue;
3117
+ out.set(entry.name, await entry.async("string"));
3118
+ }
3119
+ return out;
3120
+ }
3050
3121
  function normalizePosix2(p) {
3051
3122
  const isAbs = p.startsWith("/");
3052
3123
  const out = [];
@@ -3084,7 +3155,7 @@ function toRelKey(filePath) {
3084
3155
  if (n.endsWith("/") && n.length > 1) n = n.substring(0, n.length - 1);
3085
3156
  return n;
3086
3157
  }
3087
- var MemoryFileSystem = class {
3158
+ var _MemoryFileSystem = class _MemoryFileSystem {
3088
3159
  constructor(files = {}) {
3089
3160
  this.files = /* @__PURE__ */ new Map();
3090
3161
  for (const [filePath, content] of Object.entries(files)) {
@@ -3151,6 +3222,33 @@ var MemoryFileSystem = class {
3151
3222
  getPackagePath(packageName, version) {
3152
3223
  return `/packages/${packageName}@${version}`;
3153
3224
  }
3225
+ /**
3226
+ * Extract a `.pdpkg` (ZIP) buffer into memory under getPackagePath(name, ver).
3227
+ *
3228
+ * Uses JSZip — isomorphic (browser + Node) — so this is the SINGLE package-ingest
3229
+ * path for every host (replacing the CLI's Node-only adm-zip subclass and the
3230
+ * skill installer's ad-hoc unzip). Text files only: binary assets aren't
3231
+ * representable in the string-backed FS, so they're skipped (a `using:` package's
3232
+ * .prmd/.md/.json/.yaml is what matters for compilation). Validates entry paths
3233
+ * can't escape the package directory.
3234
+ */
3235
+ async addPackage(packageName, version, packageBuffer) {
3236
+ if (packageBuffer.length > _MemoryFileSystem.MAX_PACKAGE_SIZE) {
3237
+ throw new Error(`Package too large: ${packageBuffer.length} bytes (max ${_MemoryFileSystem.MAX_PACKAGE_SIZE})`);
3238
+ }
3239
+ const files = await extractPdpkg(packageBuffer);
3240
+ const packagePath = this.getPackagePath(packageName, version);
3241
+ const packagePrefix = this.normalizePath(packagePath.endsWith("/") ? packagePath : packagePath + "/");
3242
+ const packageRoot = this.normalizePath(packagePath);
3243
+ for (const [rel, content] of files) {
3244
+ const filePath = this.join(packagePath, rel);
3245
+ const normalized = this.normalizePath(filePath);
3246
+ if (!normalized.startsWith(packagePrefix) && normalized !== packageRoot) {
3247
+ throw new Error(`Security violation: extracted path escapes package directory: ${rel}`);
3248
+ }
3249
+ this.addFile(filePath, content);
3250
+ }
3251
+ }
3154
3252
  /** Get all files under an optional base path. */
3155
3253
  getAllFiles(basePath) {
3156
3254
  if (!basePath) {
@@ -3180,6 +3278,9 @@ var MemoryFileSystem = class {
3180
3278
  return toRelKey(filePath);
3181
3279
  }
3182
3280
  };
3281
+ /** Cap on an ingested package buffer (defends against a hostile/huge .pdpkg). */
3282
+ _MemoryFileSystem.MAX_PACKAGE_SIZE = 50 * 1024 * 1024;
3283
+ var MemoryFileSystem = _MemoryFileSystem;
3183
3284
  var HybridFileSystem = class {
3184
3285
  constructor(files = {}, backend) {
3185
3286
  this.mem = new MemoryFileSystem(files);
@@ -3193,6 +3294,15 @@ var HybridFileSystem = class {
3193
3294
  addFiles(files) {
3194
3295
  this.mem.addFiles(files);
3195
3296
  }
3297
+ /** Virtual path where a package's files live (delegates to the memory layer). */
3298
+ getPackagePath(packageName, version) {
3299
+ return this.mem.getPackagePath(packageName, version);
3300
+ }
3301
+ /** Ingest a `.pdpkg` (ZIP) buffer into the in-memory layer, so package files are
3302
+ * served synchronously alongside the workspace sources. */
3303
+ addPackage(packageName, version, packageBuffer) {
3304
+ return this.mem.addPackage(packageName, version, packageBuffer);
3305
+ }
3196
3306
  exists(filePath) {
3197
3307
  if (this.mem.exists(filePath)) return true;
3198
3308
  return this.backend.readFile(this.normalize(filePath)).then((content) => content !== null).catch(() => false);
@@ -4622,6 +4732,6 @@ function getExecutionOrder(workflow) {
4622
4732
  return order;
4623
4733
  }
4624
4734
 
4625
- 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, 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, getContentType, getExecutionOrder, getInstallDirForType, getLanguageAliasesForExtension, getLanguageForExtension, isAbsolutePosix, isPrompdFile, isValidPackageReference, isValidPackageType, joinPosix, needsFrontmatterProtection, normalizePosix, parsePackageReference, parsePackageReferenceWithPath, parseWorkflow, resolvePackageFile, resolvePosix, serializeWorkflow, stripFilePath, validateWorkflow, validateWorkflowQuick };
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 };
4626
4736
  //# sourceMappingURL=index.js.map
4627
4737
  //# sourceMappingURL=index.js.map