sim 2.2.24 → 2.2.25-preview.288.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.
- package/dist/auth/device-flow.d.ts +15 -1
- package/dist/generated/v2-api.d.ts +149 -0
- package/dist/index.js +181 -34
- package/dist/runtime.js +181 -34
- package/package.json +1 -1
|
@@ -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 = {
|
|
@@ -4190,6 +4191,7 @@ export type GetBlockQuery = {
|
|
|
4190
4191
|
type GetBlockResponseRef0 = {
|
|
4191
4192
|
id: string;
|
|
4192
4193
|
type: string;
|
|
4194
|
+
valueType?: 'string' | 'number' | 'boolean' | 'json' | 'array' | 'file';
|
|
4193
4195
|
title?: string;
|
|
4194
4196
|
required?: boolean;
|
|
4195
4197
|
requiredWhen?: GetBlockResponseRef1;
|
|
@@ -4874,6 +4876,14 @@ type GetMetaResponseRef0 = {
|
|
|
4874
4876
|
keyType: 'personal' | 'workspace' | 'oauth_access_token';
|
|
4875
4877
|
expiresAt: string | null;
|
|
4876
4878
|
scopes: Array<'api:read' | 'api:write' | 'search:read'>;
|
|
4879
|
+
keyId: string | null;
|
|
4880
|
+
userId: string | null;
|
|
4881
|
+
workspaceId: string | null;
|
|
4882
|
+
links: {
|
|
4883
|
+
openapi: string;
|
|
4884
|
+
docs: string;
|
|
4885
|
+
mcp: string;
|
|
4886
|
+
};
|
|
4877
4887
|
};
|
|
4878
4888
|
export type GetMetaResponse = {
|
|
4879
4889
|
data: GetMetaResponseRef0;
|
|
@@ -5784,6 +5794,33 @@ type GetWorkflowMcpServerResponseRef0 = {
|
|
|
5784
5794
|
export type GetWorkflowMcpServerResponse = {
|
|
5785
5795
|
data: GetWorkflowMcpServerResponseRef0;
|
|
5786
5796
|
};
|
|
5797
|
+
/** `GET /api/v2/workflows/[workflowId]/outline` */
|
|
5798
|
+
export type GetWorkflowOutlineParams = {
|
|
5799
|
+
workflowId: string;
|
|
5800
|
+
};
|
|
5801
|
+
export type GetWorkflowOutlineQuery = Record<string, unknown>;
|
|
5802
|
+
type GetWorkflowOutlineResponseRef0 = {
|
|
5803
|
+
type: string;
|
|
5804
|
+
name: string;
|
|
5805
|
+
enabled: boolean;
|
|
5806
|
+
inputs?: Record<string, unknown>;
|
|
5807
|
+
connections?: Record<string, string | Array<string>>;
|
|
5808
|
+
nestedNodes?: Record<string, unknown>;
|
|
5809
|
+
advancedMode?: boolean;
|
|
5810
|
+
errorEnabled?: boolean;
|
|
5811
|
+
retry?: {
|
|
5812
|
+
enabled: boolean;
|
|
5813
|
+
maxTries: number;
|
|
5814
|
+
waitBetweenTriesMs: number;
|
|
5815
|
+
};
|
|
5816
|
+
triggerMode?: boolean;
|
|
5817
|
+
};
|
|
5818
|
+
type GetWorkflowOutlineResponseRef1 = {
|
|
5819
|
+
blocks: Record<string, GetWorkflowOutlineResponseRef0>;
|
|
5820
|
+
};
|
|
5821
|
+
export type GetWorkflowOutlineResponse = {
|
|
5822
|
+
data: GetWorkflowOutlineResponseRef1;
|
|
5823
|
+
};
|
|
5787
5824
|
/** `GET /api/v2/workflows/[workflowId]/runs/[runId]` */
|
|
5788
5825
|
export type GetWorkflowRunParams = {
|
|
5789
5826
|
workflowId: string;
|
|
@@ -8290,6 +8327,31 @@ export type ListWorkspacesResponse = {
|
|
|
8290
8327
|
data: Array<ListWorkspacesResponseRef0>;
|
|
8291
8328
|
nextCursor: string | null;
|
|
8292
8329
|
};
|
|
8330
|
+
/** `GET /api/v2/schedules` */
|
|
8331
|
+
export type ListWorkspaceSchedulesQuery = {
|
|
8332
|
+
workspaceId: string;
|
|
8333
|
+
limit?: number;
|
|
8334
|
+
cursor?: string;
|
|
8335
|
+
sortBy?: 'createdAt';
|
|
8336
|
+
sortOrder?: 'asc' | 'desc';
|
|
8337
|
+
};
|
|
8338
|
+
type ListWorkspaceSchedulesResponseRef0 = {
|
|
8339
|
+
blockId: string;
|
|
8340
|
+
enabled: boolean;
|
|
8341
|
+
status: 'active' | 'disabled' | 'completed';
|
|
8342
|
+
failedCount: number;
|
|
8343
|
+
lastFailedAt: string | null;
|
|
8344
|
+
nextRunAt: string | null;
|
|
8345
|
+
lastRanAt: string | null;
|
|
8346
|
+
cronExpression: string | null;
|
|
8347
|
+
workflowId: string;
|
|
8348
|
+
workflowName: string;
|
|
8349
|
+
timezone: string;
|
|
8350
|
+
};
|
|
8351
|
+
export type ListWorkspaceSchedulesResponse = {
|
|
8352
|
+
data: Array<ListWorkspaceSchedulesResponseRef0>;
|
|
8353
|
+
nextCursor: string | null;
|
|
8354
|
+
};
|
|
8293
8355
|
/** `POST /api/v2/files/move` */
|
|
8294
8356
|
export type MoveFileItemsQuery = Record<string, unknown>;
|
|
8295
8357
|
type MoveFileItemsBodyRef0 = string;
|
|
@@ -11739,6 +11801,27 @@ type UpdateWorkflowVersionResponseRef0 = {
|
|
|
11739
11801
|
export type UpdateWorkflowVersionResponse = {
|
|
11740
11802
|
data: UpdateWorkflowVersionResponseRef0;
|
|
11741
11803
|
};
|
|
11804
|
+
/** `PATCH /api/v2/workspaces/[workspaceId]` */
|
|
11805
|
+
export type UpdateWorkspaceParams = {
|
|
11806
|
+
workspaceId: string;
|
|
11807
|
+
};
|
|
11808
|
+
export type UpdateWorkspaceQuery = Record<string, unknown>;
|
|
11809
|
+
export type UpdateWorkspaceBody = {
|
|
11810
|
+
name?: string;
|
|
11811
|
+
logoUrl?: string | null;
|
|
11812
|
+
};
|
|
11813
|
+
type UpdateWorkspaceResponseRef0 = {
|
|
11814
|
+
id: string;
|
|
11815
|
+
name: string;
|
|
11816
|
+
color: string;
|
|
11817
|
+
logoUrl: string | null;
|
|
11818
|
+
memberCount: number;
|
|
11819
|
+
createdAt: string;
|
|
11820
|
+
updatedAt: string;
|
|
11821
|
+
};
|
|
11822
|
+
export type UpdateWorkspaceResponse = {
|
|
11823
|
+
data: UpdateWorkspaceResponseRef0;
|
|
11824
|
+
};
|
|
11742
11825
|
/** `PUT /api/v2/workspaces/[workspaceId]/fork/exclusions` */
|
|
11743
11826
|
export type UpdateWorkspaceForkExclusionsParams = {
|
|
11744
11827
|
workspaceId: string;
|
|
@@ -15832,6 +15915,16 @@ export declare const V2_OPERATIONS: {
|
|
|
15832
15915
|
readonly summary: 'Get workflow MCP server';
|
|
15833
15916
|
readonly workspaceKeyUnsupported: true;
|
|
15834
15917
|
};
|
|
15918
|
+
readonly getWorkflowOutline: {
|
|
15919
|
+
readonly method: 'GET';
|
|
15920
|
+
readonly path: '/api/v2/workflows/[workflowId]/outline';
|
|
15921
|
+
readonly pathParams: readonly ['workflowId'];
|
|
15922
|
+
readonly pathParamDocs: {
|
|
15923
|
+
readonly workflowId: 'Unique workflow identifier.';
|
|
15924
|
+
};
|
|
15925
|
+
readonly responseMode: 'json';
|
|
15926
|
+
readonly summary: 'Get workflow outline';
|
|
15927
|
+
};
|
|
15835
15928
|
readonly getWorkflowRun: {
|
|
15836
15929
|
readonly method: 'GET';
|
|
15837
15930
|
readonly path: '/api/v2/workflows/[workflowId]/runs/[runId]';
|
|
@@ -18427,6 +18520,41 @@ export declare const V2_OPERATIONS: {
|
|
|
18427
18520
|
};
|
|
18428
18521
|
};
|
|
18429
18522
|
};
|
|
18523
|
+
readonly listWorkspaceSchedules: {
|
|
18524
|
+
readonly method: 'GET';
|
|
18525
|
+
readonly path: '/api/v2/schedules';
|
|
18526
|
+
readonly pathParams: readonly [];
|
|
18527
|
+
readonly responseMode: 'json';
|
|
18528
|
+
readonly summary: 'List workspace schedules';
|
|
18529
|
+
readonly query: {
|
|
18530
|
+
readonly workspaceId: {
|
|
18531
|
+
readonly kind: 'string';
|
|
18532
|
+
readonly required: true;
|
|
18533
|
+
readonly describe: 'Workspace whose schedules should be listed.';
|
|
18534
|
+
};
|
|
18535
|
+
readonly limit: {
|
|
18536
|
+
readonly kind: 'integer';
|
|
18537
|
+
readonly default: 50;
|
|
18538
|
+
readonly describe: 'Maximum schedules to return per page. Must be a whole number from 1 to 100. Defaults to 50.';
|
|
18539
|
+
};
|
|
18540
|
+
readonly cursor: {
|
|
18541
|
+
readonly kind: 'string';
|
|
18542
|
+
readonly describe: 'Opaque cursor from the previous page. Send it back with the same sort and filters; only `limit` may change. Change anything else and pagination must restart without a cursor.';
|
|
18543
|
+
};
|
|
18544
|
+
readonly sortBy: {
|
|
18545
|
+
readonly kind: 'enum';
|
|
18546
|
+
readonly values: readonly ['createdAt'];
|
|
18547
|
+
readonly default: 'createdAt';
|
|
18548
|
+
readonly describe: 'Field used to sort the result.';
|
|
18549
|
+
};
|
|
18550
|
+
readonly sortOrder: {
|
|
18551
|
+
readonly kind: 'enum';
|
|
18552
|
+
readonly values: readonly ['asc', 'desc'];
|
|
18553
|
+
readonly default: 'desc';
|
|
18554
|
+
readonly describe: 'Sort direction.';
|
|
18555
|
+
};
|
|
18556
|
+
};
|
|
18557
|
+
};
|
|
18430
18558
|
readonly moveFileItems: {
|
|
18431
18559
|
readonly method: 'POST';
|
|
18432
18560
|
readonly path: '/api/v2/files/move';
|
|
@@ -21302,6 +21430,27 @@ export declare const V2_OPERATIONS: {
|
|
|
21302
21430
|
};
|
|
21303
21431
|
};
|
|
21304
21432
|
};
|
|
21433
|
+
readonly updateWorkspace: {
|
|
21434
|
+
readonly method: 'PATCH';
|
|
21435
|
+
readonly path: '/api/v2/workspaces/[workspaceId]';
|
|
21436
|
+
readonly pathParams: readonly ['workspaceId'];
|
|
21437
|
+
readonly pathParamDocs: {
|
|
21438
|
+
readonly workspaceId: 'Workspace to update.';
|
|
21439
|
+
};
|
|
21440
|
+
readonly responseMode: 'json';
|
|
21441
|
+
readonly summary: 'Update workspace';
|
|
21442
|
+
readonly workspaceKeyUnsupported: true;
|
|
21443
|
+
readonly body: {
|
|
21444
|
+
readonly name: {
|
|
21445
|
+
readonly kind: 'string';
|
|
21446
|
+
readonly describe: 'New workspace display name.';
|
|
21447
|
+
};
|
|
21448
|
+
readonly logoUrl: {
|
|
21449
|
+
readonly kind: 'string';
|
|
21450
|
+
readonly describe: 'New workspace logo URL: a root-relative path (starting with /) or an https:// URL. Send null to remove the logo.';
|
|
21451
|
+
};
|
|
21452
|
+
};
|
|
21453
|
+
};
|
|
21305
21454
|
readonly updateWorkspaceForkExclusions: {
|
|
21306
21455
|
readonly method: 'PUT';
|
|
21307
21456
|
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
|
}
|
|
@@ -13056,6 +13060,14 @@ var V2_OPERATIONS = {
|
|
|
13056
13060
|
summary: "Get workflow MCP server",
|
|
13057
13061
|
workspaceKeyUnsupported: true
|
|
13058
13062
|
},
|
|
13063
|
+
getWorkflowOutline: {
|
|
13064
|
+
method: "GET",
|
|
13065
|
+
path: "/api/v2/workflows/[workflowId]/outline",
|
|
13066
|
+
pathParams: ["workflowId"],
|
|
13067
|
+
pathParamDocs: { workflowId: "Unique workflow identifier." },
|
|
13068
|
+
responseMode: "json",
|
|
13069
|
+
summary: "Get workflow outline"
|
|
13070
|
+
},
|
|
13059
13071
|
getWorkflowRun: {
|
|
13060
13072
|
method: "GET",
|
|
13061
13073
|
path: "/api/v2/workflows/[workflowId]/runs/[runId]",
|
|
@@ -15712,6 +15724,41 @@ var V2_OPERATIONS = {
|
|
|
15712
15724
|
}
|
|
15713
15725
|
}
|
|
15714
15726
|
},
|
|
15727
|
+
listWorkspaceSchedules: {
|
|
15728
|
+
method: "GET",
|
|
15729
|
+
path: "/api/v2/schedules",
|
|
15730
|
+
pathParams: [],
|
|
15731
|
+
responseMode: "json",
|
|
15732
|
+
summary: "List workspace schedules",
|
|
15733
|
+
query: {
|
|
15734
|
+
workspaceId: {
|
|
15735
|
+
kind: "string",
|
|
15736
|
+
required: true,
|
|
15737
|
+
describe: "Workspace whose schedules should be listed."
|
|
15738
|
+
},
|
|
15739
|
+
limit: {
|
|
15740
|
+
kind: "integer",
|
|
15741
|
+
default: 50,
|
|
15742
|
+
describe: "Maximum schedules to return per page. Must be a whole number from 1 to 100. Defaults to 50."
|
|
15743
|
+
},
|
|
15744
|
+
cursor: {
|
|
15745
|
+
kind: "string",
|
|
15746
|
+
describe: "Opaque cursor from the previous page. Send it back with the same sort and filters; only `limit` may change. Change anything else and pagination must restart without a cursor."
|
|
15747
|
+
},
|
|
15748
|
+
sortBy: {
|
|
15749
|
+
kind: "enum",
|
|
15750
|
+
values: ["createdAt"],
|
|
15751
|
+
default: "createdAt",
|
|
15752
|
+
describe: "Field used to sort the result."
|
|
15753
|
+
},
|
|
15754
|
+
sortOrder: {
|
|
15755
|
+
kind: "enum",
|
|
15756
|
+
values: ["asc", "desc"],
|
|
15757
|
+
default: "desc",
|
|
15758
|
+
describe: "Sort direction."
|
|
15759
|
+
}
|
|
15760
|
+
}
|
|
15761
|
+
},
|
|
15715
15762
|
moveFileItems: {
|
|
15716
15763
|
method: "POST",
|
|
15717
15764
|
path: "/api/v2/files/move",
|
|
@@ -18099,6 +18146,22 @@ var V2_OPERATIONS = {
|
|
|
18099
18146
|
}
|
|
18100
18147
|
}
|
|
18101
18148
|
},
|
|
18149
|
+
updateWorkspace: {
|
|
18150
|
+
method: "PATCH",
|
|
18151
|
+
path: "/api/v2/workspaces/[workspaceId]",
|
|
18152
|
+
pathParams: ["workspaceId"],
|
|
18153
|
+
pathParamDocs: { workspaceId: "Workspace to update." },
|
|
18154
|
+
responseMode: "json",
|
|
18155
|
+
summary: "Update workspace",
|
|
18156
|
+
workspaceKeyUnsupported: true,
|
|
18157
|
+
body: {
|
|
18158
|
+
name: { kind: "string", describe: "New workspace display name." },
|
|
18159
|
+
logoUrl: {
|
|
18160
|
+
kind: "string",
|
|
18161
|
+
describe: "New workspace logo URL: a root-relative path (starting with /) or an https:// URL. Send null to remove the logo."
|
|
18162
|
+
}
|
|
18163
|
+
}
|
|
18164
|
+
},
|
|
18102
18165
|
updateWorkspaceForkExclusions: {
|
|
18103
18166
|
method: "PUT",
|
|
18104
18167
|
path: "/api/v2/workspaces/[workspaceId]/fork/exclusions",
|
|
@@ -18537,6 +18600,17 @@ function addProfileCommand() {
|
|
|
18537
18600
|
printLine(styles3().dim(` Try: sim --profile ${safeOneLine(profileName)} whoami`));
|
|
18538
18601
|
});
|
|
18539
18602
|
}
|
|
18603
|
+
var MIN_KEY_EXPIRY_DAYS = 1;
|
|
18604
|
+
var MAX_KEY_EXPIRY_DAYS = 365;
|
|
18605
|
+
function parseExpiresIn(value) {
|
|
18606
|
+
if (value === undefined)
|
|
18607
|
+
return;
|
|
18608
|
+
const days = Number(value);
|
|
18609
|
+
if (!/^\d+$/.test(value.trim()) || days < MIN_KEY_EXPIRY_DAYS || days > MAX_KEY_EXPIRY_DAYS) {
|
|
18610
|
+
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);
|
|
18611
|
+
}
|
|
18612
|
+
return days;
|
|
18613
|
+
}
|
|
18540
18614
|
async function chooseLoginFlow(profile, options) {
|
|
18541
18615
|
requireSecureEndpoint(profile.endpoint);
|
|
18542
18616
|
if (options.method === "api-key")
|
|
@@ -18632,7 +18706,7 @@ Waiting for you to approve in the browser…`));
|
|
|
18632
18706
|
}
|
|
18633
18707
|
}
|
|
18634
18708
|
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
|
|
18709
|
+
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
18710
|
const profile = profileFrom(command, { allowUnknownProfile: true });
|
|
18637
18711
|
const authProfile = resolveAuthenticationProfileName(profile.name);
|
|
18638
18712
|
if (authProfile !== profile.name) {
|
|
@@ -18651,14 +18725,13 @@ function loginCommand() {
|
|
|
18651
18725
|
}
|
|
18652
18726
|
}
|
|
18653
18727
|
const callbackPort = parseCallbackPort(options.callbackPort);
|
|
18728
|
+
const expiresInDays = parseExpiresIn(options.expiresIn);
|
|
18654
18729
|
const loginFlow = await chooseLoginFlow(profile, options);
|
|
18655
|
-
if (loginFlow === "handoff") {
|
|
18656
|
-
|
|
18657
|
-
|
|
18658
|
-
|
|
18659
|
-
|
|
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
|
-
}
|
|
18730
|
+
if (loginFlow === "handoff" && callbackPort !== undefined) {
|
|
18731
|
+
throw new SimApiError("API-key login has no local callback, so --callback-port does not apply. Use --method oauth, or drop --callback-port.", 0);
|
|
18732
|
+
}
|
|
18733
|
+
if (loginFlow === "oauth" && expiresInDays !== undefined) {
|
|
18734
|
+
throw new SimApiError("OAuth logins renew themselves, so --expires-in does not apply. Use --method api-key, or drop --expires-in.", 0);
|
|
18662
18735
|
}
|
|
18663
18736
|
await withProfileLoginLease(profile.name, async () => {
|
|
18664
18737
|
assertLoginProfileUnchanged(profile.name, snapshot);
|
|
@@ -18666,13 +18739,35 @@ function loginCommand() {
|
|
|
18666
18739
|
await loginWithOAuth(profile, options, callbackPort, snapshot);
|
|
18667
18740
|
return;
|
|
18668
18741
|
}
|
|
18669
|
-
await loginWithHandoff(profile, options, snapshot);
|
|
18742
|
+
await loginWithHandoff(profile, options, { readOnly: options.readOnly === true, expiresInDays }, snapshot);
|
|
18670
18743
|
});
|
|
18671
18744
|
});
|
|
18672
18745
|
}
|
|
18673
|
-
|
|
18746
|
+
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
18747
|
+
var EXPIRY_TOLERANCE_MS = 60 * 60 * 1000;
|
|
18748
|
+
function requireRequestedKey(key, keyRequest) {
|
|
18749
|
+
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);
|
|
18750
|
+
const requestedAccess = keyRequest.readOnly ? "read" : "write";
|
|
18751
|
+
const issuedAccess = key.access ?? "write";
|
|
18752
|
+
if (issuedAccess !== requestedAccess) {
|
|
18753
|
+
throw refuse(issuedAccess === "read" ? "a read-only key" : "a full-access key", "--read-only");
|
|
18754
|
+
}
|
|
18755
|
+
if (keyRequest.expiresInDays === undefined) {
|
|
18756
|
+
if (key.expiresAt)
|
|
18757
|
+
throw refuse(`a key that expires ${safeOneLine(key.expiresAt ?? "")}`, "--expires-in");
|
|
18758
|
+
return;
|
|
18759
|
+
}
|
|
18760
|
+
const expiresAt = key.expiresAt ? Date.parse(key.expiresAt) : Number.NaN;
|
|
18761
|
+
if (Number.isNaN(expiresAt))
|
|
18762
|
+
throw refuse("a key that never expires", "--expires-in");
|
|
18763
|
+
const requested = Date.now() + keyRequest.expiresInDays * DAY_MS;
|
|
18764
|
+
if (Math.abs(expiresAt - requested) > EXPIRY_TOLERANCE_MS) {
|
|
18765
|
+
throw refuse(`a key that expires ${safeOneLine(key.expiresAt ?? "")}`, "--expires-in");
|
|
18766
|
+
}
|
|
18767
|
+
}
|
|
18768
|
+
async function loginWithHandoff(profile, options, keyRequest, expected) {
|
|
18674
18769
|
const auth = createAuthRequest();
|
|
18675
|
-
const url = buildApprovalUrl(profile.endpoint, auth, profile.workspaceId ?? undefined);
|
|
18770
|
+
const url = buildApprovalUrl(profile.endpoint, auth, profile.workspaceId ?? undefined, keyRequest);
|
|
18676
18771
|
printLine(`Signing in to ${styles3().bold(profile.endpoint)} as profile ${styles3().bold(safeOneLine(profile.name))}`);
|
|
18677
18772
|
printLine(`
|
|
18678
18773
|
Pairing code: ${styles3().bold(auth.pairing)}`);
|
|
@@ -18688,6 +18783,7 @@ Waiting for approval…`));
|
|
|
18688
18783
|
if (key.scope !== "platform") {
|
|
18689
18784
|
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
18785
|
}
|
|
18786
|
+
requireRequestedKey(key, keyRequest);
|
|
18691
18787
|
const settings = {
|
|
18692
18788
|
endpoint: profile.endpoint,
|
|
18693
18789
|
workspace: key.workspaceId == null ? null : normalizeWorkspaceId(key.workspaceId, "the login response")
|
|
@@ -18722,6 +18818,7 @@ Waiting for approval…`));
|
|
|
18722
18818
|
}
|
|
18723
18819
|
printLine(styles3().green(`
|
|
18724
18820
|
✓ Logged in. Key stored in ${credentialsPath()}`));
|
|
18821
|
+
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
18822
|
if (key.workspaceBound && key.workspaceId) {
|
|
18726
18823
|
printLine(styles3().dim(` Workspace-scoped key — it can only reach ${key.workspaceId}.`));
|
|
18727
18824
|
} else if (key.workspaceId) {
|
|
@@ -18800,6 +18897,23 @@ function logoutCommand() {
|
|
|
18800
18897
|
}
|
|
18801
18898
|
});
|
|
18802
18899
|
}
|
|
18900
|
+
var UNKNOWN_CREDENTIAL = {
|
|
18901
|
+
keyType: null,
|
|
18902
|
+
expiresAt: null,
|
|
18903
|
+
boundWorkspaceId: null
|
|
18904
|
+
};
|
|
18905
|
+
function credentialFactsFrom(response) {
|
|
18906
|
+
const data = toRecord(toRecord(response).data);
|
|
18907
|
+
const { keyType, expiresAt, workspaceId } = data;
|
|
18908
|
+
if (keyType !== "personal" && keyType !== "workspace" && keyType !== "oauth_access_token") {
|
|
18909
|
+
return null;
|
|
18910
|
+
}
|
|
18911
|
+
return {
|
|
18912
|
+
keyType,
|
|
18913
|
+
expiresAt: typeof expiresAt === "string" ? expiresAt : null,
|
|
18914
|
+
boundWorkspaceId: typeof workspaceId === "string" ? workspaceId : null
|
|
18915
|
+
};
|
|
18916
|
+
}
|
|
18803
18917
|
var PROFILE_REJECTION_STATUSES = new Set([401, 403, 404]);
|
|
18804
18918
|
var WHOAMI_EXIT_CODES = {
|
|
18805
18919
|
verified: 0,
|
|
@@ -18815,17 +18929,16 @@ async function verifyProfile(client, profile) {
|
|
|
18815
18929
|
status: "unauthenticated",
|
|
18816
18930
|
authenticated: false,
|
|
18817
18931
|
workspace: null,
|
|
18818
|
-
|
|
18932
|
+
...UNKNOWN_CREDENTIAL,
|
|
18819
18933
|
detail: `not logged in — run: sim login --profile ${safeOneLine(profile.name)}`
|
|
18820
18934
|
};
|
|
18821
18935
|
}
|
|
18822
|
-
let
|
|
18936
|
+
let facts = UNKNOWN_CREDENTIAL;
|
|
18823
18937
|
let authenticated = null;
|
|
18824
18938
|
try {
|
|
18825
|
-
const
|
|
18826
|
-
|
|
18827
|
-
|
|
18828
|
-
keyType = reportedKeyType;
|
|
18939
|
+
const reported = credentialFactsFrom(await client.request("getMeta"));
|
|
18940
|
+
if (reported) {
|
|
18941
|
+
facts = reported;
|
|
18829
18942
|
authenticated = true;
|
|
18830
18943
|
}
|
|
18831
18944
|
} catch (error) {
|
|
@@ -18836,7 +18949,7 @@ async function verifyProfile(client, profile) {
|
|
|
18836
18949
|
status: "rejected",
|
|
18837
18950
|
authenticated: false,
|
|
18838
18951
|
workspace: null,
|
|
18839
|
-
|
|
18952
|
+
...UNKNOWN_CREDENTIAL,
|
|
18840
18953
|
detail: error.message
|
|
18841
18954
|
};
|
|
18842
18955
|
}
|
|
@@ -18846,7 +18959,7 @@ async function verifyProfile(client, profile) {
|
|
|
18846
18959
|
status: "no-workspace",
|
|
18847
18960
|
authenticated,
|
|
18848
18961
|
workspace: null,
|
|
18849
|
-
|
|
18962
|
+
...facts,
|
|
18850
18963
|
detail: `no workspace to check against — run: sim configure --profile ${safeOneLine(profile.name)} --set-workspace <id>`
|
|
18851
18964
|
};
|
|
18852
18965
|
}
|
|
@@ -18859,7 +18972,7 @@ async function verifyProfile(client, profile) {
|
|
|
18859
18972
|
status: "verified",
|
|
18860
18973
|
authenticated: true,
|
|
18861
18974
|
workspace: { id, name, memberCount },
|
|
18862
|
-
|
|
18975
|
+
...facts,
|
|
18863
18976
|
detail: null
|
|
18864
18977
|
};
|
|
18865
18978
|
} catch (error) {
|
|
@@ -18869,7 +18982,7 @@ async function verifyProfile(client, profile) {
|
|
|
18869
18982
|
status: PROFILE_REJECTION_STATUSES.has(error.status) ? "rejected" : "unreachable",
|
|
18870
18983
|
authenticated: error.status === 401 ? false : authenticated,
|
|
18871
18984
|
workspace: null,
|
|
18872
|
-
|
|
18985
|
+
...facts,
|
|
18873
18986
|
detail: error.message
|
|
18874
18987
|
};
|
|
18875
18988
|
}
|
|
@@ -18903,7 +19016,7 @@ function whoamiCommand() {
|
|
|
18903
19016
|
status: "disabled",
|
|
18904
19017
|
authenticated: authentication.configured ? null : false,
|
|
18905
19018
|
workspace: null,
|
|
18906
|
-
|
|
19019
|
+
...UNKNOWN_CREDENTIAL,
|
|
18907
19020
|
detail: "not checked (--no-verify)"
|
|
18908
19021
|
};
|
|
18909
19022
|
const annotate = (value, source) => source === "unset" ? styles3().dim("not set") : `${value} ${styles3().dim(`(${source})`)}`;
|
|
@@ -18918,6 +19031,11 @@ function whoamiCommand() {
|
|
|
18918
19031
|
"Key type",
|
|
18919
19032
|
verification.keyType ?? styles3().dim(options.verify ? "unknown" : "not checked (--no-verify)")
|
|
18920
19033
|
],
|
|
19034
|
+
[
|
|
19035
|
+
"Key expires",
|
|
19036
|
+
verification.keyType ? verification.expiresAt ? safeOneLine(verification.expiresAt) : "never" : styles3().dim(options.verify ? "unknown" : "not checked (--no-verify)")
|
|
19037
|
+
],
|
|
19038
|
+
...verification.boundWorkspaceId ? [["Key bound to", safeOneLine(verification.boundWorkspaceId)]] : [],
|
|
18921
19039
|
["Workspace", annotate(profile.workspaceId ?? "", sources.workspaceId)],
|
|
18922
19040
|
["Output", annotate(profile.output, sources.output)],
|
|
18923
19041
|
["Verified", presentVerification(verification)]
|
|
@@ -18937,6 +19055,8 @@ function whoamiCommand() {
|
|
|
18937
19055
|
status: verification.status,
|
|
18938
19056
|
workspace: verification.workspace,
|
|
18939
19057
|
keyType: verification.keyType,
|
|
19058
|
+
expiresAt: verification.expiresAt,
|
|
19059
|
+
boundWorkspaceId: verification.boundWorkspaceId,
|
|
18940
19060
|
detail: verification.detail
|
|
18941
19061
|
}
|
|
18942
19062
|
});
|
|
@@ -19127,6 +19247,15 @@ var ACCESS_REQUEST_COLUMNS = [
|
|
|
19127
19247
|
{ header: "requester", path: "requester.email" },
|
|
19128
19248
|
{ header: "created", path: "createdAt", format: "timestamp" }
|
|
19129
19249
|
];
|
|
19250
|
+
var WORKSPACE_FIELDS = [
|
|
19251
|
+
{ header: "id" },
|
|
19252
|
+
{ header: "name" },
|
|
19253
|
+
{ header: "color" },
|
|
19254
|
+
{ header: "logo", path: "logoUrl" },
|
|
19255
|
+
{ header: "members", path: "memberCount" },
|
|
19256
|
+
{ header: "created", path: "createdAt", format: "timestamp" },
|
|
19257
|
+
{ header: "updated", path: "updatedAt", format: "timestamp" }
|
|
19258
|
+
];
|
|
19130
19259
|
var FILE_SHARE_FIELDS = [
|
|
19131
19260
|
{ header: "shared", path: "isActive", format: "bool" },
|
|
19132
19261
|
{ header: "URL", path: "url" },
|
|
@@ -19361,6 +19490,18 @@ var CLI_CONTRACT = {
|
|
|
19361
19490
|
updateWorkflowTrigger: {
|
|
19362
19491
|
describe: "Enable or disable one trigger of the live deployment"
|
|
19363
19492
|
},
|
|
19493
|
+
listWorkspaceSchedules: {
|
|
19494
|
+
describe: "Show the timing and health of every schedule the workspace’s deployments run",
|
|
19495
|
+
columns: [
|
|
19496
|
+
{ header: "workflow", path: "workflowName" },
|
|
19497
|
+
{ header: "block", path: "blockId" },
|
|
19498
|
+
{ header: "cron", path: "cronExpression" },
|
|
19499
|
+
{ header: "timezone" },
|
|
19500
|
+
{ header: "status" },
|
|
19501
|
+
{ header: "failures", path: "failedCount" },
|
|
19502
|
+
{ header: "next run", path: "nextRunAt", format: "timestamp" }
|
|
19503
|
+
]
|
|
19504
|
+
},
|
|
19364
19505
|
setSecret: { hidden: true },
|
|
19365
19506
|
deleteTable: {
|
|
19366
19507
|
confirm: "This archives the table and all of its rows; restore with `tables restore`."
|
|
@@ -19545,6 +19686,10 @@ var CLI_CONTRACT = {
|
|
|
19545
19686
|
flags: { folderPath: FOLDER_PATH_FLAG }
|
|
19546
19687
|
},
|
|
19547
19688
|
getWorkflowState: { command: "workflows state get" },
|
|
19689
|
+
getWorkflowOutline: {
|
|
19690
|
+
command: "workflows outline",
|
|
19691
|
+
describe: "Show a workflow’s draft as a compact read-only outline"
|
|
19692
|
+
},
|
|
19548
19693
|
replaceWorkflowState: {
|
|
19549
19694
|
command: "workflows state replace",
|
|
19550
19695
|
confirm: "This replaces the entire draft graph and cannot be undone."
|
|
@@ -20353,15 +20498,16 @@ var CLI_CONTRACT = {
|
|
|
20353
20498
|
},
|
|
20354
20499
|
getWorkspace: {
|
|
20355
20500
|
profileWorkspacePath: true,
|
|
20356
|
-
fields:
|
|
20357
|
-
|
|
20358
|
-
|
|
20359
|
-
|
|
20360
|
-
|
|
20361
|
-
|
|
20362
|
-
|
|
20363
|
-
|
|
20364
|
-
|
|
20501
|
+
fields: WORKSPACE_FIELDS
|
|
20502
|
+
},
|
|
20503
|
+
updateWorkspace: {
|
|
20504
|
+
profileWorkspacePath: true,
|
|
20505
|
+
fields: WORKSPACE_FIELDS,
|
|
20506
|
+
flags: {
|
|
20507
|
+
logoUrl: {
|
|
20508
|
+
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"
|
|
20509
|
+
}
|
|
20510
|
+
}
|
|
20365
20511
|
},
|
|
20366
20512
|
listWorkspaceMembers: {
|
|
20367
20513
|
command: "workspaces members list",
|
|
@@ -22559,6 +22705,7 @@ var GROUP_ALIASES = {
|
|
|
22559
22705
|
logs: "log",
|
|
22560
22706
|
"mcp-servers": "mcp-server",
|
|
22561
22707
|
sandboxes: "sandbox",
|
|
22708
|
+
schedules: "schedule",
|
|
22562
22709
|
secrets: "secret",
|
|
22563
22710
|
skills: "skill",
|
|
22564
22711
|
tables: "table",
|
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
|
}
|
|
@@ -13105,6 +13109,14 @@ var V2_OPERATIONS = {
|
|
|
13105
13109
|
summary: "Get workflow MCP server",
|
|
13106
13110
|
workspaceKeyUnsupported: true
|
|
13107
13111
|
},
|
|
13112
|
+
getWorkflowOutline: {
|
|
13113
|
+
method: "GET",
|
|
13114
|
+
path: "/api/v2/workflows/[workflowId]/outline",
|
|
13115
|
+
pathParams: ["workflowId"],
|
|
13116
|
+
pathParamDocs: { workflowId: "Unique workflow identifier." },
|
|
13117
|
+
responseMode: "json",
|
|
13118
|
+
summary: "Get workflow outline"
|
|
13119
|
+
},
|
|
13108
13120
|
getWorkflowRun: {
|
|
13109
13121
|
method: "GET",
|
|
13110
13122
|
path: "/api/v2/workflows/[workflowId]/runs/[runId]",
|
|
@@ -15761,6 +15773,41 @@ var V2_OPERATIONS = {
|
|
|
15761
15773
|
}
|
|
15762
15774
|
}
|
|
15763
15775
|
},
|
|
15776
|
+
listWorkspaceSchedules: {
|
|
15777
|
+
method: "GET",
|
|
15778
|
+
path: "/api/v2/schedules",
|
|
15779
|
+
pathParams: [],
|
|
15780
|
+
responseMode: "json",
|
|
15781
|
+
summary: "List workspace schedules",
|
|
15782
|
+
query: {
|
|
15783
|
+
workspaceId: {
|
|
15784
|
+
kind: "string",
|
|
15785
|
+
required: true,
|
|
15786
|
+
describe: "Workspace whose schedules should be listed."
|
|
15787
|
+
},
|
|
15788
|
+
limit: {
|
|
15789
|
+
kind: "integer",
|
|
15790
|
+
default: 50,
|
|
15791
|
+
describe: "Maximum schedules to return per page. Must be a whole number from 1 to 100. Defaults to 50."
|
|
15792
|
+
},
|
|
15793
|
+
cursor: {
|
|
15794
|
+
kind: "string",
|
|
15795
|
+
describe: "Opaque cursor from the previous page. Send it back with the same sort and filters; only `limit` may change. Change anything else and pagination must restart without a cursor."
|
|
15796
|
+
},
|
|
15797
|
+
sortBy: {
|
|
15798
|
+
kind: "enum",
|
|
15799
|
+
values: ["createdAt"],
|
|
15800
|
+
default: "createdAt",
|
|
15801
|
+
describe: "Field used to sort the result."
|
|
15802
|
+
},
|
|
15803
|
+
sortOrder: {
|
|
15804
|
+
kind: "enum",
|
|
15805
|
+
values: ["asc", "desc"],
|
|
15806
|
+
default: "desc",
|
|
15807
|
+
describe: "Sort direction."
|
|
15808
|
+
}
|
|
15809
|
+
}
|
|
15810
|
+
},
|
|
15764
15811
|
moveFileItems: {
|
|
15765
15812
|
method: "POST",
|
|
15766
15813
|
path: "/api/v2/files/move",
|
|
@@ -18148,6 +18195,22 @@ var V2_OPERATIONS = {
|
|
|
18148
18195
|
}
|
|
18149
18196
|
}
|
|
18150
18197
|
},
|
|
18198
|
+
updateWorkspace: {
|
|
18199
|
+
method: "PATCH",
|
|
18200
|
+
path: "/api/v2/workspaces/[workspaceId]",
|
|
18201
|
+
pathParams: ["workspaceId"],
|
|
18202
|
+
pathParamDocs: { workspaceId: "Workspace to update." },
|
|
18203
|
+
responseMode: "json",
|
|
18204
|
+
summary: "Update workspace",
|
|
18205
|
+
workspaceKeyUnsupported: true,
|
|
18206
|
+
body: {
|
|
18207
|
+
name: { kind: "string", describe: "New workspace display name." },
|
|
18208
|
+
logoUrl: {
|
|
18209
|
+
kind: "string",
|
|
18210
|
+
describe: "New workspace logo URL: a root-relative path (starting with /) or an https:// URL. Send null to remove the logo."
|
|
18211
|
+
}
|
|
18212
|
+
}
|
|
18213
|
+
},
|
|
18151
18214
|
updateWorkspaceForkExclusions: {
|
|
18152
18215
|
method: "PUT",
|
|
18153
18216
|
path: "/api/v2/workspaces/[workspaceId]/fork/exclusions",
|
|
@@ -18586,6 +18649,17 @@ function addProfileCommand() {
|
|
|
18586
18649
|
printLine(styles3().dim(` Try: sim --profile ${safeOneLine(profileName)} whoami`));
|
|
18587
18650
|
});
|
|
18588
18651
|
}
|
|
18652
|
+
var MIN_KEY_EXPIRY_DAYS = 1;
|
|
18653
|
+
var MAX_KEY_EXPIRY_DAYS = 365;
|
|
18654
|
+
function parseExpiresIn(value) {
|
|
18655
|
+
if (value === undefined)
|
|
18656
|
+
return;
|
|
18657
|
+
const days = Number(value);
|
|
18658
|
+
if (!/^\d+$/.test(value.trim()) || days < MIN_KEY_EXPIRY_DAYS || days > MAX_KEY_EXPIRY_DAYS) {
|
|
18659
|
+
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);
|
|
18660
|
+
}
|
|
18661
|
+
return days;
|
|
18662
|
+
}
|
|
18589
18663
|
async function chooseLoginFlow(profile, options) {
|
|
18590
18664
|
requireSecureEndpoint(profile.endpoint);
|
|
18591
18665
|
if (options.method === "api-key")
|
|
@@ -18681,7 +18755,7 @@ Waiting for you to approve in the browser…`));
|
|
|
18681
18755
|
}
|
|
18682
18756
|
}
|
|
18683
18757
|
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
|
|
18758
|
+
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
18759
|
const profile = profileFrom(command, { allowUnknownProfile: true });
|
|
18686
18760
|
const authProfile = resolveAuthenticationProfileName(profile.name);
|
|
18687
18761
|
if (authProfile !== profile.name) {
|
|
@@ -18700,14 +18774,13 @@ function loginCommand() {
|
|
|
18700
18774
|
}
|
|
18701
18775
|
}
|
|
18702
18776
|
const callbackPort = parseCallbackPort(options.callbackPort);
|
|
18777
|
+
const expiresInDays = parseExpiresIn(options.expiresIn);
|
|
18703
18778
|
const loginFlow = await chooseLoginFlow(profile, options);
|
|
18704
|
-
if (loginFlow === "handoff") {
|
|
18705
|
-
|
|
18706
|
-
|
|
18707
|
-
|
|
18708
|
-
|
|
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
|
-
}
|
|
18779
|
+
if (loginFlow === "handoff" && callbackPort !== undefined) {
|
|
18780
|
+
throw new SimApiError("API-key login has no local callback, so --callback-port does not apply. Use --method oauth, or drop --callback-port.", 0);
|
|
18781
|
+
}
|
|
18782
|
+
if (loginFlow === "oauth" && expiresInDays !== undefined) {
|
|
18783
|
+
throw new SimApiError("OAuth logins renew themselves, so --expires-in does not apply. Use --method api-key, or drop --expires-in.", 0);
|
|
18711
18784
|
}
|
|
18712
18785
|
await withProfileLoginLease(profile.name, async () => {
|
|
18713
18786
|
assertLoginProfileUnchanged(profile.name, snapshot);
|
|
@@ -18715,13 +18788,35 @@ function loginCommand() {
|
|
|
18715
18788
|
await loginWithOAuth(profile, options, callbackPort, snapshot);
|
|
18716
18789
|
return;
|
|
18717
18790
|
}
|
|
18718
|
-
await loginWithHandoff(profile, options, snapshot);
|
|
18791
|
+
await loginWithHandoff(profile, options, { readOnly: options.readOnly === true, expiresInDays }, snapshot);
|
|
18719
18792
|
});
|
|
18720
18793
|
});
|
|
18721
18794
|
}
|
|
18722
|
-
|
|
18795
|
+
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
18796
|
+
var EXPIRY_TOLERANCE_MS = 60 * 60 * 1000;
|
|
18797
|
+
function requireRequestedKey(key, keyRequest) {
|
|
18798
|
+
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);
|
|
18799
|
+
const requestedAccess = keyRequest.readOnly ? "read" : "write";
|
|
18800
|
+
const issuedAccess = key.access ?? "write";
|
|
18801
|
+
if (issuedAccess !== requestedAccess) {
|
|
18802
|
+
throw refuse(issuedAccess === "read" ? "a read-only key" : "a full-access key", "--read-only");
|
|
18803
|
+
}
|
|
18804
|
+
if (keyRequest.expiresInDays === undefined) {
|
|
18805
|
+
if (key.expiresAt)
|
|
18806
|
+
throw refuse(`a key that expires ${safeOneLine(key.expiresAt ?? "")}`, "--expires-in");
|
|
18807
|
+
return;
|
|
18808
|
+
}
|
|
18809
|
+
const expiresAt = key.expiresAt ? Date.parse(key.expiresAt) : Number.NaN;
|
|
18810
|
+
if (Number.isNaN(expiresAt))
|
|
18811
|
+
throw refuse("a key that never expires", "--expires-in");
|
|
18812
|
+
const requested = Date.now() + keyRequest.expiresInDays * DAY_MS;
|
|
18813
|
+
if (Math.abs(expiresAt - requested) > EXPIRY_TOLERANCE_MS) {
|
|
18814
|
+
throw refuse(`a key that expires ${safeOneLine(key.expiresAt ?? "")}`, "--expires-in");
|
|
18815
|
+
}
|
|
18816
|
+
}
|
|
18817
|
+
async function loginWithHandoff(profile, options, keyRequest, expected) {
|
|
18723
18818
|
const auth = createAuthRequest();
|
|
18724
|
-
const url = buildApprovalUrl(profile.endpoint, auth, profile.workspaceId ?? undefined);
|
|
18819
|
+
const url = buildApprovalUrl(profile.endpoint, auth, profile.workspaceId ?? undefined, keyRequest);
|
|
18725
18820
|
printLine(`Signing in to ${styles3().bold(profile.endpoint)} as profile ${styles3().bold(safeOneLine(profile.name))}`);
|
|
18726
18821
|
printLine(`
|
|
18727
18822
|
Pairing code: ${styles3().bold(auth.pairing)}`);
|
|
@@ -18737,6 +18832,7 @@ Waiting for approval…`));
|
|
|
18737
18832
|
if (key.scope !== "platform") {
|
|
18738
18833
|
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
18834
|
}
|
|
18835
|
+
requireRequestedKey(key, keyRequest);
|
|
18740
18836
|
const settings = {
|
|
18741
18837
|
endpoint: profile.endpoint,
|
|
18742
18838
|
workspace: key.workspaceId == null ? null : normalizeWorkspaceId(key.workspaceId, "the login response")
|
|
@@ -18771,6 +18867,7 @@ Waiting for approval…`));
|
|
|
18771
18867
|
}
|
|
18772
18868
|
printLine(styles3().green(`
|
|
18773
18869
|
✓ Logged in. Key stored in ${credentialsPath()}`));
|
|
18870
|
+
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
18871
|
if (key.workspaceBound && key.workspaceId) {
|
|
18775
18872
|
printLine(styles3().dim(` Workspace-scoped key — it can only reach ${key.workspaceId}.`));
|
|
18776
18873
|
} else if (key.workspaceId) {
|
|
@@ -18849,6 +18946,23 @@ function logoutCommand() {
|
|
|
18849
18946
|
}
|
|
18850
18947
|
});
|
|
18851
18948
|
}
|
|
18949
|
+
var UNKNOWN_CREDENTIAL = {
|
|
18950
|
+
keyType: null,
|
|
18951
|
+
expiresAt: null,
|
|
18952
|
+
boundWorkspaceId: null
|
|
18953
|
+
};
|
|
18954
|
+
function credentialFactsFrom(response) {
|
|
18955
|
+
const data = toRecord(toRecord(response).data);
|
|
18956
|
+
const { keyType, expiresAt, workspaceId } = data;
|
|
18957
|
+
if (keyType !== "personal" && keyType !== "workspace" && keyType !== "oauth_access_token") {
|
|
18958
|
+
return null;
|
|
18959
|
+
}
|
|
18960
|
+
return {
|
|
18961
|
+
keyType,
|
|
18962
|
+
expiresAt: typeof expiresAt === "string" ? expiresAt : null,
|
|
18963
|
+
boundWorkspaceId: typeof workspaceId === "string" ? workspaceId : null
|
|
18964
|
+
};
|
|
18965
|
+
}
|
|
18852
18966
|
var PROFILE_REJECTION_STATUSES = new Set([401, 403, 404]);
|
|
18853
18967
|
var WHOAMI_EXIT_CODES = {
|
|
18854
18968
|
verified: 0,
|
|
@@ -18864,17 +18978,16 @@ async function verifyProfile(client, profile) {
|
|
|
18864
18978
|
status: "unauthenticated",
|
|
18865
18979
|
authenticated: false,
|
|
18866
18980
|
workspace: null,
|
|
18867
|
-
|
|
18981
|
+
...UNKNOWN_CREDENTIAL,
|
|
18868
18982
|
detail: `not logged in — run: sim login --profile ${safeOneLine(profile.name)}`
|
|
18869
18983
|
};
|
|
18870
18984
|
}
|
|
18871
|
-
let
|
|
18985
|
+
let facts = UNKNOWN_CREDENTIAL;
|
|
18872
18986
|
let authenticated = null;
|
|
18873
18987
|
try {
|
|
18874
|
-
const
|
|
18875
|
-
|
|
18876
|
-
|
|
18877
|
-
keyType = reportedKeyType;
|
|
18988
|
+
const reported = credentialFactsFrom(await client.request("getMeta"));
|
|
18989
|
+
if (reported) {
|
|
18990
|
+
facts = reported;
|
|
18878
18991
|
authenticated = true;
|
|
18879
18992
|
}
|
|
18880
18993
|
} catch (error) {
|
|
@@ -18885,7 +18998,7 @@ async function verifyProfile(client, profile) {
|
|
|
18885
18998
|
status: "rejected",
|
|
18886
18999
|
authenticated: false,
|
|
18887
19000
|
workspace: null,
|
|
18888
|
-
|
|
19001
|
+
...UNKNOWN_CREDENTIAL,
|
|
18889
19002
|
detail: error.message
|
|
18890
19003
|
};
|
|
18891
19004
|
}
|
|
@@ -18895,7 +19008,7 @@ async function verifyProfile(client, profile) {
|
|
|
18895
19008
|
status: "no-workspace",
|
|
18896
19009
|
authenticated,
|
|
18897
19010
|
workspace: null,
|
|
18898
|
-
|
|
19011
|
+
...facts,
|
|
18899
19012
|
detail: `no workspace to check against — run: sim configure --profile ${safeOneLine(profile.name)} --set-workspace <id>`
|
|
18900
19013
|
};
|
|
18901
19014
|
}
|
|
@@ -18908,7 +19021,7 @@ async function verifyProfile(client, profile) {
|
|
|
18908
19021
|
status: "verified",
|
|
18909
19022
|
authenticated: true,
|
|
18910
19023
|
workspace: { id, name, memberCount },
|
|
18911
|
-
|
|
19024
|
+
...facts,
|
|
18912
19025
|
detail: null
|
|
18913
19026
|
};
|
|
18914
19027
|
} catch (error) {
|
|
@@ -18918,7 +19031,7 @@ async function verifyProfile(client, profile) {
|
|
|
18918
19031
|
status: PROFILE_REJECTION_STATUSES.has(error.status) ? "rejected" : "unreachable",
|
|
18919
19032
|
authenticated: error.status === 401 ? false : authenticated,
|
|
18920
19033
|
workspace: null,
|
|
18921
|
-
|
|
19034
|
+
...facts,
|
|
18922
19035
|
detail: error.message
|
|
18923
19036
|
};
|
|
18924
19037
|
}
|
|
@@ -18952,7 +19065,7 @@ function whoamiCommand() {
|
|
|
18952
19065
|
status: "disabled",
|
|
18953
19066
|
authenticated: authentication.configured ? null : false,
|
|
18954
19067
|
workspace: null,
|
|
18955
|
-
|
|
19068
|
+
...UNKNOWN_CREDENTIAL,
|
|
18956
19069
|
detail: "not checked (--no-verify)"
|
|
18957
19070
|
};
|
|
18958
19071
|
const annotate = (value, source) => source === "unset" ? styles3().dim("not set") : `${value} ${styles3().dim(`(${source})`)}`;
|
|
@@ -18967,6 +19080,11 @@ function whoamiCommand() {
|
|
|
18967
19080
|
"Key type",
|
|
18968
19081
|
verification.keyType ?? styles3().dim(options.verify ? "unknown" : "not checked (--no-verify)")
|
|
18969
19082
|
],
|
|
19083
|
+
[
|
|
19084
|
+
"Key expires",
|
|
19085
|
+
verification.keyType ? verification.expiresAt ? safeOneLine(verification.expiresAt) : "never" : styles3().dim(options.verify ? "unknown" : "not checked (--no-verify)")
|
|
19086
|
+
],
|
|
19087
|
+
...verification.boundWorkspaceId ? [["Key bound to", safeOneLine(verification.boundWorkspaceId)]] : [],
|
|
18970
19088
|
["Workspace", annotate(profile.workspaceId ?? "", sources.workspaceId)],
|
|
18971
19089
|
["Output", annotate(profile.output, sources.output)],
|
|
18972
19090
|
["Verified", presentVerification(verification)]
|
|
@@ -18986,6 +19104,8 @@ function whoamiCommand() {
|
|
|
18986
19104
|
status: verification.status,
|
|
18987
19105
|
workspace: verification.workspace,
|
|
18988
19106
|
keyType: verification.keyType,
|
|
19107
|
+
expiresAt: verification.expiresAt,
|
|
19108
|
+
boundWorkspaceId: verification.boundWorkspaceId,
|
|
18989
19109
|
detail: verification.detail
|
|
18990
19110
|
}
|
|
18991
19111
|
});
|
|
@@ -19176,6 +19296,15 @@ var ACCESS_REQUEST_COLUMNS = [
|
|
|
19176
19296
|
{ header: "requester", path: "requester.email" },
|
|
19177
19297
|
{ header: "created", path: "createdAt", format: "timestamp" }
|
|
19178
19298
|
];
|
|
19299
|
+
var WORKSPACE_FIELDS = [
|
|
19300
|
+
{ header: "id" },
|
|
19301
|
+
{ header: "name" },
|
|
19302
|
+
{ header: "color" },
|
|
19303
|
+
{ header: "logo", path: "logoUrl" },
|
|
19304
|
+
{ header: "members", path: "memberCount" },
|
|
19305
|
+
{ header: "created", path: "createdAt", format: "timestamp" },
|
|
19306
|
+
{ header: "updated", path: "updatedAt", format: "timestamp" }
|
|
19307
|
+
];
|
|
19179
19308
|
var FILE_SHARE_FIELDS = [
|
|
19180
19309
|
{ header: "shared", path: "isActive", format: "bool" },
|
|
19181
19310
|
{ header: "URL", path: "url" },
|
|
@@ -19410,6 +19539,18 @@ var CLI_CONTRACT = {
|
|
|
19410
19539
|
updateWorkflowTrigger: {
|
|
19411
19540
|
describe: "Enable or disable one trigger of the live deployment"
|
|
19412
19541
|
},
|
|
19542
|
+
listWorkspaceSchedules: {
|
|
19543
|
+
describe: "Show the timing and health of every schedule the workspace’s deployments run",
|
|
19544
|
+
columns: [
|
|
19545
|
+
{ header: "workflow", path: "workflowName" },
|
|
19546
|
+
{ header: "block", path: "blockId" },
|
|
19547
|
+
{ header: "cron", path: "cronExpression" },
|
|
19548
|
+
{ header: "timezone" },
|
|
19549
|
+
{ header: "status" },
|
|
19550
|
+
{ header: "failures", path: "failedCount" },
|
|
19551
|
+
{ header: "next run", path: "nextRunAt", format: "timestamp" }
|
|
19552
|
+
]
|
|
19553
|
+
},
|
|
19413
19554
|
setSecret: { hidden: true },
|
|
19414
19555
|
deleteTable: {
|
|
19415
19556
|
confirm: "This archives the table and all of its rows; restore with `tables restore`."
|
|
@@ -19594,6 +19735,10 @@ var CLI_CONTRACT = {
|
|
|
19594
19735
|
flags: { folderPath: FOLDER_PATH_FLAG }
|
|
19595
19736
|
},
|
|
19596
19737
|
getWorkflowState: { command: "workflows state get" },
|
|
19738
|
+
getWorkflowOutline: {
|
|
19739
|
+
command: "workflows outline",
|
|
19740
|
+
describe: "Show a workflow’s draft as a compact read-only outline"
|
|
19741
|
+
},
|
|
19597
19742
|
replaceWorkflowState: {
|
|
19598
19743
|
command: "workflows state replace",
|
|
19599
19744
|
confirm: "This replaces the entire draft graph and cannot be undone."
|
|
@@ -20402,15 +20547,16 @@ var CLI_CONTRACT = {
|
|
|
20402
20547
|
},
|
|
20403
20548
|
getWorkspace: {
|
|
20404
20549
|
profileWorkspacePath: true,
|
|
20405
|
-
fields:
|
|
20406
|
-
|
|
20407
|
-
|
|
20408
|
-
|
|
20409
|
-
|
|
20410
|
-
|
|
20411
|
-
|
|
20412
|
-
|
|
20413
|
-
|
|
20550
|
+
fields: WORKSPACE_FIELDS
|
|
20551
|
+
},
|
|
20552
|
+
updateWorkspace: {
|
|
20553
|
+
profileWorkspacePath: true,
|
|
20554
|
+
fields: WORKSPACE_FIELDS,
|
|
20555
|
+
flags: {
|
|
20556
|
+
logoUrl: {
|
|
20557
|
+
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"
|
|
20558
|
+
}
|
|
20559
|
+
}
|
|
20414
20560
|
},
|
|
20415
20561
|
listWorkspaceMembers: {
|
|
20416
20562
|
command: "workspaces members list",
|
|
@@ -22608,6 +22754,7 @@ var GROUP_ALIASES = {
|
|
|
22608
22754
|
logs: "log",
|
|
22609
22755
|
"mcp-servers": "mcp-server",
|
|
22610
22756
|
sandboxes: "sandbox",
|
|
22757
|
+
schedules: "schedule",
|
|
22611
22758
|
secrets: "secret",
|
|
22612
22759
|
skills: "skill",
|
|
22613
22760
|
tables: "table",
|