@melaya/runner 1.0.111 → 1.0.112

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 (2) hide show
  1. package/dist/assistantHost.py +21 -0
  2. package/package.json +42 -42
@@ -72,6 +72,21 @@ def _memory_watermark(agent) -> int:
72
72
  return 0
73
73
 
74
74
 
75
+ def _emit_usage(agent, turn_id: str) -> None:
76
+ """Live header meter (runner parity): the context-fullness GAUGE — memory
77
+ watermark vs budget — so the FE shows how full the window is before the next
78
+ compaction, exactly like the cloud path. Per-turn TOKEN totals are exported as
79
+ spans (Overview dashboard); the live in/out counter stays cloud-only for now."""
80
+ try:
81
+ mem = _agent_memory(agent)
82
+ budget = int(getattr(mem, "max_tokens", 0) or 0) if mem is not None else 0
83
+ if budget > 0:
84
+ _emit(turn_id, "usage", turnInTok=0, turnOutTok=0,
85
+ ctxUsed=_memory_watermark(agent), ctxBudget=budget)
86
+ except Exception:
87
+ pass
88
+
89
+
75
90
  def _sync_ollama_memory_budget(agent) -> None:
76
91
  """P2-6 (persistent host): the Assistant builds ONE agent + BoundedMemory, so an
77
92
  OOM num_ctx downgrade that shrinks the ollama context cache would otherwise leave
@@ -392,6 +407,11 @@ def _build_agent():
392
407
  "to find the right content yourself. Keep going until the task is COMPLETE (e.g. "
393
408
  "all N comments posted) or you are genuinely blocked; only then report what you "
394
409
  "did and what (if anything) is blocked.\n"
410
+ "- NEVER fabricate a reason for stopping. Do NOT claim 'the connection dropped', "
411
+ "'I lost connection', 'the session ended' or invent ANY infra failure — you "
412
+ "cannot observe that and it is almost always false. If a phone action is slow or "
413
+ "errors, RETRY it; only if it truly won't recover after retries do you stop, and "
414
+ "then state the EXACT tool that failed + what the screen showed.\n"
395
415
  if phone_enabled else ""
396
416
  )
397
417
  connector_rule = (
@@ -761,6 +781,7 @@ def main() -> int:
761
781
  # the ollama context (no-op for every other provider / when unchanged).
762
782
  _sync_ollama_memory_budget(agent)
763
783
  _run_turn(agent, turn_id, message)
784
+ _emit_usage(agent, turn_id)
764
785
 
765
786
 
766
787
  if __name__ == "__main__":
package/package.json CHANGED
@@ -1,42 +1,42 @@
1
- {
2
- "name": "@melaya/runner",
3
- "version": "1.0.111",
4
- "description": "Run Melaya AI pipelines locally with your own LM Studio or Ollama models",
5
- "license": "UNLICENSED",
6
- "private": false,
7
- "type": "module",
8
- "bin": {
9
- "melaya-runner": "dist/cli.js"
10
- },
11
- "main": "dist/index.js",
12
- "files": [
13
- "dist/**/*.js",
14
- "dist/**/*.d.ts",
15
- "dist/**/*.py",
16
- "localRagIngest.py",
17
- "localRagRetrieve.py",
18
- "nltk_data/**",
19
- "README.md"
20
- ],
21
- "scripts": {
22
- "build": "tsc && node -e \"const fs=require('fs'); fs.copyFileSync('localRagIngest.py','dist/localRagIngest.py'); fs.copyFileSync('localRagRetrieve.py','dist/localRagRetrieve.py'); fs.copyFileSync('src/assistantHost.py','dist/assistantHost.py')\"",
23
- "prepublishOnly": "npm run build"
24
- },
25
- "dependencies": {
26
- "chalk": "^5.3.0",
27
- "commander": "^12.0.0",
28
- "ora": "^8.0.0",
29
- "playwright": "^1.47.0",
30
- "socket.io-client": "^4.8.0"
31
- },
32
- "devDependencies": {
33
- "@types/node": "^20.0.0",
34
- "typescript": "^5.5.0"
35
- },
36
- "engines": {
37
- "node": ">=18"
38
- },
39
- "publishConfig": {
40
- "access": "public"
41
- }
42
- }
1
+ {
2
+ "name": "@melaya/runner",
3
+ "version": "1.0.112",
4
+ "description": "Run Melaya AI pipelines locally with your own LM Studio or Ollama models",
5
+ "license": "UNLICENSED",
6
+ "private": false,
7
+ "type": "module",
8
+ "bin": {
9
+ "melaya-runner": "dist/cli.js"
10
+ },
11
+ "main": "dist/index.js",
12
+ "files": [
13
+ "dist/**/*.js",
14
+ "dist/**/*.d.ts",
15
+ "dist/**/*.py",
16
+ "localRagIngest.py",
17
+ "localRagRetrieve.py",
18
+ "nltk_data/**",
19
+ "README.md"
20
+ ],
21
+ "scripts": {
22
+ "build": "tsc && node -e \"const fs=require('fs'); fs.copyFileSync('localRagIngest.py','dist/localRagIngest.py'); fs.copyFileSync('localRagRetrieve.py','dist/localRagRetrieve.py'); fs.copyFileSync('src/assistantHost.py','dist/assistantHost.py')\"",
23
+ "prepublishOnly": "npm run build"
24
+ },
25
+ "dependencies": {
26
+ "chalk": "^5.3.0",
27
+ "commander": "^12.0.0",
28
+ "ora": "^8.0.0",
29
+ "playwright": "^1.47.0",
30
+ "socket.io-client": "^4.8.0"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^20.0.0",
34
+ "typescript": "^5.5.0"
35
+ },
36
+ "engines": {
37
+ "node": ">=18"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public"
41
+ }
42
+ }