@semacode/cli 2.3.0 → 3.0.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/LICENSE +39 -39
- package/README.md +112 -41
- package/dist/agentContextPack.js +14 -10
- package/dist/agentEntryPoints.d.ts +5 -0
- package/dist/agentEntryPoints.js +102 -91
- package/dist/angular-consumer-standalone.d.ts +3 -1
- package/dist/angular-consumer-standalone.js +12 -8
- package/dist/bin.d.ts +6 -0
- package/dist/bin.js +130 -0
- package/dist/cliArgs.js +4 -4
- package/dist/cliControlError.d.ts +12 -0
- package/dist/cliControlError.js +47 -0
- package/dist/cliGrammar.d.ts +11 -0
- package/dist/cliGrammar.js +551 -0
- package/dist/cliHelp.d.ts +13 -0
- package/dist/cliHelp.js +19 -0
- package/dist/cliHelpTexto.d.ts +3 -0
- package/dist/cliHelpTexto.js +168 -0
- package/dist/cliRuntime.d.ts +2 -0
- package/dist/cliRuntime.js +31 -0
- package/dist/comandos.js +9 -22
- package/dist/contexto.js +5 -5
- package/dist/dev/index.d.ts +1 -0
- package/dist/dev/index.js +51 -9
- package/dist/discovery/catalog.js +3 -3
- package/dist/distribuicao/filesystemGlobal.d.ts +63 -0
- package/dist/distribuicao/filesystemGlobal.js +701 -0
- package/dist/distribuicao/index.d.ts +7 -0
- package/dist/distribuicao/index.js +227 -0
- package/dist/distribuicao/launcherGlobal.d.ts +53 -0
- package/dist/distribuicao/launcherGlobal.js +643 -0
- package/dist/distribuicao/launcherWindows.d.ts +28 -0
- package/dist/distribuicao/launcherWindows.js +326 -0
- package/dist/distribuicao/lockContextGlobal.d.ts +10 -0
- package/dist/distribuicao/lockContextGlobal.js +17 -0
- package/dist/distribuicao/lockGlobal.d.ts +6 -0
- package/dist/distribuicao/lockGlobal.js +520 -0
- package/dist/distribuicao/skillGlobal.d.ts +48 -0
- package/dist/distribuicao/skillGlobal.js +652 -0
- package/dist/distribuicao/skillIntentPolicy.d.ts +21 -0
- package/dist/distribuicao/skillIntentPolicy.js +115 -0
- package/dist/distribuicao/tipos.d.ts +50 -0
- package/dist/distribuicao/tipos.js +10 -0
- package/dist/distribuicao/versaoSemantica.d.ts +3 -0
- package/dist/distribuicao/versaoSemantica.js +62 -0
- package/dist/drift.part01.d.ts +34 -2
- package/dist/drift.part01.js +3 -0
- package/dist/drift.part04.d.ts +12 -2
- package/dist/drift.part04.js +89 -15
- package/dist/drift.part05.d.ts +2 -1
- package/dist/drift.part05.js +9 -6
- package/dist/drift.part06.d.ts +2 -1
- package/dist/drift.part06.js +115 -24
- package/dist/drift.part07.d.ts +11 -10
- package/dist/drift.part07.js +261 -255
- package/dist/drift.part08.d.ts +2 -1
- package/dist/drift.part08.js +35 -25
- package/dist/drift.part11.js +279 -32
- package/dist/drift.part12.d.ts +1 -1
- package/dist/drift.part12.js +196 -11
- package/dist/drift.part13.d.ts +18 -2
- package/dist/drift.part13.js +654 -76
- package/dist/drift.part14.js +21 -7
- package/dist/driftCacheCas.d.ts +43 -0
- package/dist/driftCacheCas.js +351 -0
- package/dist/driftCacheFilesystem.d.ts +64 -0
- package/dist/driftCacheFilesystem.js +313 -0
- package/dist/driftCacheModes.d.ts +38 -0
- package/dist/driftCacheModes.js +147 -0
- package/dist/driftCacheStore.d.ts +80 -0
- package/dist/driftCacheStore.js +603 -0
- package/dist/driftCatalogo.d.ts +65 -0
- package/dist/driftCatalogo.js +516 -0
- package/dist/driftEscopo.d.ts +21 -0
- package/dist/driftEscopo.js +647 -0
- package/dist/driftEscopoReferencias.d.ts +8 -0
- package/dist/driftEscopoReferencias.js +612 -0
- package/dist/driftOrcamento.d.ts +6 -0
- package/dist/driftOrcamento.js +20 -3
- package/dist/geracaoCore.js +4 -6
- package/dist/iaPrompts.d.ts +3 -3
- package/dist/iaPrompts.js +13 -14
- package/dist/index.d.ts +4 -1
- package/dist/index.js +6 -25
- package/dist/index.part01.d.ts +21 -14
- package/dist/index.part01.js +20 -165
- package/dist/index.part02.js +57 -43
- package/dist/index.part03.d.ts +23 -1
- package/dist/index.part03.js +83 -8
- package/dist/index.part04.d.ts +10 -2
- package/dist/index.part04.js +48 -14
- package/dist/index.part05.d.ts +1 -1
- package/dist/index.part05.js +109 -30
- package/dist/index.part06.js +34 -16
- package/dist/index.part07.js +31 -27
- package/dist/index.part08.d.ts +1 -1
- package/dist/index.part08.js +23 -28
- package/dist/init/templates.part01.js +393 -393
- package/dist/init/templates.part02.js +189 -189
- package/dist/initCommand.js +5 -1
- package/dist/initTemplatesBackend.js +73 -73
- package/dist/initTemplatesBase.js +7 -5
- package/dist/initTemplatesFlutter.js +137 -137
- package/dist/initTemplatesRuntime.js +350 -350
- package/dist/initTemplatesWeb.js +309 -309
- package/dist/pipelineConteudo/command.d.ts +1 -0
- package/dist/pipelineConteudo/command.js +4 -32
- package/dist/pipelineConteudo/help.d.ts +2 -0
- package/dist/pipelineConteudo/help.js +33 -0
- package/dist/profileAuthorCommand.js +3 -7
- package/dist/profileCommand.js +3 -7
- package/dist/projeto.d.ts +1 -1
- package/dist/projetoCarregar.d.ts +2 -2
- package/dist/projetoCarregar.js +69 -28
- package/dist/projetoCatalogo.d.ts +8 -0
- package/dist/projetoCatalogo.js +164 -0
- package/dist/projetoOrigens.d.ts +2 -0
- package/dist/projetoOrigens.js +65 -9
- package/dist/projetoTipos.d.ts +15 -5
- package/dist/resultadoCli.d.ts +20 -0
- package/dist/resultadoCli.js +57 -0
- package/dist/saidaCli.d.ts +35 -0
- package/dist/saidaCli.js +118 -0
- package/dist/sistemasInterativos/acceptanceEvidence.d.ts +22 -0
- package/dist/sistemasInterativos/acceptanceEvidence.js +345 -0
- package/dist/sistemasInterativos/engineObservation.d.ts +12 -0
- package/dist/sistemasInterativos/engineObservation.js +438 -0
- package/dist/sistemasInterativos/jobOrchestration.d.ts +2 -0
- package/dist/sistemasInterativos/jobOrchestration.js +204 -0
- package/dist/sistemasInterativos/operationPrimitives.d.ts +21 -0
- package/dist/sistemasInterativos/operationPrimitives.js +194 -0
- package/dist/sistemasInterativos/operations.d.ts +4 -39
- package/dist/sistemasInterativos/operations.js +5 -1164
- package/dist/skillCommand.d.ts +5 -0
- package/dist/skillCommand.js +88 -0
- package/dist/sync/index.js +35 -35
- package/docs/README.md +11 -7
- package/docs/ai-integration.md +18 -11
- package/docs/ai-onboarding.md +81 -62
- package/docs/ai-workflow.md +10 -4
- package/docs/auth.md +26 -26
- package/docs/cli.md +197 -79
- package/docs/commands.md +30 -6
- package/docs/database.md +15 -15
- package/docs/deploy.md +54 -41
- package/docs/documentation.md +11 -10
- package/docs/drift-cache.md +108 -0
- package/docs/env.md +16 -16
- package/docs/frontend.md +41 -41
- package/docs/getting-started.md +82 -57
- package/docs/i18n.md +15 -15
- package/docs/repositories.md +60 -43
- package/docs/rollback.md +38 -31
- package/docs/security.md +54 -32
- package/docs/sistemas-interativos.md +27 -27
- package/docs/support.md +8 -8
- package/docs/testing.md +123 -17
- package/docs/vocabulary.md +29 -29
- package/exemplos/agendamento.sema +1 -1
- package/exemplos/assinatura.sema +1 -1
- package/exemplos/auditoria.sema +1 -1
- package/exemplos/autenticacao.sema +1 -1
- package/exemplos/author_obra_comum.sema +1 -1
- package/exemplos/author_tema_sensivel.sema +1 -1
- package/exemplos/automacao.sema +1 -1
- package/exemplos/cadastro_usuario.sema +1 -1
- package/exemplos/calculadora.sema +1 -1
- package/exemplos/crud_simples.sema +1 -1
- package/exemplos/estoque.sema +1 -1
- package/exemplos/exportacao.sema +1 -1
- package/exemplos/fila.sema +1 -1
- package/exemplos/integracao_externa.sema +1 -1
- package/exemplos/multi_tenant.sema +1 -1
- package/exemplos/notificacao.sema +1 -1
- package/exemplos/operacao_estrategia.sema +132 -132
- package/exemplos/operacao_estrategia_discovery.sema +220 -220
- package/exemplos/operacao_estrategia_fluxo.sema +114 -114
- package/exemplos/operacao_estrategia_gates.sema +106 -106
- package/exemplos/operacao_estrategia_quarentena.sema +133 -133
- package/exemplos/operacao_estrategia_rollout.sema +124 -124
- package/exemplos/pagamento.sema +1 -1
- package/exemplos/pagamento_dominio.sema +1 -1
- package/exemplos/pedido.sema +1 -1
- package/exemplos/permissao.sema +1 -1
- package/exemplos/persistencia_vendor_first.sema +1 -1
- package/exemplos/profile_conversas.sema +165 -165
- package/exemplos/profile_game.sema +1 -1
- package/exemplos/profile_legal.sema +1 -1
- package/exemplos/profile_ops.sema +1 -1
- package/exemplos/profile_research.sema +1 -1
- package/exemplos/profile_software.sema +1 -1
- package/exemplos/profile_workflow_n8n.sema +1 -1
- package/exemplos/relatorio.sema +1 -1
- package/exemplos/replica_analitica_erp.sema +1 -1
- package/exemplos/testes_embutidos.sema +1 -1
- package/exemplos/tratamento_erro.sema +1 -1
- package/exemplos/upload_arquivo.sema +1 -1
- package/exemplos/webhook.sema +1 -1
- package/node_modules/@sema/gerador-cpp/dist/index.js +176 -176
- package/node_modules/@sema/gerador-css/dist/index.part01.js +10 -10
- package/node_modules/@sema/gerador-css/dist/index.part02.js +460 -460
- package/node_modules/@sema/gerador-dotnet/dist/index.js +169 -169
- package/node_modules/@sema/gerador-html/dist/index.js +17 -17
- package/node_modules/@sema/gerador-python/dist/index.part02.js +3 -3
- package/node_modules/@sema/gerador-typescript/dist/index.part02.js +11 -11
- package/node_modules/@sema/nucleo/dist/diagnosticos/melhorador.js +42 -42
- package/node_modules/@sema/nucleo/dist/semantico/analisador.d.ts +1 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.js +1 -0
- package/package.json +7 -2
- package/scripts/postinstall.mjs +148 -0
- package/skills/sema/SKILL.md +199 -0
- package/skills/sema/agents/openai.yaml +4 -0
- package/node_modules/@sema/gerador-cpp/dist/index.js.map +0 -1
- package/node_modules/@sema/gerador-css/dist/index.js.map +0 -1
- package/node_modules/@sema/gerador-css/dist/index.part01.js.map +0 -1
- package/node_modules/@sema/gerador-css/dist/index.part02.js.map +0 -1
- package/node_modules/@sema/gerador-dart/dist/index.js.map +0 -1
- package/node_modules/@sema/gerador-dotnet/dist/index.js.map +0 -1
- package/node_modules/@sema/gerador-html/dist/index.js.map +0 -1
- package/node_modules/@sema/gerador-javascript/dist/index.js.map +0 -1
- package/node_modules/@sema/gerador-lua/dist/index.js.map +0 -1
- package/node_modules/@sema/gerador-php/dist/index.js.map +0 -1
- package/node_modules/@sema/gerador-python/dist/index.js.map +0 -1
- package/node_modules/@sema/gerador-python/dist/index.part01.js.map +0 -1
- package/node_modules/@sema/gerador-python/dist/index.part02.js.map +0 -1
- package/node_modules/@sema/gerador-typescript/dist/index.js.map +0 -1
- package/node_modules/@sema/gerador-typescript/dist/index.part01.js.map +0 -1
- package/node_modules/@sema/gerador-typescript/dist/index.part02.js.map +0 -1
- package/node_modules/@sema/gerador-typescript/dist/index.part03.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/ast/tipos.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/diagnosticos/index.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/diagnosticos/melhorador.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/diagnosticos/snippets.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/formatador/index.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/formatador/index.part01.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/formatador/index.part02.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/index.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/ir/conversor.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/ir/conversor.part01.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/ir/conversor.part02.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/ir/conversor.part03.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/ir/modelos.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/lexer/lexer.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/lexer/tokens.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/parser/parser.declaracoes.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/parser/parser.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/parser/parser.modulo.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/parser/parser.part01.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/parser/parser.part02.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/parser/parser.part03.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/persistencia/contratos.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/analisador.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part01.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part02.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part03.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part04.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part05.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part06.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part07.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part08.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/estruturas.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/estruturas.part01.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/estruturas.part02.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/orcamentoSemantico.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/semantico/seguranca.js.map +0 -1
- package/node_modules/@sema/nucleo/dist/util/arquivos.js.map +0 -1
- package/node_modules/@sema/padroes/dist/index.js.map +0 -1
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// SEMA-GOVERNED: sema.produto.sistemas_interativos.operacao
|
|
2
|
+
// Descricao: primitivas puras de JSON canonico, digest e redacao para operacoes interativas.
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import { OPERATION_RESULT_SCHEMA_V1, } from "./operationsTypes.js";
|
|
5
|
+
const BASE_FLAGS = {
|
|
6
|
+
executed: false,
|
|
7
|
+
workspaceMutated: false,
|
|
8
|
+
engineProbed: false,
|
|
9
|
+
editorInspected: false,
|
|
10
|
+
processesInspected: false,
|
|
11
|
+
resourcesReserved: false,
|
|
12
|
+
authoritative: false,
|
|
13
|
+
};
|
|
14
|
+
const SHA256_PATTERN = /^sha256:[a-f0-9]{64}$/;
|
|
15
|
+
const OPAQUE_SHA256_PATTERN = /^opaque:sha256:[a-f0-9]{64}$/;
|
|
16
|
+
const SEMANTIC_ID_PATTERN = /^[a-z][a-z0-9_-]{0,31}(?:[.:/][a-z0-9][a-z0-9_-]{0,63})+$/;
|
|
17
|
+
const SAFE_NAME_PATTERN = /^[A-Za-z][A-Za-z0-9._+-]{0,127}$/;
|
|
18
|
+
const VERSION_PATTERN = /^[0-9]+\.[0-9]+\.[0-9]+(?:-[A-Za-z0-9.-]+)?$/;
|
|
19
|
+
export const MEDIA_TYPE_PATTERN = /^[a-z0-9][a-z0-9.+-]{0,63}\/[a-z0-9][a-z0-9.+-]{0,63}$/;
|
|
20
|
+
const DANGEROUS_KEYS = new Set(["__proto__", "prototype", "constructor"]);
|
|
21
|
+
const OPAQUE_SENSITIVE_KEYS = new Set(["recoverytoken", "sourceuriref"]);
|
|
22
|
+
const SENSITIVE_KEY_PARTS = [
|
|
23
|
+
"password", "passwd", "secret", "token", "apikey", "privatekey",
|
|
24
|
+
"clientsecret", "accesstoken", "refreshtoken", "credential",
|
|
25
|
+
"authorization", "cookie", "connectionstring",
|
|
26
|
+
];
|
|
27
|
+
const SENSITIVE_VALUE_PATTERNS = [
|
|
28
|
+
/\bbearer\s+[a-z0-9._~+\/-]{8,}/i,
|
|
29
|
+
/^(?:sk[-_][a-z0-9_-]{8,}|ghp_[a-z0-9]{20,}|github_pat_[a-z0-9_]{20,})$/i,
|
|
30
|
+
/^eyJ[a-z0-9_-]{8,}\.eyJ[a-z0-9_-]{8,}\.[a-z0-9_-]{8,}$/i,
|
|
31
|
+
/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/,
|
|
32
|
+
/-----BEGIN [A-Z0-9 ]*(?:PRIVATE KEY|CERTIFICATE)-----/,
|
|
33
|
+
/(?:^|[?&])(?:access_?token|api_?key|aws_?secret_?access_?key|secret|password|passwd|signature|sig|token|credential|authorization)=[^&#\s]+/i,
|
|
34
|
+
/:\/\/[^/\s:@]+:[^/\s@]+@/,
|
|
35
|
+
];
|
|
36
|
+
export function issue(code, field) {
|
|
37
|
+
return { code, field };
|
|
38
|
+
}
|
|
39
|
+
function normalizedIssues(issues) {
|
|
40
|
+
const unique = new Map();
|
|
41
|
+
for (const item of issues)
|
|
42
|
+
unique.set(item.code + "\u0000" + item.field, item);
|
|
43
|
+
return [...unique.values()].sort((a, b) => (a.code.localeCompare(b.code) || a.field.localeCompare(b.field)));
|
|
44
|
+
}
|
|
45
|
+
export function failure(issues) {
|
|
46
|
+
return {
|
|
47
|
+
schemaVersion: OPERATION_RESULT_SCHEMA_V1,
|
|
48
|
+
valid: false,
|
|
49
|
+
issues: normalizedIssues(issues),
|
|
50
|
+
...BASE_FLAGS,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export function success(value, digest) {
|
|
54
|
+
return {
|
|
55
|
+
schemaVersion: OPERATION_RESULT_SCHEMA_V1,
|
|
56
|
+
valid: true,
|
|
57
|
+
issues: [],
|
|
58
|
+
value,
|
|
59
|
+
...(digest === undefined ? {} : { digest }),
|
|
60
|
+
...BASE_FLAGS,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export function isRecord(value) {
|
|
64
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
65
|
+
return false;
|
|
66
|
+
const prototype = Object.getPrototypeOf(value);
|
|
67
|
+
return prototype === Object.prototype || prototype === null;
|
|
68
|
+
}
|
|
69
|
+
function normalizedKey(key) {
|
|
70
|
+
return key.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
71
|
+
}
|
|
72
|
+
export function isSha256(value) {
|
|
73
|
+
return typeof value === "string" && SHA256_PATTERN.test(value);
|
|
74
|
+
}
|
|
75
|
+
export function isOpaqueSha256(value) {
|
|
76
|
+
return typeof value === "string" && OPAQUE_SHA256_PATTERN.test(value);
|
|
77
|
+
}
|
|
78
|
+
export function isSemanticId(value) {
|
|
79
|
+
return typeof value === "string" && value.length <= 192 && SEMANTIC_ID_PATTERN.test(value);
|
|
80
|
+
}
|
|
81
|
+
export function isSafeName(value) {
|
|
82
|
+
return typeof value === "string" && SAFE_NAME_PATTERN.test(value);
|
|
83
|
+
}
|
|
84
|
+
export function isVersion(value) {
|
|
85
|
+
return typeof value === "string" && VERSION_PATTERN.test(value);
|
|
86
|
+
}
|
|
87
|
+
export function isIsoTimestamp(value) {
|
|
88
|
+
if (typeof value !== "string" || value.length > 40)
|
|
89
|
+
return false;
|
|
90
|
+
const parsed = Date.parse(value);
|
|
91
|
+
return Number.isFinite(parsed) && new Date(parsed).toISOString() === value;
|
|
92
|
+
}
|
|
93
|
+
export function isIntegerIn(value, minimum, maximum) {
|
|
94
|
+
return typeof value === "number"
|
|
95
|
+
&& Number.isSafeInteger(value)
|
|
96
|
+
&& value >= minimum
|
|
97
|
+
&& value <= maximum;
|
|
98
|
+
}
|
|
99
|
+
export function hasOnlyKeys(value, allowed) {
|
|
100
|
+
const allowlist = new Set(allowed);
|
|
101
|
+
return Object.keys(value).every((key) => allowlist.has(key));
|
|
102
|
+
}
|
|
103
|
+
function isSensitiveValue(value) {
|
|
104
|
+
if (isSha256(value) || isOpaqueSha256(value))
|
|
105
|
+
return false;
|
|
106
|
+
return SENSITIVE_VALUE_PATTERNS.some((pattern) => pattern.test(value));
|
|
107
|
+
}
|
|
108
|
+
export function inspectPlainJson(input, rootField) {
|
|
109
|
+
const issues = [];
|
|
110
|
+
const active = new Set();
|
|
111
|
+
let nodes = 0;
|
|
112
|
+
const visit = (value, field, depth) => {
|
|
113
|
+
nodes += 1;
|
|
114
|
+
if (nodes > 20_000) {
|
|
115
|
+
issues.push(issue("json_node_limit_exceeded", rootField));
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (depth > 48) {
|
|
119
|
+
issues.push(issue("json_depth_limit_exceeded", rootField));
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (typeof value === "string") {
|
|
123
|
+
if (isSensitiveValue(value))
|
|
124
|
+
issues.push(issue("sensitive_material_forbidden", field));
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (value === null || typeof value === "boolean")
|
|
128
|
+
return;
|
|
129
|
+
if (typeof value === "number") {
|
|
130
|
+
if (!Number.isFinite(value))
|
|
131
|
+
issues.push(issue("json_number_invalid", field));
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (typeof value !== "object") {
|
|
135
|
+
issues.push(issue("json_type_unsupported", field));
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (active.has(value)) {
|
|
139
|
+
issues.push(issue("json_cycle_detected", rootField));
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
active.add(value);
|
|
143
|
+
if (Array.isArray(value)) {
|
|
144
|
+
if (value.length > 10_000)
|
|
145
|
+
issues.push(issue("json_array_limit_exceeded", field));
|
|
146
|
+
for (const item of value)
|
|
147
|
+
visit(item, field, depth + 1);
|
|
148
|
+
active.delete(value);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (!isRecord(value)) {
|
|
152
|
+
issues.push(issue("json_object_not_plain", field));
|
|
153
|
+
active.delete(value);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(value))) {
|
|
157
|
+
if (DANGEROUS_KEYS.has(key))
|
|
158
|
+
issues.push(issue("json_dangerous_key", field));
|
|
159
|
+
if (descriptor.get !== undefined || descriptor.set !== undefined) {
|
|
160
|
+
issues.push(issue("json_accessor_forbidden", field));
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
const keyNormalized = normalizedKey(key);
|
|
164
|
+
const child = descriptor.value;
|
|
165
|
+
const sensitive = SENSITIVE_KEY_PARTS.some((part) => keyNormalized.includes(part));
|
|
166
|
+
const opaqueException = OPAQUE_SENSITIVE_KEYS.has(keyNormalized) && isOpaqueSha256(child);
|
|
167
|
+
if (sensitive && !opaqueException)
|
|
168
|
+
issues.push(issue("sensitive_material_forbidden", field));
|
|
169
|
+
visit(child, field, depth + 1);
|
|
170
|
+
}
|
|
171
|
+
active.delete(value);
|
|
172
|
+
};
|
|
173
|
+
visit(input, rootField, 0);
|
|
174
|
+
return normalizedIssues(issues);
|
|
175
|
+
}
|
|
176
|
+
export function canonicalJson(value) {
|
|
177
|
+
if (Array.isArray(value))
|
|
178
|
+
return "[" + value.map(canonicalJson).join(",") + "]";
|
|
179
|
+
if (isRecord(value)) {
|
|
180
|
+
return "{" + Object.keys(value).sort().map((key) => (JSON.stringify(key) + ":" + canonicalJson(value[key]))).join(",") + "}";
|
|
181
|
+
}
|
|
182
|
+
return JSON.stringify(value);
|
|
183
|
+
}
|
|
184
|
+
export function digestJsonOperacional(value) {
|
|
185
|
+
return ("sha256:" + createHash("sha256").update(canonicalJson(value)).digest("hex"));
|
|
186
|
+
}
|
|
187
|
+
export function criarReferenciaFonteOpaca(sourceUri) {
|
|
188
|
+
if (typeof sourceUri !== "string" || sourceUri.length === 0 || sourceUri.length > 4096 || sourceUri.includes("\u0000")) {
|
|
189
|
+
return failure([issue("source_uri_invalid", "sourceUri")]);
|
|
190
|
+
}
|
|
191
|
+
const sourceUriRef = ("opaque:sha256:" + createHash("sha256").update(sourceUri).digest("hex"));
|
|
192
|
+
return success({ sourceUriRef, sourceUriRedacted: true }, digestJsonOperacional(sourceUriRef));
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=operationPrimitives.js.map
|
|
@@ -1,40 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
export { criarReferenciaFonteOpaca, digestJsonOperacional, } from "./operationPrimitives.js";
|
|
2
|
+
export { derivarDiffSnapshotsEngine, validarEstadoEditor, validarProvenienciaAsset, validarSnapshotEngine, } from "./engineObservation.js";
|
|
3
|
+
export { planejarOrquestracaoJobs } from "./jobOrchestration.js";
|
|
4
|
+
export { digestVinculoClaimMultimodal, operarAcceptanceLock, validarAcceptanceLock, validarEvidenciaMultimodal, } from "./acceptanceEvidence.js";
|
|
2
5
|
export * from "./operationsTypes.js";
|
|
3
|
-
export declare function digestJsonOperacional(value: unknown): Sha256;
|
|
4
|
-
export declare function criarReferenciaFonteOpaca(sourceUri: unknown): OperationResult<{
|
|
5
|
-
readonly sourceUriRef: OpaqueSha256;
|
|
6
|
-
readonly sourceUriRedacted: true;
|
|
7
|
-
}>;
|
|
8
|
-
export declare function validarSnapshotEngine(input: unknown): OperationResult<ValidatedEngineSnapshot>;
|
|
9
|
-
export declare function derivarDiffSnapshotsEngine(beforeInput: unknown, afterInput: unknown): OperationResult<EngineSnapshotDiffV1>;
|
|
10
|
-
export declare function validarProvenienciaAsset(input: unknown): OperationResult<{
|
|
11
|
-
readonly provenance: AssetProvenanceV1;
|
|
12
|
-
readonly provenanceDigest: Sha256;
|
|
13
|
-
}>;
|
|
14
|
-
export declare function validarEstadoEditor(input: unknown): OperationResult<{
|
|
15
|
-
readonly state: EditorStateV1;
|
|
16
|
-
readonly editorStateDigest: Sha256;
|
|
17
|
-
readonly externallyObserved: false;
|
|
18
|
-
}>;
|
|
19
|
-
export declare function planejarOrquestracaoJobs(input: unknown): OperationResult<JobOrchestrationPlanV1>;
|
|
20
|
-
export declare function validarAcceptanceLock(input: unknown): OperationResult<{
|
|
21
|
-
readonly lock: AcceptanceLockV1;
|
|
22
|
-
readonly lockDigest: Sha256;
|
|
23
|
-
}>;
|
|
24
|
-
export declare function operarAcceptanceLock(operation: unknown, lockInput: unknown, contextInput: unknown): OperationResult<AcceptanceOperationValue>;
|
|
25
|
-
export declare function digestVinculoClaimMultimodal(input: {
|
|
26
|
-
readonly claimId: string;
|
|
27
|
-
readonly runId: string;
|
|
28
|
-
readonly definitionDigest: Sha256;
|
|
29
|
-
readonly planDigest: Sha256;
|
|
30
|
-
readonly contractDigest: Sha256;
|
|
31
|
-
readonly artifactDigest: Sha256;
|
|
32
|
-
readonly sceneId: string;
|
|
33
|
-
readonly timeRange: AcceptanceTimeRange;
|
|
34
|
-
readonly requiredModalities: readonly MultimodalChannelType[];
|
|
35
|
-
}): Sha256;
|
|
36
|
-
export declare function validarEvidenciaMultimodal(input: unknown): OperationResult<{
|
|
37
|
-
readonly descriptor: MultimodalEvidenceDescriptorV1;
|
|
38
|
-
readonly descriptorDigest: Sha256;
|
|
39
|
-
readonly localDescriptorOnly: true;
|
|
40
|
-
}>;
|