@pellux/goodvibes-sdk 0.27.11 → 0.28.0
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/_internal/contracts/artifacts/operator-contract.json +7534 -5938
- package/dist/_internal/contracts/generated/foundation-metadata.d.ts +2 -2
- package/dist/_internal/contracts/generated/foundation-metadata.js +2 -2
- package/dist/_internal/contracts/generated/operator-contract.d.ts.map +1 -1
- package/dist/_internal/contracts/generated/operator-contract.js +7534 -5938
- package/dist/_internal/contracts/generated/operator-method-ids.d.ts +1 -1
- package/dist/_internal/contracts/generated/operator-method-ids.d.ts.map +1 -1
- package/dist/_internal/contracts/generated/operator-method-ids.js +8 -0
- package/dist/_internal/daemon/context.d.ts +4 -0
- package/dist/_internal/daemon/context.d.ts.map +1 -1
- package/dist/_internal/daemon/index.d.ts +1 -0
- package/dist/_internal/daemon/index.d.ts.map +1 -1
- package/dist/_internal/daemon/index.js +1 -0
- package/dist/_internal/daemon/knowledge-refinement-routes.d.ts +4 -0
- package/dist/_internal/daemon/knowledge-refinement-routes.d.ts.map +1 -0
- package/dist/_internal/daemon/knowledge-refinement-routes.js +57 -0
- package/dist/_internal/daemon/knowledge-route-types.d.ts +4 -0
- package/dist/_internal/daemon/knowledge-route-types.d.ts.map +1 -1
- package/dist/_internal/daemon/knowledge-routes.d.ts +1 -1
- package/dist/_internal/daemon/knowledge-routes.d.ts.map +1 -1
- package/dist/_internal/daemon/knowledge-routes.js +2 -0
- package/dist/_internal/daemon/operator.d.ts +1 -1
- package/dist/_internal/daemon/operator.d.ts.map +1 -1
- package/dist/_internal/daemon/operator.js +10 -0
- package/dist/_internal/platform/config/schema-domain-runtime.d.ts +4 -0
- package/dist/_internal/platform/config/schema-domain-runtime.d.ts.map +1 -1
- package/dist/_internal/platform/config/schema-domain-runtime.js +17 -0
- package/dist/_internal/platform/config/schema-types.d.ts +6 -2
- package/dist/_internal/platform/config/schema-types.d.ts.map +1 -1
- package/dist/_internal/platform/control-plane/method-catalog-homegraph.d.ts.map +1 -1
- package/dist/_internal/platform/control-plane/method-catalog-homegraph.js +52 -2
- package/dist/_internal/platform/control-plane/method-catalog-knowledge.d.ts.map +1 -1
- package/dist/_internal/platform/control-plane/method-catalog-knowledge.js +58 -1
- package/dist/_internal/platform/control-plane/operator-contract-schemas-homegraph.d.ts +20 -0
- package/dist/_internal/platform/control-plane/operator-contract-schemas-homegraph.d.ts.map +1 -0
- package/dist/_internal/platform/control-plane/operator-contract-schemas-homegraph.js +140 -0
- package/dist/_internal/platform/control-plane/operator-contract-schemas-knowledge.d.ts +11 -16
- package/dist/_internal/platform/control-plane/operator-contract-schemas-knowledge.d.ts.map +1 -1
- package/dist/_internal/platform/control-plane/operator-contract-schemas-knowledge.js +78 -127
- package/dist/_internal/platform/control-plane/routes/operator.d.ts +1 -1
- package/dist/_internal/platform/control-plane/routes/operator.d.ts.map +1 -1
- package/dist/_internal/platform/control-plane/routes/operator.js +10 -0
- package/dist/_internal/platform/daemon/http/home-graph-routes.d.ts.map +1 -1
- package/dist/_internal/platform/daemon/http/home-graph-routes.js +32 -0
- package/dist/_internal/platform/daemon/http/openai-compatible-routes.d.ts +10 -0
- package/dist/_internal/platform/daemon/http/openai-compatible-routes.d.ts.map +1 -0
- package/dist/_internal/platform/daemon/http/openai-compatible-routes.js +445 -0
- package/dist/_internal/platform/daemon/http/router-route-contexts.d.ts.map +1 -1
- package/dist/_internal/platform/daemon/http/router-route-contexts.js +4 -0
- package/dist/_internal/platform/daemon/http/router.d.ts +1 -0
- package/dist/_internal/platform/daemon/http/router.d.ts.map +1 -1
- package/dist/_internal/platform/daemon/http/router.js +16 -0
- package/dist/_internal/platform/knowledge/home-graph/ask.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/home-graph/ask.js +1 -0
- package/dist/_internal/platform/knowledge/home-graph/generated-pages.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/home-graph/generated-pages.js +24 -5
- package/dist/_internal/platform/knowledge/home-graph/inventory.d.ts +23 -0
- package/dist/_internal/platform/knowledge/home-graph/inventory.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/home-graph/inventory.js +21 -0
- package/dist/_internal/platform/knowledge/home-graph/map-view.d.ts +6 -0
- package/dist/_internal/platform/knowledge/home-graph/map-view.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/home-graph/map-view.js +11 -0
- package/dist/_internal/platform/knowledge/home-graph/refinement.d.ts +56 -0
- package/dist/_internal/platform/knowledge/home-graph/refinement.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/home-graph/refinement.js +62 -0
- package/dist/_internal/platform/knowledge/home-graph/rendering.d.ts +3 -3
- package/dist/_internal/platform/knowledge/home-graph/rendering.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/home-graph/rendering.js +52 -136
- package/dist/_internal/platform/knowledge/home-graph/service.d.ts +46 -0
- package/dist/_internal/platform/knowledge/home-graph/service.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/home-graph/service.js +25 -46
- package/dist/_internal/platform/knowledge/home-graph/state.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/home-graph/state.js +20 -1
- package/dist/_internal/platform/knowledge/home-graph/status.d.ts +4 -0
- package/dist/_internal/platform/knowledge/home-graph/status.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/home-graph/status.js +43 -0
- package/dist/_internal/platform/knowledge/home-graph/types.d.ts +8 -0
- package/dist/_internal/platform/knowledge/home-graph/types.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/index.d.ts +1 -1
- package/dist/_internal/platform/knowledge/index.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/scheduling.js +1 -1
- package/dist/_internal/platform/knowledge/semantic/answer.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/semantic/answer.js +69 -9
- package/dist/_internal/platform/knowledge/semantic/fact-quality.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/semantic/fact-quality.js +12 -0
- package/dist/_internal/platform/knowledge/semantic/gap-repair.d.ts +1 -0
- package/dist/_internal/platform/knowledge/semantic/gap-repair.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/semantic/gap-repair.js +146 -5
- package/dist/_internal/platform/knowledge/semantic/self-improvement.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/semantic/self-improvement.js +126 -6
- package/dist/_internal/platform/knowledge/semantic/service.d.ts +1 -2
- package/dist/_internal/platform/knowledge/semantic/service.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/semantic/service.js +51 -54
- package/dist/_internal/platform/knowledge/semantic/types.d.ts +17 -0
- package/dist/_internal/platform/knowledge/semantic/types.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/service-jobs.d.ts +34 -0
- package/dist/_internal/platform/knowledge/service-jobs.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/service-jobs.js +64 -0
- package/dist/_internal/platform/knowledge/service.d.ts +17 -1
- package/dist/_internal/platform/knowledge/service.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/service.js +52 -69
- package/dist/_internal/platform/knowledge/store-config.d.ts +8 -0
- package/dist/_internal/platform/knowledge/store-config.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/store-config.js +10 -0
- package/dist/_internal/platform/knowledge/store-load.d.ts +2 -1
- package/dist/_internal/platform/knowledge/store-load.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/store-load.js +2 -1
- package/dist/_internal/platform/knowledge/store-read.d.ts +10 -1
- package/dist/_internal/platform/knowledge/store-read.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/store-read.js +14 -0
- package/dist/_internal/platform/knowledge/store-refinement.d.ts +4 -0
- package/dist/_internal/platform/knowledge/store-refinement.d.ts.map +1 -0
- package/dist/_internal/platform/knowledge/store-refinement.js +69 -0
- package/dist/_internal/platform/knowledge/store-schema.d.ts +2 -1
- package/dist/_internal/platform/knowledge/store-schema.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/store-schema.js +48 -0
- package/dist/_internal/platform/knowledge/store.d.ts +6 -7
- package/dist/_internal/platform/knowledge/store.d.ts.map +1 -1
- package/dist/_internal/platform/knowledge/store.js +18 -13
- package/dist/_internal/platform/knowledge/types.d.ts +56 -0
- package/dist/_internal/platform/knowledge/types.d.ts.map +1 -1
- package/dist/_internal/platform/runtime/emitters/turn.d.ts +6 -2
- package/dist/_internal/platform/runtime/emitters/turn.d.ts.map +1 -1
- package/dist/_internal/platform/runtime/emitters/turn.js +4 -4
- package/dist/_internal/platform/runtime/events/turn.d.ts +12 -2
- package/dist/_internal/platform/runtime/events/turn.d.ts.map +1 -1
- package/dist/_internal/platform/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import { summarizeError } from '../../utils/error-display.js';
|
|
2
|
+
const OPENAI_COMPAT_PATH_PREFIX = '/v1';
|
|
3
|
+
export async function dispatchOpenAICompatibleRoutes(request, context, pathPrefix = OPENAI_COMPAT_PATH_PREFIX) {
|
|
4
|
+
const url = new URL(request.url);
|
|
5
|
+
const prefix = normalizePathPrefix(pathPrefix);
|
|
6
|
+
if (!url.pathname.startsWith(`${prefix}/`) && url.pathname !== prefix)
|
|
7
|
+
return null;
|
|
8
|
+
const routePath = url.pathname.slice(prefix.length) || '/';
|
|
9
|
+
if (request.method === 'GET' && routePath === '/models') {
|
|
10
|
+
return context.recordApiResponse(request, `${prefix}/models`, handleListModels(context));
|
|
11
|
+
}
|
|
12
|
+
if (request.method === 'POST' && routePath === '/chat/completions') {
|
|
13
|
+
const response = await handleChatCompletions(request, context);
|
|
14
|
+
return context.recordApiResponse(request, `${prefix}/chat/completions`, response);
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
function handleListModels(context) {
|
|
19
|
+
const created = Math.floor(Date.now() / 1000);
|
|
20
|
+
const models = context.providerRegistry.listModels();
|
|
21
|
+
const current = context.providerRegistry.getCurrentModel();
|
|
22
|
+
const ids = new Set(['goodvibes/current', 'goodvibes/default']);
|
|
23
|
+
const plainIdCounts = new Map();
|
|
24
|
+
for (const model of models) {
|
|
25
|
+
ids.add(model.registryKey ?? `${model.provider}:${model.id}`);
|
|
26
|
+
plainIdCounts.set(model.id, (plainIdCounts.get(model.id) ?? 0) + 1);
|
|
27
|
+
}
|
|
28
|
+
for (const model of models) {
|
|
29
|
+
if (plainIdCounts.get(model.id) === 1)
|
|
30
|
+
ids.add(model.id);
|
|
31
|
+
}
|
|
32
|
+
return Response.json({
|
|
33
|
+
object: 'list',
|
|
34
|
+
data: [...ids].sort().map((id) => ({
|
|
35
|
+
id,
|
|
36
|
+
object: 'model',
|
|
37
|
+
created,
|
|
38
|
+
owned_by: id.startsWith('goodvibes/') ? 'goodvibes' : modelOwnerFor(id, models, current.provider),
|
|
39
|
+
})),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
async function handleChatCompletions(request, context) {
|
|
43
|
+
const body = await context.parseJsonBody(request);
|
|
44
|
+
if (body instanceof Response)
|
|
45
|
+
return openAIErrorFromResponse(body);
|
|
46
|
+
const parsed = body;
|
|
47
|
+
if (!Array.isArray(parsed.messages)) {
|
|
48
|
+
return openAIError('Missing required field: messages', 400, 'invalid_request_error', 'missing_messages');
|
|
49
|
+
}
|
|
50
|
+
let resolved;
|
|
51
|
+
try {
|
|
52
|
+
resolved = resolveModel(context.providerRegistry, typeof parsed.model === 'string' ? parsed.model : undefined);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
return openAIError(summarizeError(error), 400, 'invalid_request_error', 'model_not_found');
|
|
56
|
+
}
|
|
57
|
+
let prepared;
|
|
58
|
+
try {
|
|
59
|
+
prepared = prepareChatRequest(parsed);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
return openAIError(summarizeError(error), 400, 'invalid_request_error', 'invalid_messages');
|
|
63
|
+
}
|
|
64
|
+
const maxTokens = readMaxTokens(parsed);
|
|
65
|
+
if (parsed.stream === true) {
|
|
66
|
+
return streamChatCompletion({
|
|
67
|
+
request,
|
|
68
|
+
resolved,
|
|
69
|
+
prepared,
|
|
70
|
+
maxTokens,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
const response = await resolved.provider.chat({
|
|
75
|
+
model: resolved.modelId,
|
|
76
|
+
messages: prepared.messages,
|
|
77
|
+
...(prepared.tools && prepared.tools.length > 0 ? { tools: prepared.tools } : {}),
|
|
78
|
+
...(prepared.systemPrompt ? { systemPrompt: prepared.systemPrompt } : {}),
|
|
79
|
+
...(maxTokens !== undefined ? { maxTokens } : {}),
|
|
80
|
+
signal: request.signal,
|
|
81
|
+
});
|
|
82
|
+
return Response.json(buildChatCompletionResponse(resolved.responseModel, response));
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
return openAIError(summarizeError(error), 500, 'server_error', 'provider_error');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function resolveModel(registry, requested) {
|
|
89
|
+
const current = registry.getCurrentModel();
|
|
90
|
+
const raw = requested?.trim();
|
|
91
|
+
if (!raw || raw === 'goodvibes/current' || raw === 'goodvibes/default') {
|
|
92
|
+
return {
|
|
93
|
+
provider: registry.getForModel(current.id, current.provider),
|
|
94
|
+
providerId: current.provider,
|
|
95
|
+
modelId: current.id,
|
|
96
|
+
responseModel: raw || 'goodvibes/current',
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
const models = registry.listModels();
|
|
100
|
+
const exact = models.find((model) => model.registryKey === raw);
|
|
101
|
+
if (exact) {
|
|
102
|
+
return {
|
|
103
|
+
provider: registry.getForModel(exact.id, exact.provider),
|
|
104
|
+
providerId: exact.provider,
|
|
105
|
+
modelId: exact.id,
|
|
106
|
+
responseModel: exact.registryKey,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
const separator = raw.indexOf(':');
|
|
110
|
+
if (separator > 0) {
|
|
111
|
+
const providerId = raw.slice(0, separator);
|
|
112
|
+
const modelId = raw.slice(separator + 1);
|
|
113
|
+
return {
|
|
114
|
+
provider: registry.getForModel(modelId, providerId),
|
|
115
|
+
providerId,
|
|
116
|
+
modelId,
|
|
117
|
+
responseModel: raw,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const plain = models.find((model) => model.id === raw);
|
|
121
|
+
return {
|
|
122
|
+
provider: registry.getForModel(raw),
|
|
123
|
+
providerId: plain?.provider ?? '',
|
|
124
|
+
modelId: plain?.id ?? raw,
|
|
125
|
+
responseModel: plain?.registryKey ?? raw,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function prepareChatRequest(input) {
|
|
129
|
+
const systemParts = [];
|
|
130
|
+
const messages = [];
|
|
131
|
+
for (const message of input.messages) {
|
|
132
|
+
if (!isRecord(message))
|
|
133
|
+
throw new Error('Each message must be an object.');
|
|
134
|
+
const role = readString(message.role);
|
|
135
|
+
if (!role)
|
|
136
|
+
throw new Error('Each message must include a role.');
|
|
137
|
+
if (role === 'system' || role === 'developer') {
|
|
138
|
+
const content = contentAsText(normalizeMessageContent(message.content));
|
|
139
|
+
if (content.trim())
|
|
140
|
+
systemParts.push(content);
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (role === 'user') {
|
|
144
|
+
messages.push({ role: 'user', content: normalizeMessageContent(message.content) });
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (role === 'assistant') {
|
|
148
|
+
messages.push({
|
|
149
|
+
role: 'assistant',
|
|
150
|
+
content: contentAsText(normalizeMessageContent(message.content)),
|
|
151
|
+
...(Array.isArray(message.tool_calls) ? { toolCalls: normalizeToolCalls(message.tool_calls) } : {}),
|
|
152
|
+
});
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (role === 'tool') {
|
|
156
|
+
const callId = readString(message.tool_call_id) ?? readString(message.callId);
|
|
157
|
+
if (!callId)
|
|
158
|
+
throw new Error('Tool messages must include tool_call_id.');
|
|
159
|
+
messages.push({
|
|
160
|
+
role: 'tool',
|
|
161
|
+
callId,
|
|
162
|
+
content: contentAsText(normalizeMessageContent(message.content)),
|
|
163
|
+
...(readString(message.name) ? { name: readString(message.name) } : {}),
|
|
164
|
+
});
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
throw new Error(`Unsupported message role: ${role}`);
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
messages,
|
|
171
|
+
...(systemParts.length > 0 ? { systemPrompt: systemParts.join('\n\n') } : {}),
|
|
172
|
+
...(Array.isArray(input.tools) ? { tools: normalizeTools(input.tools) } : {}),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function normalizeMessageContent(content) {
|
|
176
|
+
if (typeof content === 'string')
|
|
177
|
+
return content;
|
|
178
|
+
if (content === null || content === undefined)
|
|
179
|
+
return '';
|
|
180
|
+
if (!Array.isArray(content))
|
|
181
|
+
return String(content);
|
|
182
|
+
const parts = [];
|
|
183
|
+
const textParts = [];
|
|
184
|
+
for (const item of content) {
|
|
185
|
+
if (!isRecord(item)) {
|
|
186
|
+
textParts.push(String(item));
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
const type = readString(item.type);
|
|
190
|
+
if (type === 'text' || type === 'input_text') {
|
|
191
|
+
const text = readString(item.text);
|
|
192
|
+
if (text)
|
|
193
|
+
textParts.push(text);
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
if (type === 'image_url' && isRecord(item.image_url)) {
|
|
197
|
+
const url = readString(item.image_url.url);
|
|
198
|
+
if (url?.startsWith('data:')) {
|
|
199
|
+
const parsed = parseDataUrl(url);
|
|
200
|
+
if (parsed)
|
|
201
|
+
parts.push({ type: 'image', data: parsed.data, mediaType: parsed.mediaType });
|
|
202
|
+
}
|
|
203
|
+
else if (url) {
|
|
204
|
+
textParts.push(`[image_url: ${url}]`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (parts.length === 0)
|
|
209
|
+
return textParts.join('\n');
|
|
210
|
+
if (textParts.length > 0)
|
|
211
|
+
parts.unshift({ type: 'text', text: textParts.join('\n') });
|
|
212
|
+
return parts;
|
|
213
|
+
}
|
|
214
|
+
function contentAsText(content) {
|
|
215
|
+
if (typeof content === 'string')
|
|
216
|
+
return content;
|
|
217
|
+
return content.map((part) => part.type === 'text' ? part.text : `[image:${part.mediaType}]`).join('\n');
|
|
218
|
+
}
|
|
219
|
+
function normalizeTools(tools) {
|
|
220
|
+
const normalized = [];
|
|
221
|
+
for (const tool of tools) {
|
|
222
|
+
if (!isRecord(tool) || tool.type !== 'function' || !isRecord(tool.function))
|
|
223
|
+
continue;
|
|
224
|
+
const name = readString(tool.function.name);
|
|
225
|
+
if (!name)
|
|
226
|
+
continue;
|
|
227
|
+
normalized.push({
|
|
228
|
+
name,
|
|
229
|
+
description: readString(tool.function.description) ?? '',
|
|
230
|
+
parameters: isRecord(tool.function.parameters) ? tool.function.parameters : { type: 'object', properties: {} },
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return normalized;
|
|
234
|
+
}
|
|
235
|
+
function normalizeToolCalls(toolCalls) {
|
|
236
|
+
const normalized = [];
|
|
237
|
+
for (const call of toolCalls) {
|
|
238
|
+
if (!isRecord(call) || !isRecord(call.function))
|
|
239
|
+
continue;
|
|
240
|
+
const id = readString(call.id);
|
|
241
|
+
const name = readString(call.function.name);
|
|
242
|
+
if (!id || !name)
|
|
243
|
+
continue;
|
|
244
|
+
normalized.push({
|
|
245
|
+
id,
|
|
246
|
+
name,
|
|
247
|
+
arguments: parseToolArguments(readString(call.function.arguments) ?? '{}'),
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
return normalized;
|
|
251
|
+
}
|
|
252
|
+
function parseToolArguments(raw) {
|
|
253
|
+
try {
|
|
254
|
+
const parsed = JSON.parse(raw);
|
|
255
|
+
return isRecord(parsed) ? parsed : { value: parsed };
|
|
256
|
+
}
|
|
257
|
+
catch {
|
|
258
|
+
return { raw };
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
function readMaxTokens(input) {
|
|
262
|
+
const candidate = typeof input.max_completion_tokens === 'number'
|
|
263
|
+
? input.max_completion_tokens
|
|
264
|
+
: typeof input.max_tokens === 'number'
|
|
265
|
+
? input.max_tokens
|
|
266
|
+
: undefined;
|
|
267
|
+
return candidate !== undefined && Number.isFinite(candidate) && candidate > 0
|
|
268
|
+
? Math.floor(candidate)
|
|
269
|
+
: undefined;
|
|
270
|
+
}
|
|
271
|
+
function buildChatCompletionResponse(model, response) {
|
|
272
|
+
return {
|
|
273
|
+
id: `chatcmpl-goodvibes-${crypto.randomUUID()}`,
|
|
274
|
+
object: 'chat.completion',
|
|
275
|
+
created: Math.floor(Date.now() / 1000),
|
|
276
|
+
model,
|
|
277
|
+
choices: [{
|
|
278
|
+
index: 0,
|
|
279
|
+
message: {
|
|
280
|
+
role: 'assistant',
|
|
281
|
+
content: response.content || null,
|
|
282
|
+
...(response.toolCalls.length > 0 ? { tool_calls: response.toolCalls.map(toOpenAIToolCall) } : {}),
|
|
283
|
+
},
|
|
284
|
+
logprobs: null,
|
|
285
|
+
finish_reason: mapFinishReason(response.stopReason),
|
|
286
|
+
}],
|
|
287
|
+
usage: buildUsage(response),
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
function streamChatCompletion(input) {
|
|
291
|
+
const encoder = new TextEncoder();
|
|
292
|
+
const id = `chatcmpl-goodvibes-${crypto.randomUUID()}`;
|
|
293
|
+
const created = Math.floor(Date.now() / 1000);
|
|
294
|
+
let closed = false;
|
|
295
|
+
let streamedContent = false;
|
|
296
|
+
const stream = new ReadableStream({
|
|
297
|
+
start(controller) {
|
|
298
|
+
const send = (payload) => {
|
|
299
|
+
if (closed)
|
|
300
|
+
return;
|
|
301
|
+
controller.enqueue(encoder.encode(`data: ${payload === '[DONE]' ? payload : JSON.stringify(payload)}\n\n`));
|
|
302
|
+
};
|
|
303
|
+
send({
|
|
304
|
+
id,
|
|
305
|
+
object: 'chat.completion.chunk',
|
|
306
|
+
created,
|
|
307
|
+
model: input.resolved.responseModel,
|
|
308
|
+
choices: [{ index: 0, delta: { role: 'assistant' }, logprobs: null, finish_reason: null }],
|
|
309
|
+
});
|
|
310
|
+
const onDelta = (delta) => {
|
|
311
|
+
if (delta.content) {
|
|
312
|
+
streamedContent = true;
|
|
313
|
+
send({
|
|
314
|
+
id,
|
|
315
|
+
object: 'chat.completion.chunk',
|
|
316
|
+
created,
|
|
317
|
+
model: input.resolved.responseModel,
|
|
318
|
+
choices: [{ index: 0, delta: { content: delta.content }, logprobs: null, finish_reason: null }],
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
input.resolved.provider.chat({
|
|
323
|
+
model: input.resolved.modelId,
|
|
324
|
+
messages: input.prepared.messages,
|
|
325
|
+
...(input.prepared.tools && input.prepared.tools.length > 0 ? { tools: input.prepared.tools } : {}),
|
|
326
|
+
...(input.prepared.systemPrompt ? { systemPrompt: input.prepared.systemPrompt } : {}),
|
|
327
|
+
...(input.maxTokens !== undefined ? { maxTokens: input.maxTokens } : {}),
|
|
328
|
+
signal: input.request.signal,
|
|
329
|
+
onDelta,
|
|
330
|
+
}).then((response) => {
|
|
331
|
+
if (!streamedContent && response.content) {
|
|
332
|
+
send({
|
|
333
|
+
id,
|
|
334
|
+
object: 'chat.completion.chunk',
|
|
335
|
+
created,
|
|
336
|
+
model: input.resolved.responseModel,
|
|
337
|
+
choices: [{ index: 0, delta: { content: response.content }, logprobs: null, finish_reason: null }],
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
if (response.toolCalls.length > 0) {
|
|
341
|
+
send({
|
|
342
|
+
id,
|
|
343
|
+
object: 'chat.completion.chunk',
|
|
344
|
+
created,
|
|
345
|
+
model: input.resolved.responseModel,
|
|
346
|
+
choices: [{
|
|
347
|
+
index: 0,
|
|
348
|
+
delta: { tool_calls: response.toolCalls.map(toOpenAIToolCall) },
|
|
349
|
+
logprobs: null,
|
|
350
|
+
finish_reason: null,
|
|
351
|
+
}],
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
send({
|
|
355
|
+
id,
|
|
356
|
+
object: 'chat.completion.chunk',
|
|
357
|
+
created,
|
|
358
|
+
model: input.resolved.responseModel,
|
|
359
|
+
choices: [{ index: 0, delta: {}, logprobs: null, finish_reason: mapFinishReason(response.stopReason) }],
|
|
360
|
+
usage: buildUsage(response),
|
|
361
|
+
});
|
|
362
|
+
send('[DONE]');
|
|
363
|
+
closed = true;
|
|
364
|
+
controller.close();
|
|
365
|
+
}).catch((error) => {
|
|
366
|
+
send({ error: openAIErrorBody(summarizeError(error), 'server_error', 'provider_error') });
|
|
367
|
+
send('[DONE]');
|
|
368
|
+
closed = true;
|
|
369
|
+
controller.close();
|
|
370
|
+
});
|
|
371
|
+
},
|
|
372
|
+
cancel() {
|
|
373
|
+
closed = true;
|
|
374
|
+
},
|
|
375
|
+
});
|
|
376
|
+
return new Response(stream, {
|
|
377
|
+
headers: {
|
|
378
|
+
'content-type': 'text/event-stream; charset=utf-8',
|
|
379
|
+
'cache-control': 'no-cache',
|
|
380
|
+
connection: 'keep-alive',
|
|
381
|
+
},
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
function buildUsage(response) {
|
|
385
|
+
const promptTokens = response.usage.inputTokens + (response.usage.cacheReadTokens ?? 0) + (response.usage.cacheWriteTokens ?? 0);
|
|
386
|
+
const completionTokens = response.usage.outputTokens;
|
|
387
|
+
return {
|
|
388
|
+
prompt_tokens: promptTokens,
|
|
389
|
+
completion_tokens: completionTokens,
|
|
390
|
+
total_tokens: promptTokens + completionTokens,
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
function toOpenAIToolCall(call) {
|
|
394
|
+
return {
|
|
395
|
+
id: call.id,
|
|
396
|
+
type: 'function',
|
|
397
|
+
function: {
|
|
398
|
+
name: call.name,
|
|
399
|
+
arguments: JSON.stringify(call.arguments ?? {}),
|
|
400
|
+
},
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
function mapFinishReason(reason) {
|
|
404
|
+
if (reason === 'max_tokens')
|
|
405
|
+
return 'length';
|
|
406
|
+
if (reason === 'tool_call')
|
|
407
|
+
return 'tool_calls';
|
|
408
|
+
if (reason === 'content_filter')
|
|
409
|
+
return 'content_filter';
|
|
410
|
+
return 'stop';
|
|
411
|
+
}
|
|
412
|
+
function openAIError(message, status, type, code) {
|
|
413
|
+
return Response.json({ error: openAIErrorBody(message, type, code) }, { status });
|
|
414
|
+
}
|
|
415
|
+
function openAIErrorBody(message, type, code) {
|
|
416
|
+
return { message, type, param: null, code };
|
|
417
|
+
}
|
|
418
|
+
function openAIErrorFromResponse(response) {
|
|
419
|
+
return openAIError(response.statusText || 'Invalid request body', response.status || 400, 'invalid_request_error', 'invalid_json');
|
|
420
|
+
}
|
|
421
|
+
function modelOwnerFor(id, models, fallback) {
|
|
422
|
+
const registryMatch = models.find((model) => model.registryKey === id);
|
|
423
|
+
if (registryMatch)
|
|
424
|
+
return registryMatch.provider;
|
|
425
|
+
const plainMatch = models.find((model) => model.id === id);
|
|
426
|
+
return plainMatch?.provider ?? fallback;
|
|
427
|
+
}
|
|
428
|
+
function normalizePathPrefix(prefix) {
|
|
429
|
+
const trimmed = prefix.trim();
|
|
430
|
+
if (!trimmed || trimmed === '/')
|
|
431
|
+
return OPENAI_COMPAT_PATH_PREFIX;
|
|
432
|
+
return trimmed.startsWith('/') ? trimmed.replace(/\/+$/u, '') : `/${trimmed.replace(/\/+$/u, '')}`;
|
|
433
|
+
}
|
|
434
|
+
function parseDataUrl(value) {
|
|
435
|
+
const match = value.match(/^data:([^;,]+);base64,(.+)$/u);
|
|
436
|
+
if (!match)
|
|
437
|
+
return null;
|
|
438
|
+
return { mediaType: match[1], data: match[2] };
|
|
439
|
+
}
|
|
440
|
+
function isRecord(value) {
|
|
441
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
442
|
+
}
|
|
443
|
+
function readString(value) {
|
|
444
|
+
return typeof value === 'string' ? value : undefined;
|
|
445
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-route-contexts.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/daemon/http/router-route-contexts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAEjI,OAAO,KAAK,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC1F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AACrF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAClF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,KAAK,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a,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,cAAc,EAAE,qBAAqB,CAAC;IAC/C,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAC9C,QAAQ,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,UAAU,GAAG,QAAQ,CAAC,CAAC;IAC7E,QAAQ,CAAC,YAAY,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,QAAQ,GAAG,IAAI,CAAC;IAC7D,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;CAC7C,GAAG,uBAAuB,CA4D1B;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,6BAA6B,GAAG,6BAA6B,CAEhH"}
|
|
@@ -113,6 +113,10 @@ export function buildKnowledgeRouteContext(input) {
|
|
|
113
113
|
listJobs: () => input.knowledgeService.listJobs(),
|
|
114
114
|
getJob: (jobId) => input.knowledgeService.getJob(jobId),
|
|
115
115
|
listJobRuns: (limit, jobId) => input.knowledgeService.listJobRuns(limit, jobId),
|
|
116
|
+
listRefinementTasks: (limit, filter) => input.knowledgeService.listRefinementTasks(limit, filter),
|
|
117
|
+
getRefinementTask: (id) => input.knowledgeService.getRefinementTask(id),
|
|
118
|
+
runRefinement: (body) => input.knowledgeService.runRefinement(body),
|
|
119
|
+
cancelRefinementTask: (id) => input.knowledgeService.cancelRefinementTask(id),
|
|
116
120
|
listSchedules: (limit) => input.knowledgeService.listSchedules(limit),
|
|
117
121
|
getSchedule: (id) => input.knowledgeService.getSchedule(id),
|
|
118
122
|
ingestUrl: (body) => input.knowledgeService.ingestUrl(body),
|
|
@@ -142,6 +142,7 @@ export declare class DaemonHttpRouter {
|
|
|
142
142
|
private projectPlanningRoutes;
|
|
143
143
|
constructor(context: DaemonHttpRouterContext);
|
|
144
144
|
dispose(): void;
|
|
145
|
+
private getConfigValue;
|
|
145
146
|
handleRequest(req: Request): Promise<Response>;
|
|
146
147
|
dispatchApiRoutes(req: Request): Promise<Response | null>;
|
|
147
148
|
private getHomeAssistantRoutes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/daemon/http/router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAExE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAsE,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACvI,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAC7G,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAMpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACjI,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AACpG,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAEpI,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,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AG,OAAO,CAAC,QAAQ,CAAC;IAIlD,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;CAG5D"}
|
|
@@ -30,6 +30,7 @@ import { dispatchBatchRoutes } from './batch-routes.js';
|
|
|
30
30
|
import { dispatchCloudflareRoutes } from './cloudflare-routes.js';
|
|
31
31
|
import { HomeAssistantConversationRoutes } from './homeassistant-routes.js';
|
|
32
32
|
import { HomeGraphRoutes } from './home-graph-routes.js';
|
|
33
|
+
import { dispatchOpenAICompatibleRoutes } from './openai-compatible-routes.js';
|
|
33
34
|
import { ProjectPlanningRoutes } from './project-planning-routes.js';
|
|
34
35
|
import { readTextBodyWithinLimit } from '../../utils/request-body.js';
|
|
35
36
|
export class DaemonHttpRouter {
|
|
@@ -51,6 +52,10 @@ export class DaemonHttpRouter {
|
|
|
51
52
|
this.telemetryApi?.dispose();
|
|
52
53
|
this.context.batchManager?.dispose();
|
|
53
54
|
}
|
|
55
|
+
getConfigValue(key) {
|
|
56
|
+
const getter = this.context.configManager.get;
|
|
57
|
+
return typeof getter === 'function' ? getter.call(this.context.configManager, key) : undefined;
|
|
58
|
+
}
|
|
54
59
|
async handleRequest(req) {
|
|
55
60
|
return correlationCtx.run({ requestId: req.headers.get('x-request-id') ?? crypto.randomUUID() }, async () => {
|
|
56
61
|
const url = new URL(req.url);
|
|
@@ -126,6 +131,17 @@ export class DaemonHttpRouter {
|
|
|
126
131
|
}
|
|
127
132
|
async dispatchApiRoutes(req) {
|
|
128
133
|
const url = new URL(req.url);
|
|
134
|
+
const openAICompatibleEnabled = this.getConfigValue('controlPlane.openaiCompatible.enabled') !== false;
|
|
135
|
+
if (openAICompatibleEnabled) {
|
|
136
|
+
const pathPrefix = this.getConfigValue('controlPlane.openaiCompatible.pathPrefix');
|
|
137
|
+
const response = await dispatchOpenAICompatibleRoutes(req, {
|
|
138
|
+
providerRegistry: this.context.providerRegistry,
|
|
139
|
+
parseJsonBody: (request) => this.parseJsonBody(request),
|
|
140
|
+
recordApiResponse: (request, path, routeResponse) => this.recordApiResponse(request, path, routeResponse),
|
|
141
|
+
}, typeof pathPrefix === 'string' && pathPrefix.trim() ? pathPrefix : '/v1');
|
|
142
|
+
if (response)
|
|
143
|
+
return response;
|
|
144
|
+
}
|
|
129
145
|
if (url.pathname.startsWith('/api/batch')) {
|
|
130
146
|
if (!this.context.batchManager) {
|
|
131
147
|
return Response.json({ error: 'Batch manager is not available', code: 'BATCH_MANAGER_UNAVAILABLE' }, { status: 503 });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ask.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/knowledge/home-graph/ask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC/F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,wBAAsB,oBAAoB,CAAC,KAAK,EAAE;IAChD,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,eAAe,CAAC,EAAE,wBAAwB,CAAC;IACpD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,SAAS,qBAAqB,EAAE,CAAC;CACpD,GAAG,OAAO,CAAC,kBAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"ask.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/knowledge/home-graph/ask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC/F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,wBAAsB,oBAAoB,CAAC,KAAK,EAAE;IAChD,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,eAAe,CAAC,EAAE,wBAAwB,CAAC;IACpD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,SAAS,qBAAqB,EAAE,CAAC;CACpD,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAsD9B"}
|
|
@@ -33,6 +33,7 @@ export async function answerHomeGraphQuery(input) {
|
|
|
33
33
|
linkedObjects: answer.answer.linkedObjects,
|
|
34
34
|
facts: answer.answer.facts,
|
|
35
35
|
gaps: answer.answer.gaps,
|
|
36
|
+
refinementTaskIds: answer.answer.refinementTaskIds,
|
|
36
37
|
synthesized: answer.answer.synthesized,
|
|
37
38
|
},
|
|
38
39
|
results: input.results,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generated-pages.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/knowledge/home-graph/generated-pages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAK9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"generated-pages.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/knowledge/home-graph/generated-pages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CA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
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { materializeGeneratedKnowledgeProjection, } from '../generated-projections.js';
|
|
2
2
|
import { HOME_GRAPH_CONNECTOR_ID, buildHomeGraphMetadata, edgeIsActive, homeGraphNodeId, homeGraphSourceId, isGeneratedPageSource, namespacedCanonicalUri, readRecord, uniqueStrings, } from './helpers.js';
|
|
3
3
|
import { findHomeAssistantNode, missingDevicePassportFields, readHomeGraphState, renderHomeGraphState, safeHomeGraphFilename, sourcesLinkedToNode, } from './state.js';
|
|
4
|
-
import { renderDevicePassportPage, renderPacketPage, renderRoomPage, } from './rendering.js';
|
|
5
|
-
import { isUsefulHomeGraphPageFact } from '../semantic/fact-quality.js';
|
|
4
|
+
import { issuesForScope, renderDevicePassportPage, renderPacketPage, renderRoomPage, } from './rendering.js';
|
|
5
|
+
import { hasConcreteFeatureSignal, isLowValueFeatureOrSpecText, isUsefulHomeGraphPageFact, } from '../semantic/fact-quality.js';
|
|
6
|
+
import { normalizeWhitespace, sourceSemanticText } from '../semantic/utils.js';
|
|
6
7
|
export async function generateAutomaticHomeGraphPages(context) {
|
|
7
8
|
return generateHomeGraphPagesForCurrentState(context, context.input.pageAutomation ?? {});
|
|
8
9
|
}
|
|
@@ -92,7 +93,9 @@ export async function refreshHomeGraphDevicePassport(context) {
|
|
|
92
93
|
&& edge.relation === 'belongs_to_device'))));
|
|
93
94
|
const sources = sourcesLinkedToNode(device.id, state).filter((source) => !isGeneratedPageSource(source));
|
|
94
95
|
const semanticFacts = semanticFactsLinkedToSources(sources, state.nodes, state.edges);
|
|
95
|
-
const
|
|
96
|
+
const sourceBackedNotes = sourceBackedNotesFromLinkedSources(store, sources);
|
|
97
|
+
const scopedNodeIds = new Set([device.id, ...entities.map((node) => node.id)]);
|
|
98
|
+
const issues = issuesForScope(state.issues, state.edges, scopedNodeIds, sources);
|
|
96
99
|
const missingFields = missingDevicePassportFields(device, sources);
|
|
97
100
|
const passport = await store.upsertNode({
|
|
98
101
|
id: homeGraphNodeId(spaceId, 'ha_device_passport', input.deviceId),
|
|
@@ -117,7 +120,7 @@ export async function refreshHomeGraphDevicePassport(context) {
|
|
|
117
120
|
relation: 'source_for',
|
|
118
121
|
metadata: buildHomeGraphMetadata(spaceId, installationId),
|
|
119
122
|
});
|
|
120
|
-
const markdown = renderDevicePassportPage({ spaceId, device, entities, sources,
|
|
123
|
+
const markdown = renderDevicePassportPage({ spaceId, device, entities, sources, issues, missingFields, semanticFacts, sourceBackedNotes });
|
|
121
124
|
const generated = await materializeGeneratedMarkdown({
|
|
122
125
|
store,
|
|
123
126
|
artifactStore,
|
|
@@ -155,7 +158,7 @@ export async function generateHomeGraphRoomPage(context) {
|
|
|
155
158
|
const state = readHomeGraphState(store, spaceId);
|
|
156
159
|
const areaId = input.areaId ?? input.roomId;
|
|
157
160
|
const title = input.title ?? resolveRoomTitle(state.nodes, areaId) ?? 'Home Graph Room';
|
|
158
|
-
const markdown = renderRoomPage({ ...state, title
|
|
161
|
+
const markdown = renderRoomPage({ ...state, title }, areaId);
|
|
159
162
|
const filename = `${safeHomeGraphFilename(title)}.md`;
|
|
160
163
|
const targetNode = areaId
|
|
161
164
|
? findHomeAssistantNode(state.nodes, 'ha_area', areaId) ?? findHomeAssistantNode(state.nodes, 'ha_room', areaId)
|
|
@@ -289,6 +292,22 @@ function semanticFactsLinkedToSources(sources, nodes, edges) {
|
|
|
289
292
|
&& edge.relation === 'supports_fact')).map((edge) => edge.toId));
|
|
290
293
|
return nodes.filter((node) => factIds.has(node.id) && isUsefulHomeGraphPageFact(node));
|
|
291
294
|
}
|
|
295
|
+
function sourceBackedNotesFromLinkedSources(store, sources) {
|
|
296
|
+
const notes = [];
|
|
297
|
+
for (const source of sources) {
|
|
298
|
+
const extraction = store.getExtractionBySourceId(source.id);
|
|
299
|
+
notes.push(...extractSourceBackedNotes(sourceSemanticText(source, extraction)));
|
|
300
|
+
}
|
|
301
|
+
return uniqueStrings(notes).slice(0, 24);
|
|
302
|
+
}
|
|
303
|
+
function extractSourceBackedNotes(text) {
|
|
304
|
+
return normalizeWhitespace(text)
|
|
305
|
+
.split(/(?:[.!?]\s+|\n+)/)
|
|
306
|
+
.map((part) => normalizeWhitespace(part.replace(/^[-*•]\s*/, '')))
|
|
307
|
+
.filter((part) => part.length >= 24 && part.length <= 420)
|
|
308
|
+
.filter((part) => hasConcreteFeatureSignal(part))
|
|
309
|
+
.filter((part) => !isLowValueFeatureOrSpecText(part));
|
|
310
|
+
}
|
|
292
311
|
function limitRecords(records, limit) {
|
|
293
312
|
if (typeof limit !== 'number')
|
|
294
313
|
return records;
|