@autohq/cli 0.1.417 → 0.1.418
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 +3 -2
- package/dist/index.js +84 -4
- package/package.json +1 -1
package/dist/agent-bridge.js
CHANGED
|
@@ -30820,7 +30820,7 @@ Object.assign(lookup, {
|
|
|
30820
30820
|
// package.json
|
|
30821
30821
|
var package_default = {
|
|
30822
30822
|
name: "@autohq/cli",
|
|
30823
|
-
version: "0.1.
|
|
30823
|
+
version: "0.1.418",
|
|
30824
30824
|
license: "SEE LICENSE IN README.md",
|
|
30825
30825
|
publishConfig: {
|
|
30826
30826
|
access: "public"
|
|
@@ -36414,7 +36414,8 @@ var ProjectApplySourceLocationSchema = external_exports.object({
|
|
|
36414
36414
|
name: external_exports.string().min(1),
|
|
36415
36415
|
path: external_exports.string().min(1),
|
|
36416
36416
|
file: external_exports.string().min(1),
|
|
36417
|
-
line: external_exports.number().int().positive()
|
|
36417
|
+
line: external_exports.number().int().positive(),
|
|
36418
|
+
displayPath: external_exports.string().min(1).optional()
|
|
36418
36419
|
});
|
|
36419
36420
|
var ProjectApplyRequestSchema = external_exports.object({
|
|
36420
36421
|
delete: external_exports.array(ProjectDeleteResourceSchema).default([]),
|
package/dist/index.js
CHANGED
|
@@ -20657,7 +20657,8 @@ var init_project_resources = __esm({
|
|
|
20657
20657
|
name: external_exports.string().min(1),
|
|
20658
20658
|
path: external_exports.string().min(1),
|
|
20659
20659
|
file: external_exports.string().min(1),
|
|
20660
|
-
line: external_exports.number().int().positive()
|
|
20660
|
+
line: external_exports.number().int().positive(),
|
|
20661
|
+
displayPath: external_exports.string().min(1).optional()
|
|
20661
20662
|
});
|
|
20662
20663
|
ProjectApplyRequestSchema = external_exports.object({
|
|
20663
20664
|
delete: external_exports.array(ProjectDeleteResourceSchema).default([]),
|
|
@@ -38669,7 +38670,7 @@ var init_package = __esm({
|
|
|
38669
38670
|
"package.json"() {
|
|
38670
38671
|
package_default = {
|
|
38671
38672
|
name: "@autohq/cli",
|
|
38672
|
-
version: "0.1.
|
|
38673
|
+
version: "0.1.418",
|
|
38673
38674
|
license: "SEE LICENSE IN README.md",
|
|
38674
38675
|
publishConfig: {
|
|
38675
38676
|
access: "public"
|
|
@@ -40892,6 +40893,7 @@ function readApplyDocument(path2, document, fileIndex, contextVariables) {
|
|
|
40892
40893
|
resource,
|
|
40893
40894
|
primaryResource: result.resource,
|
|
40894
40895
|
draftLocations: result.sourceLocations,
|
|
40896
|
+
authoredTriggers: result.authoredTriggers,
|
|
40895
40897
|
generatedLocation
|
|
40896
40898
|
})
|
|
40897
40899
|
};
|
|
@@ -40899,7 +40901,11 @@ function readApplyDocument(path2, document, fileIndex, contextVariables) {
|
|
|
40899
40901
|
}
|
|
40900
40902
|
function sourceLocationsForCompiledResource(input) {
|
|
40901
40903
|
if (input.resource === input.primaryResource) {
|
|
40902
|
-
|
|
40904
|
+
const draftLocations = projectCompiledTriggerSourceLocations(
|
|
40905
|
+
input.draftLocations,
|
|
40906
|
+
input.authoredTriggers
|
|
40907
|
+
);
|
|
40908
|
+
return Object.values(draftLocations).map((location) => ({
|
|
40903
40909
|
...location,
|
|
40904
40910
|
kind: input.resource.kind,
|
|
40905
40911
|
name: input.resource.metadata.name
|
|
@@ -40917,6 +40923,78 @@ function sourceLocationsForCompiledResource(input) {
|
|
|
40917
40923
|
}
|
|
40918
40924
|
];
|
|
40919
40925
|
}
|
|
40926
|
+
function projectCompiledTriggerSourceLocations(locations, authoredTriggers) {
|
|
40927
|
+
if (!Array.isArray(authoredTriggers)) {
|
|
40928
|
+
return locations;
|
|
40929
|
+
}
|
|
40930
|
+
const projected = Object.fromEntries(
|
|
40931
|
+
Object.entries(locations).filter(
|
|
40932
|
+
([path2]) => !path2.startsWith("spec.triggers[")
|
|
40933
|
+
)
|
|
40934
|
+
);
|
|
40935
|
+
let compiledIndex = 0;
|
|
40936
|
+
for (const [authoredIndex, trigger] of authoredTriggers.entries()) {
|
|
40937
|
+
if (!isRecord2(trigger)) {
|
|
40938
|
+
continue;
|
|
40939
|
+
}
|
|
40940
|
+
const events = authoredTriggerEvents(trigger);
|
|
40941
|
+
const displayName = authoredTriggerDisplayName(trigger, events);
|
|
40942
|
+
const authoredPrefix = `spec.triggers[${authoredIndex}]`;
|
|
40943
|
+
const triggerLocations = Object.entries(locations).filter(
|
|
40944
|
+
([path2]) => path2 === authoredPrefix || path2.startsWith(`${authoredPrefix}.`)
|
|
40945
|
+
);
|
|
40946
|
+
for (const [eventIndex] of events.entries()) {
|
|
40947
|
+
const compiledPrefix = `spec.triggers[${compiledIndex}]`;
|
|
40948
|
+
for (const [path2, location] of triggerLocations) {
|
|
40949
|
+
if (path2.startsWith(`${authoredPrefix}.events`)) {
|
|
40950
|
+
continue;
|
|
40951
|
+
}
|
|
40952
|
+
const suffix = path2.slice(authoredPrefix.length);
|
|
40953
|
+
projected[`${compiledPrefix}${suffix}`] = {
|
|
40954
|
+
...location,
|
|
40955
|
+
path: `${compiledPrefix}${suffix}`,
|
|
40956
|
+
displayPath: `triggers.${displayName}${suffix}`
|
|
40957
|
+
};
|
|
40958
|
+
}
|
|
40959
|
+
const eventLocation = locations[`${authoredPrefix}.events[${eventIndex}]`] ?? locations[`${authoredPrefix}.event`] ?? locations[`${authoredPrefix}.events`];
|
|
40960
|
+
if (eventLocation) {
|
|
40961
|
+
projected[`${compiledPrefix}.event`] = {
|
|
40962
|
+
...eventLocation,
|
|
40963
|
+
path: `${compiledPrefix}.event`,
|
|
40964
|
+
displayPath: `triggers.${displayName}.event`
|
|
40965
|
+
};
|
|
40966
|
+
}
|
|
40967
|
+
compiledIndex += 1;
|
|
40968
|
+
}
|
|
40969
|
+
}
|
|
40970
|
+
return projected;
|
|
40971
|
+
}
|
|
40972
|
+
function authoredTriggerEvents(trigger) {
|
|
40973
|
+
if (trigger.kind === "heartbeat") {
|
|
40974
|
+
return ["heartbeat"];
|
|
40975
|
+
}
|
|
40976
|
+
if (typeof trigger.event === "string") {
|
|
40977
|
+
return [trigger.event];
|
|
40978
|
+
}
|
|
40979
|
+
if (Array.isArray(trigger.events)) {
|
|
40980
|
+
return trigger.events.filter(
|
|
40981
|
+
(event) => typeof event === "string"
|
|
40982
|
+
);
|
|
40983
|
+
}
|
|
40984
|
+
return [];
|
|
40985
|
+
}
|
|
40986
|
+
function authoredTriggerDisplayName(trigger, events) {
|
|
40987
|
+
if (typeof trigger.name === "string") {
|
|
40988
|
+
return trigger.name;
|
|
40989
|
+
}
|
|
40990
|
+
if (events.length > 0) {
|
|
40991
|
+
return events.join(" + ");
|
|
40992
|
+
}
|
|
40993
|
+
if (typeof trigger.cron === "string") {
|
|
40994
|
+
return `cron ${trigger.cron}`;
|
|
40995
|
+
}
|
|
40996
|
+
return "trigger";
|
|
40997
|
+
}
|
|
40920
40998
|
function validateAgentFragmentDocument(document, path2, context) {
|
|
40921
40999
|
const normalizedPath = normalizeSourcePath(path2);
|
|
40922
41000
|
if (context.stack.includes(normalizedPath)) {
|
|
@@ -40980,9 +41058,11 @@ function compileAgentDocumentValue(document, path2, fileIndex, contextVariables)
|
|
|
40980
41058
|
variables: /* @__PURE__ */ new Map(),
|
|
40981
41059
|
...contextVariables && Object.keys(contextVariables).length > 0 ? { contextVariables: new Map(Object.entries(contextVariables)) } : {}
|
|
40982
41060
|
});
|
|
41061
|
+
const authoredTriggers = structuredClone(draft.spec.triggers);
|
|
40983
41062
|
return {
|
|
40984
41063
|
...compileAgentDraftResources(draft, path2),
|
|
40985
|
-
sourceLocations: draft.sourceLocations
|
|
41064
|
+
sourceLocations: draft.sourceLocations,
|
|
41065
|
+
authoredTriggers
|
|
40986
41066
|
};
|
|
40987
41067
|
}
|
|
40988
41068
|
function compileAgentDocument2(document, path2, context) {
|