@autohq/cli 0.1.676 → 0.1.678
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 +1 -1
- package/dist/index.js +398 -78
- package/package.json +1 -1
package/dist/agent-bridge.js
CHANGED
|
@@ -33217,7 +33217,7 @@ function bootstrapAdditionalData(input) {
|
|
|
33217
33217
|
// package.json
|
|
33218
33218
|
var package_default = {
|
|
33219
33219
|
name: "@autohq/cli",
|
|
33220
|
-
version: "0.1.
|
|
33220
|
+
version: "0.1.678",
|
|
33221
33221
|
license: "SEE LICENSE IN README.md",
|
|
33222
33222
|
publishConfig: {
|
|
33223
33223
|
access: "public"
|
package/dist/index.js
CHANGED
|
@@ -23403,6 +23403,21 @@ var init_validation_diagnostics = __esm({
|
|
|
23403
23403
|
message: "The Auto authoring file could not be parsed as YAML or JSON.",
|
|
23404
23404
|
owner: "schemas/project-apply-files"
|
|
23405
23405
|
},
|
|
23406
|
+
"auto.validation.schema_version.invalid": {
|
|
23407
|
+
severity: "error",
|
|
23408
|
+
message: "The authored schema version must be a positive integer.",
|
|
23409
|
+
owner: "schemas/project-apply-files"
|
|
23410
|
+
},
|
|
23411
|
+
"auto.validation.schema_version.unsupported": {
|
|
23412
|
+
severity: "error",
|
|
23413
|
+
message: "This Auto release does not support the authored schema version.",
|
|
23414
|
+
owner: "schemas/project-apply-files"
|
|
23415
|
+
},
|
|
23416
|
+
"auto.validation.authoring.unknown_field": {
|
|
23417
|
+
severity: "error",
|
|
23418
|
+
message: "The versioned authoring document contains an unknown field.",
|
|
23419
|
+
owner: "schemas/project-apply-files"
|
|
23420
|
+
},
|
|
23406
23421
|
"auto.validation.schema.invalid": {
|
|
23407
23422
|
severity: "error",
|
|
23408
23423
|
message: "The Auto resource does not match its schema.",
|
|
@@ -23429,7 +23444,8 @@ var init_validation_diagnostics = __esm({
|
|
|
23429
23444
|
location: external_exports.object({
|
|
23430
23445
|
file: external_exports.string().min(1),
|
|
23431
23446
|
line: external_exports.number().int().positive().optional(),
|
|
23432
|
-
column: external_exports.number().int().positive().optional()
|
|
23447
|
+
column: external_exports.number().int().positive().optional(),
|
|
23448
|
+
documentIndex: external_exports.number().int().nonnegative().optional()
|
|
23433
23449
|
}).optional(),
|
|
23434
23450
|
remediation: external_exports.object({
|
|
23435
23451
|
summary: external_exports.string().min(1),
|
|
@@ -24918,7 +24934,7 @@ var init_session_inbox = __esm({
|
|
|
24918
24934
|
});
|
|
24919
24935
|
|
|
24920
24936
|
// ../../packages/schemas/src/session-do-command-queue.ts
|
|
24921
|
-
var SessionDoCommandEnqueueRequestSchema, SessionDoCommandProjectionSchema, SessionDoCommandEnqueueReceiptSchema, SessionCommandMutationResponseSchema, SessionInboxMutationResponseSchema, SessionInboxSteerMutationResponseSchema;
|
|
24937
|
+
var SessionDoCommandEnqueueRequestSchema, SessionDoCommandProjectionSchema, SessionDoInboxReadResponseSchema, SessionDoCommandEnqueueReceiptSchema, SessionCommandMutationResponseSchema, SessionInboxMutationResponseSchema, SessionInboxSteerMutationResponseSchema;
|
|
24922
24938
|
var init_session_do_command_queue = __esm({
|
|
24923
24939
|
"../../packages/schemas/src/session-do-command-queue.ts"() {
|
|
24924
24940
|
"use strict";
|
|
@@ -24932,10 +24948,19 @@ var init_session_do_command_queue = __esm({
|
|
|
24932
24948
|
kind: SessionCommandKindSchema
|
|
24933
24949
|
});
|
|
24934
24950
|
SessionDoCommandProjectionSchema = external_exports.object({
|
|
24951
|
+
// Optional for responses from a draining pre-epoch SessionDO deployment.
|
|
24952
|
+
// A new SessionDO always includes its durable epoch.
|
|
24953
|
+
epoch: external_exports.string().trim().min(1).max(200).optional(),
|
|
24935
24954
|
revision: external_exports.number().int().nonnegative().safe(),
|
|
24936
24955
|
inbox: external_exports.array(SessionInboxItemSchema),
|
|
24937
24956
|
ledgerItem: SessionLedgerItemRecordSchema.nullable()
|
|
24938
24957
|
});
|
|
24958
|
+
SessionDoInboxReadResponseSchema = external_exports.object({
|
|
24959
|
+
type: external_exports.literal("session_do.inbox"),
|
|
24960
|
+
epoch: external_exports.string().trim().min(1).max(200),
|
|
24961
|
+
revision: external_exports.number().int().nonnegative().safe(),
|
|
24962
|
+
items: external_exports.array(SessionInboxItemSchema)
|
|
24963
|
+
});
|
|
24939
24964
|
SessionDoCommandEnqueueReceiptSchema = external_exports.object({
|
|
24940
24965
|
type: external_exports.literal("session_do.command.enqueued"),
|
|
24941
24966
|
commandId: SessionCommandIdSchema,
|
|
@@ -25213,11 +25238,34 @@ var init_session_ledger_stream = __esm({
|
|
|
25213
25238
|
});
|
|
25214
25239
|
SessionInboxEventSchema = external_exports.object({
|
|
25215
25240
|
type: external_exports.literal("inbox"),
|
|
25241
|
+
// Optional while older SessionDO deployments drain. Once present, the
|
|
25242
|
+
// epoch lets a client adopt a legitimate SessionDO storage reset even when
|
|
25243
|
+
// the new object's revision is lower than the last revision it observed.
|
|
25244
|
+
epoch: external_exports.string().trim().min(1).max(200).optional(),
|
|
25245
|
+
// Present only on the freshly read reconnect projection. Live
|
|
25246
|
+
// publications and command receipts omit it, so delayed work from an
|
|
25247
|
+
// unseen prior epoch cannot switch a client back after this fence.
|
|
25248
|
+
snapshot: external_exports.literal(true).optional(),
|
|
25216
25249
|
// Optional while older SessionDO deployments drain. New publishers attach
|
|
25217
25250
|
// their durable monotonic projection revision so delayed events and command
|
|
25218
25251
|
// responses cannot regress the client inbox.
|
|
25219
25252
|
revision: external_exports.number().int().nonnegative().safe().optional(),
|
|
25220
25253
|
items: external_exports.array(SessionInboxItemSchema)
|
|
25254
|
+
}).superRefine((event, context) => {
|
|
25255
|
+
if (event.epoch !== void 0 && event.revision === void 0) {
|
|
25256
|
+
context.addIssue({
|
|
25257
|
+
code: "custom",
|
|
25258
|
+
path: ["revision"],
|
|
25259
|
+
message: "An epoch inbox event must include its revision"
|
|
25260
|
+
});
|
|
25261
|
+
}
|
|
25262
|
+
if (event.snapshot && event.epoch === void 0) {
|
|
25263
|
+
context.addIssue({
|
|
25264
|
+
code: "custom",
|
|
25265
|
+
path: ["epoch"],
|
|
25266
|
+
message: "An inbox snapshot must include its epoch"
|
|
25267
|
+
});
|
|
25268
|
+
}
|
|
25221
25269
|
});
|
|
25222
25270
|
SessionLedgerStreamEventSchema = external_exports.discriminatedUnion("type", [
|
|
25223
25271
|
SessionLedgerItemEventSchema,
|
|
@@ -104503,7 +104551,7 @@ var init_package = __esm({
|
|
|
104503
104551
|
"package.json"() {
|
|
104504
104552
|
package_default = {
|
|
104505
104553
|
name: "@autohq/cli",
|
|
104506
|
-
version: "0.1.
|
|
104554
|
+
version: "0.1.678",
|
|
104507
104555
|
license: "SEE LICENSE IN README.md",
|
|
104508
104556
|
publishConfig: {
|
|
104509
104557
|
access: "public"
|
|
@@ -105507,17 +105555,140 @@ var init_agent_tool_connect = __esm({
|
|
|
105507
105555
|
}
|
|
105508
105556
|
});
|
|
105509
105557
|
|
|
105558
|
+
// ../../packages/schemas/src/project-apply-files/schema-version.ts
|
|
105559
|
+
function selectAuthoredSchemaDocument(input) {
|
|
105560
|
+
if (!isRecord4(input.document) || !Object.hasOwn(input.document, "schemaVersion")) {
|
|
105561
|
+
return {
|
|
105562
|
+
dialect: LEGACY_AUTHORED_SCHEMA_DIALECT,
|
|
105563
|
+
value: input.document
|
|
105564
|
+
};
|
|
105565
|
+
}
|
|
105566
|
+
const version2 = input.document.schemaVersion;
|
|
105567
|
+
if (typeof version2 !== "number" || !isPositiveInteger(version2)) {
|
|
105568
|
+
throw malformedSchemaVersionError(input);
|
|
105569
|
+
}
|
|
105570
|
+
if (version2 > CURRENT_AUTHORED_SCHEMA_VERSION) {
|
|
105571
|
+
throw unsupportedSchemaVersionError(input, version2);
|
|
105572
|
+
}
|
|
105573
|
+
const { schemaVersion: _controlField, ...body } = input.document;
|
|
105574
|
+
return {
|
|
105575
|
+
dialect: CURRENT_AUTHORED_SCHEMA_DIALECT,
|
|
105576
|
+
value: migrateAuthoredSchemaDocument({
|
|
105577
|
+
document: body,
|
|
105578
|
+
fromVersion: version2,
|
|
105579
|
+
toVersion: CURRENT_AUTHORED_SCHEMA_VERSION,
|
|
105580
|
+
migrations: AUTHORED_SCHEMA_MIGRATIONS
|
|
105581
|
+
})
|
|
105582
|
+
};
|
|
105583
|
+
}
|
|
105584
|
+
function isAuthoredSchemaVersionError(error51) {
|
|
105585
|
+
if (!(error51 instanceof AutoValidationDiagnosticError)) {
|
|
105586
|
+
return false;
|
|
105587
|
+
}
|
|
105588
|
+
return error51.diagnostic.code === "auto.validation.schema_version.invalid" || error51.diagnostic.code === "auto.validation.schema_version.unsupported";
|
|
105589
|
+
}
|
|
105590
|
+
function migrateAuthoredSchemaDocument(input) {
|
|
105591
|
+
if (!isPositiveInteger(input.fromVersion) || !isPositiveInteger(input.toVersion)) {
|
|
105592
|
+
throw new Error(
|
|
105593
|
+
"Authored schema migration endpoints must be positive integers"
|
|
105594
|
+
);
|
|
105595
|
+
}
|
|
105596
|
+
if (input.fromVersion > input.toVersion) {
|
|
105597
|
+
throw new Error(
|
|
105598
|
+
`Authored schema migrations cannot move backward from ${input.fromVersion} to ${input.toVersion}`
|
|
105599
|
+
);
|
|
105600
|
+
}
|
|
105601
|
+
let document = structuredClone(input.document);
|
|
105602
|
+
for (let version2 = input.fromVersion; version2 < input.toVersion; version2 += 1) {
|
|
105603
|
+
const edges = input.migrations.filter(
|
|
105604
|
+
(edge) => edge.fromVersion === version2
|
|
105605
|
+
);
|
|
105606
|
+
if (edges.length !== 1 || edges[0]?.toVersion !== version2 + 1) {
|
|
105607
|
+
throw new Error(
|
|
105608
|
+
`Authored schema migration chain requires exactly one ${version2} -> ${version2 + 1} edge`
|
|
105609
|
+
);
|
|
105610
|
+
}
|
|
105611
|
+
document = edges[0].migrate(structuredClone(document));
|
|
105612
|
+
}
|
|
105613
|
+
return document;
|
|
105614
|
+
}
|
|
105615
|
+
function malformedSchemaVersionError(input) {
|
|
105616
|
+
return new AutoValidationDiagnosticError(
|
|
105617
|
+
`Invalid schemaVersion in ${documentLabel(input)}: expected a positive integer`,
|
|
105618
|
+
autoValidationDiagnostic({
|
|
105619
|
+
code: "auto.validation.schema_version.invalid",
|
|
105620
|
+
path: ["schemaVersion"],
|
|
105621
|
+
location: diagnosticLocation(input),
|
|
105622
|
+
remediation: {
|
|
105623
|
+
summary: `Set schemaVersion to ${CURRENT_AUTHORED_SCHEMA_VERSION}, or remove it to retain the legacy dialect.`
|
|
105624
|
+
}
|
|
105625
|
+
})
|
|
105626
|
+
);
|
|
105627
|
+
}
|
|
105628
|
+
function unsupportedSchemaVersionError(input, version2) {
|
|
105629
|
+
return new AutoValidationDiagnosticError(
|
|
105630
|
+
`Unsupported schemaVersion ${version2} in ${documentLabel(input)}: this Auto release supports through ${CURRENT_AUTHORED_SCHEMA_VERSION}`,
|
|
105631
|
+
autoValidationDiagnostic({
|
|
105632
|
+
code: "auto.validation.schema_version.unsupported",
|
|
105633
|
+
path: ["schemaVersion"],
|
|
105634
|
+
location: diagnosticLocation(input),
|
|
105635
|
+
remediation: {
|
|
105636
|
+
summary: "Upgrade Auto to a release that supports this authored schema version, then validate again."
|
|
105637
|
+
}
|
|
105638
|
+
})
|
|
105639
|
+
);
|
|
105640
|
+
}
|
|
105641
|
+
function documentLabel(input) {
|
|
105642
|
+
return `${input.location.file} document ${input.documentIndex + 1}`;
|
|
105643
|
+
}
|
|
105644
|
+
function diagnosticLocation(input) {
|
|
105645
|
+
return {
|
|
105646
|
+
...input.topLevelLocations.schemaVersion ?? input.location,
|
|
105647
|
+
documentIndex: input.documentIndex
|
|
105648
|
+
};
|
|
105649
|
+
}
|
|
105650
|
+
function isRecord4(value) {
|
|
105651
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
105652
|
+
}
|
|
105653
|
+
function isPositiveInteger(value) {
|
|
105654
|
+
return Number.isInteger(value) && value > 0;
|
|
105655
|
+
}
|
|
105656
|
+
var CURRENT_AUTHORED_SCHEMA_VERSION, LEGACY_AUTHORED_SCHEMA_DIALECT, AUTHORED_SCHEMA_MIGRATIONS, CURRENT_AUTHORED_SCHEMA_DIALECT;
|
|
105657
|
+
var init_schema_version = __esm({
|
|
105658
|
+
"../../packages/schemas/src/project-apply-files/schema-version.ts"() {
|
|
105659
|
+
"use strict";
|
|
105660
|
+
init_validation_diagnostics();
|
|
105661
|
+
CURRENT_AUTHORED_SCHEMA_VERSION = 1;
|
|
105662
|
+
LEGACY_AUTHORED_SCHEMA_DIALECT = Object.freeze({
|
|
105663
|
+
kind: "legacy"
|
|
105664
|
+
});
|
|
105665
|
+
AUTHORED_SCHEMA_MIGRATIONS = Object.freeze([]);
|
|
105666
|
+
CURRENT_AUTHORED_SCHEMA_DIALECT = Object.freeze({
|
|
105667
|
+
kind: "versioned",
|
|
105668
|
+
version: CURRENT_AUTHORED_SCHEMA_VERSION
|
|
105669
|
+
});
|
|
105670
|
+
}
|
|
105671
|
+
});
|
|
105672
|
+
|
|
105510
105673
|
// ../../packages/schemas/src/project-apply-files/source.ts
|
|
105511
|
-
import {
|
|
105512
|
-
|
|
105674
|
+
import {
|
|
105675
|
+
LineCounter,
|
|
105676
|
+
isMap,
|
|
105677
|
+
parseAllDocuments as parseYamlDocuments2
|
|
105678
|
+
} from "yaml";
|
|
105679
|
+
function readSourceDocuments(file2) {
|
|
105513
105680
|
const source = Buffer.from(file2.contentBase64, "base64").toString("utf8");
|
|
105681
|
+
const lineCounter = new LineCounter();
|
|
105682
|
+
let parsedDocuments;
|
|
105514
105683
|
try {
|
|
105515
|
-
|
|
105684
|
+
parsedDocuments = parseYamlDocuments2(source, {
|
|
105685
|
+
keepSourceTokens: true,
|
|
105686
|
+
lineCounter
|
|
105687
|
+
});
|
|
105516
105688
|
const parseError = parsedDocuments.flatMap((document) => document.errors).at(0);
|
|
105517
105689
|
if (parseError) {
|
|
105518
105690
|
throw parseError;
|
|
105519
105691
|
}
|
|
105520
|
-
return parsedDocuments.filter((document) => document.contents !== null).map((document) => document.toJSON());
|
|
105521
105692
|
} catch {
|
|
105522
105693
|
throw new AutoValidationDiagnosticError(
|
|
105523
105694
|
`Invalid apply file ${file2.path}: YAML or JSON could not be parsed`,
|
|
@@ -105530,6 +105701,55 @@ function readDocumentsFromSource(file2) {
|
|
|
105530
105701
|
})
|
|
105531
105702
|
);
|
|
105532
105703
|
}
|
|
105704
|
+
return parsedDocuments.flatMap((document, documentIndex) => {
|
|
105705
|
+
if (document.contents === null) {
|
|
105706
|
+
return [];
|
|
105707
|
+
}
|
|
105708
|
+
const value = sourceDocumentValue(document, file2.path);
|
|
105709
|
+
const location = sourceNodeLocation(
|
|
105710
|
+
document.contents,
|
|
105711
|
+
file2.path,
|
|
105712
|
+
lineCounter
|
|
105713
|
+
);
|
|
105714
|
+
const topLevelLocations = topLevelSourceLocations(
|
|
105715
|
+
document.contents,
|
|
105716
|
+
file2.path,
|
|
105717
|
+
lineCounter
|
|
105718
|
+
);
|
|
105719
|
+
const selected = selectAuthoredSchemaDocument({
|
|
105720
|
+
document: value,
|
|
105721
|
+
documentIndex,
|
|
105722
|
+
location,
|
|
105723
|
+
topLevelLocations
|
|
105724
|
+
});
|
|
105725
|
+
return [
|
|
105726
|
+
{
|
|
105727
|
+
...selected,
|
|
105728
|
+
documentIndex,
|
|
105729
|
+
location,
|
|
105730
|
+
topLevelLocations
|
|
105731
|
+
}
|
|
105732
|
+
];
|
|
105733
|
+
});
|
|
105734
|
+
}
|
|
105735
|
+
function sourceDocumentValue(document, file2) {
|
|
105736
|
+
try {
|
|
105737
|
+
return document.toJSON();
|
|
105738
|
+
} catch {
|
|
105739
|
+
throw invalidSourceSyntaxError(file2);
|
|
105740
|
+
}
|
|
105741
|
+
}
|
|
105742
|
+
function invalidSourceSyntaxError(file2) {
|
|
105743
|
+
return new AutoValidationDiagnosticError(
|
|
105744
|
+
`Invalid apply file ${file2}: YAML or JSON could not be parsed`,
|
|
105745
|
+
autoValidationDiagnostic({
|
|
105746
|
+
code: "auto.validation.parse.yaml_invalid",
|
|
105747
|
+
location: { file: file2 },
|
|
105748
|
+
remediation: {
|
|
105749
|
+
summary: "Fix the YAML or JSON syntax in this file, then validate again."
|
|
105750
|
+
}
|
|
105751
|
+
})
|
|
105752
|
+
);
|
|
105533
105753
|
}
|
|
105534
105754
|
function primaryApplyDirectory() {
|
|
105535
105755
|
return APPLY_DIRECTORIES[RESOURCE_KIND_AGENT];
|
|
@@ -105551,15 +105771,39 @@ function sourceFileIndex(files) {
|
|
|
105551
105771
|
function isAbsoluteSourcePath(path2) {
|
|
105552
105772
|
return path2.startsWith("/");
|
|
105553
105773
|
}
|
|
105554
|
-
function
|
|
105774
|
+
function isRecord5(value) {
|
|
105555
105775
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
105556
105776
|
}
|
|
105777
|
+
function topLevelSourceLocations(node, file2, lineCounter) {
|
|
105778
|
+
if (!isMap(node)) {
|
|
105779
|
+
return {};
|
|
105780
|
+
}
|
|
105781
|
+
return Object.fromEntries(
|
|
105782
|
+
node.items.flatMap((pair) => {
|
|
105783
|
+
const key = pair.key?.toJSON?.();
|
|
105784
|
+
if (typeof key !== "string") {
|
|
105785
|
+
return [];
|
|
105786
|
+
}
|
|
105787
|
+
return [[key, sourceNodeLocation(pair.key, file2, lineCounter)]];
|
|
105788
|
+
})
|
|
105789
|
+
);
|
|
105790
|
+
}
|
|
105791
|
+
function sourceNodeLocation(node, file2, lineCounter) {
|
|
105792
|
+
const range = node?.range;
|
|
105793
|
+
const position = lineCounter.linePos(range?.[0] ?? 0);
|
|
105794
|
+
return {
|
|
105795
|
+
file: normalizeSourcePath(file2),
|
|
105796
|
+
line: position.line,
|
|
105797
|
+
column: position.col
|
|
105798
|
+
};
|
|
105799
|
+
}
|
|
105557
105800
|
var APPLY_DIRECTORIES, PROJECT_APPLY_RESOURCE_DIRECTORIES;
|
|
105558
105801
|
var init_source = __esm({
|
|
105559
105802
|
"../../packages/schemas/src/project-apply-files/source.ts"() {
|
|
105560
105803
|
"use strict";
|
|
105561
105804
|
init_agents();
|
|
105562
105805
|
init_validation_diagnostics();
|
|
105806
|
+
init_schema_version();
|
|
105563
105807
|
APPLY_DIRECTORIES = {
|
|
105564
105808
|
[RESOURCE_KIND_AGENT]: "agents"
|
|
105565
105809
|
};
|
|
@@ -105576,7 +105820,7 @@ function readSingleDocument2(path2, fileIndex) {
|
|
|
105576
105820
|
if (!file2) {
|
|
105577
105821
|
throw new Error(`Agent import not found: ${path2}`);
|
|
105578
105822
|
}
|
|
105579
|
-
const documents =
|
|
105823
|
+
const documents = readSourceDocuments(file2);
|
|
105580
105824
|
if (documents.length !== 1) {
|
|
105581
105825
|
throw new Error(
|
|
105582
105826
|
`Agent authoring file ${file2.path} must contain exactly one document`
|
|
@@ -105630,7 +105874,7 @@ function resolveTemplateImportPath(importPath, fileIndex) {
|
|
|
105630
105874
|
return key;
|
|
105631
105875
|
}
|
|
105632
105876
|
function removalDirectives2(document, path2) {
|
|
105633
|
-
const raw =
|
|
105877
|
+
const raw = isRecord5(document.remove) ? document.remove : {};
|
|
105634
105878
|
const directives = [];
|
|
105635
105879
|
for (const [target, value] of Object.entries(raw)) {
|
|
105636
105880
|
const names = stringList2(value, `remove.${target}`);
|
|
@@ -105658,16 +105902,16 @@ var init_agent_document_merge = __esm({
|
|
|
105658
105902
|
});
|
|
105659
105903
|
|
|
105660
105904
|
// ../../packages/schemas/src/project-apply-files/source-locations.ts
|
|
105661
|
-
import { LineCounter, isMap, isSeq, parseAllDocuments as parseAllDocuments3 } from "yaml";
|
|
105905
|
+
import { LineCounter as LineCounter2, isMap as isMap2, isSeq, parseAllDocuments as parseAllDocuments3 } from "yaml";
|
|
105662
105906
|
function readProjectConfigSourceLocations(file2) {
|
|
105663
|
-
const locations = readYamlLocations(file2, "spec");
|
|
105907
|
+
const locations = readYamlLocations(file2, "spec", 0);
|
|
105664
105908
|
return Object.values(locations).map((location) => ({
|
|
105665
105909
|
...location,
|
|
105666
105910
|
kind: RESOURCE_KIND_CONFIG,
|
|
105667
105911
|
name: PROJECT_CONFIG_RESOURCE_NAME
|
|
105668
105912
|
}));
|
|
105669
105913
|
}
|
|
105670
|
-
function readAgentDraftSourceLocations(path2, fileIndex) {
|
|
105914
|
+
function readAgentDraftSourceLocations(path2, fileIndex, documentIndex) {
|
|
105671
105915
|
const normalizedPath = normalizeSourcePath(path2);
|
|
105672
105916
|
if (normalizedPath.startsWith("packages/")) {
|
|
105673
105917
|
return {};
|
|
@@ -105676,30 +105920,39 @@ function readAgentDraftSourceLocations(path2, fileIndex) {
|
|
|
105676
105920
|
if (!file2) {
|
|
105677
105921
|
return {};
|
|
105678
105922
|
}
|
|
105679
|
-
return readYamlLocations(file2, "");
|
|
105923
|
+
return readYamlLocations(file2, "", documentIndex);
|
|
105680
105924
|
}
|
|
105681
|
-
function readYamlLocations(file2, rootPath) {
|
|
105925
|
+
function readYamlLocations(file2, rootPath, documentIndex) {
|
|
105682
105926
|
const source = Buffer.from(file2.contentBase64, "base64").toString("utf8");
|
|
105683
|
-
const lineCounter = new
|
|
105927
|
+
const lineCounter = new LineCounter2();
|
|
105684
105928
|
const documents = parseAllDocuments3(source, {
|
|
105685
105929
|
keepSourceTokens: true,
|
|
105686
105930
|
lineCounter
|
|
105687
105931
|
});
|
|
105688
|
-
|
|
105932
|
+
const document = documents[documentIndex];
|
|
105933
|
+
if (!document || document.errors.length > 0) {
|
|
105689
105934
|
return {};
|
|
105690
105935
|
}
|
|
105691
105936
|
const locations = {};
|
|
105692
|
-
collectNodeLocations(
|
|
105937
|
+
collectNodeLocations(document.contents, rootPath, locations, {
|
|
105693
105938
|
file: normalizeSourcePath(file2.path),
|
|
105694
105939
|
lineCounter
|
|
105695
105940
|
});
|
|
105696
105941
|
return locations;
|
|
105697
105942
|
}
|
|
105698
105943
|
function collectNodeLocations(node, path2, locations, context) {
|
|
105699
|
-
if (
|
|
105944
|
+
if (isMap2(node)) {
|
|
105700
105945
|
for (const pair of node.items) {
|
|
105701
105946
|
const key = String(pair.key?.toJSON());
|
|
105702
|
-
if ([
|
|
105947
|
+
if ([
|
|
105948
|
+
"import",
|
|
105949
|
+
"imports",
|
|
105950
|
+
"remove",
|
|
105951
|
+
"schemaVersion",
|
|
105952
|
+
"templateVariables",
|
|
105953
|
+
"variables",
|
|
105954
|
+
"when"
|
|
105955
|
+
].includes(key)) {
|
|
105703
105956
|
continue;
|
|
105704
105957
|
}
|
|
105705
105958
|
const childPath = propertyPath(path2, key);
|
|
@@ -105775,7 +106028,7 @@ function mergeValues3(base, override) {
|
|
|
105775
106028
|
if (override === void 0) {
|
|
105776
106029
|
return base;
|
|
105777
106030
|
}
|
|
105778
|
-
if (
|
|
106031
|
+
if (isRecord5(base) && isRecord5(override)) {
|
|
105779
106032
|
const merged = { ...base };
|
|
105780
106033
|
for (const [key, value] of Object.entries(override)) {
|
|
105781
106034
|
merged[key] = mergeValues3(merged[key], value);
|
|
@@ -105795,7 +106048,7 @@ function sortJson(value) {
|
|
|
105795
106048
|
if (Array.isArray(value)) {
|
|
105796
106049
|
return value.map(sortJson);
|
|
105797
106050
|
}
|
|
105798
|
-
if (
|
|
106051
|
+
if (isRecord5(value)) {
|
|
105799
106052
|
return Object.fromEntries(
|
|
105800
106053
|
Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, nested]) => [key, sortJson(nested)])
|
|
105801
106054
|
);
|
|
@@ -105811,6 +106064,7 @@ var init_helpers = __esm({
|
|
|
105811
106064
|
"import",
|
|
105812
106065
|
"imports",
|
|
105813
106066
|
"remove",
|
|
106067
|
+
"schemaVersion",
|
|
105814
106068
|
"templateVariables",
|
|
105815
106069
|
"variables",
|
|
105816
106070
|
"when"
|
|
@@ -105833,7 +106087,7 @@ function fileBackedStringField() {
|
|
|
105833
106087
|
};
|
|
105834
106088
|
}
|
|
105835
106089
|
function rejectDirectiveObject(value, input) {
|
|
105836
|
-
if (
|
|
106090
|
+
if (isRecord5(value) && "append" in value) {
|
|
105837
106091
|
throw new Error(
|
|
105838
106092
|
`Invalid agent authoring file ${input.path}: ${input.field} does not support directive objects; append is supported on ${APPEND_CAPABLE_FIELDS}`
|
|
105839
106093
|
);
|
|
@@ -105841,7 +106095,7 @@ function rejectDirectiveObject(value, input) {
|
|
|
105841
106095
|
return value;
|
|
105842
106096
|
}
|
|
105843
106097
|
function resolveFileBackedString2(value, input) {
|
|
105844
|
-
if (!
|
|
106098
|
+
if (!isRecord5(value)) {
|
|
105845
106099
|
return value;
|
|
105846
106100
|
}
|
|
105847
106101
|
if ("file" in value && !("append" in value)) {
|
|
@@ -105939,11 +106193,11 @@ function rejectUnresolvedAppendDirective(value) {
|
|
|
105939
106193
|
);
|
|
105940
106194
|
}
|
|
105941
106195
|
function appendDirectiveFromMarker(value) {
|
|
105942
|
-
if (!
|
|
106196
|
+
if (!isRecord5(value)) {
|
|
105943
106197
|
return void 0;
|
|
105944
106198
|
}
|
|
105945
106199
|
const marker = value[APPEND_DIRECTIVE_MARKER_KEY];
|
|
105946
|
-
if (!
|
|
106200
|
+
if (!isRecord5(marker)) {
|
|
105947
106201
|
return void 0;
|
|
105948
106202
|
}
|
|
105949
106203
|
return marker;
|
|
@@ -105965,7 +106219,7 @@ function inlineEnvironmentField() {
|
|
|
105965
106219
|
target: "spec",
|
|
105966
106220
|
merge: (base, override) => mergeValues3(base, override),
|
|
105967
106221
|
compile: (value, context) => {
|
|
105968
|
-
if (!
|
|
106222
|
+
if (!isRecord5(value)) {
|
|
105969
106223
|
return { resources: [], value };
|
|
105970
106224
|
}
|
|
105971
106225
|
const resource = inlineEnvironmentResource2(value, context.path);
|
|
@@ -105978,7 +106232,7 @@ function inlineIdentityField() {
|
|
|
105978
106232
|
target: "spec",
|
|
105979
106233
|
merge: (base, override) => mergeValues3(base, override),
|
|
105980
106234
|
compile: (value, context) => {
|
|
105981
|
-
if (!
|
|
106235
|
+
if (!isRecord5(value)) {
|
|
105982
106236
|
return { resources: [], value };
|
|
105983
106237
|
}
|
|
105984
106238
|
const resource = inlineIdentityResource2(
|
|
@@ -105991,7 +106245,7 @@ function inlineIdentityField() {
|
|
|
105991
106245
|
};
|
|
105992
106246
|
}
|
|
105993
106247
|
function assertAgentAuthoringDocument(document, path2) {
|
|
105994
|
-
if (!
|
|
106248
|
+
if (!isRecord5(document) || !("kind" in document)) {
|
|
105995
106249
|
return;
|
|
105996
106250
|
}
|
|
105997
106251
|
if (document.kind === "session") {
|
|
@@ -106169,7 +106423,7 @@ function triggersField() {
|
|
|
106169
106423
|
};
|
|
106170
106424
|
}
|
|
106171
106425
|
function mountItemKey(item) {
|
|
106172
|
-
if (!
|
|
106426
|
+
if (!isRecord5(item)) {
|
|
106173
106427
|
return void 0;
|
|
106174
106428
|
}
|
|
106175
106429
|
if (typeof item.name === "string") {
|
|
@@ -106181,7 +106435,7 @@ function mountItemKey(item) {
|
|
|
106181
106435
|
return void 0;
|
|
106182
106436
|
}
|
|
106183
106437
|
function triggerItemKey(item) {
|
|
106184
|
-
if (!
|
|
106438
|
+
if (!isRecord5(item)) {
|
|
106185
106439
|
return void 0;
|
|
106186
106440
|
}
|
|
106187
106441
|
if (typeof item.name === "string") {
|
|
@@ -106234,7 +106488,7 @@ function removeAuthoringTriggerNames(value) {
|
|
|
106234
106488
|
return value;
|
|
106235
106489
|
}
|
|
106236
106490
|
return value.map((trigger) => {
|
|
106237
|
-
if (!
|
|
106491
|
+
if (!isRecord5(trigger) || !("name" in trigger)) {
|
|
106238
106492
|
return trigger;
|
|
106239
106493
|
}
|
|
106240
106494
|
const next = { ...trigger };
|
|
@@ -106256,7 +106510,7 @@ function namedMapField() {
|
|
|
106256
106510
|
target: "spec",
|
|
106257
106511
|
merge: (base, override) => mergeValues3(base, override),
|
|
106258
106512
|
remove: (value, names) => {
|
|
106259
|
-
if (!
|
|
106513
|
+
if (!isRecord5(value)) {
|
|
106260
106514
|
return value;
|
|
106261
106515
|
}
|
|
106262
106516
|
const next = { ...value };
|
|
@@ -106297,12 +106551,21 @@ var init_scalar = __esm({
|
|
|
106297
106551
|
});
|
|
106298
106552
|
|
|
106299
106553
|
// ../../packages/schemas/src/project-apply-files/agent-fields/index.ts
|
|
106300
|
-
function parseAgentDraft(
|
|
106554
|
+
function parseAgentDraft(sourceDocument, path2, fileIndex) {
|
|
106555
|
+
const document = sourceDocument.value;
|
|
106556
|
+
if (!isRecord5(document)) {
|
|
106557
|
+
throw new Error(`Invalid agent authoring file ${path2}: expected object`);
|
|
106558
|
+
}
|
|
106301
106559
|
assertAgentAuthoringDocument(document, path2);
|
|
106560
|
+
assertKnownAgentAuthoringFields(document, sourceDocument, path2);
|
|
106302
106561
|
const sanitized = sanitizedAgentDocument2(document);
|
|
106303
106562
|
assertNoLegacyEnvelopeFields(sanitized, path2);
|
|
106304
106563
|
const draft = emptyAgentDraft();
|
|
106305
|
-
draft.sourceLocations = readAgentDraftSourceLocations(
|
|
106564
|
+
draft.sourceLocations = readAgentDraftSourceLocations(
|
|
106565
|
+
path2,
|
|
106566
|
+
fileIndex,
|
|
106567
|
+
sourceDocument.documentIndex
|
|
106568
|
+
);
|
|
106306
106569
|
for (const [key, value] of Object.entries(sanitized)) {
|
|
106307
106570
|
if (value === void 0) {
|
|
106308
106571
|
continue;
|
|
@@ -106362,7 +106625,7 @@ function mergeSourceLocations(base, override) {
|
|
|
106362
106625
|
continue;
|
|
106363
106626
|
}
|
|
106364
106627
|
const prefix = `${target}.${key}`;
|
|
106365
|
-
if (!
|
|
106628
|
+
if (!isRecord5(value)) {
|
|
106366
106629
|
merged = Object.fromEntries(
|
|
106367
106630
|
Object.entries(merged).filter(
|
|
106368
106631
|
([path2]) => path2 !== prefix && !path2.startsWith(`${prefix}.`)
|
|
@@ -106438,10 +106701,36 @@ function supportedRemovalTargets() {
|
|
|
106438
106701
|
(key) => AGENT_FIELDS[key]?.remove
|
|
106439
106702
|
);
|
|
106440
106703
|
}
|
|
106704
|
+
function assertKnownAgentAuthoringFields(document, sourceDocument, path2) {
|
|
106705
|
+
if (sourceDocument.dialect.kind === "legacy") {
|
|
106706
|
+
return;
|
|
106707
|
+
}
|
|
106708
|
+
const unknownField = Object.keys(document).find(
|
|
106709
|
+
(key) => !AGENT_FIELDS[key] && !CONTROL_FIELDS.has(key)
|
|
106710
|
+
);
|
|
106711
|
+
if (!unknownField) {
|
|
106712
|
+
return;
|
|
106713
|
+
}
|
|
106714
|
+
throw new AutoValidationDiagnosticError(
|
|
106715
|
+
`Invalid agent authoring file ${path2}: unknown field "${unknownField}" for schemaVersion ${sourceDocument.dialect.version}`,
|
|
106716
|
+
autoValidationDiagnostic({
|
|
106717
|
+
code: "auto.validation.authoring.unknown_field",
|
|
106718
|
+
path: [unknownField],
|
|
106719
|
+
location: {
|
|
106720
|
+
...sourceDocument.topLevelLocations[unknownField] ?? sourceDocument.location,
|
|
106721
|
+
documentIndex: sourceDocument.documentIndex
|
|
106722
|
+
},
|
|
106723
|
+
remediation: {
|
|
106724
|
+
summary: `Remove "${unknownField}" or replace it with a supported Agent authoring field.`
|
|
106725
|
+
}
|
|
106726
|
+
})
|
|
106727
|
+
);
|
|
106728
|
+
}
|
|
106441
106729
|
var AGENT_FIELDS;
|
|
106442
106730
|
var init_agent_fields = __esm({
|
|
106443
106731
|
"../../packages/schemas/src/project-apply-files/agent-fields/index.ts"() {
|
|
106444
106732
|
"use strict";
|
|
106733
|
+
init_validation_diagnostics();
|
|
106445
106734
|
init_source();
|
|
106446
106735
|
init_source_locations();
|
|
106447
106736
|
init_file_backed_string();
|
|
@@ -106490,7 +106779,7 @@ function readVariableScope(document, path2) {
|
|
|
106490
106779
|
if (declared === void 0) {
|
|
106491
106780
|
return /* @__PURE__ */ new Map();
|
|
106492
106781
|
}
|
|
106493
|
-
if (!
|
|
106782
|
+
if (!isRecord5(declared)) {
|
|
106494
106783
|
throw new Error(
|
|
106495
106784
|
`Invalid variables in ${path2}: variables must be a map of name to value`
|
|
106496
106785
|
);
|
|
@@ -106579,7 +106868,7 @@ function substituteValue(value, scope, site) {
|
|
|
106579
106868
|
if (Array.isArray(value)) {
|
|
106580
106869
|
return value.map((item) => substituteValue(item, scope, site));
|
|
106581
106870
|
}
|
|
106582
|
-
if (
|
|
106871
|
+
if (isRecord5(value)) {
|
|
106583
106872
|
return Object.fromEntries(
|
|
106584
106873
|
Object.entries(value).map(([key, nested]) => [
|
|
106585
106874
|
key,
|
|
@@ -106616,7 +106905,7 @@ function availableNames(scope) {
|
|
|
106616
106905
|
}
|
|
106617
106906
|
function readVariableCondition(value, path2) {
|
|
106618
106907
|
if (value === void 0) return void 0;
|
|
106619
|
-
if (!
|
|
106908
|
+
if (!isRecord5(value) || typeof value.variable !== "string" || value.variable.length === 0 || Object.keys(value).some((key) => key !== "variable")) {
|
|
106620
106909
|
throw new Error(
|
|
106621
106910
|
`Invalid when in ${path2}: expected exactly { variable: <optional variable name> }`
|
|
106622
106911
|
);
|
|
@@ -106641,7 +106930,7 @@ function collectOptionalVariableReferences(value, optional2, found) {
|
|
|
106641
106930
|
}
|
|
106642
106931
|
return;
|
|
106643
106932
|
}
|
|
106644
|
-
if (
|
|
106933
|
+
if (isRecord5(value)) {
|
|
106645
106934
|
for (const [key, nested] of Object.entries(value)) {
|
|
106646
106935
|
if (key !== "templateVariables" && key !== "when") {
|
|
106647
106936
|
collectOptionalVariableReferences(nested, optional2, found);
|
|
@@ -106662,7 +106951,7 @@ var init_template_variables = __esm({
|
|
|
106662
106951
|
|
|
106663
106952
|
// ../../packages/schemas/src/project-apply-files/agent-authoring.ts
|
|
106664
106953
|
function readApplyDocument(path2, document, fileIndex, contextVariables) {
|
|
106665
|
-
assertAgentAuthoringDocument(document, path2);
|
|
106954
|
+
assertAgentAuthoringDocument(document.value, path2);
|
|
106666
106955
|
const result = compileAgentDocumentValue(
|
|
106667
106956
|
document,
|
|
106668
106957
|
path2,
|
|
@@ -106693,7 +106982,8 @@ function readApplyDocument(path2, document, fileIndex, contextVariables) {
|
|
|
106693
106982
|
sourcePath: normalizeSourcePath(path2),
|
|
106694
106983
|
draftLocations: result.sourceLocations,
|
|
106695
106984
|
authoredTriggers: result.authoredTriggers,
|
|
106696
|
-
generatedLocation
|
|
106985
|
+
generatedLocation,
|
|
106986
|
+
documentLocation: document.location
|
|
106697
106987
|
})
|
|
106698
106988
|
};
|
|
106699
106989
|
});
|
|
@@ -106707,7 +106997,7 @@ function sourceLocationsForCompiledResource(input) {
|
|
|
106707
106997
|
return [
|
|
106708
106998
|
{
|
|
106709
106999
|
file: input.sourcePath,
|
|
106710
|
-
line:
|
|
107000
|
+
line: input.documentLocation.line,
|
|
106711
107001
|
kind: input.resource.kind,
|
|
106712
107002
|
name: input.resource.metadata.name,
|
|
106713
107003
|
path: "$"
|
|
@@ -106742,7 +107032,7 @@ function projectCompiledTriggerSourceLocations(locations, authoredTriggers) {
|
|
|
106742
107032
|
);
|
|
106743
107033
|
let compiledIndex = 0;
|
|
106744
107034
|
for (const [authoredIndex, trigger] of authoredTriggers.entries()) {
|
|
106745
|
-
if (!
|
|
107035
|
+
if (!isRecord5(trigger)) {
|
|
106746
107036
|
continue;
|
|
106747
107037
|
}
|
|
106748
107038
|
const events = authoredTriggerEvents(trigger);
|
|
@@ -106803,14 +107093,15 @@ function authoredTriggerDisplayName(trigger, events) {
|
|
|
106803
107093
|
}
|
|
106804
107094
|
return "trigger";
|
|
106805
107095
|
}
|
|
106806
|
-
function validateAgentFragmentDocument(
|
|
107096
|
+
function validateAgentFragmentDocument(sourceDocument, path2, context) {
|
|
106807
107097
|
const normalizedPath = normalizeSourcePath(path2);
|
|
106808
107098
|
if (context.stack.includes(normalizedPath)) {
|
|
106809
107099
|
throw new Error(
|
|
106810
107100
|
`Agent import cycle detected: ${[...context.stack, normalizedPath].join(" -> ")}`
|
|
106811
107101
|
);
|
|
106812
107102
|
}
|
|
106813
|
-
|
|
107103
|
+
const document = sourceDocument.value;
|
|
107104
|
+
if (!isRecord5(document)) {
|
|
106814
107105
|
throw new Error(`Invalid agent fragment file ${path2}: expected object`);
|
|
106815
107106
|
}
|
|
106816
107107
|
const variableContract = readTemplateVariableContract(
|
|
@@ -106845,7 +107136,7 @@ function validateAgentFragmentDocument(document, path2, context) {
|
|
|
106845
107136
|
for (const removal of removalDirectives2(document, normalizedPath)) {
|
|
106846
107137
|
assertSupportedAgentRemovalTarget(removal.target);
|
|
106847
107138
|
}
|
|
106848
|
-
parseAgentDraft(
|
|
107139
|
+
parseAgentDraft(sourceDocument, normalizedPath, context.fileIndex);
|
|
106849
107140
|
}
|
|
106850
107141
|
function dedupeGeneratedResources(records) {
|
|
106851
107142
|
const recordsByKey = /* @__PURE__ */ new Map();
|
|
@@ -106875,16 +107166,16 @@ function conflictingGeneratedResourceMessage(key, existing, record3) {
|
|
|
106875
107166
|
const location = existing.sourcePath === record3.sourcePath ? `defined more than once in "${existing.sourcePath}" with different content` : `defined differently in "${existing.sourcePath}" and "${record3.sourcePath}"`;
|
|
106876
107167
|
return `Conflicting generated resource "${key}" from agent authoring: ${location}. Inline generated resources must be identical when they share a name.`;
|
|
106877
107168
|
}
|
|
106878
|
-
function compileAgentDocumentValue(
|
|
107169
|
+
function compileAgentDocumentValue(sourceDocument, path2, fileIndex, contextVariables) {
|
|
106879
107170
|
const templateVariableKinds = /* @__PURE__ */ new Map();
|
|
106880
107171
|
collectTemplateVariableContracts(
|
|
106881
|
-
|
|
107172
|
+
sourceDocument,
|
|
106882
107173
|
path2,
|
|
106883
107174
|
fileIndex,
|
|
106884
107175
|
[],
|
|
106885
107176
|
templateVariableKinds
|
|
106886
107177
|
);
|
|
106887
|
-
const draft = compileAgentDocument2(
|
|
107178
|
+
const draft = compileAgentDocument2(sourceDocument, path2, {
|
|
106888
107179
|
fileIndex,
|
|
106889
107180
|
stack: [],
|
|
106890
107181
|
templateVariableKinds,
|
|
@@ -106892,21 +107183,22 @@ function compileAgentDocumentValue(document, path2, fileIndex, contextVariables)
|
|
|
106892
107183
|
...contextVariables && Object.keys(contextVariables).length > 0 ? { contextVariables: new Map(Object.entries(contextVariables)) } : {}
|
|
106893
107184
|
});
|
|
106894
107185
|
const authoredTriggers = structuredClone(draft.spec.triggers);
|
|
106895
|
-
const removals =
|
|
107186
|
+
const removals = isRecord5(sourceDocument.value) ? removalDirectives2(sourceDocument.value, normalizeSourcePath(path2)) : [];
|
|
106896
107187
|
return {
|
|
106897
107188
|
...compileAgentDraftResources(draft, path2, removals),
|
|
106898
107189
|
sourceLocations: draft.sourceLocations,
|
|
106899
107190
|
authoredTriggers
|
|
106900
107191
|
};
|
|
106901
107192
|
}
|
|
106902
|
-
function collectTemplateVariableContracts(
|
|
107193
|
+
function collectTemplateVariableContracts(sourceDocument, path2, fileIndex, stack, declarations) {
|
|
106903
107194
|
const normalizedPath = normalizeSourcePath(path2);
|
|
106904
107195
|
if (stack.includes(normalizedPath)) {
|
|
106905
107196
|
throw new Error(
|
|
106906
107197
|
`Agent import cycle detected: ${[...stack, normalizedPath].join(" -> ")}`
|
|
106907
107198
|
);
|
|
106908
107199
|
}
|
|
106909
|
-
|
|
107200
|
+
const document = sourceDocument.value;
|
|
107201
|
+
if (!isRecord5(document)) {
|
|
106910
107202
|
throw new Error(`Invalid agent authoring file ${path2}: expected object`);
|
|
106911
107203
|
}
|
|
106912
107204
|
registerTemplateVariableContract(
|
|
@@ -106929,14 +107221,15 @@ function collectTemplateVariableContracts(document, path2, fileIndex, stack, dec
|
|
|
106929
107221
|
);
|
|
106930
107222
|
}
|
|
106931
107223
|
}
|
|
106932
|
-
function compileAgentDocument2(
|
|
107224
|
+
function compileAgentDocument2(sourceDocument, path2, context) {
|
|
106933
107225
|
const normalizedPath = normalizeSourcePath(path2);
|
|
106934
107226
|
if (context.stack.includes(normalizedPath)) {
|
|
106935
107227
|
throw new Error(
|
|
106936
107228
|
`Agent import cycle detected: ${[...context.stack, normalizedPath].join(" -> ")}`
|
|
106937
107229
|
);
|
|
106938
107230
|
}
|
|
106939
|
-
|
|
107231
|
+
const document = sourceDocument.value;
|
|
107232
|
+
if (!isRecord5(document)) {
|
|
106940
107233
|
throw new Error(`Invalid agent authoring file ${path2}: expected object`);
|
|
106941
107234
|
}
|
|
106942
107235
|
const variableContract = readTemplateVariableContract(
|
|
@@ -106977,13 +107270,13 @@ function compileAgentDocument2(document, path2, context) {
|
|
|
106977
107270
|
context.fileIndex
|
|
106978
107271
|
);
|
|
106979
107272
|
const rawImportedDocument = readSingleDocument2(imported, context.fileIndex);
|
|
106980
|
-
if (!
|
|
107273
|
+
if (!isRecord5(rawImportedDocument.value)) {
|
|
106981
107274
|
throw new Error(
|
|
106982
107275
|
`Invalid agent authoring file ${imported}: expected object`
|
|
106983
107276
|
);
|
|
106984
107277
|
}
|
|
106985
107278
|
const importedContract = readTemplateVariableContract(
|
|
106986
|
-
rawImportedDocument,
|
|
107279
|
+
rawImportedDocument.value,
|
|
106987
107280
|
imported
|
|
106988
107281
|
);
|
|
106989
107282
|
registerTemplateVariableContract(
|
|
@@ -106997,20 +107290,19 @@ function compileAgentDocument2(document, path2, context) {
|
|
|
106997
107290
|
imported
|
|
106998
107291
|
);
|
|
106999
107292
|
if (!includeConditionalTemplateDocument({
|
|
107000
|
-
document: rawImportedDocument,
|
|
107293
|
+
document: rawImportedDocument.value,
|
|
107001
107294
|
declarations: context.templateVariableKinds,
|
|
107002
107295
|
variables,
|
|
107003
107296
|
path: imported
|
|
107004
107297
|
})) {
|
|
107005
107298
|
continue;
|
|
107006
107299
|
}
|
|
107007
|
-
const importedDocument =
|
|
107008
|
-
rawImportedDocument,
|
|
107009
|
-
variables,
|
|
107010
|
-
{
|
|
107300
|
+
const importedDocument = {
|
|
107301
|
+
...rawImportedDocument,
|
|
107302
|
+
value: substituteVariables(rawImportedDocument.value, variables, {
|
|
107011
107303
|
importPath
|
|
107012
|
-
}
|
|
107013
|
-
|
|
107304
|
+
})
|
|
107305
|
+
};
|
|
107014
107306
|
merged = mergeAgentDrafts(
|
|
107015
107307
|
merged,
|
|
107016
107308
|
compileAgentDocument2(importedDocument, imported, {
|
|
@@ -107026,7 +107318,7 @@ function compileAgentDocument2(document, path2, context) {
|
|
|
107026
107318
|
}
|
|
107027
107319
|
return mergeAgentDrafts(
|
|
107028
107320
|
merged,
|
|
107029
|
-
parseAgentDraft(
|
|
107321
|
+
parseAgentDraft(sourceDocument, normalizedPath, context.fileIndex)
|
|
107030
107322
|
);
|
|
107031
107323
|
}
|
|
107032
107324
|
var init_agent_authoring = __esm({
|
|
@@ -107304,10 +107596,13 @@ function collectInjectableTemplateReferences(files) {
|
|
|
107304
107596
|
function hasBuiltInDefaultAgentDocument(files) {
|
|
107305
107597
|
return files.some((file2) => {
|
|
107306
107598
|
try {
|
|
107307
|
-
return
|
|
107308
|
-
(
|
|
107599
|
+
return readSourceDocuments(file2).some(
|
|
107600
|
+
({ value }) => isRecord5(value) && value.name === BUILT_IN_DEFAULT_AGENT_NAME
|
|
107309
107601
|
);
|
|
107310
|
-
} catch {
|
|
107602
|
+
} catch (error51) {
|
|
107603
|
+
if (isAuthoredSchemaVersionError(error51)) {
|
|
107604
|
+
throw error51;
|
|
107605
|
+
}
|
|
107311
107606
|
return false;
|
|
107312
107607
|
}
|
|
107313
107608
|
});
|
|
@@ -107315,8 +107610,8 @@ function hasBuiltInDefaultAgentDocument(files) {
|
|
|
107315
107610
|
function templateImportsInFile(file2) {
|
|
107316
107611
|
try {
|
|
107317
107612
|
const specifiers = [];
|
|
107318
|
-
for (const document of
|
|
107319
|
-
if (!
|
|
107613
|
+
for (const { value: document } of readSourceDocuments(file2)) {
|
|
107614
|
+
if (!isRecord5(document)) {
|
|
107320
107615
|
continue;
|
|
107321
107616
|
}
|
|
107322
107617
|
for (const importPath of importPaths2(document)) {
|
|
@@ -107326,7 +107621,10 @@ function templateImportsInFile(file2) {
|
|
|
107326
107621
|
}
|
|
107327
107622
|
}
|
|
107328
107623
|
return specifiers;
|
|
107329
|
-
} catch {
|
|
107624
|
+
} catch (error51) {
|
|
107625
|
+
if (isAuthoredSchemaVersionError(error51)) {
|
|
107626
|
+
throw error51;
|
|
107627
|
+
}
|
|
107330
107628
|
return [];
|
|
107331
107629
|
}
|
|
107332
107630
|
}
|
|
@@ -107336,6 +107634,7 @@ var init_template_injection = __esm({
|
|
|
107336
107634
|
init_default_agent();
|
|
107337
107635
|
init_templates();
|
|
107338
107636
|
init_agent_document_merge();
|
|
107637
|
+
init_schema_version();
|
|
107339
107638
|
init_source();
|
|
107340
107639
|
}
|
|
107341
107640
|
});
|
|
@@ -107344,6 +107643,7 @@ var init_template_injection = __esm({
|
|
|
107344
107643
|
function readProjectApplyDirectorySource(input) {
|
|
107345
107644
|
const resourceRoot = normalizeSourcePath(input.resourceRoot ?? "");
|
|
107346
107645
|
const displayResourceRoot2 = input.displayResourceRoot ?? (resourceRoot || ".auto");
|
|
107646
|
+
assertSupportedSourceSchemaVersions(input.files);
|
|
107347
107647
|
const files = injectManagedTemplateFiles({
|
|
107348
107648
|
files: input.files,
|
|
107349
107649
|
registry: defaultTemplateRegistry
|
|
@@ -107415,7 +107715,7 @@ function readProjectApplyFileSource(input) {
|
|
|
107415
107715
|
}
|
|
107416
107716
|
function readProjectApplyDocumentSourceFile(file2, options = {}) {
|
|
107417
107717
|
const fileIndex = options.fileIndex ?? sourceFileIndex([file2]);
|
|
107418
|
-
const documents =
|
|
107718
|
+
const documents = readSourceDocuments(file2);
|
|
107419
107719
|
if (documents.length === 0) {
|
|
107420
107720
|
throw new AutoValidationDiagnosticError(
|
|
107421
107721
|
`Invalid apply file: ${file2.path} is empty`,
|
|
@@ -107429,7 +107729,9 @@ function readProjectApplyDocumentSourceFile(file2, options = {}) {
|
|
|
107429
107729
|
);
|
|
107430
107730
|
}
|
|
107431
107731
|
if (documents.length === 1) {
|
|
107432
|
-
const system = ProjectApplySystemConfigSchema.safeParse(
|
|
107732
|
+
const system = ProjectApplySystemConfigSchema.safeParse(
|
|
107733
|
+
documents[0]?.value
|
|
107734
|
+
);
|
|
107433
107735
|
if (system.success) {
|
|
107434
107736
|
return ProjectApplyRequestSchema.parse(system.data.spec);
|
|
107435
107737
|
}
|
|
@@ -107466,13 +107768,13 @@ function readProjectConfigResource(files, resourceRoot) {
|
|
|
107466
107768
|
);
|
|
107467
107769
|
}
|
|
107468
107770
|
const file2 = configFiles[0];
|
|
107469
|
-
const documents =
|
|
107771
|
+
const documents = readSourceDocuments(file2);
|
|
107470
107772
|
if (documents.length > 1) {
|
|
107471
107773
|
throw new Error(
|
|
107472
107774
|
`Invalid project config ${file2.path}: expected a single document`
|
|
107473
107775
|
);
|
|
107474
107776
|
}
|
|
107475
|
-
const parsed = ProjectConfigSpecSchema.safeParse(documents[0] ?? {});
|
|
107777
|
+
const parsed = ProjectConfigSpecSchema.safeParse(documents[0]?.value ?? {});
|
|
107476
107778
|
if (!parsed.success) {
|
|
107477
107779
|
throw new AutoValidationDiagnosticError(
|
|
107478
107780
|
`Invalid project config ${file2.path}: ${parsed.error.message}`,
|
|
@@ -107488,6 +107790,20 @@ function readProjectConfigResource(files, resourceRoot) {
|
|
|
107488
107790
|
spec: parsed.data
|
|
107489
107791
|
};
|
|
107490
107792
|
}
|
|
107793
|
+
function assertSupportedSourceSchemaVersions(files) {
|
|
107794
|
+
for (const file2 of files) {
|
|
107795
|
+
if (!/\.(json|ya?ml)$/i.test(normalizeSourcePath(file2.path))) {
|
|
107796
|
+
continue;
|
|
107797
|
+
}
|
|
107798
|
+
try {
|
|
107799
|
+
readSourceDocuments(file2);
|
|
107800
|
+
} catch (error51) {
|
|
107801
|
+
if (isAuthoredSchemaVersionError(error51)) {
|
|
107802
|
+
throw error51;
|
|
107803
|
+
}
|
|
107804
|
+
}
|
|
107805
|
+
}
|
|
107806
|
+
}
|
|
107491
107807
|
function assertNoLegacySessionSourceFiles(files, resourceRoot, displayResourceRoot2) {
|
|
107492
107808
|
const legacyFiles = files.filter(
|
|
107493
107809
|
(file2) => isResourceFileUnderDirectory(
|
|
@@ -107538,7 +107854,7 @@ function assertValidFragmentSourceFiles(files, resourceRoot, fileIndex) {
|
|
|
107538
107854
|
);
|
|
107539
107855
|
for (const file2 of fragments) {
|
|
107540
107856
|
try {
|
|
107541
|
-
const documents =
|
|
107857
|
+
const documents = readSourceDocuments(file2);
|
|
107542
107858
|
if (documents.length !== 1) {
|
|
107543
107859
|
throw new Error(
|
|
107544
107860
|
`Agent authoring file ${file2.path} must contain exactly one document`
|
|
@@ -107551,6 +107867,9 @@ function assertValidFragmentSourceFiles(files, resourceRoot, fileIndex) {
|
|
|
107551
107867
|
variables: /* @__PURE__ */ new Map()
|
|
107552
107868
|
});
|
|
107553
107869
|
} catch (error51) {
|
|
107870
|
+
if (isAuthoredSchemaVersionError(error51) || error51 instanceof AutoValidationDiagnosticError && error51.diagnostic.code === "auto.validation.authoring.unknown_field") {
|
|
107871
|
+
throw error51;
|
|
107872
|
+
}
|
|
107554
107873
|
throw new Error(
|
|
107555
107874
|
`Invalid fragment file ${file2.path}: ${error51 instanceof Error ? error51.message : String(error51)}`
|
|
107556
107875
|
);
|
|
@@ -107570,6 +107889,7 @@ var init_project_apply_files = __esm({
|
|
|
107570
107889
|
init_agent_authoring();
|
|
107571
107890
|
init_apply_result();
|
|
107572
107891
|
init_assets();
|
|
107892
|
+
init_schema_version();
|
|
107573
107893
|
init_source();
|
|
107574
107894
|
init_source_locations();
|
|
107575
107895
|
init_template_injection();
|
|
@@ -130112,7 +130432,7 @@ async function selectRepository(context, github, explicitRepo) {
|
|
|
130112
130432
|
const selection = github.grant.providerResourceSelection;
|
|
130113
130433
|
if (selection.kind === "selected") {
|
|
130114
130434
|
const repos = selection.resources.map(
|
|
130115
|
-
(resource) =>
|
|
130435
|
+
(resource) => isRecord6(resource) && typeof resource.fullName === "string" ? resource.fullName : void 0
|
|
130116
130436
|
).filter(isDefined);
|
|
130117
130437
|
if (repos.length === 1) {
|
|
130118
130438
|
context.writeOutput(`Using GitHub repository ${repos[0]}.`);
|
|
@@ -130442,7 +130762,7 @@ function slackWorkspaceUrl(slack) {
|
|
|
130442
130762
|
function organizationLabel(organization) {
|
|
130443
130763
|
return `${organization.organizationName} (${organization.organizationSlug})`;
|
|
130444
130764
|
}
|
|
130445
|
-
function
|
|
130765
|
+
function isRecord6(value) {
|
|
130446
130766
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
130447
130767
|
}
|
|
130448
130768
|
function isDefined(value) {
|