MCPcopy Create free account
hub / github.com/AGenUI/AGenUI / handleIncompleteDataModel

Method handleIncompleteDataModel

core/src/stream/agenui_text_stream_plugin.cpp:159–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157}
158
159bool TextStreamPlugin::handleIncompleteDataModel(
160 const std::string& buffer,
161 std::vector<ProtocolStreamExtractor::ParseResult>& outResults) {
162
163 // 1. Extract the event path
164 std::string rawPath = extractStringValue(buffer, "\"path\"");
165 std::string eventPath = normalizePath(rawPath);
166
167 // 2. Extract surfaceId
168 std::string surfaceId = extractStringValue(buffer, "\"surfaceId\"");
169
170 // 3. Find all registered Text binding paths that match by prefix or suffix
171 std::vector<std::string> matchedBindings;
172 for (const auto& bp : _textBindingPaths) {
173 if (isPathPrefix(eventPath, bp) || isSuffixMatch(eventPath, bp)) {
174 matchedBindings.push_back(bp);
175 }
176 }
177
178 if (matchedBindings.empty()) {
179 return false;
180 }
181
182 // 4. Navigate to the leaf string value for each matched binding path
183 _streamingEntries.clear();
184 for (const auto& bp : matchedBindings) {
185 std::vector<std::string> segments;
186 if (isPathPrefix(eventPath, bp)) {
187 // Prefix match: navigate into nested object
188 segments = computeRelativeSegments(eventPath, bp);
189 } else {
190 // Suffix match: value is a direct string; no navigation needed
191 segments.clear();
192 }
193
194 size_t leafStart = locateNestedStringValue(buffer, segments);
195 if (leafStart == std::string::npos) {
196 continue;
197 }
198
199 // Check whether the leaf value is already closed
200 size_t closePos = 0;
201 if (isStringValueClosed(buffer, leafStart, closePos)) {
202 continue; // Already closed; no streaming needed
203 }
204
205 TextDataModelStreamingEntry entry;
206 entry.bindingPath = bp;
207 entry.eventPath = eventPath;
208 entry.surfaceId = surfaceId;
209 entry.leafValueStart = leafStart;
210 entry.lastSentEnd = 0;
211 entry.firstEventSent = false;
212 _streamingEntries.push_back(entry);
213 }
214
215 if (_streamingEntries.empty()) {
216 return false;

Callers 1

Calls 4

extractStringValueFunction · 0.85
emptyMethod · 0.80
normalizePathFunction · 0.50
clearMethod · 0.45

Tested by

no test coverage detected