@topolo/cli 0.9.3 → 0.9.5
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.js +93 -9
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { platform as platform2 } from "os";
|
|
|
9
9
|
import { createInterface } from "readline/promises";
|
|
10
10
|
import { stdin as input } from "process";
|
|
11
11
|
|
|
12
|
-
// node_modules/@topolo/sdk/dist/index.js
|
|
12
|
+
// ../../node_modules/.pnpm/@topolo+sdk@0.11.11/node_modules/@topolo/sdk/dist/index.js
|
|
13
13
|
function applyAuthHeaders(headers, credential) {
|
|
14
14
|
if (credential.kind === "api_key") {
|
|
15
15
|
headers.set("X-Api-Key", credential.apiKey);
|
|
@@ -1546,7 +1546,9 @@ var TopoloClient = class _TopoloClient {
|
|
|
1546
1546
|
};
|
|
1547
1547
|
}
|
|
1548
1548
|
planResolvedAction(entry, input2, options) {
|
|
1549
|
-
const
|
|
1549
|
+
const inputValidation = validateTopoloActionInput(entry.inputSchema, input2);
|
|
1550
|
+
const resourceIssue = validateActionResource(entry, options.resource);
|
|
1551
|
+
const validation = resourceIssue ? { valid: false, errors: [...inputValidation.errors, resourceIssue] } : inputValidation;
|
|
1550
1552
|
const agentAccess = entry.agentAccess ?? (entry.destructive ? "off" : entry.readOnly && !entry.requiresConfirmation ? "auto" : "confirm");
|
|
1551
1553
|
const confirmationRequired = agentAccess === "confirm" || entry.requiresConfirmation || entry.destructive;
|
|
1552
1554
|
let request = null;
|
|
@@ -1605,6 +1607,13 @@ var TopoloClient = class _TopoloClient {
|
|
|
1605
1607
|
`Topolo action "${entry.actionId}" input is invalid: ${validation.errors.map((issue) => `${issue.path} ${issue.message}`).join("; ")}`
|
|
1606
1608
|
);
|
|
1607
1609
|
}
|
|
1610
|
+
const resourceIssue = validateActionResource(entry, options.resource);
|
|
1611
|
+
if (resourceIssue) {
|
|
1612
|
+
throw new TopoloSdkError(
|
|
1613
|
+
"invalid_action_resource",
|
|
1614
|
+
`Topolo action "${entry.actionId}" resource context is invalid: ${resourceIssue.message}`
|
|
1615
|
+
);
|
|
1616
|
+
}
|
|
1608
1617
|
const mapped = mapActionInput(entry, input2);
|
|
1609
1618
|
const service = entry.appSlug || entry.appId;
|
|
1610
1619
|
const result = await this.request({
|
|
@@ -1667,6 +1676,32 @@ var TopoloClient = class _TopoloClient {
|
|
|
1667
1676
|
};
|
|
1668
1677
|
}
|
|
1669
1678
|
};
|
|
1679
|
+
function validateActionResource(entry, resource) {
|
|
1680
|
+
const permissionName = entry.permissionName || entry.requiredPermission.split(".").at(-1) || "";
|
|
1681
|
+
if (!permissionName.startsWith("workspace:")) return null;
|
|
1682
|
+
if (!resource) {
|
|
1683
|
+
return {
|
|
1684
|
+
path: "$.resource",
|
|
1685
|
+
code: "required",
|
|
1686
|
+
message: "Select a workspace with the application resource catalog before planning or calling this action."
|
|
1687
|
+
};
|
|
1688
|
+
}
|
|
1689
|
+
if (resource.resourceType !== "workspace") {
|
|
1690
|
+
return {
|
|
1691
|
+
path: "$.resource.resourceType",
|
|
1692
|
+
code: "const",
|
|
1693
|
+
message: 'This action requires resourceType "workspace".'
|
|
1694
|
+
};
|
|
1695
|
+
}
|
|
1696
|
+
if (!resource.resourceId.trim()) {
|
|
1697
|
+
return {
|
|
1698
|
+
path: "$.resource.resourceId",
|
|
1699
|
+
code: "required",
|
|
1700
|
+
message: "This action requires a workspace resourceId."
|
|
1701
|
+
};
|
|
1702
|
+
}
|
|
1703
|
+
return null;
|
|
1704
|
+
}
|
|
1670
1705
|
function resolveConfiguredAppId(slug, appIds) {
|
|
1671
1706
|
for (const serviceKey of serviceKeyCandidates2(slug)) {
|
|
1672
1707
|
const configured = appIds?.[serviceKey];
|
|
@@ -2397,7 +2432,7 @@ function createTopolo(options) {
|
|
|
2397
2432
|
};
|
|
2398
2433
|
}
|
|
2399
2434
|
|
|
2400
|
-
// node_modules/@topolo/sdk/dist/node/credential-store.js
|
|
2435
|
+
// ../../node_modules/.pnpm/@topolo+sdk@0.11.11/node_modules/@topolo/sdk/dist/node/credential-store.js
|
|
2401
2436
|
import { mkdir, readFile, writeFile, chmod, rm, stat } from "fs/promises";
|
|
2402
2437
|
import { existsSync } from "fs";
|
|
2403
2438
|
import { homedir, platform } from "os";
|
|
@@ -5070,20 +5105,66 @@ function registerContextCommand(program2) {
|
|
|
5070
5105
|
const activeKey = profile.activeContext;
|
|
5071
5106
|
const rows = /* @__PURE__ */ new Map();
|
|
5072
5107
|
for (const [key, ctx] of Object.entries(stored)) {
|
|
5073
|
-
rows.set(key, {
|
|
5108
|
+
rows.set(key, {
|
|
5109
|
+
key,
|
|
5110
|
+
type: ctx.contextType,
|
|
5111
|
+
label: labelFor(ctx),
|
|
5112
|
+
signedIn: false,
|
|
5113
|
+
available: false,
|
|
5114
|
+
active: key === activeKey
|
|
5115
|
+
});
|
|
5074
5116
|
}
|
|
5117
|
+
const serviceUrls = resolvedProfileConfig(config, environment).serviceUrls;
|
|
5075
5118
|
const cred = await refreshCredentialIfNeeded(environment);
|
|
5119
|
+
let activeIdentity = null;
|
|
5076
5120
|
if (cred) {
|
|
5077
5121
|
try {
|
|
5078
|
-
|
|
5122
|
+
activeIdentity = await fetchMe(cred, serviceUrls);
|
|
5123
|
+
} catch {
|
|
5124
|
+
activeIdentity = null;
|
|
5125
|
+
}
|
|
5126
|
+
}
|
|
5127
|
+
await Promise.all(Object.entries(stored).map(async ([key, ctx]) => {
|
|
5128
|
+
try {
|
|
5129
|
+
const contextCredential = key === activeKey ? cred : await refreshContextCredentialIfNeeded(environment, key);
|
|
5130
|
+
if (!contextCredential) return;
|
|
5131
|
+
const identity = key === activeKey && activeIdentity ? activeIdentity : await fetchMe(contextCredential, serviceUrls);
|
|
5132
|
+
if (!identityMatchesContext(identity, ctx)) return;
|
|
5133
|
+
const row = rows.get(key);
|
|
5134
|
+
if (row) rows.set(key, { ...row, signedIn: true, available: true });
|
|
5135
|
+
} catch {
|
|
5136
|
+
}
|
|
5137
|
+
}));
|
|
5138
|
+
if (activeIdentity) {
|
|
5139
|
+
try {
|
|
5079
5140
|
const personalKey = contextKey("personal");
|
|
5080
5141
|
if (!rows.has(personalKey)) {
|
|
5081
|
-
rows.set(personalKey, {
|
|
5142
|
+
rows.set(personalKey, {
|
|
5143
|
+
key: personalKey,
|
|
5144
|
+
type: "personal",
|
|
5145
|
+
label: "Personal",
|
|
5146
|
+
signedIn: false,
|
|
5147
|
+
available: true,
|
|
5148
|
+
active: personalKey === activeKey
|
|
5149
|
+
});
|
|
5150
|
+
} else {
|
|
5151
|
+
const row = rows.get(personalKey);
|
|
5152
|
+
rows.set(personalKey, { ...row, available: true });
|
|
5082
5153
|
}
|
|
5083
|
-
for (const m of
|
|
5154
|
+
for (const m of activeIdentity.memberships) {
|
|
5084
5155
|
const key = contextKey("organization", m.id);
|
|
5085
5156
|
if (!rows.has(key)) {
|
|
5086
|
-
rows.set(key, {
|
|
5157
|
+
rows.set(key, {
|
|
5158
|
+
key,
|
|
5159
|
+
type: "organization",
|
|
5160
|
+
label: m.name || m.slug || m.id,
|
|
5161
|
+
signedIn: false,
|
|
5162
|
+
available: true,
|
|
5163
|
+
active: key === activeKey
|
|
5164
|
+
});
|
|
5165
|
+
} else {
|
|
5166
|
+
const row = rows.get(key);
|
|
5167
|
+
rows.set(key, { ...row, available: true });
|
|
5087
5168
|
}
|
|
5088
5169
|
}
|
|
5089
5170
|
} catch {
|
|
@@ -5094,7 +5175,10 @@ function registerContextCommand(program2) {
|
|
|
5094
5175
|
if (list.length === 0) return "No contexts yet. Run `topolo auth login` first.";
|
|
5095
5176
|
const lines = [`Contexts (${environmentLabel(environment)}):`, ""];
|
|
5096
5177
|
for (const r of list) {
|
|
5097
|
-
const marks = [
|
|
5178
|
+
const marks = [
|
|
5179
|
+
r.active ? "active" : "",
|
|
5180
|
+
r.signedIn ? "signed in" : r.available ? "available" : "sign in required"
|
|
5181
|
+
].filter(Boolean).join(", ");
|
|
5098
5182
|
lines.push(` ${r.active ? "*" : " "} ${r.label} (${r.type}) [${marks}]`);
|
|
5099
5183
|
}
|
|
5100
5184
|
lines.push("", "Switch with: topolo context use <organization|personal>");
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topolo/cli",
|
|
3
|
-
"version": "0.9.
|
|
4
|
-
"topoloPublishedVersion": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
4
|
+
"topoloPublishedVersion": "0.9.5",
|
|
5
5
|
"description": "Public command-line interface for Topolo customer organizations, developers, and agents.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"author": "Topolo",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
28
|
-
"@topolo/mcp": "0.11.
|
|
29
|
-
"@topolo/sdk": "0.11.
|
|
28
|
+
"@topolo/mcp": "0.11.11",
|
|
29
|
+
"@topolo/sdk": "0.11.11",
|
|
30
30
|
"commander": "^12.1.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|