@dsh-agentic-roleplay/core 0.9.0 → 0.10.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/lib/{access-CfQWbNZP.js → access-CXtaZNbx.js} +50 -2
- package/lib/{authoring-tools-CdHlvx32.js → authoring-tools-B4mEdKp_.js} +1349 -604
- package/lib/authoring.js +23 -19
- package/lib/{child-lYYeOwl2.js → child-Dtv76jNx.js} +116 -11
- package/lib/client.js +2810 -795
- package/lib/client.js.map +1 -1
- package/lib/compaction.js +3 -3
- package/lib/doctor.js +3 -3
- package/lib/{gallery-BKh7eu80.js → gallery-BZJleAeH.js} +5 -9
- package/lib/{generator-DdZ1-sgv.js → generator-Cg6CQc5S.js} +2 -2
- package/lib/helper.js +1 -1
- package/lib/{hooks-CcQj_dJo.js → hooks-DTjHWTfx.js} +168 -28
- package/lib/images.js +4 -4
- package/lib/index.js +362 -33
- package/lib/{library-QFL6Z_Nr.js → library-GIlrkOim.js} +9 -14
- package/lib/{lorebook-author-tools-DWBnYo1E.js → lorebook-author-tools-BCFFJSle.js} +6 -6
- package/lib/lorebook-authoring.js +4 -4
- package/lib/{narration-CjB_KwwY.js → narration-BVzew4-K.js} +7 -52
- package/lib/orchestration.js +155 -10
- package/lib/{pack-jail-BMy6NcCY.js → pack-jail-hsNQNTOf.js} +25 -15
- package/lib/{packs-BREPSfHy.js → packs-UpK_cvI4.js} +2 -2
- package/lib/{presenter-agent-B49-_iUm.js → presenter-agent-DZOgBOR9.js} +12 -17
- package/lib/{preset-BqgY1Tz4.js → preset-Cyoj1ZWa.js} +4 -4
- package/lib/{preset-author-tools-BB_Dcv2o.js → preset-author-tools-RSta6pHK.js} +6 -6
- package/lib/preset-authoring.js +5 -5
- package/lib/{presets-Bwnrx7p0.js → presets-CvpsW_10.js} +17 -9
- package/lib/{reflection-CUWG-6Qg.js → reflection-0qTvw2It.js} +53 -26
- package/lib/{turn-guard-Bb8Ew-1z.js → turn-guard-BzNeGNnc.js} +3 -3
- package/package.json +2 -2
- package/prompts/en/checks/conflict.md +1 -0
- package/prompts/en/checks/decide-conflict.md +1 -0
- package/prompts/en/checks/decide-covered.md +1 -0
- package/prompts/en/checks/decide-opening.md +1 -0
- package/prompts/en/checks/decide-same-thing.md +1 -0
- package/prompts/en/checks/decide-same-value.md +1 -0
- package/prompts/en/checks/decide-sheet.md +1 -1
- package/prompts/en/checks/fidelity.md +1 -0
- package/prompts/en/checks/notice.md +2 -2
- package/prompts/zh/checks/conflict.md +1 -0
- package/prompts/zh/checks/decide-conflict.md +1 -0
- package/prompts/zh/checks/decide-covered.md +1 -0
- package/prompts/zh/checks/decide-opening.md +1 -0
- package/prompts/zh/checks/decide-same-thing.md +1 -0
- package/prompts/zh/checks/decide-same-value.md +1 -0
- package/prompts/zh/checks/decide-sheet.md +1 -1
- package/prompts/zh/checks/fidelity.md +1 -0
- package/prompts/zh/checks/notice.md +2 -2
package/lib/authoring.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { t as guardAuthoringTurns } from "./turn-guard-
|
|
3
|
-
import { C as readWorldEditor, L as presetTools, M as deleteTriggerDocument, N as readTriggerDocuments, P as writeTriggerDocument, U as finishUpdate, W as pendingUpdate, _ as editWorldPlots, a as deleteWorldPackFile, c as createAuthoredEntity, d as replaceAuthoredEntity, i as checkWorldPack, l as deleteAuthoredEntity, o as listWorldPacks, r as registerPackJail, s as AUTHORED_ENTITY_KINDS, u as readAuthoredEntityDocument, v as editWorldRelation, z as translateTools } from "./pack-jail-
|
|
4
|
-
import { Dt as InvalidEditProblems, G as listWorldPrompts, K as readWorldPrompt, Mt as parseRelationEdit, Q as IMPORT_FOLDER, U as PROSE_PROMPTS, W as deleteWorldPrompt, ct as parseAuthoringCommand, q as writeWorldPrompt } from "./presets-
|
|
1
|
+
import { A as entitiesByPiece, C as readWorldInfo, M as CHECK_COMMANDS, P as editsSince, S as editWorldInfo, T as loadCardEvidence, _ as runChecks, a as importHooks, b as matchPieces, et as parseWorldInfoEdit, g as CHECKS, h as presentReport, i as contextOf, in as authoredWorldOf, j as readSource, k as cardTools, l as isReviewing, m as checkImported, mt as checkWorld, n as limitAuthoringAgents, o as importTools, v as cardChanges, w as loadWorldParts, x as worldFieldChanges, y as diffText } from "./authoring-tools-B4mEdKp_.js";
|
|
2
|
+
import { t as guardAuthoringTurns } from "./turn-guard-BzNeGNnc.js";
|
|
3
|
+
import { C as readWorldEditor, L as presetTools, M as deleteTriggerDocument, N as readTriggerDocuments, P as writeTriggerDocument, U as finishUpdate, W as pendingUpdate, _ as editWorldPlots, a as deleteWorldPackFile, c as createAuthoredEntity, d as replaceAuthoredEntity, i as checkWorldPack, l as deleteAuthoredEntity, o as listWorldPacks, r as registerPackJail, s as AUTHORED_ENTITY_KINDS, u as readAuthoredEntityDocument, v as editWorldRelation, z as translateTools } from "./pack-jail-hsNQNTOf.js";
|
|
4
|
+
import { Dt as InvalidEditProblems, G as listWorldPrompts, K as readWorldPrompt, Mt as parseRelationEdit, Q as IMPORT_FOLDER, U as PROSE_PROMPTS, W as deleteWorldPrompt, ct as parseAuthoringCommand, q as writeWorldPrompt } from "./presets-CvpsW_10.js";
|
|
5
5
|
import { i as translator, r as languageOf } from "./text-CbGQhK1-.js";
|
|
6
|
-
import {
|
|
7
|
-
import { g as SURFACE_NAMES, m as PACK_LIMITS, p as PACK_ACTIONS } from "./packs-
|
|
8
|
-
import "./access-
|
|
6
|
+
import { H as parsePlotsFile, Y as formatIssue, ot as shippedPromptsDirectory } from "./hooks-DTjHWTfx.js";
|
|
7
|
+
import { g as SURFACE_NAMES, m as PACK_LIMITS, p as PACK_ACTIONS } from "./packs-UpK_cvI4.js";
|
|
8
|
+
import "./access-CXtaZNbx.js";
|
|
9
9
|
import { join, relative } from "node:path";
|
|
10
10
|
import { readFile, readdir } from "node:fs/promises";
|
|
11
11
|
import { createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
@@ -514,7 +514,7 @@ function sizeOf(text) {
|
|
|
514
514
|
zh: `${text.length} 个字符,开头:${clip(text, 70)}`
|
|
515
515
|
};
|
|
516
516
|
}
|
|
517
|
-
function plain(value, max = 220) {
|
|
517
|
+
function plain$1(value, max = 220) {
|
|
518
518
|
const text = clip(value, max);
|
|
519
519
|
return {
|
|
520
520
|
en: text,
|
|
@@ -641,7 +641,7 @@ function authoredWorldWriteTools(reader) {
|
|
|
641
641
|
id: record.summary.id,
|
|
642
642
|
directory: record.directory
|
|
643
643
|
};
|
|
644
|
-
await createAuthoredEntity(world, args.kind, args.key, args.document);
|
|
644
|
+
await createAuthoredEntity(world, args.kind, args.key, args.document, { refuseUnread: true });
|
|
645
645
|
return result("created", args.kind, args.key, await readWorldEditor(world));
|
|
646
646
|
}
|
|
647
647
|
}),
|
|
@@ -664,7 +664,7 @@ function authoredWorldWriteTools(reader) {
|
|
|
664
664
|
id: record.summary.id,
|
|
665
665
|
directory: record.directory
|
|
666
666
|
};
|
|
667
|
-
await replaceAuthoredEntity(world, args.kind, args.key, args.document);
|
|
667
|
+
await replaceAuthoredEntity(world, args.kind, args.key, args.document, { refuseUnread: true });
|
|
668
668
|
return result("replaced", args.kind, args.key, await readWorldEditor(world));
|
|
669
669
|
}
|
|
670
670
|
}),
|
|
@@ -872,9 +872,9 @@ async function infoDetail(changes, before) {
|
|
|
872
872
|
try {
|
|
873
873
|
edit = parseWorldInfoEdit(changes);
|
|
874
874
|
} catch {
|
|
875
|
-
return plain(changes);
|
|
875
|
+
return plain$1(changes);
|
|
876
876
|
}
|
|
877
|
-
return before === void 0 ? plain(edit) : changedFields(before, {
|
|
877
|
+
return before === void 0 ? plain$1(edit) : changedFields(before, {
|
|
878
878
|
...before,
|
|
879
879
|
...edit
|
|
880
880
|
});
|
|
@@ -897,7 +897,7 @@ async function detailOf(exec, kind, key, current) {
|
|
|
897
897
|
const before = exec.agent === void 0 ? void 0 : await current?.(exec.agent.session.id, kind, key);
|
|
898
898
|
return before === void 0 ? createdFields(args["document"]) : changedFields(before, args["document"]);
|
|
899
899
|
}
|
|
900
|
-
case "edit_world_relationship": return plain(args["change"]);
|
|
900
|
+
case "edit_world_relationship": return plain$1(args["change"]);
|
|
901
901
|
case "replace_world_plots": return Array.isArray(args["plots"]) ? {
|
|
902
902
|
en: `${args["plots"].length} plots`,
|
|
903
903
|
zh: `${args["plots"].length} 条剧情`
|
|
@@ -1099,6 +1099,8 @@ const output = {
|
|
|
1099
1099
|
text: JSON.stringify(value, null, 2)
|
|
1100
1100
|
}]
|
|
1101
1101
|
};
|
|
1102
|
+
/** A value as the tool result carries it: plain data. */
|
|
1103
|
+
const plain = (value) => JSON.parse(JSON.stringify(value));
|
|
1102
1104
|
const deepParameter = {
|
|
1103
1105
|
type: "boolean",
|
|
1104
1106
|
description: "Also run the checks a model judges (slower, one or more model requests each). Leave it off for a quick look; turn it on when the quick checks leave the world looking thin, when the person asks for a thorough check, or before you say an import is done."
|
|
@@ -1133,16 +1135,17 @@ function kitTool(reader, judging, name, kit, description, card = false) {
|
|
|
1133
1135
|
kits: [kit],
|
|
1134
1136
|
deep: args.deep === true
|
|
1135
1137
|
});
|
|
1136
|
-
return
|
|
1138
|
+
return plain(presentReport(report));
|
|
1137
1139
|
}
|
|
1138
1140
|
});
|
|
1139
1141
|
}
|
|
1140
1142
|
/** The checks of the suite as tools of a world authoring chat; each kit is one call, and what it finds is stored with the world for the next run to compare with. */
|
|
1141
1143
|
function checkTools(reader, judging) {
|
|
1142
1144
|
return [
|
|
1143
|
-
kitTool(reader, judging, "check_world", "consistency", "Check the world for inconsistencies: whether a story could start from it (every file reads and everything that refers to something refers to something that is there; it names the problems of the first part of the world that has any, so run it again after fixing them), places no one can reach, names that clash, tracked values that are the same thing twice, and prompts the story could not use. Run it before you say a world is done. It reads only; each finding says where it is and, when clear, what would fix it."),
|
|
1144
|
-
kitTool(reader, judging, "check_card", "fidelity", "Compare the world with the card it was imported from, which is kept: whether every piece of the card the import read is in the world, whether every name in the world occurs in the card, whether the numbers the card gives were kept, and, with version new, what a newer card waiting to update the world changed that the world does not say yet. With deep, a model also compares each document with the pieces it was made from and quotes the facts that were lost or made up. A finding is a pointer: read the piece with card_read before you change anything. It reads only.", true),
|
|
1145
|
+
kitTool(reader, judging, "check_world", "consistency", "Check the world for inconsistencies: whether a story could start from it (every file reads and everything that refers to something refers to something that is there; it names the problems of the first part of the world that has any, so run it again after fixing them), places no one can reach, names that clash, tracked values that are the same thing twice, and prompts the story could not use. With deep, tracked values, characters, places and things that are the same under different words, and background entries that contradict each other, are found by meaning (with quoted passages for contradictions). Run it before you say a world is done. It reads only; each finding says where it is and, when clear, what would fix it."),
|
|
1146
|
+
kitTool(reader, judging, "check_card", "fidelity", "Compare the world with the card it was imported from, which is kept: whether every piece of the card the import read is in the world, whether every name in the world occurs in the card, whether the numbers the card gives were kept, and, with version new, what a newer card waiting to update the world changed that the world does not say yet. With deep, a model also compares each document with the pieces it was made from and quotes the facts that were lost or made up, and a piece that shares no words with the world (another language, a rewrite) is looked for by meaning before it is called lost. A finding is a pointer: read the piece with card_read before you change anything. It reads only.", true),
|
|
1145
1147
|
kitTool(reader, judging, "check_quality", "quality", "Check the authoring quality of the world: whether someone can be played, whether the characters that matter have sheets to play from, places with nothing in them, what the world says about itself. With deep, a model also judges whether each sheet is enough to play and what the world is missing to play well. It reads only; a finding is a gap to fill from what the card or the person says, never from invention."),
|
|
1148
|
+
kitTool(reader, judging, "check_play", "playability", "Check whether a story can begin well from this world: for each character the player may play, whether the place they start in has ways out, people and things, and, with deep, whether a model reading the opening and that first scene finds something the player can do. It reads only; a finding is a gap in the first scene to fill from what the card or the person says, never from invention."),
|
|
1146
1149
|
defineTool({
|
|
1147
1150
|
name: "check_list",
|
|
1148
1151
|
description: "List the checks of the suite: which kit each belongs to, whether the program or a model decides it, and what it needs.",
|
|
@@ -1150,13 +1153,13 @@ function checkTools(reader, judging) {
|
|
|
1150
1153
|
output,
|
|
1151
1154
|
isConcurrencySafe: () => true,
|
|
1152
1155
|
async execute() {
|
|
1153
|
-
return
|
|
1156
|
+
return plain(CHECKS.map((check) => ({
|
|
1154
1157
|
id: check.id,
|
|
1155
1158
|
kit: check.kit,
|
|
1156
1159
|
mode: check.mode,
|
|
1157
1160
|
needs: check.needs,
|
|
1158
1161
|
description: check.description
|
|
1159
|
-
})))
|
|
1162
|
+
})));
|
|
1160
1163
|
}
|
|
1161
1164
|
})
|
|
1162
1165
|
];
|
|
@@ -1166,7 +1169,8 @@ function checkTools(reader, judging) {
|
|
|
1166
1169
|
const KIT_TOOLS = {
|
|
1167
1170
|
consistency: "check_world",
|
|
1168
1171
|
fidelity: "check_card",
|
|
1169
|
-
quality: "check_quality"
|
|
1172
|
+
quality: "check_quality",
|
|
1173
|
+
playability: "check_play"
|
|
1170
1174
|
};
|
|
1171
1175
|
/** Hears the check commands (`/check`, `/check-world`) in an authoring chat and tells the assistant to run those kits and what to do with what they find. */
|
|
1172
1176
|
function checkHooks(ctx, prompting) {
|
|
@@ -43,11 +43,15 @@ const NO_TOKENS = {
|
|
|
43
43
|
cached: 0,
|
|
44
44
|
output: 0
|
|
45
45
|
};
|
|
46
|
-
const addTokens = (a, b) =>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
const addTokens = (a, b) => {
|
|
47
|
+
const unreported = (a.unreported ?? 0) + (b.unreported ?? 0);
|
|
48
|
+
return {
|
|
49
|
+
input: a.input + b.input,
|
|
50
|
+
cached: a.cached + b.cached,
|
|
51
|
+
output: a.output + b.output,
|
|
52
|
+
...unreported > 0 ? { unreported } : {}
|
|
53
|
+
};
|
|
54
|
+
};
|
|
51
55
|
// src/host/agents/usage.ts
|
|
52
56
|
/** The tokens the model service reported for the requests it answered in a session's events; a request it reported nothing for adds nothing. */
|
|
53
57
|
function tokensOf(events) {
|
|
@@ -59,11 +63,104 @@ function tokensOf(events) {
|
|
|
59
63
|
total = addTokens(total, {
|
|
60
64
|
input: usage.inputTokens,
|
|
61
65
|
cached: usage.cacheReadTokens ?? 0,
|
|
62
|
-
output: usage.outputTokens
|
|
66
|
+
output: usage.outputTokens,
|
|
67
|
+
...usage.cacheReadTokens === void 0 ? { unreported: usage.inputTokens } : {}
|
|
63
68
|
});
|
|
64
69
|
}
|
|
65
70
|
return total;
|
|
66
71
|
}
|
|
72
|
+
// src/host/diagnostics/estimate.ts
|
|
73
|
+
const WIDE = /[ -鿿가--]/gu;
|
|
74
|
+
/** What a text costs in tokens, roughly: a token holds about four letters of a western script and less than one character of a Chinese, Japanese or Korean one. Only for telling the parts of a prompt apart; the service's own count is what is reported for the whole. */
|
|
75
|
+
function estimateTokens(text) {
|
|
76
|
+
if (text === "") return 0;
|
|
77
|
+
const wide = text.match(WIDE)?.length ?? 0;
|
|
78
|
+
return Math.ceil((text.length - wide) / 4 + wide * .7);
|
|
79
|
+
}
|
|
80
|
+
/** The text a block of a model message puts in the prompt. */
|
|
81
|
+
function blockText(block) {
|
|
82
|
+
if (typeof block !== "object" || block === null) return "";
|
|
83
|
+
const entry = block;
|
|
84
|
+
if (typeof entry.text === "string") return entry.text;
|
|
85
|
+
if (entry.type === "tool-call") return `${typeof entry.name === "string" ? entry.name : ""}${typeof entry.arguments === "string" ? entry.arguments : JSON.stringify(entry.arguments ?? "")}`;
|
|
86
|
+
if (entry.type === "image") return "";
|
|
87
|
+
return JSON.stringify(block);
|
|
88
|
+
}
|
|
89
|
+
/** The tokens of the content of one message of the log. */
|
|
90
|
+
function messageTokens(message) {
|
|
91
|
+
const content = message?.content;
|
|
92
|
+
if (typeof content === "string") return estimateTokens(content);
|
|
93
|
+
return Array.isArray(content) ? content.reduce((sum, block) => sum + estimateTokens(blockText(block)), 0) : 0;
|
|
94
|
+
}
|
|
95
|
+
// src/host/agents/requests.ts
|
|
96
|
+
/** What a request's prompt was made of: the parts the log shows, and whatever else the service counted (the earlier turns of the conversation). */
|
|
97
|
+
function parts(held, prompt) {
|
|
98
|
+
const known = Object.keys(held).filter((id) => held[id] > 0).map((id) => ({
|
|
99
|
+
id,
|
|
100
|
+
tokens: held[id]
|
|
101
|
+
}));
|
|
102
|
+
const rest = prompt === void 0 ? 0 : prompt - known.reduce((sum, part) => sum + part.tokens, 0);
|
|
103
|
+
const all = rest > 0 ? [...known, {
|
|
104
|
+
id: "earlier",
|
|
105
|
+
tokens: rest
|
|
106
|
+
}] : known;
|
|
107
|
+
return all.length === 0 ? {} : { parts: all };
|
|
108
|
+
}
|
|
109
|
+
const KEEP_WAITING = /* @__PURE__ */ new Set([
|
|
110
|
+
"block-start",
|
|
111
|
+
"text-delta",
|
|
112
|
+
"reasoning-delta"
|
|
113
|
+
]);
|
|
114
|
+
/**
|
|
115
|
+
* The requests a session's events record, in order. The wait is measured from the start of the step to the first block the model opened;
|
|
116
|
+
* whatever DSH took to assemble the request is in it, which is small beside a model's own time to read the prompt.
|
|
117
|
+
*/
|
|
118
|
+
function requestsOf(events) {
|
|
119
|
+
const stats = [];
|
|
120
|
+
const began = /* @__PURE__ */ new Map();
|
|
121
|
+
const held = {
|
|
122
|
+
system: 0,
|
|
123
|
+
tools: 0,
|
|
124
|
+
notices: 0,
|
|
125
|
+
input: 0,
|
|
126
|
+
steps: 0
|
|
127
|
+
};
|
|
128
|
+
for (const event of events) {
|
|
129
|
+
const data = event.data;
|
|
130
|
+
const key = `${data?.turn ?? 0}:${data?.step ?? 0}`;
|
|
131
|
+
if (event.type === "step/start" && event.time !== void 0) began.set(key, event.time);
|
|
132
|
+
if (event.type === "turn/start") held.notices = held.input = held.steps = 0;
|
|
133
|
+
if (event.type === "system/message") held.system = messageTokens(data?.message);
|
|
134
|
+
if (event.type === "request/header") held.tools = estimateTokens(JSON.stringify(data?.header?.tools ?? []));
|
|
135
|
+
if (event.type === "user/message") held[data?.source?.kind === "roleplay" ? "notices" : "input"] += messageTokens(data);
|
|
136
|
+
if (event.type === "tool/result") held.steps += messageTokens(data?.message);
|
|
137
|
+
if (event.type !== "assistant/message") continue;
|
|
138
|
+
const sent = { ...held };
|
|
139
|
+
if (data?.message !== void 0) held.steps += messageTokens(data.message);
|
|
140
|
+
if (data?.stream === void 0 || stats.length >= 40) continue;
|
|
141
|
+
const start = began.get(key);
|
|
142
|
+
const chunks = data.stream.flatMap((entry) => entry.chunk === void 0 ? [] : [{
|
|
143
|
+
time: entry.time,
|
|
144
|
+
chunk: entry.chunk
|
|
145
|
+
}]);
|
|
146
|
+
const usage = chunks.findLast((entry) => entry.chunk.type === "usage")?.chunk.usage ?? data.usage;
|
|
147
|
+
const first = chunks.find((entry) => KEEP_WAITING.has(entry.chunk.type))?.time;
|
|
148
|
+
const stop = chunks.findLast((entry) => entry.chunk.type === "finish")?.chunk.reason?.kind ?? "stop";
|
|
149
|
+
const cached = usage?.cacheReadTokens;
|
|
150
|
+
const prompt = usage?.inputTokens === void 0 ? void 0 : usage.inputTokens + (cached ?? 0) + (usage.cacheWriteTokens ?? 0);
|
|
151
|
+
stats.push({
|
|
152
|
+
step: data.step ?? 0,
|
|
153
|
+
...prompt === void 0 ? {} : { prompt },
|
|
154
|
+
...usage?.outputTokens === void 0 ? {} : { output: usage.outputTokens },
|
|
155
|
+
...cached === void 0 ? {} : { cached },
|
|
156
|
+
...start === void 0 || first === void 0 ? {} : { waitMs: Math.max(0, first - start) },
|
|
157
|
+
...start === void 0 || event.time === void 0 ? {} : { ms: Math.max(0, event.time - start) },
|
|
158
|
+
stop,
|
|
159
|
+
...parts(sent, prompt)
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
return stats;
|
|
163
|
+
}
|
|
67
164
|
// src/shared/activity.ts
|
|
68
165
|
/** Longest text kept for one call's arguments or outcome, and for the persona, the prompt and the result. */
|
|
69
166
|
const MAX_RUN_TEXT = 4e3;
|
|
@@ -187,8 +284,10 @@ function childTrace(store, kind, label, extra = {}, named) {
|
|
|
187
284
|
model,
|
|
188
285
|
ms: run.ms,
|
|
189
286
|
calls: run.calls,
|
|
287
|
+
...run.detail.calls.some((call) => call.failed) ? { refused: run.detail.calls.filter((call) => call.failed).length } : {},
|
|
190
288
|
turn: run.turn,
|
|
191
289
|
tokens: run.tokens,
|
|
290
|
+
...(run.requests ?? []).length === 0 ? {} : { requests: run.requests },
|
|
192
291
|
...run.error === void 0 ? {} : { error: run.error.slice(0, 300) },
|
|
193
292
|
...id === void 0 ? {} : { run: id }
|
|
194
293
|
}, keep ? {
|
|
@@ -273,7 +372,8 @@ async function runChild(task) {
|
|
|
273
372
|
calls: stats.calls,
|
|
274
373
|
detail: detail(),
|
|
275
374
|
turn: currentTurn(task.parent),
|
|
276
|
-
tokens: stats.tokens ?? NO_TOKENS
|
|
375
|
+
tokens: stats.tokens ?? NO_TOKENS,
|
|
376
|
+
requests: stats.requests ?? []
|
|
277
377
|
});
|
|
278
378
|
return result;
|
|
279
379
|
} catch (cause) {
|
|
@@ -284,7 +384,8 @@ async function runChild(task) {
|
|
|
284
384
|
error: error instanceof Error ? error.message : String(error),
|
|
285
385
|
detail: detail(),
|
|
286
386
|
turn: currentTurn(task.parent),
|
|
287
|
-
tokens: stats.tokens ?? NO_TOKENS
|
|
387
|
+
tokens: stats.tokens ?? NO_TOKENS,
|
|
388
|
+
requests: stats.requests ?? []
|
|
288
389
|
});
|
|
289
390
|
if (attempt >= 2 || task.signal.aborted || error instanceof ChildTimeoutError || !isUnfinishedCall(error)) throw error;
|
|
290
391
|
} finally {
|
|
@@ -631,7 +732,11 @@ async function execute(task, stats) {
|
|
|
631
732
|
} catch (error) {
|
|
632
733
|
if (submitted === void 0 && !overran && !signal.aborted) throw error;
|
|
633
734
|
} finally {
|
|
634
|
-
if (entry.agent !== void 0)
|
|
735
|
+
if (entry.agent !== void 0) {
|
|
736
|
+
const events = entry.agent.session.snapshotEvents();
|
|
737
|
+
stats.tokens = tokensOf(events);
|
|
738
|
+
stats.requests = requestsOf(events);
|
|
739
|
+
}
|
|
635
740
|
await (overran ? Promise.race([activation.dispose(), new Promise((resolve) => {
|
|
636
741
|
setTimeout(resolve, STOP_GRACE_MS);
|
|
637
742
|
})]) : activation.dispose());
|
|
@@ -651,6 +756,6 @@ async function execute(task, stats) {
|
|
|
651
756
|
}
|
|
652
757
|
return submitted.value;
|
|
653
758
|
}
|
|
654
|
-
export {
|
|
759
|
+
export { tokensOf$1 as S, addTokens as _, childTrace as a, finishOf as b, runChild as c, sharedSamplingOf as d, requestsOf as f, NO_TOKENS as g, tokensOf as h, childSamplingOf as i, SAMPLING_RANGES as l, estimateTokens as m, childModel as n, helpers as o, blockText as p, childSampling as r, namedModel as s, ChildTimeoutError as t, parseSampling as u, currentTurn as v, estimateAnswer as x, cutOff as y };
|
|
655
760
|
|
|
656
|
-
//# sourceMappingURL=child-
|
|
761
|
+
//# sourceMappingURL=child-Dtv76jNx.js.map
|