@aria-framework/ai 0.20.0 → 0.22.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aria-framework/ai",
3
3
  "description": "Aria App Framework — AI module. A dependency-injected model seam (createAiClient) over several providers (LM Studio / OpenAI-compatible / Anthropic), with a fact-preservation guard, generic Polish and Generate writing engines, and a browser polish widget. Prompts and config stay in the consuming app.",
4
- "version": "0.20.0",
4
+ "version": "0.22.0",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
7
7
  "publishConfig": {
@@ -47,7 +47,7 @@
47
47
  }
48
48
  },
49
49
  "scripts": {
50
- "test": "node test/smoke.js && node test/usageStore.js && node test/providerStore.js && node test/speedStore.js && node test/health.js && node test/listModels.js && node test/benchmark.js && node test/lmxDiscovery.js && node test/lmx.js && node test/lmxVerify.js && node test/lmxStore.js && node test/lmxStatus.js && node test/jobCard.js && node test/untrusted.js && node test/packaging.js && node test/views.js && node test/fenced.js"
50
+ "test": "node test/smoke.js && node test/usageStore.js && node test/providerStore.js && node test/speedStore.js && node test/health.js && node test/listModels.js && node test/benchmark.js && node test/lmxDiscovery.js && node test/lmx.js && node test/lmxVerify.js && node test/lmxStore.js && node test/lmxStatus.js && node test/jobCard.js && node test/untrusted.js && node test/packaging.js && node test/views.js && node test/fenced.js && node test/polish.js"
51
51
  },
52
52
  "devDependencies": {
53
53
  "undici": "^8.10.0",
package/polish.js CHANGED
@@ -97,7 +97,27 @@ function system(opts) {
97
97
  return lines.join('\n');
98
98
  }
99
99
 
100
- function normalise(s) { return String(s).replace(/\s+/g, ' ').trim(); }
100
+ /**
101
+ * Two texts are "the same" when they differ only in SPACING NOISE — not when they differ in LINE
102
+ * STRUCTURE.
103
+ *
104
+ * This was `replace(/\s+/g, ' ')`, which collapses newlines along with spaces, and that made the
105
+ * `unchanged` flag structurally wrong for the one mode whose entire job is line structure. `tidy`
106
+ * is instructed to "break walls of text into paragraphs, turn a sequence of steps into a list" —
107
+ * so a SUCCESSFUL tidy of a single paragraph changes nothing but newlines, and the panel said
108
+ * "The model returned the same text — nothing to change." directly beneath the new paragraph
109
+ * break and the model's own note explaining that it had added one.
110
+ *
111
+ * Two contradictory statements and an Accept button, inviting the reader to discard a correct
112
+ * result. Horizontal whitespace is still noise; a line break is content.
113
+ */
114
+ function normalise(s) {
115
+ return String(s)
116
+ .replace(/\r\n?/g, '\n') // line-ending flavour is not a change
117
+ .replace(/[ \t]+/g, ' ') // how many spaces is not a change
118
+ .replace(/ *\n/g, '\n') // a trailing space before a break is not a change
119
+ .trim();
120
+ }
101
121
 
102
122
  /**
103
123
  * @param {(opts:object, cfg?:object) => Promise<object>} complete the client's complete()
package/usageStore.js CHANGED
@@ -114,7 +114,10 @@ function createUsageStore(opts = {}) {
114
114
 
115
115
  const placeholders = cols.map(() => '?').join(', ');
116
116
  const r = await driver.run(
117
- `INSERT INTO ${table} (${cols.join(', ')}) VALUES (${placeholders})`, values);
117
+ // RETURNING, because the id is read back. Empty on SQLite, ` RETURNING "id"` on Postgres —
118
+ // and without it lastId is undefined there, so every caller gets { id: undefined }.
119
+ `INSERT INTO ${table} (${cols.join(', ')}) VALUES (${placeholders})${driver.dialect.returning('id')}`,
120
+ values);
118
121
  return { id: r.lastId };
119
122
  },
120
123