@framers/agentos 0.1.112 → 0.1.113
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/dist/api/strategies/debate.d.ts +12 -1
- package/dist/api/strategies/debate.d.ts.map +1 -1
- package/dist/api/strategies/debate.js +41 -5
- package/dist/api/strategies/debate.js.map +1 -1
- package/dist/api/strategies/hierarchical.d.ts +15 -1
- package/dist/api/strategies/hierarchical.d.ts.map +1 -1
- package/dist/api/strategies/hierarchical.js +51 -7
- package/dist/api/strategies/hierarchical.js.map +1 -1
- package/dist/api/strategies/index.d.ts +26 -4
- package/dist/api/strategies/index.d.ts.map +1 -1
- package/dist/api/strategies/index.js +26 -4
- package/dist/api/strategies/index.js.map +1 -1
- package/dist/api/strategies/parallel.d.ts +15 -4
- package/dist/api/strategies/parallel.d.ts.map +1 -1
- package/dist/api/strategies/parallel.js +53 -16
- package/dist/api/strategies/parallel.js.map +1 -1
- package/dist/api/strategies/review-loop.d.ts +15 -1
- package/dist/api/strategies/review-loop.d.ts.map +1 -1
- package/dist/api/strategies/review-loop.js +36 -10
- package/dist/api/strategies/review-loop.js.map +1 -1
- package/dist/api/strategies/sequential.d.ts +11 -1
- package/dist/api/strategies/sequential.d.ts.map +1 -1
- package/dist/api/strategies/sequential.js +39 -8
- package/dist/api/strategies/sequential.js.map +1 -1
- package/dist/api/strategies/shared.d.ts +71 -7
- package/dist/api/strategies/shared.d.ts.map +1 -1
- package/dist/api/strategies/shared.js +89 -10
- package/dist/api/strategies/shared.js.map +1 -1
- package/dist/api/types.d.ts +54 -1
- package/dist/api/types.d.ts.map +1 -1
- package/dist/api/types.js.map +1 -1
- package/dist/memory/facade/Memory.d.ts.map +1 -1
- package/dist/memory/facade/Memory.js +8 -0
- package/dist/memory/facade/Memory.js.map +1 -1
- package/dist/memory/facade/types.d.ts +10 -0
- package/dist/memory/facade/types.d.ts.map +1 -1
- package/dist/memory/index.d.ts +6 -0
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +5 -0
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/observation/MemoryObserver.d.ts +63 -1
- package/dist/memory/observation/MemoryObserver.d.ts.map +1 -1
- package/dist/memory/observation/MemoryObserver.js +115 -4
- package/dist/memory/observation/MemoryObserver.js.map +1 -1
- package/dist/memory/observation/ObservationCompressor.d.ts +88 -0
- package/dist/memory/observation/ObservationCompressor.d.ts.map +1 -0
- package/dist/memory/observation/ObservationCompressor.js +207 -0
- package/dist/memory/observation/ObservationCompressor.js.map +1 -0
- package/dist/memory/observation/ObservationReflector.d.ts +82 -0
- package/dist/memory/observation/ObservationReflector.d.ts.map +1 -0
- package/dist/memory/observation/ObservationReflector.js +212 -0
- package/dist/memory/observation/ObservationReflector.js.map +1 -0
- package/dist/memory/observation/temporal.d.ts +54 -0
- package/dist/memory/observation/temporal.d.ts.map +1 -0
- package/dist/memory/observation/temporal.js +115 -0
- package/dist/memory/observation/temporal.js.map +1 -0
- package/dist/orchestration/builders/VoiceNodeBuilder.d.ts +82 -25
- package/dist/orchestration/builders/VoiceNodeBuilder.d.ts.map +1 -1
- package/dist/orchestration/builders/VoiceNodeBuilder.js +86 -26
- package/dist/orchestration/builders/VoiceNodeBuilder.js.map +1 -1
- package/dist/orchestration/events/GraphEvent.d.ts +67 -5
- package/dist/orchestration/events/GraphEvent.d.ts.map +1 -1
- package/dist/orchestration/events/GraphEvent.js.map +1 -1
- package/dist/orchestration/runtime/VoiceNodeExecutor.d.ts +102 -25
- package/dist/orchestration/runtime/VoiceNodeExecutor.d.ts.map +1 -1
- package/dist/orchestration/runtime/VoiceNodeExecutor.js +133 -38
- package/dist/orchestration/runtime/VoiceNodeExecutor.js.map +1 -1
- package/dist/orchestration/runtime/VoiceTransportAdapter.d.ts +94 -32
- package/dist/orchestration/runtime/VoiceTransportAdapter.d.ts.map +1 -1
- package/dist/orchestration/runtime/VoiceTransportAdapter.js +82 -28
- package/dist/orchestration/runtime/VoiceTransportAdapter.js.map +1 -1
- package/dist/orchestration/runtime/VoiceTurnCollector.d.ts +73 -20
- package/dist/orchestration/runtime/VoiceTurnCollector.d.ts.map +1 -1
- package/dist/orchestration/runtime/VoiceTurnCollector.js +84 -23
- package/dist/orchestration/runtime/VoiceTurnCollector.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,22 +3,28 @@
|
|
|
3
3
|
* @description Subscribes to voice pipeline session events and maintains a
|
|
4
4
|
* running transcript buffer, turn counter, and last-speaker tracker.
|
|
5
5
|
*
|
|
6
|
+
* ## Event bridging strategy
|
|
7
|
+
*
|
|
6
8
|
* The collector bridges the raw EventEmitter-based voice pipeline session into
|
|
7
9
|
* the typed `GraphEvent` stream consumed by the graph runtime. Four session
|
|
8
10
|
* events are handled:
|
|
9
11
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
12
|
+
* | Session event | GraphEvent emitted | Buffered? | Why |
|
|
13
|
+
* |----------------------|--------------------------|-----------|--------------------------------------------------------|
|
|
14
|
+
* | `interim_transcript` | `voice_transcript` | No | Partials are noisy and would duplicate final entries. |
|
|
15
|
+
* | `final_transcript` | `voice_transcript` | Yes | Confirmed utterances form the canonical transcript. |
|
|
16
|
+
* | `turn_complete` | `voice_turn_complete` | N/A | Marks endpoint detection; advances the turn counter. |
|
|
17
|
+
* | `barge_in` | `voice_barge_in` | N/A | Signals user interruption for downstream handlers. |
|
|
18
|
+
*
|
|
19
|
+
* ## Checkpoint restore
|
|
18
20
|
*
|
|
19
21
|
* The `initialTurnCount` constructor parameter enables checkpoint restore:
|
|
20
22
|
* pass the previously persisted count so that `turnIndex` values continue
|
|
21
|
-
* from where the session left off rather than resetting to zero.
|
|
23
|
+
* from where the session left off rather than resetting to zero. This is
|
|
24
|
+
* critical for `maxTurns` enforcement across graph suspensions.
|
|
25
|
+
*
|
|
26
|
+
* @see {@link VoiceNodeExecutor} -- creates and owns the collector during voice node execution.
|
|
27
|
+
* @see {@link VoiceNodeCheckpoint} -- persists `turnIndex` and `transcript` across suspensions.
|
|
22
28
|
*/
|
|
23
29
|
// ---------------------------------------------------------------------------
|
|
24
30
|
// VoiceTurnCollector
|
|
@@ -27,6 +33,11 @@
|
|
|
27
33
|
* Stateful collector that subscribes to a voice pipeline session and routes
|
|
28
34
|
* session events into the AgentOS `GraphEvent` stream.
|
|
29
35
|
*
|
|
36
|
+
* The collector is designed to be short-lived -- created at the start of a
|
|
37
|
+
* voice node execution and discarded when the node completes. Its state
|
|
38
|
+
* (transcript, turn count, last speaker) is captured into a
|
|
39
|
+
* {@link VoiceNodeCheckpoint} by the executor before disposal.
|
|
40
|
+
*
|
|
30
41
|
* @example
|
|
31
42
|
* ```ts
|
|
32
43
|
* const collector = new VoiceTurnCollector(
|
|
@@ -40,25 +51,49 @@
|
|
|
40
51
|
* console.log(collector.getTranscript()); // full buffered transcript
|
|
41
52
|
* console.log(collector.getLastSpeaker()); // last identified speaker
|
|
42
53
|
* ```
|
|
54
|
+
*
|
|
55
|
+
* @see {@link TranscriptEntry} -- shape of each buffered transcript entry.
|
|
56
|
+
* @see {@link VoiceNodeExecutor} -- the executor that creates and queries the collector.
|
|
43
57
|
*/
|
|
44
58
|
export class VoiceTurnCollector {
|
|
45
59
|
/**
|
|
60
|
+
* Creates a new VoiceTurnCollector and immediately subscribes to session events.
|
|
61
|
+
*
|
|
62
|
+
* Subscription is performed in the constructor (rather than a separate `init()`
|
|
63
|
+
* method) because the collector has no meaningful state before subscription and
|
|
64
|
+
* there is no cleanup/unsubscribe lifecycle -- the session EventEmitter is
|
|
65
|
+
* short-lived and garbage-collected with the collector.
|
|
66
|
+
*
|
|
46
67
|
* @param session - The voice pipeline `EventEmitter` to subscribe to.
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* @param
|
|
50
|
-
*
|
|
68
|
+
* Must emit `interim_transcript`, `final_transcript`,
|
|
69
|
+
* `turn_complete`, and `barge_in` events.
|
|
70
|
+
* @param eventSink - Callback invoked synchronously for every emitted
|
|
71
|
+
* `GraphEvent`. Must not throw -- exceptions would
|
|
72
|
+
* propagate into the session event loop.
|
|
73
|
+
* @param nodeId - Identifies the owning graph node in every emitted
|
|
74
|
+
* event, enabling consumers to filter events by node.
|
|
75
|
+
* @param initialTurnCount - Seed value for `turnCount`; pass a persisted value
|
|
76
|
+
* to resume from a checkpoint rather than starting at
|
|
77
|
+
* zero. Defaults to `0`.
|
|
51
78
|
*/
|
|
52
79
|
constructor(session, eventSink, nodeId, initialTurnCount = 0) {
|
|
53
80
|
this.eventSink = eventSink;
|
|
54
81
|
this.nodeId = nodeId;
|
|
55
|
-
/** Buffered confirmed utterances in chronological order. */
|
|
82
|
+
/** Buffered confirmed utterances in chronological order. Append-only. */
|
|
56
83
|
this.transcript = [];
|
|
57
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* Speaker identifier from the most recent `final_transcript` event.
|
|
86
|
+
* Empty string until the first final transcript arrives.
|
|
87
|
+
*/
|
|
58
88
|
this.lastSpeaker = '';
|
|
59
89
|
this.turnCount = initialTurnCount;
|
|
60
90
|
// ------------------------------------------------------------------
|
|
61
|
-
// interim_transcript
|
|
91
|
+
// interim_transcript -- partial STT result, forwarded but NOT buffered.
|
|
92
|
+
//
|
|
93
|
+
// Why not buffer? Interim transcripts are speculative and frequently
|
|
94
|
+
// revised by the STT engine. Buffering them would produce duplicate
|
|
95
|
+
// or contradictory entries. They are forwarded as events so that UIs
|
|
96
|
+
// can show live typing indicators.
|
|
62
97
|
// ------------------------------------------------------------------
|
|
63
98
|
session.on('interim_transcript', (evt) => {
|
|
64
99
|
this.eventSink({
|
|
@@ -71,17 +106,26 @@ export class VoiceTurnCollector {
|
|
|
71
106
|
});
|
|
72
107
|
});
|
|
73
108
|
// ------------------------------------------------------------------
|
|
74
|
-
// final_transcript
|
|
109
|
+
// final_transcript -- confirmed utterance, buffered AND forwarded.
|
|
110
|
+
//
|
|
111
|
+
// This is the canonical source of truth for what was said. Every
|
|
112
|
+
// confirmed utterance is appended to the transcript buffer and the
|
|
113
|
+
// last-speaker tracker is updated.
|
|
75
114
|
// ------------------------------------------------------------------
|
|
76
115
|
session.on('final_transcript', (evt) => {
|
|
116
|
+
// Default speaker to 'user' when the STT service doesn't provide
|
|
117
|
+
// diarization labels. This matches the most common single-speaker
|
|
118
|
+
// scenario where the only speaker is the human user.
|
|
77
119
|
const speaker = evt.speaker ?? 'user';
|
|
78
|
-
// Buffer the confirmed entry for downstream consumers
|
|
120
|
+
// Buffer the confirmed entry for downstream consumers (checkpoint,
|
|
121
|
+
// summarisation, analytics).
|
|
79
122
|
this.transcript.push({
|
|
80
123
|
speaker,
|
|
81
124
|
text: evt.text ?? '',
|
|
82
125
|
timestamp: Date.now(),
|
|
83
126
|
});
|
|
84
|
-
// Track the most recent speaker for quick access without iterating
|
|
127
|
+
// Track the most recent speaker for quick access without iterating
|
|
128
|
+
// the entire buffer. Used by the executor to populate the result.
|
|
85
129
|
this.lastSpeaker = speaker;
|
|
86
130
|
this.eventSink({
|
|
87
131
|
type: 'voice_transcript',
|
|
@@ -93,10 +137,14 @@ export class VoiceTurnCollector {
|
|
|
93
137
|
});
|
|
94
138
|
});
|
|
95
139
|
// ------------------------------------------------------------------
|
|
96
|
-
// turn_complete
|
|
140
|
+
// turn_complete -- endpoint detection fired; advance the turn counter.
|
|
141
|
+
//
|
|
142
|
+
// The counter is incremented BEFORE emitting the event so that the
|
|
143
|
+
// turnIndex in the emitted event reflects the new (post-increment)
|
|
144
|
+
// count. This matches the semantics expected by VoiceNodeExecutor's
|
|
145
|
+
// maxTurns check, which reads getTurnCount() after the event fires.
|
|
97
146
|
// ------------------------------------------------------------------
|
|
98
147
|
session.on('turn_complete', (evt) => {
|
|
99
|
-
// Increment before emitting so that turnIndex reflects the new count.
|
|
100
148
|
this.turnCount++;
|
|
101
149
|
this.eventSink({
|
|
102
150
|
type: 'voice_turn_complete',
|
|
@@ -107,7 +155,13 @@ export class VoiceTurnCollector {
|
|
|
107
155
|
});
|
|
108
156
|
});
|
|
109
157
|
// ------------------------------------------------------------------
|
|
110
|
-
// barge_in
|
|
158
|
+
// barge_in -- user interrupted agent mid-speech.
|
|
159
|
+
//
|
|
160
|
+
// This event does not affect the turn count or transcript buffer
|
|
161
|
+
// because the interruption itself is not a complete utterance. The
|
|
162
|
+
// interrupted text (what the agent was saying) and the user's speech
|
|
163
|
+
// (what triggered the interruption) are forwarded for downstream
|
|
164
|
+
// handlers to process.
|
|
111
165
|
// ------------------------------------------------------------------
|
|
112
166
|
session.on('barge_in', (evt) => {
|
|
113
167
|
this.eventSink({
|
|
@@ -124,6 +178,8 @@ export class VoiceTurnCollector {
|
|
|
124
178
|
/**
|
|
125
179
|
* Returns the total number of completed turns since construction (or since the
|
|
126
180
|
* provided `initialTurnCount` when restoring from a checkpoint).
|
|
181
|
+
*
|
|
182
|
+
* @returns The current turn count. Always >= `initialTurnCount`.
|
|
127
183
|
*/
|
|
128
184
|
getTurnCount() {
|
|
129
185
|
return this.turnCount;
|
|
@@ -132,7 +188,10 @@ export class VoiceTurnCollector {
|
|
|
132
188
|
* Returns a shallow copy of the buffered transcript entries.
|
|
133
189
|
*
|
|
134
190
|
* A copy is returned to prevent external callers from mutating the internal
|
|
135
|
-
* buffer
|
|
191
|
+
* buffer -- entries are append-only and must remain in chronological order
|
|
192
|
+
* for correct checkpoint persistence.
|
|
193
|
+
*
|
|
194
|
+
* @returns A new array containing all confirmed transcript entries in order.
|
|
136
195
|
*/
|
|
137
196
|
getTranscript() {
|
|
138
197
|
return [...this.transcript];
|
|
@@ -140,6 +199,8 @@ export class VoiceTurnCollector {
|
|
|
140
199
|
/**
|
|
141
200
|
* Returns the speaker identifier from the most recent `final_transcript` event,
|
|
142
201
|
* or an empty string if no final transcript has been received yet.
|
|
202
|
+
*
|
|
203
|
+
* @returns The last speaker label, or `''` if none.
|
|
143
204
|
*/
|
|
144
205
|
getLastSpeaker() {
|
|
145
206
|
return this.lastSpeaker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoiceTurnCollector.js","sourceRoot":"","sources":["../../../src/orchestration/runtime/VoiceTurnCollector.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"VoiceTurnCollector.js","sourceRoot":"","sources":["../../../src/orchestration/runtime/VoiceTurnCollector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AA6CH,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,kBAAkB;IAa7B;;;;;;;;;;;;;;;;;;;OAmBG;IACH,YACE,OAAqB,EACJ,SAAsC,EACtC,MAAc,EAC/B,gBAAgB,GAAG,CAAC;QAFH,cAAS,GAAT,SAAS,CAA6B;QACtC,WAAM,GAAN,MAAM,CAAQ;QAnCjC,yEAAyE;QACjE,eAAU,GAAsB,EAAE,CAAC;QAK3C;;;WAGG;QACK,gBAAW,GAAG,EAAE,CAAC;QA4BvB,IAAI,CAAC,SAAS,GAAG,gBAAgB,CAAC;QAElC,qEAAqE;QACrE,wEAAwE;QACxE,EAAE;QACF,qEAAqE;QACrE,oEAAoE;QACpE,qEAAqE;QACrE,mCAAmC;QACnC,qEAAqE;QACrE,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,GAAQ,EAAE,EAAE;YAC5C,IAAI,CAAC,SAAS,CAAC;gBACb,IAAI,EAAE,kBAAkB;gBACxB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,IAAI,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE;gBACpB,OAAO,EAAE,KAAK;gBACd,OAAO,EAAE,GAAG,CAAC,OAAO;gBACpB,UAAU,EAAE,GAAG,CAAC,UAAU,IAAI,CAAC;aAChC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,qEAAqE;QACrE,mEAAmE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