newmark-agent 0.5.14 → 0.6.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/conversation-utility-host.bundle.cjs +4565 -2998
- package/dist/conversation-utility-host.js +1 -1
- package/dist/core/agent.d.ts +108 -16
- package/dist/core/agent.js +698 -195
- package/dist/core/agentKernel/agent.d.ts +1 -0
- package/dist/core/agentKernel/agent.js +9 -0
- package/dist/core/agentKernelDiagnostics.d.ts +4 -6
- package/dist/core/agentKernelDiagnostics.js +12 -9
- package/dist/core/agentKernelRunner.d.ts +5 -0
- package/dist/core/agentKernelRunner.js +250 -107
- package/dist/core/autoRouter.js +17 -27
- package/dist/core/config.d.ts +2 -0
- package/dist/core/config.js +7 -1
- package/dist/core/conversationCommandState.d.ts +17 -0
- package/dist/core/conversationCommandState.js +140 -0
- package/dist/core/conversationKernel.d.ts +25 -4
- package/dist/core/conversationKernel.js +360 -89
- package/dist/core/conversationListEvent.d.ts +6 -0
- package/dist/core/conversationListEvent.js +14 -0
- package/dist/core/electronUtilityAgentClient.d.ts +4 -1
- package/dist/core/electronUtilityAgentClient.js +4 -4
- package/dist/core/electronUtilityRuntimePool.d.ts +8 -2
- package/dist/core/electronUtilityRuntimePool.js +11 -5
- package/dist/core/installUpdate.js +41 -29
- package/dist/core/modelResponseHealth.d.ts +17 -0
- package/dist/core/modelResponseHealth.js +193 -0
- package/dist/core/providerUsageAccounting.d.ts +47 -0
- package/dist/core/providerUsageAccounting.js +71 -0
- package/dist/core/requestContextEstimate.d.ts +18 -0
- package/dist/core/requestContextEstimate.js +54 -0
- package/dist/core/subagent.d.ts +89 -5
- package/dist/core/subagent.js +264 -41
- package/dist/core/subagentCommunication.d.ts +43 -0
- package/dist/core/subagentCommunication.js +167 -0
- package/dist/core/types.d.ts +34 -1
- package/dist/core/utilityAgentProtocol.d.ts +4 -0
- package/dist/core/workEventCoalescer.js +4 -1
- package/dist/core/wslAgentClient.d.ts +18 -5
- package/dist/core/wslAgentClient.js +79 -27
- package/dist/core/wslAgentProtocol.d.ts +7 -0
- package/dist/core/wslAgentRuntimePool.d.ts +8 -2
- package/dist/core/wslAgentRuntimePool.js +19 -6
- package/dist/core/wslRuntimeProcessTree.d.ts +10 -0
- package/dist/core/wslRuntimeProcessTree.js +104 -0
- package/dist/llm/provider.d.ts +5 -12
- package/dist/llm/provider.js +150 -269
- package/dist/main.js +582 -356
- package/dist/preload.js +3 -3
- package/dist/providers/chat-completions.adapter.d.ts +2 -0
- package/dist/providers/chat-completions.adapter.js +84 -36
- package/dist/providers/provider-adapter.d.ts +2 -0
- package/dist/providers/provider-events.d.ts +23 -14
- package/dist/providers/provider-events.js +148 -43
- package/dist/providers/provider-headers.d.ts +7 -3
- package/dist/providers/provider-headers.js +109 -39
- package/dist/providers/provider-request-compat.d.ts +6 -0
- package/dist/providers/provider-request-compat.js +37 -0
- package/dist/providers/responses.adapter.d.ts +2 -0
- package/dist/providers/responses.adapter.js +192 -126
- package/dist/server.d.ts +9 -2
- package/dist/server.js +100 -24
- package/dist/tools/index.js +17 -1
- package/dist/ui/index.html +2515 -693
- package/dist/ui/lucide-sprite.svg +7 -0
- package/dist/ui/startup.html +6 -6
- package/dist/wsl-agent-host.bundle.cjs +4575 -3006
- package/dist/wsl-agent-host.js +9 -4
- package/package.json +23 -4
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ResponsesAdapter = void 0;
|
|
4
4
|
const provider_events_1 = require("./provider-events");
|
|
5
5
|
const provider_headers_1 = require("./provider-headers");
|
|
6
|
+
const provider_request_compat_1 = require("./provider-request-compat");
|
|
6
7
|
const chat_messages_1 = require("./chat-messages");
|
|
7
8
|
/**
|
|
8
9
|
* OpenAI Responses adapter. Serializes a normalized request to `/responses`
|
|
@@ -80,13 +81,9 @@ class ResponsesAdapter {
|
|
|
80
81
|
body.tool_choice = 'auto';
|
|
81
82
|
body.parallel_tool_calls = true;
|
|
82
83
|
}
|
|
83
|
-
const base = request.baseUrl.replace(/\/+$/, '');
|
|
84
84
|
return {
|
|
85
|
-
url:
|
|
86
|
-
headers:
|
|
87
|
-
'Content-Type': 'application/json',
|
|
88
|
-
'Authorization': `Bearer ${request.apiKey}`,
|
|
89
|
-
},
|
|
85
|
+
url: (0, provider_request_compat_1.providerEndpoint)(request.baseUrl, '/responses'),
|
|
86
|
+
headers: (0, provider_request_compat_1.providerRequestHeaders)('openai', request.apiKey),
|
|
90
87
|
body,
|
|
91
88
|
};
|
|
92
89
|
}
|
|
@@ -116,7 +113,7 @@ class ResponsesAdapter {
|
|
|
116
113
|
const contentType = response.headers.get('content-type') || '';
|
|
117
114
|
if (!/text\/event-stream/i.test(contentType)) {
|
|
118
115
|
const json = (0, provider_events_1.normalizeResponsesPayload)(await response.json());
|
|
119
|
-
yield* this.emitNonStreaming(json);
|
|
116
|
+
yield* this.emitNonStreaming(json, response.headers);
|
|
120
117
|
return;
|
|
121
118
|
}
|
|
122
119
|
const reader = response.body?.getReader();
|
|
@@ -125,132 +122,165 @@ class ResponsesAdapter {
|
|
|
125
122
|
return;
|
|
126
123
|
}
|
|
127
124
|
const decoder = new TextDecoder();
|
|
128
|
-
|
|
125
|
+
const sse = new provider_events_1.ProviderSseDecoder();
|
|
129
126
|
const calls = new Map();
|
|
127
|
+
const callAliases = new Map();
|
|
128
|
+
const resolveCall = (payload, item = {}) => {
|
|
129
|
+
const aliases = [];
|
|
130
|
+
const itemId = item.id ?? payload.item_id;
|
|
131
|
+
const callId = item.call_id ?? payload.call_id;
|
|
132
|
+
if (itemId)
|
|
133
|
+
aliases.push(`item:${itemId}`);
|
|
134
|
+
if (callId)
|
|
135
|
+
aliases.push(`call:${callId}`);
|
|
136
|
+
if (payload.output_index !== undefined)
|
|
137
|
+
aliases.push(`index:${payload.output_index}`);
|
|
138
|
+
const key = aliases.map(alias => callAliases.get(alias)).find(value => value !== undefined) ?? `call_${calls.size}`;
|
|
139
|
+
const call = calls.get(key) || { id: String(callId || itemId || ''), name: '', argumentParts: [] };
|
|
140
|
+
if (callId)
|
|
141
|
+
call.id = String(callId);
|
|
142
|
+
if (item.name || payload.name)
|
|
143
|
+
call.name = String(item.name || payload.name);
|
|
144
|
+
calls.set(key, call);
|
|
145
|
+
for (const alias of aliases)
|
|
146
|
+
callAliases.set(alias, key);
|
|
147
|
+
return call;
|
|
148
|
+
};
|
|
130
149
|
const reasoningSummaries = new Map();
|
|
131
150
|
let emittedContent = false;
|
|
132
151
|
let completed = false;
|
|
133
152
|
let streamError = '';
|
|
153
|
+
let completedResponse;
|
|
154
|
+
let emittedText = '';
|
|
134
155
|
try {
|
|
135
|
-
while (true) {
|
|
156
|
+
stream: while (true) {
|
|
136
157
|
const { done, value } = await (0, provider_events_1.readProviderStreamChunk)(reader, signal);
|
|
137
158
|
if (done)
|
|
138
159
|
break;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if (delta) {
|
|
158
|
-
emittedContent = true;
|
|
159
|
-
reasoningSummaries.set(key, (reasoningSummaries.get(key) || '') + delta);
|
|
160
|
-
yield { type: 'reasoning.summary.delta', delta };
|
|
161
|
-
}
|
|
162
|
-
continue;
|
|
163
|
-
}
|
|
164
|
-
if (eventType === 'response.reasoning_summary_text.done') {
|
|
165
|
-
const key = `${String(payload.item_id || '')}:${String(payload.summary_index || 0)}`;
|
|
166
|
-
const summary = this.extractText(payload.text) || reasoningSummaries.get(key) || '';
|
|
167
|
-
reasoningSummaries.delete(key);
|
|
168
|
-
if (summary) {
|
|
169
|
-
emittedContent = true;
|
|
170
|
-
yield { type: 'reasoning.summary.done', summary };
|
|
171
|
-
}
|
|
172
|
-
continue;
|
|
173
|
-
}
|
|
174
|
-
if (eventType === 'response.output_text.delta') {
|
|
175
|
-
const delta = this.extractText(payload.delta);
|
|
176
|
-
if (delta) {
|
|
177
|
-
emittedContent = true;
|
|
178
|
-
yield { type: 'text.delta', delta };
|
|
179
|
-
}
|
|
180
|
-
continue;
|
|
181
|
-
}
|
|
182
|
-
if (eventType === 'response.output_item.added') {
|
|
183
|
-
const item = payload.item;
|
|
184
|
-
if (item?.type === 'function_call') {
|
|
185
|
-
const key = String(item.id || item.call_id || calls.size);
|
|
186
|
-
calls.set(key, {
|
|
187
|
-
id: String(item.call_id || item.id || key),
|
|
188
|
-
name: String(item.name || ''),
|
|
189
|
-
argumentParts: item.arguments ? [String(item.arguments)] : [],
|
|
190
|
-
emitted: false,
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
continue;
|
|
160
|
+
for (const event of sse.push(decoder.decode(value, { stream: true }))) {
|
|
161
|
+
if (event.data === '[DONE]')
|
|
162
|
+
continue;
|
|
163
|
+
let payload;
|
|
164
|
+
try {
|
|
165
|
+
payload = JSON.parse(event.data);
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
const eventType = String(event.event || payload.type || '');
|
|
171
|
+
if (eventType === 'response.reasoning_summary_text.delta') {
|
|
172
|
+
const key = `${String(payload.item_id || '')}:${String(payload.summary_index || 0)}`;
|
|
173
|
+
const delta = this.extractText(payload.delta);
|
|
174
|
+
if (delta) {
|
|
175
|
+
emittedContent = true;
|
|
176
|
+
reasoningSummaries.set(key, (reasoningSummaries.get(key) || '') + delta);
|
|
177
|
+
yield { type: 'reasoning.summary.delta', delta };
|
|
194
178
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (eventType === 'response.reasoning_summary_text.done') {
|
|
182
|
+
const key = `${String(payload.item_id || '')}:${String(payload.summary_index || 0)}`;
|
|
183
|
+
const summary = this.extractText(payload.text) || reasoningSummaries.get(key) || '';
|
|
184
|
+
reasoningSummaries.delete(key);
|
|
185
|
+
if (summary) {
|
|
186
|
+
emittedContent = true;
|
|
187
|
+
yield { type: 'reasoning.summary.done', summary };
|
|
204
188
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
emitted: false,
|
|
214
|
-
};
|
|
215
|
-
call.id = String(item.call_id || call.id);
|
|
216
|
-
call.name = String(item.name || call.name);
|
|
217
|
-
if (typeof item.arguments === 'string' && item.arguments)
|
|
218
|
-
call.argumentParts.push(item.arguments);
|
|
219
|
-
if (!call.emitted) {
|
|
220
|
-
call.emitted = true;
|
|
221
|
-
const argumentsJson = (0, provider_events_1.assembleCompatibleToolArguments)(call.argumentParts);
|
|
222
|
-
yield { type: 'tool_call.started', id: call.id, name: call.name };
|
|
223
|
-
if (argumentsJson !== '{}') {
|
|
224
|
-
yield { type: 'tool_call.arguments.delta', id: call.id, delta: argumentsJson };
|
|
225
|
-
}
|
|
226
|
-
yield { type: 'tool_call.completed', id: call.id, name: call.name, arguments: argumentsJson };
|
|
227
|
-
}
|
|
228
|
-
calls.set(key, call);
|
|
229
|
-
}
|
|
230
|
-
continue;
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (eventType === 'response.output_text.delta') {
|
|
192
|
+
const delta = this.extractText(payload.delta);
|
|
193
|
+
if (delta) {
|
|
194
|
+
emittedContent = true;
|
|
195
|
+
emittedText += delta;
|
|
196
|
+
yield { type: 'text.delta', delta };
|
|
231
197
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
if (eventType === 'response.output_item.added') {
|
|
201
|
+
const item = payload.item;
|
|
202
|
+
if (item?.type === 'function_call') {
|
|
203
|
+
const call = resolveCall(payload, item);
|
|
204
|
+
if (item.arguments)
|
|
205
|
+
call.argumentParts.push(String(item.arguments));
|
|
206
|
+
call.status = String(item.status || '');
|
|
238
207
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
if (eventType === 'response.function_call_arguments.delta') {
|
|
211
|
+
const call = resolveCall(payload);
|
|
212
|
+
const delta = String(payload.delta || '');
|
|
213
|
+
if (delta)
|
|
214
|
+
call.argumentParts.push(delta);
|
|
215
|
+
yield { type: 'tool_call.arguments.delta', id: call.id, delta };
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
if (eventType === 'response.function_call_arguments.done') {
|
|
219
|
+
const call = resolveCall(payload);
|
|
220
|
+
if (payload.name)
|
|
221
|
+
call.name = String(payload.name);
|
|
222
|
+
if (typeof payload.arguments === 'string')
|
|
223
|
+
call.finalArguments = payload.arguments;
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
if (eventType === 'response.output_item.done') {
|
|
227
|
+
const item = payload.item;
|
|
228
|
+
if (item?.type === 'function_call') {
|
|
229
|
+
const call = resolveCall(payload, item);
|
|
230
|
+
call.id = String(item.call_id || call.id);
|
|
231
|
+
call.name = String(item.name || call.name);
|
|
232
|
+
if (typeof item.arguments === 'string')
|
|
233
|
+
call.finalArguments = item.arguments;
|
|
234
|
+
call.status = String(item.status || '');
|
|
248
235
|
}
|
|
236
|
+
continue;
|
|
249
237
|
}
|
|
238
|
+
if (eventType === 'response.completed') {
|
|
239
|
+
completedResponse = (0, provider_events_1.normalizeResponsesPayload)(payload.response ?? payload);
|
|
240
|
+
streamError = this.completionError(completedResponse, response.headers);
|
|
241
|
+
completed = !streamError;
|
|
242
|
+
const usage = this.normalizeUsage(completedResponse);
|
|
243
|
+
if (usage)
|
|
244
|
+
yield { type: 'usage.updated', usage };
|
|
245
|
+
break stream;
|
|
246
|
+
}
|
|
247
|
+
if (eventType === 'response.failed' || eventType === 'response.incomplete' || eventType === 'error') {
|
|
248
|
+
const usage = this.normalizeUsage(payload.response ?? payload);
|
|
249
|
+
if (usage)
|
|
250
|
+
yield { type: 'usage.updated', usage };
|
|
251
|
+
const errorPayload = payload.error || {};
|
|
252
|
+
const responseObj = payload.response && typeof payload.response === 'object'
|
|
253
|
+
? payload.response.error
|
|
254
|
+
: undefined;
|
|
255
|
+
streamError = (0, provider_events_1.providerSemanticErrorText)(payload.error || responseObj || payload, this.extractText(errorPayload.message)
|
|
256
|
+
|| this.extractText(responseObj?.message)
|
|
257
|
+
|| this.extractText(payload.message)
|
|
258
|
+
|| eventType, response.headers);
|
|
259
|
+
break stream;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (completedResponse && completed) {
|
|
264
|
+
const snapshotText = this.extractResponsesText(completedResponse);
|
|
265
|
+
if (snapshotText && snapshotText.startsWith(emittedText) && snapshotText.length > emittedText.length) {
|
|
266
|
+
yield { type: 'text.delta', delta: snapshotText.slice(emittedText.length) };
|
|
267
|
+
emittedText = snapshotText;
|
|
268
|
+
emittedContent = true;
|
|
269
|
+
}
|
|
270
|
+
for (const raw of Array.isArray(completedResponse.output) ? completedResponse.output : []) {
|
|
271
|
+
const item = raw;
|
|
272
|
+
if (item.type !== 'function_call')
|
|
273
|
+
continue;
|
|
274
|
+
const call = resolveCall({}, item);
|
|
275
|
+
call.id = String(item.call_id || call.id);
|
|
276
|
+
call.name = String(item.name || call.name);
|
|
277
|
+
if (typeof item.arguments === 'string')
|
|
278
|
+
call.finalArguments = item.arguments;
|
|
279
|
+
call.status = String(item.status || '');
|
|
250
280
|
}
|
|
251
281
|
}
|
|
252
282
|
if (streamError) {
|
|
253
|
-
yield { type: 'response.failed', error: `[LLM Error] ${streamError}` };
|
|
283
|
+
yield { type: 'response.failed', error: streamError.startsWith('[LLM Error]') ? streamError : `[LLM Error] ${streamError}` };
|
|
254
284
|
}
|
|
255
285
|
else if (!completed) {
|
|
256
286
|
yield { type: 'response.failed', error: '[LLM Error] Responses stream ended before response.completed.' };
|
|
@@ -262,21 +292,30 @@ class ResponsesAdapter {
|
|
|
262
292
|
// Some compatible Responses providers omit output_item.done but still
|
|
263
293
|
// complete the response. Preserve that valid tool activity and fold
|
|
264
294
|
// cumulative argument snapshots before handing it to the kernel.
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
295
|
+
const completeCalls = [...calls.values()].map(call => ({ ...call,
|
|
296
|
+
argumentsJson: call.finalArguments ?? (0, provider_events_1.assembleCompatibleToolArguments)(call.argumentParts, true) }));
|
|
297
|
+
if (completeCalls.some(call => !call.id || !call.name || call.status === 'incomplete' || !this.validToolArguments(call.argumentsJson))) {
|
|
298
|
+
yield { type: 'response.failed', error: '[LLM Error] Provider returned incomplete or invalid tool-call arguments.' };
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
for (const call of completeCalls) {
|
|
269
302
|
yield { type: 'tool_call.started', id: call.id, name: call.name };
|
|
270
|
-
yield { type: 'tool_call.completed', id: call.id, name: call.name, arguments: argumentsJson };
|
|
303
|
+
yield { type: 'tool_call.completed', id: call.id, name: call.name, arguments: call.argumentsJson };
|
|
271
304
|
}
|
|
272
305
|
yield { type: 'response.completed' };
|
|
273
306
|
}
|
|
274
307
|
}
|
|
275
308
|
finally {
|
|
309
|
+
// Completion and consumer return are terminal even if a gateway keeps
|
|
310
|
+
// the HTTP body open. Release the socket as well as the reader lock.
|
|
311
|
+
try {
|
|
312
|
+
await reader.cancel();
|
|
313
|
+
}
|
|
314
|
+
catch { }
|
|
276
315
|
reader.releaseLock();
|
|
277
316
|
}
|
|
278
317
|
}
|
|
279
|
-
async *emitNonStreaming(json) {
|
|
318
|
+
async *emitNonStreaming(json, headers) {
|
|
280
319
|
const usage = this.normalizeUsage(json.usage ?? json.response ?? json);
|
|
281
320
|
if (usage)
|
|
282
321
|
yield { type: 'usage.updated', usage };
|
|
@@ -289,15 +328,25 @@ class ResponsesAdapter {
|
|
|
289
328
|
emitted = true;
|
|
290
329
|
yield { type: 'text.delta', delta: text };
|
|
291
330
|
}
|
|
292
|
-
|
|
331
|
+
const error = this.completionError(json, headers);
|
|
332
|
+
if (error) {
|
|
333
|
+
yield { type: 'response.failed', error };
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
const completeCalls = (Array.isArray(json.output) ? json.output : []).filter(item => item?.type === 'function_call').map(itemRaw => {
|
|
293
337
|
const item = itemRaw;
|
|
294
|
-
if (item.type !== 'function_call')
|
|
295
|
-
continue;
|
|
296
|
-
emitted = true;
|
|
297
338
|
const id = String(item.call_id || item.id || '');
|
|
298
339
|
const name = String(item.name || '');
|
|
340
|
+
const args = typeof item.arguments === 'string' ? item.arguments : item.arguments ? JSON.stringify(item.arguments) : '';
|
|
341
|
+
return { id, name, args, status: String(item.status || '') };
|
|
342
|
+
});
|
|
343
|
+
if (completeCalls.some(call => !call.id || !call.name || call.status === 'incomplete' || !this.validToolArguments(call.args))) {
|
|
344
|
+
yield { type: 'response.failed', error: '[LLM Error] Provider returned incomplete or invalid tool-call arguments.' };
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
for (const { id, name, args } of completeCalls) {
|
|
348
|
+
emitted = true;
|
|
299
349
|
yield { type: 'tool_call.started', id, name };
|
|
300
|
-
const args = typeof item.arguments === 'string' ? item.arguments : JSON.stringify(item.arguments || {});
|
|
301
350
|
if (args && args !== '{}')
|
|
302
351
|
yield { type: 'tool_call.arguments.delta', id, delta: args };
|
|
303
352
|
yield { type: 'tool_call.completed', id, name, arguments: args };
|
|
@@ -311,6 +360,23 @@ class ResponsesAdapter {
|
|
|
311
360
|
normalizeUsage(value) {
|
|
312
361
|
return (0, provider_events_1.normalizeProviderUsage)(value);
|
|
313
362
|
}
|
|
363
|
+
completionError(json, headers) {
|
|
364
|
+
const status = String(json.status || '');
|
|
365
|
+
if (!json.error && (!status || status === 'completed'))
|
|
366
|
+
return '';
|
|
367
|
+
const error = json.error && typeof json.error === 'object' ? json.error : {};
|
|
368
|
+
const incomplete = json.incomplete_details && typeof json.incomplete_details === 'object' ? json.incomplete_details : {};
|
|
369
|
+
return (0, provider_events_1.providerSemanticErrorText)(error, this.extractText(error.message || json.error) || `Responses response was ${status || 'unsuccessful'}${incomplete.reason ? ': ' + String(incomplete.reason) : '.'}`, headers);
|
|
370
|
+
}
|
|
371
|
+
validToolArguments(value) {
|
|
372
|
+
try {
|
|
373
|
+
const parsed = JSON.parse(value);
|
|
374
|
+
return !!parsed && typeof parsed === 'object' && !Array.isArray(parsed);
|
|
375
|
+
}
|
|
376
|
+
catch {
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
314
380
|
normalizeHeaders(headers) {
|
|
315
381
|
return (0, provider_headers_1.normalizeProviderHeaders)(headers);
|
|
316
382
|
}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Agent, AgentWorkEvent } from './core/agent';
|
|
2
2
|
import { AutomationManager } from './core/automation';
|
|
3
|
+
import type { AgentPromptMessage } from './core/conversationKernel';
|
|
3
4
|
export interface HostedMobileServerOptions {
|
|
4
5
|
agent?: Agent;
|
|
5
6
|
automation?: AutomationManager | null;
|
|
@@ -11,20 +12,26 @@ export interface HostedMobileServerOptions {
|
|
|
11
12
|
conversationUiState?: (target: {
|
|
12
13
|
workspaceId: string;
|
|
13
14
|
conversationId: string;
|
|
15
|
+
}, options?: {
|
|
16
|
+
window?: number;
|
|
17
|
+
before?: number;
|
|
14
18
|
}) => Promise<Record<string, unknown>>;
|
|
15
19
|
/** Mutate Goal/Flow state owned by the GUI runtime pool for one exact target. */
|
|
16
20
|
conversationUiAction?: (target: {
|
|
17
21
|
workspaceId: string;
|
|
18
22
|
conversationId: string;
|
|
19
|
-
}, action: 'goal_update' | 'goal_guide' | 'conversation_guide' | 'goal_toggle_pause' | 'goal_clear' | 'flow_pause' | 'flow_resume' | 'flow_guide' | 'conversation_stop' | 'input_mode' | 'queue_enqueue' | 'queue_update' | 'queue_delete' | 'queue_reorder' | 'queue_toggle_pause' | 'queue_guide', value?: string, input?: Record<string, unknown>) => Promise<Record<string, unknown>>;
|
|
23
|
+
}, action: 'goal_update' | 'goal_guide' | 'conversation_guide' | 'goal_toggle_pause' | 'goal_clear' | 'flow_pause' | 'flow_resume' | 'flow_guide' | 'conversation_stop' | 'mode' | 'input_mode' | 'queue_enqueue' | 'queue_update' | 'queue_delete' | 'queue_reorder' | 'queue_toggle_pause' | 'queue_set_pause' | 'queue_guide' | 'conversation_branch_inspect' | 'conversation_branch_activate' | 'conversation_branch_create' | 'conversation_archive', value?: string, input?: Record<string, unknown>) => Promise<Record<string, unknown>>;
|
|
20
24
|
/** Send through the same GUI runtime pool used by the desktop renderer. */
|
|
21
25
|
conversationPrompt?: (target: {
|
|
22
26
|
workspaceId: string;
|
|
23
27
|
conversationId: string;
|
|
24
|
-
}, message: string, options?: {
|
|
28
|
+
}, message: string | AgentPromptMessage, options?: {
|
|
25
29
|
requestedMode?: string;
|
|
26
30
|
goalObjective?: string;
|
|
27
31
|
inputMode?: string;
|
|
32
|
+
clientMessageId?: string;
|
|
33
|
+
flowName?: string;
|
|
34
|
+
flowStart?: number;
|
|
28
35
|
}) => Promise<Record<string, unknown>>;
|
|
29
36
|
}
|
|
30
37
|
export interface HostedMobileServerStatus {
|