@rei-standard/amsg-server 2.4.0 → 2.5.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/dist/index.cjs CHANGED
@@ -515,13 +515,23 @@ function readReasoningContent(llmResponse) {
515
515
  );
516
516
  if (!Array.isArray(choices) || choices.length === 0) return null;
517
517
  const message = (
518
- /** @type {{ message?: { reasoning_content?: unknown } }} */
518
+ /** @type {{ message?: { reasoning_content?: unknown, content?: unknown } }} */
519
519
  _optionalChain([choices, 'access', _2 => _2[0], 'optionalAccess', _3 => _3.message])
520
520
  );
521
521
  const raw = _optionalChain([message, 'optionalAccess', _4 => _4.reasoning_content]);
522
- if (typeof raw !== "string") return null;
523
- const trimmed = raw.trim();
524
- return trimmed.length > 0 ? trimmed : null;
522
+ if (typeof raw === "string") {
523
+ const trimmed = raw.trim();
524
+ if (trimmed.length > 0) return trimmed;
525
+ }
526
+ const content = _optionalChain([message, 'optionalAccess', _5 => _5.content]);
527
+ if (typeof content === "string") {
528
+ const match = content.match(/<(think|thinking|thought)>([\s\S]*?)<\/\1>/i);
529
+ if (match) {
530
+ const trimmed = match[2].trim();
531
+ if (trimmed.length > 0) return trimmed;
532
+ }
533
+ }
534
+ return null;
525
535
  }
526
536
  async function processSingleMessage(task, ctx, providedMasterKey) {
527
537
  try {
@@ -694,7 +704,7 @@ async function _callAI(payload) {
694
704
  );
695
705
  }
696
706
  const aiData = await aiResponse.json();
697
- const content = _optionalChain([aiData, 'optionalAccess', _5 => _5.choices, 'optionalAccess', _6 => _6[0], 'optionalAccess', _7 => _7.message, 'optionalAccess', _8 => _8.content]);
707
+ const content = _optionalChain([aiData, 'optionalAccess', _6 => _6.choices, 'optionalAccess', _7 => _7[0], 'optionalAccess', _8 => _8.message, 'optionalAccess', _9 => _9.content]);
698
708
  if (typeof content !== "string" || !content.trim()) {
699
709
  throw new Error("AI API error: response missing choices[0].message.content");
700
710
  }
@@ -1378,7 +1388,7 @@ async function resolveBlobStore(namespace) {
1378
1388
  }
1379
1389
  try {
1380
1390
  const blobModule = await Promise.resolve().then(() => _interopRequireWildcard(require("@netlify/blobs")));
1381
- const getStore = blobModule.getStore || _optionalChain([blobModule, 'access', _9 => _9.default, 'optionalAccess', _10 => _10.getStore]);
1391
+ const getStore = blobModule.getStore || _optionalChain([blobModule, 'access', _10 => _10.default, 'optionalAccess', _11 => _11.getStore]);
1382
1392
  if (typeof getStore === "function") {
1383
1393
  return getStore({ name: namespace });
1384
1394
  }
package/dist/index.d.cts CHANGED
@@ -879,11 +879,24 @@ function readReasoningContent(llmResponse) {
879
879
  if (!llmResponse || typeof llmResponse !== 'object') return null;
880
880
  const choices = /** @type {{ choices?: unknown }} */ (llmResponse).choices;
881
881
  if (!Array.isArray(choices) || choices.length === 0) return null;
882
- const message = /** @type {{ message?: { reasoning_content?: unknown } }} */ (choices[0])?.message;
882
+ const message = /** @type {{ message?: { reasoning_content?: unknown, content?: unknown } }} */ (choices[0])?.message;
883
+
883
884
  const raw = message?.reasoning_content;
884
- if (typeof raw !== 'string') return null;
885
- const trimmed = raw.trim();
886
- return trimmed.length > 0 ? trimmed : null;
885
+ if (typeof raw === 'string') {
886
+ const trimmed = raw.trim();
887
+ if (trimmed.length > 0) return trimmed;
888
+ }
889
+
890
+ const content = message?.content;
891
+ if (typeof content === 'string') {
892
+ const match = content.match(/<(think|thinking|thought)>([\s\S]*?)<\/\1>/i);
893
+ if (match) {
894
+ const trimmed = match[2].trim();
895
+ if (trimmed.length > 0) return trimmed;
896
+ }
897
+ }
898
+
899
+ return null;
887
900
  }
888
901
 
889
902
  /**
package/dist/index.d.ts CHANGED
@@ -879,11 +879,24 @@ function readReasoningContent(llmResponse) {
879
879
  if (!llmResponse || typeof llmResponse !== 'object') return null;
880
880
  const choices = /** @type {{ choices?: unknown }} */ (llmResponse).choices;
881
881
  if (!Array.isArray(choices) || choices.length === 0) return null;
882
- const message = /** @type {{ message?: { reasoning_content?: unknown } }} */ (choices[0])?.message;
882
+ const message = /** @type {{ message?: { reasoning_content?: unknown, content?: unknown } }} */ (choices[0])?.message;
883
+
883
884
  const raw = message?.reasoning_content;
884
- if (typeof raw !== 'string') return null;
885
- const trimmed = raw.trim();
886
- return trimmed.length > 0 ? trimmed : null;
885
+ if (typeof raw === 'string') {
886
+ const trimmed = raw.trim();
887
+ if (trimmed.length > 0) return trimmed;
888
+ }
889
+
890
+ const content = message?.content;
891
+ if (typeof content === 'string') {
892
+ const match = content.match(/<(think|thinking|thought)>([\s\S]*?)<\/\1>/i);
893
+ if (match) {
894
+ const trimmed = match[2].trim();
895
+ if (trimmed.length > 0) return trimmed;
896
+ }
897
+ }
898
+
899
+ return null;
887
900
  }
888
901
 
889
902
  /**
package/dist/index.mjs CHANGED
@@ -515,13 +515,23 @@ function readReasoningContent(llmResponse) {
515
515
  );
516
516
  if (!Array.isArray(choices) || choices.length === 0) return null;
517
517
  const message = (
518
- /** @type {{ message?: { reasoning_content?: unknown } }} */
518
+ /** @type {{ message?: { reasoning_content?: unknown, content?: unknown } }} */
519
519
  choices[0]?.message
520
520
  );
521
521
  const raw = message?.reasoning_content;
522
- if (typeof raw !== "string") return null;
523
- const trimmed = raw.trim();
524
- return trimmed.length > 0 ? trimmed : null;
522
+ if (typeof raw === "string") {
523
+ const trimmed = raw.trim();
524
+ if (trimmed.length > 0) return trimmed;
525
+ }
526
+ const content = message?.content;
527
+ if (typeof content === "string") {
528
+ const match = content.match(/<(think|thinking|thought)>([\s\S]*?)<\/\1>/i);
529
+ if (match) {
530
+ const trimmed = match[2].trim();
531
+ if (trimmed.length > 0) return trimmed;
532
+ }
533
+ }
534
+ return null;
525
535
  }
526
536
  async function processSingleMessage(task, ctx, providedMasterKey) {
527
537
  try {
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@rei-standard/amsg-server",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "ReiStandard Active Messaging server SDK with pluggable database adapters. Three-axis push schema (messageKind / messageType / messageSubtype) from @rei-standard/amsg-shared. Auto-emits ReasoningPush when the LLM response carries reasoning_content.",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "https://github.com/Tosd0/ReiStandard",
7
+ "url": "git+https://github.com/Tosd0/ReiStandard.git",
8
8
  "directory": "packages/rei-standard-amsg/server"
9
9
  },
10
10
  "license": "MIT",
@@ -33,7 +33,7 @@
33
33
  "node": ">=20"
34
34
  },
35
35
  "dependencies": {
36
- "@rei-standard/amsg-shared": "0.1.0",
36
+ "@rei-standard/amsg-shared": "0.2.0",
37
37
  "web-push": "^3.6.7",
38
38
  "@netlify/blobs": "^8.1.0"
39
39
  },