@wrongstack/core 0.41.0 → 0.54.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/{agent-bridge-D_XcS2HL.d.ts → agent-bridge-Dnhw4tnM.d.ts} +1 -1
- package/dist/{agent-subagent-runner-C66vi4Gq.d.ts → agent-subagent-runner-By7jruZ_.d.ts} +3 -3
- package/dist/{compactor-D1RHFRmF.d.ts → compactor-Duhsf0ge.d.ts} +1 -1
- package/dist/{config-ZRCf7sTu.d.ts → config-bht0txXS.d.ts} +33 -2
- package/dist/{context-7u93AcGD.d.ts → context-DtPKqKYV.d.ts} +1 -0
- package/dist/coordination/index.d.ts +12 -12
- package/dist/coordination/index.js +234 -32
- package/dist/coordination/index.js.map +1 -1
- package/dist/defaults/index.d.ts +23 -23
- package/dist/defaults/index.js +182 -75
- package/dist/defaults/index.js.map +1 -1
- package/dist/{events-BrQiweXN.d.ts → events-CbHTS4ZZ.d.ts} +136 -2
- package/dist/execution/index.d.ts +42 -16
- package/dist/execution/index.js +61 -28
- package/dist/execution/index.js.map +1 -1
- package/dist/extension/index.d.ts +6 -6
- package/dist/{goal-store-BeRsj7YX.d.ts → goal-store-DwcTDDiX.d.ts} +1 -1
- package/dist/{index-6_csX32J.d.ts → index-CI271MjL.d.ts} +5 -5
- package/dist/{index-DkVgH3wC.d.ts → index-ge5F2dnc.d.ts} +10 -8
- package/dist/index.d.ts +113 -37
- package/dist/index.js +601 -149
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.d.ts +6 -6
- package/dist/kernel/index.d.ts +9 -9
- package/dist/kernel/index.js +3 -1
- package/dist/kernel/index.js.map +1 -1
- package/dist/{mcp-servers-DONdo-XM.d.ts → mcp-servers-DE6gzBry.d.ts} +3 -3
- package/dist/models/index.d.ts +3 -3
- package/dist/models/index.js +36 -18
- package/dist/models/index.js.map +1 -1
- package/dist/{models-registry-gwMAo6E3.d.ts → models-registry-Cuq1C8V9.d.ts} +7 -0
- package/dist/{multi-agent-C8Z1i__e.d.ts → multi-agent-BmC_xiog.d.ts} +2 -2
- package/dist/{multi-agent-coordinator-BUsjiRWl.d.ts → multi-agent-coordinator-CjNX4uBD.d.ts} +2 -2
- package/dist/{null-fleet-bus-FvgHnZah.d.ts → null-fleet-bus-BNiSlTna.d.ts} +23 -11
- package/dist/observability/index.d.ts +2 -2
- package/dist/{path-resolver-DumKAi0n.d.ts → path-resolver-Bax85amb.d.ts} +2 -2
- package/dist/{permission-B6sldrSp.d.ts → permission-Drm7LpPo.d.ts} +1 -1
- package/dist/{permission-policy-CtNscWOA.d.ts → permission-policy-CU6sqWxF.d.ts} +2 -2
- package/dist/{plan-templates-DYCeRCDN.d.ts → plan-templates-CLRcurWN.d.ts} +4 -4
- package/dist/{provider-runner-Dlv8Fvw9.d.ts → provider-runner-BikCxGCx.d.ts} +3 -3
- package/dist/{retry-policy-KF18W4dg.d.ts → retry-policy-Chtlvr5b.d.ts} +1 -1
- package/dist/sdd/index.d.ts +8 -8
- package/dist/sdd/index.js.map +1 -1
- package/dist/security/index.d.ts +3 -3
- package/dist/{selector-DmXxpFyM.d.ts → selector-BvSPdJj6.d.ts} +1 -1
- package/dist/{session-reader-bfgsy2a0.d.ts → session-reader-BGhzMir4.d.ts} +1 -1
- package/dist/storage/index.d.ts +6 -6
- package/dist/storage/index.js +57 -37
- package/dist/storage/index.js.map +1 -1
- package/dist/{system-prompt-CM6zOhd2.d.ts → system-prompt-dtzV_mLm.d.ts} +1 -1
- package/dist/{tool-executor-BpK-SWtJ.d.ts → tool-executor-CgU0yWpB.d.ts} +4 -4
- package/dist/types/index.d.ts +15 -15
- package/dist/types/index.js +36 -18
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +14 -2
- package/dist/utils/index.js +18 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as BridgeTransport, B as BridgeMessage, A as AgentBridge, a as AgentBridgeConfig } from './multi-agent-
|
|
1
|
+
import { b as BridgeTransport, B as BridgeMessage, A as AgentBridge, a as AgentBridgeConfig } from './multi-agent-BmC_xiog.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* In-memory pub/sub transport for agent-to-agent messaging.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as Agent, f as AgentInput } from './index-
|
|
2
|
-
import { E as EventBus } from './events-
|
|
3
|
-
import { n as SubagentConfig, v as TaskSpec, t as SubagentRunner } from './multi-agent-
|
|
1
|
+
import { c as Agent, f as AgentInput } from './index-CI271MjL.js';
|
|
2
|
+
import { E as EventBus } from './events-CbHTS4ZZ.js';
|
|
3
|
+
import { n as SubagentConfig, v as TaskSpec, t as SubagentRunner } from './multi-agent-BmC_xiog.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Single fleet-wide event with subagent attribution. Whatever a child
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { W as WireFamily } from './models-registry-BcYJDKLm.js';
|
|
2
|
-
import { P as Permission } from './context-
|
|
2
|
+
import { a as Capabilities, P as Permission } from './context-DtPKqKYV.js';
|
|
3
3
|
|
|
4
4
|
type ContextWindowModeId = 'balanced' | 'frugal' | 'deep' | 'archival';
|
|
5
5
|
type ContextWindowAggressiveOn = 'hard' | 'soft' | 'warn';
|
|
@@ -115,6 +115,12 @@ interface ProviderConfig {
|
|
|
115
115
|
envVars?: string[];
|
|
116
116
|
/** Optional list of models the user wants visible for this provider. */
|
|
117
117
|
models?: string[];
|
|
118
|
+
/**
|
|
119
|
+
* Provider-relative custom model definitions (maps modelId → definition).
|
|
120
|
+
* Each entry adds/overrides a model for this provider with optional
|
|
121
|
+
* capability overrides. The model id is the key, not a fully qualified id.
|
|
122
|
+
*/
|
|
123
|
+
customModels?: Record<string, CustomModelDefinition>;
|
|
118
124
|
}
|
|
119
125
|
/**
|
|
120
126
|
* One entry in the per-task model matrix. Pins a catalog role, a phase, or
|
|
@@ -218,6 +224,24 @@ interface SyncConfig {
|
|
|
218
224
|
categories: SyncCategory[];
|
|
219
225
|
lastSyncedAt?: string;
|
|
220
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* Per-model capability overrides the user can define in their config.
|
|
229
|
+
* Used to add models not in the models.dev catalog, or override catalog
|
|
230
|
+
* facts when the real backend differs (e.g. local Ollama models, proxies).
|
|
231
|
+
*/
|
|
232
|
+
interface CustomModelDefinition {
|
|
233
|
+
/** Provider this model belongs to. Defaults to the owning ProviderConfig. */
|
|
234
|
+
provider?: string;
|
|
235
|
+
/** Optional display name. */
|
|
236
|
+
name?: string;
|
|
237
|
+
/** Capability overrides — only specified fields are overlaid. */
|
|
238
|
+
capabilities?: Partial<Capabilities>;
|
|
239
|
+
/**
|
|
240
|
+
* Max output tokens. If not specified, the provider family default
|
|
241
|
+
* or catalog entry is used.
|
|
242
|
+
*/
|
|
243
|
+
maxOutput?: number;
|
|
244
|
+
}
|
|
221
245
|
interface Config {
|
|
222
246
|
version: 1;
|
|
223
247
|
provider: string;
|
|
@@ -225,6 +249,13 @@ interface Config {
|
|
|
225
249
|
apiKey?: string;
|
|
226
250
|
baseUrl?: string;
|
|
227
251
|
providers?: Record<string, ProviderConfig>;
|
|
252
|
+
/**
|
|
253
|
+
* Top-level custom models (maps modelId → definition). Merged with
|
|
254
|
+
* per-provider `customModels` at resolution time. The key is the
|
|
255
|
+
* model id — not a fully qualified name. When the same model id
|
|
256
|
+
* appears in both places, the top-level one wins.
|
|
257
|
+
*/
|
|
258
|
+
models?: Record<string, CustomModelDefinition>;
|
|
228
259
|
/**
|
|
229
260
|
* Per-task model matrix. Keys are catalog roles (e.g. "security-scanner"),
|
|
230
261
|
* phase names (e.g. "review"), or the `*` default. Resolution precedence at
|
|
@@ -310,4 +341,4 @@ interface ConfigStore {
|
|
|
310
341
|
watch(cb: (next: Readonly<Config>, prev: Readonly<Config>) => void): () => void;
|
|
311
342
|
}
|
|
312
343
|
|
|
313
|
-
export { type AutonomyConfig as A, CONTEXT_WINDOW_MODES as C, DEFAULT_CONTEXT_WINDOW_MODE_ID as D, type FeaturesConfig as F, type LogConfig as L, type MCPServerConfig as M, type PluginConfig as P, type SessionLoggingConfig as S, type ToolsConfig as T, type Config as a, type ConfigLoader as b, type ConfigStore as c, type ContextConfig as d, type ContextWindowAggressiveOn as e, type ContextWindowConfigLike as f, type ContextWindowMode as g, type ContextWindowModeId as h, type ContextWindowPolicy as i, type ContextWindowThresholds as j, type
|
|
344
|
+
export { type AutonomyConfig as A, CONTEXT_WINDOW_MODES as C, DEFAULT_CONTEXT_WINDOW_MODE_ID as D, type FeaturesConfig as F, type LogConfig as L, type MCPServerConfig as M, type PluginConfig as P, type SessionLoggingConfig as S, type ToolsConfig as T, type Config as a, type ConfigLoader as b, type ConfigStore as c, type ContextConfig as d, type ContextWindowAggressiveOn as e, type ContextWindowConfigLike as f, type ContextWindowMode as g, type ContextWindowModeId as h, type ContextWindowPolicy as i, type ContextWindowThresholds as j, type CustomModelDefinition as k, type ModelMatrixEntry as l, type ProviderApiKey as m, type ProviderConfig as n, type SyncCategory as o, type SyncConfig as p, formatContextWindowModeList as q, getContextWindowMode as r, isContextWindowModeId as s, listContextWindowModes as t, resolveContextWindowPolicy as u };
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export { c as
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
|
|
1
|
+
export { B as BrainArbiter, a as BrainDecision, b as BrainDecisionOption, c as BrainDecisionQueue, d as BrainDecisionRequest, e as BrainDecisionSource, f as BrainFallback, g as BrainRisk, D as DefaultBrainArbiter, h as DefaultBrainArbiterOptions, H as HumanEscalatingBrainArbiter, O as ObservableBrainArbiter, l as formatHumanPrompt } from '../events-CbHTS4ZZ.js';
|
|
2
|
+
export { A as ACP_AGENTS, a as AGENTS_BY_PHASE, b as AGENT_CATALOG, c as ALL_AGENT_DEFINITIONS, d as ALL_FLEET_AGENTS, e as AUDIT_LOG_AGENT, f as AutoExtendCeiling, g as AutoExtendPolicy, B as BUG_HUNTER_AGENT, h as BugFinding, C as CollabBudgetConfig, i as CollabBudgetOverrides, j as CollabBudgetWarningPayload, k as CollabDebugReport, l as CollabSession, m as CollabSessionOptions, n as CreateDelegateToolOptions, o as CriticConcern, p as CriticEvaluation, D as DEFAULT_DIRECTOR_PREAMBLE, q as DEFAULT_SUBAGENT_BASELINE, r as DelegateHost, s as Director, t as DirectorAlert, u as DirectorAlertLevel, v as DirectorCancelCollabPayload, w as DirectorPromptParts, x as DirectorSessionFactory, y as DirectorSessionFactoryOptions, F as FLEET_ROSTER, z as FLEET_ROSTER_BUDGETS, E as FLEET_ROSTER_WITHACP, G as FleetCostCapError, H as FleetManager, I as FleetManagerOptions, J as FleetRosterBudget, K as FleetSpawnBudgetError, L as ICoordinator, M as IFleetManager, N as LargeAnswerStore, O as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, P as RefactorPhase, Q as RefactorPlan, S as SECURITY_SCANNER_AGENT, T as SharedFileEntry, U as SharedFileSnapshot, V as SubagentPromptParts, W as applyRosterBudget, X as attachAutoExtend, Y as composeDirectorPrompt, Z as composeSubagentPrompt, _ as createDelegateTool, $ as getAgentDefinition, a0 as makeAskResultTool, a1 as makeAskTool, a2 as makeAssignTool, a3 as makeAwaitTasksTool, a4 as makeCollabDebugTool, a5 as makeDirectorSessionFactory, a6 as makeFleetEmitTool, a7 as makeFleetHealthTool, a8 as makeFleetSessionTool, a9 as makeFleetStatusTool, aa as makeFleetUsageTool, ab as makeRollUpTool, ac as makeSpawnTool, ad as makeTerminateTool, ae as makeWorkCompleteTool, af as rosterSummaryFromConfigs } from '../null-fleet-bus-BNiSlTna.js';
|
|
3
|
+
import { b as AgentDefinition } from '../multi-agent-coordinator-CjNX4uBD.js';
|
|
4
|
+
export { T as AGENT_TOOL_PRESETS, A as AgentBudgetTier, a as AgentCapability, c as AgentPhase, D as DEFAULT_DISPATCH_ROLE, d as DefaultMultiAgentCoordinator, e as DispatchCandidate, f as DispatchClassifier, g as DispatchMethod, h as DispatchOptions, i as DispatchResult, H as HEAVY_BUDGET, L as LIGHT_BUDGET, M as MEDIUM_BUDGET, j as MultiAgentCoordinatorOptions, k as dispatchAgent, m as makeLLMClassifier, s as scoreAgents } from '../multi-agent-coordinator-CjNX4uBD.js';
|
|
5
|
+
export { c as BudgetExceededError, d as BudgetKind, e as BudgetLimits, f as BudgetNegotiationMode, g as BudgetThresholdDecision, h as BudgetThresholdHandler, i as BudgetThresholdSignal, j as BudgetUsage, m as SubagentBudget } from '../multi-agent-BmC_xiog.js';
|
|
6
|
+
export { A as AgentFactory, a as AgentFactoryResult, b as AgentRunnerOptions, F as FleetBus, c as FleetEvent, d as FleetHandler, e as FleetUsage, f as FleetUsageAggregator, S as SubagentUsageSnapshot, m as makeAgentSubagentRunner } from '../agent-subagent-runner-By7jruZ_.js';
|
|
7
|
+
export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-Dnhw4tnM.js';
|
|
8
|
+
import '../context-DtPKqKYV.js';
|
|
8
9
|
import 'node:events';
|
|
9
10
|
import '../director-state-BmYi3DGA.js';
|
|
10
|
-
import '../config-
|
|
11
|
+
import '../config-bht0txXS.js';
|
|
11
12
|
import '../models-registry-BcYJDKLm.js';
|
|
12
|
-
import '../
|
|
13
|
-
import '../index-6_csX32J.js';
|
|
13
|
+
import '../index-CI271MjL.js';
|
|
14
14
|
import '../logger-DDd5C--Z.js';
|
|
15
|
-
import '../system-prompt-
|
|
15
|
+
import '../system-prompt-dtzV_mLm.js';
|
|
16
16
|
import '../observability-BhnVLBLS.js';
|
|
17
17
|
import '../secret-scrubber-3MHDDAtm.js';
|
|
18
|
-
import '../permission-
|
|
18
|
+
import '../permission-Drm7LpPo.js';
|
|
19
19
|
|
|
20
20
|
/** Phase 1 · Discovery — map the territory before any work begins. */
|
|
21
21
|
declare const DISCOVERY_AGENTS: AgentDefinition[];
|
|
@@ -10,6 +10,147 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
10
10
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
11
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
12
|
});
|
|
13
|
+
|
|
14
|
+
// src/coordination/brain.ts
|
|
15
|
+
var ObservableBrainArbiter = class {
|
|
16
|
+
constructor(inner, events) {
|
|
17
|
+
this.inner = inner;
|
|
18
|
+
this.events = events;
|
|
19
|
+
}
|
|
20
|
+
inner;
|
|
21
|
+
events;
|
|
22
|
+
async decide(request) {
|
|
23
|
+
this.events.emit("brain.decision_requested", { request, at: Date.now() });
|
|
24
|
+
const decision = await this.inner.decide(request);
|
|
25
|
+
const event = decision.type === "ask_human" ? "brain.decision_ask_human" : decision.type === "deny" ? "brain.decision_denied" : "brain.decision_answered";
|
|
26
|
+
this.events.emit(event, { request, decision, at: Date.now() });
|
|
27
|
+
return decision;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
var BrainDecisionQueue = class {
|
|
31
|
+
constructor(events, opts = {}) {
|
|
32
|
+
this.events = events;
|
|
33
|
+
this.opts = opts;
|
|
34
|
+
this.offAnswer = this.events.on("brain.human_answered", (answer) => {
|
|
35
|
+
const pending = this.pending.get(answer.id);
|
|
36
|
+
if (!pending) return;
|
|
37
|
+
this.pending.delete(answer.id);
|
|
38
|
+
if (pending.timer) clearTimeout(pending.timer);
|
|
39
|
+
if (answer.deny) {
|
|
40
|
+
pending.resolve({ type: "deny", reason: answer.text ?? "Denied by human." });
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const option = pending.request.options?.find((o) => o.id === answer.optionId);
|
|
44
|
+
pending.resolve({
|
|
45
|
+
type: "answer",
|
|
46
|
+
optionId: answer.optionId,
|
|
47
|
+
text: answer.text ?? option?.label ?? answer.optionId ?? "Human answered.",
|
|
48
|
+
rationale: "Human answered a Brain escalation prompt."
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
events;
|
|
53
|
+
opts;
|
|
54
|
+
pending = /* @__PURE__ */ new Map();
|
|
55
|
+
offAnswer;
|
|
56
|
+
async requestHumanDecision(request) {
|
|
57
|
+
const ask = {
|
|
58
|
+
type: "ask_human",
|
|
59
|
+
prompt: formatHumanPrompt(request),
|
|
60
|
+
options: request.options,
|
|
61
|
+
rationale: "Decision escalated to human authority."
|
|
62
|
+
};
|
|
63
|
+
const pending = new Promise((resolve2) => {
|
|
64
|
+
const entry = { request, resolve: resolve2 };
|
|
65
|
+
if (this.opts.timeoutMs && this.opts.timeoutMs > 0) {
|
|
66
|
+
entry.timer = setTimeout(() => {
|
|
67
|
+
this.pending.delete(request.id);
|
|
68
|
+
resolve2({ type: "deny", reason: "Brain human decision timed out." });
|
|
69
|
+
}, this.opts.timeoutMs);
|
|
70
|
+
}
|
|
71
|
+
this.pending.set(request.id, entry);
|
|
72
|
+
});
|
|
73
|
+
this.events.emit("brain.decision_ask_human", { request, decision: ask, at: Date.now() });
|
|
74
|
+
return pending;
|
|
75
|
+
}
|
|
76
|
+
dispose() {
|
|
77
|
+
this.offAnswer();
|
|
78
|
+
for (const [id, pending] of this.pending) {
|
|
79
|
+
if (pending.timer) clearTimeout(pending.timer);
|
|
80
|
+
pending.resolve({ type: "deny", reason: "Brain decision queue disposed." });
|
|
81
|
+
this.pending.delete(id);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
var HumanEscalatingBrainArbiter = class {
|
|
86
|
+
constructor(inner, queue) {
|
|
87
|
+
this.inner = inner;
|
|
88
|
+
this.queue = queue;
|
|
89
|
+
}
|
|
90
|
+
inner;
|
|
91
|
+
queue;
|
|
92
|
+
async decide(request) {
|
|
93
|
+
const decision = await this.inner.decide(request);
|
|
94
|
+
if (decision.type !== "ask_human") return decision;
|
|
95
|
+
return this.queue.requestHumanDecision(request);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
var DefaultBrainArbiter = class {
|
|
99
|
+
allowLowRiskAutoAnswer;
|
|
100
|
+
constructor(opts = {}) {
|
|
101
|
+
this.allowLowRiskAutoAnswer = opts.allowLowRiskAutoAnswer ?? true;
|
|
102
|
+
}
|
|
103
|
+
async decide(request) {
|
|
104
|
+
const recommended = request.options?.find((option) => option.recommended);
|
|
105
|
+
if (this.allowLowRiskAutoAnswer && request.risk === "low" && recommended) {
|
|
106
|
+
return {
|
|
107
|
+
type: "answer",
|
|
108
|
+
optionId: recommended.id,
|
|
109
|
+
text: recommended.label,
|
|
110
|
+
rationale: "Low-risk request with an explicit recommended option."
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
switch (request.fallback) {
|
|
114
|
+
case "deny":
|
|
115
|
+
return {
|
|
116
|
+
type: "deny",
|
|
117
|
+
reason: `Brain could not safely decide: ${request.question}`
|
|
118
|
+
};
|
|
119
|
+
case "continue":
|
|
120
|
+
return {
|
|
121
|
+
type: "answer",
|
|
122
|
+
text: "Continue with the caller default.",
|
|
123
|
+
rationale: "No safe Brain decision was available; request fallback is continue."
|
|
124
|
+
};
|
|
125
|
+
case "ask_human":
|
|
126
|
+
return {
|
|
127
|
+
type: "ask_human",
|
|
128
|
+
prompt: formatHumanPrompt(request),
|
|
129
|
+
options: request.options,
|
|
130
|
+
rationale: "Decision requires human authority or lacks a safe automatic option."
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
function formatHumanPrompt(request) {
|
|
136
|
+
const lines = [
|
|
137
|
+
`Brain requires human decision for ${request.source}:`,
|
|
138
|
+
`Question: ${request.question}`
|
|
139
|
+
];
|
|
140
|
+
if (request.context?.trim()) {
|
|
141
|
+
lines.push("", "Context:", request.context.trim());
|
|
142
|
+
}
|
|
143
|
+
if (request.options?.length) {
|
|
144
|
+
lines.push("", "Options:");
|
|
145
|
+
for (const option of request.options) {
|
|
146
|
+
const risk = option.risk ? ` [risk: ${option.risk}]` : "";
|
|
147
|
+
const consequence = option.consequence ? ` \u2014 ${option.consequence}` : "";
|
|
148
|
+
lines.push(`- ${option.id}: ${option.label}${risk}${consequence}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
lines.push("", `Risk: ${request.risk}`);
|
|
152
|
+
return lines.join("\n");
|
|
153
|
+
}
|
|
13
154
|
async function atomicWrite(targetPath, content, opts = {}) {
|
|
14
155
|
const dir = path4.dirname(targetPath);
|
|
15
156
|
await fsp6.mkdir(dir, { recursive: true });
|
|
@@ -5814,6 +5955,12 @@ var Director = class _Director {
|
|
|
5814
5955
|
getLeaderContextPressure() {
|
|
5815
5956
|
return this.leaderContextPressure;
|
|
5816
5957
|
}
|
|
5958
|
+
resolveMaxContext() {
|
|
5959
|
+
const resolved = typeof this.maxContext === "function" ? this.maxContext() : this.maxContext;
|
|
5960
|
+
return resolved && resolved > 0 ? resolved : 128e3;
|
|
5961
|
+
}
|
|
5962
|
+
/** Optional Brain arbiter for director-level policy decisions. */
|
|
5963
|
+
brain;
|
|
5817
5964
|
/**
|
|
5818
5965
|
* Optional fleet-level policy container. When provided the Director
|
|
5819
5966
|
* delegates spawn budgeting, manifest entries, and checkpointing to it
|
|
@@ -5905,7 +6052,7 @@ var Director = class _Director {
|
|
|
5905
6052
|
leaderContextPressure = 0;
|
|
5906
6053
|
/** Maximum context load fraction before spawn is refused. */
|
|
5907
6054
|
maxLeaderContextLoad;
|
|
5908
|
-
/** Provider's max context window in tokens. */
|
|
6055
|
+
/** Provider's max context window in tokens, or a live resolver for runtime model switches. */
|
|
5909
6056
|
maxContext;
|
|
5910
6057
|
/** Per-task model matrix (static record or live getter); resolved
|
|
5911
6058
|
* per-spawn when no explicit model is set. */
|
|
@@ -5925,6 +6072,7 @@ var Director = class _Director {
|
|
|
5925
6072
|
largeAnswerStore;
|
|
5926
6073
|
constructor(opts) {
|
|
5927
6074
|
this.id = opts.config.coordinatorId || randomUUID();
|
|
6075
|
+
this.brain = opts.brain;
|
|
5928
6076
|
this.manifestPath = opts.manifestPath;
|
|
5929
6077
|
this.roster = opts.roster;
|
|
5930
6078
|
this.directorPreamble = opts.directorPreamble ?? DEFAULT_DIRECTOR_PREAMBLE;
|
|
@@ -6069,33 +6217,81 @@ var Director = class _Director {
|
|
|
6069
6217
|
return;
|
|
6070
6218
|
}
|
|
6071
6219
|
}
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6220
|
+
const grantExtension = () => {
|
|
6221
|
+
setImmediate(() => {
|
|
6222
|
+
const extra = {};
|
|
6223
|
+
const base = Math.max(payload.limit, payload.used);
|
|
6224
|
+
const grow = (ceiling) => Math.min(Math.ceil(base * 1.5), ceiling);
|
|
6225
|
+
let newLimit = base;
|
|
6226
|
+
switch (payload.kind) {
|
|
6227
|
+
case "iterations":
|
|
6228
|
+
newLimit = grow(5e4);
|
|
6229
|
+
extra.maxIterations = newLimit;
|
|
6230
|
+
break;
|
|
6231
|
+
case "tool_calls":
|
|
6232
|
+
newLimit = grow(1e5);
|
|
6233
|
+
extra.maxToolCalls = newLimit;
|
|
6234
|
+
break;
|
|
6235
|
+
case "tokens":
|
|
6236
|
+
newLimit = grow(5e6);
|
|
6237
|
+
extra.maxTokens = newLimit;
|
|
6238
|
+
break;
|
|
6239
|
+
case "cost":
|
|
6240
|
+
newLimit = Math.min(base * 1.5, 100);
|
|
6241
|
+
extra.maxCostUsd = newLimit;
|
|
6242
|
+
break;
|
|
6243
|
+
}
|
|
6244
|
+
extendCounts.set(guardKey, prior + 1);
|
|
6245
|
+
this.recordExtension(e.subagentId, e.taskId, payload.kind, newLimit);
|
|
6246
|
+
payload.extend(extra);
|
|
6247
|
+
});
|
|
6248
|
+
};
|
|
6249
|
+
if (this.brain) {
|
|
6250
|
+
void this.brain.decide({
|
|
6251
|
+
id: `director-budget-${e.subagentId}-${payload.kind}`,
|
|
6252
|
+
source: "director",
|
|
6253
|
+
question: `Should the director extend the ${payload.kind} budget for subagent ${e.subagentId}?`,
|
|
6254
|
+
context: [
|
|
6255
|
+
e.taskId ? `Task id: ${e.taskId}` : void 0,
|
|
6256
|
+
`Used: ${payload.used}`,
|
|
6257
|
+
`Limit: ${payload.limit}`,
|
|
6258
|
+
`Prior extensions for this kind: ${prior}`
|
|
6259
|
+
].filter(Boolean).join("\n"),
|
|
6260
|
+
risk: payload.kind === "cost" ? "high" : "medium",
|
|
6261
|
+
fallback: "continue",
|
|
6262
|
+
options: [
|
|
6263
|
+
{
|
|
6264
|
+
id: "extend",
|
|
6265
|
+
label: "Grant the director default budget extension",
|
|
6266
|
+
consequence: "The subagent continues with a larger per-kind budget.",
|
|
6267
|
+
risk: payload.kind === "cost" ? "high" : "medium",
|
|
6268
|
+
recommended: true
|
|
6269
|
+
},
|
|
6270
|
+
{
|
|
6271
|
+
id: "stop",
|
|
6272
|
+
label: "Stop this subagent at the current budget limit",
|
|
6273
|
+
consequence: "The current task will fail or stop due to budget pressure.",
|
|
6274
|
+
risk: "low"
|
|
6275
|
+
}
|
|
6276
|
+
]
|
|
6277
|
+
}).then((decision) => {
|
|
6278
|
+
if (decision.type === "deny") {
|
|
6279
|
+
payload.deny();
|
|
6280
|
+
return;
|
|
6281
|
+
}
|
|
6282
|
+
if (decision.type === "ask_human") {
|
|
6283
|
+
payload.deny();
|
|
6284
|
+
return;
|
|
6285
|
+
}
|
|
6286
|
+
if (decision.optionId === "stop" || /\bstop\b/i.test(decision.text)) {
|
|
6287
|
+
payload.deny();
|
|
6288
|
+
return;
|
|
6289
|
+
}
|
|
6290
|
+
grantExtension();
|
|
6291
|
+
}).catch(() => payload.deny());
|
|
6292
|
+
return;
|
|
6293
|
+
}
|
|
6294
|
+
grantExtension();
|
|
6099
6295
|
});
|
|
6100
6296
|
this.largeAnswerStore = new LargeAnswerStore(2e3);
|
|
6101
6297
|
}
|
|
@@ -6305,7 +6501,8 @@ var Director = class _Director {
|
|
|
6305
6501
|
}
|
|
6306
6502
|
}
|
|
6307
6503
|
if (this.maxLeaderContextLoad < 1) {
|
|
6308
|
-
const
|
|
6504
|
+
const maxContext = this.resolveMaxContext();
|
|
6505
|
+
const threshold = maxContext * this.maxLeaderContextLoad;
|
|
6309
6506
|
if (this.leaderContextPressure >= threshold) {
|
|
6310
6507
|
throw new FleetContextOverflowError(threshold, this.leaderContextPressure);
|
|
6311
6508
|
}
|
|
@@ -8142,7 +8339,7 @@ var FleetManager = class {
|
|
|
8142
8339
|
leaderContextPressure = 0;
|
|
8143
8340
|
/** Maximum context load fraction before spawn is refused. */
|
|
8144
8341
|
maxLeaderContextLoad;
|
|
8145
|
-
/** Provider's max context window in tokens. */
|
|
8342
|
+
/** Provider's max context window in tokens, or a live resolver for runtime model switches. */
|
|
8146
8343
|
maxContext;
|
|
8147
8344
|
constructor(opts = {}) {
|
|
8148
8345
|
this.manifestPath = opts.manifestPath;
|
|
@@ -8222,7 +8419,8 @@ var FleetManager = class {
|
|
|
8222
8419
|
}
|
|
8223
8420
|
}
|
|
8224
8421
|
if (this.maxLeaderContextLoad < 1) {
|
|
8225
|
-
const
|
|
8422
|
+
const maxContext = this.resolveMaxContext();
|
|
8423
|
+
const threshold = maxContext * this.maxLeaderContextLoad;
|
|
8226
8424
|
if (this.leaderContextPressure >= threshold) {
|
|
8227
8425
|
return {
|
|
8228
8426
|
kind: "max_context_load",
|
|
@@ -8236,6 +8434,10 @@ var FleetManager = class {
|
|
|
8236
8434
|
setLeaderContextPressure(tokens) {
|
|
8237
8435
|
this.leaderContextPressure = tokens;
|
|
8238
8436
|
}
|
|
8437
|
+
resolveMaxContext() {
|
|
8438
|
+
const resolved = typeof this.maxContext === "function" ? this.maxContext() : this.maxContext;
|
|
8439
|
+
return resolved && resolved > 0 ? resolved : 128e3;
|
|
8440
|
+
}
|
|
8239
8441
|
/**
|
|
8240
8442
|
* Assign a memorable nickname (e.g. "Einstein (Bug Hunter)") to the config,
|
|
8241
8443
|
* record it so the same name is never reused, then record the spawn.
|
|
@@ -8459,6 +8661,6 @@ var FleetManager = class {
|
|
|
8459
8661
|
}
|
|
8460
8662
|
};
|
|
8461
8663
|
|
|
8462
|
-
export { ACP_AGENTS, AGENTS_BY_PHASE, AGENT_CATALOG, TOOLS as AGENT_TOOL_PRESETS, ALL_AGENT_DEFINITIONS, ALL_FLEET_AGENTS, AUDIT_LOG_AGENT, BUG_HUNTER_AGENT, BUILD_AGENTS, BudgetExceededError, BudgetThresholdSignal, CollabSession, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_DISPATCH_ROLE, DEFAULT_SUBAGENT_BASELINE, DELIVERY_AGENTS, DISCOVERY_AGENTS, DOMAIN_AGENTS, DefaultMultiAgentCoordinator, Director, DirectorAlertLevel, FLEET_ROSTER, FLEET_ROSTER_BUDGETS, FLEET_ROSTER_WITHACP, FleetBus, FleetCostCapError, FleetManager, FleetSpawnBudgetError, FleetUsageAggregator, HEAVY_BUDGET, InMemoryAgentBridge, InMemoryBridgeTransport, KNOWLEDGE_AGENTS, LIGHT_BUDGET, LargeAnswerStore, MEDIUM_BUDGET, META_AGENTS, NULL_FLEET_BUS, PLANNING_AGENTS, REFACTOR_PLANNER_AGENT, REVIEW_AGENTS, SECURITY_SCANNER_AGENT, SubagentBudget, VERIFY_AGENTS, applyRosterBudget, attachAutoExtend, composeDirectorPrompt, composeSubagentPrompt, createDelegateTool, createMessage, dispatchAgent, getAgentDefinition, makeAgentSubagentRunner, makeAskResultTool, makeAskTool, makeAssignTool, makeAwaitTasksTool, makeCollabDebugTool, makeDirectorSessionFactory, makeFleetEmitTool, makeFleetHealthTool, makeFleetSessionTool, makeFleetStatusTool, makeFleetUsageTool, makeLLMClassifier, makeRollUpTool, makeSpawnTool, makeTerminateTool, makeWorkCompleteTool, rosterSummaryFromConfigs, scoreAgents };
|
|
8664
|
+
export { ACP_AGENTS, AGENTS_BY_PHASE, AGENT_CATALOG, TOOLS as AGENT_TOOL_PRESETS, ALL_AGENT_DEFINITIONS, ALL_FLEET_AGENTS, AUDIT_LOG_AGENT, BUG_HUNTER_AGENT, BUILD_AGENTS, BrainDecisionQueue, BudgetExceededError, BudgetThresholdSignal, CollabSession, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_DISPATCH_ROLE, DEFAULT_SUBAGENT_BASELINE, DELIVERY_AGENTS, DISCOVERY_AGENTS, DOMAIN_AGENTS, DefaultBrainArbiter, DefaultMultiAgentCoordinator, Director, DirectorAlertLevel, FLEET_ROSTER, FLEET_ROSTER_BUDGETS, FLEET_ROSTER_WITHACP, FleetBus, FleetCostCapError, FleetManager, FleetSpawnBudgetError, FleetUsageAggregator, HEAVY_BUDGET, HumanEscalatingBrainArbiter, InMemoryAgentBridge, InMemoryBridgeTransport, KNOWLEDGE_AGENTS, LIGHT_BUDGET, LargeAnswerStore, MEDIUM_BUDGET, META_AGENTS, NULL_FLEET_BUS, ObservableBrainArbiter, PLANNING_AGENTS, REFACTOR_PLANNER_AGENT, REVIEW_AGENTS, SECURITY_SCANNER_AGENT, SubagentBudget, VERIFY_AGENTS, applyRosterBudget, attachAutoExtend, composeDirectorPrompt, composeSubagentPrompt, createDelegateTool, createMessage, dispatchAgent, formatHumanPrompt, getAgentDefinition, makeAgentSubagentRunner, makeAskResultTool, makeAskTool, makeAssignTool, makeAwaitTasksTool, makeCollabDebugTool, makeDirectorSessionFactory, makeFleetEmitTool, makeFleetHealthTool, makeFleetSessionTool, makeFleetStatusTool, makeFleetUsageTool, makeLLMClassifier, makeRollUpTool, makeSpawnTool, makeTerminateTool, makeWorkCompleteTool, rosterSummaryFromConfigs, scoreAgents };
|
|
8463
8665
|
//# sourceMappingURL=index.js.map
|
|
8464
8666
|
//# sourceMappingURL=index.js.map
|