@jingyi0605/codingns 0.8.1 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/codingns.mjs +180 -0
- package/dist/public/assets/{AdaptiveButlerPage-b7s6F_sd.js → AdaptiveButlerPage-CJw8Ae62.js} +3 -3
- package/dist/public/assets/App-BOHBGFOd.js +30 -0
- package/dist/public/assets/{BootstrapPage-jFfl7KNK.js → BootstrapPage-BxHQT4nA.js} +1 -1
- package/dist/public/assets/{ConversationPage-sj_rn4q0.js → ConversationPage-DWFsF6BB.js} +6 -6
- package/dist/public/assets/{DesktopDetachPreviewPage-C5c88SOX.js → DesktopDetachPreviewPage-DOgEjYEf.js} +1 -1
- package/dist/public/assets/DesktopModal-D_A8sgQU.js +1 -0
- package/dist/public/assets/DesktopWindowPage-DK7L7osV.js +2 -0
- package/dist/public/assets/FileContextPanel-BdCoubcJ.js +1 -0
- package/dist/public/assets/GitSidebar-BeZ0hj7A.js +6 -0
- package/dist/public/assets/MobileCreateSessionSheet-DfLMVu8q.js +1 -0
- package/dist/public/assets/MobileSheet-5kZ-w-gU.js +1 -0
- package/dist/public/assets/{MobileTopHeaderFrame-_I0t7cC_.js → MobileTopHeaderFrame-lcp2GscV.js} +1 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-C6JMiOq_.js +1 -0
- package/dist/public/assets/PluginAccessOverview-DGcKAMQl.js +1 -0
- package/dist/public/assets/PluginContainerPage-BlY-xJDh.js +1 -0
- package/dist/public/assets/PluginDetailPage-CAJ7LFpD.js +1 -0
- package/dist/public/assets/PluginsListPage-BxZG1NyT.js +1 -0
- package/dist/public/assets/{RelayConnectEntryPage-CMtDWyGS.js → RelayConnectEntryPage-CfNO_TIl.js} +1 -1
- package/dist/public/assets/ServerSettingsModal-by36Z_5k.js +1 -0
- package/dist/public/assets/SessionIndexPage-DkBp9Mqz.js +1 -0
- package/dist/public/assets/SettingsPage-C-ASmJAG.js +2 -0
- package/dist/public/assets/TerminalManagerPanel-NVZRxxmH.js +1 -0
- package/dist/public/assets/{TerminalPage-CBIKHI33.js → TerminalPage-C4LNoPBp.js} +3 -3
- package/dist/public/assets/TerminalRuntimeFallbackModal-Bzum5nZ0.js +1 -0
- package/dist/public/assets/ToolFilesPage-47zbdgTW.js +1 -0
- package/dist/public/assets/ToolGitPage-Fuk_b_jg.js +1 -0
- package/dist/public/assets/ToolProcessesPage-sWSMWD-9.js +1 -0
- package/dist/public/assets/ToolsHomePage-R1mZlbZi.js +1 -0
- package/dist/public/assets/WorkbenchLandingPage-CqmiFH2u.js +1 -0
- package/dist/public/assets/WorkbenchLayout-OFi6CWgH.js +244 -0
- package/dist/public/assets/WorkbenchModal-C7qoQElW.js +1 -0
- package/dist/public/assets/WorkbenchShellRoute-BAQe_E0O.js +1 -0
- package/dist/public/assets/WorkspaceDebugDetailPage-DhKa6e9y.js +1 -0
- package/dist/public/assets/WorkspaceDetailPage-BPsrFffw.js +1 -0
- package/dist/public/assets/WorkspaceHomePage-KAtqZOAb.js +1 -0
- package/dist/public/assets/{client-runtime-manager-CdJP7nUp.js → client-runtime-manager-wmCJZKYd.js} +1 -1
- package/dist/public/assets/file-tree-icon-Mg1DiBRX.js +590 -0
- package/dist/public/assets/{index-VVxfF0s5.css → index-C4t-vvqk.css} +1 -1
- package/dist/public/assets/index-CL97fwWB.js +42 -0
- package/dist/public/assets/{login-direct-candidate-resolver-C-mo698r.js → login-direct-candidate-resolver-BOAgTuUf.js} +1 -1
- package/dist/public/assets/plugin-permission-copy-Cq99cnzV.js +1 -0
- package/dist/public/assets/plugins-api-BQTV5DOp.js +1 -0
- package/dist/public/assets/{preferences-service-CnaTvZq2.js → preferences-service-DJxbEEeg.js} +1 -1
- package/dist/public/assets/realtime-client-CLafKzzJ.js +1 -0
- package/dist/public/assets/{relay-entry-D7OgZZN-.js → relay-entry-D-LfvdiX.js} +1 -1
- package/dist/public/assets/{terminal-runtime-meta-BCtAYB0E.js → terminal-runtime-meta-BJmy8dyK.js} +1 -1
- package/dist/public/assets/useRegisteredDebugTemplates-DQAWVdCo.js +1 -0
- package/dist/public/assets/workbench-navigation-MEzCSmsK.js +1 -0
- package/dist/public/index.html +2 -2
- package/dist/server/config/env.d.ts +1 -0
- package/dist/server/config/env.js +4 -0
- package/dist/server/config/env.js.map +1 -1
- package/dist/server/helpers/wechat-claw-runtime/modules/runtime-state-store.js +1 -1
- package/dist/server/helpers/wechat-claw-runtime/modules/runtime-state-store.js.map +1 -1
- package/dist/server/modules/channels/wechat-claw-client.d.ts +51 -0
- package/dist/server/modules/channels/wechat-claw-client.js +245 -0
- package/dist/server/modules/channels/wechat-claw-client.js.map +1 -0
- package/dist/server/modules/file/file-access-guard.d.ts +2 -0
- package/dist/server/modules/file/file-access-guard.js +24 -2
- package/dist/server/modules/file/file-access-guard.js.map +1 -1
- package/dist/server/modules/file/file-controller.d.ts +153 -1
- package/dist/server/modules/file/file-controller.js +215 -1
- package/dist/server/modules/file/file-controller.js.map +1 -1
- package/dist/server/modules/file/file-preview-link-service.d.ts +2 -0
- package/dist/server/modules/file/file-preview-link-service.js +5 -1
- package/dist/server/modules/file/file-preview-link-service.js.map +1 -1
- package/dist/server/modules/file/runtime/codingns-workspace-bridge.js +911 -0
- package/dist/server/modules/file/workspace-file-bridge-service.d.ts +126 -0
- package/dist/server/modules/file/workspace-file-bridge-service.js +471 -0
- package/dist/server/modules/file/workspace-file-bridge-service.js.map +1 -0
- package/dist/server/modules/file/workspace-file-bridge-watch-service.d.ts +42 -0
- package/dist/server/modules/file/workspace-file-bridge-watch-service.js +304 -0
- package/dist/server/modules/file/workspace-file-bridge-watch-service.js.map +1 -0
- package/dist/server/modules/model-switch/cc-switch-adapter.js +1 -1
- package/dist/server/modules/model-switch/cc-switch-adapter.js.map +1 -1
- package/dist/server/modules/plugins/plugin-controller.d.ts +131 -0
- package/dist/server/modules/plugins/plugin-controller.js +277 -0
- package/dist/server/modules/plugins/plugin-controller.js.map +1 -0
- package/dist/server/modules/plugins/plugin-file-gateway-service.d.ts +38 -0
- package/dist/server/modules/plugins/plugin-file-gateway-service.js +178 -0
- package/dist/server/modules/plugins/plugin-file-gateway-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-manifest.d.ts +8 -0
- package/dist/server/modules/plugins/plugin-manifest.js +420 -0
- package/dist/server/modules/plugins/plugin-manifest.js.map +1 -0
- package/dist/server/modules/plugins/plugin-permission-service.d.ts +49 -0
- package/dist/server/modules/plugins/plugin-permission-service.js +267 -0
- package/dist/server/modules/plugins/plugin-permission-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-process-runner.d.ts +21 -0
- package/dist/server/modules/plugins/plugin-process-runner.js +127 -0
- package/dist/server/modules/plugins/plugin-process-runner.js.map +1 -0
- package/dist/server/modules/plugins/plugin-registry-service.d.ts +41 -0
- package/dist/server/modules/plugins/plugin-registry-service.js +238 -0
- package/dist/server/modules/plugins/plugin-registry-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-runtime-service.d.ts +55 -0
- package/dist/server/modules/plugins/plugin-runtime-service.js +252 -0
- package/dist/server/modules/plugins/plugin-runtime-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-runtime-session-service.d.ts +21 -0
- package/dist/server/modules/plugins/plugin-runtime-session-service.js +83 -0
- package/dist/server/modules/plugins/plugin-runtime-session-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-scheduler-service.d.ts +31 -0
- package/dist/server/modules/plugins/plugin-scheduler-service.js +232 -0
- package/dist/server/modules/plugins/plugin-scheduler-service.js.map +1 -0
- package/dist/server/modules/plugins/plugin-static-service.d.ts +11 -0
- package/dist/server/modules/plugins/plugin-static-service.js +145 -0
- package/dist/server/modules/plugins/plugin-static-service.js.map +1 -0
- package/dist/server/modules/presentation/presentation-controller.d.ts +3 -0
- package/dist/server/modules/presentation/presentation-controller.js +11 -0
- package/dist/server/modules/presentation/presentation-controller.js.map +1 -1
- package/dist/server/modules/presentation/presentation-export-task-service.d.ts +6 -0
- package/dist/server/modules/presentation/presentation-export-task-service.js +52 -8
- package/dist/server/modules/presentation/presentation-export-task-service.js.map +1 -1
- package/dist/server/modules/presentation/presentation-pptx-export-service.js +200 -14
- package/dist/server/modules/presentation/presentation-pptx-export-service.js.map +1 -1
- package/dist/server/modules/presentation/presentation-renderer.d.ts +50 -0
- package/dist/server/modules/presentation/presentation-renderer.js +450 -37
- package/dist/server/modules/presentation/presentation-renderer.js.map +1 -1
- package/dist/server/modules/tasks/task-types.d.ts +2 -0
- package/dist/server/modules/tasks/task-types.js +2 -0
- package/dist/server/modules/tasks/task-types.js.map +1 -1
- package/dist/server/modules/terminal/runtime/terminal-log-writer-process.js +1 -1
- package/dist/server/modules/terminal/runtime/terminal-log-writer-process.js.map +1 -1
- package/dist/server/routes/files.js +40 -0
- package/dist/server/routes/files.js.map +1 -1
- package/dist/server/routes/plugins-public.d.ts +3 -0
- package/dist/server/routes/plugins-public.js +5 -0
- package/dist/server/routes/plugins-public.js.map +1 -0
- package/dist/server/routes/plugins.d.ts +3 -0
- package/dist/server/routes/plugins.js +19 -0
- package/dist/server/routes/plugins.js.map +1 -0
- package/dist/server/routes/presentation.js +1 -0
- package/dist/server/routes/presentation.js.map +1 -1
- package/dist/server/server/create-server.d.ts +20 -0
- package/dist/server/server/create-server.js +47 -1
- package/dist/server/server/create-server.js.map +1 -1
- package/dist/server/shared/http/error-handler.js +10 -6
- package/dist/server/shared/http/error-handler.js.map +1 -1
- package/dist/server/shared/runtime/better-sqlite3.d.ts +5 -0
- package/dist/server/shared/runtime/better-sqlite3.js +6 -0
- package/dist/server/shared/runtime/better-sqlite3.js.map +1 -0
- package/dist/server/storage/repositories/plugin-audit-event-repository.d.ts +8 -0
- package/dist/server/storage/repositories/plugin-audit-event-repository.js +49 -0
- package/dist/server/storage/repositories/plugin-audit-event-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-definition-repository.d.ts +10 -0
- package/dist/server/storage/repositories/plugin-definition-repository.js +84 -0
- package/dist/server/storage/repositories/plugin-definition-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-enablement-repository.d.ts +9 -0
- package/dist/server/storage/repositories/plugin-enablement-repository.js +74 -0
- package/dist/server/storage/repositories/plugin-enablement-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-permission-grant-repository.d.ts +12 -0
- package/dist/server/storage/repositories/plugin-permission-grant-repository.js +142 -0
- package/dist/server/storage/repositories/plugin-permission-grant-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-run-repository.d.ts +10 -0
- package/dist/server/storage/repositories/plugin-run-repository.js +111 -0
- package/dist/server/storage/repositories/plugin-run-repository.js.map +1 -0
- package/dist/server/storage/repositories/plugin-runtime-session-repository.d.ts +10 -0
- package/dist/server/storage/repositories/plugin-runtime-session-repository.js +86 -0
- package/dist/server/storage/repositories/plugin-runtime-session-repository.js.map +1 -0
- package/dist/server/storage/sqlite/client.d.ts +2 -2
- package/dist/server/storage/sqlite/client.js +250 -1
- package/dist/server/storage/sqlite/client.js.map +1 -1
- package/dist/server/storage/sqlite/schema.sql +140 -0
- package/dist/server/types/domain.d.ts +122 -0
- package/package.json +10 -3
- package/scripts/postinstall.mjs +248 -11
- package/vendor/better-sqlite3-win32-x64-node22/LICENSE +21 -0
- package/vendor/better-sqlite3-win32-x64-node22/README.md +12 -0
- package/vendor/better-sqlite3-win32-x64-node22/README.upstream.md +99 -0
- package/vendor/better-sqlite3-win32-x64-node22/binding.gyp +38 -0
- package/vendor/better-sqlite3-win32-x64-node22/build/Release/better_sqlite3.node +0 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/common.gypi +68 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/copy.js +31 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/defines.gypi +41 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/download.sh +122 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/patches/1208.patch +15 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3/sqlite3.c +265994 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3/sqlite3.h +13968 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3/sqlite3ext.h +730 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/sqlite3.gyp +80 -0
- package/vendor/better-sqlite3-win32-x64-node22/deps/test_extension.c +21 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/database.js +90 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/index.js +3 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/aggregate.js +43 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/backup.js +67 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/function.js +31 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/inspect.js +7 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/pragma.js +12 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/serialize.js +16 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/table.js +189 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/transaction.js +78 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/methods/wrappers.js +54 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/sqlite-error.js +20 -0
- package/vendor/better-sqlite3-win32-x64-node22/lib/util.js +12 -0
- package/vendor/better-sqlite3-win32-x64-node22/package.json +38 -0
- package/vendor/better-sqlite3-win32-x64-node22/scripts/verify-runtime.cjs +42 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/addon.cpp +47 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/better_sqlite3.cpp +74 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/backup.cpp +120 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/backup.hpp +36 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/database.cpp +417 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/database.hpp +103 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement-iterator.cpp +113 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement-iterator.hpp +50 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement.cpp +383 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/objects/statement.hpp +58 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/bind-map.cpp +73 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/binder.cpp +193 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/constants.cpp +172 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/custom-aggregate.cpp +121 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/custom-function.cpp +59 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/custom-table.cpp +409 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/data-converter.cpp +17 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/data.cpp +194 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/helpers.cpp +109 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/macros.cpp +83 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/query-macros.cpp +71 -0
- package/vendor/better-sqlite3-win32-x64-node22/src/util/row-builder.cpp +49 -0
- package/vendor/node-pty-fork/README.md +1 -0
- package/vendor/node-pty-fork/scripts/runtime-install-context.cjs +24 -0
- package/vendor/node-pty-fork/scripts/verify-runtime.cjs +8 -0
- package/vendor/node-pty-fork/scripts/verify-runtime.test.cjs +30 -0
- package/vendor-src/better-sqlite3-win32-x64-node22/README.md +12 -0
- package/dist/public/assets/App-B0q8uDA-.js +0 -30
- package/dist/public/assets/DesktopWindowPage-BdKUZrKG.js +0 -2
- package/dist/public/assets/FileContextPanel-lM5mBcfn.js +0 -1
- package/dist/public/assets/GitSidebar-CmXAhyjo.js +0 -6
- package/dist/public/assets/MobileCreateSessionSheet-CceV0-AH.js +0 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-DhaM9fgx.js +0 -1
- package/dist/public/assets/ServerSettingsModal-Rkgn3jft.js +0 -1
- package/dist/public/assets/SessionIndexPage-BOumP3ij.js +0 -1
- package/dist/public/assets/SettingsPage-vx_c-00-.js +0 -2
- package/dist/public/assets/TerminalManagerPanel-D9JHCS6d.js +0 -1
- package/dist/public/assets/TerminalRuntimeFallbackModal-W5NjqFEz.js +0 -1
- package/dist/public/assets/ToolFilesPage-DWtpaN_7.js +0 -1
- package/dist/public/assets/ToolGitPage-MpGXsw4_.js +0 -1
- package/dist/public/assets/ToolProcessesPage-B1jHQKhZ.js +0 -1
- package/dist/public/assets/ToolsHomePage-CJrn8ZFl.js +0 -1
- package/dist/public/assets/WorkbenchLandingPage-CJQ1V5U-.js +0 -1
- package/dist/public/assets/WorkbenchLayout-D48i71PU.js +0 -244
- package/dist/public/assets/WorkbenchModal-BYNuMIoV.js +0 -1
- package/dist/public/assets/WorkbenchShellRoute-CGKjy4J-.js +0 -1
- package/dist/public/assets/WorkspaceDebugDetailPage-DCAYgays.js +0 -1
- package/dist/public/assets/WorkspaceDetailPage-D5v-nUIi.js +0 -1
- package/dist/public/assets/WorkspaceHomePage-I5G1p5SR.js +0 -1
- package/dist/public/assets/file-tree-icon-BFwaPxKs.js +0 -590
- package/dist/public/assets/index-CjewzOUG.js +0 -42
- package/dist/public/assets/model-switch-api-Br0ivfe5.js +0 -1
- package/dist/public/assets/realtime-client-BlQRqVmm.js +0 -1
- package/dist/public/assets/useRegisteredDebugTemplates-CXmxu69X.js +0 -1
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
export class PluginPermissionGrantRepository {
|
|
2
|
+
db;
|
|
3
|
+
constructor(db) {
|
|
4
|
+
this.db = db;
|
|
5
|
+
}
|
|
6
|
+
create(record) {
|
|
7
|
+
this.db
|
|
8
|
+
.prepare(`INSERT INTO plugin_permission_grants (
|
|
9
|
+
id,
|
|
10
|
+
plugin_id,
|
|
11
|
+
workspace_id,
|
|
12
|
+
permission_key,
|
|
13
|
+
scope_type,
|
|
14
|
+
scope_path,
|
|
15
|
+
grant_mode,
|
|
16
|
+
granted_by_user_id,
|
|
17
|
+
runtime_session_id,
|
|
18
|
+
created_at,
|
|
19
|
+
expires_at,
|
|
20
|
+
revoked_at
|
|
21
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
22
|
+
.run(record.id, record.pluginId, record.workspaceId, record.permissionKey, record.scopeType, record.scopePath, record.grantMode, record.grantedByUserId, record.runtimeSessionId, record.createdAt, record.expiresAt, record.revokedAt);
|
|
23
|
+
return record;
|
|
24
|
+
}
|
|
25
|
+
findById(id) {
|
|
26
|
+
const row = this.db
|
|
27
|
+
.prepare(`SELECT
|
|
28
|
+
id,
|
|
29
|
+
plugin_id,
|
|
30
|
+
workspace_id,
|
|
31
|
+
permission_key,
|
|
32
|
+
scope_type,
|
|
33
|
+
scope_path,
|
|
34
|
+
grant_mode,
|
|
35
|
+
granted_by_user_id,
|
|
36
|
+
runtime_session_id,
|
|
37
|
+
created_at,
|
|
38
|
+
expires_at,
|
|
39
|
+
revoked_at
|
|
40
|
+
FROM plugin_permission_grants
|
|
41
|
+
WHERE id = ?`)
|
|
42
|
+
.get(id);
|
|
43
|
+
return row ? mapPluginPermissionGrantRow(row) : null;
|
|
44
|
+
}
|
|
45
|
+
listByPluginAndWorkspace(pluginId, workspaceId) {
|
|
46
|
+
return this.db
|
|
47
|
+
.prepare(`SELECT
|
|
48
|
+
id,
|
|
49
|
+
plugin_id,
|
|
50
|
+
workspace_id,
|
|
51
|
+
permission_key,
|
|
52
|
+
scope_type,
|
|
53
|
+
scope_path,
|
|
54
|
+
grant_mode,
|
|
55
|
+
granted_by_user_id,
|
|
56
|
+
runtime_session_id,
|
|
57
|
+
created_at,
|
|
58
|
+
expires_at,
|
|
59
|
+
revoked_at
|
|
60
|
+
FROM plugin_permission_grants
|
|
61
|
+
WHERE plugin_id = ?
|
|
62
|
+
AND workspace_id = ?
|
|
63
|
+
ORDER BY created_at DESC`)
|
|
64
|
+
.all(pluginId, workspaceId)
|
|
65
|
+
.map((row) => mapPluginPermissionGrantRow(row));
|
|
66
|
+
}
|
|
67
|
+
listActiveByPluginAndWorkspace(pluginId, workspaceId, referenceAt) {
|
|
68
|
+
return this.db
|
|
69
|
+
.prepare(`SELECT
|
|
70
|
+
id,
|
|
71
|
+
plugin_id,
|
|
72
|
+
workspace_id,
|
|
73
|
+
permission_key,
|
|
74
|
+
scope_type,
|
|
75
|
+
scope_path,
|
|
76
|
+
grant_mode,
|
|
77
|
+
granted_by_user_id,
|
|
78
|
+
runtime_session_id,
|
|
79
|
+
created_at,
|
|
80
|
+
expires_at,
|
|
81
|
+
revoked_at
|
|
82
|
+
FROM plugin_permission_grants
|
|
83
|
+
WHERE plugin_id = ?
|
|
84
|
+
AND workspace_id = ?
|
|
85
|
+
AND revoked_at IS NULL
|
|
86
|
+
AND (expires_at IS NULL OR expires_at > ?)
|
|
87
|
+
ORDER BY created_at DESC`)
|
|
88
|
+
.all(pluginId, workspaceId, referenceAt)
|
|
89
|
+
.map((row) => mapPluginPermissionGrantRow(row));
|
|
90
|
+
}
|
|
91
|
+
listActiveByPluginWorkspaceAndPermission(pluginId, workspaceId, permissionKey, referenceAt) {
|
|
92
|
+
return this.db
|
|
93
|
+
.prepare(`SELECT
|
|
94
|
+
id,
|
|
95
|
+
plugin_id,
|
|
96
|
+
workspace_id,
|
|
97
|
+
permission_key,
|
|
98
|
+
scope_type,
|
|
99
|
+
scope_path,
|
|
100
|
+
grant_mode,
|
|
101
|
+
granted_by_user_id,
|
|
102
|
+
runtime_session_id,
|
|
103
|
+
created_at,
|
|
104
|
+
expires_at,
|
|
105
|
+
revoked_at
|
|
106
|
+
FROM plugin_permission_grants
|
|
107
|
+
WHERE plugin_id = ?
|
|
108
|
+
AND workspace_id = ?
|
|
109
|
+
AND permission_key = ?
|
|
110
|
+
AND revoked_at IS NULL
|
|
111
|
+
AND (expires_at IS NULL OR expires_at > ?)
|
|
112
|
+
ORDER BY created_at DESC`)
|
|
113
|
+
.all(pluginId, workspaceId, permissionKey, referenceAt)
|
|
114
|
+
.map((row) => mapPluginPermissionGrantRow(row));
|
|
115
|
+
}
|
|
116
|
+
revokeById(id, revokedAt) {
|
|
117
|
+
this.db
|
|
118
|
+
.prepare(`UPDATE plugin_permission_grants
|
|
119
|
+
SET revoked_at = ?
|
|
120
|
+
WHERE id = ?
|
|
121
|
+
AND revoked_at IS NULL`)
|
|
122
|
+
.run(revokedAt, id);
|
|
123
|
+
return this.findById(id);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function mapPluginPermissionGrantRow(row) {
|
|
127
|
+
return {
|
|
128
|
+
id: row.id,
|
|
129
|
+
pluginId: row.plugin_id,
|
|
130
|
+
workspaceId: row.workspace_id,
|
|
131
|
+
permissionKey: row.permission_key,
|
|
132
|
+
scopeType: row.scope_type,
|
|
133
|
+
scopePath: row.scope_path,
|
|
134
|
+
grantMode: row.grant_mode,
|
|
135
|
+
grantedByUserId: row.granted_by_user_id,
|
|
136
|
+
runtimeSessionId: row.runtime_session_id,
|
|
137
|
+
createdAt: row.created_at,
|
|
138
|
+
expiresAt: row.expires_at,
|
|
139
|
+
revokedAt: row.revoked_at
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=plugin-permission-grant-repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-permission-grant-repository.js","sourceRoot":"","sources":["../../../../src/storage/repositories/plugin-permission-grant-repository.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type Database from "better-sqlite3";
|
|
2
|
+
import type { PluginRun } from "../../types/domain.js";
|
|
3
|
+
export declare class PluginRunRepository {
|
|
4
|
+
private readonly db;
|
|
5
|
+
constructor(db: Database.Database);
|
|
6
|
+
create(record: PluginRun): PluginRun;
|
|
7
|
+
update(record: PluginRun): PluginRun;
|
|
8
|
+
findById(id: string): PluginRun | null;
|
|
9
|
+
listByPluginId(pluginId: string, limit?: number): PluginRun[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export class PluginRunRepository {
|
|
2
|
+
db;
|
|
3
|
+
constructor(db) {
|
|
4
|
+
this.db = db;
|
|
5
|
+
}
|
|
6
|
+
create(record) {
|
|
7
|
+
this.db
|
|
8
|
+
.prepare(`INSERT INTO plugin_runs (
|
|
9
|
+
id,
|
|
10
|
+
plugin_id,
|
|
11
|
+
workspace_id,
|
|
12
|
+
runtime_session_id,
|
|
13
|
+
trigger_kind,
|
|
14
|
+
action_id,
|
|
15
|
+
status,
|
|
16
|
+
input_summary_json,
|
|
17
|
+
output_summary_json,
|
|
18
|
+
error_code,
|
|
19
|
+
error_message,
|
|
20
|
+
started_at,
|
|
21
|
+
finished_at,
|
|
22
|
+
created_at
|
|
23
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
24
|
+
.run(record.id, record.pluginId, record.workspaceId, record.runtimeSessionId, record.triggerKind, record.actionId, record.status, record.inputSummaryJson, record.outputSummaryJson, record.errorCode, record.errorMessage, record.startedAt, record.finishedAt, record.createdAt);
|
|
25
|
+
return record;
|
|
26
|
+
}
|
|
27
|
+
update(record) {
|
|
28
|
+
this.db
|
|
29
|
+
.prepare(`UPDATE plugin_runs
|
|
30
|
+
SET plugin_id = ?,
|
|
31
|
+
workspace_id = ?,
|
|
32
|
+
runtime_session_id = ?,
|
|
33
|
+
trigger_kind = ?,
|
|
34
|
+
action_id = ?,
|
|
35
|
+
status = ?,
|
|
36
|
+
input_summary_json = ?,
|
|
37
|
+
output_summary_json = ?,
|
|
38
|
+
error_code = ?,
|
|
39
|
+
error_message = ?,
|
|
40
|
+
started_at = ?,
|
|
41
|
+
finished_at = ?
|
|
42
|
+
WHERE id = ?`)
|
|
43
|
+
.run(record.pluginId, record.workspaceId, record.runtimeSessionId, record.triggerKind, record.actionId, record.status, record.inputSummaryJson, record.outputSummaryJson, record.errorCode, record.errorMessage, record.startedAt, record.finishedAt, record.id);
|
|
44
|
+
return record;
|
|
45
|
+
}
|
|
46
|
+
findById(id) {
|
|
47
|
+
const row = this.db
|
|
48
|
+
.prepare(`SELECT
|
|
49
|
+
id,
|
|
50
|
+
plugin_id,
|
|
51
|
+
workspace_id,
|
|
52
|
+
runtime_session_id,
|
|
53
|
+
trigger_kind,
|
|
54
|
+
action_id,
|
|
55
|
+
status,
|
|
56
|
+
input_summary_json,
|
|
57
|
+
output_summary_json,
|
|
58
|
+
error_code,
|
|
59
|
+
error_message,
|
|
60
|
+
started_at,
|
|
61
|
+
finished_at,
|
|
62
|
+
created_at
|
|
63
|
+
FROM plugin_runs
|
|
64
|
+
WHERE id = ?`)
|
|
65
|
+
.get(id);
|
|
66
|
+
return row ? mapPluginRunRow(row) : null;
|
|
67
|
+
}
|
|
68
|
+
listByPluginId(pluginId, limit = 50) {
|
|
69
|
+
return this.db
|
|
70
|
+
.prepare(`SELECT
|
|
71
|
+
id,
|
|
72
|
+
plugin_id,
|
|
73
|
+
workspace_id,
|
|
74
|
+
runtime_session_id,
|
|
75
|
+
trigger_kind,
|
|
76
|
+
action_id,
|
|
77
|
+
status,
|
|
78
|
+
input_summary_json,
|
|
79
|
+
output_summary_json,
|
|
80
|
+
error_code,
|
|
81
|
+
error_message,
|
|
82
|
+
started_at,
|
|
83
|
+
finished_at,
|
|
84
|
+
created_at
|
|
85
|
+
FROM plugin_runs
|
|
86
|
+
WHERE plugin_id = ?
|
|
87
|
+
ORDER BY created_at DESC
|
|
88
|
+
LIMIT ?`)
|
|
89
|
+
.all(pluginId, limit)
|
|
90
|
+
.map((row) => mapPluginRunRow(row));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function mapPluginRunRow(row) {
|
|
94
|
+
return {
|
|
95
|
+
id: row.id,
|
|
96
|
+
pluginId: row.plugin_id,
|
|
97
|
+
workspaceId: row.workspace_id,
|
|
98
|
+
runtimeSessionId: row.runtime_session_id,
|
|
99
|
+
triggerKind: row.trigger_kind,
|
|
100
|
+
actionId: row.action_id,
|
|
101
|
+
status: row.status,
|
|
102
|
+
inputSummaryJson: row.input_summary_json,
|
|
103
|
+
outputSummaryJson: row.output_summary_json,
|
|
104
|
+
errorCode: row.error_code,
|
|
105
|
+
errorMessage: row.error_message,
|
|
106
|
+
startedAt: row.started_at,
|
|
107
|
+
finishedAt: row.finished_at,
|
|
108
|
+
createdAt: row.created_at
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=plugin-run-repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-run-repository.js","sourceRoot":"","sources":["../../../../src/storage/repositories/plugin-run-repository.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,mBAAmB;IACD;IAA7B,YAA6B,EAAqB;QAArB,OAAE,GAAF,EAAE,CAAmB;IAAG,CAAC;IAEtD,MAAM,CAAC,MAAiB;QACtB,IAAI,CAAC,EAAE;aACJ,OAAO,CACN;;;;;;;;;;;;;;;6DAeqD,CACtD;aACA,GAAG,CACF,MAAM,CAAC,EAAE,EACT,MAAM,CAAC,QAAQ,EACf,MAAM,CAAC,WAAW,EAClB,MAAM,CAAC,gBAAgB,EACvB,MAAM,CAAC,WAAW,EAClB,MAAM,CAAC,QAAQ,EACf,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,gBAAgB,EACvB,MAAM,CAAC,iBAAiB,EACxB,MAAM,CAAC,SAAS,EAChB,MAAM,CAAC,YAAY,EACnB,MAAM,CAAC,SAAS,EAChB,MAAM,CAAC,UAAU,EACjB,MAAM,CAAC,SAAS,CACjB,CAAC;QAEJ,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,MAAiB;QACtB,IAAI,CAAC,EAAE;aACJ,OAAO,CACN;;;;;;;;;;;;;sBAac,CACf;aACA,GAAG,CACF,MAAM,CAAC,QAAQ,EACf,MAAM,CAAC,WAAW,EAClB,MAAM,CAAC,gBAAgB,EACvB,MAAM,CAAC,WAAW,EAClB,MAAM,CAAC,QAAQ,EACf,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,gBAAgB,EACvB,MAAM,CAAC,iBAAiB,EACxB,MAAM,CAAC,SAAS,EAChB,MAAM,CAAC,YAAY,EACnB,MAAM,CAAC,SAAS,EAChB,MAAM,CAAC,UAAU,EACjB,MAAM,CAAC,EAAE,CACV,CAAC;QAEJ,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,QAAQ,CAAC,EAAU;QACjB,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE;aAChB,OAAO,CACN;;;;;;;;;;;;;;;;sBAgBc,CACf;aACA,GAAG,CAAC,EAAE,CAA6B,CAAC;QAEvC,OAAO,GAAG,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3C,CAAC;IAED,cAAc,CAAC,QAAgB,EAAE,KAAK,GAAG,EAAE;QACzC,OAAO,IAAI,CAAC,EAAE;aACX,OAAO,CACN;;;;;;;;;;;;;;;;;;iBAkBS,CACV;aACA,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC;aACpB,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,eAAe,CAAC,GAAmB,CAAC,CAAC,CAAC;IACxD,CAAC;CACF;AAmBD,SAAS,eAAe,CAAC,GAAiB;IACxC,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,QAAQ,EAAE,GAAG,CAAC,SAAS;QACvB,WAAW,EAAE,GAAG,CAAC,YAAY;QAC7B,gBAAgB,EAAE,GAAG,CAAC,kBAAkB;QACxC,WAAW,EAAE,GAAG,CAAC,YAAY;QAC7B,QAAQ,EAAE,GAAG,CAAC,SAAS;QACvB,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,gBAAgB,EAAE,GAAG,CAAC,kBAAkB;QACxC,iBAAiB,EAAE,GAAG,CAAC,mBAAmB;QAC1C,SAAS,EAAE,GAAG,CAAC,UAAU;QACzB,YAAY,EAAE,GAAG,CAAC,aAAa;QAC/B,SAAS,EAAE,GAAG,CAAC,UAAU;QACzB,UAAU,EAAE,GAAG,CAAC,WAAW;QAC3B,SAAS,EAAE,GAAG,CAAC,UAAU;KAC1B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type Database from "better-sqlite3";
|
|
2
|
+
import type { PluginRuntimeSession } from "../../types/domain.js";
|
|
3
|
+
export declare class PluginRuntimeSessionRepository {
|
|
4
|
+
private readonly db;
|
|
5
|
+
constructor(db: Database.Database);
|
|
6
|
+
create(record: PluginRuntimeSession): PluginRuntimeSession;
|
|
7
|
+
update(record: PluginRuntimeSession): PluginRuntimeSession;
|
|
8
|
+
findById(id: string): PluginRuntimeSession | null;
|
|
9
|
+
listByPluginId(pluginId: string, limit?: number): PluginRuntimeSession[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export class PluginRuntimeSessionRepository {
|
|
2
|
+
db;
|
|
3
|
+
constructor(db) {
|
|
4
|
+
this.db = db;
|
|
5
|
+
}
|
|
6
|
+
create(record) {
|
|
7
|
+
this.db
|
|
8
|
+
.prepare(`INSERT INTO plugin_runtime_sessions (
|
|
9
|
+
id,
|
|
10
|
+
plugin_id,
|
|
11
|
+
workspace_id,
|
|
12
|
+
opened_by_user_id,
|
|
13
|
+
source,
|
|
14
|
+
status,
|
|
15
|
+
created_at,
|
|
16
|
+
updated_at,
|
|
17
|
+
closed_at
|
|
18
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
19
|
+
.run(record.id, record.pluginId, record.workspaceId, record.openedByUserId, record.source, record.status, record.createdAt, record.updatedAt, record.closedAt);
|
|
20
|
+
return record;
|
|
21
|
+
}
|
|
22
|
+
update(record) {
|
|
23
|
+
this.db
|
|
24
|
+
.prepare(`UPDATE plugin_runtime_sessions
|
|
25
|
+
SET plugin_id = ?,
|
|
26
|
+
workspace_id = ?,
|
|
27
|
+
opened_by_user_id = ?,
|
|
28
|
+
source = ?,
|
|
29
|
+
status = ?,
|
|
30
|
+
updated_at = ?,
|
|
31
|
+
closed_at = ?
|
|
32
|
+
WHERE id = ?`)
|
|
33
|
+
.run(record.pluginId, record.workspaceId, record.openedByUserId, record.source, record.status, record.updatedAt, record.closedAt, record.id);
|
|
34
|
+
return record;
|
|
35
|
+
}
|
|
36
|
+
findById(id) {
|
|
37
|
+
const row = this.db
|
|
38
|
+
.prepare(`SELECT
|
|
39
|
+
id,
|
|
40
|
+
plugin_id,
|
|
41
|
+
workspace_id,
|
|
42
|
+
opened_by_user_id,
|
|
43
|
+
source,
|
|
44
|
+
status,
|
|
45
|
+
created_at,
|
|
46
|
+
updated_at,
|
|
47
|
+
closed_at
|
|
48
|
+
FROM plugin_runtime_sessions
|
|
49
|
+
WHERE id = ?`)
|
|
50
|
+
.get(id);
|
|
51
|
+
return row ? mapPluginRuntimeSessionRow(row) : null;
|
|
52
|
+
}
|
|
53
|
+
listByPluginId(pluginId, limit = 50) {
|
|
54
|
+
return this.db
|
|
55
|
+
.prepare(`SELECT
|
|
56
|
+
id,
|
|
57
|
+
plugin_id,
|
|
58
|
+
workspace_id,
|
|
59
|
+
opened_by_user_id,
|
|
60
|
+
source,
|
|
61
|
+
status,
|
|
62
|
+
created_at,
|
|
63
|
+
updated_at,
|
|
64
|
+
closed_at
|
|
65
|
+
FROM plugin_runtime_sessions
|
|
66
|
+
WHERE plugin_id = ?
|
|
67
|
+
ORDER BY created_at DESC
|
|
68
|
+
LIMIT ?`)
|
|
69
|
+
.all(pluginId, limit)
|
|
70
|
+
.map((row) => mapPluginRuntimeSessionRow(row));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function mapPluginRuntimeSessionRow(row) {
|
|
74
|
+
return {
|
|
75
|
+
id: row.id,
|
|
76
|
+
pluginId: row.plugin_id,
|
|
77
|
+
workspaceId: row.workspace_id,
|
|
78
|
+
openedByUserId: row.opened_by_user_id,
|
|
79
|
+
source: row.source,
|
|
80
|
+
status: row.status,
|
|
81
|
+
createdAt: row.created_at,
|
|
82
|
+
updatedAt: row.updated_at,
|
|
83
|
+
closedAt: row.closed_at
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=plugin-runtime-session-repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-runtime-session-repository.js","sourceRoot":"","sources":["../../../../src/storage/repositories/plugin-runtime-session-repository.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,8BAA8B;IACZ;IAA7B,YAA6B,EAAqB;QAArB,OAAE,GAAF,EAAE,CAAmB;IAAG,CAAC;IAEtD,MAAM,CAAC,MAA4B;QACjC,IAAI,CAAC,EAAE;aACJ,OAAO,CACN;;;;;;;;;;8CAUsC,CACvC;aACA,GAAG,CACF,MAAM,CAAC,EAAE,EACT,MAAM,CAAC,QAAQ,EACf,MAAM,CAAC,WAAW,EAClB,MAAM,CAAC,cAAc,EACrB,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,SAAS,EAChB,MAAM,CAAC,SAAS,EAChB,MAAM,CAAC,QAAQ,CAChB,CAAC;QAEJ,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,MAA4B;QACjC,IAAI,CAAC,EAAE;aACJ,OAAO,CACN;;;;;;;;sBAQc,CACf;aACA,GAAG,CACF,MAAM,CAAC,QAAQ,EACf,MAAM,CAAC,WAAW,EAClB,MAAM,CAAC,cAAc,EACrB,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,SAAS,EAChB,MAAM,CAAC,QAAQ,EACf,MAAM,CAAC,EAAE,CACV,CAAC;QAEJ,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,QAAQ,CAAC,EAAU;QACjB,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE;aAChB,OAAO,CACN;;;;;;;;;;;sBAWc,CACf;aACA,GAAG,CAAC,EAAE,CAAwC,CAAC;QAElD,OAAO,GAAG,CAAC,CAAC,CAAC,0BAA0B,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACtD,CAAC;IAED,cAAc,CAAC,QAAgB,EAAE,KAAK,GAAG,EAAE;QACzC,OAAO,IAAI,CAAC,EAAE;aACX,OAAO,CACN;;;;;;;;;;;;;iBAaS,CACV;aACA,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC;aACpB,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,0BAA0B,CAAC,GAA8B,CAAC,CAAC,CAAC;IAC9E,CAAC;CACF;AAcD,SAAS,0BAA0B,CAAC,GAA4B;IAC9D,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,QAAQ,EAAE,GAAG,CAAC,SAAS;QACvB,WAAW,EAAE,GAAG,CAAC,YAAY;QAC7B,cAAc,EAAE,GAAG,CAAC,iBAAiB;QACrC,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,SAAS,EAAE,GAAG,CAAC,UAAU;QACzB,SAAS,EAAE,GAAG,CAAC,UAAU;QACzB,QAAQ,EAAE,GAAG,CAAC,SAAS;KACxB,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { BetterSqliteDatabase } from "../../shared/runtime/better-sqlite3.js";
|
|
2
2
|
export interface DatabaseClient {
|
|
3
|
-
db:
|
|
3
|
+
db: BetterSqliteDatabase;
|
|
4
4
|
close: () => void;
|
|
5
5
|
}
|
|
6
6
|
export declare function createDatabaseClient(databasePath: string): DatabaseClient;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import Database from "better-sqlite3";
|
|
3
|
+
import Database from "../../shared/runtime/better-sqlite3.js";
|
|
4
4
|
export function createDatabaseClient(databasePath) {
|
|
5
5
|
if (databasePath !== ":memory:") {
|
|
6
6
|
fs.mkdirSync(path.dirname(databasePath), { recursive: true });
|
|
@@ -51,6 +51,10 @@ export function createDatabaseClient(databasePath) {
|
|
|
51
51
|
ensureAssistantAutomationSchema(db);
|
|
52
52
|
ensureAssistantSandboxSchema(db);
|
|
53
53
|
ensureDocumentTemplateSchema(db);
|
|
54
|
+
ensurePluginRegistrySchema(db);
|
|
55
|
+
ensurePluginRuntimeSessionSchema(db);
|
|
56
|
+
ensurePluginPermissionGrantSchema(db);
|
|
57
|
+
ensurePluginRunSchema(db);
|
|
54
58
|
ensureOpsTargetWorkspaceSchema(db);
|
|
55
59
|
ensureButlerInboxSchema(db);
|
|
56
60
|
ensureButlerFollowUpTaskSchema(db);
|
|
@@ -244,6 +248,251 @@ function ensureAuthDeviceSchema(db) {
|
|
|
244
248
|
db.exec("ALTER TABLE auth_devices ADD COLUMN user_agent TEXT");
|
|
245
249
|
}
|
|
246
250
|
}
|
|
251
|
+
function ensurePluginRegistrySchema(db) {
|
|
252
|
+
db.exec(`
|
|
253
|
+
CREATE TABLE IF NOT EXISTS plugin_definitions (
|
|
254
|
+
id TEXT PRIMARY KEY,
|
|
255
|
+
version TEXT NOT NULL,
|
|
256
|
+
name TEXT NOT NULL,
|
|
257
|
+
install_root TEXT NOT NULL,
|
|
258
|
+
manifest_json TEXT NOT NULL,
|
|
259
|
+
has_frontend INTEGER NOT NULL DEFAULT 0 CHECK (has_frontend IN (0, 1)),
|
|
260
|
+
has_backend INTEGER NOT NULL DEFAULT 0 CHECK (has_backend IN (0, 1)),
|
|
261
|
+
created_at TEXT NOT NULL,
|
|
262
|
+
updated_at TEXT NOT NULL
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
CREATE INDEX IF NOT EXISTS idx_plugin_definitions_name
|
|
266
|
+
ON plugin_definitions(name);
|
|
267
|
+
CREATE INDEX IF NOT EXISTS idx_plugin_definitions_updated_at
|
|
268
|
+
ON plugin_definitions(updated_at DESC);
|
|
269
|
+
|
|
270
|
+
CREATE TABLE IF NOT EXISTS plugin_enablements (
|
|
271
|
+
plugin_id TEXT PRIMARY KEY,
|
|
272
|
+
enabled INTEGER NOT NULL DEFAULT 0 CHECK (enabled IN (0, 1)),
|
|
273
|
+
enabled_by_user_id TEXT,
|
|
274
|
+
enabled_at TEXT,
|
|
275
|
+
disabled_by_user_id TEXT,
|
|
276
|
+
disabled_at TEXT,
|
|
277
|
+
reason TEXT,
|
|
278
|
+
updated_at TEXT NOT NULL,
|
|
279
|
+
FOREIGN KEY (plugin_id) REFERENCES plugin_definitions(id) ON DELETE CASCADE,
|
|
280
|
+
FOREIGN KEY (enabled_by_user_id) REFERENCES auth_users(id),
|
|
281
|
+
FOREIGN KEY (disabled_by_user_id) REFERENCES auth_users(id)
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
CREATE INDEX IF NOT EXISTS idx_plugin_enablements_enabled
|
|
285
|
+
ON plugin_enablements(enabled);
|
|
286
|
+
|
|
287
|
+
CREATE TABLE IF NOT EXISTS plugin_audit_events (
|
|
288
|
+
id TEXT PRIMARY KEY,
|
|
289
|
+
plugin_id TEXT NOT NULL,
|
|
290
|
+
workspace_id TEXT,
|
|
291
|
+
event_type TEXT NOT NULL CHECK (
|
|
292
|
+
event_type IN (
|
|
293
|
+
'plugin.registered',
|
|
294
|
+
'plugin.registration_failed',
|
|
295
|
+
'plugin.enabled',
|
|
296
|
+
'plugin.disabled',
|
|
297
|
+
'plugin.permission_granted',
|
|
298
|
+
'plugin.permission_revoked',
|
|
299
|
+
'plugin.permission_denied',
|
|
300
|
+
'plugin.action_invoked',
|
|
301
|
+
'plugin.action_rejected',
|
|
302
|
+
'plugin.schedule_triggered',
|
|
303
|
+
'plugin.schedule_retry_scheduled',
|
|
304
|
+
'plugin.schedule_skipped',
|
|
305
|
+
'plugin.frontend_loaded',
|
|
306
|
+
'plugin.scope_rejected',
|
|
307
|
+
'plugin.desktop_call'
|
|
308
|
+
)
|
|
309
|
+
),
|
|
310
|
+
actor_user_id TEXT,
|
|
311
|
+
payload_json TEXT NOT NULL,
|
|
312
|
+
created_at TEXT NOT NULL,
|
|
313
|
+
FOREIGN KEY (workspace_id) REFERENCES workspaces(id),
|
|
314
|
+
FOREIGN KEY (actor_user_id) REFERENCES auth_users(id)
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
CREATE INDEX IF NOT EXISTS idx_plugin_audit_events_plugin_id
|
|
318
|
+
ON plugin_audit_events(plugin_id, created_at DESC);
|
|
319
|
+
`);
|
|
320
|
+
ensurePluginAuditEventForeignKeyCompatibility(db);
|
|
321
|
+
}
|
|
322
|
+
function ensurePluginAuditEventForeignKeyCompatibility(db) {
|
|
323
|
+
if (!tableExists(db, "plugin_audit_events")) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
const table = db
|
|
327
|
+
.prepare(`SELECT sql
|
|
328
|
+
FROM sqlite_master
|
|
329
|
+
WHERE type = 'table'
|
|
330
|
+
AND name = 'plugin_audit_events'
|
|
331
|
+
LIMIT 1`)
|
|
332
|
+
.get();
|
|
333
|
+
const definition = table?.sql ?? "";
|
|
334
|
+
if (!definition.includes("REFERENCES plugin_definitions")) {
|
|
335
|
+
const supportsNewEvents = definition.includes("'plugin.permission_granted'") &&
|
|
336
|
+
definition.includes("'plugin.permission_revoked'") &&
|
|
337
|
+
definition.includes("'plugin.permission_denied'") &&
|
|
338
|
+
definition.includes("'plugin.schedule_triggered'") &&
|
|
339
|
+
definition.includes("'plugin.schedule_retry_scheduled'") &&
|
|
340
|
+
definition.includes("'plugin.schedule_skipped'");
|
|
341
|
+
if (supportsNewEvents) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
db.exec(`
|
|
346
|
+
ALTER TABLE plugin_audit_events RENAME TO plugin_audit_events_legacy;
|
|
347
|
+
|
|
348
|
+
CREATE TABLE plugin_audit_events (
|
|
349
|
+
id TEXT PRIMARY KEY,
|
|
350
|
+
plugin_id TEXT NOT NULL,
|
|
351
|
+
workspace_id TEXT,
|
|
352
|
+
event_type TEXT NOT NULL CHECK (
|
|
353
|
+
event_type IN (
|
|
354
|
+
'plugin.registered',
|
|
355
|
+
'plugin.registration_failed',
|
|
356
|
+
'plugin.enabled',
|
|
357
|
+
'plugin.disabled',
|
|
358
|
+
'plugin.permission_granted',
|
|
359
|
+
'plugin.permission_revoked',
|
|
360
|
+
'plugin.permission_denied',
|
|
361
|
+
'plugin.action_invoked',
|
|
362
|
+
'plugin.action_rejected',
|
|
363
|
+
'plugin.schedule_triggered',
|
|
364
|
+
'plugin.schedule_retry_scheduled',
|
|
365
|
+
'plugin.schedule_skipped',
|
|
366
|
+
'plugin.frontend_loaded',
|
|
367
|
+
'plugin.scope_rejected',
|
|
368
|
+
'plugin.desktop_call'
|
|
369
|
+
)
|
|
370
|
+
),
|
|
371
|
+
actor_user_id TEXT,
|
|
372
|
+
payload_json TEXT NOT NULL,
|
|
373
|
+
created_at TEXT NOT NULL,
|
|
374
|
+
FOREIGN KEY (workspace_id) REFERENCES workspaces(id),
|
|
375
|
+
FOREIGN KEY (actor_user_id) REFERENCES auth_users(id)
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
INSERT INTO plugin_audit_events (
|
|
379
|
+
id,
|
|
380
|
+
plugin_id,
|
|
381
|
+
workspace_id,
|
|
382
|
+
event_type,
|
|
383
|
+
actor_user_id,
|
|
384
|
+
payload_json,
|
|
385
|
+
created_at
|
|
386
|
+
)
|
|
387
|
+
SELECT
|
|
388
|
+
id,
|
|
389
|
+
plugin_id,
|
|
390
|
+
workspace_id,
|
|
391
|
+
event_type,
|
|
392
|
+
actor_user_id,
|
|
393
|
+
payload_json,
|
|
394
|
+
created_at
|
|
395
|
+
FROM plugin_audit_events_legacy;
|
|
396
|
+
|
|
397
|
+
DROP TABLE plugin_audit_events_legacy;
|
|
398
|
+
|
|
399
|
+
CREATE INDEX IF NOT EXISTS idx_plugin_audit_events_plugin_id
|
|
400
|
+
ON plugin_audit_events(plugin_id, created_at DESC);
|
|
401
|
+
`);
|
|
402
|
+
}
|
|
403
|
+
function ensurePluginRuntimeSessionSchema(db) {
|
|
404
|
+
db.exec(`
|
|
405
|
+
CREATE TABLE IF NOT EXISTS plugin_runtime_sessions (
|
|
406
|
+
id TEXT PRIMARY KEY,
|
|
407
|
+
plugin_id TEXT NOT NULL,
|
|
408
|
+
workspace_id TEXT NOT NULL,
|
|
409
|
+
opened_by_user_id TEXT NOT NULL,
|
|
410
|
+
source TEXT NOT NULL CHECK (source IN ('frontend', 'assistant', 'cli')),
|
|
411
|
+
status TEXT NOT NULL CHECK (status IN ('active', 'closed')),
|
|
412
|
+
created_at TEXT NOT NULL,
|
|
413
|
+
updated_at TEXT NOT NULL,
|
|
414
|
+
closed_at TEXT,
|
|
415
|
+
FOREIGN KEY (plugin_id) REFERENCES plugin_definitions(id) ON DELETE CASCADE,
|
|
416
|
+
FOREIGN KEY (workspace_id) REFERENCES workspaces(id),
|
|
417
|
+
FOREIGN KEY (opened_by_user_id) REFERENCES auth_users(id)
|
|
418
|
+
);
|
|
419
|
+
|
|
420
|
+
CREATE INDEX IF NOT EXISTS idx_plugin_runtime_sessions_plugin_id
|
|
421
|
+
ON plugin_runtime_sessions(plugin_id, created_at DESC);
|
|
422
|
+
CREATE INDEX IF NOT EXISTS idx_plugin_runtime_sessions_workspace_id
|
|
423
|
+
ON plugin_runtime_sessions(workspace_id, created_at DESC);
|
|
424
|
+
CREATE INDEX IF NOT EXISTS idx_plugin_runtime_sessions_status
|
|
425
|
+
ON plugin_runtime_sessions(status, updated_at DESC);
|
|
426
|
+
`);
|
|
427
|
+
}
|
|
428
|
+
function ensurePluginPermissionGrantSchema(db) {
|
|
429
|
+
db.exec(`
|
|
430
|
+
CREATE TABLE IF NOT EXISTS plugin_permission_grants (
|
|
431
|
+
id TEXT PRIMARY KEY,
|
|
432
|
+
plugin_id TEXT NOT NULL,
|
|
433
|
+
workspace_id TEXT NOT NULL,
|
|
434
|
+
permission_key TEXT NOT NULL CHECK (
|
|
435
|
+
permission_key IN (
|
|
436
|
+
'workspace.read_file',
|
|
437
|
+
'workspace.list_dir',
|
|
438
|
+
'workspace.write_file',
|
|
439
|
+
'desktop.open_file',
|
|
440
|
+
'desktop.reveal_in_file_manager'
|
|
441
|
+
)
|
|
442
|
+
),
|
|
443
|
+
scope_type TEXT NOT NULL CHECK (scope_type IN ('workspace', 'directory', 'file')),
|
|
444
|
+
scope_path TEXT,
|
|
445
|
+
grant_mode TEXT NOT NULL CHECK (grant_mode IN ('once', 'session', 'persistent')),
|
|
446
|
+
granted_by_user_id TEXT NOT NULL,
|
|
447
|
+
runtime_session_id TEXT,
|
|
448
|
+
created_at TEXT NOT NULL,
|
|
449
|
+
expires_at TEXT,
|
|
450
|
+
revoked_at TEXT,
|
|
451
|
+
FOREIGN KEY (plugin_id) REFERENCES plugin_definitions(id) ON DELETE CASCADE,
|
|
452
|
+
FOREIGN KEY (workspace_id) REFERENCES workspaces(id),
|
|
453
|
+
FOREIGN KEY (granted_by_user_id) REFERENCES auth_users(id),
|
|
454
|
+
FOREIGN KEY (runtime_session_id) REFERENCES plugin_runtime_sessions(id)
|
|
455
|
+
);
|
|
456
|
+
|
|
457
|
+
CREATE INDEX IF NOT EXISTS idx_plugin_permission_grants_plugin_workspace
|
|
458
|
+
ON plugin_permission_grants(plugin_id, workspace_id, permission_key, created_at DESC);
|
|
459
|
+
CREATE INDEX IF NOT EXISTS idx_plugin_permission_grants_runtime_session
|
|
460
|
+
ON plugin_permission_grants(runtime_session_id, created_at DESC);
|
|
461
|
+
CREATE INDEX IF NOT EXISTS idx_plugin_permission_grants_active
|
|
462
|
+
ON plugin_permission_grants(plugin_id, workspace_id, revoked_at, expires_at);
|
|
463
|
+
`);
|
|
464
|
+
}
|
|
465
|
+
function ensurePluginRunSchema(db) {
|
|
466
|
+
db.exec(`
|
|
467
|
+
CREATE TABLE IF NOT EXISTS plugin_runs (
|
|
468
|
+
id TEXT PRIMARY KEY,
|
|
469
|
+
plugin_id TEXT NOT NULL,
|
|
470
|
+
workspace_id TEXT NOT NULL,
|
|
471
|
+
runtime_session_id TEXT,
|
|
472
|
+
trigger_kind TEXT NOT NULL CHECK (trigger_kind IN ('frontend', 'cli', 'schedule', 'assistant')),
|
|
473
|
+
action_id TEXT,
|
|
474
|
+
status TEXT NOT NULL CHECK (status IN ('queued', 'running', 'succeeded', 'failed', 'rejected', 'cancelled')),
|
|
475
|
+
input_summary_json TEXT,
|
|
476
|
+
output_summary_json TEXT,
|
|
477
|
+
error_code TEXT,
|
|
478
|
+
error_message TEXT,
|
|
479
|
+
started_at TEXT,
|
|
480
|
+
finished_at TEXT,
|
|
481
|
+
created_at TEXT NOT NULL,
|
|
482
|
+
FOREIGN KEY (workspace_id) REFERENCES workspaces(id),
|
|
483
|
+
FOREIGN KEY (runtime_session_id) REFERENCES plugin_runtime_sessions(id)
|
|
484
|
+
);
|
|
485
|
+
|
|
486
|
+
CREATE INDEX IF NOT EXISTS idx_plugin_runs_plugin_id
|
|
487
|
+
ON plugin_runs(plugin_id, created_at DESC);
|
|
488
|
+
`);
|
|
489
|
+
const columns = db
|
|
490
|
+
.prepare("PRAGMA table_info(plugin_runs)")
|
|
491
|
+
.all();
|
|
492
|
+
if (!columns.some((column) => column.name === "runtime_session_id")) {
|
|
493
|
+
db.exec("ALTER TABLE plugin_runs ADD COLUMN runtime_session_id TEXT");
|
|
494
|
+
}
|
|
495
|
+
}
|
|
247
496
|
function ensureAuthLoginAttemptSchema(db) {
|
|
248
497
|
const columns = db
|
|
249
498
|
.prepare("PRAGMA table_info(auth_login_attempts)")
|