@agent-api/sdk 1.3.1 → 1.3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog — @agent-api/sdk
2
2
 
3
+ ## 1.3.2
4
+
5
+ ### Added
6
+
7
+ - Added volume image asset helpers for normalizing private volume paths and checking supported image paths/content types.
8
+
3
9
  ## 1.3.1
4
10
 
5
11
  ### Fixed
package/dist/index.d.ts CHANGED
@@ -6,5 +6,6 @@ export * from "./types/index.js";
6
6
  export { functionCallOutputInput, pendingFunctionCalls, runLocalFunctionHandlers, } from "./local-functions.js";
7
7
  export type { LocalFunctionHandler, LocalFunctionHandlers } from "./local-functions.js";
8
8
  export { mergeTools, publicToolToRequestTool, resolvePresetTools, resolvePresetToolsFromCatalog, } from "./preset-tools.js";
9
+ export { isSupportedVolumeImageContentType, isSupportedVolumeImagePath, normalizeVolumeAssetPath, } from "./volume-assets.js";
9
10
  export type { PresetToolCatalogClient, ResolvePresetToolsOptions, ResolvePresetToolsResult, UnknownPresetToolBehavior, } from "./preset-tools.js";
10
11
  export { AuthResource, DeviceAuthFlowError, browserAuthSessionExpiresWithin } from "./resources/auth.js";
package/dist/index.js CHANGED
@@ -4,4 +4,5 @@ export { APIError, APIConnectionError, APIStatusError, AuthenticationError, BadR
4
4
  export * from "./types/index.js";
5
5
  export { functionCallOutputInput, pendingFunctionCalls, runLocalFunctionHandlers, } from "./local-functions.js";
6
6
  export { mergeTools, publicToolToRequestTool, resolvePresetTools, resolvePresetToolsFromCatalog, } from "./preset-tools.js";
7
+ export { isSupportedVolumeImageContentType, isSupportedVolumeImagePath, normalizeVolumeAssetPath, } from "./volume-assets.js";
7
8
  export { AuthResource, DeviceAuthFlowError, browserAuthSessionExpiresWithin } from "./resources/auth.js";
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.3.1";
2
- export declare const USER_AGENT = "@agent-api/sdk/1.3.1";
1
+ export declare const VERSION = "1.3.2";
2
+ export declare const USER_AGENT = "@agent-api/sdk/1.3.2";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = "1.3.1";
1
+ export const VERSION = "1.3.2";
2
2
  export const USER_AGENT = `@agent-api/sdk/${VERSION}`;
@@ -0,0 +1,3 @@
1
+ export declare function normalizeVolumeAssetPath(src: string | null | undefined): string;
2
+ export declare function isSupportedVolumeImagePath(src: string | null | undefined): boolean;
3
+ export declare function isSupportedVolumeImageContentType(contentType: string | null | undefined): boolean;
@@ -0,0 +1,37 @@
1
+ const SUPPORTED_VOLUME_IMAGE_EXTENSIONS = new Set([
2
+ ".avif",
3
+ ".bmp",
4
+ ".gif",
5
+ ".jpeg",
6
+ ".jpg",
7
+ ".png",
8
+ ".svg",
9
+ ".webp",
10
+ ]);
11
+ export function normalizeVolumeAssetPath(src) {
12
+ const value = src?.trim() ?? "";
13
+ if (!value)
14
+ return "";
15
+ if (isExternalAssetTarget(value))
16
+ return "";
17
+ let path = value.split("#", 1)[0]?.split("?", 1)[0]?.trim() ?? "";
18
+ path = path.replace(/^\/agent-volume\/+/i, "");
19
+ path = path.replace(/^\/+/, "");
20
+ path = path.replace(/\/+/g, "/");
21
+ if (!path || path === "." || path.includes(".."))
22
+ return "";
23
+ return path;
24
+ }
25
+ export function isSupportedVolumeImagePath(src) {
26
+ const path = normalizeVolumeAssetPath(src).toLowerCase();
27
+ if (!path)
28
+ return false;
29
+ const dot = path.lastIndexOf(".");
30
+ return dot >= 0 && SUPPORTED_VOLUME_IMAGE_EXTENSIONS.has(path.slice(dot));
31
+ }
32
+ export function isSupportedVolumeImageContentType(contentType) {
33
+ return (contentType ?? "").split(";", 1)[0]?.trim().toLowerCase().startsWith("image/") ?? false;
34
+ }
35
+ function isExternalAssetTarget(src) {
36
+ return /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(src);
37
+ }
package/dist-cjs/index.js CHANGED
@@ -14,7 +14,7 @@ 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
- exports.browserAuthSessionExpiresWithin = exports.DeviceAuthFlowError = exports.AuthResource = exports.resolvePresetToolsFromCatalog = exports.resolvePresetTools = exports.publicToolToRequestTool = exports.mergeTools = exports.runLocalFunctionHandlers = exports.pendingFunctionCalls = exports.functionCallOutputInput = exports.parseResponseError = exports.isRetryableStatus = exports.RateLimitError = exports.PermissionDeniedError = exports.NotFoundError = exports.InternalServerError = exports.BadRequestError = exports.AuthenticationError = exports.APIStatusError = exports.APIConnectionError = exports.APIError = exports.collectPage = exports.Page = exports.VERSION = exports.DEFAULT_TIMEOUT_MS = exports.DEFAULT_STREAM_TIMEOUT_MS = exports.DEFAULT_MAX_RETRIES = exports.AgentAPI = void 0;
17
+ exports.browserAuthSessionExpiresWithin = exports.DeviceAuthFlowError = exports.AuthResource = exports.normalizeVolumeAssetPath = exports.isSupportedVolumeImagePath = exports.isSupportedVolumeImageContentType = exports.resolvePresetToolsFromCatalog = exports.resolvePresetTools = exports.publicToolToRequestTool = exports.mergeTools = exports.runLocalFunctionHandlers = exports.pendingFunctionCalls = exports.functionCallOutputInput = exports.parseResponseError = exports.isRetryableStatus = exports.RateLimitError = exports.PermissionDeniedError = exports.NotFoundError = exports.InternalServerError = exports.BadRequestError = exports.AuthenticationError = exports.APIStatusError = exports.APIConnectionError = exports.APIError = exports.collectPage = exports.Page = exports.VERSION = exports.DEFAULT_TIMEOUT_MS = exports.DEFAULT_STREAM_TIMEOUT_MS = exports.DEFAULT_MAX_RETRIES = exports.AgentAPI = void 0;
18
18
  var client_js_1 = require("./client.js");
19
19
  Object.defineProperty(exports, "AgentAPI", { enumerable: true, get: function () { return client_js_1.AgentAPI; } });
20
20
  Object.defineProperty(exports, "DEFAULT_MAX_RETRIES", { enumerable: true, get: function () { return client_js_1.DEFAULT_MAX_RETRIES; } });
@@ -46,6 +46,10 @@ Object.defineProperty(exports, "mergeTools", { enumerable: true, get: function (
46
46
  Object.defineProperty(exports, "publicToolToRequestTool", { enumerable: true, get: function () { return preset_tools_js_1.publicToolToRequestTool; } });
47
47
  Object.defineProperty(exports, "resolvePresetTools", { enumerable: true, get: function () { return preset_tools_js_1.resolvePresetTools; } });
48
48
  Object.defineProperty(exports, "resolvePresetToolsFromCatalog", { enumerable: true, get: function () { return preset_tools_js_1.resolvePresetToolsFromCatalog; } });
49
+ var volume_assets_js_1 = require("./volume-assets.js");
50
+ Object.defineProperty(exports, "isSupportedVolumeImageContentType", { enumerable: true, get: function () { return volume_assets_js_1.isSupportedVolumeImageContentType; } });
51
+ Object.defineProperty(exports, "isSupportedVolumeImagePath", { enumerable: true, get: function () { return volume_assets_js_1.isSupportedVolumeImagePath; } });
52
+ Object.defineProperty(exports, "normalizeVolumeAssetPath", { enumerable: true, get: function () { return volume_assets_js_1.normalizeVolumeAssetPath; } });
49
53
  var auth_js_1 = require("./resources/auth.js");
50
54
  Object.defineProperty(exports, "AuthResource", { enumerable: true, get: function () { return auth_js_1.AuthResource; } });
51
55
  Object.defineProperty(exports, "DeviceAuthFlowError", { enumerable: true, get: function () { return auth_js_1.DeviceAuthFlowError; } });
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.USER_AGENT = exports.VERSION = void 0;
4
- exports.VERSION = "1.3.1";
4
+ exports.VERSION = "1.3.2";
5
5
  exports.USER_AGENT = `@agent-api/sdk/${exports.VERSION}`;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeVolumeAssetPath = normalizeVolumeAssetPath;
4
+ exports.isSupportedVolumeImagePath = isSupportedVolumeImagePath;
5
+ exports.isSupportedVolumeImageContentType = isSupportedVolumeImageContentType;
6
+ const SUPPORTED_VOLUME_IMAGE_EXTENSIONS = new Set([
7
+ ".avif",
8
+ ".bmp",
9
+ ".gif",
10
+ ".jpeg",
11
+ ".jpg",
12
+ ".png",
13
+ ".svg",
14
+ ".webp",
15
+ ]);
16
+ function normalizeVolumeAssetPath(src) {
17
+ const value = src?.trim() ?? "";
18
+ if (!value)
19
+ return "";
20
+ if (isExternalAssetTarget(value))
21
+ return "";
22
+ let path = value.split("#", 1)[0]?.split("?", 1)[0]?.trim() ?? "";
23
+ path = path.replace(/^\/agent-volume\/+/i, "");
24
+ path = path.replace(/^\/+/, "");
25
+ path = path.replace(/\/+/g, "/");
26
+ if (!path || path === "." || path.includes(".."))
27
+ return "";
28
+ return path;
29
+ }
30
+ function isSupportedVolumeImagePath(src) {
31
+ const path = normalizeVolumeAssetPath(src).toLowerCase();
32
+ if (!path)
33
+ return false;
34
+ const dot = path.lastIndexOf(".");
35
+ return dot >= 0 && SUPPORTED_VOLUME_IMAGE_EXTENSIONS.has(path.slice(dot));
36
+ }
37
+ function isSupportedVolumeImageContentType(contentType) {
38
+ return (contentType ?? "").split(";", 1)[0]?.trim().toLowerCase().startsWith("image/") ?? false;
39
+ }
40
+ function isExternalAssetTarget(src) {
41
+ return /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(src);
42
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-api/sdk",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Production JavaScript SDK for the Managed Agent API",
5
5
  "license": "MIT",
6
6
  "repository": {