@evomap/evolver-core 2.0.0-beta.2 → 2.0.0-beta.22
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/assets/gep/genes.jsonl +5 -5
- package/dist/algo/bans.d.ts +10 -1
- package/dist/algo/bans.js +56 -6
- package/dist/algo/candidateAssembly.d.ts +25 -2
- package/dist/algo/candidateAssembly.js +171 -26
- package/dist/algo/capabilityCandidates.js +10 -0
- package/dist/algo/conversationSniffer.js +25 -8
- package/dist/algo/cycleEngine.d.ts +63 -5
- package/dist/algo/cycleEngine.js +320 -42
- package/dist/algo/cycleFailureClassifier.d.ts +1 -1
- package/dist/algo/evolutionEvent.d.ts +26 -0
- package/dist/algo/evolutionEvent.js +32 -0
- package/dist/algo/exploration.d.ts +7 -0
- package/dist/algo/exploration.js +16 -3
- package/dist/algo/geneHealth.d.ts +36 -3
- package/dist/algo/geneHealth.js +47 -4
- package/dist/algo/geneIntake.d.ts +46 -1
- package/dist/algo/geneIntake.js +121 -10
- package/dist/algo/geneSelection.d.ts +126 -6
- package/dist/algo/geneSelection.js +479 -36
- package/dist/algo/index.d.ts +6 -1
- package/dist/algo/index.js +6 -1
- package/dist/algo/kautoProjection.d.ts +41 -0
- package/dist/algo/kautoProjection.js +95 -0
- package/dist/algo/kautoValidator.d.ts +68 -0
- package/dist/algo/kautoValidator.js +256 -0
- package/dist/algo/memoryGraph.d.ts +62 -0
- package/dist/algo/memoryGraph.js +86 -0
- package/dist/algo/orchestrator.d.ts +17 -1
- package/dist/algo/orchestrator.js +30 -4
- package/dist/algo/publishEligibility.d.ts +34 -0
- package/dist/algo/publishEligibility.js +52 -0
- package/dist/algo/solidify.d.ts +11 -2
- package/dist/algo/solidify.js +37 -7
- package/dist/algo/ucb1.d.ts +53 -0
- package/dist/algo/ucb1.js +156 -0
- package/dist/assetrepair/hubRejection.d.ts +12 -0
- package/dist/assetrepair/hubRejection.js +109 -0
- package/dist/assetrepair/index.d.ts +2 -0
- package/dist/assetrepair/index.js +2 -0
- package/dist/assetrepair/repair.d.ts +33 -0
- package/dist/assetrepair/repair.js +155 -0
- package/dist/assetstore/assetSidecarRecords.d.ts +28 -0
- package/dist/assetstore/assetSidecarRecords.js +384 -0
- package/dist/assetstore/assetSidecarRecovery.d.ts +48 -0
- package/dist/assetstore/assetSidecarRecovery.js +288 -0
- package/dist/assetstore/assetStoreHealth.d.ts +81 -0
- package/dist/assetstore/assetStoreHealth.js +319 -0
- package/dist/assetstore/assetStoreLayout.d.ts +2 -0
- package/dist/assetstore/assetStoreLayout.js +6 -0
- package/dist/assetstore/assetStoreStorage.d.ts +42 -0
- package/dist/assetstore/assetStoreStorage.js +336 -0
- package/dist/assetstore/assetSyncLedger.d.ts +91 -1
- package/dist/assetstore/assetSyncLedger.js +718 -59
- package/dist/assetstore/foreignJsonlSource.d.ts +48 -0
- package/dist/assetstore/foreignJsonlSource.js +150 -0
- package/dist/assetstore/index.d.ts +5 -0
- package/dist/assetstore/index.js +5 -0
- package/dist/assetstore/learningHistory.js +3 -3
- package/dist/assetstore/localAssetStoreSnapshot.d.ts +51 -0
- package/dist/assetstore/localAssetStoreSnapshot.js +329 -0
- package/dist/assetstore/localJsonl.d.ts +12 -1
- package/dist/assetstore/localJsonl.js +251 -42
- package/dist/assetstore/provenance.d.ts +93 -4
- package/dist/assetstore/provenance.js +368 -84
- package/dist/assetstore/provider.d.ts +63 -0
- package/dist/assetstore/provider.js +97 -6
- package/dist/assetstore/reviewFilter.d.ts +19 -1
- package/dist/assetstore/reviewFilter.js +39 -1
- package/dist/assetstore/reviewLedger.d.ts +8 -2
- package/dist/assetstore/reviewLedger.js +71 -45
- package/dist/assetstore/unionReadStore.d.ts +25 -0
- package/dist/assetstore/unionReadStore.js +119 -0
- package/dist/benchmark/antiGeneBenchmark.d.ts +2 -0
- package/dist/benchmark/antiGeneBenchmark.js +4 -3
- package/dist/benchmark/antiGeneRollout.d.ts +2 -0
- package/dist/benchmark/antiGeneRollout.js +4 -3
- package/dist/benchmark/index.d.ts +3 -1
- package/dist/benchmark/index.js +3 -1
- package/dist/benchmark/selectionFlatAbstention.d.ts +152 -0
- package/dist/benchmark/selectionFlatAbstention.js +481 -0
- package/dist/benchmark/triggerShift.d.ts +62 -0
- package/dist/benchmark/triggerShift.js +106 -0
- package/dist/bootstrap/envFingerprint.d.ts +9 -0
- package/dist/bootstrap/envFingerprint.js +5 -0
- package/dist/bootstrap/index.d.ts +3 -1
- package/dist/bootstrap/index.js +3 -1
- package/dist/bootstrap/lifecycleBootstrap.d.ts +111 -0
- package/dist/bootstrap/lifecycleBootstrap.js +433 -0
- package/dist/bootstrap/v1EnvCompat.d.ts +113 -0
- package/dist/bootstrap/v1EnvCompat.js +303 -0
- package/dist/events/eventArchive.d.ts +2 -0
- package/dist/events/eventArchive.js +13 -3
- package/dist/events/eventSchema.d.ts +7 -7
- package/dist/events/eventStore.d.ts +2 -0
- package/dist/events/eventStore.js +5 -1
- package/dist/events/ingest.d.ts +2 -1
- package/dist/events/ingest.js +15 -0
- package/dist/events/paths.d.ts +12 -10
- package/dist/events/paths.js +24 -20
- package/dist/events/public.d.ts +2 -2
- package/dist/events/public.js +2 -2
- package/dist/events/reports.d.ts +2 -0
- package/dist/events/reports.js +4 -0
- package/dist/exec/autoExec.d.ts +68 -4
- package/dist/exec/autoExec.js +392 -33
- package/dist/exec/autonomousCycle.d.ts +31 -4
- package/dist/exec/autonomousCycle.js +71 -13
- package/dist/exec/claudeBridge.d.ts +80 -15
- package/dist/exec/claudeBridge.js +845 -76
- package/dist/exec/executionBinding.d.ts +414 -0
- package/dist/exec/executionBinding.js +588 -0
- package/dist/exec/index.d.ts +1 -0
- package/dist/exec/index.js +1 -0
- package/dist/exec/openPrRegistry.d.ts +8 -2
- package/dist/exec/openPrRegistry.js +32 -22
- package/dist/exec/prompt.js +14 -1
- package/dist/exec/proofOfWork.d.ts +1 -1
- package/dist/exec/proofOfWork.js +2 -2
- package/dist/exec/runnerRegistry.d.ts +153 -36
- package/dist/exec/runnerRegistry.js +848 -65
- package/dist/exec/selfPr.js +1 -7
- package/dist/feedback/envelope.d.ts +61 -0
- package/dist/feedback/envelope.js +168 -0
- package/dist/feedback/index.d.ts +1 -0
- package/dist/feedback/index.js +1 -0
- package/dist/hooks/hooks.js +1 -0
- package/dist/hub/assetCallLog.d.ts +35 -1
- package/dist/hub/assetCallLog.js +124 -1
- package/dist/hub/bindings.d.ts +8 -1
- package/dist/hub/bindings.js +29 -8
- package/dist/hub/capability.d.ts +130 -4
- package/dist/hub/conversationDistiller.d.ts +19 -0
- package/dist/hub/conversationDistiller.js +115 -37
- package/dist/hub/fake.d.ts +3 -2
- package/dist/hub/fake.js +2 -1
- package/dist/hub/index.d.ts +1 -0
- package/dist/hub/index.js +1 -0
- package/dist/hub/questionGenerator.d.ts +5 -1
- package/dist/hub/questionGenerator.js +8 -6
- package/dist/hub/recipeCompose.d.ts +27 -0
- package/dist/hub/recipeCompose.js +90 -0
- package/dist/hub/sanitize.js +122 -7
- package/dist/index.d.ts +6 -1
- package/dist/index.js +7 -1
- package/dist/issueReporter/index.d.ts +156 -0
- package/dist/issueReporter/index.js +1688 -0
- package/dist/mailbox/dispatch.d.ts +1 -1
- package/dist/mailbox/dispatch.js +22 -6
- package/dist/mailbox/envelope.d.ts +7 -1
- package/dist/mailbox/envelope.js +9 -2
- package/dist/mailbox/ipcServer.d.ts +12 -2
- package/dist/mailbox/ipcServer.js +183 -13
- package/dist/mailbox/store.d.ts +89 -3
- package/dist/mailbox/store.js +895 -41
- package/dist/modelCompatibility.d.ts +164 -0
- package/dist/modelCompatibility.js +309 -0
- package/dist/observers/valueDigestObserver.d.ts +9 -0
- package/dist/observers/valueDigestObserver.js +35 -2
- package/dist/ops/cleanup.js +1 -1
- package/dist/ops/evolutionGraphProjection.d.ts +20 -0
- package/dist/ops/evolutionGraphProjection.js +315 -0
- package/dist/ops/index.d.ts +2 -1
- package/dist/ops/index.js +2 -1
- package/dist/ops/savingsCore.js +1 -2
- package/dist/ops/selfUpdate.d.ts +18 -1
- package/dist/ops/selfUpdate.js +88 -23
- package/dist/ops/valueOutreach.d.ts +3 -1
- package/dist/ops/valueOutreach.js +5 -1
- package/dist/personality/schema.d.ts +24 -24
- package/dist/schema/evolutionGraph.d.ts +784 -0
- package/dist/schema/evolutionGraph.js +187 -0
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.js +1 -0
- package/dist/schema/proofOfWork.d.ts +125 -6
- package/dist/schema/proofOfWork.js +102 -4
- package/dist/schema/signal.d.ts +3 -3
- package/dist/schema/signal.js +1 -1
- package/dist/shadow/shadowHub.js +1 -0
- package/dist/signals/curriculum.d.ts +55 -0
- package/dist/signals/curriculum.js +202 -0
- package/dist/signals/cycleHistoryFromEvents.js +17 -8
- package/dist/signals/expand.d.ts +15 -1
- package/dist/signals/expand.js +169 -1
- package/dist/signals/extractor.d.ts +2 -2
- package/dist/signals/extractor.js +31 -6
- package/dist/signals/index.d.ts +4 -1
- package/dist/signals/index.js +4 -1
- package/dist/signals/metaSignals.d.ts +4 -0
- package/dist/signals/metaSignals.js +42 -0
- package/dist/signals/scopeVocabulary.d.ts +75 -0
- package/dist/signals/scopeVocabulary.js +91 -0
- package/dist/signals/signalGate.js +1 -1
- package/dist/signals/taskDomain.d.ts +22 -0
- package/dist/signals/taskDomain.js +43 -0
- package/dist/strategy/constraintAblation.d.ts +64 -0
- package/dist/strategy/constraintAblation.js +2820 -0
- package/dist/strategy/constraintAblationPredicates.d.ts +31 -0
- package/dist/strategy/constraintAblationPredicates.js +339 -0
- package/dist/strategy/index.d.ts +2 -1
- package/dist/strategy/index.js +2 -1
- package/dist/trace/index.d.ts +3 -1
- package/dist/trace/index.js +3 -1
- package/dist/trace/learningTrace.d.ts +216 -0
- package/dist/trace/learningTrace.js +298 -0
- package/dist/trace/proxyTurns.d.ts +31 -0
- package/dist/trace/proxyTurns.js +137 -0
- package/dist/trace/trajectory.d.ts +8 -0
- package/dist/trace/trajectory.js +14 -2
- package/dist/util/fetchPort.d.ts +1 -0
- package/dist/util/fetchPort.js +11 -0
- package/dist/util/fileLock.d.ts +113 -7
- package/dist/util/fileLock.js +1035 -80
- package/dist/util/index.d.ts +3 -1
- package/dist/util/index.js +2 -1
- package/dist/verify/index.d.ts +2 -1
- package/dist/verify/index.js +1 -1
- package/dist/verify/sandboxRunner.d.ts +30 -0
- package/dist/verify/sandboxRunner.js +370 -27
- package/dist/verify/sandboxedValidation.d.ts +16 -2
- package/dist/verify/sandboxedValidation.js +200 -22
- package/dist/verify/validation.d.ts +35 -4
- package/dist/verify/validation.js +164 -16
- package/dist/wire/geneHints.d.ts +88 -16
- package/dist/wire/geneHints.js +124 -15
- package/dist/wire/index.d.ts +8 -3
- package/dist/wire/index.js +2 -2
- package/dist/wire/schemaGate.d.ts +21 -0
- package/dist/wire/schemaGate.js +119 -10
- package/dist/workflow/dsl.d.ts +24 -3
- package/dist/workflow/dsl.js +4 -0
- package/dist/workflow/engine.d.ts +5 -1
- package/dist/workflow/engine.js +3 -0
- package/dist/workflow/index.d.ts +3 -1
- package/dist/workflow/index.js +3 -1
- package/dist/workflow/runtime.d.ts +110 -0
- package/dist/workflow/runtime.js +1298 -0
- package/dist/workflow/stateStore.d.ts +172 -0
- package/dist/workflow/stateStore.js +1044 -0
- package/package.json +12 -4
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export const RECIPE_COMPOSE_FLAG = 'compose_recipe';
|
|
2
|
+
function asRecord(value) {
|
|
3
|
+
return value && typeof value === 'object' && !Array.isArray(value)
|
|
4
|
+
? value
|
|
5
|
+
: null;
|
|
6
|
+
}
|
|
7
|
+
function assetType(asset) {
|
|
8
|
+
const typed = asset['type'] ?? asset['assetType'];
|
|
9
|
+
return typeof typed === 'string' ? typed : '';
|
|
10
|
+
}
|
|
11
|
+
function assetId(asset) {
|
|
12
|
+
const id = asset['asset_id'] ?? asset['assetId'];
|
|
13
|
+
return typeof id === 'string' ? id : '';
|
|
14
|
+
}
|
|
15
|
+
function assetSummary(asset) {
|
|
16
|
+
const summary = asset['summary'] ?? asset['shortTitle'] ?? asset['nlSummary'];
|
|
17
|
+
return typeof summary === 'string' ? summary : '';
|
|
18
|
+
}
|
|
19
|
+
export function recipeComposeRequested(payload) {
|
|
20
|
+
if (payload[RECIPE_COMPOSE_FLAG] === false)
|
|
21
|
+
return false;
|
|
22
|
+
if (payload['publish_recipe'] === false)
|
|
23
|
+
return false;
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
function shouldCompose(payload) {
|
|
27
|
+
return recipeComposeRequested(payload);
|
|
28
|
+
}
|
|
29
|
+
export function recipeAssetsFromPayload(payload) {
|
|
30
|
+
const assets = Array.isArray(payload.assets) ? payload.assets : [];
|
|
31
|
+
const records = assets.filter((item) => !!asRecord(item));
|
|
32
|
+
return {
|
|
33
|
+
gene: records.find((asset) => assetType(asset) === 'Gene'),
|
|
34
|
+
capsule: records.find((asset) => assetType(asset) === 'Capsule'),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* After a Gene/Capsule bundle is accepted by Hub, compose a Recipe as the
|
|
39
|
+
* preferred public artifact. Skill Store publish is not the default outbound.
|
|
40
|
+
* Missing recipe capability or missing Gene is a no-op, never a publish failure.
|
|
41
|
+
*/
|
|
42
|
+
export async function composeRecipeAfterAssetPublish(hub, payload) {
|
|
43
|
+
if (!shouldCompose(payload))
|
|
44
|
+
return { attempted: false, ok: true, reason: 'not_requested' };
|
|
45
|
+
const recipes = hub.recipes;
|
|
46
|
+
if (!recipes)
|
|
47
|
+
return { attempted: false, ok: true, reason: 'recipes_unsupported' };
|
|
48
|
+
const { gene, capsule } = recipeAssetsFromPayload(payload);
|
|
49
|
+
if (!gene)
|
|
50
|
+
return { attempted: false, ok: true, reason: 'gene_missing' };
|
|
51
|
+
const geneId = assetId(gene);
|
|
52
|
+
if (!geneId)
|
|
53
|
+
return { attempted: false, ok: true, reason: 'gene_missing' };
|
|
54
|
+
const title = String(payload.title || assetSummary(gene) || 'Reusable recipe').trim().slice(0, 200);
|
|
55
|
+
if (title.length < 3)
|
|
56
|
+
return { attempted: false, ok: true, reason: 'title_too_short' };
|
|
57
|
+
const description = String(payload.description || assetSummary(gene) || title).trim().slice(0, 2000);
|
|
58
|
+
const steps = [
|
|
59
|
+
{ assetId: geneId, assetType: 'Gene', position: 0 },
|
|
60
|
+
...(capsule && assetId(capsule)
|
|
61
|
+
? [{ assetId: assetId(capsule), assetType: 'Capsule', position: 1 }]
|
|
62
|
+
: []),
|
|
63
|
+
];
|
|
64
|
+
try {
|
|
65
|
+
const created = await recipes.create({
|
|
66
|
+
title,
|
|
67
|
+
description,
|
|
68
|
+
steps,
|
|
69
|
+
pricePerExecution: 5,
|
|
70
|
+
currency: 'Credit',
|
|
71
|
+
});
|
|
72
|
+
const recipeId = created.recipeId;
|
|
73
|
+
if (!recipeId)
|
|
74
|
+
return { attempted: true, ok: false, reason: 'recipe_id_missing' };
|
|
75
|
+
const published = await recipes.publish(recipeId);
|
|
76
|
+
return {
|
|
77
|
+
attempted: true,
|
|
78
|
+
ok: true,
|
|
79
|
+
recipeId,
|
|
80
|
+
status: published.status ?? created.status ?? 'published',
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
return {
|
|
85
|
+
attempted: true,
|
|
86
|
+
ok: false,
|
|
87
|
+
reason: error instanceof Error ? error.message : 'recipe_compose_failed',
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
package/dist/hub/sanitize.js
CHANGED
|
@@ -10,17 +10,15 @@ export const REDACTED = '[REDACTED]';
|
|
|
10
10
|
const REDACT_PATTERNS = [
|
|
11
11
|
// API keys & tokens (generic)
|
|
12
12
|
/Bearer\s+[A-Za-z0-9-._~+/]+=*/g,
|
|
13
|
-
|
|
13
|
+
/\bBasic\s+[A-Za-z0-9+/]{8,}={0,2}(?=$|[\s,;)}\]])/gi,
|
|
14
|
+
/\b(?:AIza[0-9A-Za-z_-]{20,}|ya29\.[0-9A-Za-z_-]{20,}|(?:xai|hf|glpat|dop_v1|pk_live|pk_test|sk_live|sk_test|rk_live|rk_test)[-_][A-Za-z0-9_-]{16,}|sq0(?:atp|csp)-[A-Za-z0-9_-]{16,})\b/g,
|
|
14
15
|
/sk-[A-Za-z0-9]{20,}/g,
|
|
15
|
-
|
|
16
|
-
/api[_-]?key[=:]\s*["']?[A-Za-z0-9-._~+/]{16,}["']?/gi,
|
|
17
|
-
/secret[=:]\s*["']?[A-Za-z0-9-._~+/]{16,}["']?/gi,
|
|
18
|
-
/password[=:]\s*["']?[^\s"',;)}\]]{6,}["']?/gi,
|
|
19
|
-
// GitHub tokens (ghp_, gho_, ghu_, ghs_, github_pat_)
|
|
16
|
+
// GitHub tokens (ghp_, gho_, ghu_, ghs_, ghr_, github_pat_)
|
|
20
17
|
/ghp_[A-Za-z0-9]{36,}/g,
|
|
21
18
|
/gho_[A-Za-z0-9]{36,}/g,
|
|
22
19
|
/ghu_[A-Za-z0-9]{36,}/g,
|
|
23
20
|
/ghs_[A-Za-z0-9]{36,}/g,
|
|
21
|
+
/ghr_[A-Za-z0-9]{36,}/g,
|
|
24
22
|
/github_pat_[A-Za-z0-9_]{22,}/g,
|
|
25
23
|
// AWS access keys
|
|
26
24
|
/AKIA[0-9A-Z]{16}/g,
|
|
@@ -54,6 +52,120 @@ const REDACT_PATTERNS = [
|
|
|
54
52
|
/\.env\.[a-zA-Z]+\b/g,
|
|
55
53
|
/(?<=[\\/])\.env\b/g,
|
|
56
54
|
];
|
|
55
|
+
// 结构化执行诊断可能来自 JSON、YAML 或键值输出,字段名与分隔符之间也可能有空格。
|
|
56
|
+
// 这里只识别字段前缀,值由下面两个小解析器分别读取:带引号的值读取到匹配的闭合引号,
|
|
57
|
+
// 不带引号的值在空白或结构分隔符处停止,避免把凭据后的普通说明文字一起吞掉。
|
|
58
|
+
const STRUCTURED_CREDENTIAL_PREFIX = /(?<![A-Za-z0-9_-])(["']?)(node[_-]?secret|access[_-]?token|refresh[_-]?token|id[_-]?token|session[_-]?token|api[_-]?key|client[_-]?secret|private[_-]?key|token|secret|password|passwd|passphrase|credential|credentials|authorization|auth|bearer|cookie|dsn|webhook|signature)\1(\s*[:=]\s*)/gi;
|
|
59
|
+
const OPAQUE_CREDENTIAL_PATTERN = /(?<![A-Za-z0-9_-])[A-Za-z0-9][A-Za-z0-9._~+=-]{31,}(?![A-Za-z0-9_-])/g;
|
|
60
|
+
const AMBIGUOUS_STRUCTURED_KEYS = new Set([
|
|
61
|
+
'token', 'secret', 'credential', 'credentials', 'authorization', 'auth', 'cookie', 'signature',
|
|
62
|
+
]);
|
|
63
|
+
const DIAGNOSTIC_STATUS_VALUE = /^(?:ok|success|successful|succeeded|failed|failure|pending|missing|invalid|expired|mismatch|denied|unavailable|refresh needed|not configured|not found|none|null|true|false|enabled|disabled|present|absent|unknown|skipped|unsupported)$/i;
|
|
64
|
+
const DIAGNOSTIC_ASSIGNMENT_VALUE = /^(?:policy|mode|state|status|configured|enabled)=(?:ok|success|successful|succeeded|failed|failure|pending|missing|invalid|expired|mismatch|denied|unavailable|none|null|true|false|enabled|disabled|present|absent|unknown|skipped|unsupported)$/i;
|
|
65
|
+
function unquoteStructuredValue(value) {
|
|
66
|
+
const trimmed = value.trim();
|
|
67
|
+
if (trimmed.length >= 2 && ((trimmed.startsWith('"') && trimmed.endsWith('"')) || (trimmed.startsWith("'") && trimmed.endsWith("'")))) {
|
|
68
|
+
return trimmed.slice(1, -1).trim();
|
|
69
|
+
}
|
|
70
|
+
return trimmed;
|
|
71
|
+
}
|
|
72
|
+
function shouldRedactStructuredField(key, rawValue) {
|
|
73
|
+
const normalizedKey = key.toLowerCase().replace(/[_-]/g, '');
|
|
74
|
+
if (!AMBIGUOUS_STRUCTURED_KEYS.has(normalizedKey))
|
|
75
|
+
return true;
|
|
76
|
+
const value = unquoteStructuredValue(rawValue);
|
|
77
|
+
const normalizedStatus = value.replace(/[_-]+/g, ' ').replace(/\s+/g, ' ').trim();
|
|
78
|
+
if (!value
|
|
79
|
+
|| /^\[redacted\]$/i.test(value)
|
|
80
|
+
|| DIAGNOSTIC_STATUS_VALUE.test(normalizedStatus)
|
|
81
|
+
|| DIAGNOSTIC_ASSIGNMENT_VALUE.test(value))
|
|
82
|
+
return false;
|
|
83
|
+
if (/^(?:Bearer|Digest|NTLM|Negotiate|AWS)\s+\S+/i.test(value))
|
|
84
|
+
return true;
|
|
85
|
+
if (/^Basic\s+[A-Za-z0-9+/]{8,}={0,2}$/i.test(value))
|
|
86
|
+
return true;
|
|
87
|
+
// 歧义字段只有在值呈现紧凑凭据形态时才脱敏,保留“auth: denied by policy”等诊断上下文。
|
|
88
|
+
return !/\s/.test(value) && value.length >= 8;
|
|
89
|
+
}
|
|
90
|
+
function readQuotedStructuredValue(input, start) {
|
|
91
|
+
const quote = input[start];
|
|
92
|
+
if (quote !== '"' && quote !== "'")
|
|
93
|
+
return undefined;
|
|
94
|
+
let escaped = false;
|
|
95
|
+
for (let index = start + 1; index < input.length; index += 1) {
|
|
96
|
+
const char = input[index];
|
|
97
|
+
if (escaped) {
|
|
98
|
+
escaped = false;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (char === '\\') {
|
|
102
|
+
escaped = true;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (char === quote) {
|
|
106
|
+
const end = index + 1;
|
|
107
|
+
return { end, raw: input.slice(start, end), quote };
|
|
108
|
+
}
|
|
109
|
+
if (char === '\r' || char === '\n')
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
function readUnquotedStructuredValue(input, start) {
|
|
115
|
+
if (input.startsWith(REDACTED, start)) {
|
|
116
|
+
return { end: start + REDACTED.length, raw: REDACTED, quote: '' };
|
|
117
|
+
}
|
|
118
|
+
let end = start;
|
|
119
|
+
while (end < input.length) {
|
|
120
|
+
const char = input[end] ?? '';
|
|
121
|
+
if (/[\s,;)}\]]/.test(char) || (char === ':' && /\s/.test(input[end + 1] ?? '')))
|
|
122
|
+
break;
|
|
123
|
+
end += 1;
|
|
124
|
+
}
|
|
125
|
+
if (end === start)
|
|
126
|
+
return undefined;
|
|
127
|
+
return { end, raw: input.slice(start, end), quote: '' };
|
|
128
|
+
}
|
|
129
|
+
function redactStructuredCredentials(input) {
|
|
130
|
+
let cursor = 0;
|
|
131
|
+
let output = '';
|
|
132
|
+
STRUCTURED_CREDENTIAL_PREFIX.lastIndex = 0;
|
|
133
|
+
let match = STRUCTURED_CREDENTIAL_PREFIX.exec(input);
|
|
134
|
+
while (match) {
|
|
135
|
+
if (match.index < cursor) {
|
|
136
|
+
match = STRUCTURED_CREDENTIAL_PREFIX.exec(input);
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
const valueStart = STRUCTURED_CREDENTIAL_PREFIX.lastIndex;
|
|
140
|
+
const span = readQuotedStructuredValue(input, valueStart) ?? readUnquotedStructuredValue(input, valueStart);
|
|
141
|
+
if (!span) {
|
|
142
|
+
match = STRUCTURED_CREDENTIAL_PREFIX.exec(input);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
output += input.slice(cursor, valueStart);
|
|
146
|
+
output += shouldRedactStructuredField(match[2] ?? '', span.raw)
|
|
147
|
+
? `${span.quote}${REDACTED}${span.quote}`
|
|
148
|
+
: span.raw;
|
|
149
|
+
cursor = span.end;
|
|
150
|
+
STRUCTURED_CREDENTIAL_PREFIX.lastIndex = span.end;
|
|
151
|
+
match = STRUCTURED_CREDENTIAL_PREFIX.exec(input);
|
|
152
|
+
}
|
|
153
|
+
return cursor === 0 ? input : output + input.slice(cursor);
|
|
154
|
+
}
|
|
155
|
+
function isOpaqueCredential(candidate) {
|
|
156
|
+
const compact = candidate.replace(/[._~+/=-]/g, '');
|
|
157
|
+
const classes = Number(/[a-z]/.test(compact)) + Number(/[A-Z]/.test(compact)) + Number(/[0-9]/.test(compact));
|
|
158
|
+
if (compact.length < 24 || classes < 3 || /^[0-9a-f]+$/i.test(compact))
|
|
159
|
+
return false;
|
|
160
|
+
const frequencies = new Map();
|
|
161
|
+
for (const char of compact)
|
|
162
|
+
frequencies.set(char, (frequencies.get(char) ?? 0) + 1);
|
|
163
|
+
const entropy = [...frequencies.values()].reduce((sum, count) => {
|
|
164
|
+
const probability = count / compact.length;
|
|
165
|
+
return sum - probability * Math.log2(probability);
|
|
166
|
+
}, 0);
|
|
167
|
+
return entropy >= 3.5;
|
|
168
|
+
}
|
|
57
169
|
// Post-filter allowlist (ported from v1 src/gep/sanitize.js, PR #151): strings the patterns above — and the path
|
|
58
170
|
// anonymizer below — WILL catch but that are not actually sensitive. If any entry matches a captured string it is
|
|
59
171
|
// kept verbatim instead of being redacted / anonymized / flagged as a leak. Keeping this as a post-filter rather
|
|
@@ -103,6 +215,9 @@ export function redactString(s) {
|
|
|
103
215
|
p.lastIndex = 0;
|
|
104
216
|
out = out.replace(p, (m) => (isAllowlisted(m) ? m : REDACTED));
|
|
105
217
|
}
|
|
218
|
+
out = redactStructuredCredentials(out);
|
|
219
|
+
OPAQUE_CREDENTIAL_PATTERN.lastIndex = 0;
|
|
220
|
+
out = out.replace(OPAQUE_CREDENTIAL_PATTERN, (candidate) => (isOpaqueCredential(candidate) ? REDACTED : candidate));
|
|
106
221
|
for (const [p, rep] of ANONYMIZE_PATTERNS) {
|
|
107
222
|
p.lastIndex = 0;
|
|
108
223
|
out = out.replace(p, (m) => (isAllowlisted(m) ? m : rep));
|
|
@@ -139,7 +254,7 @@ const LEAK_SCANNERS = [
|
|
|
139
254
|
{ type: 'api_key', pattern: /sk-proj-[A-Za-z0-9-_]{20,}/g, suggest: 'process.env.OPENAI_API_KEY' },
|
|
140
255
|
{ type: 'api_key', pattern: /sk-ant-[A-Za-z0-9-_]{20,}/g, suggest: 'process.env.ANTHROPIC_API_KEY' },
|
|
141
256
|
{ type: 'api_key', pattern: /AKIA[0-9A-Z]{16}/g, suggest: 'process.env.AWS_ACCESS_KEY_ID' },
|
|
142
|
-
{ type: 'github_token', pattern: /
|
|
257
|
+
{ type: 'github_token', pattern: /gh(?:p|o|u|s|r)_[A-Za-z0-9]{36,}/g, suggest: 'process.env.GITHUB_TOKEN' },
|
|
143
258
|
{ type: 'github_token', pattern: /github_pat_[A-Za-z0-9_]{22,}/g, suggest: 'process.env.GITHUB_TOKEN' },
|
|
144
259
|
{ type: 'npm_token', pattern: /npm_[A-Za-z0-9]{36,}/g, suggest: 'process.env.NPM_TOKEN' },
|
|
145
260
|
{ type: 'slack_token', pattern: /xox[baprsv]-[A-Za-z0-9-]{10,}/g, suggest: 'process.env.SLACK_TOKEN' },
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * as daemon from './daemon/index.js';
|
|
|
10
10
|
export * as material from './material/index.js';
|
|
11
11
|
export * as mailbox from './mailbox/index.js';
|
|
12
12
|
export * as assetstore from './assetstore/index.js';
|
|
13
|
+
export * as assetrepair from './assetrepair/index.js';
|
|
13
14
|
export * as strategy from './strategy/index.js';
|
|
14
15
|
export * as algo from './algo/index.js';
|
|
15
16
|
export * as personality from './personality/index.js';
|
|
@@ -24,4 +25,8 @@ export * as hub from './hub/index.js';
|
|
|
24
25
|
export * as shadow from './shadow/index.js';
|
|
25
26
|
export * as ops from './ops/index.js';
|
|
26
27
|
export * as util from './util/index.js';
|
|
27
|
-
export * as trace from './trace/index.js';
|
|
28
|
+
export * as trace from './trace/index.js';
|
|
29
|
+
export * as issueReporter from './issueReporter/index.js';
|
|
30
|
+
export * as feedback from './feedback/index.js';
|
|
31
|
+
export * as compatibility from './modelCompatibility.js';
|
|
32
|
+
export { isValidationCommandAllowed } from './verify/validation.js';
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export * as daemon from './daemon/index.js';
|
|
|
10
10
|
export * as material from './material/index.js';
|
|
11
11
|
export * as mailbox from './mailbox/index.js';
|
|
12
12
|
export * as assetstore from './assetstore/index.js';
|
|
13
|
+
export * as assetrepair from './assetrepair/index.js';
|
|
13
14
|
export * as strategy from './strategy/index.js';
|
|
14
15
|
export * as algo from './algo/index.js';
|
|
15
16
|
export * as personality from './personality/index.js';
|
|
@@ -24,4 +25,9 @@ export * as hub from './hub/index.js';
|
|
|
24
25
|
export * as shadow from './shadow/index.js';
|
|
25
26
|
export * as ops from './ops/index.js';
|
|
26
27
|
export * as util from './util/index.js';
|
|
27
|
-
export * as trace from './trace/index.js';
|
|
28
|
+
export * as trace from './trace/index.js';
|
|
29
|
+
export * as issueReporter from './issueReporter/index.js';
|
|
30
|
+
export * as feedback from './feedback/index.js';
|
|
31
|
+
export * as compatibility from './modelCompatibility.js';
|
|
32
|
+
// Re-export commonly used validation functions at top level for convenience
|
|
33
|
+
export { isValidationCommandAllowed } from './verify/validation.js';
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { type EnvFingerprint } from '../bootstrap/envFingerprint.js';
|
|
2
|
+
export type IssueReportSource = 'cycle_failure' | 'doctor' | 'review' | 'event';
|
|
3
|
+
export type IssueDraftStatus = 'draft' | 'rejected' | 'submitted';
|
|
4
|
+
export declare function isIssueReportSource(value: unknown): value is IssueReportSource;
|
|
5
|
+
export interface IssueReportInput {
|
|
6
|
+
source: IssueReportSource;
|
|
7
|
+
errorClass: string;
|
|
8
|
+
cycleIds?: readonly string[];
|
|
9
|
+
eventIds?: readonly string[];
|
|
10
|
+
traceIds?: readonly string[];
|
|
11
|
+
reproductionSteps?: readonly string[];
|
|
12
|
+
diagnosticCodes?: readonly string[];
|
|
13
|
+
failureClass?: string;
|
|
14
|
+
version?: string;
|
|
15
|
+
platform?: string;
|
|
16
|
+
arch?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface IssueDraft {
|
|
19
|
+
schemaVersion: 1;
|
|
20
|
+
fingerprint: string;
|
|
21
|
+
status: IssueDraftStatus;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
updatedAt: string;
|
|
24
|
+
title: string;
|
|
25
|
+
body: string;
|
|
26
|
+
source: IssueReportSource;
|
|
27
|
+
errorClass: string;
|
|
28
|
+
cycleIds: string[];
|
|
29
|
+
eventIds: string[];
|
|
30
|
+
traceRefs: string[];
|
|
31
|
+
github?: {
|
|
32
|
+
issueNumber: number;
|
|
33
|
+
url: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export interface IssueReporterOptions {
|
|
37
|
+
rootDir: string;
|
|
38
|
+
workspaceScope?: string;
|
|
39
|
+
now?: () => Date;
|
|
40
|
+
env?: Record<string, string | undefined>;
|
|
41
|
+
envFingerprint?: Partial<EnvFingerprint>;
|
|
42
|
+
dedupWindowMs?: number;
|
|
43
|
+
rateLimitWindowMs?: number;
|
|
44
|
+
maxSubmissionsPerWindow?: number;
|
|
45
|
+
logger?: (entry: IssueReporterLogEntry) => void;
|
|
46
|
+
}
|
|
47
|
+
export interface IssueReporterLogEntry {
|
|
48
|
+
fingerprint: string;
|
|
49
|
+
status: 'draft_created' | 'duplicate' | 'rejected' | 'submitted' | 'submission_failed' | 'rate_limited';
|
|
50
|
+
errorClass?: 'approval_required' | 'rate_limited' | 'transport_error' | 'invalid_response' | 'unsafe_draft' | 'local_finalize_error' | 'quota_persistence_error';
|
|
51
|
+
}
|
|
52
|
+
export interface GithubIssueTransport {
|
|
53
|
+
listOpenIssues(input: {
|
|
54
|
+
repo: string;
|
|
55
|
+
page: number;
|
|
56
|
+
perPage: number;
|
|
57
|
+
}): Promise<{
|
|
58
|
+
issues: Array<{
|
|
59
|
+
number: number;
|
|
60
|
+
url: string;
|
|
61
|
+
body: string;
|
|
62
|
+
isPullRequest: boolean;
|
|
63
|
+
}>;
|
|
64
|
+
hasNextPage: boolean;
|
|
65
|
+
}>;
|
|
66
|
+
createIssue(input: {
|
|
67
|
+
repo: string;
|
|
68
|
+
title: string;
|
|
69
|
+
body: string;
|
|
70
|
+
}): Promise<{
|
|
71
|
+
number: number;
|
|
72
|
+
url: string;
|
|
73
|
+
}>;
|
|
74
|
+
}
|
|
75
|
+
export declare class GithubIssueTransportError extends Error {
|
|
76
|
+
readonly outcome: 'not_created' | 'ambiguous';
|
|
77
|
+
constructor(outcome: 'not_created' | 'ambiguous');
|
|
78
|
+
}
|
|
79
|
+
export interface SubmitIssueOptions {
|
|
80
|
+
repo: string;
|
|
81
|
+
approved: boolean;
|
|
82
|
+
approvalSource?: 'human' | 'operator_policy';
|
|
83
|
+
transport: GithubIssueTransport;
|
|
84
|
+
}
|
|
85
|
+
export type DraftResult = {
|
|
86
|
+
status: 'created';
|
|
87
|
+
draft: IssueDraft;
|
|
88
|
+
} | {
|
|
89
|
+
status: 'duplicate';
|
|
90
|
+
draft: IssueDraft;
|
|
91
|
+
};
|
|
92
|
+
export type SubmitResult = {
|
|
93
|
+
status: 'submitted';
|
|
94
|
+
draft: IssueDraft;
|
|
95
|
+
errorClass?: 'local_finalize_error' | 'quota_persistence_error';
|
|
96
|
+
} | {
|
|
97
|
+
status: 'already_submitted';
|
|
98
|
+
draft: IssueDraft;
|
|
99
|
+
} | {
|
|
100
|
+
status: 'approval_required';
|
|
101
|
+
draft: IssueDraft;
|
|
102
|
+
} | {
|
|
103
|
+
status: 'rejected';
|
|
104
|
+
draft: IssueDraft;
|
|
105
|
+
} | {
|
|
106
|
+
status: 'rate_limited';
|
|
107
|
+
draft: IssueDraft;
|
|
108
|
+
errorClass?: 'issue_report_submission_in_flight' | 'issue_report_submission_ambiguous';
|
|
109
|
+
} | {
|
|
110
|
+
status: 'failed';
|
|
111
|
+
draft: IssueDraft;
|
|
112
|
+
errorClass: 'transport_error' | 'invalid_response' | 'unsafe_draft' | 'local_finalize_error';
|
|
113
|
+
};
|
|
114
|
+
export type IssueDraftConflictErrorClass = 'issue_report_submission_in_flight' | 'issue_report_submission_ambiguous';
|
|
115
|
+
export declare class IssueDraftConflictError extends Error {
|
|
116
|
+
readonly errorClass: IssueDraftConflictErrorClass;
|
|
117
|
+
constructor(errorClass: IssueDraftConflictErrorClass);
|
|
118
|
+
}
|
|
119
|
+
export declare function createIssueDraft(input: IssueReportInput, options: IssueReporterOptions): DraftResult;
|
|
120
|
+
export declare function rejectIssueDraft(draft: IssueDraft, options: IssueReporterOptions): IssueDraft;
|
|
121
|
+
export declare function submitIssueDraft(draft: IssueDraft, submit: SubmitIssueOptions, options: IssueReporterOptions): Promise<SubmitResult>;
|
|
122
|
+
export type IssueDraftLookupResult = {
|
|
123
|
+
status: 'found';
|
|
124
|
+
draft: IssueDraft;
|
|
125
|
+
} | {
|
|
126
|
+
status: 'missing' | 'invalid';
|
|
127
|
+
};
|
|
128
|
+
export declare function lookupIssueDraft(rootDir: string, fingerprint: string): IssueDraftLookupResult;
|
|
129
|
+
export declare function loadIssueDraft(rootDir: string, fingerprint: string): IssueDraft | null;
|
|
130
|
+
export type IssueSubmissionResolution = {
|
|
131
|
+
outcome: 'not_created' | 'abandoned';
|
|
132
|
+
} | {
|
|
133
|
+
outcome: 'submitted';
|
|
134
|
+
issueNumber: number;
|
|
135
|
+
url: string;
|
|
136
|
+
repo: string;
|
|
137
|
+
};
|
|
138
|
+
export declare function resolveIssueSubmission(fingerprint: string, resolution: IssueSubmissionResolution, options: IssueReporterOptions): IssueDraft;
|
|
139
|
+
export interface IssueReportEvent {
|
|
140
|
+
type: string;
|
|
141
|
+
eventId?: string;
|
|
142
|
+
payload?: Record<string, unknown>;
|
|
143
|
+
}
|
|
144
|
+
export interface IssueReportDoctorCheck {
|
|
145
|
+
name: string;
|
|
146
|
+
status: 'pass' | 'warn' | 'fail';
|
|
147
|
+
}
|
|
148
|
+
export interface IssueReportReviewRecord {
|
|
149
|
+
assetId: string;
|
|
150
|
+
state: 'quarantined' | 'approved' | 'rejected';
|
|
151
|
+
}
|
|
152
|
+
export declare function issueReportInputFromCycle(events: readonly IssueReportEvent[], cycleId: string): IssueReportInput | null;
|
|
153
|
+
export declare function issueReportInputFromDoctor(checks: readonly IssueReportDoctorCheck[]): IssueReportInput | null;
|
|
154
|
+
export declare function issueReportInputFromReview(record: IssueReportReviewRecord): IssueReportInput | null;
|
|
155
|
+
export declare function issueReportInputFromEvent(event: IssueReportEvent): IssueReportInput | null;
|
|
156
|
+
export declare function createIssueDraftForEventBestEffort(event: IssueReportEvent, options: IssueReporterOptions): DraftResult | null;
|