blun-king-cli 9.0.0 → 9.0.1

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 (55) hide show
  1. package/LIESMICH.txt +1 -7
  2. package/README.md +4 -16
  3. package/bin/blun.js +248 -160
  4. package/bin/core-bootstrap.js +47 -0
  5. package/bin/king.js +277 -1
  6. package/bin/launcher-mode.js +2 -1
  7. package/bin/launcher-runtime.js +221 -0
  8. package/bin/plugin-bootstrap.js +0 -0
  9. package/bin/private-paths.js +0 -0
  10. package/bin/update-lease.js +399 -0
  11. package/bin/update-notice.js +1094 -0
  12. package/blun.mjs +4060 -6667
  13. package/package.json +3 -10
  14. package/skills/screenshot-lesen/SKILL.md +0 -1
  15. package/skills/web-lesen/SKILL.md +0 -1
  16. package/telegram-plugin/dist/bridge.mjs +1 -21
  17. package/mnemo/access_routes.js +0 -692
  18. package/mnemo/agent_governance.js +0 -4242
  19. package/mnemo/agent_mail.js +0 -901
  20. package/mnemo/bootstrap_auto.js +0 -137
  21. package/mnemo/brief_coordination.js +0 -226
  22. package/mnemo/code_read_tools.js +0 -375
  23. package/mnemo/context_preview_tools.js +0 -603
  24. package/mnemo/embeddings.js +0 -66
  25. package/mnemo/external_repo_ops.js +0 -575
  26. package/mnemo/facts/example-project-rules.json +0 -90
  27. package/mnemo/facts/example.json +0 -34
  28. package/mnemo/identity_schema.sql +0 -139
  29. package/mnemo/journal_schema.js +0 -561
  30. package/mnemo/loop_doctor_tools.js +0 -661
  31. package/mnemo/mail_secret_refs.js +0 -150
  32. package/mnemo/mcp.js +0 -9309
  33. package/mnemo/memory_consolidation.js +0 -1914
  34. package/mnemo/memory_health_tools.js +0 -165
  35. package/mnemo/package.json +0 -79
  36. package/mnemo/protected_scope_gate.js +0 -627
  37. package/mnemo/resource_access_control.js +0 -684
  38. package/mnemo/runtime_governance.js +0 -1256
  39. package/mnemo/runtime_turn_gate.js +0 -862
  40. package/mnemo/sandbox.js +0 -143
  41. package/mnemo/schema.sql +0 -389
  42. package/mnemo/shared_utils.js +0 -763
  43. package/mnemo/skills/agent-auto-resume/SKILL.md +0 -56
  44. package/mnemo/skills/agent_hand/SKILL.md +0 -43
  45. package/mnemo/skills/agent_hand/run.js +0 -63
  46. package/mnemo/skills/book_flight/SKILL.md +0 -34
  47. package/mnemo/skills/external_repo_review/SKILL.md +0 -43
  48. package/mnemo/skills/external_repo_review/run.js +0 -73
  49. package/mnemo/skills/pay_invoice/SKILL.md +0 -34
  50. package/mnemo/team_quality_ops.js +0 -944
  51. package/mnemo/timeline_report_tools.js +0 -810
  52. package/mnemo/write_gate_risk.js +0 -80
  53. package/mnemo/writer_health.js +0 -152
  54. package/skills/doku-ingestion/SKILL.md +0 -48
  55. package/skills/doku-ingestion/ingest_docs.py +0 -133
@@ -1,165 +0,0 @@
1
- "use strict";
2
-
3
- const { parseMaybeJson, normalizeAgentName } = require("./shared_utils");
4
-
5
- function safeAll(db, sql, params = []) {
6
- try { return db.prepare(sql).all(...params); } catch { return []; }
7
- }
8
-
9
- function isoAgo(minutes) {
10
- return new Date(Date.now() - Math.max(1, minutes || 1440) * 60000).toISOString();
11
- }
12
-
13
- function ageMinutes(iso) {
14
- const t = iso ? Date.parse(iso) : 0;
15
- if (!t) return null;
16
- return Math.max(0, Math.round((Date.now() - t) / 60000));
17
- }
18
-
19
- function pushLatest(map, agent, target, row) {
20
- if (!agent) return;
21
- if (!map.has(agent)) map.set(agent, new Map());
22
- const current = map.get(agent).get(target);
23
- if (!current || String(row.started_at || "") > String(current.started_at || "")) {
24
- map.get(agent).set(target, row);
25
- }
26
- }
27
-
28
- const LEGACY_RUNTIME_SOURCE = "cl" + "aude-code";
29
- const LEGACY_RUNTIME_PREFIX = "cl" + "aude";
30
-
31
- function captureAt(captures, currentKind, legacyKind) {
32
- const row = captures[currentKind] || (legacyKind ? captures[legacyKind] : null);
33
- return row && row.occurred_at || null;
34
- }
35
-
36
- function rowPayload(row) {
37
- return parseMaybeJson(row && row.payload_json, {}) || {};
38
- }
39
-
40
- function memoryHealth(db, a = {}) {
41
- const staleMinutes = Math.max(5, Number(a.stale_minutes || 1440));
42
- const since = a.since || isoAgo(Math.max(staleMinutes, Number(a.window_minutes || 1440)));
43
- const requestedAgent = normalizeAgentName(a.agent_name || "");
44
- const actionRows = safeAll(db, `
45
- SELECT id, agent_name, target, status, payload_json, meta_json, started_at, session_id
46
- FROM agent_action
47
- WHERE action_kind='mnemo_runtime_hook' AND started_at >= ?
48
- ORDER BY started_at DESC
49
- LIMIT ?
50
- `, [since, Math.min(Number(a.limit || 2000), 5000)]);
51
- const registryRows = safeAll(db, "SELECT agent_name, status, last_seen_at FROM agent_registry ORDER BY agent_name");
52
- const captureRows = safeAll(db, `
53
- SELECT source, event_kind, actor, status, occurred_at, meta_json
54
- FROM capture_receipt
55
- WHERE source IN ('agent-runtime', ?) AND occurred_at >= ?
56
- ORDER BY occurred_at DESC
57
- LIMIT 2000
58
- `, [LEGACY_RUNTIME_SOURCE, since]);
59
-
60
- const agents = new Set(registryRows.map((row) => normalizeAgentName(row.agent_name)).filter(Boolean));
61
- const latestByAgent = new Map();
62
- const failuresByAgent = new Map();
63
- const capturesByAgent = new Map();
64
-
65
- for (const row of actionRows) {
66
- const agent = normalizeAgentName(row.agent_name);
67
- if (!agent) continue;
68
- agents.add(agent);
69
- pushLatest(latestByAgent, agent, row.target || "unknown", row);
70
- if (String(row.status || "").toLowerCase() !== "ok") {
71
- failuresByAgent.set(agent, (failuresByAgent.get(agent) || 0) + 1);
72
- }
73
- }
74
-
75
- for (const row of captureRows) {
76
- const meta = parseMaybeJson(row.meta_json, {}) || {};
77
- const agent = normalizeAgentName(meta.agent_name || row.actor);
78
- if (!agent) continue;
79
- agents.add(agent);
80
- if (!capturesByAgent.has(agent)) capturesByAgent.set(agent, {});
81
- const bucket = capturesByAgent.get(agent);
82
- const key = row.event_kind || "capture";
83
- if (!bucket[key] || String(row.occurred_at || "") > String(bucket[key].occurred_at || "")) {
84
- bucket[key] = row;
85
- }
86
- }
87
-
88
- const agentRows = Array.from(agents)
89
- .filter((agent) => !requestedAgent || agent === requestedAgent)
90
- .sort()
91
- .map((agent) => {
92
- const byTarget = latestByAgent.get(agent) || new Map();
93
- const latestActions = {};
94
- for (const [target, row] of byTarget.entries()) {
95
- const payload = rowPayload(row);
96
- latestActions[target] = {
97
- at: row.started_at,
98
- age_min: ageMinutes(row.started_at),
99
- status: row.status,
100
- session_id: row.session_id || null,
101
- transcript_sync_ok: payload.transcript_sync_ok,
102
- transcript_count: payload.transcript_count,
103
- prior_recall_ok: payload.prior_recall_ok,
104
- prior_count: payload.prior_count,
105
- prompt_capture_ok: payload.prompt_capture_ok,
106
- blockers: payload.blockers || [],
107
- warnings: payload.warnings || []
108
- };
109
- }
110
- const latest = actionRows.find((row) => normalizeAgentName(row.agent_name) === agent) || null;
111
- const latestPayload = rowPayload(latest);
112
- const failures = failuresByAgent.get(agent) || 0;
113
- const stale = !latest || ageMinutes(latest.started_at) > staleMinutes;
114
- const latestStatus = latest ? String(latest.status || "").toLowerCase() : "missing";
115
- const health = !latest ? "unknown" : (latestStatus !== "ok" ? "error" : (stale ? "stale" : (failures ? "degraded" : "ok")));
116
- const captures = capturesByAgent.get(agent) || {};
117
- return {
118
- agent_name: agent,
119
- health,
120
- last_hook_at: latest && latest.started_at || null,
121
- last_hook_age_min: latest ? ageMinutes(latest.started_at) : null,
122
- failures_in_window: failures,
123
- latest_hook: latest ? latest.target : null,
124
- latest_prior_recall_ok: latestPayload.prior_recall_ok == null ? null : !!latestPayload.prior_recall_ok,
125
- latest_prior_count: latestPayload.prior_count == null ? null : latestPayload.prior_count,
126
- latest_transcript_sync_ok: latestPayload.transcript_sync_ok == null ? null : !!latestPayload.transcript_sync_ok,
127
- latest_transcript_count: latestPayload.transcript_count == null ? null : latestPayload.transcript_count,
128
- lifecycle: latestActions,
129
- captures: {
130
- last_user_prompt_at: captures.user_prompt_submit && captures.user_prompt_submit.occurred_at || null,
131
- last_transcript_turn_at: captureAt(captures, "runtime_transcript_turn", LEGACY_RUNTIME_PREFIX + "_transcript_turn"),
132
- last_precompact_at: captureAt(captures, "runtime_precompact_snapshot", LEGACY_RUNTIME_PREFIX + "_precompact_snapshot"),
133
- last_session_end_at: captureAt(captures, "runtime_session_end_snapshot", LEGACY_RUNTIME_PREFIX + "_session_end_snapshot")
134
- },
135
- required_hooks_seen: {
136
- session_start: !!latestActions.SessionStart,
137
- user_prompt: !!latestActions.UserPromptSubmit,
138
- pre_compact: !!latestActions.PreCompact,
139
- post_tool: !!latestActions.PostToolUse,
140
- stop: !!latestActions.Stop,
141
- session_end: !!latestActions.SessionEnd
142
- }
143
- };
144
- });
145
-
146
- const summary = {
147
- total: agentRows.length,
148
- ok: agentRows.filter((row) => row.health === "ok").length,
149
- degraded: agentRows.filter((row) => row.health === "degraded").length,
150
- stale: agentRows.filter((row) => row.health === "stale").length,
151
- error: agentRows.filter((row) => row.health === "error").length,
152
- unknown: agentRows.filter((row) => row.health === "unknown").length,
153
- failures_in_window: agentRows.reduce((sum, row) => sum + (row.failures_in_window || 0), 0)
154
- };
155
-
156
- return {
157
- checked_at: new Date().toISOString(),
158
- since,
159
- stale_minutes: staleMinutes,
160
- summary,
161
- agents: agentRows
162
- };
163
- }
164
-
165
- module.exports = { memoryHealth };
@@ -1,79 +0,0 @@
1
- {
2
- "name": "@mnemo/core",
3
- "version": "0.1.1",
4
- "description": "Persistent memory + identity engine. SQLite + FTS5 + sqlite-vec embeddings + MCP server. The core a personal/team agent runs on so it never starts at zero.",
5
- "license": "MIT",
6
- "homepage": "https://github.com/Maykbiletti/mnemo",
7
- "repository": {
8
- "type": "git",
9
- "url": "https://github.com/Maykbiletti/mnemo.git"
10
- },
11
- "main": "mcp.js",
12
- "bin": {
13
- "mnemo": "./bin/mnemo.js",
14
- "mnemo-daemon": "./daemon.js",
15
- "mnemo-mcp": "./mcp.js",
16
- "mnemo-agent-loop": "./agent_loop_worker.js",
17
- "mnemo-agent-loop-start": "./bin/agent-loop-start.js",
18
- "mnemo-backfill-universal": "./universal_backfill.js",
19
- "mnemo-approved-artifact-hub": "./bin/approved-artifact-hub.js",
20
- "mnemo-firm-hook": "./hooks/firm-runtime-hook.js",
21
- "mnemo-hook-doctor": "./hooks/hook-doctor.js",
22
- "mnemo-hook-watchdog": "./hooks/hook-watchdog.js",
23
- "mnemo-site-contract-audit": "./bin/site-contract-audit.js",
24
- "mnemo-route-matrix-audit": "./bin/route-matrix-audit.js"
25
- },
26
- "scripts": {
27
- "init": "node bin/mnemo.js init",
28
- "bootstrap": "node bin/mnemo.js init",
29
- "bootstrap:auto": "node bootstrap_auto.js",
30
- "start": "node daemon.js",
31
- "daemon": "node daemon.js",
32
- "agent-loop": "node agent_loop_worker.js",
33
- "agent-loop:start": "node bin/agent-loop-start.js",
34
- "backfill:universal": "node universal_backfill.js",
35
- "artifact-hub:validate": "node bin/approved-artifact-hub.js validate",
36
- "mcp": "node mcp.js",
37
- "hook:session-start": "node hooks/firm-runtime-hook.js session-start",
38
- "hook:user-prompt": "node hooks/firm-runtime-hook.js user-prompt",
39
- "hook:pre-compact": "node hooks/firm-runtime-hook.js pre-compact",
40
- "hook:pre-tool": "node hooks/firm-runtime-hook.js pre-tool",
41
- "hook:post-tool": "node hooks/firm-runtime-hook.js post-tool",
42
- "hook:stop": "node hooks/firm-runtime-hook.js stop",
43
- "hook:session-end": "node hooks/firm-runtime-hook.js session-end",
44
- "hook:doctor": "node hooks/hook-doctor.js",
45
- "hook:watchdog": "node hooks/hook-watchdog.js --flush --heal",
46
- "site-contract-audit": "node bin/site-contract-audit.js",
47
- "route-matrix-audit": "node bin/route-matrix-audit.js",
48
- "embed": "node embedding_writer.js",
49
- "loops": "node loop_scanner_v2.js",
50
- "export": "node export_declarative.js",
51
- "test": "node test_shared_utils.js && node test_http_utils.js && node test_brief_coordination.js && node test_access_routes.js && node test_protected_scope_gate.js && node test_resource_access_control.js && node test_approved_artifact_hub.js && node test_runtime_governance.js && node test_memory_consolidation.js && node test_agent_governance.js && node test_gstack_governance.js && node test_writer_health.js && node test_daemon_health_dispatch.js && node test_runtime_enforcement.js && node test_access_owner_question_guard.js && node test_runtime_turn_resume_pack.js && node test_mcp_runtime_receipt_token.js && node test_agent_mail_check.js && node test_external_repo_ops.js && node test_write_gate_risk.js && node test_semantic.js",
52
- "test:integration": "node test_universal_capture.js"
53
- },
54
- "dependencies": {
55
- "@xenova/transformers": "^2.17.2",
56
- "better-sqlite3": "^12.9.0",
57
- "imapflow": "^1.3.3",
58
- "mailparser": "^3.9.8",
59
- "sqlite-vec": "^0.1.9"
60
- },
61
- "overrides": {
62
- "protobufjs": "^7.5.5"
63
- },
64
- "engines": {
65
- "node": ">=20.0.0"
66
- },
67
- "keywords": [
68
- "memory",
69
- "agent",
70
- "mcp",
71
- "sqlite",
72
- "embeddings",
73
- "personal-agent",
74
- "coding-agent",
75
- "firm-os",
76
- "llm-memory",
77
- "vector-search"
78
- ]
79
- }