@hearsay-tools/squawk 0.18.0-dev.6468 → 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.
- package/README.md +0 -1
- package/dist/ci-wait/tools.d.ts +4 -4
- package/dist/contract/health.d.ts +0 -2
- package/dist/contract/index.d.ts +0 -1
- package/dist/contract/index.js +457 -591
- package/dist/data-gitignore.js +0 -1
- package/dist/data-gitignore.js.map +1 -1
- package/dist/delegation/routes.d.ts +11 -11
- package/dist/delegation/transport.d.ts +4 -4
- package/dist/server/capabilities.d.ts +0 -1
- package/dist/server/capabilities.js +0 -3
- package/dist/server/capabilities.js.map +1 -1
- package/dist/server/server.d.ts +58 -253
- package/dist/server/server.js +1 -11
- package/dist/server/server.js.map +1 -1
- package/dist/workflows/continuation-admission.d.ts +72 -72
- package/dist/workflows/run/wait-engine.d.ts +72 -72
- package/package.json +4 -4
- package/web/dist/assets/activity-motion-CSe8gVgw.js +2 -0
- package/web/dist/assets/{activity-route-su3KawLr.js → activity-route-DURvhLQf.js} +1 -1
- package/web/dist/assets/agent-accounts-BrFoXDpa.js +18 -0
- package/web/dist/assets/attention-BeBfNOUJ.js +1 -0
- package/web/dist/assets/{cez-idle-xv7f96fc.js → cez-idle-TVRD1sce.js} +1 -1
- package/web/dist/assets/{commit-diff-panel-DmhrguZk.js → commit-diff-panel-BbM4GEgm.js} +1 -1
- package/web/dist/assets/{diff-DDwr1gUX.js → diff-DgAd6acp.js} +2 -2
- package/web/dist/assets/{diff-view-BNL7l7Vp.js → diff-view--NwKwseV.js} +3 -3
- package/web/dist/assets/{file-preview-Cm1jWwBy.js → file-preview-B36xoAJ8.js} +1 -1
- package/web/dist/assets/git-toolbar-Db0h7gTI.js +1 -0
- package/web/dist/assets/{github-wWGhoE3O.js → github-CA0qpTLt.js} +1 -1
- package/web/dist/assets/{global-activity-route-DpQr_eU9.js → global-activity-route-DRc_wjkF.js} +1 -1
- package/web/dist/assets/index-De7eAZ5M.js +17 -0
- package/web/dist/assets/index-Dps0ABGp.css +1 -0
- package/web/dist/assets/{live-protocol-DjH6ZQwI.js → live-protocol-aMLJJ0MQ.js} +1 -1
- package/web/dist/assets/preview-pane-connected-CU_lEf11.js +3 -0
- package/web/dist/assets/{project-router-uJ3SkX70.js → project-router-ir-bfT5a.js} +1 -1
- package/web/dist/assets/project-scope-context-BSdXJd3m.js +4 -0
- package/web/dist/assets/{prompt-template-menu-D5T9W-K3.js → prompt-template-menu-BJlLqUsI.js} +1 -1
- package/web/dist/assets/queries-BXo4WfX0.js +1 -0
- package/web/dist/assets/{reference-chip-AZWOlSRV.js → reference-chip-pp1FgLpK.js} +1 -1
- package/web/dist/assets/{repo-git-DJPSn50o.js → repo-git-BOfsABl4.js} +1 -1
- package/web/dist/assets/{report-reader-kzlovTso.js → report-reader-C_r69KvS.js} +1 -1
- package/web/dist/assets/reports-CWIvS-PA.js +1 -0
- package/web/dist/assets/run-header-CSEAFAfa.js +2 -0
- package/web/dist/assets/skills-jwrn7yXY.js +1 -0
- package/web/dist/assets/{tab-link-h4IjTsRH.js → tab-link-92W6MWDZ.js} +1 -1
- package/web/dist/assets/{task-changes-Db3dmYAT.js → task-changes-EalDx6wh.js} +1 -1
- package/web/dist/assets/{task-commits-D4HdW5xE.js → task-commits-ZWjrQSnF.js} +1 -1
- package/web/dist/assets/{task-files-sdaEBCfr.js → task-files-Cg-INsaD.js} +1 -1
- package/web/dist/assets/task-github-item-B8yO5uo1.js +1 -0
- package/web/dist/assets/task-thread-Bs6ZnRXz.js +9 -0
- package/web/dist/assets/{thread-state-hhRCETQT.js → thread-state-DBalnt7M.js} +1 -1
- package/web/dist/assets/use-desktop-BYMCVpyw.js +1 -0
- package/web/dist/assets/use-hand-to-agent-state-Bhmmem1E.js +1 -0
- package/web/dist/assets/{useInfiniteQuery-BcY0ra-k.js → useInfiniteQuery-C22IahAC.js} +1 -1
- package/web/dist/assets/useQuery-C0rYnV6X.js +1 -0
- package/web/dist/assets/{workflows-DRO8PcD-.js → workflows-BRhGKY_0.js} +2 -2
- package/web/dist/assets/ws-D9whCwIN.js +1 -0
- package/web/dist/index.html +15 -15
- package/web/dist/live-worker.js +1 -1
- package/dist/contract/voice.d.ts +0 -213
- package/dist/voice/decide.d.ts +0 -35
- package/dist/voice/decide.js +0 -329
- package/dist/voice/decide.js.map +0 -1
- package/dist/voice/decision-log.d.ts +0 -48
- package/dist/voice/decision-log.js +0 -117
- package/dist/voice/decision-log.js.map +0 -1
- package/dist/voice/engine.d.ts +0 -119
- package/dist/voice/engine.js +0 -61
- package/dist/voice/engine.js.map +0 -1
- package/dist/voice/fake-engine.d.ts +0 -10
- package/dist/voice/fake-engine.js +0 -192
- package/dist/voice/fake-engine.js.map +0 -1
- package/dist/voice/jev-engine.d.ts +0 -17
- package/dist/voice/jev-engine.js +0 -110
- package/dist/voice/jev-engine.js.map +0 -1
- package/dist/voice/pending-ask.d.ts +0 -17
- package/dist/voice/pending-ask.js +0 -51
- package/dist/voice/pending-ask.js.map +0 -1
- package/dist/voice/routes.d.ts +0 -115
- package/dist/voice/routes.js +0 -92
- package/dist/voice/routes.js.map +0 -1
- package/dist/voice/sentence.d.ts +0 -21
- package/dist/voice/sentence.js +0 -61
- package/dist/voice/sentence.js.map +0 -1
- package/dist/voice/thresholds.d.ts +0 -28
- package/dist/voice/thresholds.js +0 -29
- package/dist/voice/thresholds.js.map +0 -1
- package/scripts/voice-replay.ts +0 -50
- package/web/dist/assets/activity-motion-BeswQRe1.js +0 -2
- package/web/dist/assets/agent-accounts-DseqHuGY.js +0 -18
- package/web/dist/assets/attention-DlfFfWoj.js +0 -1
- package/web/dist/assets/git-toolbar-Dya9briW.js +0 -1
- package/web/dist/assets/index-DS1HIBHa.css +0 -1
- package/web/dist/assets/index-DYx21hr3.js +0 -17
- package/web/dist/assets/preview-pane-connected-DSStovll.js +0 -3
- package/web/dist/assets/project-scope-context-X6-LgbYE.js +0 -4
- package/web/dist/assets/queries-00V5jnAV.js +0 -1
- package/web/dist/assets/reports-Ds7nog_M.js +0 -1
- package/web/dist/assets/run-header-skVwUvR-.js +0 -2
- package/web/dist/assets/skills-BJPLRZL5.js +0 -1
- package/web/dist/assets/task-github-item-DyZdbhco.js +0 -1
- package/web/dist/assets/task-thread-QKAKHYiJ.js +0 -9
- package/web/dist/assets/use-desktop-C3yCutND.js +0 -1
- package/web/dist/assets/use-hand-to-agent-state-wGtVosbN.js +0 -1
- package/web/dist/assets/useQuery-C96hAjNV.js +0 -1
- package/web/dist/assets/ws-BD6s7UXb.js +0 -1
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { type VoiceDecision, type VoiceOutcome } from '../contract/index.js';
|
|
2
|
-
import type { EngineAnswer, VoiceEngineError, VoiceEngineState } from './engine.ts';
|
|
3
|
-
/**
|
|
4
|
-
* The local decision log (spec 2026-10-21-voice-mode, "Decision log"): one JSON line per decision,
|
|
5
|
-
* per failed decision and per reported outcome, in `<dataDir>/voice/decisions.ndjson`. It is the
|
|
6
|
-
* evidence for tuning the thresholds. It never holds the API key, an engine message or a header.
|
|
7
|
-
* Best effort: a log that cannot be written never fails the user's action.
|
|
8
|
-
*/
|
|
9
|
-
export type VoiceLogLine = {
|
|
10
|
-
type: 'decision';
|
|
11
|
-
at: string;
|
|
12
|
-
decisionId: string;
|
|
13
|
-
sentence: string;
|
|
14
|
-
openRunId?: string;
|
|
15
|
-
engine: 'jev' | 'fake';
|
|
16
|
-
/** What the engine was told: the view, the proposal, the card headers and the recent actions. */
|
|
17
|
-
state: VoiceEngineState;
|
|
18
|
-
answers: Record<string, EngineAnswer>;
|
|
19
|
-
decision: VoiceDecision;
|
|
20
|
-
latencyMs: number;
|
|
21
|
-
} | {
|
|
22
|
-
type: 'decision-error';
|
|
23
|
-
at: string;
|
|
24
|
-
decisionId: string;
|
|
25
|
-
sentence: string;
|
|
26
|
-
code: VoiceEngineError['code'];
|
|
27
|
-
} | {
|
|
28
|
-
type: 'outcome';
|
|
29
|
-
at: string;
|
|
30
|
-
decisionId: string;
|
|
31
|
-
outcome: VoiceOutcome;
|
|
32
|
-
};
|
|
33
|
-
export declare function appendVoiceLog(dataDir: string, line: VoiceLogLine): void;
|
|
34
|
-
export declare class RecentVoiceActions {
|
|
35
|
-
private readonly byProject;
|
|
36
|
-
private readonly loaded;
|
|
37
|
-
/**
|
|
38
|
-
* Seeds a project from the tail of its log, once. A missing, unreadable or damaged log seeds
|
|
39
|
-
* nothing and never throws; later calls for the same project do nothing.
|
|
40
|
-
*/
|
|
41
|
-
load(projectId: string, dataDir: string): void;
|
|
42
|
-
private replay;
|
|
43
|
-
record(projectId: string, decisionId: string, sentence: string, action: string): void;
|
|
44
|
-
/** Marks what became of a known decision; an unknown or forgotten id changes nothing. */
|
|
45
|
-
settle(projectId: string, decisionId: string, outcome: VoiceOutcome): void;
|
|
46
|
-
/** Up to `n` newest entries, oldest first. */
|
|
47
|
-
last(projectId: string, n?: number): VoiceEngineState['recent'];
|
|
48
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { dataReadDirs } from '../project-paths.js';
|
|
2
|
-
import { projectWriteRefused } from '../server/cockpit-ownership.js';
|
|
3
|
-
import { mergeAppendOnly } from '../merged-streams.js';
|
|
4
|
-
import { appendFileSync, closeSync, fstatSync, mkdirSync, openSync, readSync } from 'node:fs';
|
|
5
|
-
import { join } from 'node:path';
|
|
6
|
-
import { voiceOutcomeSchema } from '../contract/index.js';
|
|
7
|
-
export function appendVoiceLog(dataDir, line) {
|
|
8
|
-
if (projectWriteRefused(dataDir))
|
|
9
|
-
return;
|
|
10
|
-
try {
|
|
11
|
-
const dir = join(dataDir, 'voice');
|
|
12
|
-
mkdirSync(dir, { recursive: true });
|
|
13
|
-
appendFileSync(join(dir, 'decisions.ndjson'), `${JSON.stringify(line)}\n`, 'utf8');
|
|
14
|
-
}
|
|
15
|
-
catch {
|
|
16
|
-
// Best effort, like the other local logs: the decision already reached the user.
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
/** Most decisions kept per project; the engine is told only the newest few. */
|
|
20
|
-
const RECENT_MAX = 10;
|
|
21
|
-
/** `load` reads at most this much of the end of the log. */
|
|
22
|
-
const LOAD_TAIL_BYTES = 64 * 1024;
|
|
23
|
-
/** The last `LOAD_TAIL_BYTES` of a file as lines; a partial first line is dropped. Throws what the read throws. */
|
|
24
|
-
function readLogTail(path) {
|
|
25
|
-
const fd = openSync(path, 'r');
|
|
26
|
-
try {
|
|
27
|
-
const size = fstatSync(fd).size;
|
|
28
|
-
const start = Math.max(0, size - LOAD_TAIL_BYTES);
|
|
29
|
-
const buffer = Buffer.alloc(size - start);
|
|
30
|
-
let filled = 0;
|
|
31
|
-
while (filled < buffer.length) {
|
|
32
|
-
const n = readSync(fd, buffer, filled, buffer.length - filled, start + filled);
|
|
33
|
-
if (n === 0)
|
|
34
|
-
break;
|
|
35
|
-
filled += n;
|
|
36
|
-
}
|
|
37
|
-
const lines = buffer.subarray(0, filled).toString('utf8').split('\n');
|
|
38
|
-
return start > 0 ? lines.slice(1) : lines;
|
|
39
|
-
}
|
|
40
|
-
finally {
|
|
41
|
-
closeSync(fd);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/** One log line as replay reads it, or undefined when it is not an object with a decision ID. */
|
|
45
|
-
function parseLogLine(line) {
|
|
46
|
-
let parsed;
|
|
47
|
-
try {
|
|
48
|
-
parsed = JSON.parse(line);
|
|
49
|
-
}
|
|
50
|
-
catch {
|
|
51
|
-
return undefined;
|
|
52
|
-
}
|
|
53
|
-
if (parsed === null || typeof parsed !== 'object')
|
|
54
|
-
return undefined;
|
|
55
|
-
return typeof parsed.decisionId === 'string' ? parsed : undefined;
|
|
56
|
-
}
|
|
57
|
-
export class RecentVoiceActions {
|
|
58
|
-
byProject = new Map();
|
|
59
|
-
loaded = new Set();
|
|
60
|
-
/**
|
|
61
|
-
* Seeds a project from the tail of its log, once. A missing, unreadable or damaged log seeds
|
|
62
|
-
* nothing and never throws; later calls for the same project do nothing.
|
|
63
|
-
*/
|
|
64
|
-
load(projectId, dataDir) {
|
|
65
|
-
if (this.loaded.has(projectId))
|
|
66
|
-
return;
|
|
67
|
-
this.loaded.add(projectId);
|
|
68
|
-
const sources = dataReadDirs(dataDir).map(directory => {
|
|
69
|
-
try {
|
|
70
|
-
return readLogTail(join(directory, 'voice', 'decisions.ndjson')).flatMap(line => parseLogLine(line) ?? []);
|
|
71
|
-
}
|
|
72
|
-
catch {
|
|
73
|
-
return [];
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
// Legacy wins a duplicate (decisionId, type); survivors replay in recorded time across both logs.
|
|
77
|
-
// Decisions first, then outcomes: an outcome may belong to the other directory's decision.
|
|
78
|
-
const lines = mergeAppendOnly(sources, entry => `${entry.decisionId}:${String(entry.type)}`, entry => typeof entry.at === 'string' ? entry.at : undefined);
|
|
79
|
-
for (const type of ['decision', 'outcome']) {
|
|
80
|
-
for (const entry of lines)
|
|
81
|
-
if (entry.type === type)
|
|
82
|
-
this.replay(projectId, entry);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
replay(projectId, entry) {
|
|
86
|
-
if (entry.type === 'decision' && typeof entry.sentence === 'string') {
|
|
87
|
-
// Only the action is replayed, so a line written by another version still seeds what it can.
|
|
88
|
-
const action = entry.decision?.action;
|
|
89
|
-
if (typeof action === 'string')
|
|
90
|
-
this.record(projectId, entry.decisionId, entry.sentence, action);
|
|
91
|
-
}
|
|
92
|
-
else if (entry.type === 'outcome') {
|
|
93
|
-
const outcome = voiceOutcomeSchema.safeParse(entry.outcome);
|
|
94
|
-
if (outcome.success)
|
|
95
|
-
this.settle(projectId, entry.decisionId, outcome.data);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
record(projectId, decisionId, sentence, action) {
|
|
99
|
-
const entries = this.byProject.get(projectId) ?? [];
|
|
100
|
-
entries.push({ decisionId, sentence, action });
|
|
101
|
-
if (entries.length > RECENT_MAX)
|
|
102
|
-
entries.splice(0, entries.length - RECENT_MAX);
|
|
103
|
-
this.byProject.set(projectId, entries);
|
|
104
|
-
}
|
|
105
|
-
/** Marks what became of a known decision; an unknown or forgotten id changes nothing. */
|
|
106
|
-
settle(projectId, decisionId, outcome) {
|
|
107
|
-
const entry = this.byProject.get(projectId)?.find((e) => e.decisionId === decisionId);
|
|
108
|
-
if (entry)
|
|
109
|
-
entry.outcome = outcome;
|
|
110
|
-
}
|
|
111
|
-
/** Up to `n` newest entries, oldest first. */
|
|
112
|
-
last(projectId, n = 3) {
|
|
113
|
-
const entries = this.byProject.get(projectId) ?? [];
|
|
114
|
-
return entries.slice(-n).map(({ sentence, action, outcome }) => ({ sentence, action, ...(outcome !== undefined ? { outcome } : {}) }));
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
//# sourceMappingURL=decision-log.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decision-log.js","sourceRoot":"","sources":["../../src/voice/decision-log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9F,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAyC,MAAM,oCAAoC,CAAC;AA2B/G,MAAM,UAAU,cAAc,CAAC,OAAe,EAAE,IAAkB;IAChE,IAAI,mBAAmB,CAAC,OAAO,CAAC;QAAE,OAAO;IACzC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACnC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CA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z } from 'zod';
|
|
2
|
-
import type { VoiceView, voiceSidebarViewSchema } from '../contract/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* Typed decision-engine seam: one request carries the sentence’s questions. Consume applicable
|
|
5
|
-
* answers only; keep Jev and dry-run implementations inside this folder.
|
|
6
|
-
*/
|
|
7
|
-
export type EngineQuestion = {
|
|
8
|
-
type: 'choice';
|
|
9
|
-
instructions: string;
|
|
10
|
-
options: Record<string, string | null>;
|
|
11
|
-
} | {
|
|
12
|
-
type: 'noul';
|
|
13
|
-
instructions: string;
|
|
14
|
-
criteria: {
|
|
15
|
-
true: string;
|
|
16
|
-
false: string;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
export type EngineAnswer = {
|
|
20
|
-
type: 'choice';
|
|
21
|
-
choice: string;
|
|
22
|
-
confidence: number;
|
|
23
|
-
probabilities: Record<string, number>;
|
|
24
|
-
} | {
|
|
25
|
-
type: 'noul';
|
|
26
|
-
noul: number;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* What the engine is told besides the questions: Jev has no memory between calls. `words` numbers the
|
|
30
|
-
* sentence (`W01 answer`) so a question can ask about one word where it stands; `screen` is what the
|
|
31
|
-
* user sees (hearsay-tools/cezarion#1463).
|
|
32
|
-
*/
|
|
33
|
-
export interface VoiceEngineState {
|
|
34
|
-
sentence: string;
|
|
35
|
-
words: string[];
|
|
36
|
-
screen: {
|
|
37
|
-
page: VoiceView | 'unknown';
|
|
38
|
-
sidebarView: z.infer<typeof voiceSidebarViewSchema>;
|
|
39
|
-
project: string;
|
|
40
|
-
openTask?: {
|
|
41
|
-
title: string;
|
|
42
|
-
status: string;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
pendingProposal?: 'answer' | 'tell';
|
|
46
|
-
card?: {
|
|
47
|
-
number: number;
|
|
48
|
-
header: string;
|
|
49
|
-
question: string;
|
|
50
|
-
options?: {
|
|
51
|
-
label: string;
|
|
52
|
-
description?: string;
|
|
53
|
-
}[];
|
|
54
|
-
multiSelect?: boolean;
|
|
55
|
-
}[] | undefined;
|
|
56
|
-
recent: {
|
|
57
|
-
sentence: string;
|
|
58
|
-
action: string;
|
|
59
|
-
outcome?: string;
|
|
60
|
-
}[];
|
|
61
|
-
}
|
|
62
|
-
export interface DecisionEngine {
|
|
63
|
-
readonly id: 'jev' | 'fake';
|
|
64
|
-
/**
|
|
65
|
-
* Answers every question it is given. Rejects with `VoiceEngineError` when the engine fails, and
|
|
66
|
-
* with the caller signal's own reason when the caller aborts.
|
|
67
|
-
*/
|
|
68
|
-
decide(input: {
|
|
69
|
-
state: VoiceEngineState;
|
|
70
|
-
questions: Record<string, EngineQuestion>;
|
|
71
|
-
}, signal: AbortSignal): Promise<{
|
|
72
|
-
answers: Record<string, EngineAnswer>;
|
|
73
|
-
inputTokens?: number;
|
|
74
|
-
}>;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* The question ids code and engines agree on. A card question adds its 0-based index; a word adds
|
|
78
|
-
* its 0-based position in the sentence.
|
|
79
|
-
*/
|
|
80
|
-
export declare const QUESTION_IDS: {
|
|
81
|
-
readonly isCommand: 'is_command';
|
|
82
|
-
readonly scope: 'scope';
|
|
83
|
-
readonly projectAction: 'project_action';
|
|
84
|
-
readonly sessionAction: 'session_action';
|
|
85
|
-
readonly status: 'status';
|
|
86
|
-
readonly position: 'position';
|
|
87
|
-
readonly word: (k: number) => string;
|
|
88
|
-
readonly option: (i: number) => string;
|
|
89
|
-
readonly optionSelected: (i: number, j: number) => string;
|
|
90
|
-
};
|
|
91
|
-
/** The label of a word that is no part of a reply. Targets are `q1`…`qN` with a card, else `message`. */
|
|
92
|
-
/** Words said to the cockpit rather than the agent. Not `command`: Jev read an instruction for the
|
|
93
|
-
* agent ("ask me one more question") as a command (hearsay-tools/cezarion#1463 live testing). */
|
|
94
|
-
export declare const COMMAND_LABEL = "routing";
|
|
95
|
-
export declare const MESSAGE_LABEL = "message";
|
|
96
|
-
export declare const questionLabel: (i: number) => string;
|
|
97
|
-
/**
|
|
98
|
-
* Option keys that carry user or card text are wrapped in curly quotes, so they can never equal a bare
|
|
99
|
-
* key the code owns (`none`, `other`, an action, status or position id). "none" said as an answer is
|
|
100
|
-
* the key `“none”`; the sentinel stays `none`. The text inside is read back with `keyText`.
|
|
101
|
-
*/
|
|
102
|
-
export declare function textKey(text: string): string;
|
|
103
|
-
/** The text inside a `textKey`, or undefined when the key is not one. */
|
|
104
|
-
export declare function keyText(key: string): string | undefined;
|
|
105
|
-
/**
|
|
106
|
-
* An engine failure. The message is fixed text and the error carries no request, header or cause,
|
|
107
|
-
* so the API key cannot travel in it.
|
|
108
|
-
*/
|
|
109
|
-
export declare class VoiceEngineError extends Error {
|
|
110
|
-
readonly code: 'http' | 'timeout' | 'invalid-answer' | 'network';
|
|
111
|
-
readonly status?: number | undefined;
|
|
112
|
-
constructor(code: 'http' | 'timeout' | 'invalid-answer' | 'network', status?: number | undefined, detail?: string);
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* `CEZ_DRY_RUN=1` always gets the fake, even with a key, so a dry run never reaches the network.
|
|
116
|
-
* Otherwise Jev; its constructor throws without a key, which the capability gate in front of the
|
|
117
|
-
* route has already ruled out.
|
|
118
|
-
*/
|
|
119
|
-
export declare function selectVoiceEngine(env: NodeJS.ProcessEnv, fetchImpl?: typeof fetch): DecisionEngine;
|
package/dist/voice/engine.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { productEnv } from '../core/product-env.js';
|
|
2
|
-
import { FakeVoiceEngine } from './fake-engine.js';
|
|
3
|
-
import { JevVoiceEngine } from './jev-engine.js';
|
|
4
|
-
/**
|
|
5
|
-
* The question ids code and engines agree on. A card question adds its 0-based index; a word adds
|
|
6
|
-
* its 0-based position in the sentence.
|
|
7
|
-
*/
|
|
8
|
-
export const QUESTION_IDS = {
|
|
9
|
-
isCommand: 'is_command',
|
|
10
|
-
scope: 'scope',
|
|
11
|
-
projectAction: 'project_action',
|
|
12
|
-
sessionAction: 'session_action',
|
|
13
|
-
status: 'status',
|
|
14
|
-
position: 'position',
|
|
15
|
-
word: (k) => `w${k}`,
|
|
16
|
-
option: (i) => `q${i}_option`,
|
|
17
|
-
optionSelected: (i, j) => `q${i}_opt${j}`,
|
|
18
|
-
};
|
|
19
|
-
/** The label of a word that is no part of a reply. Targets are `q1`…`qN` with a card, else `message`. */
|
|
20
|
-
/** Words said to the cockpit rather than the agent. Not `command`: Jev read an instruction for the
|
|
21
|
-
* agent ("ask me one more question") as a command (hearsay-tools/cezarion#1463 live testing). */
|
|
22
|
-
export const COMMAND_LABEL = 'routing';
|
|
23
|
-
export const MESSAGE_LABEL = 'message';
|
|
24
|
-
export const questionLabel = (i) => `q${i + 1}`;
|
|
25
|
-
/**
|
|
26
|
-
* Option keys that carry user or card text are wrapped in curly quotes, so they can never equal a bare
|
|
27
|
-
* key the code owns (`none`, `other`, an action, status or position id). "none" said as an answer is
|
|
28
|
-
* the key `“none”`; the sentinel stays `none`. The text inside is read back with `keyText`.
|
|
29
|
-
*/
|
|
30
|
-
export function textKey(text) {
|
|
31
|
-
return `\u201c${text}\u201d`;
|
|
32
|
-
}
|
|
33
|
-
/** The text inside a `textKey`, or undefined when the key is not one. */
|
|
34
|
-
export function keyText(key) {
|
|
35
|
-
return key.length >= 2 && key.startsWith('\u201c') && key.endsWith('\u201d') ? key.slice(1, -1) : undefined;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* An engine failure. The message is fixed text and the error carries no request, header or cause,
|
|
39
|
-
* so the API key cannot travel in it.
|
|
40
|
-
*/
|
|
41
|
-
export class VoiceEngineError extends Error {
|
|
42
|
-
code;
|
|
43
|
-
status;
|
|
44
|
-
constructor(code, status, detail) {
|
|
45
|
-
super(detail ? `Voice engine ${code}: ${detail}` : `Voice engine ${code}`);
|
|
46
|
-
this.code = code;
|
|
47
|
-
this.status = status;
|
|
48
|
-
this.name = 'VoiceEngineError';
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* `CEZ_DRY_RUN=1` always gets the fake, even with a key, so a dry run never reaches the network.
|
|
53
|
-
* Otherwise Jev; its constructor throws without a key, which the capability gate in front of the
|
|
54
|
-
* route has already ruled out.
|
|
55
|
-
*/
|
|
56
|
-
export function selectVoiceEngine(env, fetchImpl) {
|
|
57
|
-
if (productEnv('DRY_RUN', env) === '1')
|
|
58
|
-
return new FakeVoiceEngine();
|
|
59
|
-
return new JevVoiceEngine({ apiKey: env.TYPESAFE_API_KEY ?? '', ...(fetchImpl ? { fetch: fetchImpl } : {}) });
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=engine.js.map
|
package/dist/voice/engine.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/voice/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGpD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAoDjD;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,SAAS,EAAE,YAAY;IACvB,KAAK,EAAE,OAAO;IACd,aAAa,EAAE,gBAAgB;IAC/B,aAAa,EAAE,gBAAgB;IAC/B,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE;IAC5B,MAAM,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS;IACrC,cAAc,EAAE,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;CACjD,CAAC;AAEX,yGAAyG;AACzG;kGACkG;AAClG,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AACvC,MAAM,CAAC,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CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type DecisionEngine, type EngineAnswer, type EngineQuestion, type VoiceEngineState } from './engine.ts';
|
|
2
|
-
export declare class FakeVoiceEngine implements DecisionEngine {
|
|
3
|
-
readonly id = "fake";
|
|
4
|
-
decide(input: {
|
|
5
|
-
state: VoiceEngineState;
|
|
6
|
-
questions: Record<string, EngineQuestion>;
|
|
7
|
-
}, _signal: AbortSignal): Promise<{
|
|
8
|
-
answers: Record<string, EngineAnswer>;
|
|
9
|
-
}>;
|
|
10
|
-
}
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { COMMAND_LABEL, MESSAGE_LABEL, QUESTION_IDS, questionLabel, textKey } from './engine.js';
|
|
2
|
-
import { copyRange, splitWords } from './sentence.js';
|
|
3
|
-
/**
|
|
4
|
-
* The dry-run engine (`CEZ_DRY_RUN=1`): deterministic, offline, and small on purpose. It reads a
|
|
5
|
-
* fixed phrase set — "open <position> <status>", "answer <choice | the Nth answer | words> to
|
|
6
|
-
* question <N>", "answer that <words>", "tell it: <text>", "reply <text>", "say <text>",
|
|
7
|
-
* "yes, confirmed", "no" / "cancel" — which is exactly what the browser E2E says. It is not a second
|
|
8
|
-
* engine: anything else reads as "not a command".
|
|
9
|
-
*/
|
|
10
|
-
const ORDINALS = ['first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth'];
|
|
11
|
-
const CARDINALS = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'];
|
|
12
|
-
const ORD = `(?:${[...ORDINALS, ...CARDINALS].join('|')}|\\d+(?:st|nd|rd|th)?)`;
|
|
13
|
-
/** "second", "two", "2nd", "2" ⇒ 2. */
|
|
14
|
-
function ordinalValue(word) {
|
|
15
|
-
const w = word.toLowerCase();
|
|
16
|
-
const named = ORDINALS.indexOf(w) + 1 || CARDINALS.indexOf(w) + 1;
|
|
17
|
-
return named || Number.parseInt(w, 10);
|
|
18
|
-
}
|
|
19
|
-
/** `questions` named in a sentence: "to question first", "for the second question", "question 2". */
|
|
20
|
-
const QUESTION_ANCHOR = new RegExp(`(?:(?:to|for)\\s+)?(?:the\\s+)?(?:question\\s+(${ORD})|(${ORD})\\s+question)\\b`, 'gi');
|
|
21
|
-
const ORDINAL_CHOICE = [
|
|
22
|
-
new RegExp(`^(?:the\\s+)?(${ORD})\\s+(?:answer|option|choice|one)$`, 'i'),
|
|
23
|
-
new RegExp(`^(?:option|choice|answer)\\s+(${ORD})$`, 'i'),
|
|
24
|
-
];
|
|
25
|
-
/** The command words a reply starts with, after any filler; what follows is the reply. */
|
|
26
|
-
const REPLY_PREFIX = /^(?:(?:um+|uh+|so|okay|ok)\b[\s,]*)*(?:answer(?:\s+that)?|tell\s+(?:it|the\s+agent|them)(?:\s+that|\s+to)?|reply(?:\s+with)?|say(?:\s+that)?|message\s+it)\b[\s:,]*/i;
|
|
27
|
-
/** Words that join a reply's parts: "and", "then", a dangling "to"/"for". */
|
|
28
|
-
const CONNECTOR = /^(?:and|then|to|for)[,.]?$/i;
|
|
29
|
-
export class FakeVoiceEngine {
|
|
30
|
-
id = 'fake';
|
|
31
|
-
// Offline and instant: the signal has nothing to stop.
|
|
32
|
-
async decide(input, _signal) {
|
|
33
|
-
const reading = read(input.state);
|
|
34
|
-
const answers = {};
|
|
35
|
-
for (const [id, question] of Object.entries(input.questions)) {
|
|
36
|
-
answers[id] =
|
|
37
|
-
question.type === 'choice'
|
|
38
|
-
? choiceAnswer(Object.keys(question.options), reading.choose(id, Object.keys(question.options)))
|
|
39
|
-
: { type: 'noul', noul: reading.noul(id) };
|
|
40
|
-
}
|
|
41
|
-
return { answers };
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function choiceAnswer(options, choice) {
|
|
45
|
-
const picked = choice !== undefined && options.includes(choice) ? choice : fallback(options);
|
|
46
|
-
return {
|
|
47
|
-
type: 'choice',
|
|
48
|
-
choice: picked,
|
|
49
|
-
confidence: 1,
|
|
50
|
-
probabilities: Object.fromEntries(options.map((option) => [option, option === picked ? 1 : 0])),
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
/** What an id the fake has no rule for gets: `none` when offered, else the first option. */
|
|
54
|
-
function fallback(options) {
|
|
55
|
-
return options.includes('none') ? 'none' : (options[0] ?? '');
|
|
56
|
-
}
|
|
57
|
-
function read(state) {
|
|
58
|
-
const sentence = clean(state.sentence);
|
|
59
|
-
const lower = sentence.toLowerCase();
|
|
60
|
-
const action = actionOf(lower);
|
|
61
|
-
const words = splitWords(state.sentence);
|
|
62
|
-
const wordLabels = labelWords(state, words, action);
|
|
63
|
-
const labelsOf = (i) => state.card?.[i]?.options?.map((o) => o.label) ?? [];
|
|
64
|
-
/** The words labelled with question `i`, as said. */
|
|
65
|
-
const answerOf = (i) => {
|
|
66
|
-
const own = wordLabels.flatMap((label, k) => (label === questionLabel(i) ? [k] : []));
|
|
67
|
-
return own.length === 0 ? undefined : copyRange(state.sentence, words, own[0], own[own.length - 1]);
|
|
68
|
-
};
|
|
69
|
-
return {
|
|
70
|
-
choose(id, options) {
|
|
71
|
-
if (id === QUESTION_IDS.scope) {
|
|
72
|
-
if (action === 'open')
|
|
73
|
-
return 'project';
|
|
74
|
-
return action === 'none' ? 'none' : 'session';
|
|
75
|
-
}
|
|
76
|
-
if (id === QUESTION_IDS.projectAction)
|
|
77
|
-
return action === 'open' ? 'open' : 'none';
|
|
78
|
-
if (id === QUESTION_IDS.sessionAction)
|
|
79
|
-
return action === 'confirm' || action === 'cancel' || action === 'respond' ? action : 'none';
|
|
80
|
-
if (id === QUESTION_IDS.position)
|
|
81
|
-
return positionOf(lower, options);
|
|
82
|
-
if (id === QUESTION_IDS.status)
|
|
83
|
-
return statusOf(lower, options);
|
|
84
|
-
const word = /^w(\d+)$/.exec(id);
|
|
85
|
-
if (word)
|
|
86
|
-
return wordLabels[Number(word[1])];
|
|
87
|
-
const option = /^q(\d+)_option$/.exec(id);
|
|
88
|
-
if (!option)
|
|
89
|
-
return undefined;
|
|
90
|
-
const answer = answerOf(Number(option[1]));
|
|
91
|
-
return answer === undefined ? 'other' : choiceOf(answer, labelsOf(Number(option[1])));
|
|
92
|
-
},
|
|
93
|
-
noul(id) {
|
|
94
|
-
if (id === QUESTION_IDS.isCommand)
|
|
95
|
-
return action === 'none' ? 0.05 : 0.95;
|
|
96
|
-
const option = /^q(\d+)_opt(\d+)$/.exec(id);
|
|
97
|
-
if (!option)
|
|
98
|
-
return 0;
|
|
99
|
-
const answer = answerOf(Number(option[1]));
|
|
100
|
-
const label = labelsOf(Number(option[1]))[Number(option[2])];
|
|
101
|
-
return answer !== undefined && label !== undefined && answer.toLowerCase().includes(label.toLowerCase()) ? 1 : 0;
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
/** Leading fillers and trailing sentence marks off; the case stays, since Other copies it as said. */
|
|
106
|
-
function clean(sentence) {
|
|
107
|
-
return sentence
|
|
108
|
-
.trim()
|
|
109
|
-
.replace(/^(?:(?:um+|uh+|so|okay|ok)\b[\s,]*)+/i, '')
|
|
110
|
-
.replace(/[\s.!?]+$/, '');
|
|
111
|
-
}
|
|
112
|
-
function actionOf(lower) {
|
|
113
|
-
const bare = lower.replace(/[,.!?]/g, '').trim();
|
|
114
|
-
if (/^(?:yes(?: confirmed)?|confirm(?:ed)?|send it)$/.test(bare))
|
|
115
|
-
return 'confirm';
|
|
116
|
-
if (/^(?:no|cancel|stop|never ?mind)$/.test(bare))
|
|
117
|
-
return 'cancel';
|
|
118
|
-
if (/^open\b/.test(lower))
|
|
119
|
-
return 'open';
|
|
120
|
-
if (REPLY_PREFIX.test(lower) && REPLY_PREFIX.exec(lower)[0].trim() !== '')
|
|
121
|
-
return 'respond';
|
|
122
|
-
return 'none';
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* One label per word: the reply's leading command words, question references and joining words are
|
|
126
|
-
* `command`; with a card, the words before the reference that names question N are `qN`, and without
|
|
127
|
-
* a reference a one-question card takes them all; without a card they are the message.
|
|
128
|
-
*/
|
|
129
|
-
function labelWords(state, words, action) {
|
|
130
|
-
const labels = words.map(() => COMMAND_LABEL);
|
|
131
|
-
if (action !== 'respond')
|
|
132
|
-
return labels;
|
|
133
|
-
const prefixEnd = REPLY_PREFIX.exec(state.sentence.trimStart())?.[0].length ?? 0;
|
|
134
|
-
const replyStart = state.sentence.length - state.sentence.trimStart().length + prefixEnd;
|
|
135
|
-
const inReply = (word) => word.start >= replyStart;
|
|
136
|
-
if (state.card === undefined) {
|
|
137
|
-
words.forEach((word, k) => {
|
|
138
|
-
if (inReply(word))
|
|
139
|
-
labels[k] = MESSAGE_LABEL;
|
|
140
|
-
});
|
|
141
|
-
return labels;
|
|
142
|
-
}
|
|
143
|
-
const anchors = [...state.sentence.matchAll(QUESTION_ANCHOR)];
|
|
144
|
-
if (anchors.length === 0) {
|
|
145
|
-
if (state.card.length === 1) {
|
|
146
|
-
words.forEach((word, k) => {
|
|
147
|
-
if (inReply(word))
|
|
148
|
-
labels[k] = questionLabel(0);
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
return labels;
|
|
152
|
-
}
|
|
153
|
-
let from = replyStart;
|
|
154
|
-
for (const anchor of anchors) {
|
|
155
|
-
const n = ordinalValue(anchor[1] ?? anchor[2] ?? '');
|
|
156
|
-
words.forEach((word, k) => {
|
|
157
|
-
if (n >= 1 && word.start >= from && word.end <= anchor.index && !CONNECTOR.test(word.text))
|
|
158
|
-
labels[k] = questionLabel(n - 1);
|
|
159
|
-
});
|
|
160
|
-
from = anchor.index + anchor[0].length;
|
|
161
|
-
}
|
|
162
|
-
return labels;
|
|
163
|
-
}
|
|
164
|
-
function positionOf(lower, options) {
|
|
165
|
-
const found = new RegExp(`\\b(next|previous|last|${ORD})\\b`).exec(lower)?.[1];
|
|
166
|
-
if (!found)
|
|
167
|
-
return undefined;
|
|
168
|
-
if (['next', 'previous', 'last'].includes(found))
|
|
169
|
-
return found;
|
|
170
|
-
const n = ordinalValue(found);
|
|
171
|
-
return [String(n), ...(n === 1 ? ['first'] : [])].find((o) => options.includes(o));
|
|
172
|
-
}
|
|
173
|
-
/** Longest id first, so "waiting for ci" wins over any shorter id inside it. */
|
|
174
|
-
function statusOf(lower, options) {
|
|
175
|
-
const spaced = options.filter((o) => o !== 'none').map((id) => ({ id, words: id.replace(/-/g, ' ') }));
|
|
176
|
-
spaced.sort((a, b) => b.words.length - a.words.length);
|
|
177
|
-
return spaced.find(({ words }) => new RegExp(`\\b${words}\\b`).test(lower.replace(/-/g, ' ')))?.id;
|
|
178
|
-
}
|
|
179
|
-
/** The choice's own words first, then "the second answer"; anything else is the user's own words. */
|
|
180
|
-
function choiceOf(segment, labels) {
|
|
181
|
-
const byLabel = labels.find((label) => label.toLowerCase() === segment.toLowerCase());
|
|
182
|
-
if (byLabel !== undefined)
|
|
183
|
-
return textKey(byLabel);
|
|
184
|
-
for (const pattern of ORDINAL_CHOICE) {
|
|
185
|
-
const word = pattern.exec(segment)?.[1];
|
|
186
|
-
const label = word === undefined ? undefined : labels[ordinalValue(word) - 1];
|
|
187
|
-
if (label !== undefined)
|
|
188
|
-
return textKey(label);
|
|
189
|
-
}
|
|
190
|
-
return 'other';
|
|
191
|
-
}
|
|
192
|
-
//# sourceMappingURL=fake-engine.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fake-engine.js","sourceRoot":"","sources":["../../src/voice/fake-engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAsF,MAAM,aAAa,CAAC;AACrL,OAAO,EAAE,SAAS,EAAE,UAAU,EAAkB,MAAM,eAAe,CAAC;AAEtE;;;;;;GAMG;AACH,MAAM,QAAQ,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,O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AAW,EAAE,CAAC,CAAC;IACtF,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;IACnD,KAAK,MAAM,OAAO,IAAI,cAAc,EAAE,CAAC;QACrC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACxC,MAAM,KAAK,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAC9E,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type DecisionEngine, type EngineAnswer, type EngineQuestion, type VoiceEngineState } from './engine.ts';
|
|
2
|
-
/** Jev (TypeSafe) behind the engine seam. Plain `fetch`: no SDK dependency. */
|
|
3
|
-
export declare class JevVoiceEngine implements DecisionEngine {
|
|
4
|
-
#private;
|
|
5
|
-
readonly id = "jev";
|
|
6
|
-
constructor(options: {
|
|
7
|
-
apiKey: string;
|
|
8
|
-
fetch?: typeof fetch;
|
|
9
|
-
});
|
|
10
|
-
decide(input: {
|
|
11
|
-
state: VoiceEngineState;
|
|
12
|
-
questions: Record<string, EngineQuestion>;
|
|
13
|
-
}, signal: AbortSignal): Promise<{
|
|
14
|
-
answers: Record<string, EngineAnswer>;
|
|
15
|
-
inputTokens?: number;
|
|
16
|
-
}>;
|
|
17
|
-
}
|