@widgetic/cli 0.1.13 → 0.1.14

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/README.md CHANGED
@@ -75,11 +75,11 @@ A call is tried at most three times. A `429` is always waited out (a `Retry-Afte
75
75
 
76
76
  The CLI is generated from the **public** contracts and from nothing else. `@widgetic/api-contracts` carries the public OpenAPI description (the file the partners' SDKs, `@widgetic/api-sdk-ts` and its siblings, are generated from, and the published API reference) and the MCP tool contract. It is not generated from the private description that Widgetic's own apps use (`@widgetic/api-sdk`, which also lists the administrator and internal operations), so none of those is a command. A mistake in the gateway cannot add one: the package is only built from a description in which every operation is marked `x-visibility: public` and has a level that an API key passes, and the build stops at the first operation that is not.
77
77
 
78
- | Level of the operation (`x-access-level`) | Who calls it | In the CLI |
79
- | ----------------------------------------- | ----------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
80
- | `user` | Any API key: your widgets, your account | Listed. Its help names no special key. |
81
- | `partner` | A partner key (`wgt_prt_…`): managed users, credits, storage, analytics | Listed. Its help says `Needs a partner API key (wgt_prt_…).` |
82
- | `public` | Browsers, with no key: the runtime of an embed | Left out of `--help`; `widgetic api call <operationId>` runs it. No key is sent. |
78
+ | Level of the operation (`x-access-level`) | Who calls it | In the CLI |
79
+ | ----------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
80
+ | `user` | Any API key: your widgets, your account | Listed. Its help names no special key. |
81
+ | `partner` | A partner key (`wgt_prt_…`), or a key made in a partner workspace (`wdg_org_…`): managed users, credits, storage, analytics | Listed. Its help says `Needs a partner API key (wgt_prt_…), or a key made in a partner workspace (wdg_org_…).` |
82
+ | `public` | Browsers, with no key: the runtime of an embed | Left out of `--help`; `widgetic api call <operationId>` runs it. No key is sent. |
83
83
 
84
84
  The CLI does not decide who may do what. The API does, on every call, from the key: a key without the scope or the level gets a 403 (exit code 3), the same answer as from the SDK or from `curl`. The CLI only makes what the key may already do easy to find and to call. One thing to know when you make the key: the `widgetic mcp` commands need a key made with **full access**, because the MCP endpoint hands a client every tool the account has and refuses a key limited to some scopes (the dashboard's "Read only", "Content" and "Custom"). The `widgetic api` commands work with a limited key, within its scopes.
85
85
 
@@ -107,33 +107,41 @@ A secret typed as the text of the flag is refused (exit code 2), nothing is sent
107
107
 
108
108
  ### Which workspace a change goes to
109
109
 
110
- A key works in one workspace at a time: an organization key (`wdg_org_…`) in its team's, a person's key (`wgt_usr_…`) in the one that person has switched to on widgetic.com. That switch is shared by everything that signs in as the person, so a change made from the terminal can land in a team's workspace while you are thinking of your own. `widgetic doctor` says where the key works (the `Workspace` line), and so does `widgetic mcp get-profile` (its `workspace`).
110
+ A key works in one workspace, the one it was made for, and nowhere else: it does not follow the workspace you have open on widgetic.com, and a person with several workspaces makes a key in each of them (Settings > API Keys, with that workspace chosen). `widgetic auth login` and `widgetic auth status` say which workspace the key works in (the answer of `GET /tokens/validate`), `widgetic doctor` says it with its plan (the `Workspace` line), and so does `widgetic mcp get-profile` (its `workspace`: the name and the plan).
111
111
 
112
- The tools that change a workflow, an A/B test or a translation take `--expected-workspace <personal|team name>` (tool contract 1.17.0 and later). It never picks or switches a workspace: it says where the change is meant for, and the server refuses it, and changes nothing (exit code 5), when the key works anywhere else.
112
+ The tools that change a workflow, an A/B test or a translation take `--expected-workspace <name>` (tool contract 1.17.0 and later; a name and nothing else since 1.25.0, when the personal workspace went away). It never picks or switches a workspace: it says where the change is meant for, and the server refuses it, and changes nothing (exit code 5), when the key works anywhere else.
113
113
 
114
114
  ```bash
115
115
  widgetic mcp save-workflow --expected-workspace "Acme Studio" --input @workflow.json
116
- widgetic mcp publish-workflow --workflow-id <id> --expected-workspace personal
116
+ widgetic mcp publish-workflow --workflow-id <id> --expected-workspace "Acme Studio"
117
117
  ```
118
118
 
119
- - **`WIDGETIC_WORKSPACE` says it for every change of a shell or a CI job**, so that a script cannot forget it: `export WIDGETIC_WORKSPACE="Acme Studio"`. A flag, or the key of `--input`, wins over it for that call. A read is not held, and neither is a tool that takes no workspace (a widget is always your own).
119
+ - **`WIDGETIC_WORKSPACE` says it for every change of a shell or a CI job**, so that a script cannot forget it: `export WIDGETIC_WORKSPACE="Acme Studio"`. A flag, or the key of `--input`, wins over it for that call. A read is not held, and neither is a tool that takes no `expected_workspace` (`widgetic schema mcp <tool>` says which do).
120
120
  - **A hold that cannot be made is not a change that goes through.** With the variable set, the CLI stops a change (exit code 2, nothing sent) when the variable is empty, when this version of the CLI was built from a tool contract that cannot hold a change (`widgetic update`), and when the tool is one it does not know (`widgetic mcp call <tool>`) and `--input` has no `expected_workspace`.
121
- - **The question before a publish names the workspace.** At a terminal it says where the key works (`… in the team workspace "Acme Studio". Continue?`), and once you say yes the change is held to the workspace it named, so a switch made in another tab in between changes nothing. With `--yes` or `--json` nothing is asked and nothing is added: a script gives `--expected-workspace` or sets the variable.
122
- - Only the `widgetic mcp` commands are held. A team called `personal` cannot be named, because the server reads that word as your own workspace: leave the argument out.
121
+ - **The question before a publish names the workspace.** At a terminal it says where the key works (`… in the workspace "Acme Studio" (Teams plan). Continue?`), and once you say yes the change is held to the workspace it named, so a key that turns out to work elsewhere changes nothing. With `--yes` or `--json` nothing is asked and nothing is added: a script gives `--expected-workspace` or sets the variable.
122
+ - Only the `widgetic mcp` commands are held.
123
+
124
+ ### When the workspace has no plan
125
+
126
+ A key is a credential for a paying workspace, and the CLI has no door of its own: it sends the key over REST and over MCP, so it is held to the same rule as the key everywhere else. A workspace in its free trial, or one that has no plan (the trial ended, the plan was cancelled, the payment ended), is not served.
127
+
128
+ - A `widgetic api` command exits with code 3 and prints the server's own words with its code (`WORKSPACE_LOCKED` when the workspace has no plan, `AUTHZ_PLAN_RESTRICTION` for a free trial or a payment that is overdue) and the request id. Nothing is retried, and it does not tell you to log in again: the key is genuine.
129
+ - `widgetic auth login` saves no such key and says why. `widgetic auth status` reports the key as not accepted and keeps it, so the same key works again as soon as the workspace has a plan.
130
+ - A free trial is refused by the MCP endpoint itself, so every `widgetic mcp` command exits with code 3. A workspace without a plan is let through to the tools, which refuse what starts work in the plan's words (exit code 5, a tool that answered with an error); `get_profile`, and following or cancelling a build that was already started, still answer.
123
131
 
124
132
  ### Environment variables
125
133
 
126
- | Variable | What it is |
127
- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- |
128
- | `WIDGETIC_API_KEY` | The API key. The one secret. |
129
- | `WIDGETIC_PROFILE` | The profile of the saved key when `--profile` is not given. |
130
- | `WIDGETIC_API_URL` | The REST address, to call another environment (https; http only for localhost). Default: the server of the OpenAPI description. |
131
- | `WIDGETIC_MCP_URL` | The MCP address. Default: `https://mcp.widgetic.com/`. |
132
- | `WIDGETIC_CONFIG_DIR` | The folder of the CLI's own files. Default: `~/.config/widgetic` (`$XDG_CONFIG_HOME/widgetic`, `%APPDATA%\widgetic` on Windows). |
133
- | `WIDGETIC_WORKSPACE` | The workspace every change of the `mcp` commands is held to: `personal`, or a team's name ([which workspace](#which-workspace-a-change-goes-to)). |
134
- | `WIDGETIC_DEBUG=1` | Print a stack with an unexpected error, and say why the CLI did not look for a newer version. |
135
- | `NO_UPDATE_NOTIFIER`, `WIDGETIC_NO_UPDATE_CHECK` | Set to anything but `0`, `false`, `no` or `off`: never look for a newer version or ask about one (`CI` does the same). |
136
- | `npm_config_registry` | The registry that the look for a newer version asks (default `https://registry.npmjs.org`); npm's own variable, https or http for localhost. |
134
+ | Variable | What it is |
135
+ | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
136
+ | `WIDGETIC_API_KEY` | The API key. The one secret. |
137
+ | `WIDGETIC_PROFILE` | The profile of the saved key when `--profile` is not given. |
138
+ | `WIDGETIC_API_URL` | The REST address, to call another environment (https; http only for localhost). Default: the server of the OpenAPI description. |
139
+ | `WIDGETIC_MCP_URL` | The MCP address. Default: `https://mcp.widgetic.com/`. |
140
+ | `WIDGETIC_CONFIG_DIR` | The folder of the CLI's own files. Default: `~/.config/widgetic` (`$XDG_CONFIG_HOME/widgetic`, `%APPDATA%\widgetic` on Windows). |
141
+ | `WIDGETIC_WORKSPACE` | The name of the workspace every change of the `mcp` commands is held to ([which workspace](#which-workspace-a-change-goes-to)). |
142
+ | `WIDGETIC_DEBUG=1` | Print a stack with an unexpected error, and say why the CLI did not look for a newer version. |
143
+ | `NO_UPDATE_NOTIFIER`, `WIDGETIC_NO_UPDATE_CHECK` | Set to anything but `0`, `false`, `no` or `off`: never look for a newer version or ask about one (`CI` does the same). |
144
+ | `npm_config_registry` | The registry that the look for a newer version asks (default `https://registry.npmjs.org`); npm's own variable, https or http for localhost. |
137
145
 
138
146
  ## Exit codes
139
147
 
@@ -6,6 +6,7 @@ import { CliError, EXIT_CODES, usageError } from "../errors.js";
6
6
  import { addBasicOptions, readCommon } from "../options.js";
7
7
  import { note, printResult, writeStdout } from "../output.js";
8
8
  import { retryNotifier } from "../retry.js";
9
+ import { quoted } from "../workspace.js";
9
10
  import { verifyApiKey } from "./verify.js";
10
11
  /**
11
12
  * `widgetic auth login | logout | status`: the one place the CLI's key is saved, forgotten and looked at. A key is read
@@ -52,6 +53,19 @@ function describeCheck(check) {
52
53
  const scopes = check.scopes.length === 0 ? 'no scopes listed' : `scopes: ${check.scopes.join(', ')}`;
53
54
  return `${check.tokenType ?? 'key'}; ${scopes}`;
54
55
  }
56
+ /**
57
+ * Where the key works, as a phrase: the workspace it was made for. A key made before the one workspace model names none
58
+ * and works in the person's default workspace. Nothing when the server did not say.
59
+ */
60
+ function describeKeyWorkspace(workspace) {
61
+ if (workspace === undefined)
62
+ return undefined;
63
+ if (workspace === null)
64
+ return 'your default workspace (this key names none)';
65
+ return workspace.name === null
66
+ ? `a workspace whose name could not be read (${workspace.id})`
67
+ : `the workspace ${quoted(workspace.name)}`;
68
+ }
55
69
  async function runLogin(environment, node) {
56
70
  const common = readCommon(node);
57
71
  const options = node.opts();
@@ -61,7 +75,7 @@ async function runLogin(environment, node) {
61
75
  throw usageError('That is not an API key: it holds spaces or characters a key never has.');
62
76
  }
63
77
  if (!common.json && !API_KEY_SHAPE.test(key)) {
64
- note(environment, 'note: that does not look like a Widgetic API key (they start with wgt_usr_, wgt_prt_ or wdg_org_); checking it anyway.');
78
+ note(environment, 'note: that does not look like a Widgetic API key (a workspace key starts with wdg_org_, a partner key with wgt_prt_); checking it anyway.');
65
79
  }
66
80
  // `--no-verify` is `verify: false`; without it the server is asked, and a key it refuses is never saved.
67
81
  const check = options.verify === false
@@ -91,15 +105,21 @@ async function runLogin(environment, node) {
91
105
  tokenType: check.tokenType,
92
106
  scopes: check.scopes,
93
107
  userId: check.userId,
94
- expiresAt: check.expiresAt
108
+ expiresAt: check.expiresAt,
109
+ // Only when the server said: `null` is "this key names none", which is an answer.
110
+ ...(check.workspace === undefined ? {} : { workspace: check.workspace })
95
111
  }
96
112
  : {})
97
113
  }, true);
98
114
  return;
99
115
  }
100
116
  const lines = [`Saved the key ${maskKey(key)} for the profile "${settings.profile}".`];
101
- if (check)
117
+ if (check) {
102
118
  lines.push(` The server accepted it (${describeCheck(check)}).`);
119
+ const where = describeKeyWorkspace(check.workspace);
120
+ if (where !== undefined)
121
+ lines.push(` It works in ${where}.`);
122
+ }
103
123
  else
104
124
  lines.push(' It was not checked with the server (--no-verify).');
105
125
  lines.push(` File: ${store.path} (only you can read it).`);
@@ -150,7 +170,8 @@ async function verdictOn(environment, settings, found, timeout, json) {
150
170
  tokenType: check.tokenType,
151
171
  scopes: check.scopes,
152
172
  userId: check.userId,
153
- expiresAt: check.expiresAt
173
+ expiresAt: check.expiresAt,
174
+ workspace: check.workspace
154
175
  },
155
176
  check,
156
177
  failure: undefined
@@ -226,6 +247,9 @@ async function runStatus(environment, node) {
226
247
  }
227
248
  if (verdict?.accepted && check) {
228
249
  lines.push(`Server: accepted (${describeCheck(check)}) at ${settings.apiUrl}`);
250
+ const where = describeKeyWorkspace(check.workspace);
251
+ if (where !== undefined)
252
+ lines.push(`Works in: ${where}`);
229
253
  }
230
254
  else if (verdict) {
231
255
  lines.push(verdict.checked
@@ -92,7 +92,7 @@ async function checkCredentials(context) {
92
92
  status: unusual ? 'warn' : 'ok',
93
93
  message: `${maskKey(key.apiKey)} from ${where} (profile "${settings.profile}")${unusual ? ', which does not look like a Widgetic key' : ''}`,
94
94
  details: { profile: settings.profile, source: key.source, key: maskKey(key.apiKey) },
95
- ...(unusual ? { hint: 'Keys start with wgt_usr_, wgt_prt_ or wdg_org_.' } : {})
95
+ ...(unusual ? { hint: 'A workspace key starts with wdg_org_ and a partner key with wgt_prt_.' } : {})
96
96
  });
97
97
  }
98
98
  if (await store.isReadableByOthers()) {
@@ -233,7 +233,7 @@ async function checkWorkspace(context, mcp) {
233
233
  if (pinned !== undefined) {
234
234
  if (pinned === '') {
235
235
  pinNote = ' WIDGETIC_WORKSPACE is set but names no workspace, so every change is refused.';
236
- pinProblem = 'Set WIDGETIC_WORKSPACE to "personal" or to the name of the team, or unset it.';
236
+ pinProblem = 'Set WIDGETIC_WORKSPACE to the name of the workspace, or unset it.';
237
237
  }
238
238
  else if (!contractHoldsWorkspaces(loadMcpManifest())) {
239
239
  pinNote = ` WIDGETIC_WORKSPACE is ${quoted(pinned)}, but this CLI cannot hold a change to a workspace, so every change is refused.`;
@@ -269,11 +269,11 @@ async function checkWorkspace(context, mcp) {
269
269
  switch (reading.status) {
270
270
  case 'known':
271
271
  return finish('ok', `This key works in ${describeWorkspace(reading.workspace)}.`, {
272
- kind: reading.workspace.kind,
273
- name: reading.workspace.name
272
+ name: reading.workspace.name,
273
+ plan: reading.workspace.plan
274
274
  });
275
275
  case 'not_reported':
276
- return finish('skip', 'The server did not say where this key works (a tool contract before 1.17.0, or the workspace could not be read just now).');
276
+ return finish('skip', 'The server did not say where this key works (a tool contract before 1.25.0, or the workspace could not be read just now).');
277
277
  case 'failed':
278
278
  return finish('warn', `Could not ask where this key works: ${reading.message}`);
279
279
  }
@@ -348,7 +348,7 @@ export function registerDoctorCommand(root, environment) {
348
348
  .command('doctor')
349
349
  // The line the list of commands of `widgetic --help` shows; the whole text is the help of `doctor` itself.
350
350
  .summary('Check the install, the API key and both servers, and say what is wrong.')
351
- .description('Check the install and both servers: the CLI and its contracts, the API key, the REST API, and the MCP server (which tool contract it speaks and which tools it offers, compared with this CLI). It also says in which workspace the key works, the person’s own or a team’s, which is where a change made with it goes.\n\nExit code 0 when nothing failed, 1 when a check did; --json prints every check.');
351
+ .description('Check the install and both servers: the CLI and its contracts, the API key, the REST API, and the MCP server (which tool contract it speaks and which tools it offers, compared with this CLI). It also says in which workspace the key works (its name and plan), which is where a change made with it goes.\n\nExit code 0 when nothing failed, 1 when a check did; --json prints every check.');
352
352
  addBasicOptions(doctor, { server: true });
353
353
  doctor.action(async () => {
354
354
  await runDoctor(environment, doctor);
@@ -1,6 +1,15 @@
1
1
  import { errorFromAnswer, isRecord, networkFailure, readAnswer } from "../http.js";
2
2
  import { withRetries } from "../retry.js";
3
3
  import { identityHeaders } from "../version.js";
4
+ /** The `workspace` of the answer: the workspace, none (`null`), or not said (`undefined`). */
5
+ function keyWorkspaceOf(workspace) {
6
+ if (workspace === null)
7
+ return null;
8
+ if (!isRecord(workspace) || typeof workspace.id !== 'string' || workspace.id === '')
9
+ return undefined;
10
+ const name = typeof workspace.name === 'string' && workspace.name.trim() !== '' ? workspace.name : null;
11
+ return { id: workspace.id, name };
12
+ }
4
13
  /** What the answer of `/tokens/validate` says about the key; a field the server did not send is `undefined`. */
5
14
  export function keyCheckOf(body) {
6
15
  const data = isRecord(body) && isRecord(body.data) ? body.data : {};
@@ -10,7 +19,8 @@ export function keyCheckOf(body) {
10
19
  ? data.scopes.filter((scope) => typeof scope === 'string')
11
20
  : [],
12
21
  userId: typeof data.userId === 'string' ? data.userId : undefined,
13
- expiresAt: typeof data.expiresAt === 'string' ? data.expiresAt : undefined
22
+ expiresAt: typeof data.expiresAt === 'string' ? data.expiresAt : undefined,
23
+ workspace: keyWorkspaceOf(data.workspace)
14
24
  };
15
25
  }
16
26
  /** The address a key is checked at. */
package/dist/constants.js CHANGED
@@ -10,7 +10,14 @@ export const DEFAULT_MCP_URL = 'https://mcp.widgetic.com/';
10
10
  export const DEFAULT_PROFILE = 'default';
11
11
  /** A profile is named like a file: letters, digits, dots, hyphens and underscores. */
12
12
  export const PROFILE_NAME = /^[A-Za-z0-9._-]{1,64}$/;
13
- /** What a Widgetic API key looks like (`wgt_usr_…`, `wgt_prt_…`, `wdg_org_…`): used to warn about a value that is not one, never to refuse one. */
13
+ /**
14
+ * What a Widgetic API key looks like (a workspace key `wdg_org_…`, a partner key `wgt_prt_…`, a staff key `wgt_adm_…`): used
15
+ * to warn about a value that is not one, never to refuse one.
16
+ *
17
+ * `wgt_usr_…`, the personal key, is no longer accepted by the gateway, and it stays in the pattern on purpose: it was a
18
+ * Widgetic key, and the gateway's refusal says what to do about it (make a workspace key in Settings > API keys), which is
19
+ * a better answer than a warning of ours that the value "does not look like" a key.
20
+ */
14
21
  export const API_KEY_SHAPE = /^(?:wgt_(?:adm|prt|usr)|wdg_org)_[A-Za-z0-9]{16,}$/;
15
22
  /**
16
23
  * What a person is told to do about the API key: with none at all, to make one in the dashboard and give it to the CLI;
@@ -103,7 +103,7 @@ export async function requireApiKey(environment, settings) {
103
103
  return found;
104
104
  throw noApiKey(settings);
105
105
  }
106
- /** `wgt_usr_…a1b2`: enough to tell two keys apart, nothing that works as a key. */
106
+ /** `wdg_org_…a1b2`: enough to tell two keys apart, nothing that works as a key. */
107
107
  export function maskKey(apiKey) {
108
108
  if (apiKey.length <= 12)
109
109
  return '…';
package/dist/overlay.js CHANGED
@@ -45,6 +45,7 @@ export const API_GROUP_SUMMARIES = {
45
45
  invoices: "A partner's invoices.",
46
46
  'managed-users': "A partner's managed users: their limits, design defaults and editor sessions.",
47
47
  operations: 'The status of work that goes on after the call that started it has answered.',
48
+ organizations: "A workspace's allowed websites: list, add, change and delete the websites that may show its widgets.",
48
49
  partners: 'A partner account: analytics, billing, presets, notifications, storage and data.',
49
50
  'public-embed': 'What the browser of a visitor calls to show and run a published widget; it needs no API key. Left out of the list.',
50
51
  tokens: 'Check that the API key in use is valid.',
@@ -74,10 +74,14 @@ export function flagSpecOf(parameter) {
74
74
  /**
75
75
  * The kind of key an operation needs, when it is not just any: said at the end of its help (so a limit on the length of
76
76
  * the description cannot cut it), because a 403 is the only other way to learn it.
77
+ *
78
+ * A partner operation takes the key of a partner (`wgt_prt_…`) and also a workspace key (`wdg_org_…`) made in the home
79
+ * workspace of a partner: the gateway gives that key the partner role, so the help names both.
77
80
  */
78
81
  export function accessNote(command) {
79
- if (command.accessLevel === 'partner')
80
- return 'Needs a partner API key (wgt_prt_…).';
82
+ if (command.accessLevel === 'partner') {
83
+ return 'Needs a partner API key (wgt_prt_…), or a key made in a partner workspace (wdg_org_…).';
84
+ }
81
85
  if (!command.auth)
82
86
  return 'Needs no API key: browsers call it, and none is sent.';
83
87
  return undefined;
package/dist/workspace.js CHANGED
@@ -3,12 +3,14 @@ import { isRecord } from "./http.js";
3
3
  /**
4
4
  * Holding a change to the workspace it was meant for.
5
5
  *
6
- * A key works in one workspace at a time: an organization key in its team's, a person's key in the workspace the
7
- * person has switched to on widgetic.com. That switch is shared, so every connection of the person moves with it, the
8
- * CLI's and an assistant's included, and `widgetic mcp save-workflow` can change the team's workflow while the person
9
- * is thinking of their own. The tools that change a workflow, an A/B test or a translation therefore take
10
- * `expected_workspace` (tool contract 1.17.0): `personal`, or the name of a team. The server refuses, and changes
11
- * nothing, when the key works anywhere else. The argument only asserts; nothing here picks or switches a workspace.
6
+ * A key works in one workspace, the one it was made for, and nowhere else (tool contract 1.25.0, the one workspace
7
+ * model: a person has no workspace of their own, and a key no longer follows the workspace the person has chosen on
8
+ * widgetic.com). A person with several workspaces has a key for each, and two terminals with two keys change two
9
+ * workspaces, so `widgetic mcp save-workflow` can change one workspace's workflow while the person is thinking of
10
+ * another. The tools that change a workflow, an A/B test or a translation therefore take `expected_workspace` (tool
11
+ * contract 1.17.0): the name of the workspace the change is for, as `get_profile` says it. The server refuses, and
12
+ * changes nothing, when the key works anywhere else. The argument only asserts; nothing here picks or switches a
13
+ * workspace.
12
14
  *
13
15
  * This is the CLI's side of it:
14
16
  *
@@ -20,8 +22,6 @@ import { isRecord } from "./http.js";
20
22
  */
21
23
  /** The argument of the tool contract that holds a change to a workspace. */
22
24
  export const WORKSPACE_ARGUMENT = 'expected_workspace';
23
- /** The word the server reads as the person's own workspace, in any case and spacing. */
24
- const PERSONAL_WORD = 'personal';
25
25
  /** The limit of the argument when a contract does not say (the gateway's own). */
26
26
  const DEFAULT_WORKSPACE_NAME_LIMIT = 100;
27
27
  /** How much of a name a line shows. */
@@ -51,7 +51,7 @@ export function holdToPinnedWorkspace(command, args, pin) {
51
51
  return;
52
52
  if (takesWorkspace(command)) {
53
53
  if (pin.value === '') {
54
- throw usageError(`WIDGETIC_WORKSPACE is set but names no workspace, so ${command.tool} was not sent.`, 'Set it to "personal" or to the name of the team, or unset it.');
54
+ throw usageError(`WIDGETIC_WORKSPACE is set but names no workspace, so ${command.tool} was not sent.`, 'Set it to the name of the workspace, or unset it.');
55
55
  }
56
56
  args[WORKSPACE_ARGUMENT] = pin.value;
57
57
  return;
@@ -63,6 +63,7 @@ export function holdToPinnedWorkspace(command, args, pin) {
63
63
  throw usageError(`WIDGETIC_WORKSPACE is set, but this CLI cannot hold ${command.tool} to a workspace (the tool contract it was built from has no ${WORKSPACE_ARGUMENT}): nothing was sent.`, 'Update the CLI: npm install -g @widgetic/cli@latest');
64
64
  }
65
65
  }
66
+ const WORKSPACE_PLANS = ['solo', 'teams', 'partner', 'shopify', 'none'];
66
67
  function firstLine(text) {
67
68
  const line = (text.split('\n')[0] ?? '').trim();
68
69
  return line.length > 200 ? `${line.slice(0, 200)}…` : line;
@@ -80,14 +81,20 @@ export async function readWorkspace(connection) {
80
81
  return { status: 'failed', message: firstLine(outcome.text) || `${PROFILE_TOOL} was refused` };
81
82
  }
82
83
  const workspace = outcome.structured?.workspace;
83
- if (isRecord(workspace) && (workspace.kind === 'personal' || workspace.kind === 'team')) {
84
+ if (isRecord(workspace)) {
84
85
  const name = typeof workspace.name === 'string' && workspace.name.trim() !== '' ? workspace.name : null;
85
- return { status: 'known', workspace: { kind: workspace.kind, name } };
86
+ const plan = typeof workspace.plan === 'string' && WORKSPACE_PLANS.includes(workspace.plan)
87
+ ? workspace.plan
88
+ : null;
89
+ // An answer with neither says nothing (the shape of a server before the one workspace model: `kind`, and no name for the
90
+ // person's own workspace, which no longer exists).
91
+ if (name !== null || plan !== null)
92
+ return { status: 'known', workspace: { name, plan } };
86
93
  }
87
94
  return { status: 'not_reported' };
88
95
  }
89
96
  /**
90
- * Text of someone else's (a team's name is typed by a stranger) or of the person's own, put in a line the terminal
97
+ * Text of someone else's (a workspace's name is typed by whoever made it, a colleague or a stranger who invited you), put in a line the terminal
91
98
  * shows: quoted as JSON, with the control and invisible characters JSON leaves alone written as escapes, so that
92
99
  * nothing in a name can move the cursor, hide the words around it or make the line read otherwise.
93
100
  */
@@ -96,35 +103,43 @@ export function quoted(text) {
96
103
  const clipped = letters.length > SHOWN_NAME_LIMIT ? `${letters.slice(0, SHOWN_NAME_LIMIT).join('')}…` : text;
97
104
  return JSON.stringify(clipped).replace(/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/gu, (character) => `\\u{${(character.codePointAt(0) ?? 0).toString(16)}}`);
98
105
  }
99
- /** Where a key works, as a phrase for a sentence. */
106
+ /** What a plan is called to the person. */
107
+ const PLAN_WORDS = {
108
+ solo: 'Solo plan',
109
+ teams: 'Teams plan',
110
+ partner: 'Partner plan',
111
+ shopify: 'Shopify store plan',
112
+ none: 'no active plan, so it is locked'
113
+ };
114
+ /** What a workspace is on, as a phrase for a sentence; nothing when the server did not say. */
115
+ export function describePlan(plan) {
116
+ return plan === null ? undefined : PLAN_WORDS[plan];
117
+ }
118
+ /** Where a key works, as a phrase for a sentence: `the workspace "Acme Studio" (Teams plan)`. */
100
119
  export function describeWorkspace(workspace) {
101
- if (workspace.kind === 'personal')
102
- return 'your own workspace';
103
- return workspace.name === null
104
- ? 'a team workspace (its name could not be read)'
105
- : `the team workspace ${quoted(workspace.name)}`;
120
+ const plan = describePlan(workspace.plan);
121
+ const place = workspace.name === null
122
+ ? 'a workspace whose name could not be read'
123
+ : `the workspace ${quoted(workspace.name)}`;
124
+ return plan === undefined ? place : `${place} (${plan})`;
106
125
  }
107
126
  /**
108
- * What a person who was shown this workspace and said yes can have the call held to: `personal`, or the team's name.
109
- * Nothing when the name cannot be given to the argument: it is not readable, it is longer than the contract allows,
110
- * or it reads as `personal` (the server takes that word for the person's own workspace).
127
+ * What a person who was shown this workspace and said yes can have the call held to: its name. Nothing when the name
128
+ * cannot be given to the argument: it is not readable, it reads as nothing, or it is longer than the contract allows.
111
129
  */
112
130
  export function assertionFor(workspace, command) {
113
- if (workspace.kind === 'personal')
114
- return 'personal';
115
131
  const name = workspace.name;
116
132
  if (name === null)
117
133
  return undefined;
118
134
  // The way the gateway reads a name (`tidy` in its workspaceExpectation.ts): compatibility form, one space for any run of
119
- // white space, no control or format characters, no edges, no capitals. A name that reads as nothing or as `personal`
120
- // cannot be sent as a team's: the server would take it for something else.
135
+ // white space, no control or format characters, no edges. A name that reads as nothing cannot be sent: the server
136
+ // would refuse it as blank (since 1.25.0 no name is special: `personal` is a name like any other).
121
137
  const read = name
122
138
  .normalize('NFKC')
123
139
  .replace(/\s+/gu, ' ')
124
140
  .replace(/[\p{Cc}\p{Cf}]/gu, '')
125
- .trim()
126
- .toLowerCase();
127
- if (read === '' || read === PERSONAL_WORD)
141
+ .trim();
142
+ if (read === '')
128
143
  return undefined;
129
144
  const property = isRecord(command.inputSchema.properties)
130
145
  ? command.inputSchema.properties[WORKSPACE_ARGUMENT]
@@ -7,7 +7,7 @@
7
7
  1. Run `widgetic doctor`. It checks the CLI, the API key, the REST API and the MCP server, and it says which workspace the key works in. Add `--json` to read every check.
8
8
  2. No key (exit code 3)? Ask the user to make one under Settings > API Keys in the dashboard (app.widgetic.com) and to run `widgetic auth login` in their own terminal: it asks for the key without showing it. Or they can start you with `WIDGETIC_API_KEY` set. The `widgetic mcp` commands need a key made with full access.
9
9
  3. Never ask for the key in the chat, put it in a command argument, write it to a file of the project or print it. A value the contract marks as a secret takes `@path` or `-` (standard input), never the text itself.
10
- 4. Say which workspace you are about to change before you create or change anything: a key works in one workspace at a time, the user's own or a team's. A change to a workflow, an A/B test or a translation can be held to the workspace the user means with `--expected-workspace`, or with `WIDGETIC_WORKSPACE` for a whole shell.
10
+ 4. Say which workspace you are about to change before you create or change anything: a key works in one workspace, the one it was made for, and a person with several workspaces has a key for each. `widgetic auth status` and `widgetic doctor` say which one it is. A change to a workflow, an A/B test or a translation can be held to the workspace the user means, by its name, with `--expected-workspace`, or with `WIDGETIC_WORKSPACE` for a whole shell.
11
11
 
12
12
  ## Find a command, then read its schema
13
13
 
package/docs/llms.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  # Widgetic CLI
2
2
 
3
- > `widgetic` is the command line of Widgetic, a service that builds interactive widgets (countdowns, quizzes, galleries and more), hosts them and gives the code to embed them. `widgetic api` runs the public REST API and `widgetic mcp` runs the AI build tools of the Widgetic MCP server. This copy describes the version it was installed with: 159 REST operations in 14 groups and 56 MCP tools (tool contract 1.24.1).
3
+ > `widgetic` is the command line of Widgetic, a service that builds interactive widgets (countdowns, quizzes, galleries and more), hosts them and gives the code to embed them. `widgetic api` runs the public REST API and `widgetic mcp` runs the AI build tools of the Widgetic MCP server. This copy describes the version it was installed with: 159 REST operations in 15 groups and 56 MCP tools (tool contract 1.25.0).
4
4
 
5
5
  Read the agent guide before you run a command: it says how to sign in without handling the API key, what to ask the user first, and how to build, publish and embed a widget. Then find a command below and read its schema with `widgetic schema`.
6
6
 
@@ -29,10 +29,11 @@ These work offline and always describe the version that is installed:
29
29
  - `invoices` (1 command): A partner's invoices (needs a partner key).
30
30
  - `managed-users` (18 commands): A partner's managed users: their limits, design defaults and editor sessions.
31
31
  - `operations` (1 command): The status of work that goes on after the call that started it has answered.
32
+ - `organizations` (4 commands): A workspace's allowed websites: list, add, change and delete the websites that may show its widgets.
32
33
  - `partners` (41 commands): A partner account: analytics, billing, presets, notifications, storage and data (needs a partner key).
33
34
  - `tokens` (1 command): Check that the API key in use is valid.
34
35
  - `uploads` (5 commands): Upload files, list and delete them, and see the upload limits.
35
- - `users` (13 commands): Your account: API keys, the websites that may show your widgets, and adapter connections.
36
+ - `users` (9 commands): Your account: API keys, the websites that may show your widgets, and adapter connections.
36
37
  - `widgets` (4 commands): Your library of widgets: list and create them, and start a composition from one.
37
38
  - `workflows` (19 commands): Workflows: create, edit, publish, pause and archive them, and restore their versions.
38
39
 
@@ -1 +1 @@
1
- {"package":"@widgetic/api-contracts","version":"1.11.142","publishTag":"latest","source":{"commit":"f78c9a1405bfecd4591c3a32323a3632df205d12","branch":null,"dirty":false,"atOriginMain":true},"openApi":{"file":"openapi-public.json","sha256":"9269c58a86e82c1ac672a987349b0d5ddda7fc01f4c52f8c36d51a0f156e14eb","paths":124,"operations":169,"servers":["https://api.widgetic.com/v1"]},"mcp":{"file":"mcp-tools.json","sha256":"6cdb18c91fecc40626d5ea23486adbea34063653b1142b6619122ace7e94a309","contractVersion":"1.24.1","serverName":"widgetic","tools":56}}
1
+ {"package":"@widgetic/api-contracts","version":"1.11.143","publishTag":"latest","source":{"commit":"a99cd5e84fcf9e3af7503f509bf4ab8360662cf2","branch":null,"dirty":false,"atOriginMain":true},"openApi":{"file":"openapi-public.json","sha256":"d4431ff8c9011d79cfe45371add0e012534d99a285867d4d90204058275c1959","paths":124,"operations":169,"servers":["https://api.widgetic.com/v1"]},"mcp":{"file":"mcp-tools.json","sha256":"2837877dd59ce5635d4d89407c22894a268e963c4aaf55214379d8be3d47b606","contractVersion":"1.25.0","serverName":"widgetic","tools":56}}