@bastani/atomic-natives 0.9.19 → 0.9.20-alpha.10

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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.9.20-alpha.4] - 2026-09-20
6
+
7
+ ### Fixed
8
+
9
+ - Supervised commands no longer fail when retained output files collide after process IDs are reused; other output-file creation failures now include the operating-system error ([#3105](https://github.com/bastani-inc/atomic/issues/3105)).
10
+ - Command output files use timestamped random names and bounded collision retries, preventing retained files from indefinitely delaying startup without overwriting existing output.
11
+ - Corrected the binding-target diagnostic type to allow an absent marker when a native override or exports hook returns a non-extensible binding.
12
+
5
13
  ## [0.9.19] - 2026-09-13
6
14
 
7
15
  Cumulative release of the `0.9.19-alpha.2` through `0.9.19-alpha.4` prereleases. Per-change details remain in the unchanged prerelease sections below.
package/README.md CHANGED
@@ -4,4 +4,4 @@ Native Rust bindings for Atomic via N-API.
4
4
 
5
5
  Rust code lives in `crates/atomic-natives`, while this package contains the generated NAPI-RS JavaScript loader (`native/index.js`), generated TypeScript declarations (`native/index.d.ts`), and release-time optional platform packages.
6
6
 
7
- Native surfaces include a Rust-backed PTY session used by the `bash` tool when `pty: true` is requested and oh-my-pi-derived `glob`/`grep`/`search` bindings used by Atomic's built-in `find` and `search` tools for full-level parity.
7
+ The bindings provide a Rust-backed PTY session for `bash` calls with `pty: true`, plus native `glob`, `grep`, and `search` operations for Atomic's built-in `find` and `search` tools.
package/native/index.d.ts CHANGED
@@ -1,12 +1,17 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
- export declare class HostSession {
4
3
 
5
- }
4
+ /**
5
+ * Which binding artifact the generated loader actually loaded: `'native'` for
6
+ * a native addon, otherwise the `platformArchABI` of the WASI flavor. Every
7
+ * flavor napi-rs can build is listed, because `NAPI_RS_NATIVE_LIBRARY_PATH`
8
+ * can point the loader at a WASI artifact this package does not build itself.
9
+ */
10
+ export declare const __napiBindingTarget: 'native' | 'wasm32-wasi' | 'wasm32-wasip1' | undefined
6
11
 
7
- export declare class OwnerLease {
12
+ export declare class HostSession {}
8
13
 
9
- }
14
+ export declare class OwnerLease {}
10
15
 
11
16
  export declare class PtySession {
12
17
  constructor()
@@ -31,13 +36,16 @@ export declare class RetainedPostgres {
31
36
  release(): void
32
37
  }
33
38
 
34
- export declare class RunnerLease {
35
-
39
+ /** Available only on Windows. */
40
+ export declare class WindowsPostgresProcessGuard {
41
+ get status(): 'live' | 'absent' | 'mismatch'
42
+ exited(): boolean
43
+ close(): void
36
44
  }
37
45
 
38
- export declare class StdinLease {
46
+ export declare class RunnerLease {}
39
47
 
40
- }
48
+ export declare class StdinLease {}
41
49
 
42
50
  /**
43
51
  * N-API wrapper around the root-scoped Rust control plane. The host marker is
@@ -61,69 +69,65 @@ export declare class SubagentControl {
61
69
  }
62
70
  export type NapiSubagentControl = SubagentControl
63
71
 
64
- export declare class SubscriptionLease {
65
-
66
- }
67
-
68
- export declare class TaskLease {
72
+ export declare class SubscriptionLease {}
69
73
 
70
- }
74
+ export declare class TaskLease {}
71
75
 
72
76
  /** A single serialized native actor is shared by all instances in this environment. */
73
77
  export declare class TaskSupervisor {
74
78
  constructor()
75
79
  /** Trusted-host seam only. Host authorization must run before admission. */
76
80
  bindHostSession(scope: OwnerScope): HostSession
77
- openTaskOwner(host: HostSession, scope: OwnerScope): {ok:true,value:OwnerLease}|{ok:false,error:TaskFailure}
78
- startAgentTask(owner: OwnerLease, intent: AgentIntent, operation: string): {ok:true,value:TaskLease}|{ok:false,error:TaskFailure}
79
- /** Admits one owned command; waiting for this setup never imposes an execution deadline. */
80
- startCommandTask(owner: OwnerLease, intent: CommandIntent, operation: string, options?: CommandResourceOptions | undefined | null): Promise<{ok:true,value:TaskLease}|{ok:false,error:TaskFailure}>
81
- resizeTaskTerminal(task: TaskLease, columns: number, rows: number): {ok:true,value:undefined}|{ok:false,error:TaskFailure}
82
- taskStdin(task: TaskLease): {ok:true,value:StdinLease}|{ok:false,error:TaskFailure}
83
- writeTaskInput(input: StdinLease, operation: string, data: InputData): Promise<{ok:true,value:InputReceipt}|{ok:false,error:TaskFailure}>
84
- readTaskOutput(task: TaskLease, range: OutputRange): Promise<{ok:true,value:OutputPage}|{ok:false,error:TaskFailure}>
85
- /** Claim once after host dispatch setup; operation replay never grants a second runner. */
86
- claimTaskRunner(task: TaskLease): {ok:true,value:RunnerLease}|{ok:false,error:TaskFailure}
87
- taskReference(task: TaskLease): {ok:true,value:NativeTaskRef}|{ok:false,error:TaskFailure}
88
- /** Read the retained terminal receipt without registering an observation or replaying execution. */
89
- taskSettlement(task: TaskLease): {ok:true,value:SettlementReceipt}|{ok:false,error:TaskFailure}
90
- lookupTask(owner: OwnerLease, taskId: string): {ok:true,value:TaskLease}|{ok:false,error:TaskFailure}
91
- /**
92
- * Registers the observation before returning. Await observeTaskWait separately.
93
- * Accepts the host-resolved numeric budget without u32 narrowing; omission arms no timer.
94
- */
95
- waitForTask(task: TaskLease, budgetMs?: number | undefined | null, designation?: HostSession | undefined | null): {ok:true,value:WaitLease}|{ok:false,error:TaskFailure}
96
- foregroundTask(task: TaskLease, host: HostSession, budgetMs?: number | undefined | null): {ok:true,value:WaitLease}|{ok:false,error:TaskFailure}
97
- observeTaskWait(wait: WaitLease): Promise<{ok:true,value:WaitOutcome}|{ok:false,error:TaskFailure}>
98
- yieldTaskWait(wait: WaitLease, reason: YieldReason): {ok:true,value:WaitOutcome}|{ok:false,error:TaskFailure}
99
- disposeTaskWait(wait: WaitLease): {ok:true,value:undefined}|{ok:false,error:TaskFailure}
100
- cancelTask(task: TaskLease, cause: CancelCause): {ok:true,value:CancelReceipt}|{ok:false,error:TaskFailure}
101
- /** Seals synchronously, then awaits independent runner cleanup acknowledgements. */
102
- closeTaskOwner(owner: OwnerLease, cause: OwnerCloseCause): Promise<{ok:true,value:OwnerCloseReceipt}|{ok:false,error:TaskFailure}>
103
- /**
104
- * Retains the latest 256 accepted activity IDs with SHA-256 hashes and receipts per task.
105
- * Identical replay is duplicate; conflicts emit no events and neither refreshes retention.
106
- * Evicted IDs are fresh reports subject to terminal/owner guards. Terminal receipts never expire
107
- * while the task record exists; this is not a total task-history byte cap or persistence layer.
108
- */
109
- reportTaskActivity(runner: RunnerLease, report: ActivityReport): {ok:true,value:ReportReceipt}|{ok:false,error:TaskFailure}
110
- reportTaskOutcome(runner: RunnerLease, report: OutcomeReport): {ok:true,value:SettlementReceipt}|{ok:false,error:TaskFailure}
111
- /**
112
- * Private trusted-runner support, not a model/facade domain door.
113
- * Allocates an unused terminal report ID atomically within the bounded activity window.
114
- * Caller report IDs are never reserved or rewritten. Replay retains the terminal receipt;
115
- * conflicting results and cancellation still use the report_task_outcome acceptance rules.
116
- */
117
- reportRunnerOutcome(runner: RunnerLease, result: TaskResult): {ok:true,value:SettlementReceipt}|{ok:false,error:TaskFailure}
118
- /** Private trusted-runner support, not a model/facade domain door. Outcome is not cleanup. */
119
- acknowledgeTaskCleanup(runner: RunnerLease, cleanup: Cleanup): {ok:true,value:Cleanup}|{ok:false,error:TaskFailure}
120
- /**
121
- * The callback wakes a drain. The host must also keep one bounded reconciliation poll
122
- * until disposal/owner closure: an oversized evicted event has no authentic wake payload.
123
- */
124
- watchOwnerTasks(owner: OwnerLease, callback: (event: NativeEvent) => void, cursor?: Cursor | undefined | null): {ok:true,value:NativeTaskSubscription}|{ok:false,error:TaskFailure}
125
- drainOwnerTasks(lease: SubscriptionLease): {ok:true,value:SubscriptionDrain}|{ok:false,error:TaskFailure}
126
- disposeSubscription(lease: SubscriptionLease): void
81
+ openTaskOwner(host: HostSession, scope: OwnerScope): {ok:true,value:OwnerLease}|{ok:false,error:TaskFailure}
82
+ startAgentTask(owner: OwnerLease, intent: AgentIntent, operation: string): {ok:true,value:TaskLease}|{ok:false,error:TaskFailure}
83
+ /** Admits one owned command; waiting for this setup never imposes an execution deadline. */
84
+ startCommandTask(owner: OwnerLease, intent: CommandIntent, operation: string, options?: CommandResourceOptions | undefined | null): Promise<{ok:true,value:TaskLease}|{ok:false,error:TaskFailure}>
85
+ resizeTaskTerminal(task: TaskLease, columns: number, rows: number): {ok:true,value:undefined}|{ok:false,error:TaskFailure}
86
+ taskStdin(task: TaskLease): {ok:true,value:StdinLease}|{ok:false,error:TaskFailure}
87
+ writeTaskInput(input: StdinLease, operation: string, data: InputData): Promise<{ok:true,value:InputReceipt}|{ok:false,error:TaskFailure}>
88
+ readTaskOutput(task: TaskLease, range: OutputRange): Promise<{ok:true,value:OutputPage}|{ok:false,error:TaskFailure}>
89
+ /** Claim once after host dispatch setup; operation replay never grants a second runner. */
90
+ claimTaskRunner(task: TaskLease): {ok:true,value:RunnerLease}|{ok:false,error:TaskFailure}
91
+ taskReference(task: TaskLease): {ok:true,value:NativeTaskRef}|{ok:false,error:TaskFailure}
92
+ /** Read the retained terminal receipt without registering an observation or replaying execution. */
93
+ taskSettlement(task: TaskLease): {ok:true,value:SettlementReceipt}|{ok:false,error:TaskFailure}
94
+ lookupTask(owner: OwnerLease, taskId: string): {ok:true,value:TaskLease}|{ok:false,error:TaskFailure}
95
+ /**
96
+ * Registers the observation before returning. Await observeTaskWait separately.
97
+ * Accepts the host-resolved numeric budget without u32 narrowing; omission arms no timer.
98
+ */
99
+ waitForTask(task: TaskLease, budgetMs?: number | undefined | null, designation?: HostSession | undefined | null): {ok:true,value:WaitLease}|{ok:false,error:TaskFailure}
100
+ foregroundTask(task: TaskLease, host: HostSession, budgetMs?: number | undefined | null): {ok:true,value:WaitLease}|{ok:false,error:TaskFailure}
101
+ observeTaskWait(wait: WaitLease): Promise<{ok:true,value:WaitOutcome}|{ok:false,error:TaskFailure}>
102
+ yieldTaskWait(wait: WaitLease, reason: YieldReason): {ok:true,value:WaitOutcome}|{ok:false,error:TaskFailure}
103
+ disposeTaskWait(wait: WaitLease): {ok:true,value:undefined}|{ok:false,error:TaskFailure}
104
+ cancelTask(task: TaskLease, cause: CancelCause): {ok:true,value:CancelReceipt}|{ok:false,error:TaskFailure}
105
+ /** Seals synchronously, then awaits independent runner cleanup acknowledgements. */
106
+ closeTaskOwner(owner: OwnerLease, cause: OwnerCloseCause): Promise<{ok:true,value:OwnerCloseReceipt}|{ok:false,error:TaskFailure}>
107
+ /**
108
+ * Retains the latest 256 accepted activity IDs with SHA-256 hashes and receipts per task.
109
+ * Identical replay is duplicate; conflicts emit no events and neither refreshes retention.
110
+ * Evicted IDs are fresh reports subject to terminal/owner guards. Terminal receipts never expire
111
+ * while the task record exists; this is not a total task-history byte cap or persistence layer.
112
+ */
113
+ reportTaskActivity(runner: RunnerLease, report: ActivityReport): {ok:true,value:ReportReceipt}|{ok:false,error:TaskFailure}
114
+ reportTaskOutcome(runner: RunnerLease, report: OutcomeReport): {ok:true,value:SettlementReceipt}|{ok:false,error:TaskFailure}
115
+ /**
116
+ * Private trusted-runner support, not a model/facade domain door.
117
+ * Allocates an unused terminal report ID atomically within the bounded activity window.
118
+ * Caller report IDs are never reserved or rewritten. Replay retains the terminal receipt;
119
+ * conflicting results and cancellation still use the report_task_outcome acceptance rules.
120
+ */
121
+ reportRunnerOutcome(runner: RunnerLease, result: TaskResult): {ok:true,value:SettlementReceipt}|{ok:false,error:TaskFailure}
122
+ /** Private trusted-runner support, not a model/facade domain door. Outcome is not cleanup. */
123
+ acknowledgeTaskCleanup(runner: RunnerLease, cleanup: Cleanup): {ok:true,value:Cleanup}|{ok:false,error:TaskFailure}
124
+ /**
125
+ * The callback wakes a drain. The host must also keep one bounded reconciliation poll
126
+ * until disposal/owner closure: an oversized evicted event has no authentic wake payload.
127
+ */
128
+ watchOwnerTasks(owner: OwnerLease, callback: (event: NativeEvent) => void, cursor?: Cursor | undefined | null): {ok:true,value:NativeTaskSubscription}|{ok:false,error:TaskFailure}
129
+ drainOwnerTasks(lease: SubscriptionLease): {ok:true,value:SubscriptionDrain}|{ok:false,error:TaskFailure}
130
+ disposeSubscription(lease: SubscriptionLease): void
127
131
  }
128
132
  export type NapiTaskSupervisor = TaskSupervisor
129
133
 
@@ -132,24 +136,19 @@ export declare class WaitLease {
132
136
  }
133
137
 
134
138
  export type ActivityChange =
135
- | { kind: 'action', tool: string, text: string }
136
- | { kind: 'model', model?: string, thinking?: string }
137
- | { kind: 'metrics', elapsedMs?: number, toolCount?: number, tokenCount?: number }
138
- | { kind: 'output', offset: string, bytesBase64: string }
139
- | { kind: 'attention-set', attention: Attention }
140
- | { kind: 'attention-clear', requestId: string }
139
+ | { kind: 'action'; tool: string; text: string }
140
+ | { kind: 'model'; model?: string; thinking?: string }
141
+ | { kind: 'metrics'; elapsedMs?: number; toolCount?: number; tokenCount?: number }
142
+ | { kind: 'output'; offset: string; bytesBase64: string }
143
+ | { kind: 'attention-set'; attention: Attention }
144
+ | { kind: 'attention-clear'; requestId: string }
141
145
 
142
146
  export interface ActivityReport {
143
147
  reportId: string
144
148
  change: ActivityChange
145
149
  }
146
150
 
147
- export type AdmissionRefusalKind = 'depthExceeded'|
148
- 'capacityExhausted'|
149
- 'dispatchGuardBusy'|
150
- 'invalidCwd'|
151
- 'unknownAgent'|
152
- 'terminalChild';
151
+ export type AdmissionRefusalKind = 'depthExceeded' | 'capacityExhausted' | 'dispatchGuardBusy' | 'invalidCwd' | 'unknownAgent' | 'terminalChild'
153
152
 
154
153
  /** Caller-provided strings retain their exact JavaScript UTF-16 code units. */
155
154
  export interface AgentIntent {
@@ -162,19 +161,14 @@ export interface AgentIntent {
162
161
  }
163
162
 
164
163
  /** The only statuses emitted by a child status watch. */
165
- export type AgentStatus = 'pending'|
166
- 'running'|
167
- 'ok'|
168
- 'error'|
169
- 'interrupted'|
170
- 'continued';
164
+ export type AgentStatus = 'pending' | 'running' | 'ok' | 'error' | 'interrupted' | 'continued'
171
165
 
172
- export type AgentTaskKind = 'agent';
166
+ export type AgentTaskKind = 'agent'
173
167
 
174
168
  export type Attention =
175
169
  | { kind: 'none' }
176
- | { kind: 'input-needed', requestId: string, prompt: string, route: PromptRoute }
177
- | { kind: 'no-recent-activity', lastActivityAt?: string }
170
+ | { kind: 'input-needed'; requestId: string; prompt: string; route: PromptRoute }
171
+ | { kind: 'no-recent-activity'; lastActivityAt?: string }
178
172
 
179
173
  export interface BlockRange {
180
174
  /** 1-indexed inclusive first line of the resolved block. */
@@ -199,12 +193,7 @@ export interface BlockRangeOptions {
199
193
  line: number
200
194
  }
201
195
 
202
- export type CancelCause = 'user'|
203
- 'owner-close'|
204
- 'execution-timeout'|
205
- 'output-limit'|
206
- 'parent-handoff'|
207
- 'shutdown';
196
+ export type CancelCause = 'user' | 'owner-close' | 'execution-timeout' | 'output-limit' | 'parent-handoff' | 'shutdown'
208
197
 
209
198
  export interface CancelReceipt {
210
199
  taskId: string
@@ -228,7 +217,7 @@ export type Cleanup =
228
217
  | { kind: 'active' }
229
218
  | { kind: 'draining' }
230
219
  | { kind: 'reaped' }
231
- | { kind: 'failed', resources: Array<ResourceFailure> }
220
+ | { kind: 'failed'; resources: Array<ResourceFailure> }
232
221
 
233
222
  export interface CommandIntent {
234
223
  kind: CommandTaskKind
@@ -244,8 +233,7 @@ export interface CommandIntent {
244
233
  parentTaskId?: string
245
234
  }
246
235
 
247
- export type CommandOutputSink = 'file-spool'|
248
- 'drained';
236
+ export type CommandOutputSink = 'file-spool' | 'drained'
249
237
 
250
238
  /** Trusted native adapter configuration, never model input or CommandIntent fields. */
251
239
  export interface CommandResourceOptions {
@@ -262,11 +250,11 @@ export interface CommandShell {
262
250
  args: string[]
263
251
  }
264
252
 
265
- export type CommandTaskKind = 'command';
253
+ export type CommandTaskKind = 'command'
266
254
 
267
255
  export type CommandTerminal =
268
256
  | { kind: 'pipe' }
269
- | { kind: 'pty', columns: number, rows: number }
257
+ | { kind: 'pty'; columns: number; rows: number }
270
258
 
271
259
  /** A context line (before or after a match). */
272
260
  export interface ContextLine {
@@ -289,8 +277,8 @@ export interface Cursor {
289
277
  export type Execution =
290
278
  | { kind: 'queued' }
291
279
  | { kind: 'running' }
292
- | { kind: 'cancelling', cause: CancelCause }
293
- | { kind: 'settled', result: TaskResult }
280
+ | { kind: 'cancelling'; cause: CancelCause }
281
+ | { kind: 'settled'; result: TaskResult }
294
282
 
295
283
  /** Resolved filesystem entry kind for glob filters and match metadata. */
296
284
  export declare enum FileType {
@@ -299,7 +287,7 @@ export declare enum FileType {
299
287
  /** Directory. */
300
288
  Dir = 2,
301
289
  /** Symbolic link. */
302
- Symlink = 3
290
+ Symlink = 3,
303
291
  }
304
292
 
305
293
  /**
@@ -455,12 +443,7 @@ export interface GrepOptions {
455
443
  }
456
444
 
457
445
  /** Output mode for [`search`] and [`grep`] (string values match JS callers). */
458
- export type GrepOutputMode = /** Emit matched lines (and optional context lines). */
459
- 'content'|
460
- /** Emit per-file or total counts instead of line content. */
461
- 'count'|
462
- /** Emit one row per file that matched| without line content. */
463
- 'filesWithMatches';
446
+ export type GrepOutputMode = 'content' | 'count' | 'filesWithMatches'
464
447
 
465
448
  /** Result of searching files. */
466
449
  export interface GrepResult {
@@ -496,12 +479,12 @@ export interface GrepResult {
496
479
  export declare function hasMatch(content: string | Uint8Array, pattern: string | Uint8Array, ignoreCase?: boolean | undefined | null, multiline?: boolean | undefined | null): boolean
497
480
 
498
481
  export type HostObservation =
499
- | { kind: 'foreground', waitId: string }
500
- | { kind: 'background', reason: string }
501
- | { kind: 'none', reason: string }
482
+ | { kind: 'foreground'; waitId: string }
483
+ | { kind: 'background'; reason: string }
484
+ | { kind: 'none'; reason: string }
502
485
 
503
486
  export type InputData =
504
- | { kind: 'bytes', bytes: Buffer }
487
+ | { kind: 'bytes'; bytes: Buffer }
505
488
  | { kind: 'eof' }
506
489
 
507
490
  export interface InputReceipt {
@@ -634,9 +617,7 @@ export interface OutputRef {
634
617
  omittedRanges: Array<OmittedRange>
635
618
  }
636
619
 
637
- export type OwnerCloseCause = 'session-close'|
638
- 'stage-close'|
639
- 'app-shutdown';
620
+ export type OwnerCloseCause = 'session-close' | 'stage-close' | 'app-shutdown'
640
621
 
641
622
  export interface OwnerCloseReceipt {
642
623
  ownerId: string
@@ -645,8 +626,8 @@ export interface OwnerCloseReceipt {
645
626
  }
646
627
 
647
628
  export type OwnerScope =
648
- | { kind: 'session', sessionId: string }
649
- | { kind: 'workflow-stage', sessionId: string, runId: string, stageId: string, stageAttemptId: string }
629
+ | { kind: 'session'; sessionId: string }
630
+ | { kind: 'workflow-stage'; sessionId: string; runId: string; stageId: string; stageAttemptId: string }
650
631
 
651
632
  export interface OwnerSnapshot {
652
633
  ownerId: string
@@ -657,6 +638,13 @@ export interface OwnerSnapshot {
657
638
  cursor: Cursor
658
639
  }
659
640
 
641
+ export interface PostgresProcessIdentity {
642
+ found: boolean
643
+ startTime?: number
644
+ }
645
+
646
+ export declare function postgresProcessStartTime(pid: number): PostgresProcessIdentity
647
+
660
648
  export interface PromptRoute {
661
649
  sessionId: string
662
650
  promptId: string
@@ -766,6 +754,8 @@ export interface SettlementReceipt {
766
754
  completionId: string
767
755
  }
768
756
 
757
+ export declare function signalVerifiedPostgres(pid: number, expectedStartTime: number, mode: string): string
758
+
769
759
  export declare function spawnRetainedPostgres(options: RetainedPostgresSpawnOptions): RetainedPostgres
770
760
 
771
761
  export interface SubscriptionDrain {
@@ -777,15 +767,15 @@ export interface SubscriptionDrain {
777
767
  }
778
768
 
779
769
  export type TaskEvent =
780
- | { kind: 'task-admitted', task: TaskRecord }
781
- | { kind: 'task-started', ref: NativeTaskRef }
782
- | { kind: 'wait-yielded', ref: NativeTaskRef, waitId: string, reason: YieldReason }
783
- | { kind: 'wait-started', ref: NativeTaskRef, waitId: string, observer: string }
784
- | { kind: 'host-observation-changed', ref: NativeTaskRef, observation: HostObservation }
785
- | { kind: 'task-activity', ref: NativeTaskRef, activity: ActivityReport }
786
- | { kind: 'task-cancelling', ref: NativeTaskRef, cause: CancelCause }
787
- | { kind: 'task-settled', ref: NativeTaskRef, result: TaskResult, completionId: string }
788
- | { kind: 'cleanup-changed', ref: NativeTaskRef, cleanup: Cleanup }
770
+ | { kind: 'task-admitted'; task: TaskRecord }
771
+ | { kind: 'task-started'; ref: NativeTaskRef }
772
+ | { kind: 'wait-yielded'; ref: NativeTaskRef; waitId: string; reason: YieldReason }
773
+ | { kind: 'wait-started'; ref: NativeTaskRef; waitId: string; observer: string }
774
+ | { kind: 'host-observation-changed'; ref: NativeTaskRef; observation: HostObservation }
775
+ | { kind: 'task-activity'; ref: NativeTaskRef; activity: ActivityReport }
776
+ | { kind: 'task-cancelling'; ref: NativeTaskRef; cause: CancelCause }
777
+ | { kind: 'task-settled'; ref: NativeTaskRef; result: TaskResult; completionId: string }
778
+ | { kind: 'cleanup-changed'; ref: NativeTaskRef; cleanup: Cleanup }
789
779
  | { kind: 'owner-closing' }
790
780
  | { kind: 'owner-closed' }
791
781
 
@@ -825,25 +815,21 @@ export interface TaskRecord {
825
815
 
826
816
  /** Terminal numeric exit codes retain JavaScript number values without i32 narrowing. */
827
817
  export type TaskResult =
828
- | { kind: 'completed', output: OutputRef, exitCode?: number }
829
- | { kind: 'failed', code: string, message: string, output?: OutputRef, exitCode?: number }
830
- | { kind: 'cancelled', cause: CancelCause, output?: OutputRef }
818
+ | { kind: 'completed'; output: OutputRef; exitCode?: number }
819
+ | { kind: 'failed'; code: string; message: string; output?: OutputRef; exitCode?: number }
820
+ | { kind: 'cancelled'; cause: CancelCause; output?: OutputRef }
831
821
 
832
822
  /**
833
823
  * Explicit termination causes. Timer/idle/wall-clock causes are intentionally
834
824
  * absent, making timer-driven termination unrepresentable.
835
825
  */
836
- export type TerminationCause = 'abort'|
837
- 'interrupt'|
838
- 'fail-fast-skip'|
839
- 'parent-shutdown';
826
+ export type TerminationCause = 'abort' | 'interrupt' | 'fail-fast-skip' | 'parent-shutdown'
840
827
 
841
828
  export type WaitOutcome =
842
- | { kind: 'settled', taskId: string, result: TaskResult }
843
- | { kind: 'yielded', taskId: string, waitId: string, reason: YieldReason }
844
-
845
- export type YieldReason = 'explicit'|
846
- 'default-background'|
847
- 'elapsed'|
848
- 'intercom-coordination'|
849
- 'input-needed';
829
+ | { kind: 'settled'; taskId: string; result: TaskResult }
830
+ | { kind: 'yielded'; taskId: string; waitId: string; reason: YieldReason }
831
+
832
+ export type YieldReason = 'explicit' | 'default-background' | 'elapsed' | 'intercom-coordination' | 'input-needed'
833
+
834
+ /** Available only on Windows. */
835
+ export declare function guardWindowsPostgresProcess(pid: number, expectedStartTime: number): WindowsPostgresProcessGuard
package/native/index.js CHANGED
@@ -1,10 +1,13 @@
1
- // prettier-ignore
2
1
  /* eslint-disable */
3
2
  // @ts-nocheck
4
3
  /* auto-generated by NAPI-RS */
5
4
 
6
5
  const { readFileSync } = require('fs')
7
6
  let nativeBinding = null
7
+ // Which artifact actually loaded. The WASI fallback chain overwrites it with
8
+ // the flavor it resolved; the late native retry below leaves it alone because
9
+ // it only runs while no WASI candidate has been loaded.
10
+ let __napiLoadedBindingTarget = 'native'
8
11
  const loadErrors = []
9
12
 
10
13
  const isMusl = () => {
@@ -63,7 +66,16 @@ const isMuslFromChildProcess = () => {
63
66
  function requireNative() {
64
67
  if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
65
68
  try {
66
- return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
69
+ const overrideBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH)
70
+ // The override may be a generated WASI loader, which already reports its
71
+ // own flavor. Adopt it: `module.exports` aliases this object, so claiming
72
+ // 'native' would both misreport the artifact and overwrite the loader's
73
+ // marker through the alias.
74
+ __napiLoadedBindingTarget =
75
+ overrideBinding && typeof overrideBinding.__napiBindingTarget === 'string'
76
+ ? overrideBinding.__napiBindingTarget
77
+ : 'native'
78
+ return overrideBinding
67
79
  } catch (err) {
68
80
  loadErrors.push(err)
69
81
  }
@@ -77,8 +89,8 @@ function requireNative() {
77
89
  try {
78
90
  const binding = require('@bastani/atomic-natives-android-arm64')
79
91
  const bindingPackageVersion = require('@bastani/atomic-natives-android-arm64/package.json').version
80
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
92
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
93
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
82
94
  }
83
95
  return binding
84
96
  } catch (e) {
@@ -93,8 +105,8 @@ function requireNative() {
93
105
  try {
94
106
  const binding = require('@bastani/atomic-natives-android-arm-eabi')
95
107
  const bindingPackageVersion = require('@bastani/atomic-natives-android-arm-eabi/package.json').version
96
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
108
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
109
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
98
110
  }
99
111
  return binding
100
112
  } catch (e) {
@@ -107,36 +119,36 @@ function requireNative() {
107
119
  if (process.arch === 'x64') {
108
120
  if ((process.config && process.config.variables && process.config.variables.shlib_suffix === 'dll.a') || (process.config && process.config.variables && process.config.variables.node_target_type === 'shared_library')) {
109
121
  try {
110
- return require('./atomic_natives.win32-x64-gnu.node')
111
- } catch (e) {
112
- loadErrors.push(e)
113
- }
114
- try {
115
- const binding = require('@bastani/atomic-natives-win32-x64-gnu')
116
- const bindingPackageVersion = require('@bastani/atomic-natives-win32-x64-gnu/package.json').version
117
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
122
+ return require('./atomic_natives.win32-x64-gnu.node')
123
+ } catch (e) {
124
+ loadErrors.push(e)
125
+ }
126
+ try {
127
+ const binding = require('@bastani/atomic-natives-win32-x64-gnu')
128
+ const bindingPackageVersion = require('@bastani/atomic-natives-win32-x64-gnu/package.json').version
129
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
130
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
131
+ }
132
+ return binding
133
+ } catch (e) {
134
+ loadErrors.push(e)
119
135
  }
120
- return binding
121
- } catch (e) {
122
- loadErrors.push(e)
123
- }
124
136
  } else {
125
137
  try {
126
- return require('./atomic_natives.win32-x64-msvc.node')
127
- } catch (e) {
128
- loadErrors.push(e)
129
- }
130
- try {
131
- const binding = require('@bastani/atomic-natives-win32-x64-msvc')
132
- const bindingPackageVersion = require('@bastani/atomic-natives-win32-x64-msvc/package.json').version
133
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
138
+ return require('./atomic_natives.win32-x64-msvc.node')
139
+ } catch (e) {
140
+ loadErrors.push(e)
141
+ }
142
+ try {
143
+ const binding = require('@bastani/atomic-natives-win32-x64-msvc')
144
+ const bindingPackageVersion = require('@bastani/atomic-natives-win32-x64-msvc/package.json').version
145
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
146
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
147
+ }
148
+ return binding
149
+ } catch (e) {
150
+ loadErrors.push(e)
135
151
  }
136
- return binding
137
- } catch (e) {
138
- loadErrors.push(e)
139
- }
140
152
  }
141
153
  } else if (process.arch === 'ia32') {
142
154
  try {
@@ -147,8 +159,8 @@ function requireNative() {
147
159
  try {
148
160
  const binding = require('@bastani/atomic-natives-win32-ia32-msvc')
149
161
  const bindingPackageVersion = require('@bastani/atomic-natives-win32-ia32-msvc/package.json').version
150
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
162
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
163
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
152
164
  }
153
165
  return binding
154
166
  } catch (e) {
@@ -163,8 +175,8 @@ function requireNative() {
163
175
  try {
164
176
  const binding = require('@bastani/atomic-natives-win32-arm64-msvc')
165
177
  const bindingPackageVersion = require('@bastani/atomic-natives-win32-arm64-msvc/package.json').version
166
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
178
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
179
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
168
180
  }
169
181
  return binding
170
182
  } catch (e) {
@@ -182,8 +194,8 @@ function requireNative() {
182
194
  try {
183
195
  const binding = require('@bastani/atomic-natives-darwin-universal')
184
196
  const bindingPackageVersion = require('@bastani/atomic-natives-darwin-universal/package.json').version
185
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
197
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
198
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
187
199
  }
188
200
  return binding
189
201
  } catch (e) {
@@ -198,8 +210,8 @@ function requireNative() {
198
210
  try {
199
211
  const binding = require('@bastani/atomic-natives-darwin-x64')
200
212
  const bindingPackageVersion = require('@bastani/atomic-natives-darwin-x64/package.json').version
201
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
213
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
214
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
203
215
  }
204
216
  return binding
205
217
  } catch (e) {
@@ -214,8 +226,8 @@ function requireNative() {
214
226
  try {
215
227
  const binding = require('@bastani/atomic-natives-darwin-arm64')
216
228
  const bindingPackageVersion = require('@bastani/atomic-natives-darwin-arm64/package.json').version
217
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
229
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
230
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
219
231
  }
220
232
  return binding
221
233
  } catch (e) {
@@ -234,8 +246,8 @@ function requireNative() {
234
246
  try {
235
247
  const binding = require('@bastani/atomic-natives-freebsd-x64')
236
248
  const bindingPackageVersion = require('@bastani/atomic-natives-freebsd-x64/package.json').version
237
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
249
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
250
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
251
  }
240
252
  return binding
241
253
  } catch (e) {
@@ -250,8 +262,8 @@ function requireNative() {
250
262
  try {
251
263
  const binding = require('@bastani/atomic-natives-freebsd-arm64')
252
264
  const bindingPackageVersion = require('@bastani/atomic-natives-freebsd-arm64/package.json').version
253
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
265
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
266
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
255
267
  }
256
268
  return binding
257
269
  } catch (e) {
@@ -271,8 +283,8 @@ function requireNative() {
271
283
  try {
272
284
  const binding = require('@bastani/atomic-natives-linux-x64-musl')
273
285
  const bindingPackageVersion = require('@bastani/atomic-natives-linux-x64-musl/package.json').version
274
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
286
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
287
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
276
288
  }
277
289
  return binding
278
290
  } catch (e) {
@@ -287,8 +299,8 @@ function requireNative() {
287
299
  try {
288
300
  const binding = require('@bastani/atomic-natives-linux-x64-gnu')
289
301
  const bindingPackageVersion = require('@bastani/atomic-natives-linux-x64-gnu/package.json').version
290
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
302
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
303
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
292
304
  }
293
305
  return binding
294
306
  } catch (e) {
@@ -305,8 +317,8 @@ function requireNative() {
305
317
  try {
306
318
  const binding = require('@bastani/atomic-natives-linux-arm64-musl')
307
319
  const bindingPackageVersion = require('@bastani/atomic-natives-linux-arm64-musl/package.json').version
308
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
320
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
321
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
322
  }
311
323
  return binding
312
324
  } catch (e) {
@@ -321,8 +333,8 @@ function requireNative() {
321
333
  try {
322
334
  const binding = require('@bastani/atomic-natives-linux-arm64-gnu')
323
335
  const bindingPackageVersion = require('@bastani/atomic-natives-linux-arm64-gnu/package.json').version
324
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
336
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
337
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
326
338
  }
327
339
  return binding
328
340
  } catch (e) {
@@ -339,8 +351,8 @@ function requireNative() {
339
351
  try {
340
352
  const binding = require('@bastani/atomic-natives-linux-arm-musleabihf')
341
353
  const bindingPackageVersion = require('@bastani/atomic-natives-linux-arm-musleabihf/package.json').version
342
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
354
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
355
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
356
  }
345
357
  return binding
346
358
  } catch (e) {
@@ -355,8 +367,8 @@ function requireNative() {
355
367
  try {
356
368
  const binding = require('@bastani/atomic-natives-linux-arm-gnueabihf')
357
369
  const bindingPackageVersion = require('@bastani/atomic-natives-linux-arm-gnueabihf/package.json').version
358
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
370
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
371
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
372
  }
361
373
  return binding
362
374
  } catch (e) {
@@ -373,8 +385,8 @@ function requireNative() {
373
385
  try {
374
386
  const binding = require('@bastani/atomic-natives-linux-loong64-musl')
375
387
  const bindingPackageVersion = require('@bastani/atomic-natives-linux-loong64-musl/package.json').version
376
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
388
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
389
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
390
  }
379
391
  return binding
380
392
  } catch (e) {
@@ -389,8 +401,8 @@ function requireNative() {
389
401
  try {
390
402
  const binding = require('@bastani/atomic-natives-linux-loong64-gnu')
391
403
  const bindingPackageVersion = require('@bastani/atomic-natives-linux-loong64-gnu/package.json').version
392
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
404
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
405
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
394
406
  }
395
407
  return binding
396
408
  } catch (e) {
@@ -407,8 +419,8 @@ function requireNative() {
407
419
  try {
408
420
  const binding = require('@bastani/atomic-natives-linux-riscv64-musl')
409
421
  const bindingPackageVersion = require('@bastani/atomic-natives-linux-riscv64-musl/package.json').version
410
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
422
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
423
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
424
  }
413
425
  return binding
414
426
  } catch (e) {
@@ -423,8 +435,8 @@ function requireNative() {
423
435
  try {
424
436
  const binding = require('@bastani/atomic-natives-linux-riscv64-gnu')
425
437
  const bindingPackageVersion = require('@bastani/atomic-natives-linux-riscv64-gnu/package.json').version
426
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
438
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
439
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
428
440
  }
429
441
  return binding
430
442
  } catch (e) {
@@ -440,8 +452,8 @@ function requireNative() {
440
452
  try {
441
453
  const binding = require('@bastani/atomic-natives-linux-ppc64-gnu')
442
454
  const bindingPackageVersion = require('@bastani/atomic-natives-linux-ppc64-gnu/package.json').version
443
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
455
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
456
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
445
457
  }
446
458
  return binding
447
459
  } catch (e) {
@@ -456,8 +468,8 @@ function requireNative() {
456
468
  try {
457
469
  const binding = require('@bastani/atomic-natives-linux-s390x-gnu')
458
470
  const bindingPackageVersion = require('@bastani/atomic-natives-linux-s390x-gnu/package.json').version
459
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
471
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
472
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
461
473
  }
462
474
  return binding
463
475
  } catch (e) {
@@ -476,8 +488,8 @@ function requireNative() {
476
488
  try {
477
489
  const binding = require('@bastani/atomic-natives-openharmony-arm64')
478
490
  const bindingPackageVersion = require('@bastani/atomic-natives-openharmony-arm64/package.json').version
479
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
491
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
492
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
481
493
  }
482
494
  return binding
483
495
  } catch (e) {
@@ -492,8 +504,8 @@ function requireNative() {
492
504
  try {
493
505
  const binding = require('@bastani/atomic-natives-openharmony-x64')
494
506
  const bindingPackageVersion = require('@bastani/atomic-natives-openharmony-x64/package.json').version
495
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
507
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
508
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
497
509
  }
498
510
  return binding
499
511
  } catch (e) {
@@ -508,8 +520,8 @@ function requireNative() {
508
520
  try {
509
521
  const binding = require('@bastani/atomic-natives-openharmony-arm')
510
522
  const bindingPackageVersion = require('@bastani/atomic-natives-openharmony-arm/package.json').version
511
- if (bindingPackageVersion !== '0.9.19' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
- throw new Error(`Native binding package version mismatch, expected 0.9.19 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
523
+ if (bindingPackageVersion !== '0.9.20-alpha.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
524
+ throw new Error(`Native binding package version mismatch, expected 0.9.20-alpha.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
525
  }
514
526
  return binding
515
527
  } catch (e) {
@@ -550,7 +562,7 @@ function createLoadErrorChain(errors) {
550
562
  //
551
563
  // NAPI_RS_WASI_FLAVOR selects one exact generated flavor and implies strict
552
564
  // WASI loading. It never crosses into another flavor or falls back to native.
553
- const __napiWasiFlavors = ["wasm32-wasi"]
565
+ const __napiWasiFlavors = ['wasm32-wasi']
554
566
  const __napiWasiFlavor = process.env.NAPI_RS_WASI_FLAVOR
555
567
  const __napiWasiFlavorRequested =
556
568
  typeof __napiWasiFlavor === 'string' && __napiWasiFlavor.length > 0
@@ -619,15 +631,16 @@ if (!nativeBinding || forceWasi) {
619
631
  }
620
632
  return null
621
633
  }
622
- if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === "wasm32-wasi")) {
634
+ if (!__napiWasiFlavorRequested || __napiWasiFlavor === 'wasm32-wasi') {
623
635
  let candidateError = null
624
636
  let candidateFailed = false
625
637
  try {
626
- candidateError = __napiWasiResolveCandidate('./atomic_natives.wasi.cjs', false, ["./atomic_natives.wasm32-wasi.debug.wasm","./atomic_natives.wasm32-wasi.wasm"])
638
+ candidateError = __napiWasiResolveCandidate('./atomic_natives.wasi.cjs', false, ['./atomic_natives.wasm32-wasi.debug.wasm', './atomic_natives.wasm32-wasi.wasm'])
627
639
  candidateFailed = candidateError !== null
628
640
  if (!candidateFailed) {
629
641
  wasiBinding = require('./atomic_natives.wasi.cjs')
630
642
  nativeBinding = wasiBinding
643
+ __napiLoadedBindingTarget = 'wasm32-wasi'
631
644
  wasiBindingLoaded = true
632
645
  }
633
646
  } catch (err) {
@@ -639,7 +652,7 @@ if (!nativeBinding || forceWasi) {
639
652
  loadErrors.push(candidateError)
640
653
  }
641
654
  }
642
- if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === "wasm32-wasi")) {
655
+ if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === 'wasm32-wasi')) {
643
656
  let candidateError = null
644
657
  let candidateFailed = false
645
658
  try {
@@ -654,6 +667,7 @@ if (!nativeBinding || forceWasi) {
654
667
  }
655
668
  wasiBinding = require('@bastani/atomic-natives-wasm32-wasi')
656
669
  nativeBinding = wasiBinding
670
+ __napiLoadedBindingTarget = 'wasm32-wasi'
657
671
  wasiBindingLoaded = true
658
672
  }
659
673
  } catch (err) {
@@ -699,6 +713,70 @@ if (!nativeBinding) {
699
713
  throw new Error(`Failed to load native binding`)
700
714
  }
701
715
 
716
+ function __napiStampBindingTarget(exportsObject, target) {
717
+ if (
718
+ Object.prototype.hasOwnProperty.call(exportsObject, '__napiBindingTarget')
719
+ ) {
720
+ if (exportsObject.__napiBindingTarget === target) {
721
+ // Already ours: the root entry aliases the object it loaded, so a WASI
722
+ // fallback candidate — or a `NAPI_RS_NATIVE_LIBRARY_PATH` override that
723
+ // is a generated loader — arrives already stamped with this same value.
724
+ return target
725
+ }
726
+ const error = new Error(
727
+ '`__napiBindingTarget` is reserved by the generated binding loader, but the loaded binding already exports it. Rename the export, e.g. #[napi(js_name = "...")].',
728
+ )
729
+ error.code = 'ERR_NAPI_BINDING_TARGET_CONFLICT'
730
+ throw error
731
+ }
732
+ if (!Object.isExtensible(exportsObject)) {
733
+ // A `#[napi(module_exports)]` hook may seal or freeze this object
734
+ // (`Object::seal` / `Object::freeze`). Reporting the artifact is metadata,
735
+ // never a reason to fail an otherwise successful load, so the stamp is
736
+ // skipped. What a consumer still sees then follows the entry point: the
737
+ // browser and deferred loaders declare `__napiBindingTarget` at module
738
+ // level and go on reporting it, while the CommonJS entries hand back this
739
+ // very object as `module.exports`, so there the value is absent.
740
+ return target
741
+ }
742
+ try {
743
+ // [[Define]], not [[Set]]: an ordinary assignment walks the prototype
744
+ // chain, so an inherited accessor could swallow the value or throw and
745
+ // fail an otherwise successful load. The descriptor is what a successful
746
+ // assignment would have produced.
747
+ Object.defineProperty(exportsObject, '__napiBindingTarget', {
748
+ configurable: true,
749
+ enumerable: true,
750
+ value: target,
751
+ writable: true,
752
+ })
753
+ } catch {
754
+ // Same rule as the non-extensible skip above: reporting the artifact is
755
+ // metadata, never a reason to fail an otherwise successful load. An exotic
756
+ // object (a Proxy whose defineProperty trap refuses) is skipped, not
757
+ // thrown over.
758
+ }
759
+ // The CommonJS loaders assign this return value so `cjs-module-lexer` — and
760
+ // therefore Node's CJS -> ESM named export detection — can see
761
+ // `__napiBindingTarget` statically.
762
+ return target
763
+ }
764
+ // Stamp before the alias, not after. The guard only reads `nativeBinding`
765
+ // (`hasOwnProperty` plus a comparison), which is safe against any addon
766
+ // accessor; an assignment is not, because a `#[napi(module_exports)]` hook can
767
+ // expose a getter reporting this very value and a setter that throws. So the
768
+ // assignment lands on the loader's own `module.exports`, still the original
769
+ // object here, and the alias below replaces it.
770
+ //
771
+ // The assignment is what keeps the marker a statically visible CommonJS export:
772
+ // `cjs-module-lexer` is Node's CJS -> ESM named export detection, it cannot see
773
+ // a bare call, and the later `module.exports = nativeBinding` does not undo the
774
+ // detection. The assignment itself always succeeds — its target is this
775
+ // loader's own, still extensible `module.exports` — and the alias below then
776
+ // discards the value it wrote. What a consumer reads is whatever the guard put
777
+ // on `nativeBinding`, so on a frozen binding, where the guard skips, the
778
+ // linked import resolves to `undefined`.
779
+ module.exports.__napiBindingTarget = __napiStampBindingTarget(nativeBinding, __napiLoadedBindingTarget)
702
780
  module.exports = nativeBinding
703
781
  module.exports.HostSession = nativeBinding.HostSession
704
782
  module.exports.OwnerLease = nativeBinding.OwnerLease
@@ -727,7 +805,14 @@ module.exports.GrepOutputMode = nativeBinding.GrepOutputMode
727
805
  module.exports.hasMatch = nativeBinding.hasMatch
728
806
  module.exports.invalidateFsScanCache = nativeBinding.invalidateFsScanCache
729
807
  module.exports.OwnerCloseCause = nativeBinding.OwnerCloseCause
808
+ module.exports.postgresProcessStartTime = nativeBinding.postgresProcessStartTime
730
809
  module.exports.search = nativeBinding.search
810
+ module.exports.signalVerifiedPostgres = nativeBinding.signalVerifiedPostgres
731
811
  module.exports.spawnRetainedPostgres = nativeBinding.spawnRetainedPostgres
732
812
  module.exports.TerminationCause = nativeBinding.TerminationCause
733
813
  module.exports.YieldReason = nativeBinding.YieldReason
814
+
815
+ if (process.platform === 'win32') {
816
+ module.exports.WindowsPostgresProcessGuard = nativeBinding.WindowsPostgresProcessGuard
817
+ module.exports.guardWindowsPostgresProcess = nativeBinding.guardWindowsPostgresProcess
818
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/atomic-natives",
3
- "version": "0.9.19",
3
+ "version": "0.9.20-alpha.10",
4
4
  "description": "Native Rust bindings for Atomic via N-API",
5
5
  "homepage": "https://github.com/bastani-inc/atomic",
6
6
  "author": "Bastani",
@@ -28,7 +28,7 @@
28
28
  "prepublish:native": "napi prepublish --npm-dir npm --tag-style npm --no-gh-release"
29
29
  },
30
30
  "devDependencies": {
31
- "@napi-rs/cli": "3.9.0"
31
+ "@napi-rs/cli": "3.10.4"
32
32
  },
33
33
  "engines": {
34
34
  "bun": ">=1.4.2",
@@ -59,13 +59,13 @@
59
59
  "access": "public"
60
60
  },
61
61
  "optionalDependencies": {
62
- "@bastani/atomic-natives-win32-x64-msvc": "0.9.19",
63
- "@bastani/atomic-natives-darwin-x64": "0.9.19",
64
- "@bastani/atomic-natives-linux-x64-gnu": "0.9.19",
65
- "@bastani/atomic-natives-linux-arm64-gnu": "0.9.19",
66
- "@bastani/atomic-natives-darwin-arm64": "0.9.19",
67
- "@bastani/atomic-natives-win32-arm64-msvc": "0.9.19",
68
- "@bastani/atomic-natives-linux-x64-musl": "0.9.19",
69
- "@bastani/atomic-natives-linux-arm64-musl": "0.9.19"
62
+ "@bastani/atomic-natives-win32-x64-msvc": "0.9.20-alpha.10",
63
+ "@bastani/atomic-natives-darwin-x64": "0.9.20-alpha.10",
64
+ "@bastani/atomic-natives-linux-x64-gnu": "0.9.20-alpha.10",
65
+ "@bastani/atomic-natives-linux-arm64-gnu": "0.9.20-alpha.10",
66
+ "@bastani/atomic-natives-darwin-arm64": "0.9.20-alpha.10",
67
+ "@bastani/atomic-natives-win32-arm64-msvc": "0.9.20-alpha.10",
68
+ "@bastani/atomic-natives-linux-x64-musl": "0.9.20-alpha.10",
69
+ "@bastani/atomic-natives-linux-arm64-musl": "0.9.20-alpha.10"
70
70
  }
71
- }
71
+ }