@stackfactor/agent-utils 1.32.0 → 1.33.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/README.md CHANGED
@@ -992,6 +992,9 @@ const problems = learningContentPlan.planProblems(plan, microSkillIdsInCourseOrd
992
992
  term is owned by the same lesson or a later one. It never throws.
993
993
  - `planContextSchema` parses what a lesson agent is given: unknown keys are
994
994
  dropped, and a missing `handsTo` becomes `""`.
995
+ - `readPlanContext(value)` is what a lesson agent calls on its request's
996
+ `planContext`. It answers `undefined` for `undefined` or `null`, and the parsed
997
+ context otherwise; any other value throws a 400 that names the first bad path.
995
998
  - Types: `ContentPlan`, `ContentPlanLesson`, `ContentPlanTerm`,
996
999
  `ContentPlanExtension`. `PlanContext` is client-api's
997
1000
  `LearningContentPlanContext`. `LearningContentThread` and
@@ -1050,7 +1053,7 @@ if (lines) {
1050
1053
  // place lines.opening and lines.closing in the lesson, and answer `thread`
1051
1054
  } else {
1052
1055
  // a whole lesson: answer an empty `thread` object and go on; `problems` says why
1053
- // a thread-only update: throw `error` when it is there, else report `problems`
1056
+ // a thread-only update: `learningContentThread.requireLines(result)` answers the lines or throws
1054
1057
  }
1055
1058
  ```
1056
1059
 
@@ -1103,6 +1106,24 @@ in the call itself.
1103
1106
  Each problem is a sentence the model can act on, for example
1104
1107
  `The opening has 72 words; the limit is 60.`
1105
1108
 
1109
+ #### After the review, and on an update
1110
+
1111
+ `linesAfterReview(onPage, written, planContext)` says which text each place
1112
+ keeps after a lesson's review. A reviewer's fix may have rewritten or removed a
1113
+ line since the writer wrote it. For each line on its own, the candidate is the
1114
+ text on the page, trimmed, when it is not blank; otherwise it is the written
1115
+ line. The opening keeps its candidate when the two lines pass `threadProblems`
1116
+ with that opening beside the written closing; otherwise it goes back to the
1117
+ written opening. The closing is judged the same way beside the written opening.
1118
+ A place that is null, absent, blank or not a string counts as gone. The call
1119
+ never throws for an odd `onPage` and changes neither argument.
1120
+
1121
+ `requireLines(result)` is for a thread-only update, where a lesson without both
1122
+ lines is a failure. It answers `result.lines` when they are there. Otherwise it
1123
+ throws the call's own `result.error`, or, when there is none, an error whose
1124
+ message is the JSON of `{ code: 502, message }`, the message naming the
1125
+ `problems`.
1126
+
1106
1127
  ## Supported Models
1107
1128
 
1108
1129
  ### Text / Chat
@@ -48,6 +48,6 @@ export { learningActivityMedia };
48
48
  export { learningContentPlan };
49
49
  export { learningContentThread };
50
50
  export type { ContentPlan, ContentPlanExtension, ContentPlanLesson, ContentPlanTerm, LearningContentThread, LearningContentThreadSentence } from "./learningContentPlan.js";
51
- export type { PlanContext, ThreadLines, WriteThreadInput, WriteThreadResult } from "./learningContentThread.js";
51
+ export type { PlanContext, ThreadLines, ThreadLinesOnPage, WriteThreadInput, WriteThreadResult } from "./learningContentThread.js";
52
52
  export type { ActivityContentField, ActivityMediaChoices, ActivityMediaOptions, ActivityMediaPlatform, ActivityMediaSummary, ActivityMediaTarget, MediaCount, MediaIntegrationChoice, MotionGraphicStyle, } from "./learningActivityMedia.js";
53
53
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,aAAa,EAAE,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB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AoB,EACpB,mBAAmB,EACnB,UAAU,EACV,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,4BAA4B,CAAC"}
@@ -46,6 +46,17 @@ export declare const planExtensionSchema: z.ZodType<ContentPlanExtension>;
46
46
  * null becomes "", the three booleans default to false, the lists to [].
47
47
  */
48
48
  export declare const planContextSchema: z.ZodType<LearningContentPlanContext>;
49
+ /**
50
+ * What a lesson agent calls on the `planContext` of its request before it does
51
+ * any work. `undefined` and `null` answer `undefined` (no plan context). A value
52
+ * that {@link planContextSchema} parses answers the parsed context. Anything else
53
+ * throws an Error whose message is the JSON of `{ code: 400, message }`, the
54
+ * message being "Schema validation error: planContext", then the first issue's
55
+ * path (joined with ".", behind a leading "." when not empty), then " - " and the
56
+ * first issue's message. Changes nothing it is given.
57
+ * @throws A 400 for a value that is not a plan context
58
+ */
59
+ export declare const readPlanContext: (value: unknown) => LearningContentPlanContext | undefined;
49
60
  /**
50
61
  * What does not fit between a plan and the skill it is for, one sentence each,
51
62
  * each sentence once, in the order first met. `[]` when it fits. It never
@@ -96,6 +107,7 @@ declare const _default: {
96
107
  }>;
97
108
  planSchema: z.ZodType<ContentPlan, unknown, z.core.$ZodTypeInternals<ContentPlan, unknown>>;
98
109
  planContextSchema: z.ZodType<learningContentPlan.LearningContentPlanContext, unknown, z.core.$ZodTypeInternals<learningContentPlan.LearningContentPlanContext, unknown>>;
110
+ readPlanContext: (value: unknown) => LearningContentPlanContext | undefined;
99
111
  planProblems: (plan: ContentPlan, microSkillIds: unknown[]) => string[];
100
112
  planExtensionSchema: z.ZodType<ContentPlanExtension, unknown, z.core.$ZodTypeInternals<ContentPlanExtension, unknown>>;
101
113
  extensionProblems: (extension: ContentPlanExtension, existingPlan: unknown, microSkillIds: unknown[]) => string[];
@@ -1 +1 @@
1
- {"version":3,"file":"learningContentPlan.d.ts","sourceRoot":"","sources":["../../src/learningContentPlan.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAA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@@ -5,7 +5,7 @@
5
5
  // model. The limits are client-api's, which mirror core's.
6
6
  //
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.mergePlanExtension = exports.extensionProblems = exports.planProblems = exports.planContextSchema = exports.planExtensionSchema = exports.planSchema = exports.PLAN_LIMITS = void 0;
8
+ exports.mergePlanExtension = exports.extensionProblems = exports.planProblems = exports.readPlanContext = exports.planContextSchema = exports.planExtensionSchema = exports.planSchema = exports.PLAN_LIMITS = void 0;
9
9
  const zod_1 = require("zod");
10
10
  const client_api_1 = require("@stackfactor/client-api");
11
11
  /** client-api's limits, frozen: THROUGH_LINE, ROLE, HANDS_TO, TERM, DEFINITION, BUILDS_ON, OWNED_TERMS. */
@@ -115,6 +115,27 @@ exports.planContextSchema = zod_1.z.object({
115
115
  buildsOn: zod_1.z.array(zod_1.z.object({ term: zod_1.z.string(), definition: zod_1.z.string() })).default([]),
116
116
  ownedTerms: zod_1.z.array(zod_1.z.object({ term: zod_1.z.string(), definition: zod_1.z.string() })).default([]),
117
117
  });
118
+ /**
119
+ * What a lesson agent calls on the `planContext` of its request before it does
120
+ * any work. `undefined` and `null` answer `undefined` (no plan context). A value
121
+ * that {@link planContextSchema} parses answers the parsed context. Anything else
122
+ * throws an Error whose message is the JSON of `{ code: 400, message }`, the
123
+ * message being "Schema validation error: planContext", then the first issue's
124
+ * path (joined with ".", behind a leading "." when not empty), then " - " and the
125
+ * first issue's message. Changes nothing it is given.
126
+ * @throws A 400 for a value that is not a plan context
127
+ */
128
+ const readPlanContext = (value) => {
129
+ if (value === undefined || value === null)
130
+ return undefined;
131
+ const parsed = exports.planContextSchema.safeParse(value);
132
+ if (parsed.success)
133
+ return parsed.data;
134
+ const issue = parsed.error.issues[0];
135
+ const path = issue.path.length > 0 ? `.${issue.path.join(".")}` : "";
136
+ throw new Error(JSON.stringify({ code: 400, message: `Schema validation error: planContext${path} - ${issue.message}` }));
137
+ };
138
+ exports.readPlanContext = readPlanContext;
118
139
  /**
119
140
  * What does not fit between a plan and the skill it is for, one sentence each,
120
141
  * each sentence once, in the order first met. `[]` when it fits. It never
@@ -298,6 +319,7 @@ exports.default = {
298
319
  PLAN_LIMITS: exports.PLAN_LIMITS,
299
320
  planSchema: exports.planSchema,
300
321
  planContextSchema: exports.planContextSchema,
322
+ readPlanContext: exports.readPlanContext,
301
323
  planProblems: exports.planProblems,
302
324
  planExtensionSchema: exports.planExtensionSchema,
303
325
  extensionProblems: exports.extensionProblems,
@@ -154,6 +154,33 @@ export interface WriteThreadResult {
154
154
  * @throws The error of a plan context that does not parse, or of a cancelled request or a 402
155
155
  */
156
156
  export declare const writeThread: (input: WriteThreadInput) => Promise<WriteThreadResult>;
157
+ /** What stands at the two thread places of a lesson after its review. A place that is gone, or blank, is null or absent. */
158
+ export interface ThreadLinesOnPage {
159
+ opening?: string | null;
160
+ closing?: string | null;
161
+ }
162
+ /**
163
+ * Which text each thread place of a lesson keeps after its review. A review (a
164
+ * reviewer's fix, applied by the Judge or automatically) may have rewritten or
165
+ * removed a line after the writer wrote it. Per line, and independent of the
166
+ * other: the candidate is the on-page text, trimmed, when it is a non-blank
167
+ * string, else the written line. The opening keeps its candidate when
168
+ * `threadProblems({ opening: candidate, closing: written.closing })` is empty,
169
+ * else it goes back to `written.opening`; the closing likewise, checked beside
170
+ * the written opening. A null, absent, blank or non-string place counts as gone.
171
+ * Never throws for an odd `onPage`, and changes neither argument.
172
+ */
173
+ export declare const linesAfterReview: (onPage: ThreadLinesOnPage, written: ThreadLines, planContext: PlanContext) => ThreadLines;
174
+ /**
175
+ * For a thread-only update, where a lesson without both lines is a failure.
176
+ * Answers `result.lines` when they are there; else throws `result.error`
177
+ * itself when there is one; else throws an Error whose message is the JSON of
178
+ * `{ code: 502, message }`, the message naming `result.problems` (joined by a
179
+ * space) after "The thread lines could not be written: ", or just that
180
+ * sentence without the colon when there are none.
181
+ * @throws The call's own error, or a 502
182
+ */
183
+ export declare const requireLines: (result: WriteThreadResult) => ThreadLines;
157
184
  declare const _default: {
158
185
  THREAD_LIMITS: Readonly<{
159
186
  OPENING_WORDS: 60;
@@ -164,7 +191,9 @@ declare const _default: {
164
191
  countSentences: (text: string) => number;
165
192
  countWords: (text: string) => number;
166
193
  findPositionPhrases: (text: string) => string[];
194
+ linesAfterReview: (onPage: ThreadLinesOnPage, written: ThreadLines, planContext: PlanContext) => ThreadLines;
167
195
  namesTerm: (text: string, term: string) => boolean;
196
+ requireLines: (result: WriteThreadResult) => ThreadLines;
168
197
  threadProblems: (lines: ThreadLines, planContext: PlanContext) => string[];
169
198
  threadRulesForPrompt: () => {
170
199
  opening: {
@@ -1 +1 @@
1
- {"version":3,"file":"learningContentThread.d.ts","sourceRoot":"","sources":["../../src/learningContentThread.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAG1E,yHAAyH;AACzH,eAAO,MAAM,aAAa;;;;;EAAsG,CAAC;AAEjI,sFAAsF;AACtF,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qFAAqF;AACrF,MAAM,MAAM,WAAW,GAAG,0BAA0B,CAAC;AAOrD;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,KAAG,MAGK,CAAC;AA0BhD;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,KAAG,MA2B7C,CAAC;AA2CF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,KAAG,MAAM,EAiBxD,CAAC;AAkBF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,EAAE,MAAM,MAAM,KAAG,OAKtD,CAAC;AAiBF;;;;;;;;GAQG;AACH,eAAO,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
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
- exports.writeThread = exports.threadRulesForPrompt = exports.threadProblems = exports.namesTerm = exports.findPositionPhrases = exports.countSentences = exports.countWords = exports.THREAD_LIMITS = void 0;
41
+ exports.requireLines = exports.linesAfterReview = exports.writeThread = exports.threadRulesForPrompt = exports.threadProblems = exports.namesTerm = exports.findPositionPhrases = exports.countSentences = exports.countWords = exports.THREAD_LIMITS = void 0;
42
42
  const zod_1 = require("zod");
43
43
  const langChain_js_1 = __importStar(require("./langChain.js"));
44
44
  const cancellation_js_1 = require("./cancellation.js");
@@ -395,12 +395,53 @@ const writeThread = async (input) => {
395
395
  return { lines: null, problems: second.problems, attempts: 2, ...("error" in second ? { error: second.error } : {}) };
396
396
  };
397
397
  exports.writeThread = writeThread;
398
+ /**
399
+ * Which text each thread place of a lesson keeps after its review. A review (a
400
+ * reviewer's fix, applied by the Judge or automatically) may have rewritten or
401
+ * removed a line after the writer wrote it. Per line, and independent of the
402
+ * other: the candidate is the on-page text, trimmed, when it is a non-blank
403
+ * string, else the written line. The opening keeps its candidate when
404
+ * `threadProblems({ opening: candidate, closing: written.closing })` is empty,
405
+ * else it goes back to `written.opening`; the closing likewise, checked beside
406
+ * the written opening. A null, absent, blank or non-string place counts as gone.
407
+ * Never throws for an odd `onPage`, and changes neither argument.
408
+ */
409
+ const linesAfterReview = (onPage, written, planContext) => {
410
+ const candidateFor = (place, fallback) => (typeof place === "string" && place.trim() !== "" ? place.trim() : fallback);
411
+ const opening = candidateFor(onPage?.opening, written.opening);
412
+ const closing = candidateFor(onPage?.closing, written.closing);
413
+ return {
414
+ opening: (0, exports.threadProblems)({ opening, closing: written.closing }, planContext).length === 0 ? opening : written.opening,
415
+ closing: (0, exports.threadProblems)({ opening: written.opening, closing }, planContext).length === 0 ? closing : written.closing,
416
+ };
417
+ };
418
+ exports.linesAfterReview = linesAfterReview;
419
+ /**
420
+ * For a thread-only update, where a lesson without both lines is a failure.
421
+ * Answers `result.lines` when they are there; else throws `result.error`
422
+ * itself when there is one; else throws an Error whose message is the JSON of
423
+ * `{ code: 502, message }`, the message naming `result.problems` (joined by a
424
+ * space) after "The thread lines could not be written: ", or just that
425
+ * sentence without the colon when there are none.
426
+ * @throws The call's own error, or a 502
427
+ */
428
+ const requireLines = (result) => {
429
+ if (result.lines)
430
+ return result.lines;
431
+ if (result.error !== undefined && result.error !== null)
432
+ throw result.error;
433
+ const problems = (result.problems ?? []).join(" ");
434
+ throw new Error(JSON.stringify({ code: 502, message: problems === "" ? "The thread lines could not be written" : `The thread lines could not be written: ${problems}` }));
435
+ };
436
+ exports.requireLines = requireLines;
398
437
  exports.default = {
399
438
  THREAD_LIMITS: exports.THREAD_LIMITS,
400
439
  countSentences: exports.countSentences,
401
440
  countWords: exports.countWords,
402
441
  findPositionPhrases: exports.findPositionPhrases,
442
+ linesAfterReview: exports.linesAfterReview,
403
443
  namesTerm: exports.namesTerm,
444
+ requireLines: exports.requireLines,
404
445
  threadProblems: exports.threadProblems,
405
446
  threadRulesForPrompt: exports.threadRulesForPrompt,
406
447
  writeThread: exports.writeThread,
@@ -1,3 +1,3 @@
1
1
  /** This package's version, written by scripts/write-version.js at build time; do not edit. */
2
- export declare const VERSION = "1.32.0";
2
+ export declare const VERSION = "1.33.0";
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  /** This package's version, written by scripts/write-version.js at build time; do not edit. */
5
- exports.VERSION = "1.32.0";
5
+ exports.VERSION = "1.33.0";
@@ -48,6 +48,6 @@ export { learningActivityMedia };
48
48
  export { learningContentPlan };
49
49
  export { learningContentThread };
50
50
  export type { ContentPlan, ContentPlanExtension, ContentPlanLesson, ContentPlanTerm, LearningContentThread, LearningContentThreadSentence } from "./learningContentPlan.js";
51
- export type { PlanContext, ThreadLines, WriteThreadInput, WriteThreadResult } from "./learningContentThread.js";
51
+ export type { PlanContext, ThreadLines, ThreadLinesOnPage, WriteThreadInput, WriteThreadResult } from "./learningContentThread.js";
52
52
  export type { ActivityContentField, ActivityMediaChoices, ActivityMediaOptions, ActivityMediaPlatform, ActivityMediaSummary, ActivityMediaTarget, MediaCount, MediaIntegrationChoice, MotionGraphicStyle, } from "./learningActivityMedia.js";
53
53
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,aAAa,EAAE,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAC7D,OAAO,gBAAgB,EAAE,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,kBAAkB,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC7G,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC7G,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,OAAO,MAAM,oBA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S,GACV,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC;AAE3F,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,eAAe,EACf,WAAW,EACX,aAAa,EACb,oBAAoB,GACrB,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAEjC,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAEjC,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,eAAe,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAE5K,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEnI,YAAY,EACV,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,4BAA4B,CAAC"}
@@ -46,6 +46,17 @@ export declare const planExtensionSchema: z.ZodType<ContentPlanExtension>;
46
46
  * null becomes "", the three booleans default to false, the lists to [].
47
47
  */
48
48
  export declare const planContextSchema: z.ZodType<LearningContentPlanContext>;
49
+ /**
50
+ * What a lesson agent calls on the `planContext` of its request before it does
51
+ * any work. `undefined` and `null` answer `undefined` (no plan context). A value
52
+ * that {@link planContextSchema} parses answers the parsed context. Anything else
53
+ * throws an Error whose message is the JSON of `{ code: 400, message }`, the
54
+ * message being "Schema validation error: planContext", then the first issue's
55
+ * path (joined with ".", behind a leading "." when not empty), then " - " and the
56
+ * first issue's message. Changes nothing it is given.
57
+ * @throws A 400 for a value that is not a plan context
58
+ */
59
+ export declare const readPlanContext: (value: unknown) => LearningContentPlanContext | undefined;
49
60
  /**
50
61
  * What does not fit between a plan and the skill it is for, one sentence each,
51
62
  * each sentence once, in the order first met. `[]` when it fits. It never
@@ -96,6 +107,7 @@ declare const _default: {
96
107
  }>;
97
108
  planSchema: z.ZodType<ContentPlan, unknown, z.core.$ZodTypeInternals<ContentPlan, unknown>>;
98
109
  planContextSchema: z.ZodType<learningContentPlan.LearningContentPlanContext, unknown, z.core.$ZodTypeInternals<learningContentPlan.LearningContentPlanContext, unknown>>;
110
+ readPlanContext: (value: unknown) => LearningContentPlanContext | undefined;
99
111
  planProblems: (plan: ContentPlan, microSkillIds: unknown[]) => string[];
100
112
  planExtensionSchema: z.ZodType<ContentPlanExtension, unknown, z.core.$ZodTypeInternals<ContentPlanExtension, unknown>>;
101
113
  extensionProblems: (extension: ContentPlanExtension, existingPlan: unknown, microSkillIds: unknown[]) => string[];
@@ -1 +1 @@
1
- {"version":3,"file":"learningContentPlan.d.ts","sourceRoot":"","sources":["../../src/learningContentPlan.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAE1E,2GAA2G;AAC3G,eAAO,MAAM,WAAW;;;;;;;;EAAyE,CAAC;AAElG,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACn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OAAO,OAAO,KAAG,0BAA0B,GAAG,SAO7E,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,WAAW,EAAE,eAAe,OAAO,EAAE,KAAG,MAAM,EA2ChF,CAAC;AAMF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,iBAAiB,GAAI,WAAW,oBAAoB,EAAE,cAAc,OAAO,EAAE,eAAe,OAAO,EAAE,KAAG,MAAM,EAqE1H,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,cAAc,OAAO,EAAE,WAAW,oBAAoB,KAAG,WAc3F,CAAC;AAEF,uFAAuF;AACvF,YAAY,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,sFAAsF;AACtF,YAAY,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;;;;;;;;;;;;;6BAnLtC,OAAO,KAAG,0BAA0B,GAAG,SAAS;yBAkBpD,WAAW,iBAAiB,OAAO,EAAE,KAAG,MAAM,EAAE;;mCAiEtC,oBAAoB,gBAAgB,OAAO,iBAAiB,OAAO,EAAE,KAAG,MAAM,EAAE;uCA6E5E,OAAO,aAAa,oBAAoB,KAAG,WAAW;;AAqBvG,wBASE"}
@@ -112,6 +112,26 @@ export const planContextSchema = z.object({
112
112
  buildsOn: z.array(z.object({ term: z.string(), definition: z.string() })).default([]),
113
113
  ownedTerms: z.array(z.object({ term: z.string(), definition: z.string() })).default([]),
114
114
  });
115
+ /**
116
+ * What a lesson agent calls on the `planContext` of its request before it does
117
+ * any work. `undefined` and `null` answer `undefined` (no plan context). A value
118
+ * that {@link planContextSchema} parses answers the parsed context. Anything else
119
+ * throws an Error whose message is the JSON of `{ code: 400, message }`, the
120
+ * message being "Schema validation error: planContext", then the first issue's
121
+ * path (joined with ".", behind a leading "." when not empty), then " - " and the
122
+ * first issue's message. Changes nothing it is given.
123
+ * @throws A 400 for a value that is not a plan context
124
+ */
125
+ export const readPlanContext = (value) => {
126
+ if (value === undefined || value === null)
127
+ return undefined;
128
+ const parsed = planContextSchema.safeParse(value);
129
+ if (parsed.success)
130
+ return parsed.data;
131
+ const issue = parsed.error.issues[0];
132
+ const path = issue.path.length > 0 ? `.${issue.path.join(".")}` : "";
133
+ throw new Error(JSON.stringify({ code: 400, message: `Schema validation error: planContext${path} - ${issue.message}` }));
134
+ };
115
135
  /**
116
136
  * What does not fit between a plan and the skill it is for, one sentence each,
117
137
  * each sentence once, in the order first met. `[]` when it fits. It never
@@ -292,6 +312,7 @@ export default {
292
312
  PLAN_LIMITS,
293
313
  planSchema,
294
314
  planContextSchema,
315
+ readPlanContext,
295
316
  planProblems,
296
317
  planExtensionSchema,
297
318
  extensionProblems,
@@ -154,6 +154,33 @@ export interface WriteThreadResult {
154
154
  * @throws The error of a plan context that does not parse, or of a cancelled request or a 402
155
155
  */
156
156
  export declare const writeThread: (input: WriteThreadInput) => Promise<WriteThreadResult>;
157
+ /** What stands at the two thread places of a lesson after its review. A place that is gone, or blank, is null or absent. */
158
+ export interface ThreadLinesOnPage {
159
+ opening?: string | null;
160
+ closing?: string | null;
161
+ }
162
+ /**
163
+ * Which text each thread place of a lesson keeps after its review. A review (a
164
+ * reviewer's fix, applied by the Judge or automatically) may have rewritten or
165
+ * removed a line after the writer wrote it. Per line, and independent of the
166
+ * other: the candidate is the on-page text, trimmed, when it is a non-blank
167
+ * string, else the written line. The opening keeps its candidate when
168
+ * `threadProblems({ opening: candidate, closing: written.closing })` is empty,
169
+ * else it goes back to `written.opening`; the closing likewise, checked beside
170
+ * the written opening. A null, absent, blank or non-string place counts as gone.
171
+ * Never throws for an odd `onPage`, and changes neither argument.
172
+ */
173
+ export declare const linesAfterReview: (onPage: ThreadLinesOnPage, written: ThreadLines, planContext: PlanContext) => ThreadLines;
174
+ /**
175
+ * For a thread-only update, where a lesson without both lines is a failure.
176
+ * Answers `result.lines` when they are there; else throws `result.error`
177
+ * itself when there is one; else throws an Error whose message is the JSON of
178
+ * `{ code: 502, message }`, the message naming `result.problems` (joined by a
179
+ * space) after "The thread lines could not be written: ", or just that
180
+ * sentence without the colon when there are none.
181
+ * @throws The call's own error, or a 502
182
+ */
183
+ export declare const requireLines: (result: WriteThreadResult) => ThreadLines;
157
184
  declare const _default: {
158
185
  THREAD_LIMITS: Readonly<{
159
186
  OPENING_WORDS: 60;
@@ -164,7 +191,9 @@ declare const _default: {
164
191
  countSentences: (text: string) => number;
165
192
  countWords: (text: string) => number;
166
193
  findPositionPhrases: (text: string) => string[];
194
+ linesAfterReview: (onPage: ThreadLinesOnPage, written: ThreadLines, planContext: PlanContext) => ThreadLines;
167
195
  namesTerm: (text: string, term: string) => boolean;
196
+ requireLines: (result: WriteThreadResult) => ThreadLines;
168
197
  threadProblems: (lines: ThreadLines, planContext: PlanContext) => string[];
169
198
  threadRulesForPrompt: () => {
170
199
  opening: {
@@ -1 +1 @@
1
- {"version":3,"file":"learningContentThread.d.ts","sourceRoot":"","sources":["../../src/learningContentThread.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAG1E,yHAAyH;AACzH,eAAO,MAAM,aAAa;;;;;EAAsG,CAAC;AAEjI,sFAAsF;AACtF,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qFAAqF;AACrF,MAAM,MAAM,WAAW,GAAG,0BAA0B,CAAC;AAOrD;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,KAAG,MAGK,CAAC;AA0BhD;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,KAAG,MA2B7C,CAAC;AA2CF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,KAAG,MAAM,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E,MAAM,EAAE,CAAC;KACpC;yBAqDwC,gBAAgB,KAAG,OAAO,CAAC,iBAAiB,CAAC;;AAsFtF,wBAWE"}
@@ -352,12 +352,51 @@ export const writeThread = async (input) => {
352
352
  return { lines: second.lines, problems: [], attempts: 2 };
353
353
  return { lines: null, problems: second.problems, attempts: 2, ...("error" in second ? { error: second.error } : {}) };
354
354
  };
355
+ /**
356
+ * Which text each thread place of a lesson keeps after its review. A review (a
357
+ * reviewer's fix, applied by the Judge or automatically) may have rewritten or
358
+ * removed a line after the writer wrote it. Per line, and independent of the
359
+ * other: the candidate is the on-page text, trimmed, when it is a non-blank
360
+ * string, else the written line. The opening keeps its candidate when
361
+ * `threadProblems({ opening: candidate, closing: written.closing })` is empty,
362
+ * else it goes back to `written.opening`; the closing likewise, checked beside
363
+ * the written opening. A null, absent, blank or non-string place counts as gone.
364
+ * Never throws for an odd `onPage`, and changes neither argument.
365
+ */
366
+ export const linesAfterReview = (onPage, written, planContext) => {
367
+ const candidateFor = (place, fallback) => (typeof place === "string" && place.trim() !== "" ? place.trim() : fallback);
368
+ const opening = candidateFor(onPage?.opening, written.opening);
369
+ const closing = candidateFor(onPage?.closing, written.closing);
370
+ return {
371
+ opening: threadProblems({ opening, closing: written.closing }, planContext).length === 0 ? opening : written.opening,
372
+ closing: threadProblems({ opening: written.opening, closing }, planContext).length === 0 ? closing : written.closing,
373
+ };
374
+ };
375
+ /**
376
+ * For a thread-only update, where a lesson without both lines is a failure.
377
+ * Answers `result.lines` when they are there; else throws `result.error`
378
+ * itself when there is one; else throws an Error whose message is the JSON of
379
+ * `{ code: 502, message }`, the message naming `result.problems` (joined by a
380
+ * space) after "The thread lines could not be written: ", or just that
381
+ * sentence without the colon when there are none.
382
+ * @throws The call's own error, or a 502
383
+ */
384
+ export const requireLines = (result) => {
385
+ if (result.lines)
386
+ return result.lines;
387
+ if (result.error !== undefined && result.error !== null)
388
+ throw result.error;
389
+ const problems = (result.problems ?? []).join(" ");
390
+ throw new Error(JSON.stringify({ code: 502, message: problems === "" ? "The thread lines could not be written" : `The thread lines could not be written: ${problems}` }));
391
+ };
355
392
  export default {
356
393
  THREAD_LIMITS,
357
394
  countSentences,
358
395
  countWords,
359
396
  findPositionPhrases,
397
+ linesAfterReview,
360
398
  namesTerm,
399
+ requireLines,
361
400
  threadProblems,
362
401
  threadRulesForPrompt,
363
402
  writeThread,
@@ -1,3 +1,3 @@
1
1
  /** This package's version, written by scripts/write-version.js at build time; do not edit. */
2
- export declare const VERSION = "1.32.0";
2
+ export declare const VERSION = "1.33.0";
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -1,2 +1,2 @@
1
1
  /** This package's version, written by scripts/write-version.js at build time; do not edit. */
2
- export const VERSION = "1.32.0";
2
+ export const VERSION = "1.33.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackfactor/agent-utils",
3
- "version": "1.32.0",
3
+ "version": "1.33.0",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",