@elysra/tungsten-runtime 0.1.0 → 0.1.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/README.md +80 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# @elysra/tungsten-runtime
|
|
2
|
+
|
|
3
|
+
The TypeScript runtime for SDKs generated by [Tungsten](https://github.com/pboachie/tungsten), an OpenAPI compiler for agent-facing clients and tools.
|
|
4
|
+
|
|
5
|
+
It provides HTTP transport, argument validation, retries, idempotency, structured error results, previews and confirmation, pagination, OAuth and server-sent events. The core package has no production dependencies.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @elysra/tungsten-runtime
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The package uses ES modules and includes TypeScript declarations. Node.js 22 or newer is required on Node. The core entry point uses Web APIs; Node-specific filesystem adapters have their own export.
|
|
14
|
+
|
|
15
|
+
## Use with a generated SDK
|
|
16
|
+
|
|
17
|
+
Install the [Tungsten CLI](https://github.com/pboachie/tungsten#install), then initialize a project from your OpenAPI document:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
tungsten init --from openapi.json --targets typescript
|
|
21
|
+
tungsten check
|
|
22
|
+
tungsten generate
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Review `tungsten.yml` for the generated output directory and `agent.yml` for operation safety policies. Install and build the generated SDK in its output directory:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
npm install
|
|
29
|
+
npm run build
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Generated clients already depend on this runtime. Use their typed resource methods for normal application code. To integrate at the descriptor level, import the generated descriptors and create a core:
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { ClientCore } from "@elysra/tungsten-runtime";
|
|
36
|
+
import { api, operations } from "./generated/typescript/src/descriptors.js";
|
|
37
|
+
|
|
38
|
+
const core = new ClientCore(api, {
|
|
39
|
+
baseUrl: "https://api.example.com",
|
|
40
|
+
operations,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Select the operation your application intends to call.
|
|
44
|
+
const operation = operations.find(op => op.id === "petstore.listPets");
|
|
45
|
+
if (!operation) throw new Error("Operation not found in the generated API");
|
|
46
|
+
|
|
47
|
+
const result = await core.call(operation, { limit: 10 });
|
|
48
|
+
if (result.ok) {
|
|
49
|
+
console.log(result.value);
|
|
50
|
+
} else {
|
|
51
|
+
console.error(result.error.category, result.error.remediation);
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Use the descriptor import path, operation ID and arguments generated for your own API. API and transport failures return a `Result` with a diagnostic envelope; they do not require parsing exception messages. `unwrap` and `throwing` are available for applications that prefer exceptions.
|
|
56
|
+
|
|
57
|
+
## Safety and persistence
|
|
58
|
+
|
|
59
|
+
Generated safety policies determine whether calls can retry, need idempotency keys, or require a preview and confirmation token. Confirmation tokens are bound to the arguments and client session that created them. Your API still enforces authentication and authorization.
|
|
60
|
+
|
|
61
|
+
For Node applications that need idempotency keys to survive restarts:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import { FileIdempotencyStore } from "@elysra/tungsten-runtime/node";
|
|
65
|
+
|
|
66
|
+
const idempotencyStore = new FileIdempotencyStore("./state/idempotency.json");
|
|
67
|
+
// Pass idempotencyStore in the generated client's options or ClientCore options.
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Keep `@elysra/tungsten-runtime/node` out of browser bundles. Applications own the storage location and its lifecycle.
|
|
71
|
+
|
|
72
|
+
## Related packages and documentation
|
|
73
|
+
|
|
74
|
+
- [@elysra/tungsten-mcp](https://www.npmjs.com/package/@elysra/tungsten-mcp): MCP servers for generated APIs.
|
|
75
|
+
- [@elysra/tungsten-webmcp](https://www.npmjs.com/package/@elysra/tungsten-webmcp): browser WebMCP tool registration.
|
|
76
|
+
- [Documentation](https://pboachie.github.io/tungsten/) and [source/issues](https://github.com/pboachie/tungsten).
|
|
77
|
+
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
Apache-2.0. The Tungsten compiler is licensed separately under AGPL-3.0-only.
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elysra/tungsten-runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Runtime for SDKs generated by tungsten: transport, retries, idempotency, diagnostic error envelopes, previews and pagination.",
|
|
5
5
|
"keywords": ["openapi", "sdk", "tungsten", "agents", "runtime", "typescript"],
|
|
6
6
|
"homepage": "https://github.com/pboachie/tungsten",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" },
|
|
18
18
|
"./node": { "types": "./dist/node.d.ts", "import": "./dist/node.js" }
|
|
19
19
|
},
|
|
20
|
-
"files": ["dist", "LICENSE"],
|
|
20
|
+
"files": ["dist", "LICENSE", "README.md"],
|
|
21
21
|
"engines": { "node": ">=22" },
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "tsc -p tsconfig.json"
|