agent-contracts 0.30.2 → 0.30.4
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/LICENSE +1 -1
- package/README.md +7 -3
- package/cli-contract.yaml +2 -2
- package/dist/cli.js +139 -28
- package/dist/cli.js.map +1 -1
- package/dist/index.js +139 -28
- package/dist/index.js.map +1 -1
- package/dsl_base/agents/dsl-designer.yaml +4 -0
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -53790,33 +53790,7 @@ function buildNavigationIndex(dsl) {
|
|
|
53790
53790
|
};
|
|
53791
53791
|
}
|
|
53792
53792
|
|
|
53793
|
-
// src/renderer/
|
|
53794
|
-
Handlebars.registerHelper("eq", (a3, b3) => a3 === b3);
|
|
53795
|
-
Handlebars.registerHelper("notEmpty", (obj) => {
|
|
53796
|
-
if (!obj || typeof obj !== "object") return false;
|
|
53797
|
-
return Object.keys(obj).length > 0;
|
|
53798
|
-
});
|
|
53799
|
-
Handlebars.registerHelper("inc", (val) => val + 1);
|
|
53800
|
-
Handlebars.registerHelper(
|
|
53801
|
-
"lookupPayloadFields",
|
|
53802
|
-
(schema) => {
|
|
53803
|
-
const effective = resolveAllOf(schema ?? {});
|
|
53804
|
-
const props = effective["properties"];
|
|
53805
|
-
if (!props) return [];
|
|
53806
|
-
const requiredSet = new Set(
|
|
53807
|
-
effective["required"] ?? []
|
|
53808
|
-
);
|
|
53809
|
-
return Object.entries(props).map(([name, sub]) => {
|
|
53810
|
-
const enumVals = sub["enum"];
|
|
53811
|
-
return {
|
|
53812
|
-
name,
|
|
53813
|
-
type: sub["type"] ?? "any",
|
|
53814
|
-
required: requiredSet.has(name),
|
|
53815
|
-
enum: enumVals ? enumVals.join(" | ") : void 0
|
|
53816
|
-
};
|
|
53817
|
-
});
|
|
53818
|
-
}
|
|
53819
|
-
);
|
|
53793
|
+
// src/renderer/serialization.ts
|
|
53820
53794
|
function toYamlLines(obj, indent) {
|
|
53821
53795
|
const pad = " ".repeat(indent);
|
|
53822
53796
|
if (obj === null || obj === void 0) return [`${pad}null`];
|
|
@@ -53883,9 +53857,146 @@ function toYamlLines(obj, indent) {
|
|
|
53883
53857
|
}
|
|
53884
53858
|
return [`${pad}${String(obj)}`];
|
|
53885
53859
|
}
|
|
53886
|
-
|
|
53860
|
+
function toYamlString(obj) {
|
|
53887
53861
|
return toYamlLines(obj, 0).join("\n");
|
|
53862
|
+
}
|
|
53863
|
+
function toJsonString(obj, indent = 2) {
|
|
53864
|
+
return JSON.stringify(obj, null, indent);
|
|
53865
|
+
}
|
|
53866
|
+
function toYamlFrontmatter(obj) {
|
|
53867
|
+
const body = toYamlString(obj);
|
|
53868
|
+
if (!body) return "---\n---\n";
|
|
53869
|
+
return `---
|
|
53870
|
+
${body}
|
|
53871
|
+
---
|
|
53872
|
+
`;
|
|
53873
|
+
}
|
|
53874
|
+
|
|
53875
|
+
// src/renderer/handoff-payload.ts
|
|
53876
|
+
function resolveHandoffPayload(handoffType) {
|
|
53877
|
+
if (!handoffType) return {};
|
|
53878
|
+
if (handoffType.example && typeof handoffType.example === "object" && !Array.isArray(handoffType.example)) {
|
|
53879
|
+
return handoffType.example;
|
|
53880
|
+
}
|
|
53881
|
+
if (handoffType.schema && typeof handoffType.schema === "object") {
|
|
53882
|
+
return exampleFromSchema(handoffType.schema);
|
|
53883
|
+
}
|
|
53884
|
+
return {};
|
|
53885
|
+
}
|
|
53886
|
+
function buildHandoffEnvelope(handoffType, idOverride) {
|
|
53887
|
+
if (!handoffType) return {};
|
|
53888
|
+
const type = idOverride ?? handoffType.id;
|
|
53889
|
+
return {
|
|
53890
|
+
...type ? { type } : {},
|
|
53891
|
+
...handoffType.version !== void 0 ? { version: handoffType.version } : {},
|
|
53892
|
+
payload: resolveHandoffPayload(handoffType)
|
|
53893
|
+
};
|
|
53894
|
+
}
|
|
53895
|
+
function exampleFromSchema(schema) {
|
|
53896
|
+
const effective = resolveAllOf(schema);
|
|
53897
|
+
if (effective["$ref"] && !effective["properties"] && !effective["type"]) {
|
|
53898
|
+
return {};
|
|
53899
|
+
}
|
|
53900
|
+
return exampleFromJsonSchema(effective);
|
|
53901
|
+
}
|
|
53902
|
+
function exampleFromJsonSchema(schema) {
|
|
53903
|
+
const type = schema["type"];
|
|
53904
|
+
if (type === "object" || schema["properties"]) {
|
|
53905
|
+
return exampleFromObjectSchema(schema);
|
|
53906
|
+
}
|
|
53907
|
+
return {};
|
|
53908
|
+
}
|
|
53909
|
+
function exampleFromObjectSchema(schema) {
|
|
53910
|
+
const props = schema["properties"];
|
|
53911
|
+
if (!props) return {};
|
|
53912
|
+
const required = new Set(
|
|
53913
|
+
schema["required"] ?? []
|
|
53914
|
+
);
|
|
53915
|
+
const result = {};
|
|
53916
|
+
for (const [key, propSchema] of Object.entries(props)) {
|
|
53917
|
+
if (!required.has(key)) continue;
|
|
53918
|
+
result[key] = exampleFromPropertySchema(
|
|
53919
|
+
propSchema,
|
|
53920
|
+
key
|
|
53921
|
+
);
|
|
53922
|
+
}
|
|
53923
|
+
return result;
|
|
53924
|
+
}
|
|
53925
|
+
function exampleFromPropertySchema(schema, propName) {
|
|
53926
|
+
const effective = resolveAllOf(schema);
|
|
53927
|
+
if (effective["example"] !== void 0) return effective["example"];
|
|
53928
|
+
if (effective["const"] !== void 0) return effective["const"];
|
|
53929
|
+
const enumVals = effective["enum"];
|
|
53930
|
+
if (enumVals && enumVals.length > 0) return enumVals[0];
|
|
53931
|
+
const type = effective["type"];
|
|
53932
|
+
if (type === "string" || !type && effective["format"]) {
|
|
53933
|
+
return `<${propName}>`;
|
|
53934
|
+
}
|
|
53935
|
+
if (type === "integer") return 0;
|
|
53936
|
+
if (type === "number") return 0;
|
|
53937
|
+
if (type === "boolean") return false;
|
|
53938
|
+
if (type === "array") {
|
|
53939
|
+
const items = effective["items"];
|
|
53940
|
+
if (items && typeof items === "object") {
|
|
53941
|
+
return [exampleFromPropertySchema(items, "item")];
|
|
53942
|
+
}
|
|
53943
|
+
return [];
|
|
53944
|
+
}
|
|
53945
|
+
if (type === "object" || effective["properties"]) {
|
|
53946
|
+
return exampleFromObjectSchema(effective);
|
|
53947
|
+
}
|
|
53948
|
+
return null;
|
|
53949
|
+
}
|
|
53950
|
+
|
|
53951
|
+
// src/renderer/renderer.ts
|
|
53952
|
+
Handlebars.registerHelper("eq", (a3, b3) => a3 === b3);
|
|
53953
|
+
Handlebars.registerHelper("notEmpty", (obj) => {
|
|
53954
|
+
if (!obj || typeof obj !== "object") return false;
|
|
53955
|
+
return Object.keys(obj).length > 0;
|
|
53888
53956
|
});
|
|
53957
|
+
Handlebars.registerHelper("inc", (val) => val + 1);
|
|
53958
|
+
Handlebars.registerHelper(
|
|
53959
|
+
"lookupPayloadFields",
|
|
53960
|
+
(schema) => {
|
|
53961
|
+
const effective = resolveAllOf(schema ?? {});
|
|
53962
|
+
const props = effective["properties"];
|
|
53963
|
+
if (!props) return [];
|
|
53964
|
+
const requiredSet = new Set(
|
|
53965
|
+
effective["required"] ?? []
|
|
53966
|
+
);
|
|
53967
|
+
return Object.entries(props).map(([name, sub]) => {
|
|
53968
|
+
const enumVals = sub["enum"];
|
|
53969
|
+
return {
|
|
53970
|
+
name,
|
|
53971
|
+
type: sub["type"] ?? "any",
|
|
53972
|
+
required: requiredSet.has(name),
|
|
53973
|
+
enum: enumVals ? enumVals.join(" | ") : void 0
|
|
53974
|
+
};
|
|
53975
|
+
});
|
|
53976
|
+
}
|
|
53977
|
+
);
|
|
53978
|
+
Handlebars.registerHelper("yamlBlock", (obj) => {
|
|
53979
|
+
return toYamlString(obj);
|
|
53980
|
+
});
|
|
53981
|
+
Handlebars.registerHelper("jsonBlock", (obj) => {
|
|
53982
|
+
return toJsonString(obj);
|
|
53983
|
+
});
|
|
53984
|
+
Handlebars.registerHelper("yamlFrontmatter", (obj) => {
|
|
53985
|
+
return toYamlFrontmatter(obj);
|
|
53986
|
+
});
|
|
53987
|
+
Handlebars.registerHelper(
|
|
53988
|
+
"handoffPayload",
|
|
53989
|
+
(handoffType) => {
|
|
53990
|
+
return resolveHandoffPayload(handoffType ?? void 0);
|
|
53991
|
+
}
|
|
53992
|
+
);
|
|
53993
|
+
Handlebars.registerHelper(
|
|
53994
|
+
"handoffEnvelope",
|
|
53995
|
+
(handoffType, options) => {
|
|
53996
|
+
const idOverride = typeof options?.hash?.id === "string" ? options.hash.id : void 0;
|
|
53997
|
+
return buildHandoffEnvelope(handoffType ?? void 0, idOverride);
|
|
53998
|
+
}
|
|
53999
|
+
);
|
|
53889
54000
|
Handlebars.registerHelper(
|
|
53890
54001
|
"join",
|
|
53891
54002
|
(arr, separator) => {
|