@tasker-systems/tasker 0.1.6 → 0.1.8
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/events/index.d.ts +1 -1
- package/dist/events/index.js +88 -1
- package/dist/events/index.js.map +1 -1
- package/dist/{index-CRCYa9Xk.d.ts → index-CVhy3k3k.d.ts} +24 -0
- package/dist/index.d.ts +205 -23
- package/dist/index.js +248 -136
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/tasker_ts.darwin-arm64.node +0 -0
- package/tasker_ts.linux-x64-gnu.node +0 -0
package/dist/events/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { y as ErrorCallback, n as EventName, o as EventNames, d as EventPoller, z as EventPollerConfig, f as EventSystem, 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, D as StepEventCallback, t as StepEventName, u as StepEventNames, h as StepExecutionCompletedPayload, i as StepExecutionFailedPayload, j as StepExecutionReceivedPayload, k as StepExecutionStartedPayload, T as TaskerEventEmitter, l as TaskerEventMap, W as WorkerErrorPayload, v as WorkerEventName, w as WorkerEventNames, m as WorkerEventPayload, x as createEventPoller } from '../index-
|
|
1
|
+
export { y as ErrorCallback, n as EventName, o as EventNames, d as EventPoller, z as EventPollerConfig, f as EventSystem, 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, D as StepEventCallback, t as StepEventName, u as StepEventNames, h as StepExecutionCompletedPayload, i as StepExecutionFailedPayload, j as StepExecutionReceivedPayload, k as StepExecutionStartedPayload, T as TaskerEventEmitter, l as TaskerEventMap, W as WorkerErrorPayload, v as WorkerEventName, w as WorkerEventNames, m as WorkerEventPayload, x as createEventPoller } from '../index-CVhy3k3k.js';
|
|
2
2
|
import 'eventemitter3';
|
|
3
3
|
import '../ffi/index.js';
|
package/dist/events/index.js
CHANGED
|
@@ -1486,6 +1486,10 @@ var StepExecutionSubscriber = class {
|
|
|
1486
1486
|
/**
|
|
1487
1487
|
* Send a completion result to Rust via FFI and handle the response.
|
|
1488
1488
|
*
|
|
1489
|
+
* If the primary FFI call fails (e.g. serialization error, unexpected
|
|
1490
|
+
* type mismatch), we construct a guaranteed-safe failure result so the
|
|
1491
|
+
* step is marked as permanently failed rather than silently lost.
|
|
1492
|
+
*
|
|
1489
1493
|
* @returns true if the completion was accepted by Rust, false otherwise
|
|
1490
1494
|
*/
|
|
1491
1495
|
async sendCompletionViaFfi(event, napiResult, isSuccess) {
|
|
@@ -1509,8 +1513,61 @@ var StepExecutionSubscriber = class {
|
|
|
1509
1513
|
return false;
|
|
1510
1514
|
} catch (error) {
|
|
1511
1515
|
this.handleFfiError(event, error);
|
|
1512
|
-
return
|
|
1516
|
+
return this.submitFallbackFailure(event, error);
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
/**
|
|
1520
|
+
* Submit a minimal safe-failure result after the primary FFI call fails.
|
|
1521
|
+
*
|
|
1522
|
+
* Builds a primitive-only result guaranteed to serialize, then attempts
|
|
1523
|
+
* to submit it. Throws if the fallback is also rejected or fails,
|
|
1524
|
+
* since the step would otherwise be silently lost.
|
|
1525
|
+
*/
|
|
1526
|
+
submitFallbackFailure(event, originalError) {
|
|
1527
|
+
const fallback = this.buildFfiSafeFailure(event, originalError);
|
|
1528
|
+
try {
|
|
1529
|
+
const accepted = this.module.completeStepEvent(event.eventId, fallback);
|
|
1530
|
+
if (accepted) {
|
|
1531
|
+
pinoLog.warn(
|
|
1532
|
+
{ component: "subscriber", eventId: event.eventId },
|
|
1533
|
+
"FFI fallback failure submitted successfully"
|
|
1534
|
+
);
|
|
1535
|
+
return true;
|
|
1536
|
+
}
|
|
1537
|
+
this.throwOrphanedError(event, "rejected", originalError);
|
|
1538
|
+
} catch (fallbackError) {
|
|
1539
|
+
this.throwOrphanedError(event, "failed", originalError, fallbackError);
|
|
1540
|
+
}
|
|
1541
|
+
return false;
|
|
1542
|
+
}
|
|
1543
|
+
/**
|
|
1544
|
+
* Throw an error indicating a step has been orphaned (both primary and fallback failed).
|
|
1545
|
+
*/
|
|
1546
|
+
throwOrphanedError(event, reason, originalError, fallbackError) {
|
|
1547
|
+
const originalMsg = originalError instanceof Error ? originalError.message : String(originalError);
|
|
1548
|
+
if (reason === "rejected") {
|
|
1549
|
+
pinoLog.error(
|
|
1550
|
+
{ component: "subscriber", eventId: event.eventId, stepUuid: event.stepUuid },
|
|
1551
|
+
"FFI fallback submission also rejected - step is orphaned"
|
|
1552
|
+
);
|
|
1553
|
+
throw new Error(
|
|
1554
|
+
`Both primary and fallback FFI submissions rejected for event ${event.eventId}. Step ${event.stepUuid} is orphaned.`
|
|
1555
|
+
);
|
|
1513
1556
|
}
|
|
1557
|
+
const fallbackMsg = fallbackError instanceof Error ? fallbackError.message : String(fallbackError);
|
|
1558
|
+
pinoLog.error(
|
|
1559
|
+
{
|
|
1560
|
+
component: "subscriber",
|
|
1561
|
+
eventId: event.eventId,
|
|
1562
|
+
stepUuid: event.stepUuid,
|
|
1563
|
+
error: fallbackMsg,
|
|
1564
|
+
originalError: originalMsg
|
|
1565
|
+
},
|
|
1566
|
+
"FFI fallback also failed - step is orphaned"
|
|
1567
|
+
);
|
|
1568
|
+
throw new Error(
|
|
1569
|
+
`Both primary and fallback FFI submissions failed for event ${event.eventId}. Step ${event.stepUuid} is orphaned. Fallback: ${fallbackMsg}, Original: ${originalMsg}`
|
|
1570
|
+
);
|
|
1514
1571
|
}
|
|
1515
1572
|
/**
|
|
1516
1573
|
* Handle successful FFI completion submission.
|
|
@@ -1570,6 +1627,36 @@ var StepExecutionSubscriber = class {
|
|
|
1570
1627
|
error_message: error instanceof Error ? error.message : String(error)
|
|
1571
1628
|
});
|
|
1572
1629
|
}
|
|
1630
|
+
/**
|
|
1631
|
+
* Build a minimal NapiStepExecutionResult guaranteed to serialize through napi-rs.
|
|
1632
|
+
*
|
|
1633
|
+
* Uses only primitive values so there is zero chance of a secondary
|
|
1634
|
+
* serialization failure. The step will be marked as permanently failed
|
|
1635
|
+
* rather than silently lost.
|
|
1636
|
+
*/
|
|
1637
|
+
buildFfiSafeFailure(event, error) {
|
|
1638
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1639
|
+
return {
|
|
1640
|
+
stepUuid: event.stepUuid,
|
|
1641
|
+
success: false,
|
|
1642
|
+
result: {},
|
|
1643
|
+
status: "error",
|
|
1644
|
+
metadata: {
|
|
1645
|
+
executionTimeMs: 0,
|
|
1646
|
+
retryable: false,
|
|
1647
|
+
completedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1648
|
+
...this.workerId != null && { workerId: this.workerId },
|
|
1649
|
+
custom: {
|
|
1650
|
+
ffi_serialization_error: errorMessage.substring(0, 500)
|
|
1651
|
+
}
|
|
1652
|
+
},
|
|
1653
|
+
error: {
|
|
1654
|
+
message: `FFI serialization failed: ${errorMessage}`.substring(0, 500),
|
|
1655
|
+
errorType: "FFI_SERIALIZATION_ERROR",
|
|
1656
|
+
retryable: false
|
|
1657
|
+
}
|
|
1658
|
+
};
|
|
1659
|
+
}
|
|
1573
1660
|
};
|
|
1574
1661
|
|
|
1575
1662
|
// src/events/event-system.ts
|