@topolo/cli 0.10.0 → 0.10.1

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.
Files changed (2) hide show
  1. package/dist/index.js +32 -10
  2. package/package.json +9 -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.14.4/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);
@@ -2948,7 +2948,7 @@ function createTopolo(options) {
2948
2948
  };
2949
2949
  }
2950
2950
 
2951
- // node_modules/@topolo/sdk/dist/node/credential-store.js
2951
+ // node_modules/.pnpm/@topolo+sdk@0.14.4/node_modules/@topolo/sdk/dist/node/credential-store.js
2952
2952
  import { mkdir, readFile, writeFile, chmod, rm, stat } from "fs/promises";
2953
2953
  import { existsSync } from "fs";
2954
2954
  import { homedir, platform } from "os";
@@ -6087,8 +6087,15 @@ async function fetchMe(credential, serviceUrls) {
6087
6087
  const user = data.user ?? {};
6088
6088
  const rawMemberships = user.organizationMemberships || data.organizations || [];
6089
6089
  const memberships = rawMemberships.filter((m) => m && m.id);
6090
- const activeType = user.orgId ? "organization" : "personal";
6091
- return { memberships, activeType, activeOrgId: user.orgId || void 0 };
6090
+ const availableContexts = Array.isArray(user.availableContexts) ? user.availableContexts : [];
6091
+ const activeType = user.activeContextType === "personal" ? "personal" : "organization";
6092
+ const activeOrgId = activeType === "organization" ? user.activeContextId || void 0 : void 0;
6093
+ return {
6094
+ memberships,
6095
+ activeType,
6096
+ activeOrgId,
6097
+ personalAvailable: availableContexts.some((candidate) => candidate?.type === "personal")
6098
+ };
6092
6099
  }
6093
6100
  function credentialFromTokens(tokens) {
6094
6101
  const accessToken = tokens.accessToken || tokens.access_token;
@@ -6132,7 +6139,7 @@ function hasSameAccessToken(left, right) {
6132
6139
  return leftCredential?.kind === "access_token" && rightCredential?.kind === "access_token" && leftCredential.accessToken === rightCredential.accessToken;
6133
6140
  }
6134
6141
  function identityMatchesContext(me, context) {
6135
- if (context.contextType === "personal") return me.activeType === "personal";
6142
+ if (context.contextType === "personal") return me.personalAvailable && me.activeType === "personal";
6136
6143
  return me.activeType === "organization" && me.activeOrgId === context.organizationId;
6137
6144
  }
6138
6145
  function registerContextCommand(program2) {
@@ -6147,6 +6154,7 @@ function registerContextCommand(program2) {
6147
6154
  const activeKey = profile.activeContext;
6148
6155
  const rows = /* @__PURE__ */ new Map();
6149
6156
  for (const [key, ctx] of Object.entries(stored)) {
6157
+ if (ctx.contextType === "personal") continue;
6150
6158
  rows.set(key, {
6151
6159
  key,
6152
6160
  type: ctx.contextType,
@@ -6172,15 +6180,22 @@ function registerContextCommand(program2) {
6172
6180
  if (!contextCredential) return;
6173
6181
  const identity = key === activeKey && activeIdentity ? activeIdentity : await fetchMe(contextCredential, serviceUrls);
6174
6182
  if (!identityMatchesContext(identity, ctx)) return;
6175
- const row = rows.get(key);
6176
- if (row) rows.set(key, { ...row, signedIn: true, available: true });
6183
+ const row = rows.get(key) ?? {
6184
+ key,
6185
+ type: ctx.contextType,
6186
+ label: labelFor(ctx),
6187
+ signedIn: false,
6188
+ available: false,
6189
+ active: key === activeKey
6190
+ };
6191
+ rows.set(key, { ...row, signedIn: true, available: true });
6177
6192
  } catch {
6178
6193
  }
6179
6194
  }));
6180
6195
  if (activeIdentity) {
6181
6196
  try {
6182
6197
  const personalKey = contextKey("personal");
6183
- if (!rows.has(personalKey)) {
6198
+ if (activeIdentity.personalAvailable && !rows.has(personalKey)) {
6184
6199
  rows.set(personalKey, {
6185
6200
  key: personalKey,
6186
6201
  type: "personal",
@@ -6189,7 +6204,7 @@ function registerContextCommand(program2) {
6189
6204
  available: true,
6190
6205
  active: personalKey === activeKey
6191
6206
  });
6192
- } else {
6207
+ } else if (activeIdentity.personalAvailable) {
6193
6208
  const row = rows.get(personalKey);
6194
6209
  rows.set(personalKey, { ...row, available: true });
6195
6210
  }
@@ -6265,8 +6280,9 @@ function registerContextCommand(program2) {
6265
6280
  );
6266
6281
  if (!match) {
6267
6282
  const names = me.memberships.map((m) => m.slug || m.name || m.id);
6283
+ const available = [me.personalAvailable ? "personal" : "", ...names].filter(Boolean);
6268
6284
  throw new Error(
6269
- `You are not a member of "${target}". Available: personal${names.length ? ", " + names.join(", ") : ""}.`
6285
+ `You are not a member of "${target}". Available: ${available.join(", ") || "none"}.`
6270
6286
  );
6271
6287
  }
6272
6288
  resolved = {
@@ -6292,6 +6308,12 @@ function registerContextCommand(program2) {
6292
6308
  }
6293
6309
  }
6294
6310
  if (!newCredential) {
6311
+ if (resolved.contextType === "personal") {
6312
+ const identity = await fetchMe(cred, serviceUrls);
6313
+ if (!identity.personalAvailable) {
6314
+ throw new Error("Personal context is not available for this account.");
6315
+ }
6316
+ }
6295
6317
  try {
6296
6318
  newCredential = await exchangeForContext(cred, serviceUrls, {
6297
6319
  type: resolved.contextType,
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@topolo/cli",
3
- "version": "0.10.0",
4
- "topoloPublishedVersion": "0.10.0",
3
+ "packageManager": "pnpm@10.17.1",
4
+ "version": "0.10.1",
5
+ "topoloPublishedVersion": "0.10.1",
5
6
  "description": "Public command-line interface for Topolo customer organizations, developers, and agents.",
6
7
  "license": "UNLICENSED",
7
8
  "author": "Topolo",
@@ -21,9 +22,9 @@
21
22
  "dev": "tsup --watch",
22
23
  "typecheck": "tsc --noEmit",
23
24
  "start": "node dist/index.js",
24
- "test": "if test \"$TOPOLO_BUILD_READY\" = 1; then vitest run; else python3 ../../tooling/with-resource-lock.py ../topolo-sdk -- sh -c 'pnpm --dir ../topolo-sdk build && exec vitest run'; fi",
25
+ "test": "vitest run",
25
26
  "test:watch": "vitest",
26
- "coverage": "if test \"$TOPOLO_BUILD_READY\" = 1; then vitest run --coverage; else python3 ../../tooling/with-resource-lock.py ../topolo-sdk -- sh -c 'pnpm --dir ../topolo-sdk build && exec vitest run --coverage'; fi"
27
+ "coverage": "vitest run --coverage"
27
28
  },
28
29
  "dependencies": {
29
30
  "@modelcontextprotocol/sdk": "^1.0.0",
@@ -40,5 +41,9 @@
40
41
  },
41
42
  "engines": {
42
43
  "node": ">=20"
44
+ },
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/Topolo-io/TopoloCli.git"
43
48
  }
44
49
  }