@codemoot/core 0.2.6 → 0.2.9
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/index.d.ts +12 -2
- package/dist/index.js +34 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1974,6 +1974,8 @@ interface ProgressCallbacks {
|
|
|
1974
1974
|
onHeartbeat?: (elapsedSec: number) => void;
|
|
1975
1975
|
/** Called on each stdout chunk for progress feedback. */
|
|
1976
1976
|
onProgress?: (chunk: string) => void;
|
|
1977
|
+
/** Called when the subprocess closes — flush any buffered state. */
|
|
1978
|
+
onClose?: () => void;
|
|
1977
1979
|
}
|
|
1978
1980
|
interface CliCallOptions extends ProgressCallbacks {
|
|
1979
1981
|
/** Total timeout in ms. Default: 600_000 (10 min). */
|
|
@@ -2179,6 +2181,7 @@ interface StepResult {
|
|
|
2179
2181
|
durationMs: number;
|
|
2180
2182
|
verdict?: 'approved' | 'needs_revision';
|
|
2181
2183
|
feedback?: string;
|
|
2184
|
+
score?: number;
|
|
2182
2185
|
}
|
|
2183
2186
|
declare class StepRunner {
|
|
2184
2187
|
private registry;
|
|
@@ -2201,9 +2204,14 @@ interface LoopResult {
|
|
|
2201
2204
|
iterations: number;
|
|
2202
2205
|
approved: boolean;
|
|
2203
2206
|
history: StepResult[];
|
|
2207
|
+
finalScore?: number;
|
|
2208
|
+
}
|
|
2209
|
+
interface LoopOptions {
|
|
2210
|
+
/** Score threshold for auto-approval on iteration >= 2. Only applies when set. */
|
|
2211
|
+
autoApproveThreshold?: number;
|
|
2204
2212
|
}
|
|
2205
2213
|
declare class LoopController {
|
|
2206
|
-
executeLoop(generateStep: ResolvedStep, reviewStep: ResolvedStep, inputs: Map<string, string>, task: string, maxIterations: number, runner: StepRunner, eventBus: EventBus): Promise<LoopResult>;
|
|
2214
|
+
executeLoop(generateStep: ResolvedStep, reviewStep: ResolvedStep, inputs: Map<string, string>, task: string, maxIterations: number, runner: StepRunner, eventBus: EventBus, loopOptions?: LoopOptions): Promise<LoopResult>;
|
|
2207
2215
|
}
|
|
2208
2216
|
|
|
2209
2217
|
declare class CancellationToken {
|
|
@@ -2252,6 +2260,8 @@ interface PlanOptions {
|
|
|
2252
2260
|
maxRounds?: number;
|
|
2253
2261
|
stream?: boolean;
|
|
2254
2262
|
workflowDir?: string;
|
|
2263
|
+
/** Score threshold (1-10) for auto-approving plans on 2nd+ iteration. Default: 8. */
|
|
2264
|
+
autoApproveThreshold?: number;
|
|
2255
2265
|
}
|
|
2256
2266
|
interface SessionResult {
|
|
2257
2267
|
sessionId: string;
|
|
@@ -2669,6 +2679,6 @@ declare const DEFAULT_DLP_CONFIG: DlpConfig;
|
|
|
2669
2679
|
*/
|
|
2670
2680
|
declare function sanitize(input: string, config?: Partial<DlpConfig>): DlpResult;
|
|
2671
2681
|
|
|
2672
|
-
declare const VERSION = "0.2.
|
|
2682
|
+
declare const VERSION = "0.2.8";
|
|
2673
2683
|
|
|
2674
2684
|
export { type ArtifactRecord, ArtifactStore, type ArtifactType, type AssembledContext, type AttemptResult, BINARY_SNIFF_BYTES, type BridgeCapabilities, type BridgeOptions, type BridgeResumeOptions, type BudgetConfig, type BuildPhase, type BuildRun, BuildStore, type BuildSummary, type BuiltInRole, CLEANUP_TIMEOUT_SEC, CONTEXT_ACTIVE, CONTEXT_BUFFER, CONTEXT_RETRIEVED, CURRENT_VERSION, type CacheEntry, CacheStore, type CallModelOptions, CancellationError, CancellationToken, type ChatMessage, type CleanupConfidence, type CleanupFinding, type CleanupReport, type CleanupScope, type CleanupSource, CliAdapter, type CliAdapterConfig, type CliBridge, type CliCallOptions, type CliDetectionResult, ConfigError, type ContextBudget, ContextBuilder, type ContextBuilderOptions, type CostInput, type CostLogEntry, CostStore, type CostSummary, CostTracker, type CostUpdateEvent, DAYS_PER_YEAR, DEFAULT_CONFIG, DEFAULT_DLP_CONFIG, DEFAULT_MAX_TOKENS, DEFAULT_RULES, DEFAULT_TIMEOUT_SEC, DLP_MAX_CONTENT, DLP_MAX_PROCESSING_MS, DatabaseError, type DebateConfig, type DebateEngineState, type DebateInput, type DebateMessageRow, type DebateOptions, type DebatePattern, type DebateResponse, type DebateResult, DebateStore, type DebateTurnRow, type DebateTurnStatus, type DlpAuditEntry, type DlpConfig, type DlpMode, DlpReasonCode, type DlpRedaction, type DlpResult, type EngineEvent, type EnqueueOptions, ErrorCode, EventBus, type ExecutionMode, type FallbackConfig, HTTP_TOO_MANY_REQUESTS, type HandoffCommand, type HandoffEnvelopeOptions, type HostFindingInput, IMPLEMENTER_MAX_TOKENS, type JobLogRecord, type JobRecord, type JobStatus, JobStore, type JobType, type LogLevel, type Logger, type LoopConfig, LoopController, type LoopIterationEvent, type LoopResult, MCP_CONTENT_MAX_LENGTH, MCP_TASK_MAX_LENGTH, MCP_TIMEOUT_MAX, type MemoryCategory, type MemoryConfig, type MemoryInput, type MemoryRecord, MemoryStore, type MessageStatus, MessageStore, type MeteringSource, type ModelAdapter, type ModelCallResult, type ModelConfig, ModelError, type ModelPricing, type ModelProvider, ModelRegistry, Orchestrator, type OrchestratorOptions, type OutputConfig, type ParsedVerdict, type PlanInput, type PlanOptions, type PolicyContext, type PolicyDecision, type PolicyMode, type PolicyResult, type PolicyRule, type PresetName, type ProgressCallbacks, type ProjectConfig, type ProjectConfigInput, type PromptType, type PromptVariables, REVIEW_DIFF_MAX_CHARS, REVIEW_PRESETS, REVIEW_TEXT_MAX_CHARS, type ResolvedStep, type ResolvedWorkflow, type ResultStatus, type RetryConfig, type RetryOptions, type ReviewInput, type ReviewOptions, type ReviewPreset, type ReviewResult, type Role, type RoleConfig, RoleManager, type RunOptions, type Session, type SessionCompletedEvent, type SessionEvent, type SessionFailedEvent, SessionManager, type SessionOverflowStatus, type SessionResult, type SessionStartedEvent, type SessionStatus, SessionStore, type StepCompletedEvent, type StepDefinition, type StepFailedEvent, type StepResult, StepRunner, type StepStartedEvent, type StepType, TerminalReason, type TextDeltaEmitter, type TextDeltaEvent, type TextDoneEvent, type TokenUsage, type TranscriptEntry, type UnifiedSession, VERSION, type VerdictResult, type WorkflowDefinition, WorkflowEngine, WorkflowError, buildHandoffEnvelope, buildReconstructionPrompt, calculateCost, calculateDebateTokens, callModel, clearDetectionCache, computeThreeWayStats, computeTwoWayStats, costInputSchema, createIgnoreFilter, createLogger, debateInputSchema, debateOutputSchema, detectCli, estimateTokens, evaluatePolicy, generateId, generateSessionId, getModelPricing, getReviewPreset, getSchemaVersion, getTokenBudgetStatus, hashConfig, hashContent, hostFindingsSchema, isRateLimit, isRetryable, listPresetNames, listPresets, loadConfig, loadIgnorePatterns, loadPreset, memoryInputSchema, mergeThreeWay, mergeTwoWay, migrateConfig, openDatabase, parseDebateVerdict, parseVerdict, planInputSchema, preflightTokenCheck, projectConfigSchema, recalculateConfidenceStats, renderPrompt, reviewInputSchema, reviewOutputSchema, runAllScanners, runMigrations, sanitize, scanAntiPatterns, scanDeadCode, scanDuplicates, scanHardcoded, scanNearDuplicates, scanSecurity, scanUnusedDeps, scanUnusedExports, shouldIgnore, sleep, streamModel, validateConfig, withCanonicalRetry, withFallback, withRetry, writeConfig };
|
package/dist/index.js
CHANGED
|
@@ -2950,6 +2950,10 @@ var CliAdapter = class {
|
|
|
2950
2950
|
if (settled) return;
|
|
2951
2951
|
settled = true;
|
|
2952
2952
|
cleanup();
|
|
2953
|
+
try {
|
|
2954
|
+
options?.onClose?.();
|
|
2955
|
+
} catch {
|
|
2956
|
+
}
|
|
2953
2957
|
if (code !== 0) {
|
|
2954
2958
|
reject(
|
|
2955
2959
|
new ModelError(
|
|
@@ -3177,9 +3181,8 @@ var ModelRegistry = class _ModelRegistry {
|
|
|
3177
3181
|
async healthCheckAll() {
|
|
3178
3182
|
const results = /* @__PURE__ */ new Map();
|
|
3179
3183
|
const detection = await detectCli("codex");
|
|
3180
|
-
const healthy = detection.available && (detection.authOk ?? false);
|
|
3181
3184
|
for (const alias of this.configs.keys()) {
|
|
3182
|
-
results.set(alias,
|
|
3185
|
+
results.set(alias, detection.available);
|
|
3183
3186
|
}
|
|
3184
3187
|
return results;
|
|
3185
3188
|
}
|
|
@@ -3535,9 +3538,12 @@ ${vars.task}`
|
|
|
3535
3538
|
"",
|
|
3536
3539
|
"Provide specific, actionable feedback. Reference plan sections by name.",
|
|
3537
3540
|
"",
|
|
3538
|
-
"At the END of your review, you MUST include
|
|
3541
|
+
"At the END of your review, you MUST include ALL of these lines:",
|
|
3542
|
+
"SCORE: X/10",
|
|
3539
3543
|
"VERDICT: APPROVED",
|
|
3540
|
-
"VERDICT: NEEDS_REVISION"
|
|
3544
|
+
"VERDICT: NEEDS_REVISION",
|
|
3545
|
+
"",
|
|
3546
|
+
"Where X is your numeric score (1-10) and VERDICT is exactly one of the two options."
|
|
3541
3547
|
].join("\n"),
|
|
3542
3548
|
user: (vars) => `## Task:
|
|
3543
3549
|
${vars.task}
|
|
@@ -3605,9 +3611,9 @@ ${vars.plan ?? ""}`
|
|
|
3605
3611
|
"",
|
|
3606
3612
|
"Provide specific feedback with file names and references.",
|
|
3607
3613
|
"",
|
|
3608
|
-
"At the END of your review, you MUST include
|
|
3609
|
-
"
|
|
3610
|
-
"VERDICT: NEEDS_REVISION"
|
|
3614
|
+
"At the END of your review, you MUST include ALL of these lines:",
|
|
3615
|
+
"SCORE: X/10",
|
|
3616
|
+
"VERDICT: APPROVED or VERDICT: NEEDS_REVISION"
|
|
3611
3617
|
].join("\n"),
|
|
3612
3618
|
user: (vars) => [
|
|
3613
3619
|
`## Task:
|
|
@@ -3695,7 +3701,7 @@ var EventBus = class extends EventEmitter {
|
|
|
3695
3701
|
|
|
3696
3702
|
// src/engine/loop-controller.ts
|
|
3697
3703
|
var LoopController = class {
|
|
3698
|
-
async executeLoop(generateStep, reviewStep, inputs, task, maxIterations, runner, eventBus) {
|
|
3704
|
+
async executeLoop(generateStep, reviewStep, inputs, task, maxIterations, runner, eventBus, loopOptions) {
|
|
3699
3705
|
const history = [];
|
|
3700
3706
|
let currentInputs = new Map(inputs);
|
|
3701
3707
|
let approved = false;
|
|
@@ -3706,7 +3712,12 @@ var LoopController = class {
|
|
|
3706
3712
|
reviewInputs.set(generateStep.definition.id, generateResult.output);
|
|
3707
3713
|
const reviewResult = await runner.execute(reviewStep, reviewInputs, task, iteration);
|
|
3708
3714
|
history.push(reviewResult);
|
|
3709
|
-
|
|
3715
|
+
let verdict = reviewResult.verdict ?? "needs_revision";
|
|
3716
|
+
const score = reviewResult.score;
|
|
3717
|
+
const threshold = loopOptions?.autoApproveThreshold;
|
|
3718
|
+
if (verdict === "needs_revision" && threshold != null && score != null && score >= threshold && iteration >= 2) {
|
|
3719
|
+
verdict = "approved";
|
|
3720
|
+
}
|
|
3710
3721
|
eventBus.emitEvent({
|
|
3711
3722
|
type: "loop.iteration",
|
|
3712
3723
|
stepId: reviewStep.definition.id,
|
|
@@ -3722,7 +3733,8 @@ var LoopController = class {
|
|
|
3722
3733
|
finalOutput: generateResult.output,
|
|
3723
3734
|
iterations: iteration,
|
|
3724
3735
|
approved,
|
|
3725
|
-
history
|
|
3736
|
+
history,
|
|
3737
|
+
finalScore: score
|
|
3726
3738
|
};
|
|
3727
3739
|
}
|
|
3728
3740
|
if (iteration < maxIterations) {
|
|
@@ -4464,10 +4476,15 @@ var StepRunner = class {
|
|
|
4464
4476
|
});
|
|
4465
4477
|
let verdict;
|
|
4466
4478
|
let feedback;
|
|
4479
|
+
let score;
|
|
4467
4480
|
if (stepType === "review") {
|
|
4468
4481
|
const parsed = parseVerdict(result.text);
|
|
4469
4482
|
verdict = parsed.verdict;
|
|
4470
4483
|
feedback = parsed.feedback || void 0;
|
|
4484
|
+
const scoreMatch = result.text.slice(-500).match(/SCORE:\s*(\d+)\/10/);
|
|
4485
|
+
if (scoreMatch) {
|
|
4486
|
+
score = Number.parseInt(scoreMatch[1], 10);
|
|
4487
|
+
}
|
|
4471
4488
|
}
|
|
4472
4489
|
this.eventBus.emitEvent({
|
|
4473
4490
|
type: "step.completed",
|
|
@@ -4483,7 +4500,8 @@ var StepRunner = class {
|
|
|
4483
4500
|
usage: result.usage,
|
|
4484
4501
|
durationMs,
|
|
4485
4502
|
verdict,
|
|
4486
|
-
feedback
|
|
4503
|
+
feedback,
|
|
4504
|
+
score
|
|
4487
4505
|
};
|
|
4488
4506
|
}
|
|
4489
4507
|
resolvePromptType(stepType, stepId, iteration) {
|
|
@@ -4755,7 +4773,8 @@ var Orchestrator = class extends EventEmitter2 {
|
|
|
4755
4773
|
async plan(task, options) {
|
|
4756
4774
|
return this.executeSession(task, ["plan-review"], {
|
|
4757
4775
|
maxIterations: options?.maxRounds,
|
|
4758
|
-
stream: options?.stream
|
|
4776
|
+
stream: options?.stream,
|
|
4777
|
+
planAutoApproveThreshold: options?.autoApproveThreshold ?? 8
|
|
4759
4778
|
});
|
|
4760
4779
|
}
|
|
4761
4780
|
/**
|
|
@@ -5073,7 +5092,8 @@ ${r.text}`)
|
|
|
5073
5092
|
task,
|
|
5074
5093
|
maxIterations,
|
|
5075
5094
|
stepRunner,
|
|
5076
|
-
this.eventBus
|
|
5095
|
+
this.eventBus,
|
|
5096
|
+
{ autoApproveThreshold: options.planAutoApproveThreshold }
|
|
5077
5097
|
);
|
|
5078
5098
|
inputs.set("plan.output", planLoop.finalOutput);
|
|
5079
5099
|
totalIterations += planLoop.iterations;
|
|
@@ -6080,7 +6100,7 @@ var hostFindingSchema = z3.object({
|
|
|
6080
6100
|
var hostFindingsSchema = z3.array(hostFindingSchema);
|
|
6081
6101
|
|
|
6082
6102
|
// src/index.ts
|
|
6083
|
-
var VERSION = "0.2.
|
|
6103
|
+
var VERSION = "0.2.8";
|
|
6084
6104
|
export {
|
|
6085
6105
|
ArtifactStore,
|
|
6086
6106
|
BINARY_SNIFF_BYTES,
|