@diegoaltoworks/chatter 0.20.0 → 0.21.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.
@@ -14,7 +14,7 @@ export interface PipelineMessage {
14
14
  content: string;
15
15
  }
16
16
  export interface PreparedChat {
17
- /** Fully assembled system prompt (rules + persona + retrieved context) */
17
+ /** Fully assembled system prompt (see `prepareChat` for the layer order) */
18
18
  system: string;
19
19
  /** Conversation messages, unchanged */
20
20
  messages: PipelineMessage[];
@@ -22,12 +22,24 @@ export interface PreparedChat {
22
22
  /**
23
23
  * Run retrieval for the latest user message and assemble the system prompt.
24
24
  *
25
+ * The assembled system prompt is layered, in order:
26
+ * base rules → persona → channel hint (optional) → retrieved context.
27
+ *
28
+ * `personaLayer` and `channelHint` let a caller shape those middle layers
29
+ * without hand-rolling its own sandwich around `store`/`prompts`. Both are
30
+ * optional, and blank (or whitespace-only) values are ignored: omit them and
31
+ * the prompt is exactly what it has always been.
32
+ *
25
33
  * @throws if the conversation contains no user message
26
34
  */
27
- export declare function prepareChat({ store, prompts, mode, messages, }: {
35
+ export declare function prepareChat({ store, prompts, mode, messages, personaLayer, channelHint, }: {
28
36
  store: VectorStore;
29
37
  prompts: PromptLoader;
30
38
  mode: PipelineMode;
31
39
  messages: PipelineMessage[];
40
+ /** Replaces the mode's persona from the loader when provided */
41
+ personaLayer?: string;
42
+ /** Extra system-prompt section describing the delivery channel */
43
+ channelHint?: string;
32
44
  }): Promise<PreparedChat>;
33
45
  //# sourceMappingURL=pipeline.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/core/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,S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IACnB,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,gEAAgE;IAChE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,YAAY,CAAC,CAmBxB"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Chat pipeline tests
3
+ *
4
+ * Uses faked prompts and vector store so prompt assembly can be asserted
5
+ * without touching OpenAI or Turso.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=pipeline.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.test.d.ts","sourceRoot":"","sources":["../../src/core/pipeline.test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
package/dist/index.js CHANGED
@@ -7768,7 +7768,9 @@ async function prepareChat({
7768
7768
  store,
7769
7769
  prompts,
7770
7770
  mode,
7771
- messages
7771
+ messages,
7772
+ personaLayer,
7773
+ channelHint
7772
7774
  }) {
7773
7775
  const lastUserMsg = [...messages].reverse().find((m) => m.role === "user");
7774
7776
  if (!lastUserMsg) {
@@ -7776,9 +7778,15 @@ async function prepareChat({
7776
7778
  }
7777
7779
  const { topK, label } = MODE_SETTINGS[mode];
7778
7780
  const ctx = await store.query(lastUserMsg.content, topK, ["base", mode]);
7779
- const persona = mode === "private" ? prompts.privatePersona : prompts.publicPersona;
7780
- const system = [prompts.baseSystemRules, persona, `${label}:
7781
- ${ctx.join("\n\n")}`].join("\n\n");
7781
+ const persona = personaLayer?.trim() || (mode === "private" ? prompts.privatePersona : prompts.publicPersona);
7782
+ const hint = channelHint?.trim();
7783
+ const system = [
7784
+ prompts.baseSystemRules,
7785
+ persona,
7786
+ ...hint ? [hint] : [],
7787
+ `${label}:
7788
+ ${ctx.join("\n\n")}`
7789
+ ].join("\n\n");
7782
7790
  return { system, messages };
7783
7791
  }
7784
7792
 
package/dist/index.mjs CHANGED
@@ -7737,7 +7737,9 @@ async function prepareChat({
7737
7737
  store,
7738
7738
  prompts,
7739
7739
  mode,
7740
- messages
7740
+ messages,
7741
+ personaLayer,
7742
+ channelHint
7741
7743
  }) {
7742
7744
  const lastUserMsg = [...messages].reverse().find((m) => m.role === "user");
7743
7745
  if (!lastUserMsg) {
@@ -7745,9 +7747,15 @@ async function prepareChat({
7745
7747
  }
7746
7748
  const { topK, label } = MODE_SETTINGS[mode];
7747
7749
  const ctx = await store.query(lastUserMsg.content, topK, ["base", mode]);
7748
- const persona = mode === "private" ? prompts.privatePersona : prompts.publicPersona;
7749
- const system = [prompts.baseSystemRules, persona, `${label}:
7750
- ${ctx.join("\n\n")}`].join("\n\n");
7750
+ const persona = personaLayer?.trim() || (mode === "private" ? prompts.privatePersona : prompts.publicPersona);
7751
+ const hint = channelHint?.trim();
7752
+ const system = [
7753
+ prompts.baseSystemRules,
7754
+ persona,
7755
+ ...hint ? [hint] : [],
7756
+ `${label}:
7757
+ ${ctx.join("\n\n")}`
7758
+ ].join("\n\n");
7751
7759
  return { system, messages };
7752
7760
  }
7753
7761
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diegoaltoworks/chatter",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "Embeddable AI chatbot framework with RAG, authentication, and customizable widgets",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -94,19 +94,19 @@
94
94
  "zod": "^3.25.76 || ^4.4.3"
95
95
  },
96
96
  "dependencies": {
97
- "jose": "6.2.3"
97
+ "jose": "6.2.8"
98
98
  },
99
99
  "devDependencies": {
100
- "@biomejs/biome": "2.5.6",
100
+ "@biomejs/biome": "2.5.7",
101
101
  "@libsql/client": "0.17.4",
102
102
  "@modelcontextprotocol/sdk": "1.30.0",
103
103
  "@types/bun": "1.3.14",
104
- "@types/node": "26.1.2",
104
+ "@types/node": "26.2.0",
105
105
  "esbuild": "0.28.1",
106
- "hono": "4.12.34",
106
+ "hono": "4.13.1",
107
107
  "husky": "9.1.7",
108
108
  "lint-staged": "17.3.0",
109
- "openai": "7.3.0",
109
+ "openai": "7.4.0",
110
110
  "typescript": "7.0.2",
111
111
  "zod": "4.4.3"
112
112
  },