agor-live 0.3.7
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/LICENSE +94 -0
- package/README.md +163 -0
- package/bin/agor-daemon.js +20 -0
- package/bin/agor.js +14 -0
- package/dist/cli/base-command.d.ts +29 -0
- package/dist/cli/base-command.js +41 -0
- package/dist/cli/commands/board/add-session.d.ts +15 -0
- package/dist/cli/commands/board/add-session.js +102 -0
- package/dist/cli/commands/board/list.d.ts +14 -0
- package/dist/cli/commands/board/list.js +74 -0
- package/dist/cli/commands/config/clear.d.ts +13 -0
- package/dist/cli/commands/config/clear.js +21 -0
- package/dist/cli/commands/config/get.d.ts +13 -0
- package/dist/cli/commands/config/get.js +41 -0
- package/dist/cli/commands/config/index.d.ts +13 -0
- package/dist/cli/commands/config/index.js +118 -0
- package/dist/cli/commands/config/set.d.ts +14 -0
- package/dist/cli/commands/config/set.js +50 -0
- package/dist/cli/commands/config/unset.d.ts +13 -0
- package/dist/cli/commands/config/unset.js +35 -0
- package/dist/cli/commands/daemon/index.d.ts +13 -0
- package/dist/cli/commands/daemon/index.js +65 -0
- package/dist/cli/commands/daemon/logs.d.ts +13 -0
- package/dist/cli/commands/daemon/logs.js +78 -0
- package/dist/cli/commands/daemon/restart.d.ts +13 -0
- package/dist/cli/commands/daemon/restart.js +177 -0
- package/dist/cli/commands/daemon/start.d.ts +13 -0
- package/dist/cli/commands/daemon/start.js +193 -0
- package/dist/cli/commands/daemon/status.d.ts +13 -0
- package/dist/cli/commands/daemon/status.js +93 -0
- package/dist/cli/commands/daemon/stop.d.ts +13 -0
- package/dist/cli/commands/daemon/stop.js +108 -0
- package/dist/cli/commands/init.d.ts +44 -0
- package/dist/cli/commands/init.js +459 -0
- package/dist/cli/commands/mcp/add.d.ts +26 -0
- package/dist/cli/commands/mcp/add.js +162 -0
- package/dist/cli/commands/mcp/list.d.ts +16 -0
- package/dist/cli/commands/mcp/list.js +89 -0
- package/dist/cli/commands/mcp/remove.d.ts +17 -0
- package/dist/cli/commands/mcp/remove.js +86 -0
- package/dist/cli/commands/mcp/show.d.ts +14 -0
- package/dist/cli/commands/mcp/show.js +131 -0
- package/dist/cli/commands/repo/add.d.ts +16 -0
- package/dist/cli/commands/repo/add.js +105 -0
- package/dist/cli/commands/repo/list.d.ts +17 -0
- package/dist/cli/commands/repo/list.js +99 -0
- package/dist/cli/commands/repo/rm.d.ts +17 -0
- package/dist/cli/commands/repo/rm.js +126 -0
- package/dist/cli/commands/repo/worktree/add.d.ts +21 -0
- package/dist/cli/commands/repo/worktree/add.js +145 -0
- package/dist/cli/commands/repo/worktree/list.d.ts +21 -0
- package/dist/cli/commands/repo/worktree/list.js +136 -0
- package/dist/cli/commands/session/list.d.ts +30 -0
- package/dist/cli/commands/session/list.js +204 -0
- package/dist/cli/commands/session/load-claude.d.ts +16 -0
- package/dist/cli/commands/session/load-claude.js +211 -0
- package/dist/cli/commands/user/create-admin.d.ts +13 -0
- package/dist/cli/commands/user/create-admin.js +65 -0
- package/dist/cli/commands/user/create.d.ts +16 -0
- package/dist/cli/commands/user/create.js +126 -0
- package/dist/cli/commands/user/delete.d.ts +16 -0
- package/dist/cli/commands/user/delete.js +77 -0
- package/dist/cli/commands/user/list.d.ts +13 -0
- package/dist/cli/commands/user/list.js +78 -0
- package/dist/cli/commands/user/update.d.ts +19 -0
- package/dist/cli/commands/user/update.js +149 -0
- package/dist/cli/hooks/command-not-found.d.ts +9 -0
- package/dist/cli/hooks/command-not-found.js +14 -0
- package/dist/cli/lib/banner.d.ts +25 -0
- package/dist/cli/lib/banner.js +25 -0
- package/dist/cli/lib/context.d.ts +27 -0
- package/dist/cli/lib/context.js +32 -0
- package/dist/cli/lib/daemon-manager.d.ts +48 -0
- package/dist/cli/lib/daemon-manager.js +109 -0
- package/dist/cli/lib/help.d.ts +13 -0
- package/dist/cli/lib/help.js +46 -0
- package/dist/core/agentic-tool-B_gFNpk5.d.ts +33 -0
- package/dist/core/agentic-tool-DsyX8diw.d.cts +33 -0
- package/dist/core/api/index.cjs +98 -0
- package/dist/core/api/index.d.cts +174 -0
- package/dist/core/api/index.d.ts +174 -0
- package/dist/core/api/index.js +62 -0
- package/dist/core/board-comment-BUm0fpmD.d.cts +134 -0
- package/dist/core/board-comment-gC_-twPx.d.ts +134 -0
- package/dist/core/claude/index.cjs +673 -0
- package/dist/core/claude/index.d.cts +124 -0
- package/dist/core/claude/index.d.ts +124 -0
- package/dist/core/claude/index.js +629 -0
- package/dist/core/config/browser.cjs +165 -0
- package/dist/core/config/browser.d.cts +289 -0
- package/dist/core/config/browser.d.ts +289 -0
- package/dist/core/config/browser.js +131 -0
- package/dist/core/config/index.cjs +518 -0
- package/dist/core/config/index.d.cts +246 -0
- package/dist/core/config/index.d.ts +246 -0
- package/dist/core/config/index.js +451 -0
- package/dist/core/db/index.cjs +3726 -0
- package/dist/core/db/index.d.cts +631 -0
- package/dist/core/db/index.d.ts +631 -0
- package/dist/core/db/index.js +3649 -0
- package/dist/core/dist/agentic-tool-B_gFNpk5.d.ts +33 -0
- package/dist/core/dist/agentic-tool-DsyX8diw.d.cts +33 -0
- package/dist/core/dist/api/index.cjs +98 -0
- package/dist/core/dist/api/index.d.cts +174 -0
- package/dist/core/dist/api/index.d.ts +174 -0
- package/dist/core/dist/api/index.js +62 -0
- package/dist/core/dist/board-comment-BUm0fpmD.d.cts +134 -0
- package/dist/core/dist/board-comment-gC_-twPx.d.ts +134 -0
- package/dist/core/dist/claude/index.cjs +673 -0
- package/dist/core/dist/claude/index.d.cts +124 -0
- package/dist/core/dist/claude/index.d.ts +124 -0
- package/dist/core/dist/claude/index.js +629 -0
- package/dist/core/dist/config/browser.cjs +165 -0
- package/dist/core/dist/config/browser.d.cts +289 -0
- package/dist/core/dist/config/browser.d.ts +289 -0
- package/dist/core/dist/config/browser.js +131 -0
- package/dist/core/dist/config/index.cjs +518 -0
- package/dist/core/dist/config/index.d.cts +246 -0
- package/dist/core/dist/config/index.d.ts +246 -0
- package/dist/core/dist/config/index.js +451 -0
- package/dist/core/dist/db/index.cjs +3726 -0
- package/dist/core/dist/db/index.d.cts +631 -0
- package/dist/core/dist/db/index.d.ts +631 -0
- package/dist/core/dist/db/index.js +3649 -0
- package/dist/core/dist/environment/variable-resolver.cjs +92 -0
- package/dist/core/dist/environment/variable-resolver.d.cts +52 -0
- package/dist/core/dist/environment/variable-resolver.d.ts +52 -0
- package/dist/core/dist/environment/variable-resolver.js +53 -0
- package/dist/core/dist/feathers/index.cjs +66 -0
- package/dist/core/dist/feathers/index.d.cts +7 -0
- package/dist/core/dist/feathers/index.d.ts +7 -0
- package/dist/core/dist/feathers/index.js +25 -0
- package/dist/core/dist/feathers-BzHEPnpl.d.cts +228 -0
- package/dist/core/dist/feathers-BzHEPnpl.d.ts +228 -0
- package/dist/core/dist/git/index.cjs +302 -0
- package/dist/core/dist/git/index.d.cts +137 -0
- package/dist/core/dist/git/index.d.ts +137 -0
- package/dist/core/dist/git/index.js +260 -0
- package/dist/core/dist/id-DMqyogFB.d.cts +131 -0
- package/dist/core/dist/id-DMqyogFB.d.ts +131 -0
- package/dist/core/dist/index.cjs +4653 -0
- package/dist/core/dist/index.d.cts +23 -0
- package/dist/core/dist/index.d.ts +23 -0
- package/dist/core/dist/index.js +4509 -0
- package/dist/core/dist/message-BoxZISHg.d.cts +120 -0
- package/dist/core/dist/message-DvBzHu7V.d.ts +120 -0
- package/dist/core/dist/permissions/index.cjs +112 -0
- package/dist/core/dist/permissions/index.d.cts +81 -0
- package/dist/core/dist/permissions/index.d.ts +81 -0
- package/dist/core/dist/permissions/index.js +85 -0
- package/dist/core/dist/repo-3CUrCRbq.d.cts +405 -0
- package/dist/core/dist/repo-CnvJ0B6-.d.ts +405 -0
- package/dist/core/dist/session-BPjJlVdZ.d.cts +429 -0
- package/dist/core/dist/session-wAzjHatv.d.ts +429 -0
- package/dist/core/dist/task-BIEgT1DK.d.cts +163 -0
- package/dist/core/dist/task-DuIfiUbW.d.ts +163 -0
- package/dist/core/dist/templates/handlebars-helpers.cjs +156 -0
- package/dist/core/dist/templates/handlebars-helpers.d.cts +45 -0
- package/dist/core/dist/templates/handlebars-helpers.d.ts +45 -0
- package/dist/core/dist/templates/handlebars-helpers.js +119 -0
- package/dist/core/dist/tools/claude/models.cjs +70 -0
- package/dist/core/dist/tools/claude/models.d.cts +27 -0
- package/dist/core/dist/tools/claude/models.d.ts +27 -0
- package/dist/core/dist/tools/claude/models.js +44 -0
- package/dist/core/dist/tools/index.cjs +3367 -0
- package/dist/core/dist/tools/index.d.cts +967 -0
- package/dist/core/dist/tools/index.d.ts +967 -0
- package/dist/core/dist/tools/index.js +3314 -0
- package/dist/core/dist/tools/models.cjs +119 -0
- package/dist/core/dist/tools/models.d.cts +47 -0
- package/dist/core/dist/tools/models.d.ts +47 -0
- package/dist/core/dist/tools/models.js +86 -0
- package/dist/core/dist/types/index.cjs +152 -0
- package/dist/core/dist/types/index.d.cts +214 -0
- package/dist/core/dist/types/index.d.ts +214 -0
- package/dist/core/dist/types/index.js +112 -0
- package/dist/core/dist/user-BmL3kFol.d.ts +50 -0
- package/dist/core/dist/user-eUuKj7yM.d.cts +50 -0
- package/dist/core/dist/utils/pricing.cjs +102 -0
- package/dist/core/dist/utils/pricing.d.cts +43 -0
- package/dist/core/dist/utils/pricing.d.ts +43 -0
- package/dist/core/dist/utils/pricing.js +75 -0
- package/dist/core/dist/worktrees-BzIxB1U6.d.cts +2745 -0
- package/dist/core/dist/worktrees-CYem1ya2.d.ts +2745 -0
- package/dist/core/environment/variable-resolver.cjs +92 -0
- package/dist/core/environment/variable-resolver.d.cts +52 -0
- package/dist/core/environment/variable-resolver.d.ts +52 -0
- package/dist/core/environment/variable-resolver.js +53 -0
- package/dist/core/feathers/index.cjs +66 -0
- package/dist/core/feathers/index.d.cts +7 -0
- package/dist/core/feathers/index.d.ts +7 -0
- package/dist/core/feathers/index.js +25 -0
- package/dist/core/feathers-BzHEPnpl.d.cts +228 -0
- package/dist/core/feathers-BzHEPnpl.d.ts +228 -0
- package/dist/core/git/index.cjs +302 -0
- package/dist/core/git/index.d.cts +137 -0
- package/dist/core/git/index.d.ts +137 -0
- package/dist/core/git/index.js +260 -0
- package/dist/core/id-DMqyogFB.d.cts +131 -0
- package/dist/core/id-DMqyogFB.d.ts +131 -0
- package/dist/core/index.cjs +4653 -0
- package/dist/core/index.d.cts +23 -0
- package/dist/core/index.d.ts +23 -0
- package/dist/core/index.js +4509 -0
- package/dist/core/message-BoxZISHg.d.cts +120 -0
- package/dist/core/message-DvBzHu7V.d.ts +120 -0
- package/dist/core/package.json +133 -0
- package/dist/core/permissions/index.cjs +112 -0
- package/dist/core/permissions/index.d.cts +81 -0
- package/dist/core/permissions/index.d.ts +81 -0
- package/dist/core/permissions/index.js +85 -0
- package/dist/core/repo-3CUrCRbq.d.cts +405 -0
- package/dist/core/repo-CnvJ0B6-.d.ts +405 -0
- package/dist/core/session-BPjJlVdZ.d.cts +429 -0
- package/dist/core/session-wAzjHatv.d.ts +429 -0
- package/dist/core/task-BIEgT1DK.d.cts +163 -0
- package/dist/core/task-DuIfiUbW.d.ts +163 -0
- package/dist/core/templates/handlebars-helpers.cjs +156 -0
- package/dist/core/templates/handlebars-helpers.d.cts +45 -0
- package/dist/core/templates/handlebars-helpers.d.ts +45 -0
- package/dist/core/templates/handlebars-helpers.js +119 -0
- package/dist/core/tools/claude/models.cjs +70 -0
- package/dist/core/tools/claude/models.d.cts +27 -0
- package/dist/core/tools/claude/models.d.ts +27 -0
- package/dist/core/tools/claude/models.js +44 -0
- package/dist/core/tools/index.cjs +3367 -0
- package/dist/core/tools/index.d.cts +967 -0
- package/dist/core/tools/index.d.ts +967 -0
- package/dist/core/tools/index.js +3314 -0
- package/dist/core/tools/models.cjs +119 -0
- package/dist/core/tools/models.d.cts +47 -0
- package/dist/core/tools/models.d.ts +47 -0
- package/dist/core/tools/models.js +86 -0
- package/dist/core/types/index.cjs +152 -0
- package/dist/core/types/index.d.cts +214 -0
- package/dist/core/types/index.d.ts +214 -0
- package/dist/core/types/index.js +112 -0
- package/dist/core/user-BmL3kFol.d.ts +50 -0
- package/dist/core/user-eUuKj7yM.d.cts +50 -0
- package/dist/core/utils/pricing.cjs +102 -0
- package/dist/core/utils/pricing.d.cts +43 -0
- package/dist/core/utils/pricing.d.ts +43 -0
- package/dist/core/utils/pricing.js +75 -0
- package/dist/core/worktrees-BzIxB1U6.d.cts +2745 -0
- package/dist/core/worktrees-CYem1ya2.d.ts +2745 -0
- package/dist/daemon/adapters/drizzle.d.ts +114 -0
- package/dist/daemon/adapters/drizzle.js +219 -0
- package/dist/daemon/declarations.d.ts +101 -0
- package/dist/daemon/declarations.js +0 -0
- package/dist/daemon/index.d.ts +2 -0
- package/dist/daemon/index.js +4093 -0
- package/dist/daemon/mcp/routes.d.ts +15 -0
- package/dist/daemon/mcp/routes.js +641 -0
- package/dist/daemon/mcp/tokens.d.ts +50 -0
- package/dist/daemon/mcp/tokens.js +85 -0
- package/dist/daemon/services/board-comments.d.ts +97 -0
- package/dist/daemon/services/board-comments.js +326 -0
- package/dist/daemon/services/board-objects.d.ts +71 -0
- package/dist/daemon/services/board-objects.js +117 -0
- package/dist/daemon/services/boards.d.ts +64 -0
- package/dist/daemon/services/boards.js +286 -0
- package/dist/daemon/services/config.d.ts +35 -0
- package/dist/daemon/services/config.js +68 -0
- package/dist/daemon/services/context.d.ts +55 -0
- package/dist/daemon/services/context.js +113 -0
- package/dist/daemon/services/health-monitor.d.ts +58 -0
- package/dist/daemon/services/health-monitor.js +158 -0
- package/dist/daemon/services/mcp-servers.d.ts +42 -0
- package/dist/daemon/services/mcp-servers.js +275 -0
- package/dist/daemon/services/messages.d.ts +49 -0
- package/dist/daemon/services/messages.js +269 -0
- package/dist/daemon/services/repos.d.ts +61 -0
- package/dist/daemon/services/repos.js +350 -0
- package/dist/daemon/services/session-mcp-servers.d.ts +56 -0
- package/dist/daemon/services/session-mcp-servers.js +51 -0
- package/dist/daemon/services/sessions.d.ts +64 -0
- package/dist/daemon/services/sessions.js +398 -0
- package/dist/daemon/services/tasks.d.ts +55 -0
- package/dist/daemon/services/tasks.js +318 -0
- package/dist/daemon/services/terminals.d.ts +75 -0
- package/dist/daemon/services/terminals.js +110 -0
- package/dist/daemon/services/users.d.ts +98 -0
- package/dist/daemon/services/users.js +177 -0
- package/dist/daemon/services/worktrees.d.ts +98 -0
- package/dist/daemon/services/worktrees.js +719 -0
- package/dist/daemon/strategies/anonymous.d.ts +20 -0
- package/dist/daemon/strategies/anonymous.js +32 -0
- package/dist/ui/assets/cc-CYmbalCD.png +0 -0
- package/dist/ui/assets/codex-4sLD1mVS.png +0 -0
- package/dist/ui/assets/cursor-BUy5pFVL.png +0 -0
- package/dist/ui/assets/gemini-ajOb7iAl.png +0 -0
- package/dist/ui/assets/index-Dc4ELxry.css +32 -0
- package/dist/ui/assets/index-KfIu8v4V.js +578 -0
- package/dist/ui/favicon.png +0 -0
- package/dist/ui/index.html +26 -0
- package/dist/ui/vite.svg +1 -0
- package/package.json +90 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Params, Paginated, Id, NullableId } from '@agor/core/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Custom Drizzle Adapter for FeathersJS
|
|
5
|
+
*
|
|
6
|
+
* Lightweight adapter that bridges FeathersJS service interface with Drizzle ORM.
|
|
7
|
+
* Uses the repository pattern from @agor/core/db for type-safe database operations.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Query operators supported by the adapter
|
|
12
|
+
*/
|
|
13
|
+
interface Query {
|
|
14
|
+
$limit?: number;
|
|
15
|
+
$skip?: number;
|
|
16
|
+
$sort?: Record<string, 1 | -1>;
|
|
17
|
+
$select?: string[];
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Pagination configuration
|
|
22
|
+
*/
|
|
23
|
+
interface PaginationOptions {
|
|
24
|
+
default?: number;
|
|
25
|
+
max?: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Adapter options
|
|
29
|
+
*/
|
|
30
|
+
interface DrizzleAdapterOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Name of the ID field (default: 'id')
|
|
33
|
+
*/
|
|
34
|
+
id?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Pagination configuration
|
|
37
|
+
*/
|
|
38
|
+
paginate?: PaginationOptions;
|
|
39
|
+
/**
|
|
40
|
+
* Allow multi-record operations (patch/remove without ID)
|
|
41
|
+
*/
|
|
42
|
+
multi?: boolean | string[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Repository interface that the adapter expects
|
|
46
|
+
*/
|
|
47
|
+
interface Repository<T> {
|
|
48
|
+
create(data: Partial<T>): Promise<T>;
|
|
49
|
+
findById(id: string): Promise<T | null>;
|
|
50
|
+
findAll(): Promise<T[]>;
|
|
51
|
+
update(id: string, updates: Partial<T>): Promise<T>;
|
|
52
|
+
delete(id: string): Promise<void>;
|
|
53
|
+
count?(): Promise<number>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Drizzle Service Adapter
|
|
57
|
+
*
|
|
58
|
+
* Implements FeathersJS service methods using a Drizzle repository.
|
|
59
|
+
* Emits events for real-time WebSocket broadcasting.
|
|
60
|
+
*/
|
|
61
|
+
declare class DrizzleService<T = any, D = Partial<T>, P extends Params = Params> {
|
|
62
|
+
private repository;
|
|
63
|
+
id: string;
|
|
64
|
+
paginate?: PaginationOptions;
|
|
65
|
+
multi: boolean | string[];
|
|
66
|
+
emit?: (event: string, ...args: any[]) => boolean;
|
|
67
|
+
constructor(repository: Repository<T>, options?: DrizzleAdapterOptions);
|
|
68
|
+
/**
|
|
69
|
+
* Extract query parameters from params
|
|
70
|
+
*/
|
|
71
|
+
private getQuery;
|
|
72
|
+
/**
|
|
73
|
+
* Apply filters to data array (client-side filtering)
|
|
74
|
+
*/
|
|
75
|
+
private filterData;
|
|
76
|
+
/**
|
|
77
|
+
* Sort data array
|
|
78
|
+
*/
|
|
79
|
+
private sortData;
|
|
80
|
+
/**
|
|
81
|
+
* Select specific fields from data
|
|
82
|
+
*/
|
|
83
|
+
private selectFields;
|
|
84
|
+
/**
|
|
85
|
+
* Apply pagination to data
|
|
86
|
+
*/
|
|
87
|
+
private paginateData;
|
|
88
|
+
/**
|
|
89
|
+
* Find records
|
|
90
|
+
*/
|
|
91
|
+
find(params?: P): Promise<Paginated<T> | T[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Get a single record by ID
|
|
94
|
+
*/
|
|
95
|
+
get(id: Id, _params?: P): Promise<T>;
|
|
96
|
+
/**
|
|
97
|
+
* Create one or more records
|
|
98
|
+
*/
|
|
99
|
+
create(data: D | D[], params?: P): Promise<T | T[]>;
|
|
100
|
+
/**
|
|
101
|
+
* Update a record (complete replacement)
|
|
102
|
+
*/
|
|
103
|
+
update(id: Id, data: D, params?: P): Promise<T>;
|
|
104
|
+
/**
|
|
105
|
+
* Patch a record (partial update)
|
|
106
|
+
*/
|
|
107
|
+
patch(id: NullableId, data: D, params?: P): Promise<T | T[]>;
|
|
108
|
+
/**
|
|
109
|
+
* Remove one or more records
|
|
110
|
+
*/
|
|
111
|
+
remove(id: NullableId, params?: P): Promise<T | T[]>;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export { type DrizzleAdapterOptions, DrizzleService, type PaginationOptions, type Query, type Repository };
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
// src/adapters/drizzle.ts
|
|
2
|
+
var DrizzleService = class {
|
|
3
|
+
constructor(repository, options = {}) {
|
|
4
|
+
this.repository = repository;
|
|
5
|
+
this.id = options.id ?? "id";
|
|
6
|
+
this.paginate = options.paginate;
|
|
7
|
+
this.multi = options.multi ?? false;
|
|
8
|
+
}
|
|
9
|
+
id;
|
|
10
|
+
paginate;
|
|
11
|
+
multi;
|
|
12
|
+
// Event emitter for FeathersJS (will be injected by framework)
|
|
13
|
+
// biome-ignore lint/suspicious/noExplicitAny: FeathersJS event system
|
|
14
|
+
emit;
|
|
15
|
+
/**
|
|
16
|
+
* Extract query parameters from params
|
|
17
|
+
*/
|
|
18
|
+
getQuery(params) {
|
|
19
|
+
return params?.query ?? {};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Apply filters to data array (client-side filtering)
|
|
23
|
+
*/
|
|
24
|
+
filterData(data, query) {
|
|
25
|
+
let filtered = [...data];
|
|
26
|
+
for (const [key, value] of Object.entries(query)) {
|
|
27
|
+
if (key.startsWith("$")) continue;
|
|
28
|
+
filtered = filtered.filter((item) => {
|
|
29
|
+
if (typeof value === "object" && value !== null) {
|
|
30
|
+
for (const [op, opValue] of Object.entries(value)) {
|
|
31
|
+
switch (op) {
|
|
32
|
+
case "$in":
|
|
33
|
+
return Array.isArray(opValue) && opValue.includes(item[key]);
|
|
34
|
+
case "$nin":
|
|
35
|
+
return Array.isArray(opValue) && !opValue.includes(item[key]);
|
|
36
|
+
case "$ne":
|
|
37
|
+
return item[key] !== opValue;
|
|
38
|
+
case "$gt":
|
|
39
|
+
return item[key] > opValue;
|
|
40
|
+
case "$gte":
|
|
41
|
+
return item[key] >= opValue;
|
|
42
|
+
case "$lt":
|
|
43
|
+
return item[key] < opValue;
|
|
44
|
+
case "$lte":
|
|
45
|
+
return item[key] <= opValue;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return item[key] === value;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return filtered;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Sort data array
|
|
56
|
+
*/
|
|
57
|
+
sortData(data, sortSpec) {
|
|
58
|
+
if (!sortSpec) return data;
|
|
59
|
+
const sorted = [...data];
|
|
60
|
+
const entries = Object.entries(sortSpec);
|
|
61
|
+
sorted.sort((a, b) => {
|
|
62
|
+
for (const [field, direction] of entries) {
|
|
63
|
+
const aVal = a[field];
|
|
64
|
+
const bVal = b[field];
|
|
65
|
+
if (aVal < bVal) return direction === 1 ? -1 : 1;
|
|
66
|
+
if (aVal > bVal) return direction === 1 ? 1 : -1;
|
|
67
|
+
}
|
|
68
|
+
return 0;
|
|
69
|
+
});
|
|
70
|
+
return sorted;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Select specific fields from data
|
|
74
|
+
*/
|
|
75
|
+
selectFields(data, fields) {
|
|
76
|
+
if (!fields || fields.length === 0) return data;
|
|
77
|
+
return data.map((item) => {
|
|
78
|
+
const selected = {};
|
|
79
|
+
for (const field of fields) {
|
|
80
|
+
if (field in item) {
|
|
81
|
+
selected[field] = item[field];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return selected;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Apply pagination to data
|
|
89
|
+
*/
|
|
90
|
+
paginateData(data, query, total) {
|
|
91
|
+
const limit = query.$limit ?? this.paginate?.default ?? data.length;
|
|
92
|
+
const skip = query.$skip ?? 0;
|
|
93
|
+
if (!this.paginate) {
|
|
94
|
+
return data;
|
|
95
|
+
}
|
|
96
|
+
const maxLimit = this.paginate.max ?? 1e3;
|
|
97
|
+
const actualLimit = Math.min(limit, maxLimit);
|
|
98
|
+
const paginated = data.slice(skip, skip + actualLimit);
|
|
99
|
+
return {
|
|
100
|
+
total,
|
|
101
|
+
limit: actualLimit,
|
|
102
|
+
skip,
|
|
103
|
+
data: paginated
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Find records
|
|
108
|
+
*/
|
|
109
|
+
async find(params) {
|
|
110
|
+
const query = this.getQuery(params);
|
|
111
|
+
let data = await this.repository.findAll();
|
|
112
|
+
const total = data.length;
|
|
113
|
+
data = this.filterData(data, query);
|
|
114
|
+
data = this.sortData(data, query.$sort);
|
|
115
|
+
const selected = this.selectFields(data, query.$select);
|
|
116
|
+
return this.paginateData(selected, query, total);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get a single record by ID
|
|
120
|
+
*/
|
|
121
|
+
async get(id, _params) {
|
|
122
|
+
const result = await this.repository.findById(String(id));
|
|
123
|
+
if (!result) {
|
|
124
|
+
throw new Error(`No record found for id '${id}'`);
|
|
125
|
+
}
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Create one or more records
|
|
130
|
+
*/
|
|
131
|
+
async create(data, params) {
|
|
132
|
+
if (Array.isArray(data)) {
|
|
133
|
+
const results = await Promise.all(
|
|
134
|
+
data.map((item) => this.repository.create(item))
|
|
135
|
+
);
|
|
136
|
+
for (const result2 of results) {
|
|
137
|
+
this.emit?.("created", result2, params);
|
|
138
|
+
}
|
|
139
|
+
return results;
|
|
140
|
+
}
|
|
141
|
+
const result = await this.repository.create(data);
|
|
142
|
+
console.log("\u{1F514} [DrizzleService] Emitting created event, emit function exists:", !!this.emit);
|
|
143
|
+
this.emit?.("created", result, params);
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Update a record (complete replacement)
|
|
148
|
+
*/
|
|
149
|
+
async update(id, data, params) {
|
|
150
|
+
const existing = await this.get(id, params);
|
|
151
|
+
if (!existing) {
|
|
152
|
+
throw new Error(`No record found for id '${id}'`);
|
|
153
|
+
}
|
|
154
|
+
const result = await this.repository.update(String(id), data);
|
|
155
|
+
this.emit?.("updated", result, params);
|
|
156
|
+
this.emit?.("patched", result, params);
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Patch a record (partial update)
|
|
161
|
+
*/
|
|
162
|
+
async patch(id, data, params) {
|
|
163
|
+
if (id === null) {
|
|
164
|
+
if (!this.multi) {
|
|
165
|
+
throw new Error("Multi-patch is not enabled");
|
|
166
|
+
}
|
|
167
|
+
const query = this.getQuery(params);
|
|
168
|
+
let records = await this.repository.findAll();
|
|
169
|
+
records = this.filterData(records, query);
|
|
170
|
+
const results = await Promise.all(
|
|
171
|
+
records.map(
|
|
172
|
+
(record) => this.repository.update(
|
|
173
|
+
record[this.id],
|
|
174
|
+
data
|
|
175
|
+
)
|
|
176
|
+
)
|
|
177
|
+
);
|
|
178
|
+
for (const result2 of results) {
|
|
179
|
+
this.emit?.("patched", result2, params);
|
|
180
|
+
}
|
|
181
|
+
return results;
|
|
182
|
+
}
|
|
183
|
+
const existing = await this.get(id, params);
|
|
184
|
+
if (!existing) {
|
|
185
|
+
throw new Error(`No record found for id '${id}'`);
|
|
186
|
+
}
|
|
187
|
+
const result = await this.repository.update(String(id), data);
|
|
188
|
+
this.emit?.("patched", result, params);
|
|
189
|
+
return result;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Remove one or more records
|
|
193
|
+
*/
|
|
194
|
+
async remove(id, params) {
|
|
195
|
+
if (id === null) {
|
|
196
|
+
if (!this.multi) {
|
|
197
|
+
throw new Error("Multi-remove is not enabled");
|
|
198
|
+
}
|
|
199
|
+
const query = this.getQuery(params);
|
|
200
|
+
let records = await this.repository.findAll();
|
|
201
|
+
records = this.filterData(records, query);
|
|
202
|
+
await Promise.all(records.map((record) => this.repository.delete(record[this.id])));
|
|
203
|
+
for (const record of records) {
|
|
204
|
+
this.emit?.("removed", record, params);
|
|
205
|
+
}
|
|
206
|
+
return records;
|
|
207
|
+
}
|
|
208
|
+
const existing = await this.get(id, params);
|
|
209
|
+
if (!existing) {
|
|
210
|
+
throw new Error(`No record found for id '${id}'`);
|
|
211
|
+
}
|
|
212
|
+
await this.repository.delete(String(id));
|
|
213
|
+
this.emit?.("removed", existing, params);
|
|
214
|
+
return existing;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
export {
|
|
218
|
+
DrizzleService
|
|
219
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { ExpressApplication, Service } from '@agor/core/feathers';
|
|
2
|
+
import { AuthenticatedUser as AuthenticatedUser$1, AuthenticatedParams as AuthenticatedParams$1, CreateHookContext as CreateHookContext$1, HookContext as HookContext$1, Session, Params, Task, Repo, Board, Message, Worktree, WorktreeID } from '@agor/core/types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* FeathersJS Type Declarations for Agor Daemon
|
|
6
|
+
*
|
|
7
|
+
* Provides proper TypeScript types for:
|
|
8
|
+
* - Hook contexts with authentication
|
|
9
|
+
* - Service implementations with custom methods
|
|
10
|
+
* - Application instance
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
type AuthenticatedUser = AuthenticatedUser$1;
|
|
14
|
+
type AuthenticatedParams = AuthenticatedParams$1;
|
|
15
|
+
type CreateHookContext<T = unknown> = CreateHookContext$1<T>;
|
|
16
|
+
type HookContext<T = unknown> = HookContext$1<T>;
|
|
17
|
+
/**
|
|
18
|
+
* Application type for the daemon
|
|
19
|
+
*/
|
|
20
|
+
type Application = ExpressApplication;
|
|
21
|
+
/**
|
|
22
|
+
* Sessions service with custom methods (server-side implementation)
|
|
23
|
+
* This matches the SessionRepository methods exposed via the service adapter
|
|
24
|
+
*/
|
|
25
|
+
interface SessionsServiceImpl extends Service<Session, Partial<Session>, Params> {
|
|
26
|
+
fork(id: string, data: {
|
|
27
|
+
prompt: string;
|
|
28
|
+
task_id?: string;
|
|
29
|
+
}, params?: Params): Promise<Session>;
|
|
30
|
+
spawn(id: string, data: {
|
|
31
|
+
prompt: string;
|
|
32
|
+
title?: string;
|
|
33
|
+
agentic_tool?: Session['agentic_tool'];
|
|
34
|
+
task_id?: string;
|
|
35
|
+
}, params?: Params): Promise<Session>;
|
|
36
|
+
getGenealogy(id: string, params?: Params): Promise<unknown>;
|
|
37
|
+
on(event: string, handler: (...args: any[]) => void): this;
|
|
38
|
+
removeListener(event: string, handler: (...args: any[]) => void): this;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Tasks service with custom methods (server-side implementation)
|
|
42
|
+
*/
|
|
43
|
+
interface TasksServiceImpl extends Service<Task, Partial<Task>, Params> {
|
|
44
|
+
createMany(data: Array<Partial<Task>>): Promise<Task[]>;
|
|
45
|
+
complete(id: string, data: {
|
|
46
|
+
git_state?: {
|
|
47
|
+
sha_at_end?: string;
|
|
48
|
+
commit_message?: string;
|
|
49
|
+
};
|
|
50
|
+
}, params?: Params): Promise<Task>;
|
|
51
|
+
fail(id: string, data: {
|
|
52
|
+
error?: string;
|
|
53
|
+
}, params?: Params): Promise<Task>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Repos service with custom methods (server-side implementation)
|
|
57
|
+
*/
|
|
58
|
+
interface ReposServiceImpl extends Service<Repo, Partial<Repo>, Params> {
|
|
59
|
+
cloneRepository(data: {
|
|
60
|
+
url: string;
|
|
61
|
+
name?: string;
|
|
62
|
+
destination?: string;
|
|
63
|
+
}, params?: Params): Promise<Repo>;
|
|
64
|
+
createWorktree(id: string, data: {
|
|
65
|
+
name: string;
|
|
66
|
+
ref: string;
|
|
67
|
+
createBranch?: boolean;
|
|
68
|
+
}, params?: Params): Promise<Repo>;
|
|
69
|
+
removeWorktree(id: string, name: string, params?: Params): Promise<Repo>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Boards service with custom methods (server-side implementation)
|
|
73
|
+
*/
|
|
74
|
+
interface BoardsServiceImpl extends Service<Board, Partial<Board>, Params> {
|
|
75
|
+
addSession(boardId: string, sessionId: string, params?: Params): Promise<Board>;
|
|
76
|
+
removeSession(boardId: string, sessionId: string, params?: Params): Promise<Board>;
|
|
77
|
+
upsertBoardObject(boardId: string, objectId: string, objectData: unknown, params?: Params): Promise<Board>;
|
|
78
|
+
removeBoardObject(boardId: string, objectId: string, params?: Params): Promise<Board>;
|
|
79
|
+
batchUpsertBoardObjects(boardId: string, objects: unknown[], params?: Params): Promise<Board>;
|
|
80
|
+
deleteZone(boardId: string, zoneId: string, deleteAssociatedSessions: boolean, params?: Params): Promise<{
|
|
81
|
+
board: Board;
|
|
82
|
+
affectedSessions: string[];
|
|
83
|
+
}>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Messages service with custom methods (server-side implementation)
|
|
87
|
+
*/
|
|
88
|
+
interface MessagesServiceImpl extends Service<Message, Partial<Message>, Params> {
|
|
89
|
+
createMany(data: Array<Partial<Message>>): Promise<Message[]>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Worktrees service with custom methods (server-side implementation)
|
|
93
|
+
*/
|
|
94
|
+
interface WorktreesServiceImpl extends Service<Worktree, Partial<Worktree>, Params> {
|
|
95
|
+
startEnvironment(id: WorktreeID, params?: Params): Promise<Worktree>;
|
|
96
|
+
stopEnvironment(id: WorktreeID, params?: Params): Promise<Worktree>;
|
|
97
|
+
restartEnvironment(id: WorktreeID, params?: Params): Promise<Worktree>;
|
|
98
|
+
checkHealth(id: WorktreeID, params?: Params): Promise<Worktree>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export type { Application, AuthenticatedParams, AuthenticatedUser, BoardsServiceImpl, CreateHookContext, HookContext, MessagesServiceImpl, ReposServiceImpl, SessionsServiceImpl, TasksServiceImpl, WorktreesServiceImpl };
|
|
File without changes
|