@topolo/sdk 0.11.7 → 0.11.9

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}`);
@@ -1804,7 +1818,7 @@ var TopoloClient = class _TopoloClient {
1804
1818
  }
1805
1819
  const mapped = mapActionInput(entry, input);
1806
1820
  const service = entry.appSlug || entry.appId;
1807
- return this.request({
1821
+ const result = await this.request({
1808
1822
  service,
1809
1823
  ...entry.apiBaseUrl ? { baseUrl: entry.apiBaseUrl } : {},
1810
1824
  method: entry.method,
@@ -1818,6 +1832,7 @@ var TopoloClient = class _TopoloClient {
1818
1832
  },
1819
1833
  confirm: options.confirm === true || entry.readOnly && !entry.destructive && !entry.requiresConfirmation
1820
1834
  });
1835
+ return redactActionResult(result);
1821
1836
  }
1822
1837
  /**
1823
1838
  * Introspect the current credential. Returns the caller's resolved identity,
@@ -1941,6 +1956,18 @@ function readOptionalString(value) {
1941
1956
  function isRecord3(value) {
1942
1957
  return typeof value === "object" && value !== null && !Array.isArray(value);
1943
1958
  }
1959
+ function redactActionResult(value) {
1960
+ if (Array.isArray(value)) return value.map(redactActionResult);
1961
+ if (!isRecord3(value)) return value;
1962
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [
1963
+ key,
1964
+ isSensitiveActionResultKey(key) ? "[REDACTED]" : redactActionResult(item)
1965
+ ]));
1966
+ }
1967
+ function isSensitiveActionResultKey(key) {
1968
+ const normalized = key.toLowerCase().replace(/[^a-z0-9]/g, "");
1969
+ return ["authorization", "cookie", "setcookie", "proxyauthorization", "capability"].includes(normalized) || /(token|secret|password|privatekey|apikey)$/.test(normalized);
1970
+ }
1944
1971
  function resolveConfiguredServiceUrl(slug, serviceUrls) {
1945
1972
  for (const serviceKey of serviceKeyCandidates2(slug)) {
1946
1973
  const configured = serviceUrls?.[serviceKey];
@@ -3448,6 +3475,7 @@ function createTopolo(options) {
3448
3475
  defineTopoloRecentActivityWidget,
3449
3476
  defineTopoloStatsWidget,
3450
3477
  digestTopoloActionCatalog,
3478
+ encodeTopoloActionBase64,
3451
3479
  enrichActionContract,
3452
3480
  extractTopoloServiceErrorCode,
3453
3481
  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}`);
@@ -1722,7 +1735,7 @@ var TopoloClient = class _TopoloClient {
1722
1735
  }
1723
1736
  const mapped = mapActionInput(entry, input);
1724
1737
  const service = entry.appSlug || entry.appId;
1725
- return this.request({
1738
+ const result = await this.request({
1726
1739
  service,
1727
1740
  ...entry.apiBaseUrl ? { baseUrl: entry.apiBaseUrl } : {},
1728
1741
  method: entry.method,
@@ -1736,6 +1749,7 @@ var TopoloClient = class _TopoloClient {
1736
1749
  },
1737
1750
  confirm: options.confirm === true || entry.readOnly && !entry.destructive && !entry.requiresConfirmation
1738
1751
  });
1752
+ return redactActionResult(result);
1739
1753
  }
1740
1754
  /**
1741
1755
  * Introspect the current credential. Returns the caller's resolved identity,
@@ -1859,6 +1873,18 @@ function readOptionalString(value) {
1859
1873
  function isRecord3(value) {
1860
1874
  return typeof value === "object" && value !== null && !Array.isArray(value);
1861
1875
  }
1876
+ function redactActionResult(value) {
1877
+ if (Array.isArray(value)) return value.map(redactActionResult);
1878
+ if (!isRecord3(value)) return value;
1879
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [
1880
+ key,
1881
+ isSensitiveActionResultKey(key) ? "[REDACTED]" : redactActionResult(item)
1882
+ ]));
1883
+ }
1884
+ function isSensitiveActionResultKey(key) {
1885
+ const normalized = key.toLowerCase().replace(/[^a-z0-9]/g, "");
1886
+ return ["authorization", "cookie", "setcookie", "proxyauthorization", "capability"].includes(normalized) || /(token|secret|password|privatekey|apikey)$/.test(normalized);
1887
+ }
1862
1888
  function resolveConfiguredServiceUrl(slug, serviceUrls) {
1863
1889
  for (const serviceKey of serviceKeyCandidates2(slug)) {
1864
1890
  const configured = serviceUrls?.[serviceKey];
@@ -3365,6 +3391,7 @@ export {
3365
3391
  defineTopoloRecentActivityWidget,
3366
3392
  defineTopoloStatsWidget,
3367
3393
  digestTopoloActionCatalog,
3394
+ encodeTopoloActionBase64,
3368
3395
  enrichActionContract,
3369
3396
  extractTopoloServiceErrorCode,
3370
3397
  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.9",
4
+ "topoloPublishedVersion": "0.11.9",
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",