@autohq/cli 0.1.97 → 0.1.99
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/index.js +194 -124
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18504,33 +18504,6 @@ var init_tokens = __esm({
|
|
|
18504
18504
|
}
|
|
18505
18505
|
});
|
|
18506
18506
|
|
|
18507
|
-
// src/lib/config/active-project.ts
|
|
18508
|
-
function requireActiveProject(config2) {
|
|
18509
|
-
if (!config2.organizationId || !config2.projectId) {
|
|
18510
|
-
throw new Error(
|
|
18511
|
-
"Run `auto orgs use <organization>` and `auto projects use <project>` first."
|
|
18512
|
-
);
|
|
18513
|
-
}
|
|
18514
|
-
return {
|
|
18515
|
-
organizationId: config2.organizationId,
|
|
18516
|
-
projectId: config2.projectId
|
|
18517
|
-
};
|
|
18518
|
-
}
|
|
18519
|
-
function clearAccessToken(config2) {
|
|
18520
|
-
return {
|
|
18521
|
-
...config2,
|
|
18522
|
-
accessToken: void 0,
|
|
18523
|
-
accessTokenExpiresAt: void 0,
|
|
18524
|
-
accessTokenOrganizationId: void 0,
|
|
18525
|
-
accessTokenProjectId: void 0
|
|
18526
|
-
};
|
|
18527
|
-
}
|
|
18528
|
-
var init_active_project = __esm({
|
|
18529
|
-
"src/lib/config/active-project.ts"() {
|
|
18530
|
-
"use strict";
|
|
18531
|
-
}
|
|
18532
|
-
});
|
|
18533
|
-
|
|
18534
18507
|
// src/lib/config/path.ts
|
|
18535
18508
|
import { createHash } from "crypto";
|
|
18536
18509
|
import { homedir as homedir2 } from "os";
|
|
@@ -18632,6 +18605,56 @@ var init_file = __esm({
|
|
|
18632
18605
|
}
|
|
18633
18606
|
});
|
|
18634
18607
|
|
|
18608
|
+
// src/lib/config/active-project.ts
|
|
18609
|
+
function requireActiveProject(config2) {
|
|
18610
|
+
if (!config2.organizationId || !config2.projectId) {
|
|
18611
|
+
throw new Error(
|
|
18612
|
+
"Run `auto orgs use <organization>` and `auto projects use <project>` first."
|
|
18613
|
+
);
|
|
18614
|
+
}
|
|
18615
|
+
return {
|
|
18616
|
+
organizationId: config2.organizationId,
|
|
18617
|
+
projectId: config2.projectId
|
|
18618
|
+
};
|
|
18619
|
+
}
|
|
18620
|
+
function persistActiveOrganization(configPath, organizationId) {
|
|
18621
|
+
const config2 = readConfig(configPath);
|
|
18622
|
+
writeConfig(
|
|
18623
|
+
clearAccessToken({
|
|
18624
|
+
...config2,
|
|
18625
|
+
organizationId,
|
|
18626
|
+
projectId: void 0
|
|
18627
|
+
}),
|
|
18628
|
+
configPath
|
|
18629
|
+
);
|
|
18630
|
+
}
|
|
18631
|
+
function persistActiveProject(configPath, project) {
|
|
18632
|
+
const config2 = readConfig(configPath);
|
|
18633
|
+
writeConfig(
|
|
18634
|
+
clearAccessToken({
|
|
18635
|
+
...config2,
|
|
18636
|
+
organizationId: project.organizationId,
|
|
18637
|
+
projectId: project.projectId
|
|
18638
|
+
}),
|
|
18639
|
+
configPath
|
|
18640
|
+
);
|
|
18641
|
+
}
|
|
18642
|
+
function clearAccessToken(config2) {
|
|
18643
|
+
return {
|
|
18644
|
+
...config2,
|
|
18645
|
+
accessToken: void 0,
|
|
18646
|
+
accessTokenExpiresAt: void 0,
|
|
18647
|
+
accessTokenOrganizationId: void 0,
|
|
18648
|
+
accessTokenProjectId: void 0
|
|
18649
|
+
};
|
|
18650
|
+
}
|
|
18651
|
+
var init_active_project = __esm({
|
|
18652
|
+
"src/lib/config/active-project.ts"() {
|
|
18653
|
+
"use strict";
|
|
18654
|
+
init_file();
|
|
18655
|
+
}
|
|
18656
|
+
});
|
|
18657
|
+
|
|
18635
18658
|
// src/lib/streams/sse.ts
|
|
18636
18659
|
async function* readSseEvents(body) {
|
|
18637
18660
|
const decoder = new TextDecoder();
|
|
@@ -18855,7 +18878,7 @@ function createResourceApi(context) {
|
|
|
18855
18878
|
};
|
|
18856
18879
|
}
|
|
18857
18880
|
async function listProjectServiceAccounts(context, options) {
|
|
18858
|
-
const project = context.activeProject();
|
|
18881
|
+
const project = await context.activeProject();
|
|
18859
18882
|
const response = await context.authenticatedFetch(
|
|
18860
18883
|
context.apiUrl(
|
|
18861
18884
|
projectApiPath(project, "/service-accounts"),
|
|
@@ -18870,7 +18893,7 @@ async function listProjectServiceAccounts(context, options) {
|
|
|
18870
18893
|
return ProjectServiceAccountListResponseSchema.parse(await response.json());
|
|
18871
18894
|
}
|
|
18872
18895
|
async function getSessionPresence(context, request, options) {
|
|
18873
|
-
const project = context.activeProject();
|
|
18896
|
+
const project = await context.activeProject();
|
|
18874
18897
|
const response = await context.authenticatedFetch(
|
|
18875
18898
|
context.apiUrl(
|
|
18876
18899
|
projectApiPath(
|
|
@@ -18888,12 +18911,12 @@ async function getSessionPresence(context, request, options) {
|
|
|
18888
18911
|
return SessionPresenceResponseSchema.parse(await response.json());
|
|
18889
18912
|
}
|
|
18890
18913
|
async function connectSessionPresence(context, request, options) {
|
|
18891
|
-
const project = context.activeProject();
|
|
18914
|
+
const project = await context.activeProject();
|
|
18892
18915
|
const response = await context.authenticatedFetch(
|
|
18893
18916
|
context.apiUrl(
|
|
18894
18917
|
projectApiPath(
|
|
18895
18918
|
project,
|
|
18896
|
-
`/sessions/${encodeURIComponent(request.name)}/presence/
|
|
18919
|
+
`/sessions/${encodeURIComponent(request.name)}/presence/connections`
|
|
18897
18920
|
),
|
|
18898
18921
|
options.apiBaseUrl
|
|
18899
18922
|
),
|
|
@@ -18921,7 +18944,7 @@ async function connectSessionPresence(context, request, options) {
|
|
|
18921
18944
|
return SessionPresenceConnectResponseSchema.parse(await response.json());
|
|
18922
18945
|
}
|
|
18923
18946
|
async function recordSessionPresenceIcon(context, request, options) {
|
|
18924
|
-
const project = context.activeProject();
|
|
18947
|
+
const project = await context.activeProject();
|
|
18925
18948
|
const response = await context.authenticatedFetch(
|
|
18926
18949
|
context.apiUrl(
|
|
18927
18950
|
projectApiPath(
|
|
@@ -18943,12 +18966,12 @@ async function recordSessionPresenceIcon(context, request, options) {
|
|
|
18943
18966
|
return SessionPresenceIconResponseSchema.parse(await response.json());
|
|
18944
18967
|
}
|
|
18945
18968
|
async function startToolConnection(context, request, options) {
|
|
18946
|
-
const project = context.activeProject();
|
|
18969
|
+
const project = await context.activeProject();
|
|
18947
18970
|
const response = await context.authenticatedFetch(
|
|
18948
18971
|
context.apiUrl(
|
|
18949
18972
|
projectApiPath(
|
|
18950
18973
|
project,
|
|
18951
|
-
`/tools/${encodeURIComponent(request.name)}/
|
|
18974
|
+
`/tools/${encodeURIComponent(request.name)}/connections`
|
|
18952
18975
|
),
|
|
18953
18976
|
options.apiBaseUrl
|
|
18954
18977
|
),
|
|
@@ -18985,7 +19008,7 @@ async function completeToolConnection(context, request, options) {
|
|
|
18985
19008
|
return ToolConnectCompleteResponseSchema.parse(await response.json());
|
|
18986
19009
|
}
|
|
18987
19010
|
async function createProjectServiceAccount(context, request, options) {
|
|
18988
|
-
const project = context.activeProject();
|
|
19011
|
+
const project = await context.activeProject();
|
|
18989
19012
|
const response = await context.authenticatedFetch(
|
|
18990
19013
|
context.apiUrl(
|
|
18991
19014
|
projectApiPath(project, "/service-accounts"),
|
|
@@ -19006,7 +19029,7 @@ async function createProjectServiceAccount(context, request, options) {
|
|
|
19006
19029
|
return ProjectServiceAccountTokenResponseSchema.parse(await response.json());
|
|
19007
19030
|
}
|
|
19008
19031
|
async function updateProjectServiceAccount(context, request, options) {
|
|
19009
|
-
const project = context.activeProject();
|
|
19032
|
+
const project = await context.activeProject();
|
|
19010
19033
|
const response = await context.authenticatedFetch(
|
|
19011
19034
|
context.apiUrl(
|
|
19012
19035
|
projectApiPath(
|
|
@@ -19030,17 +19053,17 @@ async function updateProjectServiceAccount(context, request, options) {
|
|
|
19030
19053
|
return ProjectServiceAccountUpdateResponseSchema.parse(await response.json());
|
|
19031
19054
|
}
|
|
19032
19055
|
async function rotateProjectServiceAccountToken(context, request, options) {
|
|
19033
|
-
const project = context.activeProject();
|
|
19056
|
+
const project = await context.activeProject();
|
|
19034
19057
|
const response = await context.authenticatedFetch(
|
|
19035
19058
|
context.apiUrl(
|
|
19036
19059
|
projectApiPath(
|
|
19037
19060
|
project,
|
|
19038
|
-
`/service-accounts/${encodeURIComponent(request.name)}/
|
|
19061
|
+
`/service-accounts/${encodeURIComponent(request.name)}/tokens`
|
|
19039
19062
|
),
|
|
19040
19063
|
options.apiBaseUrl
|
|
19041
19064
|
),
|
|
19042
19065
|
{
|
|
19043
|
-
method: "
|
|
19066
|
+
method: "POST"
|
|
19044
19067
|
},
|
|
19045
19068
|
options.apiBaseUrl
|
|
19046
19069
|
);
|
|
@@ -19050,7 +19073,7 @@ async function rotateProjectServiceAccountToken(context, request, options) {
|
|
|
19050
19073
|
return ProjectServiceAccountTokenResponseSchema.parse(await response.json());
|
|
19051
19074
|
}
|
|
19052
19075
|
async function removeProjectServiceAccount(context, request, options) {
|
|
19053
|
-
const project = context.activeProject();
|
|
19076
|
+
const project = await context.activeProject();
|
|
19054
19077
|
const response = await context.authenticatedFetch(
|
|
19055
19078
|
context.apiUrl(
|
|
19056
19079
|
projectApiPath(
|
|
@@ -19091,7 +19114,7 @@ async function deleteProjectResource(context, request, options) {
|
|
|
19091
19114
|
};
|
|
19092
19115
|
}
|
|
19093
19116
|
async function applyProjectResources(context, request, options) {
|
|
19094
|
-
const path2 = projectApplyPath(context);
|
|
19117
|
+
const path2 = await projectApplyPath(context);
|
|
19095
19118
|
const response = await context.authenticatedFetch(
|
|
19096
19119
|
context.apiUrl(path2, options.apiBaseUrl),
|
|
19097
19120
|
{
|
|
@@ -19108,9 +19131,9 @@ async function applyProjectResources(context, request, options) {
|
|
|
19108
19131
|
}
|
|
19109
19132
|
return ProjectApplyResponseSchema.parse(await response.json());
|
|
19110
19133
|
}
|
|
19111
|
-
function projectApplyPath(context) {
|
|
19134
|
+
async function projectApplyPath(context) {
|
|
19112
19135
|
try {
|
|
19113
|
-
return projectApiPath(context.activeProject(), "/resources/apply");
|
|
19136
|
+
return projectApiPath(await context.activeProject(), "/resources/apply");
|
|
19114
19137
|
} catch (error51) {
|
|
19115
19138
|
if (context.shouldTryProjectInferredAuth()) {
|
|
19116
19139
|
return apiPath("/project/resources/apply");
|
|
@@ -19129,7 +19152,7 @@ function projectResource(context, endpoint) {
|
|
|
19129
19152
|
};
|
|
19130
19153
|
}
|
|
19131
19154
|
async function applyProjectResource(context, endpoint, request, options) {
|
|
19132
|
-
const project = context.activeProject();
|
|
19155
|
+
const project = await context.activeProject();
|
|
19133
19156
|
const response = await context.authenticatedFetch(
|
|
19134
19157
|
context.apiUrl(projectApiPath(project, endpoint.path), options.apiBaseUrl),
|
|
19135
19158
|
{
|
|
@@ -19147,7 +19170,7 @@ async function applyProjectResource(context, endpoint, request, options) {
|
|
|
19147
19170
|
return endpoint.applyResponseSchema.parse(await response.json());
|
|
19148
19171
|
}
|
|
19149
19172
|
async function listProjectResources(context, endpoint, options) {
|
|
19150
|
-
const project = context.activeProject();
|
|
19173
|
+
const project = await context.activeProject();
|
|
19151
19174
|
const response = await context.authenticatedFetch(
|
|
19152
19175
|
context.apiUrl(projectApiPath(project, endpoint.path), options.apiBaseUrl),
|
|
19153
19176
|
{},
|
|
@@ -19193,22 +19216,15 @@ function createApiClient(input) {
|
|
|
19193
19216
|
function apiUrl(path2, explicit) {
|
|
19194
19217
|
return `${apiBaseUrl(explicit)}${path2}`;
|
|
19195
19218
|
}
|
|
19196
|
-
function activeProject() {
|
|
19197
|
-
const
|
|
19198
|
-
|
|
19199
|
-
const projectId = input.env.AUTO_PROJECT_ID?.trim() || config2.projectId;
|
|
19200
|
-
return requireActiveProject({
|
|
19201
|
-
...config2,
|
|
19202
|
-
organizationId,
|
|
19203
|
-
projectId
|
|
19204
|
-
});
|
|
19219
|
+
async function activeProject() {
|
|
19220
|
+
const { organizationId, projectId } = await resolveActiveSelection();
|
|
19221
|
+
return requireActiveProject({ organizationId, projectId });
|
|
19205
19222
|
}
|
|
19206
19223
|
function shouldTryProjectInferredAuth() {
|
|
19207
19224
|
return Boolean(input.env.AUTO_API_TOKEN?.trim());
|
|
19208
19225
|
}
|
|
19209
|
-
function activeOrganization() {
|
|
19210
|
-
const
|
|
19211
|
-
const organizationId = input.env.AUTO_ORGANIZATION_ID?.trim() || config2.organizationId;
|
|
19226
|
+
async function activeOrganization() {
|
|
19227
|
+
const { organizationId } = await resolveActiveSelection();
|
|
19212
19228
|
if (!organizationId) {
|
|
19213
19229
|
throw new Error(
|
|
19214
19230
|
"No active organization. Run `auto auth login` to sign in, then `auto orgs use <organization>` to select one."
|
|
@@ -19216,6 +19232,90 @@ function createApiClient(input) {
|
|
|
19216
19232
|
}
|
|
19217
19233
|
return { organizationId };
|
|
19218
19234
|
}
|
|
19235
|
+
async function resolveActiveSelection() {
|
|
19236
|
+
const config2 = readConfig(input.configPath);
|
|
19237
|
+
const envOrganizationId = input.env.AUTO_ORGANIZATION_ID?.trim();
|
|
19238
|
+
const envProjectId = input.env.AUTO_PROJECT_ID?.trim();
|
|
19239
|
+
const organizationId = envOrganizationId || config2.organizationId;
|
|
19240
|
+
const projectId = envProjectId || config2.projectId;
|
|
19241
|
+
if (organizationId && projectId || !canDiscoverDefaultSelection(config2)) {
|
|
19242
|
+
return { organizationId, projectId };
|
|
19243
|
+
}
|
|
19244
|
+
const discovered = await discoverDefaultSelection(organizationId);
|
|
19245
|
+
const resolved = {
|
|
19246
|
+
organizationId: organizationId || discovered.organizationId,
|
|
19247
|
+
projectId: projectId || discovered.projectId
|
|
19248
|
+
};
|
|
19249
|
+
persistDiscoveredSelection({
|
|
19250
|
+
config: config2,
|
|
19251
|
+
envOrganizationId,
|
|
19252
|
+
envProjectId,
|
|
19253
|
+
resolved
|
|
19254
|
+
});
|
|
19255
|
+
return resolved;
|
|
19256
|
+
}
|
|
19257
|
+
function canDiscoverDefaultSelection(config2) {
|
|
19258
|
+
return Boolean(config2.refreshToken) && !input.env.AUTO_API_TOKEN?.trim();
|
|
19259
|
+
}
|
|
19260
|
+
async function discoverDefaultSelection(pinnedOrganizationId) {
|
|
19261
|
+
try {
|
|
19262
|
+
const organizationId = pinnedOrganizationId ?? await singleOrganizationId();
|
|
19263
|
+
if (!organizationId) {
|
|
19264
|
+
return {};
|
|
19265
|
+
}
|
|
19266
|
+
const { projects } = await fetchProjects2();
|
|
19267
|
+
const organizationProjects = projects.filter(
|
|
19268
|
+
(project) => project.organizationId === organizationId
|
|
19269
|
+
);
|
|
19270
|
+
return {
|
|
19271
|
+
organizationId,
|
|
19272
|
+
...organizationProjects.length === 1 ? { projectId: organizationProjects[0].projectId } : {}
|
|
19273
|
+
};
|
|
19274
|
+
} catch {
|
|
19275
|
+
return {};
|
|
19276
|
+
}
|
|
19277
|
+
}
|
|
19278
|
+
async function singleOrganizationId() {
|
|
19279
|
+
const { organizations } = await fetchOrganizations();
|
|
19280
|
+
return organizations.length === 1 ? organizations[0].organizationId : void 0;
|
|
19281
|
+
}
|
|
19282
|
+
function persistDiscoveredSelection(selection) {
|
|
19283
|
+
const { config: config2, envOrganizationId, envProjectId, resolved } = selection;
|
|
19284
|
+
if (envOrganizationId || !resolved.organizationId) {
|
|
19285
|
+
return;
|
|
19286
|
+
}
|
|
19287
|
+
const discoveredProjectId = !envProjectId && resolved.projectId !== config2.projectId ? resolved.projectId : void 0;
|
|
19288
|
+
if (discoveredProjectId) {
|
|
19289
|
+
persistActiveProject(input.configPath, {
|
|
19290
|
+
organizationId: resolved.organizationId,
|
|
19291
|
+
projectId: discoveredProjectId
|
|
19292
|
+
});
|
|
19293
|
+
return;
|
|
19294
|
+
}
|
|
19295
|
+
if (!config2.organizationId) {
|
|
19296
|
+
persistActiveOrganization(input.configPath, resolved.organizationId);
|
|
19297
|
+
}
|
|
19298
|
+
}
|
|
19299
|
+
async function fetchOrganizations(apiBaseUrl2) {
|
|
19300
|
+
const response = await bootstrapFetch(
|
|
19301
|
+
apiUrl(apiPath("/auth/browser/organizations"), apiBaseUrl2),
|
|
19302
|
+
{}
|
|
19303
|
+
);
|
|
19304
|
+
if (!response.ok) {
|
|
19305
|
+
throw new Error(await responseErrorMessage(response));
|
|
19306
|
+
}
|
|
19307
|
+
return await response.json();
|
|
19308
|
+
}
|
|
19309
|
+
async function fetchProjects2(apiBaseUrl2) {
|
|
19310
|
+
const response = await bootstrapFetch(
|
|
19311
|
+
apiUrl(apiPath("/auth/browser/projects"), apiBaseUrl2),
|
|
19312
|
+
{}
|
|
19313
|
+
);
|
|
19314
|
+
if (!response.ok) {
|
|
19315
|
+
throw new Error(await responseErrorMessage(response));
|
|
19316
|
+
}
|
|
19317
|
+
return await response.json();
|
|
19318
|
+
}
|
|
19219
19319
|
async function refreshAccessToken(explicitApiBaseUrl) {
|
|
19220
19320
|
if (refreshAccessTokenPromise) {
|
|
19221
19321
|
return refreshAccessTokenPromise;
|
|
@@ -19235,7 +19335,7 @@ function createApiClient(input) {
|
|
|
19235
19335
|
if (!config2.refreshToken) {
|
|
19236
19336
|
return void 0;
|
|
19237
19337
|
}
|
|
19238
|
-
const project = activeProject();
|
|
19338
|
+
const project = await activeProject();
|
|
19239
19339
|
const refreshed = await postJson(
|
|
19240
19340
|
input.fetch,
|
|
19241
19341
|
apiUrl(apiPath("/auth/cli/token"), explicitApiBaseUrl),
|
|
@@ -19270,7 +19370,7 @@ function createApiClient(input) {
|
|
|
19270
19370
|
if (!config2.refreshToken && !config2.accessToken && !cachedAccessToken) {
|
|
19271
19371
|
return void 0;
|
|
19272
19372
|
}
|
|
19273
|
-
const project = activeProject();
|
|
19373
|
+
const project = await activeProject();
|
|
19274
19374
|
if (!inputOptions.forceRefresh && hasUsableAccessToken(config2, project) && config2.accessToken) {
|
|
19275
19375
|
cachedAccessToken = config2.accessToken;
|
|
19276
19376
|
cachedRefreshToken = config2.refreshToken;
|
|
@@ -19426,24 +19526,10 @@ function createApiClient(input) {
|
|
|
19426
19526
|
return AuthWhoamiResponseSchema.parse(await response.json());
|
|
19427
19527
|
},
|
|
19428
19528
|
async listProjects(options = {}) {
|
|
19429
|
-
|
|
19430
|
-
apiUrl(apiPath("/auth/browser/projects"), options.apiBaseUrl),
|
|
19431
|
-
{}
|
|
19432
|
-
);
|
|
19433
|
-
if (!response.ok) {
|
|
19434
|
-
throw new Error(await responseErrorMessage(response));
|
|
19435
|
-
}
|
|
19436
|
-
return await response.json();
|
|
19529
|
+
return fetchProjects2(options.apiBaseUrl);
|
|
19437
19530
|
},
|
|
19438
19531
|
async listOrganizations(options = {}) {
|
|
19439
|
-
|
|
19440
|
-
apiUrl(apiPath("/auth/browser/organizations"), options.apiBaseUrl),
|
|
19441
|
-
{}
|
|
19442
|
-
);
|
|
19443
|
-
if (!response.ok) {
|
|
19444
|
-
throw new Error(await responseErrorMessage(response));
|
|
19445
|
-
}
|
|
19446
|
-
return await response.json();
|
|
19532
|
+
return fetchOrganizations(options.apiBaseUrl);
|
|
19447
19533
|
},
|
|
19448
19534
|
async createOrganization(inputOptions) {
|
|
19449
19535
|
const response = await bootstrapFetch(
|
|
@@ -19474,7 +19560,7 @@ function createApiClient(input) {
|
|
|
19474
19560
|
};
|
|
19475
19561
|
},
|
|
19476
19562
|
async createProject(inputOptions) {
|
|
19477
|
-
const organization = activeOrganization();
|
|
19563
|
+
const organization = await activeOrganization();
|
|
19478
19564
|
const response = await bootstrapFetch(
|
|
19479
19565
|
apiUrl(
|
|
19480
19566
|
apiPath(
|
|
@@ -19498,7 +19584,7 @@ function createApiClient(input) {
|
|
|
19498
19584
|
return await response.json();
|
|
19499
19585
|
},
|
|
19500
19586
|
async inviteOrganizationMember(inputOptions) {
|
|
19501
|
-
const organization = activeOrganization();
|
|
19587
|
+
const organization = await activeOrganization();
|
|
19502
19588
|
return requestJson(
|
|
19503
19589
|
orgApiPath(organization.organizationId, "/invitations"),
|
|
19504
19590
|
{
|
|
@@ -19512,7 +19598,7 @@ function createApiClient(input) {
|
|
|
19512
19598
|
);
|
|
19513
19599
|
},
|
|
19514
19600
|
async inviteProjectMember(inputOptions) {
|
|
19515
|
-
const project = activeProject();
|
|
19601
|
+
const project = await activeProject();
|
|
19516
19602
|
return requestJson(
|
|
19517
19603
|
projectApiPath(project, "/invitations"),
|
|
19518
19604
|
{
|
|
@@ -19526,7 +19612,7 @@ function createApiClient(input) {
|
|
|
19526
19612
|
);
|
|
19527
19613
|
},
|
|
19528
19614
|
async addOrganizationMember(inputOptions) {
|
|
19529
|
-
const organization = activeOrganization();
|
|
19615
|
+
const organization = await activeOrganization();
|
|
19530
19616
|
return requestJson(
|
|
19531
19617
|
orgApiPath(organization.organizationId, "/members"),
|
|
19532
19618
|
{
|
|
@@ -19540,7 +19626,7 @@ function createApiClient(input) {
|
|
|
19540
19626
|
);
|
|
19541
19627
|
},
|
|
19542
19628
|
async addProjectMember(inputOptions) {
|
|
19543
|
-
const project = activeProject();
|
|
19629
|
+
const project = await activeProject();
|
|
19544
19630
|
return requestJson(
|
|
19545
19631
|
projectApiPath(project, "/members"),
|
|
19546
19632
|
{
|
|
@@ -19554,7 +19640,7 @@ function createApiClient(input) {
|
|
|
19554
19640
|
);
|
|
19555
19641
|
},
|
|
19556
19642
|
async listOrganizationMembers(inputOptions = {}) {
|
|
19557
|
-
const organization = activeOrganization();
|
|
19643
|
+
const organization = await activeOrganization();
|
|
19558
19644
|
return requestJson(
|
|
19559
19645
|
orgApiPath(organization.organizationId, "/members"),
|
|
19560
19646
|
{
|
|
@@ -19564,14 +19650,14 @@ function createApiClient(input) {
|
|
|
19564
19650
|
);
|
|
19565
19651
|
},
|
|
19566
19652
|
async listProjectMembers(inputOptions = {}) {
|
|
19567
|
-
const project = activeProject();
|
|
19653
|
+
const project = await activeProject();
|
|
19568
19654
|
return requestJson(projectApiPath(project, "/members"), {
|
|
19569
19655
|
method: "GET",
|
|
19570
19656
|
apiBaseUrl: inputOptions.apiBaseUrl
|
|
19571
19657
|
});
|
|
19572
19658
|
},
|
|
19573
19659
|
async setOrganizationMemberRole(inputOptions) {
|
|
19574
|
-
const organization = activeOrganization();
|
|
19660
|
+
const organization = await activeOrganization();
|
|
19575
19661
|
return requestJson(
|
|
19576
19662
|
orgApiPath(organization.organizationId, "/members"),
|
|
19577
19663
|
{
|
|
@@ -19585,7 +19671,7 @@ function createApiClient(input) {
|
|
|
19585
19671
|
);
|
|
19586
19672
|
},
|
|
19587
19673
|
async setProjectMemberRole(inputOptions) {
|
|
19588
|
-
const project = activeProject();
|
|
19674
|
+
const project = await activeProject();
|
|
19589
19675
|
return requestJson(
|
|
19590
19676
|
projectApiPath(project, "/members"),
|
|
19591
19677
|
{
|
|
@@ -19599,7 +19685,7 @@ function createApiClient(input) {
|
|
|
19599
19685
|
);
|
|
19600
19686
|
},
|
|
19601
19687
|
async removeOrganizationMember(inputOptions) {
|
|
19602
|
-
const organization = activeOrganization();
|
|
19688
|
+
const organization = await activeOrganization();
|
|
19603
19689
|
return requestJson(
|
|
19604
19690
|
orgApiPath(organization.organizationId, "/members"),
|
|
19605
19691
|
{
|
|
@@ -19612,7 +19698,7 @@ function createApiClient(input) {
|
|
|
19612
19698
|
);
|
|
19613
19699
|
},
|
|
19614
19700
|
async removeProjectMember(inputOptions) {
|
|
19615
|
-
const project = activeProject();
|
|
19701
|
+
const project = await activeProject();
|
|
19616
19702
|
return requestJson(
|
|
19617
19703
|
projectApiPath(project, "/members"),
|
|
19618
19704
|
{
|
|
@@ -19625,7 +19711,7 @@ function createApiClient(input) {
|
|
|
19625
19711
|
);
|
|
19626
19712
|
},
|
|
19627
19713
|
async startConnection(provider, options = {}) {
|
|
19628
|
-
const organization = activeOrganization();
|
|
19714
|
+
const organization = await activeOrganization();
|
|
19629
19715
|
const response = await authenticatedFetch(
|
|
19630
19716
|
apiUrl(apiPath("/connections"), options.apiBaseUrl),
|
|
19631
19717
|
{
|
|
@@ -19648,7 +19734,7 @@ function createApiClient(input) {
|
|
|
19648
19734
|
return await response.json();
|
|
19649
19735
|
},
|
|
19650
19736
|
async connectTelegram(options) {
|
|
19651
|
-
const organization = activeOrganization();
|
|
19737
|
+
const organization = await activeOrganization();
|
|
19652
19738
|
const response = await authenticatedFetch(
|
|
19653
19739
|
apiUrl(apiPath("/connections/telegram"), options.apiBaseUrl),
|
|
19654
19740
|
{
|
|
@@ -19693,7 +19779,7 @@ function createApiClient(input) {
|
|
|
19693
19779
|
return await response.json();
|
|
19694
19780
|
},
|
|
19695
19781
|
async allowConnection(provider, projectId, options = {}) {
|
|
19696
|
-
const organization = activeOrganization();
|
|
19782
|
+
const organization = await activeOrganization();
|
|
19697
19783
|
const response = await authenticatedFetch(
|
|
19698
19784
|
apiUrl(apiPath("/connections"), options.apiBaseUrl),
|
|
19699
19785
|
{
|
|
@@ -19716,7 +19802,7 @@ function createApiClient(input) {
|
|
|
19716
19802
|
return await response.json();
|
|
19717
19803
|
},
|
|
19718
19804
|
async removeConnection(provider, connection, options = {}) {
|
|
19719
|
-
const organization = activeOrganization();
|
|
19805
|
+
const organization = await activeOrganization();
|
|
19720
19806
|
const response = await authenticatedFetch(
|
|
19721
19807
|
apiUrl(apiPath("/connections"), options.apiBaseUrl),
|
|
19722
19808
|
{
|
|
@@ -19744,7 +19830,7 @@ function createApiClient(input) {
|
|
|
19744
19830
|
shouldTryProjectInferredAuth
|
|
19745
19831
|
}),
|
|
19746
19832
|
async setSecret(name, request, options = {}) {
|
|
19747
|
-
const organization = activeOrganization();
|
|
19833
|
+
const organization = await activeOrganization();
|
|
19748
19834
|
const path2 = options.projectId ? projectApiPath(
|
|
19749
19835
|
{
|
|
19750
19836
|
organizationId: organization.organizationId,
|
|
@@ -19772,7 +19858,7 @@ function createApiClient(input) {
|
|
|
19772
19858
|
return SecretSetResponseSchema.parse(await response.json());
|
|
19773
19859
|
},
|
|
19774
19860
|
async listSecrets(options = {}) {
|
|
19775
|
-
const organization = activeOrganization();
|
|
19861
|
+
const organization = await activeOrganization();
|
|
19776
19862
|
const path2 = options.projectId ? projectApiPath(
|
|
19777
19863
|
{
|
|
19778
19864
|
organizationId: organization.organizationId,
|
|
@@ -19791,7 +19877,7 @@ function createApiClient(input) {
|
|
|
19791
19877
|
return SecretListResponseSchema.parse(await response.json());
|
|
19792
19878
|
},
|
|
19793
19879
|
async removeSecret(name, options = {}) {
|
|
19794
|
-
const organization = activeOrganization();
|
|
19880
|
+
const organization = await activeOrganization();
|
|
19795
19881
|
const path2 = options.projectId ? projectApiPath(
|
|
19796
19882
|
{
|
|
19797
19883
|
organizationId: organization.organizationId,
|
|
@@ -19815,7 +19901,7 @@ function createApiClient(input) {
|
|
|
19815
19901
|
return SecretDeleteResponseSchema.parse(await response.json());
|
|
19816
19902
|
},
|
|
19817
19903
|
async listConnections(options = {}) {
|
|
19818
|
-
const organization = activeOrganization();
|
|
19904
|
+
const organization = await activeOrganization();
|
|
19819
19905
|
const url2 = new URL(
|
|
19820
19906
|
apiUrl(
|
|
19821
19907
|
orgApiPath(organization.organizationId, "/connections"),
|
|
@@ -19836,7 +19922,7 @@ function createApiClient(input) {
|
|
|
19836
19922
|
return await response.json();
|
|
19837
19923
|
},
|
|
19838
19924
|
async listConnectionProviders(options = {}) {
|
|
19839
|
-
const organization = activeOrganization();
|
|
19925
|
+
const organization = await activeOrganization();
|
|
19840
19926
|
const url2 = new URL(
|
|
19841
19927
|
apiUrl(
|
|
19842
19928
|
orgApiPath(organization.organizationId, "/connections"),
|
|
@@ -19855,7 +19941,7 @@ function createApiClient(input) {
|
|
|
19855
19941
|
return await response.json();
|
|
19856
19942
|
},
|
|
19857
19943
|
async listGithubDiscoverableInstallations(options = {}) {
|
|
19858
|
-
const organization = activeOrganization();
|
|
19944
|
+
const organization = await activeOrganization();
|
|
19859
19945
|
const url2 = new URL(
|
|
19860
19946
|
apiUrl(
|
|
19861
19947
|
apiPath("/connections/github/discoverable-installations"),
|
|
@@ -19874,7 +19960,7 @@ function createApiClient(input) {
|
|
|
19874
19960
|
return await response.json();
|
|
19875
19961
|
},
|
|
19876
19962
|
async setupGithubConnection(input2) {
|
|
19877
|
-
const organization = activeOrganization();
|
|
19963
|
+
const organization = await activeOrganization();
|
|
19878
19964
|
const response = await authenticatedFetch(
|
|
19879
19965
|
apiUrl(apiPath("/connections/github/setup"), input2.apiBaseUrl),
|
|
19880
19966
|
{
|
|
@@ -19897,7 +19983,7 @@ function createApiClient(input) {
|
|
|
19897
19983
|
return await response.json();
|
|
19898
19984
|
},
|
|
19899
19985
|
async triggerRun(sessionName, options) {
|
|
19900
|
-
const project = activeProject();
|
|
19986
|
+
const project = await activeProject();
|
|
19901
19987
|
const response = await authenticatedFetch(
|
|
19902
19988
|
apiUrl(
|
|
19903
19989
|
sessionApiPath(project, sessionName, "/runs"),
|
|
@@ -20023,7 +20109,7 @@ function createApiClient(input) {
|
|
|
20023
20109
|
});
|
|
20024
20110
|
},
|
|
20025
20111
|
async archiveRuns(runIds, options = {}) {
|
|
20026
|
-
const scope = activeProject();
|
|
20112
|
+
const scope = await activeProject();
|
|
20027
20113
|
return requestJson(projectApiPath(scope, "/runs"), {
|
|
20028
20114
|
apiBaseUrl: options.apiBaseUrl,
|
|
20029
20115
|
method: "PATCH",
|
|
@@ -20031,7 +20117,7 @@ function createApiClient(input) {
|
|
|
20031
20117
|
});
|
|
20032
20118
|
},
|
|
20033
20119
|
async unarchiveRuns(runIds, options = {}) {
|
|
20034
|
-
const scope = activeProject();
|
|
20120
|
+
const scope = await activeProject();
|
|
20035
20121
|
return requestJson(projectApiPath(scope, "/runs"), {
|
|
20036
20122
|
apiBaseUrl: options.apiBaseUrl,
|
|
20037
20123
|
method: "PATCH",
|
|
@@ -20099,7 +20185,7 @@ function createApiClient(input) {
|
|
|
20099
20185
|
return await response.json();
|
|
20100
20186
|
},
|
|
20101
20187
|
async listSessionRuns(sessionName, options = {}) {
|
|
20102
|
-
const scope = activeProject();
|
|
20188
|
+
const scope = await activeProject();
|
|
20103
20189
|
return requestJson(
|
|
20104
20190
|
sessionApiPath(scope, sessionName, "/runs"),
|
|
20105
20191
|
{
|
|
@@ -20109,7 +20195,7 @@ function createApiClient(input) {
|
|
|
20109
20195
|
);
|
|
20110
20196
|
},
|
|
20111
20197
|
async listRuns(options = {}) {
|
|
20112
|
-
const scope = activeProject();
|
|
20198
|
+
const scope = await activeProject();
|
|
20113
20199
|
return requestJson(projectApiPath(scope, "/runs"), {
|
|
20114
20200
|
apiBaseUrl: options.apiBaseUrl,
|
|
20115
20201
|
searchParams: runListSearchParams(options)
|
|
@@ -20224,7 +20310,7 @@ function createApiClient(input) {
|
|
|
20224
20310
|
writeConfig({ ...config2, organizationId, projectId }, input.configPath);
|
|
20225
20311
|
},
|
|
20226
20312
|
async applySession(name, spec, options = {}) {
|
|
20227
|
-
const project = activeProject();
|
|
20313
|
+
const project = await activeProject();
|
|
20228
20314
|
const response = await authenticatedFetch(
|
|
20229
20315
|
apiUrl(projectApiPath(project, "/sessions"), options.apiBaseUrl),
|
|
20230
20316
|
{
|
|
@@ -21675,7 +21761,7 @@ var init_package = __esm({
|
|
|
21675
21761
|
"package.json"() {
|
|
21676
21762
|
package_default = {
|
|
21677
21763
|
name: "@autohq/cli",
|
|
21678
|
-
version: "0.1.
|
|
21764
|
+
version: "0.1.99",
|
|
21679
21765
|
license: "SEE LICENSE IN README.md",
|
|
21680
21766
|
publishConfig: {
|
|
21681
21767
|
access: "public"
|
|
@@ -29105,7 +29191,7 @@ function createGithubConnectionApi(context) {
|
|
|
29105
29191
|
const client = createConnectionServiceClient(context);
|
|
29106
29192
|
return {
|
|
29107
29193
|
async listInstallations(options = {}) {
|
|
29108
|
-
const organization = client.activeOrganization();
|
|
29194
|
+
const organization = await client.activeOrganization();
|
|
29109
29195
|
return client.requestJson(
|
|
29110
29196
|
apiPath("/connections/github/discoverable-installations"),
|
|
29111
29197
|
{
|
|
@@ -29117,7 +29203,7 @@ function createGithubConnectionApi(context) {
|
|
|
29117
29203
|
);
|
|
29118
29204
|
},
|
|
29119
29205
|
async setupConnection(input) {
|
|
29120
|
-
const organization = client.activeOrganization();
|
|
29206
|
+
const organization = await client.activeOrganization();
|
|
29121
29207
|
return client.requestJson(
|
|
29122
29208
|
apiPath("/connections/github/setup"),
|
|
29123
29209
|
{
|
|
@@ -29825,26 +29911,10 @@ function projectLine(project) {
|
|
|
29825
29911
|
return `${project.organizationName} (${project.organizationSlug}) / ${project.projectName} (${project.projectSlug}) role=${project.role}`;
|
|
29826
29912
|
}
|
|
29827
29913
|
function setActiveOrganization(context, organizationId) {
|
|
29828
|
-
|
|
29829
|
-
writeConfig(
|
|
29830
|
-
clearAccessToken({
|
|
29831
|
-
...config2,
|
|
29832
|
-
organizationId,
|
|
29833
|
-
projectId: void 0
|
|
29834
|
-
}),
|
|
29835
|
-
context.configPath
|
|
29836
|
-
);
|
|
29914
|
+
persistActiveOrganization(context.configPath, organizationId);
|
|
29837
29915
|
}
|
|
29838
29916
|
function setActiveProject(context, project) {
|
|
29839
|
-
|
|
29840
|
-
writeConfig(
|
|
29841
|
-
clearAccessToken({
|
|
29842
|
-
...config2,
|
|
29843
|
-
organizationId: project.organizationId,
|
|
29844
|
-
projectId: project.projectId
|
|
29845
|
-
}),
|
|
29846
|
-
context.configPath
|
|
29847
|
-
);
|
|
29917
|
+
persistActiveProject(context.configPath, project);
|
|
29848
29918
|
}
|
|
29849
29919
|
async function resolveOrganization(input) {
|
|
29850
29920
|
const client = createDirectoryClient(input.context);
|