@agent-os-sdk/client 0.9.7 → 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
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-os-sdk/client",
3
- "version": "0.9.7",
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",
@@ -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
  */