@guilz-dev/belay 0.9.3 → 0.10.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 +38 -3
- package/dist/adapters/codex/hooks.d.ts +1 -0
- package/dist/adapters/codex/hooks.js +3 -0
- package/dist/adapters/cursor/dispatcher-generation.d.ts +3 -0
- package/dist/adapters/cursor/dispatcher-generation.js +5 -0
- package/dist/adapters/cursor/hook-dispatch-entry.d.ts +10 -0
- package/dist/adapters/cursor/hook-dispatch-entry.js +137 -0
- package/dist/adapters/cursor/hook-router.d.ts +23 -0
- package/dist/adapters/cursor/hook-router.js +273 -0
- package/dist/adapters/cursor/hooks.d.ts +5 -1
- package/dist/adapters/cursor/hooks.js +112 -10
- package/dist/adapters/cursor/routing-config-trust.d.ts +1 -0
- package/dist/adapters/cursor/routing-config-trust.js +67 -0
- package/dist/adapters/cursor/routing-layout.d.ts +5 -0
- package/dist/adapters/cursor/routing-layout.js +29 -0
- package/dist/adapters/cursor/runtime-entry.d.ts +17 -0
- package/dist/adapters/cursor/runtime-entry.js +74 -49
- package/dist/adapters/layouts/scope.d.ts +5 -0
- package/dist/adapters/layouts/scope.js +71 -0
- package/dist/adapters/shared/gate-runtime.js +29 -17
- package/dist/bundle/claude-runtime.mjs +2428 -2072
- package/dist/bundle/codex-runtime.mjs +2440 -2084
- package/dist/bundle/cursor-dispatcher.mjs +517 -0
- package/dist/bundle/cursor-runtime.mjs +2521 -2133
- package/dist/cli.js +53 -4
- package/dist/commands/approval-token.d.ts +10 -0
- package/dist/commands/approval-token.js +26 -0
- package/dist/commands/audit.d.ts +2 -1
- package/dist/commands/audit.js +2 -2
- package/dist/commands/config.d.ts +1 -1
- package/dist/commands/config.js +28 -2
- package/dist/commands/doctor.js +149 -17
- package/dist/commands/dogfood-check.d.ts +3 -0
- package/dist/commands/dogfood-check.js +116 -0
- package/dist/commands/dogfood.d.ts +1 -0
- package/dist/commands/dogfood.js +4 -3
- package/dist/commands/health-snapshot.js +9 -4
- package/dist/commands/judge.js +2 -2
- package/dist/commands/recovery-checkpoints.d.ts +3 -3
- package/dist/commands/recovery-checkpoints.js +2 -11
- package/dist/config-io.d.ts +1 -0
- package/dist/config-io.js +19 -3
- package/dist/core/audit-legacy-archive.js +43 -25
- package/dist/core/classify-tool.js +16 -8
- package/dist/core/dogfood-environment.d.ts +8 -0
- package/dist/core/dogfood-environment.js +55 -0
- package/dist/core/effect-ir/argv-delegate.d.ts +9 -0
- package/dist/core/effect-ir/argv-delegate.js +42 -0
- package/dist/core/effect-ir/shell-lower/argv-delegate-gate.d.ts +3 -0
- package/dist/core/effect-ir/shell-lower/argv-delegate-gate.js +40 -0
- package/dist/core/effect-ir/shell-lower/augment.d.ts +4 -0
- package/dist/core/effect-ir/shell-lower/augment.js +97 -0
- package/dist/core/effect-ir/shell-lower/context.d.ts +10 -0
- package/dist/core/effect-ir/shell-lower/context.js +1 -0
- package/dist/core/effect-ir/shell-lower/decode-process.d.ts +9 -0
- package/dist/core/effect-ir/shell-lower/decode-process.js +201 -0
- package/dist/core/effect-ir/shell-lower/decoders/belay.d.ts +2 -0
- package/dist/core/effect-ir/shell-lower/decoders/belay.js +41 -0
- package/dist/core/effect-ir/shell-lower/decoders/builtins.d.ts +7 -0
- package/dist/core/effect-ir/shell-lower/decoders/builtins.js +194 -0
- package/dist/core/effect-ir/shell-lower/decoders/decode-package-exec.d.ts +4 -0
- package/dist/core/effect-ir/shell-lower/decoders/decode-package-exec.js +68 -0
- package/dist/core/effect-ir/shell-lower/decoders/docker.d.ts +3 -0
- package/dist/core/effect-ir/shell-lower/decoders/docker.js +43 -0
- package/dist/core/effect-ir/shell-lower/decoders/filesystem.d.ts +9 -0
- package/dist/core/effect-ir/shell-lower/decoders/filesystem.js +217 -0
- package/dist/core/effect-ir/shell-lower/decoders/prisma.d.ts +2 -0
- package/dist/core/effect-ir/shell-lower/decoders/prisma.js +54 -0
- package/dist/core/effect-ir/shell-lower/decoders/ruby.d.ts +11 -0
- package/dist/core/effect-ir/shell-lower/decoders/ruby.js +147 -0
- package/dist/core/effect-ir/shell-lower/decoders/toolchain.d.ts +7 -0
- package/dist/core/effect-ir/shell-lower/decoders/toolchain.js +155 -0
- package/dist/core/effect-ir/shell-lower/requirement.d.ts +12 -0
- package/dist/core/effect-ir/shell-lower/requirement.js +65 -0
- package/dist/core/effect-ir/shell-lower/segment.d.ts +11 -0
- package/dist/core/effect-ir/shell-lower/segment.js +82 -0
- package/dist/core/effect-ir/shell-lower/tokens.d.ts +26 -0
- package/dist/core/effect-ir/shell-lower/tokens.js +183 -0
- package/dist/core/effect-ir/shell-lower.d.ts +2 -7
- package/dist/core/effect-ir/shell-lower.js +60 -1502
- package/dist/core/egress-approval.js +0 -18
- package/dist/core/glob.js +32 -16
- package/dist/core/integrity.d.ts +2 -2
- package/dist/core/integrity.js +52 -12
- package/dist/core/notify.d.ts +8 -2
- package/dist/core/notify.js +63 -7
- package/dist/core/recovery/operator-guidance.js +4 -4
- package/dist/core/replay-scrub.d.ts +2 -0
- package/dist/core/replay-scrub.js +8 -0
- package/dist/core/repo-config-trust.d.ts +31 -0
- package/dist/core/repo-config-trust.js +152 -0
- package/dist/core/shell-substitution.js +2 -2
- package/dist/core/shell-unparseable.js +3 -1
- package/dist/corpus/benign-probe-cores.d.ts +1 -1
- package/dist/corpus/benign-probe-cores.js +0 -1
- package/dist/defaults.d.ts +7 -3
- package/dist/defaults.js +29 -47
- package/dist/installer/bootstrap.d.ts +1 -0
- package/dist/installer/bootstrap.js +2 -2
- package/dist/installer/runtime-artifacts.js +43 -13
- package/dist/installer/scope-config.js +2 -2
- package/dist/installer.js +48 -13
- package/dist/node-resolution.d.ts +1 -0
- package/dist/node-resolution.js +61 -0
- package/dist/templates.d.ts +7 -4
- package/dist/templates.js +42 -4
- package/dist/types.d.ts +20 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -1
|
@@ -5,7 +5,6 @@ import path from 'node:path';
|
|
|
5
5
|
import { compactApprovals, createApprovalRecordWithEnvelope } from '../../core/approval.js';
|
|
6
6
|
import { buildReplayHint, buildRetryInstructionForConfig, canAutoReplay, getExecutionLeaseMs, validateReplayEnvelope, } from '../../core/approval-replay.js';
|
|
7
7
|
import { claimApprovedForReplay, gateApprovalStoreFromDeps, recordApproval, } from '../../core/approval-service.js';
|
|
8
|
-
import { issueApprovalToken } from '../../core/approval-token.js';
|
|
9
8
|
import { buildAuditActionSnapshot, buildAuditReplayContext, } from '../../core/audit-replay-context.js';
|
|
10
9
|
import { approvalCorrelationId, serializeAuditRecordV3, toolInvocationCorrelationId, } from '../../core/audit-serialize.js';
|
|
11
10
|
import { boundedUtf8Tail } from '../../core/bounded-output.js';
|
|
@@ -37,6 +36,7 @@ import { notifyDeny } from '../../core/notify.js';
|
|
|
37
36
|
import { canonicalPath } from '../../core/path-utils.js';
|
|
38
37
|
import { recoveryFailClosedResult, recoveryFailReasonFromSkip, } from '../../core/recovery/fail-closed.js';
|
|
39
38
|
import { fingerprintReplayPayload, redactToolInvocationId } from '../../core/replay-scrub.js';
|
|
39
|
+
import { assertRepoConfigTrusted } from '../../core/repo-config-trust.js';
|
|
40
40
|
import { FILE_CHECKPOINT_ISOLATION_UNAVAILABLE, isTransactionalEligible, runTransactionalExecution, TRANSACTIONAL_ALREADY_APPLIED, TRANSACTIONAL_APPROVAL_BYPASS_REASONS, } from '../../core/transactional/index.js';
|
|
41
41
|
import { buildAuditProvenanceFields } from '../../runtime-provenance.js';
|
|
42
42
|
import { egressStatus } from '../../services/egress-service.js';
|
|
@@ -91,7 +91,15 @@ async function loadJsonFile(filePath, fallback) {
|
|
|
91
91
|
export function createDefaultGateRuntimeDeps() {
|
|
92
92
|
return {
|
|
93
93
|
async readConfig(configPath) {
|
|
94
|
-
|
|
94
|
+
try {
|
|
95
|
+
return JSON.parse(await readFile(configPath, 'utf8'));
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
if (error.code === 'ENOENT') {
|
|
99
|
+
return {};
|
|
100
|
+
}
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
95
103
|
},
|
|
96
104
|
async appendAudit(ctx, event) {
|
|
97
105
|
const auditPath = path.join(ctx.repoRoot, ctx.config.audit.logPath);
|
|
@@ -149,6 +157,7 @@ export function createDefaultGateRuntimeDeps() {
|
|
|
149
157
|
}
|
|
150
158
|
export async function resolveGateConfig(ctx, deps) {
|
|
151
159
|
const loaded = await deps.readConfig(ctx.configPath);
|
|
160
|
+
await assertRepoConfigTrusted(ctx.repoRoot, ctx.layout.name, loaded);
|
|
152
161
|
let teamConfig = null;
|
|
153
162
|
const teamPath = teamConfigPath();
|
|
154
163
|
if (existsSync(teamPath)) {
|
|
@@ -675,7 +684,23 @@ export async function evaluateGatedAction(ctx, deps, params) {
|
|
|
675
684
|
...authorization,
|
|
676
685
|
egressProxyActive,
|
|
677
686
|
};
|
|
678
|
-
|
|
687
|
+
let predicted = await classifyGatedActionAsync(action, ctx.config, enrichedClassifierOptions);
|
|
688
|
+
if (action.kind === 'tool' &&
|
|
689
|
+
predicted.reason === 'unclassified_tool' &&
|
|
690
|
+
(ctx.config.policy.codexUnmappedTool ?? 'deny') === 'deny') {
|
|
691
|
+
predicted = {
|
|
692
|
+
...predicted,
|
|
693
|
+
verdict: 'deny_pending_approval',
|
|
694
|
+
reason: 'unmapped_tool',
|
|
695
|
+
assessment: {
|
|
696
|
+
reversibility: 'irreversible',
|
|
697
|
+
external: false,
|
|
698
|
+
blastRadius: 'unknown tool action',
|
|
699
|
+
confidence: 0.5,
|
|
700
|
+
signals: ['unmapped_tool'],
|
|
701
|
+
},
|
|
702
|
+
};
|
|
703
|
+
}
|
|
679
704
|
if (action.kind === 'shell' &&
|
|
680
705
|
action.command &&
|
|
681
706
|
isContainedUnknownExecutionEligible(ctx.config, action, predicted)) {
|
|
@@ -910,6 +935,7 @@ async function gateDecisionToVerdict(ctx, deps, kind, result, auditExtras = {})
|
|
|
910
935
|
event: auditEvent,
|
|
911
936
|
sourceEvent,
|
|
912
937
|
kind,
|
|
938
|
+
repoLabel: path.basename(ctx.repoRoot),
|
|
913
939
|
...(auditExtras.toolInvocationCorrelationId
|
|
914
940
|
? { toolInvocationCorrelationId: auditExtras.toolInvocationCorrelationId }
|
|
915
941
|
: {}),
|
|
@@ -936,19 +962,6 @@ async function gateDecisionToVerdict(ctx, deps, kind, result, auditExtras = {})
|
|
|
936
962
|
if (created) {
|
|
937
963
|
await recordGateApprovalAsk(stateDir, result.reason, false);
|
|
938
964
|
}
|
|
939
|
-
let approvalToken;
|
|
940
|
-
try {
|
|
941
|
-
approvalToken = await issueApprovalToken({
|
|
942
|
-
approvalId: approval.approvalId,
|
|
943
|
-
fingerprint: approval.fingerprint,
|
|
944
|
-
repoRoot: approval.repoRoot,
|
|
945
|
-
issuedAt: approval.createdAt,
|
|
946
|
-
expiresAt: approval.expiresAt,
|
|
947
|
-
}, configuredControlPlaneDir(ctx.config));
|
|
948
|
-
}
|
|
949
|
-
catch {
|
|
950
|
-
approvalToken = undefined;
|
|
951
|
-
}
|
|
952
965
|
const denialReason = failure?.reason ?? result.reason;
|
|
953
966
|
if (ctx.config.notifications.webhookUrl || ctx.config.notifications.commandHook) {
|
|
954
967
|
await notifyDeny(ctx.config.notifications, {
|
|
@@ -957,7 +970,6 @@ async function gateDecisionToVerdict(ctx, deps, kind, result, auditExtras = {})
|
|
|
957
970
|
summary: result.normalizedCommand ?? result.summary ?? '',
|
|
958
971
|
repoRoot: ctx.repoRoot,
|
|
959
972
|
fingerprint: result.fingerprint,
|
|
960
|
-
approvalToken,
|
|
961
973
|
});
|
|
962
974
|
}
|
|
963
975
|
const failureAuditFields = typeof failure?.auditFields === 'function'
|