dsh-diagnostic-tutor 0.1.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.
Files changed (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +658 -0
  3. package/cordis.patch.yml +23 -0
  4. package/lib/api.js +413 -0
  5. package/lib/api.js.map +1 -0
  6. package/lib/client.js +2029 -0
  7. package/lib/client.js.map +1 -0
  8. package/lib/contract.js +14 -0
  9. package/lib/contract.js.map +1 -0
  10. package/lib/diagnosis.js +224 -0
  11. package/lib/diagnosis.js.map +1 -0
  12. package/lib/handoff.js +194 -0
  13. package/lib/handoff.js.map +1 -0
  14. package/lib/index.js +186 -0
  15. package/lib/index.js.map +1 -0
  16. package/lib/lesson.js +285 -0
  17. package/lib/lesson.js.map +1 -0
  18. package/lib/prompt.js +96 -0
  19. package/lib/prompt.js.map +1 -0
  20. package/lib/state.js +500 -0
  21. package/lib/state.js.map +1 -0
  22. package/lib/tools.js +994 -0
  23. package/lib/tools.js.map +1 -0
  24. package/lib/trust-fence.js +101 -0
  25. package/lib/trust-fence.js.map +1 -0
  26. package/lib/types/api.d.ts +62 -0
  27. package/lib/types/api.d.ts.map +1 -0
  28. package/lib/types/contract.d.ts +147 -0
  29. package/lib/types/contract.d.ts.map +1 -0
  30. package/lib/types/diagnosis.d.ts +116 -0
  31. package/lib/types/diagnosis.d.ts.map +1 -0
  32. package/lib/types/handoff.d.ts +141 -0
  33. package/lib/types/handoff.d.ts.map +1 -0
  34. package/lib/types/index.d.ts +71 -0
  35. package/lib/types/index.d.ts.map +1 -0
  36. package/lib/types/lesson.d.ts +295 -0
  37. package/lib/types/lesson.d.ts.map +1 -0
  38. package/lib/types/prompt.d.ts +85 -0
  39. package/lib/types/prompt.d.ts.map +1 -0
  40. package/lib/types/state.d.ts +627 -0
  41. package/lib/types/state.d.ts.map +1 -0
  42. package/lib/types/tools.d.ts +38 -0
  43. package/lib/types/tools.d.ts.map +1 -0
  44. package/lib/types/trust-fence.d.ts +53 -0
  45. package/lib/types/trust-fence.d.ts.map +1 -0
  46. package/lib/types/udt.d.ts +95 -0
  47. package/lib/types/udt.d.ts.map +1 -0
  48. package/lib/types/vocabulary.d.ts +162 -0
  49. package/lib/types/vocabulary.d.ts.map +1 -0
  50. package/lib/udt.js +141 -0
  51. package/lib/udt.js.map +1 -0
  52. package/lib/vocabulary.js +182 -0
  53. package/lib/vocabulary.js.map +1 -0
  54. package/package.json +104 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handoff.d.ts","sourceRoot":"","sources":["../../src/handoff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gBAAgB,kEAAmE,CAAA;AAChG,eAAO,MAAM,mBAAmB;;;;;;EAA2B,CAAA;AAC3D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE/D,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;iBA+BxB,CAAA;AACF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA;AACzD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAA;AAM/B,sDAAsD;AACtD,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,aAAa,GAAG,SAAS,CAAA;CACrC,GAAG,aAAa,CAWhB;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,M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Harness plugin entry point.
3
+ *
4
+ * A DSH plugin is a module exporting `apply(ctx, config)`. Cordis calls it at
5
+ * load time and everything registered through `ctx` is disposed automatically
6
+ * on unload.
7
+ *
8
+ * ---------------------------------------------------------------------------
9
+ * v0.0.3 scope (see docs/planning/PLAN.md §7)
10
+ * ---------------------------------------------------------------------------
11
+ * Goal → detection → diagnosis map. The runtime now carries real product
12
+ * semantics: it records a learning goal in the learner's words, plants a map
13
+ * root, and lets a map grow one diagnosis at a time under rules that make
14
+ * unverified mastery impossible to store.
15
+ *
16
+ * Still deliberately absent:
17
+ * - no lesson generation, no quiz system -> v0.0.4+
18
+ * - no client half / UI -> v0.0.4
19
+ * - no resource ingestion, no RAG -> out of scope for v0.1
20
+ *
21
+ * ---------------------------------------------------------------------------
22
+ * Cross-version discipline (see PLAN.md 2.12 #9 / #16)
23
+ * ---------------------------------------------------------------------------
24
+ * Three harness cohorts can be resolvable at once (the running host, the
25
+ * shared profile fallback, and this package's own store). Therefore:
26
+ *
27
+ * 1. never `export default` — Cordis' `unwrapExports` prefers `.default` and
28
+ * would silently DROP `inject`, so only named exports appear here.
29
+ * 2. every *type* coming from `@deepseek-ai/*` is imported with `import type`
30
+ * (enforced by `verbatimModuleSyntax`), so no second runtime copy is
31
+ * resolved for anything that merely describes a shape.
32
+ * 3. services and instances — `tools`, `storageDomain`, `skills`,
33
+ * `systemPrompt`, the opened `Domain` — are always taken from `ctx` via
34
+ * `ctx.get(...)`, never constructed and never `instanceof`-checked. A
35
+ * cross-cohort copy would make such a check silently false.
36
+ *
37
+ * Pure *builder* helpers (`defineTool`, `defineDomain`, `domainTable`) are the
38
+ * one documented exception: they take plain data and return plain data, so
39
+ * they are imported as values. See the header of `state.ts`.
40
+ */
41
+ import type { Context } from '@deepseek-ai/cordis';
42
+ /**
43
+ * Plugin module name. Stable kebab-case, equal to the loader row `id` in
44
+ * cordis.patch.yml and distinct from the npm package name.
45
+ */
46
+ export declare const name = "diagnostic-tutor";
47
+ /**
48
+ * Services this plugin requires before it may load.
49
+ *
50
+ * Only services the standard profiles guarantee are declared here — both come
51
+ * from `@deepseek-ai/dsh-base`. Everything optional (the skill catalog, the
52
+ * system prompt) is resolved lazily with `ctx.get(...)`, so a profile without
53
+ * them loses the corresponding enhancement instead of leaving the whole plugin
54
+ * tree pending. A pending plugin prints nothing at all, which is hard to
55
+ * diagnose.
56
+ */
57
+ export declare const inject: string[];
58
+ /**
59
+ * Load the plugin.
60
+ *
61
+ * `apply` is async, and Cordis keeps the fiber in `LOADING` until the returned
62
+ * promise settles — so `await ctx.plugin(...)` genuinely waits for the storage
63
+ * domain to be open, for first-run initialization to be durable, and for the
64
+ * tools to be registered. A nested `ctx.inject(...)` would return its own
65
+ * fiber, letting the outer fiber report ACTIVE while the domain was still
66
+ * opening.
67
+ *
68
+ * @param ctx - the Cordis context the loader hands to this plugin.
69
+ */
70
+ export declare function apply(ctx: Context): Promise<void>;
71
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAUlD;;;GAGG;AACH,eAAO,MAAM,IAAI,qBAAqB,CAAA;AAEtC;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM,UAA6B,CAAA;AAEhD;;;;;;;;;;;GAWG;AACH,wBAAsB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CA0HvD"}
@@ -0,0 +1,295 @@
1
+ /**
2
+ * Learning Block and Lesson schemas.
3
+ *
4
+ * The data schema lives here (host side, zod-validated at the durable
5
+ * boundary). The **renderers live in the client half** and are keyed by
6
+ * `block.type`, so adding Formula, Code, Comparison, Practice or Resource later
7
+ * means adding one renderer entry — never rewriting the lesson renderer.
8
+ *
9
+ * A block is `{ id, type, content, metadata? }`: the envelope is uniform and
10
+ * `content` is shaped per type. The envelope is what the renderer registry
11
+ * dispatches on; `content` is what a renderer understands. An unrecognised
12
+ * `type` is not an error — the client falls back to a readable placeholder, so
13
+ * a lesson authored by a newer host still renders in an older browser half.
14
+ *
15
+ * ---------------------------------------------------------------------------
16
+ * What v0.0.4 deliberately does NOT do
17
+ * ---------------------------------------------------------------------------
18
+ * There is no model-generated lesson here. `buildPrototypeLesson` is a
19
+ * **deterministic projection of state the runtime already holds** — the node's
20
+ * own title, relation, state and evidence — assembled into the four block
21
+ * types. It exists to prove the schema and the renderer end to end.
22
+ *
23
+ * That is why every lesson carries `origin`. A prototype lesson can never be
24
+ * mistaken for teaching content, and when real generation arrives it will be
25
+ * distinguishable in the stored record rather than by convention.
26
+ */
27
+ import { z } from 'zod';
28
+ import type { CourseRecord, NodeRecord } from './state.js';
29
+ /**
30
+ * A teaching unit is a few blocks, not a chapter.
31
+ *
32
+ * The cap is what makes "never generate a whole course in one call" structural
33
+ * rather than advisory — the same reasoning as the diagnosis map's node caps.
34
+ * Six leaves room for a real unit (orient, example, diagram, check) plus a
35
+ * correction.
36
+ */
37
+ export declare const MAX_BLOCKS_PER_UPDATE = 6;
38
+ /**
39
+ * A lesson accumulates across a session, so its ceiling is higher than one
40
+ * call's — but it is still a ceiling. Past this the lesson has stopped being a
41
+ * learning surface and become a document.
42
+ */
43
+ export declare const MAX_BLOCKS_PER_LESSON = 24;
44
+ /**
45
+ * Per-field length caps, enforced by zod at the durable boundary.
46
+ *
47
+ * Structural validation alone would accept a single 5 MB text block; these make
48
+ * "oversized payload" a rejection rather than a rendering problem.
49
+ */
50
+ export declare const MAX_TEXT_CHARS = 6000;
51
+ export declare const MAX_DIAGRAM_CHARS = 4000;
52
+ export declare const MAX_PROMPT_CHARS = 1000;
53
+ export declare const MAX_TITLE_CHARS = 200;
54
+ export declare const MAX_STEP_CHARS = 400;
55
+ export declare const MAX_STEPS = 12;
56
+ export declare const TextBlockSchema: z.ZodObject<{
57
+ type: z.ZodLiteral<"text">;
58
+ content: z.ZodObject<{
59
+ md: z.ZodString;
60
+ }, z.core.$strip>;
61
+ id: z.ZodString;
62
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
63
+ }, z.core.$strip>;
64
+ export declare const ExampleBlockSchema: z.ZodObject<{
65
+ type: z.ZodLiteral<"example">;
66
+ content: z.ZodObject<{
67
+ title: z.ZodString;
68
+ steps: z.ZodArray<z.ZodString>;
69
+ takeaway: z.ZodOptional<z.ZodString>;
70
+ }, z.core.$strip>;
71
+ id: z.ZodString;
72
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
73
+ }, z.core.$strip>;
74
+ export declare const DiagramBlockSchema: z.ZodObject<{
75
+ type: z.ZodLiteral<"diagram">;
76
+ content: z.ZodObject<{
77
+ format: z.ZodEnum<{
78
+ ascii: "ascii";
79
+ mermaid: "mermaid";
80
+ }>;
81
+ spec: z.ZodString;
82
+ caption: z.ZodOptional<z.ZodString>;
83
+ }, z.core.$strip>;
84
+ id: z.ZodString;
85
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
86
+ }, z.core.$strip>;
87
+ export declare const CheckBlockSchema: z.ZodObject<{
88
+ type: z.ZodLiteral<"check">;
89
+ content: z.ZodObject<{
90
+ prompt: z.ZodString;
91
+ expect: z.ZodOptional<z.ZodEnum<{
92
+ reasoning: "reasoning";
93
+ answer: "answer";
94
+ }>>;
95
+ hint: z.ZodOptional<z.ZodString>;
96
+ }, z.core.$strip>;
97
+ id: z.ZodString;
98
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
99
+ }, z.core.$strip>;
100
+ /** Every block type this version understands. */
101
+ export declare const BLOCK_SCHEMAS: readonly [z.ZodObject<{
102
+ type: z.ZodLiteral<"text">;
103
+ content: z.ZodObject<{
104
+ md: z.ZodString;
105
+ }, z.core.$strip>;
106
+ id: z.ZodString;
107
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
108
+ }, z.core.$strip>, z.ZodObject<{
109
+ type: z.ZodLiteral<"example">;
110
+ content: z.ZodObject<{
111
+ title: z.ZodString;
112
+ steps: z.ZodArray<z.ZodString>;
113
+ takeaway: z.ZodOptional<z.ZodString>;
114
+ }, z.core.$strip>;
115
+ id: z.ZodString;
116
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
117
+ }, z.core.$strip>, z.ZodObject<{
118
+ type: z.ZodLiteral<"diagram">;
119
+ content: z.ZodObject<{
120
+ format: z.ZodEnum<{
121
+ ascii: "ascii";
122
+ mermaid: "mermaid";
123
+ }>;
124
+ spec: z.ZodString;
125
+ caption: z.ZodOptional<z.ZodString>;
126
+ }, z.core.$strip>;
127
+ id: z.ZodString;
128
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
129
+ }, z.core.$strip>, z.ZodObject<{
130
+ type: z.ZodLiteral<"check">;
131
+ content: z.ZodObject<{
132
+ prompt: z.ZodString;
133
+ expect: z.ZodOptional<z.ZodEnum<{
134
+ reasoning: "reasoning";
135
+ answer: "answer";
136
+ }>>;
137
+ hint: z.ZodOptional<z.ZodString>;
138
+ }, z.core.$strip>;
139
+ id: z.ZodString;
140
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
141
+ }, z.core.$strip>];
142
+ export declare const BlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
143
+ type: z.ZodLiteral<"text">;
144
+ content: z.ZodObject<{
145
+ md: z.ZodString;
146
+ }, z.core.$strip>;
147
+ id: z.ZodString;
148
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
149
+ }, z.core.$strip>, z.ZodObject<{
150
+ type: z.ZodLiteral<"example">;
151
+ content: z.ZodObject<{
152
+ title: z.ZodString;
153
+ steps: z.ZodArray<z.ZodString>;
154
+ takeaway: z.ZodOptional<z.ZodString>;
155
+ }, z.core.$strip>;
156
+ id: z.ZodString;
157
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
158
+ }, z.core.$strip>, z.ZodObject<{
159
+ type: z.ZodLiteral<"diagram">;
160
+ content: z.ZodObject<{
161
+ format: z.ZodEnum<{
162
+ ascii: "ascii";
163
+ mermaid: "mermaid";
164
+ }>;
165
+ spec: z.ZodString;
166
+ caption: z.ZodOptional<z.ZodString>;
167
+ }, z.core.$strip>;
168
+ id: z.ZodString;
169
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
170
+ }, z.core.$strip>, z.ZodObject<{
171
+ type: z.ZodLiteral<"check">;
172
+ content: z.ZodObject<{
173
+ prompt: z.ZodString;
174
+ expect: z.ZodOptional<z.ZodEnum<{
175
+ reasoning: "reasoning";
176
+ answer: "answer";
177
+ }>>;
178
+ hint: z.ZodOptional<z.ZodString>;
179
+ }, z.core.$strip>;
180
+ id: z.ZodString;
181
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
182
+ }, z.core.$strip>], "type">;
183
+ export type TextBlock = z.infer<typeof TextBlockSchema>;
184
+ export type ExampleBlock = z.infer<typeof ExampleBlockSchema>;
185
+ export type DiagramBlock = z.infer<typeof DiagramBlockSchema>;
186
+ export type CheckBlock = z.infer<typeof CheckBlockSchema>;
187
+ export type Block = z.infer<typeof BlockSchema>;
188
+ export type BlockType = Block['type'];
189
+ /** The block types this build can render, for diagnostics and tests. */
190
+ export declare const SUPPORTED_BLOCK_TYPES: readonly BlockType[];
191
+ /**
192
+ * `tutor` is what the runtime writes now: blocks the teaching brain submitted
193
+ * through `udt_lesson_update`.
194
+ *
195
+ * `prototype` is retained rather than removed because v0.0.4 wrote records with
196
+ * it, and the domain version cannot be bumped to invalidate them (the `single`
197
+ * layout rejects a version mismatch outright — see `state.ts`). It is no longer
198
+ * produced by the runtime.
199
+ */
200
+ export declare const LESSON_ORIGINS: readonly ["prototype", "tutor"];
201
+ export declare const LessonOriginSchema: z.ZodEnum<{
202
+ prototype: "prototype";
203
+ tutor: "tutor";
204
+ }>;
205
+ export type LessonOrigin = z.infer<typeof LessonOriginSchema>;
206
+ export declare const LessonSchema: z.ZodObject<{
207
+ id: z.ZodString;
208
+ courseId: z.ZodString;
209
+ nodeId: z.ZodString;
210
+ title: z.ZodString;
211
+ blocks: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
212
+ type: z.ZodLiteral<"text">;
213
+ content: z.ZodObject<{
214
+ md: z.ZodString;
215
+ }, z.core.$strip>;
216
+ id: z.ZodString;
217
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
218
+ }, z.core.$strip>, z.ZodObject<{
219
+ type: z.ZodLiteral<"example">;
220
+ content: z.ZodObject<{
221
+ title: z.ZodString;
222
+ steps: z.ZodArray<z.ZodString>;
223
+ takeaway: z.ZodOptional<z.ZodString>;
224
+ }, z.core.$strip>;
225
+ id: z.ZodString;
226
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
227
+ }, z.core.$strip>, z.ZodObject<{
228
+ type: z.ZodLiteral<"diagram">;
229
+ content: z.ZodObject<{
230
+ format: z.ZodEnum<{
231
+ ascii: "ascii";
232
+ mermaid: "mermaid";
233
+ }>;
234
+ spec: z.ZodString;
235
+ caption: z.ZodOptional<z.ZodString>;
236
+ }, z.core.$strip>;
237
+ id: z.ZodString;
238
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
239
+ }, z.core.$strip>, z.ZodObject<{
240
+ type: z.ZodLiteral<"check">;
241
+ content: z.ZodObject<{
242
+ prompt: z.ZodString;
243
+ expect: z.ZodOptional<z.ZodEnum<{
244
+ reasoning: "reasoning";
245
+ answer: "answer";
246
+ }>>;
247
+ hint: z.ZodOptional<z.ZodString>;
248
+ }, z.core.$strip>;
249
+ id: z.ZodString;
250
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
251
+ }, z.core.$strip>], "type">>;
252
+ origin: z.ZodEnum<{
253
+ prototype: "prototype";
254
+ tutor: "tutor";
255
+ }>;
256
+ createdAt: z.ZodString;
257
+ updatedAt: z.ZodString;
258
+ }, z.core.$strip>;
259
+ export type LessonRecord = z.infer<typeof LessonSchema>;
260
+ export type LessonKey = string;
261
+ /**
262
+ * Build a prototype lesson for one node.
263
+ *
264
+ * **Not on the runtime path any more.** v0.0.5 teaches through the tutor, and
265
+ * `udt_lesson_update` is how blocks arrive. This builder is kept for two
266
+ * honest reasons: v0.0.4 wrote `origin: 'prototype'` records that must still
267
+ * parse, and it is a convenient deterministic fixture for the preview and the
268
+ * block-renderer tests.
269
+ *
270
+ * It projects stored state into the four block types — it does not invent
271
+ * teaching content.
272
+ *
273
+ * @param input.course - the course the node belongs to.
274
+ * @param input.node - the node to build for.
275
+ * @param input.nodes - every node of the course, for the map diagram.
276
+ * @param input.now - ISO timestamp.
277
+ * @returns a validated lesson record.
278
+ */
279
+ export declare function buildPrototypeLesson(input: {
280
+ course: CourseRecord;
281
+ node: NodeRecord;
282
+ nodes: readonly NodeRecord[];
283
+ now: string;
284
+ }): LessonRecord;
285
+ /**
286
+ * Read a block's type without trusting the value.
287
+ *
288
+ * Used by the client's renderer registry so an unknown type degrades instead of
289
+ * throwing.
290
+ *
291
+ * @param value - any parsed block-shaped value.
292
+ * @returns the declared type, or `undefined`.
293
+ */
294
+ export declare function blockTypeOf(value: unknown): string | undefined;
295
+ //# sourceMappingURL=lesson.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lesson.d.ts","sourceRoot":"","sources":["../../src/lesson.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA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MAAM,qBAAqB,EAAE,SAAS,SAAS,EAErD,CAAA;AAMD;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,iCAAkC,CAAA;AAC7D,eAAO,MAAM,kBAAkB;;;EAAyB,CAAA;AACxD,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAE7D,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAUvB,CAAA;AACF,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AACvD,MAAM,MAAM,SAAS,GAAG,MAAM,CAAA;AAsD9B;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAC1C,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,EAAE,UAAU,CAAA;IAChB,KAAK,EAAE,SAAS,UAAU,EAAE,CAAA;IAC5B,GAAG,EAAE,MAAM,CAAA;CACZ,GAAG,YAAY,CA2Df;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAI9D"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Waking the teaching brain.
3
+ *
4
+ * "Start learning" is a UI act, but teaching happens in the chat — so the panel
5
+ * needs a way to tell the tutor that a node is now in focus. This module is
6
+ * that hand-off: it composes one ordinary user-role turn from the plugin and
7
+ * delivers it to the agent that owns the learner's session.
8
+ *
9
+ * Why a user-role message rather than injected context: `agent.inject()` adds
10
+ * model-visible context but **does not wake an idle agent**, so nothing would
11
+ * happen until the learner typed something. `followup()` opens a turn, which is
12
+ * exactly the intent of pressing the button. `@deepseek-ai/dsh-command-goal`
13
+ * and `dsh-headless` do the same thing for the same reason.
14
+ *
15
+ * The source is `{ kind: 'diagnostic-tutor' }` — the plugin declares its own
16
+ * kind. Harness 0.1.7 removed the shared catch-all `plugin` kind: a producer now
17
+ * merges its own entry into `MessageSourceMap`, and the augmentation below is
18
+ * that declaration. It is also what makes the value type-check at all, so a
19
+ * future rename cannot drift out of sync silently.
20
+ *
21
+ * Note what this module does **not** do: it does not decide what to teach. It
22
+ * reports which node the learner selected and asks the tutor to begin. Every
23
+ * teaching decision stays with the teaching brain.
24
+ */
25
+ import type { Context } from '@deepseek-ai/cordis';
26
+ import type { CourseRecord, NodeRecord } from './state.js';
27
+ /**
28
+ * Attribution for every turn this plugin opens.
29
+ *
30
+ * Must equal the declared kind below; TypeScript enforces it, because the value
31
+ * is passed where the augmented union is expected.
32
+ */
33
+ export declare const PLUGIN_SOURCE = "diagnostic-tutor";
34
+ /**
35
+ * Declare this plugin's message-source kind.
36
+ *
37
+ * Harness 0.1.7 has no shared catch-all `plugin` kind (see `MessageSourceMap`
38
+ * in `@deepseek-ai/dsh-llm`): `kind` is merge-extensible and each producer names
39
+ * itself in its own module. `dsh-schedule`, `dsh-webhook` and `agent-team` all
40
+ * do exactly this.
41
+ *
42
+ * The literal is repeated rather than referenced through `PLUGIN_SOURCE`,
43
+ * because a module augmentation needs a literal type. The two cannot drift: the
44
+ * assignment below fails to compile if they disagree.
45
+ */
46
+ declare module '@deepseek-ai/dsh-llm' {
47
+ interface MessageSourceMap {
48
+ 'diagnostic-tutor': {
49
+ readonly kind: 'diagnostic-tutor';
50
+ };
51
+ }
52
+ }
53
+ export interface FocusPromptResult {
54
+ /** Whether a turn was actually opened. */
55
+ readonly prompted: boolean;
56
+ /** Why not, when `prompted` is false. Surfaced to the panel, not to the learner as an error. */
57
+ readonly reason?: string;
58
+ }
59
+ /**
60
+ * Compose the turn text.
61
+ *
62
+ * Written in the learner's voice, because it lands in the transcript they are
63
+ * reading: it should look like the button they just pressed, not like a system
64
+ * directive. It states the node and the expected shape of the reply, and stops
65
+ * — the tool descriptions carry the detail about blocks and caps.
66
+ *
67
+ * @param course - the course being learned.
68
+ * @param node - the node put in focus.
69
+ * @returns the message text.
70
+ */
71
+ export declare function focusPromptText(course: CourseRecord, node: NodeRecord): string;
72
+ /**
73
+ * Deliver one turn to the agent that owns a session.
74
+ *
75
+ * Never throws for a missing agent: the focus has already been recorded by the
76
+ * time this runs, and the tutor can pick it up on the next turn regardless. A
77
+ * graceful "not prompted" keeps the button useful in every configuration.
78
+ *
79
+ * @param ctx - the plugin's context.
80
+ * @param sessionId - the session the panel is showing, when it knows one.
81
+ * @param text - the turn text.
82
+ * @returns whether a turn was opened, and why not when it was not.
83
+ */
84
+ export declare function promptSession(ctx: Context, sessionId: string | undefined, text: string): FocusPromptResult;
85
+ //# sourceMappingURL=prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAGlD,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,aAAa,qBAAqB,CAAA;AAE/C;;;;;;;;;;;GAWG;AACH,OAAO,QAAQ,sBAAsB,CAAC;IACpC,UAAU,gBAAgB;QACxB,kBAAkB,EAAE;YAAE,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAA;SAAE,CAAA;KAC1D;CACF;AAED,MAAM,WAAW,iBAAiB;IAChC,0CAA0C;IAC1C,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,gGAAgG;IAChG,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,CAM9E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,iBAAiB,CAsC1G"}