@myagentroam/agent 0.9.118 → 0.9.119
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.
|
@@ -122,6 +122,11 @@ export type ModelEvent = {
|
|
|
122
122
|
query?: string | undefined;
|
|
123
123
|
url?: string | undefined;
|
|
124
124
|
title?: string | undefined;
|
|
125
|
+
sources?: readonly {
|
|
126
|
+
url: string;
|
|
127
|
+
title?: string | undefined;
|
|
128
|
+
}[] | undefined;
|
|
129
|
+
sourcesTruncated?: boolean | undefined;
|
|
125
130
|
};
|
|
126
131
|
} | {
|
|
127
132
|
type: 'citation';
|
|
@@ -282,6 +282,7 @@ export class OpenAiResponsesAdapter {
|
|
|
282
282
|
const pendingCompletedText = new Map();
|
|
283
283
|
const emittedCompletedText = new Set();
|
|
284
284
|
const emittedFunctionCalls = new Set();
|
|
285
|
+
const hostedWebCalls = new Map();
|
|
285
286
|
try {
|
|
286
287
|
for await (const raw of rawEvents) {
|
|
287
288
|
const event = record(raw);
|
|
@@ -427,20 +428,25 @@ export class OpenAiResponsesAdapter {
|
|
|
427
428
|
else if (type.includes('web_search_call') ||
|
|
428
429
|
text(record(event.item).type) === 'web_search_call') {
|
|
429
430
|
const item = record(event.item);
|
|
431
|
+
const itemId = text(event.item_id) ?? text(item.id) ?? 'web';
|
|
432
|
+
const previous = hostedWebCalls.get(itemId);
|
|
430
433
|
const action = record(Object.keys(record(event.action)).length ? event.action : item.action);
|
|
431
434
|
const actionType = text(action.type);
|
|
435
|
+
const kind = actionType === 'open_page' || actionType === 'find_in_page'
|
|
436
|
+
? 'WEB_FETCH'
|
|
437
|
+
: (previous?.kind ?? 'WEB_SEARCH');
|
|
438
|
+
const summary = { ...previous?.summary, ...hostedWebActionSummary(action) };
|
|
439
|
+
hostedWebCalls.set(itemId, { kind, summary });
|
|
432
440
|
yield {
|
|
433
441
|
type: 'hosted_tool',
|
|
434
|
-
itemId
|
|
435
|
-
kind
|
|
436
|
-
? 'WEB_FETCH'
|
|
437
|
-
: 'WEB_SEARCH',
|
|
442
|
+
itemId,
|
|
443
|
+
kind,
|
|
438
444
|
status: type.endsWith('.failed')
|
|
439
445
|
? 'FAILED'
|
|
440
446
|
: type.endsWith('.completed') || type === 'response.output_item.done'
|
|
441
447
|
? 'COMPLETED'
|
|
442
448
|
: 'RUNNING',
|
|
443
|
-
summary
|
|
449
|
+
summary
|
|
444
450
|
};
|
|
445
451
|
}
|
|
446
452
|
else if (type === 'response.output_text.annotation.added') {
|
|
@@ -884,7 +890,12 @@ function responsesRequestBody(configuration, request, messages, prefixIdentity =
|
|
|
884
890
|
parallel_tool_calls: !lite,
|
|
885
891
|
store: false,
|
|
886
892
|
text: { verbosity: 'low' },
|
|
887
|
-
include: [
|
|
893
|
+
include: [
|
|
894
|
+
'reasoning.encrypted_content',
|
|
895
|
+
...(configuration.hostedWebSearch && request.allowTools !== false && toolChoice !== 'none'
|
|
896
|
+
? ['web_search_call.action.sources']
|
|
897
|
+
: [])
|
|
898
|
+
],
|
|
888
899
|
...(request.promptCacheKey ? { prompt_cache_key: request.promptCacheKey } : {}),
|
|
889
900
|
reasoning: {
|
|
890
901
|
effort: request.requestReasoningEffort?.trim() ||
|
|
@@ -1512,6 +1523,41 @@ const RESPONSE_ITEM_TYPES = new Set([
|
|
|
1512
1523
|
]);
|
|
1513
1524
|
// A freeform patch item can contain the complete 4 MiB patch plus its JSON envelope.
|
|
1514
1525
|
const MAX_RESPONSE_ITEM_BYTES = 5 * 1024 * 1024;
|
|
1526
|
+
function hostedWebActionSummary(action) {
|
|
1527
|
+
const queries = Array.isArray(action.queries)
|
|
1528
|
+
? action.queries
|
|
1529
|
+
.slice(0, 10)
|
|
1530
|
+
.filter((query) => typeof query === 'string' && query.length > 0)
|
|
1531
|
+
: [];
|
|
1532
|
+
const query = text(action.query) || queries.join('\n');
|
|
1533
|
+
const url = text(action.url);
|
|
1534
|
+
const title = text(action.title);
|
|
1535
|
+
const sources = Array.isArray(action.sources)
|
|
1536
|
+
? action.sources
|
|
1537
|
+
.slice(0, 20)
|
|
1538
|
+
.map((source) => {
|
|
1539
|
+
const value = record(source);
|
|
1540
|
+
const sourceUrl = text(value.url);
|
|
1541
|
+
if (!sourceUrl)
|
|
1542
|
+
return undefined;
|
|
1543
|
+
const sourceTitle = text(value.title);
|
|
1544
|
+
return {
|
|
1545
|
+
url: sourceUrl.slice(0, 2048),
|
|
1546
|
+
...(sourceTitle ? { title: sourceTitle.slice(0, 256) } : {})
|
|
1547
|
+
};
|
|
1548
|
+
})
|
|
1549
|
+
.filter((source) => source !== undefined)
|
|
1550
|
+
: [];
|
|
1551
|
+
return {
|
|
1552
|
+
...(query ? { query: query.slice(0, 10_000) } : {}),
|
|
1553
|
+
...(url ? { url: url.slice(0, 2048) } : {}),
|
|
1554
|
+
...(title ? { title: title.slice(0, 256) } : {}),
|
|
1555
|
+
...(sources.length ? { sources } : {}),
|
|
1556
|
+
...(Array.isArray(action.sources) && action.sources.length > 20
|
|
1557
|
+
? { sourcesTruncated: true }
|
|
1558
|
+
: {})
|
|
1559
|
+
};
|
|
1560
|
+
}
|
|
1515
1561
|
function responseItem(value) {
|
|
1516
1562
|
const item = record(value);
|
|
1517
1563
|
const itemType = text(item.type);
|
package/dist/sdk/types.d.ts
CHANGED
|
@@ -122,6 +122,11 @@ export type MarAgentEvent = MarAgentEventBase & ({
|
|
|
122
122
|
query?: string | undefined;
|
|
123
123
|
url?: string | undefined;
|
|
124
124
|
title?: string | undefined;
|
|
125
|
+
sources?: readonly {
|
|
126
|
+
url: string;
|
|
127
|
+
title?: string | undefined;
|
|
128
|
+
}[] | undefined;
|
|
129
|
+
sourcesTruncated?: boolean | undefined;
|
|
125
130
|
};
|
|
126
131
|
} | {
|
|
127
132
|
type: 'citation.added';
|