@argosvix/sdk 0.4.15-alpha.0 → 0.4.17-alpha.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.
- package/README.md +63 -7
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +254 -32
- package/dist/client.js.map +1 -1
- package/dist/context.d.ts +12 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +19 -0
- package/dist/context.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/prompts.d.ts +45 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +88 -0
- package/dist/prompts.js.map +1 -0
- package/dist/recorder.d.ts +2 -0
- package/dist/recorder.d.ts.map +1 -1
- package/dist/recorder.js +20 -0
- package/dist/recorder.js.map +1 -1
- package/package.json +83 -83
package/README.md
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Transparent observability wrapper for AI provider SDKs. Wrap a single line of code and get cost, latency, token, and error records for every LLM call across OpenAI, Anthropic, Gemini, and Mistral.
|
|
4
4
|
|
|
5
|
-
> 🟢 **Alpha released** — backend ingest (`ingest.argosvix.com`) and dashboard (`dashboard.argosvix.com`) are live. Published on npm as `@argosvix/sdk@alpha`.
|
|
5
|
+
> 🟢 **Alpha released** — backend ingest (`ingest.argosvix.com`) and dashboard (`dashboard.argosvix.com`) are live. Published on npm as `@argosvix/sdk@alpha`. The entire sign-up to API-key flow runs in the browser; a Free plan and paid plans (Pro / Team) are available. See [`CHANGELOG.md`](./CHANGELOG.md) for the full change log.
|
|
6
6
|
>
|
|
7
7
|
> Design principles:
|
|
8
|
-
> - **No end-user PII is sent.**
|
|
8
|
+
> - **No end-user PII is sent.** By default, prompt and completion bodies are never recorded; only token counts, cost, latency, and error codes leave your process. Content capture is a separate opt-in (`captureContent`, see below) and always applies PII masking before send.
|
|
9
9
|
> - **Idempotent wrap.** Wrapping the same client twice is a no-op; we track instances via WeakMap / WeakSet.
|
|
10
10
|
> - **No global monkey-patching.** Only the client argument you pass in is mutated; the global namespace is untouched.
|
|
11
11
|
|
|
@@ -31,10 +31,12 @@ npm install @argosvix/sdk@alpha openai
|
|
|
31
31
|
|
|
32
32
|
1. Sign up at <https://dashboard.argosvix.com/en/signup> with an email address and password.
|
|
33
33
|
2. Open the verification link sent to your inbox.
|
|
34
|
-
3.
|
|
34
|
+
3. Create an API key from the dashboard's API keys page. The raw key (`argk_…`) is displayed **once** at creation — copy and store it safely. You can create additional keys or revoke a key from the same page at any time.
|
|
35
|
+
|
|
36
|
+
Alternatively, run `npx @argosvix/cli init` — it opens the browser for a one-time approval, issues a least-privilege key, and writes it to `.env` for you.
|
|
35
37
|
|
|
36
38
|
```bash
|
|
37
|
-
export ARGOSVIX_API_KEY=
|
|
39
|
+
export ARGOSVIX_API_KEY=argk_...
|
|
38
40
|
# Default ingest endpoint = https://ingest.argosvix.com
|
|
39
41
|
# Override with ARGOSVIX_API_BASE if you self-host the backend.
|
|
40
42
|
```
|
|
@@ -70,7 +72,24 @@ Each call automatically records:
|
|
|
70
72
|
- Arbitrary tags (`tags: { service: "X", env: "prod" }`).
|
|
71
73
|
- Structured error details (`statusCode`, `code`, `type`, `retryAfter`).
|
|
72
74
|
|
|
73
|
-
**Not recorded:** prompt bodies, completion bodies, system messages, or tool-call argument bodies. Only the metadata required for aggregation is sent
|
|
75
|
+
**Not recorded by default:** prompt bodies, completion bodies, system messages, or tool-call argument bodies. Only the metadata required for aggregation is sent. To record bodies as well, see [Content capture (opt-in)](#content-capture-opt-in) below.
|
|
76
|
+
|
|
77
|
+
## Content capture (opt-in)
|
|
78
|
+
|
|
79
|
+
By default only metadata leaves your process. Set `captureContent: true` to also record prompt and completion bodies (and tool-call arguments / results) — useful for quality review, eval datasets, and debugging:
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
const client = wrap(new OpenAI(), {
|
|
83
|
+
apiKey: process.env.ARGOSVIX_API_KEY,
|
|
84
|
+
captureContent: true,
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
- **Coverage:** non-streaming calls on all four providers — OpenAI (Chat Completions + Responses), Anthropic, Gemini (legacy + current SDK), and Mistral. Streaming calls keep recording metadata as usual, but bodies are not captured.
|
|
89
|
+
- **PII masking before send:** emails, credit-card numbers, phone numbers, IP addresses, etc. are replaced with `[REDACTED_*]` inside your process, before the record leaves it. (`disablePiiRedaction: true` turns the filter off — at your own risk.)
|
|
90
|
+
- **Server-side consent gate:** unless the account is on a paid plan (Pro or higher) **and** plaintext storage has been explicitly enabled in the dashboard settings (consent dialog), the backend discards the bodies. Flipping the SDK flag alone stores nothing.
|
|
91
|
+
|
|
92
|
+
See <https://argosvix.com/en/docs/sdk-reference> for details.
|
|
74
93
|
|
|
75
94
|
## Short-lived runtimes (Cloudflare Workers / AWS Lambda / Vercel Edge)
|
|
76
95
|
|
|
@@ -324,6 +343,37 @@ await withTrace(async () => {
|
|
|
324
343
|
`withSpan` records the step's latency/status/error automatically. Keep `metadata` to
|
|
325
344
|
non-sensitive structured attributes (counts, sizes) — don't put raw documents or args there.
|
|
326
345
|
|
|
346
|
+
## Deployed prompts (`resolvePrompt` / `withPrompt`)
|
|
347
|
+
|
|
348
|
+
If you manage prompts in Argosvix (prompt registry + deployments), `resolvePrompt` fetches the
|
|
349
|
+
currently deployed version of a prompt at runtime, and `withPrompt` tags every wrapped LLM call
|
|
350
|
+
inside it with `prompt: {name}@v{version}` — so quality and cost can be compared per prompt
|
|
351
|
+
version in the dashboard:
|
|
352
|
+
|
|
353
|
+
```typescript
|
|
354
|
+
import { resolvePrompt, withPrompt } from "@argosvix/sdk";
|
|
355
|
+
|
|
356
|
+
const p = await resolvePrompt("support-bot", { apiKey: process.env.ARGOSVIX_API_KEY! });
|
|
357
|
+
// p.template = prompt body · p.version = deployed version · p.tag = "support-bot@v3"
|
|
358
|
+
|
|
359
|
+
await withPrompt(p, async () => {
|
|
360
|
+
// this call is tagged prompt:support-bot@v3 automatically
|
|
361
|
+
await client.chat.completions.create({
|
|
362
|
+
model: "gpt-5.5",
|
|
363
|
+
messages: [{ role: "system", content: p.template }, { role: "user", content: input }],
|
|
364
|
+
});
|
|
365
|
+
});
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
- `resolvePrompt(name, options)` resolves the current version for a deploy label (default
|
|
369
|
+
`"production"`, override with `options.label`). Results are cached in-memory with a
|
|
370
|
+
60-second TTL (`cacheTtlMs`, `0` disables), so it is safe on the hot path.
|
|
371
|
+
- Stale fallback: on network errors / timeouts / 5xx an expired cache entry is returned
|
|
372
|
+
instead of failing, so a transient backend outage doesn't stop your app. With no cached
|
|
373
|
+
value the error is thrown. 4xx (e.g. a deployment that doesn't exist) always throws.
|
|
374
|
+
- `withPrompt` accepts the `resolvePrompt` result, a `{ name, version }` object, or a raw
|
|
375
|
+
tag string. An explicit `tags.prompt` on the call wins over the ambient tag.
|
|
376
|
+
|
|
327
377
|
## Tags + aggregation
|
|
328
378
|
|
|
329
379
|
Tags are persisted per record. The backend dashboard supports cross-dimension aggregation such as "cost trend for `service=support-bot`" (Phase C dashboard and beyond).
|
|
@@ -468,14 +518,20 @@ Helper for short-lived runtimes (Cloudflare Workers, AWS Lambda, Vercel Edge). A
|
|
|
468
518
|
|
|
469
519
|
### `class Recorder`
|
|
470
520
|
- `record(record: LlmCallRecord): void`
|
|
471
|
-
- `flush(): Promise<LlmCallRecord[]>` — POSTs the buffer to the backend. Retries on 5xx and network errors; 4xx errors are not retried.
|
|
521
|
+
- `flush(): Promise<LlmCallRecord[]>` — POSTs the buffer to the backend. Retries on 5xx and network errors; 4xx errors are not retried. On `429` (monthly ingest quota reached) the SDK logs a warning once per process, so records don't stop silently at the end of the month.
|
|
472
522
|
- `getBufferSize(): number`
|
|
473
523
|
|
|
524
|
+
### `resolvePrompt(name: string, options: ResolvePromptOptions): Promise<ResolvedPrompt>`
|
|
525
|
+
Fetches the currently deployed version of a registered prompt (60 s TTL cache + stale fallback on backend failure). See "Deployed prompts" above.
|
|
526
|
+
|
|
527
|
+
### `withPrompt(prompt, fn)`
|
|
528
|
+
Runs `fn` with an ambient prompt tag; every wrapped call inside gets `tags.prompt = "{name}@v{version}"` automatically.
|
|
529
|
+
|
|
474
530
|
### `calculateCost(provider, model, promptTokens, completionTokens): number`
|
|
475
531
|
Internal pricing calculator returning USD. Exported for unit tests and custom-pricing experimentation. Resource-prefixed model names (e.g. `models/gemini-2.0-flash`) are looked up by their terminal model name.
|
|
476
532
|
|
|
477
533
|
### Types
|
|
478
|
-
`Provider` · `ArgosvixConfig` · `LlmCallRecord` · `PricingEntry`
|
|
534
|
+
`Provider` · `ArgosvixConfig` · `LlmCallRecord` · `PricingEntry` · `ResolvedPrompt` · `ResolvePromptOptions`
|
|
479
535
|
|
|
480
536
|
## License
|
|
481
537
|
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,YAAY,CAAC;AAE1E,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAOzC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAE,cAAmB,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,YAAY,CAAC;AAE1E,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAOzC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAE,cAAmB,GAAG,CAAC,CAyChF;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAE3D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAE1E;AA0oBD,0FAA0F;AAC1F,wBAAgB,0BAA0B,IAAI,IAAI,CAEjD;AA82CD;;;;;;;;;GASG"}
|