narrarium-engine 0.1.24 → 0.1.26

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.
Files changed (87) hide show
  1. package/README.md +21 -3
  2. package/dist/ai/config.d.ts +27 -0
  3. package/dist/ai/config.d.ts.map +1 -1
  4. package/dist/ai/config.js +16 -1
  5. package/dist/ai/config.js.map +1 -1
  6. package/dist/ai/fetch-client.d.ts +2 -2
  7. package/dist/ai/fetch-client.d.ts.map +1 -1
  8. package/dist/ai/fetch-client.js +54 -5
  9. package/dist/ai/fetch-client.js.map +1 -1
  10. package/dist/ai/memory.d.ts +30 -6
  11. package/dist/ai/memory.d.ts.map +1 -1
  12. package/dist/ai/memory.js +15 -2
  13. package/dist/ai/memory.js.map +1 -1
  14. package/dist/ai/prompt-cache.d.ts +41 -0
  15. package/dist/ai/prompt-cache.d.ts.map +1 -0
  16. package/dist/ai/prompt-cache.js +76 -0
  17. package/dist/ai/prompt-cache.js.map +1 -0
  18. package/dist/ai/request.d.ts +6 -1
  19. package/dist/ai/request.d.ts.map +1 -1
  20. package/dist/ai/request.js +76 -1
  21. package/dist/ai/request.js.map +1 -1
  22. package/dist/ai/router.d.ts +5 -1
  23. package/dist/ai/router.d.ts.map +1 -1
  24. package/dist/ai/router.js +2 -1
  25. package/dist/ai/router.js.map +1 -1
  26. package/dist/ai/routing.d.ts.map +1 -1
  27. package/dist/ai/routing.js +7 -2
  28. package/dist/ai/routing.js.map +1 -1
  29. package/dist/ai/types.d.ts +19 -1
  30. package/dist/ai/types.d.ts.map +1 -1
  31. package/dist/ai/types.js.map +1 -1
  32. package/dist/autopilot/campaign.d.ts +9 -2
  33. package/dist/autopilot/campaign.d.ts.map +1 -1
  34. package/dist/autopilot/campaign.js +84 -14
  35. package/dist/autopilot/campaign.js.map +1 -1
  36. package/dist/autopilot/estimate-texts.d.ts +5 -0
  37. package/dist/autopilot/estimate-texts.d.ts.map +1 -1
  38. package/dist/autopilot/estimate-texts.js +9 -3
  39. package/dist/autopilot/estimate-texts.js.map +1 -1
  40. package/dist/autopilot/estimate.d.ts +25 -3
  41. package/dist/autopilot/estimate.d.ts.map +1 -1
  42. package/dist/autopilot/estimate.js +70 -20
  43. package/dist/autopilot/estimate.js.map +1 -1
  44. package/dist/autopilot/frozen.d.ts +2 -0
  45. package/dist/autopilot/frozen.d.ts.map +1 -1
  46. package/dist/autopilot/frozen.js.map +1 -1
  47. package/dist/autopilot/planner.d.ts +1 -0
  48. package/dist/autopilot/planner.d.ts.map +1 -1
  49. package/dist/autopilot/planner.js +133 -12
  50. package/dist/autopilot/planner.js.map +1 -1
  51. package/dist/autopilot/review-policy.d.ts +25 -5
  52. package/dist/autopilot/review-policy.d.ts.map +1 -1
  53. package/dist/autopilot/review-policy.js +84 -2
  54. package/dist/autopilot/review-policy.js.map +1 -1
  55. package/dist/autopilot/review-readers.d.ts +69 -0
  56. package/dist/autopilot/review-readers.d.ts.map +1 -0
  57. package/dist/autopilot/review-readers.js +79 -0
  58. package/dist/autopilot/review-readers.js.map +1 -0
  59. package/dist/autopilot/runner.d.ts +2 -0
  60. package/dist/autopilot/runner.d.ts.map +1 -1
  61. package/dist/autopilot/runner.js +22 -0
  62. package/dist/autopilot/runner.js.map +1 -1
  63. package/dist/autopilot/state.d.ts +11 -0
  64. package/dist/autopilot/state.d.ts.map +1 -1
  65. package/dist/autopilot/state.js +60 -5
  66. package/dist/autopilot/state.js.map +1 -1
  67. package/dist/autopilot/tasks.d.ts.map +1 -1
  68. package/dist/autopilot/tasks.js +138 -60
  69. package/dist/autopilot/tasks.js.map +1 -1
  70. package/dist/autopilot/types.d.ts +93 -11
  71. package/dist/autopilot/types.d.ts.map +1 -1
  72. package/dist/autopilot/types.js +2 -0
  73. package/dist/autopilot/types.js.map +1 -1
  74. package/dist/index.d.ts +2 -0
  75. package/dist/index.d.ts.map +1 -1
  76. package/dist/index.js +2 -0
  77. package/dist/index.js.map +1 -1
  78. package/dist/server/client.d.ts.map +1 -1
  79. package/dist/server/client.js +9 -2
  80. package/dist/server/client.js.map +1 -1
  81. package/dist/server/protocol.d.ts +20 -0
  82. package/dist/server/protocol.d.ts.map +1 -1
  83. package/dist/server/protocol.js +24 -0
  84. package/dist/server/protocol.js.map +1 -1
  85. package/dist/version.d.ts +1 -1
  86. package/dist/version.js +1 -1
  87. package/package.json +1 -1
@@ -1,13 +1,23 @@
1
1
  import type { DirectorProfile } from "../profiles/director.js";
2
2
  import { type AutopilotState, type ReviewPolicy } from "./types.js";
3
3
  /**
4
- * How the chapters and the book are reviewed (`ReviewPolicy`): the vote they must reach, the rounds of review of a chapter, the rounds the simulated readers
5
- * read in, the rounds a review of the book makes before it waits for the author. The director's profile gives the defaults (its approval score, its rounds);
6
- * the run's options (`options.review`) say otherwise for a run, and a review of the book launched later (`state.campaign.review`) for itself. One place says
7
- * which wins, for the planner and the tasks alike. Pure.
4
+ * The policy as the options keep it: each value in its range, a value that is not a number left out; `null` (or nothing usable) is no policy. The targets of the readers
5
+ * are read softly, as the rest: a vote out of range is brought into it, a reader or a vote that cannot be read is left out, and nothing makes the whole policy fail.
8
6
  */
9
- /** The policy as the options keep it: each value in its range, a value that is not a number left out; `null` (or nothing usable) is no policy. */
10
7
  export declare function normalizeReviewPolicy(value: unknown, base?: ReviewPolicy): ReviewPolicy | undefined;
8
+ /** The readers' targets of a policy, as a review reads them. */
9
+ export interface ReaderTargets {
10
+ /** The vote the average of the readers that count must reach. */
11
+ average?: number;
12
+ /** The vote each reader must reach, by slug. */
13
+ each: Readonly<Record<string, number>>;
14
+ /** The readers that do not count. */
15
+ excluded: ReadonlySet<string>;
16
+ }
17
+ /** The targets for the readers a policy (or a review of the book) names; `undefined` when it names none. Pure. */
18
+ export declare function readerTargetsFrom(policy: Pick<ReviewPolicy, "readersTarget" | "readerTargets" | "readersExcluded"> | undefined, fallback?: Pick<ReviewPolicy, "readersTarget" | "readerTargets" | "readersExcluded">): ReaderTargets | undefined;
19
+ /** Whether the targets ask something of the readers (a vote for their average, or for one of them): leaving some out asks nothing, it only changes the average. */
20
+ export declare function readersGated(targets: ReaderTargets | undefined): targets is ReaderTargets;
11
21
  type PolicyState = Pick<AutopilotState, "options"> & Partial<Pick<AutopilotState, "campaign">>;
12
22
  /** The vote a chapter and the book must reach: the review of the book in progress, else the run's policy, else the director's approval score. */
13
23
  export declare function reviewTarget(state: PolicyState, director: Pick<DirectorProfile, "approvalScore">): number;
@@ -18,5 +28,15 @@ export declare function reviewMaxRounds(state: PolicyState, director: Pick<Direc
18
28
  * progress (0: they do not read again), else the run's policy, else 1 (the first round only, as it always was).
19
29
  */
20
30
  export declare function reviewReaderRounds(state: PolicyState): number;
31
+ /** The readers' targets in force: the review of the book in progress's, else the run's; `undefined` when neither names any. */
32
+ export declare function reviewReaderTargets(state: PolicyState): ReaderTargets | undefined;
33
+ /**
34
+ * The targets the readers must meet in a review: `own` (what the review itself names, when it is a review of the book) over the run's policy, when they ask something
35
+ * (`readersGated`), the readers read in this run (`options.readers`) and one of those that read counts (`active` are the readers that read, by slug; absent: the host does
36
+ * not say, and any does). `undefined` otherwise: a review without it is the one the engine always made.
37
+ */
38
+ export declare function gateFor(options: Pick<AutopilotState["options"], "readers" | "review">, own: Pick<ReviewPolicy, "readersTarget" | "readerTargets" | "readersExcluded"> | undefined, active?: readonly string[]): ReaderTargets | undefined;
39
+ /** The targets the readers must meet in the review that goes on (see `gateFor`): the review of the book in progress's own over the run's. */
40
+ export declare function readerGate(state: PolicyState, active?: readonly string[]): ReaderTargets | undefined;
21
41
  export {};
22
42
  //# sourceMappingURL=review-policy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"review-policy.d.ts","sourceRoot":"","sources":["../../src/autopilot/review-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,EAAiD,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAEnH;;;;;GAKG;AAEH,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,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,aAAa,GAAG,SAAS,CAEpG"}
@@ -1,12 +1,49 @@
1
1
  import { clampNumber, numericValue } from "../profiles/read.js";
2
- import { REVIEW_MAX_CAMPAIGN_ROUNDS, REVIEW_MAX_ROUNDS } from "./types.js";
2
+ import { REVIEW_MAX_CAMPAIGN_ROUNDS, REVIEW_MAX_READER_ENTRIES, REVIEW_MAX_ROUNDS } from "./types.js";
3
3
  /**
4
4
  * How the chapters and the book are reviewed (`ReviewPolicy`): the vote they must reach, the rounds of review of a chapter, the rounds the simulated readers
5
5
  * read in, the rounds a review of the book makes before it waits for the author. The director's profile gives the defaults (its approval score, its rounds);
6
6
  * the run's options (`options.review`) say otherwise for a run, and a review of the book launched later (`state.campaign.review`) for itself. One place says
7
7
  * which wins, for the planner and the tasks alike. Pure.
8
8
  */
9
- /** The policy as the options keep it: each value in its range, a value that is not a number left out; `null` (or nothing usable) is no policy. */
9
+ /** A reader as the policy names it: its slug, a short text without control characters; anything else is no reader. */
10
+ function readerSlug(value) {
11
+ if (typeof value !== "string")
12
+ return undefined;
13
+ const slug = value.trim();
14
+ return slug && slug.length <= 120 && !/[\u0000-\u001f\u007f]/.test(slug) ? slug : undefined;
15
+ }
16
+ /**
17
+ * The target of each reader as the options keep it (the slugs that are readers, each vote from 1 to 10 to a tenth, at most `REVIEW_MAX_READER_ENTRIES`): a vote that is not a
18
+ * number leaves the reader without a target. Given whole, it replaces what there was; a value that is not a mapping leaves what there was.
19
+ */
20
+ function readerTargetsOf(value, base) {
21
+ if (value === null)
22
+ return undefined;
23
+ if (!value || typeof value !== "object" || Array.isArray(value))
24
+ return base;
25
+ const targets = {};
26
+ for (const [name, vote] of Object.entries(value)) {
27
+ const slug = readerSlug(name);
28
+ const read = numericValue(vote);
29
+ if (slug && read !== undefined && Object.keys(targets).length < REVIEW_MAX_READER_ENTRIES)
30
+ targets[slug] = clampNumber(read, 1, 10, 1);
31
+ }
32
+ return Object.keys(targets).length ? targets : undefined;
33
+ }
34
+ /** The readers that do not count as the options keep them (each once, at most `REVIEW_MAX_READER_ENTRIES`); a value that is not a list leaves what there was. */
35
+ function readersExcludedOf(value, base) {
36
+ if (value === null)
37
+ return undefined;
38
+ if (!Array.isArray(value))
39
+ return base;
40
+ const slugs = [...new Set(value.map(readerSlug).filter((slug) => slug !== undefined))].slice(0, REVIEW_MAX_READER_ENTRIES);
41
+ return slugs.length ? slugs : undefined;
42
+ }
43
+ /**
44
+ * The policy as the options keep it: each value in its range, a value that is not a number left out; `null` (or nothing usable) is no policy. The targets of the readers
45
+ * are read softly, as the rest: a vote out of range is brought into it, a reader or a vote that cannot be read is left out, and nothing makes the whole policy fail.
46
+ */
10
47
  export function normalizeReviewPolicy(value, base) {
11
48
  if (value === null)
12
49
  return undefined;
@@ -24,6 +61,9 @@ export function normalizeReviewPolicy(value, base) {
24
61
  const maxRounds = pick("maxRounds", 1, REVIEW_MAX_ROUNDS, 0);
25
62
  const readerRounds = pick("readerRounds", 1, REVIEW_MAX_ROUNDS, 0);
26
63
  const campaignMaxRounds = pick("campaignMaxRounds", 0, REVIEW_MAX_CAMPAIGN_ROUNDS, 0);
64
+ const readersTarget = pick("readersTarget", 1, 10, 1);
65
+ const readerTargets = readerTargetsOf(source.readerTargets, base?.readerTargets);
66
+ const readersExcluded = readersExcludedOf(source.readersExcluded, base?.readersExcluded);
27
67
  if (targetScore !== undefined)
28
68
  policy.targetScore = targetScore;
29
69
  if (maxRounds !== undefined)
@@ -32,8 +72,27 @@ export function normalizeReviewPolicy(value, base) {
32
72
  policy.readerRounds = readerRounds;
33
73
  if (campaignMaxRounds)
34
74
  policy.campaignMaxRounds = campaignMaxRounds;
75
+ if (readersTarget !== undefined)
76
+ policy.readersTarget = readersTarget;
77
+ if (readerTargets)
78
+ policy.readerTargets = readerTargets;
79
+ if (readersExcluded)
80
+ policy.readersExcluded = readersExcluded;
35
81
  return Object.keys(policy).length ? policy : undefined;
36
82
  }
83
+ /** The targets for the readers a policy (or a review of the book) names; `undefined` when it names none. Pure. */
84
+ export function readerTargetsFrom(policy, fallback) {
85
+ const average = policy?.readersTarget ?? fallback?.readersTarget;
86
+ const each = policy?.readerTargets ?? fallback?.readerTargets ?? {};
87
+ const excluded = policy?.readersExcluded ?? fallback?.readersExcluded ?? [];
88
+ if (average === undefined && !Object.keys(each).length && !excluded.length)
89
+ return undefined;
90
+ return { ...(average !== undefined ? { average } : {}), each, excluded: new Set(excluded) };
91
+ }
92
+ /** Whether the targets ask something of the readers (a vote for their average, or for one of them): leaving some out asks nothing, it only changes the average. */
93
+ export function readersGated(targets) {
94
+ return Boolean(targets && (targets.average !== undefined || Object.keys(targets.each).length > 0));
95
+ }
37
96
  /** The review of the book in progress, when there is one: its policy wins over the run's. */
38
97
  function reviewInProgress(state) {
39
98
  return state.campaign?.reason === "review-target" ? state.campaign.review : undefined;
@@ -53,4 +112,27 @@ export function reviewMaxRounds(state, director) {
53
112
  export function reviewReaderRounds(state) {
54
113
  return reviewInProgress(state)?.readerRounds ?? state.options.review?.readerRounds ?? 1;
55
114
  }
115
+ /** The readers' targets in force: the review of the book in progress's, else the run's; `undefined` when neither names any. */
116
+ export function reviewReaderTargets(state) {
117
+ return readerTargetsFrom(reviewInProgress(state), state.options.review);
118
+ }
119
+ /**
120
+ * The targets the readers must meet in a review: `own` (what the review itself names, when it is a review of the book) over the run's policy, when they ask something
121
+ * (`readersGated`), the readers read in this run (`options.readers`) and one of those that read counts (`active` are the readers that read, by slug; absent: the host does
122
+ * not say, and any does). `undefined` otherwise: a review without it is the one the engine always made.
123
+ */
124
+ export function gateFor(options, own, active) {
125
+ if (!options.readers)
126
+ return undefined;
127
+ const targets = readerTargetsFrom(own, options.review);
128
+ if (!readersGated(targets))
129
+ return undefined;
130
+ if (active && !active.some((slug) => !targets.excluded.has(slug)))
131
+ return undefined;
132
+ return targets;
133
+ }
134
+ /** The targets the readers must meet in the review that goes on (see `gateFor`): the review of the book in progress's own over the run's. */
135
+ export function readerGate(state, active) {
136
+ return gateFor(state.options, reviewInProgress(state), active);
137
+ }
56
138
  //# sourceMappingURL=review-policy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"review-policy.js","sourceRoot":"","sources":["../../src/autopilot/review-policy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAA0C,MAAM,YAAY,CAAC;AAEnH;;;;;GAKG;AAEH,kJAAkJ;AAClJ,MAAM,UAAU,qBAAqB,CAAC,KAAc,EAAE,IAAmB;IACvE,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IACrC,MAAM,MAAM,GAAG,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAgC,CAAC,CAAC,CAAC,EAAE,CAAC;IACnH,MAAM,IAAI,GAAG,CAAC,GAAuB,EAAE,GAAW,EAAE,GAAW,EAAE,QAAgB,EAAsB,EAAE;QACvG,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI;YAAE,OAAO,SAAS,CAAC;QAC3C,MAAM,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACvC,IAAI,IAAI,KAAK,SAAS;YAAE,OAAO,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;QACrE,OAAO,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC,CAAC;IACF,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAClD,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,CAAC,CAAC;IAC7D,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CAAC,YAAY,CAAC,OAAO,CAAC;QAAE,OAAO,SAAS,CAAC;IAC7C,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IACpF,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,6IAA6I;AAC7I,MAAM,UAAU,UAAU,CAAC,KAAkB,EAAE,MAA0B;IACvE,OAAO,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;AACjE,CAAC"}
@@ -0,0 +1,69 @@
1
+ import type { ReaderTargets } from "./review-policy.js";
2
+ import type { ChapterRound } from "./types.js";
3
+ /**
4
+ * What the readers say of a chapter, compared with the targets the author set for them (`ReviewPolicy.readersTarget`, `readerTargets`, `readersExcluded`): the average of
5
+ * the readers that count, what is under its target, and whether a vote the chapter has is still the vote of its text. Pure: the review (`planner.ts`, `tasks.ts`) and the
6
+ * review of the book (`campaign.ts`) read the same rules from here, and a host that shows the votes reads them too.
7
+ */
8
+ /** The vote of one reader. */
9
+ export interface ReaderVote {
10
+ slug: string;
11
+ score: number;
12
+ }
13
+ /** The average of the votes of the readers that count, to a tenth; `null` when none does. */
14
+ export declare function countingAverage(votes: readonly ReaderVote[], excluded: ReadonlySet<string>): number | null;
15
+ /** What stands between a chapter and a target of the readers: their average, or one reader. */
16
+ export type ReaderBlocker = {
17
+ subject: "average";
18
+ vote: number;
19
+ target: number;
20
+ } | {
21
+ subject: "reader";
22
+ slug: string;
23
+ vote: number;
24
+ target: number;
25
+ };
26
+ /**
27
+ * How the votes of the readers stand against their targets: the average of those that count, what is under its target (the average first, then the readers in the order
28
+ * they voted), and how far it all is from the targets in tenths of a vote (the sum of what each lacks): a round of corrections got closer when it is smaller.
29
+ */
30
+ export interface ReaderStanding {
31
+ average: number | null;
32
+ blockers: ReaderBlocker[];
33
+ shortfall: number;
34
+ }
35
+ /** Judge the votes of the readers by their targets. A reader that does not count has no say, whatever its vote or its target; with no vote there is nothing under a target. */
36
+ export declare function readerStanding(votes: readonly ReaderVote[], targets: ReaderTargets): ReaderStanding;
37
+ /** What the readers last said of a chapter, from the rounds of its review: the entry, the votes it has, and whether they are of the text as it is now. */
38
+ export interface ChapterReading {
39
+ /** The vote of each reader, when the round recorded them (`ChapterRound.readerVotes`); an older round has the average alone. */
40
+ votes?: ReaderVote[];
41
+ /** The average the round recorded: of the readers that counted when it was made; `null` when none did. */
42
+ average: number | null;
43
+ /** The round of the review it belongs to, when the round says it. */
44
+ round?: number;
45
+ reading?: ChapterRound["reading"];
46
+ /** Nothing was corrected after they read: this is the vote of the text as it is. */
47
+ current: boolean;
48
+ }
49
+ /**
50
+ * The last reading of a chapter among its rounds (`null` when the readers never read it). It is the vote of the text as it is while it is the last entry and no
51
+ * correction followed it: a reading of its own is the last thing that happened, and the round of the director that read it has no fix accepted (`accepted`); any
52
+ * later round, or fixes after it, make it a vote of the text before.
53
+ */
54
+ export declare function chapterReading(rounds: readonly ChapterRound[] | undefined): ChapterReading | null;
55
+ /**
56
+ * Where a chapter stands against the readers' targets: the standing, when there is a vote of the text as it is that the targets can be read from (`null` otherwise), and
57
+ * whether the readers must read it for that (`needsReading`: they never did, what they said is of the text before the corrections, or a target is for one reader, or
58
+ * some readers do not count, and the round only has the average of them all).
59
+ */
60
+ export declare function chapterStanding(rounds: readonly ChapterRound[] | undefined, targets: ReaderTargets): {
61
+ standing: ReaderStanding | null;
62
+ reading: ChapterReading | null;
63
+ needsReading: boolean;
64
+ };
65
+ /** What stands in the way, in words: «the readers' average 6.4/10 is under 7.5/10», «Anna's 5/10 is under the 8/10 asked of her». `names` says a reader by its slug. */
66
+ export declare function blockerText(blocker: ReaderBlocker, language: string, names?: (slug: string) => string): string;
67
+ /** All that stands in the way in one sentence («the readers' average 6.4/10 is under 7.5/10; Anna gives 5/10, under the 8/10 asked of this reader»). */
68
+ export declare function blockersText(blockers: readonly ReaderBlocker[], language: string, names?: (slug: string) => string): string;
69
+ //# sourceMappingURL=review-readers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review-readers.d.ts","sourceRoot":"","sources":["../../src/autopilot/review-readers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;GAIG;AAEH,8BAA8B;AAC9B,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAID,6FAA6F;AAC7F,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,EAAE,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI,CAG1G;AAED,+FAA+F;AAC/F,MAAM,MAAM,aAAa,GAAG;IAAE,OAAO,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAErJ;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,+KAA+K;AAC/K,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,EAAE,OAAO,EAAE,aAAa,GAAG,cAAc,CAUnG;AAED,0JAA0J;AAC1J,MAAM,WAAW,cAAc;IAC7B,gIAAgI;IAChI,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,0GAA0G;IAC1G,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IAClC,oFAAoF;IACpF,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,GAAG,cAAc,GAAG,IAAI,CAejG;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,EAAE,OAAO,EAAE,aAAa,GAAG;IAAE,QAAQ,EAAE,cAAc,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAAC,YAAY,EAAE,OAAO,CAAA;CAAE,CAO/L;AAID,wKAAwK;AACxK,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAuB,GAAG,MAAM,CAW9H;AAED,wJAAwJ;AACxJ,wBAAgB,YAAY,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,CAE3H"}
@@ -0,0 +1,79 @@
1
+ import { isItalian } from "../util/text.js";
2
+ const tenth = (value) => Math.round(value * 10) / 10;
3
+ /** The average of the votes of the readers that count, to a tenth; `null` when none does. */
4
+ export function countingAverage(votes, excluded) {
5
+ const counting = votes.filter((vote) => !excluded.has(vote.slug));
6
+ return counting.length ? tenth(counting.reduce((sum, vote) => sum + vote.score, 0) / counting.length) : null;
7
+ }
8
+ /** Judge the votes of the readers by their targets. A reader that does not count has no say, whatever its vote or its target; with no vote there is nothing under a target. */
9
+ export function readerStanding(votes, targets) {
10
+ const average = countingAverage(votes, targets.excluded);
11
+ const blockers = [];
12
+ if (targets.average !== undefined && average !== null && average < targets.average)
13
+ blockers.push({ subject: "average", vote: average, target: targets.average });
14
+ for (const vote of votes) {
15
+ const target = targets.each[vote.slug];
16
+ const score = tenth(vote.score);
17
+ if (target !== undefined && !targets.excluded.has(vote.slug) && score < target)
18
+ blockers.push({ subject: "reader", slug: vote.slug, vote: score, target });
19
+ }
20
+ return { average, blockers, shortfall: blockers.reduce((sum, blocker) => sum + Math.round((blocker.target - blocker.vote) * 10), 0) };
21
+ }
22
+ /**
23
+ * The last reading of a chapter among its rounds (`null` when the readers never read it). It is the vote of the text as it is while it is the last entry and no
24
+ * correction followed it: a reading of its own is the last thing that happened, and the round of the director that read it has no fix accepted (`accepted`); any
25
+ * later round, or fixes after it, make it a vote of the text before.
26
+ */
27
+ export function chapterReading(rounds) {
28
+ if (!rounds?.length)
29
+ return null;
30
+ for (let index = rounds.length - 1; index >= 0; index -= 1) {
31
+ const entry = rounds[index];
32
+ if (entry?.readers === undefined && !entry?.readerVotes)
33
+ continue;
34
+ const votes = entry.readerVotes ? Object.entries(entry.readerVotes).map(([slug, score]) => ({ slug, score })) : undefined;
35
+ return {
36
+ ...(votes ? { votes } : {}),
37
+ average: entry.readers ?? null,
38
+ ...(entry.round !== undefined ? { round: entry.round } : {}),
39
+ ...(entry.reading ? { reading: entry.reading } : {}),
40
+ current: index === rounds.length - 1 && (entry.reading !== undefined || !((entry.accepted ?? 0) > 0)),
41
+ };
42
+ }
43
+ return null;
44
+ }
45
+ /**
46
+ * Where a chapter stands against the readers' targets: the standing, when there is a vote of the text as it is that the targets can be read from (`null` otherwise), and
47
+ * whether the readers must read it for that (`needsReading`: they never did, what they said is of the text before the corrections, or a target is for one reader, or
48
+ * some readers do not count, and the round only has the average of them all).
49
+ */
50
+ export function chapterStanding(rounds, targets) {
51
+ const reading = chapterReading(rounds);
52
+ if (!reading || !reading.current)
53
+ return { standing: null, reading, needsReading: true };
54
+ if (reading.votes)
55
+ return { standing: readerStanding(reading.votes, targets), reading, needsReading: false };
56
+ const detailed = Object.keys(targets.each).length > 0 || targets.excluded.size > 0;
57
+ if (detailed || reading.average === null)
58
+ return { standing: null, reading, needsReading: true };
59
+ return { standing: readerStanding([{ slug: "", score: reading.average }], { ...targets, each: {}, excluded: new Set() }), reading, needsReading: false };
60
+ }
61
+ const vote = (value) => `${value}/10`;
62
+ /** What stands in the way, in words: «the readers' average 6.4/10 is under 7.5/10», «Anna's 5/10 is under the 8/10 asked of her». `names` says a reader by its slug. */
63
+ export function blockerText(blocker, language, names = (slug) => slug) {
64
+ const italian = isItalian(language);
65
+ if (blocker.subject === "average") {
66
+ return italian
67
+ ? `la media dei lettori ${vote(blocker.vote)} è sotto ${vote(blocker.target)}`
68
+ : `the readers' average ${vote(blocker.vote)} is under ${vote(blocker.target)}`;
69
+ }
70
+ const name = names(blocker.slug);
71
+ return italian
72
+ ? `${name} dà ${vote(blocker.vote)}, sotto i ${vote(blocker.target)} chiesti a questo lettore`
73
+ : `${name} gives ${vote(blocker.vote)}, under the ${vote(blocker.target)} asked of this reader`;
74
+ }
75
+ /** All that stands in the way in one sentence («the readers' average 6.4/10 is under 7.5/10; Anna gives 5/10, under the 8/10 asked of this reader»). */
76
+ export function blockersText(blockers, language, names) {
77
+ return blockers.map((blocker) => blockerText(blocker, language, names)).join("; ");
78
+ }
79
+ //# sourceMappingURL=review-readers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review-readers.js","sourceRoot":"","sources":["../../src/autopilot/review-readers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAgB5C,MAAM,KAAK,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC;AAErE,6FAA6F;AAC7F,MAAM,UAAU,eAAe,CAAC,KAA4B,EAAE,QA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OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrF,CAAC"}
@@ -126,6 +126,8 @@ export declare function reconcileAuthorChanges(working: AutopilotState, base: Au
126
126
  * then the book grows.
127
127
  */
128
128
  export declare function extendPlanIfNeeded(state: AutopilotState, targetChapters?: number): AutopilotState;
129
+ /** The task a call belongs to, from its label (`autopilot:specialists:3:1` is `autopilot:specialists`, `reader-evaluation:mara` is `reader-evaluation`): the calls of a task begin with the same instructions. */
130
+ export declare function promptTaskOf(label: string): string;
129
131
  /**
130
132
  * Closed list: errors that declare themselves retryable (`retryable: true`, as `AiProviderError` does) and the
131
133
  * failures of the book store itself (a working copy being refreshed, a full disk: transient, like a network failure)
@@ -1 +1 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/autopilot/runner.ts"],"names":[],"mappings":"AACA,OAAO,EAAyC,KAAK,MAAM,EAAkE,MAAM,gBAAgB,CAAC;AAKpJ,OAAO,EAA4D,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAUjI,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,KAAK,EAAmB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAStE,OAAO,EAAoG,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAqBrJ,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EAGvB,KAAK,sBAAsB,EAG3B,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EAEvB,KAAK,cAAc,EAGnB,KAAK,iBAAiB,EAEtB,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,YAAY,CAAC;AAEpB;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,kFAAkF;IAClF,UAAU,CAAC,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IA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IAAI;QAAE,YAAY,EAAE,qBAAqB,GAAG,IAAI,CAAC;QAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAAC;QAAC,KAAK,CAAC,EAAE,kBAAkB,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE;IAcpJ,+GAA+G;IAC/G,IAAI,aAAa,IAAI,MAAM,GAAG,IAAI,CAEjC;IAED,yJAAyJ;IACzJ,OAAO,CAAC,SAAS;IAOjB,iJAAiJ;IACjJ,SAAS,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;IAOzC,oIAAoI;IACpI,SAAS,IAAI,IAAI;IAMjB,0KAA0K;IAC1K,OAAO,CAAC,OAAO;IAqBf,OAAO,CAAC,IAAI;YAQE,WAAW;IAsBzB,OAAO,CAAC,QAAQ;IAMhB;;;;OAIG;YACW,eAAe;IAyB7B,OAAO,CAAC,UAAU;IAMlB,4IAA4I;IAC5I,OAAO,CAAC,YAAY;IAepB,OAAO,CAAC,eAAe;IAKvB,oHAAoH;YACtG,aAAa;IAM3B,OAAO,CAAC,gBAAgB;IAKxB;;;;OAIG;YACW,gBAAgB;IAwB9B,4FAA4F;YAC9E,eAAe;IAKvB,OAAO,CAAC,KAAK,GAAE,YAAY,GAAG;QAAE,YAAY,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,cAAc,CAAC;IA4D7F,iGAAiG;YACnF,QAAQ;IAggBtB;;;;;;OAMG;YACW,UAAU;IAgCxB,2IAA2I;IAC3I,OAAO,CAAC,SAAS;IAKjB,+EAA+E;IAC/E,OAAO,CAAC,SAAS;IAMjB;;;OAGG;YACW,cAAc;IA4B5B;;;OAGG;IACH,yIAAyI;IACzI,OAAO,CAAC,UAAU;YAMJ,MAAM;CA8CrB"}
@@ -313,6 +313,11 @@ function modelLearnedNotice(learning, responses, italian) {
313
313
  detail: `The provider answered: ${said}. ${responses ? "It says to use the Responses API for this model (/v1/responses) or to turn thinking off when tools are used. " : ""}${done} ${where}`,
314
314
  };
315
315
  }
316
+ /** The task a call belongs to, from its label (`autopilot:specialists:3:1` is `autopilot:specialists`, `reader-evaluation:mara` is `reader-evaluation`): the calls of a task begin with the same instructions. */
317
+ export function promptTaskOf(label) {
318
+ const parts = label.split(":");
319
+ return parts.slice(0, parts[0] === "autopilot" ? 2 : 1).join(":");
320
+ }
316
321
  function describeError(error) {
317
322
  return redactSecrets(error instanceof Error ? error.message : String(error));
318
323
  }
@@ -805,6 +810,21 @@ export class AutopilotRun {
805
810
  }
806
811
  /** A call learned something about a model: said as an event for a host to persist, and as an insight for the author (the words of the provider, and the two ways out). */
807
812
  learned(activityId, learning, italian) {
813
+ if (learning.kind === "prompt-caching") {
814
+ this.emit({
815
+ type: "prompt-caching-learned",
816
+ activityId,
817
+ integrationId: learning.integrationId,
818
+ integrationName: learning.integrationName,
819
+ model: learning.model,
820
+ learned: learning.learned,
821
+ ...(learning.inputTokens !== undefined ? { inputTokens: learning.inputTokens } : {}),
822
+ ...(learning.cachedInputTokens !== undefined ? { cachedInputTokens: learning.cachedInputTokens } : {}),
823
+ ...(learning.hint ? { hint: learning.hint } : {}),
824
+ ...(learning.body ? { body: learning.body } : {}),
825
+ });
826
+ return;
827
+ }
808
828
  const responses = suggestsResponsesApi(learning.body);
809
829
  this.emit({ type: "model-learned", activityId, learned: learning.kind, integrationId: learning.integrationId, integrationName: learning.integrationName, model: learning.model, off: learning.off, body: learning.body, responses });
810
830
  this.emit({ type: "insight", activityId, tone: "warning", code: "modelLearned", model: learning.model, ...modelLearnedNotice(learning, responses, italian) });
@@ -1254,6 +1274,8 @@ export class AutopilotRun {
1254
1274
  response = await this.config.ai.complete({
1255
1275
  ...request,
1256
1276
  user,
1277
+ // The calls of one task of this book share the start of their prompt: a provider that takes a key for its cache is told which they are (the engine sends a hash of it).
1278
+ cacheKey: request.cacheKey ?? `${this.config.bookId}/${promptTaskOf(request.label)}`,
1257
1279
  signal: stepController.signal,
1258
1280
  onText,
1259
1281
  ...(onStructuredText ? { onStructuredText } : {}),