@mcoda/codali 0.1.135-codali.40 → 0.1.135-codali.42

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.
Files changed (82) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/README.md +8 -0
  3. package/config/skills/testing-and-verification/SKILL.md +5 -5
  4. package/config/skills/webapp-testing/SKILL.md +13 -0
  5. package/config/skills/webapp-testing/journey-driver.mjs +85 -0
  6. package/dist/cli/TerminalCommand.js +2 -2
  7. package/dist/cli/tui/TerminalPresentation.js +1 -1
  8. package/dist/config/OrchestrationConfig.d.ts +1 -0
  9. package/dist/config/OrchestrationConfig.d.ts.map +1 -1
  10. package/dist/config/OrchestrationConfig.js +8 -3
  11. package/dist/docdex/DocdexClient.d.ts +11 -0
  12. package/dist/docdex/DocdexClient.d.ts.map +1 -1
  13. package/dist/docdex/DocdexClient.js +55 -1
  14. package/dist/permissions/PermissionGate.d.ts +7 -0
  15. package/dist/permissions/PermissionGate.d.ts.map +1 -1
  16. package/dist/permissions/PermissionGate.js +26 -0
  17. package/dist/providers/ConfiguredProvider.d.ts +2 -0
  18. package/dist/providers/ConfiguredProvider.d.ts.map +1 -1
  19. package/dist/providers/ConfiguredProvider.js +29 -0
  20. package/dist/providers/ModelServiceError.d.ts +2 -2
  21. package/dist/providers/ModelServiceError.d.ts.map +1 -1
  22. package/dist/providers/ModelServiceError.js +4 -0
  23. package/dist/runtime/AnswerVerification.d.ts +14 -0
  24. package/dist/runtime/AnswerVerification.d.ts.map +1 -1
  25. package/dist/runtime/AnswerVerification.js +26 -0
  26. package/dist/runtime/ContextCompression.d.ts +5 -0
  27. package/dist/runtime/ContextCompression.d.ts.map +1 -1
  28. package/dist/runtime/ContextCompression.js +16 -4
  29. package/dist/runtime/FigureCheck.d.ts +20 -0
  30. package/dist/runtime/FigureCheck.d.ts.map +1 -0
  31. package/dist/runtime/FigureCheck.js +44 -0
  32. package/dist/runtime/InteractionContract.d.ts +22 -0
  33. package/dist/runtime/InteractionContract.d.ts.map +1 -1
  34. package/dist/runtime/InteractionContract.js +41 -0
  35. package/dist/runtime/InteractionRouter.d.ts +3 -3
  36. package/dist/runtime/InteractionRouter.d.ts.map +1 -1
  37. package/dist/runtime/InteractionRouter.js +1 -1
  38. package/dist/runtime/OutageWait.d.ts +33 -5
  39. package/dist/runtime/OutageWait.d.ts.map +1 -1
  40. package/dist/runtime/OutageWait.js +68 -8
  41. package/dist/runtime/ResearchEvidence.d.ts +21 -1
  42. package/dist/runtime/ResearchEvidence.d.ts.map +1 -1
  43. package/dist/runtime/ResearchEvidence.js +109 -3
  44. package/dist/runtime/ReviewCoordinator.d.ts.map +1 -1
  45. package/dist/runtime/ReviewCoordinator.js +2 -1
  46. package/dist/runtime/ReviewSource.d.ts +5 -0
  47. package/dist/runtime/ReviewSource.d.ts.map +1 -1
  48. package/dist/runtime/ReviewSource.js +6 -1
  49. package/dist/runtime/SessionController.d.ts +71 -1
  50. package/dist/runtime/SessionController.d.ts.map +1 -1
  51. package/dist/runtime/SessionController.js +553 -39
  52. package/dist/runtime/TaskReview.d.ts.map +1 -1
  53. package/dist/runtime/TaskReview.js +17 -2
  54. package/dist/runtime/VerificationCommand.d.ts +8 -0
  55. package/dist/runtime/VerificationCommand.d.ts.map +1 -1
  56. package/dist/runtime/VerificationCommand.js +114 -0
  57. package/dist/runtime/WorkingStyle.d.ts +20 -0
  58. package/dist/runtime/WorkingStyle.d.ts.map +1 -0
  59. package/dist/runtime/WorkingStyle.js +71 -0
  60. package/dist/tools/ToolRegistry.d.ts.map +1 -1
  61. package/dist/tools/ToolRegistry.js +19 -2
  62. package/dist/tools/ToolTypes.d.ts +3 -0
  63. package/dist/tools/ToolTypes.d.ts.map +1 -1
  64. package/dist/tools/browser/BrowserTool.d.ts +23 -1
  65. package/dist/tools/browser/BrowserTool.d.ts.map +1 -1
  66. package/dist/tools/browser/BrowserTool.js +83 -4
  67. package/dist/tools/browser/HttpFallback.d.ts +39 -0
  68. package/dist/tools/browser/HttpFallback.d.ts.map +1 -0
  69. package/dist/tools/browser/HttpFallback.js +240 -0
  70. package/dist/tools/calculation/CalculatorTool.d.ts +16 -1
  71. package/dist/tools/calculation/CalculatorTool.d.ts.map +1 -1
  72. package/dist/tools/calculation/CalculatorTool.js +147 -20
  73. package/dist/tools/shell/AsyncProcess.d.ts.map +1 -1
  74. package/dist/tools/shell/AsyncProcess.js +6 -0
  75. package/dist/tools/shell/IsolatedExecutor.d.ts.map +1 -1
  76. package/dist/tools/shell/IsolatedExecutor.js +10 -2
  77. package/dist/tools/shell/ShellTool.d.ts +2 -0
  78. package/dist/tools/shell/ShellTool.d.ts.map +1 -1
  79. package/dist/tools/shell/ShellTool.js +32 -2
  80. package/dist/tools/verification/VitestTool.d.ts.map +1 -1
  81. package/dist/tools/verification/VitestTool.js +75 -5
  82. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,115 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ ## 0.1.135-codali.42
6
+
7
+ - Interrupted research can resume from saved source passages and its draft
8
+ with `/continue` or `codali resume`. Pending operations that may have
9
+ changed workspace files still require reconciliation.
10
+ - A model outage can be retried for up to six hours, subject to the remaining
11
+ turn time. Set `CODALI_MODEL_OUTAGE_WAIT_MS` to change the allowance.
12
+ Retry delays respect the server's requested wait and leave time to deliver
13
+ saved work. Optional working-style lookups return promptly when Docdex is offline.
14
+
15
+ - Model requests: every request now has a time allowance (ten minutes, or four
16
+ times the slowest answered request, bounded by what the request could need,
17
+ and doubled each time the same request stalls). A request that does not
18
+ return is abandoned and retried on the outage path. A 12-hour build had
19
+ finished its work and then waited 158 minutes on one review request.
20
+ - Research never ends with nothing: a research turn writes one full draft
21
+ after 55% of its time. The points that draft leaves open ("could not be
22
+ verified", "no official source was found") steer the remaining research, and
23
+ the draft is what is delivered if the final answer cannot be written in
24
+ time or the model service is down. A final draft that still admits open
25
+ points is sent back to research while at least four minutes remain. When no
26
+ draft exists, the pages read are listed with one excerpt of at most 25 words
27
+ each, marked as evidence and not an answer. Sign-in, quota and request
28
+ errors are reported as before.
29
+ - Web sources: `browser_open` reads PDF documents as text (downloaded with one
30
+ plain GET, extracted offline in the sandbox, up to 96 MB). A page whose site
31
+ refuses the automated browser (HTTP/2 or connection errors, timeouts,
32
+ downloads) is read with one plain GET and its static HTML converted to
33
+ text; the result says so. Name-resolution and certificate errors are not
34
+ worked around.
35
+ - Context: the working context uses more of the model's window (output reserve
36
+ 15%, at least 16k tokens, at most 30%) and is trimmed in steps (from 90% of
37
+ the input room down to 60%) instead of on almost every request.
38
+ - Calculations: `calculate` accepts named steps (`a = 2*3; b = a+4; b/2`), up
39
+ to 64 statements or named formulas, later formulas that use earlier labels,
40
+ inverse and hyperbolic functions, log2, cbrt, hypot, trunc and sign, and
41
+ integers beyond 2^53 as rounded values with a warning. A name that replaces
42
+ `e` or `pi` produces a warning. It remains a numeric grammar: no code runs.
43
+ - Calculations: the equation review of a short quantitative answer can no
44
+ longer replace most of an answer that was worked out with calculation
45
+ tools: a review that adds nulls, or changes two or more values and over half
46
+ of them, is rejected. A single corrected value is still accepted.
47
+ - Tests: `verify_tests` with the python runner runs pytest-style tests (plain
48
+ `test_` functions and `Test` classes, `pytest.raises`, `pytest.approx`,
49
+ `pytest.mark.parametrize`) on the standard library. Fixtures, async tests
50
+ and generator tests fail with a message that names them.
51
+ - Shell: `run_shell` takes `timeoutSeconds` (default 120, up to 900) for a full
52
+ test suite, a build or a browser journey. A host can set a default
53
+ (`shellTimeoutMs`) and a separate maximum (`shellMaxTimeoutMs`).
54
+ - Sandbox: the availability probe is retried with more time when it only ran
55
+ out of time on a busy host, instead of reporting that user namespaces are
56
+ unavailable.
57
+ - Completion check: review pages are 24,000 characters (were 8,000); a page
58
+ requested again beside a new one is skipped instead of ending the review. A
59
+ test run inside `bash -c` counts as validation when its steps are joined
60
+ only by `&&` and nothing is expanded (`cd app && npm test 2>&1 | tail -40`);
61
+ lines that can hide the exit status are refused.
62
+ - Tool calls: a lookup sent in the same batch as `start_work` or
63
+ `final_answer` now runs; only the transition waits and is told to come alone.
64
+ - Answers: when the request explicitly asks for exactly one fenced code block
65
+ and no prose, text around the single block is dropped and the block is kept
66
+ unchanged. The runtime's own failed-test note is placed inside the block as
67
+ a comment in its language.
68
+ - Web apps: the `webapp-testing` skill ships `journey-driver.mjs`, a
69
+ dependency-free headless-Chrome driver (launch on a free port, goto, click,
70
+ type, waits that report what the page shows, screenshot, startServer), with
71
+ a recipe for running server, browser and steps in one shell call.
72
+ - Model routes: a route that served this process and then drops out of the
73
+ catalog (for example while a node restarts) is now a temporary outage that
74
+ the session waits out, instead of a final "no eligible route" error.
75
+ - Working style: Codali follows the user's working style (how they ask for
76
+ work to be done, communicate and judge quality) from the local Docdex
77
+ personal-preferences store through `docdex_working_style`. It is loaded once
78
+ per session, ranks below the request, workspace instructions and repository
79
+ facts, and never widens permissions. Codali keeps only short style lines in
80
+ style categories at the lowest sensitivity, and drops personal context,
81
+ contact details, secret-like values and links even if Docdex returns them.
82
+ It is on by default and adds nothing when Docdex or the tool is unavailable.
83
+ Turn it off with `docdex.workingStyle: false`, `CODALI_WORKING_STYLE=0` or
84
+ the `workingStyle: false` session option. Benchmark sessions always turn it
85
+ off.
86
+
87
+ ## 0.1.135-codali.41
88
+
89
+ - Output: a request that explicitly asks for only JSON ("return only JSON",
90
+ "respond with JSON only") now always gets bare JSON; a ```json fence around
91
+ the answer is removed even when the extracted output contract said text.
92
+ - Research: the final evidence audit is shown the source passages behind each
93
+ quote and specific figure in the draft first (budget 48,000 characters, up
94
+ from 24,000), so verbatim, sourced claims are no longer relabelled as
95
+ unverified because their passage was left out.
96
+ - Long answers: high and max effort allow 65,536 output tokens (was 8,192), so
97
+ the consistency audit of a long design is no longer cut off and discarded.
98
+ - Long answers: derived figures in a long answer are listed as arithmetic
99
+ expressions and evaluated by the calculator; the consistency audit gets the
100
+ mismatches to correct, instead of rereading its own arithmetic.
101
+ - App builds: browser journeys must check the server state after each action
102
+ (including logout), treat unexpected 4xx/5xx responses and console errors as
103
+ failures, check that table rows match their headers and that every role
104
+ action has a control; delivery notes may claim only checks that passed.
105
+ - Code answers: when the final code differs from the code of the session's
106
+ last verify_tests run, the runtime runs the final code against that run's
107
+ tests itself; if they fail, the model gets one repair round with the
108
+ failures, or, without time for one, the answer states that the tests failed.
109
+ - Deadlines: the final answer call is bounded to half of the remaining window
110
+ when a retry fits, so one stalled request no longer loses a finished
111
+ investigation at the deadline.
112
+
3
113
  ## 0.1.135-codali.40
4
114
 
5
115
  - Routing: a session that can neither write to the workspace nor run commands
package/README.md CHANGED
@@ -86,6 +86,14 @@ inference usage is separate from Codali model totals. Legacy `binary`,
86
86
  `binarySha256` and `startupTimeoutMs` settings are accepted but do not launch a
87
87
  process. If the shared service is unavailable, Codali continues with local tools.
88
88
 
89
+ Codali follows your working style, meaning how you ask for work to be done,
90
+ communicate and judge quality. It reads this from Docdex's personal-preferences
91
+ store (`docdex_working_style`) once per session. It ranks below your request,
92
+ workspace instructions and repository facts. Only short style lines at the
93
+ lowest sensitivity are used; personal context, contact details, secret-like
94
+ values and links are dropped. Turn it off with `"docdex": { "workingStyle": false }`
95
+ or `CODALI_WORKING_STYLE=0`.
96
+
89
97
  | Command | Purpose |
90
98
  | --- | --- |
91
99
  | `/status`, `/usage` | Current execution state, reconciled accounting and server limits |
@@ -3,14 +3,14 @@ name: testing-and-verification
3
3
  description: "Verify software with real unit, integration, contract and UI checks."
4
4
  ---
5
5
 
6
- Inspect requirements, exports, tests, scripts and runtime before writing tests; never invent API names. Derive expected results independently from requirements, not from implementation. Cover boundaries, empties, ties/order, duplicates, cancellation/rejections, units and rounding. For stateful rules, test invalid-to-valid sequences; a rejected step must not corrupt later valid behavior unless specified. Resolve contradictory model-written expectations from the original requirement.
6
+ Inspect requirements, exports, tests, scripts and runtime before writing tests; never invent API names. Derive expected results independently from requirements, not from implementation. Cover boundaries, empties, ties/order, duplicates, cancellation, units and rounding. For stateful rules, test invalid-to-valid sequences; a rejected step must not corrupt later valid behavior unless specified. Resolve contradictory model-written expectations from the original requirement.
7
7
 
8
- Reproduce bugs with isolated fixtures and the repository runner. Missing dependencies are not reproductions. Discover tool schemas. Node --test uses default discovery or explicit test files; a directory argument is not portable test discovery. For supplied Python answers, verify_tests runner python supports standard-library unittest.TestCase, not pytest.
8
+ Reproduce bugs with isolated fixtures and the repository runner. Missing dependencies are not reproductions. Node --test uses default discovery or explicit test files; a directory argument is not portable test discovery. verify_tests python runs unittest and plain test_* functions with pytest.raises/approx/parametrize, no fixtures.
9
9
 
10
- For apps, exercise the actual setup, build, entrypoint and a real user journey, not just helper tests. Verify persisted seed state, restart persistence, authorization, invalid input, duplicate requests, rollback and concurrency. Before a negative authorization test, prove authentication, fixture existence and a permitted operation succeed. A missing route returning 404 proves nothing about tenant isolation. Zero tests, syntax-only checks, no-op scripts and placeholder UI do not prove domain functionality.
10
+ For apps, exercise the actual setup, build, entrypoint and a real user journey, not just helper tests. Verify persisted seed state, restart persistence, authorization, invalid input, duplicate requests, rollback and concurrency. Before a negative authorization test, prove authentication, fixture existence and a permitted operation succeed. A missing route returning 404 proves nothing about tenant isolation. Zero tests, syntax-only checks, no-op scripts and placeholder UI prove nothing.
11
11
 
12
- Use webapp-testing for rendered interaction: loading/error/empty states, keyboard operation and responsive layout. Temporary servers and checks can share one shell call; persistent previews need managed services. Sandbox writes must fit claimed paths.
12
+ Use webapp-testing for rendered interaction: loading/error/empty states, keyboard operation, layout. For a browser journey load webapp-testing first: it ships a tested Chrome driver; write only the steps. Temporary servers and checks share one shell call (set timeoutSeconds); previews need managed services. Sandbox writes must fit claimed paths.
13
13
 
14
- Record commands, environment, exit status and output. Distinguish passed, failed, skipped and untested. Diagnose before rerunning; never loop unchanged checks or weaken requirements. Expand checks only for unresolved impact/risk. Attach actual receipts to work_verify. Provide reproducible start/test instructions and disclose infrastructure or platform blockers. Model-authored passing tests are limited evidence, not independent proof of completion.
14
+ Record commands, exit status and output. Separate passed, failed, skipped, untested. Diagnose before rerunning; never loop unchanged checks or weaken requirements. Expand checks only for unresolved impact/risk. Attach actual receipts to work_verify. Give reproducible start/test instructions; disclose platform blockers. Model-authored passing tests are limited evidence, not independent proof of completion.
15
15
 
16
16
  Source: https://raw.githubusercontent.com/obra/superpowers/main/skills/test-driven-development/SKILL.md. Adaptation without blanket approval or test-first mandates.
@@ -7,6 +7,19 @@ Read the application entry point and package scripts before choosing a launch me
7
7
 
8
8
  For a backend, use its existing managed service or an authorized host service workflow. A temporary run_shell server can support checks within that single call, but cannot provide a persistent demo URL.
9
9
 
10
+ Browser journey of an app with a backend: do not write a browser driver. Read this skill's journey-driver.mjs with skill_read (path journey-driver.mjs, follow nextOffset to the end) and save it unchanged in the project's test folder. It needs Node 22 and an installed Chrome or Chromium, and no packages. Then write one short script that does everything in a single run_shell call, because processes do not survive the call:
11
+
12
+ import { launch, startServer } from './journey-driver.mjs';
13
+ const server = await startServer('node', ['server/index.js'], { url: 'http://127.0.0.1:3000/health', env: { PORT: '3000' } });
14
+ const page = await launch();
15
+ try {
16
+ await page.goto('http://127.0.0.1:3000/');
17
+ await page.type('#email', 'admin@example.test'); await page.type('#password', 'correct horse');
18
+ await page.click('button[type=submit]'); await page.waitForText('Dashboard');
19
+ } finally { await page.close(); server.kill(); }
20
+
21
+ The page object has goto, click, type, text, waitForSelector, waitForText, waitFor (any expression), evaluate and screenshot. A wait that fails reports what the page shows instead. Print PASS or FAIL per scenario and exit non-zero on a failure. Run it with run_shell and timeoutSeconds sized to the journey (for example 300). Use data-testid or id selectors you put in the markup yourself.
22
+
10
23
  Inspect rendered page state before selecting controls. Exercise the requested user journey, verify visible outcomes, and run the project's real tests separately. A successful HTTP fetch does not prove interactivity. Record the tested URL and observed results; identify untested behavior.
11
24
 
12
25
  Source: https://github.com/anthropics/skills/blob/main/skills/webapp-testing/SKILL.md. Original Codali adaptation of its inspect-before-action workflow; no upstream scripts bundled.
@@ -0,0 +1,85 @@
1
+ // journey-driver.mjs: drive headless Chrome over its debugging protocol.
2
+ // No dependencies; Node 22 or newer. Copy it into the project's test folder.
3
+ import { spawn } from 'node:child_process';
4
+ import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
5
+ import { tmpdir } from 'node:os';
6
+ import { join } from 'node:path';
7
+
8
+ export const sleep = ms => new Promise(r => setTimeout(r, ms));
9
+
10
+ /** Start the app and wait until `url` answers. Kill the returned process when done. */
11
+ export async function startServer(command, args, { url, env = {}, ms = 20000 } = {}) {
12
+ const proc = spawn(command, args, { stdio: 'inherit', env: { ...process.env, ...env } });
13
+ for (const end = Date.now() + ms; ;) {
14
+ try { await fetch(url); return proc; } catch {}
15
+ if (proc.exitCode !== null) throw new Error('Server exited before it answered');
16
+ if (Date.now() > end) { proc.kill(); throw new Error(`Server not reachable at ${url}`); }
17
+ await sleep(100);
18
+ }
19
+ }
20
+
21
+ /** Launch Chrome and return page controls. Every wait fails with a clear message. */
22
+ export async function launch({ chrome = process.env.CHROME_BIN } = {}) {
23
+ const dir = mkdtempSync(join(process.env.TMPDIR || tmpdir(), 'journey-'));
24
+ // Port 0: Chrome picks a free port and writes it to DevToolsActivePort, so
25
+ // two journeys on one machine never attach to each other's browser.
26
+ const flags = ['--headless=new', '--no-sandbox', '--disable-gpu', '--no-first-run',
27
+ '--remote-debugging-port=0', `--user-data-dir=${dir}`, 'about:blank'];
28
+ let proc;
29
+ for (const bin of [chrome, 'google-chrome', 'chromium', 'chromium-browser'].filter(Boolean)) {
30
+ const candidate = spawn(bin, flags, { stdio: 'ignore' });
31
+ if (await new Promise(r => { candidate.once('error', () => r(false)); setTimeout(() => r(true), 300); })) { proc = candidate; break; }
32
+ }
33
+ if (!proc) throw new Error('No Chrome or Chromium executable found');
34
+ let target;
35
+ for (let i = 0; i < 150 && !target; i++) {
36
+ try {
37
+ const port = Number(readFileSync(join(dir, 'DevToolsActivePort'), 'utf8').split('\n')[0]);
38
+ target = (await (await fetch(`http://127.0.0.1:${port}/json`)).json()).find(t => t.type === 'page');
39
+ } catch {}
40
+ if (!target) await sleep(100);
41
+ }
42
+ if (!target) { proc.kill(); throw new Error('Chrome did not open its debugging port'); }
43
+ const ws = new WebSocket(target.webSocketDebuggerUrl);
44
+ await new Promise((res, rej) => { ws.onopen = res; ws.onerror = () => rej(new Error('Debugging socket failed')); });
45
+ let id = 0;
46
+ const pending = new Map();
47
+ ws.onmessage = e => {
48
+ const m = JSON.parse(e.data), p = pending.get(m.id);
49
+ if (p) { pending.delete(m.id); m.error ? p.rej(new Error(m.error.message)) : p.res(m.result); }
50
+ };
51
+ const cdp = (method, params = {}) => new Promise((res, rej) => { pending.set(++id, { res, rej }); ws.send(JSON.stringify({ id, method, params })); });
52
+ await cdp('Page.enable'); await cdp('Runtime.enable');
53
+ const evaluate = async expression => {
54
+ const r = await cdp('Runtime.evaluate', { expression, awaitPromise: true, returnByValue: true });
55
+ if (r.exceptionDetails) throw new Error(r.exceptionDetails.exception?.description || r.exceptionDetails.text);
56
+ return r.result.value;
57
+ };
58
+ const waitFor = async (expression, what = expression, ms = 5000) => {
59
+ for (const end = Date.now() + ms; ;) {
60
+ const value = await evaluate(expression).catch(() => undefined);
61
+ if (value) return value;
62
+ if (Date.now() > end) throw new Error(`Timed out waiting for ${what}; page shows: ${String(await evaluate('document.body?.innerText ?? ""').catch(() => '')).slice(0, 300)}`);
63
+ await sleep(50);
64
+ }
65
+ };
66
+ const q = s => `document.querySelector(${JSON.stringify(s)})`;
67
+ return {
68
+ cdp, evaluate, waitFor,
69
+ goto: async url => { await cdp('Page.navigate', { url }); await waitFor('document.readyState === "complete"', `load of ${url}`, 10000); },
70
+ waitForSelector: (s, ms) => waitFor(`!!${q(s)}`, `selector ${s}`, ms),
71
+ waitForText: (t, ms) => waitFor(`!!document.body && document.body.innerText.includes(${JSON.stringify(t)})`, `text "${t}"`, ms),
72
+ click: async s => { await waitFor(`!!${q(s)}`, `selector ${s}`); await evaluate(`${q(s)}.click()`); },
73
+ // Sets the value the way a framework expects, then fires input and change.
74
+ type: async (s, text) => {
75
+ await waitFor(`!!${q(s)}`, `selector ${s}`);
76
+ await evaluate(`(() => { const e = ${q(s)}; e.focus();
77
+ const set = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e), 'value')?.set;
78
+ set ? set.call(e, ${JSON.stringify(text)}) : (e.value = ${JSON.stringify(text)});
79
+ e.dispatchEvent(new Event('input', { bubbles: true })); e.dispatchEvent(new Event('change', { bubbles: true })); })()`);
80
+ },
81
+ text: (s = 'body') => evaluate(`${q(s)}?.innerText ?? ''`),
82
+ screenshot: async () => Buffer.from((await cdp('Page.captureScreenshot', { format: 'png' })).data, 'base64'),
83
+ close: async () => { try { ws.close(); } catch {} proc.kill(); await sleep(150); rmSync(dir, { recursive: true, force: true }); },
84
+ };
85
+ }
@@ -389,7 +389,7 @@ export class TerminalCommand {
389
389
  await controller.clearSession();
390
390
  if (closed || epoch !== cancelEpoch)
391
391
  throw new Error("Cancelled by user before execution");
392
- const result = prompt ? await controller.interact(prompt) : await controller.run();
392
+ const result = prompt ? await controller.interact(prompt) : controller.unfinishedInteraction && !(controller.state && controller.state.status !== "completed") ? await controller.continueInteraction() : await controller.run();
393
393
  if (tui)
394
394
  tui.result(redactSecretValues(result.content));
395
395
  else if (!args.json)
@@ -777,7 +777,7 @@ export class TerminalCommand {
777
777
  else if (args.command === "amend")
778
778
  await controller.steer(rest.join(" "));
779
779
  else if (args.command === "resume" && !interactive) {
780
- if (controller.state?.status === "completed")
780
+ if (controller.state?.status === "completed" && !controller.unfinishedInteraction)
781
781
  output(controller.status());
782
782
  else {
783
783
  run();
@@ -112,7 +112,7 @@ export const toolCompletionSummary = (name, args, output) => {
112
112
  };
113
113
  export const terminalHelp = () => [
114
114
  "GET STARTED", " Just type a message. Ask a question, inspect your project, or request a change.", "",
115
- "CONVERSATION", " /new Start fresh; keep the saved session", " /sessions Browse saved conversations", " /resume ID Pick up a saved session", " /continue Resume the active work", " /stop Stop safely and keep progress", " /quit Close Codali", "",
115
+ "CONVERSATION", " /new Start fresh; keep the saved session", " /sessions Browse saved conversations", " /resume ID Pick up a saved session", " /continue Resume the active work or an unfinished answer", " /stop Stop safely and keep progress", " /quit Close Codali", "",
116
116
  "WORK & REVIEW", " /status Current workspace and progress", " /goal · /plan · /tasks · /decisions", " /diff Inspect workspace changes", " /review Review the current work", " /artifacts Browse, open or export generated files", "",
117
117
  "MODELS & LIMITS", " /usage Tokens, model calls and account limits", " /model · /models Inspect or select model routes", " /effort low · medium · high · max", " /permissions plan · ask · workspace · full (saved per directory)", " /config Inspect, validate or reload configuration", "",
118
118
  "CONTEXT & RECOVERY", " /context · /compact · /checkpoint · /fork", " /skills Browse available local skills", " /tools · /mcp · /docdex", " /reconcile · /reconcile-media · /retention", "",
@@ -110,6 +110,7 @@ export interface OrchestrationConfig {
110
110
  binary?: string;
111
111
  binarySha256?: string;
112
112
  startupTimeoutMs?: number;
113
+ workingStyle?: boolean;
113
114
  };
114
115
  }
115
116
  export interface ResolvedOrchestrationConfig {
@@ -1 +1 @@
1
- {"version":3,"file":"OrchestrationConfig.d.ts","sourceRoot":"","sources":["../../src/config/OrchestrationConfig.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC;AAC5D,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG,YAAY,GAAG,oBAAoB,GAAG,mBAAmB,GAAG,oBAAoB,CAAC;AACnI,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB;AACD,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC,CAK/E,CAAC;AAEH,MAAM,WA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O,MAAM,sBAAsB,GAAI,UAAU,2BAA2B,KAAG,2BAI9E,CAAC;AA4BF,eAAO,MAAM,iBAAiB,GAAI,QAAQ,mBAAmB,KAAG,MAAsF,CAAC;AAEvJ,eAAO,MAAM,2BAA2B,GAAI,OAAO,OAAO,KAAG,mBA0I5D,CAAC;AAEF,gFAAgF;AAChF,eAAO,MAAM,wBAAwB,GAAI,QAAQ,mBAAmB,EAAE,gBAAqB;;iBA1O9D,MAAM;oBAAkB,MAAM;mBAAiB,MAAM,GAAG,IAAI;aAAW,MAAM;;;;CA8PzG,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,QAAQ,mBAAmB,EAAE,MAAM,MAAM,EAAE,YAAY,cAAc,KAAG,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,CAerJ,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAU,aAAuG,KAAG,OAAO,CAAC,2BAA2B,CAI1L,CAAC;AACF,eAAO,MAAM,YAAY,GAAI,QAAQ,mBAAmB,EAAE,OAAO,WAAW,KAAG,YAAyE,CAAC"}
@@ -5,8 +5,11 @@ import path from "node:path";
5
5
  export const EFFORT_BUDGETS = Object.freeze({
6
6
  low: Object.freeze({ maxSteps: 12, maxToolCalls: 12, maxModelCalls: 12, maxTotalTokens: 32000, maxOutputTokens: 2048, timeoutMs: 300000 }),
7
7
  medium: Object.freeze({ maxSteps: 32, maxToolCalls: 48, maxModelCalls: 36, maxTotalTokens: 128000, maxOutputTokens: 4096, timeoutMs: 900000 }),
8
- high: Object.freeze({ maxSteps: 64, maxToolCalls: 128, maxModelCalls: 72, maxTotalTokens: 320000, maxOutputTokens: 8192, timeoutMs: 1800000 }),
9
- max: Object.freeze({ maxSteps: 128, maxToolCalls: 256, maxModelCalls: 144, maxTotalTokens: 640000, maxOutputTokens: 8192, timeoutMs: 3600000 }),
8
+ // Output caps here bound every routed request (a node serving gateway calls
9
+ // uses these presets); 8192 cut a 22.6k-character answer audit in cycle 5.
10
+ // Routes still clamp to their own advertised limit.
11
+ high: Object.freeze({ maxSteps: 64, maxToolCalls: 128, maxModelCalls: 72, maxTotalTokens: 320000, maxOutputTokens: 65536, timeoutMs: 1800000 }),
12
+ max: Object.freeze({ maxSteps: 128, maxToolCalls: 256, maxModelCalls: 144, maxTotalTokens: 640000, maxOutputTokens: 65536, timeoutMs: 3600000 }),
10
13
  });
11
14
  export const pinOrchestrationConfig = (resolved) => {
12
15
  const config = validateOrchestrationConfig(structuredClone(resolved.config));
@@ -240,7 +243,9 @@ export const validateOrchestrationConfig = (input) => {
240
243
  }
241
244
  if (root.docdex !== undefined) {
242
245
  const d = object(root.docdex, "docdex");
243
- fields(d, ["baseUrl", "binary", "binarySha256", "startupTimeoutMs"], "docdex");
246
+ fields(d, ["baseUrl", "binary", "binarySha256", "startupTimeoutMs", "workingStyle"], "docdex");
247
+ if (d.workingStyle !== undefined && typeof d.workingStyle !== "boolean")
248
+ throw new Error("docdex.workingStyle: expected boolean");
244
249
  if (d.baseUrl !== undefined) {
245
250
  const url = new URL(nonempty(d.baseUrl, "docdex.baseUrl"));
246
251
  if (!["http:", "https:"].includes(url.protocol))
@@ -1,6 +1,8 @@
1
1
  import type { DocdexCapabilitySnapshot } from "../cognitive/Types.js";
2
2
  import { type DocdexCatalogEntry } from "./DocdexCatalog.js";
3
3
  export interface DocdexClientOptions {
4
+ /** Waits before reconnecting to a daemon that stopped answering (default DOCDEX_RECONNECT_WAITS_MS). */
5
+ reconnectWaitsMs?: number[];
4
6
  /** Trusted host accounting hook; each retrieval HTTP attempt reserves before dispatch. */
5
7
  beforeRequest?: (url: string) => void | Promise<void>;
6
8
  signal?: () => AbortSignal | undefined;
@@ -115,6 +117,8 @@ export declare const normalizeDocdexRuntimeOperation: (value: string) => DocdexR
115
117
  * `repo.root`.
116
118
  */
117
119
  export declare const docdexRepoRootFor: (contextRepoRoot: string | undefined, repoId: string | undefined, workspaceRoot: string) => string | undefined;
120
+ /** Waits before reconnecting to a Docdex daemon that stopped answering. */
121
+ export declare const DOCDEX_RECONNECT_WAITS_MS: number[];
118
122
  export declare class DocdexClient {
119
123
  private options;
120
124
  private repoId?;
@@ -182,7 +186,12 @@ export declare class DocdexClient {
182
186
  chatContext(messages: DocdexChatMessage[], options?: DocdexChatContextOptions): Promise<unknown>;
183
187
  dagExport(sessionId: string, options?: DocdexDagOptions): Promise<unknown>;
184
188
  private ensureMcpSession;
189
+ /** Docdex restarts (an update, a crash, a host reboot) while a session runs.
190
+ * A call that finds it gone, or finds its MCP session forgotten, reconnects
191
+ * and is sent again after short waits (about 27 s in all) instead of failing
192
+ * for the rest of the turn on a health result cached before the restart. */
185
193
  callMcp<T>(method: string, params: Record<string, unknown>, timeoutMs?: number, recovered?: boolean): Promise<T>;
194
+ private callMcpOnce;
186
195
  private catalogRequest?;
187
196
  listCatalog(): Promise<DocdexCatalogEntry[]>;
188
197
  callCatalog<T>(name: string, arguments_: Record<string, unknown>): Promise<T>;
@@ -208,6 +217,8 @@ export declare class DocdexClient {
208
217
  knowledgeQuery(query: string, limit?: number): Promise<unknown>;
209
218
  tree(options?: DocdexTreeOptions): Promise<unknown>;
210
219
  openFile(pathValue: string, options?: DocdexOpenFileOptions): Promise<unknown>;
220
+ /** The user's curated working style from Docdex personal preferences (read-only profile lane). */
221
+ workingStyle(mode: "build" | "review" | "release" | "answer", repoPath?: string, maxChars?: number): Promise<unknown>;
211
222
  getProfile(agentId?: string): Promise<unknown>;
212
223
  savePreference(agentId: string, category: string, content: string, metadata?: DocdexWriteMetadata): Promise<unknown>;
213
224
  webResearch(query: string, options?: DocdexWebResearchOptions): Promise<unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"DocdexClient.d.ts","sourceRoot":"","sources":["../../src/docdex/DocdexClient.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,wBAAwB,EAEzB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAyC,KAAK,kBAAkB,EAAE,M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MAAM,EAAE,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,OAAO,CAAC;YAwBtE,eAAe;IA4C7B,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAWxE,WAAW,CACf,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,OAAO,CAAA;KAAO,GACtD,OAAO,CAAC,OAAO,CAAC;IAgCb,eAAe,CAAC,YAAY,UAAQ,GAAG,OAAO,CAAC,wBAAwB,CAAC;CAmC/E"}
@@ -85,6 +85,7 @@ const MCP_OPERATION_BY_METHOD = {
85
85
  docdex_tree: "tree",
86
86
  docdex_open: "open",
87
87
  docdex_get_profile: "profile_read",
88
+ docdex_working_style: "profile_read",
88
89
  docdex_save_preference: "profile_write",
89
90
  docdex_web_research: "web_research",
90
91
  docdex_rerank: "rerank",
@@ -156,6 +157,19 @@ const sanitizeSearchRetryQuery = (query) => {
156
157
  * `repo.root`.
157
158
  */
158
159
  export const docdexRepoRootFor = (contextRepoRoot, repoId, workspaceRoot) => contextRepoRoot ?? (repoId ? undefined : workspaceRoot);
160
+ /** Waits before reconnecting to a Docdex daemon that stopped answering. */
161
+ export const DOCDEX_RECONNECT_WAITS_MS = [1000, 3000, 8000, 15000];
162
+ const transportFailure = (error) => {
163
+ let current = error;
164
+ for (let depth = 0; current && typeof current === "object" && depth < 4; current = current.cause, depth++) {
165
+ const code = current.code;
166
+ if (typeof code === "string" && /^(?:ECONNREFUSED|ECONNRESET|EPIPE|ENOTFOUND|EAI_AGAIN|EHOSTUNREACH|ETIMEDOUT|UND_ERR_SOCKET|UND_ERR_CLOSED)$/.test(code))
167
+ return true;
168
+ if (current instanceof TypeError && /^(?:fetch failed|terminated)$/.test(current.message))
169
+ return true;
170
+ }
171
+ return false;
172
+ };
159
173
  export class DocdexClient {
160
174
  constructor(options) {
161
175
  this.options = options;
@@ -892,7 +906,42 @@ export class DocdexClient {
892
906
  this.mcpInitialize = undefined;
893
907
  }
894
908
  }
909
+ /** Docdex restarts (an update, a crash, a host reboot) while a session runs.
910
+ * A call that finds it gone, or finds its MCP session forgotten, reconnects
911
+ * and is sent again after short waits (about 27 s in all) instead of failing
912
+ * for the rest of the turn on a health result cached before the restart. */
895
913
  async callMcp(method, params, timeoutMs, recovered = false) {
914
+ // The optional working-style hint runs before normal answers. An absent
915
+ // local daemon must not consume the turn's budget before its first call.
916
+ const waits = method === "docdex_working_style" ? [] : this.options.reconnectWaitsMs ?? DOCDEX_RECONNECT_WAITS_MS;
917
+ let sessionRenewed = false;
918
+ for (let attempt = 0;; attempt++) {
919
+ const hadSession = !!this.mcpSessionId;
920
+ try {
921
+ return await this.callMcpOnce(method, params, timeoutMs, recovered);
922
+ }
923
+ catch (error) {
924
+ const status = error instanceof DocdexRuntimeError ? error.status : undefined;
925
+ // A forgotten MCP session means the daemon restarted and is back: renew it once, at once.
926
+ // (A 404 without a session means the daemon has no MCP route at all; callers fall back.)
927
+ if (status === 404 && hadSession && !sessionRenewed) {
928
+ sessionRenewed = true;
929
+ this.mcpSessionId = undefined;
930
+ continue;
931
+ }
932
+ const down = error instanceof DocdexRuntimeError ? error.retryable && error.code === "docdex_unavailable" && (status === undefined || [502, 503, 504].includes(status)) : transportFailure(error);
933
+ // A transport failure can arrive after a write committed. Replaying
934
+ // that call could duplicate the entry.
935
+ const operation = MCP_OPERATION_BY_METHOD[method];
936
+ if (!down || attempt >= waits.length || operation === "memory_save" || operation === "profile_write" || operation === "diary_write")
937
+ throw error;
938
+ this.healthChecked = false;
939
+ this.mcpSessionId = undefined;
940
+ await new Promise(resolve => setTimeout(resolve, waits[attempt]));
941
+ }
942
+ }
943
+ }
944
+ async callMcpOnce(method, params, timeoutMs, recovered = false) {
896
945
  const operation = MCP_OPERATION_BY_METHOD[method];
897
946
  if (operation) {
898
947
  this.assertOperationAllowed(operation);
@@ -903,7 +952,7 @@ export class DocdexClient {
903
952
  await this.ensureMcpSession();
904
953
  // The daemon recognizes the web-specific deadline only on standard MCP
905
954
  // tools/call envelopes; a legacy direct method gets the generic 30s limit.
906
- const standardToolCall = method === "docdex_web_research";
955
+ const standardToolCall = method === "docdex_web_research" || method === "docdex_working_style";
907
956
  const payload = {
908
957
  jsonrpc: "2.0",
909
958
  id: randomUUID(),
@@ -928,6 +977,7 @@ export class DocdexClient {
928
977
  const code = this.mapResponseErrorCode(500, body);
929
978
  throw this.runtimeError(code, raw.error.message ?? "Docdex MCP error", {
930
979
  retryable: code === "docdex_unavailable",
980
+ status: response.status,
931
981
  details: { method, rpcCode: raw.error.code },
932
982
  });
933
983
  }
@@ -1144,6 +1194,10 @@ export class DocdexClient {
1144
1194
  clamp: options.clamp,
1145
1195
  }));
1146
1196
  }
1197
+ /** The user's curated working style from Docdex personal preferences (read-only profile lane). */
1198
+ workingStyle(mode, repoPath, maxChars = 6000) {
1199
+ return this.callMcp("docdex_working_style", { mode, ...(repoPath ? { repo_path: repoPath } : {}), max_chars: maxChars }, 5000);
1200
+ }
1147
1201
  getProfile(agentId) {
1148
1202
  const params = {};
1149
1203
  if (agentId)
@@ -35,6 +35,13 @@ export declare class PermissionGate {
35
35
  deniedTools?: string[];
36
36
  });
37
37
  inspect(): Record<string, unknown>;
38
+ /** Whether a call of this tool could ever be allowed in this session without
39
+ * a new grant: by profile, by host options, or by asking someone who can
40
+ * approve it. A tool that never can is better left out of what the model is
41
+ * offered: in unattended builds every browser_session call was refused. */
42
+ couldAuthorize(tool: ToolDescriptor): boolean;
43
+ /** The sandbox became available after the session opened. */
44
+ setShellIsolated(available: boolean): void;
38
45
  setProfile(profile: PermissionProfile): void;
39
46
  /** Whether workspace writes or commands can ever be authorized in this
40
47
  * session: by profile, or by asking someone who can approve them. */
@@ -1 +1 @@
1
- {"version":3,"file":"PermissionGate.d.ts","sourceRoot":"","sources":["../../src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B,YAAY,IAAI,gBAAgB;IAEhC,aAAa,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI;IAKtC,SAAS,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAwB1F"}
@@ -77,6 +77,32 @@ export class PermissionGate {
77
77
  inspect() {
78
78
  return { profile: this.profile, revision: this.revision, sessionGrants: this.grants.size, sessionDenials: this.denials.size, shellIsolated: this.options.shellIsolated === true, allowWeb: this.profile === "full" || this.options.allowWeb === true, allowMemory: this.profile === "full" || this.options.allowMemory === true, allowMedia: this.profile === "full" || this.options.allowMedia === true, deniedTools: this.options.deniedTools ?? [] };
79
79
  }
80
+ /** Whether a call of this tool could ever be allowed in this session without
81
+ * a new grant: by profile, by host options, or by asking someone who can
82
+ * approve it. A tool that never can is better left out of what the model is
83
+ * offered: in unattended builds every browser_session call was refused. */
84
+ couldAuthorize(tool) {
85
+ const kind = permissionKind(tool);
86
+ if (this.options.deniedTools?.includes(tool.name))
87
+ return false;
88
+ if (kind === "read")
89
+ return true;
90
+ if (this.profile === "plan")
91
+ return false;
92
+ if (kind === "shell" && !this.options.shellIsolated)
93
+ return false;
94
+ if (this.prompt || this.profile === "full" || this.grants.size)
95
+ return true;
96
+ if (kind === "web")
97
+ return this.options.allowWeb === true;
98
+ if (kind === "memory")
99
+ return this.options.allowMemory === true;
100
+ if (kind === "media")
101
+ return this.options.allowMedia === true;
102
+ return this.profile === "workspace" && (kind === "write" || kind === "shell");
103
+ }
104
+ /** The sandbox became available after the session opened. */
105
+ setShellIsolated(available) { this.options.shellIsolated = available; this.revision += 1; }
80
106
  setProfile(profile) {
81
107
  if (!["plan", "ask", "workspace", "full"].includes(profile))
82
108
  throw new Error("Unknown permission profile");
@@ -59,6 +59,8 @@ export interface ModelInvocation {
59
59
  resolvedCatalogId?: string;
60
60
  nativeReasoningRequest?: Record<string, unknown>;
61
61
  }
62
+ /** Test-only: forgets served routes so a scenario starts like a fresh process. */
63
+ export declare const forgetServedRoutes: () => void;
62
64
  export declare class ConfiguredProvider implements Provider {
63
65
  readonly resolved: ResolvedOrchestrationConfig;
64
66
  readonly binding: string;