@arizeai/phoenix-client 6.8.1 → 6.9.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.
Files changed (103) hide show
  1. package/README.md +78 -0
  2. package/dist/esm/__generated__/api/v1.d.ts +30 -15
  3. package/dist/esm/__generated__/api/v1.d.ts.map +1 -1
  4. package/dist/esm/constants/serverRequirements.d.ts +1 -0
  5. package/dist/esm/constants/serverRequirements.d.ts.map +1 -1
  6. package/dist/esm/constants/serverRequirements.js +7 -0
  7. package/dist/esm/constants/serverRequirements.js.map +1 -1
  8. package/dist/esm/sessions/addSessionNote.d.ts +45 -0
  9. package/dist/esm/sessions/addSessionNote.d.ts.map +1 -0
  10. package/dist/esm/sessions/addSessionNote.js +45 -0
  11. package/dist/esm/sessions/addSessionNote.js.map +1 -0
  12. package/dist/esm/sessions/index.d.ts +1 -0
  13. package/dist/esm/sessions/index.d.ts.map +1 -1
  14. package/dist/esm/sessions/index.js +1 -0
  15. package/dist/esm/sessions/index.js.map +1 -1
  16. package/dist/esm/spans/addSpanNote.d.ts +5 -3
  17. package/dist/esm/spans/addSpanNote.d.ts.map +1 -1
  18. package/dist/esm/spans/addSpanNote.js +7 -4
  19. package/dist/esm/spans/addSpanNote.js.map +1 -1
  20. package/dist/esm/traces/addTraceAnnotation.d.ts +43 -0
  21. package/dist/esm/traces/addTraceAnnotation.d.ts.map +1 -0
  22. package/dist/esm/traces/addTraceAnnotation.js +43 -0
  23. package/dist/esm/traces/addTraceAnnotation.js.map +1 -0
  24. package/dist/esm/traces/addTraceNote.d.ts +5 -2
  25. package/dist/esm/traces/addTraceNote.d.ts.map +1 -1
  26. package/dist/esm/traces/addTraceNote.js +7 -3
  27. package/dist/esm/traces/addTraceNote.js.map +1 -1
  28. package/dist/esm/traces/index.d.ts +3 -0
  29. package/dist/esm/traces/index.d.ts.map +1 -1
  30. package/dist/esm/traces/index.js +2 -0
  31. package/dist/esm/traces/index.js.map +1 -1
  32. package/dist/esm/traces/logTraceAnnotations.d.ts +53 -0
  33. package/dist/esm/traces/logTraceAnnotations.d.ts.map +1 -0
  34. package/dist/esm/traces/logTraceAnnotations.js +50 -0
  35. package/dist/esm/traces/logTraceAnnotations.js.map +1 -0
  36. package/dist/esm/traces/types.d.ts +24 -0
  37. package/dist/esm/traces/types.d.ts.map +1 -0
  38. package/dist/esm/traces/types.js +38 -0
  39. package/dist/esm/traces/types.js.map +1 -0
  40. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  41. package/dist/esm/utils/apiErrorUtils.d.ts +2 -0
  42. package/dist/esm/utils/apiErrorUtils.d.ts.map +1 -0
  43. package/dist/esm/utils/apiErrorUtils.js +19 -0
  44. package/dist/esm/utils/apiErrorUtils.js.map +1 -0
  45. package/dist/esm/utils/formatPromptMessages.d.ts.map +1 -1
  46. package/dist/esm/utils/getPromptBySelector.d.ts.map +1 -1
  47. package/dist/src/__generated__/api/v1.d.ts +30 -15
  48. package/dist/src/__generated__/api/v1.d.ts.map +1 -1
  49. package/dist/src/constants/serverRequirements.d.ts +1 -0
  50. package/dist/src/constants/serverRequirements.d.ts.map +1 -1
  51. package/dist/src/constants/serverRequirements.js +8 -1
  52. package/dist/src/constants/serverRequirements.js.map +1 -1
  53. package/dist/src/sessions/addSessionNote.d.ts +45 -0
  54. package/dist/src/sessions/addSessionNote.d.ts.map +1 -0
  55. package/dist/src/sessions/addSessionNote.js +48 -0
  56. package/dist/src/sessions/addSessionNote.js.map +1 -0
  57. package/dist/src/sessions/index.d.ts +1 -0
  58. package/dist/src/sessions/index.d.ts.map +1 -1
  59. package/dist/src/sessions/index.js +1 -0
  60. package/dist/src/sessions/index.js.map +1 -1
  61. package/dist/src/spans/addSpanNote.d.ts +5 -3
  62. package/dist/src/spans/addSpanNote.d.ts.map +1 -1
  63. package/dist/src/spans/addSpanNote.js +7 -4
  64. package/dist/src/spans/addSpanNote.js.map +1 -1
  65. package/dist/src/traces/addTraceAnnotation.d.ts +43 -0
  66. package/dist/src/traces/addTraceAnnotation.d.ts.map +1 -0
  67. package/dist/src/traces/addTraceAnnotation.js +47 -0
  68. package/dist/src/traces/addTraceAnnotation.js.map +1 -0
  69. package/dist/src/traces/addTraceNote.d.ts +5 -2
  70. package/dist/src/traces/addTraceNote.d.ts.map +1 -1
  71. package/dist/src/traces/addTraceNote.js +7 -3
  72. package/dist/src/traces/addTraceNote.js.map +1 -1
  73. package/dist/src/traces/index.d.ts +3 -0
  74. package/dist/src/traces/index.d.ts.map +1 -1
  75. package/dist/src/traces/index.js +2 -0
  76. package/dist/src/traces/index.js.map +1 -1
  77. package/dist/src/traces/logTraceAnnotations.d.ts +53 -0
  78. package/dist/src/traces/logTraceAnnotations.d.ts.map +1 -0
  79. package/dist/src/traces/logTraceAnnotations.js +53 -0
  80. package/dist/src/traces/logTraceAnnotations.js.map +1 -0
  81. package/dist/src/traces/types.d.ts +24 -0
  82. package/dist/src/traces/types.d.ts.map +1 -0
  83. package/dist/src/traces/types.js +42 -0
  84. package/dist/src/traces/types.js.map +1 -0
  85. package/dist/src/utils/apiErrorUtils.d.ts +2 -0
  86. package/dist/src/utils/apiErrorUtils.d.ts.map +1 -0
  87. package/dist/src/utils/apiErrorUtils.js +22 -0
  88. package/dist/src/utils/apiErrorUtils.js.map +1 -0
  89. package/dist/src/utils/formatPromptMessages.d.ts.map +1 -1
  90. package/dist/src/utils/getPromptBySelector.d.ts.map +1 -1
  91. package/dist/tsconfig.tsbuildinfo +1 -1
  92. package/package.json +4 -4
  93. package/src/__generated__/api/v1.ts +30 -15
  94. package/src/constants/serverRequirements.ts +8 -0
  95. package/src/sessions/addSessionNote.ts +74 -0
  96. package/src/sessions/index.ts +1 -0
  97. package/src/spans/addSpanNote.ts +7 -4
  98. package/src/traces/addTraceAnnotation.ts +65 -0
  99. package/src/traces/addTraceNote.ts +7 -3
  100. package/src/traces/index.ts +3 -0
  101. package/src/traces/logTraceAnnotations.ts +75 -0
  102. package/src/traces/types.ts +72 -0
  103. package/src/utils/apiErrorUtils.ts +17 -0
@@ -18,6 +18,7 @@ export declare const DELETE_SESSIONS: RouteRequirement;
18
18
  export declare const LIST_PROJECT_SESSIONS: RouteRequirement;
19
19
  export declare const ANNOTATE_SESSIONS: RouteRequirement;
20
20
  export declare const ADD_TRACE_NOTE: RouteRequirement;
21
+ export declare const ADD_SESSION_NOTE: RouteRequirement;
21
22
  export declare const GET_SPANS_TRACE_IDS: ParameterRequirement;
22
23
  export declare const GET_SPANS_FILTERS: ParameterRequirement;
23
24
  export declare const LIST_PROJECT_TRACES: RouteRequirement;
@@ -1 +1 @@
1
- {"version":3,"file":"serverRequirements.d.ts","sourceRoot":"","sources":["../../../src/constants/serverRequirements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AAErC,eAAO,MAAM,WAAW,EAAE,gBAKzB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,gBAK5B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,gBAK7B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,gBAKnC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,gBAK/B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,gBAK5B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,oBAMjC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,oBAM/B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,gBAKjC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,oBAMpC,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,oBAMxC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,qBAAqB,EAYnD,CAAC"}
1
+ {"version":3,"file":"serverRequirements.d.ts","sourceRoot":"","sources":["../../../src/constants/serverRequirements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AAErC,eAAO,MAAM,WAAW,EAAE,gBAKzB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,gBAK5B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,gBAK7B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,gBAKnC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,gBAK/B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,gBAK5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,gBAK9B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,oBAMjC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,oBAM/B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,gBAKjC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,oBAMpC,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,oBAMxC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,qBAAqB,EAanD,CAAC"}
@@ -13,7 +13,7 @@
13
13
  * function that uses it.
14
14
  */
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.ALL_REQUIREMENTS = exports.DATASET_UPLOAD_EXAMPLE_IDS = exports.GET_SPANS_BY_ATTRIBUTE = exports.LIST_PROJECT_TRACES = exports.GET_SPANS_FILTERS = exports.GET_SPANS_TRACE_IDS = exports.ADD_TRACE_NOTE = exports.ANNOTATE_SESSIONS = exports.LIST_PROJECT_SESSIONS = exports.DELETE_SESSIONS = exports.DELETE_SESSION = exports.GET_SESSION = void 0;
16
+ exports.ALL_REQUIREMENTS = exports.DATASET_UPLOAD_EXAMPLE_IDS = exports.GET_SPANS_BY_ATTRIBUTE = exports.LIST_PROJECT_TRACES = exports.GET_SPANS_FILTERS = exports.GET_SPANS_TRACE_IDS = exports.ADD_SESSION_NOTE = exports.ADD_TRACE_NOTE = exports.ANNOTATE_SESSIONS = exports.LIST_PROJECT_SESSIONS = exports.DELETE_SESSIONS = exports.DELETE_SESSION = exports.GET_SESSION = void 0;
17
17
  exports.GET_SESSION = {
18
18
  kind: "route",
19
19
  method: "GET",
@@ -50,6 +50,12 @@ exports.ADD_TRACE_NOTE = {
50
50
  path: "/v1/trace_notes",
51
51
  minServerVersion: [14, 13, 0],
52
52
  };
53
+ exports.ADD_SESSION_NOTE = {
54
+ kind: "route",
55
+ method: "POST",
56
+ path: "/v1/session_notes",
57
+ minServerVersion: [14, 17, 0],
58
+ };
53
59
  exports.GET_SPANS_TRACE_IDS = {
54
60
  kind: "parameter",
55
61
  parameterName: "trace_id",
@@ -97,6 +103,7 @@ exports.ALL_REQUIREMENTS = [
97
103
  exports.LIST_PROJECT_SESSIONS,
98
104
  exports.ANNOTATE_SESSIONS,
99
105
  exports.ADD_TRACE_NOTE,
106
+ exports.ADD_SESSION_NOTE,
100
107
  exports.GET_SPANS_TRACE_IDS,
101
108
  exports.GET_SPANS_FILTERS,
102
109
  exports.GET_SPANS_BY_ATTRIBUTE,
@@ -1 +1 @@
1
- {"version":3,"file":"serverRequirements.js","sourceRoot":"","sources":["../../../src/constants/serverRequirements.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAQU,QAAA,WAAW,GAAqB;IAC3C,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,2BAA2B;IACjC,gBAAgB,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;CAC7B,CAAC;AAEW,QAAA,cAAc,GAAqB;IAC9C,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,2BAA2B;IACjC,gBAAgB,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;CAC9B,CAAC;AAEW,QAAA,eAAe,GAAqB;IAC/C,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,MAAM;IACd,IAAI,EAAE,qBAAqB;IAC3B,gBAAgB,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;CAC9B,CAAC;AAEW,QAAA,qBAAqB,GAAqB;IACrD,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,oCAAoC;IAC1C,gBAAgB,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;CAC7B,CAAC;AAEW,QAAA,iBAAiB,GAAqB;IACjD,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,MAAM;IACd,IAAI,EAAE,yBAAyB;IAC/B,gBAAgB,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;CAC7B,CAAC;AAEW,QAAA,cAAc,GAAqB;IAC9C,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,MAAM;IACd,IAAI,EAAE,iBAAiB;IACvB,gBAAgB,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;CAC9B,CAAC;AAEW,QAAA,mBAAmB,GAAyB;IACvD,IAAI,EAAE,WAAW;IACjB,aAAa,EAAE,UAAU;IACzB,iBAAiB,EAAE,OAAO;IAC1B,KAAK,EAAE,6BAA6B;IACpC,gBAAgB,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;CAC7B,CAAC;AAEW,QAAA,iBAAiB,GAAyB;IACrD,IAAI,EAAE,WAAW;IACjB,aAAa,EAAE,WAAW;IAC1B,iBAAiB,EAAE,OAAO;IAC1B,KAAK,EAAE,6BAA6B;IACpC,gBAAgB,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;CAC9B,CAAC;AAEW,QAAA,mBAAmB,GAAqB;IACnD,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,0CAA0C;IAChD,gBAAgB,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;CAC9B,CAAC;AAEW,QAAA,sBAAsB,GAAyB;IAC1D,IAAI,EAAE,WAAW;IACjB,aAAa,EAAE,WAAW;IAC1B,iBAAiB,EAAE,OAAO;IAC1B,KAAK,EAAE,6BAA6B;IACpC,gBAAgB,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;CAC7B,CAAC;AAEW,QAAA,0BAA0B,GAAyB;IAC9D,IAAI,EAAE,WAAW;IACjB,aAAa,EAAE,aAAa;IAC5B,iBAAiB,EAAE,MAAM;IACzB,KAAK,EAAE,0BAA0B;IACjC,gBAAgB,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;CAC7B,CAAC;AAEF;;;;;GAKG;AACU,QAAA,gBAAgB,GAAqC;IAChE,mBAAW;IACX,sBAAc;IACd,uBAAe;IACf,6BAAqB;IACrB,yBAAiB;IACjB,sBAAc;IACd,2BAAmB;IACnB,yBAAiB;IACjB,8BAAsB;IACtB,2BAAmB;IACnB,kCAA0B;CAClB,CAAC"}
1
+ {"version":3,"file":"serverRequirements.js","sourceRoot":"","sources":["../../../src/constants/serverRequirements.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,45 @@
1
+ import type { ClientFn } from "../types/core";
2
+ /**
3
+ * Parameters for a single session note.
4
+ */
5
+ export interface SessionNote {
6
+ /**
7
+ * The session ID used to track a conversation, thread, or session.
8
+ */
9
+ sessionId: string;
10
+ /**
11
+ * The note text to add to the session.
12
+ */
13
+ note: string;
14
+ }
15
+ /**
16
+ * Parameters to add a session note.
17
+ */
18
+ export interface AddSessionNoteParams extends ClientFn {
19
+ sessionNote: SessionNote;
20
+ }
21
+ /**
22
+ * Add a note to a session.
23
+ *
24
+ * Notes are a special type of annotation that allow multiple entries per session.
25
+ * Each note gets a unique UUIDv4 identifier.
26
+ *
27
+ * @param params - The parameters to add a session note.
28
+ * @returns The ID of the created note annotation.
29
+ *
30
+ * @requires Phoenix server >= 14.17.0
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * const result = await addSessionNote({
35
+ * sessionNote: {
36
+ * sessionId: "my-session",
37
+ * note: "Needs review"
38
+ * }
39
+ * });
40
+ * ```
41
+ */
42
+ export declare function addSessionNote({ client: _client, sessionNote, }: AddSessionNoteParams): Promise<{
43
+ id: string;
44
+ }>;
45
+ //# sourceMappingURL=addSessionNote.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addSessionNote.d.ts","sourceRoot":"","sources":["../../../src/sessions/addSessionNote.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI9C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,QAAQ;IACpD,WAAW,EAAE,WAAW,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,cAAc,CAAC,EACnC,MAAM,EAAE,OAAO,EACf,WAAW,GACZ,EAAE,oBAAoB,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAsBhD"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addSessionNote = addSessionNote;
4
+ const client_1 = require("../client");
5
+ const serverRequirements_1 = require("../constants/serverRequirements");
6
+ const apiErrorUtils_1 = require("../utils/apiErrorUtils");
7
+ const serverVersionUtils_1 = require("../utils/serverVersionUtils");
8
+ /**
9
+ * Add a note to a session.
10
+ *
11
+ * Notes are a special type of annotation that allow multiple entries per session.
12
+ * Each note gets a unique UUIDv4 identifier.
13
+ *
14
+ * @param params - The parameters to add a session note.
15
+ * @returns The ID of the created note annotation.
16
+ *
17
+ * @requires Phoenix server >= 14.17.0
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const result = await addSessionNote({
22
+ * sessionNote: {
23
+ * sessionId: "my-session",
24
+ * note: "Needs review"
25
+ * }
26
+ * });
27
+ * ```
28
+ */
29
+ async function addSessionNote({ client: _client, sessionNote, }) {
30
+ const client = _client !== null && _client !== void 0 ? _client : (0, client_1.createClient)();
31
+ await (0, serverVersionUtils_1.ensureServerCapability)({ client, requirement: serverRequirements_1.ADD_SESSION_NOTE });
32
+ const { data, error } = await client.POST("/v1/session_notes", {
33
+ body: {
34
+ data: {
35
+ session_id: sessionNote.sessionId.trim(),
36
+ note: sessionNote.note,
37
+ },
38
+ },
39
+ });
40
+ if (error) {
41
+ throw new Error(`Failed to add session note: ${(0, apiErrorUtils_1.formatApiError)(error)}`);
42
+ }
43
+ if (!(data === null || data === void 0 ? void 0 : data.data)) {
44
+ throw new Error("Failed to add session note: no data returned");
45
+ }
46
+ return data.data;
47
+ }
48
+ //# sourceMappingURL=addSessionNote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addSessionNote.js","sourceRoot":"","sources":["../../../src/sessions/addSessionNote.ts"],"names":[],"mappings":";;AAgDA,wCAyBC;AAzED,sCAAyC;AACzC,wEAAmE;AAEnE,0DAAwD;AACxD,oEAAqE;AAuBrE;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,KAAK,UAAU,cAAc,CAAC,EACnC,MAAM,EAAE,OAAO,EACf,WAAW,GACU;IACrB,MAAM,MAAM,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAA,qBAAY,GAAE,CAAC;IACzC,MAAM,IAAA,2CAAsB,EAAC,EAAE,MAAM,EAAE,WAAW,EAAE,qCAAgB,EAAE,CAAC,CAAC;IAExE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,mBAAmB,EAAE;QAC7D,IAAI,EAAE;YACJ,IAAI,EAAE;gBACJ,UAAU,EAAE,WAAW,CAAC,SAAS,CAAC,IAAI,EAAE;gBACxC,IAAI,EAAE,WAAW,CAAC,IAAI;aACvB;SACF;KACF,CAAC,CAAC;IAEH,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,+BAA+B,IAAA,8BAAc,EAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,IAAI,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAA,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export * from "./addSessionAnnotation";
2
+ export * from "./addSessionNote";
2
3
  export * from "./deleteSession";
3
4
  export * from "./deleteSessions";
4
5
  export * from "./getSession";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sessions/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sessions/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC"}
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./addSessionAnnotation"), exports);
18
+ __exportStar(require("./addSessionNote"), exports);
18
19
  __exportStar(require("./deleteSession"), exports);
19
20
  __exportStar(require("./deleteSessions"), exports);
20
21
  __exportStar(require("./getSession"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sessions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,kDAAgC;AAChC,mDAAiC;AACjC,+CAA6B;AAC7B,oDAAkC;AAClC,iDAA+B;AAC/B,0DAAwC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sessions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,mDAAiC;AACjC,kDAAgC;AAChC,mDAAiC;AACjC,+CAA6B;AAC7B,oDAAkC;AAClC,iDAA+B;AAC/B,0DAAwC"}
@@ -21,9 +21,11 @@ export interface AddSpanNoteParams extends ClientFn {
21
21
  /**
22
22
  * Add a note to a span.
23
23
  *
24
- * Notes are a special type of annotation that allow multiple entries per span
25
- * (unlike regular annotations which are unique by name and identifier).
26
- * Each note gets a unique UUIDv4 identifier.
24
+ * Notes are append-only: each call creates a new note with an auto-generated
25
+ * UUIDv4 identifier, so multiple notes accumulate on the same span. Structured
26
+ * annotations, by contrast, are keyed by `(name, spanId, identifier)` — to keep
27
+ * multiple structured annotations with the same name on a span, supply distinct
28
+ * identifiers; otherwise re-writing the same name overwrites the existing one.
27
29
  *
28
30
  * @param params - The parameters to add a span note
29
31
  * @returns The ID of the created note annotation
@@ -1 +1 @@
1
- {"version":3,"file":"addSpanNote.d.ts","sourceRoot":"","sources":["../../../src/spans/addSpanNote.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,QAAQ;IACjD,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,WAAW,CAAC,EAChC,MAAM,EAAE,OAAO,EACf,QAAQ,GACT,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAqB7C"}
1
+ {"version":3,"file":"addSpanNote.d.ts","sourceRoot":"","sources":["../../../src/spans/addSpanNote.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG9C;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,QAAQ;IACjD,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,WAAW,CAAC,EAChC,MAAM,EAAE,OAAO,EACf,QAAQ,GACT,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAqB7C"}
@@ -2,12 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addSpanNote = addSpanNote;
4
4
  const client_1 = require("../client");
5
+ const apiErrorUtils_1 = require("../utils/apiErrorUtils");
5
6
  /**
6
7
  * Add a note to a span.
7
8
  *
8
- * Notes are a special type of annotation that allow multiple entries per span
9
- * (unlike regular annotations which are unique by name and identifier).
10
- * Each note gets a unique UUIDv4 identifier.
9
+ * Notes are append-only: each call creates a new note with an auto-generated
10
+ * UUIDv4 identifier, so multiple notes accumulate on the same span. Structured
11
+ * annotations, by contrast, are keyed by `(name, spanId, identifier)` — to keep
12
+ * multiple structured annotations with the same name on a span, supply distinct
13
+ * identifiers; otherwise re-writing the same name overwrites the existing one.
11
14
  *
12
15
  * @param params - The parameters to add a span note
13
16
  * @returns The ID of the created note annotation
@@ -33,7 +36,7 @@ async function addSpanNote({ client: _client, spanNote, }) {
33
36
  },
34
37
  });
35
38
  if (error) {
36
- throw new Error(`Failed to add span note: ${error}`);
39
+ throw new Error(`Failed to add span note: ${(0, apiErrorUtils_1.formatApiError)(error)}`);
37
40
  }
38
41
  if (!(data === null || data === void 0 ? void 0 : data.data)) {
39
42
  throw new Error("Failed to add span note: no data returned");
@@ -1 +1 @@
1
- {"version":3,"file":"addSpanNote.js","sourceRoot":"","sources":["../../../src/spans/addSpanNote.ts"],"names":[],"mappings":";;AA4CA,kCAwBC;AApED,sCAAyC;AAwBzC;;;;;;;;;;;;;;;;;;;GAmBG;AACI,KAAK,UAAU,WAAW,CAAC,EAChC,MAAM,EAAE,OAAO,EACf,QAAQ,GACU;IAClB,MAAM,MAAM,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAA,qBAAY,GAAE,CAAC;IAEzC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE;QAC1D,IAAI,EAAE;YACJ,IAAI,EAAE;gBACJ,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE;gBAC/B,IAAI,EAAE,QAAQ,CAAC,IAAI;aACpB;SACF;KACF,CAAC,CAAC;IAEH,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,4BAA4B,KAAK,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,IAAI,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAA,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC"}
1
+ {"version":3,"file":"addSpanNote.js","sourceRoot":"","sources":["../../../src/spans/addSpanNote.ts"],"names":[],"mappings":";;AA+CA,kCAwBC;AAvED,sCAAyC;AAEzC,0DAAwD;AAuBxD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACI,KAAK,UAAU,WAAW,CAAC,EAChC,MAAM,EAAE,OAAO,EACf,QAAQ,GACU;IAClB,MAAM,MAAM,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAA,qBAAY,GAAE,CAAC;IAEzC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE;QAC1D,IAAI,EAAE;YACJ,IAAI,EAAE;gBACJ,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE;gBAC/B,IAAI,EAAE,QAAQ,CAAC,IAAI;aACpB;SACF;KACF,CAAC,CAAC;IAEH,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAA,8BAAc,EAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACvE,CAAC;IAED,IAAI,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAA,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC"}
@@ -0,0 +1,43 @@
1
+ import type { ClientFn } from "../types/core";
2
+ import type { TraceAnnotation } from "./types";
3
+ /**
4
+ * Parameters to add a trace annotation
5
+ */
6
+ export interface AddTraceAnnotationParams extends ClientFn {
7
+ traceAnnotation: TraceAnnotation;
8
+ /**
9
+ * If true, the request will be fulfilled synchronously and return the annotation ID.
10
+ * If false, the request will be processed asynchronously and return null.
11
+ * @default false
12
+ */
13
+ sync?: boolean;
14
+ }
15
+ /**
16
+ * Add an annotation to a trace.
17
+ *
18
+ * The annotation can be of type "LLM", "CODE", or "HUMAN" and can include a label, score, and metadata.
19
+ * If an identifier is provided and an annotation with that identifier already exists, it will be updated.
20
+ *
21
+ * @param params - The parameters to add a trace annotation
22
+ * @returns The ID of the created or updated annotation
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const result = await addTraceAnnotation({
27
+ * traceAnnotation: {
28
+ * traceId: "abc123",
29
+ * name: "correctness",
30
+ * label: "correct",
31
+ * score: 1.0,
32
+ * annotatorKind: "HUMAN",
33
+ * identifier: "custom_id_123",
34
+ * metadata: { reviewer: "alice" }
35
+ * },
36
+ * sync: true,
37
+ * });
38
+ * ```
39
+ */
40
+ export declare function addTraceAnnotation({ client: _client, traceAnnotation, sync, }: AddTraceAnnotationParams): Promise<{
41
+ id: string;
42
+ } | null>;
43
+ //# sourceMappingURL=addTraceAnnotation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addTraceAnnotation.d.ts","sourceRoot":"","sources":["../../../src/traces/addTraceAnnotation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/C;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,QAAQ;IACxD,eAAe,EAAE,eAAe,CAAC;IACjC;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,MAAM,EAAE,OAAO,EACf,eAAe,EACf,IAAY,GACb,EAAE,wBAAwB,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAiB3D"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addTraceAnnotation = addTraceAnnotation;
4
+ const client_1 = require("../client");
5
+ const types_1 = require("./types");
6
+ /**
7
+ * Add an annotation to a trace.
8
+ *
9
+ * The annotation can be of type "LLM", "CODE", or "HUMAN" and can include a label, score, and metadata.
10
+ * If an identifier is provided and an annotation with that identifier already exists, it will be updated.
11
+ *
12
+ * @param params - The parameters to add a trace annotation
13
+ * @returns The ID of the created or updated annotation
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const result = await addTraceAnnotation({
18
+ * traceAnnotation: {
19
+ * traceId: "abc123",
20
+ * name: "correctness",
21
+ * label: "correct",
22
+ * score: 1.0,
23
+ * annotatorKind: "HUMAN",
24
+ * identifier: "custom_id_123",
25
+ * metadata: { reviewer: "alice" }
26
+ * },
27
+ * sync: true,
28
+ * });
29
+ * ```
30
+ */
31
+ async function addTraceAnnotation({ client: _client, traceAnnotation, sync = false, }) {
32
+ var _a;
33
+ const client = _client !== null && _client !== void 0 ? _client : (0, client_1.createClient)();
34
+ const { data, error } = await client.POST("/v1/trace_annotations", {
35
+ params: {
36
+ query: { sync },
37
+ },
38
+ body: {
39
+ data: [(0, types_1.toTraceAnnotationData)(traceAnnotation)],
40
+ },
41
+ });
42
+ if (error) {
43
+ throw new Error(`Failed to add trace annotation: ${error}`);
44
+ }
45
+ return ((_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a[0]) || null;
46
+ }
47
+ //# sourceMappingURL=addTraceAnnotation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addTraceAnnotation.js","sourceRoot":"","sources":["../../../src/traces/addTraceAnnotation.ts"],"names":[],"mappings":";;AA2CA,gDAqBC;AAhED,sCAAyC;AAGzC,mCAAgD;AAehD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,KAAK,UAAU,kBAAkB,CAAC,EACvC,MAAM,EAAE,OAAO,EACf,eAAe,EACf,IAAI,GAAG,KAAK,GACa;;IACzB,MAAM,MAAM,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAA,qBAAY,GAAE,CAAC;IAEzC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,uBAAuB,EAAE;QACjE,MAAM,EAAE;YACN,KAAK,EAAE,EAAE,IAAI,EAAE;SAChB;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,CAAC,IAAA,6BAAqB,EAAC,eAAe,CAAC,CAAC;SAC/C;KACF,CAAC,CAAC;IAEH,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,mCAAmC,KAAK,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,CAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,0CAAG,CAAC,CAAC,KAAI,IAAI,CAAC;AACjC,CAAC"}
@@ -21,8 +21,11 @@ export interface AddTraceNoteParams extends ClientFn {
21
21
  /**
22
22
  * Add a note to a trace.
23
23
  *
24
- * Notes are a special type of annotation that allow multiple entries per trace.
25
- * Each note gets a unique timestamp-based identifier.
24
+ * Notes are append-only: each call creates a new note with an auto-generated
25
+ * UUIDv4 identifier, so multiple notes accumulate on the same trace. Structured
26
+ * annotations, by contrast, are keyed by `(name, traceId, identifier)` — to keep
27
+ * multiple structured annotations with the same name on a trace, supply distinct
28
+ * identifiers; otherwise re-writing the same name overwrites the existing one.
26
29
  *
27
30
  * @param params - The parameters to add a trace note.
28
31
  * @returns The ID of the created note annotation.
@@ -1 +1 @@
1
- {"version":3,"file":"addTraceNote.d.ts","sourceRoot":"","sources":["../../../src/traces/addTraceNote.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG9C;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,QAAQ;IAClD,SAAS,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,YAAY,CAAC,EACjC,MAAM,EAAE,OAAO,EACf,SAAS,GACV,EAAE,kBAAkB,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAsB9C"}
1
+ {"version":3,"file":"addTraceNote.d.ts","sourceRoot":"","sources":["../../../src/traces/addTraceNote.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI9C;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,QAAQ;IAClD,SAAS,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,YAAY,CAAC,EACjC,MAAM,EAAE,OAAO,EACf,SAAS,GACV,EAAE,kBAAkB,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAsB9C"}
@@ -3,12 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addTraceNote = addTraceNote;
4
4
  const client_1 = require("../client");
5
5
  const serverRequirements_1 = require("../constants/serverRequirements");
6
+ const apiErrorUtils_1 = require("../utils/apiErrorUtils");
6
7
  const serverVersionUtils_1 = require("../utils/serverVersionUtils");
7
8
  /**
8
9
  * Add a note to a trace.
9
10
  *
10
- * Notes are a special type of annotation that allow multiple entries per trace.
11
- * Each note gets a unique timestamp-based identifier.
11
+ * Notes are append-only: each call creates a new note with an auto-generated
12
+ * UUIDv4 identifier, so multiple notes accumulate on the same trace. Structured
13
+ * annotations, by contrast, are keyed by `(name, traceId, identifier)` — to keep
14
+ * multiple structured annotations with the same name on a trace, supply distinct
15
+ * identifiers; otherwise re-writing the same name overwrites the existing one.
12
16
  *
13
17
  * @param params - The parameters to add a trace note.
14
18
  * @returns The ID of the created note annotation.
@@ -35,7 +39,7 @@ async function addTraceNote({ client: _client, traceNote, }) {
35
39
  },
36
40
  });
37
41
  if (error) {
38
- throw new Error(`Failed to add trace note: ${error}`);
42
+ throw new Error(`Failed to add trace note: ${(0, apiErrorUtils_1.formatApiError)(error)}`);
39
43
  }
40
44
  if (!(data === null || data === void 0 ? void 0 : data.data)) {
41
45
  throw new Error("Failed to add trace note: no data returned");
@@ -1 +1 @@
1
- {"version":3,"file":"addTraceNote.js","sourceRoot":"","sources":["../../../src/traces/addTraceNote.ts"],"names":[],"mappings":";;AA6CA,oCAyBC;AAtED,sCAAyC;AACzC,wEAAiE;AAEjE,oEAAqE;AAuBrE;;;;;;;;;;;;;;;;;;GAkBG;AACI,KAAK,UAAU,YAAY,CAAC,EACjC,MAAM,EAAE,OAAO,EACf,SAAS,GACU;IACnB,MAAM,MAAM,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAA,qBAAY,GAAE,CAAC;IACzC,MAAM,IAAA,2CAAsB,EAAC,EAAE,MAAM,EAAE,WAAW,EAAE,mCAAc,EAAE,CAAC,CAAC;IAEtE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE;QAC3D,IAAI,EAAE;YACJ,IAAI,EAAE;gBACJ,QAAQ,EAAE,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE;gBAClC,IAAI,EAAE,SAAS,CAAC,IAAI;aACrB;SACF;KACF,CAAC,CAAC;IAEH,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,6BAA6B,KAAK,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAA,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC"}
1
+ {"version":3,"file":"addTraceNote.js","sourceRoot":"","sources":["../../../src/traces/addTraceNote.ts"],"names":[],"mappings":";;AAiDA,oCAyBC;AA1ED,sCAAyC;AACzC,wEAAiE;AAEjE,0DAAwD;AACxD,oEAAqE;AAuBrE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACI,KAAK,UAAU,YAAY,CAAC,EACjC,MAAM,EAAE,OAAO,EACf,SAAS,GACU;IACnB,MAAM,MAAM,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAA,qBAAY,GAAE,CAAC;IACzC,MAAM,IAAA,2CAAsB,EAAC,EAAE,MAAM,EAAE,WAAW,EAAE,mCAAc,EAAE,CAAC,CAAC;IAEtE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE;QAC3D,IAAI,EAAE;YACJ,IAAI,EAAE;gBACJ,QAAQ,EAAE,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE;gBAClC,IAAI,EAAE,SAAS,CAAC,IAAI;aACrB;SACF;KACF,CAAC,CAAC;IAEH,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAA,8BAAc,EAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,IAAI,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAA,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC"}
@@ -1,3 +1,6 @@
1
+ export * from "./addTraceAnnotation";
1
2
  export * from "./addTraceNote";
2
3
  export * from "./getTraces";
4
+ export * from "./logTraceAnnotations";
5
+ export type { TraceAnnotation } from "./types";
3
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/traces/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/traces/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC"}
@@ -14,6 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./addTraceAnnotation"), exports);
17
18
  __exportStar(require("./addTraceNote"), exports);
18
19
  __exportStar(require("./getTraces"), exports);
20
+ __exportStar(require("./logTraceAnnotations"), exports);
19
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/traces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,8CAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/traces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,iDAA+B;AAC/B,8CAA4B;AAC5B,wDAAsC"}
@@ -0,0 +1,53 @@
1
+ import type { ClientFn } from "../types/core";
2
+ import type { TraceAnnotation } from "./types";
3
+ /**
4
+ * Parameters to log multiple trace annotations
5
+ */
6
+ export interface LogTraceAnnotationsParams extends ClientFn {
7
+ /**
8
+ * The trace annotations to log
9
+ */
10
+ traceAnnotations: TraceAnnotation[];
11
+ /**
12
+ * If true, the request will be fulfilled synchronously and return the annotation IDs.
13
+ * If false, the request will be processed asynchronously and return null.
14
+ * @default false
15
+ */
16
+ sync?: boolean;
17
+ }
18
+ /**
19
+ * Log multiple trace annotations in a single request.
20
+ *
21
+ * Each annotation can be of type "LLM", "CODE", or "HUMAN" and can include a label, score, and metadata.
22
+ * If an identifier is provided and an annotation with that identifier already exists, it will be updated.
23
+ *
24
+ * @param params - The parameters to log trace annotations
25
+ * @returns The IDs of the created or updated annotations
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * const results = await logTraceAnnotations({
30
+ * traceAnnotations: [
31
+ * {
32
+ * traceId: "abc123",
33
+ * name: "correctness",
34
+ * label: "correct",
35
+ * score: 1.0,
36
+ * annotatorKind: "HUMAN",
37
+ * },
38
+ * {
39
+ * traceId: "def456",
40
+ * name: "faithfulness",
41
+ * label: "faithful",
42
+ * score: 0.9,
43
+ * annotatorKind: "LLM",
44
+ * },
45
+ * ],
46
+ * sync: true,
47
+ * });
48
+ * ```
49
+ */
50
+ export declare function logTraceAnnotations({ client: _client, traceAnnotations, sync, }: LogTraceAnnotationsParams): Promise<{
51
+ id: string;
52
+ }[]>;
53
+ //# sourceMappingURL=logTraceAnnotations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logTraceAnnotations.d.ts","sourceRoot":"","sources":["../../../src/traces/logTraceAnnotations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/C;;GAEG;AACH,MAAM,WAAW,yBAA0B,SAAQ,QAAQ;IACzD;;OAEG;IACH,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAsB,mBAAmB,CAAC,EACxC,MAAM,EAAE,OAAO,EACf,gBAAgB,EAChB,IAAY,GACb,EAAE,yBAAyB,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,CAiBvD"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logTraceAnnotations = logTraceAnnotations;
4
+ const client_1 = require("../client");
5
+ const types_1 = require("./types");
6
+ /**
7
+ * Log multiple trace annotations in a single request.
8
+ *
9
+ * Each annotation can be of type "LLM", "CODE", or "HUMAN" and can include a label, score, and metadata.
10
+ * If an identifier is provided and an annotation with that identifier already exists, it will be updated.
11
+ *
12
+ * @param params - The parameters to log trace annotations
13
+ * @returns The IDs of the created or updated annotations
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const results = await logTraceAnnotations({
18
+ * traceAnnotations: [
19
+ * {
20
+ * traceId: "abc123",
21
+ * name: "correctness",
22
+ * label: "correct",
23
+ * score: 1.0,
24
+ * annotatorKind: "HUMAN",
25
+ * },
26
+ * {
27
+ * traceId: "def456",
28
+ * name: "faithfulness",
29
+ * label: "faithful",
30
+ * score: 0.9,
31
+ * annotatorKind: "LLM",
32
+ * },
33
+ * ],
34
+ * sync: true,
35
+ * });
36
+ * ```
37
+ */
38
+ async function logTraceAnnotations({ client: _client, traceAnnotations, sync = false, }) {
39
+ const client = _client !== null && _client !== void 0 ? _client : (0, client_1.createClient)();
40
+ const { data, error } = await client.POST("/v1/trace_annotations", {
41
+ params: {
42
+ query: { sync },
43
+ },
44
+ body: {
45
+ data: traceAnnotations.map(types_1.toTraceAnnotationData),
46
+ },
47
+ });
48
+ if (error) {
49
+ throw new Error(`Failed to log trace annotations: ${error}`);
50
+ }
51
+ return (data === null || data === void 0 ? void 0 : data.data) || [];
52
+ }
53
+ //# sourceMappingURL=logTraceAnnotations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logTraceAnnotations.js","sourceRoot":"","sources":["../../../src/traces/logTraceAnnotations.ts"],"names":[],"mappings":";;AAqDA,kDAqBC;AA1ED,sCAAyC;AAGzC,mCAAgD;AAkBhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACI,KAAK,UAAU,mBAAmB,CAAC,EACxC,MAAM,EAAE,OAAO,EACf,gBAAgB,EAChB,IAAI,GAAG,KAAK,GACc;IAC1B,MAAM,MAAM,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAA,qBAAY,GAAE,CAAC;IAEzC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,uBAAuB,EAAE;QACjE,MAAM,EAAE;YACN,KAAK,EAAE,EAAE,IAAI,EAAE;SAChB;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,gBAAgB,CAAC,GAAG,CAAC,6BAAqB,CAAC;SAClD;KACF,CAAC,CAAC;IAEH,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,oCAAoC,KAAK,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,KAAI,EAAE,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { paths } from "../__generated__/api/v1";
2
+ import type { Annotation } from "../types/annotations";
3
+ type TraceAnnotationData = paths["/v1/trace_annotations"]["post"]["requestBody"]["content"]["application/json"]["data"][0];
4
+ /**
5
+ * Parameters for a single trace annotation
6
+ */
7
+ export interface TraceAnnotation extends Annotation {
8
+ /**
9
+ * The OpenTelemetry Trace ID (hex format without 0x prefix)
10
+ */
11
+ traceId: string;
12
+ /**
13
+ * The kind of annotator used for the annotation
14
+ * Can be "HUMAN", "LLM", or "CODE"
15
+ * @default "HUMAN"
16
+ */
17
+ annotatorKind?: TraceAnnotationData["annotator_kind"];
18
+ }
19
+ /**
20
+ * Convert a TraceAnnotation to the API format
21
+ */
22
+ export declare function toTraceAnnotationData(annotation: TraceAnnotation): TraceAnnotationData;
23
+ export {};
24
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/traces/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAoB,MAAM,sBAAsB,CAAC;AAEzE,KAAK,mBAAmB,GACtB,KAAK,CAAC,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAElG;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,UAAU;IACjD;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,aAAa,CAAC,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;CACvD;AA8BD;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,eAAe,GAC1B,mBAAmB,CAgBrB"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toTraceAnnotationData = toTraceAnnotationData;
4
+ /**
5
+ * Build and validate annotation result fields
6
+ */
7
+ function buildTraceAnnotationResult(annotation) {
8
+ const result = {};
9
+ if (annotation.label !== undefined) {
10
+ result.label = annotation.label.trim() || null;
11
+ }
12
+ if (annotation.score !== undefined) {
13
+ result.score = annotation.score;
14
+ }
15
+ if (annotation.explanation !== undefined) {
16
+ result.explanation = annotation.explanation.trim() || null;
17
+ }
18
+ const hasValidResult = result.label || result.score !== undefined || result.explanation;
19
+ if (!hasValidResult) {
20
+ throw new Error("At least one of label, score, or explanation must be provided for trace annotation");
21
+ }
22
+ return result;
23
+ }
24
+ /**
25
+ * Convert a TraceAnnotation to the API format
26
+ */
27
+ function toTraceAnnotationData(annotation) {
28
+ var _a, _b, _c, _d;
29
+ if (annotation.name.trim() === "note") {
30
+ throw new Error('The name "note" is reserved for trace and span notes. Use addTraceNote instead.');
31
+ }
32
+ const result = buildTraceAnnotationResult(annotation);
33
+ return {
34
+ trace_id: annotation.traceId.trim(),
35
+ name: annotation.name.trim(),
36
+ annotator_kind: (_a = annotation.annotatorKind) !== null && _a !== void 0 ? _a : "HUMAN",
37
+ result,
38
+ metadata: (_b = annotation.metadata) !== null && _b !== void 0 ? _b : null,
39
+ identifier: (_d = (_c = annotation.identifier) === null || _c === void 0 ? void 0 : _c.trim()) !== null && _d !== void 0 ? _d : "",
40
+ };
41
+ }
42
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/traces/types.ts"],"names":[],"mappings":";;AAqDA,sDAkBC;AAjDD;;GAEG;AACH,SAAS,0BAA0B,CACjC,UAAoE;IAEpE,MAAM,MAAM,GAAqB,EAAE,CAAC;IAEpC,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACnC,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC;IACjD,CAAC;IACD,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACnC,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;IAClC,CAAC;IACD,IAAI,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC;IAC7D,CAAC;IAED,MAAM,cAAc,GAClB,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,WAAW,CAAC;IACnE,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,oFAAoF,CACrF,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,SAAgB,qBAAqB,CACnC,UAA2B;;IAE3B,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,MAAM,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CACb,iFAAiF,CAClF,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,0BAA0B,CAAC,UAAU,CAAC,CAAC;IAEtD,OAAO;QACL,QAAQ,EAAE,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE;QACnC,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE;QAC5B,cAAc,EAAE,MAAA,UAAU,CAAC,aAAa,mCAAI,OAAO;QACnD,MAAM;QACN,QAAQ,EAAE,MAAA,UAAU,CAAC,QAAQ,mCAAI,IAAI;QACrC,UAAU,EAAE,MAAA,MAAA,UAAU,CAAC,UAAU,0CAAE,IAAI,EAAE,mCAAI,EAAE;KAChD,CAAC;AACJ,CAAC"}