@thanh01.pmt/domain-kit 0.6.2 → 0.6.4

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.
@@ -1,5 +1,5 @@
1
1
  import '../chunk-HRSBIVAW.mjs';
2
- export { CIO_CODE_RE, CONCEPT_CODE_RE, LEARNER_CLAUSE, SIO_CODE_RE, ULO_CODE_RE, assignConceptCodes, auditDepthLayers, auditPhasePlan, auditSyllabusCoverage, authorDepthLayersHierarchically, breakPrerequisiteCycles, cioActionSlug, cioCode, conceptCodeFromName, detectPrerequisiteCycles, escalateAndMapConcepts, extractFeatureSteps, extractFeatureStepsBatched, extractProjectOverview, extractScaffold, generateHybridGraph, generateKnowledgeGraph, sioCode, standardStatement, techTagFor, uloCode, verifyKnowledgeGraph, verifyProjectGraph } from '../chunk-GVBDM746.mjs';
2
+ export { CIO_CODE_RE, CONCEPT_CODE_RE, LEARNER_CLAUSE, SIO_CODE_RE, ULO_CODE_RE, assignConceptCodes, auditDepthLayers, auditPhasePlan, auditSyllabusCoverage, authorDepthLayersHierarchically, breakPrerequisiteCycles, cioActionSlug, cioCode, conceptCodeFromName, detectPrerequisiteCycles, escalateAndMapConcepts, extractFeatureSteps, extractFeatureStepsBatched, extractProjectOverview, extractScaffold, generateHybridGraph, generateKnowledgeGraph, sioCode, standardStatement, techTagFor, uloCode, verifyKnowledgeGraph, verifyProjectGraph } from '../chunk-6MM3MVQ5.mjs';
3
3
  import '../chunk-7A2SG466.mjs';
4
4
  import '../chunk-IBVXXVGE.mjs';
5
5
  import '../chunk-T4Y2DE2W.mjs';
package/dist/index.cjs CHANGED
@@ -3963,11 +3963,16 @@ function excerpt(text, max) {
3963
3963
  const t = (text || "").trim();
3964
3964
  return t.length > max ? t.slice(0, max) + "..." : t;
3965
3965
  }
3966
- async function chatJson(client, system, user, transport) {
3966
+ async function chatJson(client, system, user, onTransport) {
3967
3967
  const r = await client.chat(
3968
3968
  [{ role: "system", content: system }, { role: "user", content: user }],
3969
- { temperature: 0.1, maxTokens: parseInt(process.env.KG_MAX_TOKENS || "65536", 10) }
3969
+ {
3970
+ temperature: 0.1,
3971
+ maxTokens: Math.min(parseInt(process.env.KG_MAX_TOKENS || "16384", 10), 32768)
3972
+ }
3970
3973
  );
3974
+ const t = r._transport ?? transportResultFrom("9router", client.model, { framingStripped: true });
3975
+ onTransport?.(t);
3971
3976
  return parseJsonFromLlm(r.content);
3972
3977
  }
3973
3978
  var LO_BATCH_SIZE = 10;
@@ -3981,6 +3986,10 @@ async function authorDepthLayersHierarchically(client, concepts, techStack, warn
3981
3986
  const uloByConcept = {};
3982
3987
  const cioByConcept = {};
3983
3988
  const sioByConcept = {};
3989
+ let lastTransport;
3990
+ const setTransport = (t) => {
3991
+ lastTransport = t;
3992
+ };
3984
3993
  concepts.map((c) => "- " + c.id + ": " + c.name + (c.description ? " \u2014 " + excerpt(c.description, 160) : "")).join("\n");
3985
3994
  const uloSystem = [
3986
3995
  "You are a Curriculum Design Expert writing Universal Learning Objectives (ULO).",
@@ -4009,7 +4018,7 @@ async function authorDepthLayersHierarchically(client, concepts, techStack, warn
4009
4018
  for (const batch of chunkConcepts(concepts, LO_BATCH_SIZE)) {
4010
4019
  const batchList = batch.map((c) => "- " + c.id + " (" + c.name + ")" + (c.description ? ": " + excerpt(c.description, 160) : "")).join("\n");
4011
4020
  const batchUser = "Concepts:\n" + batchList + '\n\nReturn JSON:\n{"ulos":[{"concept_id":"C1","ulo":"..."}]}';
4012
- const uloRes = await chatJson(client, uloSystem, batchUser, transportResultFrom("9router", client.model, { framingStripped: true }));
4021
+ const uloRes = await chatJson(client, uloSystem, batchUser, setTransport);
4013
4022
  for (const u of uloRes.ulos ?? []) {
4014
4023
  if (u.concept_id && u.ulo) uloByConcept[u.concept_id] = standardStatement(u.ulo);
4015
4024
  }
@@ -4048,7 +4057,7 @@ async function authorDepthLayersHierarchically(client, concepts, techStack, warn
4048
4057
  new Set(batch.map((c) => c.id));
4049
4058
  const batchUloContext = batch.map((c) => "- " + c.id + " (" + c.name + "): " + (uloByConcept[c.id] || "(missing)")).join("\n");
4050
4059
  const batchCioUser = "Approved ULOs:\n" + batchUloContext + '\n\nReturn JSON:\n{"cios":[{"concept_id":"C1","cio":"..."}]}';
4051
- const cioRes = await chatJson(client, cioSystem, batchCioUser, transportResultFrom("9router", client.model, { framingStripped: true }));
4060
+ const cioRes = await chatJson(client, cioSystem, batchCioUser, setTransport);
4052
4061
  for (const x of cioRes.cios ?? []) {
4053
4062
  if (x.concept_id && x.cio) cioByConcept[x.concept_id] = standardStatement(x.cio);
4054
4063
  }
@@ -4101,7 +4110,7 @@ async function authorDepthLayersHierarchically(client, concepts, techStack, warn
4101
4110
  "Return JSON:",
4102
4111
  '{"sios":[{"concept_id":"C1","sio":["...","..."]}]}'
4103
4112
  ].join("\n");
4104
- const sioRes = await chatJson(client, sioSystem, batchSioUser, transportResultFrom("9router", client.model, { framingStripped: true }));
4113
+ const sioRes = await chatJson(client, sioSystem, batchSioUser, setTransport);
4105
4114
  for (const x of sioRes.sios ?? []) {
4106
4115
  if (x.concept_id && Array.isArray(x.sio)) sioByConcept[x.concept_id] = x.sio.map((item) => standardStatement(String(item)));
4107
4116
  }
@@ -4113,14 +4122,17 @@ async function authorDepthLayersHierarchically(client, concepts, techStack, warn
4113
4122
  }
4114
4123
  }
4115
4124
  concepts.map((c) => c.id);
4116
- const auditOnce = () => auditDepthLayers(concepts.map((c) => ({
4117
- id: c.id,
4118
- name: c.name,
4119
- keywords: c.keywords ?? [],
4120
- ulo: uloByConcept[c.id],
4121
- cio: cioByConcept[c.id],
4122
- sio: sioByConcept[c.id]
4123
- })));
4125
+ const auditOnce = () => auditDepthLayers(
4126
+ concepts.map((c) => ({
4127
+ id: c.id,
4128
+ name: c.name,
4129
+ keywords: c.keywords ?? [],
4130
+ ulo: uloByConcept[c.id],
4131
+ cio: cioByConcept[c.id],
4132
+ sio: sioByConcept[c.id]
4133
+ })),
4134
+ lastTransport
4135
+ );
4124
4136
  let audits = auditOnce();
4125
4137
  const repairRound = async (round) => {
4126
4138
  const failingNow = audits.filter((a) => !a.passed);
@@ -4166,7 +4178,7 @@ async function authorDepthLayersHierarchically(client, concepts, techStack, warn
4166
4178
  '{"repairs":[{"concept_id":"C1","ulo":"...","cio":"...","sio":["..."]}]}'
4167
4179
  ].join("\n");
4168
4180
  try {
4169
- const repairRes = await chatJson(client, repairSystem, repairUser);
4181
+ const repairRes = await chatJson(client, repairSystem, repairUser, setTransport);
4170
4182
  for (const r of repairRes.repairs ?? []) {
4171
4183
  if (!r.concept_id) continue;
4172
4184
  if (r.ulo) uloByConcept[r.concept_id] = standardStatement(r.ulo);
@@ -4202,7 +4214,7 @@ async function authorDepthLayersHierarchically(client, concepts, techStack, warn
4202
4214
  "Depth-layer contract audit failed after repair for: " + detail + " \u2014 regenerate or fix the prompt contract (fail-closed, no silent fallback)"
4203
4215
  );
4204
4216
  }
4205
- return { uloByConcept, cioByConcept, sioByConcept, audits, warnings, lastTransport: audits[0]?.transport };
4217
+ return { uloByConcept, cioByConcept, sioByConcept, audits, warnings, lastTransport: lastTransport ?? audits[0]?.transport };
4206
4218
  }
4207
4219
  function cell(v) {
4208
4220
  return (v || "").split(",").map((s) => s.trim()).filter(Boolean);