@saleso.innovations/bridge 0.1.45 → 0.1.46

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 +1 @@
1
- {"version":3,"file":"hermesForwarder.d.ts","sourceRoot":"","sources":["../src/hermesForwarder.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAyB,eAAe,EAAE,MAAM,aAAa,CAAC;AAuBtF,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAkBF,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,sBAA2B,GAAG;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,CAaA;AAiID,wBAAsB,eAAe,CACnC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,eAAe,EACrB,KAAK,EAAE,UAAU,EACjB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,mBAAmB,CAAC,CA6G9B;AA4BD,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,sBAA2B,IAC/D,SAAS,MAAM,EAAE,MAAM,eAAe,EAAE,OAAO,UAAU,KAAG,OAAO,CAAC,IAAI,CAAC,CAOxF"}
1
+ {"version":3,"file":"hermesForwarder.d.ts","sourceRoot":"","sources":["../src/hermesForwarder.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAyB,eAAe,EAAE,MAAM,aAAa,CAAC;AAiCtF,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAkBF,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,sBAA2B,GAAG;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,CAaA;AAiID,wBAAsB,eAAe,CACnC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,eAAe,EACrB,KAAK,EAAE,UAAU,EACjB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,mBAAmB,CAAC,CAsG9B;AA4BD,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,sBAA2B,IAC/D,SAAS,MAAM,EAAE,MAAM,eAAe,EAAE,OAAO,UAAU,KAAG,OAAO,CAAC,IAAI,CAAC,CAOxF"}
@@ -6,8 +6,20 @@ import { getLatestTurnMessageIds, getSessionUsage, hermesStateDbExists } from ".
6
6
  import { diffSkillsLearned, snapshotSkills } from "./skillLearnedDetector.js";
7
7
  import { buildTurnActivity, createTurnActivityAccumulator, parseSseDataLines, processSseEventBlock, } from "./turnActivity.js";
8
8
  import { parseMediaReferences, resolveMediaReferenceBytes, stripMediaReferences, } from "./hermesFiles.js";
9
- import { looksLikeHermesStructuredStream, unwrapHermesStructuredContent, } from "./hermesStructuredContent.js";
9
+ import { unwrapHermesStructuredContent } from "./hermesStructuredContent.js";
10
10
  import { resolveProfileContext } from "./profiles.js";
11
+ /**
12
+ * Instructs Hermes models to reply in plain conversational markdown so the Cleos
13
+ * chat renders Telegram-style text (and streams cleanly), instead of emitting
14
+ * model-specific JSON. Cards, when enabled, are still built from this markdown
15
+ * downstream by the structurer.
16
+ */
17
+ const PLAIN_MARKDOWN_SYSTEM_PROMPT = [
18
+ "You are replying inside a mobile chat app. Respond in plain, conversational markdown only.",
19
+ "Do not output JSON, UI component objects, or wrap the whole reply in a code fence.",
20
+ "Use light markdown for structure: short paragraphs separated by blank lines, \"-\" for bullet lists, and **bold** for emphasis.",
21
+ "Write naturally, like a normal chat message.",
22
+ ].join("\n");
11
23
  function readHermesApiKeyFromEnvFile(home) {
12
24
  const envPath = join(home?.trim() || join(homedir(), ".hermes"), ".env");
13
25
  try {
@@ -165,7 +177,10 @@ export async function forwardToHermes(content, meta, reply, options = {}) {
165
177
  const body = {
166
178
  model,
167
179
  stream: true,
168
- messages: [{ role: "user", content: userContent }],
180
+ messages: [
181
+ { role: "system", content: PLAIN_MARKDOWN_SYSTEM_PROMPT },
182
+ { role: "user", content: userContent },
183
+ ],
169
184
  user: sessionId,
170
185
  };
171
186
  const turnStartedAt = Date.now();
@@ -190,13 +205,8 @@ export async function forwardToHermes(content, meta, reply, options = {}) {
190
205
  const counters = { textSequence: 0, activitySequence: 0 };
191
206
  const accumulator = createTurnActivityAccumulator();
192
207
  let fullText = "";
193
- let suppressStreamDeltas = false;
194
208
  const streamingReply = {
195
- delta(text, sequence) {
196
- if (!suppressStreamDeltas) {
197
- reply.delta(text, sequence);
198
- }
199
- },
209
+ delta: (text, sequence) => reply.delta(text, sequence),
200
210
  activity: (activity) => reply.activity(activity),
201
211
  complete: (...args) => reply.complete(...args),
202
212
  failed: (failure) => reply.failed(failure),
@@ -211,18 +221,13 @@ export async function forwardToHermes(content, meta, reply, options = {}) {
211
221
  for (const eventBlock of events) {
212
222
  processSseEventBlock(eventBlock, streamingReply, counters, accumulator, (delta) => {
213
223
  fullText += delta;
214
- if (!suppressStreamDeltas && looksLikeHermesStructuredStream(fullText)) {
215
- suppressStreamDeltas = true;
216
- }
217
224
  });
218
225
  }
219
226
  }
220
227
  if (!fullText.trim()) {
221
228
  fullText = "(Hermes returned an empty response)";
222
- if (!suppressStreamDeltas) {
223
- reply.delta(fullText, counters.textSequence);
224
- counters.textSequence += 1;
225
- }
229
+ reply.delta(fullText, counters.textSequence);
230
+ counters.textSequence += 1;
226
231
  }
227
232
  const mediaRefs = parseMediaReferences(fullText);
228
233
  const attachments = mediaRefs.length > 0 ? await uploadMediaAttachments(meta.agentId, mediaRefs, home) : [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saleso.innovations/bridge",
3
- "version": "0.1.45",
3
+ "version": "0.1.46",
4
4
  "description": "Connect your Hermes agent to the Cleos iOS app via pairing code.",
5
5
  "type": "module",
6
6
  "license": "MIT",