@wrongstack/core 0.303.0 → 0.305.1
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/chronicle/project-server.js +18 -48
- package/dist/coordination/agents/index.js +530 -130
- package/dist/coordination/agents/project-agent-consolidation.d.ts +5 -0
- package/dist/coordination/agents/project-agent-directive-outcome.d.ts +57 -0
- package/dist/coordination/agents/project-agent-identity.d.ts +26 -12
- package/dist/coordination/agents/project-agent-learning-policy.d.ts +22 -1
- package/dist/coordination/agents/project-agent-learning-structured.d.ts +46 -1
- package/dist/coordination/agents/project-agent-quarantine.d.ts +63 -0
- package/dist/coordination/agents/project-agent-skill-layer.d.ts +55 -10
- package/dist/coordination/agents/types.d.ts +10 -2
- package/dist/coordination/director-prompts.d.ts +19 -6
- package/dist/coordination/director-tools.d.ts +2 -2
- package/dist/coordination/fleet.d.ts +0 -6
- package/dist/coordination/index.d.ts +2 -1
- package/dist/coordination/index.js +1581 -955
- package/dist/coordination/mailbox-project-server.js +28 -57
- package/dist/core/agent-types.d.ts +4 -2
- package/dist/core/agent.d.ts +1 -0
- package/dist/core/context.d.ts +15 -0
- package/dist/core/conversation-state.d.ts +14 -0
- package/dist/core/fallback-profile-manager.d.ts +70 -2
- package/dist/core/index.js +308 -108
- package/dist/core/system-prompt-blocks.d.ts +1 -1
- package/dist/core/system-prompt-builder.d.ts +13 -1
- package/dist/core/system-prompt-glossary.d.ts +73 -0
- package/dist/core/system-prompt-memory-skills.d.ts +2 -2
- package/dist/defaults/index.js +910 -693
- package/dist/execution/council-orchestrator.d.ts +3 -13
- package/dist/execution/index.js +211 -75
- package/dist/execution/one-shot-llm.d.ts +5 -0
- package/dist/hq/index.js +17 -7
- package/dist/hq/protocol/kanban.d.ts +21 -0
- package/dist/hq/protocol.js +5 -1
- package/dist/hq/redaction.d.ts +14 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3505 -2539
- package/dist/infrastructure/index.js +247 -122
- package/dist/plugin/index.js +101 -3
- package/dist/registry/index.js +11 -0
- package/dist/registry/tool-registry.d.ts +8 -0
- package/dist/replay/hash.d.ts +9 -0
- package/dist/replay/index.js +14 -4
- package/dist/replay/replay-provider-runner.d.ts +31 -1
- package/dist/security/index.js +25 -20
- package/dist/security/secret-vault.d.ts +2 -0
- package/dist/session-catalog/index.js +62 -8
- package/dist/session-catalog/project-server.js +109 -78
- package/dist/session-catalog/protocol.d.ts +11 -4
- package/dist/session-catalog/store.d.ts +2 -2
- package/dist/storage/index.js +224 -67
- package/dist/storage/memory-consolidator.d.ts +4 -2
- package/dist/storage/session-resume-validation.d.ts +24 -0
- package/dist/storage/session-store/directory-scan.d.ts +5 -1
- package/dist/storage/session-store/fork-session.d.ts +13 -1
- package/dist/storage/session-store/load-cache.d.ts +11 -0
- package/dist/storage/session-store/prune-helpers.d.ts +5 -0
- package/dist/storage/session-store.d.ts +18 -0
- package/dist/tools/index.js +174 -74
- package/dist/types/config/mcp-features.d.ts +31 -1
- package/dist/types/config/root.d.ts +12 -0
- package/dist/types/config/tools.d.ts +22 -0
- package/dist/types/config/ui.d.ts +7 -4
- package/dist/types/default-config.d.ts +1 -0
- package/dist/types/index.js +24 -1
- package/dist/types/session.d.ts +9 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +214 -76
- package/dist/utils/project-state-guard.d.ts +21 -0
- package/dist/utils/session-scoped-path.d.ts +17 -0
- package/dist/utils/todos-format.d.ts +20 -0
- package/instructions/leader-after-task.md +3 -4
- package/instructions/system-lite.md +10 -13
- package/instructions/system-pro.md +18 -25
- package/instructions/system.md +18 -23
- package/package.json +3 -3
- package/skills/wrongstack-kanban/SKILL.md +95 -124
|
@@ -28,6 +28,11 @@ export interface ConsolidationMetadata {
|
|
|
28
28
|
}
|
|
29
29
|
/** Structured directives in the raw buffer, with legacy-format fallback. */
|
|
30
30
|
export declare function readRawLearnedEntries(role: string, projectRoot?: string): StructuredLearnedEntry[];
|
|
31
|
+
/**
|
|
32
|
+
* The role document's path, for callers that need to rewrite it in place
|
|
33
|
+
* without going through the full save-and-record-metadata pass.
|
|
34
|
+
*/
|
|
35
|
+
export declare function consolidatedDocumentPath(role: string, projectRoot?: string): string;
|
|
31
36
|
export declare function loadProjectAgentConsolidated(role: string, projectRoot?: string): string;
|
|
32
37
|
export declare function loadConsolidationMetadata(role: string, projectRoot?: string): ConsolidationMetadata | undefined;
|
|
33
38
|
export declare function isConsolidated(role: string, projectRoot?: string): boolean;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outcome attribution for captured directives.
|
|
3
|
+
*
|
|
4
|
+
* Capture answers "what did the agent conclude?". This module answers the
|
|
5
|
+
* question the loop was missing: **did that conclusion help?** Without it the
|
|
6
|
+
* environment's reward reached `affinity.json` and stopped there, so a directive
|
|
7
|
+
* that made every task worse was injected forever and could only ever leave the
|
|
8
|
+
* buffer by growing old.
|
|
9
|
+
*
|
|
10
|
+
* The attribution is deliberately cheap and model-free. When a task finishes,
|
|
11
|
+
* its final report is scanned for evidence that each already-stored directive
|
|
12
|
+
* was actually exercised — its anchors (commands, paths, package names, which
|
|
13
|
+
* capture already extracts into `entry.how`) appearing verbatim, or enough of
|
|
14
|
+
* its distinctive wording to be unambiguous. Every directive that was exercised
|
|
15
|
+
* takes the task's outcome onto its own record.
|
|
16
|
+
*
|
|
17
|
+
* This is correlation, not proof: a directive can be mentioned and irrelevant,
|
|
18
|
+
* or decisive and unmentioned. It is used accordingly — to order eviction, to
|
|
19
|
+
* protect proven rules from being overwritten, to retire rules that keep losing,
|
|
20
|
+
* and to tell the distillation pass which directives earned their place. None of
|
|
21
|
+
* those decisions is safe to make on age alone, which is what they used before.
|
|
22
|
+
*/
|
|
23
|
+
import { type StructuredLearnedEntry } from './project-agent-learning-structured.js';
|
|
24
|
+
/** Trials a directive must have before a bad record can retire it. */
|
|
25
|
+
export declare const DIRECTIVE_QUARANTINE_MIN_APPLIED = 8;
|
|
26
|
+
/** Utility below which a directive with enough trials is retired. */
|
|
27
|
+
export declare const DIRECTIVE_QUARANTINE_MAX_UTILITY = 0.3;
|
|
28
|
+
/**
|
|
29
|
+
* Whether `report` shows this directive was exercised.
|
|
30
|
+
*
|
|
31
|
+
* One anchor is enough: anchors are exact commands, paths and package names, so
|
|
32
|
+
* their appearance in a report is a direct statement that the thing the
|
|
33
|
+
* directive is about was touched. Directives with no anchors fall back to
|
|
34
|
+
* wording, which needs a high bar because generic prose overlaps easily.
|
|
35
|
+
*/
|
|
36
|
+
export declare function directiveWasApplied(entry: StructuredLearnedEntry, report: string): boolean;
|
|
37
|
+
export interface DirectiveOutcomeResult {
|
|
38
|
+
role: string;
|
|
39
|
+
/** Directives credited with this task's outcome. */
|
|
40
|
+
attributed: number;
|
|
41
|
+
/** Directives retired into `quarantine.md` by this update. */
|
|
42
|
+
quarantined: string[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Fold one completed task's outcome into the record of every directive it
|
|
46
|
+
* exercised, then retire the ones whose record has become bad enough.
|
|
47
|
+
*
|
|
48
|
+
* Must run **before** the same output is captured: a directive written by this
|
|
49
|
+
* task has not been tested by this task, and crediting it here would let every
|
|
50
|
+
* new directive vouch for itself.
|
|
51
|
+
*
|
|
52
|
+
* Can throw on an invalid role or an unwritable role directory. Callers on the
|
|
53
|
+
* task-completion path must swallow it: a lost outcome costs ranking quality,
|
|
54
|
+
* which is never worth failing a completed task over.
|
|
55
|
+
*/
|
|
56
|
+
export declare function recordDirectiveOutcomes(role: string, report: string, succeeded: boolean, projectRoot?: string): DirectiveOutcomeResult;
|
|
57
|
+
//# sourceMappingURL=project-agent-directive-outcome.d.ts.map
|
|
@@ -24,22 +24,22 @@ import { type ConsolidationMetadata } from './project-agent-consolidation.js';
|
|
|
24
24
|
import type { LearnedCaptureResult, ProjectAgentConfig, RoleKnowledgeManifest } from './project-agent-identity-types.js';
|
|
25
25
|
import { type ProjectAgentLearningPolicy } from './project-agent-learning-policy.js';
|
|
26
26
|
import { type StructuredLearnedEntry } from './project-agent-learning-structured.js';
|
|
27
|
-
export { validateProjectAgentConfig } from './project-agent-config-validation.js';
|
|
28
|
-
export { loadProjectAgentConfig } from './project-agent-config-io.js';
|
|
29
|
-
export { CAPTURE_SESSION_WINDOW_MS, resetCaptureWindow, resetCaptureWindows, } from './project-agent-capture-window.js';
|
|
30
|
-
export { CAPTURE_COOLDOWN_MS, CAPTURE_MAX_PER_SESSION };
|
|
31
|
-
export { buildSkillDistillInstruction, clearProjectSkillAugmentation, DEFAULT_EAGER_SKILL_LIMIT, listProjectSkillAugmentations, loadProjectSkillAugmentation, loadSkillAffinity, rankRoleSkills, recordSkillLoad, recordSkillOutcome, renderSkillAugmentation, resolveRoleSkillCandidates, routeDirectiveToSkill, saveProjectSkillAugmentation, setSkillPinned, SKILL_AUGMENTATION_MAX_BYTES, type SkillAffinity, type SkillAffinityEntry, } from './project-agent-skill-layer.js';
|
|
32
|
-
export { readRawLearnedEntries, type SaveConsolidationOptions } from './project-agent-consolidation.js';
|
|
33
27
|
export { type AutoOptimizeDecision, type AutoOptimizeEvent, type AutoOptimizePolicy, type AutoOptimizePolicyOverrides, DEFAULT_AUTO_OPTIMIZE_POLICY, evaluateAutoOptimize, LearningOptimizationScheduler, type LearningOptimizationSchedulerOptions, resolveAutoOptimizePolicy, } from './project-agent-auto-optimize.js';
|
|
34
|
-
export {
|
|
35
|
-
export {
|
|
28
|
+
export { CAPTURE_SESSION_WINDOW_MS, resetCaptureWindow, resetCaptureWindows, } from './project-agent-capture-window.js';
|
|
29
|
+
export { loadProjectAgentConfig } from './project-agent-config-io.js';
|
|
30
|
+
export { validateProjectAgentConfig } from './project-agent-config-validation.js';
|
|
31
|
+
export { buildConsolidationInstruction, type ConsolidationMetadata, clearProjectAgentConsolidated, consolidatedDocumentPath, isConsolidated, loadConsolidationMetadata, loadProjectAgentConsolidated, readRawLearnedEntries, type SaveConsolidationOptions, saveProjectAgentConsolidated, } from './project-agent-consolidation.js';
|
|
32
|
+
export { DIRECTIVE_QUARANTINE_MAX_UTILITY, DIRECTIVE_QUARANTINE_MIN_APPLIED, type DirectiveOutcomeResult, directiveWasApplied, recordDirectiveOutcomes, } from './project-agent-directive-outcome.js';
|
|
36
33
|
export type { CreateProjectAgentInput, LearnedCaptureResult, ProjectAgentConfig, ProjectAgentProfile, RoleKnowledgeManifest, } from './project-agent-identity-types.js';
|
|
34
|
+
export { splitLearnedEntries, tokenOverlap } from './project-agent-learning-entries.js';
|
|
37
35
|
export { classifyLearnedEntry, LEARNED_ENTRY_MAX_CHARS, LEARNED_HARD_LIMIT, LEARNED_SOFT_LIMIT, type LearnedEntryCategory, normalizeLearnedEntry, } from './project-agent-learning-normalize.js';
|
|
38
|
-
export { loadProjectAgentLearningPolicy, type ProjectAgentLearningPolicy, updateProjectAgentLearningPolicy, } from './project-agent-learning-policy.js';
|
|
39
|
-
export { decomposeLearnedEntry, enforceLearnedBudget, mergeStructuredEntries, parseLearnedEntryStamp, renderLearnedInstructions, type StructuredLearnedEntry, } from './project-agent-learning-structured.js';
|
|
36
|
+
export { loadProjectAgentLearningPolicy, type ProjectAgentLearningPolicy, recordProjectAgentOptimizePass, updateProjectAgentLearningPolicy, } from './project-agent-learning-policy.js';
|
|
37
|
+
export { DIRECTIVE_PROVEN_MIN_APPLIED, DIRECTIVE_PROVEN_MIN_UTILITY, decomposeLearnedEntry, directiveTrials, directiveUtility, enforceLearnedBudget, isProvenDirective, mergeStructuredEntries, parseLearnedEntryStamp, parseStructuredLearnedEntriesFromContent, renderLearnedInstructions, type StructuredLearnedEntry, } from './project-agent-learning-structured.js';
|
|
38
|
+
export { type LearningOptimizerLlm, type OptimizeLearningOptions, type OptimizeLearningResult, optimizeProjectAgentLearning, unwrapWholeDocumentFence, } from './project-agent-optimizer.js';
|
|
40
39
|
export { assertProjectAgentRole } from './project-agent-paths.js';
|
|
41
|
-
export {
|
|
42
|
-
export {
|
|
40
|
+
export { type QuarantinedDirective, quarantinePath, readQuarantinedDirectives, retiredDirectivesToWarnAbout, scrubRetiredLines, } from './project-agent-quarantine.js';
|
|
41
|
+
export { buildSkillDistillInstruction, clearProjectSkillAugmentation, DEFAULT_EAGER_SKILL_LIMIT, listProjectSkillAugmentations, loadProjectSkillAugmentation, loadSkillAffinity, rankRoleSkills, recordSkillLoad, recordSkillOutcome, renderSkillAugmentation, resolveRoleSkillCandidates, routeDirectiveToSkill, SKILL_AUGMENTATION_MAX_BYTES, SKILL_EVIDENCE_HALF_LIFE_DAYS, type SkillAffinity, type SkillAffinityEntry, saveProjectSkillAugmentation, scoreSkillAffinity, setSkillPinned, } from './project-agent-skill-layer.js';
|
|
42
|
+
export { CAPTURE_COOLDOWN_MS, CAPTURE_MAX_PER_SESSION };
|
|
43
43
|
export { listProjectAgentRoles, refreshProjectAgentIdentity, resetProjectAgentIdentity, updateProjectAgentConfig, updateProjectAgentIdentity, updateProjectAgentKnowledge, updateProjectAgentLearned, } from './project-agent-files.js';
|
|
44
44
|
export { createProjectAgent, loadProjectAgentProfile, slugifyProjectAgentRole, } from './project-agent-profile.js';
|
|
45
45
|
/**
|
|
@@ -129,6 +129,20 @@ export interface ProjectAgentLearnStats {
|
|
|
129
129
|
skills: string[];
|
|
130
130
|
/** Directives already routed to a skill and awaiting distillation. */
|
|
131
131
|
skilledEntryCount: number;
|
|
132
|
+
/**
|
|
133
|
+
* How the buffer is actually performing, not just how big it is.
|
|
134
|
+
*
|
|
135
|
+
* `lifetimeCaptureCount` measures volume, which says nothing about whether
|
|
136
|
+
* the role is learning the right things. These three do:
|
|
137
|
+
* `provenEntryCount` is directives with a real track record, `deadEntryCount`
|
|
138
|
+
* is directives that have never been exercised at all (a high share means the
|
|
139
|
+
* agent is writing things nobody uses), and `directiveHitRate` is the share
|
|
140
|
+
* of applications that ended in a successful task.
|
|
141
|
+
*/
|
|
142
|
+
appliedEntryCount: number;
|
|
143
|
+
deadEntryCount: number;
|
|
144
|
+
/** `null` until at least one directive has been exercised. */
|
|
145
|
+
directiveHitRate: number | null;
|
|
132
146
|
}
|
|
133
147
|
export declare function getProjectAgentLearnStats(role: string, projectRoot?: string): ProjectAgentLearnStats;
|
|
134
148
|
/**
|
|
@@ -5,7 +5,28 @@ export interface ProjectAgentLearningPolicy {
|
|
|
5
5
|
lifetimeCaptureCount: number;
|
|
6
6
|
lastCaptureAt?: string | undefined;
|
|
7
7
|
lastCaptureSource?: 'automatic' | 'manual' | 'taught' | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* When an optimization pass last ran to completion for this role, whatever it
|
|
10
|
+
* managed to do.
|
|
11
|
+
*
|
|
12
|
+
* The auto-optimize cooldown used to read `consolidation.json` alone, which is
|
|
13
|
+
* only written when a model produced a role document. A pass that ran without
|
|
14
|
+
* a model still rewrote every skill addendum and still left no trace, so on a
|
|
15
|
+
* headless box `minIntervalMs` never applied and a full pass re-ran after
|
|
16
|
+
* every capture.
|
|
17
|
+
*/
|
|
18
|
+
lastOptimizeAt?: string | undefined;
|
|
8
19
|
}
|
|
9
20
|
export declare function loadProjectAgentLearningPolicy(role: string, projectRoot?: string): ProjectAgentLearningPolicy;
|
|
10
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Merge a patch into the persisted policy.
|
|
23
|
+
*
|
|
24
|
+
* Always re-reads immediately before writing. Capture and the optimization pass
|
|
25
|
+
* both own fields in this file and run on independent schedules, so writing a
|
|
26
|
+
* whole object built from a value read earlier in the call silently reverts
|
|
27
|
+
* whatever the other one recorded in between.
|
|
28
|
+
*/
|
|
29
|
+
export declare function updateProjectAgentLearningPolicy(role: string, patch: Partial<ProjectAgentLearningPolicy>, projectRoot?: string): ProjectAgentLearningPolicy;
|
|
30
|
+
/** Stamp the completion of an optimization pass so the cooldown can see it. */
|
|
31
|
+
export declare function recordProjectAgentOptimizePass(role: string, projectRoot?: string, at?: string): void;
|
|
11
32
|
//# sourceMappingURL=project-agent-learning-policy.d.ts.map
|
|
@@ -27,7 +27,43 @@ export interface StructuredLearnedEntry {
|
|
|
27
27
|
* the optimization pass; unrouted entries stay role-level.
|
|
28
28
|
*/
|
|
29
29
|
skill?: string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Completed tasks where this directive was injected **and** the agent's
|
|
32
|
+
* report showed it was actually exercised (its anchors or distinctive
|
|
33
|
+
* wording appeared in the output).
|
|
34
|
+
*
|
|
35
|
+
* Optional so an entry can be constructed without a track record; treat a
|
|
36
|
+
* missing value as 0 by reading it through {@link directiveTrials}.
|
|
37
|
+
*/
|
|
38
|
+
applied?: number | undefined;
|
|
39
|
+
/** Of those, the ones that ended in a successful task. */
|
|
40
|
+
wins?: number | undefined;
|
|
30
41
|
}
|
|
42
|
+
/** Normalized track record. A missing counter reads as 0, never as NaN. */
|
|
43
|
+
export declare function directiveTrials(entry: Pick<StructuredLearnedEntry, 'applied' | 'wins'>): {
|
|
44
|
+
applied: number;
|
|
45
|
+
wins: number;
|
|
46
|
+
losses: number;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Laplace-smoothed success rate of a directive: the fraction of tasks that
|
|
50
|
+
* succeeded among those where the directive was actually exercised.
|
|
51
|
+
*
|
|
52
|
+
* An unproven directive scores exactly 0.5 — a neutral prior, not a penalty.
|
|
53
|
+
* That matters everywhere this is used as a ranking key: "no evidence" must
|
|
54
|
+
* never sort below "evidence of harm", which is the inversion the skill-level
|
|
55
|
+
* score used to have.
|
|
56
|
+
*/
|
|
57
|
+
export declare function directiveUtility(entry: Pick<StructuredLearnedEntry, 'applied' | 'wins'>): number;
|
|
58
|
+
/** Trials before a directive's record is trusted enough to protect or retire it. */
|
|
59
|
+
export declare const DIRECTIVE_PROVEN_MIN_APPLIED = 5;
|
|
60
|
+
/** Utility at or above which a directive is treated as proven. */
|
|
61
|
+
export declare const DIRECTIVE_PROVEN_MIN_UTILITY = 0.7;
|
|
62
|
+
/**
|
|
63
|
+
* A directive that has earned the right not to be overwritten by a near
|
|
64
|
+
* duplicate: exercised enough times, and correlated with success when it was.
|
|
65
|
+
*/
|
|
66
|
+
export declare function isProvenDirective(entry: StructuredLearnedEntry): boolean;
|
|
31
67
|
export declare function parseLearnedEntryStamp(entry: string): {
|
|
32
68
|
capturedAt: string;
|
|
33
69
|
category: LearnedEntryCategory | null;
|
|
@@ -47,7 +83,16 @@ export declare function mergeStructuredEntries(existing: StructuredLearnedEntry[
|
|
|
47
83
|
export declare function renderLearnedInstructions(role: string, entries: StructuredLearnedEntry[], capturedAt: string): string;
|
|
48
84
|
/**
|
|
49
85
|
* Keep the rendered buffer within `maxBytes` by evicting the least valuable
|
|
50
|
-
* entries
|
|
86
|
+
* entries: plain facts before hard-won warnings, then the worst track record,
|
|
87
|
+
* then the oldest.
|
|
88
|
+
*
|
|
89
|
+
* Track record before age is the point of the ordering. Age says when a
|
|
90
|
+
* directive arrived; utility says whether it has ever helped. A directive that
|
|
91
|
+
* has been exercised eight times and correlated with failure every time is the
|
|
92
|
+
* cheapest thing in the buffer no matter how recently it was written, and a
|
|
93
|
+
* directive that keeps working should outlive newer arrivals. Entries with no
|
|
94
|
+
* record sit at the neutral 0.5 prior, so this reduces to the previous
|
|
95
|
+
* age-ordered behaviour for any buffer that predates outcome tracking.
|
|
51
96
|
*
|
|
52
97
|
* This replaces the old "block every automatic capture once the file passes
|
|
53
98
|
* 8 KB" gate. That gate had no way to ever clear itself (consolidation wrote a
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The retired-directive log, and the surgery that keeps a retired directive
|
|
3
|
+
* from surviving inside a document that was distilled while it was still
|
|
4
|
+
* believed.
|
|
5
|
+
*
|
|
6
|
+
* Retirement removes a directive from the capture buffer, but by then it may
|
|
7
|
+
* already have been folded into `skills/<skill>.md` and `consolidated.md` —
|
|
8
|
+
* both of which are injected into every spawn and neither of which is rebuilt
|
|
9
|
+
* until the next optimization pass, up to six hours later. Without the scrub
|
|
10
|
+
* below, "stops being injected" was only true of the buffer, which is the one
|
|
11
|
+
* copy the agent was least likely to be reading.
|
|
12
|
+
*
|
|
13
|
+
* Its own module so both the writer (`project-agent-directive-outcome`) and the
|
|
14
|
+
* reader (`project-agent-consolidation`, building the distillation prompt) can
|
|
15
|
+
* depend on it without depending on each other.
|
|
16
|
+
*/
|
|
17
|
+
import { type StructuredLearnedEntry } from './project-agent-learning-structured.js';
|
|
18
|
+
/** Ceiling on the retired-directive log. Local audit only; never injected. */
|
|
19
|
+
export declare const QUARANTINE_MAX_BYTES: number;
|
|
20
|
+
export interface QuarantinedDirective {
|
|
21
|
+
what: string;
|
|
22
|
+
skill?: string | undefined;
|
|
23
|
+
}
|
|
24
|
+
export declare function quarantinePath(role: string, projectRoot?: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Append retired directives to the role's log.
|
|
27
|
+
*
|
|
28
|
+
* They are kept rather than deleted: a directive can be right about a project
|
|
29
|
+
* that has since changed, and the log is the only place to see what the loop
|
|
30
|
+
* decided to stop believing.
|
|
31
|
+
*/
|
|
32
|
+
export declare function appendQuarantine(role: string, retired: readonly StructuredLearnedEntry[], at: string, projectRoot?: string): void;
|
|
33
|
+
/** Every directive this role has retired, newest last. */
|
|
34
|
+
export declare function readQuarantinedDirectives(role: string, projectRoot?: string): QuarantinedDirective[];
|
|
35
|
+
/**
|
|
36
|
+
* Remove any line that states one of the retired directives, together with the
|
|
37
|
+
* indented lines that hang off it.
|
|
38
|
+
*
|
|
39
|
+
* Line-oriented rather than model-driven on purpose: this runs on the task
|
|
40
|
+
* completion path, where a provider call is not affordable and a failure to
|
|
41
|
+
* scrub means the agent keeps being told to do the thing that kept failing.
|
|
42
|
+
*/
|
|
43
|
+
export declare function scrubRetiredLines(text: string, retired: readonly string[]): string;
|
|
44
|
+
/**
|
|
45
|
+
* Whether a scrubbed document still says anything actionable.
|
|
46
|
+
*
|
|
47
|
+
* Chrome does not count. A skill addendum keeps its title and its standing
|
|
48
|
+
* "read these as refinements of the bundled skill" blockquote no matter how
|
|
49
|
+
* many rules are removed, so testing for "any long line" would report an
|
|
50
|
+
* addendum with nothing left in it as still having content.
|
|
51
|
+
*/
|
|
52
|
+
export declare function hasDirectiveContent(text: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Retired directives worth warning the distiller about: the ones it could only
|
|
55
|
+
* resurrect from an existing document.
|
|
56
|
+
*
|
|
57
|
+
* A directive the agent has since written again is deliberately excluded. The
|
|
58
|
+
* whole reason retirement archives rather than deletes is that a rule can be
|
|
59
|
+
* right about a project that has since changed; if the role re-learned it, it
|
|
60
|
+
* is back in the buffer with a fresh record and has earned its second chance.
|
|
61
|
+
*/
|
|
62
|
+
export declare function retiredDirectivesToWarnAbout(role: string, currentDirectives: readonly string[], projectRoot?: string, skill?: string): string[];
|
|
63
|
+
//# sourceMappingURL=project-agent-quarantine.d.ts.map
|
|
@@ -33,16 +33,27 @@ export declare function clearProjectSkillAugmentation(role: string, skill?: stri
|
|
|
33
33
|
/** Skill names that have a project addendum for this role. */
|
|
34
34
|
export declare function listProjectSkillAugmentations(role: string, projectRoot?: string): string[];
|
|
35
35
|
/**
|
|
36
|
-
* Render a distilled skill addendum. Used as the deterministic fallback when
|
|
37
|
-
*
|
|
38
|
-
*
|
|
36
|
+
* Render a distilled skill addendum. Used as the deterministic fallback when no
|
|
37
|
+
* LLM is available — the directives are already instructive, so emitting them
|
|
38
|
+
* verbatim under a stable header is strictly better than no addendum.
|
|
39
|
+
*
|
|
40
|
+
* `existing` is **not optional in practice**: this renderer only ever sees the
|
|
41
|
+
* directives currently sitting in the capture buffer, and the buffer is pruned
|
|
42
|
+
* after every successful optimization. Rendering from the buffer alone and
|
|
43
|
+
* writing the result over the file therefore deleted every directive distilled
|
|
44
|
+
* by an earlier pass. That happened silently on any headless box, and on a
|
|
45
|
+
* model-backed one whenever a single per-skill call timed out and the role-level
|
|
46
|
+
* consolidation then pruned; the only remaining copy was under `archive/`.
|
|
47
|
+
*
|
|
48
|
+
* Passing the current addendum in keeps it: prior body first, new directives
|
|
49
|
+
* appended, near-duplicates of lines already present dropped.
|
|
39
50
|
*/
|
|
40
|
-
export declare function renderSkillAugmentation(role: string, skill: string, directives: readonly string[], updatedAt: string): string;
|
|
51
|
+
export declare function renderSkillAugmentation(role: string, skill: string, directives: readonly string[], updatedAt: string, existing?: string): string;
|
|
41
52
|
/**
|
|
42
53
|
* Instruction for the optimization pass: turn the directives that capture
|
|
43
54
|
* routed to one skill into that skill's project addendum.
|
|
44
55
|
*/
|
|
45
|
-
export declare function buildSkillDistillInstruction(role: string, skill: string, directives: readonly string[], existing?: string): string;
|
|
56
|
+
export declare function buildSkillDistillInstruction(role: string, skill: string, directives: readonly string[], existing?: string, retired?: readonly string[]): string;
|
|
46
57
|
export interface SkillAffinityEntry {
|
|
47
58
|
/** Times this skill was eagerly loaded into a spawn of this role. */
|
|
48
59
|
loaded: number;
|
|
@@ -63,17 +74,51 @@ export interface SkillAffinity {
|
|
|
63
74
|
export declare function loadSkillAffinity(role: string, projectRoot?: string): SkillAffinity;
|
|
64
75
|
/** Record that these skills were loaded into a spawn of `role`. */
|
|
65
76
|
export declare function recordSkillLoad(role: string, skills: readonly string[], projectRoot?: string): void;
|
|
66
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* Record the outcome of a task that ran with these skills loaded.
|
|
79
|
+
*
|
|
80
|
+
* Also stamps `lastUsedAt`: an outcome is the strongest evidence that a skill
|
|
81
|
+
* was in use, and the recency decay in {@link scoreSkillAffinity} reads that
|
|
82
|
+
* stamp. Leaving it to `recordSkillLoad` alone meant an affinity file written
|
|
83
|
+
* only through this path looked like it had never been touched.
|
|
84
|
+
*/
|
|
67
85
|
export declare function recordSkillOutcome(role: string, skills: readonly string[], ok: boolean, projectRoot?: string): void;
|
|
68
86
|
/** Record that a learned directive was routed to this skill. */
|
|
69
87
|
export declare function recordSkillLearned(role: string, skill: string, projectRoot?: string): void;
|
|
70
88
|
export declare function setSkillPinned(role: string, skill: string, pinned: boolean, projectRoot?: string): SkillAffinity;
|
|
89
|
+
/** Half-life of outcome evidence, in days. Older evidence fades toward neutral. */
|
|
90
|
+
export declare const SKILL_EVIDENCE_HALF_LIFE_DAYS = 30;
|
|
71
91
|
/**
|
|
72
|
-
* Score a skill for this role. Higher wins. Deterministic and monotone:
|
|
73
|
-
*
|
|
74
|
-
* back to the curated order and
|
|
92
|
+
* Score a skill for this role. Higher wins. Deterministic and monotone: with no
|
|
93
|
+
* recorded history every candidate scores exactly the same, so ranking falls
|
|
94
|
+
* back to the curated order and a fresh project behaves as if this layer did
|
|
95
|
+
* not exist.
|
|
96
|
+
*
|
|
97
|
+
* Four properties the previous scoring got wrong, each of which showed up as a
|
|
98
|
+
* skill that could not be dislodged:
|
|
99
|
+
*
|
|
100
|
+
* 1. **Failure counts against a skill.** The old form skipped Laplace smoothing
|
|
101
|
+
* when there were no outcomes, so "no evidence" scored 0 while ten straight
|
|
102
|
+
* failures scored 0.25 — failure ranked as evidence of relevance. The
|
|
103
|
+
* success rate is now centred on the 0.5 prior, so a losing record is
|
|
104
|
+
* negative and an untried skill is exactly neutral.
|
|
105
|
+
* 2. **Exposure is not merit.** `min(loaded, 10) * 0.1` paid a skill up to a
|
|
106
|
+
* full point for having been selected, which is a loop: selected skills
|
|
107
|
+
* out-scored unselected ones because they had been selected. The term is now
|
|
108
|
+
* an exploration bonus that *decays* with load count, so a skill that has
|
|
109
|
+
* never been tried is the one with something to prove.
|
|
110
|
+
* 3. **Evidence goes stale.** Counters are lifetime totals; a project that
|
|
111
|
+
* switched test runners four months ago still carried the old runner's wins
|
|
112
|
+
* at full weight. Outcome evidence now decays with a
|
|
113
|
+
* {@link SKILL_EVIDENCE_HALF_LIFE_DAYS}-day half-life.
|
|
114
|
+
* 4. **One chatty skill could pin the top slot.** `learned * 2` is unbounded, so
|
|
115
|
+
* a skill that attracts routing dominates every other signal forever. It is
|
|
116
|
+
* now logarithmic: still the strongest single term, no longer a lock.
|
|
117
|
+
*
|
|
118
|
+
* A missing `lastUsedAt` means "unknown", not "ancient" — legacy affinity files
|
|
119
|
+
* written before the field existed must not have their evidence zeroed.
|
|
75
120
|
*/
|
|
76
|
-
export declare function scoreSkillAffinity(entry: SkillAffinityEntry | undefined): number;
|
|
121
|
+
export declare function scoreSkillAffinity(entry: SkillAffinityEntry | undefined, now?: number): number;
|
|
77
122
|
/**
|
|
78
123
|
* Rank the candidate skills for a role by project affinity, keeping the
|
|
79
124
|
* curated order as a stable tie-break, and return at most `limit` names.
|
|
@@ -91,8 +91,16 @@ export declare const TOOLS: {
|
|
|
91
91
|
readonly write: readonly ["read", "grep", "glob", "search", "tree", "write", "edit", "replace", "patch", "mailbox"];
|
|
92
92
|
/** Full build loop: edit + run (lint/format/typecheck/test/bash). */
|
|
93
93
|
readonly build: readonly ["read", "grep", "glob", "search", "tree", "write", "edit", "replace", "patch", "bash", "exec", "lint", "format", "typecheck", "test", "mailbox"];
|
|
94
|
-
/**
|
|
95
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Version control.
|
|
96
|
+
*
|
|
97
|
+
* `mailbox` is in every preset on purpose: a subagent that hits a wall must
|
|
98
|
+
* be able to say so. This was the one preset without it, which left the `git`
|
|
99
|
+
* and `release` roles able to fail but not to ask — the two roles whose work
|
|
100
|
+
* most often needs a decision from the leader (force-push, tag collision,
|
|
101
|
+
* dirty tree) and least often has a safe default.
|
|
102
|
+
*/
|
|
103
|
+
readonly vcs: readonly ["read", "grep", "glob", "git", "diff", "mailbox"];
|
|
96
104
|
/** Dependency management + CVE audit. */
|
|
97
105
|
readonly deps: readonly ["read", "grep", "glob", "install", "outdated", "audit", "json", "mailbox"];
|
|
98
106
|
/** Documentation authoring. */
|
|
@@ -101,13 +101,22 @@ export interface SubagentPromptParts {
|
|
|
101
101
|
*/
|
|
102
102
|
export declare function composeSubagentPrompt(parts?: SubagentPromptParts): string;
|
|
103
103
|
/**
|
|
104
|
-
* Render a
|
|
105
|
-
*
|
|
106
|
-
*
|
|
104
|
+
* Render a bullet list summarising a roster — stuffed into
|
|
105
|
+
* `composeDirectorPrompt({ rosterSummary })` so the leader can see the roles it
|
|
106
|
+
* may spawn without scanning tool descriptions.
|
|
107
107
|
*
|
|
108
|
-
* Each entry: `- <role-id
|
|
109
|
-
*
|
|
110
|
-
*
|
|
108
|
+
* Each entry: `- <role-id>[ (<name>)][ (provider/model)] — <capability>`
|
|
109
|
+
*
|
|
110
|
+
* The capability comes from `dispatch.summary`, the curated one-liner the
|
|
111
|
+
* catalog already writes for every agent and the dispatcher already routes on.
|
|
112
|
+
* It used to come from the first 80 characters of `config.prompt`, which is
|
|
113
|
+
* how a 77-role menu came to read as 77 variations of "You are the X agent.
|
|
114
|
+
* Your job is…" with the discriminating half cut off. A leader given that list
|
|
115
|
+
* can only reliably pick the roles whose id spells out the job — and the usage
|
|
116
|
+
* data matched exactly that: 57 of the 77 roles had never once been chosen.
|
|
117
|
+
*
|
|
118
|
+
* The prompt headline stays as the fallback for roles with no dispatch
|
|
119
|
+
* metadata, so a hand-written project role is still listed.
|
|
111
120
|
*/
|
|
112
121
|
export declare function rosterSummaryFromConfigs(roster: Record<string, {
|
|
113
122
|
name: string;
|
|
@@ -115,5 +124,9 @@ export declare function rosterSummaryFromConfigs(roster: Record<string, {
|
|
|
115
124
|
model?: string | undefined;
|
|
116
125
|
prompt?: string | undefined;
|
|
117
126
|
role?: string | undefined;
|
|
127
|
+
dispatch?: {
|
|
128
|
+
summary: string;
|
|
129
|
+
keywords: string[];
|
|
130
|
+
} | undefined;
|
|
118
131
|
}>): string;
|
|
119
132
|
//# sourceMappingURL=director-prompts.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { SubagentConfig } from '../types/multi-agent.js';
|
|
2
2
|
import type { Tool } from '../types/tool.js';
|
|
3
3
|
import type * as Host from './director-host-contracts.js';
|
|
4
|
-
export { makeQualityGateTool } from './director-quality-gate-tool.js';
|
|
5
|
-
export { makeCollabDebugTool, makeFleetEmitTool, makeWorkCompleteTool, } from './director-collab-tools.js';
|
|
6
4
|
export { makeAskResultTool, makeAskTool, makeAssignTool, makeAwaitTasksTool, makeFleetTool, makeRollUpTool, makeTerminateAllTool, makeTerminateTool, } from './director-basic-tools.js';
|
|
5
|
+
export { makeCollabDebugTool, makeFleetEmitTool, makeWorkCompleteTool, } from './director-collab-tools.js';
|
|
6
|
+
export { makeQualityGateTool } from './director-quality-gate-tool.js';
|
|
7
7
|
export declare function makeSpawnTool(director: Host.DirectorAdmissionPort, roster?: Record<string, SubagentConfig>): Tool;
|
|
8
8
|
export declare function makeKanbanQueueTool(director: Host.DirectorLeaseRecoveryPort, roster?: Record<string, SubagentConfig>): Tool;
|
|
9
9
|
//# sourceMappingURL=director-tools.d.ts.map
|
|
@@ -26,12 +26,6 @@ export declare const REFACTOR_PLANNER_AGENT: SubagentConfig;
|
|
|
26
26
|
export declare const SECURITY_SCANNER_AGENT: SubagentConfig;
|
|
27
27
|
/** Generic template used directly or cloned into project-specific roles. */
|
|
28
28
|
export declare const GENERIC_AGENT: SubagentConfig;
|
|
29
|
-
/**
|
|
30
|
-
* All agents in a map for easy lookup by role. The 75-role phase catalog
|
|
31
|
-
* (`ALL_AGENT_DEFINITIONS`) already includes `critic` and the historical
|
|
32
|
-
* audit/review specialists. Adding standalone `generic` and `shadow-agent`
|
|
33
|
-
* roles produces 77 unique built-in role ids.
|
|
34
|
-
*/
|
|
35
29
|
export declare const FLEET_ROSTER: Record<string, SubagentConfig>;
|
|
36
30
|
export interface FleetRosterBudget {
|
|
37
31
|
timeoutMs?: number | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { createMessage, InMemoryAgentBridge, InMemoryBridgeTransport, } from './agent-bridge.js';
|
|
2
2
|
export { type AgentFactory, type AgentFactoryResult, type AgentRunnerOptions, makeAgentSubagentRunner, withDisabledToolFiltering, } from './agent-subagent-runner.js';
|
|
3
|
-
export { AGENT_CATALOG, AGENTS_BY_PHASE, type AgentBudgetTier, type AgentCapability, type AgentDefinition, type AgentPhase, ALL_AGENT_DEFINITIONS, applyProjectAgentConfig, assertProjectAgentRole, BUILD_AGENTS, buildConsolidationInstruction, buildProjectContextualizedPrompt, buildSkillDistillInstruction, CAPTURE_COOLDOWN_MS, CAPTURE_MAX_PER_SESSION, CAPTURE_SESSION_WINDOW_MS, type ConsolidationMetadata, type CreateProjectAgentInput, canCaptureNewLearned, captureLearnedFromAgentOutput, captureLearnedFromAgentOutputDetailed, clearProjectAgentConsolidated, clearProjectSkillAugmentation, createProjectAgent, createProjectAgentRoster, DEFAULT_EAGER_SKILL_LIMIT, DELIVERY_AGENTS,
|
|
3
|
+
export { AGENT_CATALOG, AGENTS_BY_PHASE, type AgentBudgetTier, type AgentCapability, type AgentDefinition, type AgentPhase, ALL_AGENT_DEFINITIONS, type AutoOptimizeDecision, type AutoOptimizeEvent, type AutoOptimizePolicy, type AutoOptimizePolicyOverrides, applyProjectAgentConfig, assertProjectAgentRole, BUILD_AGENTS, buildConsolidationInstruction, buildProjectContextualizedPrompt, buildSkillDistillInstruction, CAPTURE_COOLDOWN_MS, CAPTURE_MAX_PER_SESSION, CAPTURE_SESSION_WINDOW_MS, type ConsolidationMetadata, type CreateProjectAgentInput, canCaptureNewLearned, captureLearnedFromAgentOutput, captureLearnedFromAgentOutputDetailed, clearProjectAgentConsolidated, clearProjectSkillAugmentation, consolidatedDocumentPath, createProjectAgent, createProjectAgentRoster, DEFAULT_AUTO_OPTIMIZE_POLICY, DEFAULT_EAGER_SKILL_LIMIT, DELIVERY_AGENTS, DIRECTIVE_QUARANTINE_MAX_UTILITY, DIRECTIVE_QUARANTINE_MIN_APPLIED, DISCOVERY_AGENTS, type DirectiveOutcomeResult, DOMAIN_AGENTS, detectLearnedConflicts, directiveTrials, directiveUtility, directiveWasApplied, evaluateAutoOptimize, getAgentDefinition, getProjectAgentLearnStats, HEAVY_BUDGET, hintLearnedNeedsSummarization, isConsolidated, isProvenDirective, KNOWLEDGE_AGENTS, LEARNED_HARD_LIMIT, LEARNED_SOFT_LIMIT, type LearnedCaptureResult, LearningOptimizationScheduler, type LearningOptimizationSchedulerOptions, type LearningOptimizerLlm, LIGHT_BUDGET, listProjectAgentLearnedEntries, listProjectAgentRoles, listProjectSkillAugmentations, loadConsolidationMetadata, loadProjectAgentConfig, loadProjectAgentConsolidated, loadProjectAgentIdentity, loadProjectAgentLearned, loadProjectAgentLearningPolicy, loadProjectAgentProfile, loadProjectSkillAugmentation, loadRoleKnowledgeManifest, loadSkillAffinity, MEDIUM_BUDGET, META_AGENTS, type OptimizeLearningOptions, type OptimizeLearningResult, optimizeProjectAgentLearning, PLANNING_AGENTS, type ProjectAgentConfig, type ProjectAgentLearningPolicy, type ProjectAgentProfile, type QuarantinedDirective, quarantinePath, REVIEW_AGENTS, type RoleKnowledgeManifest, rankRoleSkills, readQuarantinedDirectives, readRawLearnedEntries, recordDirectiveOutcomes, recordSkillLoad, recordSkillOutcome, refreshProjectAgentIdentity, renderSkillAugmentation, resetCaptureWindow, resetCaptureWindows, resetProjectAgentIdentity, resolveAutoOptimizePolicy, resolveRoleSkillCandidates, retiredDirectivesToWarnAbout, routeDirectiveToSkill, type SaveConsolidationOptions, SKILL_AUGMENTATION_MAX_BYTES, type SkillAffinity, type SkillAffinityEntry, saveProjectAgentConsolidated, saveProjectSkillAugmentation, scoreSkillAffinity, scrubRetiredLines, setSkillPinned, slugifyProjectAgentRole, unwrapWholeDocumentFence, updateProjectAgentConfig, updateProjectAgentIdentity, updateProjectAgentKnowledge, updateProjectAgentLearned, updateProjectAgentLearningPolicy, VERIFY_AGENTS, validateProjectAgentConfig, } from './agents/index.js';
|
|
4
4
|
export { type AutoExtendCeiling, type AutoExtendPolicy, attachAutoExtend, } from './auto-extend.js';
|
|
5
5
|
export { type BrainArbiter, type BrainDecision, type BrainDecisionOption, BrainDecisionQueue, type BrainDecisionRequest, type BrainDecisionSource, type BrainEscalationMode, type BrainFallback, type BrainRisk, DefaultBrainArbiter, type DefaultBrainArbiterOptions, EscalationRoutingBrainArbiter, formatHumanPrompt, HumanEscalatingBrainArbiter, ObservableBrainArbiter, terminalPolicyDecision, } from './brain.js';
|
|
6
6
|
export { BrainDecisionLedger, type BrainDecisionLedgerOptions, type BrainLedgerEntry, brainDecisionKey, createLedgerGuardBrainArbiter, type LedgerGuardBrainArbiterOptions, } from './brain-ledger.js';
|
|
@@ -34,6 +34,7 @@ export type { MailboxCredentialVerifier, RedactedMailboxCredential, } from './ma
|
|
|
34
34
|
export { redactMailboxCredential } from './mailbox-credential-store.js';
|
|
35
35
|
export { CREDENTIAL_VERIFY_COOLDOWN_MS, CREDENTIAL_VERIFY_MAX_FAILURES, CREDENTIAL_VERIFY_WINDOW_MS, CredentialVerifyThrottle, credentialVerifyThrottle, } from './mailbox-credential-throttle.js';
|
|
36
36
|
export { MailboxEventEmitter } from './mailbox-events.js';
|
|
37
|
+
export { mailboxProjectServerEndpoint, mailboxProjectServerMetadataPath, } from './mailbox-project-server-endpoint.js';
|
|
37
38
|
export { buildDownAlert, buildRecoveryAlert, type DownAlertInput, MAILBOX_HEALTH_DEFAULT_FAILURE_THRESHOLD, MAILBOX_HEALTH_DEFAULT_FROM, MAILBOX_HEALTH_DEFAULT_INTERVAL_MS, MAILBOX_HEALTH_DEFAULT_TIMEOUT_MS, type MailboxHealthEvent, MailboxHealthWatchdog, type MailboxHealthWatchdogOptions, type RecoveryAlertInput, validateWatchdogOptions, type WatchdogConfig, } from './mailbox-health.js';
|
|
38
39
|
export { createMailboxHooks, type MailboxHooksOptions, } from './mailbox-hooks.js';
|
|
39
40
|
export { authorizeMailboxBearerToken, authorizePersistedMailboxCredential, createMailboxHttpRouter, MAILBOX_HTTP_DEFAULT_MAX_AGE_MS, MAILBOX_HTTP_MAX_AGE_CEILING_MS, MAILBOX_HTTP_MAX_BODY_BYTES, MAILBOX_HTTP_RATE_LIMIT_PER_MINUTE, MAILBOX_HTTP_RATE_LIMIT_WINDOW_MS, type MailboxHttpAccessDecision, MailboxHttpRateLimiter, type MailboxHttpRouter, type MailboxHttpRouterOptions, } from './mailbox-http-router.js';
|