@mrrlin-dev/mcp 0.4.141 → 0.4.143
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/bin.cjs +32 -24
- package/package.json +1 -1
package/dist/bin.cjs
CHANGED
|
@@ -43772,6 +43772,28 @@ function addTurnTokenUsage(total, turn) {
|
|
|
43772
43772
|
outputTokens: add2(total.outputTokens, turn.outputTokens)
|
|
43773
43773
|
};
|
|
43774
43774
|
}
|
|
43775
|
+
var CONTEXT_WINDOW_TOKENS = 2e5;
|
|
43776
|
+
function extractContextWindow(method, params) {
|
|
43777
|
+
if (method !== TOKEN_USAGE_NOTIFICATION_METHOD)
|
|
43778
|
+
return null;
|
|
43779
|
+
if (params === null || typeof params !== "object")
|
|
43780
|
+
return null;
|
|
43781
|
+
const usage = params.tokenUsage;
|
|
43782
|
+
if (usage === null || typeof usage !== "object")
|
|
43783
|
+
return null;
|
|
43784
|
+
const window = readCount(usage, "modelContextWindow");
|
|
43785
|
+
return window !== null && window > 0 ? window : null;
|
|
43786
|
+
}
|
|
43787
|
+
function isNearContextLimit(usage, contextWindow) {
|
|
43788
|
+
if (!usage)
|
|
43789
|
+
return false;
|
|
43790
|
+
const contextTokens = (usage.inputTokens ?? 0) + (usage.outputTokens ?? 0);
|
|
43791
|
+
if (contextTokens <= 0)
|
|
43792
|
+
return false;
|
|
43793
|
+
const window = contextWindow && contextWindow > 0 ? contextWindow : CONTEXT_WINDOW_TOKENS;
|
|
43794
|
+
const remainingTokens = window - contextTokens;
|
|
43795
|
+
return remainingTokens / window < 0.03 || remainingTokens < 4e3;
|
|
43796
|
+
}
|
|
43775
43797
|
|
|
43776
43798
|
// ../../packages/agent-client/dist/providers/codex/event-mapper.js
|
|
43777
43799
|
var CodexBridgeEventMapper = class {
|
|
@@ -43938,7 +43960,8 @@ var CodexBridgeEventMapper = class {
|
|
|
43938
43960
|
const usage = extractTurnTokenUsage(TOKEN_USAGE_NOTIFICATION_METHOD, notification.params);
|
|
43939
43961
|
if (!usage)
|
|
43940
43962
|
return [];
|
|
43941
|
-
|
|
43963
|
+
const contextWindow = extractContextWindow(TOKEN_USAGE_NOTIFICATION_METHOD, notification.params);
|
|
43964
|
+
return [contextWindow === null ? { type: "token_usage", usage } : { type: "token_usage", usage, contextWindow }];
|
|
43942
43965
|
}
|
|
43943
43966
|
/** Bare `error` notifications carry model-stream failures ({ error: { message }, willRetry }).
|
|
43944
43967
|
* Retryable ones (willRetry=true) are transport noise — codex is still driving the turn — so
|
|
@@ -60648,7 +60671,7 @@ var mcpToolDescriptions = {
|
|
|
60648
60671
|
[mcpToolNames.searchWikiPages]: "Search project Wiki pages using ranked full-text search. Returns excerpts suitable for grounding Director decisions.",
|
|
60649
60672
|
[mcpToolNames.searchKnowledge]: "Search the rendered Mrrlin docs wiki using the lexical RAG index. Returns cited chunks with stable wiki_url fields.",
|
|
60650
60673
|
[mcpToolNames.updatePlan]: "Update a plan/epic.",
|
|
60651
|
-
[mcpToolNames.updateTask]: `Update a task. Honors DB invariants: closed_no_result requires linked Evidence wiki pages. Set directorThreadId here to persist the worker's resumable provider thread handle.
|
|
60674
|
+
[mcpToolNames.updateTask]: `Update a task. Honors DB invariants: closed_no_result requires linked Evidence wiki pages. Set directorThreadId here to persist the worker's resumable provider thread handle. declaredOutcome is an object {sentence, requires, verification} stating what must exist when the task is done; the Director sets it itself when writing the spec. Approving or skipping the spec (specApproved "approved"/"skipped") is the operator's tap on the task page and is refused for the Director: write the spec, set declaredOutcome, mark it ready, then ask the operator to approve. requires holds one kind; verification is "machine" for page, code_change or message, "human_tap" for document, file_set or structured_data.`,
|
|
60652
60675
|
[mcpToolNames.resetDirectorThread]: "Clear a task's persisted Director execution thread handle so the next execution run starts a fresh provider thread. Records a director_thread_reset task event.",
|
|
60653
60676
|
[mcpToolNames.archiveTask]: "Archive a task: hides it from default reads, removes it from plan progress and scheduler consideration, cancels its non-terminal execution runs, and closes its open inbox items. Reversible \u2014 the project owner can restore it with unarchive_task. Records an 'archived' task event.",
|
|
60654
60677
|
[mcpToolNames.unarchiveTask]: "Restore an archived task to its original status and visibility. Owner-only \u2014 refused with NOT_PROJECT_OWNER for any other caller. Does not resurrect the execution runs or inbox items that were cancelled/closed when the task was archived. Records a 'restored' task event.",
|
|
@@ -63794,7 +63817,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
63794
63817
|
}
|
|
63795
63818
|
|
|
63796
63819
|
// src/_generated/version.ts
|
|
63797
|
-
var PKG_VERSION = "0.4.
|
|
63820
|
+
var PKG_VERSION = "0.4.143";
|
|
63798
63821
|
|
|
63799
63822
|
// src/bridge-allowed-origins.ts
|
|
63800
63823
|
var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
|
|
@@ -67883,6 +67906,7 @@ async function driveTurn(deps, codex, projectSlug, runId, leaseId, threadId, inp
|
|
|
67883
67906
|
let touch = () => {
|
|
67884
67907
|
};
|
|
67885
67908
|
let turnUsage = null;
|
|
67909
|
+
let turnContextWindow = null;
|
|
67886
67910
|
const promptBytes = Buffer.byteLength(inputText, "utf8");
|
|
67887
67911
|
const turnStartedAt = Date.now();
|
|
67888
67912
|
let lastActivityAt = turnStartedAt;
|
|
@@ -67914,6 +67938,7 @@ async function driveTurn(deps, codex, projectSlug, runId, leaseId, threadId, inp
|
|
|
67914
67938
|
pending.push(persist(event));
|
|
67915
67939
|
if (event.type === "token_usage") {
|
|
67916
67940
|
turnUsage = event.usage;
|
|
67941
|
+
turnContextWindow = event.contextWindow ?? turnContextWindow;
|
|
67917
67942
|
} else if (event.type === "rate_limits") {
|
|
67918
67943
|
const signal = detectExhaustedProviderLimit(event.snapshot, Date.now());
|
|
67919
67944
|
if (signal) {
|
|
@@ -67975,7 +68000,7 @@ async function driveTurn(deps, codex, projectSlug, runId, leaseId, threadId, inp
|
|
|
67975
68000
|
clearInterval(touchTimer);
|
|
67976
68001
|
unsub();
|
|
67977
68002
|
}
|
|
67978
|
-
const telemetry = { promptBytes, usage: turnUsage };
|
|
68003
|
+
const telemetry = { promptBytes, usage: turnUsage, contextWindow: turnContextWindow };
|
|
67979
68004
|
return turnError ? { ok: false, error: turnError, interruptFailed, telemetry } : { ok: true, telemetry };
|
|
67980
68005
|
});
|
|
67981
68006
|
}
|
|
@@ -68238,14 +68263,6 @@ async function driveRun(deps, projectSlug, runId) {
|
|
|
68238
68263
|
runTelemetry.usage = addTurnTokenUsage(runTelemetry.usage, outcome.telemetry.usage);
|
|
68239
68264
|
return outcome;
|
|
68240
68265
|
};
|
|
68241
|
-
const isContextBudgetExhausted = (usage) => {
|
|
68242
|
-
if (!usage) return false;
|
|
68243
|
-
const contextTokens = (usage.inputTokens ?? 0) + (usage.outputTokens ?? 0);
|
|
68244
|
-
if (contextTokens <= 0) return false;
|
|
68245
|
-
const maxTokens = 2e5;
|
|
68246
|
-
const remainingTokens = maxTokens - contextTokens;
|
|
68247
|
-
return remainingTokens / maxTokens < 0.03 || remainingTokens < 4e3;
|
|
68248
|
-
};
|
|
68249
68266
|
const effortDecision = deriveEffort({
|
|
68250
68267
|
impact: task.impact,
|
|
68251
68268
|
type: task.type,
|
|
@@ -68589,7 +68606,7 @@ Continue executing task ${task.id}. Make the next concrete increment of progress
|
|
|
68589
68606
|
await failRun(deps, projectSlug, task, runId, leaseId, outcome.error);
|
|
68590
68607
|
return;
|
|
68591
68608
|
}
|
|
68592
|
-
if (
|
|
68609
|
+
if (isNearContextLimit(outcome.telemetry.usage, outcome.telemetry.contextWindow)) {
|
|
68593
68610
|
console.warn(
|
|
68594
68611
|
JSON.stringify({
|
|
68595
68612
|
event: "context_budget_gate_triggered",
|
|
@@ -78803,18 +78820,9 @@ function createBridgeMessageHandler(deps) {
|
|
|
78803
78820
|
return;
|
|
78804
78821
|
}
|
|
78805
78822
|
if (event.type === "token_usage") {
|
|
78806
|
-
const usage = event
|
|
78823
|
+
const { usage, contextWindow } = event;
|
|
78807
78824
|
turnTokenUsage = addTurnTokenUsage(turnTokenUsage, usage);
|
|
78808
|
-
if (
|
|
78809
|
-
const totalTokens = (turnTokenUsage.inputTokens ?? 0) + (turnTokenUsage.outputTokens ?? 0);
|
|
78810
|
-
if (totalTokens > 0) {
|
|
78811
|
-
const maxTokens = 2e5;
|
|
78812
|
-
const remainingTokens = maxTokens - totalTokens;
|
|
78813
|
-
if (remainingTokens / maxTokens < 0.03 || remainingTokens < 4e3) {
|
|
78814
|
-
contextBudgetGateTriggered = true;
|
|
78815
|
-
}
|
|
78816
|
-
}
|
|
78817
|
-
}
|
|
78825
|
+
if (isNearContextLimit(usage, contextWindow)) contextBudgetGateTriggered = true;
|
|
78818
78826
|
return;
|
|
78819
78827
|
}
|
|
78820
78828
|
if (event.type === "turn_completed" || event.type === "rate_limits") {
|