@enactprotocol/shared 1.0.13 → 1.2.0

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.
@@ -33,7 +33,7 @@ export class EnactApiClient {
33
33
  }
34
34
  const responseData = await response.json();
35
35
  // Debug logging to help identify response structure issues
36
- if (process.env.NODE_ENV === "development" || process.env.DEBUG) {
36
+ if ((process.env.NODE_ENV === "development" || process.env.DEBUG) && !process.env.ENACT_SILENT) {
37
37
  console.error(`API Response for ${endpoint}:`, responseData);
38
38
  }
39
39
  return responseData;
@@ -103,7 +103,7 @@ export class EnactApiClient {
103
103
  const endpoint = "/functions/v1/tools-search";
104
104
  try {
105
105
  // Log the request for debugging
106
- if (process.env.NODE_ENV === "development" || process.env.DEBUG) {
106
+ if ((process.env.NODE_ENV === "development" || process.env.DEBUG) && !process.env.ENACT_SILENT) {
107
107
  console.error(`Search request to ${endpoint}:`, JSON.stringify(query, null, 2));
108
108
  }
109
109
  const response = await this.makeRequest(endpoint, {
@@ -2,6 +2,7 @@ export interface EnactToolDefinition {
2
2
  name: string;
3
3
  description: string;
4
4
  command: string;
5
+ from?: string;
5
6
  version?: string;
6
7
  timeout?: string;
7
8
  tags?: string[];
@@ -34,7 +35,14 @@ export interface EnactToolDefinition {
34
35
  value: string;
35
36
  role?: string;
36
37
  };
37
- signatures?: Record<string, any>;
38
+ signatures?: {
39
+ signer: string;
40
+ algorithm: string;
41
+ type: string;
42
+ value: string;
43
+ created: string;
44
+ role?: string;
45
+ }[];
38
46
  raw_content?: string;
39
47
  namespace?: string;
40
48
  enact?: string;
@@ -77,7 +85,6 @@ export interface EnactExecOptions {
77
85
  timeout?: string;
78
86
  dry?: boolean;
79
87
  verbose?: boolean;
80
- skipVerification?: boolean;
81
- verifyPolicy?: string;
82
88
  force?: boolean;
89
+ dangerouslySkipVerification?: boolean;
83
90
  }
@@ -67,7 +67,7 @@ export declare class DaggerExecutionProvider extends ExecutionProvider {
67
67
  verbose?: boolean;
68
68
  showSpinner?: boolean;
69
69
  streamOutput?: boolean;
70
- }): Promise<CommandResult>;
70
+ }, tool?: EnactTool): Promise<CommandResult>;
71
71
  /**
72
72
  * Execute command using Dagger connect with proper session management
73
73
  */
@@ -294,7 +294,7 @@ export class DaggerExecutionProvider extends ExecutionProvider {
294
294
  logger.warn(`Attempt ${attempt}: Engine unhealthy, resetting...`);
295
295
  await this.resetEngineContainer();
296
296
  }
297
- const result = await this.executeCommand(tool.command, inputs, environment, tool.timeout);
297
+ const result = await this.executeCommand(tool.command, inputs, environment, tool.timeout, undefined, tool);
298
298
  logger.debug(`Command result: exitCode=${result.exitCode}, stdout length=${result.stdout?.length || 0}, stderr length=${result.stderr?.length || 0}`);
299
299
  const output = this.parseOutput(result.stdout, tool);
300
300
  return {
@@ -389,7 +389,7 @@ export class DaggerExecutionProvider extends ExecutionProvider {
389
389
  }
390
390
  return "EXECUTION_ERROR";
391
391
  }
392
- async executeCommand(command, inputs, environment, timeout, options) {
392
+ async executeCommand(command, inputs, environment, timeout, options, tool) {
393
393
  const verbose = options?.verbose ?? false;
394
394
  const showSpinner = options?.showSpinner ?? false;
395
395
  // Create abort controller for this execution
@@ -410,16 +410,18 @@ export class DaggerExecutionProvider extends ExecutionProvider {
410
410
  // Substitute template variables in command (Enact Protocol style)
411
411
  const substitutedCommand = this.substituteCommandVariables(command, inputs);
412
412
  if (verbose) {
413
+ // Determine which container image to use - prefer tool's 'from' field over default baseImage
414
+ const containerImage = tool?.from || this.options.baseImage;
413
415
  try {
414
416
  const pc = require("picocolors");
415
417
  console.error(pc.cyan("\n🐳 Executing Enact command in Dagger container:"));
416
418
  console.error(pc.white(substitutedCommand));
417
- console.error(pc.gray(`Base image: ${this.options.baseImage}`));
419
+ console.error(pc.gray(`Container image: ${containerImage}${tool?.from ? ' (from tool.from)' : ' (default baseImage)'}`));
418
420
  }
419
421
  catch (e) {
420
422
  console.error("\n🐳 Executing Enact command in Dagger container:");
421
423
  console.error(substitutedCommand);
422
- console.error(`Base image: ${this.options.baseImage}`);
424
+ console.error(`Container image: ${containerImage}${tool?.from ? ' (from tool.from)' : ' (default baseImage)'}`);
423
425
  }
424
426
  }
425
427
  // Parse and apply timeout with engine timeout consideration
@@ -428,7 +430,7 @@ export class DaggerExecutionProvider extends ExecutionProvider {
428
430
  logger.debug(`Parsed timeout: ${effectiveTimeout}ms (command: ${timeoutMs}ms, engine: ${this.options.engineTimeout}ms)`);
429
431
  // Execute command with enhanced error handling and timeout management
430
432
  const result = await Promise.race([
431
- this.executeWithConnect(substitutedCommand, environment, inputs),
433
+ this.executeWithConnect(substitutedCommand, environment, inputs, tool),
432
434
  this.createTimeoutPromise(effectiveTimeout),
433
435
  ]);
434
436
  if (spinner) {
@@ -462,7 +464,7 @@ export class DaggerExecutionProvider extends ExecutionProvider {
462
464
  /**
463
465
  * Execute command using Dagger connect with proper session management
464
466
  */
465
- async executeWithConnect(command, environment, inputs) {
467
+ async executeWithConnect(command, environment, inputs, tool) {
466
468
  return new Promise((resolve, reject) => {
467
469
  // Setup abort handling
468
470
  const abortHandler = () => {
@@ -474,7 +476,7 @@ export class DaggerExecutionProvider extends ExecutionProvider {
474
476
  connect(async (client) => {
475
477
  try {
476
478
  logger.debug("🔗 Connected to Dagger client");
477
- const container = await this.setupContainer(client, environment, inputs);
479
+ const container = await this.setupContainer(client, environment, inputs, tool);
478
480
  logger.debug("📦 Container setup complete");
479
481
  const commandResult = await this.executeInContainer(container, command);
480
482
  logger.debug("⚡ Command execution complete");
@@ -505,10 +507,12 @@ export class DaggerExecutionProvider extends ExecutionProvider {
505
507
  /**
506
508
  * Enhanced container setup with better tool detection and installation
507
509
  */
508
- async setupContainer(client, environment, inputs) {
509
- logger.debug(`🚀 Setting up container with base image: ${this.options.baseImage}`);
510
+ async setupContainer(client, environment, inputs, tool) {
511
+ // Determine which container image to use - prefer tool's 'from' field over default baseImage
512
+ const containerImage = tool?.from || this.options.baseImage;
513
+ logger.debug(`🚀 Setting up container with image: ${containerImage}${tool?.from ? ' (from tool.from)' : ' (default baseImage)'}`);
510
514
  // Start with base container
511
- let container = client.container().from(this.options.baseImage);
515
+ let container = client.container().from(containerImage);
512
516
  logger.debug("📦 Base container created");
513
517
  // Set working directory
514
518
  container = container.withWorkdir(this.options.workdir);
@@ -520,7 +524,7 @@ export class DaggerExecutionProvider extends ExecutionProvider {
520
524
  logger.debug(`🌍 Added ${Object.keys(environment.vars).length} environment variables`);
521
525
  // Install common tools needed for Enact commands
522
526
  if (this.options.enableNetwork) {
523
- container = await this.installCommonTools(container);
527
+ container = await this.installCommonTools(container, containerImage);
524
528
  logger.debug("🔧 Common tools installed");
525
529
  }
526
530
  else {
@@ -541,18 +545,18 @@ export class DaggerExecutionProvider extends ExecutionProvider {
541
545
  * Install common tools that Enact commands might need
542
546
  * Enhanced with better error handling and timeout
543
547
  */
544
- async installCommonTools(container) {
545
- logger.debug(`🔧 Installing common tools for base image: ${this.options.baseImage}`);
548
+ async installCommonTools(container, containerImage) {
549
+ logger.debug(`🔧 Installing common tools for container image: ${containerImage}`);
546
550
  try {
547
551
  // For node images, most tools are already available, so we can skip installation
548
- if (this.options.baseImage?.includes("node:")) {
552
+ if (containerImage.includes("node:")) {
549
553
  logger.debug("📦 Node.js image detected, skipping tool installation (most tools already available)");
550
554
  return container;
551
555
  }
552
556
  // Determine package manager based on base image
553
- const isAlpine = this.options.baseImage?.includes("alpine");
554
- const isDebian = this.options.baseImage?.includes("debian") ||
555
- this.options.baseImage?.includes("ubuntu");
557
+ const isAlpine = containerImage.includes("alpine");
558
+ const isDebian = containerImage.includes("debian") ||
559
+ containerImage.includes("ubuntu");
556
560
  if (isAlpine) {
557
561
  logger.debug("📦 Detected Alpine Linux, installing basic tools");
558
562
  // Alpine Linux uses apk package manager - with better timeout handling
@@ -572,7 +576,7 @@ export class DaggerExecutionProvider extends ExecutionProvider {
572
576
  ]);
573
577
  }
574
578
  else {
575
- logger.warn(`Unknown base image ${this.options.baseImage}, skipping tool installation`);
579
+ logger.warn(`Unknown container image ${containerImage}, skipping tool installation`);
576
580
  }
577
581
  logger.debug("✅ Common tools installation complete");
578
582
  return container;
@@ -878,7 +882,7 @@ export class DaggerExecutionProvider extends ExecutionProvider {
878
882
  verbose,
879
883
  showSpinner: true,
880
884
  streamOutput: false,
881
- });
885
+ }, undefined);
882
886
  if (result.exitCode !== 0) {
883
887
  throw new Error(`Command failed with exit code ${result.exitCode}: ${result.stderr}`);
884
888
  }
@@ -6,7 +6,6 @@ export interface EnactCoreOptions {
6
6
  authToken?: string;
7
7
  verbose?: boolean;
8
8
  defaultTimeout?: string;
9
- verificationPolicy?: "permissive" | "enterprise" | "paranoid";
10
9
  daggerOptions?: {
11
10
  baseImage?: string;
12
11
  enableNetwork?: boolean;
@@ -24,11 +23,11 @@ export interface ToolSearchOptions {
24
23
  }
25
24
  export interface ToolExecuteOptions {
26
25
  timeout?: string;
27
- verifyPolicy?: "permissive" | "enterprise" | "paranoid";
28
- skipVerification?: boolean;
29
26
  force?: boolean;
30
27
  dryRun?: boolean;
31
28
  verbose?: boolean;
29
+ isLocalFile?: boolean;
30
+ dangerouslySkipVerification?: boolean;
32
31
  }
33
32
  export declare class EnactCore {
34
33
  private apiClient;
@@ -40,21 +39,30 @@ export declare class EnactCore {
40
39
  */
41
40
  setAuthToken(token: string): void;
42
41
  /**
43
- * Search for tools
42
+ * Static method to search for tools (no execution provider needed)
43
+ */
44
+ static searchTools(options: ToolSearchOptions, coreOptions?: Pick<EnactCoreOptions, 'apiUrl' | 'supabaseUrl'>): Promise<EnactTool[]>;
45
+ /**
46
+ * Instance method wrapper for backward compatibility
44
47
  */
45
48
  searchTools(options: ToolSearchOptions): Promise<EnactTool[]>;
46
49
  /**
47
- * Fallback search method that gets all tools and filters locally
50
+ * Static fallback search method that gets all tools and filters locally
51
+ */
52
+ private static searchToolsFallback;
53
+ /**
54
+ * Static method to get a specific tool by name
48
55
  */
49
- private searchToolsFallback;
56
+ static getToolByName(name: string, version?: string, coreOptions?: Pick<EnactCoreOptions, 'apiUrl' | 'supabaseUrl'>): Promise<EnactTool | null>;
50
57
  /**
51
- * Get a specific tool by name
58
+ * Instance method wrapper for backward compatibility
52
59
  */
53
60
  getToolByName(name: string, version?: string): Promise<EnactTool | null>;
54
61
  /**
55
62
  * Execute a tool by name
56
63
  */
57
64
  executeToolByName(name: string, inputs?: Record<string, any>, options?: ToolExecuteOptions): Promise<ExecutionResult>;
65
+ private verifyTool;
58
66
  /**
59
67
  * Execute a tool directly
60
68
  */
@@ -64,16 +72,11 @@ export declare class EnactCore {
64
72
  */
65
73
  executeRawTool(toolYaml: string, inputs?: Record<string, any>, options?: ToolExecuteOptions): Promise<ExecutionResult>;
66
74
  /**
67
- * Verify a tool's signature
75
+ * Static method to check if a tool exists
68
76
  */
69
- verifyTool(name: string, policy?: string): Promise<{
70
- verified: boolean;
71
- signatures: any[];
72
- policy: string;
73
- errors?: string[];
74
- }>;
77
+ static toolExists(name: string, coreOptions?: Pick<EnactCoreOptions, 'apiUrl' | 'supabaseUrl'>): Promise<boolean>;
75
78
  /**
76
- * Check if a tool exists
79
+ * Instance method wrapper for backward compatibility
77
80
  */
78
81
  toolExists(name: string): Promise<boolean>;
79
82
  /**
@@ -85,7 +88,16 @@ export declare class EnactCore {
85
88
  */
86
89
  getToolsByAuthor(author: string, limit?: number): Promise<EnactTool[]>;
87
90
  /**
88
- * Get all tools with filters
91
+ * Static method to get all tools with filters
92
+ */
93
+ static getTools(options?: {
94
+ limit?: number;
95
+ offset?: number;
96
+ tags?: string[];
97
+ author?: string;
98
+ }, coreOptions?: Pick<EnactCoreOptions, 'apiUrl' | 'supabaseUrl'>): Promise<EnactTool[]>;
99
+ /**
100
+ * Instance method wrapper for backward compatibility
89
101
  */
90
102
  getTools(options?: {
91
103
  limit?: number;
@@ -102,7 +114,14 @@ export declare class EnactCore {
102
114
  server?: string;
103
115
  }>;
104
116
  /**
105
- * Publish a tool (requires authentication)
117
+ * Static method to publish a tool
118
+ */
119
+ static publishTool(tool: EnactTool, authToken: string, coreOptions?: Pick<EnactCoreOptions, 'apiUrl' | 'supabaseUrl'>): Promise<{
120
+ success: boolean;
121
+ message: string;
122
+ }>;
123
+ /**
124
+ * Instance method wrapper for backward compatibility
106
125
  */
107
126
  publishTool(tool: EnactTool): Promise<{
108
127
  success: boolean;
@@ -118,7 +137,6 @@ export declare class EnactCore {
118
137
  getStatus(): Promise<{
119
138
  executionProvider: string;
120
139
  apiUrl: string;
121
- verificationPolicy: string;
122
140
  defaultTimeout: string;
123
141
  authenticated: boolean;
124
142
  }>;
@@ -135,4 +153,3 @@ export declare class EnactCore {
135
153
  */
136
154
  private generateExecutionId;
137
155
  }
138
- export declare const enactCore: EnactCore;