@ykurilov/agent-chat-core 0.70.1 → 0.71.1
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/CHANGELOG.md +10 -0
- package/dist/{chunk-EL2KSERW.js → chunk-YMUK7P4S.js} +32 -8
- package/dist/chunk-YMUK7P4S.js.map +1 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/storage-contract.js +1 -1
- package/dist/types/conversation/answer-reasoning.d.ts +6 -0
- package/dist/types/conversation/types.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/models/model-catalog.d.ts +5 -0
- package/dist/types/models/model-choice.d.ts +7 -0
- package/package.json +1 -1
- package/dist/chunk-EL2KSERW.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @ykurilov/agent-chat-core
|
|
2
2
|
|
|
3
|
+
## 0.71.1
|
|
4
|
+
|
|
5
|
+
No changes in this release.
|
|
6
|
+
|
|
7
|
+
## 0.71.0
|
|
8
|
+
|
|
9
|
+
### Minor Changes
|
|
10
|
+
|
|
11
|
+
- 8b8c651: Три вида поля Одуванчик: сжатое, обычное и расширенное. Настройки модели/провайдера/рассуждений из каталога, цена и метки, инструменты приложения, шторка телефона. Сфера и токены из опубликованных ds-react/ds-tokens. Необязательный договор скина v29, сохранение уровня ответа для подписи в истории.
|
|
12
|
+
|
|
3
13
|
## 0.70.1
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -5625,6 +5625,22 @@ function parseNestedJson(text, schema, tally) {
|
|
|
5625
5625
|
return coerceBySchema(parsed.value, schema, tally);
|
|
5626
5626
|
}
|
|
5627
5627
|
|
|
5628
|
+
// src/conversation/answer-reasoning.ts
|
|
5629
|
+
var ANSWER_REASONING_PART = "data-answer-reasoning";
|
|
5630
|
+
function answerReasoningOf(parts) {
|
|
5631
|
+
const part = parts.find((item) => item.type === ANSWER_REASONING_PART);
|
|
5632
|
+
if (!part || !("data" in part) || typeof part.data !== "object" || part.data === null) return void 0;
|
|
5633
|
+
const level = part.data.level;
|
|
5634
|
+
return typeof level === "string" ? level : void 0;
|
|
5635
|
+
}
|
|
5636
|
+
function withoutAnswerReasoning(parts) {
|
|
5637
|
+
return parts.some((part) => part.type === ANSWER_REASONING_PART) ? parts.filter((part) => part.type !== ANSWER_REASONING_PART) : parts;
|
|
5638
|
+
}
|
|
5639
|
+
function withAnswerReasoning(parts, level) {
|
|
5640
|
+
if (level === void 0) return parts;
|
|
5641
|
+
return [...withoutAnswerReasoning(parts), { type: ANSWER_REASONING_PART, data: { level } }];
|
|
5642
|
+
}
|
|
5643
|
+
|
|
5628
5644
|
// src/agent-run/run-agent-turn.ts
|
|
5629
5645
|
import { stepCountIs, streamText } from "ai";
|
|
5630
5646
|
|
|
@@ -7209,7 +7225,7 @@ async function runTurn(turnInput, emitRaw) {
|
|
|
7209
7225
|
providerId = fallbackProviderIds[0];
|
|
7210
7226
|
logError(`[\u0437\u0430\u043F\u0430\u0441\u043D\u043E\u0439 \u043F\u0440\u043E\u0432\u0430\u0439\u0434\u0435\u0440] \u0447\u0430\u0442=${input.chatId} \u043C\u043E\u0434\u0435\u043B\u044C=${modelId} \u0441=${input.providerId} \u043D\u0430=${providerId} \u043F\u0440\u0438\u0447\u0438\u043D\u0430=${primaryPaused} \u043E\u0441\u043D\u043E\u0432\u043D\u043E\u0439 \u043D\u0430 \u043F\u0430\u0443\u0437\u0435`);
|
|
7211
7227
|
}
|
|
7212
|
-
emit({ type: "start", messageId, messageMetadata: { modelId, providerId: input.providerId } });
|
|
7228
|
+
emit({ type: "start", messageId, messageMetadata: { modelId, providerId: input.providerId, ...input.reasoning !== void 0 && { reasoningLevel: input.reasoning } } });
|
|
7213
7229
|
if (input.liveDemos && chatHasExternalContent(await storage.listMessages(input.chatId)) && externalContent.announce()) emitRaw(externalContentChunk());
|
|
7214
7230
|
const silenceSetting = resolveSilenceSwitch(input.providerFallback);
|
|
7215
7231
|
if (silenceSetting.onSilence === "restart-step-on-next" && silenceSetting.maxSwitches > 0) {
|
|
@@ -7485,7 +7501,7 @@ async function runTurn(turnInput, emitRaw) {
|
|
|
7485
7501
|
}
|
|
7486
7502
|
}
|
|
7487
7503
|
for (const chunk of seam.flush()) emitNow(chunk);
|
|
7488
|
-
if (!started) emit({ type: "start", messageId, messageMetadata: { modelId, providerId: input.providerId } });
|
|
7504
|
+
if (!started) emit({ type: "start", messageId, messageMetadata: { modelId, providerId: input.providerId, ...input.reasoning !== void 0 && { reasoningLevel: input.reasoning } } });
|
|
7489
7505
|
if (input.waitingWidgets && !input.abortSignal.aborted && errors.length === 0) {
|
|
7490
7506
|
for (const toolCallId of extraWidgetCallIds(await saver.snapshot(), input.waitingWidgets)) {
|
|
7491
7507
|
emitNow({ type: "tool-output-error", toolCallId, errorText: ONE_QUESTION_AT_A_TIME });
|
|
@@ -7564,7 +7580,7 @@ async function runTurn(turnInput, emitRaw) {
|
|
|
7564
7580
|
finished = await finishWithRetries(
|
|
7565
7581
|
storage,
|
|
7566
7582
|
messageId,
|
|
7567
|
-
{ status, parts, usage, reasoningDurationsMs, error, ...answeredByBackup, ...input.afterTurn && { afterTurn: "pending" } },
|
|
7583
|
+
{ status, parts: withAnswerReasoning(parts, input.reasoning), usage, reasoningDurationsMs, error, ...answeredByBackup, ...input.afterTurn && { afterTurn: "pending" } },
|
|
7568
7584
|
logError
|
|
7569
7585
|
);
|
|
7570
7586
|
} catch (failure) {
|
|
@@ -7622,7 +7638,7 @@ async function runTurn(turnInput, emitRaw) {
|
|
|
7622
7638
|
if (input.onFinished) runFinishedHook(input, status, answeredProviderId);
|
|
7623
7639
|
emitToClient({
|
|
7624
7640
|
type: "message-metadata",
|
|
7625
|
-
messageMetadata: { status, reasoningDurationsMs, ...titlesMetadata(parts), ...answeredByBackup, ...usage && { usage }, ...error && { error } }
|
|
7641
|
+
messageMetadata: { status, reasoningDurationsMs, ...input.reasoning !== void 0 && { reasoningLevel: input.reasoning }, ...titlesMetadata(parts), ...answeredByBackup, ...usage && { usage }, ...error && { error } }
|
|
7626
7642
|
});
|
|
7627
7643
|
if (status === "error") for (const chunk of errors) emitToClient(chunk);
|
|
7628
7644
|
if (terminal.length === 0) terminal.push(status === "stopped" ? { type: "abort" } : { type: "finish" });
|
|
@@ -7721,7 +7737,7 @@ function readAnswerAttempt(input, attempt, opened, classify) {
|
|
|
7721
7737
|
// Только id сообщения: SDK дописывает куски в ответ с этим id.
|
|
7722
7738
|
...originalMessage && { originalMessages: [originalMessage] },
|
|
7723
7739
|
sendReasoning: true,
|
|
7724
|
-
messageMetadata: ({ part }) => part.type === "start" ? { modelId: input.modelId, providerId: found.provider.id } : void 0,
|
|
7740
|
+
messageMetadata: ({ part }) => part.type === "start" ? { modelId: input.modelId, providerId: found.provider.id, ...input.reasoning !== void 0 && { reasoningLevel: input.reasoning } } : void 0,
|
|
7725
7741
|
onError
|
|
7726
7742
|
}).pipeThrough(
|
|
7727
7743
|
new TransformStream({
|
|
@@ -10833,6 +10849,10 @@ function buildModelMenu(catalog, env, defaultChoice) {
|
|
|
10833
10849
|
models: catalog.models.filter((model) => model.providerModelIds[provider.id]).map((model) => ({
|
|
10834
10850
|
id: model.id,
|
|
10835
10851
|
displayName: model.displayName,
|
|
10852
|
+
...model.menu?.group !== void 0 && { group: model.menu.group },
|
|
10853
|
+
...model.menu?.description !== void 0 && { description: model.menu.description },
|
|
10854
|
+
...model.menu?.tags !== void 0 && { tags: [...model.menu.tags] },
|
|
10855
|
+
...model.pricing?.[provider.id] && { price: { inputPerMillion: model.pricing[provider.id].inputPerMillion, outputPerMillion: model.pricing[provider.id].outputPerMillion } },
|
|
10836
10856
|
acceptsImages: modelAcceptsImages(model, provider.id),
|
|
10837
10857
|
reasoning: {
|
|
10838
10858
|
levels: [...model.reasoning.levels ?? []],
|
|
@@ -11428,13 +11448,15 @@ function withRetries(model, context) {
|
|
|
11428
11448
|
function toAgentChatMessage(message) {
|
|
11429
11449
|
if (message.role === "user") return { id: message.id, role: "user", parts: message.parts };
|
|
11430
11450
|
const { pendingSteps: _steps, ...usage } = message.usage ?? {};
|
|
11451
|
+
const reasoningLevel = answerReasoningOf(message.parts);
|
|
11431
11452
|
const thoughtTitles = thoughtTitlesOfParts(message.parts);
|
|
11432
11453
|
return {
|
|
11433
11454
|
id: message.id,
|
|
11434
11455
|
role: "assistant",
|
|
11435
|
-
parts: message.parts,
|
|
11456
|
+
parts: withoutAnswerReasoning(message.parts),
|
|
11436
11457
|
metadata: {
|
|
11437
11458
|
status: message.status,
|
|
11459
|
+
...reasoningLevel !== void 0 && { reasoningLevel },
|
|
11438
11460
|
reasoningDurationsMs: message.reasoningDurationsMs,
|
|
11439
11461
|
...Object.keys(thoughtTitles).length > 0 && { thoughtTitles },
|
|
11440
11462
|
...message.modelId && { modelId: message.modelId },
|
|
@@ -12239,7 +12261,7 @@ var SHOWS_EVERYTHING = {
|
|
|
12239
12261
|
visibleChunks: (stream) => stream,
|
|
12240
12262
|
visibleCompactions: (markers) => markers
|
|
12241
12263
|
};
|
|
12242
|
-
var MODEL_METADATA_KEYS = ["modelId", "providerId", "usage"];
|
|
12264
|
+
var MODEL_METADATA_KEYS = ["modelId", "providerId", "reasoningLevel", "usage"];
|
|
12243
12265
|
var MODEL_CHAT_KEYS = ["ownerId", "modelId", "providerId", "reasoning"];
|
|
12244
12266
|
var withoutErrorDetails = (metadata) => {
|
|
12245
12267
|
const error = metadata.error;
|
|
@@ -12305,6 +12327,7 @@ function clientVisibilityOf(capabilities, sdkScreenTool, { thoughtTitles = false
|
|
|
12305
12327
|
const shownTitles = {};
|
|
12306
12328
|
let serverOrdinal = 0;
|
|
12307
12329
|
const kept = message.parts.flatMap((part) => {
|
|
12330
|
+
if (part.type === ANSWER_REASONING_PART) return [];
|
|
12308
12331
|
if (part.type === "reasoning" && placesThoughts) {
|
|
12309
12332
|
const title = serverTitles[String(serverOrdinal++)];
|
|
12310
12333
|
if (title === void 0) return [];
|
|
@@ -15126,6 +15149,7 @@ export {
|
|
|
15126
15149
|
IMPORT_MAX_IMAGES,
|
|
15127
15150
|
IMPORT_MAX_IMAGE_BYTES,
|
|
15128
15151
|
InvalidModelChoiceError,
|
|
15152
|
+
buildModelMenu,
|
|
15129
15153
|
BASIC_WIDGET_NAMES,
|
|
15130
15154
|
SUGGESTIONS_SHOWN,
|
|
15131
15155
|
defineWidget,
|
|
@@ -15143,4 +15167,4 @@ export {
|
|
|
15143
15167
|
InvalidWidgetAnswerError,
|
|
15144
15168
|
createChatService
|
|
15145
15169
|
};
|
|
15146
|
-
//# sourceMappingURL=chunk-
|
|
15170
|
+
//# sourceMappingURL=chunk-YMUK7P4S.js.map
|