@nexus-cortex/core 4.127.2 → 4.129.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/.env.defaults +29 -5
- package/dist/adapters/GatewayTranslationLayer.d.ts +2 -0
- package/dist/adapters/GatewayTranslationLayer.d.ts.map +1 -1
- package/dist/adapters/GatewayTranslationLayer.js +3 -0
- package/dist/adapters/GatewayTranslationLayer.js.map +1 -1
- package/dist/agents/AgentStore.d.ts.map +1 -1
- package/dist/agents/AgentStore.js +6 -0
- package/dist/agents/AgentStore.js.map +1 -1
- package/dist/config/RuntimeConfigRegistry.d.ts.map +1 -1
- package/dist/config/RuntimeConfigRegistry.js +3 -0
- package/dist/config/RuntimeConfigRegistry.js.map +1 -1
- package/dist/config/SettingsLoader.d.ts.map +1 -1
- package/dist/config/SettingsLoader.js +4 -0
- package/dist/config/SettingsLoader.js.map +1 -1
- package/dist/config/SettingsSchema.d.ts +5 -0
- package/dist/config/SettingsSchema.d.ts.map +1 -1
- package/dist/config/SettingsSchema.js +37 -1
- package/dist/config/SettingsSchema.js.map +1 -1
- package/dist/config/effectiveConfig.d.ts.map +1 -1
- package/dist/config/effectiveConfig.js +4 -1
- package/dist/config/effectiveConfig.js.map +1 -1
- package/dist/config/setupPlan.d.ts.map +1 -1
- package/dist/config/setupPlan.js +3 -1
- package/dist/config/setupPlan.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/models/cards/mercury/index.d.ts +1 -0
- package/dist/models/cards/mercury/index.d.ts.map +1 -1
- package/dist/models/cards/mercury/index.js +4 -0
- package/dist/models/cards/mercury/index.js.map +1 -1
- package/dist/models/cards/mercury/mercury-3.d.ts +29 -0
- package/dist/models/cards/mercury/mercury-3.d.ts.map +1 -0
- package/dist/models/cards/mercury/mercury-3.js +38 -0
- package/dist/models/cards/mercury/mercury-3.js.map +1 -0
- package/dist/models/registry/ModularModelRegistry.d.ts.map +1 -1
- package/dist/models/registry/ModularModelRegistry.js +2 -1
- package/dist/models/registry/ModularModelRegistry.js.map +1 -1
- package/dist/orchestrator/CortexOrchestrator.d.ts +0 -6
- package/dist/orchestrator/CortexOrchestrator.d.ts.map +1 -1
- package/dist/orchestrator/CortexOrchestrator.js +38 -16
- package/dist/orchestrator/CortexOrchestrator.js.map +1 -1
- package/dist/orchestrator/SubAgentIPC.d.ts +2 -0
- package/dist/orchestrator/SubAgentIPC.d.ts.map +1 -1
- package/dist/orchestrator/SubAgentIPC.js.map +1 -1
- package/dist/orchestrator/SubAgentProcessManager.d.ts.map +1 -1
- package/dist/orchestrator/SubAgentProcessManager.js +1 -0
- package/dist/orchestrator/SubAgentProcessManager.js.map +1 -1
- package/dist/orchestrator/SubAgentTypes.d.ts +14 -0
- package/dist/orchestrator/SubAgentTypes.d.ts.map +1 -1
- package/dist/orchestrator/toolAllowlist.d.ts +17 -0
- package/dist/orchestrator/toolAllowlist.d.ts.map +1 -0
- package/dist/orchestrator/toolAllowlist.js +36 -0
- package/dist/orchestrator/toolAllowlist.js.map +1 -0
- package/dist/tools/ServerSideTools.d.ts.map +1 -1
- package/dist/tools/ServerSideTools.js +4 -2
- package/dist/tools/ServerSideTools.js.map +1 -1
- package/dist/tools/ToolProfile.d.ts +17 -1
- package/dist/tools/ToolProfile.d.ts.map +1 -1
- package/dist/tools/ToolProfile.js +34 -1
- package/dist/tools/ToolProfile.js.map +1 -1
- package/dist/tools/registries/BaseToolRegistry.d.ts.map +1 -1
- package/dist/tools/registries/BaseToolRegistry.js +7 -1
- package/dist/tools/registries/BaseToolRegistry.js.map +1 -1
- package/dist/training/usageAccounting.d.ts +3 -0
- package/dist/training/usageAccounting.d.ts.map +1 -1
- package/dist/training/usageAccounting.js +2 -1
- package/dist/training/usageAccounting.js.map +1 -1
- package/package.json +3 -3
|
@@ -46,7 +46,7 @@ import { CacheMetricsAccumulator } from '../session/CacheMetricsAccumulator.js';
|
|
|
46
46
|
import { SubAgentProcessManager, createSubAgentProcessManager } from './SubAgentProcessManager.js';
|
|
47
47
|
// Phase 1: Tool Architecture Refactor - Unified Tool Registry
|
|
48
48
|
import { toolFactory } from '../tools/ToolFactory.js';
|
|
49
|
-
import { resolveToolProfile, resolveToolAnchor, resolveFrameProfile, resolveLiftNudge, resolveLiftPlan, resolveEndTurnResolver, resolveHeadlessDropAskUser, resolveDeferredLoading, isNarrowProfile, isToolAllowedByProfile, applyToolProfile, webToolBlocked, resolveVisionHelperModel, resolveVisionHandoffMax, resolveSliceNudge, resolveSliceBlock, resolveSliceBlockAt, resolveSliceBlockMax } from '../tools/ToolProfile.js';
|
|
49
|
+
import { resolveToolProfile, resolveToolAnchor, resolveFrameProfile, resolveLiftNudge, resolveLiftPlan, resolveEndTurnResolver, resolveHeadlessDropAskUser, resolveDeferredLoading, isNarrowProfile, isToolAllowedByProfile, applyToolProfile, webToolBlocked, resolveVisionHelperModel, resolveVisionHandoffMax, resolveSliceNudge, resolveSliceBlock, resolveSliceBlockAt, resolveSliceBlockMax, anchorAppliesToProcess } from '../tools/ToolProfile.js';
|
|
50
50
|
import { sliceReadFile, decideSliceBlock, sliceReadStep } from './sliceBlock.js';
|
|
51
51
|
import { TurnEvidence, evaluateEndTurnGates, buildMissingEndTurnReminder } from './endTurnGates.js';
|
|
52
52
|
import { resolveCompactionResume, pickDropped, buildCompactionResumeReminder, isCompactionResumeMessage, resolveTaskText, resumeMemoryTargetTokens, coversAll, buildRollingSeedMessage, memoryIndexLine, upsertMemoryIndex, scaleEstimateToRequestView, approxCharsOf, anchoredRequestEstimate, resolveCompactionHandoffQA, resolveHandoffQAMaxQuestions, runHandoffQA } from './compactionResume.js';
|
|
@@ -85,6 +85,7 @@ import { classifyTask } from '../training/TaskClassifier.js';
|
|
|
85
85
|
import { closestToolMatches } from './toolNameMatcher.js';
|
|
86
86
|
import { classifyApiError } from './apiErrorClassifier.js';
|
|
87
87
|
import { pinStaticSystemPrompt } from './staticSystemPromptPin.js';
|
|
88
|
+
import { applyAllowlistKeepingCore } from './toolAllowlist.js';
|
|
88
89
|
import { hasVisibleAssistantText, shouldForceSynthesis } from './assistantTextPresence.js';
|
|
89
90
|
import { resolveTurnContractEnforce, checkTurnFormat, buildFormatRejectMessage, resolveActionPlanFields, ACTION_PLAN_TOOLS, planFieldsMissing, stripPlanFields, buildPlanFieldsRejectMessage } from './turnContractValidator.js'; // HB-TURN-CONTRACT-ENFORCE / R172
|
|
90
91
|
import { computeToolBudgetSignal, isToolProgressStalled } from './toolBudgetSignal.js';
|
|
@@ -1687,6 +1688,8 @@ export class CortexOrchestrator {
|
|
|
1687
1688
|
applyAnchorIfArmed(tools) {
|
|
1688
1689
|
if (this.anchorLifted)
|
|
1689
1690
|
return tools;
|
|
1691
|
+
if (!anchorAppliesToProcess(process.env))
|
|
1692
|
+
return tools; // R266: delegates never get the narrow frame
|
|
1690
1693
|
const anchor = resolveToolAnchor(process.env, this.cardAnchorProfile);
|
|
1691
1694
|
if (!anchor)
|
|
1692
1695
|
return tools;
|
|
@@ -1696,7 +1699,7 @@ export class CortexOrchestrator {
|
|
|
1696
1699
|
* armed (pre-lift calls to hidden tools are refused like any hidden
|
|
1697
1700
|
* tool), the session profile after. */
|
|
1698
1701
|
effectiveGuardProfile() {
|
|
1699
|
-
if (!this.anchorLifted) {
|
|
1702
|
+
if (!this.anchorLifted && anchorAppliesToProcess(process.env)) {
|
|
1700
1703
|
const anchor = resolveToolAnchor(process.env, this.cardAnchorProfile);
|
|
1701
1704
|
if (anchor)
|
|
1702
1705
|
return anchor;
|
|
@@ -3803,6 +3806,7 @@ export class CortexOrchestrator {
|
|
|
3803
3806
|
// armed anchor narrowed toolsToUse at assembly. (When deferred loading
|
|
3804
3807
|
// is on, the re-filter block below performs the rebuild.)
|
|
3805
3808
|
if (!this.anchorLifted &&
|
|
3809
|
+
anchorAppliesToProcess(process.env) &&
|
|
3806
3810
|
resolveToolAnchor(process.env, this.cardAnchorProfile) &&
|
|
3807
3811
|
// Persist frame (backlog item 5): the anchored surface IS the session
|
|
3808
3812
|
// surface — never lift, never deliver the deferred corpus.
|
|
@@ -4216,6 +4220,17 @@ export class CortexOrchestrator {
|
|
|
4216
4220
|
const serverSideMetadata = extractServerSideMetadata(effectiveModel.provider, apiResponse.data);
|
|
4217
4221
|
if (this.config.debug)
|
|
4218
4222
|
console.log('[Orchestrator] Server-side metadata extracted:', serverSideMetadata ? 'YES' : 'NO');
|
|
4223
|
+
// 2026-10-18: bank every provider server-side call as a decision event (engagement evidence + cost attribution). Before this the only
|
|
4224
|
+
// trace of an x_thread_fetch was a text annotation in the merged message; usage.serverSideToolsUsed showed the LAST request only.
|
|
4225
|
+
if (serverSideMetadata && serverSideMetadata.toolCalls.length > 0) {
|
|
4226
|
+
const details = convertedResponse.usage?.serverSideToolUsageDetails;
|
|
4227
|
+
for (const tc of serverSideMetadata.toolCalls) {
|
|
4228
|
+
try {
|
|
4229
|
+
this.gateDeps().recordEvent('server_side_tool', { provider: effectiveModel.provider, name: tc.name, status: tc.status, args: String(tc.arguments ?? '').slice(0, 300), ...(details ? { details } : {}) }, tc.name);
|
|
4230
|
+
}
|
|
4231
|
+
catch { /* best-effort */ }
|
|
4232
|
+
}
|
|
4233
|
+
}
|
|
4219
4234
|
if (serverSideMetadata && this.config.debug) {
|
|
4220
4235
|
console.log('[Orchestrator] Server-side tool metadata detected:', {
|
|
4221
4236
|
autonomousExecution: serverSideMetadata.autonomousExecution,
|
|
@@ -5637,6 +5652,7 @@ export class CortexOrchestrator {
|
|
|
5637
5652
|
this.deliverPlateauInstructionAtBoot(); // R210 HB-PLATEAU-STOP — streaming mirror
|
|
5638
5653
|
// Anchor lift — streaming mirror of the sendMessage continuation path.
|
|
5639
5654
|
if (!this.anchorLifted &&
|
|
5655
|
+
anchorAppliesToProcess(process.env) &&
|
|
5640
5656
|
resolveToolAnchor(process.env, this.cardAnchorProfile) &&
|
|
5641
5657
|
// Persist frame (backlog item 5): the anchored surface IS the session
|
|
5642
5658
|
// surface — never lift, never deliver the deferred corpus.
|
|
@@ -6312,14 +6328,6 @@ export class CortexOrchestrator {
|
|
|
6312
6328
|
getToolDefinitions() {
|
|
6313
6329
|
return toolFactory.getAllTools();
|
|
6314
6330
|
}
|
|
6315
|
-
/**
|
|
6316
|
-
* Normalize a tool name for whitelist matching: lowercase + strip non-
|
|
6317
|
-
* alphanumerics so PascalCase canonical names match the lower/snake_case
|
|
6318
|
-
* names used in agent definitions (e.g. `WebSearch` ≡ `web_search`).
|
|
6319
|
-
*/
|
|
6320
|
-
static normalizeToolName(name) {
|
|
6321
|
-
return name.toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
6322
|
-
}
|
|
6323
6331
|
/**
|
|
6324
6332
|
* Apply `config.allowedBaseTools` to the factory/base tool list. Returns the
|
|
6325
6333
|
* list unchanged when no allowlist is configured. MCP/management/context
|
|
@@ -6346,11 +6354,7 @@ export class CortexOrchestrator {
|
|
|
6346
6354
|
return this.getFrameRunner().step({ action: input, task: this.lastRealUserText(), elapsedMs, deadlineMs: this.turnDeadlineMsActive, cwd: this.config.workingDirectory || process.cwd(), sessionId: this.currentSessionId ?? 'session', signal, predictorModel: 'generator' });
|
|
6347
6355
|
}
|
|
6348
6356
|
applyBaseToolAllowlist(tools) {
|
|
6349
|
-
|
|
6350
|
-
if (!allow || allow.length === 0)
|
|
6351
|
-
return tools;
|
|
6352
|
-
const allowed = new Set(allow.map((t) => CortexOrchestrator.normalizeToolName(t)));
|
|
6353
|
-
return tools.filter((t) => allowed.has(CortexOrchestrator.normalizeToolName(t.name)));
|
|
6357
|
+
return applyAllowlistKeepingCore(tools, this.config.allowedBaseTools); // R266: SearchTools + EndTurn always survive
|
|
6354
6358
|
}
|
|
6355
6359
|
/**
|
|
6356
6360
|
* Get adapter registry (for advanced use cases)
|
|
@@ -7087,6 +7091,16 @@ export class CortexOrchestrator {
|
|
|
7087
7091
|
*/
|
|
7088
7092
|
noteRequestUsage(usage) {
|
|
7089
7093
|
this.sessionUsage = addMainUsage(this.sessionUsage, usage); // R190: cumulative first — the anchor logic below skips zero usage
|
|
7094
|
+
// 2026-10-18: one server_side_tool event PER REQUEST that ran provider server-side tools (count + xAI's per-family details).
|
|
7095
|
+
// This hook sees every main request; the Phase 2.4 per-call events see only the turn's final response.
|
|
7096
|
+
const sst = Number(usage?.serverSideToolsUsed ?? 0);
|
|
7097
|
+
if (sst > 0) {
|
|
7098
|
+
const details = usage?.serverSideToolUsageDetails;
|
|
7099
|
+
try {
|
|
7100
|
+
this.gateDeps().recordEvent('server_side_tool', { count: sst, ...(details ? { details } : {}) }, 'server_side_tools');
|
|
7101
|
+
}
|
|
7102
|
+
catch { /* best-effort */ }
|
|
7103
|
+
}
|
|
7090
7104
|
const promptTokens = Number(usage?.inputTokens ?? 0);
|
|
7091
7105
|
if (!(promptTokens > 0))
|
|
7092
7106
|
return;
|
|
@@ -8503,10 +8517,15 @@ export class CortexOrchestrator {
|
|
|
8503
8517
|
// model gets an unambiguous, server-qualified handle. Without prefixing,
|
|
8504
8518
|
// bare names like `browse` collide with the model's PascalCase native
|
|
8505
8519
|
// tool conventions and tools across servers can shadow each other.
|
|
8520
|
+
// R266: a server named in CORTEX_MCP_AUTOCONNECT was asked for explicitly (the Browse delegate's
|
|
8521
|
+
// envOverrides) — its tools are ESSENTIAL so the deferred filter cannot strip them; other MCP tools
|
|
8522
|
+
// keep no tier (deferred as before).
|
|
8523
|
+
const pinnedServers = new Set((process.env.CORTEX_MCP_AUTOCONNECT ?? '').split(',').map((x) => x.trim()).filter(Boolean));
|
|
8506
8524
|
return mcpTools.map(tool => ({
|
|
8507
8525
|
name: prefixMcpToolName(tool.serverName, tool.name),
|
|
8508
8526
|
description: tool.description || `MCP tool from ${tool.serverName}`,
|
|
8509
8527
|
schema: tool.inputSchema || { type: 'object', properties: {} },
|
|
8528
|
+
...(pinnedServers.has(tool.serverName) ? { discoveryTier: 'essential' } : {}),
|
|
8510
8529
|
metadata: {
|
|
8511
8530
|
source: 'mcp',
|
|
8512
8531
|
serverName: tool.serverName,
|
|
@@ -8898,8 +8917,11 @@ export class CortexOrchestrator {
|
|
|
8898
8917
|
const { runtime, reason } = await this.resolveSubAgentRuntimeFor(input);
|
|
8899
8918
|
if (this.config.debug)
|
|
8900
8919
|
console.log(`[SubAgent] runtime ${runtime} (${reason})`);
|
|
8920
|
+
// R266b: the delegate inherits the parent's approval mode — auto-approving parents (headless, one-shot, TUI yolo)
|
|
8921
|
+
// must not leave a child blocked on an approval the operator never sees; interactive parents keep the IPC forward.
|
|
8922
|
+
const permissionMode = this.approvalMode?.autoApproveActions === true ? 'auto' : 'interactive';
|
|
8901
8923
|
if (runtime !== 'herdr')
|
|
8902
|
-
return processManager.spawnAgent(agentDef, taskPrompt, options);
|
|
8924
|
+
return processManager.spawnAgent(agentDef, taskPrompt, { ...options, permissionMode });
|
|
8903
8925
|
const name = sanitizeHerdrAgentName(`${agentDef.name}-${randomBytes(2).toString('hex')}`);
|
|
8904
8926
|
const result = await runDelegateInHerdr({
|
|
8905
8927
|
agentDef,
|