@agent-os-sdk/client 0.9.6 → 0.9.8

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.
@@ -39,6 +39,7 @@ export declare class HttpRequestBuilder {
39
39
  * @throws Error if requireFlow is true and correlationId is missing
40
40
  */
41
41
  build(opts: HttpRequestBuilderOptions): Record<string, string>;
42
+ private resolveCorrelationId;
42
43
  /**
43
44
  * Build User-Agent string with SDK version and runtime info
44
45
  */
@@ -1 +1 @@
1
- {"version":3,"file":"HttpRequestBuilder.d.ts","sourceRoot":"","sources":["../../src/client/HttpRequestBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAO9D;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACtC,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,wCAAwC;IACxC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kDAAkD;IAClD,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;GAGG;AACH,qBAAa,kBAAkB;IAC3B;;;;OAIG;IACH,KAAK,CAAC,IAAI,EAAE,yBAAyB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAmC9D;;OAEG;IACH,OAAO,CAAC,cAAc;CAYzB;AAGD,eAAO,MAAM,kBAAkB,oBAA2B,CAAC"}
1
+ {"version":3,"file":"HttpRequestBuilder.d.ts","sourceRoot":"","sources":["../../src/client/HttpRequestBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAQ9D;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACtC,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,wCAAwC;IACxC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kDAAkD;IAClD,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;GAGG;AACH,qBAAa,kBAAkB;IAC3B;;;;OAIG;IACH,KAAK,CAAC,IAAI,EAAE,yBAAyB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAiC9D,OAAO,CAAC,oBAAoB;IAS5B;;OAEG;IACH,OAAO,CAAC,cAAc;CAYzB;AAGD,eAAO,MAAM,kBAAkB,oBAA2B,CAAC"}
@@ -16,6 +16,7 @@
16
16
  */
17
17
  import { sanitizeHeader, sanitizeHeaders } from "./sanitize.js";
18
18
  const SDK_VERSION = typeof __SDK_VERSION__ !== "undefined" ? __SDK_VERSION__ : "0.7.12-dev";
19
+ const CORRELATION_ID_PATTERN = /^[A-Za-z0-9._:-]{8,128}$/;
19
20
  /**
20
21
  * Build headers for HTTP requests.
21
22
  * This is the SINGLE SOURCE OF TRUTH for header generation.
@@ -36,9 +37,7 @@ export class HttpRequestBuilder {
36
37
  if (opts.requireFlow && !opts.context?.correlationId) {
37
38
  throw new Error("X-Correlation-Id required for flow-scoped operations");
38
39
  }
39
- if (opts.context?.correlationId) {
40
- headers["X-Correlation-Id"] = opts.context.correlationId;
41
- }
40
+ headers["X-Correlation-Id"] = this.resolveCorrelationId(opts.context?.correlationId);
42
41
  // Authorization
43
42
  if (opts.token) {
44
43
  headers["Authorization"] = `Bearer ${opts.token}`;
@@ -53,6 +52,13 @@ export class HttpRequestBuilder {
53
52
  }
54
53
  return sanitizeHeaders(headers);
55
54
  }
55
+ resolveCorrelationId(raw) {
56
+ const candidate = sanitizeHeader((raw ?? "").trim());
57
+ if (CORRELATION_ID_PATTERN.test(candidate)) {
58
+ return candidate;
59
+ }
60
+ return crypto.randomUUID();
61
+ }
56
62
  /**
57
63
  * Build User-Agent string with SDK version and runtime info
58
64
  */
@@ -13,7 +13,7 @@ export class EvaluationModule {
13
13
  * List all evaluation datasets.
14
14
  */
15
15
  async listDatasets(params) {
16
- return this.client.GET("/v1/api/evaluation/datasets", {
16
+ return this.client.GET("/v1/api/evaluations/datasets", {
17
17
  params: { query: params },
18
18
  headers: this.headers(),
19
19
  });
@@ -22,7 +22,7 @@ export class EvaluationModule {
22
22
  * Get a dataset by ID.
23
23
  */
24
24
  async getDataset(datasetId) {
25
- return this.client.GET("/v1/api/evaluation/datasets/{id}", {
25
+ return this.client.GET("/v1/api/evaluations/datasets/{id}", {
26
26
  params: { path: { id: datasetId } },
27
27
  headers: this.headers(),
28
28
  });
@@ -31,7 +31,7 @@ export class EvaluationModule {
31
31
  * Create a new dataset.
32
32
  */
33
33
  async createDataset(body) {
34
- return this.client.POST("/v1/api/evaluation/datasets", {
34
+ return this.client.POST("/v1/api/evaluations/datasets", {
35
35
  body,
36
36
  headers: this.headers(),
37
37
  });
@@ -40,7 +40,7 @@ export class EvaluationModule {
40
40
  * Delete a dataset.
41
41
  */
42
42
  async deleteDataset(datasetId) {
43
- return this.client.DELETE("/v1/api/evaluation/datasets/{id}", {
43
+ return this.client.DELETE("/v1/api/evaluations/datasets/{id}", {
44
44
  params: { path: { id: datasetId } },
45
45
  headers: this.headers(),
46
46
  });
@@ -50,7 +50,7 @@ export class EvaluationModule {
50
50
  * List examples in a dataset.
51
51
  */
52
52
  async listExamples(datasetId, params) {
53
- return this.client.GET("/v1/api/evaluation/datasets/{id}/examples", {
53
+ return this.client.GET("/v1/api/evaluations/datasets/{id}/examples", {
54
54
  params: { path: { id: datasetId }, query: params },
55
55
  headers: this.headers(),
56
56
  });
@@ -59,7 +59,7 @@ export class EvaluationModule {
59
59
  * Add examples to a dataset.
60
60
  */
61
61
  async addExamples(datasetId, examples) {
62
- return this.client.POST("/v1/api/evaluation/datasets/{id}/examples", {
62
+ return this.client.POST("/v1/api/evaluations/datasets/{id}/examples", {
63
63
  params: { path: { id: datasetId } },
64
64
  body: { examples },
65
65
  headers: this.headers(),
@@ -70,7 +70,7 @@ export class EvaluationModule {
70
70
  * List all experiments.
71
71
  */
72
72
  async listExperiments(params) {
73
- return this.client.GET("/v1/api/evaluation/experiments", {
73
+ return this.client.GET("/v1/api/evaluations/experiments", {
74
74
  params: { query: params },
75
75
  headers: this.headers(),
76
76
  });
@@ -79,7 +79,7 @@ export class EvaluationModule {
79
79
  * Get an experiment by ID.
80
80
  */
81
81
  async getExperiment(experimentId) {
82
- return this.client.GET("/v1/api/evaluation/experiments/{id}", {
82
+ return this.client.GET("/v1/api/evaluations/experiments/{id}", {
83
83
  params: { path: { id: experimentId } },
84
84
  headers: this.headers(),
85
85
  });
@@ -88,7 +88,7 @@ export class EvaluationModule {
88
88
  * Create a new experiment.
89
89
  */
90
90
  async createExperiment(body) {
91
- return this.client.POST("/v1/api/evaluation/experiments", {
91
+ return this.client.POST("/v1/api/evaluations/experiments", {
92
92
  body,
93
93
  headers: this.headers(),
94
94
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-os-sdk/client",
3
- "version": "0.9.6",
3
+ "version": "0.9.8",
4
4
  "description": "Official TypeScript SDK for Agent OS platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -50,4 +50,4 @@
50
50
  "dist",
51
51
  "src"
52
52
  ]
53
- }
53
+ }
@@ -21,6 +21,7 @@ import { sanitizeHeader, sanitizeHeaders } from "./sanitize.js";
21
21
  // SDK version injected at build time, fallback for local dev
22
22
  declare const __SDK_VERSION__: string | undefined;
23
23
  const SDK_VERSION = typeof __SDK_VERSION__ !== "undefined" ? __SDK_VERSION__ : "0.7.12-dev";
24
+ const CORRELATION_ID_PATTERN = /^[A-Za-z0-9._:-]{8,128}$/;
24
25
 
25
26
  /**
26
27
  * Options for building request headers
@@ -59,9 +60,7 @@ export class HttpRequestBuilder {
59
60
  if (opts.requireFlow && !opts.context?.correlationId) {
60
61
  throw new Error("X-Correlation-Id required for flow-scoped operations");
61
62
  }
62
- if (opts.context?.correlationId) {
63
- headers["X-Correlation-Id"] = opts.context.correlationId;
64
- }
63
+ headers["X-Correlation-Id"] = this.resolveCorrelationId(opts.context?.correlationId);
65
64
 
66
65
  // Authorization
67
66
  if (opts.token) {
@@ -81,6 +80,15 @@ export class HttpRequestBuilder {
81
80
  return sanitizeHeaders(headers);
82
81
  }
83
82
 
83
+ private resolveCorrelationId(raw?: string): string {
84
+ const candidate = sanitizeHeader((raw ?? "").trim());
85
+ if (CORRELATION_ID_PATTERN.test(candidate)) {
86
+ return candidate;
87
+ }
88
+
89
+ return crypto.randomUUID();
90
+ }
91
+
84
92
  /**
85
93
  * Build User-Agent string with SDK version and runtime info
86
94
  */
@@ -77,7 +77,7 @@ export class EvaluationModule {
77
77
  limit?: number;
78
78
  offset?: number;
79
79
  }): Promise<APIResponse<DatasetListResponse>> {
80
- return this.client.GET<DatasetListResponse>("/v1/api/evaluation/datasets", {
80
+ return this.client.GET<DatasetListResponse>("/v1/api/evaluations/datasets", {
81
81
  params: { query: params },
82
82
  headers: this.headers(),
83
83
  });
@@ -87,7 +87,7 @@ export class EvaluationModule {
87
87
  * Get a dataset by ID.
88
88
  */
89
89
  async getDataset(datasetId: string): Promise<APIResponse<EvalDataset>> {
90
- return this.client.GET<EvalDataset>("/v1/api/evaluation/datasets/{id}", {
90
+ return this.client.GET<EvalDataset>("/v1/api/evaluations/datasets/{id}", {
91
91
  params: { path: { id: datasetId } },
92
92
  headers: this.headers(),
93
93
  });
@@ -101,7 +101,7 @@ export class EvaluationModule {
101
101
  description?: string;
102
102
  agent_id?: string;
103
103
  }): Promise<APIResponse<EvalDataset>> {
104
- return this.client.POST<EvalDataset>("/v1/api/evaluation/datasets", {
104
+ return this.client.POST<EvalDataset>("/v1/api/evaluations/datasets", {
105
105
  body,
106
106
  headers: this.headers(),
107
107
  });
@@ -111,7 +111,7 @@ export class EvaluationModule {
111
111
  * Delete a dataset.
112
112
  */
113
113
  async deleteDataset(datasetId: string): Promise<APIResponse<void>> {
114
- return this.client.DELETE<void>("/v1/api/evaluation/datasets/{id}", {
114
+ return this.client.DELETE<void>("/v1/api/evaluations/datasets/{id}", {
115
115
  params: { path: { id: datasetId } },
116
116
  headers: this.headers(),
117
117
  });
@@ -126,7 +126,7 @@ export class EvaluationModule {
126
126
  limit?: number;
127
127
  offset?: number;
128
128
  }): Promise<APIResponse<ExamplesListResponse>> {
129
- return this.client.GET<ExamplesListResponse>("/v1/api/evaluation/datasets/{id}/examples", {
129
+ return this.client.GET<ExamplesListResponse>("/v1/api/evaluations/datasets/{id}/examples", {
130
130
  params: { path: { id: datasetId }, query: params },
131
131
  headers: this.headers(),
132
132
  });
@@ -136,7 +136,7 @@ export class EvaluationModule {
136
136
  * Add examples to a dataset.
137
137
  */
138
138
  async addExamples(datasetId: string, examples: ExampleData[]): Promise<APIResponse<void>> {
139
- return this.client.POST<void>("/v1/api/evaluation/datasets/{id}/examples", {
139
+ return this.client.POST<void>("/v1/api/evaluations/datasets/{id}/examples", {
140
140
  params: { path: { id: datasetId } },
141
141
  body: { examples },
142
142
  headers: this.headers(),
@@ -155,7 +155,7 @@ export class EvaluationModule {
155
155
  limit?: number;
156
156
  offset?: number;
157
157
  }): Promise<APIResponse<ExperimentListResponse>> {
158
- return this.client.GET<ExperimentListResponse>("/v1/api/evaluation/experiments", {
158
+ return this.client.GET<ExperimentListResponse>("/v1/api/evaluations/experiments", {
159
159
  params: { query: params },
160
160
  headers: this.headers(),
161
161
  });
@@ -165,7 +165,7 @@ export class EvaluationModule {
165
165
  * Get an experiment by ID.
166
166
  */
167
167
  async getExperiment(experimentId: string): Promise<APIResponse<Experiment>> {
168
- return this.client.GET<Experiment>("/v1/api/evaluation/experiments/{id}", {
168
+ return this.client.GET<Experiment>("/v1/api/evaluations/experiments/{id}", {
169
169
  params: { path: { id: experimentId } },
170
170
  headers: this.headers(),
171
171
  });
@@ -181,7 +181,7 @@ export class EvaluationModule {
181
181
  name?: string;
182
182
  config?: Record<string, unknown>;
183
183
  }): Promise<APIResponse<Experiment>> {
184
- return this.client.POST<Experiment>("/v1/api/evaluation/experiments", {
184
+ return this.client.POST<Experiment>("/v1/api/evaluations/experiments", {
185
185
  body,
186
186
  headers: this.headers(),
187
187
  });