@livx.cc/agentx 0.99.144 → 0.99.146

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.
@@ -1024,6 +1024,53 @@ interface PlanContext {
1024
1024
  heard?: string;
1025
1025
  }
1026
1026
 
1027
+ declare const MOMENTS: readonly ["turn_end", "barge_in", "in_between", "ask"];
1028
+ type Moment = typeof MOMENTS[number];
1029
+ /** moment `ask`: they ask for something that takes a while; the line ("Hacker News, one sec.") is the turn's bridge when MAIN is slow.
1030
+ * `names`: topic words the line itself says ("Paris?!"): they must have been heard. */
1031
+ interface TreeNode {
1032
+ when: string[];
1033
+ p: number;
1034
+ moment: Moment;
1035
+ line: string;
1036
+ next: TreeNode[];
1037
+ names?: string[];
1038
+ }
1039
+ /** The grower's context: a short rolling talk, never the whole call. */
1040
+ interface TreeContext {
1041
+ /** The last lines of the talk, oldest first ("them: …" / "you: …"). */
1042
+ talk: string[];
1043
+ lang: string;
1044
+ /** Who is speaking, in the host's words. */
1045
+ persona?: string;
1046
+ /** Recent lines already played — not to be reused. */
1047
+ recent: string[];
1048
+ }
1049
+ interface GrowResult {
1050
+ nodes: TreeNode[];
1051
+ tokens?: {
1052
+ input: number;
1053
+ output: number;
1054
+ };
1055
+ }
1056
+ declare class ConvoTreeOptions {
1057
+ /** A leaf plays at this confidence or above. */
1058
+ threshold: number;
1059
+ /** How much more likely a cue of one word / of two or more is if its branch is the true one. */
1060
+ cueEvidence: number;
1061
+ phraseEvidence: number;
1062
+ /** A hit weakens each sibling by this factor. */
1063
+ siblingDecay: number;
1064
+ /** A cue counts only within the newest N words: older ones have passed, a reaction to them would be late. */
1065
+ cueWindow: number;
1066
+ }
1067
+ /** The fill picker: which live leaf fits what they just said, or none. `-1` = none (silence). */
1068
+ type LeafPicker = (heard: string, lines: {
1069
+ i: number;
1070
+ line: string;
1071
+ when: string[];
1072
+ }[], signal: AbortSignal) => Promise<number>;
1073
+
1027
1074
  type LineKind = Exclude<ChannelKind, 'silence'>;
1028
1075
  /** The main (channel-1) response lifecycle. `idle` = no turn in flight (the user has the floor). */
1029
1076
  type MainState = 'idle' | 'queued' | 'thinking' | 'streaming_text' | 'first_audio' | 'speaking';
@@ -1040,6 +1087,10 @@ interface ChannelContext {
1040
1087
  lang: string;
1041
1088
  /** A content reaction (chatty): "oh no", "wait, really?", a key-word echo — not just an "mm-hm". */
1042
1089
  react?: boolean;
1090
+ /** A live bridge: name what they asked for, or answer `none` when no wait is coming. */
1091
+ ask?: boolean;
1092
+ /** The line may carry sound tags ([laughter], [gasp], [quiet]): `live` only. */
1093
+ tags?: boolean;
1043
1094
  }
1044
1095
  interface ChannelEvent {
1045
1096
  trigger: Trigger;
@@ -1053,6 +1104,17 @@ interface ChannelEvent {
1053
1104
  ms: number;
1054
1105
  /** A bridge moment ('working') that stayed silent: why (bridgeBlock). */
1055
1106
  reason?: string;
1107
+ /** The line is a ConvoTree leaf: the moment it was predicted for and its confidence. */
1108
+ moment?: Moment;
1109
+ conf?: number;
1110
+ }
1111
+ /** One tree grown: how long it took, its branches, what it cost, or why it failed. */
1112
+ interface TreeEvent {
1113
+ ms: number;
1114
+ branches: number;
1115
+ lines?: string[];
1116
+ tokens?: GrowResult['tokens'];
1117
+ error?: string;
1056
1118
  }
1057
1119
  /** How talkative the second channel is (`--channel-mode`). */
1058
1120
  type ChannelMode = 'turn' | 'normal' | 'chatty' | 'live';
@@ -1091,6 +1153,8 @@ declare class SecondChannelOptions {
1091
1153
  decideEveryWords: number;
1092
1154
  decisionBudgetMs: number;
1093
1155
  generateBudgetMs: number;
1156
+ /** `live`: how long the fast model may take on a bridge line; later = silence. */
1157
+ bridgeBudgetMs: number;
1094
1158
  minGapMs: number;
1095
1159
  /** Backchannel after backchannel needs this gap (~4-6 cues in a 30s monologue — Para phone call 2026-10-13: 5s left
1096
1160
  * one cue in a long statement). */
@@ -1143,6 +1207,29 @@ declare class SecondChannelOptions {
1143
1207
  * backchannel through (the plan then only vetoes short commands / questions / low density). */
1144
1208
  cueOnly: boolean;
1145
1209
  onPlan: (p: BcPlan, revised: boolean, ms: number) => void;
1210
+ /** `live` only (convoTree.ts): grows the prediction tree after each reply. Once a tree is up it is the only source of
1211
+ * lines while the user talks: a leaf above its threshold, or silence. No tree yet / a failed one: the reactive path. */
1212
+ grow?: (ctx: TreeContext, signal: AbortSignal) => Promise<GrowResult>;
1213
+ /** The quick model at a turn's end with no cue hit: names a leaf or none, inside `pickBudgetMs`. */
1214
+ pickLeaf?: LeafPicker;
1215
+ pickBudgetMs: number;
1216
+ growBudgetMs: number;
1217
+ tree: Partial<ConvoTreeOptions>;
1218
+ /** The tree grower's persona (who is speaking). */
1219
+ persona: string;
1220
+ /** Lines of talk the grower sees. */
1221
+ talkLines: number;
1222
+ /** Mid-turn: at this many words the tree regrows once from what they are saying now. */
1223
+ regrowAtWords: number;
1224
+ /** A leaf is dropped once the talk moved this many words past its cue. */
1225
+ leafStaleWords: number;
1226
+ /** Interims stop this long: the quick model may pick a leaf (shorter than the ~400ms word cadence, so most gaps count; leafGated spaces the calls). */
1227
+ leafBreathMs: number;
1228
+ /** Played leaves the grower must avoid, and how many lines pass before a tag may play again. */
1229
+ leafMemory: number;
1230
+ tagEvery: number;
1231
+ onTree: (e: TreeEvent) => void;
1232
+ onLeaf: (e: ChannelEvent) => void;
1146
1233
  now: () => number;
1147
1234
  random: () => number;
1148
1235
  }
@@ -1166,6 +1253,9 @@ declare class SecondChannel {
1166
1253
  private cutLine;
1167
1254
  private bridged;
1168
1255
  private bridgeDraft;
1256
+ private bridgeReady;
1257
+ private askLeaf;
1258
+ private leafReady;
1169
1259
  private recent;
1170
1260
  private picks;
1171
1261
  private inflight;
@@ -1186,6 +1276,17 @@ declare class SecondChannel {
1186
1276
  private lastReactAt;
1187
1277
  private normalTiming;
1188
1278
  private degradedLogged;
1279
+ private tree;
1280
+ private growing;
1281
+ private growTries;
1282
+ private replyGrown;
1283
+ private talk;
1284
+ private leaves;
1285
+ private sinceTag;
1286
+ private regrown;
1287
+ private picking;
1288
+ private breathTimer;
1289
+ private leafTimer;
1189
1290
  constructor(options?: Partial<SecondChannelOptions> | undefined);
1190
1291
  /** The language lines are spoken in (detected from the user's words, or set by the host). */
1191
1292
  get language(): string | null;
@@ -1195,6 +1296,8 @@ declare class SecondChannel {
1195
1296
  /** Once a language is known, switching needs strong evidence (detectLanguage's `switching`): an English "Um," read as
1196
1297
  * Portuguese flipped a live session to pt (silence until a pt bank was generated — it then spoke Portuguese). */
1197
1298
  private detect;
1299
+ /** `live` speaks no stock bridge/filler, with or without aec. */
1300
+ private get ownWords();
1198
1301
  private get bank();
1199
1302
  private get o();
1200
1303
  /** The user's live partial for the current turn (the whole partial, not a delta). */
@@ -1214,6 +1317,8 @@ declare class SecondChannel {
1214
1317
  /** Is `text` the line the last barge-in cut (ours, still holding the floor)? Hosts strip it from the cut reply — it is
1215
1318
  * not the agent's speech. By identity, not by text: a real reply that merely repeats a recent line is kept. Consumed once. */
1216
1319
  spoke(text: string): boolean;
1320
+ /** Another fill line (progress) already covers this turn's wait: no bridge after it. */
1321
+ covered(): void;
1217
1322
  /** Resolves when the in-flight line finished playing (immediately when none) — hosts enqueue channel-1 audio behind it. */
1218
1323
  drain(): Promise<void>;
1219
1324
  /** Channel-1's last reply ended on a CLOSED question (yes/no, "X or Y?", a confirm): the user's current turn answers or
@@ -1234,6 +1339,20 @@ declare class SecondChannel {
1234
1339
  private rule;
1235
1340
  /** Plan (or, with `heard`, revise) the backchannels of the user's turn — async, never on the hot path. */
1236
1341
  private requestPlan;
1342
+ private noteTalk;
1343
+ /** Grow the tree off the hot path. A tree that lands after its turn is still the best guess: it replaces what is live. */
1344
+ private requestTree;
1345
+ /** Text match on the partial (no model). barge_in plays now, in_between at the next breath; turn_end waits in the tree. */
1346
+ private treeStep;
1347
+ /** A breath with no cue hit: the quick model may name the leaf that fits the words just said. Its answer plays only if
1348
+ * they have not moved on. */
1349
+ private armBreath;
1350
+ /** The user's turn went to MAIN: the armed leaf at once, else the quick model may name one in time. It plays only while
1351
+ * MAIN is still silent, as the turn's first sound. */
1352
+ private turnEndLeaf;
1353
+ private leafGated;
1354
+ /** A leaf's gates: never over MAIN's audio or another line, spaced, capped; never a repeat. */
1355
+ private playLeaf;
1237
1356
  /** A clause boundary mid-floor: a breath or a comma-like close. Not a question (it wants the answer, not "mm-hm"), and a
1238
1357
  * sentence end only deep into a story — a short request's end is the end of their turn (replay: "mm-hm" right after
1239
1358
  * "Check hacker news for recent news.", just before the final). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livx.cc/agentx",
3
- "version": "0.99.144",
3
+ "version": "0.99.146",
4
4
  "description": "Edge-native AI agent runtime — drives a virtual filesystem via any LLM (ai.libx.js). Same bytes run in node, browser, or edge.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",