@nyraxis/sdk 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/LICENSE +21 -0
- package/README.md +61 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +79 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nyraxis
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# @nyraxis/sdk
|
|
2
|
+
|
|
3
|
+
Universal AI agent observability for JavaScript/TypeScript.
|
|
4
|
+
|
|
5
|
+
Automatically traces every LLM provider, framework, and vector DB.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @nyraxis/sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { init, shutdown } from "@nyraxis/sdk";
|
|
17
|
+
|
|
18
|
+
// Initialize once at app startup
|
|
19
|
+
init({
|
|
20
|
+
apiKey: "nyx_...",
|
|
21
|
+
baseUrl: "https://your-nyraxis-backend.com",
|
|
22
|
+
agentName: "my-agent",
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// All LLM calls are now auto-traced — no code changes needed.
|
|
26
|
+
// Works with: OpenAI, Anthropic, Google, Cohere, Mistral, Bedrock, etc.
|
|
27
|
+
|
|
28
|
+
// Before process exit:
|
|
29
|
+
await shutdown();
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Trace Grouping
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { withWorkflow, withTask } from "@nyraxis/sdk";
|
|
36
|
+
|
|
37
|
+
// Group related LLM calls into a single trace
|
|
38
|
+
const result = await withWorkflow({ name: "research-agent" }, async () => {
|
|
39
|
+
const summary = await withTask({ name: "summarize" }, async () => {
|
|
40
|
+
return await openai.chat.completions.create({ ... });
|
|
41
|
+
});
|
|
42
|
+
return summary;
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Auto-Instrumented
|
|
47
|
+
|
|
48
|
+
### LLM Providers
|
|
49
|
+
OpenAI, Anthropic, Google (Gemini/PaLM/VertexAI), Cohere, Mistral, AWS Bedrock,
|
|
50
|
+
Azure OpenAI, Ollama, Together AI, Groq, Replicate, HuggingFace, AI21, Aleph Alpha,
|
|
51
|
+
DeepSeek, Fireworks, Perplexity, WatsonX, SageMaker
|
|
52
|
+
|
|
53
|
+
### Frameworks
|
|
54
|
+
LangChain.js, Vercel AI SDK
|
|
55
|
+
|
|
56
|
+
### Vector Databases
|
|
57
|
+
Pinecone, Chroma, Weaviate, Qdrant, Milvus, PGVector, Redis, LanceDB
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nyraxis/sdk — Universal AI agent observability for JavaScript/TypeScript.
|
|
3
|
+
*
|
|
4
|
+
* Auto-traces every LLM provider, framework, and vector DB.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* import { init, shutdown } from "@nyraxis/sdk";
|
|
8
|
+
* init({ apiKey: "nyx_...", agentName: "my-agent" });
|
|
9
|
+
* // All LLM calls are now auto-traced.
|
|
10
|
+
* await shutdown(); // before process exit
|
|
11
|
+
*/
|
|
12
|
+
/** Configuration for trace grouping decorators. */
|
|
13
|
+
export interface DecoratorConfig {
|
|
14
|
+
name: string;
|
|
15
|
+
version?: number;
|
|
16
|
+
associationProperties?: Record<string, string>;
|
|
17
|
+
traceContent?: boolean;
|
|
18
|
+
inputParameters?: unknown[];
|
|
19
|
+
suppressTracing?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface NyraxisConfig {
|
|
22
|
+
/** Your Nyraxis API key (nyx_...) */
|
|
23
|
+
apiKey: string;
|
|
24
|
+
/** Nyraxis backend URL (default: http://localhost:8000) */
|
|
25
|
+
baseUrl?: string;
|
|
26
|
+
/** Name for this agent in the dashboard */
|
|
27
|
+
agentName?: string;
|
|
28
|
+
/** Optional version string */
|
|
29
|
+
agentVersion?: string;
|
|
30
|
+
/** If true, send spans immediately (default: false) */
|
|
31
|
+
disableBatch?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export declare function init(config: NyraxisConfig): void;
|
|
34
|
+
/** Flush pending traces without full teardown. Safe to call multiple times. */
|
|
35
|
+
export declare function flush(): Promise<void>;
|
|
36
|
+
/** Flush and shut down. Call once before process exit. */
|
|
37
|
+
export declare function shutdown(): Promise<void>;
|
|
38
|
+
/** Check if the SDK has been initialized. */
|
|
39
|
+
export declare function isInitialized(): boolean;
|
|
40
|
+
export declare function withWorkflow<A extends unknown[], F extends (...args: A) => ReturnType<F>>(config: DecoratorConfig, fn: F, ...args: A): Promise<Awaited<ReturnType<F>>>;
|
|
41
|
+
export declare function withTask<A extends unknown[], F extends (...args: A) => ReturnType<F>>(config: DecoratorConfig, fn: F, ...args: A): Promise<Awaited<ReturnType<F>>>;
|
|
42
|
+
export declare function withAgent<A extends unknown[], F extends (...args: A) => ReturnType<F>>(config: DecoratorConfig, fn: F, ...args: A): Promise<Awaited<ReturnType<F>>>;
|
|
43
|
+
export declare function withTool<A extends unknown[], F extends (...args: A) => ReturnType<F>>(config: DecoratorConfig, fn: F, ...args: A): Promise<Awaited<ReturnType<F>>>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @nyraxis/sdk — Universal AI agent observability for JavaScript/TypeScript.
|
|
4
|
+
*
|
|
5
|
+
* Auto-traces every LLM provider, framework, and vector DB.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* import { init, shutdown } from "@nyraxis/sdk";
|
|
9
|
+
* init({ apiKey: "nyx_...", agentName: "my-agent" });
|
|
10
|
+
* // All LLM calls are now auto-traced.
|
|
11
|
+
* await shutdown(); // before process exit
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.init = init;
|
|
15
|
+
exports.flush = flush;
|
|
16
|
+
exports.shutdown = shutdown;
|
|
17
|
+
exports.isInitialized = isInitialized;
|
|
18
|
+
exports.withWorkflow = withWorkflow;
|
|
19
|
+
exports.withTask = withTask;
|
|
20
|
+
exports.withAgent = withAgent;
|
|
21
|
+
exports.withTool = withTool;
|
|
22
|
+
const node_server_sdk_1 = require("@traceloop/node-server-sdk");
|
|
23
|
+
let _initialized = false;
|
|
24
|
+
function init(config) {
|
|
25
|
+
if (_initialized)
|
|
26
|
+
return;
|
|
27
|
+
if (!config.apiKey) {
|
|
28
|
+
throw new Error("Nyraxis: apiKey is required. Get one from your dashboard.");
|
|
29
|
+
}
|
|
30
|
+
const baseUrl = (config.baseUrl ?? "http://localhost:8000").replace(/\/+$/, "");
|
|
31
|
+
const agentName = config.agentName ?? "nyraxis-agent";
|
|
32
|
+
// Set the API key header via the environment variable the OTLP exporter reads.
|
|
33
|
+
// This avoids needing a custom exporter — the SDK's built-in OTLP exporter
|
|
34
|
+
// picks up OTEL_EXPORTER_OTLP_HEADERS automatically.
|
|
35
|
+
process.env.OTEL_EXPORTER_OTLP_HEADERS = `X-API-Key=${config.apiKey}`;
|
|
36
|
+
(0, node_server_sdk_1.initialize)({
|
|
37
|
+
appName: agentName,
|
|
38
|
+
baseUrl: `${baseUrl}/api/v1/ingest/otel`,
|
|
39
|
+
disableBatch: config.disableBatch ?? false,
|
|
40
|
+
traceloopSyncEnabled: false,
|
|
41
|
+
silenceInitializationMessage: true,
|
|
42
|
+
});
|
|
43
|
+
_initialized = true;
|
|
44
|
+
}
|
|
45
|
+
/** Flush pending traces without full teardown. Safe to call multiple times. */
|
|
46
|
+
async function flush() {
|
|
47
|
+
if (!_initialized)
|
|
48
|
+
return;
|
|
49
|
+
try {
|
|
50
|
+
await (0, node_server_sdk_1.forceFlush)();
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// best-effort — don't crash the app
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/** Flush and shut down. Call once before process exit. */
|
|
57
|
+
async function shutdown() {
|
|
58
|
+
if (!_initialized)
|
|
59
|
+
return;
|
|
60
|
+
await flush();
|
|
61
|
+
_initialized = false;
|
|
62
|
+
}
|
|
63
|
+
/** Check if the SDK has been initialized. */
|
|
64
|
+
function isInitialized() {
|
|
65
|
+
return _initialized;
|
|
66
|
+
}
|
|
67
|
+
// Re-export decorators for trace grouping
|
|
68
|
+
async function withWorkflow(config, fn, ...args) {
|
|
69
|
+
return (0, node_server_sdk_1.withWorkflow)(config, fn, ...args);
|
|
70
|
+
}
|
|
71
|
+
async function withTask(config, fn, ...args) {
|
|
72
|
+
return (0, node_server_sdk_1.withTask)(config, fn, ...args);
|
|
73
|
+
}
|
|
74
|
+
async function withAgent(config, fn, ...args) {
|
|
75
|
+
return (0, node_server_sdk_1.withAgent)(config, fn, ...args);
|
|
76
|
+
}
|
|
77
|
+
async function withTool(config, fn, ...args) {
|
|
78
|
+
return (0, node_server_sdk_1.withTool)(config, fn, ...args);
|
|
79
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nyraxis/sdk",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Universal AI agent observability for JavaScript/TypeScript — trace every LLM provider and framework",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"require": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"test": "node --test src/__tests__/index.test.mjs",
|
|
16
|
+
"prepublishOnly": "npm run build && npm test"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"observability", "llm", "tracing", "opentelemetry", "ai", "agents",
|
|
20
|
+
"openai", "anthropic", "langchain", "nyraxis"
|
|
21
|
+
],
|
|
22
|
+
"author": "Nyraxis <support@nyraxis.io>",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/nyraxis/nyraxis"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://docs.nyraxis.com",
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/nyraxis/nyraxis/issues"
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@traceloop/node-server-sdk": "^0.11.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"typescript": "^5.3.0"
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist/",
|
|
43
|
+
"README.md",
|
|
44
|
+
"LICENSE"
|
|
45
|
+
]
|
|
46
|
+
}
|