@autohq/cli 0.1.166 → 0.1.168
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/agent-bridge.js +78 -5
- package/dist/index.js +311 -238
- package/package.json +1 -1
package/dist/agent-bridge.js
CHANGED
|
@@ -22067,6 +22067,12 @@ var PROJECT_APPLY_RESOURCE_KINDS = [
|
|
|
22067
22067
|
RESOURCE_KIND_ENVIRONMENT,
|
|
22068
22068
|
RESOURCE_KIND_AGENT
|
|
22069
22069
|
];
|
|
22070
|
+
var PROJECT_APPLY_BUNDLE_VERSION = 1;
|
|
22071
|
+
var MAX_PROJECT_APPLY_BUNDLE_BYTES = 64 * 1024 * 1024;
|
|
22072
|
+
var PROJECT_APPLY_BUNDLE_CONTENT_TYPE = "application/vnd.auto.project-apply-bundle+json";
|
|
22073
|
+
function projectApplyBundleStorageKey(sha256) {
|
|
22074
|
+
return `project-apply-bundles/${sha256}.json`;
|
|
22075
|
+
}
|
|
22070
22076
|
var ProjectDeleteResourceBaseSchema = external_exports.object({
|
|
22071
22077
|
name: external_exports.string().trim().min(1)
|
|
22072
22078
|
});
|
|
@@ -22086,14 +22092,72 @@ var ProjectApplyAssetsSchema = external_exports.record(
|
|
|
22086
22092
|
}),
|
|
22087
22093
|
ProjectApplyAssetSchema
|
|
22088
22094
|
);
|
|
22089
|
-
var AvatarAssetUploadRequestSchema = ProjectApplyAssetSchema.omit({
|
|
22090
|
-
sha256: true
|
|
22091
|
-
});
|
|
22092
22095
|
var AvatarAssetUploadResponseSchema = external_exports.object({
|
|
22093
22096
|
sha256: external_exports.string().regex(/^[a-f0-9]{64}$/),
|
|
22094
22097
|
contentType: external_exports.enum(AVATAR_ASSET_CONTENT_TYPES),
|
|
22095
22098
|
sizeBytes: external_exports.number().int().positive()
|
|
22096
22099
|
});
|
|
22100
|
+
var ApplyBundlePathSchema = external_exports.string().trim().min(1).max(4096).refine((path2) => !path2.startsWith("/") && !path2.includes("\0"), {
|
|
22101
|
+
message: "apply bundle paths must be relative paths"
|
|
22102
|
+
});
|
|
22103
|
+
var ProjectApplyBundleFileSchema = external_exports.object({
|
|
22104
|
+
path: ApplyBundlePathSchema,
|
|
22105
|
+
contentBase64: external_exports.string().regex(/^[A-Za-z0-9+/]*={0,2}$/)
|
|
22106
|
+
});
|
|
22107
|
+
var ProjectApplyBundleSchema = external_exports.object({
|
|
22108
|
+
version: external_exports.literal(PROJECT_APPLY_BUNDLE_VERSION),
|
|
22109
|
+
files: external_exports.array(ProjectApplyBundleFileSchema).max(2e4)
|
|
22110
|
+
});
|
|
22111
|
+
var ProjectApplyBundleRefSchema = external_exports.object({
|
|
22112
|
+
kind: external_exports.literal("vercel_blob"),
|
|
22113
|
+
storageKey: external_exports.string().trim().min(1).max(1024),
|
|
22114
|
+
sha256: external_exports.string().regex(SHA256_HEX_PATTERN),
|
|
22115
|
+
sizeBytes: external_exports.number().int().positive().max(MAX_PROJECT_APPLY_BUNDLE_BYTES)
|
|
22116
|
+
}).superRefine((ref, context) => {
|
|
22117
|
+
const expectedStorageKey = projectApplyBundleStorageKey(ref.sha256);
|
|
22118
|
+
if (ref.storageKey === expectedStorageKey) {
|
|
22119
|
+
return;
|
|
22120
|
+
}
|
|
22121
|
+
context.addIssue({
|
|
22122
|
+
code: "custom",
|
|
22123
|
+
path: ["storageKey"],
|
|
22124
|
+
message: "apply bundle storage key must match its sha256"
|
|
22125
|
+
});
|
|
22126
|
+
});
|
|
22127
|
+
var ProjectApplyBundleUploadRequestSchema = external_exports.object({
|
|
22128
|
+
sha256: external_exports.string().regex(SHA256_HEX_PATTERN),
|
|
22129
|
+
sizeBytes: external_exports.number().int().positive().max(MAX_PROJECT_APPLY_BUNDLE_BYTES)
|
|
22130
|
+
});
|
|
22131
|
+
var ProjectApplyBundleUploadResponseSchema = external_exports.object({
|
|
22132
|
+
method: external_exports.literal("PUT"),
|
|
22133
|
+
uploadUrl: external_exports.string().url(),
|
|
22134
|
+
contentType: external_exports.literal(PROJECT_APPLY_BUNDLE_CONTENT_TYPE),
|
|
22135
|
+
source: ProjectApplyBundleRefSchema
|
|
22136
|
+
});
|
|
22137
|
+
var ProjectApplyBundleDirectoryEntrypointSchema = external_exports.object({
|
|
22138
|
+
kind: external_exports.literal("directory"),
|
|
22139
|
+
resourceRoot: ApplyBundlePathSchema.default(".auto"),
|
|
22140
|
+
displayResourceRoot: external_exports.string().trim().min(1).max(4096).optional()
|
|
22141
|
+
});
|
|
22142
|
+
var ProjectApplyBundleFileEntrypointSchema = external_exports.object({
|
|
22143
|
+
kind: external_exports.literal("file"),
|
|
22144
|
+
filePath: ApplyBundlePathSchema
|
|
22145
|
+
});
|
|
22146
|
+
var ProjectApplyBundleEntrypointSchema = external_exports.discriminatedUnion("kind", [
|
|
22147
|
+
ProjectApplyBundleDirectoryEntrypointSchema,
|
|
22148
|
+
ProjectApplyBundleFileEntrypointSchema
|
|
22149
|
+
]);
|
|
22150
|
+
var ProjectApplySourceSchema = external_exports.object({
|
|
22151
|
+
kind: external_exports.literal("bundle"),
|
|
22152
|
+
bundle: ProjectApplyBundleRefSchema,
|
|
22153
|
+
entrypoint: ProjectApplyBundleEntrypointSchema
|
|
22154
|
+
});
|
|
22155
|
+
var ProjectApplySourceRequestSchema = external_exports.object({
|
|
22156
|
+
source: ProjectApplySourceSchema,
|
|
22157
|
+
delete: external_exports.array(ProjectDeleteResourceSchema).default([]),
|
|
22158
|
+
dryRun: external_exports.boolean().default(false),
|
|
22159
|
+
prune: external_exports.boolean().default(true)
|
|
22160
|
+
});
|
|
22097
22161
|
var ProjectApplyRequestSchema = external_exports.object({
|
|
22098
22162
|
delete: external_exports.array(ProjectDeleteResourceSchema).default([]),
|
|
22099
22163
|
dryRun: external_exports.boolean().default(false),
|
|
@@ -22177,11 +22241,20 @@ var ProjectResourceApplyWorkflowErrorSchema = external_exports.object({
|
|
|
22177
22241
|
});
|
|
22178
22242
|
var ProjectResourceApplyWorkflowInputSchema = external_exports.object({
|
|
22179
22243
|
operationId: ProjectResourceApplyOperationIdSchema,
|
|
22180
|
-
request: ProjectApplyRequestSchema,
|
|
22244
|
+
request: ProjectApplyRequestSchema.optional(),
|
|
22245
|
+
sourceRequest: ProjectApplySourceRequestSchema.optional(),
|
|
22181
22246
|
organizationId: OrganizationIdSchema,
|
|
22182
22247
|
projectId: ProjectIdSchema.nullable().optional(),
|
|
22183
22248
|
actor: AuthActorSchema,
|
|
22184
22249
|
auditAction: ProjectResourceApplyAuditActionSchema
|
|
22250
|
+
}).superRefine((input, context) => {
|
|
22251
|
+
if ((input.request ? 1 : 0) + (input.sourceRequest ? 1 : 0) !== 1) {
|
|
22252
|
+
context.addIssue({
|
|
22253
|
+
code: "custom",
|
|
22254
|
+
path: ["request"],
|
|
22255
|
+
message: "exactly one of request or sourceRequest is required"
|
|
22256
|
+
});
|
|
22257
|
+
}
|
|
22185
22258
|
});
|
|
22186
22259
|
var ProjectResourceApplyWorkflowResultSchema = external_exports.discriminatedUnion(
|
|
22187
22260
|
"status",
|
|
@@ -26482,7 +26555,7 @@ Object.assign(lookup, {
|
|
|
26482
26555
|
// package.json
|
|
26483
26556
|
var package_default = {
|
|
26484
26557
|
name: "@autohq/cli",
|
|
26485
|
-
version: "0.1.
|
|
26558
|
+
version: "0.1.168",
|
|
26486
26559
|
license: "SEE LICENSE IN README.md",
|
|
26487
26560
|
publishConfig: {
|
|
26488
26561
|
access: "public"
|
package/dist/index.js
CHANGED
|
@@ -18762,7 +18762,10 @@ var init_project_service_accounts = __esm({
|
|
|
18762
18762
|
});
|
|
18763
18763
|
|
|
18764
18764
|
// ../../packages/schemas/src/project-resources.ts
|
|
18765
|
-
|
|
18765
|
+
function projectApplyBundleStorageKey(sha256) {
|
|
18766
|
+
return `project-apply-bundles/${sha256}.json`;
|
|
18767
|
+
}
|
|
18768
|
+
var EnvironmentApplyDocumentSchema, IdentityApplyDocumentSchema, AgentApplyDocumentSchema, ProjectApplyResourceSchema, PROJECT_RESOURCE_APPLY_ORDER, PROJECT_RESOURCE_KINDS, PROJECT_APPLY_RESOURCE_KINDS, PROJECT_APPLY_BUNDLE_VERSION, MAX_PROJECT_APPLY_BUNDLE_BYTES, PROJECT_APPLY_BUNDLE_CONTENT_TYPE, ProjectDeleteResourceBaseSchema, ProjectDeleteResourceSchema, AVATAR_ASSET_CONTENT_TYPES, MAX_AVATAR_ASSET_BASE64_LENGTH, ProjectApplyAssetSchema, ProjectApplyAssetsSchema, AvatarAssetUploadResponseSchema, ApplyBundlePathSchema, ProjectApplyBundleFileSchema, ProjectApplyBundleSchema, ProjectApplyBundleRefSchema, ProjectApplyBundleUploadRequestSchema, ProjectApplyBundleUploadResponseSchema, ProjectApplyBundleDirectoryEntrypointSchema, ProjectApplyBundleFileEntrypointSchema, ProjectApplyBundleEntrypointSchema, ProjectApplySourceSchema, ProjectApplySourceRequestSchema, ProjectApplyRequestSchema, ProjectApplySystemConfigSchema, ProjectAppliedResourceSchema, ProjectApplyDiagnosticSchema, ProjectApplyResponsePrunedSchema, ProjectApplyPlanDiffSchema, ProjectApplyResponseSchema, ProjectResourceApplyResultSchema, ProjectResourceApplyAuditActionSchema, ProjectResourceApplyOperationIdSchema, ProjectResourceApplyWorkflowErrorSchema, ProjectResourceApplyWorkflowInputSchema, ProjectResourceApplyWorkflowResultSchema;
|
|
18766
18769
|
var init_project_resources = __esm({
|
|
18767
18770
|
"../../packages/schemas/src/project-resources.ts"() {
|
|
18768
18771
|
"use strict";
|
|
@@ -18804,6 +18807,9 @@ var init_project_resources = __esm({
|
|
|
18804
18807
|
RESOURCE_KIND_ENVIRONMENT,
|
|
18805
18808
|
RESOURCE_KIND_AGENT
|
|
18806
18809
|
];
|
|
18810
|
+
PROJECT_APPLY_BUNDLE_VERSION = 1;
|
|
18811
|
+
MAX_PROJECT_APPLY_BUNDLE_BYTES = 64 * 1024 * 1024;
|
|
18812
|
+
PROJECT_APPLY_BUNDLE_CONTENT_TYPE = "application/vnd.auto.project-apply-bundle+json";
|
|
18807
18813
|
ProjectDeleteResourceBaseSchema = external_exports.object({
|
|
18808
18814
|
name: external_exports.string().trim().min(1)
|
|
18809
18815
|
});
|
|
@@ -18823,14 +18829,72 @@ var init_project_resources = __esm({
|
|
|
18823
18829
|
}),
|
|
18824
18830
|
ProjectApplyAssetSchema
|
|
18825
18831
|
);
|
|
18826
|
-
AvatarAssetUploadRequestSchema = ProjectApplyAssetSchema.omit({
|
|
18827
|
-
sha256: true
|
|
18828
|
-
});
|
|
18829
18832
|
AvatarAssetUploadResponseSchema = external_exports.object({
|
|
18830
18833
|
sha256: external_exports.string().regex(/^[a-f0-9]{64}$/),
|
|
18831
18834
|
contentType: external_exports.enum(AVATAR_ASSET_CONTENT_TYPES),
|
|
18832
18835
|
sizeBytes: external_exports.number().int().positive()
|
|
18833
18836
|
});
|
|
18837
|
+
ApplyBundlePathSchema = external_exports.string().trim().min(1).max(4096).refine((path2) => !path2.startsWith("/") && !path2.includes("\0"), {
|
|
18838
|
+
message: "apply bundle paths must be relative paths"
|
|
18839
|
+
});
|
|
18840
|
+
ProjectApplyBundleFileSchema = external_exports.object({
|
|
18841
|
+
path: ApplyBundlePathSchema,
|
|
18842
|
+
contentBase64: external_exports.string().regex(/^[A-Za-z0-9+/]*={0,2}$/)
|
|
18843
|
+
});
|
|
18844
|
+
ProjectApplyBundleSchema = external_exports.object({
|
|
18845
|
+
version: external_exports.literal(PROJECT_APPLY_BUNDLE_VERSION),
|
|
18846
|
+
files: external_exports.array(ProjectApplyBundleFileSchema).max(2e4)
|
|
18847
|
+
});
|
|
18848
|
+
ProjectApplyBundleRefSchema = external_exports.object({
|
|
18849
|
+
kind: external_exports.literal("vercel_blob"),
|
|
18850
|
+
storageKey: external_exports.string().trim().min(1).max(1024),
|
|
18851
|
+
sha256: external_exports.string().regex(SHA256_HEX_PATTERN),
|
|
18852
|
+
sizeBytes: external_exports.number().int().positive().max(MAX_PROJECT_APPLY_BUNDLE_BYTES)
|
|
18853
|
+
}).superRefine((ref, context) => {
|
|
18854
|
+
const expectedStorageKey = projectApplyBundleStorageKey(ref.sha256);
|
|
18855
|
+
if (ref.storageKey === expectedStorageKey) {
|
|
18856
|
+
return;
|
|
18857
|
+
}
|
|
18858
|
+
context.addIssue({
|
|
18859
|
+
code: "custom",
|
|
18860
|
+
path: ["storageKey"],
|
|
18861
|
+
message: "apply bundle storage key must match its sha256"
|
|
18862
|
+
});
|
|
18863
|
+
});
|
|
18864
|
+
ProjectApplyBundleUploadRequestSchema = external_exports.object({
|
|
18865
|
+
sha256: external_exports.string().regex(SHA256_HEX_PATTERN),
|
|
18866
|
+
sizeBytes: external_exports.number().int().positive().max(MAX_PROJECT_APPLY_BUNDLE_BYTES)
|
|
18867
|
+
});
|
|
18868
|
+
ProjectApplyBundleUploadResponseSchema = external_exports.object({
|
|
18869
|
+
method: external_exports.literal("PUT"),
|
|
18870
|
+
uploadUrl: external_exports.string().url(),
|
|
18871
|
+
contentType: external_exports.literal(PROJECT_APPLY_BUNDLE_CONTENT_TYPE),
|
|
18872
|
+
source: ProjectApplyBundleRefSchema
|
|
18873
|
+
});
|
|
18874
|
+
ProjectApplyBundleDirectoryEntrypointSchema = external_exports.object({
|
|
18875
|
+
kind: external_exports.literal("directory"),
|
|
18876
|
+
resourceRoot: ApplyBundlePathSchema.default(".auto"),
|
|
18877
|
+
displayResourceRoot: external_exports.string().trim().min(1).max(4096).optional()
|
|
18878
|
+
});
|
|
18879
|
+
ProjectApplyBundleFileEntrypointSchema = external_exports.object({
|
|
18880
|
+
kind: external_exports.literal("file"),
|
|
18881
|
+
filePath: ApplyBundlePathSchema
|
|
18882
|
+
});
|
|
18883
|
+
ProjectApplyBundleEntrypointSchema = external_exports.discriminatedUnion("kind", [
|
|
18884
|
+
ProjectApplyBundleDirectoryEntrypointSchema,
|
|
18885
|
+
ProjectApplyBundleFileEntrypointSchema
|
|
18886
|
+
]);
|
|
18887
|
+
ProjectApplySourceSchema = external_exports.object({
|
|
18888
|
+
kind: external_exports.literal("bundle"),
|
|
18889
|
+
bundle: ProjectApplyBundleRefSchema,
|
|
18890
|
+
entrypoint: ProjectApplyBundleEntrypointSchema
|
|
18891
|
+
});
|
|
18892
|
+
ProjectApplySourceRequestSchema = external_exports.object({
|
|
18893
|
+
source: ProjectApplySourceSchema,
|
|
18894
|
+
delete: external_exports.array(ProjectDeleteResourceSchema).default([]),
|
|
18895
|
+
dryRun: external_exports.boolean().default(false),
|
|
18896
|
+
prune: external_exports.boolean().default(true)
|
|
18897
|
+
});
|
|
18834
18898
|
ProjectApplyRequestSchema = external_exports.object({
|
|
18835
18899
|
delete: external_exports.array(ProjectDeleteResourceSchema).default([]),
|
|
18836
18900
|
dryRun: external_exports.boolean().default(false),
|
|
@@ -18914,11 +18978,20 @@ var init_project_resources = __esm({
|
|
|
18914
18978
|
});
|
|
18915
18979
|
ProjectResourceApplyWorkflowInputSchema = external_exports.object({
|
|
18916
18980
|
operationId: ProjectResourceApplyOperationIdSchema,
|
|
18917
|
-
request: ProjectApplyRequestSchema,
|
|
18981
|
+
request: ProjectApplyRequestSchema.optional(),
|
|
18982
|
+
sourceRequest: ProjectApplySourceRequestSchema.optional(),
|
|
18918
18983
|
organizationId: OrganizationIdSchema,
|
|
18919
18984
|
projectId: ProjectIdSchema.nullable().optional(),
|
|
18920
18985
|
actor: AuthActorSchema,
|
|
18921
18986
|
auditAction: ProjectResourceApplyAuditActionSchema
|
|
18987
|
+
}).superRefine((input, context) => {
|
|
18988
|
+
if ((input.request ? 1 : 0) + (input.sourceRequest ? 1 : 0) !== 1) {
|
|
18989
|
+
context.addIssue({
|
|
18990
|
+
code: "custom",
|
|
18991
|
+
path: ["request"],
|
|
18992
|
+
message: "exactly one of request or sourceRequest is required"
|
|
18993
|
+
});
|
|
18994
|
+
}
|
|
18922
18995
|
});
|
|
18923
18996
|
ProjectResourceApplyWorkflowResultSchema = external_exports.discriminatedUnion(
|
|
18924
18997
|
"status",
|
|
@@ -19886,6 +19959,7 @@ var init_paths = __esm({
|
|
|
19886
19959
|
});
|
|
19887
19960
|
|
|
19888
19961
|
// src/lib/api/resources.ts
|
|
19962
|
+
import { createHash as createHash3 } from "crypto";
|
|
19889
19963
|
function createResourceApi(context) {
|
|
19890
19964
|
const environments = projectResource(context, {
|
|
19891
19965
|
path: "/environments",
|
|
@@ -19904,8 +19978,8 @@ function createResourceApi(context) {
|
|
|
19904
19978
|
);
|
|
19905
19979
|
return {
|
|
19906
19980
|
applyEnvironmentResource: environments.apply,
|
|
19907
|
-
|
|
19908
|
-
|
|
19981
|
+
prepareProjectApplyBundleUpload: (request, options) => prepareProjectApplyBundleUpload(context, request, options ?? {}),
|
|
19982
|
+
uploadProjectApplyBundle: (request) => uploadProjectApplyBundle(context, request),
|
|
19909
19983
|
applyProjectResources: (request, options) => applyProjectResources(
|
|
19910
19984
|
context,
|
|
19911
19985
|
request,
|
|
@@ -19928,54 +20002,59 @@ function createResourceApi(context) {
|
|
|
19928
20002
|
updateProjectServiceAccount: (request, options) => updateProjectServiceAccount(context, request, options ?? {})
|
|
19929
20003
|
};
|
|
19930
20004
|
}
|
|
19931
|
-
async function
|
|
19932
|
-
const
|
|
19933
|
-
context.apiUrl(
|
|
19934
|
-
apiPath(`/avatars/${encodeURIComponent(request.sha256)}`),
|
|
19935
|
-
options.apiBaseUrl
|
|
19936
|
-
),
|
|
19937
|
-
{ method: "HEAD" },
|
|
19938
|
-
options.apiBaseUrl
|
|
19939
|
-
);
|
|
19940
|
-
if (response.ok) {
|
|
19941
|
-
return true;
|
|
19942
|
-
}
|
|
19943
|
-
if (response.status === 404) {
|
|
19944
|
-
return false;
|
|
19945
|
-
}
|
|
19946
|
-
throw new Error(await responseErrorMessage(response));
|
|
19947
|
-
}
|
|
19948
|
-
async function uploadAvatarAsset(context, request, options) {
|
|
19949
|
-
const path2 = await avatarAssetUploadPath(context, request.sha256);
|
|
20005
|
+
async function prepareProjectApplyBundleUpload(context, request, options) {
|
|
20006
|
+
const path2 = await projectApplyBundleUploadPath(context);
|
|
19950
20007
|
const response = await context.authenticatedFetch(
|
|
19951
20008
|
context.apiUrl(path2, options.apiBaseUrl),
|
|
19952
20009
|
{
|
|
19953
|
-
method: "
|
|
20010
|
+
method: "POST",
|
|
19954
20011
|
headers: { "content-type": "application/json" },
|
|
19955
|
-
body: JSON.stringify(
|
|
19956
|
-
contentType: request.contentType,
|
|
19957
|
-
dataBase64: request.dataBase64
|
|
19958
|
-
})
|
|
20012
|
+
body: JSON.stringify(request)
|
|
19959
20013
|
},
|
|
19960
20014
|
options.apiBaseUrl
|
|
19961
20015
|
);
|
|
19962
|
-
if (response.status === 404) {
|
|
19963
|
-
throw new AvatarAssetUploadUnsupportedError(
|
|
19964
|
-
await responseErrorMessage(response)
|
|
19965
|
-
);
|
|
19966
|
-
}
|
|
19967
20016
|
if (!response.ok) {
|
|
19968
20017
|
throw new Error(await responseErrorMessage(response));
|
|
19969
20018
|
}
|
|
19970
|
-
return
|
|
20019
|
+
return ProjectApplyBundleUploadResponseSchema.parse(await response.json());
|
|
20020
|
+
}
|
|
20021
|
+
async function stageEmptyApplyBundle(context, options) {
|
|
20022
|
+
const body = JSON.stringify({
|
|
20023
|
+
version: PROJECT_APPLY_BUNDLE_VERSION,
|
|
20024
|
+
files: []
|
|
20025
|
+
});
|
|
20026
|
+
const sizeBytes = Buffer.byteLength(body, "utf8");
|
|
20027
|
+
const upload = await prepareProjectApplyBundleUpload(
|
|
20028
|
+
context,
|
|
20029
|
+
{ sha256: createHash3("sha256").update(body).digest("hex"), sizeBytes },
|
|
20030
|
+
options
|
|
20031
|
+
);
|
|
20032
|
+
await uploadProjectApplyBundle(context, {
|
|
20033
|
+
uploadUrl: upload.uploadUrl,
|
|
20034
|
+
method: upload.method,
|
|
20035
|
+
contentType: upload.contentType,
|
|
20036
|
+
body
|
|
20037
|
+
});
|
|
20038
|
+
return upload.source;
|
|
19971
20039
|
}
|
|
19972
|
-
async function
|
|
19973
|
-
const
|
|
20040
|
+
async function uploadProjectApplyBundle(context, request) {
|
|
20041
|
+
const response = await context.fetch(request.uploadUrl, {
|
|
20042
|
+
method: request.method,
|
|
20043
|
+
headers: { "content-type": request.contentType },
|
|
20044
|
+
body: request.body
|
|
20045
|
+
});
|
|
20046
|
+
if (!response.ok) {
|
|
20047
|
+
throw new Error(
|
|
20048
|
+
`Project apply bundle upload failed with ${response.status}: ${await response.text()}`
|
|
20049
|
+
);
|
|
20050
|
+
}
|
|
20051
|
+
}
|
|
20052
|
+
async function projectApplyBundleUploadPath(context) {
|
|
19974
20053
|
try {
|
|
19975
|
-
return projectApiPath(await context.activeProject(),
|
|
20054
|
+
return projectApiPath(await context.activeProject(), "/apply-bundles");
|
|
19976
20055
|
} catch (error51) {
|
|
19977
20056
|
if (context.shouldTryProjectInferredAuth()) {
|
|
19978
|
-
return apiPath(
|
|
20057
|
+
return apiPath("/project/apply-bundles");
|
|
19979
20058
|
}
|
|
19980
20059
|
throw error51;
|
|
19981
20060
|
}
|
|
@@ -20196,12 +20275,18 @@ async function removeProjectServiceAccount(context, request, options) {
|
|
|
20196
20275
|
return ProjectServiceAccountRemoveResponseSchema.parse(await response.json());
|
|
20197
20276
|
}
|
|
20198
20277
|
async function deleteProjectResource(context, request, options) {
|
|
20278
|
+
const bundle = await stageEmptyApplyBundle(context, options);
|
|
20199
20279
|
const response = await applyProjectResources(
|
|
20200
20280
|
context,
|
|
20201
20281
|
{
|
|
20282
|
+
source: {
|
|
20283
|
+
kind: "bundle",
|
|
20284
|
+
bundle,
|
|
20285
|
+
entrypoint: { kind: "directory", resourceRoot: ".auto" }
|
|
20286
|
+
},
|
|
20202
20287
|
delete: [request],
|
|
20203
|
-
|
|
20204
|
-
|
|
20288
|
+
dryRun: false,
|
|
20289
|
+
prune: false
|
|
20205
20290
|
},
|
|
20206
20291
|
options
|
|
20207
20292
|
);
|
|
@@ -20284,15 +20369,13 @@ async function listProjectResources(context, endpoint, options) {
|
|
|
20284
20369
|
}
|
|
20285
20370
|
return await response.json();
|
|
20286
20371
|
}
|
|
20287
|
-
var
|
|
20372
|
+
var SlackConfigTokenRequiredError;
|
|
20288
20373
|
var init_resources2 = __esm({
|
|
20289
20374
|
"src/lib/api/resources.ts"() {
|
|
20290
20375
|
"use strict";
|
|
20291
20376
|
init_src();
|
|
20292
20377
|
init_errors3();
|
|
20293
20378
|
init_paths();
|
|
20294
|
-
AvatarAssetUploadUnsupportedError = class extends Error {
|
|
20295
|
-
};
|
|
20296
20379
|
SlackConfigTokenRequiredError = class extends Error {
|
|
20297
20380
|
workspace;
|
|
20298
20381
|
constructor(message, workspace) {
|
|
@@ -21041,6 +21124,7 @@ function createApiClient(input) {
|
|
|
21041
21124
|
activeProject,
|
|
21042
21125
|
apiUrl,
|
|
21043
21126
|
authenticatedFetch,
|
|
21127
|
+
fetch: input.fetch,
|
|
21044
21128
|
shouldTryProjectInferredAuth
|
|
21045
21129
|
}),
|
|
21046
21130
|
async setSecret(name, request, options = {}) {
|
|
@@ -21581,7 +21665,7 @@ var init_package = __esm({
|
|
|
21581
21665
|
"package.json"() {
|
|
21582
21666
|
package_default = {
|
|
21583
21667
|
name: "@autohq/cli",
|
|
21584
|
-
version: "0.1.
|
|
21668
|
+
version: "0.1.168",
|
|
21585
21669
|
license: "SEE LICENSE IN README.md",
|
|
21586
21670
|
publishConfig: {
|
|
21587
21671
|
access: "public"
|
|
@@ -22425,106 +22509,6 @@ var init_agent_tool_connect = __esm({
|
|
|
22425
22509
|
}
|
|
22426
22510
|
});
|
|
22427
22511
|
|
|
22428
|
-
// src/commands/apply/assets.ts
|
|
22429
|
-
async function resolveApplyAssets(input) {
|
|
22430
|
-
const entries = Object.entries(input.request.assets);
|
|
22431
|
-
if (entries.length === 0) {
|
|
22432
|
-
return { resources: input.request.resources, assets: {} };
|
|
22433
|
-
}
|
|
22434
|
-
const probes = await Promise.all(
|
|
22435
|
-
entries.map(async ([path2, asset]) => ({
|
|
22436
|
-
path: path2,
|
|
22437
|
-
asset,
|
|
22438
|
-
stored: await input.client.hasAvatarAsset(
|
|
22439
|
-
{ sha256: asset.sha256 },
|
|
22440
|
-
{ apiBaseUrl: input.apiBaseUrl }
|
|
22441
|
-
)
|
|
22442
|
-
}))
|
|
22443
|
-
);
|
|
22444
|
-
const inline2 = {};
|
|
22445
|
-
for (const probe of probes) {
|
|
22446
|
-
if (probe.stored) {
|
|
22447
|
-
continue;
|
|
22448
|
-
}
|
|
22449
|
-
if (!await uploadAvatarAsset2(input.client, probe.asset, input.apiBaseUrl)) {
|
|
22450
|
-
inline2[probe.path] = probe.asset;
|
|
22451
|
-
}
|
|
22452
|
-
}
|
|
22453
|
-
const resources = input.request.resources.map(
|
|
22454
|
-
(resource) => stampAvatarSha256(resource, input.request.assets)
|
|
22455
|
-
);
|
|
22456
|
-
return { resources, assets: inline2 };
|
|
22457
|
-
}
|
|
22458
|
-
function assertApplyRequestBodySize(input) {
|
|
22459
|
-
const bytes = Buffer.byteLength(input.body, "utf8");
|
|
22460
|
-
if (bytes <= MAX_APPLY_REQUEST_BODY_BYTES) {
|
|
22461
|
-
return;
|
|
22462
|
-
}
|
|
22463
|
-
const paths = Object.keys(input.assets);
|
|
22464
|
-
const assetDetail = paths.length > 0 ? ` ${paths.length} avatar asset(s) are not yet stored on the server, so their bytes must ride this request: ${paths.join(", ")}. Apply the agents referencing them in smaller batches (auto apply -f <file> --no-prune) or shrink the image files.` : "";
|
|
22465
|
-
throw new Error(
|
|
22466
|
-
`Apply request body is ${formatMegabytes(bytes)}MB, over the ~4.5MB server request limit.${assetDetail}`
|
|
22467
|
-
);
|
|
22468
|
-
}
|
|
22469
|
-
async function uploadAvatarAsset2(client, asset, apiBaseUrl) {
|
|
22470
|
-
try {
|
|
22471
|
-
await client.uploadAvatarAsset(asset, { apiBaseUrl });
|
|
22472
|
-
return true;
|
|
22473
|
-
} catch (error51) {
|
|
22474
|
-
if (error51 instanceof AvatarAssetUploadUnsupportedError) {
|
|
22475
|
-
return false;
|
|
22476
|
-
}
|
|
22477
|
-
throw error51;
|
|
22478
|
-
}
|
|
22479
|
-
}
|
|
22480
|
-
function stampAvatarSha256(resource, assets) {
|
|
22481
|
-
if (resource.kind === "identity") {
|
|
22482
|
-
const avatar = resource.spec.avatar;
|
|
22483
|
-
const asset = avatar ? assets[avatar.asset] : void 0;
|
|
22484
|
-
if (!avatar || !asset) {
|
|
22485
|
-
return resource;
|
|
22486
|
-
}
|
|
22487
|
-
return {
|
|
22488
|
-
...resource,
|
|
22489
|
-
spec: {
|
|
22490
|
-
...resource.spec,
|
|
22491
|
-
avatar: { asset: avatar.asset, sha256: asset.sha256 }
|
|
22492
|
-
}
|
|
22493
|
-
};
|
|
22494
|
-
}
|
|
22495
|
-
if (resource.kind === RESOURCE_KIND_AGENT && typeof resource.spec.identity === "object" && resource.spec.identity !== null && !Array.isArray(resource.spec.identity)) {
|
|
22496
|
-
const identity2 = resource.spec.identity;
|
|
22497
|
-
const avatar = identity2.avatar;
|
|
22498
|
-
const asset = avatar ? assets[avatar.asset] : void 0;
|
|
22499
|
-
if (!avatar || !asset) {
|
|
22500
|
-
return resource;
|
|
22501
|
-
}
|
|
22502
|
-
return {
|
|
22503
|
-
...resource,
|
|
22504
|
-
spec: {
|
|
22505
|
-
...resource.spec,
|
|
22506
|
-
identity: {
|
|
22507
|
-
...identity2,
|
|
22508
|
-
avatar: { asset: avatar.asset, sha256: asset.sha256 }
|
|
22509
|
-
}
|
|
22510
|
-
}
|
|
22511
|
-
};
|
|
22512
|
-
}
|
|
22513
|
-
return resource;
|
|
22514
|
-
}
|
|
22515
|
-
function formatMegabytes(bytes) {
|
|
22516
|
-
return (bytes / (1024 * 1024)).toFixed(1);
|
|
22517
|
-
}
|
|
22518
|
-
var MAX_APPLY_REQUEST_BODY_BYTES;
|
|
22519
|
-
var init_assets = __esm({
|
|
22520
|
-
"src/commands/apply/assets.ts"() {
|
|
22521
|
-
"use strict";
|
|
22522
|
-
init_src();
|
|
22523
|
-
init_resources2();
|
|
22524
|
-
MAX_APPLY_REQUEST_BODY_BYTES = 4 * 1024 * 1024;
|
|
22525
|
-
}
|
|
22526
|
-
});
|
|
22527
|
-
|
|
22528
22512
|
// ../../packages/schemas/src/project-apply-files/source.ts
|
|
22529
22513
|
import { parseAllDocuments as parseYamlDocuments2 } from "yaml";
|
|
22530
22514
|
function readDocumentsFromSource(file2) {
|
|
@@ -23366,7 +23350,7 @@ var init_apply_result = __esm({
|
|
|
23366
23350
|
});
|
|
23367
23351
|
|
|
23368
23352
|
// ../../packages/schemas/src/project-apply-files/assets.ts
|
|
23369
|
-
import { createHash as
|
|
23353
|
+
import { createHash as createHash4 } from "crypto";
|
|
23370
23354
|
import { extname as extname2 } from "path";
|
|
23371
23355
|
function readApplyAssets(resources, readAsset) {
|
|
23372
23356
|
const assets = {};
|
|
@@ -23413,7 +23397,7 @@ function projectApplyAssetFromSource(input) {
|
|
|
23413
23397
|
);
|
|
23414
23398
|
}
|
|
23415
23399
|
return {
|
|
23416
|
-
sha256:
|
|
23400
|
+
sha256: createHash4("sha256").update(bytes).digest("hex"),
|
|
23417
23401
|
contentType: extension === ".png" ? "image/png" : "image/jpeg",
|
|
23418
23402
|
dataBase64: bytes.toString("base64")
|
|
23419
23403
|
};
|
|
@@ -23430,7 +23414,7 @@ function avatarAssetTarget(resource) {
|
|
|
23430
23414
|
return void 0;
|
|
23431
23415
|
}
|
|
23432
23416
|
var ALLOWED_AVATAR_EXTENSIONS;
|
|
23433
|
-
var
|
|
23417
|
+
var init_assets = __esm({
|
|
23434
23418
|
"../../packages/schemas/src/project-apply-files/assets.ts"() {
|
|
23435
23419
|
"use strict";
|
|
23436
23420
|
init_agents();
|
|
@@ -23587,7 +23571,7 @@ var init_project_apply_files = __esm({
|
|
|
23587
23571
|
init_project_resources();
|
|
23588
23572
|
init_agent_authoring();
|
|
23589
23573
|
init_apply_result();
|
|
23590
|
-
|
|
23574
|
+
init_assets();
|
|
23591
23575
|
init_source();
|
|
23592
23576
|
}
|
|
23593
23577
|
});
|
|
@@ -23602,6 +23586,7 @@ var init_project_apply_files2 = __esm({
|
|
|
23602
23586
|
|
|
23603
23587
|
// src/commands/apply/files.ts
|
|
23604
23588
|
import {
|
|
23589
|
+
existsSync as existsSync4,
|
|
23605
23590
|
readFileSync as readFileSync4,
|
|
23606
23591
|
readdirSync as readdirSync3,
|
|
23607
23592
|
realpathSync,
|
|
@@ -23616,7 +23601,7 @@ import {
|
|
|
23616
23601
|
relative,
|
|
23617
23602
|
resolve as resolve2
|
|
23618
23603
|
} from "path";
|
|
23619
|
-
function
|
|
23604
|
+
function readProjectApplyBundleInput(options) {
|
|
23620
23605
|
if (options.file && options.directory) {
|
|
23621
23606
|
throw new Error("Cannot use --file with --directory.");
|
|
23622
23607
|
}
|
|
@@ -23624,21 +23609,45 @@ function readProjectApplyRequest(options) {
|
|
|
23624
23609
|
const file2 = resolve2(options.file);
|
|
23625
23610
|
const projectRoot2 = applyFileProjectRoot(file2);
|
|
23626
23611
|
const sourceRoot = applyFileSourceRoot(file2, projectRoot2);
|
|
23627
|
-
|
|
23612
|
+
const files2 = sourceFiles(sourceRoot, projectRoot2);
|
|
23613
|
+
const request = readProjectApplyFileSource({
|
|
23628
23614
|
file: sourceFile(file2, projectRoot2),
|
|
23629
|
-
files:
|
|
23615
|
+
files: files2,
|
|
23630
23616
|
readAsset: filesystemAssetReader(projectRoot2)
|
|
23631
23617
|
});
|
|
23618
|
+
return {
|
|
23619
|
+
request,
|
|
23620
|
+
bundle: applyBundle(
|
|
23621
|
+
withProjectApplyAssetFiles({ files: files2, request, projectRoot: projectRoot2 })
|
|
23622
|
+
),
|
|
23623
|
+
entrypoint: {
|
|
23624
|
+
kind: "file",
|
|
23625
|
+
filePath: sourcePathRelative(projectRoot2, file2)
|
|
23626
|
+
}
|
|
23627
|
+
};
|
|
23632
23628
|
}
|
|
23633
23629
|
const directory = resolve2(options.directory ?? join5(process.cwd(), ".auto"));
|
|
23634
23630
|
const projectRoot = applyProjectRoot(directory);
|
|
23635
|
-
|
|
23636
|
-
|
|
23637
|
-
|
|
23638
|
-
|
|
23639
|
-
|
|
23640
|
-
|
|
23641
|
-
|
|
23631
|
+
const files = sourceFiles(directory, projectRoot);
|
|
23632
|
+
const resourceRoot = sourcePathRelative(projectRoot, directory);
|
|
23633
|
+
return {
|
|
23634
|
+
request: readProjectApplyDirectorySource({
|
|
23635
|
+
files,
|
|
23636
|
+
resourceRoot,
|
|
23637
|
+
displayResourceRoot: displayResourceRoot(directory),
|
|
23638
|
+
emptyMessage: `No resource files found in ${directory}`,
|
|
23639
|
+
readAsset: filesystemAssetReader(projectRoot)
|
|
23640
|
+
}),
|
|
23641
|
+
bundle: applyBundle(files),
|
|
23642
|
+
entrypoint: {
|
|
23643
|
+
kind: "directory",
|
|
23644
|
+
resourceRoot,
|
|
23645
|
+
displayResourceRoot: displayResourceRoot(directory)
|
|
23646
|
+
}
|
|
23647
|
+
};
|
|
23648
|
+
}
|
|
23649
|
+
function serializeProjectApplyBundle(bundle) {
|
|
23650
|
+
return JSON.stringify(ProjectApplyBundleSchema.parse(bundle));
|
|
23642
23651
|
}
|
|
23643
23652
|
function sourceFiles(root, projectRoot) {
|
|
23644
23653
|
let entries;
|
|
@@ -23664,6 +23673,28 @@ function sourceFile(path2, projectRoot) {
|
|
|
23664
23673
|
contentBase64: readFileSync4(path2).toString("base64")
|
|
23665
23674
|
};
|
|
23666
23675
|
}
|
|
23676
|
+
function applyBundle(files) {
|
|
23677
|
+
return ProjectApplyBundleSchema.parse({
|
|
23678
|
+
version: PROJECT_APPLY_BUNDLE_VERSION,
|
|
23679
|
+
files: [...files].sort(
|
|
23680
|
+
(left, right) => left.path.localeCompare(right.path)
|
|
23681
|
+
)
|
|
23682
|
+
});
|
|
23683
|
+
}
|
|
23684
|
+
function withProjectApplyAssetFiles(input) {
|
|
23685
|
+
const files = [...input.files];
|
|
23686
|
+
const includedPaths = new Set(files.map((file2) => file2.path));
|
|
23687
|
+
for (const assetPath of Object.keys(input.request.assets)) {
|
|
23688
|
+
if (includedPaths.has(assetPath)) {
|
|
23689
|
+
continue;
|
|
23690
|
+
}
|
|
23691
|
+
files.push(
|
|
23692
|
+
sourceFile(resolve2(input.projectRoot, assetPath), input.projectRoot)
|
|
23693
|
+
);
|
|
23694
|
+
includedPaths.add(assetPath);
|
|
23695
|
+
}
|
|
23696
|
+
return files;
|
|
23697
|
+
}
|
|
23667
23698
|
function filesystemAssetReader(projectRoot) {
|
|
23668
23699
|
return ({ asset, resourceName }) => {
|
|
23669
23700
|
const path2 = validateAgentAvatarAsset({
|
|
@@ -23687,6 +23718,9 @@ function applyFileProjectRoot(file2) {
|
|
|
23687
23718
|
if (basename3(dir) === ".auto") {
|
|
23688
23719
|
return dirname5(dir);
|
|
23689
23720
|
}
|
|
23721
|
+
if (directoryHasAutoRoot(dir)) {
|
|
23722
|
+
return dir;
|
|
23723
|
+
}
|
|
23690
23724
|
const parent = dirname5(dir);
|
|
23691
23725
|
if (parent === dir) {
|
|
23692
23726
|
return process.cwd();
|
|
@@ -23698,6 +23732,13 @@ function applyFileSourceRoot(file2, projectRoot) {
|
|
|
23698
23732
|
const autoRoot = resolve2(projectRoot, ".auto");
|
|
23699
23733
|
return file2 === autoRoot || isInside(file2, autoRoot) ? autoRoot : dirname5(file2);
|
|
23700
23734
|
}
|
|
23735
|
+
function directoryHasAutoRoot(directory) {
|
|
23736
|
+
const autoRoot = resolve2(directory, ".auto");
|
|
23737
|
+
if (!existsSync4(autoRoot)) {
|
|
23738
|
+
return false;
|
|
23739
|
+
}
|
|
23740
|
+
return statSync2(autoRoot).isDirectory();
|
|
23741
|
+
}
|
|
23701
23742
|
function displayResourceRoot(directory) {
|
|
23702
23743
|
return basename3(directory) === ".auto" ? ".auto" : directory;
|
|
23703
23744
|
}
|
|
@@ -23773,59 +23814,88 @@ var init_files = __esm({
|
|
|
23773
23814
|
});
|
|
23774
23815
|
|
|
23775
23816
|
// src/commands/apply/actions.ts
|
|
23817
|
+
import { createHash as createHash5 } from "crypto";
|
|
23776
23818
|
async function applyResource(input) {
|
|
23777
23819
|
if (input.commandOptions.connect && input.commandOptions.json) {
|
|
23778
23820
|
throw new Error("Cannot use --connect with --json output.");
|
|
23779
23821
|
}
|
|
23780
|
-
const
|
|
23781
|
-
|
|
23822
|
+
const bundleInput = readProjectApplyBundleInput(input.commandOptions);
|
|
23823
|
+
const commandOptions = {
|
|
23824
|
+
...input.commandOptions,
|
|
23825
|
+
prune: input.commandOptions.file ? false : input.commandOptions.prune ?? bundleInput.request.prune
|
|
23826
|
+
};
|
|
23827
|
+
await applyProjectBundleInput({
|
|
23828
|
+
commandOptions,
|
|
23829
|
+
client: input.client,
|
|
23830
|
+
input: bundleInput,
|
|
23831
|
+
writeOutput: input.writeOutput,
|
|
23832
|
+
style: input.style
|
|
23833
|
+
});
|
|
23834
|
+
}
|
|
23835
|
+
async function applyProjectBundleInput(input) {
|
|
23836
|
+
const dryRun = input.commandOptions.dryRun ?? input.input.request.dryRun;
|
|
23837
|
+
const prune = input.commandOptions.prune ?? input.input.request.prune;
|
|
23838
|
+
const body = serializeProjectApplyBundle(input.input.bundle);
|
|
23839
|
+
const sizeBytes = Buffer.byteLength(body, "utf8");
|
|
23840
|
+
if (sizeBytes > MAX_PROJECT_APPLY_BUNDLE_BYTES) {
|
|
23841
|
+
throw new Error(
|
|
23842
|
+
`Project apply bundle is ${formatMegabytes(sizeBytes)}MB, over the ${formatMegabytes(MAX_PROJECT_APPLY_BUNDLE_BYTES)}MB upload limit.`
|
|
23843
|
+
);
|
|
23844
|
+
}
|
|
23845
|
+
const upload = await input.client.prepareProjectApplyBundleUpload(
|
|
23846
|
+
{
|
|
23847
|
+
sha256: createHash5("sha256").update(body).digest("hex"),
|
|
23848
|
+
sizeBytes
|
|
23849
|
+
},
|
|
23850
|
+
{ apiBaseUrl: input.commandOptions.apiBaseUrl }
|
|
23851
|
+
);
|
|
23852
|
+
await input.client.uploadProjectApplyBundle({
|
|
23853
|
+
uploadUrl: upload.uploadUrl,
|
|
23854
|
+
method: upload.method,
|
|
23855
|
+
contentType: upload.contentType,
|
|
23856
|
+
body
|
|
23857
|
+
});
|
|
23858
|
+
const response = await input.client.applyProjectResources(
|
|
23859
|
+
{
|
|
23860
|
+
source: {
|
|
23861
|
+
kind: "bundle",
|
|
23862
|
+
bundle: upload.source,
|
|
23863
|
+
entrypoint: input.input.entrypoint
|
|
23864
|
+
},
|
|
23865
|
+
dryRun,
|
|
23866
|
+
prune
|
|
23867
|
+
},
|
|
23868
|
+
{ apiBaseUrl: input.commandOptions.apiBaseUrl }
|
|
23869
|
+
);
|
|
23870
|
+
await writeProjectApplyResponse({
|
|
23782
23871
|
commandOptions: {
|
|
23783
23872
|
...input.commandOptions,
|
|
23784
|
-
|
|
23873
|
+
dryRun,
|
|
23874
|
+
prune
|
|
23785
23875
|
},
|
|
23786
23876
|
client: input.client,
|
|
23787
|
-
request,
|
|
23877
|
+
request: input.input.request,
|
|
23878
|
+
response,
|
|
23788
23879
|
writeOutput: input.writeOutput,
|
|
23789
23880
|
style: input.style
|
|
23790
23881
|
});
|
|
23791
23882
|
}
|
|
23792
|
-
async function
|
|
23883
|
+
async function writeProjectApplyResponse(input) {
|
|
23793
23884
|
const style = input.style ?? plainStyle;
|
|
23794
|
-
const
|
|
23795
|
-
|
|
23796
|
-
client: input.client,
|
|
23797
|
-
request: input.request,
|
|
23798
|
-
apiBaseUrl: input.commandOptions.apiBaseUrl,
|
|
23799
|
-
dryRun
|
|
23800
|
-
});
|
|
23801
|
-
const request = {
|
|
23802
|
-
...input.request.delete.length > 0 ? { delete: input.request.delete } : {},
|
|
23803
|
-
dryRun,
|
|
23804
|
-
prune: input.commandOptions.prune ?? input.request.prune,
|
|
23805
|
-
resources: resolved.resources,
|
|
23806
|
-
...Object.keys(resolved.assets).length > 0 ? { assets: resolved.assets } : {}
|
|
23807
|
-
};
|
|
23808
|
-
assertApplyRequestBodySize({
|
|
23809
|
-
body: JSON.stringify(request),
|
|
23810
|
-
assets: resolved.assets
|
|
23811
|
-
});
|
|
23812
|
-
const response = await input.client.applyProjectResources(request, {
|
|
23813
|
-
apiBaseUrl: input.commandOptions.apiBaseUrl
|
|
23814
|
-
});
|
|
23815
|
-
const resources = response.resources.map((resource, index) => ({
|
|
23816
|
-
kind: appliedResourceKind(input.request, response, index),
|
|
23885
|
+
const resources = input.response.resources.map((resource, index) => ({
|
|
23886
|
+
kind: appliedResourceKind(input.request, input.response, index),
|
|
23817
23887
|
resource
|
|
23818
23888
|
}));
|
|
23819
23889
|
if (input.commandOptions.json) {
|
|
23820
|
-
input.writeOutput(JSON.stringify(response));
|
|
23890
|
+
input.writeOutput(JSON.stringify(input.response));
|
|
23821
23891
|
return;
|
|
23822
23892
|
}
|
|
23823
|
-
if (response.dryRun) {
|
|
23893
|
+
if (input.response.dryRun) {
|
|
23824
23894
|
const actionWidth = Math.max(
|
|
23825
|
-
...response.plan.map((item) => item.action.length),
|
|
23895
|
+
...input.response.plan.map((item) => item.action.length),
|
|
23826
23896
|
0
|
|
23827
23897
|
);
|
|
23828
|
-
for (const item of response.plan) {
|
|
23898
|
+
for (const item of input.response.plan) {
|
|
23829
23899
|
input.writeOutput(
|
|
23830
23900
|
`${planActionStyle(
|
|
23831
23901
|
style,
|
|
@@ -23844,7 +23914,7 @@ async function applyProjectInput(input) {
|
|
|
23844
23914
|
);
|
|
23845
23915
|
}
|
|
23846
23916
|
}
|
|
23847
|
-
writeDiagnostics(response.diagnostics, input.writeOutput, style);
|
|
23917
|
+
writeDiagnostics(input.response.diagnostics, input.writeOutput, style);
|
|
23848
23918
|
return;
|
|
23849
23919
|
}
|
|
23850
23920
|
for (const { kind, resource } of resources) {
|
|
@@ -23860,7 +23930,7 @@ async function applyProjectInput(input) {
|
|
|
23860
23930
|
`${style.label("resource_version")} ${resource.metadata.resourceVersion}`
|
|
23861
23931
|
);
|
|
23862
23932
|
}
|
|
23863
|
-
for (const trigger of response.triggers) {
|
|
23933
|
+
for (const trigger of input.response.triggers) {
|
|
23864
23934
|
input.writeOutput(`${style.label("webhook_event")} ${trigger.event}`);
|
|
23865
23935
|
input.writeOutput(`${style.label("webhook_endpoint")} ${trigger.endpoint}`);
|
|
23866
23936
|
input.writeOutput(
|
|
@@ -23868,12 +23938,12 @@ async function applyProjectInput(input) {
|
|
|
23868
23938
|
);
|
|
23869
23939
|
input.writeOutput(`${style.label("webhook_status")} ${trigger.status}`);
|
|
23870
23940
|
}
|
|
23871
|
-
for (const resource of response.pruned) {
|
|
23941
|
+
for (const resource of input.response.pruned) {
|
|
23872
23942
|
input.writeOutput(
|
|
23873
23943
|
`${style.warn("pruned")} ${resource.kind}/${resource.name}`
|
|
23874
23944
|
);
|
|
23875
23945
|
}
|
|
23876
|
-
writeDiagnostics(response.diagnostics, input.writeOutput, style);
|
|
23946
|
+
writeDiagnostics(input.response.diagnostics, input.writeOutput, style);
|
|
23877
23947
|
if (input.commandOptions.connect) {
|
|
23878
23948
|
const connections = mcpOAuthAgentToolConnectionsFromAppliedResources(resources);
|
|
23879
23949
|
for (const item of connections) {
|
|
@@ -23910,12 +23980,15 @@ function planActionStyle(style, action) {
|
|
|
23910
23980
|
return (text) => text;
|
|
23911
23981
|
}
|
|
23912
23982
|
}
|
|
23983
|
+
function formatMegabytes(bytes) {
|
|
23984
|
+
return (bytes / (1024 * 1024)).toFixed(1);
|
|
23985
|
+
}
|
|
23913
23986
|
var init_actions = __esm({
|
|
23914
23987
|
"src/commands/apply/actions.ts"() {
|
|
23915
23988
|
"use strict";
|
|
23989
|
+
init_src();
|
|
23916
23990
|
init_style();
|
|
23917
23991
|
init_agent_tool_connect();
|
|
23918
|
-
init_assets();
|
|
23919
23992
|
init_files();
|
|
23920
23993
|
}
|
|
23921
23994
|
});
|
|
@@ -24010,7 +24083,13 @@ var init_resources3 = __esm({
|
|
|
24010
24083
|
|
|
24011
24084
|
// src/commands/edit/actions.ts
|
|
24012
24085
|
import { spawn as spawn2 } from "child_process";
|
|
24013
|
-
import {
|
|
24086
|
+
import {
|
|
24087
|
+
mkdirSync as mkdirSync3,
|
|
24088
|
+
mkdtempSync as mkdtempSync2,
|
|
24089
|
+
readFileSync as readFileSync5,
|
|
24090
|
+
rmSync as rmSync2,
|
|
24091
|
+
writeFileSync as writeFileSync4
|
|
24092
|
+
} from "fs";
|
|
24014
24093
|
import { tmpdir as tmpdir2 } from "os";
|
|
24015
24094
|
import { join as join6 } from "path";
|
|
24016
24095
|
import { parseAllDocuments as parseYamlDocuments3, stringify as stringify4 } from "yaml";
|
|
@@ -24029,11 +24108,13 @@ async function editResource(input) {
|
|
|
24029
24108
|
const current = await requireProjectResource(input.client, reference, {
|
|
24030
24109
|
apiBaseUrl: input.commandOptions.apiBaseUrl
|
|
24031
24110
|
});
|
|
24032
|
-
const document =
|
|
24111
|
+
const document = editableAgentFacade(current);
|
|
24033
24112
|
const source = `${stringify4(document).trimEnd()}
|
|
24034
24113
|
`;
|
|
24035
24114
|
const tempRoot = mkdtempSync2(join6(tmpdir2(), "auto-edit-"));
|
|
24036
|
-
const
|
|
24115
|
+
const agentsDir = join6(tempRoot, ".auto", "agents");
|
|
24116
|
+
mkdirSync3(agentsDir, { recursive: true });
|
|
24117
|
+
const filePath = join6(agentsDir, `${reference.name}.yaml`);
|
|
24037
24118
|
writeFileSync4(filePath, source, "utf8");
|
|
24038
24119
|
let removeTempFile = false;
|
|
24039
24120
|
try {
|
|
@@ -24044,22 +24125,16 @@ async function editResource(input) {
|
|
|
24044
24125
|
removeTempFile = true;
|
|
24045
24126
|
return { changed: false, resource: reference };
|
|
24046
24127
|
}
|
|
24047
|
-
|
|
24048
|
-
const
|
|
24049
|
-
|
|
24050
|
-
dryRun: false,
|
|
24051
|
-
prune: false,
|
|
24052
|
-
resources: [editedResource],
|
|
24053
|
-
assets: {}
|
|
24054
|
-
};
|
|
24055
|
-
await applyProjectInput({
|
|
24128
|
+
assertEditedResourceIdentity(filePath, reference);
|
|
24129
|
+
const bundleInput = readProjectApplyBundleInput({ file: filePath });
|
|
24130
|
+
await applyProjectBundleInput({
|
|
24056
24131
|
commandOptions: {
|
|
24057
24132
|
apiBaseUrl: input.commandOptions.apiBaseUrl,
|
|
24058
24133
|
dryRun: input.commandOptions.dryRun,
|
|
24059
24134
|
prune: false
|
|
24060
24135
|
},
|
|
24061
24136
|
client: input.client,
|
|
24062
|
-
|
|
24137
|
+
input: bundleInput,
|
|
24063
24138
|
writeOutput: input.writeOutput
|
|
24064
24139
|
});
|
|
24065
24140
|
removeTempFile = true;
|
|
@@ -24108,44 +24183,41 @@ async function runEditor(editor, filePath) {
|
|
|
24108
24183
|
});
|
|
24109
24184
|
});
|
|
24110
24185
|
}
|
|
24111
|
-
function
|
|
24186
|
+
function assertEditedResourceIdentity(filePath, expected) {
|
|
24112
24187
|
const source = readFileSync5(filePath, "utf8");
|
|
24113
|
-
let
|
|
24188
|
+
let parsedDocuments;
|
|
24114
24189
|
try {
|
|
24115
|
-
|
|
24190
|
+
parsedDocuments = parseYamlDocuments3(source);
|
|
24116
24191
|
} catch (error51) {
|
|
24117
24192
|
throw new Error(
|
|
24118
24193
|
`Invalid edited resource: ${error51 instanceof Error ? error51.message : String(error51)}`
|
|
24119
24194
|
);
|
|
24120
24195
|
}
|
|
24196
|
+
const parseError = parsedDocuments.flatMap((document2) => document2.errors)[0];
|
|
24197
|
+
if (parseError) {
|
|
24198
|
+
throw new Error(`Invalid edited resource: ${parseError.message}`);
|
|
24199
|
+
}
|
|
24200
|
+
const documents = parsedDocuments.filter((document2) => document2.contents !== null).map((document2) => document2.toJSON());
|
|
24121
24201
|
if (documents.length !== 1) {
|
|
24122
24202
|
throw new Error("Edited resource must contain exactly one YAML document.");
|
|
24123
24203
|
}
|
|
24124
|
-
const
|
|
24125
|
-
|
|
24126
|
-
|
|
24127
|
-
|
|
24128
|
-
if (parsed.data.kind !== expected.kind) {
|
|
24129
|
-
throw new Error(
|
|
24130
|
-
`Edited resource kind changed from "${expected.kind}" to "${parsed.data.kind}".`
|
|
24131
|
-
);
|
|
24204
|
+
const document = documents[0];
|
|
24205
|
+
const name = typeof document === "object" && document !== null && "name" in document && typeof document.name === "string" ? document.name : void 0;
|
|
24206
|
+
if (name === void 0) {
|
|
24207
|
+
throw new Error("Invalid edited resource: missing agent name.");
|
|
24132
24208
|
}
|
|
24133
|
-
if (
|
|
24209
|
+
if (name !== expected.name) {
|
|
24134
24210
|
throw new Error(
|
|
24135
|
-
`Edited resource name changed from "${expected.name}" to "${
|
|
24211
|
+
`Edited resource name changed from "${expected.name}" to "${name}".`
|
|
24136
24212
|
);
|
|
24137
24213
|
}
|
|
24138
|
-
return parsed.data;
|
|
24139
24214
|
}
|
|
24140
|
-
function
|
|
24215
|
+
function editableAgentFacade(resource) {
|
|
24141
24216
|
return {
|
|
24142
|
-
|
|
24143
|
-
metadata: {
|
|
24144
|
-
|
|
24145
|
-
|
|
24146
|
-
...resource.metadata.annotations ? { annotations: resource.metadata.annotations } : {}
|
|
24147
|
-
},
|
|
24148
|
-
spec: resource.spec
|
|
24217
|
+
name: resource.metadata.name,
|
|
24218
|
+
...resource.metadata.labels ? { labels: resource.metadata.labels } : {},
|
|
24219
|
+
...resource.metadata.annotations ? { annotations: resource.metadata.annotations } : {},
|
|
24220
|
+
...resource.spec
|
|
24149
24221
|
};
|
|
24150
24222
|
}
|
|
24151
24223
|
var init_actions2 = __esm({
|
|
@@ -24154,6 +24226,7 @@ var init_actions2 = __esm({
|
|
|
24154
24226
|
init_src();
|
|
24155
24227
|
init_resources3();
|
|
24156
24228
|
init_actions();
|
|
24229
|
+
init_files();
|
|
24157
24230
|
}
|
|
24158
24231
|
});
|
|
24159
24232
|
|
|
@@ -29537,7 +29610,7 @@ var init_launcher = __esm({
|
|
|
29537
29610
|
});
|
|
29538
29611
|
|
|
29539
29612
|
// src/cli/program.ts
|
|
29540
|
-
import { existsSync as
|
|
29613
|
+
import { existsSync as existsSync5 } from "fs";
|
|
29541
29614
|
import { Command, Option as Option4 } from "commander";
|
|
29542
29615
|
|
|
29543
29616
|
// src/commands/account/commands.ts
|
|
@@ -29962,14 +30035,14 @@ async function authorizeSensitiveActionLoopback(input) {
|
|
|
29962
30035
|
successHtml: () => renderOAuthLoopbackPage({
|
|
29963
30036
|
status: "success",
|
|
29964
30037
|
eyebrow: "Auto CLI",
|
|
29965
|
-
title: "
|
|
29966
|
-
message: "Auto received the fresh browser authorization.
|
|
30038
|
+
title: "Authorization confirmed",
|
|
30039
|
+
message: "Auto received the fresh browser authorization. Return to your terminal to finish deleting the account.",
|
|
29967
30040
|
details: [{ label: "Account", value: input.email }]
|
|
29968
30041
|
}),
|
|
29969
30042
|
failureHtml: () => renderOAuthLoopbackPage({
|
|
29970
30043
|
status: "failure",
|
|
29971
30044
|
eyebrow: "Auto CLI",
|
|
29972
|
-
title: "
|
|
30045
|
+
title: "Authorization failed",
|
|
29973
30046
|
message: "The browser authorization did not complete. Return to your terminal to retry or inspect the error.",
|
|
29974
30047
|
details: [{ label: "Account", value: input.email }]
|
|
29975
30048
|
})
|
|
@@ -36173,7 +36246,7 @@ function createProgram(options = {}) {
|
|
|
36173
36246
|
assertValidProfileName(pin);
|
|
36174
36247
|
const base = options.configPath ?? defaultConfigPath();
|
|
36175
36248
|
const pinnedPath = profileFilePath(base, pin);
|
|
36176
|
-
if (!
|
|
36249
|
+
if (!existsSync5(pinnedPath)) {
|
|
36177
36250
|
const names = listProfiles(base).map((profile) => profile.name);
|
|
36178
36251
|
throw new Error(
|
|
36179
36252
|
`No stored profile "${pin}". Stored profiles: ${names.join(", ") || "(none)"}.`
|