@tasker-systems/tasker 0.1.1 → 0.1.3

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.
@@ -1,5 +1,5 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
- import { l as FfiStepEvent, p as StepExecutionResult, k as FfiDispatchMetrics, T as TaskerRuntime } from './runtime-interface-CE4viUt7.js';
2
+ import { l as FfiStepEvent, p as StepExecutionResult, k as FfiDispatchMetrics, T as TaskerRuntime } from './runtime-interface-D940vUzy.js';
3
3
 
4
4
  /**
5
5
  * Event emitter for TypeScript workers.
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { T as TaskerRuntime, F as FfiDomainEvent, H as HandlerDefinitionDto } from './runtime-interface-CE4viUt7.js';
2
- export { B as BaseTaskerRuntime, C as ClientHealthResponse, c as ClientPaginationInfo, d as ClientResult, e as ClientStepAuditResponse, f as ClientStepReadiness, g as ClientStepResponse, h as ClientTaskListResponse, i as ClientTaskRequest, j as ClientTaskResponse, D as DependencyResult, a as FfiBootstrapConfig, b as FfiBootstrapResult, k as FfiDispatchMetrics, L as FfiLogFields, l as FfiStepEvent, q as FfiStopResult, W as FfiWorkerStatus, m as HandlerDefinition, O as OrchestrationMetadata, R as RetryConfiguration, S as StepDefinition, n as StepExecutionError, o as StepExecutionMetadata, p as StepExecutionResult, r as Task, s as WorkflowStep } from './runtime-interface-CE4viUt7.js';
3
- import { S as StepHandlerResult, a as StepHandler, B as BatchWorkerConfig, b as StepContext, E as ExecutableHandler, c as StepHandlerClass, T as TaskerEventEmitter, d as EventPoller, e as StepExecutionSubscriber, f as EventSystem } from './index-B3BcknlZ.js';
4
- export { y as ErrorCallback, I as ErrorType, n as EventName, o as EventNames, z as EventPollerConfig, F as EventSystemConfig, G as EventSystemStats, A as MetricsCallback, p as MetricsEventName, q as MetricsEventNames, M as MetricsPayload, P as PollerCyclePayload, r as PollerEventName, s as PollerEventNames, C as PollerState, g as StepCompletionSentPayload, L as StepContextParams, D as StepEventCallback, t as StepEventName, u as StepEventNames, h as StepExecutionCompletedPayload, i as StepExecutionFailedPayload, j as StepExecutionReceivedPayload, k as StepExecutionStartedPayload, H as StepExecutionSubscriberConfig, N as StepHandlerResultParams, l as TaskerEventMap, W as WorkerErrorPayload, v as WorkerEventName, w as WorkerEventNames, m as WorkerEventPayload, x as createEventPoller, J as isStandardErrorType, K as isTypicallyRetryable } from './index-B3BcknlZ.js';
5
- import { FfiLayerConfig } from './ffi/index.js';
6
- export { BunRuntime, DenoRuntime, FfiLayer, NodeRuntime, RuntimeInfo, RuntimeType, detectRuntime, getLibraryPath, getRuntimeInfo, isBun, isDeno, isNode } from './ffi/index.js';
1
+ import { T as TaskerRuntime, C as ClientTaskResponse, a as ClientTaskListResponse, b as ClientStepResponse, c as ClientStepAuditResponse, d as ClientHealthResponse, F as FfiDomainEvent, H as HandlerDefinitionDto } from './runtime-interface-D940vUzy.js';
2
+ export { B as BaseTaskerRuntime, g as ClientPaginationInfo, h as ClientResult, i as ClientStepReadiness, j as ClientTaskRequest, D as DependencyResult, e as FfiBootstrapConfig, f as FfiBootstrapResult, k as FfiDispatchMetrics, L as FfiLogFields, l as FfiStepEvent, q as FfiStopResult, W as FfiWorkerStatus, m as HandlerDefinition, O as OrchestrationMetadata, R as RetryConfiguration, S as StepDefinition, n as StepExecutionError, o as StepExecutionMetadata, p as StepExecutionResult, r as Task, s as WorkflowStep } from './runtime-interface-D940vUzy.js';
3
+ import { FfiLayer, FfiLayerConfig } from './ffi/index.js';
4
+ export { BunRuntime, DenoRuntime, NodeRuntime, RuntimeInfo, RuntimeType, detectRuntime, getLibraryPath, getRuntimeInfo, isBun, isDeno, isNode } from './ffi/index.js';
5
+ import { S as StepHandlerResult, a as StepHandler, B as BatchWorkerConfig, b as StepContext, E as ExecutableHandler, c as StepHandlerClass, T as TaskerEventEmitter, d as EventPoller, e as StepExecutionSubscriber, f as EventSystem } from './index-CTl8lGpU.js';
6
+ export { y as ErrorCallback, I as ErrorType, n as EventName, o as EventNames, z as EventPollerConfig, F as EventSystemConfig, G as EventSystemStats, A as MetricsCallback, p as MetricsEventName, q as MetricsEventNames, M as MetricsPayload, P as PollerCyclePayload, r as PollerEventName, s as PollerEventNames, C as PollerState, g as StepCompletionSentPayload, L as StepContextParams, D as StepEventCallback, t as StepEventName, u as StepEventNames, h as StepExecutionCompletedPayload, i as StepExecutionFailedPayload, j as StepExecutionReceivedPayload, k as StepExecutionStartedPayload, H as StepExecutionSubscriberConfig, N as StepHandlerResultParams, l as TaskerEventMap, W as WorkerErrorPayload, v as WorkerEventName, w as WorkerEventNames, m as WorkerEventPayload, x as createEventPoller, J as isStandardErrorType, K as isTypicallyRetryable } from './index-CTl8lGpU.js';
7
7
  import { Logger } from 'pino';
8
8
  import 'eventemitter3';
9
9
 
@@ -225,6 +225,166 @@ declare function getRustVersion(runtime?: TaskerRuntime): string;
225
225
  */
226
226
  declare function healthCheck(runtime?: TaskerRuntime): boolean;
227
227
 
228
+ /**
229
+ * High-level client wrapper for orchestration API operations.
230
+ *
231
+ * The raw FFI exposes `runtime.clientCreateTask(json)` and similar methods
232
+ * that require callers to construct complete JSON request strings with all
233
+ * required fields and return untyped `ClientResult` envelopes.
234
+ *
235
+ * This module provides a `TaskerClient` class with typed methods, sensible
236
+ * defaults, and proper error handling.
237
+ *
238
+ * @example
239
+ * ```typescript
240
+ * import { FfiLayer, TaskerClient } from '@tasker-systems/tasker';
241
+ *
242
+ * const ffiLayer = new FfiLayer();
243
+ * await ffiLayer.load();
244
+ * const client = new TaskerClient(ffiLayer);
245
+ *
246
+ * const task = client.createTask({ name: 'process_order', namespace: 'ecommerce' });
247
+ * console.log(task.task_uuid);
248
+ * ```
249
+ *
250
+ * @packageDocumentation
251
+ */
252
+
253
+ /**
254
+ * Options for creating a task.
255
+ *
256
+ * Only `name` is required; all other fields have sensible defaults.
257
+ */
258
+ interface CreateTaskOptions {
259
+ /** Named task template name */
260
+ name: string;
261
+ /** Task namespace (default: 'default') */
262
+ namespace?: string;
263
+ /** Workflow context passed to step handlers (default: {}) */
264
+ context?: Record<string, unknown>;
265
+ /** Template version (default: '1.0.0') */
266
+ version?: string;
267
+ /** Who initiated the request (default: 'tasker-core-typescript') */
268
+ initiator?: string;
269
+ /** Originating system (default: 'tasker-core') */
270
+ sourceSystem?: string;
271
+ /** Reason for creating the task (default: 'Task requested') */
272
+ reason?: string;
273
+ /** Optional tags */
274
+ tags?: string[];
275
+ /** Optional priority */
276
+ priority?: number | null;
277
+ /** Optional correlation ID (auto-generated if not provided) */
278
+ correlationId?: string;
279
+ /** Optional parent correlation ID */
280
+ parentCorrelationId?: string | null;
281
+ /** Optional idempotency key */
282
+ idempotencyKey?: string | null;
283
+ }
284
+ /**
285
+ * Options for listing tasks.
286
+ */
287
+ interface ListTasksOptions {
288
+ /** Maximum number of results (default: 50) */
289
+ limit?: number;
290
+ /** Pagination offset (default: 0) */
291
+ offset?: number;
292
+ /** Filter by namespace */
293
+ namespace?: string;
294
+ /** Filter by status */
295
+ status?: string;
296
+ }
297
+ /**
298
+ * Error thrown when a client operation fails.
299
+ */
300
+ declare class TaskerClientError extends Error {
301
+ /** Whether the error is potentially recoverable */
302
+ readonly recoverable: boolean;
303
+ constructor(message: string, recoverable?: boolean);
304
+ }
305
+ /**
306
+ * High-level client for orchestration API operations.
307
+ *
308
+ * Wraps the raw FFI methods with typed interfaces, sensible defaults,
309
+ * and proper error handling via `TaskerClientError`.
310
+ */
311
+ declare class TaskerClient {
312
+ private readonly ffiLayer;
313
+ constructor(ffiLayer: FfiLayer);
314
+ /**
315
+ * Create a task via the orchestration API.
316
+ *
317
+ * @param options - Task creation options (only `name` is required)
318
+ * @returns Typed task response
319
+ * @throws TaskerClientError if the operation fails
320
+ */
321
+ createTask(options: CreateTaskOptions): ClientTaskResponse;
322
+ /**
323
+ * Get a task by UUID.
324
+ *
325
+ * @param taskUuid - The task UUID
326
+ * @returns Typed task response
327
+ * @throws TaskerClientError if the operation fails
328
+ */
329
+ getTask(taskUuid: string): ClientTaskResponse;
330
+ /**
331
+ * List tasks with optional filtering and pagination.
332
+ *
333
+ * @param options - Filtering and pagination options
334
+ * @returns Typed task list response with pagination
335
+ * @throws TaskerClientError if the operation fails
336
+ */
337
+ listTasks(options?: ListTasksOptions): ClientTaskListResponse;
338
+ /**
339
+ * Cancel a task by UUID.
340
+ *
341
+ * @param taskUuid - The task UUID
342
+ * @throws TaskerClientError if the operation fails
343
+ */
344
+ cancelTask(taskUuid: string): void;
345
+ /**
346
+ * List workflow steps for a task.
347
+ *
348
+ * @param taskUuid - The task UUID
349
+ * @returns Array of typed step responses
350
+ * @throws TaskerClientError if the operation fails
351
+ */
352
+ listTaskSteps(taskUuid: string): ClientStepResponse[];
353
+ /**
354
+ * Get a specific workflow step.
355
+ *
356
+ * @param taskUuid - The task UUID
357
+ * @param stepUuid - The step UUID
358
+ * @returns Typed step response
359
+ * @throws TaskerClientError if the operation fails
360
+ */
361
+ getStep(taskUuid: string, stepUuid: string): ClientStepResponse;
362
+ /**
363
+ * Get audit history for a workflow step.
364
+ *
365
+ * @param taskUuid - The task UUID
366
+ * @param stepUuid - The step UUID
367
+ * @returns Array of typed audit history entries
368
+ * @throws TaskerClientError if the operation fails
369
+ */
370
+ getStepAuditHistory(taskUuid: string, stepUuid: string): ClientStepAuditResponse[];
371
+ /**
372
+ * Check orchestration API health.
373
+ *
374
+ * @returns Typed health response
375
+ * @throws TaskerClientError if the operation fails
376
+ */
377
+ healthCheck(): ClientHealthResponse;
378
+ /**
379
+ * Unwrap a ClientResult envelope, throwing on error.
380
+ */
381
+ private unwrap;
382
+ /**
383
+ * Get the FFI runtime from the layer.
384
+ */
385
+ private getRuntime;
386
+ }
387
+
228
388
  /**
229
389
  * API mixin for HTTP functionality.
230
390
  *
@@ -4010,4 +4170,4 @@ declare class WorkerServer {
4010
4170
  private cleanupOnError;
4011
4171
  }
4012
4172
 
4013
- export { type APICapable, APIMixin, ApiHandler, ApiResponse, BasePublisher, type BaseResolver, BaseSubscriber, type BatchAggregationResult, type BatchAnalyzerOutcome, type BatchMetadata, type BatchProcessingOutcome, type BatchWorkerContext, type BatchWorkerOutcome, type Batchable, BatchableMixin, type BootstrapConfig, type BootstrapResult, ClassLookupResolver, type CreateBatchesOutcome, type CursorConfig, type DecisionCapable, DecisionHandler, DecisionMixin, type DecisionPointOutcome, DecisionType, DefaultPublisher, type DomainEvent, type DomainEventCallback, type DomainEventErrorCallback, type DomainEventMetadata, type DomainEventPollerConfig, DuplicatePublisherError, type EventDeclaration, EventPoller, EventSystem, ExecutableHandler, ExplicitMappingResolver, type FailureStrategy, FfiLayerConfig, type HandlerEntry, type HandlerFactory, HandlerRegistry, type HandlerSpec, HandlerSystem, InProcessDomainEventPoller, type LogFields, MethodDispatchError, MethodDispatchWrapper, type NoBatchesOutcome, NoResolverMatchError, type PollerStats, type PublishContext, PublisherNotFoundError, PublisherRegistry, PublisherValidationError, RegistryFrozenError, RegistryResolver, type RegistryResolverStatic, ResolutionError, ResolverChain, type ResolverConfig, ResolverNotFoundError, type RustBatchWorkerInputs, type RustCursorConfig, type ServerComponents, type HealthCheckResult as ServerHealthCheckResult, type ServerState, type ServerStatus, ShutdownController, type ShutdownHandler, StepContext, type StepEventContext, StepExecutionSubscriber, StepHandler, StepHandlerClass, StepHandlerResult, type StepResult, type StopResult, type SubscriberClass, SubscriberRegistry, type SubscriberStats, TaskerEventEmitter, TaskerRuntime, WorkerServer, type WorkerServerConfig, type WorkerStatus, aggregateBatchResults, applyAPI, applyBatchable, applyDecision, bootstrapWorker, createBatchWorkerContext, createBatches, createDomainEvent, createFfiPollAdapter, createLogger, createStepEventContext, effectiveMethod, ffiEventToDomainEvent, fromCallable, fromDto, getRustVersion, getVersion, getWorkerStatus, hasResolverHint, healthCheck, isCreateBatches, isNoBatches, isWorkerRunning, logDebug, logError, logInfo, logTrace, logWarn, noBatches, normalizeToDefinition, stopWorker, transitionToGracefulShutdown, usesMethodDispatch };
4173
+ export { type APICapable, APIMixin, ApiHandler, ApiResponse, BasePublisher, type BaseResolver, BaseSubscriber, type BatchAggregationResult, type BatchAnalyzerOutcome, type BatchMetadata, type BatchProcessingOutcome, type BatchWorkerContext, type BatchWorkerOutcome, type Batchable, BatchableMixin, type BootstrapConfig, type BootstrapResult, ClassLookupResolver, ClientHealthResponse, ClientStepAuditResponse, ClientStepResponse, ClientTaskListResponse, ClientTaskResponse, type CreateBatchesOutcome, type CreateTaskOptions, type CursorConfig, type DecisionCapable, DecisionHandler, DecisionMixin, type DecisionPointOutcome, DecisionType, DefaultPublisher, type DomainEvent, type DomainEventCallback, type DomainEventErrorCallback, type DomainEventMetadata, type DomainEventPollerConfig, DuplicatePublisherError, type EventDeclaration, EventPoller, EventSystem, ExecutableHandler, ExplicitMappingResolver, type FailureStrategy, FfiLayer, FfiLayerConfig, type HandlerEntry, type HandlerFactory, HandlerRegistry, type HandlerSpec, HandlerSystem, InProcessDomainEventPoller, type ListTasksOptions, type LogFields, MethodDispatchError, MethodDispatchWrapper, type NoBatchesOutcome, NoResolverMatchError, type PollerStats, type PublishContext, PublisherNotFoundError, PublisherRegistry, PublisherValidationError, RegistryFrozenError, RegistryResolver, type RegistryResolverStatic, ResolutionError, ResolverChain, type ResolverConfig, ResolverNotFoundError, type RustBatchWorkerInputs, type RustCursorConfig, type ServerComponents, type HealthCheckResult as ServerHealthCheckResult, type ServerState, type ServerStatus, ShutdownController, type ShutdownHandler, StepContext, type StepEventContext, StepExecutionSubscriber, StepHandler, StepHandlerClass, StepHandlerResult, type StepResult, type StopResult, type SubscriberClass, SubscriberRegistry, type SubscriberStats, TaskerClient, TaskerClientError, TaskerEventEmitter, TaskerRuntime, WorkerServer, type WorkerServerConfig, type WorkerStatus, aggregateBatchResults, applyAPI, applyBatchable, applyDecision, bootstrapWorker, createBatchWorkerContext, createBatches, createDomainEvent, createFfiPollAdapter, createLogger, createStepEventContext, effectiveMethod, ffiEventToDomainEvent, fromCallable, fromDto, getRustVersion, getVersion, getWorkerStatus, hasResolverHint, healthCheck, isCreateBatches, isNoBatches, isWorkerRunning, logDebug, logError, logInfo, logTrace, logWarn, noBatches, normalizeToDefinition, stopWorker, transitionToGracefulShutdown, usesMethodDispatch };
package/dist/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
2
  import pino from 'pino';
3
3
  import { existsSync } from 'fs';
4
+ import { dirname, join } from 'path';
5
+ import { fileURLToPath } from 'url';
4
6
  import { readdir } from 'fs/promises';
5
- import { join } from 'path';
6
7
 
7
8
  var __create = Object.create;
8
9
  var __defProp = Object.defineProperty;
@@ -521,8 +522,8 @@ var require_koffi19 = __commonJS2({
521
522
  data = data.subarray(0, header.size);
522
523
  if (header.type == "0" || header.type == "7") {
523
524
  let filename3 = dest_dir + "/" + header.filename;
524
- let dirname = path2.dirname(filename3);
525
- fs2.mkdirSync(dirname, { recursive: true, mode: 493 });
525
+ let dirname2 = path2.dirname(filename3);
526
+ fs2.mkdirSync(dirname2, { recursive: true, mode: 493 });
526
527
  fs2.writeFileSync(filename3, data, { mode: header.mode });
527
528
  } else if (header.type == "5") {
528
529
  let filename3 = dest_dir + "/" + header.filename;
@@ -2103,6 +2104,151 @@ function healthCheck(runtime) {
2103
2104
  }
2104
2105
  }
2105
2106
 
2107
+ // src/client/index.ts
2108
+ var TaskerClientError = class extends Error {
2109
+ /** Whether the error is potentially recoverable */
2110
+ recoverable;
2111
+ constructor(message, recoverable = false) {
2112
+ super(message);
2113
+ this.name = "TaskerClientError";
2114
+ this.recoverable = recoverable;
2115
+ }
2116
+ };
2117
+ var TaskerClient = class {
2118
+ ffiLayer;
2119
+ constructor(ffiLayer) {
2120
+ this.ffiLayer = ffiLayer;
2121
+ }
2122
+ /**
2123
+ * Create a task via the orchestration API.
2124
+ *
2125
+ * @param options - Task creation options (only `name` is required)
2126
+ * @returns Typed task response
2127
+ * @throws TaskerClientError if the operation fails
2128
+ */
2129
+ createTask(options) {
2130
+ const request = {
2131
+ name: options.name,
2132
+ namespace: options.namespace ?? "default",
2133
+ version: options.version ?? "1.0.0",
2134
+ context: options.context ?? {},
2135
+ initiator: options.initiator ?? "tasker-core-typescript",
2136
+ source_system: options.sourceSystem ?? "tasker-core",
2137
+ reason: options.reason ?? "Task requested",
2138
+ tags: options.tags ?? [],
2139
+ requested_at: (/* @__PURE__ */ new Date()).toISOString(),
2140
+ options: null,
2141
+ priority: options.priority ?? null,
2142
+ correlation_id: options.correlationId ?? crypto.randomUUID(),
2143
+ parent_correlation_id: options.parentCorrelationId ?? null,
2144
+ idempotency_key: options.idempotencyKey ?? null
2145
+ };
2146
+ const result = this.getRuntime().clientCreateTask(JSON.stringify(request));
2147
+ return this.unwrap(result);
2148
+ }
2149
+ /**
2150
+ * Get a task by UUID.
2151
+ *
2152
+ * @param taskUuid - The task UUID
2153
+ * @returns Typed task response
2154
+ * @throws TaskerClientError if the operation fails
2155
+ */
2156
+ getTask(taskUuid) {
2157
+ const result = this.getRuntime().clientGetTask(taskUuid);
2158
+ return this.unwrap(result);
2159
+ }
2160
+ /**
2161
+ * List tasks with optional filtering and pagination.
2162
+ *
2163
+ * @param options - Filtering and pagination options
2164
+ * @returns Typed task list response with pagination
2165
+ * @throws TaskerClientError if the operation fails
2166
+ */
2167
+ listTasks(options = {}) {
2168
+ const params = {
2169
+ limit: options.limit ?? 50,
2170
+ offset: options.offset ?? 0,
2171
+ namespace: options.namespace ?? null,
2172
+ status: options.status ?? null
2173
+ };
2174
+ const result = this.getRuntime().clientListTasks(JSON.stringify(params));
2175
+ return this.unwrap(result);
2176
+ }
2177
+ /**
2178
+ * Cancel a task by UUID.
2179
+ *
2180
+ * @param taskUuid - The task UUID
2181
+ * @throws TaskerClientError if the operation fails
2182
+ */
2183
+ cancelTask(taskUuid) {
2184
+ const result = this.getRuntime().clientCancelTask(taskUuid);
2185
+ this.unwrap(result);
2186
+ }
2187
+ /**
2188
+ * List workflow steps for a task.
2189
+ *
2190
+ * @param taskUuid - The task UUID
2191
+ * @returns Array of typed step responses
2192
+ * @throws TaskerClientError if the operation fails
2193
+ */
2194
+ listTaskSteps(taskUuid) {
2195
+ const result = this.getRuntime().clientListTaskSteps(taskUuid);
2196
+ return this.unwrap(result);
2197
+ }
2198
+ /**
2199
+ * Get a specific workflow step.
2200
+ *
2201
+ * @param taskUuid - The task UUID
2202
+ * @param stepUuid - The step UUID
2203
+ * @returns Typed step response
2204
+ * @throws TaskerClientError if the operation fails
2205
+ */
2206
+ getStep(taskUuid, stepUuid) {
2207
+ const result = this.getRuntime().clientGetStep(taskUuid, stepUuid);
2208
+ return this.unwrap(result);
2209
+ }
2210
+ /**
2211
+ * Get audit history for a workflow step.
2212
+ *
2213
+ * @param taskUuid - The task UUID
2214
+ * @param stepUuid - The step UUID
2215
+ * @returns Array of typed audit history entries
2216
+ * @throws TaskerClientError if the operation fails
2217
+ */
2218
+ getStepAuditHistory(taskUuid, stepUuid) {
2219
+ const result = this.getRuntime().clientGetStepAuditHistory(taskUuid, stepUuid);
2220
+ return this.unwrap(result);
2221
+ }
2222
+ /**
2223
+ * Check orchestration API health.
2224
+ *
2225
+ * @returns Typed health response
2226
+ * @throws TaskerClientError if the operation fails
2227
+ */
2228
+ healthCheck() {
2229
+ const result = this.getRuntime().clientHealthCheck();
2230
+ return this.unwrap(result);
2231
+ }
2232
+ /**
2233
+ * Unwrap a ClientResult envelope, throwing on error.
2234
+ */
2235
+ unwrap(result) {
2236
+ if (!result.success) {
2237
+ throw new TaskerClientError(
2238
+ result.error ?? "Unknown client error",
2239
+ result.recoverable ?? false
2240
+ );
2241
+ }
2242
+ return result.data;
2243
+ }
2244
+ /**
2245
+ * Get the FFI runtime from the layer.
2246
+ */
2247
+ getRuntime() {
2248
+ return this.ffiLayer.getRuntime();
2249
+ }
2250
+ };
2251
+
2106
2252
  // src/events/event-names.ts
2107
2253
  var StepEventNames = {
2108
2254
  /** Emitted when a step execution event is received from the FFI layer */
@@ -3903,7 +4049,10 @@ var FfiLayer = class _FfiLayer {
3903
4049
  const path2 = customPath ?? this.configuredLibraryPath ?? this.discoverLibraryPath();
3904
4050
  if (!path2) {
3905
4051
  throw new Error(
3906
- "FFI library not found. TASKER_FFI_LIBRARY_PATH environment variable must be set to the path of the compiled library.\nExample: export TASKER_FFI_LIBRARY_PATH=/path/to/target/debug/libtasker_ts.dylib\nBuild the library with: cargo build -p tasker-ts"
4052
+ `FFI library not found. No bundled native library matches this platform, and TASKER_FFI_LIBRARY_PATH is not set.
4053
+ Current platform: ${process.platform}-${process.arch}
4054
+ Supported: linux-x64, linux-arm64, darwin-arm64
4055
+ Override: export TASKER_FFI_LIBRARY_PATH=/path/to/libtasker_ts.dylib`
3907
4056
  );
3908
4057
  }
3909
4058
  this.runtime = await this.createRuntime();
@@ -3957,23 +4106,27 @@ var FfiLayer = class _FfiLayer {
3957
4106
  * Static method for finding the library path without creating an instance.
3958
4107
  * Useful for test utilities and pre-flight checks.
3959
4108
  *
3960
- * REQUIRES: TASKER_FFI_LIBRARY_PATH environment variable to be set.
3961
- * This explicit requirement prevents confusion from automatic debug/release
3962
- * library discovery and ensures intentional configuration at build/runtime.
4109
+ * Resolution order:
4110
+ * 1. TASKER_FFI_LIBRARY_PATH environment variable (explicit override)
4111
+ * 2. Bundled native library in the package's native/ directory
3963
4112
  *
3964
4113
  * @param _callerDir Deprecated parameter, kept for API compatibility
3965
4114
  * @returns Path to the library if found and exists, null otherwise
3966
4115
  */
3967
4116
  static findLibraryPath(_callerDir) {
3968
4117
  const envPath = process.env.TASKER_FFI_LIBRARY_PATH;
3969
- if (!envPath) {
3970
- return null;
4118
+ if (envPath) {
4119
+ if (!existsSync(envPath)) {
4120
+ console.warn(`TASKER_FFI_LIBRARY_PATH is set to "${envPath}" but the file does not exist`);
4121
+ return null;
4122
+ }
4123
+ return envPath;
3971
4124
  }
3972
- if (!existsSync(envPath)) {
3973
- console.warn(`TASKER_FFI_LIBRARY_PATH is set to "${envPath}" but the file does not exist`);
3974
- return null;
4125
+ const bundledPath = findBundledNativeLibrary();
4126
+ if (bundledPath && existsSync(bundledPath)) {
4127
+ return bundledPath;
3975
4128
  }
3976
- return envPath;
4129
+ return null;
3977
4130
  }
3978
4131
  /**
3979
4132
  * Discover the FFI library path.
@@ -4009,6 +4162,21 @@ var FfiLayer = class _FfiLayer {
4009
4162
  }
4010
4163
  }
4011
4164
  };
4165
+ var BUNDLED_LIBRARIES = {
4166
+ "linux-x64": "libtasker_ts-linux-x64.so",
4167
+ "linux-arm64": "libtasker_ts-linux-arm64.so",
4168
+ "darwin-arm64": "libtasker_ts-darwin-arm64.dylib"
4169
+ };
4170
+ function findBundledNativeLibrary() {
4171
+ const key = `${process.platform}-${process.arch}`;
4172
+ const filename2 = BUNDLED_LIBRARIES[key];
4173
+ if (!filename2) {
4174
+ return null;
4175
+ }
4176
+ const thisDir = dirname(fileURLToPath(import.meta.url));
4177
+ const packageRoot = join(thisDir, "..", "..");
4178
+ return join(packageRoot, "native", filename2);
4179
+ }
4012
4180
 
4013
4181
  // src/ffi/index.ts
4014
4182
  init_node_runtime();
@@ -7865,6 +8033,6 @@ var WorkerServer = class {
7865
8033
  }
7866
8034
  };
7867
8035
 
7868
- export { APIMixin, ApiHandler, ApiResponse, BasePublisher, BaseSubscriber, BaseTaskerRuntime, BatchableMixin, BunRuntime, ClassLookupResolver, DecisionHandler, DecisionMixin, DecisionType, DefaultPublisher, DenoRuntime, DuplicatePublisherError, ErrorType, EventNames, EventPoller, EventSystem, ExplicitMappingResolver, FfiLayer, HandlerRegistry, HandlerSystem, InProcessDomainEventPoller, MethodDispatchError, MethodDispatchWrapper, MetricsEventNames, NoResolverMatchError, NodeRuntime, PollerEventNames, PublisherNotFoundError, PublisherRegistry, PublisherValidationError, RegistryFrozenError, RegistryResolver, ResolutionError, ResolverChain, ResolverNotFoundError, ShutdownController, StepContext, StepEventNames, StepExecutionSubscriber, StepHandler, StepHandlerResult, SubscriberRegistry, TaskerEventEmitter, WorkerEventNames, WorkerServer, aggregateBatchResults, applyAPI, applyBatchable, applyDecision, bootstrapWorker, createBatchWorkerContext, createBatches, createDomainEvent, createEventPoller, createFfiPollAdapter, createLogger, createStepEventContext, detectRuntime, effectiveMethod, ffiEventToDomainEvent, fromCallable, fromDto, getLibraryPath, getRuntimeInfo, getRustVersion, getVersion, getWorkerStatus, hasResolverHint, healthCheck, isBun, isCreateBatches, isDeno, isNoBatches, isNode, isStandardErrorType, isTypicallyRetryable, isWorkerRunning, logDebug, logError, logInfo, logTrace, logWarn, noBatches, normalizeToDefinition, stopWorker, transitionToGracefulShutdown, usesMethodDispatch };
8036
+ export { APIMixin, ApiHandler, ApiResponse, BasePublisher, BaseSubscriber, BaseTaskerRuntime, BatchableMixin, BunRuntime, ClassLookupResolver, DecisionHandler, DecisionMixin, DecisionType, DefaultPublisher, DenoRuntime, DuplicatePublisherError, ErrorType, EventNames, EventPoller, EventSystem, ExplicitMappingResolver, FfiLayer, HandlerRegistry, HandlerSystem, InProcessDomainEventPoller, MethodDispatchError, MethodDispatchWrapper, MetricsEventNames, NoResolverMatchError, NodeRuntime, PollerEventNames, PublisherNotFoundError, PublisherRegistry, PublisherValidationError, RegistryFrozenError, RegistryResolver, ResolutionError, ResolverChain, ResolverNotFoundError, ShutdownController, StepContext, StepEventNames, StepExecutionSubscriber, StepHandler, StepHandlerResult, SubscriberRegistry, TaskerClient, TaskerClientError, TaskerEventEmitter, WorkerEventNames, WorkerServer, aggregateBatchResults, applyAPI, applyBatchable, applyDecision, bootstrapWorker, createBatchWorkerContext, createBatches, createDomainEvent, createEventPoller, createFfiPollAdapter, createLogger, createStepEventContext, detectRuntime, effectiveMethod, ffiEventToDomainEvent, fromCallable, fromDto, getLibraryPath, getRuntimeInfo, getRustVersion, getVersion, getWorkerStatus, hasResolverHint, healthCheck, isBun, isCreateBatches, isDeno, isNoBatches, isNode, isStandardErrorType, isTypicallyRetryable, isWorkerRunning, logDebug, logError, logInfo, logTrace, logWarn, noBatches, normalizeToDefinition, stopWorker, transitionToGracefulShutdown, usesMethodDispatch };
7869
8037
  //# sourceMappingURL=index.js.map
7870
8038
  //# sourceMappingURL=index.js.map