@hasna/conversations 0.1.5 → 0.1.6
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/bin/hook.js +626 -0
- package/bin/index.js +114 -16
- package/bin/mcp.js +244 -156
- package/dist/hooks/blocker-hook.d.ts +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +243 -153
- package/dist/lib/identity.d.ts +1 -1
- package/dist/lib/messages.d.ts +1 -0
- package/dist/types.d.ts +2 -0
- package/package.json +4 -3
package/bin/hook.js
ADDED
|
@@ -0,0 +1,626 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// @bun
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
8
|
+
var __toCommonJS = (from) => {
|
|
9
|
+
var entry = __moduleCache.get(from), desc;
|
|
10
|
+
if (entry)
|
|
11
|
+
return entry;
|
|
12
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function")
|
|
14
|
+
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
}));
|
|
18
|
+
__moduleCache.set(from, entry);
|
|
19
|
+
return entry;
|
|
20
|
+
};
|
|
21
|
+
var __export = (target, all) => {
|
|
22
|
+
for (var name in all)
|
|
23
|
+
__defProp(target, name, {
|
|
24
|
+
get: all[name],
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
set: (newValue) => all[name] = () => newValue
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
31
|
+
|
|
32
|
+
// src/lib/db.ts
|
|
33
|
+
var exports_db = {};
|
|
34
|
+
__export(exports_db, {
|
|
35
|
+
getDbPath: () => getDbPath,
|
|
36
|
+
getDb: () => getDb,
|
|
37
|
+
closeDb: () => closeDb
|
|
38
|
+
});
|
|
39
|
+
import { Database } from "bun:sqlite";
|
|
40
|
+
import { mkdirSync } from "fs";
|
|
41
|
+
import { join, dirname } from "path";
|
|
42
|
+
import { homedir } from "os";
|
|
43
|
+
function getDbPath() {
|
|
44
|
+
if (process.env.CONVERSATIONS_DB_PATH)
|
|
45
|
+
return process.env.CONVERSATIONS_DB_PATH;
|
|
46
|
+
return join(homedir(), ".conversations", "messages.db");
|
|
47
|
+
}
|
|
48
|
+
function getDb() {
|
|
49
|
+
if (db)
|
|
50
|
+
return db;
|
|
51
|
+
const dbPath = getDbPath();
|
|
52
|
+
mkdirSync(dirname(dbPath), { recursive: true });
|
|
53
|
+
db = new Database(dbPath, { create: true });
|
|
54
|
+
db.exec("PRAGMA journal_mode = WAL");
|
|
55
|
+
db.exec("PRAGMA busy_timeout = 5000");
|
|
56
|
+
db.exec(`
|
|
57
|
+
CREATE TABLE IF NOT EXISTS messages (
|
|
58
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
59
|
+
session_id TEXT NOT NULL,
|
|
60
|
+
from_agent TEXT NOT NULL,
|
|
61
|
+
to_agent TEXT NOT NULL,
|
|
62
|
+
space TEXT,
|
|
63
|
+
content TEXT NOT NULL,
|
|
64
|
+
priority TEXT NOT NULL DEFAULT 'normal',
|
|
65
|
+
working_dir TEXT,
|
|
66
|
+
repository TEXT,
|
|
67
|
+
branch TEXT,
|
|
68
|
+
metadata TEXT,
|
|
69
|
+
created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%f', 'now')),
|
|
70
|
+
read_at TEXT
|
|
71
|
+
)
|
|
72
|
+
`);
|
|
73
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_messages_session ON messages(session_id)");
|
|
74
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_messages_to ON messages(to_agent)");
|
|
75
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_messages_created ON messages(created_at)");
|
|
76
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_messages_space ON messages(space)");
|
|
77
|
+
db.exec(`
|
|
78
|
+
CREATE TABLE IF NOT EXISTS projects (
|
|
79
|
+
id TEXT PRIMARY KEY,
|
|
80
|
+
name TEXT NOT NULL UNIQUE,
|
|
81
|
+
description TEXT,
|
|
82
|
+
path TEXT,
|
|
83
|
+
created_by TEXT NOT NULL,
|
|
84
|
+
created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%f', 'now')),
|
|
85
|
+
metadata TEXT,
|
|
86
|
+
tags TEXT,
|
|
87
|
+
status TEXT NOT NULL DEFAULT 'active',
|
|
88
|
+
repository TEXT,
|
|
89
|
+
settings TEXT
|
|
90
|
+
)
|
|
91
|
+
`);
|
|
92
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_projects_name ON projects(name)");
|
|
93
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_projects_status ON projects(status)");
|
|
94
|
+
db.exec(`
|
|
95
|
+
CREATE TABLE IF NOT EXISTS spaces (
|
|
96
|
+
name TEXT PRIMARY KEY,
|
|
97
|
+
description TEXT,
|
|
98
|
+
parent_id TEXT REFERENCES spaces(name),
|
|
99
|
+
project_id TEXT REFERENCES projects(id),
|
|
100
|
+
created_by TEXT NOT NULL,
|
|
101
|
+
created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%f', 'now')),
|
|
102
|
+
archived_at TEXT
|
|
103
|
+
)
|
|
104
|
+
`);
|
|
105
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_spaces_parent ON spaces(parent_id)");
|
|
106
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_spaces_project ON spaces(project_id)");
|
|
107
|
+
db.exec(`
|
|
108
|
+
CREATE TABLE IF NOT EXISTS space_members (
|
|
109
|
+
space TEXT NOT NULL REFERENCES spaces(name),
|
|
110
|
+
agent TEXT NOT NULL,
|
|
111
|
+
joined_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%f', 'now')),
|
|
112
|
+
PRIMARY KEY (space, agent)
|
|
113
|
+
)
|
|
114
|
+
`);
|
|
115
|
+
db.exec(`
|
|
116
|
+
CREATE TABLE IF NOT EXISTS agent_presence (
|
|
117
|
+
agent TEXT PRIMARY KEY,
|
|
118
|
+
status TEXT NOT NULL DEFAULT 'online',
|
|
119
|
+
last_seen_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%f', 'now')),
|
|
120
|
+
metadata TEXT
|
|
121
|
+
)
|
|
122
|
+
`);
|
|
123
|
+
const existingTables = db.prepare("SELECT name FROM sqlite_master WHERE type='table'").all();
|
|
124
|
+
const tableNames = existingTables.map((t) => t.name);
|
|
125
|
+
if (tableNames.includes("channels") && tableNames.includes("spaces")) {
|
|
126
|
+
const spaceCount = db.prepare("SELECT COUNT(*) as c FROM spaces").get().c;
|
|
127
|
+
const channelCount = db.prepare("SELECT COUNT(*) as c FROM channels").get().c;
|
|
128
|
+
if (channelCount > 0 && spaceCount === 0) {
|
|
129
|
+
db.exec("BEGIN");
|
|
130
|
+
try {
|
|
131
|
+
db.exec(`
|
|
132
|
+
INSERT OR IGNORE INTO spaces (name, description, created_by, created_at)
|
|
133
|
+
SELECT name, description, created_by, created_at FROM channels
|
|
134
|
+
`);
|
|
135
|
+
if (tableNames.includes("channel_members")) {
|
|
136
|
+
db.exec(`
|
|
137
|
+
INSERT OR IGNORE INTO space_members (space, agent, joined_at)
|
|
138
|
+
SELECT channel, agent, joined_at FROM channel_members
|
|
139
|
+
`);
|
|
140
|
+
}
|
|
141
|
+
db.exec("COMMIT");
|
|
142
|
+
} catch (e) {
|
|
143
|
+
db.exec("ROLLBACK");
|
|
144
|
+
throw e;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
db.exec("DROP TABLE IF EXISTS channel_members");
|
|
148
|
+
db.exec("DROP TABLE IF EXISTS channels");
|
|
149
|
+
}
|
|
150
|
+
const msgCols = db.prepare("PRAGMA table_info(messages)").all();
|
|
151
|
+
const colNames = msgCols.map((c) => c.name);
|
|
152
|
+
if (colNames.includes("channel") && !colNames.includes("space")) {
|
|
153
|
+
db.exec("ALTER TABLE messages ADD COLUMN space TEXT");
|
|
154
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_messages_space ON messages(space)");
|
|
155
|
+
db.exec("UPDATE messages SET space = channel WHERE channel IS NOT NULL");
|
|
156
|
+
db.exec(`
|
|
157
|
+
UPDATE messages
|
|
158
|
+
SET session_id = 'space:' || substr(session_id, 9)
|
|
159
|
+
WHERE session_id LIKE 'channel:%'
|
|
160
|
+
`);
|
|
161
|
+
}
|
|
162
|
+
const spaceCols = db.prepare("PRAGMA table_info(spaces)").all();
|
|
163
|
+
const spaceColNames = spaceCols.map((c) => c.name);
|
|
164
|
+
if (!spaceColNames.includes("archived_at")) {
|
|
165
|
+
db.exec("ALTER TABLE spaces ADD COLUMN archived_at TEXT");
|
|
166
|
+
}
|
|
167
|
+
const msgCols2 = db.prepare("PRAGMA table_info(messages)").all();
|
|
168
|
+
const colNames2 = msgCols2.map((c) => c.name);
|
|
169
|
+
if (!colNames2.includes("edited_at")) {
|
|
170
|
+
db.exec("ALTER TABLE messages ADD COLUMN edited_at TEXT");
|
|
171
|
+
}
|
|
172
|
+
if (!colNames2.includes("pinned_at")) {
|
|
173
|
+
db.exec("ALTER TABLE messages ADD COLUMN pinned_at TEXT");
|
|
174
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_messages_pinned ON messages(pinned_at)");
|
|
175
|
+
}
|
|
176
|
+
if (!colNames2.includes("blocking")) {
|
|
177
|
+
db.exec("ALTER TABLE messages ADD COLUMN blocking INTEGER NOT NULL DEFAULT 0");
|
|
178
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_messages_blocking ON messages(blocking)");
|
|
179
|
+
}
|
|
180
|
+
return db;
|
|
181
|
+
}
|
|
182
|
+
function closeDb() {
|
|
183
|
+
if (db) {
|
|
184
|
+
db.close();
|
|
185
|
+
db = null;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
var db = null;
|
|
189
|
+
var init_db = () => {};
|
|
190
|
+
|
|
191
|
+
// src/hooks/blocker-hook.ts
|
|
192
|
+
init_db();
|
|
193
|
+
|
|
194
|
+
// src/lib/identity.ts
|
|
195
|
+
import { readFileSync, writeFileSync, mkdirSync as mkdirSync2 } from "fs";
|
|
196
|
+
import { join as join2, dirname as dirname2 } from "path";
|
|
197
|
+
import { homedir as homedir2 } from "os";
|
|
198
|
+
|
|
199
|
+
// src/lib/names.ts
|
|
200
|
+
var AGENT_NAMES = [
|
|
201
|
+
"amber-fox",
|
|
202
|
+
"arctic-wolf",
|
|
203
|
+
"ashen-crow",
|
|
204
|
+
"azure-hawk",
|
|
205
|
+
"astral-lynx",
|
|
206
|
+
"autumn-bear",
|
|
207
|
+
"agile-puma",
|
|
208
|
+
"alpine-ibex",
|
|
209
|
+
"ancient-owl",
|
|
210
|
+
"aqua-otter",
|
|
211
|
+
"arid-viper",
|
|
212
|
+
"atom-finch",
|
|
213
|
+
"auburn-deer",
|
|
214
|
+
"aurora-seal",
|
|
215
|
+
"avid-mink",
|
|
216
|
+
"blaze-tiger",
|
|
217
|
+
"bright-heron",
|
|
218
|
+
"bronze-eagle",
|
|
219
|
+
"brisk-hare",
|
|
220
|
+
"burnt-moth",
|
|
221
|
+
"bold-raven",
|
|
222
|
+
"blue-whale",
|
|
223
|
+
"boreal-fox",
|
|
224
|
+
"brass-cobra",
|
|
225
|
+
"brave-ram",
|
|
226
|
+
"brick-crane",
|
|
227
|
+
"brief-newt",
|
|
228
|
+
"briny-crab",
|
|
229
|
+
"broad-elk",
|
|
230
|
+
"brook-dove",
|
|
231
|
+
"calm-panda",
|
|
232
|
+
"cedar-jay",
|
|
233
|
+
"chief-lion",
|
|
234
|
+
"chrome-bat",
|
|
235
|
+
"civic-wren",
|
|
236
|
+
"clear-swan",
|
|
237
|
+
"cliff-goat",
|
|
238
|
+
"coal-shark",
|
|
239
|
+
"cold-crane",
|
|
240
|
+
"copper-jay",
|
|
241
|
+
"coral-fish",
|
|
242
|
+
"crisp-lark",
|
|
243
|
+
"cross-mole",
|
|
244
|
+
"cubic-wasp",
|
|
245
|
+
"cyan-toad",
|
|
246
|
+
"dark-stag",
|
|
247
|
+
"dawn-robin",
|
|
248
|
+
"deep-squid",
|
|
249
|
+
"delta-fox",
|
|
250
|
+
"dense-boar",
|
|
251
|
+
"dew-spider",
|
|
252
|
+
"dim-gecko",
|
|
253
|
+
"draft-bear",
|
|
254
|
+
"drift-gull",
|
|
255
|
+
"dry-newt",
|
|
256
|
+
"dual-crane",
|
|
257
|
+
"dune-mouse",
|
|
258
|
+
"dusk-moth",
|
|
259
|
+
"dusty-mule",
|
|
260
|
+
"dwarf-carp",
|
|
261
|
+
"east-falcon",
|
|
262
|
+
"echo-parrot",
|
|
263
|
+
"edge-shark",
|
|
264
|
+
"elm-beetle",
|
|
265
|
+
"ember-lynx",
|
|
266
|
+
"epoch-crane",
|
|
267
|
+
"even-pike",
|
|
268
|
+
"extra-ant",
|
|
269
|
+
"elder-stork",
|
|
270
|
+
"ebon-crow",
|
|
271
|
+
"ever-finch",
|
|
272
|
+
"exact-moth",
|
|
273
|
+
"exile-wren",
|
|
274
|
+
"equal-dove",
|
|
275
|
+
"etch-hare",
|
|
276
|
+
"faint-orca",
|
|
277
|
+
"far-condor",
|
|
278
|
+
"fern-mouse",
|
|
279
|
+
"fierce-yak",
|
|
280
|
+
"first-kite",
|
|
281
|
+
"fjord-seal",
|
|
282
|
+
"flint-wolf",
|
|
283
|
+
"fog-parrot",
|
|
284
|
+
"forge-bull",
|
|
285
|
+
"fossil-ray",
|
|
286
|
+
"frank-mink",
|
|
287
|
+
"free-eagle",
|
|
288
|
+
"fresh-colt",
|
|
289
|
+
"frost-bear",
|
|
290
|
+
"fuse-wasp",
|
|
291
|
+
"gale-hawk",
|
|
292
|
+
"gem-turtle",
|
|
293
|
+
"ghost-lynx",
|
|
294
|
+
"gilt-robin",
|
|
295
|
+
"glad-moose",
|
|
296
|
+
"glass-eel",
|
|
297
|
+
"gleam-puma",
|
|
298
|
+
"glyph-owl",
|
|
299
|
+
"gold-crane",
|
|
300
|
+
"gorge-lion",
|
|
301
|
+
"grain-duck",
|
|
302
|
+
"grand-wolf",
|
|
303
|
+
"gray-fox",
|
|
304
|
+
"green-hare",
|
|
305
|
+
"grit-shark",
|
|
306
|
+
"half-stork",
|
|
307
|
+
"haze-panther",
|
|
308
|
+
"heart-dove",
|
|
309
|
+
"helm-eagle",
|
|
310
|
+
"herb-toad",
|
|
311
|
+
"hex-spider",
|
|
312
|
+
"high-falcon",
|
|
313
|
+
"hive-hornet",
|
|
314
|
+
"holo-swan",
|
|
315
|
+
"hood-cobra",
|
|
316
|
+
"horn-bison",
|
|
317
|
+
"huge-squid",
|
|
318
|
+
"hull-crab",
|
|
319
|
+
"hunt-marten",
|
|
320
|
+
"husk-moth",
|
|
321
|
+
"ice-leopard",
|
|
322
|
+
"idle-crane",
|
|
323
|
+
"inch-beetle",
|
|
324
|
+
"indigo-jay",
|
|
325
|
+
"inner-fox",
|
|
326
|
+
"ion-parrot",
|
|
327
|
+
"iron-bull",
|
|
328
|
+
"isle-pelican",
|
|
329
|
+
"ivory-hawk",
|
|
330
|
+
"ivy-snake",
|
|
331
|
+
"iota-wren",
|
|
332
|
+
"ink-raven",
|
|
333
|
+
"ignite-ram",
|
|
334
|
+
"inert-slug",
|
|
335
|
+
"infra-mole",
|
|
336
|
+
"jade-tiger",
|
|
337
|
+
"jest-magpie",
|
|
338
|
+
"jewel-crane",
|
|
339
|
+
"joint-boar",
|
|
340
|
+
"jovial-elk",
|
|
341
|
+
"jump-frog",
|
|
342
|
+
"jungle-cat",
|
|
343
|
+
"jury-dove",
|
|
344
|
+
"just-heron",
|
|
345
|
+
"jolt-wasp",
|
|
346
|
+
"keen-osprey",
|
|
347
|
+
"kelp-seal",
|
|
348
|
+
"key-falcon",
|
|
349
|
+
"kind-panda",
|
|
350
|
+
"knot-viper",
|
|
351
|
+
"kraft-bear",
|
|
352
|
+
"kite-mouse",
|
|
353
|
+
"knoll-deer",
|
|
354
|
+
"know-crane",
|
|
355
|
+
"karma-wolf",
|
|
356
|
+
"lake-otter",
|
|
357
|
+
"lapis-jay",
|
|
358
|
+
"last-condor",
|
|
359
|
+
"leaf-gecko",
|
|
360
|
+
"lean-coyote",
|
|
361
|
+
"light-lynx",
|
|
362
|
+
"lime-parrot",
|
|
363
|
+
"live-eagle",
|
|
364
|
+
"long-crane",
|
|
365
|
+
"lost-fox",
|
|
366
|
+
"loud-finch",
|
|
367
|
+
"low-shark",
|
|
368
|
+
"luck-rabbit",
|
|
369
|
+
"lunar-owl",
|
|
370
|
+
"lush-ibis",
|
|
371
|
+
"malt-badger",
|
|
372
|
+
"maple-wren",
|
|
373
|
+
"mars-falcon",
|
|
374
|
+
"matte-crow",
|
|
375
|
+
"mesa-hawk",
|
|
376
|
+
"mild-orca",
|
|
377
|
+
"mint-dove",
|
|
378
|
+
"mist-puma",
|
|
379
|
+
"mock-robin",
|
|
380
|
+
"mono-wolf",
|
|
381
|
+
"moon-bear",
|
|
382
|
+
"moss-turtle",
|
|
383
|
+
"mud-heron",
|
|
384
|
+
"mute-swan",
|
|
385
|
+
"myth-lynx",
|
|
386
|
+
"navy-eagle",
|
|
387
|
+
"near-mink",
|
|
388
|
+
"neon-parrot",
|
|
389
|
+
"nest-crane",
|
|
390
|
+
"next-fox",
|
|
391
|
+
"nimble-ram",
|
|
392
|
+
"node-spider",
|
|
393
|
+
"noon-hawk",
|
|
394
|
+
"north-seal",
|
|
395
|
+
"nova-owl",
|
|
396
|
+
"null-moth",
|
|
397
|
+
"numb-carp",
|
|
398
|
+
"nutmeg-jay",
|
|
399
|
+
"neat-cobra",
|
|
400
|
+
"nomad-elk",
|
|
401
|
+
"oak-badger",
|
|
402
|
+
"oat-finch",
|
|
403
|
+
"odd-pelican",
|
|
404
|
+
"olive-bear",
|
|
405
|
+
"onyx-raven",
|
|
406
|
+
"opal-crane",
|
|
407
|
+
"open-wolf",
|
|
408
|
+
"orbit-lynx",
|
|
409
|
+
"ore-shark",
|
|
410
|
+
"outer-dove",
|
|
411
|
+
"pale-tiger",
|
|
412
|
+
"park-heron",
|
|
413
|
+
"peak-eagle",
|
|
414
|
+
"pine-fox",
|
|
415
|
+
"pixel-owl",
|
|
416
|
+
"plain-goat",
|
|
417
|
+
"plum-crane",
|
|
418
|
+
"polar-ray",
|
|
419
|
+
"port-falcon",
|
|
420
|
+
"prime-wolf",
|
|
421
|
+
"prism-jay",
|
|
422
|
+
"proud-lion",
|
|
423
|
+
"pulse-bat",
|
|
424
|
+
"pure-swan",
|
|
425
|
+
"pyro-hawk",
|
|
426
|
+
"quake-bear",
|
|
427
|
+
"quartz-jay",
|
|
428
|
+
"quest-falcon",
|
|
429
|
+
"quick-otter",
|
|
430
|
+
"quiet-crane",
|
|
431
|
+
"rain-leopard",
|
|
432
|
+
"rapid-hare",
|
|
433
|
+
"raw-condor",
|
|
434
|
+
"reef-dolphin",
|
|
435
|
+
"regal-stag",
|
|
436
|
+
"ridge-fox",
|
|
437
|
+
"rift-cobra",
|
|
438
|
+
"rigid-crane",
|
|
439
|
+
"river-otter",
|
|
440
|
+
"rock-eagle",
|
|
441
|
+
"root-mole",
|
|
442
|
+
"rose-finch",
|
|
443
|
+
"rough-boar",
|
|
444
|
+
"ruby-hawk",
|
|
445
|
+
"rust-wolf",
|
|
446
|
+
"sage-owl",
|
|
447
|
+
"salt-crane",
|
|
448
|
+
"sand-viper",
|
|
449
|
+
"satin-dove",
|
|
450
|
+
"scale-dragon",
|
|
451
|
+
"scarlet-ibis",
|
|
452
|
+
"sea-falcon",
|
|
453
|
+
"shade-lynx",
|
|
454
|
+
"sharp-eagle",
|
|
455
|
+
"shell-crab",
|
|
456
|
+
"short-fox",
|
|
457
|
+
"sigma-jay",
|
|
458
|
+
"silk-moth",
|
|
459
|
+
"silver-wolf",
|
|
460
|
+
"slate-bear",
|
|
461
|
+
"slim-heron",
|
|
462
|
+
"smoke-puma",
|
|
463
|
+
"snap-turtle",
|
|
464
|
+
"snow-leopard",
|
|
465
|
+
"solar-crane",
|
|
466
|
+
"solid-ram",
|
|
467
|
+
"sonic-bat",
|
|
468
|
+
"south-seal",
|
|
469
|
+
"spark-robin",
|
|
470
|
+
"spice-wren",
|
|
471
|
+
"split-mink",
|
|
472
|
+
"spring-elk",
|
|
473
|
+
"squid-ink",
|
|
474
|
+
"stark-crow",
|
|
475
|
+
"steel-hawk",
|
|
476
|
+
"stern-bull",
|
|
477
|
+
"still-swan",
|
|
478
|
+
"stone-fox",
|
|
479
|
+
"storm-eagle",
|
|
480
|
+
"stout-boar",
|
|
481
|
+
"stray-cat",
|
|
482
|
+
"strong-lion",
|
|
483
|
+
"sun-parrot",
|
|
484
|
+
"surf-dolphin",
|
|
485
|
+
"swift-deer",
|
|
486
|
+
"teal-crane",
|
|
487
|
+
"terra-wolf",
|
|
488
|
+
"thick-bear",
|
|
489
|
+
"thin-spider",
|
|
490
|
+
"third-owl",
|
|
491
|
+
"thorn-fox",
|
|
492
|
+
"tide-seal",
|
|
493
|
+
"timber-jay",
|
|
494
|
+
"tiny-wren",
|
|
495
|
+
"toast-mole",
|
|
496
|
+
"topaz-hawk",
|
|
497
|
+
"torch-lynx",
|
|
498
|
+
"trace-falcon",
|
|
499
|
+
"true-eagle",
|
|
500
|
+
"tusk-walrus",
|
|
501
|
+
"ultra-crane",
|
|
502
|
+
"umbra-wolf",
|
|
503
|
+
"unit-fox",
|
|
504
|
+
"upper-hawk",
|
|
505
|
+
"urban-jay",
|
|
506
|
+
"vale-deer",
|
|
507
|
+
"vast-eagle",
|
|
508
|
+
"vault-bear",
|
|
509
|
+
"velvet-owl",
|
|
510
|
+
"vent-crane",
|
|
511
|
+
"verse-fox",
|
|
512
|
+
"vigor-lynx",
|
|
513
|
+
"vine-parrot",
|
|
514
|
+
"vivid-swan",
|
|
515
|
+
"void-raven",
|
|
516
|
+
"volt-hawk",
|
|
517
|
+
"vow-falcon",
|
|
518
|
+
"vintage-jay",
|
|
519
|
+
"vista-wolf",
|
|
520
|
+
"vital-hare",
|
|
521
|
+
"warm-otter",
|
|
522
|
+
"wave-dolphin",
|
|
523
|
+
"wax-crane",
|
|
524
|
+
"west-falcon",
|
|
525
|
+
"wheat-mouse",
|
|
526
|
+
"white-tiger",
|
|
527
|
+
"wide-eagle",
|
|
528
|
+
"wild-fox",
|
|
529
|
+
"wind-hawk",
|
|
530
|
+
"wire-spider",
|
|
531
|
+
"wise-owl",
|
|
532
|
+
"wood-thrush",
|
|
533
|
+
"wool-ram",
|
|
534
|
+
"wren-song",
|
|
535
|
+
"wry-crow",
|
|
536
|
+
"xeno-crane",
|
|
537
|
+
"xerus-fox",
|
|
538
|
+
"yarn-robin",
|
|
539
|
+
"yew-falcon",
|
|
540
|
+
"young-wolf",
|
|
541
|
+
"zeal-hawk",
|
|
542
|
+
"zen-panda",
|
|
543
|
+
"zero-crane",
|
|
544
|
+
"zinc-eagle",
|
|
545
|
+
"zone-fox"
|
|
546
|
+
];
|
|
547
|
+
|
|
548
|
+
// src/lib/identity.ts
|
|
549
|
+
var AGENT_ID_FILE = join2(homedir2(), ".conversations", "agent-id");
|
|
550
|
+
var cachedAutoName = null;
|
|
551
|
+
function isNameTaken(name) {
|
|
552
|
+
try {
|
|
553
|
+
const { getDb: getDb2 } = (init_db(), __toCommonJS(exports_db));
|
|
554
|
+
const db2 = getDb2();
|
|
555
|
+
const row = db2.prepare("SELECT agent FROM agent_presence WHERE agent = ?").get(name);
|
|
556
|
+
return !!row;
|
|
557
|
+
} catch {
|
|
558
|
+
return false;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
function getAutoName() {
|
|
562
|
+
if (cachedAutoName)
|
|
563
|
+
return cachedAutoName;
|
|
564
|
+
try {
|
|
565
|
+
const name2 = readFileSync(AGENT_ID_FILE, "utf-8").trim();
|
|
566
|
+
if (name2) {
|
|
567
|
+
cachedAutoName = name2;
|
|
568
|
+
return name2;
|
|
569
|
+
}
|
|
570
|
+
} catch {}
|
|
571
|
+
const shuffled = [...AGENT_NAMES].sort(() => Math.random() - 0.5);
|
|
572
|
+
let name = shuffled[0];
|
|
573
|
+
for (const candidate of shuffled) {
|
|
574
|
+
if (!isNameTaken(candidate)) {
|
|
575
|
+
name = candidate;
|
|
576
|
+
break;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
cachedAutoName = name;
|
|
580
|
+
try {
|
|
581
|
+
mkdirSync2(dirname2(AGENT_ID_FILE), { recursive: true });
|
|
582
|
+
writeFileSync(AGENT_ID_FILE, name + `
|
|
583
|
+
`, "utf-8");
|
|
584
|
+
} catch {}
|
|
585
|
+
return name;
|
|
586
|
+
}
|
|
587
|
+
function resolveIdentity(explicit) {
|
|
588
|
+
const explicitValue = explicit?.trim();
|
|
589
|
+
if (explicitValue)
|
|
590
|
+
return explicitValue;
|
|
591
|
+
const envValue = process.env.CONVERSATIONS_AGENT_ID?.trim();
|
|
592
|
+
if (envValue)
|
|
593
|
+
return envValue;
|
|
594
|
+
return getAutoName();
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
// src/hooks/blocker-hook.ts
|
|
598
|
+
var agent = resolveIdentity();
|
|
599
|
+
var db2 = getDb();
|
|
600
|
+
var blockers = db2.prepare(`
|
|
601
|
+
SELECT id, from_agent, content, space, created_at FROM messages
|
|
602
|
+
WHERE blocking = 1 AND read_at IS NULL
|
|
603
|
+
AND (
|
|
604
|
+
to_agent = ?
|
|
605
|
+
OR space IN (SELECT space FROM space_members WHERE agent = ?)
|
|
606
|
+
)
|
|
607
|
+
ORDER BY created_at ASC
|
|
608
|
+
LIMIT 10
|
|
609
|
+
`).all(agent, agent);
|
|
610
|
+
closeDb();
|
|
611
|
+
if (blockers.length === 0) {
|
|
612
|
+
process.exit(0);
|
|
613
|
+
}
|
|
614
|
+
var lines = blockers.map((b) => {
|
|
615
|
+
const where = b.space ? `in #${b.space}` : "via DM";
|
|
616
|
+
return `[BLOCKER #${b.id}] ${b.from_agent} ${where}: ${b.content}`;
|
|
617
|
+
});
|
|
618
|
+
console.error(`\u26A0 You have ${blockers.length} blocking message(s) that require acknowledgment:
|
|
619
|
+
`);
|
|
620
|
+
for (const line of lines) {
|
|
621
|
+
console.error(line);
|
|
622
|
+
}
|
|
623
|
+
console.error(`
|
|
624
|
+
Use mark_read to acknowledge these messages before continuing.`);
|
|
625
|
+
console.error(`Message IDs: ${blockers.map((b) => b.id).join(", ")}`);
|
|
626
|
+
process.exit(2);
|