@semacode/cli 2.2.0 → 2.3.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/README.md +91 -4
- package/dist/agentContext.d.ts +1 -1
- package/dist/agentContextPack.js +6 -1
- package/dist/agentContextTipos.d.ts +4 -2
- package/dist/agentContextTipos.js +7 -0
- package/dist/agentEntryPoints.js +70 -19
- package/dist/comandos.js +4 -0
- package/dist/discovery/catalog.d.ts +11 -0
- package/dist/discovery/catalog.js +521 -0
- package/dist/discovery/command.d.ts +11 -0
- package/dist/discovery/command.js +226 -0
- package/dist/discovery/index.d.ts +5 -0
- package/dist/discovery/index.js +8 -0
- package/dist/discovery/ranker.d.ts +3 -0
- package/dist/discovery/ranker.js +310 -0
- package/dist/discovery/redaction.d.ts +2 -0
- package/dist/discovery/redaction.js +21 -0
- package/dist/discovery/render.d.ts +2 -0
- package/dist/discovery/render.js +100 -0
- package/dist/discovery/types.d.ts +119 -0
- package/dist/discovery/types.js +13 -0
- package/dist/exemplosOficiais.js +29 -8
- package/dist/iaPrompts.d.ts +1 -1
- package/dist/iaPrompts.js +3 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +23 -5
- package/dist/index.part01.d.ts +1 -1
- package/dist/index.part01.js +39 -4
- package/dist/index.part06.js +3 -0
- package/dist/initTemplatesBase.js +3 -2
- package/dist/profileArtefatoValidadores.d.ts +3 -2
- package/dist/profileArtefatoValidadores.js +81 -0
- package/dist/profileAuthorTipos.d.ts +4 -3
- package/dist/profileCatalogo.d.ts +5 -5
- package/dist/profileCatalogo.js +30 -0
- package/dist/profileCommand.d.ts +8 -2
- package/dist/profileCommand.js +15 -5
- package/dist/profileRegras.d.ts +5 -5
- package/dist/profileRegras.js +13 -1
- package/dist/profileRulePacks.js +68 -0
- package/dist/sistemasInterativos/adapterProtocol.d.ts +3 -0
- package/dist/sistemasInterativos/adapterProtocol.js +240 -0
- package/dist/sistemasInterativos/advancedCatalog.d.ts +5 -0
- package/dist/sistemasInterativos/advancedCatalog.js +442 -0
- package/dist/sistemasInterativos/autonomy.d.ts +230 -0
- package/dist/sistemasInterativos/autonomy.js +753 -0
- package/dist/sistemasInterativos/canonical.d.ts +3 -0
- package/dist/sistemasInterativos/canonical.js +43 -0
- package/dist/sistemasInterativos/catalog.d.ts +116 -0
- package/dist/sistemasInterativos/catalog.js +543 -0
- package/dist/sistemasInterativos/command.d.ts +7 -0
- package/dist/sistemasInterativos/command.js +311 -0
- package/dist/sistemasInterativos/controlRun.d.ts +56 -0
- package/dist/sistemasInterativos/controlRun.js +391 -0
- package/dist/sistemasInterativos/evidence.d.ts +5 -0
- package/dist/sistemasInterativos/evidence.js +306 -0
- package/dist/sistemasInterativos/experienceIr.d.ts +12 -0
- package/dist/sistemasInterativos/experienceIr.js +895 -0
- package/dist/sistemasInterativos/experienceIrSemantics.d.ts +30 -0
- package/dist/sistemasInterativos/experienceIrSemantics.js +368 -0
- package/dist/sistemasInterativos/experienceIrTypes.d.ts +370 -0
- package/dist/sistemasInterativos/experienceIrTypes.js +5 -0
- package/dist/sistemasInterativos/extensionCommand.d.ts +391 -0
- package/dist/sistemasInterativos/extensionCommand.js +383 -0
- package/dist/sistemasInterativos/index.d.ts +19 -0
- package/dist/sistemasInterativos/index.js +22 -0
- package/dist/sistemasInterativos/operations.d.ts +40 -0
- package/dist/sistemasInterativos/operations.js +1167 -0
- package/dist/sistemasInterativos/operationsTypes.d.ts +297 -0
- package/dist/sistemasInterativos/operationsTypes.js +11 -0
- package/dist/sistemasInterativos/planner.d.ts +2 -0
- package/dist/sistemasInterativos/planner.js +159 -0
- package/dist/sistemasInterativos/portability.d.ts +164 -0
- package/dist/sistemasInterativos/portability.js +539 -0
- package/dist/sistemasInterativos/render.d.ts +3 -0
- package/dist/sistemasInterativos/render.js +179 -0
- package/dist/sistemasInterativos/temporal.d.ts +183 -0
- package/dist/sistemasInterativos/temporal.js +543 -0
- package/dist/sistemasInterativos/types.d.ts +215 -0
- package/dist/sistemasInterativos/types.js +4 -0
- package/dist/sistemasInterativos/validator.d.ts +2 -0
- package/dist/sistemasInterativos/validator.js +305 -0
- package/docs/README.md +6 -0
- package/docs/ai-integration.md +7 -1
- package/docs/ai-workflow.md +5 -4
- package/docs/commands.md +43 -1
- package/docs/descoberta-capacidades.md +106 -0
- package/docs/documentation.md +11 -2
- package/docs/profiles.md +11 -2
- package/docs/sistemas-interativos.md +381 -0
- package/docs/testing.md +11 -2
- package/exemplos/profile_simulation.sema +211 -0
- package/exemplos/sistemas-interativos/README.md +100 -0
- package/exemplos/sistemas-interativos/advanced/acceptance-context-evaluate-valid.json +5 -0
- package/exemplos/sistemas-interativos/advanced/acceptance-lock-valid.json +16 -0
- package/exemplos/sistemas-interativos/advanced/asset-provenance-valid.json +32 -0
- package/exemplos/sistemas-interativos/advanced/autonomy-repair-valid.json +93 -0
- package/exemplos/sistemas-interativos/advanced/control-run-definition-valid.json +78 -0
- package/exemplos/sistemas-interativos/advanced/control-run-valid.json +27 -0
- package/exemplos/sistemas-interativos/advanced/distributed-workers-valid.json +79 -0
- package/exemplos/sistemas-interativos/advanced/editor-state-valid.json +42 -0
- package/exemplos/sistemas-interativos/advanced/engine-snapshot-after-valid.json +32 -0
- package/exemplos/sistemas-interativos/advanced/engine-snapshot-before-valid.json +23 -0
- package/exemplos/sistemas-interativos/advanced/job-orchestration-valid.json +39 -0
- package/exemplos/sistemas-interativos/advanced/multimodal-evidence-valid.json +46 -0
- package/exemplos/sistemas-interativos/advanced/multiplayer-authority-valid.json +39 -0
- package/exemplos/sistemas-interativos/advanced/playtest-fuzz-valid.json +37 -0
- package/exemplos/sistemas-interativos/advanced/portability-valid.json +104 -0
- package/exemplos/sistemas-interativos/advanced/temporal-evidence-valid.json +27 -0
- package/exemplos/sistemas-interativos/advanced/temporal-valid.json +118 -0
- package/exemplos/sistemas-interativos/experience-ir-valid.json +459 -0
- package/exemplos/sistemas-interativos/game-2d.json +83 -0
- package/exemplos/sistemas-interativos/game-3d-human.json +81 -0
- package/exemplos/sistemas-interativos/game-pixel-16-bit.json +97 -0
- package/exemplos/sistemas-interativos/game-pixel-8-bit.json +94 -0
- package/exemplos/sistemas-interativos/game-xr-human.json +80 -0
- package/exemplos/sistemas-interativos/hybrid-2-5d.json +108 -0
- package/exemplos/sistemas-interativos/protocol-mutating-rollback-valid.json +75 -0
- package/exemplos/sistemas-interativos/protocol-read-only-valid.json +58 -0
- package/exemplos/sistemas-interativos/simulation-2d-controlled.json +97 -0
- package/exemplos/sistemas-interativos/simulation-3d-calibrated-autonomous.json +141 -0
- package/exemplos/sistemas-interativos/simulation-headless-autonomous-batch.json +112 -0
- package/exemplos/sistemas-interativos/simulation-pixel-16-bit.json +103 -0
- package/exemplos/sistemas-interativos/simulation-text-controlled.json +95 -0
- package/node_modules/@sema/gerador-lua/dist/index.js +31 -2
- package/node_modules/@sema/gerador-lua/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
// SEMA-GOVERNED: sema.produto.sistemas_interativos.cli
|
|
2
|
+
// Descricao: handler local read-only para catalogar, validar, planejar e verificar evidencias.
|
|
3
|
+
import { readFile } from "node:fs/promises";
|
|
4
|
+
import { validarProtocoloAdapterSistemaInterativo } from "./adapterProtocol.js";
|
|
5
|
+
import { CATALOGO_ADAPTADORES_INTERATIVOS, CATALOGO_CAPABILITIES_INTERATIVAS, CATALOGO_PIPELINES_INTERATIVOS, MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS, SCHEMA_DEFINICAO_SISTEMA_INTERATIVO, listarAdaptadoresSistemasInterativos, } from "./catalog.js";
|
|
6
|
+
import { derivarEstadoSistemaInterativo, validarBundleEvidenciasSistemaInterativo } from "./evidence.js";
|
|
7
|
+
import { CONTROL_RUN_SCHEMA_VERSION, validarControlRunInterativo, } from "./controlRun.js";
|
|
8
|
+
import { SCHEMA_EXTENSOES_CLI_INTERATIVAS, executarExtensaoCliInterativa, } from "./extensionCommand.js";
|
|
9
|
+
import { planejarSistemaInterativo } from "./planner.js";
|
|
10
|
+
import { renderizarResultadoSistemasInterativos } from "./render.js";
|
|
11
|
+
import { validarDefinicaoSistemaInterativo } from "./validator.js";
|
|
12
|
+
const ALIASES_SUBCOMANDO = Object.freeze({
|
|
13
|
+
capabilities: "capabilities",
|
|
14
|
+
capacidades: "capabilities",
|
|
15
|
+
schema: "schema",
|
|
16
|
+
esquema: "schema",
|
|
17
|
+
pipelines: "pipelines",
|
|
18
|
+
adapters: "adapters",
|
|
19
|
+
adaptadores: "adapters",
|
|
20
|
+
validar: "validar",
|
|
21
|
+
planejar: "planejar",
|
|
22
|
+
"validar-evidencias": "validar-evidencias",
|
|
23
|
+
status: "status",
|
|
24
|
+
"validar-protocolo": "validar-protocolo",
|
|
25
|
+
"validar-control-run": "validar-control-run",
|
|
26
|
+
});
|
|
27
|
+
const FILTROS_PIPELINE = Object.freeze({
|
|
28
|
+
"--kind": "kind",
|
|
29
|
+
"--spatial-model": "spatialModel",
|
|
30
|
+
"--render-mode": "renderMode",
|
|
31
|
+
"--visual-profile": "visualProfile",
|
|
32
|
+
"--control-mode": "controlMode",
|
|
33
|
+
"--fidelity": "fidelity",
|
|
34
|
+
});
|
|
35
|
+
const ESPECIFICACOES = Object.freeze({
|
|
36
|
+
capabilities: { opcoes: {}, flags: ["--json"], posicionais: 0 },
|
|
37
|
+
schema: { opcoes: {}, flags: ["--json"], posicionais: 0 },
|
|
38
|
+
pipelines: { opcoes: FILTROS_PIPELINE, flags: ["--json"], posicionais: 0 },
|
|
39
|
+
adapters: {
|
|
40
|
+
opcoes: {
|
|
41
|
+
...FILTROS_PIPELINE,
|
|
42
|
+
"--role": "role",
|
|
43
|
+
"--time-model": "timeModel",
|
|
44
|
+
},
|
|
45
|
+
flags: ["--json"],
|
|
46
|
+
posicionais: 0,
|
|
47
|
+
},
|
|
48
|
+
validar: { opcoes: {}, flags: ["--json"], posicionais: 1 },
|
|
49
|
+
planejar: { opcoes: {}, flags: ["--json"], posicionais: 1 },
|
|
50
|
+
"validar-evidencias": {
|
|
51
|
+
opcoes: {
|
|
52
|
+
"--plano-arquivo": "planFile",
|
|
53
|
+
"--bundle-arquivo": "bundleFile",
|
|
54
|
+
"--evidencias-arquivo": "bundleFile",
|
|
55
|
+
},
|
|
56
|
+
flags: ["--json"],
|
|
57
|
+
posicionais: 1,
|
|
58
|
+
},
|
|
59
|
+
status: {
|
|
60
|
+
opcoes: {
|
|
61
|
+
"--plano-arquivo": "planFile",
|
|
62
|
+
"--bundle-arquivo": "bundleFile",
|
|
63
|
+
"--evidencias-arquivo": "bundleFile",
|
|
64
|
+
},
|
|
65
|
+
flags: ["--json"],
|
|
66
|
+
posicionais: 1,
|
|
67
|
+
},
|
|
68
|
+
"validar-protocolo": { opcoes: {}, flags: ["--json"], posicionais: 1 },
|
|
69
|
+
"validar-control-run": {
|
|
70
|
+
opcoes: {
|
|
71
|
+
"--definition-arquivo": "definitionFile",
|
|
72
|
+
"--plano-arquivo": "planFile",
|
|
73
|
+
"--contrato-arquivo": "contractFile",
|
|
74
|
+
"--entrada-arquivo": "inputFile",
|
|
75
|
+
"--entrada-auxiliar-arquivo": "secondaryInputFile",
|
|
76
|
+
"--evidencia-arquivo": "evidenceFile",
|
|
77
|
+
"--resultado-arquivo": "resultFile",
|
|
78
|
+
},
|
|
79
|
+
flags: ["--json"],
|
|
80
|
+
posicionais: 1,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
const VOCABULARIOS_FILTRO = Object.freeze({
|
|
84
|
+
kind: MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.kinds,
|
|
85
|
+
spatialModel: MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.spatialModels,
|
|
86
|
+
renderMode: MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.renderModes,
|
|
87
|
+
visualProfile: MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.visualProfiles,
|
|
88
|
+
controlMode: MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.controlModes,
|
|
89
|
+
fidelity: MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.fidelities,
|
|
90
|
+
role: MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.adapterRoles,
|
|
91
|
+
timeModel: MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS.timeModels,
|
|
92
|
+
});
|
|
93
|
+
function parsearArgumentos(args) {
|
|
94
|
+
const primeiro = args[0];
|
|
95
|
+
const usaPadrao = primeiro === undefined || primeiro.startsWith("--");
|
|
96
|
+
const nomeBruto = usaPadrao ? "capabilities" : primeiro.toLowerCase().replace(/_/g, "-");
|
|
97
|
+
const subcomando = ALIASES_SUBCOMANDO[nomeBruto];
|
|
98
|
+
if (!subcomando)
|
|
99
|
+
return { valido: false, subcomando: "desconhecido", errorCode: "INTERATIVO_SUBCOMANDO_DESCONHECIDO" };
|
|
100
|
+
const especificacao = ESPECIFICACOES[subcomando];
|
|
101
|
+
const tokens = usaPadrao ? args : args.slice(1);
|
|
102
|
+
const posicionais = [];
|
|
103
|
+
const opcoes = {};
|
|
104
|
+
const flags = new Set();
|
|
105
|
+
for (let indice = 0; indice < tokens.length; indice += 1) {
|
|
106
|
+
const token = tokens[indice];
|
|
107
|
+
if (!token.startsWith("--")) {
|
|
108
|
+
posicionais.push(token);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (especificacao.flags.includes(token)) {
|
|
112
|
+
if (flags.has(token))
|
|
113
|
+
return { valido: false, subcomando, errorCode: "INTERATIVO_ARGUMENTOS_INVALIDOS" };
|
|
114
|
+
flags.add(token);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const chave = especificacao.opcoes[token];
|
|
118
|
+
if (!chave || opcoes[chave] !== undefined) {
|
|
119
|
+
return { valido: false, subcomando, errorCode: "INTERATIVO_ARGUMENTOS_INVALIDOS" };
|
|
120
|
+
}
|
|
121
|
+
const valor = tokens[indice + 1];
|
|
122
|
+
if (valor === undefined || valor.startsWith("--")) {
|
|
123
|
+
return { valido: false, subcomando, errorCode: "INTERATIVO_ARGUMENTOS_INVALIDOS" };
|
|
124
|
+
}
|
|
125
|
+
opcoes[chave] = valor;
|
|
126
|
+
indice += 1;
|
|
127
|
+
}
|
|
128
|
+
if (posicionais.length !== especificacao.posicionais) {
|
|
129
|
+
return { valido: false, subcomando, errorCode: "INTERATIVO_ARGUMENTOS_INVALIDOS" };
|
|
130
|
+
}
|
|
131
|
+
for (const [chave, valor] of Object.entries(opcoes)) {
|
|
132
|
+
const vocabulario = VOCABULARIOS_FILTRO[chave];
|
|
133
|
+
if (vocabulario && !vocabulario.includes(valor)) {
|
|
134
|
+
return { valido: false, subcomando, errorCode: "INTERATIVO_FILTRO_INVALIDO" };
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if ((subcomando === "validar-evidencias" || subcomando === "status") && !opcoes.bundleFile) {
|
|
138
|
+
return { valido: false, subcomando, errorCode: "INTERATIVO_ARGUMENTOS_INVALIDOS" };
|
|
139
|
+
}
|
|
140
|
+
if (subcomando === "validar-control-run" && [
|
|
141
|
+
"definitionFile", "planFile", "contractFile", "inputFile", "evidenceFile", "resultFile",
|
|
142
|
+
].some((chave) => opcoes[chave] === undefined)) {
|
|
143
|
+
return { valido: false, subcomando, errorCode: "INTERATIVO_ARGUMENTOS_INVALIDOS" };
|
|
144
|
+
}
|
|
145
|
+
return { valido: true, argumentos: { subcomando, posicionais, opcoes } };
|
|
146
|
+
}
|
|
147
|
+
async function lerJson(arquivo) {
|
|
148
|
+
return JSON.parse(await readFile(arquivo, "utf8"));
|
|
149
|
+
}
|
|
150
|
+
function basePayload(comando, sucesso) {
|
|
151
|
+
return {
|
|
152
|
+
sucesso,
|
|
153
|
+
comando,
|
|
154
|
+
readOnly: true,
|
|
155
|
+
executed: false,
|
|
156
|
+
workspaceMutated: false,
|
|
157
|
+
authoritative: false,
|
|
158
|
+
externalExecutionRequired: true,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function erro(comando, errorCode) {
|
|
162
|
+
return { exitCode: 1, payload: { ...basePayload(comando, false), errorCode } };
|
|
163
|
+
}
|
|
164
|
+
function filtrosAdapters(opcoes) {
|
|
165
|
+
return {
|
|
166
|
+
kind: opcoes.kind,
|
|
167
|
+
spatialModel: opcoes.spatialModel,
|
|
168
|
+
renderMode: opcoes.renderMode,
|
|
169
|
+
visualProfile: opcoes.visualProfile,
|
|
170
|
+
role: opcoes.role,
|
|
171
|
+
controlMode: opcoes.controlMode,
|
|
172
|
+
timeModel: opcoes.timeModel,
|
|
173
|
+
fidelity: opcoes.fidelity,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function limparIndefinidos(entrada) {
|
|
177
|
+
return Object.fromEntries(Object.entries(entrada).filter(([, valor]) => valor !== undefined));
|
|
178
|
+
}
|
|
179
|
+
export async function executarComandoSistemasInterativos(args) {
|
|
180
|
+
const extensao = await executarExtensaoCliInterativa(args);
|
|
181
|
+
if (extensao !== null)
|
|
182
|
+
return extensao;
|
|
183
|
+
const parse = parsearArgumentos(args);
|
|
184
|
+
if (!parse.valido)
|
|
185
|
+
return erro(parse.subcomando, parse.errorCode);
|
|
186
|
+
const { subcomando, posicionais, opcoes } = parse.argumentos;
|
|
187
|
+
try {
|
|
188
|
+
if (subcomando === "capabilities") {
|
|
189
|
+
return {
|
|
190
|
+
exitCode: 0,
|
|
191
|
+
payload: {
|
|
192
|
+
...basePayload("capabilities", true),
|
|
193
|
+
matrix: MATRIZ_DOMINIO_SISTEMAS_INTERATIVOS,
|
|
194
|
+
capabilities: CATALOGO_CAPABILITIES_INTERATIVAS,
|
|
195
|
+
pipelineIds: CATALOGO_PIPELINES_INTERATIVOS.map((item) => item.pipelineId),
|
|
196
|
+
adapterIds: CATALOGO_ADAPTADORES_INTERATIVOS.map((item) => item.adapterId),
|
|
197
|
+
extensionCommands: Object.keys(SCHEMA_EXTENSOES_CLI_INTERATIVAS.commands),
|
|
198
|
+
extensionSchemaVersion: SCHEMA_EXTENSOES_CLI_INTERATIVAS.schemaVersion,
|
|
199
|
+
runner: "external",
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
if (subcomando === "schema") {
|
|
204
|
+
return {
|
|
205
|
+
exitCode: 0,
|
|
206
|
+
payload: {
|
|
207
|
+
...basePayload("schema", true),
|
|
208
|
+
...SCHEMA_DEFINICAO_SISTEMA_INTERATIVO,
|
|
209
|
+
interactiveExtensions: SCHEMA_EXTENSOES_CLI_INTERATIVAS,
|
|
210
|
+
controlRun: {
|
|
211
|
+
schemaVersion: CONTROL_RUN_SCHEMA_VERSION,
|
|
212
|
+
command: "sema interativo validar-control-run <control-run.json> --definition-arquivo <definition.json> --plano-arquivo <plan.json> --contrato-arquivo <validation-contract.json> --entrada-arquivo <input.json> [--entrada-auxiliar-arquivo <supporting-input.json>] --evidencia-arquivo <evidence.json> --resultado-arquivo <result.json> --json",
|
|
213
|
+
requiredTopLevelFields: [
|
|
214
|
+
"schemaVersion", "runId", "systemId", "pipelineId", "validatorCommand",
|
|
215
|
+
"definitionDigest", "planDigest", "pipelineContractDigest", "validationContractDigest",
|
|
216
|
+
"producerId", "producerVersion", "producerConfigurationDigest",
|
|
217
|
+
"verifierId", "verifierVersion", "verifierConfigurationDigest",
|
|
218
|
+
"inputSchemaKeys", "inputDigests", "evidenceDigest", "resultDigest",
|
|
219
|
+
],
|
|
220
|
+
readOnly: true,
|
|
221
|
+
executed: false,
|
|
222
|
+
authoritative: false,
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
if (subcomando === "pipelines") {
|
|
228
|
+
const pipelines = CATALOGO_PIPELINES_INTERATIVOS.filter((item) => ((opcoes.kind === undefined || item.kinds.includes(opcoes.kind))
|
|
229
|
+
&& (opcoes.spatialModel === undefined || item.spatialModels.includes(opcoes.spatialModel))
|
|
230
|
+
&& (opcoes.renderMode === undefined || item.renderModes.includes(opcoes.renderMode))
|
|
231
|
+
&& (opcoes.visualProfile === undefined || item.visualProfiles.includes(opcoes.visualProfile))
|
|
232
|
+
&& (opcoes.controlMode === undefined || item.controlModes.includes(opcoes.controlMode))
|
|
233
|
+
&& (opcoes.fidelity === undefined || item.fidelities.includes(opcoes.fidelity))));
|
|
234
|
+
return { exitCode: 0, payload: { ...basePayload("pipelines", true), pipelines } };
|
|
235
|
+
}
|
|
236
|
+
if (subcomando === "adapters") {
|
|
237
|
+
const filtros = limparIndefinidos(filtrosAdapters(opcoes));
|
|
238
|
+
const resultado = listarAdaptadoresSistemasInterativos(filtros);
|
|
239
|
+
return { exitCode: 0, payload: { ...basePayload("adapters", true), ...resultado } };
|
|
240
|
+
}
|
|
241
|
+
if (subcomando === "validar") {
|
|
242
|
+
const definicao = await lerJson(posicionais[0]);
|
|
243
|
+
const resultado = validarDefinicaoSistemaInterativo(definicao);
|
|
244
|
+
return { exitCode: resultado.valida ? 0 : 1, payload: { ...basePayload("validar", resultado.valida), ...resultado } };
|
|
245
|
+
}
|
|
246
|
+
if (subcomando === "planejar") {
|
|
247
|
+
const definicao = await lerJson(posicionais[0]);
|
|
248
|
+
const resultado = planejarSistemaInterativo(definicao);
|
|
249
|
+
const sucesso = resultado.bloqueios.length === 0;
|
|
250
|
+
return { exitCode: sucesso ? 0 : 1, payload: { ...basePayload("planejar", sucesso), ...resultado } };
|
|
251
|
+
}
|
|
252
|
+
if (subcomando === "validar-evidencias" || subcomando === "status") {
|
|
253
|
+
const definicao = await lerJson(posicionais[0]);
|
|
254
|
+
const [plano, bundle] = await Promise.all([
|
|
255
|
+
opcoes.planFile === undefined
|
|
256
|
+
? Promise.resolve(planejarSistemaInterativo(definicao).plano)
|
|
257
|
+
: lerJson(opcoes.planFile),
|
|
258
|
+
lerJson(opcoes.bundleFile),
|
|
259
|
+
]);
|
|
260
|
+
if (subcomando === "validar-evidencias") {
|
|
261
|
+
const resultado = validarBundleEvidenciasSistemaInterativo(definicao, plano, bundle);
|
|
262
|
+
return { exitCode: resultado.valido ? 0 : 1, payload: { ...basePayload("validar-evidencias", resultado.valido), ...resultado } };
|
|
263
|
+
}
|
|
264
|
+
const estado = derivarEstadoSistemaInterativo(definicao, plano, bundle);
|
|
265
|
+
const sucesso = estado.bloqueios.length === 0;
|
|
266
|
+
return { exitCode: sucesso ? 0 : 1, payload: { ...basePayload("status", sucesso), estado } };
|
|
267
|
+
}
|
|
268
|
+
if (subcomando === "validar-control-run") {
|
|
269
|
+
const [manifesto, definicao, plano, contrato, entrada, entradaAuxiliar, evidencia, resultado] = await Promise.all([
|
|
270
|
+
lerJson(posicionais[0]),
|
|
271
|
+
lerJson(opcoes.definitionFile),
|
|
272
|
+
lerJson(opcoes.planFile),
|
|
273
|
+
lerJson(opcoes.contractFile),
|
|
274
|
+
lerJson(opcoes.inputFile),
|
|
275
|
+
opcoes.secondaryInputFile === undefined ? Promise.resolve(undefined) : lerJson(opcoes.secondaryInputFile),
|
|
276
|
+
lerJson(opcoes.evidenceFile),
|
|
277
|
+
lerJson(opcoes.resultFile),
|
|
278
|
+
]);
|
|
279
|
+
const controlRun = validarControlRunInterativo(manifesto, {
|
|
280
|
+
definicao,
|
|
281
|
+
plano,
|
|
282
|
+
contrato,
|
|
283
|
+
entradas: entradaAuxiliar === undefined ? [entrada] : [entrada, entradaAuxiliar],
|
|
284
|
+
evidencia,
|
|
285
|
+
resultado,
|
|
286
|
+
});
|
|
287
|
+
return {
|
|
288
|
+
exitCode: controlRun.valid ? 0 : 1,
|
|
289
|
+
payload: { ...basePayload("validar-control-run", controlRun.valid), resultado: controlRun },
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
const registro = await lerJson(posicionais[0]);
|
|
293
|
+
const resultado = validarProtocoloAdapterSistemaInterativo(registro);
|
|
294
|
+
return { exitCode: resultado.valido ? 0 : 1, payload: { ...basePayload("validar-protocolo", resultado.valido), ...resultado } };
|
|
295
|
+
}
|
|
296
|
+
catch {
|
|
297
|
+
return erro(subcomando, "INTERATIVO_ENTRADA_INVALIDA");
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
export async function comandoSistemasInterativos(_posicionaisGlobais, args, emJson) {
|
|
301
|
+
const resultado = await executarComandoSistemasInterativos(args);
|
|
302
|
+
const saidaJson = emJson || args.includes("--json");
|
|
303
|
+
if (saidaJson)
|
|
304
|
+
console.log(JSON.stringify(resultado.payload, null, 2));
|
|
305
|
+
else if (resultado.exitCode === 0)
|
|
306
|
+
console.log(renderizarResultadoSistemasInterativos(resultado.payload));
|
|
307
|
+
else
|
|
308
|
+
console.error(renderizarResultadoSistemasInterativos(resultado.payload));
|
|
309
|
+
return resultado.exitCode;
|
|
310
|
+
}
|
|
311
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export declare const CONTROL_RUN_SCHEMA_VERSION: "sema.interactive.control-run/v1";
|
|
2
|
+
export interface ManifestoControlRunInterativo {
|
|
3
|
+
readonly schemaVersion: typeof CONTROL_RUN_SCHEMA_VERSION;
|
|
4
|
+
readonly runId: string;
|
|
5
|
+
readonly systemId: string;
|
|
6
|
+
readonly pipelineId: string;
|
|
7
|
+
readonly validatorCommand: string;
|
|
8
|
+
readonly definitionDigest: string;
|
|
9
|
+
readonly planDigest: string;
|
|
10
|
+
readonly pipelineContractDigest: string;
|
|
11
|
+
readonly validationContractDigest: string;
|
|
12
|
+
readonly producerId: string;
|
|
13
|
+
readonly producerVersion: string;
|
|
14
|
+
readonly producerConfigurationDigest: string;
|
|
15
|
+
readonly verifierId: string;
|
|
16
|
+
readonly verifierVersion: string;
|
|
17
|
+
readonly verifierConfigurationDigest: string;
|
|
18
|
+
readonly inputSchemaKeys: readonly string[];
|
|
19
|
+
readonly inputDigests: readonly string[];
|
|
20
|
+
readonly evidenceDigest: string;
|
|
21
|
+
readonly resultDigest: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ArtefatosControlRunInterativo {
|
|
24
|
+
readonly definicao: unknown;
|
|
25
|
+
readonly plano: unknown;
|
|
26
|
+
readonly contrato: unknown;
|
|
27
|
+
readonly entradas: readonly unknown[];
|
|
28
|
+
readonly evidencia: unknown;
|
|
29
|
+
readonly resultado: unknown;
|
|
30
|
+
}
|
|
31
|
+
export interface BindingControlRunInterativo {
|
|
32
|
+
readonly kind: "DEFINITION" | "PLAN" | "PIPELINE_CONTRACT" | "VALIDATION_CONTRACT" | "INPUT" | "EVIDENCE" | "RESULT";
|
|
33
|
+
readonly id: string;
|
|
34
|
+
readonly digest: string;
|
|
35
|
+
readonly matched: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface ResultadoControlRunInterativo {
|
|
38
|
+
readonly valid: boolean;
|
|
39
|
+
readonly controlRunDigest: string;
|
|
40
|
+
readonly definitionDigest: string;
|
|
41
|
+
readonly planDigest: string;
|
|
42
|
+
readonly pipelineContractDigest: string;
|
|
43
|
+
readonly validationContractDigest: string;
|
|
44
|
+
readonly inputDigests: readonly string[];
|
|
45
|
+
readonly evidenceDigest: string;
|
|
46
|
+
readonly resultDigest: string;
|
|
47
|
+
readonly bindings: readonly BindingControlRunInterativo[];
|
|
48
|
+
readonly issues: readonly string[];
|
|
49
|
+
readonly completed: false;
|
|
50
|
+
readonly localCoverageComplete: boolean;
|
|
51
|
+
readonly awaitingExternalAttestation: true;
|
|
52
|
+
readonly executed: false;
|
|
53
|
+
readonly workspaceMutated: false;
|
|
54
|
+
readonly authoritative: false;
|
|
55
|
+
}
|
|
56
|
+
export declare function validarControlRunInterativo(manifestoEntrada: unknown, artefatos: ArtefatosControlRunInterativo): ResultadoControlRunInterativo;
|