@wrongstack/core 0.306.3 → 0.307.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/dist/chronicle/index.js +957 -953
- package/dist/chronicle/metrics-ingest.d.ts +55 -0
- package/dist/chronicle/metrics-schema.d.ts +86 -0
- package/dist/chronicle/metrics-store.d.ts +5 -120
- package/dist/chronicle/project-server.js +1083 -1084
- package/dist/chronicle/sqlite-journal-quota.d.ts +39 -0
- package/dist/chronicle/sqlite-journal-schema.d.ts +25 -0
- package/dist/chronicle/sqlite-journal.d.ts +12 -177
- package/dist/coordination/agents/index.js +1738 -1690
- package/dist/coordination/agents/project-agent-capture.d.ts +48 -0
- package/dist/coordination/agents/project-agent-identity.d.ts +3 -129
- package/dist/coordination/agents/project-agent-roster.d.ts +17 -0
- package/dist/coordination/index.js +6103 -5890
- package/dist/coordination/mailbox-http-actor-query.d.ts +16 -0
- package/dist/coordination/mailbox-http-router.d.ts +0 -48
- package/dist/coordination/mailbox-http-sse.d.ts +12 -0
- package/dist/coordination/mailbox-message-types.d.ts +71 -0
- package/dist/coordination/mailbox-predicates.d.ts +13 -0
- package/dist/coordination/mailbox-project-server.js +1 -1
- package/dist/coordination/mailbox-session-sync.d.ts +8 -0
- package/dist/coordination/mailbox-types.d.ts +6 -793
- package/dist/core/agent-loop-context.d.ts +28 -0
- package/dist/core/agent-loop-detector.d.ts +25 -0
- package/dist/core/conversation-state.d.ts +1 -2
- package/dist/core/fallback-doctor.d.ts +72 -0
- package/dist/core/fallback-model.d.ts +19 -1
- package/dist/core/fallback-profile-manager.d.ts +21 -3
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.js +1143 -766
- package/dist/defaults/index.js +3833 -3595
- package/dist/execution/auto-compaction-middleware.d.ts +64 -0
- package/dist/execution/autonomy-brain-llm.d.ts +55 -0
- package/dist/execution/autonomy-brain.d.ts +3 -156
- package/dist/execution/compaction-budget.d.ts +38 -0
- package/dist/execution/compaction-core.d.ts +3 -166
- package/dist/execution/compaction-elision.d.ts +58 -0
- package/dist/execution/council-orchestrator-helpers.d.ts +39 -0
- package/dist/execution/council-orchestrator.d.ts +3 -42
- package/dist/execution/council-response-parser.d.ts +56 -0
- package/dist/execution/index.d.ts +1 -1
- package/dist/execution/index.js +10016 -9903
- package/dist/execution/prompt-enhancer.js +11 -3
- package/dist/execution/retry-policy.d.ts +27 -0
- package/dist/execution/tool-executor-guard.d.ts +18 -0
- package/dist/execution/tool-executor-runner.d.ts +12 -0
- package/dist/execution/tool-executor.d.ts +0 -75
- package/dist/goal/index.js +19 -6
- package/dist/hq/index.js +58 -17
- package/dist/index.d.ts +2 -1
- package/dist/index.js +8731 -7756
- package/dist/infrastructure/index.js +24 -1
- package/dist/kernel/events/agent-events.d.ts +2 -0
- package/dist/kernel/events/provider-events.d.ts +13 -0
- package/dist/plugin/index.js +2123 -1918
- package/dist/plugins/auto-review-config.d.ts +53 -0
- package/dist/plugins/auto-review-git.d.ts +19 -0
- package/dist/plugins/auto-review-plugin.d.ts +2 -140
- package/dist/plugins/review-finding-verification.d.ts +7 -0
- package/dist/prompts/index.d.ts +1 -0
- package/dist/prompts/prompt-journal.d.ts +94 -0
- package/dist/security/index.js +677 -667
- package/dist/security/permission-explain.d.ts +19 -0
- package/dist/security/permission-policy.d.ts +0 -101
- package/dist/security/yolo-risk.d.ts +5 -4
- package/dist/session-catalog/index.js +270 -227
- package/dist/session-catalog/project-server.js +277 -234
- package/dist/session-catalog/store-rebuild.d.ts +9 -0
- package/dist/session-catalog/store-schema.d.ts +48 -0
- package/dist/session-catalog/store.d.ts +0 -17
- package/dist/storage/cloud-config-sync/sanitize.d.ts +18 -0
- package/dist/storage/cloud-config-sync.d.ts +1 -1
- package/dist/storage/director-state.d.ts +6 -0
- package/dist/storage/file-session-writer.d.ts +2 -58
- package/dist/storage/index.d.ts +2 -1
- package/dist/storage/index.js +2121 -1736
- package/dist/storage/orphan-lock-cleaner.d.ts +15 -0
- package/dist/storage/provider-config-watcher.d.ts +9 -0
- package/dist/storage/session-recovery.d.ts +9 -0
- package/dist/storage/session-store/rename-session.d.ts +16 -0
- package/dist/storage/session-store/resume-session.d.ts +26 -0
- package/dist/storage/session-store/session-store-clear.d.ts +11 -0
- package/dist/storage/session-store/session-store-index.d.ts +13 -0
- package/dist/storage/session-store/strict-empty-check.d.ts +7 -0
- package/dist/storage/session-store.d.ts +2 -129
- package/dist/storage/session-summary-tracker.d.ts +39 -0
- package/dist/storage/session-write-buffer.d.ts +43 -0
- package/dist/storage/session-writer/session-writer-flush.d.ts +4 -0
- package/dist/storage/session-writer/session-writer-summary-tracker.d.ts +28 -0
- package/dist/tools/fallback-agent-model-assign-tool.d.ts +18 -0
- package/dist/tools/fallback-leader-model-set-tool.d.ts +18 -0
- package/dist/tools/fallback-manage-tools.d.ts +8 -45
- package/dist/tools/fallback-profile-manage-tool.d.ts +16 -0
- package/dist/tools/fallback-provider-key-set-tool.d.ts +17 -0
- package/dist/tools/fallback-provider-manage-tool.d.ts +26 -0
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +5150 -5090
- package/dist/types/config/root.d.ts +21 -2
- package/dist/types/default-config.d.ts +1 -1
- package/dist/types/index.d.ts +54 -55
- package/dist/types/index.js +953 -932
- package/dist/types/runtime-capability-manifest.d.ts +5 -5
- package/dist/types/session-markers.d.ts +12 -0
- package/dist/types/session-markers.js +19 -0
- package/dist/types/session.d.ts +7 -0
- package/dist/worktree/worktree-manager.d.ts +1 -1
- package/instructions/coordination/subagent-baseline.md +2 -2
- package/instructions/llm/prompt-enhancer.md +2 -1
- package/instructions/sections/tool/common-patterns.md +21 -0
- package/instructions/sections/tool/delegation-compact.md +3 -1
- package/instructions/sections/tool/delegation-full.md +5 -1
- package/instructions/system-lite.md +28 -3
- package/instructions/system-pro.md +37 -8
- package/instructions/system.md +4 -2
- package/package.json +5 -5
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Request } from '../types/provider.js';
|
|
2
|
+
import { type RequestTokenBreakdown } from '../utils/token-estimate.js';
|
|
3
|
+
import type { AgentInternals } from './agent-internals.js';
|
|
4
|
+
import type { AgentResponseHandler } from './agent-response.js';
|
|
5
|
+
import { type RunOptions } from './context.js';
|
|
6
|
+
export interface AgentLoopContextManager {
|
|
7
|
+
refreshProviderContextLimit(provider: import('../types/provider.js').Provider, model: string, opts?: {
|
|
8
|
+
probe?: boolean;
|
|
9
|
+
}): Promise<void>;
|
|
10
|
+
compactContextIfNeeded(): Promise<boolean>;
|
|
11
|
+
stashRequestTokens(req: Request): RequestTokenBreakdown;
|
|
12
|
+
refreshContextRequestTokenStash(opts?: {
|
|
13
|
+
force?: boolean | undefined;
|
|
14
|
+
}): number;
|
|
15
|
+
buildRequestWithPreflightCompaction(opts: RunOptions): Promise<{
|
|
16
|
+
req: Request;
|
|
17
|
+
provider: import('../types/provider.js').Provider;
|
|
18
|
+
preFlight: RequestTokenBreakdown;
|
|
19
|
+
}>;
|
|
20
|
+
emitContextPct(): void;
|
|
21
|
+
currentMaxContext(): number;
|
|
22
|
+
calibrationKey(model?: string): string;
|
|
23
|
+
get lastPreFlightMsgCount(): number;
|
|
24
|
+
}
|
|
25
|
+
export declare function createAgentLoopContextManager(a: AgentInternals, handlers: {
|
|
26
|
+
response: AgentResponseHandler;
|
|
27
|
+
}): AgentLoopContextManager;
|
|
28
|
+
//# sourceMappingURL=agent-loop-context.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ContentBlock, ToolUseBlock } from '../types/blocks.js';
|
|
2
|
+
import type { AgentInternals } from './agent-internals.js';
|
|
3
|
+
export declare function iterationFingerprint(blocks: ContentBlock[]): string;
|
|
4
|
+
export declare function stableStringify(value: unknown): string;
|
|
5
|
+
export declare function canonicalize(value: unknown): unknown;
|
|
6
|
+
export declare function hashSmall(s: string): string;
|
|
7
|
+
export interface LoopDetectorResult {
|
|
8
|
+
action: 'none' | 'steer' | 'cut';
|
|
9
|
+
cutSummary?: string;
|
|
10
|
+
steerMessage?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare class AgentLoopDetector {
|
|
13
|
+
private readonly a;
|
|
14
|
+
private lastToolSignature;
|
|
15
|
+
private toolLoopCount;
|
|
16
|
+
private iterationSteerDone;
|
|
17
|
+
private readonly recentCallKeys;
|
|
18
|
+
private readonly steeredCallKeys;
|
|
19
|
+
constructor(a: AgentInternals);
|
|
20
|
+
checkIteration(iterationIndex: number, content: ContentBlock[], toolUses: ToolUseBlock[], queueSteer: (text: string) => void): {
|
|
21
|
+
cut: boolean;
|
|
22
|
+
cutSummary?: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=agent-loop-detector.d.ts.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { ContentBlock } from '../types/blocks.js';
|
|
2
2
|
import type { Message } from '../types/messages.js';
|
|
3
|
-
import type { TodoItem } from './context.js';
|
|
4
|
-
import { Context } from './context.js';
|
|
3
|
+
import type { Context, TodoItem } from './context.js';
|
|
5
4
|
/**
|
|
6
5
|
* Observable wrapper for mutable conversation state. Production code should
|
|
7
6
|
* mutate messages, todos, and meta through this API so subscribers see a
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FallbackDoctor — diagnostic and simulation engine for WrongStack fallback systems.
|
|
3
|
+
*
|
|
4
|
+
* Provides deep inspection of active fallback configurations, diagnosing:
|
|
5
|
+
* - Single-provider sibling quarantine risks (account-wide token/quota blocks)
|
|
6
|
+
* - Context window bottlenecks (models too small for long sessions)
|
|
7
|
+
* - Provider credential and configuration health
|
|
8
|
+
* - Real-time quarantine / waiting room blocks
|
|
9
|
+
* - Step-by-step failover simulation for hypothetical errors (429, quota, etc.)
|
|
10
|
+
*/
|
|
11
|
+
import type { ProviderModelStatusTracker } from '../coordination/provider-status-tracker.js';
|
|
12
|
+
import type { Config } from '../types/config.js';
|
|
13
|
+
import { type ProviderErrorKind } from '../types/provider.js';
|
|
14
|
+
export interface FallbackDiagnosticWarning {
|
|
15
|
+
readonly code: 'EMPTY_CHAIN' | 'SIBLING_QUARANTINE_RISK' | 'PROVIDER_UNUSABLE' | 'MODEL_QUARANTINED' | 'CALENDAR_BLOCKED' | 'CONTEXT_WINDOW_WARNING';
|
|
16
|
+
readonly severity: 'warning' | 'critical' | 'info';
|
|
17
|
+
readonly message: string;
|
|
18
|
+
readonly target?: string | undefined;
|
|
19
|
+
readonly recommendation?: string | undefined;
|
|
20
|
+
}
|
|
21
|
+
export interface FallbackDiagnosticReport {
|
|
22
|
+
readonly primary: {
|
|
23
|
+
readonly providerId: string;
|
|
24
|
+
readonly model: string;
|
|
25
|
+
};
|
|
26
|
+
readonly activeProfile: string | undefined;
|
|
27
|
+
readonly explicitChain: readonly string[];
|
|
28
|
+
readonly effectiveOrder: readonly string[];
|
|
29
|
+
readonly autoEnabled: boolean;
|
|
30
|
+
readonly status: 'healthy' | 'warning' | 'critical';
|
|
31
|
+
readonly warnings: readonly FallbackDiagnosticWarning[];
|
|
32
|
+
readonly crossProviderCount: number;
|
|
33
|
+
readonly uniqueProviders: readonly string[];
|
|
34
|
+
}
|
|
35
|
+
export interface FallbackSimulationStep {
|
|
36
|
+
readonly index: number;
|
|
37
|
+
readonly providerId: string;
|
|
38
|
+
readonly model: string;
|
|
39
|
+
readonly skipped: boolean;
|
|
40
|
+
readonly reason?: string | undefined;
|
|
41
|
+
readonly providerSwitched: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface FallbackSimulationResult {
|
|
44
|
+
readonly triggeringError: ProviderErrorKind;
|
|
45
|
+
readonly isFallbackEligible: boolean;
|
|
46
|
+
readonly primary: {
|
|
47
|
+
readonly providerId: string;
|
|
48
|
+
readonly model: string;
|
|
49
|
+
};
|
|
50
|
+
readonly steps: readonly FallbackSimulationStep[];
|
|
51
|
+
readonly finalTarget: {
|
|
52
|
+
readonly providerId: string;
|
|
53
|
+
readonly model: string;
|
|
54
|
+
} | null;
|
|
55
|
+
readonly summary: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Diagnose the active fallback configuration and chain for common failure modes.
|
|
59
|
+
*/
|
|
60
|
+
export declare function diagnoseFallbackConfig(config: Config, tracker?: ProviderModelStatusTracker | undefined, opts?: {
|
|
61
|
+
modelContextLimitMap?: Record<string, number> | undefined;
|
|
62
|
+
} | undefined): FallbackDiagnosticReport;
|
|
63
|
+
/**
|
|
64
|
+
* Simulate a failover scenario for a given error kind and token level.
|
|
65
|
+
*/
|
|
66
|
+
export declare function simulateFallbackFailover(config: Config, opts?: {
|
|
67
|
+
errorKind?: ProviderErrorKind | undefined;
|
|
68
|
+
currentTokens?: number | undefined;
|
|
69
|
+
statusTracker?: ProviderModelStatusTracker | undefined;
|
|
70
|
+
modelContextLimitMap?: Record<string, number> | undefined;
|
|
71
|
+
}): FallbackSimulationResult;
|
|
72
|
+
//# sourceMappingURL=fallback-doctor.d.ts.map
|
|
@@ -143,9 +143,27 @@ export declare function fallbackProfileChain(config: Config, profileName: string
|
|
|
143
143
|
export declare function smartDefaultFallbackChain(config: Config): string[];
|
|
144
144
|
/**
|
|
145
145
|
* The effective fallback chain for a turn: the explicit `fallbackModels` list
|
|
146
|
-
* when non-empty, otherwise the
|
|
146
|
+
* when non-empty, otherwise the selected profile, otherwise the smart default
|
|
147
|
+
* (unless `fallbackAuto` is off).
|
|
148
|
+
*
|
|
149
|
+
* NOTE: this is the SELECTED chain, not the full runtime order — it omits the
|
|
150
|
+
* bridge, the primary re-insertion, the extra `default`-profile depth and the
|
|
151
|
+
* last-resort sweep that {@link runtimeFallbackChain} adds. Use
|
|
152
|
+
* `runtimeFallbackChain` for anything shown to a user as "what will be tried".
|
|
147
153
|
*/
|
|
148
154
|
export declare function effectiveFallbackChain(config: Config): string[];
|
|
155
|
+
/**
|
|
156
|
+
* The chain the agent loop will ACTUALLY rotate through, in order, if the
|
|
157
|
+
* current primary fails right now — the same `resolveCandidates` call the
|
|
158
|
+
* fallback extension makes, including bridge, primary re-insertion, the
|
|
159
|
+
* `default`-profile depth and the last-resort sweep.
|
|
160
|
+
*
|
|
161
|
+
* `/fallback` used to render `effectiveFallbackChain` instead, so the
|
|
162
|
+
* displayed chain could be four entries while the runtime rotated through
|
|
163
|
+
* seventeen — the view was structurally unable to match the behavior it
|
|
164
|
+
* claimed to describe.
|
|
165
|
+
*/
|
|
166
|
+
export declare function runtimeFallbackChain(config: Config): string[];
|
|
149
167
|
/**
|
|
150
168
|
* Build the cross-provider fallback extension. Always returns an extension —
|
|
151
169
|
* the effective chain (`effectiveFallbackChain`) is recomputed every turn from
|
|
@@ -59,12 +59,30 @@ export declare class FallbackProfileManager {
|
|
|
59
59
|
setStatusTracker(tracker: ProviderModelStatusTracker | undefined): void;
|
|
60
60
|
hasProfile(name: string): boolean;
|
|
61
61
|
listProfiles(): readonly string[];
|
|
62
|
+
/**
|
|
63
|
+
* The profile the session has selected (`config.fallbackProfile`, set by
|
|
64
|
+
* `/fallback profile use <name>`), or undefined when none is selected or the
|
|
65
|
+
* name no longer resolves to a defined profile.
|
|
66
|
+
*
|
|
67
|
+
* Consulted by every resolution entry point when the caller does not name a
|
|
68
|
+
* profile itself. Without this the leader — which passes no profile — could
|
|
69
|
+
* never use a named profile at all: `config.fallbackProfiles` was reachable
|
|
70
|
+
* only by copying a chain into `fallbackModels`.
|
|
71
|
+
*/
|
|
72
|
+
activeProfileName(): string | undefined;
|
|
62
73
|
/**
|
|
63
74
|
* Resolve a named fallback profile to a validated, provider-filtered chain.
|
|
64
75
|
*
|
|
65
|
-
* Returns an empty chain when
|
|
66
|
-
*
|
|
67
|
-
*
|
|
76
|
+
* Returns an empty chain when the profile doesn't exist, or when every entry
|
|
77
|
+
* is excluded, quarantined, or blacked out.
|
|
78
|
+
*
|
|
79
|
+
* Filtering is intentionally identical to {@link resolveRefs} (the explicit
|
|
80
|
+
* `fallbackModels` path): the self-exclusion, the runtime status tracker,
|
|
81
|
+
* and the availability calendar — nothing else. Anything a named profile
|
|
82
|
+
* drops, an explicit chain drops too, and vice versa. Profiles used to apply
|
|
83
|
+
* two extra filters (provider "usability" and the `providers[].models`
|
|
84
|
+
* snapshot) that the explicit path did not, which silently rerouted roles
|
|
85
|
+
* pinned to a profile onto a different model than the one configured.
|
|
68
86
|
*
|
|
69
87
|
* @param name - Profile name from config.fallbackProfiles.
|
|
70
88
|
* @param defaultProvider - Used when an entry has no explicit provider.
|
package/dist/core/index.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ export { buildBtwBlock, consumeBtwNotes, pendingBtwCount, setBtwNote, } from './
|
|
|
4
4
|
export { Context, type ContextInit, type ProviderMemoryEvidence, type RunOptions, type TodoItem, } from './context.js';
|
|
5
5
|
export { type ContinuationInput, type ContinuationSource, detectContinueIntent, type ResolvedContinuation, resolveContinuation, } from './continue-intent.js';
|
|
6
6
|
export { ConversationState, type ReadonlyConversationState, type StateChange, type StateChangeHandler, wrapAsState, } from './conversation-state.js';
|
|
7
|
-
export {
|
|
7
|
+
export { diagnoseFallbackConfig, type FallbackDiagnosticReport, type FallbackDiagnosticWarning, type FallbackSimulationResult, type FallbackSimulationStep, simulateFallbackFailover, } from './fallback-doctor.js';
|
|
8
|
+
export { createFallbackModelExtension, effectiveFallbackChain, type FallbackGateFn, type FallbackModelDeps, fallbackProfileChain, runtimeFallbackChain, smartDefaultFallbackChain, } from './fallback-model.js';
|
|
8
9
|
export { FallbackProfileManager } from './fallback-profile-manager.js';
|
|
9
10
|
export { InputBuilder, type InputBuilderEvent, type InputBuilderOptions, } from './input-builder.js';
|
|
10
11
|
export { type InstructionBundle, type InstructionBundlePaths, loadInstructionBundle, type SystemInstructionVariant, } from './instruction-bundle.js';
|