@jungjaehoon/mama-os 0.16.0 → 0.17.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/cli/commands/connector.d.ts +9 -0
- package/dist/cli/commands/connector.d.ts.map +1 -0
- package/dist/cli/commands/connector.js +158 -0
- package/dist/cli/commands/connector.js.map +1 -0
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +133 -0
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/connectors/calendar/index.d.ts +23 -0
- package/dist/connectors/calendar/index.d.ts.map +1 -0
- package/dist/connectors/calendar/index.js +120 -0
- package/dist/connectors/calendar/index.js.map +1 -0
- package/dist/connectors/chatwork/index.d.ts +33 -0
- package/dist/connectors/chatwork/index.d.ts.map +1 -0
- package/dist/connectors/chatwork/index.js +136 -0
- package/dist/connectors/chatwork/index.js.map +1 -0
- package/dist/connectors/discord/index.d.ts +24 -0
- package/dist/connectors/discord/index.d.ts.map +1 -0
- package/dist/connectors/discord/index.js +149 -0
- package/dist/connectors/discord/index.js.map +1 -0
- package/dist/connectors/drive/index.d.ts +32 -0
- package/dist/connectors/drive/index.d.ts.map +1 -0
- package/dist/connectors/drive/index.js +166 -0
- package/dist/connectors/drive/index.js.map +1 -0
- package/dist/connectors/framework/connector-registry.d.ts +13 -0
- package/dist/connectors/framework/connector-registry.d.ts.map +1 -0
- package/dist/connectors/framework/connector-registry.js +42 -0
- package/dist/connectors/framework/connector-registry.js.map +1 -0
- package/dist/connectors/framework/gws-utils.d.ts +10 -0
- package/dist/connectors/framework/gws-utils.d.ts.map +1 -0
- package/dist/connectors/framework/gws-utils.js +28 -0
- package/dist/connectors/framework/gws-utils.js.map +1 -0
- package/dist/connectors/framework/index.d.ts +6 -0
- package/dist/connectors/framework/index.d.ts.map +1 -0
- package/dist/connectors/framework/index.js +13 -0
- package/dist/connectors/framework/index.js.map +1 -0
- package/dist/connectors/framework/polling-scheduler.d.ts +25 -0
- package/dist/connectors/framework/polling-scheduler.d.ts.map +1 -0
- package/dist/connectors/framework/polling-scheduler.js +98 -0
- package/dist/connectors/framework/polling-scheduler.js.map +1 -0
- package/dist/connectors/framework/raw-store.d.ts +16 -0
- package/dist/connectors/framework/raw-store.d.ts.map +1 -0
- package/dist/connectors/framework/raw-store.js +84 -0
- package/dist/connectors/framework/raw-store.js.map +1 -0
- package/dist/connectors/framework/types.d.ts +71 -0
- package/dist/connectors/framework/types.d.ts.map +1 -0
- package/dist/connectors/framework/types.js +7 -0
- package/dist/connectors/framework/types.js.map +1 -0
- package/dist/connectors/gmail/index.d.ts +22 -0
- package/dist/connectors/gmail/index.d.ts.map +1 -0
- package/dist/connectors/gmail/index.js +128 -0
- package/dist/connectors/gmail/index.js.map +1 -0
- package/dist/connectors/imessage/index.d.ts +26 -0
- package/dist/connectors/imessage/index.d.ts.map +1 -0
- package/dist/connectors/imessage/index.js +121 -0
- package/dist/connectors/imessage/index.js.map +1 -0
- package/dist/connectors/index.d.ts +10 -0
- package/dist/connectors/index.d.ts.map +1 -0
- package/dist/connectors/index.js +54 -0
- package/dist/connectors/index.js.map +1 -0
- package/dist/connectors/kagemusha/index.d.ts +23 -0
- package/dist/connectors/kagemusha/index.d.ts.map +1 -0
- package/dist/connectors/kagemusha/index.js +101 -0
- package/dist/connectors/kagemusha/index.js.map +1 -0
- package/dist/connectors/notion/index.d.ts +28 -0
- package/dist/connectors/notion/index.d.ts.map +1 -0
- package/dist/connectors/notion/index.js +197 -0
- package/dist/connectors/notion/index.js.map +1 -0
- package/dist/connectors/obsidian/index.d.ts +23 -0
- package/dist/connectors/obsidian/index.d.ts.map +1 -0
- package/dist/connectors/obsidian/index.js +146 -0
- package/dist/connectors/obsidian/index.js.map +1 -0
- package/dist/connectors/sheets/index.d.ts +24 -0
- package/dist/connectors/sheets/index.d.ts.map +1 -0
- package/dist/connectors/sheets/index.js +199 -0
- package/dist/connectors/sheets/index.js.map +1 -0
- package/dist/connectors/slack/index.d.ts +24 -0
- package/dist/connectors/slack/index.d.ts.map +1 -0
- package/dist/connectors/slack/index.js +139 -0
- package/dist/connectors/slack/index.js.map +1 -0
- package/dist/connectors/telegram/index.d.ts +24 -0
- package/dist/connectors/telegram/index.d.ts.map +1 -0
- package/dist/connectors/telegram/index.js +139 -0
- package/dist/connectors/telegram/index.js.map +1 -0
- package/dist/connectors/trello/index.d.ts +30 -0
- package/dist/connectors/trello/index.d.ts.map +1 -0
- package/dist/connectors/trello/index.js +181 -0
- package/dist/connectors/trello/index.js.map +1 -0
- package/dist/gateways/telegram.d.ts +3 -4
- package/dist/gateways/telegram.d.ts.map +1 -1
- package/dist/gateways/telegram.js +37 -48
- package/dist/gateways/telegram.js.map +1 -1
- package/dist/memory/history-extractor.d.ts +69 -0
- package/dist/memory/history-extractor.d.ts.map +1 -0
- package/dist/memory/history-extractor.js +243 -0
- package/dist/memory/history-extractor.js.map +1 -0
- package/package.json +2 -3
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mama connector command
|
|
3
|
+
*
|
|
4
|
+
* Manage data source connectors (list, add, remove, status).
|
|
5
|
+
* Config file: ~/.mama/connectors.json
|
|
6
|
+
*/
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
export declare function createConnectorCommand(): Command;
|
|
9
|
+
//# sourceMappingURL=connector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/connector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsBpC,wBAAgB,sBAAsB,IAAI,OAAO,CA6IhD"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* mama connector command
|
|
4
|
+
*
|
|
5
|
+
* Manage data source connectors (list, add, remove, status).
|
|
6
|
+
* Config file: ~/.mama/connectors.json
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.createConnectorCommand = createConnectorCommand;
|
|
10
|
+
const node_fs_1 = require("node:fs");
|
|
11
|
+
const node_os_1 = require("node:os");
|
|
12
|
+
const node_path_1 = require("node:path");
|
|
13
|
+
const commander_1 = require("commander");
|
|
14
|
+
const index_js_1 = require("../../connectors/index.js");
|
|
15
|
+
const CONNECTORS_CONFIG_PATH = (0, node_path_1.join)((0, node_os_1.homedir)(), '.mama', 'connectors.json');
|
|
16
|
+
function loadConnectorsConfig() {
|
|
17
|
+
if (!(0, node_fs_1.existsSync)(CONNECTORS_CONFIG_PATH))
|
|
18
|
+
return {};
|
|
19
|
+
try {
|
|
20
|
+
return JSON.parse((0, node_fs_1.readFileSync)(CONNECTORS_CONFIG_PATH, 'utf-8'));
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function saveConnectorsConfig(config) {
|
|
27
|
+
const dir = (0, node_path_1.join)((0, node_os_1.homedir)(), '.mama');
|
|
28
|
+
if (!(0, node_fs_1.existsSync)(dir))
|
|
29
|
+
(0, node_fs_1.mkdirSync)(dir, { recursive: true });
|
|
30
|
+
(0, node_fs_1.writeFileSync)(CONNECTORS_CONFIG_PATH, JSON.stringify(config, null, 2), 'utf-8');
|
|
31
|
+
}
|
|
32
|
+
function createConnectorCommand() {
|
|
33
|
+
const cmd = new commander_1.Command('connector').description('Manage data source connectors');
|
|
34
|
+
// ── list ────────────────────────────────────────────────────────────────────
|
|
35
|
+
cmd
|
|
36
|
+
.command('list')
|
|
37
|
+
.description('List all connectors and their status')
|
|
38
|
+
.action(() => {
|
|
39
|
+
const config = loadConnectorsConfig();
|
|
40
|
+
console.log('\nAvailable connectors:\n');
|
|
41
|
+
for (const name of index_js_1.AVAILABLE_CONNECTORS) {
|
|
42
|
+
const connectorCfg = config[name];
|
|
43
|
+
const enabled = connectorCfg?.enabled ?? false;
|
|
44
|
+
const status = enabled ? '✓ enabled ' : '✗ disabled';
|
|
45
|
+
const interval = connectorCfg?.pollIntervalMinutes
|
|
46
|
+
? ` (poll: ${connectorCfg.pollIntervalMinutes}m)`
|
|
47
|
+
: '';
|
|
48
|
+
console.log(` ${status} ${name}${interval}`);
|
|
49
|
+
}
|
|
50
|
+
console.log('');
|
|
51
|
+
});
|
|
52
|
+
// ── add ─────────────────────────────────────────────────────────────────────
|
|
53
|
+
cmd
|
|
54
|
+
.command('add <name>')
|
|
55
|
+
.description('Enable a connector')
|
|
56
|
+
.action(async (name) => {
|
|
57
|
+
if (!index_js_1.AVAILABLE_CONNECTORS.includes(name)) {
|
|
58
|
+
console.error(`Unknown connector: ${name}`);
|
|
59
|
+
console.error(`Available: ${index_js_1.AVAILABLE_CONNECTORS.join(', ')}`);
|
|
60
|
+
process.exitCode = 1;
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const config = loadConnectorsConfig();
|
|
64
|
+
// Build a default enabled config if not present
|
|
65
|
+
if (!config[name]) {
|
|
66
|
+
config[name] = {
|
|
67
|
+
enabled: true,
|
|
68
|
+
pollIntervalMinutes: 60,
|
|
69
|
+
channels: {},
|
|
70
|
+
auth: { type: 'none' },
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
config[name].enabled = true;
|
|
75
|
+
}
|
|
76
|
+
saveConnectorsConfig(config);
|
|
77
|
+
console.log(`\n✓ Connector '${name}' enabled.\n`);
|
|
78
|
+
// Show auth requirements
|
|
79
|
+
try {
|
|
80
|
+
const connector = await (0, index_js_1.loadConnector)(name, config[name]);
|
|
81
|
+
const reqs = connector.getAuthRequirements();
|
|
82
|
+
if (reqs.length > 0) {
|
|
83
|
+
console.log('Auth requirements:');
|
|
84
|
+
for (const req of reqs) {
|
|
85
|
+
console.log(` • ${req.description}`);
|
|
86
|
+
if (req.type === 'token' && req.tokenName) {
|
|
87
|
+
console.log(` Set env: ${req.tokenName}`);
|
|
88
|
+
}
|
|
89
|
+
if (req.type === 'cli' && req.cliAuthCommand) {
|
|
90
|
+
console.log(` Run: ${req.cliAuthCommand}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
console.log('');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
// Auth requirements display is best-effort
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
// ── remove ──────────────────────────────────────────────────────────────────
|
|
101
|
+
cmd
|
|
102
|
+
.command('remove <name>')
|
|
103
|
+
.description('Disable a connector')
|
|
104
|
+
.action((name) => {
|
|
105
|
+
if (!index_js_1.AVAILABLE_CONNECTORS.includes(name)) {
|
|
106
|
+
console.error(`Unknown connector: ${name}`);
|
|
107
|
+
console.error(`Available: ${index_js_1.AVAILABLE_CONNECTORS.join(', ')}`);
|
|
108
|
+
process.exitCode = 1;
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const config = loadConnectorsConfig();
|
|
112
|
+
if (!config[name]) {
|
|
113
|
+
console.log(`Connector '${name}' is already disabled (no config found).`);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
config[name].enabled = false;
|
|
117
|
+
saveConnectorsConfig(config);
|
|
118
|
+
console.log(`\n✓ Connector '${name}' disabled.\n`);
|
|
119
|
+
});
|
|
120
|
+
// ── status ──────────────────────────────────────────────────────────────────
|
|
121
|
+
cmd
|
|
122
|
+
.command('status')
|
|
123
|
+
.description('Show connector health and last poll times')
|
|
124
|
+
.action(async () => {
|
|
125
|
+
const config = loadConnectorsConfig();
|
|
126
|
+
const enabledNames = index_js_1.AVAILABLE_CONNECTORS.filter((name) => config[name]?.enabled === true);
|
|
127
|
+
if (enabledNames.length === 0) {
|
|
128
|
+
console.log('\nNo connectors enabled. Run: mama connector add <name>\n');
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
console.log('\nConnector health:\n');
|
|
132
|
+
await Promise.all(enabledNames.map(async (name) => {
|
|
133
|
+
let connector;
|
|
134
|
+
try {
|
|
135
|
+
connector = await (0, index_js_1.loadConnector)(name, config[name]);
|
|
136
|
+
await connector.init();
|
|
137
|
+
const health = await connector.healthCheck();
|
|
138
|
+
const statusIcon = health.healthy ? '✓' : '✗';
|
|
139
|
+
const lastPoll = health.lastPollTime ? health.lastPollTime.toLocaleString() : 'never';
|
|
140
|
+
console.log(` ${statusIcon} ${name}`);
|
|
141
|
+
console.log(` last poll: ${lastPoll} items: ${health.lastPollCount}`);
|
|
142
|
+
if (health.error) {
|
|
143
|
+
console.log(` error: ${health.error}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch (err) {
|
|
147
|
+
console.log(` ✗ ${name}`);
|
|
148
|
+
console.log(` error: ${err instanceof Error ? err.message : String(err)}`);
|
|
149
|
+
}
|
|
150
|
+
finally {
|
|
151
|
+
await connector?.dispose();
|
|
152
|
+
}
|
|
153
|
+
}));
|
|
154
|
+
console.log('');
|
|
155
|
+
});
|
|
156
|
+
return cmd;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=connector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector.js","sourceRoot":"","sources":["../../../src/cli/commands/connector.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AA4BH,wDA6IC;AAvKD,qCAA6E;AAC7E,qCAAkC;AAClC,yCAAiC;AAEjC,yCAAoC;AAEpC,wDAAgF;AAGhF,MAAM,sBAAsB,GAAG,IAAA,gBAAI,EAAC,IAAA,iBAAO,GAAE,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;AAE3E,SAAS,oBAAoB;IAC3B,IAAI,CAAC,IAAA,oBAAU,EAAC,sBAAsB,CAAC;QAAE,OAAO,EAAE,CAAC;IACnD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAA,sBAAY,EAAC,sBAAsB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yG5E;AA4QD;;GAEG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,EAC9C,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,GACtC,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/start.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAwBH,OAAO,EACL,UAAU,EAKX,MAAM,6BAA6B,CAAC;AA6hBrC;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,wCAAwC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyG5E;AA4QD;;GAEG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,EAC9C,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,GACtC,OAAO,CAAC,IAAI,CAAC,CA+oFf"}
|
|
@@ -1111,6 +1111,8 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1111
1111
|
const { initDB, getAdapter } = require('@jungjaehoon/mama-core/db-manager');
|
|
1112
1112
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
1113
1113
|
const mamaCore = require('@jungjaehoon/mama-core');
|
|
1114
|
+
// Connector extraction function — set when Claude CLI extraction process is ready
|
|
1115
|
+
let connectorExtractionFn = null;
|
|
1114
1116
|
// Set extraction backend to Claude CLI persistent session (no API key needed)
|
|
1115
1117
|
if (mamaCore.setExtractionFn) {
|
|
1116
1118
|
const { PersistentClaudeProcess } = await import('../../agent/persistent-cli-process.js');
|
|
@@ -1173,6 +1175,12 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1173
1175
|
const result = await proc.sendMessage(prompt);
|
|
1174
1176
|
return parseExtractionResponse(result.response);
|
|
1175
1177
|
});
|
|
1178
|
+
// Expose extraction for connector pipeline
|
|
1179
|
+
connectorExtractionFn = async (prompt) => {
|
|
1180
|
+
const proc = await getExtractionProcess();
|
|
1181
|
+
const result = await proc.sendMessage(prompt);
|
|
1182
|
+
return result.response;
|
|
1183
|
+
};
|
|
1176
1184
|
}
|
|
1177
1185
|
const mamaApi = (mamaCore && typeof mamaCore === 'object' && 'mama' in mamaCore ? mamaCore.mama : mamaCore);
|
|
1178
1186
|
const suggest = (mamaApi.suggest ?? mamaApi.search);
|
|
@@ -1879,6 +1887,131 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1879
1887
|
},
|
|
1880
1888
|
});
|
|
1881
1889
|
tokenKeepAlive.start();
|
|
1890
|
+
// === Connector Framework ===
|
|
1891
|
+
const connectorsConfigPath = (0, node_path_1.join)((0, node_os_1.homedir)(), '.mama', 'connectors.json');
|
|
1892
|
+
if ((0, node_fs_1.existsSync)(connectorsConfigPath)) {
|
|
1893
|
+
const { ConnectorRegistry, PollingScheduler, RawStore } = await import('../../connectors/framework/index.js');
|
|
1894
|
+
const { loadConnector } = await import('../../connectors/index.js');
|
|
1895
|
+
const { buildProjectTruth, buildActivityExtractionPrompt, buildSpokeExtractionPrompt, groupByChannel, } = await import('../../memory/history-extractor.js');
|
|
1896
|
+
const { saveMemory, MEMORY_KINDS } = await import('@jungjaehoon/mama-core');
|
|
1897
|
+
let connectorsConfig;
|
|
1898
|
+
try {
|
|
1899
|
+
connectorsConfig = JSON.parse((0, node_fs_1.readFileSync)(connectorsConfigPath, 'utf-8'));
|
|
1900
|
+
}
|
|
1901
|
+
catch (err) {
|
|
1902
|
+
console.error(`[connector] failed to parse connectors.json:`, err);
|
|
1903
|
+
connectorsConfig = {};
|
|
1904
|
+
}
|
|
1905
|
+
const connectorRegistry = new ConnectorRegistry();
|
|
1906
|
+
const rawStore = new RawStore((0, node_path_1.join)((0, node_os_1.homedir)(), '.mama', 'connectors'));
|
|
1907
|
+
// Build channel configs for role classification
|
|
1908
|
+
// For kagemusha connector, channels are keyed as "source:channelId" (e.g., "chatwork:ROOM_ID")
|
|
1909
|
+
// but items have source=row.channel (e.g., "chatwork") and channel=row.channel_id (e.g., "chatwork:ROOM_ID")
|
|
1910
|
+
// So we need to distribute kagemusha channel configs by their source prefix
|
|
1911
|
+
const allChannelConfigs = {};
|
|
1912
|
+
for (const [name, cc] of Object.entries(connectorsConfig)) {
|
|
1913
|
+
if (name === 'kagemusha') {
|
|
1914
|
+
// Distribute kagemusha channels by source prefix
|
|
1915
|
+
for (const [channelKey, channelCfg] of Object.entries(cc.channels ?? {})) {
|
|
1916
|
+
const [source] = channelKey.split(':');
|
|
1917
|
+
if (!allChannelConfigs[source])
|
|
1918
|
+
allChannelConfigs[source] = {};
|
|
1919
|
+
allChannelConfigs[source][channelKey] = channelCfg;
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
else {
|
|
1923
|
+
allChannelConfigs[name] = cc.channels ?? {};
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
for (const [name, connConfig] of Object.entries(connectorsConfig)) {
|
|
1927
|
+
if (!connConfig.enabled)
|
|
1928
|
+
continue;
|
|
1929
|
+
try {
|
|
1930
|
+
const connector = await loadConnector(name, connConfig);
|
|
1931
|
+
await connector.init();
|
|
1932
|
+
connectorRegistry.register(name, connector);
|
|
1933
|
+
console.log(`[connector] ${name} initialized`);
|
|
1934
|
+
}
|
|
1935
|
+
catch (err) {
|
|
1936
|
+
console.error(`[connector] ${name} failed to init:`, err);
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
if (connectorRegistry.getActive().size > 0) {
|
|
1940
|
+
const connectorScheduler = new PollingScheduler(rawStore, (0, node_path_1.join)((0, node_os_1.homedir)(), '.mama', 'connectors'));
|
|
1941
|
+
const validKinds = new Set(MEMORY_KINDS);
|
|
1942
|
+
const extractAndSave = async (label, groups, buildPrompt) => {
|
|
1943
|
+
for (const [channelKey, channelItems] of groups) {
|
|
1944
|
+
const prompt = buildPrompt(channelItems);
|
|
1945
|
+
if (prompt.length > 20000) {
|
|
1946
|
+
console.log(`[connector] ${label}:${channelKey} skipped (prompt too large: ${prompt.length})`);
|
|
1947
|
+
continue;
|
|
1948
|
+
}
|
|
1949
|
+
try {
|
|
1950
|
+
if (!connectorExtractionFn)
|
|
1951
|
+
throw new Error('Extraction not available');
|
|
1952
|
+
const responseText = await connectorExtractionFn(prompt);
|
|
1953
|
+
const jsonMatch = responseText.match(/\[[\s\S]*\]/);
|
|
1954
|
+
if (jsonMatch) {
|
|
1955
|
+
const extracted = JSON.parse(jsonMatch[0]);
|
|
1956
|
+
for (const item of extracted) {
|
|
1957
|
+
if (!item.topic || !item.summary)
|
|
1958
|
+
continue;
|
|
1959
|
+
const projectName = item.project ?? 'unknown';
|
|
1960
|
+
const topicStr = item.work_unit
|
|
1961
|
+
? `${projectName}/${item.work_unit}`
|
|
1962
|
+
.toLowerCase()
|
|
1963
|
+
.replace(/[^a-z0-9가-힣_/]+/g, '_')
|
|
1964
|
+
: `${projectName}/${item.topic}`.toLowerCase().replace(/[^a-z0-9가-힣_/]+/g, '_');
|
|
1965
|
+
await saveMemory({
|
|
1966
|
+
topic: topicStr,
|
|
1967
|
+
kind: (validKinds.has(item.kind ?? '') ? item.kind : 'fact'),
|
|
1968
|
+
summary: item.summary,
|
|
1969
|
+
details: item.reasoning ?? item.summary,
|
|
1970
|
+
confidence: Math.max(0, Math.min(1, item.confidence ?? 0.7)),
|
|
1971
|
+
scopes: [{ kind: 'project', id: projectName }],
|
|
1972
|
+
source: { package: 'standalone', source_type: 'connector' },
|
|
1973
|
+
eventDate: item.event_date ?? new Date().toISOString().split('T')[0],
|
|
1974
|
+
});
|
|
1975
|
+
}
|
|
1976
|
+
console.log(`[connector] ${label}:${channelKey}: ${extracted.length} memories saved`);
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
catch (err) {
|
|
1980
|
+
console.error(`[connector] ${label}:${channelKey} extraction failed:`, err);
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
};
|
|
1984
|
+
connectorScheduler.startBatch(connectorRegistry, allChannelConfigs, 60, // unified polling interval (minutes)
|
|
1985
|
+
async ({ truth, activity, spoke }) => {
|
|
1986
|
+
// Pass 0: Truth → ProjectTruth (no LLM)
|
|
1987
|
+
const projectTruth = buildProjectTruth(truth);
|
|
1988
|
+
if (truth.length > 0) {
|
|
1989
|
+
console.log(`[connector] truth snapshot: ${Object.keys(projectTruth.projects).length} projects`);
|
|
1990
|
+
}
|
|
1991
|
+
// Pass 1: Activity extraction with truth context
|
|
1992
|
+
if (activity.length > 0) {
|
|
1993
|
+
const activityGroups = groupByChannel(activity);
|
|
1994
|
+
console.log(`[connector] activity: ${activity.length} items in ${activityGroups.size} channels`);
|
|
1995
|
+
await extractAndSave('activity', activityGroups, (items) => buildActivityExtractionPrompt(items, projectTruth));
|
|
1996
|
+
}
|
|
1997
|
+
// Pass 2: Spoke extraction with project context
|
|
1998
|
+
if (spoke.length > 0) {
|
|
1999
|
+
const hubContext = Object.entries(projectTruth.projects).flatMap(([proj, p]) => Object.entries(p.workUnits).map(([wu, state]) => ({
|
|
2000
|
+
project: proj,
|
|
2001
|
+
workUnit: wu,
|
|
2002
|
+
assignedTo: state.assigned,
|
|
2003
|
+
status: state.status,
|
|
2004
|
+
})));
|
|
2005
|
+
const spokeGroups = groupByChannel(spoke);
|
|
2006
|
+
console.log(`[connector] spoke: ${spoke.length} items in ${spokeGroups.size} channels`);
|
|
2007
|
+
await extractAndSave('spoke', spokeGroups, (items) => buildSpokeExtractionPrompt(items, hubContext, projectTruth));
|
|
2008
|
+
}
|
|
2009
|
+
});
|
|
2010
|
+
console.log(`[connector] ${connectorRegistry.getActive().size} connectors active`);
|
|
2011
|
+
// Add to graceful shutdown
|
|
2012
|
+
gateways.push({ stop: () => Promise.resolve(connectorScheduler.stop()) });
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
1882
2015
|
// Start API server
|
|
1883
2016
|
const skillRegistry = new skill_registry_js_1.SkillRegistry();
|
|
1884
2017
|
// Migrate existing plugin .mcp.json into global config (one-time)
|