@cgh567/agent 2.4.2 → 2.4.4
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/agents/business/talisman-ceo.md +183 -0
- package/agents/business/talisman-comms.md +257 -0
- package/agents/business/talisman-cto.md +153 -0
- package/agents/business/talisman-finance.md +246 -0
- package/agents/business/talisman-marketing.md +240 -0
- package/agents/business/talisman-sales.md +242 -0
- package/agents/business/talisman-support.md +236 -0
- package/bin/helios-rpc.js +19 -0
- package/daemon/adapters/helios-rpc-adapter.js +5 -12
- package/daemon/adapters/tui_wakeup.js +8 -0
- package/daemon/context-enrichment.js +27 -0
- package/daemon/daemon-manager.js +1 -1
- package/daemon/db/email-infrastructure-migrate.js +192 -0
- package/daemon/db/hbo-core-migrate.js +189 -0
- package/daemon/helios-api.js +863 -64
- package/daemon/helios-company-daemon.js +233 -33
- package/daemon/lib/blast-radius-analyzer.js +75 -0
- package/daemon/lib/domain-bootstrap-orchestrator.js +267 -0
- package/daemon/lib/forensic-log.js +113 -0
- package/daemon/lib/goal-research-pipeline.js +644 -0
- package/daemon/lib/harada/cascade-judge.js +84 -1
- package/daemon/lib/harada/cascade-research-dispatcher.js +282 -0
- package/daemon/lib/harada/pillar-dispatcher.js +23 -2
- package/daemon/lib/hbo-bridge.js +74 -6
- package/daemon/lib/headroom-middleware.js +129 -0
- package/daemon/lib/headroom-proxy-manager.js +309 -0
- package/daemon/lib/hed-engine.js +25 -0
- package/daemon/lib/intelligence/department-page-generator.js +46 -1
- package/daemon/lib/interpretation-engine.js +92 -0
- package/daemon/lib/mental-model-cache.js +96 -0
- package/daemon/lib/project-factory.js +47 -0
- package/daemon/lib/session-log-reader.js +93 -0
- package/daemon/lib/standard-work-bootstrap.js +87 -1
- package/daemon/lib/task-completion-processor.js +23 -0
- package/daemon/lib/wizard-engine.js +57 -6
- package/daemon/package.json +2 -1
- package/daemon/routes/agents.js +51 -6
- package/daemon/routes/channels.js +116 -2
- package/daemon/routes/crm.js +85 -0
- package/daemon/routes/dashboard.js +62 -16
- package/daemon/routes/dept.js +10 -1
- package/daemon/routes/email-triage.js +19 -10
- package/daemon/routes/hbo.js +618 -58
- package/daemon/routes/hed.js +133 -0
- package/daemon/routes/inbox.js +397 -8
- package/daemon/routes/project.js +580 -66
- package/daemon/routes/routines.js +14 -0
- package/daemon/routes/tasks.js +15 -1
- package/daemon/schema-apply.js +174 -0
- package/daemon/schema-definitions.js +433 -0
- package/daemon/schema-migrations-hbo.js +20 -0
- package/daemon/schema-migrations-hed.js +18 -0
- package/daemon/schema-migrations-proj.js +153 -0
- package/extensions/__tests__/codebase-index.test.ts +73 -0
- package/extensions/__tests__/extension-command-registration.test.ts +35 -0
- package/extensions/__tests__/git-push-guard.test.ts +68 -0
- package/extensions/context-compaction.ts +104 -76
- package/extensions/cortex/__tests__/cortex-core.test.ts +100 -0
- package/extensions/cortex/wal-replay.ts +91 -0
- package/extensions/email/actions/draft-response.ts +21 -1
- package/extensions/email/auth/accounts.ts +5 -11
- package/extensions/email/auth/inbox-dog.ts +5 -2
- package/extensions/email/backfill.ts +20 -13
- package/extensions/email/providers/gmail.ts +164 -0
- package/extensions/email/providers/google-calendar.ts +34 -5
- package/extensions/helios-browser/__tests__/browser-routing.test.ts +57 -0
- package/extensions/helios-browser/backends/playwright.ts +3 -1
- package/extensions/helios-governance/__tests__/governance-gates.test.ts +40 -0
- package/extensions/helios-governance/__tests__/tournament-consumer.test.js +66 -0
- package/extensions/hema-dispatch-v3/headroom-compress.ts +103 -0
- package/extensions/hema-dispatch-v3/index.ts +46 -72
- package/extensions/interview/__tests__/server.test.ts +117 -0
- package/extensions/lib/helios-root.cjs +46 -0
- package/extensions/subagent-mesh/__tests__/handlers.test.ts +98 -0
- package/extensions/warm-tick/warm-tick-maintenance.ts +164 -0
- package/lib/__tests__/bulk-ingest.live.test.ts +66 -0
- package/lib/__tests__/crash-fixes.test.ts +49 -0
- package/lib/__tests__/hbo-core-store.test.js +238 -0
- package/lib/__tests__/maintenance-mission-wiring.test.ts +35 -0
- package/lib/broker/__tests__/jit-subscription.test.js +44 -1
- package/lib/broker/__tests__/lifecycle-channels.test.js +25 -1
- package/lib/compression/__tests__/ccr-store.test.js +138 -0
- package/lib/compression/__tests__/pipeline.test.js +280 -0
- package/lib/compression/__tests__/smart-crusher.test.js +242 -0
- package/lib/compression/dist/server.js +34 -1
- package/lib/compression/dist/start-server.js +77 -0
- package/lib/event-bus.mts +1 -1
- package/lib/graph/learning/headroom-learn-bridge.js +175 -0
- package/lib/graph-availability.js +62 -0
- package/lib/hbo-core-store.compiled.js +834 -0
- package/lib/hbo-core-store.js +124 -0
- package/lib/hbo-core-store.ts +979 -0
- package/lib/mission-loop/__tests__/research-handler.test.ts +143 -0
- package/lib/skill-sync.js +6 -1
- package/lib/startup-integrity.js +9 -2
- package/lib/triage-core/__tests__/classifier-fixture.test.ts +254 -0
- package/lib/triage-core/__tests__/classifier-post-norm.test.ts +1 -1
- package/lib/triage-core/__tests__/classifier.test.ts +45 -7
- package/lib/triage-core/__tests__/correction-detector.test.ts +36 -0
- package/lib/triage-core/__tests__/d6-dunbar-boost.test.ts +5 -5
- package/lib/triage-core/__tests__/orchestrator-pipeline.test.ts +107 -0
- package/lib/triage-core/__tests__/orchestrator.test.ts +113 -1
- package/lib/triage-core/__tests__/signals.test.ts +357 -0
- package/lib/triage-core/__tests__/sql-parity.test.ts +216 -0
- package/lib/triage-core/backfill-cost-estimator.ts +91 -0
- package/lib/triage-core/backfill-orchestrator.ts +119 -0
- package/lib/triage-core/classifier.ts +41 -8
- package/lib/triage-core/cos/cross-channel-escalation.ts +2 -3
- package/lib/triage-core/cos/response-debt.ts +2 -2
- package/lib/triage-core/graph/__tests__/batch-persistence.test.ts +283 -0
- package/lib/triage-core/graph/batch-persistence.ts +66 -2
- package/lib/triage-core/graph/betweenness-worker.js +75 -0
- package/lib/triage-core/graph/graph-rank-sql.ts +67 -0
- package/lib/triage-core/graph/persistence.ts +1 -1
- package/lib/triage-core/graph/schema-v2.ts +2 -0
- package/lib/triage-core/graph/schema.cypher +11 -0
- package/lib/triage-core/graph/triage-query.ts +1 -1
- package/lib/triage-core/learning.ts +15 -20
- package/lib/triage-core/mental-model/bedrock-config.ts +78 -0
- package/lib/triage-core/mental-model/cos-integration.ts +1 -1
- package/lib/triage-core/mental-model/entity-extractor.ts +51 -4
- package/lib/triage-core/mental-model/identity-resolver.ts +5 -5
- package/lib/triage-core/mental-model/key-facts.ts +1 -2
- package/lib/triage-core/mental-model/model-assembler-sql.ts +200 -0
- package/lib/triage-core/mental-model/model-assembler.ts +16 -3
- package/lib/triage-core/orchestrator.ts +8 -15
- package/lib/triage-core/scheduled-sends.ts +39 -2
- package/lib/triage-core/signals/comms-style.ts +1 -1
- package/lib/triage-core/signals/cross-channel-escalation.ts +2 -2
- package/lib/triage-core/signals/favee-type.ts +6 -1
- package/lib/triage-core/signals/goal-relevance.ts +31 -2
- package/lib/triage-core/signals/personal-importance.ts +1 -1
- package/lib/triage-core/signals/referral-chain.ts +0 -1
- package/lib/triage-core/signals/relationship-decay.ts +4 -0
- package/lib/triage-core/signals/relationship-health.ts +6 -1
- package/lib/triage-core/signals/trajectory-signal.ts +38 -3
- package/lib/triage-core/tournament-runner.js +11 -1
- package/lib/triage-core/triage-llm-factory.ts +110 -0
- package/lib/triage-core/triage-local-llm.ts +145 -0
- package/lib/triage-core/triage-sql-store.ts +337 -0
- package/lib/triage-core/types.ts +2 -2
- package/lib/unified-graph.atomic.test.ts +52 -0
- package/lib/unified-graph.failure-categories.test.ts +55 -0
- package/package.json +18 -7
- package/prebuilds/darwin-arm64/better_sqlite3.node +0 -0
- package/prebuilds/linux-x64/better_sqlite3.node +0 -0
- package/prebuilds/win32-x64/better_sqlite3.node +0 -0
- package/skills/helios-bookkeeping/SKILL.md +321 -0
- package/skills/helios-briefer/SKILL.md +44 -0
- package/skills/helios-client-relations/SKILL.md +322 -0
- package/skills/helios-personal-triager/SKILL.md +45 -0
- package/skills/helios-recruitment/SKILL.md +317 -0
- package/skills/helios-relationship-nudger/SKILL.md +77 -0
- package/skills/helios-researcher/SKILL.md +44 -0
- package/skills/helios-scheduler/SKILL.md +58 -0
- package/skills/helios-tax-analyst/SKILL.md +280 -0
- package/lib/triage-core/orchestrator.ts.bak-r005-r006-r008 +0 -1823
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* lib/graph/learning/headroom-learn-bridge.js
|
|
4
|
+
*
|
|
5
|
+
* Post-RETROSPECTIVE learning bridge: mines session compression stats and
|
|
6
|
+
* tool-call failure patterns, then writes structured knowledge to Memgraph.
|
|
7
|
+
*
|
|
8
|
+
* Called from lib/mission-loop/phase-handlers/retrospective.ts (fire-and-forget):
|
|
9
|
+
* const { runBridge } = require('../../graph/learning/headroom-learn-bridge');
|
|
10
|
+
* await runBridge(safeWrite, sessionId, missionRunId);
|
|
11
|
+
*
|
|
12
|
+
* Interface:
|
|
13
|
+
* runBridge(safeWrite, sessionId, missionRunId): Promise<void>
|
|
14
|
+
* safeWrite: (cypher: string, params?: object) => Promise<void>
|
|
15
|
+
* sessionId: string
|
|
16
|
+
* missionRunId: string
|
|
17
|
+
* Returns: void — never throws, fully fail-open
|
|
18
|
+
*
|
|
19
|
+
* Memgraph writes:
|
|
20
|
+
* - HeadroomSession node (tracks per-session compression stats)
|
|
21
|
+
* - KnowledgeAsset nodes (one per unique tool-failure pattern found)
|
|
22
|
+
*
|
|
23
|
+
* Debounce: 5 minutes per sessionId — prevents multiple RETROSPECTIVE calls
|
|
24
|
+
* within the same session from firing duplicate writes.
|
|
25
|
+
*
|
|
26
|
+
* No hardcoded company IDs. companyId is derived from sessionId prefix if
|
|
27
|
+
* available (format: "<companyId>__<sessionSuffix>"), else 'unknown'.
|
|
28
|
+
*
|
|
29
|
+
* Cross-platform: os.homedir(), path.join() throughout.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
const os = require('os');
|
|
33
|
+
const path = require('path');
|
|
34
|
+
const fs = require('fs');
|
|
35
|
+
|
|
36
|
+
// ── Debounce ──────────────────────────────────────────────────────────────────
|
|
37
|
+
// Map<sessionId, lastRunMs>
|
|
38
|
+
const _lastRun = new Map();
|
|
39
|
+
const DEBOUNCE_MS = 5 * 60 * 1000; // 5 minutes
|
|
40
|
+
|
|
41
|
+
// ── Helpers ───────────────────────────────────────────────────────────────────
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Derive companyId from sessionId.
|
|
45
|
+
* Convention in helios-agent: sessionId may be prefixed as "pi__<suffix>" or
|
|
46
|
+
* "<companyId>__<suffix>". If no __ separator found, returns 'unknown'.
|
|
47
|
+
*/
|
|
48
|
+
function deriveCompanyId(sessionId) {
|
|
49
|
+
if (!sessionId || typeof sessionId !== 'string') return 'unknown';
|
|
50
|
+
// Skip the standard pi__ prefix — that's not a companyId
|
|
51
|
+
if (sessionId.startsWith('pi__')) return 'unknown';
|
|
52
|
+
const sep = sessionId.indexOf('__');
|
|
53
|
+
if (sep > 0) return sessionId.substring(0, sep);
|
|
54
|
+
return 'unknown';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Read tool-failure patterns from HELIOS_SESSION_TOOL_FAILURES env var.
|
|
59
|
+
* The env var is expected to be a JSON array of { toolName, errorClass } objects,
|
|
60
|
+
* set by the daemon before spawning Pi. Returns [] if absent or unparseable.
|
|
61
|
+
*/
|
|
62
|
+
function readToolFailures() {
|
|
63
|
+
try {
|
|
64
|
+
const raw = process.env.HELIOS_SESSION_TOOL_FAILURES;
|
|
65
|
+
if (!raw) return [];
|
|
66
|
+
const parsed = JSON.parse(raw);
|
|
67
|
+
if (!Array.isArray(parsed)) return [];
|
|
68
|
+
return parsed.filter(
|
|
69
|
+
(f) => f && typeof f.toolName === 'string' && typeof f.errorClass === 'string'
|
|
70
|
+
);
|
|
71
|
+
} catch (_) {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Write a HeadroomSession node to Memgraph.
|
|
78
|
+
* Non-fatal: resolves even if safeWrite rejects.
|
|
79
|
+
*/
|
|
80
|
+
async function writeHeadroomSession(safeWrite, sessionId, missionRunId) {
|
|
81
|
+
const companyId = deriveCompanyId(sessionId);
|
|
82
|
+
const cypher = `
|
|
83
|
+
MERGE (hs:HeadroomSession {sessionId: $sessionId})
|
|
84
|
+
SET hs.missionRunId = $missionRunId,
|
|
85
|
+
hs.companyId = $companyId,
|
|
86
|
+
hs.updatedAt = localdatetime()
|
|
87
|
+
`;
|
|
88
|
+
try {
|
|
89
|
+
await safeWrite(cypher, { sessionId, missionRunId, companyId });
|
|
90
|
+
} catch (e) {
|
|
91
|
+
process.stderr.write(`[headroom-learn-bridge] HeadroomSession write failed (non-fatal): ${e && e.message}\n`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Write KnowledgeAsset nodes for each unique tool-failure pattern.
|
|
97
|
+
* Non-fatal per write.
|
|
98
|
+
*/
|
|
99
|
+
async function writeKnowledgeAssets(safeWrite, failures, sessionId) {
|
|
100
|
+
if (!failures || failures.length === 0) return;
|
|
101
|
+
|
|
102
|
+
// Deduplicate by toolName+errorClass
|
|
103
|
+
const seen = new Set();
|
|
104
|
+
const unique = failures.filter((f) => {
|
|
105
|
+
const key = `${f.toolName}::${f.errorClass}`;
|
|
106
|
+
if (seen.has(key)) return false;
|
|
107
|
+
seen.add(key);
|
|
108
|
+
return true;
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
for (const failure of unique) {
|
|
112
|
+
const assetId = `hroom-${Buffer.from(`${sessionId}:${failure.toolName}:${failure.errorClass}`).toString('base64').replace(/[^a-z0-9]/gi, '').slice(0, 32)}`;
|
|
113
|
+
const cypher = `
|
|
114
|
+
MERGE (ka:KnowledgeAsset {id: $assetId})
|
|
115
|
+
SET ka.source = 'headroom-learn-bridge',
|
|
116
|
+
ka.type = 'tool_failure_pattern',
|
|
117
|
+
ka.toolName = $toolName,
|
|
118
|
+
ka.errorClass = $errorClass,
|
|
119
|
+
ka.sessionId = $sessionId,
|
|
120
|
+
ka.updatedAt = localdatetime()
|
|
121
|
+
`;
|
|
122
|
+
try {
|
|
123
|
+
await safeWrite(cypher, {
|
|
124
|
+
assetId,
|
|
125
|
+
toolName : failure.toolName,
|
|
126
|
+
errorClass : failure.errorClass,
|
|
127
|
+
sessionId,
|
|
128
|
+
});
|
|
129
|
+
} catch (e) {
|
|
130
|
+
process.stderr.write(`[headroom-learn-bridge] KnowledgeAsset write failed (non-fatal): ${e && e.message}\n`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// ── Public API ────────────────────────────────────────────────────────────────
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Run the headroom learn bridge for a completed RETROSPECTIVE phase.
|
|
139
|
+
*
|
|
140
|
+
* @param {Function} safeWrite Memgraph writer: (cypher, params?) => Promise<void>
|
|
141
|
+
* @param {string} sessionId Current session ID
|
|
142
|
+
* @param {string} missionRunId Current mission run ID
|
|
143
|
+
* @returns {Promise<void>} Always resolves — never rejects
|
|
144
|
+
*/
|
|
145
|
+
async function runBridge(safeWrite, sessionId, missionRunId) {
|
|
146
|
+
try {
|
|
147
|
+
// Debounce: skip if we ran within the last 5 minutes for this session
|
|
148
|
+
const lastRun = _lastRun.get(sessionId);
|
|
149
|
+
if (lastRun && Date.now() - lastRun < DEBOUNCE_MS) {
|
|
150
|
+
process.stderr.write(
|
|
151
|
+
`[headroom-learn-bridge] Debounced for session ${sessionId} ` +
|
|
152
|
+
`(${Math.round((Date.now() - lastRun) / 1000)}s since last run)\n`
|
|
153
|
+
);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
_lastRun.set(sessionId, Date.now());
|
|
157
|
+
|
|
158
|
+
// Run both writes in parallel — independent of each other
|
|
159
|
+
const failures = readToolFailures();
|
|
160
|
+
await Promise.all([
|
|
161
|
+
writeHeadroomSession(safeWrite, sessionId, missionRunId),
|
|
162
|
+
writeKnowledgeAssets(safeWrite, failures, sessionId),
|
|
163
|
+
]);
|
|
164
|
+
|
|
165
|
+
process.stderr.write(
|
|
166
|
+
`[headroom-learn-bridge] Completed for session=${sessionId} ` +
|
|
167
|
+
`missionRunId=${missionRunId} failures=${failures.length}\n`
|
|
168
|
+
);
|
|
169
|
+
} catch (e) {
|
|
170
|
+
// Top-level catch: bridge is fully non-fatal
|
|
171
|
+
process.stderr.write(`[headroom-learn-bridge] Unexpected error (non-fatal): ${e && e.message}\n`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
module.exports = { runBridge };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* lib/graph-availability.js
|
|
4
|
+
*
|
|
5
|
+
* Single source of truth for Memgraph availability state within a SINGLE
|
|
6
|
+
* Node.js process. Listeners are notified on state change only (not on
|
|
7
|
+
* redundant sets of the same value).
|
|
8
|
+
*
|
|
9
|
+
* ⚠️ PROCESS SCOPE WARNING:
|
|
10
|
+
* This module uses Node.js module-level state. Each OS process has its own
|
|
11
|
+
* module registry and therefore its own independent _available + _listeners.
|
|
12
|
+
* It is ONLY valid within a single process:
|
|
13
|
+
*
|
|
14
|
+
* ✅ Pi extension process — memgraph-autostart sets state, cortex/hema read it
|
|
15
|
+
* ✅ Eval container — same process, same state
|
|
16
|
+
* ❌ helios-company-daemon.js — runs in its own process; state here is NEVER
|
|
17
|
+
* set by memgraph-autostart (which runs in Pi's process). Do NOT use
|
|
18
|
+
* isMemgraphAvailable() in daemon code to gate Memgraph writes — use the
|
|
19
|
+
* try/catch + setImmediate fire-and-forget pattern instead.
|
|
20
|
+
* ❌ broker/server.js — forked process; has its own availability state
|
|
21
|
+
*
|
|
22
|
+
* Usage (within Pi's extension process only):
|
|
23
|
+
* const { isMemgraphAvailable, setMemgraphAvailable, onAvailabilityChange } = require('./graph-availability');
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
let _available = false;
|
|
27
|
+
let _listeners = [];
|
|
28
|
+
|
|
29
|
+
function setMemgraphAvailable(available) {
|
|
30
|
+
const v = !!available;
|
|
31
|
+
if (v === _available) return;
|
|
32
|
+
_available = v;
|
|
33
|
+
const snap = _listeners.slice();
|
|
34
|
+
for (const fn of snap) {
|
|
35
|
+
try { fn(_available); } catch (e) {
|
|
36
|
+
process.stderr.write('[graph-availability] listener error: ' + String(e) + '\n');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function isMemgraphAvailable() {
|
|
42
|
+
return _available;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function onAvailabilityChange(fn) {
|
|
46
|
+
_listeners.push(fn);
|
|
47
|
+
return function unsubscribe() {
|
|
48
|
+
_listeners = _listeners.filter((l) => l !== fn);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function _resetForTest() {
|
|
53
|
+
_available = false;
|
|
54
|
+
_listeners = [];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = {
|
|
58
|
+
setMemgraphAvailable,
|
|
59
|
+
isMemgraphAvailable,
|
|
60
|
+
onAvailabilityChange,
|
|
61
|
+
_resetForTest,
|
|
62
|
+
};
|