@hearsay-tools/squawk 0.18.0-dev.6462 → 0.18.0-dev.6472

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 (125) hide show
  1. package/README.md +3 -4
  2. package/dist/ci-wait/tools.d.ts +4 -4
  3. package/dist/contract/events.d.ts +4 -4
  4. package/dist/contract/health.d.ts +2 -5
  5. package/dist/contract/index.d.ts +0 -1
  6. package/dist/contract/index.js +458 -592
  7. package/dist/contract/workspace.d.ts +1 -1
  8. package/dist/data-gitignore.js +0 -1
  9. package/dist/data-gitignore.js.map +1 -1
  10. package/dist/delegation/routes.d.ts +11 -11
  11. package/dist/delegation/transport.d.ts +4 -4
  12. package/dist/home/identity.d.ts +0 -2
  13. package/dist/home/identity.js +2 -2
  14. package/dist/home/identity.js.map +1 -1
  15. package/dist/server/capabilities.d.ts +0 -1
  16. package/dist/server/capabilities.js +0 -3
  17. package/dist/server/capabilities.js.map +1 -1
  18. package/dist/server/forge/github.d.ts +1 -2
  19. package/dist/server/forge/github.js +3 -4
  20. package/dist/server/forge/github.js.map +1 -1
  21. package/dist/server/forge/types.d.ts +2 -2
  22. package/dist/server/git-changes.d.ts +1 -1
  23. package/dist/server/run-checkout.js +2 -2
  24. package/dist/server/run-checkout.js.map +1 -1
  25. package/dist/server/server.d.ts +58 -253
  26. package/dist/server/server.js +12 -24
  27. package/dist/server/server.js.map +1 -1
  28. package/dist/server/validators.js +1 -1
  29. package/dist/server-install/types.d.ts +3 -3
  30. package/dist/server-install/types.js +3 -3
  31. package/dist/ui-state.d.ts +3 -3
  32. package/dist/ui-state.js +3 -3
  33. package/dist/workflows/continuation-admission.d.ts +72 -72
  34. package/dist/workflows/run/wait-engine.d.ts +72 -72
  35. package/dist/workspace/ui-state.js +1 -1
  36. package/dist/workspace/ui-state.js.map +1 -1
  37. package/package.json +4 -4
  38. package/web/dist/assets/activity-motion-CSe8gVgw.js +2 -0
  39. package/web/dist/assets/{activity-route-su3KawLr.js → activity-route-DURvhLQf.js} +1 -1
  40. package/web/dist/assets/agent-accounts-BrFoXDpa.js +18 -0
  41. package/web/dist/assets/attention-BeBfNOUJ.js +1 -0
  42. package/web/dist/assets/{cez-idle-xv7f96fc.js → cez-idle-TVRD1sce.js} +1 -1
  43. package/web/dist/assets/{commit-diff-panel-DmhrguZk.js → commit-diff-panel-BbM4GEgm.js} +1 -1
  44. package/web/dist/assets/{diff-DDwr1gUX.js → diff-DgAd6acp.js} +2 -2
  45. package/web/dist/assets/{diff-view-BNL7l7Vp.js → diff-view--NwKwseV.js} +3 -3
  46. package/web/dist/assets/{file-preview-Cm1jWwBy.js → file-preview-B36xoAJ8.js} +1 -1
  47. package/web/dist/assets/git-toolbar-Db0h7gTI.js +1 -0
  48. package/web/dist/assets/{github-wWGhoE3O.js → github-CA0qpTLt.js} +1 -1
  49. package/web/dist/assets/{global-activity-route-DpQr_eU9.js → global-activity-route-DRc_wjkF.js} +1 -1
  50. package/web/dist/assets/index-De7eAZ5M.js +17 -0
  51. package/web/dist/assets/index-Dps0ABGp.css +1 -0
  52. package/web/dist/assets/{live-protocol-DjH6ZQwI.js → live-protocol-aMLJJ0MQ.js} +1 -1
  53. package/web/dist/assets/preview-pane-connected-CU_lEf11.js +3 -0
  54. package/web/dist/assets/{project-router-uJ3SkX70.js → project-router-ir-bfT5a.js} +1 -1
  55. package/web/dist/assets/project-scope-context-BSdXJd3m.js +4 -0
  56. package/web/dist/assets/{prompt-template-menu-D5T9W-K3.js → prompt-template-menu-BJlLqUsI.js} +1 -1
  57. package/web/dist/assets/queries-BXo4WfX0.js +1 -0
  58. package/web/dist/assets/{reference-chip-AZWOlSRV.js → reference-chip-pp1FgLpK.js} +1 -1
  59. package/web/dist/assets/{repo-git-DJPSn50o.js → repo-git-BOfsABl4.js} +1 -1
  60. package/web/dist/assets/{report-reader-kzlovTso.js → report-reader-C_r69KvS.js} +1 -1
  61. package/web/dist/assets/reports-CWIvS-PA.js +1 -0
  62. package/web/dist/assets/run-header-CSEAFAfa.js +2 -0
  63. package/web/dist/assets/skills-jwrn7yXY.js +1 -0
  64. package/web/dist/assets/{tab-link-h4IjTsRH.js → tab-link-92W6MWDZ.js} +1 -1
  65. package/web/dist/assets/{task-changes-Db3dmYAT.js → task-changes-EalDx6wh.js} +1 -1
  66. package/web/dist/assets/{task-commits-D4HdW5xE.js → task-commits-ZWjrQSnF.js} +1 -1
  67. package/web/dist/assets/{task-files-sdaEBCfr.js → task-files-Cg-INsaD.js} +1 -1
  68. package/web/dist/assets/task-github-item-B8yO5uo1.js +1 -0
  69. package/web/dist/assets/task-thread-Bs6ZnRXz.js +9 -0
  70. package/web/dist/assets/{thread-state-hhRCETQT.js → thread-state-DBalnt7M.js} +1 -1
  71. package/web/dist/assets/use-desktop-BYMCVpyw.js +1 -0
  72. package/web/dist/assets/use-hand-to-agent-state-Bhmmem1E.js +1 -0
  73. package/web/dist/assets/{useInfiniteQuery-BcY0ra-k.js → useInfiniteQuery-C22IahAC.js} +1 -1
  74. package/web/dist/assets/useQuery-C0rYnV6X.js +1 -0
  75. package/web/dist/assets/{workflows-DRO8PcD-.js → workflows-BRhGKY_0.js} +2 -2
  76. package/web/dist/assets/ws-D9whCwIN.js +1 -0
  77. package/web/dist/index.html +15 -15
  78. package/web/dist/live-worker.js +1 -1
  79. package/dist/contract/voice.d.ts +0 -213
  80. package/dist/voice/decide.d.ts +0 -35
  81. package/dist/voice/decide.js +0 -329
  82. package/dist/voice/decide.js.map +0 -1
  83. package/dist/voice/decision-log.d.ts +0 -48
  84. package/dist/voice/decision-log.js +0 -117
  85. package/dist/voice/decision-log.js.map +0 -1
  86. package/dist/voice/engine.d.ts +0 -119
  87. package/dist/voice/engine.js +0 -61
  88. package/dist/voice/engine.js.map +0 -1
  89. package/dist/voice/fake-engine.d.ts +0 -10
  90. package/dist/voice/fake-engine.js +0 -192
  91. package/dist/voice/fake-engine.js.map +0 -1
  92. package/dist/voice/jev-engine.d.ts +0 -17
  93. package/dist/voice/jev-engine.js +0 -110
  94. package/dist/voice/jev-engine.js.map +0 -1
  95. package/dist/voice/pending-ask.d.ts +0 -17
  96. package/dist/voice/pending-ask.js +0 -51
  97. package/dist/voice/pending-ask.js.map +0 -1
  98. package/dist/voice/routes.d.ts +0 -115
  99. package/dist/voice/routes.js +0 -92
  100. package/dist/voice/routes.js.map +0 -1
  101. package/dist/voice/sentence.d.ts +0 -21
  102. package/dist/voice/sentence.js +0 -61
  103. package/dist/voice/sentence.js.map +0 -1
  104. package/dist/voice/thresholds.d.ts +0 -28
  105. package/dist/voice/thresholds.js +0 -29
  106. package/dist/voice/thresholds.js.map +0 -1
  107. package/scripts/voice-replay.ts +0 -50
  108. package/web/dist/assets/activity-motion-BeswQRe1.js +0 -2
  109. package/web/dist/assets/agent-accounts-DseqHuGY.js +0 -18
  110. package/web/dist/assets/attention-DlfFfWoj.js +0 -1
  111. package/web/dist/assets/git-toolbar-Dya9briW.js +0 -1
  112. package/web/dist/assets/index-DS1HIBHa.css +0 -1
  113. package/web/dist/assets/index-DYx21hr3.js +0 -17
  114. package/web/dist/assets/preview-pane-connected-DSStovll.js +0 -3
  115. package/web/dist/assets/project-scope-context-X6-LgbYE.js +0 -4
  116. package/web/dist/assets/queries-00V5jnAV.js +0 -1
  117. package/web/dist/assets/reports-Ds7nog_M.js +0 -1
  118. package/web/dist/assets/run-header-skVwUvR-.js +0 -2
  119. package/web/dist/assets/skills-BJPLRZL5.js +0 -1
  120. package/web/dist/assets/task-github-item-DyZdbhco.js +0 -1
  121. package/web/dist/assets/task-thread-QKAKHYiJ.js +0 -9
  122. package/web/dist/assets/use-desktop-C3yCutND.js +0 -1
  123. package/web/dist/assets/use-hand-to-agent-state-wGtVosbN.js +0 -1
  124. package/web/dist/assets/useQuery-C96hAjNV.js +0 -1
  125. package/web/dist/assets/ws-BD6s7UXb.js +0 -1
@@ -1,110 +0,0 @@
1
- import { z } from 'zod';
2
- import { VoiceEngineError } from './engine.js';
3
- const ENDPOINT = 'https://api.typesafe.ai/v1/systemone';
4
- /** Pinned: the confidence thresholds are tuned against one model version (see jev-issue-intake.cjs). */
5
- const MODEL = 'jev-1.13.0';
6
- /** Per call, no retries: the palette falls back to today's behavior on an error. */
7
- const TIMEOUT_MS = 5000;
8
- const unit = z.number().min(0).max(1);
9
- // Loose objects on purpose: Jev may add keys; only what we read is checked. The envelope leaves
10
- // answer values unknown: an answer nobody asked for is dropped, so it is never validated.
11
- const envelopeSchema = z.object({
12
- answers: z.record(z.string(), z.unknown()),
13
- usage: z.object({ input_tokens: z.unknown().optional() }).optional(),
14
- });
15
- const answerSchema = z.discriminatedUnion('type', [
16
- z.object({ type: z.literal('choice'), choice: z.string(), confidence: unit, probabilities: z.record(z.string(), unit) }),
17
- z.object({ type: z.literal('noul'), noul: unit }),
18
- ]);
19
- /** Jev (TypeSafe) behind the engine seam. Plain `fetch`: no SDK dependency. */
20
- export class JevVoiceEngine {
21
- id = 'jev';
22
- #apiKey;
23
- #fetch;
24
- constructor(options) {
25
- if (!options.apiKey)
26
- throw new Error('TYPESAFE_API_KEY is not set');
27
- this.#apiKey = options.apiKey;
28
- this.#fetch = options.fetch ?? fetch;
29
- }
30
- async decide(input, signal) {
31
- if (signal.aborted)
32
- throw signal.reason;
33
- // Our own timer rather than AbortSignal.timeout, so a test drives it with fake timers.
34
- const timeout = new AbortController();
35
- let timedOut = false;
36
- const timer = setTimeout(() => {
37
- timedOut = true;
38
- timeout.abort();
39
- }, TIMEOUT_MS);
40
- try {
41
- let body;
42
- try {
43
- const response = await this.#fetch(ENDPOINT, {
44
- method: 'POST',
45
- headers: { 'content-type': 'application/json', authorization: `Bearer ${this.#apiKey}` },
46
- body: JSON.stringify({ model: MODEL, state: input.state, questions: wireQuestions(input.questions) }),
47
- signal: AbortSignal.any([signal, timeout.signal]),
48
- });
49
- if (!response.ok)
50
- throw new VoiceEngineError('http', response.status);
51
- body = await response.json().catch((error) => {
52
- if (signal.aborted || timedOut)
53
- throw error;
54
- throw new VoiceEngineError('invalid-answer', undefined, 'the response is not JSON');
55
- });
56
- }
57
- catch (error) {
58
- // The caller's abort wins: the route tells a closed request from an engine failure.
59
- if (signal.aborted)
60
- throw signal.reason;
61
- if (timedOut)
62
- throw new VoiceEngineError('timeout');
63
- if (error instanceof VoiceEngineError)
64
- throw error;
65
- throw new VoiceEngineError('network');
66
- }
67
- return parse(body, input.questions);
68
- }
69
- finally {
70
- clearTimeout(timer);
71
- }
72
- }
73
- }
74
- function wireQuestions(questions) {
75
- return Object.fromEntries(Object.entries(questions).map(([id, q]) => [
76
- id,
77
- q.type === 'choice'
78
- ? { type: 'choice', instructions: q.instructions, criteria: q.options }
79
- : { type: 'noul', instructions: q.instructions, criteria: q.criteria },
80
- ]));
81
- }
82
- /** Checks every asked question against its answer; answers nobody asked for are dropped. */
83
- function parse(body, questions) {
84
- const parsed = envelopeSchema.safeParse(body);
85
- if (!parsed.success)
86
- throw new VoiceEngineError('invalid-answer', undefined, 'the response has the wrong shape');
87
- const answers = {};
88
- for (const [id, question] of Object.entries(questions)) {
89
- const raw = parsed.data.answers[id];
90
- if (raw === undefined)
91
- throw new VoiceEngineError('invalid-answer', undefined, `no answer for "${id}"`);
92
- const checked = answerSchema.safeParse(raw);
93
- if (!checked.success)
94
- throw new VoiceEngineError('invalid-answer', undefined, `"${id}" has the wrong shape`);
95
- const answer = checked.data;
96
- if (answer.type !== question.type) {
97
- throw new VoiceEngineError('invalid-answer', undefined, `"${id}" has the wrong answer type`);
98
- }
99
- if (answer.type === 'choice' && question.type === 'choice') {
100
- const offered = Object.keys(question.options);
101
- if (!offered.includes(answer.choice) || Object.keys(answer.probabilities).some((key) => !offered.includes(key))) {
102
- throw new VoiceEngineError('invalid-answer', undefined, `"${id}" names an option that was not offered`);
103
- }
104
- }
105
- answers[id] = answer;
106
- }
107
- const tokens = parsed.data.usage?.input_tokens;
108
- return typeof tokens === 'number' && Number.isFinite(tokens) ? { answers, inputTokens: tokens } : { answers };
109
- }
110
- //# sourceMappingURL=jev-eng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AE,CAAC;YAC3D,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAC9C,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBAChH,MAAM,IAAI,gBAAgB,CAAC,gBAAgB,EAAE,SAAS,EAAE,IAAI,EAAE,wCAAwC,CAAC,CAAC;YAC1G,CAAC;QACH,CAAC;QACD,OAAO,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;IACvB,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,YAAY,CAAC;IAC/C,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;AAChH,CAAC"}
@@ -1,17 +0,0 @@
1
- import { type AskQuestion } from '../contract/index.js';
2
- import type { RunRecord } from '../contract/index.js';
3
- /**
4
- * The question card voice mode offers the engine (spec 2026-10-21-voice-mode, "How it decides"):
5
- * the latest `ask.requested` in the run's durable history that no delivery or Finish has retired.
6
- *
7
- * The transcript is the source because the cockpit's ask card renders from it, and voice offers
8
- * exactly the card the cockpit shows. Attention reads the open human wait instead
9
- * (hearsay-tools/cezarion#1236), and the two can differ: a run that goes terminal cancels its open
10
- * waits, yet its unanswered card stays shown and answerable through Continue, so a missing human
11
- * wait does not hide the card. An open human wait that names a different ask (`askSeq`) does: the
12
- * run waits on something else. Undefined when there is no card or the history cannot be read.
13
- */
14
- export declare function readPendingHumanAsk(dataDir: string, run: Pick<RunRecord, 'id' | 'waits'>): {
15
- requestId: string;
16
- questions: AskQuestion[];
17
- } | undefined;
@@ -1,51 +0,0 @@
1
- import { WAIT_KINDS } from '../workflows/run/wait-kinds.js';
2
- import { HUMAN_ASK_EVENT_TYPES, askRequestSchema } from '../contract/index.js';
3
- import { pendingAskOf } from '../contract/index.js';
4
- import { readHistoryText } from '../runs/history-file.js';
5
- /** The ask events of a run's durable history, or undefined when it has no history. Throws what the read throws. */
6
- function readHumanAskEvents(dataDir, runId) {
7
- const raw = readHistoryText(dataDir, runId);
8
- if (raw === undefined)
9
- return undefined;
10
- const events = [];
11
- for (const line of raw.split('\n')) {
12
- if (!line)
13
- continue;
14
- try {
15
- const event = JSON.parse(line);
16
- if (event !== null && typeof event === 'object' && 'type' in event &&
17
- typeof event.type === 'string' && HUMAN_ASK_EVENT_TYPES.has(event.type))
18
- events.push(event);
19
- }
20
- catch { /* Match readEvents: a damaged line does not hide later valid receipts. */ }
21
- }
22
- return events;
23
- }
24
- /**
25
- * The question card voice mode offers the engine (spec 2026-10-21-voice-mode, "How it decides"):
26
- * the latest `ask.requested` in the run's durable history that no delivery or Finish has retired.
27
- *
28
- * The transcript is the source because the cockpit's ask card renders from it, and voice offers
29
- * exactly the card the cockpit shows. Attention reads the open human wait instead
30
- * (hearsay-tools/cezarion#1236), and the two can differ: a run that goes terminal cancels its open
31
- * waits, yet its unanswered card stays shown and answerable through Continue, so a missing human
32
- * wait does not hide the card. An open human wait that names a different ask (`askSeq`) does: the
33
- * run waits on something else. Undefined when there is no card or the history cannot be read.
34
- */
35
- export function readPendingHumanAsk(dataDir, run) {
36
- try {
37
- const events = readHumanAskEvents(dataDir, run.id);
38
- const pending = events === undefined ? undefined : pendingAskOf(events);
39
- if (pending === undefined)
40
- return undefined;
41
- const elsewhere = WAIT_KINDS.human.selectOpen(run.waits ?? []).some(wait => wait.askSeq !== undefined && wait.askSeq !== pending.seq);
42
- if (elsewhere)
43
- return undefined;
44
- const parsed = askRequestSchema.safeParse({ questions: pending.questions });
45
- return parsed.success ? { requestId: pending.requestId, questions: parsed.data.questions } : undefined;
46
- }
47
- catch {
48
- return undefined;
49
- }
50
- }
51
- //# sourceMappingURL=pending-ask.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pending-ask.js","sourceRoot":"","sources":["../../src/voice/pending-ask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAoB,MAAM,kCAAkC,CAAC;AAC7G,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAExE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,mHAAmH;AACnH,SAAS,kBAAkB,CAAC,OAAe,EAAE,KAAa;IACxD,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC5C,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACxC,MAAM,MAAM,GAAe,EAAE,CAAC;IAC9B,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACnC,IAAI,CAAC,IAAI;YAAE,SAAS;QACpB,IAAI,CAAC;YACH,MAAM,KAAK,GAAY,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACxC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK;gBAChE,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;gBAAE,MAAM,CAAC,IAAI,CAAC,KAAiB,CAAC,CAAC;QAC5G,CAAC;QAAC,MAAM,CAAC,CAAC,0EAA0E,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAe,EACf,GAAoC;IAEpC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,kBAAkB,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QACnD,MAAM,OAAO,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACxE,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QAC5C,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;QACtI,IAAI,SAAS;YAAE,OAAO,SAAS,CAAC;QAChC,MAAM,MAAM,GAAG,gBAAgB,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;QAC5E,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACzG,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
@@ -1,115 +0,0 @@
1
- import type { ProjectApiEnv } from '../server/server.ts';
2
- import { type RecentVoiceActions } from './decision-log.ts';
3
- import { type DecisionEngine } from './engine.ts';
4
- /** The one refusal both routes answer while voice mode is off (capability `voice`). */
5
- export declare const VOICE_OFF: string;
6
- export interface VoiceRouteDeps {
7
- voiceEnabled(): boolean;
8
- /** Read per request, so the dry-run and key rules follow the live environment. */
9
- engine(): DecisionEngine;
10
- recent: RecentVoiceActions;
11
- uuid?: () => string;
12
- }
13
- /**
14
- * Voice mode routes (spec 2026-10-21-voice-mode, "Architecture"). One chained family, mounted in the
15
- * `v1` chain so they answer under `/api/v1/voice/*` and `/api/v1/p/:projectId/voice/*`. The gate runs
16
- * before validation, so an off server never validates, decides or writes.
17
- */
18
- export declare function createVoiceRoutes(deps: VoiceRouteDeps): import("hono/hono-base").HonoBase<ProjectApiEnv, {
19
- "/voice/decide": {
20
- $post: {
21
- output: {
22
- error: string;
23
- };
24
- outputFormat: "json";
25
- status: 503;
26
- input: {
27
- json: {
28
- text: string;
29
- sidebarView: "active" | "automations";
30
- openRunId?: string | undefined;
31
- view?: "automations" | "git" | "github" | "inbox" | "new-task" | "other" | "settings" | "task" | undefined;
32
- askRequestId?: string | null | undefined;
33
- proposal?: {
34
- decisionId: string;
35
- action: "answer" | "tell";
36
- } | undefined;
37
- };
38
- };
39
- } | {
40
- output: {
41
- action: "open";
42
- decisionId: string;
43
- status: "archived" | "cancelled" | "done" | "failed" | "finished" | "monitoring" | "needs-permission" | "needs-review" | "needs-you" | "queued" | "running" | "scheduled" | "unread" | "waiting-for-capacity" | "waiting-for-ci" | "waiting-on-workers" | "working";
44
- position: number | "last" | "next" | "previous";
45
- confidence: number;
46
- alternatives?: {
47
- status: "archived" | "cancelled" | "done" | "failed" | "finished" | "monitoring" | "needs-permission" | "needs-review" | "needs-you" | "queued" | "running" | "scheduled" | "unread" | "waiting-for-capacity" | "waiting-for-ci" | "waiting-on-workers" | "working";
48
- position: number | "last" | "next" | "previous";
49
- }[] | undefined;
50
- } | {
51
- action: "answer";
52
- decisionId: string;
53
- runId: string;
54
- askRequestId: string;
55
- answers: ({
56
- question: number;
57
- kind: "option";
58
- labels: string[];
59
- } | {
60
- question: number;
61
- kind: "other";
62
- text: string;
63
- })[];
64
- confidence: number;
65
- } | {
66
- action: "tell";
67
- decisionId: string;
68
- runId: string;
69
- text: string;
70
- confidence: number;
71
- } | {
72
- action: "confirm";
73
- decisionId: string;
74
- } | {
75
- action: "cancel";
76
- decisionId: string;
77
- } | {
78
- action: "none";
79
- decisionId: string;
80
- reason: "ambiguous" | "no-open-question" | "no-open-task" | "not-a-command" | "stale-context" | "unclear" | "unsupported";
81
- };
82
- outputFormat: "json";
83
- status: 200;
84
- input: {
85
- json: {
86
- text: string;
87
- sidebarView: "active" | "automations";
88
- openRunId?: string | undefined;
89
- view?: "automations" | "git" | "github" | "inbox" | "new-task" | "other" | "settings" | "task" | undefined;
90
- askRequestId?: string | null | undefined;
91
- proposal?: {
92
- decisionId: string;
93
- action: "answer" | "tell";
94
- } | undefined;
95
- };
96
- };
97
- };
98
- };
99
- } & {
100
- "/voice/outcome": {
101
- $post: {
102
- output: {
103
- ok: true;
104
- };
105
- outputFormat: "json";
106
- status: 200;
107
- input: {
108
- json: {
109
- decisionId: string;
110
- outcome: "abandoned" | "cancelled" | "confirmed" | "executed" | "replaced";
111
- };
112
- };
113
- };
114
- };
115
- }, "/", "/voice/outcome">;
@@ -1,92 +0,0 @@
1
- import { productName } from '../home/display.js';
2
- import { randomUUID } from 'node:crypto';
3
- import { basename } from 'node:path';
4
- import { Hono } from 'hono';
5
- import { voiceDecideRequestSchema, voiceOutcomeRequestSchema, } from '../contract/index.js';
6
- import { jsonZodValidator } from '../server/validators.js';
7
- import { appendVoiceLog } from './decision-log.js';
8
- import { decideVoice } from './decide.js';
9
- import { VoiceEngineError } from './engine.js';
10
- import { readPendingHumanAsk } from './pending-ask.js';
11
- /** The one refusal both routes answer while voice mode is off (capability `voice`). */
12
- export const VOICE_OFF = `Voice mode is off: set CEZ_VOICE=1 and TYPESAFE_API_KEY, then restart ${productName('cezar')}`;
13
- /**
14
- * Voice mode routes (spec 2026-10-21-voice-mode, "Architecture"). One chained family, mounted in the
15
- * `v1` chain so they answer under `/api/v1/voice/*` and `/api/v1/p/:projectId/voice/*`. The gate runs
16
- * before validation, so an off server never validates, decides or writes.
17
- */
18
- export function createVoiceRoutes(deps) {
19
- const gate = async (c, next) => {
20
- if (!deps.voiceEnabled())
21
- return c.json({ error: VOICE_OFF }, 409);
22
- await next();
23
- };
24
- return new Hono()
25
- .use('/voice/*', gate)
26
- .post('/voice/decide', jsonZodValidator(voiceDecideRequestSchema), async (c) => {
27
- const project = c.get('project');
28
- const body = c.req.valid('json');
29
- // An id this project does not know is "no open task", not an error: the tab can outlive the run.
30
- // Its card id goes with it, so "no open task" wins over a stale card.
31
- const openRun = body.openRunId === undefined ? undefined : project.store.getRun(body.openRunId);
32
- const { openRunId: _unknown, askRequestId: _card, ...rest } = body;
33
- const request = openRun ? body : rest;
34
- const screen = {
35
- project: basename(project.root),
36
- ...(openRun ? { openTask: { title: openRun.titleSummary ?? openRun.title, status: openRun.status } } : {}),
37
- };
38
- const ask = openRun ? readPendingHumanAsk(project.store.sourceDataDir(openRun.id), openRun) : undefined;
39
- const decisionId = deps.uuid?.() ?? randomUUID();
40
- deps.recent.load(project.id, project.dataDir);
41
- const recent = deps.recent.last(project.id);
42
- const engine = deps.engine();
43
- try {
44
- const { decision, answers, latencyMs, state } = await decideVoice({
45
- request,
46
- ...(ask ? { ask } : {}),
47
- screen,
48
- recent,
49
- engine,
50
- decisionId,
51
- signal: c.req.raw.signal,
52
- });
53
- appendVoiceLog(project.dataDir, {
54
- type: 'decision',
55
- at: new Date().toISOString(),
56
- decisionId,
57
- sentence: request.text,
58
- ...(request.openRunId !== undefined ? { openRunId: request.openRunId } : {}),
59
- engine: engine.id,
60
- state,
61
- answers,
62
- decision,
63
- latencyMs,
64
- });
65
- deps.recent.record(project.id, decisionId, request.text, decision.action);
66
- return c.json(decision, 200);
67
- }
68
- catch (error) {
69
- // The caller's own abort and any bug go to Hono's error handler and write no line.
70
- if (!(error instanceof VoiceEngineError))
71
- throw error;
72
- appendVoiceLog(project.dataDir, {
73
- type: 'decision-error',
74
- at: new Date().toISOString(),
75
- decisionId,
76
- sentence: request.text,
77
- code: error.code,
78
- });
79
- // Only the code leaves the server: never the engine's message, status or headers.
80
- return c.json({ error: `Voice decision unavailable (${error.code})` }, 503);
81
- }
82
- })
83
- .post('/voice/outcome', jsonZodValidator(voiceOutcomeRequestSchema), async (c) => {
84
- const project = c.get('project');
85
- const { decisionId, outcome } = c.req.valid('json');
86
- deps.recent.load(project.id, project.dataDir);
87
- appendVoiceLog(project.dataDir, { type: 'outcome', at: new Date().toISOString(), decisionId, outcome });
88
- deps.recent.settle(project.id, decisionId, outcome);
89
- return c.json({ ok: true }, 200);
90
- });
91
- }
92
- //# sourceMappingURL=routes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/voice/routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,IAAI,EAA2B,MAAM,MAAM,CAAC;AACrD,OAAO,EACL,wBAAwB,EACxB,yBAAyB,GAE1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,cAAc,EAA2B,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAoB,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAuB,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,uFAAuF;AACvF,MAAM,CAAC,MAAM,SAAS,GAAG,yEAAyE,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;AAUzH;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAoB;IACpD,MAAM,IAAI,GAAG,KAAK,EAAE,CAAU,EAAE,IAAU,EAAE,EAAE;QAC5C,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YAAE,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,E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C,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAa,EAAE,EAAE,GAAG,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -1,21 +0,0 @@
1
- /**
2
- * The dictated sentence as numbered words (hearsay-tools/cezarion#1463). The engine labels each word
3
- * with the part of the reply it belongs to; code copies the words back out of the sentence exactly as
4
- * said (spec 2026-10-21-voice-mode, "Answer the question card"). Pure string work; nothing here
5
- * decides anything.
6
- */
7
- export interface VoiceWord {
8
- /** `W01`, `W02`, … as the engine sees it in `words`. */
9
- id: string;
10
- text: string;
11
- /** Where the word sits in the sentence: `sentence.slice(start, end) === text`. */
12
- start: number;
13
- end: number;
14
- }
15
- export declare function wordId(index: number): string;
16
- export declare function splitWords(sentence: string): VoiceWord[];
17
- /** The indices of the words inside a question reference: they point at a question, they never answer it. */
18
- export declare function questionReferenceWords(sentence: string, words: readonly VoiceWord[], headers: string[]): Set<number>;
19
- export declare function namesQuestion(sentence: string, headers: string[]): boolean;
20
- /** The words `first`..`last` exactly as said, without a trailing sentence mark or comma. */
21
- export declare function copyRange(sentence: string, words: readonly VoiceWord[], first: number, last: number): string;
@@ -1,61 +0,0 @@
1
- /**
2
- * The dictated sentence as numbered words (hearsay-tools/cezarion#1463). The engine labels each word
3
- * with the part of the reply it belongs to; code copies the words back out of the sentence exactly as
4
- * said (spec 2026-10-21-voice-mode, "Answer the question card"). Pure string work; nothing here
5
- * decides anything.
6
- */
7
- const ORDINAL = '(?:one|two|three|four|first|second|third|fourth|[1-4])';
8
- function escapeRegExp(text) {
9
- return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
10
- }
11
- /**
12
- * Where the sentence names a question: by number ("to question first", "the second question") or by
13
- * its card header ("to Library", "for the Library question", "Library question").
14
- */
15
- function questionAnchors(headers) {
16
- const named = [...headers]
17
- .filter((header) => header.trim() !== '')
18
- .sort((a, b) => b.length - a.length)
19
- .map((header) => {
20
- const h = `(?<!\\w)${escapeRegExp(header.trim())}(?!\\w)`;
21
- return `\\b(?:to|for)\\s+(?:the\\s+)?${h}(?:\\s+question\\b)?|(?:\\bthe\\s+)?${h}\\s+question\\b`;
22
- });
23
- const numbered = `(?:\\b(?:to|for)\\s+)?(?:\\bthe\\s+)?\\b(?:question\\s+${ORDINAL}|${ORDINAL}\\s+question)\\b`;
24
- return new RegExp([...named, numbered].join('|'), 'gi');
25
- }
26
- export function wordId(index) {
27
- return `W${String(index + 1).padStart(2, '0')}`;
28
- }
29
- export function splitWords(sentence) {
30
- return [...sentence.matchAll(/\S+/g)].map((match, i) => ({
31
- id: wordId(i),
32
- text: match[0],
33
- start: match.index,
34
- end: match.index + match[0].length,
35
- }));
36
- }
37
- /** The indices of the words inside a question reference: they point at a question, they never answer it. */
38
- export function questionReferenceWords(sentence, words, headers) {
39
- const found = new Set();
40
- for (const anchor of sentence.matchAll(questionAnchors(headers))) {
41
- const from = anchor.index;
42
- const to = anchor.index + anchor[0].length;
43
- words.forEach((word, i) => {
44
- if (word.start < to && word.end > from)
45
- found.add(i);
46
- });
47
- }
48
- return found;
49
- }
50
- export function namesQuestion(sentence, headers) {
51
- return questionAnchors(headers).test(sentence);
52
- }
53
- /** The words `first`..`last` exactly as said, without a trailing sentence mark or comma. */
54
- export function copyRange(sentence, words, first, last) {
55
- const from = words[first];
56
- const to = words[last];
57
- if (from === undefined || to === undefined)
58
- return '';
59
- return sentence.slice(from.start, to.end).replace(/[\s.!?,]+$/, '');
60
- }
61
- //# sourceMappingURL=sentence.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sentence.js","sourceRoot":"","sources":["../../src/voice/sentence.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,MAAM,OAAO,GAAG,wDAAwD,CAAC;AAEzE,SAAS,YAAY,CAAC,IAAY;IAChC,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC;AAED;;;GAGG;AACH,SAAS,eAAe,CAAC,OAAiB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are tuned against one pinned
3
- * Jev version (spec 2026-10-21-voice-mode, "How it decides"); no other file holds a threshold.
4
- */
5
- /**
6
- * `is_command` noul below this reads as chatter, but only when the action is `none` or below
7
- * `ACTION_MIN`; it never vetoes a confident action. Live jev-1.13.0 scored real commands at 0.33–0.47
8
- * ("open second failed": 0.33 with `open` at 0.98), while chatter had no action above 0.40.
9
- */
10
- export declare const IS_COMMAND_MIN = 0.5;
11
- /** The `action` choice below this confidence is not acted on. */
12
- export declare const ACTION_MIN = 0.55;
13
- /** A confirm or cancel needs this much confidence, since it sends or drops a proposal. */
14
- export declare const CONFIRM_MIN = 0.7;
15
- /** The `status` choice below this confidence comes with alternatives. */
16
- export declare const OPEN_STATUS_SURE = 0.6;
17
- /** A card option is taken when its probability is at least this; otherwise the words go to Other. */
18
- export declare const ANSWER_OPTION_MIN = 0.5;
19
- /** A multi-select option is taken when its noul is at least this. */
20
- export declare const OPTION_SELECTED_MIN = 0.5;
21
- /**
22
- * A reply target (an answer to one card question, or the message) is taken when the mean confidence
23
- * of its words is at least this. Not the minimum: live jev-1.13.0 gave correct boundary words
24
- * 0.04–0.5 (spike for hearsay-tools/cezarion#1463). Set just below the lowest mean of a correct
25
- * target in three live runs of the replay set (`scripts/voice-replay.ts`): 0.36, for "tell it that
26
- * that file is fine".
27
- */
28
- export declare const EXTRACT_MIN = 0.3;
@@ -1,29 +0,0 @@
1
- /**
2
- * The confidence cut-offs `decideVoice` applies to engine answers. They are tuned against one pinned
3
- * Jev version (spec 2026-10-21-voice-mode, "How it decides"); no other file holds a threshold.
4
- */
5
- /**
6
- * `is_command` noul below this reads as chatter, but only when the action is `none` or below
7
- * `ACTION_MIN`; it never vetoes a confident action. Live jev-1.13.0 scored real commands at 0.33–0.47
8
- * ("open second failed": 0.33 with `open` at 0.98), while chatter had no action above 0.40.
9
- */
10
- export const IS_COMMAND_MIN = 0.5;
11
- /** The `action` choice below this confidence is not acted on. */
12
- export const ACTION_MIN = 0.55;
13
- /** A confirm or cancel needs this much confidence, since it sends or drops a proposal. */
14
- export const CONFIRM_MIN = 0.7;
15
- /** The `status` choice below this confidence comes with alternatives. */
16
- export const OPEN_STATUS_SURE = 0.6;
17
- /** A card option is taken when its probability is at least this; otherwise the words go to Other. */
18
- export const ANSWER_OPTION_MIN = 0.5;
19
- /** A multi-select option is taken when its noul is at least this. */
20
- export const OPTION_SELECTED_MIN = 0.5;
21
- /**
22
- * A reply target (an answer to one card question, or the message) is taken when the mean confidence
23
- * of its words is at least this. Not the minimum: live jev-1.13.0 gave correct boundary words
24
- * 0.04–0.5 (spike for hearsay-tools/cezarion#1463). Set just below the lowest mean of a correct
25
- * target in three live runs of the replay set (`scripts/voice-replay.ts`): 0.36, for "tell it that
26
- * that file is fine".
27
- */
28
- export const EXTRACT_MIN = 0.3;
29
- //# sourceMappingURL=thresholds.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"thresholds.js","sourceRoot":"","sources":["../../src/voice/thresholds.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAC;AAClC,iEAAiE;AACjE,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC;AAC/B,0FAA0F;AAC1F,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAC;AAC/B,yEAAyE;AACzE,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AACpC,qGAAqG;AACrG,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AACrC,qEAAqE;AACrE,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AACvC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAC"}
@@ -1,50 +0,0 @@
1
- // The voice replay set against the live Jev engine (hearsay-tools/cezarion#1463). Not part of any
2
- // test run: it costs API calls and needs TYPESAFE_API_KEY in the environment. From packages/cezar:
3
- //
4
- // node --import tsx scripts/voice-replay.ts
5
- //
6
- // For each case it prints the expected and actual decision, each target's min and mean word
7
- // confidence, the latency and the input tokens, and exits 1 on any mismatch. It never prints the key.
8
- import { JevVoiceEngine } from '../src/voice/jev-engine.ts';
9
- import type { DecisionEngine } from '../src/voice/engine.ts';
10
- import { REPLAY_CASES, mismatch, replayDecision, targetConfidences } from '../src/voice/replay-set.testkit.ts';
11
-
12
- const apiKey = process.env.TYPESAFE_API_KEY;
13
- if (!apiKey) {
14
- console.error('TYPESAFE_API_KEY is not set.');
15
- process.exit(2);
16
- }
17
- const jev = new JevVoiceEngine({ apiKey });
18
-
19
- let failed = 0;
20
- const latencies: number[] = [];
21
- for (const replay of REPLAY_CASES) {
22
- let inputTokens: number | undefined;
23
- const engine: DecisionEngine = {
24
- id: jev.id,
25
- async decide(input, signal) {
26
- const result = await jev.decide(input, signal);
27
- inputTokens = result.inputTokens;
28
- return result;
29
- },
30
- };
31
- try {
32
- const { decision, answers, latencyMs } = await replayDecision(replay, engine);
33
- latencies.push(latencyMs);
34
- const wrong = mismatch(replay.expect, decision);
35
- if (wrong) failed += 1;
36
- console.log(`${wrong ? 'FAIL' : 'ok '} ${replay.name} — "${replay.sentence}" (${latencyMs} ms, ${inputTokens ?? '?'} in-tokens)`);
37
- if (wrong) console.log(` ${wrong}`);
38
- const { decisionId: _id, ...shown } = decision;
39
- console.log(` decision: ${JSON.stringify(shown)}`);
40
- for (const [label, { min, mean }] of Object.entries(targetConfidences(replay.sentence, answers))) {
41
- console.log(` ${label}: min ${min.toFixed(2)}, mean ${mean.toFixed(2)}`);
42
- }
43
- } catch (error) {
44
- failed += 1;
45
- console.log(`FAIL ${replay.name} — ${error instanceof Error ? error.message : 'engine error'}`);
46
- }
47
- }
48
- const range = latencies.length ? `${Math.min(...latencies)}–${Math.max(...latencies)} ms` : 'n/a';
49
- console.log(`\n${REPLAY_CASES.length - failed}/${REPLAY_CASES.length} cases passed; latency ${range}`);
50
- process.exit(failed === 0 ? 0 : 1);