@sixsevenai/ai-dlc 1.2.5 → 1.2.6
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/dist/cli.mjs +191 -2
- package/package.json +29 -29
package/dist/cli.mjs
CHANGED
|
@@ -24033,7 +24033,7 @@ function filterResponses(responses, config, context, expectedFormat) {
|
|
|
24033
24033
|
}
|
|
24034
24034
|
return { valid, flagged };
|
|
24035
24035
|
}
|
|
24036
|
-
var HEDGING_PATTERNS;
|
|
24036
|
+
var HEDGING_PATTERNS, DEFAULT_RED_FLAG_CONFIG;
|
|
24037
24037
|
var init_red_flag_filter = __esm({
|
|
24038
24038
|
"maker/red-flag-filter.ts"() {
|
|
24039
24039
|
"use strict";
|
|
@@ -24058,6 +24058,13 @@ var init_red_flag_filter = __esm({
|
|
|
24058
24058
|
/\bif I understand correctly\b/i,
|
|
24059
24059
|
/\bto the best of my knowledge\b/i
|
|
24060
24060
|
];
|
|
24061
|
+
DEFAULT_RED_FLAG_CONFIG = {
|
|
24062
|
+
maxTokens: 700,
|
|
24063
|
+
hedgingThreshold: 0,
|
|
24064
|
+
// Zero tolerance
|
|
24065
|
+
formatStrictness: "high",
|
|
24066
|
+
repetitionLimit: 3
|
|
24067
|
+
};
|
|
24061
24068
|
}
|
|
24062
24069
|
});
|
|
24063
24070
|
|
|
@@ -25768,6 +25775,112 @@ function createCliAgentSpawner() {
|
|
|
25768
25775
|
};
|
|
25769
25776
|
};
|
|
25770
25777
|
}
|
|
25778
|
+
async function handleMakerApplyFilter(args) {
|
|
25779
|
+
let responses;
|
|
25780
|
+
try {
|
|
25781
|
+
responses = JSON.parse(args.responsesJson);
|
|
25782
|
+
} catch (e) {
|
|
25783
|
+
return { ok: false, error: `Invalid JSON in --responses-json: ${e}` };
|
|
25784
|
+
}
|
|
25785
|
+
if (!Array.isArray(responses)) {
|
|
25786
|
+
return { ok: false, error: "--responses-json must be a JSON array" };
|
|
25787
|
+
}
|
|
25788
|
+
const config = {
|
|
25789
|
+
...DEFAULT_RED_FLAG_CONFIG,
|
|
25790
|
+
...args.maxTokens !== void 0 && { maxTokens: args.maxTokens },
|
|
25791
|
+
...args.hedgingThreshold !== void 0 && { hedgingThreshold: args.hedgingThreshold },
|
|
25792
|
+
...args.formatStrictness !== void 0 && { formatStrictness: args.formatStrictness },
|
|
25793
|
+
...args.repetitionLimit !== void 0 && { repetitionLimit: args.repetitionLimit }
|
|
25794
|
+
};
|
|
25795
|
+
const result = filterResponses(responses, config, args.context, args.expectedFormat);
|
|
25796
|
+
const flaggedByRule = {
|
|
25797
|
+
token_overflow: 0,
|
|
25798
|
+
hedging_language: 0,
|
|
25799
|
+
format_violation: 0,
|
|
25800
|
+
context_drift: 0,
|
|
25801
|
+
repetition: 0
|
|
25802
|
+
};
|
|
25803
|
+
for (const f of result.flagged) {
|
|
25804
|
+
if (f.flaggedBy) {
|
|
25805
|
+
for (const rule of f.flaggedBy) {
|
|
25806
|
+
flaggedByRule[rule] = (flaggedByRule[rule] ?? 0) + 1;
|
|
25807
|
+
}
|
|
25808
|
+
}
|
|
25809
|
+
}
|
|
25810
|
+
const output = {
|
|
25811
|
+
valid: result.valid,
|
|
25812
|
+
flagged: result.flagged.map((f) => ({
|
|
25813
|
+
agentId: f.agentId,
|
|
25814
|
+
response: f.response,
|
|
25815
|
+
flaggedBy: f.flaggedBy ?? []
|
|
25816
|
+
})),
|
|
25817
|
+
stats: {
|
|
25818
|
+
total: responses.length,
|
|
25819
|
+
passed: result.valid.length,
|
|
25820
|
+
flaggedCount: result.flagged.length,
|
|
25821
|
+
flaggedByRule
|
|
25822
|
+
}
|
|
25823
|
+
};
|
|
25824
|
+
return { ok: true, value: output };
|
|
25825
|
+
}
|
|
25826
|
+
async function handleMakerTally(args) {
|
|
25827
|
+
const k = args.k ?? 2;
|
|
25828
|
+
const maxRounds = args.maxRounds ?? 15;
|
|
25829
|
+
const totalRoundsSoFar = args.totalRoundsSoFar ?? 0;
|
|
25830
|
+
let newResponses;
|
|
25831
|
+
try {
|
|
25832
|
+
newResponses = JSON.parse(args.responsesJson);
|
|
25833
|
+
} catch (e) {
|
|
25834
|
+
return { ok: false, error: `Invalid JSON in --responses-json: ${e}` };
|
|
25835
|
+
}
|
|
25836
|
+
if (!Array.isArray(newResponses)) {
|
|
25837
|
+
return { ok: false, error: "--responses-json must be a JSON array" };
|
|
25838
|
+
}
|
|
25839
|
+
let priorVotes = [];
|
|
25840
|
+
if (args.previousVotesJson) {
|
|
25841
|
+
try {
|
|
25842
|
+
priorVotes = JSON.parse(args.previousVotesJson);
|
|
25843
|
+
} catch (e) {
|
|
25844
|
+
return { ok: false, error: `Invalid JSON in --previous-votes-json: ${e}` };
|
|
25845
|
+
}
|
|
25846
|
+
}
|
|
25847
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
25848
|
+
const newVotes = newResponses.map((r) => ({
|
|
25849
|
+
agentId: r.agentId,
|
|
25850
|
+
responseHash: hashResponse(r.response),
|
|
25851
|
+
response: r.response,
|
|
25852
|
+
confidence: 1,
|
|
25853
|
+
timestamp: now,
|
|
25854
|
+
tokenCount: r.tokenCount ?? Math.ceil(r.response.length / 4),
|
|
25855
|
+
model: "haiku",
|
|
25856
|
+
temperature: 0
|
|
25857
|
+
}));
|
|
25858
|
+
const allVotes = [...priorVotes, ...newVotes];
|
|
25859
|
+
const tally = tallyVotes(allVotes);
|
|
25860
|
+
const consensus = hasConsensus(tally, k);
|
|
25861
|
+
let deadlockResolved = false;
|
|
25862
|
+
const finalWinnerHash = tally.leadingHash;
|
|
25863
|
+
if (!consensus && totalRoundsSoFar >= maxRounds && finalWinnerHash) {
|
|
25864
|
+
deadlockResolved = true;
|
|
25865
|
+
}
|
|
25866
|
+
const winnerResponse = finalWinnerHash ? tally.responses.get(finalWinnerHash) ?? null : null;
|
|
25867
|
+
const tallyMap = {};
|
|
25868
|
+
for (const [hash, count] of tally.counts) {
|
|
25869
|
+
tallyMap[hash] = count;
|
|
25870
|
+
}
|
|
25871
|
+
const output = {
|
|
25872
|
+
consensusReached: consensus || deadlockResolved,
|
|
25873
|
+
winner: consensus || deadlockResolved ? winnerResponse : null,
|
|
25874
|
+
winnerHash: consensus || deadlockResolved ? finalWinnerHash ?? null : null,
|
|
25875
|
+
margin: tally.margin,
|
|
25876
|
+
leadingCount: tally.leadingCount,
|
|
25877
|
+
runnerUpCount: tally.runnerUpCount,
|
|
25878
|
+
totalVotes: allVotes.length,
|
|
25879
|
+
deadlockResolved,
|
|
25880
|
+
tally: tallyMap
|
|
25881
|
+
};
|
|
25882
|
+
return { ok: true, value: output };
|
|
25883
|
+
}
|
|
25771
25884
|
async function handleMakerInit(args, basePath) {
|
|
25772
25885
|
const checkpointPath = generateCheckpointPath(
|
|
25773
25886
|
basePath,
|
|
@@ -25935,6 +26048,8 @@ var init_maker_execute = __esm({
|
|
|
25935
26048
|
init_types2();
|
|
25936
26049
|
init_executor();
|
|
25937
26050
|
init_checkpoint();
|
|
26051
|
+
init_red_flag_filter();
|
|
26052
|
+
init_voter();
|
|
25938
26053
|
makerExecuteHandler = {
|
|
25939
26054
|
name: "maker:execute",
|
|
25940
26055
|
description: "Execute MAKER multi-agent consensus workflow",
|
|
@@ -45664,7 +45779,7 @@ __export(core_exports, {
|
|
|
45664
45779
|
validateWorkflowId: () => validateWorkflowId
|
|
45665
45780
|
});
|
|
45666
45781
|
function getVersion() {
|
|
45667
|
-
return true ? "1.2.
|
|
45782
|
+
return true ? "1.2.6" : "0.0.0-dev";
|
|
45668
45783
|
}
|
|
45669
45784
|
var VERSION;
|
|
45670
45785
|
var init_core = __esm({
|
|
@@ -49338,6 +49453,60 @@ async function handleMaker(args) {
|
|
|
49338
49453
|
console.log(JSON.stringify(metricsResult, null, 2));
|
|
49339
49454
|
process.exit(0);
|
|
49340
49455
|
}
|
|
49456
|
+
case "apply-filter": {
|
|
49457
|
+
const responsesJsonIdx = args.indexOf("--responses-json");
|
|
49458
|
+
const contextIdx = args.indexOf("--context");
|
|
49459
|
+
const formatIdx = args.indexOf("--expected-format");
|
|
49460
|
+
const maxTokensIdx = args.indexOf("--max-tokens");
|
|
49461
|
+
const hedgingIdx = args.indexOf("--hedging-threshold");
|
|
49462
|
+
const strictnessIdx = args.indexOf("--format-strictness");
|
|
49463
|
+
const repetitionIdx = args.indexOf("--repetition-limit");
|
|
49464
|
+
if (responsesJsonIdx === -1 || !args[responsesJsonIdx + 1]) {
|
|
49465
|
+
console.error(`Usage: maker apply-filter --responses-json '[{"agentId":"...","response":"..."},...]' [--context "..."] [--expected-format "..."] [--max-tokens N] [--hedging-threshold N] [--format-strictness high|medium|low] [--repetition-limit N]`);
|
|
49466
|
+
process.exit(1);
|
|
49467
|
+
}
|
|
49468
|
+
const filterArgs = {
|
|
49469
|
+
responsesJson: args[responsesJsonIdx + 1],
|
|
49470
|
+
...contextIdx !== -1 && { context: args[contextIdx + 1] },
|
|
49471
|
+
...formatIdx !== -1 && { expectedFormat: args[formatIdx + 1] },
|
|
49472
|
+
...maxTokensIdx !== -1 && { maxTokens: parseInt(args[maxTokensIdx + 1], 10) },
|
|
49473
|
+
...hedgingIdx !== -1 && { hedgingThreshold: parseInt(args[hedgingIdx + 1], 10) },
|
|
49474
|
+
...strictnessIdx !== -1 && { formatStrictness: args[strictnessIdx + 1] },
|
|
49475
|
+
...repetitionIdx !== -1 && { repetitionLimit: parseInt(args[repetitionIdx + 1], 10) }
|
|
49476
|
+
};
|
|
49477
|
+
const result = await handleMakerApplyFilter(filterArgs);
|
|
49478
|
+
if (!result.ok) {
|
|
49479
|
+
console.error(JSON.stringify({ success: false, error: result.error }));
|
|
49480
|
+
process.exit(1);
|
|
49481
|
+
}
|
|
49482
|
+
console.log(JSON.stringify({ success: true, ...result.value }, null, 2));
|
|
49483
|
+
break;
|
|
49484
|
+
}
|
|
49485
|
+
case "tally": {
|
|
49486
|
+
const responsesJsonIdx = args.indexOf("--responses-json");
|
|
49487
|
+
const kIdx = args.indexOf("--k");
|
|
49488
|
+
const prevVotesIdx = args.indexOf("--previous-votes-json");
|
|
49489
|
+
const maxRoundsIdx = args.indexOf("--max-rounds");
|
|
49490
|
+
const totalRoundsIdx = args.indexOf("--total-rounds-so-far");
|
|
49491
|
+
if (responsesJsonIdx === -1 || !args[responsesJsonIdx + 1]) {
|
|
49492
|
+
console.error(`Usage: maker tally --responses-json '[{"agentId":"...","response":"...","tokenCount":N},...]' [--k 2] [--previous-votes-json '[...]'] [--max-rounds 15] [--total-rounds-so-far N]`);
|
|
49493
|
+
process.exit(1);
|
|
49494
|
+
}
|
|
49495
|
+
const tallyArgs = {
|
|
49496
|
+
responsesJson: args[responsesJsonIdx + 1],
|
|
49497
|
+
...kIdx !== -1 && { k: parseInt(args[kIdx + 1], 10) },
|
|
49498
|
+
...prevVotesIdx !== -1 && { previousVotesJson: args[prevVotesIdx + 1] },
|
|
49499
|
+
...maxRoundsIdx !== -1 && { maxRounds: parseInt(args[maxRoundsIdx + 1], 10) },
|
|
49500
|
+
...totalRoundsIdx !== -1 && { totalRoundsSoFar: parseInt(args[totalRoundsIdx + 1], 10) }
|
|
49501
|
+
};
|
|
49502
|
+
const result = await handleMakerTally(tallyArgs);
|
|
49503
|
+
if (!result.ok) {
|
|
49504
|
+
console.error(JSON.stringify({ success: false, error: result.error }));
|
|
49505
|
+
process.exit(1);
|
|
49506
|
+
}
|
|
49507
|
+
console.log(JSON.stringify({ success: true, ...result.value }, null, 2));
|
|
49508
|
+
break;
|
|
49509
|
+
}
|
|
49341
49510
|
default:
|
|
49342
49511
|
outputError(`
|
|
49343
49512
|
MAKER Commands - Multi-Agent Consensus Execution
|
|
@@ -49352,6 +49521,8 @@ Subcommands:
|
|
|
49352
49521
|
resume <execution-id> Resume failed/partial execution
|
|
49353
49522
|
validate <execution-id> Validate checkpoint integrity
|
|
49354
49523
|
metrics <execution-id> Show execution metrics
|
|
49524
|
+
apply-filter Apply deterministic red-flag filter to responses
|
|
49525
|
+
tally Tally votes and determine consensus
|
|
49355
49526
|
|
|
49356
49527
|
Init Options:
|
|
49357
49528
|
--task "description" Task to execute (required)
|
|
@@ -49377,6 +49548,22 @@ Metrics Options:
|
|
|
49377
49548
|
--chronicle Correlate with Chronicle events
|
|
49378
49549
|
--compare Compare checkpoint vs Chronicle metrics
|
|
49379
49550
|
|
|
49551
|
+
Apply-Filter Options:
|
|
49552
|
+
--responses-json '[...]' JSON array of {agentId, response} objects (required)
|
|
49553
|
+
--context "..." Step context for drift detection
|
|
49554
|
+
--expected-format "..." Expected output format for validation
|
|
49555
|
+
--max-tokens N Max tokens before flagging (default: 700)
|
|
49556
|
+
--hedging-threshold N Hedging count before flagging (default: 0)
|
|
49557
|
+
--format-strictness level high|medium|low (default: high)
|
|
49558
|
+
--repetition-limit N Max phrase repetitions (default: 3)
|
|
49559
|
+
|
|
49560
|
+
Tally Options:
|
|
49561
|
+
--responses-json '[...]' JSON array of {agentId, response, tokenCount} (required)
|
|
49562
|
+
--k N Consensus margin required (default: 2)
|
|
49563
|
+
--previous-votes-json '[...]' Prior round Vote[] JSON for multi-round sessions
|
|
49564
|
+
--max-rounds N Max rounds before deadlock resolution (default: 15)
|
|
49565
|
+
--total-rounds-so-far N Total rounds completed (for deadlock detection)
|
|
49566
|
+
|
|
49380
49567
|
Examples:
|
|
49381
49568
|
ai-dlc maker init --task "Generate FileSystemService" --unit unit-file-system
|
|
49382
49569
|
ai-dlc maker execute maker-20251219-143022
|
|
@@ -49384,6 +49571,8 @@ Examples:
|
|
|
49384
49571
|
ai-dlc maker resume maker-20251219-143022
|
|
49385
49572
|
ai-dlc maker validate maker-20251219-143022
|
|
49386
49573
|
ai-dlc maker metrics maker-20251219-143022 --chronicle --compare
|
|
49574
|
+
ai-dlc maker apply-filter --responses-json '[{"agentId":"a1","response":"class Order {}"}]'
|
|
49575
|
+
ai-dlc maker tally --responses-json '[{"agentId":"a1","response":"class Order {}","tokenCount":3}]' --k 1
|
|
49387
49576
|
`);
|
|
49388
49577
|
}
|
|
49389
49578
|
}
|
package/package.json
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@sixsevenai/ai-dlc",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"description": "AI-DLC TypeScript Enforcement Engine - Global CLI",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
"ai-dlc": "dist/cli.mjs"
|
|
8
|
-
},
|
|
9
|
-
"files": [
|
|
10
|
-
"dist/",
|
|
11
|
-
"README.md"
|
|
12
|
-
],
|
|
13
|
-
"engines": {
|
|
14
|
-
"node": ">=18.0.0"
|
|
15
|
-
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"build": "tsup"
|
|
18
|
-
},
|
|
19
|
-
"keywords": [
|
|
20
|
-
"ai-dlc",
|
|
21
|
-
"cli",
|
|
22
|
-
"workflow",
|
|
23
|
-
"enforcement"
|
|
24
|
-
],
|
|
25
|
-
"license": "MIT",
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"tsup": "^8.5.1"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@sixsevenai/ai-dlc",
|
|
3
|
+
"version": "1.2.6",
|
|
4
|
+
"description": "AI-DLC TypeScript Enforcement Engine - Global CLI",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"ai-dlc": "dist/cli.mjs"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=18.0.0"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsup"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"ai-dlc",
|
|
21
|
+
"cli",
|
|
22
|
+
"workflow",
|
|
23
|
+
"enforcement"
|
|
24
|
+
],
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"tsup": "^8.5.1"
|
|
28
|
+
}
|
|
29
|
+
}
|