@artifactshare/cli 0.11.0 → 0.11.2

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
@@ -5,6 +5,14 @@ For user-facing announcements, see https://artifactshare.com/updates?product=cli
5
5
 
6
6
  ## Unreleased
7
7
 
8
+ ## 0.11.2 - 2026-08-12
9
+
10
+ - Direct agents with a user present to project-scoped browser login, and reserve API-token guidance for unattended CI or scripts without browser approval.
11
+
12
+ ## 0.11.1 - 2026-08-12
13
+
14
+ - Warn in `doctor` when an agent credential's approved project differs from the configured default destination, and provide an `init` command to align them.
15
+
8
16
  ## 0.11.0 - 2026-08-12
9
17
 
10
18
  - Add `login --preset agent` for browser-approved credentials restricted to one project, with scoped defaults and guidance across login, `whoami`, and `doctor`.
package/dist/index.js CHANGED
@@ -542,6 +542,7 @@ function authRecoveryDetails(baseUrl, loginCommand = `${CLI_INVOCATION} login --
542
542
  token_url: tokensUrl(baseUrl),
543
543
  env_var: TOKEN_ENV_VAR,
544
544
  login_command: loginCommand,
545
+ agent_login_command: `${loginCommand} --preset agent`,
545
546
  token_option: TOKEN_OPTION
546
547
  };
547
548
  }
@@ -551,7 +552,7 @@ function authRequiredError(baseUrl) {
551
552
  code: "auth_required",
552
553
  message: "Login is required.",
553
554
  why: `No ${TOKEN_ENV_VAR} or ${TOKEN_OPTION} value was provided.`,
554
- hint: `In an interactive terminal, run ${CLI_INVOCATION} login --profile default. In agents or CI, issue a token at ${url}, then set ${TOKEN_ENV_VAR} or pass ${TOKEN_OPTION}.`,
555
+ hint: `With a user present, run ${CLI_INVOCATION} login --profile default; for an agent, add --preset agent. In unattended CI or scripts without browser approval, issue a token at ${url}, then set ${TOKEN_ENV_VAR} or pass ${TOKEN_OPTION}.`,
555
556
  agentRecoverable: false,
556
557
  requiresHuman: true,
557
558
  recovery: { kind: "ask_human" },
@@ -564,7 +565,7 @@ function profileReauthRequiredError(baseUrl, source, profile) {
564
565
  code: "auth_required",
565
566
  message: "Login is required.",
566
567
  why: `The saved credential for profile "${profile}" is invalid or expired.`,
567
- hint: `In an interactive terminal, run ${loginCommand}. In agents or CI, issue a token at ${tokensUrl(baseUrl)}, then set ${TOKEN_ENV_VAR} or pass ${TOKEN_OPTION}.`,
568
+ hint: `With a user present, run ${loginCommand}; for an agent, add --preset agent. In unattended CI or scripts without browser approval, issue a token at ${tokensUrl(baseUrl)}, then set ${TOKEN_ENV_VAR} or pass ${TOKEN_OPTION}.`,
568
569
  agentRecoverable: false,
569
570
  requiresHuman: true,
570
571
  recovery: { kind: "ask_human" },
@@ -2148,7 +2149,7 @@ async function profileAuthRequired(source, profile, reason, options, globalConfi
2148
2149
  error: {
2149
2150
  ...error,
2150
2151
  why,
2151
- hint: `${switchHint} Or in an interactive terminal run ${CLI_INVOCATION} login --profile ${profile}. In agents or CI, issue a token at ${url}, then set ${TOKEN_ENV_VAR}.`,
2152
+ hint: `${switchHint} Or with a user present run ${CLI_INVOCATION} login --profile ${profile}; for an agent, add --preset agent. In unattended CI or scripts without browser approval, issue a token at ${url}, then set ${TOKEN_ENV_VAR}.`,
2152
2153
  agent_recoverable: true,
2153
2154
  requires_human: false,
2154
2155
  recovery: {
@@ -2170,7 +2171,7 @@ async function profileAuthRequired(source, profile, reason, options, globalConfi
2170
2171
  error: {
2171
2172
  ...error,
2172
2173
  why,
2173
- hint: `In an interactive terminal, run ${CLI_INVOCATION} login --profile ${profile}. In agents or CI, issue a token at ${url}, then set ${TOKEN_ENV_VAR}.`,
2174
+ hint: `With a user present, run ${CLI_INVOCATION} login --profile ${profile}; for an agent, add --preset agent. In unattended CI or scripts without browser approval, issue a token at ${url}, then set ${TOKEN_ENV_VAR}.`,
2174
2175
  details
2175
2176
  }
2176
2177
  };
@@ -3536,6 +3537,7 @@ function resolveDoctorNextCommand(data) {
3536
3537
  return LOGIN_COMMAND;
3537
3538
  }
3538
3539
  if ((data.auth.code === "auth_required" || data.auth.code === "token_invalid") && !bearerTokenBlocksLogin(data)) return data.auth.profile ? `${LOGIN_COMMAND} --profile ${data.auth.profile}` : LOGIN_COMMAND;
3540
+ if (data.destination.ok && data.destination.code === "agent_scope_mismatch") return data.destination.approved_project_id && data.auth.profile ? `${CLI_INVOCATION} init --profile ${data.auth.profile} --project-id ${data.destination.approved_project_id} --json` : null;
3539
3541
  return null;
3540
3542
  }
3541
3543
  function authRecovery(data, nextCommand) {
@@ -3640,6 +3642,9 @@ async function runDoctor(parsed, mode) {
3640
3642
  if (!body) throw new Error("Doctor response was not valid JSON.");
3641
3643
  data.auth.ok = body.auth?.ok ?? true;
3642
3644
  data.auth.email = body.user?.email ?? null;
3645
+ const authority = doctorAuthority(body.auth?.authority);
3646
+ if (authority) data.auth.authority = authority;
3647
+ applyAgentDestinationDiagnostic(data, authority);
3643
3648
  data.upload.checked = true;
3644
3649
  data.upload.ok = body.upload?.ok ?? false;
3645
3650
  if (!data.upload.ok) {
@@ -3648,6 +3653,30 @@ async function runDoctor(parsed, mode) {
3648
3653
  }
3649
3654
  return writeSuccess(command, doctorDataWithNextCommand(data), mode);
3650
3655
  }
3656
+ function doctorAuthority(value) {
3657
+ if (!value || typeof value !== "object") return null;
3658
+ const authority = value;
3659
+ if (authority.preset === "agent" && typeof authority.project_id === "string" && authority.project_id) return {
3660
+ preset: "agent",
3661
+ project_id: authority.project_id
3662
+ };
3663
+ if (authority.preset === "unrestricted" && (authority.project_id === null || authority.project_id === void 0)) return {
3664
+ preset: "unrestricted",
3665
+ project_id: null
3666
+ };
3667
+ return null;
3668
+ }
3669
+ function applyAgentDestinationDiagnostic(data, authority) {
3670
+ if (authority?.preset !== "agent" || !authority.project_id || !data.destination.ok || data.destination.project_id === authority.project_id) return;
3671
+ data.destination = {
3672
+ ok: true,
3673
+ type: data.destination.type,
3674
+ project_id: data.destination.project_id,
3675
+ approved_project_id: authority.project_id,
3676
+ code: "agent_scope_mismatch",
3677
+ hint: data.auth.profile ? `The configured default destination is outside this agent credential's approved project. Run ${CLI_INVOCATION} init --profile ${data.auth.profile} --project-id ${authority.project_id} --json to use the approved project by default.` : `The configured default destination is outside this agent credential's approved project. Pass --project-id ${authority.project_id} when sharing.`
3678
+ };
3679
+ }
3651
3680
  async function configDiagnostics(project) {
3652
3681
  const globalConfig = await readGlobalConfig();
3653
3682
  const cwd = process.cwd();
@@ -5728,7 +5757,8 @@ npx --yes @artifactshare/cli doctor --json
5728
5757
 
5729
5758
  Authentication:
5730
5759
  Interactive terminal: run ${CLI_INVOCATION} login --profile default, then approve in your browser.
5731
- Agents or CI: issue a token at ${DEFAULT_BASE_URL}/settings/tokens, then set ${TOKEN_ENV_VAR} or pass ${TOKEN_OPTION}.
5760
+ Agent with a user present: run ${CLI_INVOCATION} login --profile <name> --preset agent, then approve one project in your browser.
5761
+ Unattended CI or scripts: issue a token at ${DEFAULT_BASE_URL}/settings/tokens, then set ${TOKEN_ENV_VAR} or pass ${TOKEN_OPTION}.
5732
5762
 
5733
5763
  Common failures:
5734
5764
  auth_required Use ${TOKEN_ENV_VAR} or ${TOKEN_OPTION}; tokens are issued at ${DEFAULT_BASE_URL}/settings/tokens
@@ -5752,7 +5782,8 @@ const loginDefinition = define({
5752
5782
  npx --yes @artifactshare/cli login --profile client-a --preset agent --json
5753
5783
 
5754
5784
  login requires browser approval in an interactive terminal.
5755
- For agents or CI, issue a token at ${DEFAULT_BASE_URL}/settings/tokens, then pass it to normal commands with ${TOKEN_ENV_VAR} or ${TOKEN_OPTION}; do not pass the token to login.
5785
+ For an agent with a user present, use --preset agent and approve one project in the browser.
5786
+ For unattended CI or scripts without browser approval, issue a token at ${DEFAULT_BASE_URL}/settings/tokens, then pass it to normal commands with ${TOKEN_ENV_VAR} or ${TOKEN_OPTION}; do not pass the token to login.
5756
5787
 
5757
5788
  Common failures:
5758
5789
  auth_denied The browser approval was denied
@@ -6446,7 +6477,7 @@ const profilesImportTokenDefinition = define({
6446
6477
  },
6447
6478
  examples: `printf '%s' "$TOKEN" | npx --yes @artifactshare/cli profiles import-token --profile client-a --json
6448
6479
 
6449
- Reads the token from standard input only. Use this in agents or CI after issuing a token at ${DEFAULT_BASE_URL}/settings/tokens.
6480
+ Reads the token from standard input only. Use this in unattended CI or scripts without browser approval after issuing a token at ${DEFAULT_BASE_URL}/settings/tokens.
6450
6481
 
6451
6482
  Common failures:
6452
6483
  validation_failed Pass --profile and pipe a non-empty token on standard input
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artifactshare/cli",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
4
4
  "description": "Upload and share HTML, Markdown, folders, and static sites from terminals, AI agents, automation, and CI.",
5
5
  "homepage": "https://artifactshare.com/connect",
6
6
  "repository": {
@@ -65,14 +65,14 @@ contain `$`, spaces, `*`, or `?`; use single quotes such as
65
65
 
66
66
  ## Authentication
67
67
 
68
- - In non-interactive environments (agents, CI, scripts), ask the user to issue
69
- an API token at `https://artifactshare.com/settings/tokens`, then use
70
- `ARTIFACTSHARE_TOKEN` or `--token` for normal commands.
71
68
  - `login --profile <name> --preset agent --json` starts device login for a
72
69
  project-scoped agent profile. Omit `--preset` for unrestricted login. It may
73
70
  open the OS browser for approval. Use it when a user is present; the pending
74
71
  event on stderr includes `browser_open`. Do not pass API tokens to `login`.
75
72
  Profiles created by `login` renew expired CLI sessions automatically.
73
+ - In unattended CI or scripts without browser approval, ask the user to issue
74
+ an API token at `https://artifactshare.com/settings/tokens`, then use
75
+ `ARTIFACTSHARE_TOKEN` or `--token` for normal commands.
76
76
  - `logout --profile <name> --json` revokes a device-login refresh credential
77
77
  before removing it locally and leaves profile metadata in `config.json`.
78
78
  If remote revoke fails, the local credential is kept and logout fails.
@@ -49,7 +49,7 @@ contain `$`, spaces, `*`, or `?`; use single quotes such as
49
49
  exactly one of `--link-expires-at <RFC3339 UTC>` or `--no-link-expiry`; omit
50
50
  both to use the workspace default on share or preserve the current expiry on
51
51
  edit. Results expose `link_expires_at` as a UTC timestamp or `null`.
52
- - For an agent with a user present, prefer `login --preset agent --profile <name> --json` and let the user select one project during browser approval. In unattended CI or scripts, ask the user to issue an API token at `https://artifactshare.com/settings/tokens`, then run normal commands with `ARTIFACTSHARE_TOKEN` or `--token`; do not pass API tokens to `login`.
52
+ - For an agent with a user present, use `login --preset agent --profile <name> --json` and let the user select one project during browser approval. In unattended CI or scripts without browser approval, ask the user to issue an API token at `https://artifactshare.com/settings/tokens`, then run normal commands with `ARTIFACTSHARE_TOKEN` or `--token`; do not pass API tokens to `login`.
53
53
  - To save that token as a named profile without TTY or browser login, pipe it on standard input: `printf '%s' "$TOKEN" | npx --yes @artifactshare/cli profiles import-token --profile <name> --json`. Imported API-token profiles are not renewed by the CLI. Add `--allow-plaintext-token-store` only on a trusted machine without a native token store.
54
54
  - Use `login --profile <name> --json` when a user is present for browser approval. The pending event on stderr includes `browser_open`. Profiles created by `login` renew expired CLI sessions automatically.
55
55
  - Use `logout --profile <name> --json` to revoke a device-login credential before removing it locally; this keeps profile metadata. API-token profiles are removed locally only and their server token is not revoked.