@adriane-ai/napi 0.1.0-rc.1
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/LICENSE +201 -0
- package/NOTICE +13 -0
- package/README.md +88 -0
- package/adriane_napi.darwin-arm64.node +0 -0
- package/adriane_napi.linux-x64-gnu.node +0 -0
- package/adriane_napi.win32-x64-msvc.node +0 -0
- package/index.d.ts +72 -0
- package/index.js +65 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and do
|
|
117
|
+
not modify the License. You may add Your own attribution notices
|
|
118
|
+
within Derivative Works that You distribute, alongside or as an
|
|
119
|
+
addendum to the NOTICE text from the Work, provided that such
|
|
120
|
+
additional attribution notices cannot be construed as modifying
|
|
121
|
+
the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Adriane
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Adriane
|
|
2
|
+
Copyright 2026 The Adriane maintainers
|
|
3
|
+
|
|
4
|
+
This product includes software developed as part of the Adriane project
|
|
5
|
+
(https://github.com/prxmat/adriane-engine).
|
|
6
|
+
|
|
7
|
+
The Adriane framework — the Rust engine (crates/*), the TypeScript and Python
|
|
8
|
+
SDKs and supporting packages (packages/*), and the Claude Code plugin (plugin/*) —
|
|
9
|
+
is licensed under the Apache License, Version 2.0. You may obtain a copy of the
|
|
10
|
+
License in the root LICENSE file or at http://www.apache.org/licenses/LICENSE-2.0.
|
|
11
|
+
|
|
12
|
+
Adriane Studio, the hosted commercial control plane, is a separate product and is
|
|
13
|
+
not part of this repository.
|
package/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# adriane-napi — Node bindings for the Rust engine
|
|
2
|
+
|
|
3
|
+
napi-rs bindings that expose the Rust engine to Node, so the TypeScript SDK and
|
|
4
|
+
control plane can call the Rust core during the migration (ADR 0002) without a flag
|
|
5
|
+
day. JSON in / JSON out keeps the boundary trivial.
|
|
6
|
+
|
|
7
|
+
Published to the pnpm workspace as `@adriane-ai/napi` (see `pnpm-workspace.yaml`).
|
|
8
|
+
|
|
9
|
+
## Exposed
|
|
10
|
+
|
|
11
|
+
- `engineVersion(): string`
|
|
12
|
+
- `validateGraphJson(definitionJson: string): string` — returns a JSON array of
|
|
13
|
+
validation errors (`[]` when sound). The drop-in replacement for the TS
|
|
14
|
+
`validateGraph` (same `GraphDefinition` wire shape, same error codes).
|
|
15
|
+
|
|
16
|
+
## Dev flow (the one to use day to day)
|
|
17
|
+
|
|
18
|
+
From the repo root:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pnpm napi:build # runs scripts/build-napi.sh
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The script runs `cargo build -p adriane-napi`, detects the platform
|
|
25
|
+
(`.dylib` on macOS, `.so` on Linux, `.dll` otherwise) and copies the cdylib to
|
|
26
|
+
`crates/bindings/adriane_napi.node` — exactly the file the handwritten `index.js`
|
|
27
|
+
requires. `index.js` and `index.d.ts` are **handwritten and checked in**; the dev
|
|
28
|
+
flow never regenerates them.
|
|
29
|
+
|
|
30
|
+
The script (and the root `rust:*` scripts) assume `cargo` is on `PATH`. rustup's
|
|
31
|
+
installer arranges that for normal login shells; the script additionally sources
|
|
32
|
+
`"$HOME/.cargo/env"` itself if `cargo` is missing, so it also works from bare
|
|
33
|
+
non-login shells.
|
|
34
|
+
|
|
35
|
+
Smoke test:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
node crates/bindings/smoke.cjs
|
|
39
|
+
# engineVersion: 0.0.1
|
|
40
|
+
# valid → []
|
|
41
|
+
# dangling edge → [{"code":"INVALID_EDGE_REFERENCE",...}]
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Release flow (`@napi-rs/cli` — for publish pipelines, not dev)
|
|
45
|
+
|
|
46
|
+
`package.json` carries a `napi` config block (`"name": "adriane_napi"`, matching
|
|
47
|
+
the binary basename) and two scripts, named so turbo ignores them (turbo only
|
|
48
|
+
picks up `build`/`test`/`lint`/`typecheck`):
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pnpm --filter @adriane-ai/napi run build:napi # napi build --platform --release
|
|
52
|
+
pnpm --filter @adriane-ai/napi run build:napi:debug # napi build --platform
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`napi build --platform` compiles the crate and emits a platform-suffixed binary
|
|
56
|
+
(e.g. `adriane_napi.darwin-arm64.node`) plus **regenerated** `index.js`/`index.d.ts`:
|
|
57
|
+
the generated loader switch-cases over `process.platform`/`process.arch` and
|
|
58
|
+
requires the suffixed binary (or an `@adriane-ai/napi-<platform>` sub-package), which
|
|
59
|
+
is what you want when publishing prebuilds for many targets from CI.
|
|
60
|
+
|
|
61
|
+
**Why dev does not use it:** the generated loader never looks at
|
|
62
|
+
`adriane_napi.node`, so it silently ignores what `scripts/build-napi.sh` produces —
|
|
63
|
+
on a fresh machine, `pnpm napi:build` would build a binary the loader cannot find.
|
|
64
|
+
The CLI path was verified locally (build succeeds, generated loader loads, SDK
|
|
65
|
+
example and tests pass), but the handwritten loader is kept as the committed state
|
|
66
|
+
so the dev script stays the single source of truth. A real release pipeline should
|
|
67
|
+
run `build:napi` per target and ship the generated loader in the published package
|
|
68
|
+
instead.
|
|
69
|
+
|
|
70
|
+
## SDK integration
|
|
71
|
+
|
|
72
|
+
`packages/graph-sdk/src/rust-validator.ts` loads `@adriane-ai/napi` **optionally**:
|
|
73
|
+
if the module (or its `.node` binary) is absent, the require throws, the SDK
|
|
74
|
+
catches it and falls back to the pure-TypeScript `validateGraph` from
|
|
75
|
+
`@adriane-ai/graph-core`. Nothing in the SDK hard-depends on the native addon.
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pnpm --filter @adriane-ai/graph-sdk exec node --import tsx examples/rust-validation.ts
|
|
79
|
+
# Rust validator active: true (with the .node present; false → TS fallback)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## CI
|
|
83
|
+
|
|
84
|
+
`.github/workflows/ci.yml` (ready-to-activate; the repo is not under git yet) runs
|
|
85
|
+
a `node` lane (pnpm install, typecheck, test, lint) and a `rust` lane
|
|
86
|
+
(`cargo fmt --check`, `cargo clippy --all-targets -- -D warnings`, `cargo test`
|
|
87
|
+
inside `crates/`). The same gates are wired locally as root scripts:
|
|
88
|
+
`pnpm rust:fmt`, `pnpm rust:lint`, `pnpm rust:test`, `pnpm napi:build`.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/** Version of the bound Rust engine. */
|
|
2
|
+
export function engineVersion(): string;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Validate a graph definition (JSON). Returns a JSON array of validation errors
|
|
6
|
+
* (`[]` when sound). Throws on malformed JSON.
|
|
7
|
+
*/
|
|
8
|
+
export function validateGraphJson(definitionJson: string): string;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Compile graph DSL YAML into a validated `GraphDefinition` (JSON string).
|
|
12
|
+
* Throws with a clear message on parse, DSL, or structural validation failure.
|
|
13
|
+
*/
|
|
14
|
+
export function compileGraphYamlJson(yaml: string): string;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A JS callback invoked from Rust during a run. Receives a JSON string payload.
|
|
18
|
+
*
|
|
19
|
+
* `onNode` and `onCondition` may be **async**: they can return a `Promise`, and Rust
|
|
20
|
+
* awaits it (the napi bridge resolves the returned promise to its JS-resolved value
|
|
21
|
+
* before continuing). A synchronous return is still accepted. `onEvent` is
|
|
22
|
+
* fire-and-forget — its return is never awaited.
|
|
23
|
+
*
|
|
24
|
+
* - `onNode(payloadJson)`: `payloadJson` is either
|
|
25
|
+
* `{ kind: "node", nodeId, input, state }` (a custom JS node handler — return the
|
|
26
|
+
* channel-update JSON, or a `Promise` resolving to it) or
|
|
27
|
+
* `{ kind: "tool", name, input }` (a JS tool `execute` fn — return the tool-result
|
|
28
|
+
* JSON, or a `Promise` resolving to it).
|
|
29
|
+
* - `onCondition(payloadJson)`: `payloadJson` is `{ name, state }`; return a boolean,
|
|
30
|
+
* a boolean-ish string (`"true"`/`"false"`), or a `Promise` resolving to either.
|
|
31
|
+
* - `onEvent(payloadJson)`: `payloadJson` is a serialized `RunEvent`; return nothing
|
|
32
|
+
* (fire-and-forget).
|
|
33
|
+
*/
|
|
34
|
+
export type EngineNodeCallback = (payloadJson: string) => string | Promise<string>;
|
|
35
|
+
export type EngineConditionCallback = (
|
|
36
|
+
payloadJson: string
|
|
37
|
+
) => boolean | string | Promise<boolean | string>;
|
|
38
|
+
export type EngineEventCallback = (payloadJson: string) => void;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Start a fresh run of a graph on the Rust engine. `specJson` is the `EngineSpec`
|
|
42
|
+
* (graph, runId, initialData, agents, jsNodeIds, jsToolNames). Resolves to a JSON
|
|
43
|
+
* `RunOutcome` (`{ state, status, pendingApprovals }`).
|
|
44
|
+
*/
|
|
45
|
+
export function engineRun(
|
|
46
|
+
specJson: string,
|
|
47
|
+
onNode: EngineNodeCallback,
|
|
48
|
+
onCondition: EngineConditionCallback,
|
|
49
|
+
onEvent: EngineEventCallback
|
|
50
|
+
): Promise<string>;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Resume a previously suspended run from its serialized state (`specJson.state`).
|
|
54
|
+
* Resolves to a JSON `RunOutcome`.
|
|
55
|
+
*/
|
|
56
|
+
export function engineResume(
|
|
57
|
+
specJson: string,
|
|
58
|
+
onNode: EngineNodeCallback,
|
|
59
|
+
onCondition: EngineConditionCallback,
|
|
60
|
+
onEvent: EngineEventCallback
|
|
61
|
+
): Promise<string>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Grant the tools in `specJson.approvedTools` (written into the `__approvedTools`
|
|
65
|
+
* channel) and resume. Resolves to a JSON `RunOutcome`.
|
|
66
|
+
*/
|
|
67
|
+
export function engineApproveAndResume(
|
|
68
|
+
specJson: string,
|
|
69
|
+
onNode: EngineNodeCallback,
|
|
70
|
+
onCondition: EngineConditionCallback,
|
|
71
|
+
onEvent: EngineEventCallback
|
|
72
|
+
): Promise<string>;
|
package/index.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Loads the Adriane Rust engine native addon (@adriane-ai/napi).
|
|
2
|
+
//
|
|
3
|
+
// Resolution order (first hit wins):
|
|
4
|
+
// 1. ./adriane_napi.node — local dev build (scripts/build-napi.sh).
|
|
5
|
+
// 2. ./adriane_napi.<triple>.node — local per-platform build (`napi build --platform`).
|
|
6
|
+
// 3. @adriane-ai/napi-<triple> — the published per-platform optional package.
|
|
7
|
+
//
|
|
8
|
+
// Covered targets: darwin (arm64/x64), linux glibc (x64/arm64), win32 x64. NOT built:
|
|
9
|
+
// linux musl/Alpine, win32 arm64, android, and other arches — on those this module
|
|
10
|
+
// THROWS. Callers (e.g. @adriane-ai/graph-sdk) require it inside try/catch and fall back
|
|
11
|
+
// to the in-process TypeScript engine, so a missing addon degrades gracefully.
|
|
12
|
+
"use strict";
|
|
13
|
+
|
|
14
|
+
const { existsSync } = require("node:fs");
|
|
15
|
+
const { join } = require("node:path");
|
|
16
|
+
|
|
17
|
+
const { platform, arch } = process;
|
|
18
|
+
|
|
19
|
+
// Node cannot read libc from platform/arch alone; probe the process report so a musl
|
|
20
|
+
// (Alpine) host is not mistaken for a glibc target we don't actually ship.
|
|
21
|
+
function isGlibc() {
|
|
22
|
+
try {
|
|
23
|
+
return Boolean(process.report.getReport().header.glibcVersionRuntime);
|
|
24
|
+
} catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// (platform, arch) -> napi triple suffix, or null when no prebuilt binary exists.
|
|
30
|
+
function tripleFor() {
|
|
31
|
+
if (platform === "darwin") return arch === "arm64" ? "darwin-arm64" : "darwin-x64";
|
|
32
|
+
if (platform === "win32") return arch === "x64" ? "win32-x64-msvc" : null;
|
|
33
|
+
if (platform === "linux" && isGlibc()) {
|
|
34
|
+
if (arch === "x64") return "linux-x64-gnu";
|
|
35
|
+
if (arch === "arm64") return "linux-arm64-gnu";
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function load() {
|
|
41
|
+
const local = join(__dirname, "adriane_napi.node");
|
|
42
|
+
if (existsSync(local)) return require(local);
|
|
43
|
+
|
|
44
|
+
const triple = tripleFor();
|
|
45
|
+
if (triple) {
|
|
46
|
+
const localTriple = join(__dirname, `adriane_napi.${triple}.node`);
|
|
47
|
+
if (existsSync(localTriple)) return require(localTriple);
|
|
48
|
+
try {
|
|
49
|
+
return require(`@adriane-ai/napi-${triple}`);
|
|
50
|
+
} catch {
|
|
51
|
+
// fall through to the descriptive error below
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const libc =
|
|
56
|
+
platform === "linux" ? (isGlibc() ? " (glibc)" : " (musl/non-glibc, unsupported)") : "";
|
|
57
|
+
throw new Error(
|
|
58
|
+
`@adriane-ai/napi: no prebuilt native binary for ${platform}-${arch}${libc}. ` +
|
|
59
|
+
`Prebuilt targets: darwin arm64/x64, linux glibc x64/arm64, win32 x64. ` +
|
|
60
|
+
`The Rust engine is unavailable here; callers fall back to the TypeScript engine. ` +
|
|
61
|
+
`To build locally: bash scripts/build-napi.sh`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
module.exports = load();
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@adriane-ai/napi",
|
|
3
|
+
"version": "0.1.0-rc.1",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"description": "Node bindings to the Adriane Rust engine (graph validation, DSL compile, run/resume/approve).",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"types": "index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"index.js",
|
|
10
|
+
"index.d.ts",
|
|
11
|
+
"adriane_napi.*.node",
|
|
12
|
+
"LICENSE",
|
|
13
|
+
"NOTICE"
|
|
14
|
+
],
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"napi": {
|
|
19
|
+
"name": "adriane_napi",
|
|
20
|
+
"package": {
|
|
21
|
+
"name": "@adriane-ai/napi"
|
|
22
|
+
},
|
|
23
|
+
"triples": {
|
|
24
|
+
"defaults": false,
|
|
25
|
+
"additional": [
|
|
26
|
+
"x86_64-apple-darwin",
|
|
27
|
+
"aarch64-apple-darwin",
|
|
28
|
+
"x86_64-unknown-linux-gnu",
|
|
29
|
+
"aarch64-unknown-linux-gnu",
|
|
30
|
+
"x86_64-pc-windows-msvc"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@napi-rs/cli": "^2.18.4"
|
|
36
|
+
},
|
|
37
|
+
"optionalDependencies": {
|
|
38
|
+
"@adriane-ai/napi-darwin-x64": "0.1.0-rc.1",
|
|
39
|
+
"@adriane-ai/napi-darwin-arm64": "0.1.0-rc.1",
|
|
40
|
+
"@adriane-ai/napi-linux-x64-gnu": "0.1.0-rc.1",
|
|
41
|
+
"@adriane-ai/napi-linux-arm64-gnu": "0.1.0-rc.1",
|
|
42
|
+
"@adriane-ai/napi-win32-x64-msvc": "0.1.0-rc.1"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build:napi": "napi build --platform --release --js napi-generated.js --dts napi-generated.d.ts",
|
|
46
|
+
"build:napi:debug": "napi build --platform --js napi-generated.js --dts napi-generated.d.ts",
|
|
47
|
+
"artifacts": "napi artifacts",
|
|
48
|
+
"prepublish:napi": "napi prepublish -t npm"
|
|
49
|
+
}
|
|
50
|
+
}
|