@mercury-fw/utils 0.39.0 → 0.41.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @mercury-fw/utils
2
2
 
3
+ ## 0.41.0
4
+
5
+ ## 0.40.0
6
+
7
+ ### Minor Changes
8
+
9
+ - 0739f77: A plugin acts as the person Mercury is talking to, who logs in to the service through Mercury.
10
+
11
+ - Plugin contract version 4: a plugin declares `actsAs: "person" | "mercury"`, and one acting as the person contributes a `login`; its tools get the turn's `person` and `requireLogin` in their context.
12
+ - A person is offered only the plugins acting as the person: their prompt fragments, skills and tools. A plugin acting as Mercury, or declaring nothing, is offered on the terminal only until people can be allowed to make Mercury act as itself; the startup log names it.
13
+ - `createCliTool` adds `--user` with the person's id to every command, staged confirmations included, and when the CLI exits with code 3 (not logged in) returns their login instead. `createCliPersonLogin` builds a plugin's `login` on a CLI's two-step remote login. A failed `runCli` carries `exitCode`.
14
+ - Channel contract version 4: channels get `logins` (`accept` a callback URL, `complete` a login) and `detectLoginRequired`.
15
+ - The HTTP channel, with `HTTP_SURFACE_PUBLIC_URL` set, streams a `login` event with the link to open and takes the person back at `GET /login/callback`, public and protected by the single-use state.
16
+ - `mercury.cliCredentials` can declare `userSetup`, run by `mfw credentials setup <plugin> --user-app`: the app people log in through, set up without logging anyone in.
17
+ - plugin-jira and plugin-bitbucket act as the person, on CLIs 2.3.0: set up their people's app with `--user-app` and register `<HTTP_SURFACE_PUBLIC_URL>/login/callback` on it. Jira's skill now says `currentUser()` is the person.
18
+ - plugin-atlassian-admin acts as Mercury, on CLI 0.2.0, whose `init` asks for the key without echoing it: until permissions exist it's available on the terminal only.
19
+ - A third-party plugin needs `apiVersion: 4` to load, and `actsAs: "person"` with a `login` to be offered to people.
20
+
3
21
  ## 0.39.0
4
22
 
5
23
  ### Minor Changes
@@ -18,12 +18,14 @@ import { join } from "node:path";
18
18
  /** What a plugin declares: `name` as it was declared (the folder, or the
19
19
  * path), which `mfw credentials` takes; `path` relative to the home; and the
20
20
  * commands, each a binary on the container's PATH and its arguments: `setup`
21
- * sets up the service identity, `check` reports on the login, `logout`
22
- * removes one identity's login (the service's, or a person's with `--user`). */
21
+ * sets up the service identity, `userSetup` the app people log in through
22
+ * (no person logged in), `check` reports on the login, `logout` removes one
23
+ * identity's login (the service's, or a person's with `--user`). */
23
24
  export type DeclaredCredentials = {
24
25
  name: string;
25
26
  path: string;
26
27
  setup: string[];
28
+ userSetup?: string[];
27
29
  check?: string[];
28
30
  logout?: string[];
29
31
  };
@@ -50,7 +52,7 @@ const BINARY = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
50
52
  const ELSEWHERE = ".config/mercury-home";
51
53
 
52
54
  const INVALID =
53
- "invalid mercury.cliCredentials in package.json: expected { folder } with a single folder name under ~/.config, or { path } relative to the home and outside ~/.config, with setup (and optionally check, logout) as a binary name followed by its arguments, e.g. [\"jira\", \"init\"]";
55
+ "invalid mercury.cliCredentials in package.json: expected { folder } with a single folder name under ~/.config, or { path } relative to the home and outside ~/.config, with setup (and optionally userSetup, check, logout) as a binary name followed by its arguments, e.g. [\"jira\", \"init\"]";
54
56
 
55
57
  /** Whether `path` is a usable home-relative path for a login: inside the
56
58
  * home and outside `~/.config`, the volume, where a login is a `folder`. */
@@ -85,11 +87,15 @@ export function readCliCredentials(pkg: unknown): DeclaredCredentials | undefine
85
87
  if (!("cliCredentials" in mercury)) return undefined;
86
88
  const declared = (mercury as { cliCredentials?: unknown }).cliCredentials;
87
89
  if (typeof declared !== "object" || declared === null) throw new Error(INVALID);
88
- const { folder, path, setup, check, logout } = declared as Record<string, unknown>;
89
- if (!isCommand(setup) || (check !== undefined && !isCommand(check)) || (logout !== undefined && !isCommand(logout))) {
90
+ const { folder, path, setup, userSetup, check, logout } = declared as Record<string, unknown>;
91
+ const optional = { userSetup, check, logout };
92
+ if (!isCommand(setup) || Object.values(optional).some((c) => c !== undefined && !isCommand(c))) {
90
93
  throw new Error(INVALID);
91
94
  }
92
- const commands = { setup, ...(check === undefined ? {} : { check }), ...(logout === undefined ? {} : { logout }) };
95
+ const commands: Pick<DeclaredCredentials, "setup" | "userSetup" | "check" | "logout"> = { setup };
96
+ for (const [field, command] of Object.entries(optional) as [keyof typeof optional, string[] | undefined][]) {
97
+ if (command !== undefined) commands[field] = command;
98
+ }
93
99
  if (folder !== undefined && path === undefined && typeof folder === "string" && FOLDER.test(folder)) {
94
100
  return { name: folder, path: `.config/${folder}`, ...commands };
95
101
  }
@@ -1,12 +1,14 @@
1
1
  /** What a plugin declares: `name` as it was declared (the folder, or the
2
2
  * path), which `mfw credentials` takes; `path` relative to the home; and the
3
3
  * commands, each a binary on the container's PATH and its arguments: `setup`
4
- * sets up the service identity, `check` reports on the login, `logout`
5
- * removes one identity's login (the service's, or a person's with `--user`). */
4
+ * sets up the service identity, `userSetup` the app people log in through
5
+ * (no person logged in), `check` reports on the login, `logout` removes one
6
+ * identity's login (the service's, or a person's with `--user`). */
6
7
  export type DeclaredCredentials = {
7
8
  name: string;
8
9
  path: string;
9
10
  setup: string[];
11
+ userSetup?: string[];
10
12
  check?: string[];
11
13
  logout?: string[];
12
14
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mercury-fw/utils",
3
- "version": "0.39.0",
3
+ "version": "0.41.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",