@alwaysmeticulous/cli 2.283.2 → 2.284.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.
Files changed (54) hide show
  1. package/dist/command-utils/sentry.utils.js +12 -4
  2. package/dist/command-utils/sentry.utils.js.map +1 -1
  3. package/dist/commands/agent/screenshot-dom-diff.command.js +6 -3
  4. package/dist/commands/agent/screenshot-dom-diff.command.js.map +1 -1
  5. package/dist/commands/agent/screenshot-image-files.command.js +6 -3
  6. package/dist/commands/agent/screenshot-image-files.command.js.map +1 -1
  7. package/dist/commands/agent/screenshot-image.command.js +6 -3
  8. package/dist/commands/agent/screenshot-image.command.js.map +1 -1
  9. package/dist/commands/agent/test-run-diffs.command.js +6 -3
  10. package/dist/commands/agent/test-run-diffs.command.js.map +1 -1
  11. package/dist/commands/agent/timeline.command.js +6 -3
  12. package/dist/commands/agent/timeline.command.js.map +1 -1
  13. package/dist/commands/auth/index.js +11 -3
  14. package/dist/commands/auth/index.js.map +1 -1
  15. package/dist/commands/auth/set-project.command.d.ts +2 -0
  16. package/dist/commands/auth/set-project.command.js +73 -0
  17. package/dist/commands/auth/set-project.command.js.map +1 -0
  18. package/dist/commands/auth/unset-project.command.d.ts +2 -0
  19. package/dist/commands/auth/unset-project.command.js +26 -0
  20. package/dist/commands/auth/unset-project.command.js.map +1 -0
  21. package/dist/commands/auth/whoami.command.js +15 -11
  22. package/dist/commands/auth/whoami.command.js.map +1 -1
  23. package/dist/commands/ci/upload-assets.command.js +11 -9
  24. package/dist/commands/ci/upload-assets.command.js.map +1 -1
  25. package/dist/commands/ci/upload-container.command.js +11 -9
  26. package/dist/commands/ci/upload-container.command.js.map +1 -1
  27. package/dist/commands/debug/index.js +10 -4
  28. package/dist/commands/debug/index.js.map +1 -1
  29. package/dist/commands/download/test-run.command.js +6 -3
  30. package/dist/commands/download/test-run.command.js.map +1 -1
  31. package/dist/commands/local/relevant-sessions.command.js +10 -4
  32. package/dist/commands/local/relevant-sessions.command.js.map +1 -1
  33. package/dist/commands/project/show.command.js +10 -4
  34. package/dist/commands/project/show.command.js.map +1 -1
  35. package/dist/commands/record/login.command.js +10 -4
  36. package/dist/commands/record/login.command.js.map +1 -1
  37. package/dist/commands/record/session.command.js +12 -6
  38. package/dist/commands/record/session.command.js.map +1 -1
  39. package/dist/utils/__tests__/handle-auth-failure.spec.d.ts +1 -0
  40. package/dist/utils/__tests__/handle-auth-failure.spec.js +88 -0
  41. package/dist/utils/__tests__/handle-auth-failure.spec.js.map +1 -0
  42. package/dist/utils/__tests__/resolve-project-identifier.spec.d.ts +1 -0
  43. package/dist/utils/__tests__/resolve-project-identifier.spec.js +66 -0
  44. package/dist/utils/__tests__/resolve-project-identifier.spec.js.map +1 -0
  45. package/dist/utils/cli-user-error.d.ts +15 -0
  46. package/dist/utils/cli-user-error.js +27 -0
  47. package/dist/utils/cli-user-error.js.map +1 -0
  48. package/dist/utils/handle-auth-failure.d.ts +17 -0
  49. package/dist/utils/handle-auth-failure.js +61 -0
  50. package/dist/utils/handle-auth-failure.js.map +1 -0
  51. package/dist/utils/resolve-project-identifier.d.ts +23 -0
  52. package/dist/utils/resolve-project-identifier.js +47 -0
  53. package/dist/utils/resolve-project-identifier.js.map +1 -0
  54. package/package.json +9 -9
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d52b108e-b149-5324-8993-33af0279182e")}catch(e){}}();
3
+
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.CliUserError = void 0;
6
+ /**
7
+ * Thrown by command helpers (e.g. `resolveProjectIdentifier`,
8
+ * `handleAuthFailure`) when the command cannot proceed for a reason that
9
+ * is the user's responsibility — not a bug. `wrapHandler` prints the
10
+ * message and exits with the supplied code, without the generic
11
+ * `--help` tip or a stack trace.
12
+ *
13
+ * Use this instead of `process.exit(1)` inside utilities so that exit
14
+ * happens in one place (the top-level handler) and tests can assert on
15
+ * thrown behavior rather than process-level side effects.
16
+ */
17
+ class CliUserError extends Error {
18
+ exitCode;
19
+ constructor(message, exitCode = 1) {
20
+ super(message);
21
+ this.name = "CliUserError";
22
+ this.exitCode = exitCode;
23
+ }
24
+ }
25
+ exports.CliUserError = CliUserError;
26
+ //# sourceMappingURL=cli-user-error.js.map
27
+ //# debugId=d52b108e-b149-5324-8993-33af0279182e
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-user-error.js","sources":["../../src/utils/cli-user-error.ts"],"sourceRoot":"","names":[],"mappings":";;;;;AAAA;;;;;;;;;;GAUG;AACH,MAAa,YAAa,SAAQ,KAAK;IAC5B,QAAQ,CAAS;IAE1B,YAAY,OAAe,EAAE,QAAQ,GAAG,CAAC;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AARD,oCAQC","debugId":"d52b108e-b149-5324-8993-33af0279182e"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Handles a 401/403 response from an OAuth-authenticated request.
3
+ *
4
+ * - When the stored access token is genuinely past its `exp`, clears
5
+ * stored tokens so the next command kicks off a fresh OAuth login.
6
+ * - Otherwise (e.g. issuer/audience mismatch against the configured
7
+ * backend), keeps the tokens and surfaces the backend's actual
8
+ * rejection message plus a pointer to `meticulous auth logout`.
9
+ *
10
+ * Throws `CliUserError` when the error is an auth failure, so the
11
+ * command exits non-zero via `wrapHandler`. Returns `false` (no throw)
12
+ * when the error is not an auth failure — the caller should rethrow.
13
+ *
14
+ * Typical use at a call site:
15
+ * try { ... } catch (error) { handleAuthFailure(error); throw error; }
16
+ */
17
+ export declare const handleAuthFailure: (error: unknown) => false;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a9ff3b13-559c-5b71-b2ff-d7b1ed03e03b")}catch(e){}}();
3
+
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.handleAuthFailure = void 0;
6
+ const client_1 = require("@alwaysmeticulous/client");
7
+ const cli_user_error_1 = require("./cli-user-error");
8
+ /**
9
+ * Handles a 401/403 response from an OAuth-authenticated request.
10
+ *
11
+ * - When the stored access token is genuinely past its `exp`, clears
12
+ * stored tokens so the next command kicks off a fresh OAuth login.
13
+ * - Otherwise (e.g. issuer/audience mismatch against the configured
14
+ * backend), keeps the tokens and surfaces the backend's actual
15
+ * rejection message plus a pointer to `meticulous auth logout`.
16
+ *
17
+ * Throws `CliUserError` when the error is an auth failure, so the
18
+ * command exits non-zero via `wrapHandler`. Returns `false` (no throw)
19
+ * when the error is not an auth failure — the caller should rethrow.
20
+ *
21
+ * Typical use at a call site:
22
+ * try { ... } catch (error) { handleAuthFailure(error); throw error; }
23
+ */
24
+ const handleAuthFailure = (error) => {
25
+ if (!(0, client_1.isFetchError)(error)) {
26
+ return false;
27
+ }
28
+ const status = error.response?.status;
29
+ if (status !== 401 && status !== 403) {
30
+ return false;
31
+ }
32
+ const stored = (0, client_1.getStoredOAuthTokens)();
33
+ const expired = stored ? (0, client_1.isJwtExpired)(stored.accessToken) : false;
34
+ if (expired) {
35
+ (0, client_1.clearOAuthTokens)();
36
+ throw new cli_user_error_1.CliUserError("Your stored OAuth token has expired and could not be refreshed. " +
37
+ "Re-run the command to start a fresh login.");
38
+ }
39
+ const serverMessage = extractServerMessage(error.response?.data);
40
+ const detail = serverMessage ? `: ${serverMessage}` : ".";
41
+ throw new cli_user_error_1.CliUserError(`Authentication failed (HTTP ${status})${detail}\n` +
42
+ "If the token is stale, run `meticulous auth logout` and re-run the command.");
43
+ };
44
+ exports.handleAuthFailure = handleAuthFailure;
45
+ const extractServerMessage = (data) => {
46
+ if (!data) {
47
+ return null;
48
+ }
49
+ if (typeof data === "string") {
50
+ return data;
51
+ }
52
+ if (typeof data === "object") {
53
+ const message = data.message;
54
+ if (typeof message === "string") {
55
+ return message;
56
+ }
57
+ }
58
+ return null;
59
+ };
60
+ //# sourceMappingURL=handle-auth-failure.js.map
61
+ //# debugId=a9ff3b13-559c-5b71-b2ff-d7b1ed03e03b
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-auth-failure.js","sources":["../../src/utils/handle-auth-failure.ts"],"sourceRoot":"","names":[],"mappings":";;;;;AAAA,qDAKkC;AAClC,qDAAgD;AAEhD;;;;;;;;;;;;;;;GAeG;AACI,MAAM,iBAAiB,GAAG,CAAC,KAAc,EAAS,EAAE;IACzD,IAAI,CAAC,IAAA,qBAAY,EAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC;IACtC,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,MAAM,GAAG,IAAA,6BAAoB,GAAE,CAAC;IACtC,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,IAAA,qBAAY,EAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAElE,IAAI,OAAO,EAAE,CAAC;QACZ,IAAA,yBAAgB,GAAE,CAAC;QACnB,MAAM,IAAI,6BAAY,CACpB,kEAAkE;YAChE,4CAA4C,CAC/C,CAAC;IACJ,CAAC;IAED,MAAM,aAAa,GAAG,oBAAoB,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACjE,MAAM,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,KAAK,aAAa,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IAC1D,MAAM,IAAI,6BAAY,CACpB,+BAA+B,MAAM,IAAI,MAAM,IAAI;QACjD,6EAA6E,CAChF,CAAC;AACJ,CAAC,CAAC;AA1BW,QAAA,iBAAiB,qBA0B5B;AAEF,MAAM,oBAAoB,GAAG,CAAC,IAAa,EAAiB,EAAE;IAC5D,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAI,IAA8B,CAAC,OAAO,CAAC;QACxD,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,OAAO,CAAC;QACjB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","debugId":"a9ff3b13-559c-5b71-b2ff-d7b1ed03e03b"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Resolves the project identifier for project-scoped CLI commands given the
3
+ * resolved API token.
4
+ *
5
+ * - OAuth tokens are user-scoped (not project-scoped), so they require a
6
+ * stored project id (set via `meticulous auth set-project`).
7
+ * - Project-scoped API tokens already pin the project, so no extra
8
+ * identifier is needed.
9
+ *
10
+ * Throws `CliUserError` when an OAuth caller has no project selected. The
11
+ * top-level `wrapHandler` catches it and exits non-zero with the message.
12
+ */
13
+ export declare const resolveProjectIdentifier: (apiToken: string) => {
14
+ projectId?: string;
15
+ };
16
+ /**
17
+ * Best-effort lookup of the stored projectId for OAuth callers. Returns
18
+ * `undefined` for project-scoped API tokens (the token already pins the
19
+ * project) and for OAuth tokens with no stored project. Use this for calls
20
+ * where the project context is useful but not strictly required — e.g. agent
21
+ * telemetry — and a missing project should not abort the command.
22
+ */
23
+ export declare const getProjectIdForOAuthCaller: (apiToken: string) => string | undefined;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f092b81e-09f7-584b-b411-20150da1cf58")}catch(e){}}();
3
+
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.getProjectIdForOAuthCaller = exports.resolveProjectIdentifier = void 0;
6
+ const client_1 = require("@alwaysmeticulous/client");
7
+ const cli_user_error_1 = require("./cli-user-error");
8
+ /**
9
+ * Resolves the project identifier for project-scoped CLI commands given the
10
+ * resolved API token.
11
+ *
12
+ * - OAuth tokens are user-scoped (not project-scoped), so they require a
13
+ * stored project id (set via `meticulous auth set-project`).
14
+ * - Project-scoped API tokens already pin the project, so no extra
15
+ * identifier is needed.
16
+ *
17
+ * Throws `CliUserError` when an OAuth caller has no project selected. The
18
+ * top-level `wrapHandler` catches it and exits non-zero with the message.
19
+ */
20
+ const resolveProjectIdentifier = (apiToken) => {
21
+ if (!(0, client_1.isOAuthJwt)(apiToken)) {
22
+ return {};
23
+ }
24
+ const projectId = (0, client_1.getStoredProjectId)();
25
+ if (!projectId) {
26
+ throw new cli_user_error_1.CliUserError("No project selected. Run `meticulous auth set-project` to choose " +
27
+ "one before running OAuth-authenticated commands.");
28
+ }
29
+ return { projectId };
30
+ };
31
+ exports.resolveProjectIdentifier = resolveProjectIdentifier;
32
+ /**
33
+ * Best-effort lookup of the stored projectId for OAuth callers. Returns
34
+ * `undefined` for project-scoped API tokens (the token already pins the
35
+ * project) and for OAuth tokens with no stored project. Use this for calls
36
+ * where the project context is useful but not strictly required — e.g. agent
37
+ * telemetry — and a missing project should not abort the command.
38
+ */
39
+ const getProjectIdForOAuthCaller = (apiToken) => {
40
+ if (!(0, client_1.isOAuthJwt)(apiToken)) {
41
+ return undefined;
42
+ }
43
+ return (0, client_1.getStoredProjectId)() ?? undefined;
44
+ };
45
+ exports.getProjectIdForOAuthCaller = getProjectIdForOAuthCaller;
46
+ //# sourceMappingURL=resolve-project-identifier.js.map
47
+ //# debugId=f092b81e-09f7-584b-b411-20150da1cf58
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-project-identifier.js","sources":["../../src/utils/resolve-project-identifier.ts"],"sourceRoot":"","names":[],"mappings":";;;;;AAAA,qDAA0E;AAC1E,qDAAgD;AAEhD;;;;;;;;;;;GAWG;AACI,MAAM,wBAAwB,GAAG,CACtC,QAAgB,EACQ,EAAE;IAC1B,IAAI,CAAC,IAAA,mBAAU,EAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,SAAS,GAAG,IAAA,2BAAkB,GAAE,CAAC;IACvC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,6BAAY,CACpB,mEAAmE;YACjE,kDAAkD,CACrD,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,CAAC;AACvB,CAAC,CAAC;AAfW,QAAA,wBAAwB,4BAenC;AAEF;;;;;;GAMG;AACI,MAAM,0BAA0B,GAAG,CACxC,QAAgB,EACI,EAAE;IACtB,IAAI,CAAC,IAAA,mBAAU,EAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,IAAA,2BAAkB,GAAE,IAAI,SAAS,CAAC;AAC3C,CAAC,CAAC;AAPW,QAAA,0BAA0B,8BAOrC","debugId":"f092b81e-09f7-584b-b411-20150da1cf58"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alwaysmeticulous/cli",
3
- "version": "2.283.2",
3
+ "version": "2.284.0",
4
4
  "description": "The Meticulous CLI",
5
5
  "license": "ISC",
6
6
  "main": "dist/index.js",
@@ -24,17 +24,17 @@
24
24
  "tar": "^7.5.8",
25
25
  "yargs": "^17.5.1",
26
26
  "@alwaysmeticulous/api": "2.283.1",
27
+ "@alwaysmeticulous/client": "2.284.0",
27
28
  "@alwaysmeticulous/common": "2.283.1",
28
- "@alwaysmeticulous/debug-workspace": "2.283.1",
29
- "@alwaysmeticulous/client": "2.283.1",
30
- "@alwaysmeticulous/downloading-helpers": "2.283.1",
31
- "@alwaysmeticulous/remote-replay-launcher": "2.283.1",
29
+ "@alwaysmeticulous/debug-workspace": "2.284.0",
30
+ "@alwaysmeticulous/downloading-helpers": "2.284.0",
31
+ "@alwaysmeticulous/record": "2.283.1",
32
+ "@alwaysmeticulous/remote-replay-launcher": "2.284.0",
32
33
  "@alwaysmeticulous/replay-debugger-ui": "2.283.1",
34
+ "@alwaysmeticulous/replay-orchestrator-launcher": "2.284.0",
33
35
  "@alwaysmeticulous/sdk-bundles-api": "2.283.1",
34
- "@alwaysmeticulous/record": "2.283.1",
35
- "@alwaysmeticulous/tunnels-client": "2.283.1",
36
- "@alwaysmeticulous/replay-orchestrator-launcher": "2.283.1",
37
- "@alwaysmeticulous/sentry": "2.283.2"
36
+ "@alwaysmeticulous/sentry": "2.283.2",
37
+ "@alwaysmeticulous/tunnels-client": "2.283.1"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/cli-progress": "^3.11.5",