heyio 1.12.1 → 3.0.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/api/middleware/auth.d.ts +14 -0
- package/dist/api/middleware/auth.d.ts.map +1 -0
- package/dist/api/middleware/auth.js +66 -0
- package/dist/api/middleware/auth.js.map +1 -0
- package/dist/api/notifications.d.ts +14 -0
- package/dist/api/notifications.d.ts.map +1 -0
- package/dist/api/notifications.js +112 -0
- package/dist/api/notifications.js.map +1 -0
- package/dist/api/routes/activity.d.ts +3 -0
- package/dist/api/routes/activity.d.ts.map +1 -0
- package/dist/api/routes/activity.js +28 -0
- package/dist/api/routes/activity.js.map +1 -0
- package/dist/api/routes/attachments.d.ts +3 -0
- package/dist/api/routes/attachments.d.ts.map +1 -0
- package/dist/api/routes/attachments.js +83 -0
- package/dist/api/routes/attachments.js.map +1 -0
- package/dist/api/routes/config.d.ts +3 -0
- package/dist/api/routes/config.d.ts.map +1 -0
- package/dist/api/routes/config.js +106 -0
- package/dist/api/routes/config.js.map +1 -0
- package/dist/api/routes/conversations.d.ts +3 -0
- package/dist/api/routes/conversations.d.ts.map +1 -0
- package/dist/api/routes/conversations.js +69 -0
- package/dist/api/routes/conversations.js.map +1 -0
- package/dist/api/routes/health.d.ts +3 -0
- package/dist/api/routes/health.d.ts.map +1 -0
- package/dist/api/routes/health.js +16 -0
- package/dist/api/routes/health.js.map +1 -0
- package/dist/api/routes/inbox.d.ts +3 -0
- package/dist/api/routes/inbox.d.ts.map +1 -0
- package/dist/api/routes/inbox.js +88 -0
- package/dist/api/routes/inbox.js.map +1 -0
- package/dist/api/routes/schedules.d.ts +3 -0
- package/dist/api/routes/schedules.d.ts.map +1 -0
- package/dist/api/routes/schedules.js +96 -0
- package/dist/api/routes/schedules.js.map +1 -0
- package/dist/api/routes/skills.d.ts +2 -0
- package/dist/api/routes/skills.d.ts.map +1 -0
- package/dist/api/routes/skills.js +85 -0
- package/dist/api/routes/skills.js.map +1 -0
- package/dist/api/routes/squads.d.ts +3 -0
- package/dist/api/routes/squads.d.ts.map +1 -0
- package/dist/api/routes/squads.js +129 -0
- package/dist/api/routes/squads.js.map +1 -0
- package/dist/api/routes/usage.d.ts +3 -0
- package/dist/api/routes/usage.d.ts.map +1 -0
- package/dist/api/routes/usage.js +55 -0
- package/dist/api/routes/usage.js.map +1 -0
- package/dist/api/routes/wiki.d.ts +2 -0
- package/dist/api/routes/wiki.d.ts.map +1 -0
- package/dist/api/routes/wiki.js +43 -0
- package/dist/api/routes/wiki.js.map +1 -0
- package/dist/api/server.d.ts +7 -0
- package/dist/api/server.d.ts.map +1 -0
- package/dist/api/server.js +136 -634
- package/dist/api/server.js.map +1 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +2 -91
- package/dist/config.js.map +1 -0
- package/dist/copilot/client.d.ts +5 -0
- package/dist/copilot/client.d.ts.map +1 -0
- package/dist/copilot/client.js +19 -11
- package/dist/copilot/client.js.map +1 -0
- package/dist/copilot/health-monitor.d.ts +14 -0
- package/dist/copilot/health-monitor.d.ts.map +1 -0
- package/dist/copilot/health-monitor.js +70 -0
- package/dist/copilot/health-monitor.js.map +1 -0
- package/dist/copilot/orchestrator.d.ts +5 -0
- package/dist/copilot/orchestrator.d.ts.map +1 -0
- package/dist/copilot/orchestrator.js +127 -123
- package/dist/copilot/orchestrator.js.map +1 -0
- package/dist/copilot/tools.d.ts +49 -0
- package/dist/copilot/tools.d.ts.map +1 -0
- package/dist/copilot/tools.js +545 -321
- package/dist/copilot/tools.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +82 -26
- package/dist/index.js.map +1 -0
- package/dist/logging/logger.d.ts +6 -0
- package/dist/logging/logger.d.ts.map +1 -0
- package/dist/logging/logger.js +21 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/models/index.d.ts +6 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +4 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/pricing.d.ts +25 -0
- package/dist/models/pricing.d.ts.map +1 -0
- package/dist/models/pricing.js +96 -0
- package/dist/models/pricing.js.map +1 -0
- package/dist/models/registry.d.ts +34 -0
- package/dist/models/registry.d.ts.map +1 -0
- package/dist/models/registry.js +109 -0
- package/dist/models/registry.js.map +1 -0
- package/dist/models/token-tracker.d.ts +40 -0
- package/dist/models/token-tracker.d.ts.map +1 -0
- package/dist/models/token-tracker.js +102 -0
- package/dist/models/token-tracker.js.map +1 -0
- package/dist/scheduler/engine.d.ts +9 -0
- package/dist/scheduler/engine.d.ts.map +1 -0
- package/dist/scheduler/engine.js +127 -0
- package/dist/scheduler/engine.js.map +1 -0
- package/dist/skills/index.d.ts +3 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +2 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/store.d.ts +52 -0
- package/dist/skills/store.d.ts.map +1 -0
- package/dist/skills/store.js +148 -0
- package/dist/skills/store.js.map +1 -0
- package/dist/squad/agent.d.ts +46 -0
- package/dist/squad/agent.d.ts.map +1 -0
- package/dist/squad/agent.js +261 -0
- package/dist/squad/agent.js.map +1 -0
- package/dist/squad/autonomy.d.ts +16 -0
- package/dist/squad/autonomy.d.ts.map +1 -0
- package/dist/squad/autonomy.js +63 -0
- package/dist/squad/autonomy.js.map +1 -0
- package/dist/squad/event-bus.d.ts +22 -0
- package/dist/squad/event-bus.d.ts.map +1 -0
- package/dist/squad/event-bus.js +56 -0
- package/dist/squad/event-bus.js.map +1 -0
- package/dist/squad/execution/index.d.ts +12 -0
- package/dist/squad/execution/index.d.ts.map +1 -0
- package/dist/squad/execution/index.js +7 -0
- package/dist/squad/execution/index.js.map +1 -0
- package/dist/squad/execution/instance.d.ts +40 -0
- package/dist/squad/execution/instance.d.ts.map +1 -0
- package/dist/squad/execution/instance.js +138 -0
- package/dist/squad/execution/instance.js.map +1 -0
- package/dist/squad/execution/meeting.d.ts +25 -0
- package/dist/squad/execution/meeting.d.ts.map +1 -0
- package/dist/squad/execution/meeting.js +140 -0
- package/dist/squad/execution/meeting.js.map +1 -0
- package/dist/squad/execution/pr.d.ts +15 -0
- package/dist/squad/execution/pr.d.ts.map +1 -0
- package/dist/squad/execution/pr.js +93 -0
- package/dist/squad/execution/pr.js.map +1 -0
- package/dist/squad/execution/runner.d.ts +22 -0
- package/dist/squad/execution/runner.d.ts.map +1 -0
- package/dist/squad/execution/runner.js +68 -0
- package/dist/squad/execution/runner.js.map +1 -0
- package/dist/squad/execution/tasks.d.ts +11 -0
- package/dist/squad/execution/tasks.d.ts.map +1 -0
- package/dist/squad/execution/tasks.js +85 -0
- package/dist/squad/execution/tasks.js.map +1 -0
- package/dist/squad/execution/worktree.d.ts +26 -0
- package/dist/squad/execution/worktree.d.ts.map +1 -0
- package/dist/squad/execution/worktree.js +111 -0
- package/dist/squad/execution/worktree.js.map +1 -0
- package/dist/squad/hiring.d.ts +32 -0
- package/dist/squad/hiring.d.ts.map +1 -0
- package/dist/squad/hiring.js +200 -0
- package/dist/squad/hiring.js.map +1 -0
- package/dist/squad/index.d.ts +8 -0
- package/dist/squad/index.d.ts.map +1 -0
- package/dist/squad/index.js +6 -0
- package/dist/squad/index.js.map +1 -0
- package/dist/squad/manager.d.ts +48 -0
- package/dist/squad/manager.d.ts.map +1 -0
- package/dist/squad/manager.js +274 -0
- package/dist/squad/manager.js.map +1 -0
- package/dist/squad/name-generator.d.ts +16 -0
- package/dist/squad/name-generator.d.ts.map +1 -0
- package/dist/squad/name-generator.js +113 -0
- package/dist/squad/name-generator.js.map +1 -0
- package/dist/squad/roles/templates.d.ts +5 -0
- package/dist/squad/roles/templates.d.ts.map +1 -0
- package/dist/squad/roles/templates.js +102 -0
- package/dist/squad/roles/templates.js.map +1 -0
- package/dist/squad/skill-parser.d.ts +36 -0
- package/dist/squad/skill-parser.d.ts.map +1 -0
- package/dist/squad/skill-parser.js +83 -0
- package/dist/squad/skill-parser.js.map +1 -0
- package/dist/squad/source-resolver.d.ts +20 -0
- package/dist/squad/source-resolver.d.ts.map +1 -0
- package/dist/squad/source-resolver.js +52 -0
- package/dist/squad/source-resolver.js.map +1 -0
- package/dist/store/activity.d.ts +43 -0
- package/dist/store/activity.d.ts.map +1 -0
- package/dist/store/activity.js +131 -0
- package/dist/store/activity.js.map +1 -0
- package/dist/store/db.d.ts +5 -0
- package/dist/store/db.d.ts.map +1 -0
- package/dist/store/db.js +209 -248
- package/dist/store/db.js.map +1 -0
- package/dist/store/inbox.d.ts +53 -0
- package/dist/store/inbox.d.ts.map +1 -0
- package/dist/store/inbox.js +151 -0
- package/dist/store/inbox.js.map +1 -0
- package/dist/store/schedules.d.ts +53 -0
- package/dist/store/schedules.d.ts.map +1 -0
- package/dist/store/schedules.js +149 -54
- package/dist/store/schedules.js.map +1 -0
- package/dist/wiki/index.d.ts +3 -0
- package/dist/wiki/index.d.ts.map +1 -0
- package/dist/wiki/index.js +2 -0
- package/dist/wiki/index.js.map +1 -0
- package/dist/wiki/store.d.ts +49 -0
- package/dist/wiki/store.d.ts.map +1 -0
- package/dist/wiki/store.js +115 -0
- package/dist/wiki/store.js.map +1 -0
- package/package.json +52 -56
- package/src/api/middleware/auth.ts +76 -0
- package/src/api/notifications.ts +122 -0
- package/src/api/routes/activity.ts +29 -0
- package/src/api/routes/attachments.ts +93 -0
- package/src/api/routes/config.ts +115 -0
- package/src/api/routes/conversations.ts +87 -0
- package/src/api/routes/health.ts +18 -0
- package/src/api/routes/inbox.ts +98 -0
- package/src/api/routes/schedules.ts +121 -0
- package/src/api/routes/skills.ts +105 -0
- package/src/api/routes/squads.ts +145 -0
- package/src/api/routes/usage.ts +57 -0
- package/src/api/routes/wiki.ts +49 -0
- package/src/api/server.ts +186 -0
- package/src/config.ts +3 -0
- package/src/copilot/client.ts +42 -0
- package/src/copilot/health-monitor.ts +85 -0
- package/src/copilot/orchestrator.ts +222 -0
- package/src/copilot/tools.ts +707 -0
- package/src/index.ts +112 -0
- package/src/logging/logger.ts +26 -0
- package/src/models/index.ts +11 -0
- package/src/models/pricing.ts +121 -0
- package/src/models/registry.ts +131 -0
- package/src/models/token-tracker.ts +151 -0
- package/src/scheduler/engine.ts +146 -0
- package/src/skills/index.ts +13 -0
- package/src/skills/store.ts +188 -0
- package/src/squad/agent.ts +326 -0
- package/src/squad/autonomy.ts +78 -0
- package/src/squad/event-bus.ts +71 -0
- package/src/squad/execution/index.ts +17 -0
- package/src/squad/execution/instance.ts +186 -0
- package/src/squad/execution/meeting.ts +191 -0
- package/src/squad/execution/pr.ts +127 -0
- package/src/squad/execution/runner.ts +97 -0
- package/src/squad/execution/tasks.ts +111 -0
- package/src/squad/execution/worktree.ts +138 -0
- package/src/squad/hiring.ts +222 -0
- package/src/squad/index.ts +17 -0
- package/src/squad/manager.ts +337 -0
- package/src/squad/name-generator.ts +135 -0
- package/src/squad/roles/templates.ts +104 -0
- package/src/squad/skill-parser.ts +120 -0
- package/src/squad/source-resolver.ts +57 -0
- package/src/store/activity.ts +176 -0
- package/src/store/db.ts +237 -0
- package/src/store/inbox.ts +199 -0
- package/src/store/schedules.ts +199 -0
- package/src/wiki/index.ts +12 -0
- package/src/wiki/store.ts +139 -0
- package/tsconfig.json +9 -0
- package/LICENSE +0 -21
- package/README.md +0 -333
- package/dist/api/auth.js +0 -46
- package/dist/chat/attachments.js +0 -112
- package/dist/copilot/agents.js +0 -309
- package/dist/copilot/ceremonies.js +0 -174
- package/dist/copilot/gh-token.js +0 -64
- package/dist/copilot/io-scheduler.js +0 -79
- package/dist/copilot/model-router.js +0 -114
- package/dist/copilot/scheduler.js +0 -88
- package/dist/copilot/skills.js +0 -246
- package/dist/copilot/specialist-runner.js +0 -191
- package/dist/copilot/squad-tools.js +0 -258
- package/dist/copilot/system-message.js +0 -86
- package/dist/copilot/token-tracker.js +0 -98
- package/dist/copilot/trigger-schedule.js +0 -33
- package/dist/daemon.js +0 -67
- package/dist/logging.js +0 -27
- package/dist/mcp/config.js +0 -29
- package/dist/mcp/index.js +0 -3
- package/dist/mcp/registry.js +0 -42
- package/dist/notify.js +0 -25
- package/dist/paths.js +0 -17
- package/dist/setup.js +0 -35
- package/dist/store/agent-events.js +0 -19
- package/dist/store/audit-log.js +0 -71
- package/dist/store/conversations.js +0 -164
- package/dist/store/feed.js +0 -44
- package/dist/store/instances.js +0 -75
- package/dist/store/squad-colors.js +0 -23
- package/dist/store/squads.js +0 -60
- package/dist/store/tasks.js +0 -78
- package/dist/store/token-usage.js +0 -94
- package/dist/telegram/bot.js +0 -41
- package/dist/telegram/handlers.js +0 -42
- package/dist/watchdog.js +0 -37
- package/dist/wiki/backlinks.js +0 -51
- package/dist/wiki/fs.js +0 -108
- package/dist/wiki/search.js +0 -47
- package/web-dist/assets/AuditLogView-C5QtUQBq.js +0 -6
- package/web-dist/assets/ChatView-DLu9BMg8.js +0 -1
- package/web-dist/assets/FeedView-6OV-l6Gl.js +0 -6
- package/web-dist/assets/HistoryView-DizPqv0y.js +0 -1
- package/web-dist/assets/LoginView-CG1O9fmR.js +0 -1
- package/web-dist/assets/McpView-TJN-fZvI.js +0 -1
- package/web-dist/assets/SchedulesView-BDFpImX6.js +0 -6
- package/web-dist/assets/SettingsView-D-K1iC1c.js +0 -1
- package/web-dist/assets/SkillsView-DnNmO192.js +0 -15
- package/web-dist/assets/SquadDetailView-BBvrgHzn.js +0 -26
- package/web-dist/assets/SquadHealthView-DF2zF9D3.js +0 -11
- package/web-dist/assets/SquadsView-CPVzko7k.js +0 -6
- package/web-dist/assets/ToggleSwitch.vue_vue_type_script_setup_true_lang-Bk_t9_Rn.js +0 -1
- package/web-dist/assets/UsageView-OcyM5k14.js +0 -16
- package/web-dist/assets/WikiView-KhFqBZI0.js +0 -26
- package/web-dist/assets/api-BiDVwQrs.js +0 -1
- package/web-dist/assets/arrow-left-DFbf2tii.js +0 -6
- package/web-dist/assets/git-branch-BLstr_Gr.js +0 -6
- package/web-dist/assets/index-B-o45ao1.css +0 -1
- package/web-dist/assets/index-DCJUYZtV.js +0 -269
- package/web-dist/assets/pencil-D4Zz_t0y.js +0 -6
- package/web-dist/assets/plus-gmwiZVfr.js +0 -6
- package/web-dist/assets/save-BvtAs5WB.js +0 -6
- package/web-dist/assets/search-BabUvoGD.js +0 -6
- package/web-dist/assets/squad-colors-B8B_Y-lz.js +0 -1
- package/web-dist/assets/trash-2-C21cNLJl.js +0 -6
- package/web-dist/assets/triangle-alert-BrzY_E1n.js +0 -6
- package/web-dist/assets/x-xgLSmc9e.js +0 -6
- package/web-dist/favicon.svg +0 -10
- package/web-dist/index.html +0 -14
- package/web-dist/logo.svg +0 -10
package/dist/notify.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { loadConfig } from "./config.js";
|
|
2
|
-
import { postFeedItem } from "./store/feed.js";
|
|
3
|
-
import { logWarn } from "./logging.js";
|
|
4
|
-
export async function notify(title, content, source) {
|
|
5
|
-
const config = loadConfig();
|
|
6
|
-
// Always post to feed
|
|
7
|
-
postFeedItem(source, title, content);
|
|
8
|
-
// Notify via Telegram if enabled
|
|
9
|
-
if (config.backgroundNotifyTelegram && config.telegramEnabled) {
|
|
10
|
-
try {
|
|
11
|
-
const { getBot } = await import("./telegram/bot.js");
|
|
12
|
-
const bot = getBot();
|
|
13
|
-
if (bot && config.authorizedUserId) {
|
|
14
|
-
const msg = `📬 *${title}*\n\n${content.slice(0, 1000)}`;
|
|
15
|
-
await bot.api.sendMessage(config.authorizedUserId, msg, {
|
|
16
|
-
parse_mode: "Markdown",
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
catch (err) {
|
|
21
|
-
logWarn("Telegram notification failed", { title, source }, err);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=notify.js.map
|
package/dist/paths.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { homedir } from "node:os";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
const IO_HOME = join(homedir(), ".io");
|
|
4
|
-
export const PATHS = {
|
|
5
|
-
home: IO_HOME,
|
|
6
|
-
config: join(IO_HOME, "config.json"),
|
|
7
|
-
db: join(IO_HOME, "io.db"),
|
|
8
|
-
wiki: join(IO_HOME, "wiki"),
|
|
9
|
-
wikiPages: join(IO_HOME, "wiki", "pages"),
|
|
10
|
-
wikiSquadTemplates: join(IO_HOME, "wiki", "templates", "squad"),
|
|
11
|
-
skills: join(IO_HOME, "skills"),
|
|
12
|
-
mcpConfig: join(IO_HOME, "mcp.json"),
|
|
13
|
-
sessions: join(IO_HOME, "sessions"),
|
|
14
|
-
source: join(IO_HOME, "source"),
|
|
15
|
-
attachments: join(IO_HOME, "attachments"),
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=paths.js.map
|
package/dist/setup.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { createInterface } from "node:readline";
|
|
2
|
-
import { loadConfig, saveConfig } from "./config.js";
|
|
3
|
-
import { PATHS } from "./paths.js";
|
|
4
|
-
import { mkdirSync, existsSync } from "node:fs";
|
|
5
|
-
export async function runSetup() {
|
|
6
|
-
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
7
|
-
const ask = (q) => new Promise((resolve) => rl.question(q, resolve));
|
|
8
|
-
console.log("\n🤖 IO Setup\n");
|
|
9
|
-
if (!existsSync(PATHS.home))
|
|
10
|
-
mkdirSync(PATHS.home, { recursive: true });
|
|
11
|
-
const config = loadConfig();
|
|
12
|
-
// Supabase (required for API auth)
|
|
13
|
-
console.log("— Supabase Auth (required for web/API access) —");
|
|
14
|
-
const supabaseUrl = await ask(`Supabase URL [${config.supabaseUrl ?? ""}]: `);
|
|
15
|
-
const supabaseAnonKey = await ask(`Supabase Anon Key [${config.supabaseAnonKey ? "****" : ""}]: `);
|
|
16
|
-
const authorizedEmail = await ask(`Authorized Email [${config.authorizedEmail ?? ""}]: `);
|
|
17
|
-
// Telegram (optional)
|
|
18
|
-
console.log("\n— Telegram Bot (optional) —");
|
|
19
|
-
const telegramBotToken = await ask(`Bot Token [${config.telegramBotToken ? "****" : ""}]: `);
|
|
20
|
-
const authorizedUserId = await ask(`Your Telegram User ID [${config.authorizedUserId ?? ""}]: `);
|
|
21
|
-
const telegramEnabled = await ask(`Enable Telegram? (y/n) [${config.telegramEnabled ? "y" : "n"}]: `);
|
|
22
|
-
saveConfig({
|
|
23
|
-
supabaseUrl: supabaseUrl || config.supabaseUrl,
|
|
24
|
-
supabaseAnonKey: supabaseAnonKey || config.supabaseAnonKey,
|
|
25
|
-
authorizedEmail: authorizedEmail || config.authorizedEmail,
|
|
26
|
-
telegramBotToken: telegramBotToken || config.telegramBotToken,
|
|
27
|
-
authorizedUserId: authorizedUserId
|
|
28
|
-
? parseInt(authorizedUserId, 10)
|
|
29
|
-
: config.authorizedUserId,
|
|
30
|
-
telegramEnabled: telegramEnabled === "y" ? true : telegramEnabled === "n" ? false : config.telegramEnabled,
|
|
31
|
-
});
|
|
32
|
-
console.log(`\n✅ Configuration saved to ${PATHS.config}\n`);
|
|
33
|
-
rl.close();
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=setup.js.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { getDb } from "./db.js";
|
|
3
|
-
export function addAgentEvent(taskId, type, summary, payload) {
|
|
4
|
-
const db = getDb();
|
|
5
|
-
const id = randomUUID();
|
|
6
|
-
db.prepare("INSERT INTO agent_events (id, task_id, type, summary, payload) VALUES (?, ?, ?, ?, ?)").run(id, taskId, type, summary, JSON.stringify(payload));
|
|
7
|
-
return db.prepare("SELECT * FROM agent_events WHERE id = ?").get(id);
|
|
8
|
-
}
|
|
9
|
-
export function getAgentEvents(taskId) {
|
|
10
|
-
const db = getDb();
|
|
11
|
-
return db
|
|
12
|
-
.prepare("SELECT * FROM agent_events WHERE task_id = ? ORDER BY created_at ASC")
|
|
13
|
-
.all(taskId);
|
|
14
|
-
}
|
|
15
|
-
export function clearAgentEvents(taskId) {
|
|
16
|
-
const db = getDb();
|
|
17
|
-
db.prepare("DELETE FROM agent_events WHERE task_id = ?").run(taskId);
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=agent-events.js.map
|
package/dist/store/audit-log.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { getDb } from "./db.js";
|
|
3
|
-
export function addAuditEntry(action_type, summary, payload, opts) {
|
|
4
|
-
const db = getDb();
|
|
5
|
-
const id = randomUUID();
|
|
6
|
-
db.prepare(`INSERT INTO audit_log (id, squad_id, agent_id, task_id, action_type, summary, payload)
|
|
7
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)`).run(id, opts?.squad_id ?? null, opts?.agent_id ?? null, opts?.task_id ?? null, action_type, summary, JSON.stringify(payload));
|
|
8
|
-
return db.prepare("SELECT * FROM audit_log WHERE id = ?").get(id);
|
|
9
|
-
}
|
|
10
|
-
export function getAuditLog(filters = {}) {
|
|
11
|
-
const db = getDb();
|
|
12
|
-
const conditions = [];
|
|
13
|
-
const params = [];
|
|
14
|
-
if (filters.squad_id) {
|
|
15
|
-
conditions.push("squad_id = ?");
|
|
16
|
-
params.push(filters.squad_id);
|
|
17
|
-
}
|
|
18
|
-
if (filters.agent_id) {
|
|
19
|
-
conditions.push("agent_id = ?");
|
|
20
|
-
params.push(filters.agent_id);
|
|
21
|
-
}
|
|
22
|
-
if (filters.action_type) {
|
|
23
|
-
conditions.push("action_type = ?");
|
|
24
|
-
params.push(filters.action_type);
|
|
25
|
-
}
|
|
26
|
-
if (filters.from) {
|
|
27
|
-
conditions.push("created_at >= ?");
|
|
28
|
-
params.push(filters.from);
|
|
29
|
-
}
|
|
30
|
-
if (filters.to) {
|
|
31
|
-
conditions.push("created_at <= ?");
|
|
32
|
-
params.push(filters.to);
|
|
33
|
-
}
|
|
34
|
-
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
35
|
-
const limit = filters.limit ?? 50;
|
|
36
|
-
const offset = filters.offset ?? 0;
|
|
37
|
-
return db
|
|
38
|
-
.prepare(`SELECT * FROM audit_log ${where} ORDER BY created_at DESC LIMIT ? OFFSET ?`)
|
|
39
|
-
.all(...params, limit, offset);
|
|
40
|
-
}
|
|
41
|
-
export function countAuditLog(filters = {}) {
|
|
42
|
-
const db = getDb();
|
|
43
|
-
const conditions = [];
|
|
44
|
-
const params = [];
|
|
45
|
-
if (filters.squad_id) {
|
|
46
|
-
conditions.push("squad_id = ?");
|
|
47
|
-
params.push(filters.squad_id);
|
|
48
|
-
}
|
|
49
|
-
if (filters.agent_id) {
|
|
50
|
-
conditions.push("agent_id = ?");
|
|
51
|
-
params.push(filters.agent_id);
|
|
52
|
-
}
|
|
53
|
-
if (filters.action_type) {
|
|
54
|
-
conditions.push("action_type = ?");
|
|
55
|
-
params.push(filters.action_type);
|
|
56
|
-
}
|
|
57
|
-
if (filters.from) {
|
|
58
|
-
conditions.push("created_at >= ?");
|
|
59
|
-
params.push(filters.from);
|
|
60
|
-
}
|
|
61
|
-
if (filters.to) {
|
|
62
|
-
conditions.push("created_at <= ?");
|
|
63
|
-
params.push(filters.to);
|
|
64
|
-
}
|
|
65
|
-
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
66
|
-
const row = db
|
|
67
|
-
.prepare(`SELECT COUNT(*) as count FROM audit_log ${where}`)
|
|
68
|
-
.get(...params);
|
|
69
|
-
return row.count;
|
|
70
|
-
}
|
|
71
|
-
//# sourceMappingURL=audit-log.js.map
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { getDb } from "./db.js";
|
|
3
|
-
import { logWarn } from "../logging.js";
|
|
4
|
-
function parseAttachments(value) {
|
|
5
|
-
if (!value)
|
|
6
|
-
return [];
|
|
7
|
-
try {
|
|
8
|
-
const parsed = JSON.parse(value);
|
|
9
|
-
return Array.isArray(parsed) ? parsed : [];
|
|
10
|
-
}
|
|
11
|
-
catch (err) {
|
|
12
|
-
logWarn("Failed to parse stored conversation attachments", { rawValue: value }, err);
|
|
13
|
-
return [];
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function toMessage(row) {
|
|
17
|
-
return {
|
|
18
|
-
id: row.id,
|
|
19
|
-
conversationId: row.conversation_id,
|
|
20
|
-
role: row.role,
|
|
21
|
-
content: row.content,
|
|
22
|
-
source: row.source,
|
|
23
|
-
attachments: parseAttachments(row.attachments),
|
|
24
|
-
createdAt: row.created_at,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function toSummary(row) {
|
|
28
|
-
return {
|
|
29
|
-
id: row.id,
|
|
30
|
-
preview: row.preview,
|
|
31
|
-
messageCount: row.message_count,
|
|
32
|
-
startedAt: row.started_at,
|
|
33
|
-
updatedAt: row.updated_at,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
export function saveMessage(conversationId, role, content, source, attachments = []) {
|
|
37
|
-
const db = getDb();
|
|
38
|
-
const id = randomUUID();
|
|
39
|
-
db.prepare("INSERT INTO conversation_messages (id, conversation_id, role, content, source, attachments) VALUES (?, ?, ?, ?, ?, ?)").run(id, conversationId, role, content, source, JSON.stringify(attachments));
|
|
40
|
-
const row = db
|
|
41
|
-
.prepare("SELECT * FROM conversation_messages WHERE id = ?")
|
|
42
|
-
.get(id);
|
|
43
|
-
return toMessage(row);
|
|
44
|
-
}
|
|
45
|
-
export function getConversation(conversationId) {
|
|
46
|
-
const db = getDb();
|
|
47
|
-
const rows = db
|
|
48
|
-
.prepare("SELECT * FROM conversation_messages WHERE conversation_id = ? ORDER BY created_at ASC")
|
|
49
|
-
.all(conversationId);
|
|
50
|
-
return rows.map(toMessage);
|
|
51
|
-
}
|
|
52
|
-
export function listConversations(opts = {}) {
|
|
53
|
-
const db = getDb();
|
|
54
|
-
const limit = opts.limit ?? 50;
|
|
55
|
-
const offset = opts.offset ?? 0;
|
|
56
|
-
let where = "WHERE 1=1";
|
|
57
|
-
const params = [];
|
|
58
|
-
if (opts.from) {
|
|
59
|
-
where += " AND started_at >= ?";
|
|
60
|
-
params.push(opts.from);
|
|
61
|
-
}
|
|
62
|
-
if (opts.to) {
|
|
63
|
-
where += " AND updated_at <= ?";
|
|
64
|
-
params.push(opts.to);
|
|
65
|
-
}
|
|
66
|
-
const countRow = db
|
|
67
|
-
.prepare(`SELECT COUNT(*) as cnt FROM (
|
|
68
|
-
SELECT conversation_id as id,
|
|
69
|
-
MIN(created_at) as started_at,
|
|
70
|
-
MAX(created_at) as updated_at
|
|
71
|
-
FROM conversation_messages
|
|
72
|
-
GROUP BY conversation_id
|
|
73
|
-
) ${where}`)
|
|
74
|
-
.get(...params);
|
|
75
|
-
const total = countRow.cnt;
|
|
76
|
-
const rows = db
|
|
77
|
-
.prepare(`SELECT
|
|
78
|
-
sub.id,
|
|
79
|
-
sub.started_at,
|
|
80
|
-
sub.updated_at,
|
|
81
|
-
sub.message_count,
|
|
82
|
-
first_msg.content as preview
|
|
83
|
-
FROM (
|
|
84
|
-
SELECT conversation_id as id,
|
|
85
|
-
MIN(created_at) as started_at,
|
|
86
|
-
MAX(created_at) as updated_at,
|
|
87
|
-
COUNT(*) as message_count
|
|
88
|
-
FROM conversation_messages
|
|
89
|
-
GROUP BY conversation_id
|
|
90
|
-
) sub
|
|
91
|
-
JOIN conversation_messages first_msg
|
|
92
|
-
ON first_msg.conversation_id = sub.id
|
|
93
|
-
AND first_msg.role = 'user'
|
|
94
|
-
AND first_msg.created_at = (
|
|
95
|
-
SELECT MIN(created_at) FROM conversation_messages
|
|
96
|
-
WHERE conversation_id = sub.id AND role = 'user'
|
|
97
|
-
)
|
|
98
|
-
${where}
|
|
99
|
-
ORDER BY sub.updated_at DESC
|
|
100
|
-
LIMIT ? OFFSET ?`)
|
|
101
|
-
.all(...params, limit, offset);
|
|
102
|
-
return { items: rows.map(toSummary), total };
|
|
103
|
-
}
|
|
104
|
-
export function searchConversations(query, opts = {}) {
|
|
105
|
-
const db = getDb();
|
|
106
|
-
const limit = opts.limit ?? 50;
|
|
107
|
-
const offset = opts.offset ?? 0;
|
|
108
|
-
let dateWhere = "";
|
|
109
|
-
const dateParams = [];
|
|
110
|
-
if (opts.from) {
|
|
111
|
-
dateWhere += " AND cm.created_at >= ?";
|
|
112
|
-
dateParams.push(opts.from);
|
|
113
|
-
}
|
|
114
|
-
if (opts.to) {
|
|
115
|
-
dateWhere += " AND cm.created_at <= ?";
|
|
116
|
-
dateParams.push(opts.to);
|
|
117
|
-
}
|
|
118
|
-
// Find distinct conversation IDs matching FTS query
|
|
119
|
-
const matchingIds = db
|
|
120
|
-
.prepare(`SELECT DISTINCT cm.conversation_id
|
|
121
|
-
FROM conversation_messages cm
|
|
122
|
-
JOIN conversation_messages_fts fts ON fts.rowid = cm.rowid
|
|
123
|
-
WHERE conversation_messages_fts MATCH ?${dateWhere}
|
|
124
|
-
LIMIT 500`)
|
|
125
|
-
.all(query, ...dateParams);
|
|
126
|
-
if (matchingIds.length === 0) {
|
|
127
|
-
return { items: [], total: 0 };
|
|
128
|
-
}
|
|
129
|
-
const idList = matchingIds.map((r) => r.conversation_id);
|
|
130
|
-
const placeholders = idList.map(() => "?").join(",");
|
|
131
|
-
const total = idList.length;
|
|
132
|
-
const rows = db
|
|
133
|
-
.prepare(`SELECT
|
|
134
|
-
sub.id,
|
|
135
|
-
sub.started_at,
|
|
136
|
-
sub.updated_at,
|
|
137
|
-
sub.message_count,
|
|
138
|
-
first_msg.content as preview
|
|
139
|
-
FROM (
|
|
140
|
-
SELECT conversation_id as id,
|
|
141
|
-
MIN(created_at) as started_at,
|
|
142
|
-
MAX(created_at) as updated_at,
|
|
143
|
-
COUNT(*) as message_count
|
|
144
|
-
FROM conversation_messages
|
|
145
|
-
WHERE conversation_id IN (${placeholders})
|
|
146
|
-
GROUP BY conversation_id
|
|
147
|
-
) sub
|
|
148
|
-
JOIN conversation_messages first_msg
|
|
149
|
-
ON first_msg.conversation_id = sub.id
|
|
150
|
-
AND first_msg.role = 'user'
|
|
151
|
-
AND first_msg.created_at = (
|
|
152
|
-
SELECT MIN(created_at) FROM conversation_messages
|
|
153
|
-
WHERE conversation_id = sub.id AND role = 'user'
|
|
154
|
-
)
|
|
155
|
-
ORDER BY sub.updated_at DESC
|
|
156
|
-
LIMIT ? OFFSET ?`)
|
|
157
|
-
.all(...idList, limit, offset);
|
|
158
|
-
return { items: rows.map(toSummary), total };
|
|
159
|
-
}
|
|
160
|
-
export function deleteConversation(conversationId) {
|
|
161
|
-
const db = getDb();
|
|
162
|
-
db.prepare("DELETE FROM conversation_messages WHERE conversation_id = ?").run(conversationId);
|
|
163
|
-
}
|
|
164
|
-
//# sourceMappingURL=conversations.js.map
|
package/dist/store/feed.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { getDb } from "./db.js";
|
|
3
|
-
export function postFeedItem(source, title, content) {
|
|
4
|
-
const db = getDb();
|
|
5
|
-
const id = randomUUID();
|
|
6
|
-
db.prepare("INSERT INTO feed_items (id, source, title, content) VALUES (?, ?, ?, ?)").run(id, source, title, content);
|
|
7
|
-
return db.prepare("SELECT * FROM feed_items WHERE id = ?").get(id);
|
|
8
|
-
}
|
|
9
|
-
export function getFeedItems(opts) {
|
|
10
|
-
const db = getDb();
|
|
11
|
-
let sql = "SELECT * FROM feed_items WHERE 1=1";
|
|
12
|
-
const params = [];
|
|
13
|
-
if (opts?.unreadOnly) {
|
|
14
|
-
sql += " AND read = 0";
|
|
15
|
-
}
|
|
16
|
-
if (opts?.source) {
|
|
17
|
-
sql += " AND source = ?";
|
|
18
|
-
params.push(opts.source);
|
|
19
|
-
}
|
|
20
|
-
sql += " ORDER BY created_at DESC";
|
|
21
|
-
if (opts?.limit) {
|
|
22
|
-
sql += " LIMIT ?";
|
|
23
|
-
params.push(opts.limit);
|
|
24
|
-
}
|
|
25
|
-
if (opts?.offset) {
|
|
26
|
-
sql += " OFFSET ?";
|
|
27
|
-
params.push(opts.offset);
|
|
28
|
-
}
|
|
29
|
-
return db.prepare(sql).all(...params);
|
|
30
|
-
}
|
|
31
|
-
export function markFeedItemRead(id) {
|
|
32
|
-
const db = getDb();
|
|
33
|
-
db.prepare("UPDATE feed_items SET read = 1 WHERE id = ?").run(id);
|
|
34
|
-
}
|
|
35
|
-
export function deleteFeedItem(id) {
|
|
36
|
-
const db = getDb();
|
|
37
|
-
db.prepare("DELETE FROM feed_items WHERE id = ?").run(id);
|
|
38
|
-
}
|
|
39
|
-
export function getUnreadCount() {
|
|
40
|
-
const db = getDb();
|
|
41
|
-
const row = db.prepare("SELECT COUNT(*) as count FROM feed_items WHERE read = 0").get();
|
|
42
|
-
return row.count;
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=feed.js.map
|
package/dist/store/instances.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { exec } from "node:child_process";
|
|
3
|
-
import { promisify } from "node:util";
|
|
4
|
-
import { getDb } from "./db.js";
|
|
5
|
-
import { logWarn } from "../logging.js";
|
|
6
|
-
const execAsync = promisify(exec);
|
|
7
|
-
const MAX_INSTANCES_PER_SQUAD = 3;
|
|
8
|
-
export function getInstance(instanceId) {
|
|
9
|
-
const db = getDb();
|
|
10
|
-
return db.prepare("SELECT * FROM instances WHERE id = ?").get(instanceId);
|
|
11
|
-
}
|
|
12
|
-
export async function createInstance(squadId, branch) {
|
|
13
|
-
const db = getDb();
|
|
14
|
-
// Check max instances
|
|
15
|
-
const active = db
|
|
16
|
-
.prepare("SELECT COUNT(*) as count FROM instances WHERE squad_id = ? AND status = 'active'")
|
|
17
|
-
.get(squadId);
|
|
18
|
-
if (active.count >= MAX_INSTANCES_PER_SQUAD) {
|
|
19
|
-
throw new Error(`Squad already has ${MAX_INSTANCES_PER_SQUAD} active instances. Destroy one first.`);
|
|
20
|
-
}
|
|
21
|
-
// Get squad repo to determine worktree location
|
|
22
|
-
const squad = db.prepare("SELECT * FROM squads WHERE id = ?").get(squadId);
|
|
23
|
-
if (!squad?.repo_url) {
|
|
24
|
-
throw new Error("Squad has no repo_url configured.");
|
|
25
|
-
}
|
|
26
|
-
const id = randomUUID();
|
|
27
|
-
const worktreePath = `/tmp/io-worktrees/${squadId}/${branch}`;
|
|
28
|
-
// Create git worktree
|
|
29
|
-
const repoCwd = squad.repo_url.startsWith("/") ? squad.repo_url : process.cwd();
|
|
30
|
-
try {
|
|
31
|
-
await execAsync(`git worktree add ${worktreePath} -b ${branch}`, { cwd: repoCwd });
|
|
32
|
-
}
|
|
33
|
-
catch (err) {
|
|
34
|
-
logWarn("Failed to create new git worktree branch, retrying existing branch", { squadId, branch, worktreePath }, err);
|
|
35
|
-
// Branch may already exist
|
|
36
|
-
await execAsync(`git worktree add ${worktreePath} ${branch}`, { cwd: repoCwd });
|
|
37
|
-
}
|
|
38
|
-
db.prepare(`INSERT INTO instances (id, squad_id, branch, worktree_path, status)
|
|
39
|
-
VALUES (?, ?, ?, ?, 'active')`).run(id, squadId, branch, worktreePath);
|
|
40
|
-
return db.prepare("SELECT * FROM instances WHERE id = ?").get(id);
|
|
41
|
-
}
|
|
42
|
-
export async function destroyInstance(instanceId) {
|
|
43
|
-
const db = getDb();
|
|
44
|
-
const instance = db
|
|
45
|
-
.prepare("SELECT * FROM instances WHERE id = ?")
|
|
46
|
-
.get(instanceId);
|
|
47
|
-
if (!instance)
|
|
48
|
-
throw new Error(`Instance ${instanceId} not found.`);
|
|
49
|
-
// Remove worktree
|
|
50
|
-
try {
|
|
51
|
-
await execAsync(`git worktree remove ${instance.worktree_path} --force`);
|
|
52
|
-
}
|
|
53
|
-
catch (err) {
|
|
54
|
-
logWarn("Failed to remove git worktree, it may already be gone", { instanceId: instance.id, worktreePath: instance.worktree_path }, err);
|
|
55
|
-
}
|
|
56
|
-
db.prepare("UPDATE instances SET status = 'destroyed' WHERE id = ?").run(instanceId);
|
|
57
|
-
}
|
|
58
|
-
export function getInstancesForSquad(squadId) {
|
|
59
|
-
const db = getDb();
|
|
60
|
-
return db
|
|
61
|
-
.prepare("SELECT * FROM instances WHERE squad_id = ? AND status = 'active' ORDER BY created_at")
|
|
62
|
-
.all(squadId);
|
|
63
|
-
}
|
|
64
|
-
export function touchInstanceActivity(instanceId) {
|
|
65
|
-
const db = getDb();
|
|
66
|
-
db.prepare("UPDATE instances SET last_activity = datetime('now') WHERE id = ?").run(instanceId);
|
|
67
|
-
}
|
|
68
|
-
export function getStaleInstances(minutesThreshold = 30) {
|
|
69
|
-
const db = getDb();
|
|
70
|
-
return db
|
|
71
|
-
.prepare(`SELECT * FROM instances WHERE status = 'active'
|
|
72
|
-
AND datetime(last_activity, '+${minutesThreshold} minutes') < datetime('now')`)
|
|
73
|
-
.all();
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=instances.js.map
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// Palette complementary to the site's brand gradient (magenta #E43A9C → violet #F041FF)
|
|
2
|
-
// Avoiding direct brand colors; using analogous/complementary hues that look cohesive
|
|
3
|
-
export const SQUAD_COLOR_PALETTE = [
|
|
4
|
-
"#06b6d4", // cyan (complementary to magenta)
|
|
5
|
-
"#14b8a6", // teal
|
|
6
|
-
"#f59e0b", // amber (warm contrast)
|
|
7
|
-
"#8b5cf6", // violet (analogous)
|
|
8
|
-
"#3b82f6", // blue
|
|
9
|
-
"#10b981", // emerald
|
|
10
|
-
"#f43f5e", // rose (analogous warm)
|
|
11
|
-
"#6366f1", // indigo
|
|
12
|
-
];
|
|
13
|
-
const DEFAULT_SQUAD_COLOR = "#3b82f6";
|
|
14
|
-
export function pickSquadColor(usedColors, random = Math.random) {
|
|
15
|
-
const used = new Set(usedColors.filter(Boolean).map((c) => c.toLowerCase()));
|
|
16
|
-
const available = SQUAD_COLOR_PALETTE.filter((c) => !used.has(c.toLowerCase()));
|
|
17
|
-
const source = available.length > 0 ? available : SQUAD_COLOR_PALETTE;
|
|
18
|
-
if (source.length === 0)
|
|
19
|
-
return DEFAULT_SQUAD_COLOR;
|
|
20
|
-
const index = Math.floor(random() * source.length);
|
|
21
|
-
return source[index] ?? DEFAULT_SQUAD_COLOR;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=squad-colors.js.map
|
package/dist/store/squads.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { getDb } from "./db.js";
|
|
3
|
-
import { pickSquadColor } from "./squad-colors.js";
|
|
4
|
-
export function createSquad(name, universe, repoUrl) {
|
|
5
|
-
const db = getDb();
|
|
6
|
-
const id = randomUUID();
|
|
7
|
-
const slug = name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
8
|
-
const usedColors = db
|
|
9
|
-
.prepare("SELECT color FROM squads WHERE color IS NOT NULL")
|
|
10
|
-
.all();
|
|
11
|
-
const color = pickSquadColor(usedColors.map((row) => row.color));
|
|
12
|
-
db.prepare("INSERT INTO squads (id, name, slug, universe, color, repo_url) VALUES (?, ?, ?, ?, ?, ?)").run(id, name, slug, universe, color, repoUrl ?? null);
|
|
13
|
-
return db.prepare("SELECT * FROM squads WHERE id = ?").get(id);
|
|
14
|
-
}
|
|
15
|
-
export function getSquad(id) {
|
|
16
|
-
const db = getDb();
|
|
17
|
-
return db.prepare("SELECT * FROM squads WHERE id = ?").get(id);
|
|
18
|
-
}
|
|
19
|
-
export function listSquads() {
|
|
20
|
-
const db = getDb();
|
|
21
|
-
const squads = db.prepare("SELECT * FROM squads ORDER BY created_at DESC").all();
|
|
22
|
-
const agents = db.prepare("SELECT * FROM agents ORDER BY created_at").all();
|
|
23
|
-
return { squads, agents };
|
|
24
|
-
}
|
|
25
|
-
export function deleteSquad(id) {
|
|
26
|
-
const db = getDb();
|
|
27
|
-
db.prepare("DELETE FROM squads WHERE id = ?").run(id);
|
|
28
|
-
}
|
|
29
|
-
export function updateSquadRules(id, rules) {
|
|
30
|
-
const db = getDb();
|
|
31
|
-
db.prepare("UPDATE squads SET rules = ?, updated_at = datetime('now') WHERE id = ?").run(rules, id);
|
|
32
|
-
}
|
|
33
|
-
export function addAgent(squadId, input) {
|
|
34
|
-
const db = getDb();
|
|
35
|
-
const id = randomUUID();
|
|
36
|
-
db.prepare(`INSERT INTO agents (id, squad_id, character_name, role_title, persona, is_lead, is_qa, is_test)
|
|
37
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`).run(id, squadId, input.character_name, input.role_title, input.persona, input.is_lead ? 1 : 0, input.is_qa ? 1 : 0, input.is_test ? 1 : 0);
|
|
38
|
-
return db.prepare("SELECT * FROM agents WHERE id = ?").get(id);
|
|
39
|
-
}
|
|
40
|
-
export function getAgentsForSquad(squadId) {
|
|
41
|
-
const db = getDb();
|
|
42
|
-
return db
|
|
43
|
-
.prepare("SELECT * FROM agents WHERE squad_id = ? ORDER BY created_at")
|
|
44
|
-
.all(squadId);
|
|
45
|
-
}
|
|
46
|
-
export function getLeadForSquad(squadId) {
|
|
47
|
-
const db = getDb();
|
|
48
|
-
return db
|
|
49
|
-
.prepare("SELECT * FROM agents WHERE squad_id = ? AND is_lead = 1 LIMIT 1")
|
|
50
|
-
.get(squadId);
|
|
51
|
-
}
|
|
52
|
-
export function updateAgentStatus(agentId, status) {
|
|
53
|
-
const db = getDb();
|
|
54
|
-
db.prepare("UPDATE agents SET status = ? WHERE id = ?").run(status, agentId);
|
|
55
|
-
}
|
|
56
|
-
export function removeAgent(agentId) {
|
|
57
|
-
const db = getDb();
|
|
58
|
-
db.prepare("DELETE FROM agents WHERE id = ?").run(agentId);
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=squads.js.map
|
package/dist/store/tasks.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { getDb } from "./db.js";
|
|
3
|
-
export function createTask(squadId, description, instanceId, agentId) {
|
|
4
|
-
const db = getDb();
|
|
5
|
-
const id = randomUUID();
|
|
6
|
-
db.prepare(`INSERT INTO tasks (id, squad_id, instance_id, agent_id, description, status)
|
|
7
|
-
VALUES (?, ?, ?, ?, ?, 'pending')`).run(id, squadId, instanceId ?? null, agentId ?? null, description);
|
|
8
|
-
return db.prepare("SELECT * FROM tasks WHERE id = ?").get(id);
|
|
9
|
-
}
|
|
10
|
-
export function getTasksForSquad(squadId) {
|
|
11
|
-
const db = getDb();
|
|
12
|
-
return db
|
|
13
|
-
.prepare("SELECT * FROM tasks WHERE squad_id = ? ORDER BY created_at DESC")
|
|
14
|
-
.all(squadId);
|
|
15
|
-
}
|
|
16
|
-
export function updateTaskStatus(taskId, status, result) {
|
|
17
|
-
const db = getDb();
|
|
18
|
-
if (result !== undefined) {
|
|
19
|
-
db.prepare("UPDATE tasks SET status = ?, result = ?, updated_at = datetime('now') WHERE id = ?").run(status, result, taskId);
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
db.prepare("UPDATE tasks SET status = ?, updated_at = datetime('now') WHERE id = ?").run(status, taskId);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
export function getTask(taskId) {
|
|
26
|
-
const db = getDb();
|
|
27
|
-
return db.prepare("SELECT * FROM tasks WHERE id = ?").get(taskId);
|
|
28
|
-
}
|
|
29
|
-
export function getActiveTasksForInstance(instanceId) {
|
|
30
|
-
const db = getDb();
|
|
31
|
-
return db
|
|
32
|
-
.prepare("SELECT * FROM tasks WHERE instance_id = ? AND status NOT IN ('done', 'failed') ORDER BY created_at")
|
|
33
|
-
.all(instanceId);
|
|
34
|
-
}
|
|
35
|
-
/** Squads with active tasks and no update within this window are flagged as stalled. */
|
|
36
|
-
const STALL_THRESHOLD_MS = 60 * 60 * 1000; // 60 minutes
|
|
37
|
-
export function getSquadTaskMetrics(squadId) {
|
|
38
|
-
const db = getDb();
|
|
39
|
-
const row = db
|
|
40
|
-
.prepare(`SELECT
|
|
41
|
-
COUNT(*) AS total,
|
|
42
|
-
SUM(CASE WHEN status = 'done' THEN 1 ELSE 0 END) AS completed,
|
|
43
|
-
SUM(CASE WHEN status = 'done' AND updated_at >= datetime('now', '-7 days') THEN 1 ELSE 0 END) AS completed_recent,
|
|
44
|
-
SUM(CASE WHEN status = 'pending' THEN 1 ELSE 0 END) AS pending,
|
|
45
|
-
SUM(CASE WHEN status = 'in_progress' THEN 1 ELSE 0 END) AS in_progress,
|
|
46
|
-
SUM(CASE WHEN status = 'failed' THEN 1 ELSE 0 END) AS failed,
|
|
47
|
-
AVG(CASE WHEN status = 'done'
|
|
48
|
-
THEN (julianday(updated_at) - julianday(created_at)) * 1440
|
|
49
|
-
ELSE NULL END) AS avg_cycle_minutes,
|
|
50
|
-
MAX(CASE WHEN status IN ('pending', 'in_progress') THEN updated_at ELSE NULL END) AS last_active_update
|
|
51
|
-
FROM tasks WHERE squad_id = ?`)
|
|
52
|
-
.get(squadId);
|
|
53
|
-
// A squad is considered stalled if it has active tasks but none have been
|
|
54
|
-
// updated within STALL_THRESHOLD_MS.
|
|
55
|
-
const hasActiveTasks = row.pending + row.in_progress > 0;
|
|
56
|
-
const isStalled = hasActiveTasks &&
|
|
57
|
-
row.last_active_update !== null &&
|
|
58
|
-
new Date(row.last_active_update + "Z").getTime() <
|
|
59
|
-
Date.now() - STALL_THRESHOLD_MS;
|
|
60
|
-
const recentTasks = db
|
|
61
|
-
.prepare("SELECT * FROM tasks WHERE squad_id = ? ORDER BY updated_at DESC LIMIT 5")
|
|
62
|
-
.all(squadId);
|
|
63
|
-
return {
|
|
64
|
-
squadId,
|
|
65
|
-
tasksTotal: row.total ?? 0,
|
|
66
|
-
tasksCompleted: row.completed ?? 0,
|
|
67
|
-
tasksCompletedRecent: row.completed_recent ?? 0,
|
|
68
|
-
tasksPending: row.pending ?? 0,
|
|
69
|
-
tasksInProgress: row.in_progress ?? 0,
|
|
70
|
-
tasksFailed: row.failed ?? 0,
|
|
71
|
-
avgCycleTimeMinutes: row.avg_cycle_minutes != null
|
|
72
|
-
? Math.round(row.avg_cycle_minutes * 10) / 10
|
|
73
|
-
: null,
|
|
74
|
-
isStalled,
|
|
75
|
-
recentTasks,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=tasks.js.map
|