@vaudience/aigentflow-flow-validator 0.24.0 → 0.25.0
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/PARITY.md +23 -0
- package/dist/cli.js +106 -0
- package/dist/index.cjs +105 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +105 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -457,6 +457,7 @@ var aigentflow_spec_default = {
|
|
|
457
457
|
"ai",
|
|
458
458
|
"aiv",
|
|
459
459
|
"async",
|
|
460
|
+
"atlas",
|
|
460
461
|
"browser",
|
|
461
462
|
"chart",
|
|
462
463
|
"db",
|
|
@@ -986,6 +987,48 @@ var aigentflow_spec_default = {
|
|
|
986
987
|
"utils/parse-date"
|
|
987
988
|
]
|
|
988
989
|
},
|
|
990
|
+
atlasExecutor: {
|
|
991
|
+
scheme: "atlas",
|
|
992
|
+
providerAgent: "agent",
|
|
993
|
+
providerCapability: "capability",
|
|
994
|
+
agentResource: "run",
|
|
995
|
+
capabilityRefPattern: "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$",
|
|
996
|
+
operationUnknown: {
|
|
997
|
+
code: "atlas_operation_unknown",
|
|
998
|
+
messageFormat: "step %s uses %s, which is not an Atlas operation. The providers are agent (resource run) and capability (resource: a capability reference).",
|
|
999
|
+
suggestion: "Use atlas://agent/run or atlas://capability/<capability-ref>."
|
|
1000
|
+
},
|
|
1001
|
+
agentMissing: {
|
|
1002
|
+
code: "atlas_agent_missing",
|
|
1003
|
+
messageFormat: "step %s runs an Atlas agent but query.agent is missing or empty.",
|
|
1004
|
+
suggestion: "Set query.agent to the agent to run, written out as a literal such as @acme/reporter."
|
|
1005
|
+
},
|
|
1006
|
+
agentNotLiteral: {
|
|
1007
|
+
code: "atlas_agent_not_literal",
|
|
1008
|
+
messageFormat: "step %s computes query.agent from a template. The agent must be a fixed literal, never derived from input.",
|
|
1009
|
+
suggestion: "Write the agent out as a literal such as @acme/reporter. Data may go into the prompt or the inputs instead."
|
|
1010
|
+
},
|
|
1011
|
+
capabilitiesNotLiteral: {
|
|
1012
|
+
code: "atlas_capabilities_not_literal",
|
|
1013
|
+
messageFormat: "step %s computes an entry of query.capabilities from a template. Capabilities must be fixed literals, never derived from input.",
|
|
1014
|
+
suggestion: "Write each capability out as a literal. Data may go into the prompt or the inputs instead."
|
|
1015
|
+
},
|
|
1016
|
+
promptMissing: {
|
|
1017
|
+
code: "atlas_prompt_missing",
|
|
1018
|
+
messageFormat: "step %s runs an Atlas agent with neither query.prompt nor query.prompt_template.",
|
|
1019
|
+
suggestion: "Set exactly one of query.prompt or query.prompt_template."
|
|
1020
|
+
},
|
|
1021
|
+
promptBoth: {
|
|
1022
|
+
code: "atlas_prompt_both",
|
|
1023
|
+
messageFormat: "step %s sets both query.prompt and query.prompt_template.",
|
|
1024
|
+
suggestion: "Keep exactly one of query.prompt or query.prompt_template."
|
|
1025
|
+
},
|
|
1026
|
+
capabilityRefInvalid: {
|
|
1027
|
+
code: "atlas_capability_ref_invalid",
|
|
1028
|
+
messageFormat: "step %s uses atlas://capability/%s, which is not a valid capability reference.",
|
|
1029
|
+
suggestion: "A capability reference starts with a letter or digit and continues with letters, digits and _ . : - up to 128 characters in all."
|
|
1030
|
+
}
|
|
1031
|
+
},
|
|
989
1032
|
flowDataReservedKeys: {
|
|
990
1033
|
code: "flow_data_key_reserved",
|
|
991
1034
|
fieldFormat: "data.%s",
|
|
@@ -2028,6 +2071,21 @@ var FUNCTION_OPERATIONS = {
|
|
|
2028
2071
|
operations: new Set(aigentflow_spec_default.functionOperations.operations),
|
|
2029
2072
|
sorted: aigentflow_spec_default.functionOperations.operations
|
|
2030
2073
|
};
|
|
2074
|
+
var atlas = aigentflow_spec_default.atlasExecutor;
|
|
2075
|
+
var ATLAS_EXECUTOR = {
|
|
2076
|
+
scheme: atlas.scheme,
|
|
2077
|
+
providerAgent: atlas.providerAgent,
|
|
2078
|
+
providerCapability: atlas.providerCapability,
|
|
2079
|
+
agentResource: atlas.agentResource,
|
|
2080
|
+
capabilityRefPattern: new RegExp(atlas.capabilityRefPattern),
|
|
2081
|
+
operationUnknown: atlas.operationUnknown,
|
|
2082
|
+
agentMissing: atlas.agentMissing,
|
|
2083
|
+
agentNotLiteral: atlas.agentNotLiteral,
|
|
2084
|
+
capabilitiesNotLiteral: atlas.capabilitiesNotLiteral,
|
|
2085
|
+
promptMissing: atlas.promptMissing,
|
|
2086
|
+
promptBoth: atlas.promptBoth,
|
|
2087
|
+
capabilityRefInvalid: atlas.capabilityRefInvalid
|
|
2088
|
+
};
|
|
2031
2089
|
|
|
2032
2090
|
// src/validators/executors.ts
|
|
2033
2091
|
var SCHEME_SEPARATOR = "://";
|
|
@@ -2091,6 +2149,51 @@ function checkExecutor(executor, field, stepID, issues) {
|
|
|
2091
2149
|
}
|
|
2092
2150
|
checkFunctionOperation(executor, field, stepID, templated, issues);
|
|
2093
2151
|
}
|
|
2152
|
+
function checkAtlasStep(executor, query, stepField, stepID, issues) {
|
|
2153
|
+
if (executor.includes(TEMPLATE_ACTION_OPEN)) return;
|
|
2154
|
+
const m = EXECUTOR_URL_PATTERN.exec(executor);
|
|
2155
|
+
if (m === null || m[1] !== ATLAS_EXECUTOR.scheme) return;
|
|
2156
|
+
const provider = m[2];
|
|
2157
|
+
const resource = m[3];
|
|
2158
|
+
const quoted = JSON.stringify(stepID);
|
|
2159
|
+
const report = (rule, ...args) => {
|
|
2160
|
+
let message = rule.messageFormat.replace("%s", () => quoted);
|
|
2161
|
+
for (const a of args) message = message.replace("%s", () => a);
|
|
2162
|
+
issues.error({
|
|
2163
|
+
field: stepField,
|
|
2164
|
+
message,
|
|
2165
|
+
code: rule.code,
|
|
2166
|
+
stepId: stepID,
|
|
2167
|
+
suggestion: rule.suggestion
|
|
2168
|
+
});
|
|
2169
|
+
};
|
|
2170
|
+
const q2 = isRecord(query) ? query : {};
|
|
2171
|
+
if (provider === ATLAS_EXECUTOR.providerCapability) {
|
|
2172
|
+
if (!ATLAS_EXECUTOR.capabilityRefPattern.test(resource)) {
|
|
2173
|
+
report(ATLAS_EXECUTOR.capabilityRefInvalid, resource);
|
|
2174
|
+
}
|
|
2175
|
+
} else if (provider === ATLAS_EXECUTOR.providerAgent && resource === ATLAS_EXECUTOR.agentResource) {
|
|
2176
|
+
const agent = q2.agent;
|
|
2177
|
+
if (typeof agent !== "string" || agent === "") {
|
|
2178
|
+
report(ATLAS_EXECUTOR.agentMissing);
|
|
2179
|
+
} else if (agent.includes(TEMPLATE_ACTION_OPEN)) {
|
|
2180
|
+
report(ATLAS_EXECUTOR.agentNotLiteral);
|
|
2181
|
+
}
|
|
2182
|
+
const prompt = q2.prompt;
|
|
2183
|
+
const promptTemplate = q2.prompt_template;
|
|
2184
|
+
const hasPrompt = prompt !== void 0 && prompt !== null && prompt !== "";
|
|
2185
|
+
const hasTemplate = promptTemplate !== void 0 && promptTemplate !== null && promptTemplate !== "";
|
|
2186
|
+
if (!hasPrompt && !hasTemplate) report(ATLAS_EXECUTOR.promptMissing);
|
|
2187
|
+
else if (hasPrompt && hasTemplate) report(ATLAS_EXECUTOR.promptBoth);
|
|
2188
|
+
} else {
|
|
2189
|
+
report(ATLAS_EXECUTOR.operationUnknown, executor);
|
|
2190
|
+
return;
|
|
2191
|
+
}
|
|
2192
|
+
const caps = q2.capabilities;
|
|
2193
|
+
if (Array.isArray(caps) && caps.some((c) => typeof c === "string" && c.includes(TEMPLATE_ACTION_OPEN))) {
|
|
2194
|
+
report(ATLAS_EXECUTOR.capabilitiesNotLiteral);
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2094
2197
|
function checkFunctionOperation(executor, field, stepID, templated, issues) {
|
|
2095
2198
|
if (templated) return;
|
|
2096
2199
|
const m = EXECUTOR_URL_PATTERN.exec(executor);
|
|
@@ -2115,6 +2218,7 @@ function validateExecutors(flow, issues) {
|
|
|
2115
2218
|
const executor = issues.stringOf(step, "executor", `steps.${stepID}`);
|
|
2116
2219
|
if (executor !== null && executor !== "") {
|
|
2117
2220
|
checkExecutor(executor, `steps.${stepID}.executor`, stepID, issues);
|
|
2221
|
+
checkAtlasStep(executor, step.query, `steps.${stepID}`, stepID, issues);
|
|
2118
2222
|
}
|
|
2119
2223
|
const loop = step.loop;
|
|
2120
2224
|
if (isRecord(loop) && Array.isArray(loop.steps)) {
|
|
@@ -2131,6 +2235,7 @@ function validateExecutors(flow, issues) {
|
|
|
2131
2235
|
`${stepID}.${subID}`,
|
|
2132
2236
|
issues
|
|
2133
2237
|
);
|
|
2238
|
+
checkAtlasStep(subExecutor, subStep.query, subPath, `${stepID}.${subID}`, issues);
|
|
2134
2239
|
}
|
|
2135
2240
|
});
|
|
2136
2241
|
}
|