@topolo/sdk 0.11.10 → 0.11.11
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 +36 -1
- package/dist/index.js +36 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1757,7 +1757,9 @@ var TopoloClient = class _TopoloClient {
|
|
|
1757
1757
|
};
|
|
1758
1758
|
}
|
|
1759
1759
|
planResolvedAction(entry, input, options) {
|
|
1760
|
-
const
|
|
1760
|
+
const inputValidation = validateTopoloActionInput(entry.inputSchema, input);
|
|
1761
|
+
const resourceIssue = validateActionResource(entry, options.resource);
|
|
1762
|
+
const validation = resourceIssue ? { valid: false, errors: [...inputValidation.errors, resourceIssue] } : inputValidation;
|
|
1761
1763
|
const agentAccess = entry.agentAccess ?? (entry.destructive ? "off" : entry.readOnly && !entry.requiresConfirmation ? "auto" : "confirm");
|
|
1762
1764
|
const confirmationRequired = agentAccess === "confirm" || entry.requiresConfirmation || entry.destructive;
|
|
1763
1765
|
let request = null;
|
|
@@ -1816,6 +1818,13 @@ var TopoloClient = class _TopoloClient {
|
|
|
1816
1818
|
`Topolo action "${entry.actionId}" input is invalid: ${validation.errors.map((issue) => `${issue.path} ${issue.message}`).join("; ")}`
|
|
1817
1819
|
);
|
|
1818
1820
|
}
|
|
1821
|
+
const resourceIssue = validateActionResource(entry, options.resource);
|
|
1822
|
+
if (resourceIssue) {
|
|
1823
|
+
throw new TopoloSdkError(
|
|
1824
|
+
"invalid_action_resource",
|
|
1825
|
+
`Topolo action "${entry.actionId}" resource context is invalid: ${resourceIssue.message}`
|
|
1826
|
+
);
|
|
1827
|
+
}
|
|
1819
1828
|
const mapped = mapActionInput(entry, input);
|
|
1820
1829
|
const service = entry.appSlug || entry.appId;
|
|
1821
1830
|
const result = await this.request({
|
|
@@ -1878,6 +1887,32 @@ var TopoloClient = class _TopoloClient {
|
|
|
1878
1887
|
};
|
|
1879
1888
|
}
|
|
1880
1889
|
};
|
|
1890
|
+
function validateActionResource(entry, resource) {
|
|
1891
|
+
const permissionName = entry.permissionName || entry.requiredPermission.split(".").at(-1) || "";
|
|
1892
|
+
if (!permissionName.startsWith("workspace:")) return null;
|
|
1893
|
+
if (!resource) {
|
|
1894
|
+
return {
|
|
1895
|
+
path: "$.resource",
|
|
1896
|
+
code: "required",
|
|
1897
|
+
message: "Select a workspace with the application resource catalog before planning or calling this action."
|
|
1898
|
+
};
|
|
1899
|
+
}
|
|
1900
|
+
if (resource.resourceType !== "workspace") {
|
|
1901
|
+
return {
|
|
1902
|
+
path: "$.resource.resourceType",
|
|
1903
|
+
code: "const",
|
|
1904
|
+
message: 'This action requires resourceType "workspace".'
|
|
1905
|
+
};
|
|
1906
|
+
}
|
|
1907
|
+
if (!resource.resourceId.trim()) {
|
|
1908
|
+
return {
|
|
1909
|
+
path: "$.resource.resourceId",
|
|
1910
|
+
code: "required",
|
|
1911
|
+
message: "This action requires a workspace resourceId."
|
|
1912
|
+
};
|
|
1913
|
+
}
|
|
1914
|
+
return null;
|
|
1915
|
+
}
|
|
1881
1916
|
function resolveConfiguredAppId(slug, appIds) {
|
|
1882
1917
|
for (const serviceKey of serviceKeyCandidates2(slug)) {
|
|
1883
1918
|
const configured = appIds?.[serviceKey];
|
package/dist/index.js
CHANGED
|
@@ -1674,7 +1674,9 @@ var TopoloClient = class _TopoloClient {
|
|
|
1674
1674
|
};
|
|
1675
1675
|
}
|
|
1676
1676
|
planResolvedAction(entry, input, options) {
|
|
1677
|
-
const
|
|
1677
|
+
const inputValidation = validateTopoloActionInput(entry.inputSchema, input);
|
|
1678
|
+
const resourceIssue = validateActionResource(entry, options.resource);
|
|
1679
|
+
const validation = resourceIssue ? { valid: false, errors: [...inputValidation.errors, resourceIssue] } : inputValidation;
|
|
1678
1680
|
const agentAccess = entry.agentAccess ?? (entry.destructive ? "off" : entry.readOnly && !entry.requiresConfirmation ? "auto" : "confirm");
|
|
1679
1681
|
const confirmationRequired = agentAccess === "confirm" || entry.requiresConfirmation || entry.destructive;
|
|
1680
1682
|
let request = null;
|
|
@@ -1733,6 +1735,13 @@ var TopoloClient = class _TopoloClient {
|
|
|
1733
1735
|
`Topolo action "${entry.actionId}" input is invalid: ${validation.errors.map((issue) => `${issue.path} ${issue.message}`).join("; ")}`
|
|
1734
1736
|
);
|
|
1735
1737
|
}
|
|
1738
|
+
const resourceIssue = validateActionResource(entry, options.resource);
|
|
1739
|
+
if (resourceIssue) {
|
|
1740
|
+
throw new TopoloSdkError(
|
|
1741
|
+
"invalid_action_resource",
|
|
1742
|
+
`Topolo action "${entry.actionId}" resource context is invalid: ${resourceIssue.message}`
|
|
1743
|
+
);
|
|
1744
|
+
}
|
|
1736
1745
|
const mapped = mapActionInput(entry, input);
|
|
1737
1746
|
const service = entry.appSlug || entry.appId;
|
|
1738
1747
|
const result = await this.request({
|
|
@@ -1795,6 +1804,32 @@ var TopoloClient = class _TopoloClient {
|
|
|
1795
1804
|
};
|
|
1796
1805
|
}
|
|
1797
1806
|
};
|
|
1807
|
+
function validateActionResource(entry, resource) {
|
|
1808
|
+
const permissionName = entry.permissionName || entry.requiredPermission.split(".").at(-1) || "";
|
|
1809
|
+
if (!permissionName.startsWith("workspace:")) return null;
|
|
1810
|
+
if (!resource) {
|
|
1811
|
+
return {
|
|
1812
|
+
path: "$.resource",
|
|
1813
|
+
code: "required",
|
|
1814
|
+
message: "Select a workspace with the application resource catalog before planning or calling this action."
|
|
1815
|
+
};
|
|
1816
|
+
}
|
|
1817
|
+
if (resource.resourceType !== "workspace") {
|
|
1818
|
+
return {
|
|
1819
|
+
path: "$.resource.resourceType",
|
|
1820
|
+
code: "const",
|
|
1821
|
+
message: 'This action requires resourceType "workspace".'
|
|
1822
|
+
};
|
|
1823
|
+
}
|
|
1824
|
+
if (!resource.resourceId.trim()) {
|
|
1825
|
+
return {
|
|
1826
|
+
path: "$.resource.resourceId",
|
|
1827
|
+
code: "required",
|
|
1828
|
+
message: "This action requires a workspace resourceId."
|
|
1829
|
+
};
|
|
1830
|
+
}
|
|
1831
|
+
return null;
|
|
1832
|
+
}
|
|
1798
1833
|
function resolveConfiguredAppId(slug, appIds) {
|
|
1799
1834
|
for (const serviceKey of serviceKeyCandidates2(slug)) {
|
|
1800
1835
|
const configured = appIds?.[serviceKey];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topolo/sdk",
|
|
3
|
-
"version": "0.11.
|
|
4
|
-
"topoloPublishedVersion": "0.11.
|
|
3
|
+
"version": "0.11.11",
|
|
4
|
+
"topoloPublishedVersion": "0.11.11",
|
|
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",
|