profclaw 0.0.1-beta.1 → 0.0.1-beta.2
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/README.md +1 -1
- package/dist/adapters/openclaw.js +1 -1
- package/dist/agents/executor.js +38 -6
- package/dist/auth/auth-service.js +8 -6
- package/dist/auth/device-identity.js +7 -5
- package/dist/auth/github-oauth.js +3 -1
- package/dist/auth/pairing-codes.js +6 -4
- package/dist/browser/service.js +5 -3
- package/dist/chat/execution/guardrails.js +3 -1
- package/dist/chat/execution/workflows/executor.js +4 -2
- package/dist/chat/memory.js +3 -1
- package/dist/chat/proactive/index.js +13 -11
- package/dist/chat/tools.js +8 -7
- package/dist/cli/commands/auth.js +22 -13
- package/dist/cli/commands/onboard.js +248 -59
- package/dist/cli/commands/setup.js +180 -104
- package/dist/cron/issue-poller.js +1 -1
- package/dist/hooks/agent-webhook.js +10 -7
- package/dist/hooks/prompt-submit.js +5 -6
- package/dist/hooks/session-end.js +10 -6
- package/dist/hooks/tool-use.js +9 -6
- package/dist/integrations/github-ticket-sync.js +8 -6
- package/dist/integrations/github.js +8 -6
- package/dist/integrations/jira.js +5 -3
- package/dist/mcp/server.js +12 -9
- package/dist/memory/experience-store.js +15 -14
- package/dist/notifications/slack.js +4 -2
- package/dist/providers/types.d.ts +2 -2
- package/dist/queue/failure-handler.js +15 -13
- package/dist/queue/index.js +6 -4
- package/dist/queue/memory-queue.js +23 -27
- package/dist/queue/task-queue.js +18 -22
- package/dist/routes/agents.js +3 -1
- package/dist/routes/auth.js +11 -9
- package/dist/routes/devices.js +17 -15
- package/dist/routes/gateway.js +3 -1
- package/dist/routes/hooks.js +7 -5
- package/dist/routes/import.js +10 -8
- package/dist/routes/labels.js +11 -9
- package/dist/routes/oobe.js +8 -6
- package/dist/routes/openapi.js +1 -1
- package/dist/routes/projects.js +27 -25
- package/dist/routes/settings.js +7 -5
- package/dist/routes/setup.js +12 -11
- package/dist/routes/slack.js +28 -27
- package/dist/routes/stats.js +6 -4
- package/dist/routes/summaries.js +4 -3
- package/dist/routes/sync.js +7 -5
- package/dist/routes/tasks.js +10 -8
- package/dist/routes/tickets.js +26 -26
- package/dist/routes/tokens.js +5 -3
- package/dist/routes/users.js +14 -12
- package/dist/routes/webhooks.js +5 -3
- package/dist/settings/index.js +3 -1
- package/dist/storage/index.d.ts +2 -1
- package/dist/storage/index.js +9 -4
- package/dist/storage/libsql.js +29 -21
- package/dist/storage/schema.d.ts +107 -46
- package/dist/summaries/storage.js +3 -1
- package/dist/tickets/index.js +10 -8
- package/dist/utils/circuit-breaker.js +10 -5
- package/dist/utils/logger.d.ts +5 -1
- package/dist/utils/logger.js +23 -7
- package/package.json +4 -3
- package/ui/dist/assets/{ActivityView-CkPgKhwm.js → ActivityView-DIPQSJ_d.js} +1 -1
- package/ui/dist/assets/{AgentList-C3SVdeEz.js → AgentList-CqyaYrcq.js} +1 -1
- package/ui/dist/assets/{AnalyticsDashboard-DVU--vlP.js → AnalyticsDashboard-C-mjuGHT.js} +1 -1
- package/ui/dist/assets/{AreaChart-B5qMEGWj.js → AreaChart-CfYWmbtr.js} +1 -1
- package/ui/dist/assets/{CartesianChart-B50bcUJi.js → CartesianChart-BaQ3It0c.js} +1 -1
- package/ui/dist/assets/{ChatView-BZFJs7w_.js → ChatView-DxxQy6pl.js} +1 -1
- package/ui/dist/assets/CostsDashboard-CDBBcGkg.js +1 -0
- package/ui/dist/assets/{EstimateSelect-CLpB4NQO.js → EstimateSelect-CDjf5qKl.js} +1 -1
- package/ui/dist/assets/{FloatingChatbot-CBzBY9a0.js → FloatingChatbot-CZHjvJIe.js} +1 -1
- package/ui/dist/assets/{InviteCodeManagement-DsbdPa6W.js → InviteCodeManagement-DTm-IPTm.js} +1 -1
- package/ui/dist/assets/{ProjectDetail-BEM3tFXg.js → ProjectDetail-DlYUcOss.js} +1 -1
- package/ui/dist/assets/{ProjectIcon-CN1FmFAk.js → ProjectIcon-BMRpnM04.js} +1 -1
- package/ui/dist/assets/{ProjectList-DSDaNhxQ.js → ProjectList-D85TN0i0.js} +1 -1
- package/ui/dist/assets/{Settings-dPVcqC_d.js → Settings-CgPqzUvj.js} +3 -3
- package/ui/dist/assets/{StatusIndicator-DA3NAo_b.js → StatusIndicator-yig0uZEA.js} +1 -1
- package/ui/dist/assets/{SummaryDetail-Bjnf9lT8.js → SummaryDetail-CwLAfHgJ.js} +1 -1
- package/ui/dist/assets/{SummaryList-ENwKDBKW.js → SummaryList-BvS5Idnu.js} +1 -1
- package/ui/dist/assets/{TaskDetail-DnwG6MzB.js → TaskDetail-zarC1fOt.js} +1 -1
- package/ui/dist/assets/{TaskList-D9Ug_HiV.js → TaskList-CyJq3ANE.js} +1 -1
- package/ui/dist/assets/{TicketBoard-CviH1571.js → TicketBoard-BlWr3-iH.js} +1 -1
- package/ui/dist/assets/{TicketDetail-8Jk8O-33.js → TicketDetail-DmqWKj2W.js} +1 -1
- package/ui/dist/assets/{TicketList-B-iV4rRA.js → TicketList-Scj4pMWa.js} +1 -1
- package/ui/dist/assets/{UserManagement-CPZ8s7s2.js → UserManagement-BH7uG7dw.js} +1 -1
- package/ui/dist/assets/{ViewSwitcher-BUyOOWDI.js → ViewSwitcher-3HzZUdWn.js} +1 -1
- package/ui/dist/assets/{alert-dialog-BOmnTkN-.js → alert-dialog-DWPb2IfQ.js} +1 -1
- package/ui/dist/assets/{archive-D5my9zOG.js → archive-CGck7gxR.js} +1 -1
- package/ui/dist/assets/{badge-B4ov81_m.js → badge-DEmc3Z_l.js} +1 -1
- package/ui/dist/assets/{brain-C53ElFLD.js → brain-CfFdLVqb.js} +1 -1
- package/ui/dist/assets/{bug-D0TJoCYn.js → bug-DqSGPUUE.js} +1 -1
- package/ui/dist/assets/{calendar-BkWIhKa1.js → calendar-BuZ4zbPW.js} +1 -1
- package/ui/dist/assets/{chevron-up-BRTtndUZ.js → chevron-up-DcJ4LL_N.js} +1 -1
- package/ui/dist/assets/{circle-x-BN89YhbS.js → circle-x-C78PNZjF.js} +1 -1
- package/ui/dist/assets/{constants-fc7TFI7u.js → constants-DhDjZe4P.js} +1 -1
- package/ui/dist/assets/{cpu-B41x1-vV.js → cpu-Ck6AoG8c.js} +1 -1
- package/ui/dist/assets/{database-D9Cnfmzj.js → database-CA2w8Lvt.js} +1 -1
- package/ui/dist/assets/{dialog-DrWB4EYD.js → dialog-BOdGWhgE.js} +1 -1
- package/ui/dist/assets/{ellipsis-NuUWekvu.js → ellipsis-FhHKRbfl.js} +1 -1
- package/ui/dist/assets/{ellipsis-vertical-BueMfuCw.js → ellipsis-vertical-CO0UqE4-.js} +1 -1
- package/ui/dist/assets/{file-code-HR9829Jc.js → file-code-ChnhYYj1.js} +1 -1
- package/ui/dist/assets/{folder-open-C_7oYEqe.js → folder-open-CHwA1-ve.js} +1 -1
- package/ui/dist/assets/{funnel-B5gmNXGf.js → funnel-ByEjRFNB.js} +1 -1
- package/ui/dist/assets/{git-branch-BRMiJmV3.js → git-branch-GTOPQgU4.js} +1 -1
- package/ui/dist/assets/{git-commit-horizontal-CXOUQeJI.js → git-commit-horizontal-F5M84Kut.js} +1 -1
- package/ui/dist/assets/{globe-CCspjvus.js → globe-CQWfr7hT.js} +1 -1
- package/ui/dist/assets/{hash-g3102kPC.js → hash-nKC9gtLg.js} +1 -1
- package/ui/dist/assets/{history-CNqcBBrV.js → history-DfFSA9xJ.js} +1 -1
- package/ui/dist/assets/{index-kb4AJXUB.js → index--JkIxVXb.js} +3 -3
- package/ui/dist/assets/index-Ca3vk7Gq.js +1 -0
- package/ui/dist/assets/{index-C9jNQXzL.js → index-DHGvP9mp.js} +1 -1
- package/ui/dist/assets/index-DeI8lKRR.js +1 -0
- package/ui/dist/assets/{index-DURTouJI.js → index-Z4-RtZcs.js} +1 -1
- package/ui/dist/assets/{index-CEZ6R2Uw.js → index-a4Fxq0Hb.js} +1 -1
- package/ui/dist/assets/{layers-CLXiHN6o.js → layers-DFeLExSa.js} +1 -1
- package/ui/dist/assets/{layout-dashboard-B07MFhBs.js → layout-dashboard-WmgjMhWF.js} +1 -1
- package/ui/dist/assets/{lightbulb-B2dgG5ks.js → lightbulb-Bo8hEr7B.js} +1 -1
- package/ui/dist/assets/{link-2-BxNmr9hL.js → link-2-YqrpQXBH.js} +1 -1
- package/ui/dist/assets/{markdown-renderer-CjU6hBcW.js → markdown-renderer-Croje6Xe.js} +1 -1
- package/ui/dist/assets/{message-square-Bf2-CVbt.js → message-square-CD0H5hot.js} +1 -1
- package/ui/dist/assets/{pencil-D096Ey62.js → pencil-DpFnj5dn.js} +1 -1
- package/ui/dist/assets/{play-DfdcSI3x.js → play-DVgea_jT.js} +1 -1
- package/ui/dist/assets/{popover-BV0QJDQq.js → popover-JXecfWG5.js} +1 -1
- package/ui/dist/assets/{progress-DjPEDJfI.js → progress-C1ghf1Fu.js} +1 -1
- package/ui/dist/assets/{rocket-CPsTc-5G.js → rocket-BFxPYGx9.js} +1 -1
- package/ui/dist/assets/{select-LsO16slr.js → select-MADP8m6Q.js} +1 -1
- package/ui/dist/assets/{send-BDYBZDUZ.js → send-eYnW_7n-.js} +1 -1
- package/ui/dist/assets/{server-B3k6noce.js → server-CPMaysH8.js} +1 -1
- package/ui/dist/assets/{settings-2-Cu4xTjhG.js → settings-2-scXUOuE_.js} +1 -1
- package/ui/dist/assets/{sheet-BScLnPKX.js → sheet-r6NSOxi-.js} +1 -1
- package/ui/dist/assets/{shield-check-CQqkwufI.js → shield-check-PEr7nmVw.js} +1 -1
- package/ui/dist/assets/{shield-off-ZFruH9KO.js → shield-off-CLtXio62.js} +1 -1
- package/ui/dist/assets/{skeleton-CtkIA_MU.js → skeleton-C9oEzNlU.js} +1 -1
- package/ui/dist/assets/{smartphone-DnoksVkc.js → smartphone-DusFfY0U.js} +1 -1
- package/ui/dist/assets/{square-uD9ZHMfW.js → square-e1yxB2eR.js} +1 -1
- package/ui/dist/assets/{switch-MQPnwGJK.js → switch-tNs0n-kz.js} +1 -1
- package/ui/dist/assets/{table-B8cqlywA.js → table-CXxtLicg.js} +1 -1
- package/ui/dist/assets/{tag-wEJQRWlV.js → tag-tAwMmQ9G.js} +1 -1
- package/ui/dist/assets/{textarea-D5LJCOGl.js → textarea-BjiEeIWh.js} +1 -1
- package/ui/dist/assets/{timer-mbGHegmr.js → timer-Vel1N3RP.js} +1 -1
- package/ui/dist/assets/{tooltip-Df1CunSp.js → tooltip-ZMwtfr1J.js} +1 -1
- package/ui/dist/assets/{trash-2-B4oAXsX-.js → trash-2-eM-CNwsZ.js} +1 -1
- package/ui/dist/assets/{trending-up-BGWxvlmZ.js → trending-up-BGafmjRo.js} +1 -1
- package/ui/dist/assets/{wand-sparkles-CZy4xvL3.js → wand-sparkles-DPvcd9Pi.js} +1 -1
- package/ui/dist/assets/{wrench-ByZkjO6m.js → wrench-B8s3zYVV.js} +1 -1
- package/ui/dist/index.html +1 -1
- package/ui/dist/assets/CostsDashboard-ChfH8BlG.js +0 -1
- package/ui/dist/assets/index-27mTPKuh.js +0 -1
- package/ui/dist/assets/index-BMx3fH-e.js +0 -1
package/dist/routes/users.js
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* Handles user profile and preferences management.
|
|
5
5
|
*/
|
|
6
6
|
import { Hono } from 'hono';
|
|
7
|
+
import { createContextualLogger } from '../utils/logger.js';
|
|
8
|
+
const log = createContextualLogger('Users');
|
|
7
9
|
import { getCookie } from 'hono/cookie';
|
|
8
10
|
import { eq } from 'drizzle-orm';
|
|
9
11
|
import { randomUUID, randomBytes, createHash } from 'crypto';
|
|
@@ -642,7 +644,7 @@ userRoutes.post('/me/recovery-codes/regenerate', async (c) => {
|
|
|
642
644
|
});
|
|
643
645
|
}
|
|
644
646
|
catch (error) {
|
|
645
|
-
|
|
647
|
+
log.error('Recovery code regeneration error', error instanceof Error ? error : new Error(String(error)));
|
|
646
648
|
return c.json({ error: 'Failed to regenerate recovery codes' }, 500);
|
|
647
649
|
}
|
|
648
650
|
});
|
|
@@ -672,7 +674,7 @@ userRoutes.get('/me/recovery-codes/count', async (c) => {
|
|
|
672
674
|
});
|
|
673
675
|
}
|
|
674
676
|
catch (error) {
|
|
675
|
-
|
|
677
|
+
log.error('Recovery code count error', error instanceof Error ? error : new Error(String(error)));
|
|
676
678
|
return c.json({ error: 'Failed to get recovery code count' }, 500);
|
|
677
679
|
}
|
|
678
680
|
});
|
|
@@ -713,7 +715,7 @@ userRoutes.get('/admin/list', requireAdmin, async (c) => {
|
|
|
713
715
|
return c.json({ users: allUsers, total: allUsers.length });
|
|
714
716
|
}
|
|
715
717
|
catch (error) {
|
|
716
|
-
|
|
718
|
+
log.error('List users error', error instanceof Error ? error : new Error(String(error)));
|
|
717
719
|
return c.json({ error: 'Failed to list users' }, 500);
|
|
718
720
|
}
|
|
719
721
|
});
|
|
@@ -756,7 +758,7 @@ userRoutes.post('/admin/invites', requireAdmin, async (c) => {
|
|
|
756
758
|
});
|
|
757
759
|
}
|
|
758
760
|
catch (err) {
|
|
759
|
-
|
|
761
|
+
log.error('Generate invites error', err instanceof Error ? err : new Error(String(err)));
|
|
760
762
|
return c.json({ error: 'Failed to generate invite codes' }, 500);
|
|
761
763
|
}
|
|
762
764
|
});
|
|
@@ -784,7 +786,7 @@ userRoutes.get('/admin/invites', requireAdmin, async (c) => {
|
|
|
784
786
|
return c.json({ invites: allInvites, total: allInvites.length });
|
|
785
787
|
}
|
|
786
788
|
catch (err) {
|
|
787
|
-
|
|
789
|
+
log.error('List invites error', err instanceof Error ? err : new Error(String(err)));
|
|
788
790
|
return c.json({ error: 'Failed to list invite codes' }, 500);
|
|
789
791
|
}
|
|
790
792
|
});
|
|
@@ -810,7 +812,7 @@ userRoutes.delete('/admin/invites/:id', requireAdmin, async (c) => {
|
|
|
810
812
|
return c.json({ message: 'Invite code deleted' });
|
|
811
813
|
}
|
|
812
814
|
catch (err) {
|
|
813
|
-
|
|
815
|
+
log.error('Delete invite error', err instanceof Error ? err : new Error(String(err)));
|
|
814
816
|
return c.json({ error: 'Failed to delete invite code' }, 500);
|
|
815
817
|
}
|
|
816
818
|
});
|
|
@@ -825,7 +827,7 @@ userRoutes.get('/admin/registration-mode', requireAdmin, async (c) => {
|
|
|
825
827
|
return c.json({ mode: settings.system.registrationMode });
|
|
826
828
|
}
|
|
827
829
|
catch (err) {
|
|
828
|
-
|
|
830
|
+
log.error('Get registration mode error', err instanceof Error ? err : new Error(String(err)));
|
|
829
831
|
return c.json({ error: 'Failed to get registration mode' }, 500);
|
|
830
832
|
}
|
|
831
833
|
});
|
|
@@ -846,7 +848,7 @@ userRoutes.patch('/admin/registration-mode', requireAdmin, async (c) => {
|
|
|
846
848
|
return c.json({ mode, message: `Registration mode set to ${mode}` });
|
|
847
849
|
}
|
|
848
850
|
catch (err) {
|
|
849
|
-
|
|
851
|
+
log.error('Set registration mode error', err instanceof Error ? err : new Error(String(err)));
|
|
850
852
|
return c.json({ error: 'Failed to set registration mode' }, 500);
|
|
851
853
|
}
|
|
852
854
|
});
|
|
@@ -887,7 +889,7 @@ userRoutes.get('/admin/:userId', requireAdmin, async (c) => {
|
|
|
887
889
|
return c.json({ user: result[0], activeSessions: userSessions.length });
|
|
888
890
|
}
|
|
889
891
|
catch (error) {
|
|
890
|
-
|
|
892
|
+
log.error('Get user error', error instanceof Error ? error : new Error(String(error)));
|
|
891
893
|
return c.json({ error: 'Failed to get user' }, 500);
|
|
892
894
|
}
|
|
893
895
|
});
|
|
@@ -923,7 +925,7 @@ userRoutes.patch('/admin/:userId', requireAdmin, async (c) => {
|
|
|
923
925
|
return c.json({ message: 'User updated' });
|
|
924
926
|
}
|
|
925
927
|
catch (error) {
|
|
926
|
-
|
|
928
|
+
log.error('Update user error', error instanceof Error ? error : new Error(String(error)));
|
|
927
929
|
return c.json({ error: 'Failed to update user' }, 500);
|
|
928
930
|
}
|
|
929
931
|
});
|
|
@@ -961,7 +963,7 @@ userRoutes.post('/admin/:userId/reset-password', requireAdmin, async (c) => {
|
|
|
961
963
|
});
|
|
962
964
|
}
|
|
963
965
|
catch (error) {
|
|
964
|
-
|
|
966
|
+
log.error('Reset password error', error instanceof Error ? error : new Error(String(error)));
|
|
965
967
|
return c.json({ error: 'Failed to reset password' }, 500);
|
|
966
968
|
}
|
|
967
969
|
});
|
|
@@ -991,7 +993,7 @@ userRoutes.delete('/admin/:userId', requireAdmin, async (c) => {
|
|
|
991
993
|
return c.json({ message: 'User deleted' });
|
|
992
994
|
}
|
|
993
995
|
catch (error) {
|
|
994
|
-
|
|
996
|
+
log.error('Delete user error', error instanceof Error ? error : new Error(String(error)));
|
|
995
997
|
return c.json({ error: 'Failed to delete user' }, 500);
|
|
996
998
|
}
|
|
997
999
|
});
|
package/dist/routes/webhooks.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
|
+
import { createContextualLogger } from '../utils/logger.js';
|
|
3
|
+
const log = createContextualLogger('Webhooks');
|
|
2
4
|
import { handleGitHubWebhook } from '../integrations/github.js';
|
|
3
5
|
import { handleJiraWebhook } from '../integrations/jira.js';
|
|
4
6
|
import { handleLinearWebhook } from '../integrations/linear.js';
|
|
@@ -18,7 +20,7 @@ webhooks.post('/github', async (c) => {
|
|
|
18
20
|
});
|
|
19
21
|
}
|
|
20
22
|
catch (error) {
|
|
21
|
-
|
|
23
|
+
log.error('GitHub webhook error', error instanceof Error ? error : new Error(String(error)));
|
|
22
24
|
return c.json({
|
|
23
25
|
error: 'Webhook processing failed',
|
|
24
26
|
message: error instanceof Error ? error.message : 'Unknown error',
|
|
@@ -39,7 +41,7 @@ webhooks.post('/jira', async (c) => {
|
|
|
39
41
|
});
|
|
40
42
|
}
|
|
41
43
|
catch (error) {
|
|
42
|
-
|
|
44
|
+
log.error('Jira webhook error', error instanceof Error ? error : new Error(String(error)));
|
|
43
45
|
return c.json({
|
|
44
46
|
error: 'Webhook processing failed',
|
|
45
47
|
message: error instanceof Error ? error.message : 'Unknown error',
|
|
@@ -60,7 +62,7 @@ webhooks.post('/linear', async (c) => {
|
|
|
60
62
|
});
|
|
61
63
|
}
|
|
62
64
|
catch (error) {
|
|
63
|
-
|
|
65
|
+
log.error('Linear webhook error', error instanceof Error ? error : new Error(String(error)));
|
|
64
66
|
return c.json({
|
|
65
67
|
error: 'Webhook processing failed',
|
|
66
68
|
message: error instanceof Error ? error.message : 'Unknown error',
|
package/dist/settings/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { getStorage } from '../storage/index.js';
|
|
3
|
+
import { createContextualLogger } from '../utils/logger.js';
|
|
4
|
+
const log = createContextualLogger('Settings');
|
|
3
5
|
// Plugin status enum
|
|
4
6
|
export const PluginStatusSchema = z.enum(['enabled', 'disabled', 'error', 'checking']);
|
|
5
7
|
// Settings schema with categories
|
|
@@ -199,7 +201,7 @@ export async function getSettings() {
|
|
|
199
201
|
return maskSecrets(settingsCache);
|
|
200
202
|
}
|
|
201
203
|
catch (error) {
|
|
202
|
-
|
|
204
|
+
log.warn('Failed to load settings, using defaults', { error: error instanceof Error ? error.message : String(error) });
|
|
203
205
|
settingsCache = { ...DEFAULT_SETTINGS };
|
|
204
206
|
return maskSecrets(settingsCache);
|
|
205
207
|
}
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { StorageAdapter } from "./adapter.js";
|
|
2
2
|
import type { LibSQLDatabase } from "drizzle-orm/libsql";
|
|
3
3
|
import type { Client } from "@libsql/client";
|
|
4
|
+
import * as schema from "./schema.js";
|
|
4
5
|
/**
|
|
5
6
|
* Initialize storage based on configuration
|
|
6
7
|
*/
|
|
@@ -12,7 +13,7 @@ export declare function getStorage(): StorageAdapter;
|
|
|
12
13
|
/**
|
|
13
14
|
* Get the raw drizzle database instance for advanced queries
|
|
14
15
|
*/
|
|
15
|
-
export declare function getDb(): LibSQLDatabase<
|
|
16
|
+
export declare function getDb(): LibSQLDatabase<typeof schema>;
|
|
16
17
|
/**
|
|
17
18
|
* Get the raw libsql client for executing raw SQL
|
|
18
19
|
*/
|
package/dist/storage/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { LibSQLAdapter } from "./libsql.js";
|
|
2
2
|
import { loadConfig } from "../utils/config-loader.js";
|
|
3
|
+
import { createContextualLogger } from "../utils/logger.js";
|
|
4
|
+
const log = createContextualLogger('Storage');
|
|
3
5
|
let storage = null;
|
|
4
6
|
/**
|
|
5
7
|
* Initialize storage based on configuration
|
|
@@ -27,10 +29,10 @@ export async function initStorage() {
|
|
|
27
29
|
if (tier === "local") {
|
|
28
30
|
const dbPath = dbPathOverride || process.env.DB_PATH || settings.storage?.dbPath;
|
|
29
31
|
storage = new LibSQLAdapter({ dbPath });
|
|
30
|
-
|
|
32
|
+
log.info('Initializing LibSQL storage', { dbPath: dbPath || 'default path' });
|
|
31
33
|
}
|
|
32
34
|
else {
|
|
33
|
-
|
|
35
|
+
log.info('Initializing in-memory storage (LibSQL in-memory)');
|
|
34
36
|
storage = new LibSQLAdapter({ dbPath: ":memory:" });
|
|
35
37
|
}
|
|
36
38
|
await storage.connect();
|
|
@@ -52,7 +54,6 @@ export function getDb() {
|
|
|
52
54
|
if (!storage) {
|
|
53
55
|
throw new Error("Storage not initialized. Call initStorage() first.");
|
|
54
56
|
}
|
|
55
|
-
// Access the internal db property via the LibSQLAdapter
|
|
56
57
|
return storage.getDb();
|
|
57
58
|
}
|
|
58
59
|
/**
|
|
@@ -113,8 +114,12 @@ export async function loadAllProviderConfigs() {
|
|
|
113
114
|
});
|
|
114
115
|
return result.rows
|
|
115
116
|
.map((row) => {
|
|
117
|
+
const value = row.value;
|
|
118
|
+
if (typeof value !== "string") {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
116
121
|
try {
|
|
117
|
-
return JSON.parse(
|
|
122
|
+
return JSON.parse(value);
|
|
118
123
|
}
|
|
119
124
|
catch {
|
|
120
125
|
return null;
|
package/dist/storage/libsql.js
CHANGED
|
@@ -14,6 +14,9 @@ function getNumber(value, key) {
|
|
|
14
14
|
const candidate = value[key];
|
|
15
15
|
return typeof candidate === "number" ? candidate : 0;
|
|
16
16
|
}
|
|
17
|
+
function toInValues(params) {
|
|
18
|
+
return (params ?? []);
|
|
19
|
+
}
|
|
17
20
|
function toSummary(row) {
|
|
18
21
|
return {
|
|
19
22
|
id: row.id,
|
|
@@ -1032,13 +1035,13 @@ export class LibSQLAdapter {
|
|
|
1032
1035
|
}
|
|
1033
1036
|
// === Tasks ===
|
|
1034
1037
|
async createTask(input) {
|
|
1035
|
-
const
|
|
1036
|
-
const
|
|
1038
|
+
const id = ('id' in input && typeof input.id === 'string') ? input.id : randomUUID();
|
|
1039
|
+
const status = ('status' in input && typeof input.status === 'string') ? input.status : 'pending';
|
|
1037
1040
|
const now = new Date();
|
|
1038
1041
|
const newTask = {
|
|
1039
1042
|
...input,
|
|
1040
1043
|
id,
|
|
1041
|
-
status:
|
|
1044
|
+
status: status,
|
|
1042
1045
|
createdAt: now,
|
|
1043
1046
|
updatedAt: now,
|
|
1044
1047
|
attempts: 0,
|
|
@@ -1123,7 +1126,11 @@ export class LibSQLAdapter {
|
|
|
1123
1126
|
createdAt: now,
|
|
1124
1127
|
});
|
|
1125
1128
|
}
|
|
1126
|
-
return {
|
|
1129
|
+
return toSummary({
|
|
1130
|
+
...newSummary,
|
|
1131
|
+
createdAt: now,
|
|
1132
|
+
rawOutput: null,
|
|
1133
|
+
});
|
|
1127
1134
|
}
|
|
1128
1135
|
async getSummary(id, includeRawOutput = false) {
|
|
1129
1136
|
const results = await this.db
|
|
@@ -1141,14 +1148,14 @@ export class LibSQLAdapter {
|
|
|
1141
1148
|
.where(eq(schema.summaryBlobs.summaryId, id))
|
|
1142
1149
|
.limit(1);
|
|
1143
1150
|
if (blob[0]) {
|
|
1144
|
-
return { ...summary, rawOutput: blob[0].rawOutput };
|
|
1151
|
+
return { ...toSummary(summary), rawOutput: blob[0].rawOutput };
|
|
1145
1152
|
}
|
|
1146
1153
|
}
|
|
1147
1154
|
// Strip rawOutput from response if not requested (for backward compat with old data)
|
|
1148
1155
|
if (!includeRawOutput) {
|
|
1149
|
-
return { ...summary, rawOutput: undefined };
|
|
1156
|
+
return { ...toSummary(summary), rawOutput: undefined };
|
|
1150
1157
|
}
|
|
1151
|
-
return summary;
|
|
1158
|
+
return toSummary(summary);
|
|
1152
1159
|
}
|
|
1153
1160
|
/**
|
|
1154
1161
|
* Get raw output for a summary (lazy loading)
|
|
@@ -1172,11 +1179,12 @@ export class LibSQLAdapter {
|
|
|
1172
1179
|
return summary[0]?.rawOutput || null;
|
|
1173
1180
|
}
|
|
1174
1181
|
async getTaskSummaries(taskId) {
|
|
1175
|
-
|
|
1182
|
+
const summaries = await this.db
|
|
1176
1183
|
.select()
|
|
1177
1184
|
.from(schema.summaries)
|
|
1178
1185
|
.where(eq(schema.summaries.taskId, taskId))
|
|
1179
1186
|
.orderBy(desc(schema.summaries.createdAt));
|
|
1187
|
+
return summaries.map(toSummary);
|
|
1180
1188
|
}
|
|
1181
1189
|
async querySummaries(query) {
|
|
1182
1190
|
const conditions = [];
|
|
@@ -1238,7 +1246,7 @@ export class LibSQLAdapter {
|
|
|
1238
1246
|
.from(schema.summaries)
|
|
1239
1247
|
.where(whereClause);
|
|
1240
1248
|
return {
|
|
1241
|
-
summaries: summaries,
|
|
1249
|
+
summaries: summaries.map(toSummary),
|
|
1242
1250
|
total: totalRes[0].value,
|
|
1243
1251
|
};
|
|
1244
1252
|
}
|
|
@@ -1339,7 +1347,6 @@ export class LibSQLAdapter {
|
|
|
1339
1347
|
completed: 0,
|
|
1340
1348
|
failed: 0,
|
|
1341
1349
|
avgDuration: 0,
|
|
1342
|
-
lastActivity: null,
|
|
1343
1350
|
};
|
|
1344
1351
|
}
|
|
1345
1352
|
if (row.status === "completed") {
|
|
@@ -1349,11 +1356,12 @@ export class LibSQLAdapter {
|
|
|
1349
1356
|
else if (row.status === "failed") {
|
|
1350
1357
|
stats[row.agent].failed = row.count;
|
|
1351
1358
|
}
|
|
1352
|
-
|
|
1359
|
+
const agentStats = stats[row.agent];
|
|
1360
|
+
if (row.lastActivity !== null) {
|
|
1353
1361
|
const lastActivity = new Date(row.lastActivity);
|
|
1354
|
-
if (!
|
|
1355
|
-
lastActivity >
|
|
1356
|
-
|
|
1362
|
+
if (!agentStats.lastActivity ||
|
|
1363
|
+
lastActivity > agentStats.lastActivity) {
|
|
1364
|
+
agentStats.lastActivity = lastActivity;
|
|
1357
1365
|
}
|
|
1358
1366
|
}
|
|
1359
1367
|
}
|
|
@@ -1390,10 +1398,8 @@ export class LibSQLAdapter {
|
|
|
1390
1398
|
const date = s.createdAt.toISOString().split("T")[0];
|
|
1391
1399
|
const model = s.model || "unknown";
|
|
1392
1400
|
const agent = s.agent || "unknown";
|
|
1393
|
-
const
|
|
1394
|
-
const
|
|
1395
|
-
const cost = costObj?.amount || 0;
|
|
1396
|
-
const tokens = tokensObj?.total || 0;
|
|
1401
|
+
const cost = getNumber(s.cost, "amount");
|
|
1402
|
+
const tokens = getNumber(s.tokensUsed, "total");
|
|
1397
1403
|
accumulate(date, model, agent, cost, tokens);
|
|
1398
1404
|
}
|
|
1399
1405
|
// Source 2: Conversation messages (chat/agentic sessions)
|
|
@@ -1451,7 +1457,8 @@ export class LibSQLAdapter {
|
|
|
1451
1457
|
return [];
|
|
1452
1458
|
const targetVector = new Float32Array(embedding);
|
|
1453
1459
|
const results = allEmbeddings.map((row) => {
|
|
1454
|
-
const
|
|
1460
|
+
const embeddingBuffer = row.embedding;
|
|
1461
|
+
const rowVector = new Float32Array(embeddingBuffer.buffer, embeddingBuffer.byteOffset, embeddingBuffer.byteLength / 4);
|
|
1455
1462
|
const distance = this.cosineSimilarity(targetVector, rowVector);
|
|
1456
1463
|
return {
|
|
1457
1464
|
entityId: row.entityId,
|
|
@@ -1480,14 +1487,14 @@ export class LibSQLAdapter {
|
|
|
1480
1487
|
async query(sql, params) {
|
|
1481
1488
|
const result = await this.client.execute({
|
|
1482
1489
|
sql,
|
|
1483
|
-
args: params
|
|
1490
|
+
args: toInValues(params),
|
|
1484
1491
|
});
|
|
1485
1492
|
return result.rows;
|
|
1486
1493
|
}
|
|
1487
1494
|
async execute(sql, params) {
|
|
1488
1495
|
await this.client.execute({
|
|
1489
1496
|
sql,
|
|
1490
|
-
args: params
|
|
1497
|
+
args: toInValues(params),
|
|
1491
1498
|
});
|
|
1492
1499
|
}
|
|
1493
1500
|
// === Task Events (Audit Log) ===
|
|
@@ -1837,6 +1844,7 @@ export class LibSQLAdapter {
|
|
|
1837
1844
|
const totalRes = await this.db
|
|
1838
1845
|
.select({ value: count() })
|
|
1839
1846
|
.from(schema.taskArchives);
|
|
1847
|
+
// Map archived tasks back to Task format
|
|
1840
1848
|
const tasks = archived.map((a) => ({
|
|
1841
1849
|
id: a.originalId,
|
|
1842
1850
|
title: a.title,
|