sim 2.2.24-preview.285.1 → 2.2.25-preview.287.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.
@@ -17,9 +17,23 @@ export interface MintedKey {
17
17
  workspaceId: string | null;
18
18
  /** Whether the key can *only* reach that workspace. */
19
19
  workspaceBound: boolean;
20
+ /**
21
+ * The access the key was minted with, or null from a server that predates
22
+ * read-only handoff keys — which mints full access whatever was asked.
23
+ */
24
+ access: KeyAccess | null;
25
+ /** When the key expires; null when it never does or the server did not say. */
26
+ expiresAt: string | null;
27
+ }
28
+ type KeyAccess = 'read' | 'write';
29
+ /** What the terminal asks the minted key to be; the browser approval decides. */
30
+ export interface KeyRequest {
31
+ readOnly: boolean;
32
+ /** Whole days until the key expires; undefined for a key that never expires. */
33
+ expiresInDays?: number;
20
34
  }
21
35
  export declare function createAuthRequest(): AuthRequest;
22
- export declare function buildApprovalUrl(endpoint: string, auth: AuthRequest, workspaceId?: string): string;
36
+ export declare function buildApprovalUrl(endpoint: string, auth: AuthRequest, workspaceId?: string, keyRequest?: KeyRequest): string;
23
37
  /**
24
38
  * Polls until the user approves in the browser.
25
39
  *
@@ -1502,6 +1502,7 @@ export type CreateCredentialConnectionBody = {
1502
1502
  };
1503
1503
  type CreateCredentialConnectionResponseRef0 = {
1504
1504
  authorizationUrl: string;
1505
+ draftId: string;
1505
1506
  expiresAt: string;
1506
1507
  };
1507
1508
  export type CreateCredentialConnectionResponse = {
@@ -4874,6 +4875,14 @@ type GetMetaResponseRef0 = {
4874
4875
  keyType: 'personal' | 'workspace' | 'oauth_access_token';
4875
4876
  expiresAt: string | null;
4876
4877
  scopes: Array<'api:read' | 'api:write' | 'search:read'>;
4878
+ keyId: string | null;
4879
+ userId: string | null;
4880
+ workspaceId: string | null;
4881
+ links: {
4882
+ openapi: string;
4883
+ docs: string;
4884
+ mcp: string;
4885
+ };
4877
4886
  };
4878
4887
  export type GetMetaResponse = {
4879
4888
  data: GetMetaResponseRef0;
@@ -11739,6 +11748,27 @@ type UpdateWorkflowVersionResponseRef0 = {
11739
11748
  export type UpdateWorkflowVersionResponse = {
11740
11749
  data: UpdateWorkflowVersionResponseRef0;
11741
11750
  };
11751
+ /** `PATCH /api/v2/workspaces/[workspaceId]` */
11752
+ export type UpdateWorkspaceParams = {
11753
+ workspaceId: string;
11754
+ };
11755
+ export type UpdateWorkspaceQuery = Record<string, unknown>;
11756
+ export type UpdateWorkspaceBody = {
11757
+ name?: string;
11758
+ logoUrl?: string | null;
11759
+ };
11760
+ type UpdateWorkspaceResponseRef0 = {
11761
+ id: string;
11762
+ name: string;
11763
+ color: string;
11764
+ logoUrl: string | null;
11765
+ memberCount: number;
11766
+ createdAt: string;
11767
+ updatedAt: string;
11768
+ };
11769
+ export type UpdateWorkspaceResponse = {
11770
+ data: UpdateWorkspaceResponseRef0;
11771
+ };
11742
11772
  /** `PUT /api/v2/workspaces/[workspaceId]/fork/exclusions` */
11743
11773
  export type UpdateWorkspaceForkExclusionsParams = {
11744
11774
  workspaceId: string;
@@ -21302,6 +21332,27 @@ export declare const V2_OPERATIONS: {
21302
21332
  };
21303
21333
  };
21304
21334
  };
21335
+ readonly updateWorkspace: {
21336
+ readonly method: 'PATCH';
21337
+ readonly path: '/api/v2/workspaces/[workspaceId]';
21338
+ readonly pathParams: readonly ['workspaceId'];
21339
+ readonly pathParamDocs: {
21340
+ readonly workspaceId: 'Workspace to update.';
21341
+ };
21342
+ readonly responseMode: 'json';
21343
+ readonly summary: 'Update workspace';
21344
+ readonly workspaceKeyUnsupported: true;
21345
+ readonly body: {
21346
+ readonly name: {
21347
+ readonly kind: 'string';
21348
+ readonly describe: 'New workspace display name.';
21349
+ };
21350
+ readonly logoUrl: {
21351
+ readonly kind: 'string';
21352
+ readonly describe: 'New workspace logo URL: a root-relative path (starting with /) or an https:// URL. Send null to remove the logo.';
21353
+ };
21354
+ };
21355
+ };
21305
21356
  readonly updateWorkspaceForkExclusions: {
21306
21357
  readonly method: 'PUT';
21307
21358
  readonly path: '/api/v2/workspaces/[workspaceId]/fork/exclusions';
package/dist/index.js CHANGED
@@ -9402,13 +9402,15 @@ function createAuthRequest() {
9402
9402
  pairing: pairingCode()
9403
9403
  };
9404
9404
  }
9405
- function buildApprovalUrl(endpoint, auth, workspaceId) {
9405
+ function buildApprovalUrl(endpoint, auth, workspaceId, keyRequest = { readOnly: false }) {
9406
9406
  return buildUrl(endpoint, APPROVAL_PATH, {
9407
9407
  request: auth.request,
9408
9408
  challenge: auth.challenge,
9409
9409
  pairing: auth.pairing,
9410
9410
  scope: "platform",
9411
- workspace: workspaceId
9411
+ workspace: workspaceId,
9412
+ access: keyRequest.readOnly ? "read" : undefined,
9413
+ expires: keyRequest.expiresInDays
9412
9414
  });
9413
9415
  }
9414
9416
  function toRedirectError(endpoint, response) {
@@ -9485,7 +9487,9 @@ async function pollForKey(endpoint, auth, signal) {
9485
9487
  apiKey: body.key.apiKey,
9486
9488
  scope: body.scope ?? "copilot",
9487
9489
  workspaceId: body.workspaceId ?? null,
9488
- workspaceBound: body.workspaceBound === true
9490
+ workspaceBound: body.workspaceBound === true,
9491
+ access: body.access === "read" || body.access === "write" ? body.access : null,
9492
+ expiresAt: typeof body.expiresAt === "string" ? body.expiresAt : null
9489
9493
  };
9490
9494
  }
9491
9495
  }
@@ -18099,6 +18103,22 @@ var V2_OPERATIONS = {
18099
18103
  }
18100
18104
  }
18101
18105
  },
18106
+ updateWorkspace: {
18107
+ method: "PATCH",
18108
+ path: "/api/v2/workspaces/[workspaceId]",
18109
+ pathParams: ["workspaceId"],
18110
+ pathParamDocs: { workspaceId: "Workspace to update." },
18111
+ responseMode: "json",
18112
+ summary: "Update workspace",
18113
+ workspaceKeyUnsupported: true,
18114
+ body: {
18115
+ name: { kind: "string", describe: "New workspace display name." },
18116
+ logoUrl: {
18117
+ kind: "string",
18118
+ describe: "New workspace logo URL: a root-relative path (starting with /) or an https:// URL. Send null to remove the logo."
18119
+ }
18120
+ }
18121
+ },
18102
18122
  updateWorkspaceForkExclusions: {
18103
18123
  method: "PUT",
18104
18124
  path: "/api/v2/workspaces/[workspaceId]/fork/exclusions",
@@ -18537,6 +18557,17 @@ function addProfileCommand() {
18537
18557
  printLine(styles3().dim(` Try: sim --profile ${safeOneLine(profileName)} whoami`));
18538
18558
  });
18539
18559
  }
18560
+ var MIN_KEY_EXPIRY_DAYS = 1;
18561
+ var MAX_KEY_EXPIRY_DAYS = 365;
18562
+ function parseExpiresIn(value) {
18563
+ if (value === undefined)
18564
+ return;
18565
+ const days = Number(value);
18566
+ if (!/^\d+$/.test(value.trim()) || days < MIN_KEY_EXPIRY_DAYS || days > MAX_KEY_EXPIRY_DAYS) {
18567
+ throw new SimApiError(`Invalid --expires-in "${redact(value)}". Use a whole number of days from ${MIN_KEY_EXPIRY_DAYS} to ${MAX_KEY_EXPIRY_DAYS}.`, 0);
18568
+ }
18569
+ return days;
18570
+ }
18540
18571
  async function chooseLoginFlow(profile, options) {
18541
18572
  requireSecureEndpoint(profile.endpoint);
18542
18573
  if (options.method === "api-key")
@@ -18632,7 +18663,7 @@ Waiting for you to approve in the browser…`));
18632
18663
  }
18633
18664
  }
18634
18665
  function loginCommand() {
18635
- return new Command("login").description("Log in through the browser and store the login for the profile").addOption(new Option("--method <method>", "Credential to obtain: oauth requires OAuth support; api-key creates a permanent key through pairing (auto-selects when omitted)").choices(["oauth", "api-key"])).option("--no-browser", "Print the approval URL without opening it (either login method)").option("--read-only", "Ask only for permission to read, never to change anything").option("--callback-port <port>", "Pin the local port the browser returns to").option("-y, --yes", "Overwrite an existing API-key profile without prompting").action(async (options, command) => {
18666
+ return new Command("login").description("Log in through the browser and store the login for the profile").addOption(new Option("--method <method>", "Credential to obtain: oauth requires OAuth support; api-key creates an API key through pairing (auto-selects when omitted)").choices(["oauth", "api-key"])).option("--no-browser", "Print the approval URL without opening it (either login method)").option("--read-only", "Ask only for permission to read, never to change anything").option("--expires-in <days>", `API-key login only: days until the key expires (${MIN_KEY_EXPIRY_DAYS}-${MAX_KEY_EXPIRY_DAYS}); omit for a key that never expires`).option("--callback-port <port>", "Pin the local port the browser returns to").option("-y, --yes", "Overwrite an existing API-key profile without prompting").action(async (options, command) => {
18636
18667
  const profile = profileFrom(command, { allowUnknownProfile: true });
18637
18668
  const authProfile = resolveAuthenticationProfileName(profile.name);
18638
18669
  if (authProfile !== profile.name) {
@@ -18651,14 +18682,13 @@ function loginCommand() {
18651
18682
  }
18652
18683
  }
18653
18684
  const callbackPort = parseCallbackPort(options.callbackPort);
18685
+ const expiresInDays = parseExpiresIn(options.expiresIn);
18654
18686
  const loginFlow = await chooseLoginFlow(profile, options);
18655
- if (loginFlow === "handoff") {
18656
- if (options.readOnly) {
18657
- throw new SimApiError("API-key login cannot issue a read-only login. Use --method oauth, or drop --read-only.", 0);
18658
- }
18659
- if (callbackPort !== undefined) {
18660
- throw new SimApiError("API-key login has no local callback, so --callback-port does not apply. Use --method oauth, or drop --callback-port.", 0);
18661
- }
18687
+ if (loginFlow === "handoff" && callbackPort !== undefined) {
18688
+ throw new SimApiError("API-key login has no local callback, so --callback-port does not apply. Use --method oauth, or drop --callback-port.", 0);
18689
+ }
18690
+ if (loginFlow === "oauth" && expiresInDays !== undefined) {
18691
+ throw new SimApiError("OAuth logins renew themselves, so --expires-in does not apply. Use --method api-key, or drop --expires-in.", 0);
18662
18692
  }
18663
18693
  await withProfileLoginLease(profile.name, async () => {
18664
18694
  assertLoginProfileUnchanged(profile.name, snapshot);
@@ -18666,13 +18696,35 @@ function loginCommand() {
18666
18696
  await loginWithOAuth(profile, options, callbackPort, snapshot);
18667
18697
  return;
18668
18698
  }
18669
- await loginWithHandoff(profile, options, snapshot);
18699
+ await loginWithHandoff(profile, options, { readOnly: options.readOnly === true, expiresInDays }, snapshot);
18670
18700
  });
18671
18701
  });
18672
18702
  }
18673
- async function loginWithHandoff(profile, options, expected) {
18703
+ var DAY_MS = 24 * 60 * 60 * 1000;
18704
+ var EXPIRY_TOLERANCE_MS = 60 * 60 * 1000;
18705
+ function requireRequestedKey(key, keyRequest) {
18706
+ const refuse = (issued, flag) => new SimApiError(`The server issued ${issued}, not the key requested. Nothing was stored; update the Sim deployment or adjust ${flag}.`, 0);
18707
+ const requestedAccess = keyRequest.readOnly ? "read" : "write";
18708
+ const issuedAccess = key.access ?? "write";
18709
+ if (issuedAccess !== requestedAccess) {
18710
+ throw refuse(issuedAccess === "read" ? "a read-only key" : "a full-access key", "--read-only");
18711
+ }
18712
+ if (keyRequest.expiresInDays === undefined) {
18713
+ if (key.expiresAt)
18714
+ throw refuse(`a key that expires ${safeOneLine(key.expiresAt ?? "")}`, "--expires-in");
18715
+ return;
18716
+ }
18717
+ const expiresAt = key.expiresAt ? Date.parse(key.expiresAt) : Number.NaN;
18718
+ if (Number.isNaN(expiresAt))
18719
+ throw refuse("a key that never expires", "--expires-in");
18720
+ const requested = Date.now() + keyRequest.expiresInDays * DAY_MS;
18721
+ if (Math.abs(expiresAt - requested) > EXPIRY_TOLERANCE_MS) {
18722
+ throw refuse(`a key that expires ${safeOneLine(key.expiresAt ?? "")}`, "--expires-in");
18723
+ }
18724
+ }
18725
+ async function loginWithHandoff(profile, options, keyRequest, expected) {
18674
18726
  const auth = createAuthRequest();
18675
- const url = buildApprovalUrl(profile.endpoint, auth, profile.workspaceId ?? undefined);
18727
+ const url = buildApprovalUrl(profile.endpoint, auth, profile.workspaceId ?? undefined, keyRequest);
18676
18728
  printLine(`Signing in to ${styles3().bold(profile.endpoint)} as profile ${styles3().bold(safeOneLine(profile.name))}`);
18677
18729
  printLine(`
18678
18730
  Pairing code: ${styles3().bold(auth.pairing)}`);
@@ -18688,6 +18740,7 @@ Waiting for approval…`));
18688
18740
  if (key.scope !== "platform") {
18689
18741
  throw new SimApiError(`Server issued a ${key.scope} key, but the CLI requires a platform API key. Update the Sim deployment and try again.`, 0);
18690
18742
  }
18743
+ requireRequestedKey(key, keyRequest);
18691
18744
  const settings = {
18692
18745
  endpoint: profile.endpoint,
18693
18746
  workspace: key.workspaceId == null ? null : normalizeWorkspaceId(key.workspaceId, "the login response")
@@ -18722,6 +18775,7 @@ Waiting for approval…`));
18722
18775
  }
18723
18776
  printLine(styles3().green(`
18724
18777
  ✓ Logged in. Key stored in ${credentialsPath()}`));
18778
+ printLine(styles3().dim(` ${key.access === "read" ? "Read-only key — commands that change anything will be refused." : "Full-access key."} ${key.expiresAt ? `Expires ${safeOneLine(key.expiresAt)}.` : "Never expires."}`));
18725
18779
  if (key.workspaceBound && key.workspaceId) {
18726
18780
  printLine(styles3().dim(` Workspace-scoped key — it can only reach ${key.workspaceId}.`));
18727
18781
  } else if (key.workspaceId) {
@@ -18800,6 +18854,23 @@ function logoutCommand() {
18800
18854
  }
18801
18855
  });
18802
18856
  }
18857
+ var UNKNOWN_CREDENTIAL = {
18858
+ keyType: null,
18859
+ expiresAt: null,
18860
+ boundWorkspaceId: null
18861
+ };
18862
+ function credentialFactsFrom(response) {
18863
+ const data = toRecord(toRecord(response).data);
18864
+ const { keyType, expiresAt, workspaceId } = data;
18865
+ if (keyType !== "personal" && keyType !== "workspace" && keyType !== "oauth_access_token") {
18866
+ return null;
18867
+ }
18868
+ return {
18869
+ keyType,
18870
+ expiresAt: typeof expiresAt === "string" ? expiresAt : null,
18871
+ boundWorkspaceId: typeof workspaceId === "string" ? workspaceId : null
18872
+ };
18873
+ }
18803
18874
  var PROFILE_REJECTION_STATUSES = new Set([401, 403, 404]);
18804
18875
  var WHOAMI_EXIT_CODES = {
18805
18876
  verified: 0,
@@ -18815,17 +18886,16 @@ async function verifyProfile(client, profile) {
18815
18886
  status: "unauthenticated",
18816
18887
  authenticated: false,
18817
18888
  workspace: null,
18818
- keyType: null,
18889
+ ...UNKNOWN_CREDENTIAL,
18819
18890
  detail: `not logged in — run: sim login --profile ${safeOneLine(profile.name)}`
18820
18891
  };
18821
18892
  }
18822
- let keyType = null;
18893
+ let facts = UNKNOWN_CREDENTIAL;
18823
18894
  let authenticated = null;
18824
18895
  try {
18825
- const response = await client.request("getMeta");
18826
- const reportedKeyType = toRecord(toRecord(response).data).keyType;
18827
- if (reportedKeyType === "personal" || reportedKeyType === "workspace" || reportedKeyType === "oauth_access_token") {
18828
- keyType = reportedKeyType;
18896
+ const reported = credentialFactsFrom(await client.request("getMeta"));
18897
+ if (reported) {
18898
+ facts = reported;
18829
18899
  authenticated = true;
18830
18900
  }
18831
18901
  } catch (error) {
@@ -18836,7 +18906,7 @@ async function verifyProfile(client, profile) {
18836
18906
  status: "rejected",
18837
18907
  authenticated: false,
18838
18908
  workspace: null,
18839
- keyType: null,
18909
+ ...UNKNOWN_CREDENTIAL,
18840
18910
  detail: error.message
18841
18911
  };
18842
18912
  }
@@ -18846,7 +18916,7 @@ async function verifyProfile(client, profile) {
18846
18916
  status: "no-workspace",
18847
18917
  authenticated,
18848
18918
  workspace: null,
18849
- keyType,
18919
+ ...facts,
18850
18920
  detail: `no workspace to check against — run: sim configure --profile ${safeOneLine(profile.name)} --set-workspace <id>`
18851
18921
  };
18852
18922
  }
@@ -18859,7 +18929,7 @@ async function verifyProfile(client, profile) {
18859
18929
  status: "verified",
18860
18930
  authenticated: true,
18861
18931
  workspace: { id, name, memberCount },
18862
- keyType,
18932
+ ...facts,
18863
18933
  detail: null
18864
18934
  };
18865
18935
  } catch (error) {
@@ -18869,7 +18939,7 @@ async function verifyProfile(client, profile) {
18869
18939
  status: PROFILE_REJECTION_STATUSES.has(error.status) ? "rejected" : "unreachable",
18870
18940
  authenticated: error.status === 401 ? false : authenticated,
18871
18941
  workspace: null,
18872
- keyType,
18942
+ ...facts,
18873
18943
  detail: error.message
18874
18944
  };
18875
18945
  }
@@ -18903,7 +18973,7 @@ function whoamiCommand() {
18903
18973
  status: "disabled",
18904
18974
  authenticated: authentication.configured ? null : false,
18905
18975
  workspace: null,
18906
- keyType: null,
18976
+ ...UNKNOWN_CREDENTIAL,
18907
18977
  detail: "not checked (--no-verify)"
18908
18978
  };
18909
18979
  const annotate = (value, source) => source === "unset" ? styles3().dim("not set") : `${value} ${styles3().dim(`(${source})`)}`;
@@ -18918,6 +18988,11 @@ function whoamiCommand() {
18918
18988
  "Key type",
18919
18989
  verification.keyType ?? styles3().dim(options.verify ? "unknown" : "not checked (--no-verify)")
18920
18990
  ],
18991
+ [
18992
+ "Key expires",
18993
+ verification.keyType ? verification.expiresAt ? safeOneLine(verification.expiresAt) : "never" : styles3().dim(options.verify ? "unknown" : "not checked (--no-verify)")
18994
+ ],
18995
+ ...verification.boundWorkspaceId ? [["Key bound to", safeOneLine(verification.boundWorkspaceId)]] : [],
18921
18996
  ["Workspace", annotate(profile.workspaceId ?? "", sources.workspaceId)],
18922
18997
  ["Output", annotate(profile.output, sources.output)],
18923
18998
  ["Verified", presentVerification(verification)]
@@ -18937,6 +19012,8 @@ function whoamiCommand() {
18937
19012
  status: verification.status,
18938
19013
  workspace: verification.workspace,
18939
19014
  keyType: verification.keyType,
19015
+ expiresAt: verification.expiresAt,
19016
+ boundWorkspaceId: verification.boundWorkspaceId,
18940
19017
  detail: verification.detail
18941
19018
  }
18942
19019
  });
@@ -19127,6 +19204,15 @@ var ACCESS_REQUEST_COLUMNS = [
19127
19204
  { header: "requester", path: "requester.email" },
19128
19205
  { header: "created", path: "createdAt", format: "timestamp" }
19129
19206
  ];
19207
+ var WORKSPACE_FIELDS = [
19208
+ { header: "id" },
19209
+ { header: "name" },
19210
+ { header: "color" },
19211
+ { header: "logo", path: "logoUrl" },
19212
+ { header: "members", path: "memberCount" },
19213
+ { header: "created", path: "createdAt", format: "timestamp" },
19214
+ { header: "updated", path: "updatedAt", format: "timestamp" }
19215
+ ];
19130
19216
  var FILE_SHARE_FIELDS = [
19131
19217
  { header: "shared", path: "isActive", format: "bool" },
19132
19218
  { header: "URL", path: "url" },
@@ -20353,15 +20439,16 @@ var CLI_CONTRACT = {
20353
20439
  },
20354
20440
  getWorkspace: {
20355
20441
  profileWorkspacePath: true,
20356
- fields: [
20357
- { header: "id" },
20358
- { header: "name" },
20359
- { header: "color" },
20360
- { header: "logo", path: "logoUrl" },
20361
- { header: "members", path: "memberCount" },
20362
- { header: "created", path: "createdAt", format: "timestamp" },
20363
- { header: "updated", path: "updatedAt", format: "timestamp" }
20364
- ]
20442
+ fields: WORKSPACE_FIELDS
20443
+ },
20444
+ updateWorkspace: {
20445
+ profileWorkspacePath: true,
20446
+ fields: WORKSPACE_FIELDS,
20447
+ flags: {
20448
+ logoUrl: {
20449
+ describe: "New workspace logo: a root-relative path (starting with /) or an https:// URL. To remove the logo, send logoUrl: null through the API or MCP"
20450
+ }
20451
+ }
20365
20452
  },
20366
20453
  listWorkspaceMembers: {
20367
20454
  command: "workspaces members list",
package/dist/runtime.js CHANGED
@@ -9111,13 +9111,15 @@ function createAuthRequest() {
9111
9111
  pairing: pairingCode()
9112
9112
  };
9113
9113
  }
9114
- function buildApprovalUrl(endpoint, auth, workspaceId) {
9114
+ function buildApprovalUrl(endpoint, auth, workspaceId, keyRequest = { readOnly: false }) {
9115
9115
  return buildUrl(endpoint, APPROVAL_PATH, {
9116
9116
  request: auth.request,
9117
9117
  challenge: auth.challenge,
9118
9118
  pairing: auth.pairing,
9119
9119
  scope: "platform",
9120
- workspace: workspaceId
9120
+ workspace: workspaceId,
9121
+ access: keyRequest.readOnly ? "read" : undefined,
9122
+ expires: keyRequest.expiresInDays
9121
9123
  });
9122
9124
  }
9123
9125
  function toRedirectError(endpoint, response) {
@@ -9194,7 +9196,9 @@ async function pollForKey(endpoint, auth, signal) {
9194
9196
  apiKey: body.key.apiKey,
9195
9197
  scope: body.scope ?? "copilot",
9196
9198
  workspaceId: body.workspaceId ?? null,
9197
- workspaceBound: body.workspaceBound === true
9199
+ workspaceBound: body.workspaceBound === true,
9200
+ access: body.access === "read" || body.access === "write" ? body.access : null,
9201
+ expiresAt: typeof body.expiresAt === "string" ? body.expiresAt : null
9198
9202
  };
9199
9203
  }
9200
9204
  }
@@ -18148,6 +18152,22 @@ var V2_OPERATIONS = {
18148
18152
  }
18149
18153
  }
18150
18154
  },
18155
+ updateWorkspace: {
18156
+ method: "PATCH",
18157
+ path: "/api/v2/workspaces/[workspaceId]",
18158
+ pathParams: ["workspaceId"],
18159
+ pathParamDocs: { workspaceId: "Workspace to update." },
18160
+ responseMode: "json",
18161
+ summary: "Update workspace",
18162
+ workspaceKeyUnsupported: true,
18163
+ body: {
18164
+ name: { kind: "string", describe: "New workspace display name." },
18165
+ logoUrl: {
18166
+ kind: "string",
18167
+ describe: "New workspace logo URL: a root-relative path (starting with /) or an https:// URL. Send null to remove the logo."
18168
+ }
18169
+ }
18170
+ },
18151
18171
  updateWorkspaceForkExclusions: {
18152
18172
  method: "PUT",
18153
18173
  path: "/api/v2/workspaces/[workspaceId]/fork/exclusions",
@@ -18586,6 +18606,17 @@ function addProfileCommand() {
18586
18606
  printLine(styles3().dim(` Try: sim --profile ${safeOneLine(profileName)} whoami`));
18587
18607
  });
18588
18608
  }
18609
+ var MIN_KEY_EXPIRY_DAYS = 1;
18610
+ var MAX_KEY_EXPIRY_DAYS = 365;
18611
+ function parseExpiresIn(value) {
18612
+ if (value === undefined)
18613
+ return;
18614
+ const days = Number(value);
18615
+ if (!/^\d+$/.test(value.trim()) || days < MIN_KEY_EXPIRY_DAYS || days > MAX_KEY_EXPIRY_DAYS) {
18616
+ throw new SimApiError(`Invalid --expires-in "${redact(value)}". Use a whole number of days from ${MIN_KEY_EXPIRY_DAYS} to ${MAX_KEY_EXPIRY_DAYS}.`, 0);
18617
+ }
18618
+ return days;
18619
+ }
18589
18620
  async function chooseLoginFlow(profile, options) {
18590
18621
  requireSecureEndpoint(profile.endpoint);
18591
18622
  if (options.method === "api-key")
@@ -18681,7 +18712,7 @@ Waiting for you to approve in the browser…`));
18681
18712
  }
18682
18713
  }
18683
18714
  function loginCommand() {
18684
- return new Command("login").description("Log in through the browser and store the login for the profile").addOption(new Option("--method <method>", "Credential to obtain: oauth requires OAuth support; api-key creates a permanent key through pairing (auto-selects when omitted)").choices(["oauth", "api-key"])).option("--no-browser", "Print the approval URL without opening it (either login method)").option("--read-only", "Ask only for permission to read, never to change anything").option("--callback-port <port>", "Pin the local port the browser returns to").option("-y, --yes", "Overwrite an existing API-key profile without prompting").action(async (options, command) => {
18715
+ return new Command("login").description("Log in through the browser and store the login for the profile").addOption(new Option("--method <method>", "Credential to obtain: oauth requires OAuth support; api-key creates an API key through pairing (auto-selects when omitted)").choices(["oauth", "api-key"])).option("--no-browser", "Print the approval URL without opening it (either login method)").option("--read-only", "Ask only for permission to read, never to change anything").option("--expires-in <days>", `API-key login only: days until the key expires (${MIN_KEY_EXPIRY_DAYS}-${MAX_KEY_EXPIRY_DAYS}); omit for a key that never expires`).option("--callback-port <port>", "Pin the local port the browser returns to").option("-y, --yes", "Overwrite an existing API-key profile without prompting").action(async (options, command) => {
18685
18716
  const profile = profileFrom(command, { allowUnknownProfile: true });
18686
18717
  const authProfile = resolveAuthenticationProfileName(profile.name);
18687
18718
  if (authProfile !== profile.name) {
@@ -18700,14 +18731,13 @@ function loginCommand() {
18700
18731
  }
18701
18732
  }
18702
18733
  const callbackPort = parseCallbackPort(options.callbackPort);
18734
+ const expiresInDays = parseExpiresIn(options.expiresIn);
18703
18735
  const loginFlow = await chooseLoginFlow(profile, options);
18704
- if (loginFlow === "handoff") {
18705
- if (options.readOnly) {
18706
- throw new SimApiError("API-key login cannot issue a read-only login. Use --method oauth, or drop --read-only.", 0);
18707
- }
18708
- if (callbackPort !== undefined) {
18709
- throw new SimApiError("API-key login has no local callback, so --callback-port does not apply. Use --method oauth, or drop --callback-port.", 0);
18710
- }
18736
+ if (loginFlow === "handoff" && callbackPort !== undefined) {
18737
+ throw new SimApiError("API-key login has no local callback, so --callback-port does not apply. Use --method oauth, or drop --callback-port.", 0);
18738
+ }
18739
+ if (loginFlow === "oauth" && expiresInDays !== undefined) {
18740
+ throw new SimApiError("OAuth logins renew themselves, so --expires-in does not apply. Use --method api-key, or drop --expires-in.", 0);
18711
18741
  }
18712
18742
  await withProfileLoginLease(profile.name, async () => {
18713
18743
  assertLoginProfileUnchanged(profile.name, snapshot);
@@ -18715,13 +18745,35 @@ function loginCommand() {
18715
18745
  await loginWithOAuth(profile, options, callbackPort, snapshot);
18716
18746
  return;
18717
18747
  }
18718
- await loginWithHandoff(profile, options, snapshot);
18748
+ await loginWithHandoff(profile, options, { readOnly: options.readOnly === true, expiresInDays }, snapshot);
18719
18749
  });
18720
18750
  });
18721
18751
  }
18722
- async function loginWithHandoff(profile, options, expected) {
18752
+ var DAY_MS = 24 * 60 * 60 * 1000;
18753
+ var EXPIRY_TOLERANCE_MS = 60 * 60 * 1000;
18754
+ function requireRequestedKey(key, keyRequest) {
18755
+ const refuse = (issued, flag) => new SimApiError(`The server issued ${issued}, not the key requested. Nothing was stored; update the Sim deployment or adjust ${flag}.`, 0);
18756
+ const requestedAccess = keyRequest.readOnly ? "read" : "write";
18757
+ const issuedAccess = key.access ?? "write";
18758
+ if (issuedAccess !== requestedAccess) {
18759
+ throw refuse(issuedAccess === "read" ? "a read-only key" : "a full-access key", "--read-only");
18760
+ }
18761
+ if (keyRequest.expiresInDays === undefined) {
18762
+ if (key.expiresAt)
18763
+ throw refuse(`a key that expires ${safeOneLine(key.expiresAt ?? "")}`, "--expires-in");
18764
+ return;
18765
+ }
18766
+ const expiresAt = key.expiresAt ? Date.parse(key.expiresAt) : Number.NaN;
18767
+ if (Number.isNaN(expiresAt))
18768
+ throw refuse("a key that never expires", "--expires-in");
18769
+ const requested = Date.now() + keyRequest.expiresInDays * DAY_MS;
18770
+ if (Math.abs(expiresAt - requested) > EXPIRY_TOLERANCE_MS) {
18771
+ throw refuse(`a key that expires ${safeOneLine(key.expiresAt ?? "")}`, "--expires-in");
18772
+ }
18773
+ }
18774
+ async function loginWithHandoff(profile, options, keyRequest, expected) {
18723
18775
  const auth = createAuthRequest();
18724
- const url = buildApprovalUrl(profile.endpoint, auth, profile.workspaceId ?? undefined);
18776
+ const url = buildApprovalUrl(profile.endpoint, auth, profile.workspaceId ?? undefined, keyRequest);
18725
18777
  printLine(`Signing in to ${styles3().bold(profile.endpoint)} as profile ${styles3().bold(safeOneLine(profile.name))}`);
18726
18778
  printLine(`
18727
18779
  Pairing code: ${styles3().bold(auth.pairing)}`);
@@ -18737,6 +18789,7 @@ Waiting for approval…`));
18737
18789
  if (key.scope !== "platform") {
18738
18790
  throw new SimApiError(`Server issued a ${key.scope} key, but the CLI requires a platform API key. Update the Sim deployment and try again.`, 0);
18739
18791
  }
18792
+ requireRequestedKey(key, keyRequest);
18740
18793
  const settings = {
18741
18794
  endpoint: profile.endpoint,
18742
18795
  workspace: key.workspaceId == null ? null : normalizeWorkspaceId(key.workspaceId, "the login response")
@@ -18771,6 +18824,7 @@ Waiting for approval…`));
18771
18824
  }
18772
18825
  printLine(styles3().green(`
18773
18826
  ✓ Logged in. Key stored in ${credentialsPath()}`));
18827
+ printLine(styles3().dim(` ${key.access === "read" ? "Read-only key — commands that change anything will be refused." : "Full-access key."} ${key.expiresAt ? `Expires ${safeOneLine(key.expiresAt)}.` : "Never expires."}`));
18774
18828
  if (key.workspaceBound && key.workspaceId) {
18775
18829
  printLine(styles3().dim(` Workspace-scoped key — it can only reach ${key.workspaceId}.`));
18776
18830
  } else if (key.workspaceId) {
@@ -18849,6 +18903,23 @@ function logoutCommand() {
18849
18903
  }
18850
18904
  });
18851
18905
  }
18906
+ var UNKNOWN_CREDENTIAL = {
18907
+ keyType: null,
18908
+ expiresAt: null,
18909
+ boundWorkspaceId: null
18910
+ };
18911
+ function credentialFactsFrom(response) {
18912
+ const data = toRecord(toRecord(response).data);
18913
+ const { keyType, expiresAt, workspaceId } = data;
18914
+ if (keyType !== "personal" && keyType !== "workspace" && keyType !== "oauth_access_token") {
18915
+ return null;
18916
+ }
18917
+ return {
18918
+ keyType,
18919
+ expiresAt: typeof expiresAt === "string" ? expiresAt : null,
18920
+ boundWorkspaceId: typeof workspaceId === "string" ? workspaceId : null
18921
+ };
18922
+ }
18852
18923
  var PROFILE_REJECTION_STATUSES = new Set([401, 403, 404]);
18853
18924
  var WHOAMI_EXIT_CODES = {
18854
18925
  verified: 0,
@@ -18864,17 +18935,16 @@ async function verifyProfile(client, profile) {
18864
18935
  status: "unauthenticated",
18865
18936
  authenticated: false,
18866
18937
  workspace: null,
18867
- keyType: null,
18938
+ ...UNKNOWN_CREDENTIAL,
18868
18939
  detail: `not logged in — run: sim login --profile ${safeOneLine(profile.name)}`
18869
18940
  };
18870
18941
  }
18871
- let keyType = null;
18942
+ let facts = UNKNOWN_CREDENTIAL;
18872
18943
  let authenticated = null;
18873
18944
  try {
18874
- const response = await client.request("getMeta");
18875
- const reportedKeyType = toRecord(toRecord(response).data).keyType;
18876
- if (reportedKeyType === "personal" || reportedKeyType === "workspace" || reportedKeyType === "oauth_access_token") {
18877
- keyType = reportedKeyType;
18945
+ const reported = credentialFactsFrom(await client.request("getMeta"));
18946
+ if (reported) {
18947
+ facts = reported;
18878
18948
  authenticated = true;
18879
18949
  }
18880
18950
  } catch (error) {
@@ -18885,7 +18955,7 @@ async function verifyProfile(client, profile) {
18885
18955
  status: "rejected",
18886
18956
  authenticated: false,
18887
18957
  workspace: null,
18888
- keyType: null,
18958
+ ...UNKNOWN_CREDENTIAL,
18889
18959
  detail: error.message
18890
18960
  };
18891
18961
  }
@@ -18895,7 +18965,7 @@ async function verifyProfile(client, profile) {
18895
18965
  status: "no-workspace",
18896
18966
  authenticated,
18897
18967
  workspace: null,
18898
- keyType,
18968
+ ...facts,
18899
18969
  detail: `no workspace to check against — run: sim configure --profile ${safeOneLine(profile.name)} --set-workspace <id>`
18900
18970
  };
18901
18971
  }
@@ -18908,7 +18978,7 @@ async function verifyProfile(client, profile) {
18908
18978
  status: "verified",
18909
18979
  authenticated: true,
18910
18980
  workspace: { id, name, memberCount },
18911
- keyType,
18981
+ ...facts,
18912
18982
  detail: null
18913
18983
  };
18914
18984
  } catch (error) {
@@ -18918,7 +18988,7 @@ async function verifyProfile(client, profile) {
18918
18988
  status: PROFILE_REJECTION_STATUSES.has(error.status) ? "rejected" : "unreachable",
18919
18989
  authenticated: error.status === 401 ? false : authenticated,
18920
18990
  workspace: null,
18921
- keyType,
18991
+ ...facts,
18922
18992
  detail: error.message
18923
18993
  };
18924
18994
  }
@@ -18952,7 +19022,7 @@ function whoamiCommand() {
18952
19022
  status: "disabled",
18953
19023
  authenticated: authentication.configured ? null : false,
18954
19024
  workspace: null,
18955
- keyType: null,
19025
+ ...UNKNOWN_CREDENTIAL,
18956
19026
  detail: "not checked (--no-verify)"
18957
19027
  };
18958
19028
  const annotate = (value, source) => source === "unset" ? styles3().dim("not set") : `${value} ${styles3().dim(`(${source})`)}`;
@@ -18967,6 +19037,11 @@ function whoamiCommand() {
18967
19037
  "Key type",
18968
19038
  verification.keyType ?? styles3().dim(options.verify ? "unknown" : "not checked (--no-verify)")
18969
19039
  ],
19040
+ [
19041
+ "Key expires",
19042
+ verification.keyType ? verification.expiresAt ? safeOneLine(verification.expiresAt) : "never" : styles3().dim(options.verify ? "unknown" : "not checked (--no-verify)")
19043
+ ],
19044
+ ...verification.boundWorkspaceId ? [["Key bound to", safeOneLine(verification.boundWorkspaceId)]] : [],
18970
19045
  ["Workspace", annotate(profile.workspaceId ?? "", sources.workspaceId)],
18971
19046
  ["Output", annotate(profile.output, sources.output)],
18972
19047
  ["Verified", presentVerification(verification)]
@@ -18986,6 +19061,8 @@ function whoamiCommand() {
18986
19061
  status: verification.status,
18987
19062
  workspace: verification.workspace,
18988
19063
  keyType: verification.keyType,
19064
+ expiresAt: verification.expiresAt,
19065
+ boundWorkspaceId: verification.boundWorkspaceId,
18989
19066
  detail: verification.detail
18990
19067
  }
18991
19068
  });
@@ -19176,6 +19253,15 @@ var ACCESS_REQUEST_COLUMNS = [
19176
19253
  { header: "requester", path: "requester.email" },
19177
19254
  { header: "created", path: "createdAt", format: "timestamp" }
19178
19255
  ];
19256
+ var WORKSPACE_FIELDS = [
19257
+ { header: "id" },
19258
+ { header: "name" },
19259
+ { header: "color" },
19260
+ { header: "logo", path: "logoUrl" },
19261
+ { header: "members", path: "memberCount" },
19262
+ { header: "created", path: "createdAt", format: "timestamp" },
19263
+ { header: "updated", path: "updatedAt", format: "timestamp" }
19264
+ ];
19179
19265
  var FILE_SHARE_FIELDS = [
19180
19266
  { header: "shared", path: "isActive", format: "bool" },
19181
19267
  { header: "URL", path: "url" },
@@ -20402,15 +20488,16 @@ var CLI_CONTRACT = {
20402
20488
  },
20403
20489
  getWorkspace: {
20404
20490
  profileWorkspacePath: true,
20405
- fields: [
20406
- { header: "id" },
20407
- { header: "name" },
20408
- { header: "color" },
20409
- { header: "logo", path: "logoUrl" },
20410
- { header: "members", path: "memberCount" },
20411
- { header: "created", path: "createdAt", format: "timestamp" },
20412
- { header: "updated", path: "updatedAt", format: "timestamp" }
20413
- ]
20491
+ fields: WORKSPACE_FIELDS
20492
+ },
20493
+ updateWorkspace: {
20494
+ profileWorkspacePath: true,
20495
+ fields: WORKSPACE_FIELDS,
20496
+ flags: {
20497
+ logoUrl: {
20498
+ describe: "New workspace logo: a root-relative path (starting with /) or an https:// URL. To remove the logo, send logoUrl: null through the API or MCP"
20499
+ }
20500
+ }
20414
20501
  },
20415
20502
  listWorkspaceMembers: {
20416
20503
  command: "workspaces members list",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sim",
3
- "version": "2.2.24-preview.285.1",
3
+ "version": "2.2.25-preview.287.1",
4
4
  "description": "Sim CLI - talk to the Sim API from your terminal",
5
5
  "type": "module",
6
6
  "bin": {