@mcoda/codali 0.1.135-codali.37 → 0.1.135-codali.38

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/CHANGELOG.md CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - Model outages: a turn waits out an outage for up to 30 minutes (the retry
6
+ ladder, then a retry a minute), bounded by half the time it has left; the
7
+ four-minute ladder alone lost a three-hour build to a nine-minute relay
8
+ outage. Requests allowed more than 300 s no longer fail at 300 s without
9
+ response headers (the platform fetch's default).
10
+ - Deadlines: continuation and answer audits start only when they can finish
11
+ before the deadline and are stopped in time; if one fails or is stopped the
12
+ finished draft is delivered. A research audit that got no reply had cost a
13
+ complete answer.
14
+ - Research: web search is declared whenever page tools are, so a turn that
15
+ opens pages can find them instead of guessing URLs and opening search-engine
16
+ pages. The prompt states today's date from the host clock; one answer had
17
+ dated itself months earlier and called the real dates suspect.
18
+ - Calculator: comb/C/nCr, perm/P/nPr and factorial.
19
+
20
+ ## 0.1.135-codali.37 and earlier
21
+
5
22
  - Sandbox: a relocated Python (a CI tool cache or a copied installation, whose
6
23
  binary records the library directory it was built for) finds its interpreter
7
24
  library; the loader path points only at libraries already mounted from the
@@ -1,4 +1,12 @@
1
+ import { Agent } from "undici";
1
2
  import type { Provider, ProviderConfig, ProviderRequest, ProviderResponse } from "./ProviderTypes.js";
3
+ /** The platform fetch gives up after 300 s without response headers, even when
4
+ * the caller allows longer. A long non-streamed request (an answer audit on a
5
+ * large draft) then failed at exactly 300 s and the turn lost its finished
6
+ * answer. Requests allowed more than that use a dispatcher without those
7
+ * limits; the caller's own timeout still bounds them. */
8
+ export declare const FETCH_HEADERS_TIMEOUT_MS = 300000;
9
+ export declare const dispatcherFor: (timeoutMs: number) => Agent | undefined;
2
10
  export declare const fetchWithTransientRetry: (url: string, init: RequestInit, controller?: AbortController) => Promise<Response>;
3
11
  export declare class OpenAiCompatibleProvider implements Provider {
4
12
  private config;
@@ -1 +1 @@
1
- {"version":3,"file":"OpenAiCompatibleProvider.d.ts","sourceRoot":"","sources":["../../src/providers/OpenAiCompatibleProvider.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EAEd,eAAe,EACf,gBAAgB,EAGjB,MAAM,oBAAoB,CAAC;AAmK5B,eAAO,MAAM,uBAAuB,GAClC,KAAK,MAAM,EACX,MAAM,WAAW,EACjB,aAAa,eAAe,KAC3B,OAAO,CAAC,QAAQ,CAclB,CAAC;AAEF,qBAAa,wBAAyB,YAAW,QAAQ;IAS3C,OAAO,CAAC,MAAM;IAR1B,+EAA+E;IAC/E,QAAQ,CAAC,iBAAiB,QAAQ;IAElC,IAAI,SAAuB;IAC3B,OAAO,CAAC,WAAW,CAAoC;IACvD,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,sBAAsB,CAAoC;gBAE9C,MAAM,EAAE,cAAc;IAWpC,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAyQnE,OAAO,CAAC,WAAW;CA0BpB"}
1
+ {"version":3,"file":"OpenAiCompatibleProvider.d.ts","sourceRoot":"","sources":["../../src/providers/OpenAiCompatibleProvider.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EAEd,eAAe,EACf,gBAAgB,EAGjB,MAAM,oBAAoB,CAAC;AAmK5B;;;;yDAIyD;AACzD,eAAO,MAAM,wBAAwB,SAAU,CAAC;AAEhD,eAAO,MAAM,aAAa,GAAI,WAAW,MAAM,KAAG,KAAK,GAAG,SACgC,CAAC;AAE3F,eAAO,MAAM,uBAAuB,GAClC,KAAK,MAAM,EACX,MAAM,WAAW,EACjB,aAAa,eAAe,KAC3B,OAAO,CAAC,QAAQ,CAclB,CAAC;AAEF,qBAAa,wBAAyB,YAAW,QAAQ;IAS3C,OAAO,CAAC,MAAM;IAR1B,+EAA+E;IAC/E,QAAQ,CAAC,iBAAiB,QAAQ;IAElC,IAAI,SAAuB;IAC3B,OAAO,CAAC,WAAW,CAAoC;IACvD,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,sBAAsB,CAAoC;gBAE9C,MAAM,EAAE,cAAc;IAWpC,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA2QnE,OAAO,CAAC,WAAW;CA0BpB"}
@@ -1,4 +1,5 @@
1
1
  import { normalizeLocalOpenAiCompatibleRunnerConfig, } from "@mcoda/shared";
2
+ import { Agent } from "undici";
2
3
  import { ModelServiceError } from "./ModelServiceError.js";
3
4
  const parseToolArgs = (raw) => {
4
5
  try {
@@ -120,6 +121,15 @@ const isTransientNetworkError = (error) => {
120
121
  }
121
122
  return error instanceof TypeError && /fetch failed|network|socket/i.test(error.message);
122
123
  };
124
+ /** The platform fetch gives up after 300 s without response headers, even when
125
+ * the caller allows longer. A long non-streamed request (an answer audit on a
126
+ * large draft) then failed at exactly 300 s and the turn lost its finished
127
+ * answer. Requests allowed more than that use a dispatcher without those
128
+ * limits; the caller's own timeout still bounds them. */
129
+ export const FETCH_HEADERS_TIMEOUT_MS = 300000;
130
+ let unboundedDispatcher;
131
+ export const dispatcherFor = (timeoutMs) => timeoutMs > FETCH_HEADERS_TIMEOUT_MS
132
+ ? (unboundedDispatcher ?? (unboundedDispatcher = new Agent({ headersTimeout: 0, bodyTimeout: 0 }))) : undefined;
123
133
  export const fetchWithTransientRetry = async (url, init, controller) => {
124
134
  let lastError;
125
135
  for (let attempt = 0; attempt <= TRANSIENT_RETRIES; attempt += 1) {
@@ -254,6 +264,8 @@ export class OpenAiCompatibleProvider {
254
264
  body: JSON.stringify(body),
255
265
  signal: controller.signal,
256
266
  redirect: "error",
267
+ // The platform fetch accepts an undici dispatcher; RequestInit does not declare it.
268
+ ...(dispatcherFor(timeoutMs) ? { dispatcher: dispatcherFor(timeoutMs) } : {}),
257
269
  }, controller);
258
270
  if (!response.ok) {
259
271
  throw await ModelServiceError.fromResponse(response);
@@ -0,0 +1,14 @@
1
+ /** Waits between retries of a model request that failed before dispatch (about four minutes in total). */
2
+ export declare const PREFLIGHT_RECOVERY_WAITS_MS: number[];
3
+ /** The outage waits that fit the host's total (CODALI_MODEL_OUTAGE_WAIT_MS, in
4
+ * milliseconds); all of them when it is unset. */
5
+ export declare const outageWaitsMs: (budget?: string | undefined) => number[];
6
+ /** The longest a turn waits out one model-service outage. The ladder alone
7
+ * (about four minutes) lost a three-hour build to a nine-minute relay outage. */
8
+ export declare const MODEL_OUTAGE_WAIT_MS: number;
9
+ /** The wait before outage retry `attempt` (0-based): the ladder, then a minute
10
+ * per retry, while the total stays within the host's budget
11
+ * (CODALI_MODEL_OUTAGE_WAIT_MS), MODEL_OUTAGE_WAIT_MS and half the time the
12
+ * turn has left. Undefined once the outage has used that allowance. */
13
+ export declare const outageWaitMs: (attempt: number, remainingMs?: number, budget?: string | undefined) => number | undefined;
14
+ //# sourceMappingURL=OutageWait.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OutageWait.d.ts","sourceRoot":"","sources":["../../src/runtime/OutageWait.ts"],"names":[],"mappings":"AACA,0GAA0G;AAC1G,eAAO,MAAM,2BAA2B,UAA4D,CAAC;AACrG;kDACkD;AAClD,eAAO,MAAM,aAAa,GAAI,SAAQ,MAAM,GAAG,SAAmD,KAAG,MAAM,EAK1G,CAAC;AACF;iFACiF;AACjF,eAAO,MAAM,oBAAoB,QAAc,CAAC;AAChD;;;uEAGuE;AACvE,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,EAAE,oBAAsB,EAAE,SAAQ,MAAM,GAAG,SAAmD,KAAG,MAAM,GAAG,SAWrJ,CAAC"}
@@ -0,0 +1,33 @@
1
+ // How long a turn waits out a model-service outage before giving up.
2
+ /** Waits between retries of a model request that failed before dispatch (about four minutes in total). */
3
+ export const PREFLIGHT_RECOVERY_WAITS_MS = [500, 2000, 5000, 15000, 30000, 60000, 60000, 60000];
4
+ /** The outage waits that fit the host's total (CODALI_MODEL_OUTAGE_WAIT_MS, in
5
+ * milliseconds); all of them when it is unset. */
6
+ export const outageWaitsMs = (budget = process.env.CODALI_MODEL_OUTAGE_WAIT_MS) => {
7
+ const total = budget === undefined || budget.trim() === "" ? Infinity : Number(budget);
8
+ if (!(total >= 0))
9
+ return PREFLIGHT_RECOVERY_WAITS_MS;
10
+ let waited = 0;
11
+ return PREFLIGHT_RECOVERY_WAITS_MS.filter(wait => (waited += wait) <= total);
12
+ };
13
+ /** The longest a turn waits out one model-service outage. The ladder alone
14
+ * (about four minutes) lost a three-hour build to a nine-minute relay outage. */
15
+ export const MODEL_OUTAGE_WAIT_MS = 30 * 60000;
16
+ /** The wait before outage retry `attempt` (0-based): the ladder, then a minute
17
+ * per retry, while the total stays within the host's budget
18
+ * (CODALI_MODEL_OUTAGE_WAIT_MS), MODEL_OUTAGE_WAIT_MS and half the time the
19
+ * turn has left. Undefined once the outage has used that allowance. */
20
+ export const outageWaitMs = (attempt, remainingMs = Infinity, budget = process.env.CODALI_MODEL_OUTAGE_WAIT_MS) => {
21
+ const parsed = budget === undefined || budget.trim() === "" ? Infinity : Number(budget);
22
+ const cap = Math.min(parsed >= 0 ? parsed : Infinity, MODEL_OUTAGE_WAIT_MS, remainingMs * 0.5);
23
+ let waited = 0;
24
+ for (let index = 0; index <= attempt; index++) {
25
+ const wait = PREFLIGHT_RECOVERY_WAITS_MS[index] ?? 60000;
26
+ if (waited + wait > cap)
27
+ return undefined;
28
+ if (index === attempt)
29
+ return wait;
30
+ waited += wait;
31
+ }
32
+ return undefined;
33
+ };
@@ -5,11 +5,15 @@ import type { Provider, ProviderMessage } from "../providers/ProviderTypes.js";
5
5
  import { type EffortLevel, type ResolvedOrchestrationConfig } from "../config/OrchestrationConfig.js";
6
6
  import { PermissionGate, type PermissionProfile, type PermissionPrompt } from "../permissions/PermissionGate.js";
7
7
  import { type InteractionDecision } from "./InteractionRouter.js";
8
- /** Waits between retries of a model request that failed before dispatch (about four minutes in total). */
9
- export declare const PREFLIGHT_RECOVERY_WAITS_MS: number[];
10
- /** The outage waits that fit the host's total (CODALI_MODEL_OUTAGE_WAIT_MS, in
11
- * milliseconds); all of them when it is unset. */
12
- export declare const outageWaitsMs: (budget?: string | undefined) => number[];
8
+ import { PREFLIGHT_RECOVERY_WAITS_MS, outageWaitsMs, outageWaitMs, MODEL_OUTAGE_WAIT_MS } from "./OutageWait.js";
9
+ /** Today's date from the host clock, stated as authoritative. Without it a
10
+ * research answer dated itself from the model's own belief (2026-08-24 on
11
+ * 2026-11-13) and called the real dates in retrieved pages suspect. Day
12
+ * granularity keeps the prompt stable within a day. */
13
+ /** Kept back after an optional pass so the draft can still be delivered. */
14
+ export declare const OPTIONAL_PASS_DELIVERY_MARGIN_MS = 20000;
15
+ export declare const todayNotice: (now?: Date) => string;
16
+ export { PREFLIGHT_RECOVERY_WAITS_MS, outageWaitsMs, outageWaitMs, MODEL_OUTAGE_WAIT_MS };
13
17
  import { ToolRegistry } from "../tools/ToolRegistry.js";
14
18
  import { type ToolDefinition } from "../tools/ToolTypes.js";
15
19
  import { MediaJobStore } from "../connectors/media/MediaJobStore.js";
@@ -122,6 +126,9 @@ export declare class SessionController {
122
126
  toolCalls: number;
123
127
  };
124
128
  private inspectionTiming;
129
+ /** Time left for an optional model pass after a draft exists: until the host
130
+ * deadline or the turn timeout, less a margin to deliver the answer. */
131
+ private optionalPassWindowMs;
125
132
  private beginBudget;
126
133
  private sequence;
127
134
  private messages;
@@ -259,5 +266,4 @@ export declare class SessionController {
259
266
  completed: boolean;
260
267
  }>;
261
268
  }
262
- export {};
263
269
  //# sourceMappingURL=SessionController.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SessionController.d.ts","sourceRoot":"","sources":["../../src/runtime/SessionController.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4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,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ3F,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;YAEf,MAAM;IAQpB,OAAO,CAAC,kBAAkB;IAgB1B;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,eAAe;YAIT,kBAAkB;IAkBhC,OAAO,CAAC,yBAAyB;IAcjC,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,iBAAiB;YAKX,iBAAiB;IAe/B,OAAO,CAAC,QAAQ;YA8QF,UAAU;YA8EV,SAAS;IAkIvB,OAAO,CAAC,eAAe;IAgDvB,OAAO,CAAC,UAAU;IAElB,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,SAAS;IA+EjB,OAAO,CAAC,UAAU;IAalB,OAAO,CAAC,qBAAqB;YAMf,sBAAsB;IAgEpC,OAAO,CAAC,qBAAqB;YASf,MAAM;YA4FN,iBAAiB;YAMjB,sBAAsB;YAgBtB,gBAAgB;IAiC9B,4FAA4F;IACtF,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAA;KAAE,CAAC;YAiNrG,oBAAoB;YA6BpB,2BAA2B;IAmCzC,+EAA+E;YACjE,kBAAkB;YAsdlB,kBAAkB;IA2D1B,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;CA8H7E"}
@@ -33,17 +33,15 @@ import { preparedDocdexMessage } from "./PreparedDocdex.js";
33
33
  import { budgetInspection } from "./InspectionBudget.js";
34
34
  import { InspectionConvergence } from "./InspectionConvergence.js";
35
35
  import { capacityRetryDelayMs, isCapacityRefusal, MODEL_CAPACITY_WAIT_MS } from "../providers/ModelCapacityWait.js";
36
- /** Waits between retries of a model request that failed before dispatch (about four minutes in total). */
37
- export const PREFLIGHT_RECOVERY_WAITS_MS = [500, 2000, 5000, 15000, 30000, 60000, 60000, 60000];
38
- /** The outage waits that fit the host's total (CODALI_MODEL_OUTAGE_WAIT_MS, in
39
- * milliseconds); all of them when it is unset. */
40
- export const outageWaitsMs = (budget = process.env.CODALI_MODEL_OUTAGE_WAIT_MS) => {
41
- const total = budget === undefined || budget.trim() === "" ? Infinity : Number(budget);
42
- if (!(total >= 0))
43
- return PREFLIGHT_RECOVERY_WAITS_MS;
44
- let waited = 0;
45
- return PREFLIGHT_RECOVERY_WAITS_MS.filter(wait => (waited += wait) <= total);
46
- };
36
+ import { PREFLIGHT_RECOVERY_WAITS_MS, outageWaitsMs, outageWaitMs, MODEL_OUTAGE_WAIT_MS } from "./OutageWait.js";
37
+ /** Today's date from the host clock, stated as authoritative. Without it a
38
+ * research answer dated itself from the model's own belief (2026-08-24 on
39
+ * 2026-11-13) and called the real dates in retrieved pages suspect. Day
40
+ * granularity keeps the prompt stable within a day. */
41
+ /** Kept back after an optional pass so the draft can still be delivered. */
42
+ export const OPTIONAL_PASS_DELIVERY_MARGIN_MS = 20000;
43
+ export const todayNotice = (now = new Date()) => `Today's date is ${now.toISOString().slice(0, 10)} (UTC, from the host clock). "Today", "current" and "as it applies now" mean this date; trust it over any date you assume, and use server_time when you need the exact time.`;
44
+ export { PREFLIGHT_RECOVERY_WAITS_MS, outageWaitsMs, outageWaitMs, MODEL_OUTAGE_WAIT_MS };
47
45
  import { ProgressTracker } from "./ProgressTracker.js";
48
46
  import { accountedUsage, usageAccounts } from "./UsageReconciliation.js";
49
47
  import { ToolRegistry, toolDescriptorFor } from "../tools/ToolRegistry.js";
@@ -214,6 +212,17 @@ export class SessionController {
214
212
  return { remainingMs: timeout - (Date.now() - this.budgetStartedAt),
215
213
  answerReserveMs: Math.min(timeout * 0.5, Math.max(timeout * 0.25, this.longestModelMs * 2, 60000)) };
216
214
  }
215
+ /** Time left for an optional model pass after a draft exists: until the host
216
+ * deadline or the turn timeout, less a margin to deliver the answer. */
217
+ optionalPassWindowMs() {
218
+ const ends = [];
219
+ if (this.options.deadlineAt)
220
+ ends.push(this.options.deadlineAt);
221
+ const timeout = this.limits().timeoutMs;
222
+ if (timeout)
223
+ ends.push(this.budgetStartedAt + timeout);
224
+ return ends.length ? Math.min(...ends) - Date.now() - OPTIONAL_PASS_DELIVERY_MARGIN_MS : Infinity;
225
+ }
217
226
  beginBudget() {
218
227
  this.budgetStartedAt = Date.now();
219
228
  this.longestModelMs = 0;
@@ -1455,7 +1464,7 @@ export class SessionController {
1455
1464
  // dispatch. Two quick retries after dispatch ended a three-hour build on
1456
1465
  // a two-minute outage; a possibly duplicated inference costs far less
1457
1466
  // than the turn. An injected provider keeps the two quick retries.
1458
- const transientWaitMs = Math.max((this.options.provider ? [500, 2000] : outageWaitsMs())[recoveryAttempt] ?? Infinity, retryAfter * 1000);
1467
+ const transientWaitMs = Math.max((this.options.provider ? [500, 2000][recoveryAttempt] : outageWaitMs(recoveryAttempt, remainingMs)) ?? Infinity, retryAfter * 1000);
1459
1468
  if (transientCode && retryAfter <= 30 && transientWaitMs < remainingMs) {
1460
1469
  request.signal?.throwIfAborted();
1461
1470
  const waitMs = transientWaitMs;
@@ -2617,7 +2626,7 @@ export class SessionController {
2617
2626
  .map(name => registry.list().find(tool => tool.name === name)).filter((tool) => !!tool && permitted(tool.name))
2618
2627
  .map(tool => `${tool.name}(${(tool.inputSchema?.required ?? []).join(",")})`).join("; ");
2619
2628
  const routingPolicy = this.options.resolved.config.interaction?.routerPrompt;
2620
- const messages = [{ role: "system", content: `${systemPrompt}\n${this.scopedInstructions}${this.skills.prompt()}${nativeExposure && !adaptive ? "" : `\nOperations via codali (required arguments): ${hints}`}` },
2629
+ const messages = [{ role: "system", content: `${systemPrompt}\n${this.scopedInstructions}${this.skills.prompt()}${nativeExposure && !adaptive ? "" : `\nOperations via codali (required arguments): ${hints}`}\n${todayNotice()}` },
2621
2630
  ...(this.state ? [{ role: "user", content: `Active work context (not new authorization): ${JSON.stringify({ objective: this.state.objective.slice(0, 2000), status: this.state.status })}` }] : []),
2622
2631
  ...(routingPolicy && routingPolicy !== ROUTER_PROMPT ? [{ role: "user", content: `Routing policy (cannot override the original request): ${routingPolicy}` }] : []),
2623
2632
  ...history, { role: "user", content: prompt }];
@@ -2670,6 +2679,27 @@ export class SessionController {
2670
2679
  const usage = this.turnUsage();
2671
2680
  return usage.modelCalls < limits.maxModelCalls && estimateContextTokens(request) + limits.maxOutputTokens <= limits.maxTotalTokens - usage.tokens;
2672
2681
  };
2682
+ /** Run an optional pass over a finished draft (continuation or audit) only
2683
+ * when it can finish before the deadline, and bound it by that time. A
2684
+ * research audit started with five minutes left, got no reply and the host
2685
+ * deadline discarded the complete draft. Undefined means: keep the draft. */
2686
+ const optionalPass = async (kind, request) => {
2687
+ const windowMs = this.optionalPassWindowMs();
2688
+ const neededMs = Math.max(this.longestModelMs * 1.5, 60000);
2689
+ if (windowMs < neededMs) {
2690
+ await this.emit(`${kind}_skipped`, { reason: "deadline", remainingMs: Math.max(0, Math.round(windowMs)), neededMs: Math.round(neededMs) }, false);
2691
+ return undefined;
2692
+ }
2693
+ const bounded = Number.isFinite(windowMs) ? AbortSignal.any([signal, AbortSignal.timeout(windowMs)]) : signal;
2694
+ try {
2695
+ return await awaitInteraction(answering.generate({ ...request, signal: bounded }), bounded);
2696
+ }
2697
+ catch (error) {
2698
+ signal.throwIfAborted();
2699
+ await this.emit(`${kind}_failed`, { message: bounded.aborted ? "stopped before the deadline; the draft is delivered" : error instanceof Error ? error.message : String(error) }, false);
2700
+ return undefined;
2701
+ }
2702
+ };
2673
2703
  /** Some model servers stop at their own output cap and report a normal
2674
2704
  * finish. Ask for the rest instead of delivering half an answer. */
2675
2705
  const completeCutOff = async (decision, outputTokens, outputLimited = false) => {
@@ -2684,15 +2714,9 @@ export class SessionController {
2684
2714
  break;
2685
2715
  this.inspectionAnswerReserve = 0;
2686
2716
  await this.emit("interaction_progress", { message: "The answer stopped at an output limit; writing the rest" }, false);
2687
- let next;
2688
- try {
2689
- next = await awaitInteraction(answering.generate(request), signal);
2690
- }
2691
- catch (error) {
2692
- signal.throwIfAborted();
2693
- await this.emit("answer_continuation_failed", { message: error instanceof Error ? error.message : String(error) }, false);
2717
+ const next = await optionalPass("answer_continuation", request);
2718
+ if (!next)
2694
2719
  break;
2695
- }
2696
2720
  const defect = (next.toolCalls ?? next.message.toolCalls ?? []).length ? "tool_call" : !next.message.content.trim() ? "empty" : undefined;
2697
2721
  if (defect) {
2698
2722
  await this.emit("answer_continuation_failed", { message: defect }, false);
@@ -2723,15 +2747,9 @@ export class SessionController {
2723
2747
  }
2724
2748
  this.inspectionAnswerReserve = 0;
2725
2749
  await this.emit("interaction_progress", { message: "Checking the answer for internal contradictions" }, false);
2726
- let checked;
2727
- try {
2728
- checked = await awaitInteraction(answering.generate(auditRequest), signal);
2729
- }
2730
- catch (error) {
2731
- signal.throwIfAborted();
2732
- await this.emit("consistency_answer_audit_failed", { message: error instanceof Error ? error.message : String(error), draftSha256: hash(decision.reply) }, false);
2750
+ const checked = await optionalPass("consistency_answer_audit", auditRequest);
2751
+ if (!checked)
2733
2752
  return decision;
2734
- }
2735
2753
  // The draft is already a usable answer, so a bad edit must not replace it.
2736
2754
  const content = checked.message.content;
2737
2755
  const unusable = rewriteDefect(decision.reply, checked, { minRatio: 0.6, maxRatio: 1.5 });
@@ -2761,7 +2779,9 @@ export class SessionController {
2761
2779
  if (auditBudget(auditRequest)) {
2762
2780
  this.inspectionAnswerReserve = 0;
2763
2781
  await this.emit("interaction_progress", { message: "Checking the calculation against the original inputs and units" }, false);
2764
- const checked = await awaitInteraction(answering.generate(auditRequest), signal);
2782
+ const checked = await optionalPass("calculation_answer_audit", auditRequest);
2783
+ if (!checked)
2784
+ return decision;
2765
2785
  const unusable = rewriteDefect(decision.reply, checked);
2766
2786
  if (unusable) {
2767
2787
  await this.emit("calculation_answer_audit_rejected", { reason: unusable, draftSha256: hash(decision.reply), draftChars: decision.reply.length, answerChars: checked.message.content.length }, false);
@@ -2786,7 +2806,9 @@ export class SessionController {
2786
2806
  await this.emit("research_answer_audit_skipped", { reason: "remaining_shared_budget", sourcePackets: researchEvidence.length }, false);
2787
2807
  return citationCheck(decision);
2788
2808
  }
2789
- const audited = await awaitInteraction(answering.generate(auditRequest), signal);
2809
+ const audited = await optionalPass("research_answer_audit", auditRequest);
2810
+ if (!audited)
2811
+ return citationCheck(decision);
2790
2812
  const unusable = rewriteDefect(decision.reply, audited);
2791
2813
  if (unusable) {
2792
2814
  await this.emit("research_answer_audit_rejected", { reason: unusable, draftSha256: hash(decision.reply), draftChars: decision.reply.length, answerChars: audited.message.content.length }, false);
@@ -2822,6 +2844,11 @@ export class SessionController {
2822
2844
  // closed after one search, with 26 of 30 minutes unused.
2823
2845
  if (exposed.has("docdex_web_research") && permitted("browser_open") && registry.list().some(tool => tool.name === "browser_open"))
2824
2846
  exposed.add("browser_open");
2847
+ // The reverse holds too: a turn that opens web pages needs search to find
2848
+ // them. Without it two research answers guessed URLs and opened search-engine
2849
+ // pages (captchas, 403s) for 25 minutes and delivered mostly "unverified".
2850
+ if (exposed.has("browser_open") && permitted("docdex_web_research") && registry.list().some(tool => tool.name === "docdex_web_research"))
2851
+ exposed.add("docdex_web_research");
2825
2852
  if (exposed.has("browser_open") && registry.list().some(tool => tool.name === "browser_read"))
2826
2853
  exposed.add("browser_read");
2827
2854
  if (this.contextArchive.size && registry.list().some(tool => tool.name === "context_read"))
@@ -1 +1 @@
1
- {"version":3,"file":"CalculatorTool.d.ts","sourceRoot":"","sources":["../../../src/tools/calculation/CalculatorTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA8C1E,yGAAyG;AACzG,eAAO,MAAM,mBAAmB,GAAI,YAAY,MAAM,KAAG,MA0DxD,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAAO,cA0BtC,CAAC"}
1
+ {"version":3,"file":"CalculatorTool.d.ts","sourceRoot":"","sources":["../../../src/tools/calculation/CalculatorTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAsE1E,yGAAyG;AACzG,eAAO,MAAM,mBAAmB,GAAI,YAAY,MAAM,KAAG,MA0DxD,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAAO,cA0BtC,CAAC"}
@@ -28,6 +28,29 @@ const tokenize = (expression) => {
28
28
  }
29
29
  return tokens;
30
30
  };
31
+ const countArgs = (n, k) => {
32
+ if (!Number.isInteger(n) || !Number.isInteger(k) || n < 0 || k < 0)
33
+ throw new Error("Counting functions take non-negative integers");
34
+ };
35
+ /** n choose k, exact while the result is a safe integer (each partial product is). */
36
+ const combinations = (n, k) => {
37
+ countArgs(n, k);
38
+ if (k > n)
39
+ return 0;
40
+ let result = 1;
41
+ for (let i = 1; i <= Math.min(k, n - k); i++)
42
+ result = finite(result * (n - Math.min(k, n - k) + i) / i);
43
+ return Math.round(result);
44
+ };
45
+ const permutations = (n, k) => {
46
+ countArgs(n, k);
47
+ if (k > n)
48
+ return 0;
49
+ let result = 1;
50
+ for (let i = 0; i < k; i++)
51
+ result = finite(result * (n - i));
52
+ return result;
53
+ };
31
54
  const functions = new Map([
32
55
  ["abs", { min: 1, max: 1, run: Math.abs }],
33
56
  ["sqrt", { min: 1, max: 1, run: Math.sqrt }],
@@ -45,6 +68,11 @@ const functions = new Map([
45
68
  ["min", { min: 1, max: 128, run: Math.min }],
46
69
  ["max", { min: 1, max: 128, run: Math.max }],
47
70
  ["sum", { min: 1, max: 128, run: (...args) => args.reduce((total, value) => finite(total + value), 0) }],
71
+ // Counting functions: hypergeometric and sampling questions need them, and a
72
+ // rejected C(40,8) made the model type binomial coefficients from memory.
73
+ ...["comb", "choose", "nCr", "C"].map(name => [name, { min: 2, max: 2, run: combinations }]),
74
+ ...["perm", "nPr", "P"].map(name => [name, { min: 2, max: 2, run: permutations }]),
75
+ ["factorial", { min: 1, max: 1, run: (n) => permutations(n, n) }],
48
76
  ]);
49
77
  /** Bounded Pratt parser; exponentiation is right associative and binds more tightly than unary minus. */
50
78
  export const evaluateCalculation = (expression) => {
@@ -132,7 +160,7 @@ export const evaluateCalculation = (expression) => {
132
160
  };
133
161
  export const createCalculatorTool = () => ({
134
162
  name: "calculate", capability: "calculation", readOnly: true,
135
- description: "Calculate {expression:'formula'} OR {expressions:{label:'formula'}} (up to16). Supports exp,ln/log(natural),log10,pow,sin/cos/tan(radians),abs,sqrt,floor,ceil,round,min,max,sum; + - * / %, ^ **, pi,e. Math.function aliases accepted only for this allowlist. No variables, assignments or code. IEEE-754 approximate; exact decimals use decimal_calculate. Tool success checks arithmetic, not whether your formula models the request.",
163
+ description: "Calculate {expression:'formula'} OR {expressions:{label:'formula'}} (up to16). Supports exp,ln/log(natural),log10,pow,sin/cos/tan(radians),abs,sqrt,floor,ceil,round,min,max,sum,comb/C(n,k),perm/P(n,k),factorial; + - * / %, ^ **, pi,e. Math.function aliases accepted only for this allowlist. No variables, assignments or code. IEEE-754 approximate; exact decimals use decimal_calculate. Tool success checks arithmetic, not whether your formula models the request.",
136
164
  inputSchema: { type: "object", properties: { expression: { type: "string", description: "One numeric formula, e.g. exp(-2)*3. Supply this OR expressions.", minLength: 1, maxLength: 4096 },
137
165
  expressions: { type: "object", description: "Map labels to complete formula STRINGS, e.g. {total:'2*3+4',check:'10'}. Each formula is independent; labels are not variables. Supply this OR expression.", minProperties: 1, maxProperties: 16, propertyNames: { pattern: "^[A-Za-z][A-Za-z0-9_]{0,63}$" }, additionalProperties: true },
138
166
  }, oneOf: [{ required: ["expression"] }, { required: ["expressions"] }], additionalProperties: false },
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  "url": "https://github.com/bekirdag/mcoda/issues"
10
10
  },
11
11
  "dependencies": {
12
- "@mcoda/db": "0.1.135-codali.37",
13
- "@mcoda/shared": "0.1.135-codali.37",
12
+ "@mcoda/db": "0.1.135-codali.38",
13
+ "@mcoda/shared": "0.1.135-codali.38",
14
14
  "@modelcontextprotocol/sdk": "1.30.0",
15
15
  "ajv": "8.20.0",
16
16
  "browser-use": "0.9.0",
@@ -18,6 +18,7 @@
18
18
  "mathjs": "15.2.0",
19
19
  "playwright-core": "1.64.1",
20
20
  "string-width": "8.3.0",
21
+ "undici": "6.28.0",
21
22
  "vitest": "3.2.7",
22
23
  "yaml": "2.9.0",
23
24
  "zod": "4.5.2"
@@ -57,5 +58,5 @@
57
58
  },
58
59
  "type": "module",
59
60
  "types": "dist/index.d.ts",
60
- "version": "0.1.135-codali.37"
61
+ "version": "0.1.135-codali.38"
61
62
  }