@topolo/sdk 0.11.7 → 0.11.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.
package/dist/index.cjs CHANGED
@@ -59,6 +59,7 @@ __export(index_exports, {
59
59
  defineTopoloRecentActivityWidget: () => defineTopoloRecentActivityWidget,
60
60
  defineTopoloStatsWidget: () => defineTopoloStatsWidget,
61
61
  digestTopoloActionCatalog: () => digestTopoloActionCatalog,
62
+ encodeTopoloActionBase64: () => encodeTopoloActionBase64,
62
63
  enrichActionContract: () => enrichActionContract,
63
64
  extractTopoloServiceErrorCode: () => extractTopoloServiceErrorCode,
64
65
  extractTopoloServiceErrorDetails: () => extractTopoloServiceErrorDetails,
@@ -938,7 +939,7 @@ function prepareTopoloActionUploadInput(contractValue, content, input, options)
938
939
  if (bytes.byteLength > contract.maxBytes) {
939
940
  throw new TopoloSdkError("upload_too_large", `Upload content exceeds the ${contract.maxBytes}-byte action limit.`);
940
941
  }
941
- return mapUploadInput(contract, bytesToBase64(bytes), input, options);
942
+ return mapUploadInput(contract, encodeTopoloActionBase64(bytes), input, options);
942
943
  }
943
944
  function prepareTopoloActionBase64UploadInput(contractValue, contentBase64, input, options) {
944
945
  const contract = parseTopoloActionUploadContract(contractValue);
@@ -1074,7 +1075,7 @@ function requiredField(value, name) {
1074
1075
  function matchesContentType(contentType, accepted) {
1075
1076
  return accepted.some((candidate) => candidate === "*/*" || candidate === contentType || candidate.endsWith("/*") && contentType.startsWith(candidate.slice(0, -1)));
1076
1077
  }
1077
- function bytesToBase64(bytes) {
1078
+ function encodeTopoloActionBase64(bytes) {
1078
1079
  let binary = "";
1079
1080
  const chunkSize = 32768;
1080
1081
  for (let offset = 0; offset < bytes.length; offset += chunkSize) {
@@ -1253,7 +1254,20 @@ var TopoloClient = class _TopoloClient {
1253
1254
  throw err;
1254
1255
  }
1255
1256
  const contentType = res.headers.get("Content-Type") ?? "";
1256
- const parsed = contentType.includes("application/json") ? await res.json().catch(() => null) : await res.text().catch(() => null);
1257
+ const normalizedContentType = contentType.split(";", 1)[0]?.trim().toLowerCase() ?? "";
1258
+ let parsed;
1259
+ if (normalizedContentType === "application/json" || normalizedContentType.endsWith("+json")) {
1260
+ parsed = await res.json().catch(() => null);
1261
+ } else if (!res.ok || !normalizedContentType || normalizedContentType.startsWith("text/")) {
1262
+ parsed = await res.text().catch(() => null);
1263
+ } else {
1264
+ const bytes = new Uint8Array(await res.arrayBuffer());
1265
+ parsed = {
1266
+ contentType: normalizedContentType,
1267
+ contentLength: bytes.byteLength,
1268
+ contentBase64: encodeTopoloActionBase64(bytes)
1269
+ };
1270
+ }
1257
1271
  if (!res.ok) {
1258
1272
  const durationMs = Date.now() - startedAt;
1259
1273
  const message = describeError(parsed, `HTTP ${res.status}`);
@@ -3448,6 +3462,7 @@ function createTopolo(options) {
3448
3462
  defineTopoloRecentActivityWidget,
3449
3463
  defineTopoloStatsWidget,
3450
3464
  digestTopoloActionCatalog,
3465
+ encodeTopoloActionBase64,
3451
3466
  enrichActionContract,
3452
3467
  extractTopoloServiceErrorCode,
3453
3468
  extractTopoloServiceErrorDetails,
package/dist/index.d.cts CHANGED
@@ -80,6 +80,7 @@ interface TopoloActionUploadOptions {
80
80
  declare function parseTopoloActionUploadContract(value: unknown): TopoloActionUploadContract;
81
81
  declare function prepareTopoloActionUploadInput(contractValue: unknown, content: Uint8Array | ArrayBuffer, input: Record<string, unknown>, options: TopoloActionUploadOptions): Record<string, unknown>;
82
82
  declare function prepareTopoloActionBase64UploadInput(contractValue: unknown, contentBase64: string, input: Record<string, unknown>, options: TopoloActionUploadOptions): Record<string, unknown>;
83
+ declare function encodeTopoloActionBase64(bytes: Uint8Array): string;
83
84
 
84
85
  interface TopoloClientOptions {
85
86
  credential: TopoloCredential;
@@ -167,6 +168,11 @@ interface RequestOptions {
167
168
  headers?: Record<string, string>;
168
169
  signal?: AbortSignal;
169
170
  }
171
+ interface TopoloBinaryResponse {
172
+ contentType: string;
173
+ contentLength: number;
174
+ contentBase64: string;
175
+ }
170
176
  /**
171
177
  * A single entry from the live platform service catalog. Returned by
172
178
  * {@link TopoloClient.listServices}. Shape mirrors the public-safe projection
@@ -1380,4 +1386,4 @@ declare function createTopolo(options: TopoloClientOptions): {
1380
1386
  };
1381
1387
  type Topolo = ReturnType<typeof createTopolo>;
1382
1388
 
1383
- export { ACTION_CATALOG_DIGEST_ALGORITHM, type ActionContractManifest, type ActionContractSource, type AgentIdentity, type AppApiId, type ApplicationCatalogEntry, type ApplicationDeployTarget, type ApplicationDirectory, type ApplicationDirectoryApplication, type ApplicationDirectoryClient, type ApplicationDirectorySource, type ApplicationId, type CredentialIntrospection, type CrmContactSummary, CrmModule, DEFAULT_APP_URLS, type DeviceAuthorizationResponse, IdentityModule, type ListContactsOptions, type ListContactsResult, type OAuthHelperOptions, type P2PActionDetail, type P2PActionRequestInput, type P2PActionRequestResult, type P2PActionRow, type P2PActionRun, type P2PCapability, type P2PConnection, type P2PHold, type P2PLedgerEntry, P2PModule, type P2PPolicy, type P2PPricingModel, type P2PSettlementBatch, type P2PSettlementGroup, type PublishCapabilityInput, type RequestOptions, type ServiceCatalogUrlEntry, TOPOLO_ENVIRONMENT_SERVICE_URLS, TOPOLO_RUNTIME_ENVIRONMENTS, TOPOLO_WIDGET_ENDPOINT, TOPOLO_WIDGET_REFRESH_INTERVAL_MS, type TokenResponse, type Topolo, type TopoloActionAgentContract, type TopoloActionCatalogEntry, type TopoloActionCatalogSummary, type TopoloActionDigestInput, type TopoloActionPlan, type TopoloActionPreparation, type TopoloActionUploadOptions, type TopoloActionValidationIssue, type TopoloActionValidationResult, type TopoloAgentExecutionContext, type TopoloApiKeyResourceMetadata, TopoloAuthError, type TopoloBindableResource, type TopoloBindableResourceCatalog, type TopoloChartWidget, TopoloClient, type TopoloClientOptions, TopoloConfirmationRequiredError, type TopoloCredential, type TopoloDebugEvent, TopoloHttpError, type TopoloInlineBase64UploadContract, type TopoloNotificationsWidget, TopoloOAuth, TopoloPermissionError, type TopoloQuickActionsWidget, type TopoloRecentActivityWidget, type TopoloRuntimeEnvironment, TopoloSdkError, type TopoloServiceCatalogEntry, type TopoloStatsWidget, type TopoloWidget, type TopoloWidgetActionItem, type TopoloWidgetActivityItem, type TopoloWidgetApiResponse, type TopoloWidgetBase, type TopoloWidgetConfig, type TopoloWidgetDraft, type TopoloWidgetMetric, type TopoloWidgetNotificationItem, type TopoloWidgetResponseOptions, type TopoloWidgetSnapshotMetadata, type TopoloWidgetSnapshotMetric, type TopoloWidgetType, type TopoloWidgetValidationResult, type TopoloWorkspace, type TopoloWorkspaceListResult, type TopoloWorkspaceMutationResult, type TopoloWorkspacePolicy, WorkspacesModule, actionContractCompleteness, applicationEntryFromCatalog, assertTopoloServiceUrlEnvironment, canonicalTopoloErrorCode, canonicalTopoloRequestId, canonicalTopoloRequired, canonicalTopoloRetryAfter, compactActionCatalogEntry, compactActionPlan, compactActionPreparation, compactActionResult, compactActionValidation, createTopolo, createTopoloAgentExecutionContext, createTopoloWidgetError, createTopoloWidgetResponse, defineTopoloChartWidget, defineTopoloNotificationsWidget, defineTopoloQuickActionsWidget, defineTopoloRecentActivityWidget, defineTopoloStatsWidget, digestTopoloActionCatalog, enrichActionContract, extractTopoloServiceErrorCode, extractTopoloServiceErrorDetails, formatDirectoryApplicationIds, friendlyAppId, listApplicationDirectory, parseTopoloActionUploadContract, preferExactActionMatches, prepareTopoloActionBase64UploadInput, prepareTopoloActionUploadInput, publicTopoloErrorMessage, resolveApplicationDirectoryEntry, resolveCatalogServiceUrl, resolveServiceUrl, topoloErrorHint, topoloServiceOrigins, validateTopoloActionInput, validateTopoloWidgetResponse };
1389
+ export { ACTION_CATALOG_DIGEST_ALGORITHM, type ActionContractManifest, type ActionContractSource, type AgentIdentity, type AppApiId, type ApplicationCatalogEntry, type ApplicationDeployTarget, type ApplicationDirectory, type ApplicationDirectoryApplication, type ApplicationDirectoryClient, type ApplicationDirectorySource, type ApplicationId, type CredentialIntrospection, type CrmContactSummary, CrmModule, DEFAULT_APP_URLS, type DeviceAuthorizationResponse, IdentityModule, type ListContactsOptions, type ListContactsResult, type OAuthHelperOptions, type P2PActionDetail, type P2PActionRequestInput, type P2PActionRequestResult, type P2PActionRow, type P2PActionRun, type P2PCapability, type P2PConnection, type P2PHold, type P2PLedgerEntry, P2PModule, type P2PPolicy, type P2PPricingModel, type P2PSettlementBatch, type P2PSettlementGroup, type PublishCapabilityInput, type RequestOptions, type ServiceCatalogUrlEntry, TOPOLO_ENVIRONMENT_SERVICE_URLS, TOPOLO_RUNTIME_ENVIRONMENTS, TOPOLO_WIDGET_ENDPOINT, TOPOLO_WIDGET_REFRESH_INTERVAL_MS, type TokenResponse, type Topolo, type TopoloActionAgentContract, type TopoloActionCatalogEntry, type TopoloActionCatalogSummary, type TopoloActionDigestInput, type TopoloActionPlan, type TopoloActionPreparation, type TopoloActionUploadOptions, type TopoloActionValidationIssue, type TopoloActionValidationResult, type TopoloAgentExecutionContext, type TopoloApiKeyResourceMetadata, TopoloAuthError, type TopoloBinaryResponse, type TopoloBindableResource, type TopoloBindableResourceCatalog, type TopoloChartWidget, TopoloClient, type TopoloClientOptions, TopoloConfirmationRequiredError, type TopoloCredential, type TopoloDebugEvent, TopoloHttpError, type TopoloInlineBase64UploadContract, type TopoloNotificationsWidget, TopoloOAuth, TopoloPermissionError, type TopoloQuickActionsWidget, type TopoloRecentActivityWidget, type TopoloRuntimeEnvironment, TopoloSdkError, type TopoloServiceCatalogEntry, type TopoloStatsWidget, type TopoloWidget, type TopoloWidgetActionItem, type TopoloWidgetActivityItem, type TopoloWidgetApiResponse, type TopoloWidgetBase, type TopoloWidgetConfig, type TopoloWidgetDraft, type TopoloWidgetMetric, type TopoloWidgetNotificationItem, type TopoloWidgetResponseOptions, type TopoloWidgetSnapshotMetadata, type TopoloWidgetSnapshotMetric, type TopoloWidgetType, type TopoloWidgetValidationResult, type TopoloWorkspace, type TopoloWorkspaceListResult, type TopoloWorkspaceMutationResult, type TopoloWorkspacePolicy, WorkspacesModule, actionContractCompleteness, applicationEntryFromCatalog, assertTopoloServiceUrlEnvironment, canonicalTopoloErrorCode, canonicalTopoloRequestId, canonicalTopoloRequired, canonicalTopoloRetryAfter, compactActionCatalogEntry, compactActionPlan, compactActionPreparation, compactActionResult, compactActionValidation, createTopolo, createTopoloAgentExecutionContext, createTopoloWidgetError, createTopoloWidgetResponse, defineTopoloChartWidget, defineTopoloNotificationsWidget, defineTopoloQuickActionsWidget, defineTopoloRecentActivityWidget, defineTopoloStatsWidget, digestTopoloActionCatalog, encodeTopoloActionBase64, enrichActionContract, extractTopoloServiceErrorCode, extractTopoloServiceErrorDetails, formatDirectoryApplicationIds, friendlyAppId, listApplicationDirectory, parseTopoloActionUploadContract, preferExactActionMatches, prepareTopoloActionBase64UploadInput, prepareTopoloActionUploadInput, publicTopoloErrorMessage, resolveApplicationDirectoryEntry, resolveCatalogServiceUrl, resolveServiceUrl, topoloErrorHint, topoloServiceOrigins, validateTopoloActionInput, validateTopoloWidgetResponse };
package/dist/index.d.ts CHANGED
@@ -80,6 +80,7 @@ interface TopoloActionUploadOptions {
80
80
  declare function parseTopoloActionUploadContract(value: unknown): TopoloActionUploadContract;
81
81
  declare function prepareTopoloActionUploadInput(contractValue: unknown, content: Uint8Array | ArrayBuffer, input: Record<string, unknown>, options: TopoloActionUploadOptions): Record<string, unknown>;
82
82
  declare function prepareTopoloActionBase64UploadInput(contractValue: unknown, contentBase64: string, input: Record<string, unknown>, options: TopoloActionUploadOptions): Record<string, unknown>;
83
+ declare function encodeTopoloActionBase64(bytes: Uint8Array): string;
83
84
 
84
85
  interface TopoloClientOptions {
85
86
  credential: TopoloCredential;
@@ -167,6 +168,11 @@ interface RequestOptions {
167
168
  headers?: Record<string, string>;
168
169
  signal?: AbortSignal;
169
170
  }
171
+ interface TopoloBinaryResponse {
172
+ contentType: string;
173
+ contentLength: number;
174
+ contentBase64: string;
175
+ }
170
176
  /**
171
177
  * A single entry from the live platform service catalog. Returned by
172
178
  * {@link TopoloClient.listServices}. Shape mirrors the public-safe projection
@@ -1380,4 +1386,4 @@ declare function createTopolo(options: TopoloClientOptions): {
1380
1386
  };
1381
1387
  type Topolo = ReturnType<typeof createTopolo>;
1382
1388
 
1383
- export { ACTION_CATALOG_DIGEST_ALGORITHM, type ActionContractManifest, type ActionContractSource, type AgentIdentity, type AppApiId, type ApplicationCatalogEntry, type ApplicationDeployTarget, type ApplicationDirectory, type ApplicationDirectoryApplication, type ApplicationDirectoryClient, type ApplicationDirectorySource, type ApplicationId, type CredentialIntrospection, type CrmContactSummary, CrmModule, DEFAULT_APP_URLS, type DeviceAuthorizationResponse, IdentityModule, type ListContactsOptions, type ListContactsResult, type OAuthHelperOptions, type P2PActionDetail, type P2PActionRequestInput, type P2PActionRequestResult, type P2PActionRow, type P2PActionRun, type P2PCapability, type P2PConnection, type P2PHold, type P2PLedgerEntry, P2PModule, type P2PPolicy, type P2PPricingModel, type P2PSettlementBatch, type P2PSettlementGroup, type PublishCapabilityInput, type RequestOptions, type ServiceCatalogUrlEntry, TOPOLO_ENVIRONMENT_SERVICE_URLS, TOPOLO_RUNTIME_ENVIRONMENTS, TOPOLO_WIDGET_ENDPOINT, TOPOLO_WIDGET_REFRESH_INTERVAL_MS, type TokenResponse, type Topolo, type TopoloActionAgentContract, type TopoloActionCatalogEntry, type TopoloActionCatalogSummary, type TopoloActionDigestInput, type TopoloActionPlan, type TopoloActionPreparation, type TopoloActionUploadOptions, type TopoloActionValidationIssue, type TopoloActionValidationResult, type TopoloAgentExecutionContext, type TopoloApiKeyResourceMetadata, TopoloAuthError, type TopoloBindableResource, type TopoloBindableResourceCatalog, type TopoloChartWidget, TopoloClient, type TopoloClientOptions, TopoloConfirmationRequiredError, type TopoloCredential, type TopoloDebugEvent, TopoloHttpError, type TopoloInlineBase64UploadContract, type TopoloNotificationsWidget, TopoloOAuth, TopoloPermissionError, type TopoloQuickActionsWidget, type TopoloRecentActivityWidget, type TopoloRuntimeEnvironment, TopoloSdkError, type TopoloServiceCatalogEntry, type TopoloStatsWidget, type TopoloWidget, type TopoloWidgetActionItem, type TopoloWidgetActivityItem, type TopoloWidgetApiResponse, type TopoloWidgetBase, type TopoloWidgetConfig, type TopoloWidgetDraft, type TopoloWidgetMetric, type TopoloWidgetNotificationItem, type TopoloWidgetResponseOptions, type TopoloWidgetSnapshotMetadata, type TopoloWidgetSnapshotMetric, type TopoloWidgetType, type TopoloWidgetValidationResult, type TopoloWorkspace, type TopoloWorkspaceListResult, type TopoloWorkspaceMutationResult, type TopoloWorkspacePolicy, WorkspacesModule, actionContractCompleteness, applicationEntryFromCatalog, assertTopoloServiceUrlEnvironment, canonicalTopoloErrorCode, canonicalTopoloRequestId, canonicalTopoloRequired, canonicalTopoloRetryAfter, compactActionCatalogEntry, compactActionPlan, compactActionPreparation, compactActionResult, compactActionValidation, createTopolo, createTopoloAgentExecutionContext, createTopoloWidgetError, createTopoloWidgetResponse, defineTopoloChartWidget, defineTopoloNotificationsWidget, defineTopoloQuickActionsWidget, defineTopoloRecentActivityWidget, defineTopoloStatsWidget, digestTopoloActionCatalog, enrichActionContract, extractTopoloServiceErrorCode, extractTopoloServiceErrorDetails, formatDirectoryApplicationIds, friendlyAppId, listApplicationDirectory, parseTopoloActionUploadContract, preferExactActionMatches, prepareTopoloActionBase64UploadInput, prepareTopoloActionUploadInput, publicTopoloErrorMessage, resolveApplicationDirectoryEntry, resolveCatalogServiceUrl, resolveServiceUrl, topoloErrorHint, topoloServiceOrigins, validateTopoloActionInput, validateTopoloWidgetResponse };
1389
+ export { ACTION_CATALOG_DIGEST_ALGORITHM, type ActionContractManifest, type ActionContractSource, type AgentIdentity, type AppApiId, type ApplicationCatalogEntry, type ApplicationDeployTarget, type ApplicationDirectory, type ApplicationDirectoryApplication, type ApplicationDirectoryClient, type ApplicationDirectorySource, type ApplicationId, type CredentialIntrospection, type CrmContactSummary, CrmModule, DEFAULT_APP_URLS, type DeviceAuthorizationResponse, IdentityModule, type ListContactsOptions, type ListContactsResult, type OAuthHelperOptions, type P2PActionDetail, type P2PActionRequestInput, type P2PActionRequestResult, type P2PActionRow, type P2PActionRun, type P2PCapability, type P2PConnection, type P2PHold, type P2PLedgerEntry, P2PModule, type P2PPolicy, type P2PPricingModel, type P2PSettlementBatch, type P2PSettlementGroup, type PublishCapabilityInput, type RequestOptions, type ServiceCatalogUrlEntry, TOPOLO_ENVIRONMENT_SERVICE_URLS, TOPOLO_RUNTIME_ENVIRONMENTS, TOPOLO_WIDGET_ENDPOINT, TOPOLO_WIDGET_REFRESH_INTERVAL_MS, type TokenResponse, type Topolo, type TopoloActionAgentContract, type TopoloActionCatalogEntry, type TopoloActionCatalogSummary, type TopoloActionDigestInput, type TopoloActionPlan, type TopoloActionPreparation, type TopoloActionUploadOptions, type TopoloActionValidationIssue, type TopoloActionValidationResult, type TopoloAgentExecutionContext, type TopoloApiKeyResourceMetadata, TopoloAuthError, type TopoloBinaryResponse, type TopoloBindableResource, type TopoloBindableResourceCatalog, type TopoloChartWidget, TopoloClient, type TopoloClientOptions, TopoloConfirmationRequiredError, type TopoloCredential, type TopoloDebugEvent, TopoloHttpError, type TopoloInlineBase64UploadContract, type TopoloNotificationsWidget, TopoloOAuth, TopoloPermissionError, type TopoloQuickActionsWidget, type TopoloRecentActivityWidget, type TopoloRuntimeEnvironment, TopoloSdkError, type TopoloServiceCatalogEntry, type TopoloStatsWidget, type TopoloWidget, type TopoloWidgetActionItem, type TopoloWidgetActivityItem, type TopoloWidgetApiResponse, type TopoloWidgetBase, type TopoloWidgetConfig, type TopoloWidgetDraft, type TopoloWidgetMetric, type TopoloWidgetNotificationItem, type TopoloWidgetResponseOptions, type TopoloWidgetSnapshotMetadata, type TopoloWidgetSnapshotMetric, type TopoloWidgetType, type TopoloWidgetValidationResult, type TopoloWorkspace, type TopoloWorkspaceListResult, type TopoloWorkspaceMutationResult, type TopoloWorkspacePolicy, WorkspacesModule, actionContractCompleteness, applicationEntryFromCatalog, assertTopoloServiceUrlEnvironment, canonicalTopoloErrorCode, canonicalTopoloRequestId, canonicalTopoloRequired, canonicalTopoloRetryAfter, compactActionCatalogEntry, compactActionPlan, compactActionPreparation, compactActionResult, compactActionValidation, createTopolo, createTopoloAgentExecutionContext, createTopoloWidgetError, createTopoloWidgetResponse, defineTopoloChartWidget, defineTopoloNotificationsWidget, defineTopoloQuickActionsWidget, defineTopoloRecentActivityWidget, defineTopoloStatsWidget, digestTopoloActionCatalog, encodeTopoloActionBase64, enrichActionContract, extractTopoloServiceErrorCode, extractTopoloServiceErrorDetails, formatDirectoryApplicationIds, friendlyAppId, listApplicationDirectory, parseTopoloActionUploadContract, preferExactActionMatches, prepareTopoloActionBase64UploadInput, prepareTopoloActionUploadInput, publicTopoloErrorMessage, resolveApplicationDirectoryEntry, resolveCatalogServiceUrl, resolveServiceUrl, topoloErrorHint, topoloServiceOrigins, validateTopoloActionInput, validateTopoloWidgetResponse };
package/dist/index.js CHANGED
@@ -856,7 +856,7 @@ function prepareTopoloActionUploadInput(contractValue, content, input, options)
856
856
  if (bytes.byteLength > contract.maxBytes) {
857
857
  throw new TopoloSdkError("upload_too_large", `Upload content exceeds the ${contract.maxBytes}-byte action limit.`);
858
858
  }
859
- return mapUploadInput(contract, bytesToBase64(bytes), input, options);
859
+ return mapUploadInput(contract, encodeTopoloActionBase64(bytes), input, options);
860
860
  }
861
861
  function prepareTopoloActionBase64UploadInput(contractValue, contentBase64, input, options) {
862
862
  const contract = parseTopoloActionUploadContract(contractValue);
@@ -992,7 +992,7 @@ function requiredField(value, name) {
992
992
  function matchesContentType(contentType, accepted) {
993
993
  return accepted.some((candidate) => candidate === "*/*" || candidate === contentType || candidate.endsWith("/*") && contentType.startsWith(candidate.slice(0, -1)));
994
994
  }
995
- function bytesToBase64(bytes) {
995
+ function encodeTopoloActionBase64(bytes) {
996
996
  let binary = "";
997
997
  const chunkSize = 32768;
998
998
  for (let offset = 0; offset < bytes.length; offset += chunkSize) {
@@ -1171,7 +1171,20 @@ var TopoloClient = class _TopoloClient {
1171
1171
  throw err;
1172
1172
  }
1173
1173
  const contentType = res.headers.get("Content-Type") ?? "";
1174
- const parsed = contentType.includes("application/json") ? await res.json().catch(() => null) : await res.text().catch(() => null);
1174
+ const normalizedContentType = contentType.split(";", 1)[0]?.trim().toLowerCase() ?? "";
1175
+ let parsed;
1176
+ if (normalizedContentType === "application/json" || normalizedContentType.endsWith("+json")) {
1177
+ parsed = await res.json().catch(() => null);
1178
+ } else if (!res.ok || !normalizedContentType || normalizedContentType.startsWith("text/")) {
1179
+ parsed = await res.text().catch(() => null);
1180
+ } else {
1181
+ const bytes = new Uint8Array(await res.arrayBuffer());
1182
+ parsed = {
1183
+ contentType: normalizedContentType,
1184
+ contentLength: bytes.byteLength,
1185
+ contentBase64: encodeTopoloActionBase64(bytes)
1186
+ };
1187
+ }
1175
1188
  if (!res.ok) {
1176
1189
  const durationMs = Date.now() - startedAt;
1177
1190
  const message = describeError(parsed, `HTTP ${res.status}`);
@@ -3365,6 +3378,7 @@ export {
3365
3378
  defineTopoloRecentActivityWidget,
3366
3379
  defineTopoloStatsWidget,
3367
3380
  digestTopoloActionCatalog,
3381
+ encodeTopoloActionBase64,
3368
3382
  enrichActionContract,
3369
3383
  extractTopoloServiceErrorCode,
3370
3384
  extractTopoloServiceErrorDetails,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@topolo/sdk",
3
- "version": "0.11.7",
4
- "topoloPublishedVersion": "0.11.7",
3
+ "version": "0.11.8",
4
+ "topoloPublishedVersion": "0.11.8",
5
5
  "description": "Typed client SDK for the Topolo platform. Used by TopoloCli, TopoloMCP, and third-party agents.",
6
6
  "license": "UNLICENSED",
7
7
  "author": "Topolo",