neatlogs 1.1.0 → 1.1.2

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 (45) hide show
  1. package/README.md +2 -2
  2. package/dist/anthropic.cjs +68 -2
  3. package/dist/anthropic.cjs.map +1 -1
  4. package/dist/anthropic.mjs +68 -2
  5. package/dist/anthropic.mjs.map +1 -1
  6. package/dist/azure-openai.cjs +68 -2
  7. package/dist/azure-openai.cjs.map +1 -1
  8. package/dist/azure-openai.mjs +68 -2
  9. package/dist/azure-openai.mjs.map +1 -1
  10. package/dist/bedrock.cjs +68 -2
  11. package/dist/bedrock.cjs.map +1 -1
  12. package/dist/bedrock.mjs +68 -2
  13. package/dist/bedrock.mjs.map +1 -1
  14. package/dist/browser.cjs +19 -9
  15. package/dist/browser.cjs.map +1 -1
  16. package/dist/browser.d.ts +23 -5
  17. package/dist/browser.mjs +19 -9
  18. package/dist/browser.mjs.map +1 -1
  19. package/dist/index.cjs +225 -381
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.ts +38 -19
  22. package/dist/index.mjs +224 -381
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/langchain.cjs +68 -2
  25. package/dist/langchain.cjs.map +1 -1
  26. package/dist/langchain.mjs +68 -2
  27. package/dist/langchain.mjs.map +1 -1
  28. package/dist/openai.cjs +68 -2
  29. package/dist/openai.cjs.map +1 -1
  30. package/dist/openai.mjs +68 -2
  31. package/dist/openai.mjs.map +1 -1
  32. package/dist/opencode-plugin.cjs +2 -2
  33. package/dist/opencode-plugin.cjs.map +1 -1
  34. package/dist/opencode-plugin.d.ts +1 -1
  35. package/dist/opencode-plugin.mjs +2 -2
  36. package/dist/opencode-plugin.mjs.map +1 -1
  37. package/dist/openrouter-agent.cjs +68 -2
  38. package/dist/openrouter-agent.cjs.map +1 -1
  39. package/dist/openrouter-agent.mjs +68 -2
  40. package/dist/openrouter-agent.mjs.map +1 -1
  41. package/dist/vertex-ai.cjs +68 -2
  42. package/dist/vertex-ai.cjs.map +1 -1
  43. package/dist/vertex-ai.mjs +68 -2
  44. package/dist/vertex-ai.mjs.map +1 -1
  45. package/package.json +5 -5
package/dist/index.d.ts CHANGED
@@ -40,26 +40,16 @@ interface InitOptions {
40
40
  baseUrl?: string;
41
41
  /** Name of the workflow being traced. Defaults to process.argv[1]. */
42
42
  workflowName?: string;
43
- /** Explicit session ID for grouping traces. */
44
- sessionId?: string;
45
- /** Auto-generate a session ID if none provided. Defaults to false. */
46
- autoSession?: boolean;
47
43
  /**
48
44
  * Operator identifier — whoever is RUNNING the SDK (a developer, a service
49
45
  * account, a CI job). Attached to all spans as a resource attribute. This is
50
46
  * NOT the end-user of your application.
47
+ *
48
+ * Session and end-user identity are PER-REQUEST, not process-global, so they
49
+ * are never set here. Declare them at the trace root via `trace()`/`span()`
50
+ * options, or for pure-`wrap()` code via the request-scoped `identify()`.
51
51
  */
52
52
  userId?: string;
53
- /**
54
- * Process-global default for the END-USER — the user of your application.
55
- * Use this for single-user processes (CLI, per-user worker) and pure-`wrap()`
56
- * setups, where it lands on the root span automatically. On a multi-tenant
57
- * server set the end-user per request via `trace({ endUserId })` instead.
58
- * One end-user per trace; the backend rolls it up to the trace and its session.
59
- */
60
- endUserId?: string;
61
- /** Optional arbitrary end-user fields stored as JSON (e.g. { plan: 'pro' }). */
62
- endUserMetadata?: Record<string, any>;
63
53
  /** Tags to attach to all spans. Must be string array. */
64
54
  tags?: string[];
65
55
  /** Custom metadata to attach to all spans. */
@@ -82,7 +72,7 @@ interface InitOptions {
82
72
  pii?: 'redact' | 'hash' | false;
83
73
  /** SDK version override. */
84
74
  version?: string;
85
- /** Backend endpoint URL. Defaults to https://staging-cloud.neatlogs.com */
75
+ /** Base ingest endpoint. Defaults to https://ingest.neatlogs.com. */
86
76
  endpoint?: string;
87
77
  /** Maximum spans per export batch. Defaults to 100. */
88
78
  batchSize?: number;
@@ -121,6 +111,12 @@ interface SpanOptions {
121
111
  parameters?: Record<string, any>;
122
112
  /** JSON schema describing the tool interface (for kind: MCP_TOOL). */
123
113
  toolJsonSchema?: Record<string, any>;
114
+ /**
115
+ * Session this trace belongs to — groups the traces of a multi-turn
116
+ * conversation (one turn = one trace). Usually set on the WORKFLOW root. The
117
+ * backend groups traces by it; when absent it falls back to the trace id.
118
+ */
119
+ sessionId?: string;
124
120
  /**
125
121
  * Identifier of the END-USER this trace belongs to — the user of your
126
122
  * application, not the operator running the SDK. The backend rolls it up to
@@ -216,8 +212,9 @@ declare function getSessionConfig(): Record<string, any>;
216
212
  * and executes the provided callback within the span.
217
213
  *
218
214
  * **Session-Aware Trace Creation:**
219
- * - If `session_id` is set in init() AND no active parent span exists,
220
- * this creates a NEW root trace (for multi-turn conversations).
215
+ * - If a session id is resolved (per-call `sessionId` or the request-scoped
216
+ * `identify()` context) AND no active parent span exists, this creates a NEW
217
+ * root trace (for multi-turn conversations).
221
218
  * - Otherwise, creates a normal child span within the existing trace.
222
219
  *
223
220
  * @param options - Trace configuration options
@@ -323,6 +320,28 @@ declare function Span(options: SpanOptions): <T extends (...args: any[]) => any>
323
320
  */
324
321
  declare function log(msgTemplate: string, options?: Record<string, any>): void;
325
322
 
323
+ interface IdentifyOptions {
324
+ sessionId?: string;
325
+ endUserId?: string;
326
+ endUserMetadata?: Record<string, any>;
327
+ }
328
+ /**
329
+ * Bind session / end-user identity for the duration of `fn`.
330
+ *
331
+ * Only defined fields are set, so a nested `identify()` overrides one field
332
+ * without clearing the others (it merges onto the enclosing store). The previous
333
+ * store is automatically restored when `fn` returns / rejects. Returns whatever
334
+ * `fn` returns (sync value or Promise).
335
+ *
336
+ * @example
337
+ * ```typescript
338
+ * await neatlogs.identify({ sessionId: 'chat_123' }, async () => {
339
+ * await wrappedClient.chat.completions.create(...);
340
+ * });
341
+ * ```
342
+ */
343
+ declare function identify<T>(opts: IdentifyOptions, fn: () => T): T;
344
+
326
345
  interface ContextSetter {
327
346
  set(template: string, variables: Record<string, any>): void;
328
347
  }
@@ -571,6 +590,6 @@ declare function registerCrewaiTask(task: {
571
590
  * SDK version. Kept in sync with package.json by the `version:sync` script
572
591
  * (runs automatically on `prebuild`). Do not edit by hand — bump package.json.
573
592
  */
574
- declare const __version__ = "1.1.0";
593
+ declare const __version__ = "1.1.2";
575
594
 
576
- export { type CachedPrompt, type InitOptions, type MaskFunction, PromptApiError, PromptClient, PromptClientError, PromptHandle, type PromptMessage, PromptNotFoundError, PromptTemplate, Span, type SpanKind, type SpanOptions, type TraceOptions, UserPromptTemplate, __version__, bindTemplates, createPrompt, deletePrompt, fetchPrompt, flush, getMastraObservability, getPrompt, getSessionConfig, init, isDebugEnabled, listPrompts, log, registerCrewaiTask, removeTag, saveAsVersion, shutdown, span, trace, updatePrompt };
595
+ export { type CachedPrompt, type InitOptions, type MaskFunction, PromptApiError, PromptClient, PromptClientError, PromptHandle, type PromptMessage, PromptNotFoundError, PromptTemplate, Span, type SpanKind, type SpanOptions, type TraceOptions, UserPromptTemplate, __version__, bindTemplates, createPrompt, deletePrompt, fetchPrompt, flush, getMastraObservability, getPrompt, getSessionConfig, identify, init, isDebugEnabled, listPrompts, log, registerCrewaiTask, removeTag, saveAsVersion, shutdown, span, trace, updatePrompt };