@mcoda/codali 0.1.135-codali.13 → 0.1.135-codali.18

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 (54) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/ORCHESTRATION.md +53 -0
  3. package/README.md +44 -5
  4. package/config/orchestration.schema.json +56 -0
  5. package/dist/cli/TerminalArtifacts.d.ts +5 -0
  6. package/dist/cli/TerminalArtifacts.d.ts.map +1 -0
  7. package/dist/cli/TerminalArtifacts.js +26 -0
  8. package/dist/cli/TerminalCommand.d.ts.map +1 -1
  9. package/dist/cli/TerminalCommand.js +363 -62
  10. package/dist/cli/TerminalInput.d.ts +7 -0
  11. package/dist/cli/TerminalInput.d.ts.map +1 -1
  12. package/dist/cli/TerminalInput.js +53 -7
  13. package/dist/cli/TerminalModels.d.ts +6 -0
  14. package/dist/cli/TerminalModels.d.ts.map +1 -0
  15. package/dist/cli/TerminalModels.js +45 -0
  16. package/dist/cli/TerminalPlan.d.ts +40 -0
  17. package/dist/cli/TerminalPlan.d.ts.map +1 -0
  18. package/dist/cli/TerminalPlan.js +37 -0
  19. package/dist/cli/tui/TerminalCells.d.ts +6 -0
  20. package/dist/cli/tui/TerminalCells.d.ts.map +1 -0
  21. package/dist/cli/tui/TerminalCells.js +47 -0
  22. package/dist/cli/tui/TerminalEditor.d.ts +22 -0
  23. package/dist/cli/tui/TerminalEditor.d.ts.map +1 -0
  24. package/dist/cli/tui/TerminalEditor.js +88 -0
  25. package/dist/cli/tui/TerminalPresentation.d.ts +4 -0
  26. package/dist/cli/tui/TerminalPresentation.d.ts.map +1 -0
  27. package/dist/cli/tui/TerminalPresentation.js +68 -0
  28. package/dist/cli/tui/TerminalScreen.d.ts +49 -0
  29. package/dist/cli/tui/TerminalScreen.d.ts.map +1 -0
  30. package/dist/cli/tui/TerminalScreen.js +130 -0
  31. package/dist/cli/tui/TerminalTui.d.ts +78 -0
  32. package/dist/cli/tui/TerminalTui.d.ts.map +1 -0
  33. package/dist/cli/tui/TerminalTui.js +469 -0
  34. package/dist/cli.d.ts.map +1 -1
  35. package/dist/cli.js +4 -2
  36. package/dist/config/OrchestrationConfig.d.ts +15 -0
  37. package/dist/config/OrchestrationConfig.d.ts.map +1 -1
  38. package/dist/config/OrchestrationConfig.js +19 -1
  39. package/dist/connectors/media/MediaJobStore.d.ts +2 -1
  40. package/dist/connectors/media/MediaJobStore.d.ts.map +1 -1
  41. package/dist/connectors/media/MediaJobStore.js +11 -3
  42. package/dist/runtime/InteractionRouter.d.ts +30 -0
  43. package/dist/runtime/InteractionRouter.d.ts.map +1 -0
  44. package/dist/runtime/InteractionRouter.js +53 -0
  45. package/dist/runtime/PreparedMemory.d.ts +3 -0
  46. package/dist/runtime/PreparedMemory.d.ts.map +1 -0
  47. package/dist/runtime/PreparedMemory.js +30 -0
  48. package/dist/runtime/SessionController.d.ts +27 -1
  49. package/dist/runtime/SessionController.d.ts.map +1 -1
  50. package/dist/runtime/SessionController.js +275 -33
  51. package/dist/session/SessionStore.d.ts +5 -1
  52. package/dist/session/SessionStore.d.ts.map +1 -1
  53. package/dist/session/SessionStore.js +11 -2
  54. package/package.json +4 -3
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - Honor `interaction.answerBinding` for read-only inspections as well as explanations.
6
+
7
+ - Prepare codali.17 with history-aware interaction dispatch before repository
8
+ execution. Greetings and questions no longer create coding tasks or reviewer
9
+ loops; configured small-model prompts prepare bounded stronger-model requests.
10
+ - Record private redacted request/model-response/final-outcome audit events,
11
+ preserve cumulative usage with bounded turn budgets, and remove transport
12
+ metadata from repeated model context. Conversation metadata v2 prevents older
13
+ clients from reinterpreting these sessions as coding jobs; v1 work sessions
14
+ remain readable.
15
+ - Add mouse-wheel scrollback that stays anchored during streaming, readable tool
16
+ activity and errors, and dedicated help/usage views. Preserve keyboard access,
17
+ approval controls and terminal restoration.
18
+
5
19
  - Retry transient Windows state-file replacement conflicts without deleting the
6
20
  previous state or suppressing permanent errors. Retain file durability checks.
7
21
  - Resolve native macOS Git within the selected developer installation so sandboxed
package/ORCHESTRATION.md CHANGED
@@ -460,3 +460,56 @@ receipts and independent-review excerpts preserve the beginning, a detected
460
460
  failure region, and the end of bounded output; omission markers never imply
461
461
  that an unretained full log is available. Successful test exit status remains
462
462
  separate from whether the tests prove the requested behavior.
463
+
464
+ ## Terminal interaction dispatch and audit
465
+
466
+ Natural-language terminal messages first pass through a bounded semantic
467
+ dispatcher. It uses recent conversation and the active goal to choose a direct
468
+ answer, stronger no-tool answer, read-only investigation, action, or clarification.
469
+ It does not match a list of phrases. Conversation does not initialize a work
470
+ record, repository index or verification loop. Side questions preserve active
471
+ work. Action requests retain the original text and relevant conversation beside
472
+ the prepared brief; the brief cannot grant permissions or replace constraints.
473
+
474
+ `codali setup` configures the evaluated local Qwen3 4B Instruct route as `intent`
475
+ when it is advertised and healthy, with configured Strata candidates as fallback.
476
+ The older `router` binding used by automation is unchanged. Existing profiles
477
+ without an `intent` binding use a bounded lead call until the operator configures
478
+ one. No model is downloaded automatically.
479
+
480
+ The optional `interaction` object accepts:
481
+
482
+ ```json
483
+ {
484
+ "routerBinding": "intent",
485
+ "answerBinding": "lead",
486
+ "promptVersion": "my-interaction-v1",
487
+ "maxInputChars": 24000,
488
+ "historyChars": 6000,
489
+ "maxOutputTokens": 768,
490
+ "maxTotalTokens": 16000,
491
+ "maxModelCalls": 8,
492
+ "maxInspectionSteps": 6,
493
+ "timeoutMs": 90000
494
+ }
495
+ ```
496
+
497
+ Optional `routerPrompt` and `answerPrompt` strings replace the built-in prompts.
498
+ The router must return exactly `{"mode":"answer","text":"Hello!"}` with mode
499
+ one of `answer`, `reason`, `inspect`, `execute`, `clarify`. For delegated modes,
500
+ text is a task brief of at most 500 characters, not a proposed solution. Invalid
501
+ output gets one bounded repair attempt; it cannot start execution. Model bindings
502
+ still enforce catalog entitlement, backend identity and context capacity.
503
+
504
+ Session totals accumulate, while turn budgets restart per message. Unknown
505
+ remote outcomes retain their token reservations until reconciled. Execution
506
+ continues to use the selected effort budget and existing completion gate.
507
+
508
+ Private session `transcript.jsonl` records `interaction_request`, `model_request`,
509
+ `model_response`, and `interaction_result` or `interaction_failed`. Correlation
510
+ IDs, actual message/tool payloads, configuration and prompt hashes, model routes,
511
+ token receipts and final outcomes support later investigation. Registered
512
+ credentials and recognizable token formats are redacted; files have private
513
+ permissions and stay outside the repository. No training or log upload is enabled.
514
+ Cancellation may leave a remote model outcome unknown; the log preserves that
515
+ reservation rather than inventing a response or zero usage.
package/README.md CHANGED
@@ -11,6 +11,31 @@ codali doctor
11
11
  codali chat --permissions ask --effort medium
12
12
  ```
13
13
 
14
+ Interactive `codali` and `codali chat` open the terminal UI with a scrollable
15
+ conversation, multiline editor, tool cards, approval dialogs and persistent
16
+ model, effort, permission and usage status. `codali resume SESSION_ID` restores
17
+ the conversation and waits for input; `/continue` resumes execution. JSONL and
18
+ noninteractive resume retain their automation behavior.
19
+
20
+ | Key | Action |
21
+ | --- | --- |
22
+ | Enter | Send, or queue a message while work is running |
23
+ | Alt+Enter or Ctrl+J | Insert a newline |
24
+ | Ctrl+S | Submit a correction; cancel current work and apply it at the next safe checkpoint |
25
+ | Ctrl+P / Ctrl+R | Search commands / input history |
26
+ | Tab | Complete a slash command or an `@workspace/path` reference |
27
+ | Page Up / Page Down | Scroll conversation or inspect a dialog |
28
+ | Ctrl+O | Expand or collapse tool output |
29
+ | Escape | Close a view, deny an approval, or cancel active work |
30
+ | Ctrl+C | Cancel work; press again within one second to exit |
31
+ | Ctrl+D | Exit with an empty editor |
32
+
33
+ Approvals start on **Deny**. Use Left/Right to choose, then Enter to confirm;
34
+ Page Up/Down exposes the complete arguments. Pasted text remains editable and
35
+ cannot select an approval. Use `NO_COLOR=1` for a monochrome TUI or `--plain`
36
+ for a line-oriented interface. Redirected output and `TERM=dumb` use plain mode.
37
+ The UI restores terminal modes and the original screen when it closes.
38
+
14
39
  For automation, inject `MCODA_MSWARM_API_KEY` through your secret manager, or pipe
15
40
  the key to `codali login --stdin`. Keys are never command-line arguments. Existing
16
41
  encrypted mcoda credentials are reused when their service origin matches.
@@ -55,12 +80,21 @@ runtime versions remain available for existing profiles.
55
80
  | `/permissions [plan\|ask\|workspace\|clear]` | Inspect/change policy or revoke exact session grants |
56
81
  | `/effort [low\|medium\|high\|max]` | Change the shared model, tool, token and time budget between turns |
57
82
  | `/goal`, `/plan`, `/tasks`, `/decisions` | Read the durable objective, criteria, dependencies and architecture decisions |
58
- | `/models`, `/config [reload]` | Inspect configured routes and the effective configuration hash |
83
+ | `/goal amend TEXT` | Record an explicit goal amendment between turns, preserving the original objective; execution waits for `/continue` |
84
+ | `/model`, `/models`, `/config [reload\|validate PATH\|diff PATH]` | Inspect routes or validate/compare a proposed configuration before reloading |
85
+ | `/plan [show\|history\|edit TEXT\|mode plan\|execute]` | Inspect or revise the plan; execute mode uses the approval policy |
86
+ | `/plan diff [FROM [TO]]` | Review changed task scope, dependencies and phases between saved revisions; defaults to the previous and current plan |
87
+ | `/tools`, `/mcp`, `/docdex` | Inspect available tools, connectors and indexing configuration |
59
88
  | `/context`, `/diff`, `/review` | Inspect retained context/changes or request a new review task |
60
89
  | `/checkpoint`, `/compact` | Save progress or reduce conversation context while preserving canonical work state |
61
- | `/cancel`, `/continue`, `/steer TEXT` | Interrupt, continue, or apply an explicit goal amendment |
62
- | `/sessions`, `/resume ID`, `/fork`, `/new TEXT` | Manage sessions; forks require fresh verification and reset grants |
90
+ | `/stop`, `/cancel`, `/continue`, `/steer TEXT` | Stop the turn and discard queued instructions, continue, or apply an explicit goal amendment |
91
+ | `/sessions`, `/resume ID`, `/fork`, `/new [TEXT]`, `/clear [TEXT]` | Start a fresh prompt or objective without deleting previous sessions; forks require fresh verification and reset grants |
92
+ | `/exit`, `/quit` | Cancel owned work, discard queued instructions and close after cleanup |
63
93
  | `/artifacts` | Inspect durable image, audio and video jobs and artifact checksums |
94
+ | `/model select BINDING MODEL_ID [--save]` | Preview an entitled configured model; `--save` persists the shared binding and activates it between turns. Compatible embedding replicas preserve the index; another vector space requires a separate configuration, fresh session and rebuild |
95
+ | `/artifacts export JOB_ID PATH` | Copy a verified result to a new workspace file, subject to permissions; existing files are preserved |
96
+ | `/artifacts open JOB_ID` | Verify the result and launch the Linux/macOS desktop viewer; over SSH, export and download it if no display is available |
97
+ | `/tasks media JOB_ID`, `/tasks cancel JOB_ID` | Inspect an owned media job or request cancellation; the worker must confirm the final outcome |
64
98
  | `/reconcile ID success\|failed NOTE` | Record an observed outcome for an interrupted tool invocation |
65
99
  | `/export`, `/retention DAYS`, `/delete-session ID` | Export redacted events, preview retention candidates, or delete an inactive session |
66
100
 
@@ -99,8 +133,13 @@ they do not trigger an automatic retry of a side effect. Session data lives unde
99
133
  `~/.local/state/codali/workspaces/`, outside the editable repository. Media workers
100
134
  survive terminal disconnects and keep binary artifacts out of model transcripts.
101
135
 
102
- `--json` emits JSONL events. Stable fields are `schemaVersion`, `type` and `data`;
103
- session events also carry `id`, `sessionId`, `sequence` and `at`. `turn_result`
136
+ `--json` emits JSONL events; `--output-format jsonl` is its explicit alias
137
+ (`text` selects readable output).
138
+ `--permission-profile` aliases `--permissions`. Validate a shared configuration
139
+ without inference with `codali config validate --file PATH`.
140
+
141
+ Stable event fields are `schemaVersion`, `type` and `data`; session events also
142
+ carry `id`, `sessionId`, `sequence` and `at`. `turn_result`
104
143
  contains `completed`; consumers must check it. `command_failed` covers command
105
144
  failures. Exit codes are 0 for verified completion (or a requested planning turn),
106
145
  1 for errors, 2 for open/blocked work, and 130 for cancellation. `--plain` disables
@@ -245,6 +245,62 @@
245
245
  "minimum": 1
246
246
  }
247
247
  }
248
+ },
249
+ "interaction": {
250
+ "type": "object",
251
+ "additionalProperties": false,
252
+ "properties": {
253
+ "routerBinding": {
254
+ "type": "string",
255
+ "minLength": 1
256
+ },
257
+ "answerBinding": {
258
+ "type": "string",
259
+ "minLength": 1
260
+ },
261
+ "promptVersion": {
262
+ "type": "string",
263
+ "minLength": 1
264
+ },
265
+ "routerPrompt": {
266
+ "type": "string",
267
+ "minLength": 1,
268
+ "maxLength": 16000
269
+ },
270
+ "answerPrompt": {
271
+ "type": "string",
272
+ "minLength": 1,
273
+ "maxLength": 16000
274
+ },
275
+ "maxInputChars": {
276
+ "type": "integer",
277
+ "minimum": 1
278
+ },
279
+ "historyChars": {
280
+ "type": "integer",
281
+ "minimum": 1
282
+ },
283
+ "maxOutputTokens": {
284
+ "type": "integer",
285
+ "minimum": 1
286
+ },
287
+ "maxTotalTokens": {
288
+ "type": "integer",
289
+ "minimum": 1
290
+ },
291
+ "maxModelCalls": {
292
+ "type": "integer",
293
+ "minimum": 1
294
+ },
295
+ "maxInspectionSteps": {
296
+ "type": "integer",
297
+ "minimum": 1
298
+ },
299
+ "timeoutMs": {
300
+ "type": "integer",
301
+ "minimum": 1
302
+ }
303
+ }
248
304
  }
249
305
  },
250
306
  "required": [
@@ -0,0 +1,5 @@
1
+ import type { MediaJobStore } from "../connectors/media/MediaJobStore.js";
2
+ export declare const artifactViewer: (platform: NodeJS.Platform, env: NodeJS.ProcessEnv) => string;
3
+ /** Only an explicit terminal action can launch a local viewer; never a model tool. */
4
+ export declare const openTerminalArtifact: (store: MediaJobStore, id: string, signal: AbortSignal) => Promise<string>;
5
+ //# sourceMappingURL=TerminalArtifacts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TerminalArtifacts.d.ts","sourceRoot":"","sources":["../../src/cli/TerminalArtifacts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAE1E,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,CAAC,QAAQ,EAAE,KAAK,MAAM,CAAC,UAAU,KAAG,MAIlF,CAAC;AAEF,sFAAsF;AACtF,eAAO,MAAM,oBAAoB,GAAU,OAAO,aAAa,EAAE,IAAI,MAAM,EAAE,QAAQ,WAAW,KAAG,OAAO,CAAC,MAAM,CAahH,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { spawn } from "node:child_process";
2
+ export const artifactViewer = (platform, env) => {
3
+ if (platform === "darwin")
4
+ return "open";
5
+ if (platform === "linux" && (env.DISPLAY || env.WAYLAND_DISPLAY))
6
+ return "xdg-open";
7
+ throw new Error("No supported desktop viewer is available here. Use /artifacts export JOB_ID PATH, then download the file to your desktop.");
8
+ };
9
+ /** Only an explicit terminal action can launch a local viewer; never a model tool. */
10
+ export const openTerminalArtifact = async (store, id, signal) => {
11
+ signal.throwIfAborted();
12
+ const artifact = await store.verifiedArtifact(id);
13
+ const executable = artifactViewer(process.platform, process.env);
14
+ signal.throwIfAborted();
15
+ await new Promise((resolve, reject) => {
16
+ const child = spawn(executable, [artifact.path], { shell: false, detached: false, stdio: "ignore", signal });
17
+ const timeout = setTimeout(() => { child.kill("SIGKILL"); finish(new Error("Viewer launcher timed out; export the file and open it manually")); }, 10000);
18
+ const finish = (error) => { clearTimeout(timeout); if (error)
19
+ reject(error);
20
+ else
21
+ resolve(); };
22
+ child.once("error", finish);
23
+ child.once("exit", (code, signal) => finish(code === 0 ? undefined : new Error(`Viewer launcher failed (${signal ?? code}); export the file and open it manually`)));
24
+ });
25
+ return artifact.path;
26
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"TerminalCommand.d.ts","sourceRoot":"","sources":["../../src/cli/TerminalCommand.ts"],"names":[],"mappings":"AAKA,OAAO,EAA2E,KAAK,WAAW,EAA4B,KAAK,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAEzM,OAAO,EAAkB,KAAK,iBAAiB,EAAyB,MAAM,kCAAkC,CAAC;AAMjH,OAAO,EAAkC,KAAK,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAI1F,OAAO,EAA2D,KAAK,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAOnI,UAAU,SAAS;IAAG,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,a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