@cetra-ai/cli 0.0.0-stage → 0.0.0

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.
Files changed (41) hide show
  1. package/LICENSE +48 -0
  2. package/README.md +14 -2
  3. package/dist/cli.js +2816 -0
  4. package/dist/skills/cetra/SKILL.md +95 -0
  5. package/dist/skills/cetra/references/anthropic.md +82 -0
  6. package/dist/skills/cetra/references/attributes.md +178 -0
  7. package/dist/skills/cetra/references/bedrock.md +46 -0
  8. package/dist/skills/cetra/references/crewai.md +38 -0
  9. package/dist/skills/cetra/references/dspy.md +38 -0
  10. package/dist/skills/cetra/references/from-laminar.md +49 -0
  11. package/dist/skills/cetra/references/from-langfuse.md +59 -0
  12. package/dist/skills/cetra/references/google-adk.md +60 -0
  13. package/dist/skills/cetra/references/google-genai.md +50 -0
  14. package/dist/skills/cetra/references/integrations.md +71 -0
  15. package/dist/skills/cetra/references/langchain.md +76 -0
  16. package/dist/skills/cetra/references/litellm.md +45 -0
  17. package/dist/skills/cetra/references/llama-index.md +38 -0
  18. package/dist/skills/cetra/references/metadata-and-tags.md +117 -0
  19. package/dist/skills/cetra/references/openai-agents.md +55 -0
  20. package/dist/skills/cetra/references/openai.md +82 -0
  21. package/dist/skills/cetra/references/openinference.md +51 -0
  22. package/dist/skills/cetra/references/openllmetry.md +42 -0
  23. package/dist/skills/cetra/references/opentelemetry-genai.md +49 -0
  24. package/dist/skills/cetra/references/opentelemetry.md +134 -0
  25. package/dist/skills/cetra/references/otlp.md +73 -0
  26. package/dist/skills/cetra/references/privacy-controls.md +120 -0
  27. package/dist/skills/cetra/references/python-context.md +63 -0
  28. package/dist/skills/cetra/references/python-opentelemetry.md +136 -0
  29. package/dist/skills/cetra/references/python-tracing.md +77 -0
  30. package/dist/skills/cetra/references/python.md +79 -0
  31. package/dist/skills/cetra/references/sessions.md +84 -0
  32. package/dist/skills/cetra/references/sql-schema.md +210 -0
  33. package/dist/skills/cetra/references/troubleshooting.md +90 -0
  34. package/dist/skills/cetra/references/typescript-context.md +22 -0
  35. package/dist/skills/cetra/references/typescript-opentelemetry.md +68 -0
  36. package/dist/skills/cetra/references/typescript-runtimes.md +54 -0
  37. package/dist/skills/cetra/references/typescript-tracing.md +40 -0
  38. package/dist/skills/cetra/references/typescript.md +56 -0
  39. package/dist/skills/cetra/references/users.md +87 -0
  40. package/dist/skills/cetra/references/vercel-ai-sdk.md +82 -0
  41. package/package.json +39 -4
@@ -0,0 +1,56 @@
1
+ <!-- Generated from website/src/content/docs/docs/reference/typescript/index.mdx by website/scripts/skill-references.mjs. Do not edit: run `just docs-gen`. -->
2
+
3
+ # TypeScript SDK
4
+
5
+ Install the cetra TypeScript SDK, configure it and find your way around its reference pages.
6
+
7
+ Use the TypeScript SDK to send traces and scores from Node, Bun, Deno or an edge runtime to cetra. The `@cetra-ai/sdk` package (MIT, ESM only) is a thin layer over OpenTelemetry: tracing goes out as OTLP/HTTP protobuf, and scores and feedback go over a small REST surface. It runs on Node 22.12 or later, Bun, Deno and edge runtimes, with one `fetch`-based transport everywhere.
8
+
9
+ The pages of this reference:
10
+
11
+ - [Tracing](https://cetra.sh/docs/reference/typescript/tracing/): `observe`, `withSpan` and `withLlmSpan`.
12
+ - [Context](https://cetra.sh/docs/reference/typescript/context/): sessions, users, tags and metadata, and baggage.
13
+ - [Scores, datasets and experiments](https://cetra.sh/docs/reference/typescript/scores-datasets-experiments/): `score`, the `Client` and `evaluate`.
14
+ - [OpenTelemetry](https://cetra.sh/docs/reference/typescript/opentelemetry/): instrumentation helpers, the Vercel AI SDK, existing OpenTelemetry setups and masking.
15
+ - [Runtimes](https://cetra.sh/docs/reference/typescript/runtimes/): edge runtimes, serverless, browser feedback and known limits.
16
+ - [API](https://cetra.sh/docs/reference/typescript/api/): every export.
17
+
18
+ ## Install
19
+
20
+ ```sh
21
+ pnpm add @cetra-ai/sdk
22
+ ```
23
+
24
+ The instrumentation helpers need their OpenInference packages (optional peers, installed next to the SDK):
25
+
26
+ ```sh
27
+ pnpm add @arizeai/openinference-instrumentation-openai openai
28
+ ```
29
+
30
+ ## Initialize
31
+
32
+ For a first trace, follow the [quick start](https://cetra.sh/docs/get-started/quickstart/).
33
+
34
+ `init()` is once per process: a second call logs one warning and changes nothing. Without an API key (argument and `CETRA_API_KEY` both unset) it warns once and runs disabled; `CETRA_ENABLED=false` silences the warning.
35
+
36
+ ## Configuration
37
+
38
+ | Option | Env | Default |
39
+ | ------------------- | ----------------------- | --------------------------------- |
40
+ | `apiKey` | `CETRA_API_KEY` | unset: one warning, SDK disabled |
41
+ | `baseUrl` | `CETRA_BASE_URL` | `http://localhost:8080` |
42
+ | `environment` | `CETRA_ENVIRONMENT` | unset |
43
+ | `release` | `CETRA_RELEASE` | unset |
44
+ | `captureContent` | `CETRA_CAPTURE_CONTENT` | `true` |
45
+ | `sampleRate` | `CETRA_SAMPLE_RATE` | `1` (trace-id ratio sampler) |
46
+ | `useGlobalProvider` | — | `false` |
47
+ | `instrument` | — | `[]` |
48
+ | `mask` | — | none |
49
+ | `exportFilter` | — | none |
50
+ | `enabled` | `CETRA_ENABLED` | `true` (no-op mode when `false`) |
51
+
52
+ An explicit argument wins over the env var, which wins over the default. Env values are trimmed; an empty value counts as unset. An invalid value throws a `ConfigError` naming the option, never its value. `OTEL_SERVICE_NAME` (from the config's env source) sets `service.name`.
53
+
54
+ ## What is never logged
55
+
56
+ Logs and warnings never contain payloads (prompts, completions, attribute values), API keys or email addresses: ids, sizes and counts only. An invalid score logs `cetra: score not queued: <reason>` with the reason, never the value. The API key never appears in errors or serialized config.
@@ -0,0 +1,87 @@
1
+ <!-- Generated from website/src/content/docs/docs/tracing/users.mdx by website/scripts/skill-references.mjs. Do not edit: run `just docs-gen`. -->
2
+
3
+ # Users
4
+
5
+ Attach a user ID to your traces to see each user's activity, cost and sessions.
6
+
7
+ Set a user ID on your traces to see what each of your users does and costs.
8
+
9
+ A user is an end user of your application. cetra builds the user list from the user IDs on your traces. See the [data model](https://cetra.sh/docs/concepts/data-model/).
10
+
11
+ ## Set a user ID
12
+
13
+ Use the same context block as for sessions. Every span started inside it carries the user ID.
14
+
15
+ **Python**
16
+
17
+ ```python
18
+ import cetra
19
+
20
+ cetra.init()
21
+
22
+ @cetra.observe(name="turn")
23
+ def turn() -> None: ...
24
+
25
+ with cetra.context(user_id="u-17", session_id="chat-42"):
26
+ turn()
27
+
28
+ cetra.flush()
29
+ ```
30
+
31
+ **TypeScript**
32
+
33
+ ```ts
34
+ import { observe, withContext } from "@cetra-ai/sdk";
35
+ ```
36
+
37
+ ```ts
38
+ const turn = observe(({ question }: { question: string }) => `answered: ${question}`, {
39
+ name: "turn",
40
+ });
41
+ withContext({ sessionId: "chat-42", userId: "u-17", tags: ["beta"] }, () =>
42
+ turn({ question: "why?" }),
43
+ );
44
+ ```
45
+
46
+ **Attributes**
47
+
48
+ Set the attribute `cetra.user.id` on a span. cetra also reads `user.id` and `enduser.id`, and the user attributes of the other [conventions](https://cetra.sh/docs/concepts/conventions/).
49
+
50
+ ```python
51
+ with tracer.start_as_current_span("turn") as span:
52
+ span.set_attribute("cetra.user.id", "u-17")
53
+ ```
54
+
55
+ Use an ID that is stable for a person and that is not their email address or name. cetra shows the ID as you send it, and deletes data by it.
56
+
57
+ ## In the UI
58
+
59
+ Select **Users** in the sidebar, or press `g` then `u`. A summary strip shows **Traces**, **Error rate**, **p95 latency**, **Cost** and **Tokens** for the users in the time range. Below it, **Top by cost** lists the users who cost the most. Select one to open that user.
60
+
61
+ The columns are:
62
+
63
+ - **User**: the user ID. If the user has a `user.name` metadata value, the name comes first and the ID after it. A `user.plan` value shows as a pill.
64
+ - **Activity**: a small chart of traces over the time range.
65
+ - **Traces**, **Sessions**, **Traces / session**, **Tokens** and **Cost**.
66
+ - **Errors** and **Error rate**.
67
+ - One column per score name found in the users' traces.
68
+ - **Metadata**, **First seen** and **Last seen**.
69
+
70
+ Select **Columns** to show, hide or reorder them. The list has facets, preset chips and saved views, as the traces list has. They work on the traces of the users ([Filters and search](https://cetra.sh/docs/tracing/filters-and-search/)). The name and plan come from trace metadata keys `user.name` and `user.plan`.
71
+
72
+ Select a row to open the user in a panel, with their metrics, activity, scores, metadata and recent sessions. **Open page** opens the user's own page. It has a time range picker and three tabs:
73
+
74
+ - **Overview**: the user's scores, metadata and usage charts.
75
+ - **Sessions**: the user's sessions.
76
+ - **Traces**: the user's traces.
77
+
78
+ An admin sees **Delete user data…** on the page.
79
+
80
+ ## Filter by user
81
+
82
+ Filter the traces list with `user_id = 'u-17'`. In SQL, group by `user_id` to rank users by spend. See [SQL console](https://cetra.sh/docs/tracing/sql-console/).
83
+
84
+ ## Limits
85
+
86
+ - A trace takes its user from the root span, or from the first span that has one.
87
+ - An administrator can delete all the data of a user from the project settings ([Deletion and retention](https://cetra.sh/docs/platform/deletion-and-retention/)).
@@ -0,0 +1,82 @@
1
+ <!-- Generated from website/src/content/docs/docs/integrations/vercel-ai-sdk.mdx by website/scripts/skill-references.mjs. Do not edit: run `just docs-gen`. -->
2
+
3
+ # Vercel AI SDK
4
+
5
+ Trace the Vercel AI SDK with cetra: generateText, streamText, tool calls, structured output and embeddings, versions 4 to 7.
6
+
7
+ cetra traces the Vercel AI SDK's generateText, streamText, generateObject, tool calls and embeddings, with sessions, users and metadata.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install @cetra-ai/sdk ai @ai-sdk/openai
13
+ ```
14
+
15
+ ## Set up (AI SDK 4 to 6)
16
+
17
+ The AI SDK sends spans to the tracer you give it. `aiTelemetry()` hands out a tracer from cetra, and adds your session, user, tags and metadata to the telemetry metadata.
18
+
19
+ ```ts
20
+ import { aiTelemetry, init } from "@cetra-ai/sdk";
21
+ import { generateText } from "ai";
22
+ import { openai } from "@ai-sdk/openai";
23
+ ```
24
+
25
+ ```ts
26
+ // Pass `telemetry` as `experimental_telemetry` to the Vercel AI SDK; the
27
+ // tracer it hands out is the cetra one, so AI spans land in cetra.
28
+ const telemetry = aiTelemetry({ sessionId: "chat-42", functionId: "chat" });
29
+ telemetry.tracer?.startSpan("ai.chat").end();
30
+ ```
31
+
32
+ ```ts
33
+ init({ apiKey: process.env.CETRA_API_KEY });
34
+
35
+ const result = await generateText({
36
+ model: openai("gpt-4o-mini"),
37
+ prompt: "What is the weather in Paris?",
38
+ experimental_telemetry: aiTelemetry({ sessionId: "chat-42", functionId: "chat" }),
39
+ });
40
+ ```
41
+
42
+ ## Set up (AI SDK 7)
43
+
44
+ AI SDK 7 does not emit spans by itself. The spans come from the `@ai-sdk/otel` package, passed in `telemetry.integrations`, and go to the global OpenTelemetry tracer provider. The fixtures for version 7 were captured this way, with a global provider. To use it with cetra, register cetra's provider as the global one with `useGlobalProvider: true`.
45
+
46
+ ```ts
47
+ import { init } from "@cetra-ai/sdk";
48
+ import { OpenTelemetry } from "@ai-sdk/otel";
49
+ import { openai } from "@ai-sdk/openai";
50
+ import { generateText } from "ai";
51
+
52
+ init({ apiKey: process.env.CETRA_API_KEY, useGlobalProvider: true });
53
+
54
+ await generateText({
55
+ model: openai("gpt-4o-mini"),
56
+ prompt: "What is the weather in Paris?",
57
+ telemetry: { isEnabled: true, integrations: new OpenTelemetry() },
58
+ });
59
+ ```
60
+
61
+ ## What you get
62
+
63
+ - The outer call (`ai.generateText`) is a `chain` span and each model call under it (`doGenerate` or `doStream`) is an `llm` span. Tokens and cost are on the `llm` spans only, so they are never counted twice.
64
+ - A tool call is a `tool` span with its arguments and result.
65
+ - Structured output (`generateObject`) is stored as JSON.
66
+ - `streamText` records the time to first token.
67
+ - Cache read and cache write tokens are recorded for Anthropic models. cetra adjusts the input count where the AI SDK reports it without the cache.
68
+ - `embed` and `embedMany` are traced.
69
+ - Session ID, user ID and metadata set through the telemetry metadata arrive as the span's session, user and metadata.
70
+ - In version 7 the spans are named `invoke_agent …`, `step …` and `chat …`.
71
+
72
+ ## Limits
73
+
74
+ - Versions 5, 6 and 7 are covered by captured spans. Version 4 is covered by a hand-written case that checks the older `args` and `result` shapes.
75
+ - Images in the prompt, passed as base64, are extracted as media.
76
+ - With `useGlobalProvider`, cetra keeps only LLM-related spans from your other OpenTelemetry code. See [OpenTelemetry (TypeScript)](https://cetra.sh/docs/reference/typescript/opentelemetry/).
77
+
78
+ ## Next
79
+
80
+ - [Traces](https://cetra.sh/docs/tracing/traces/): read the trace as a tree and a timeline.
81
+ - [Cost and tokens](https://cetra.sh/docs/tracing/cost-and-tokens/): how cost is computed from the token counts.
82
+ - [Online rules](https://cetra.sh/docs/evaluation/online-rules/): score these traces automatically.
package/package.json CHANGED
@@ -1,6 +1,41 @@
1
1
  {
2
2
  "name": "@cetra-ai/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.0",
4
+ "description": "Set up cetra tracing with one command and one prompt to your coding agent.",
5
+ "license": "MIT",
6
+ "homepage": "https://cetra.sh/docs/get-started/coding-agent/",
7
+ "bugs": "https://github.com/cetra-ai/cetra/issues",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/cetra-ai/cetra.git",
11
+ "directory": "node-cli"
12
+ },
13
+ "type": "module",
14
+ "engines": {
15
+ "node": ">=22.12"
16
+ },
17
+ "bin": {
18
+ "cetra-cli": "./dist/cli.js"
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "scripts": {
27
+ "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
28
+ "build": "tsdown",
29
+ "test": "vitest run",
30
+ "check:package": "publint",
31
+ "check": "biome check . && pnpm typecheck && pnpm build && pnpm test && pnpm check:package"
32
+ },
33
+ "devDependencies": {
34
+ "@types/node": "26.6.6",
35
+ "publint": "0.3.25",
36
+ "smol-toml": "1.9.1",
37
+ "tsdown": "0.23.7",
38
+ "typescript": "5.9.3",
39
+ "vitest": "5.1.0"
40
+ }
41
+ }