@aurora-foundation/obsidian-next 0.4.7 → 0.4.9

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.
Files changed (232) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/LICENSE +628 -190
  3. package/README.md +23 -9
  4. package/dist/auditLog-6WDBDNYL.js +8 -0
  5. package/dist/auditLog-HGPVDSDC.js +8 -0
  6. package/dist/auditLog-TDIKFBM4.js +8 -0
  7. package/dist/auditLog-XC2KY3ZZ.js +8 -0
  8. package/dist/chunk-2I235WNB.js +133 -0
  9. package/dist/chunk-2JWDGXTR.js +42 -0
  10. package/dist/chunk-2NOB6W2B.js +133 -0
  11. package/dist/chunk-3LFKVKKL.js +7199 -0
  12. package/dist/chunk-3U6WHPDX.js +4695 -0
  13. package/dist/chunk-3UCL6RYE.js +7272 -0
  14. package/dist/chunk-4GN2UQLI.js +130 -0
  15. package/dist/chunk-4MW33MZD.js +516 -0
  16. package/dist/chunk-4PUJBUKZ.js +4716 -0
  17. package/dist/chunk-4QHK6H6O.js +130 -0
  18. package/dist/chunk-55CQIHCO.js +133 -0
  19. package/dist/chunk-5LWINFWI.js +676 -0
  20. package/dist/chunk-5OKGLNQW.js +439 -0
  21. package/dist/chunk-5T6ETZEO.js +6183 -0
  22. package/dist/chunk-5WGIFUVL.js +4234 -0
  23. package/dist/chunk-66EW47T3.js +4237 -0
  24. package/dist/chunk-6TXUOTT2.js +581 -0
  25. package/dist/chunk-6YUYSYDA.js +130 -0
  26. package/dist/chunk-74VPNFMX.js +133 -0
  27. package/dist/chunk-77CGJRGV.js +6188 -0
  28. package/dist/chunk-7DS3VT4C.js +7135 -0
  29. package/dist/chunk-7FHX3VBT.js +133 -0
  30. package/dist/chunk-7MHF56YU.js +6178 -0
  31. package/dist/chunk-ABLPMV7G.js +133 -0
  32. package/dist/chunk-B77K6OQZ.js +687 -0
  33. package/dist/chunk-BKOXH66O.js +133 -0
  34. package/dist/chunk-BPP76UN2.js +130 -0
  35. package/dist/chunk-C4D56GRC.js +5936 -0
  36. package/dist/chunk-CCDPY4WE.js +370 -0
  37. package/dist/chunk-CHNVBJN3.js +7272 -0
  38. package/dist/chunk-CKBZI576.js +7229 -0
  39. package/dist/chunk-CW5HBSJ2.js +7198 -0
  40. package/dist/chunk-DGHDJEY7.js +133 -0
  41. package/dist/chunk-DPNIQWKZ.js +439 -0
  42. package/dist/chunk-DU4T3V2T.js +214 -0
  43. package/dist/chunk-DV3WFKNB.js +4679 -0
  44. package/dist/chunk-DZI2OVN2.js +516 -0
  45. package/dist/chunk-E45VILML.js +7198 -0
  46. package/dist/chunk-ECEUUYXC.js +7199 -0
  47. package/dist/chunk-EJRRSHPW.js +685 -0
  48. package/dist/chunk-EMBMLZFE.js +370 -0
  49. package/dist/chunk-EPG5V5OO.js +285 -0
  50. package/dist/chunk-F2R4HXXW.js +130 -0
  51. package/dist/chunk-FK6N66ES.js +581 -0
  52. package/dist/chunk-G3CZKGYA.js +197 -0
  53. package/dist/chunk-GUUPG4A7.js +7111 -0
  54. package/dist/chunk-HBAAUGUN.js +7230 -0
  55. package/dist/chunk-HHFJMK2Q.js +6177 -0
  56. package/dist/chunk-HINRQTCZ.js +196 -0
  57. package/dist/chunk-HRKJ3R2U.js +288 -0
  58. package/dist/chunk-HWVK4CVE.js +439 -0
  59. package/dist/chunk-JEYSADNZ.js +581 -0
  60. package/dist/chunk-JNEIL7UN.js +4252 -0
  61. package/dist/chunk-JTWSK277.js +676 -0
  62. package/dist/chunk-K4CHTTCJ.js +942 -0
  63. package/dist/chunk-K7R5KUDS.js +4695 -0
  64. package/dist/chunk-KNJFOURE.js +7151 -0
  65. package/dist/chunk-KY22FIT3.js +7256 -0
  66. package/dist/chunk-L2OTIJSF.js +4228 -0
  67. package/dist/chunk-LEEBUHP6.js +4655 -0
  68. package/dist/chunk-LK7UP2T7.js +130 -0
  69. package/dist/chunk-LPGNO3PK.js +284 -0
  70. package/dist/chunk-LYQYJMWS.js +133 -0
  71. package/dist/chunk-MBYFJXR3.js +130 -0
  72. package/dist/chunk-N3WX44L3.js +130 -0
  73. package/dist/chunk-N6AQWES3.js +6197 -0
  74. package/dist/chunk-NW4XSTQZ.js +130 -0
  75. package/dist/chunk-NWG2XURH.js +130 -0
  76. package/dist/chunk-O3GF3LJD.js +6142 -0
  77. package/dist/chunk-OHP5LD3Y.js +6188 -0
  78. package/dist/chunk-P5PQSFZT.js +6182 -0
  79. package/dist/chunk-PAADOWNP.js +130 -0
  80. package/dist/chunk-PERGND7L.js +7213 -0
  81. package/dist/chunk-PWA7V4XX.js +179 -0
  82. package/dist/chunk-QGCWEP6L.js +7111 -0
  83. package/dist/chunk-QVT2IHNJ.js +175 -0
  84. package/dist/chunk-QZNGYPMS.js +6161 -0
  85. package/dist/chunk-R6P2E2ZQ.js +207 -0
  86. package/dist/chunk-ROSDMGIL.js +4679 -0
  87. package/dist/chunk-RQZP7IKG.js +196 -0
  88. package/dist/chunk-RUQSPX3U.js +133 -0
  89. package/dist/chunk-S3BYHP5M.js +130 -0
  90. package/dist/chunk-S6GNETVE.js +438 -0
  91. package/dist/chunk-SDT2ZE2R.js +133 -0
  92. package/dist/chunk-SHQBXJFC.js +6166 -0
  93. package/dist/chunk-TJNISYTE.js +42 -0
  94. package/dist/chunk-TJW74HFF.js +130 -0
  95. package/dist/chunk-TPP72DTK.js +7096 -0
  96. package/dist/chunk-UOESII6R.js +42 -0
  97. package/dist/chunk-UWEDGLYJ.js +6142 -0
  98. package/dist/chunk-V5FYNAFX.js +133 -0
  99. package/dist/chunk-VPURF6UT.js +7198 -0
  100. package/dist/chunk-VQH6LWIZ.js +6184 -0
  101. package/dist/chunk-VS22YVX6.js +7111 -0
  102. package/dist/chunk-VSF5KBW7.js +367 -0
  103. package/dist/chunk-VV3JMCKY.js +214 -0
  104. package/dist/chunk-W5L7HOE3.js +133 -0
  105. package/dist/chunk-WFEVQISK.js +676 -0
  106. package/dist/chunk-WJZPSCEP.js +516 -0
  107. package/dist/chunk-WLV4MKEF.js +16 -0
  108. package/dist/chunk-WSEVQFFI.js +5428 -0
  109. package/dist/chunk-X7N2RNR3.js +5428 -0
  110. package/dist/chunk-XKZNMRNO.js +133 -0
  111. package/dist/chunk-Y7BVEC36.js +130 -0
  112. package/dist/chunk-YG7YSNNU.js +4226 -0
  113. package/dist/chunk-YHM62466.js +261 -0
  114. package/dist/chunk-YLTYJLDZ.js +7208 -0
  115. package/dist/chunk-YPMJD4YE.js +56 -0
  116. package/dist/chunk-YTX3FU2A.js +7199 -0
  117. package/dist/chunk-ZEQ3EBBN.js +214 -0
  118. package/dist/chunk-ZIWLQSLK.js +42 -0
  119. package/dist/chunk-ZJELNTEO.js +516 -0
  120. package/dist/chunk-ZOSSVNGK.js +370 -0
  121. package/dist/config-EYK32F2E.js +10 -0
  122. package/dist/config-FJPPPYTY.js +10 -0
  123. package/dist/config-VAHPVILX.js +10 -0
  124. package/dist/context-2YGE4U75.js +10 -0
  125. package/dist/context-5UFVYKES.js +9 -0
  126. package/dist/context-ANZF4J72.js +10 -0
  127. package/dist/context-GLUNCUBQ.js +10 -0
  128. package/dist/context-M5ULPZKQ.js +10 -0
  129. package/dist/context-NYOIRZKV.js +10 -0
  130. package/dist/context-YP2REI6A.js +10 -0
  131. package/dist/database-MP2JBLMF.js +8 -0
  132. package/dist/index.js +6177 -4688
  133. package/dist/keyManager-P2SZONKE.js +8 -0
  134. package/dist/mcp/index.js +127 -47
  135. package/dist/memory-BPGJAL4J.js +13 -0
  136. package/dist/memory-FRQOUI6W.js +13 -0
  137. package/dist/memory-OAMK27IZ.js +13 -0
  138. package/dist/memory-OZ734ALL.js +13 -0
  139. package/dist/memory-PQ2EWRMU.js +13 -0
  140. package/dist/memory-PXL45M6W.js +13 -0
  141. package/dist/memory-QZTBTYPH.js +13 -0
  142. package/dist/migrations-TLJ3WRVW.js +188 -0
  143. package/dist/resume-2NHDK6EI.js +17 -0
  144. package/dist/resume-44L2PDB2.js +17 -0
  145. package/dist/resume-4MXIWUJO.js +7 -0
  146. package/dist/resume-72VJX66I.js +17 -0
  147. package/dist/resume-7ZW4XM3B.js +15 -0
  148. package/dist/resume-AZHYQ657.js +17 -0
  149. package/dist/resume-CNLXSYHV.js +17 -0
  150. package/dist/resume-DPN4Q777.js +16 -0
  151. package/dist/resume-DSFHVNPI.js +15 -0
  152. package/dist/resume-GHLQJJTO.js +17 -0
  153. package/dist/resume-HJ6SBWTF.js +17 -0
  154. package/dist/resume-HRLYHY2L.js +17 -0
  155. package/dist/resume-ISIQFKO6.js +17 -0
  156. package/dist/resume-JQDEA6PS.js +15 -0
  157. package/dist/resume-KP3Y3Y7P.js +17 -0
  158. package/dist/resume-M4KHR5OI.js +17 -0
  159. package/dist/resume-N62OAMBG.js +17 -0
  160. package/dist/resume-NNMA5POT.js +17 -0
  161. package/dist/resume-ODYT3J4H.js +17 -0
  162. package/dist/resume-PCFJXA5O.js +17 -0
  163. package/dist/resume-PLF4XGBD.js +15 -0
  164. package/dist/resume-Q2PFX57V.js +17 -0
  165. package/dist/resume-QB4XI2J5.js +17 -0
  166. package/dist/resume-R5MFTUPF.js +17 -0
  167. package/dist/resume-SVA7223Z.js +17 -0
  168. package/dist/resume-TYKKDJZI.js +17 -0
  169. package/dist/resume-XIS45HKV.js +17 -0
  170. package/dist/resume-YCSEJTU7.js +17 -0
  171. package/dist/resume-YD76GI2J.js +15 -0
  172. package/dist/resume-YDN7EL77.js +17 -0
  173. package/dist/resume-YE7DB4ZA.js +17 -0
  174. package/dist/resume-YKAKOXWV.js +15 -0
  175. package/dist/resume-ZHBCVFDY.js +17 -0
  176. package/dist/scheduler-2CK24A2Q.js +14 -0
  177. package/dist/scheduler-7OAF2XKX.js +14 -0
  178. package/dist/scheduler-AS23AAB5.js +14 -0
  179. package/dist/scheduler-PCOYQJA5.js +14 -0
  180. package/dist/scheduler-V2ECBQPK.js +14 -0
  181. package/dist/scheduler-VEWZ6L7V.js +13 -0
  182. package/dist/scheduler-W37QMGDQ.js +14 -0
  183. package/dist/session-2E2JKPD7.js +15 -0
  184. package/dist/session-2VSF257B.js +14 -0
  185. package/dist/session-4APFTDJU.js +14 -0
  186. package/dist/session-5YS5LNNL.js +16 -0
  187. package/dist/session-6MO5ZPOB.js +16 -0
  188. package/dist/session-6XMGPRTQ.js +14 -0
  189. package/dist/session-7DJR77R7.js +16 -0
  190. package/dist/session-7DQHPWTR.js +14 -0
  191. package/dist/session-ADKIQCR5.js +16 -0
  192. package/dist/session-AOGH2GGI.js +16 -0
  193. package/dist/session-C4W6GDYG.js +16 -0
  194. package/dist/session-DCGNGGMV.js +14 -0
  195. package/dist/session-F5JKZAN2.js +16 -0
  196. package/dist/session-G6F3O2FQ.js +16 -0
  197. package/dist/session-GFBSARRO.js +16 -0
  198. package/dist/session-H5IWAIUI.js +16 -0
  199. package/dist/session-IPFA6AHC.js +14 -0
  200. package/dist/session-IWG2UOAX.js +14 -0
  201. package/dist/session-KJ2K4Y4M.js +14 -0
  202. package/dist/session-KPXFBW6Q.js +14 -0
  203. package/dist/session-KR256UL5.js +16 -0
  204. package/dist/session-M72LJXPR.js +16 -0
  205. package/dist/session-MBK3FODN.js +14 -0
  206. package/dist/session-MOUFAU7G.js +16 -0
  207. package/dist/session-NRC6ZXFQ.js +16 -0
  208. package/dist/session-NRPQMV4K.js +16 -0
  209. package/dist/session-O5IFFJZQ.js +14 -0
  210. package/dist/session-OF5BGKDE.js +16 -0
  211. package/dist/session-OGRZMIM7.js +14 -0
  212. package/dist/session-OJOFAJG3.js +16 -0
  213. package/dist/session-OKU4N3SP.js +16 -0
  214. package/dist/session-P2VAOSFB.js +14 -0
  215. package/dist/session-PKOVZD4M.js +16 -0
  216. package/dist/session-POAIMUVN.js +16 -0
  217. package/dist/session-PSHFONFE.js +16 -0
  218. package/dist/session-QKYVVZFV.js +16 -0
  219. package/dist/session-QPWGBMUS.js +14 -0
  220. package/dist/session-R5UG5PZR.js +14 -0
  221. package/dist/session-RAY6BZRQ.js +16 -0
  222. package/dist/session-S3VATHMU.js +16 -0
  223. package/dist/session-SYTD7RHW.js +14 -0
  224. package/dist/session-UHMMVO4J.js +16 -0
  225. package/dist/session-WEX5K3ZY.js +14 -0
  226. package/dist/session-XFLOXGU3.js +14 -0
  227. package/dist/session-XV2A4HHG.js +14 -0
  228. package/dist/settings-3VPJYD4D.js +8 -0
  229. package/dist/settings-GZTJJTBK.js +8 -0
  230. package/dist/settings-YKJFSKMO.js +8 -0
  231. package/dist/shell-FM34624T.js +8 -0
  232. package/package.json +14 -4
@@ -0,0 +1,130 @@
1
+ import {
2
+ history,
3
+ session,
4
+ tasks
5
+ } from "./chunk-C4D56GRC.js";
6
+ import {
7
+ context
8
+ } from "./chunk-EMBMLZFE.js";
9
+ import {
10
+ bus
11
+ } from "./chunk-WQM6FFSD.js";
12
+
13
+ // src/commands/resume.ts
14
+ import path from "path";
15
+ var resumeCommand = async (args) => {
16
+ if (args[0] === "--delete" || args[0] === "-d") {
17
+ const sessionId = args[1];
18
+ if (!sessionId) {
19
+ bus.emitAgent({
20
+ type: "error",
21
+ message: "Usage: /resume --delete <session_id>"
22
+ });
23
+ return;
24
+ }
25
+ const deleted = await session.delete(sessionId);
26
+ if (deleted) {
27
+ bus.emitAgent({
28
+ type: "done",
29
+ summary: `Session ${sessionId} deleted.`
30
+ });
31
+ } else {
32
+ bus.emitAgent({
33
+ type: "error",
34
+ message: `Session ${sessionId} not found.`
35
+ });
36
+ }
37
+ return;
38
+ }
39
+ if (args[0] === "--last" || args[0] === "-l") {
40
+ const sessions = await session.list();
41
+ if (sessions.length === 0) {
42
+ bus.emitAgent({
43
+ type: "error",
44
+ message: "No saved sessions found."
45
+ });
46
+ return;
47
+ }
48
+ args[0] = sessions[0].id;
49
+ }
50
+ if (!args[0]) {
51
+ const sessions = await session.list();
52
+ if (sessions.length === 0) {
53
+ bus.emitAgent({
54
+ type: "thought",
55
+ content: "No saved sessions found.\n\nSessions are created when you run /exit."
56
+ });
57
+ bus.emitAgent({
58
+ type: "done",
59
+ summary: "No sessions available."
60
+ });
61
+ return;
62
+ }
63
+ const content2 = [
64
+ "Saved Session Registry",
65
+ ...sessions.slice(0, 10).map((s) => {
66
+ const date = new Date(s.savedAt);
67
+ const dateStr = date.toLocaleDateString();
68
+ const timeStr = date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
69
+ const workspaceName = path.basename(s.workspace);
70
+ return [
71
+ ` \u23BF [${s.id}]`,
72
+ ` \u23BF Date ${dateStr} ${timeStr}`,
73
+ ` \u23BF Workspace ${workspaceName}`,
74
+ s.task ? ` \u23BF Task ${s.task}` : null,
75
+ ` \u23BF Activity ${s.filesModified} files handled`,
76
+ ""
77
+ ].filter(Boolean).join("\n");
78
+ }),
79
+ sessions.length > 10 ? ` ... and ${sessions.length - 10} more sessions
80
+ ` : "",
81
+ " [Usage]",
82
+ " \u23BF /resume <id> Restore session",
83
+ " \u23BF /resume --last Restore latest",
84
+ ""
85
+ ].join("\n");
86
+ bus.emitAgent({
87
+ type: "thought",
88
+ content: content2
89
+ });
90
+ bus.emitAgent({
91
+ type: "done",
92
+ summary: `${sessions.length} session(s) available.`
93
+ });
94
+ return;
95
+ }
96
+ const sessionIdArg = args[0];
97
+ const result = await session.restore(sessionIdArg);
98
+ if (!result.success) {
99
+ bus.emitAgent({
100
+ type: "error",
101
+ message: result.error || "Failed to restore session"
102
+ });
103
+ return;
104
+ }
105
+ const currentTask = tasks.get();
106
+ const currentContext = context.get();
107
+ const content = [
108
+ "Session Restored Successfully",
109
+ ` \u23BF ID ${sessionIdArg}`,
110
+ ` \u23BF Root ${path.basename(process.cwd())}`,
111
+ "",
112
+ " [Restored State]",
113
+ ` \u23BF Context ${currentContext.files_read.length} files in set`,
114
+ ` \u23BF History ${(await history.load()).length} events rehydrated`,
115
+ ` \u23BF Task ${currentTask?.title || "None"}`,
116
+ ""
117
+ ].join("\n");
118
+ bus.emitAgent({
119
+ type: "thought",
120
+ content
121
+ });
122
+ bus.emitAgent({
123
+ type: "done",
124
+ summary: `Session ${sessionIdArg} restored.`
125
+ });
126
+ };
127
+
128
+ export {
129
+ resumeCommand
130
+ };
@@ -0,0 +1,284 @@
1
+ // src/core/settings.ts
2
+ import fs from "fs/promises";
3
+ import path from "path";
4
+ import os from "os";
5
+ import { z } from "zod";
6
+ var SETTINGS_DIR = ".obsidian-next";
7
+ var SETTINGS_FILE = "settings.json";
8
+ var SettingsSchema = z.object({
9
+ // Execution mode
10
+ mode: z.enum(["auto", "plan", "safe"]).default("safe"),
11
+ // Auto-accept settings
12
+ autoAccept: z.object({
13
+ enabled: z.boolean().default(false),
14
+ readOperations: z.boolean().default(true),
15
+ safeCommands: z.boolean().default(true)
16
+ }).default({}),
17
+ // Tool permissions
18
+ permissions: z.object({
19
+ // Patterns always allowed without prompt: "tool:pattern"
20
+ allow: z.array(z.string()).default([]),
21
+ // Patterns allowed without prompt AND without sandbox
22
+ allowUnsandboxed: z.array(z.string()).default([]),
23
+ // Patterns always blocked
24
+ deny: z.array(z.string()).default([])
25
+ }).default({}),
26
+ // Security settings
27
+ security: z.object({
28
+ // PII redaction before sending to LLM
29
+ piiRedaction: z.boolean().default(true),
30
+ // Audit logging of all commands
31
+ auditLogging: z.boolean().default(true),
32
+ // Key storage backend preference
33
+ keyBackend: z.enum(["auto", "keychain", "secret-tool", "encrypted-file", "env"]).default("auto")
34
+ }).default({}),
35
+ // UI preferences
36
+ ui: z.object({
37
+ syntaxHighlight: z.boolean().default(true),
38
+ diffColors: z.boolean().default(true),
39
+ showLineNumbers: z.boolean().default(true),
40
+ // Owl animation settings
41
+ owlAnimation: z.object({
42
+ enabled: z.boolean().default(false),
43
+ flyWhenIdle: z.boolean().default(false),
44
+ idleTimeout: z.number().default(6e4),
45
+ // 60s before idle animation
46
+ sleepTimeout: z.number().default(3e5)
47
+ // 5m before sleep animation
48
+ }).default({})
49
+ }).default({}),
50
+ // Remote Gateway (Telegram)
51
+ telegram: z.object({
52
+ enabled: z.boolean().default(false),
53
+ botToken: z.string().optional(),
54
+ allowedUserIds: z.array(z.string()).default([])
55
+ }).default({})
56
+ });
57
+ var DEFAULT_SETTINGS = {
58
+ mode: "safe",
59
+ autoAccept: {
60
+ enabled: false,
61
+ readOperations: false,
62
+ safeCommands: false
63
+ },
64
+ permissions: {
65
+ allow: [],
66
+ // Empty - user builds their own allow list
67
+ allowUnsandboxed: [],
68
+ deny: []
69
+ },
70
+ security: {
71
+ piiRedaction: true,
72
+ // Enabled by default - protects user privacy
73
+ auditLogging: true,
74
+ // Enabled by default - for accountability
75
+ keyBackend: "auto"
76
+ // Auto-detect best available backend
77
+ },
78
+ ui: {
79
+ syntaxHighlight: true,
80
+ diffColors: true,
81
+ showLineNumbers: true,
82
+ owlAnimation: {
83
+ enabled: false,
84
+ flyWhenIdle: false,
85
+ idleTimeout: 6e4,
86
+ // 60s before idle animation
87
+ sleepTimeout: 3e5
88
+ // 5m before sleep animation
89
+ }
90
+ },
91
+ telegram: {
92
+ enabled: false,
93
+ allowedUserIds: []
94
+ }
95
+ };
96
+ var SettingsManager = class {
97
+ settingsPath;
98
+ cache = null;
99
+ sessionAllow = /* @__PURE__ */ new Set();
100
+ sessionUnsandboxed = /* @__PURE__ */ new Set();
101
+ sessionDeny = /* @__PURE__ */ new Set();
102
+ constructor() {
103
+ this.settingsPath = path.join(os.homedir(), SETTINGS_DIR, SETTINGS_FILE);
104
+ }
105
+ async load() {
106
+ if (this.cache) return this.cache;
107
+ return this.reload();
108
+ }
109
+ async reload() {
110
+ try {
111
+ const data = await fs.readFile(this.settingsPath, "utf-8");
112
+ const parsed = JSON.parse(data);
113
+ this.cache = SettingsSchema.parse({ ...DEFAULT_SETTINGS, ...parsed });
114
+ } catch {
115
+ this.cache = DEFAULT_SETTINGS;
116
+ await this.save(DEFAULT_SETTINGS);
117
+ }
118
+ return this.cache;
119
+ }
120
+ /**
121
+ * Add a permission to the allow list (called when user approves a command)
122
+ */
123
+ async addAllowedPermission(tool, command) {
124
+ const s = await this.load();
125
+ const pattern = `${tool}:${command}`;
126
+ if (!s.permissions.allow.includes(pattern)) {
127
+ s.permissions.allow.push(pattern);
128
+ await this.save({ permissions: s.permissions });
129
+ }
130
+ }
131
+ /**
132
+ * Add a permission to the unsandboxed allow list
133
+ */
134
+ async addUnsandboxedPermission(tool, command) {
135
+ const s = await this.load();
136
+ const pattern = `${tool}:${command}`;
137
+ if (!s.permissions.allowUnsandboxed.includes(pattern)) {
138
+ s.permissions.allowUnsandboxed.push(pattern);
139
+ if (!s.permissions.allow.includes(pattern)) {
140
+ s.permissions.allow.push(pattern);
141
+ }
142
+ await this.save({ permissions: s.permissions });
143
+ }
144
+ }
145
+ /**
146
+ * Add a permission to the session-only allow/deny list
147
+ */
148
+ async addSessionPermission(tool, command, approved, bypass = false) {
149
+ const pattern = `${tool}:${command}`;
150
+ if (approved) {
151
+ this.sessionAllow.add(pattern);
152
+ this.sessionDeny.delete(pattern);
153
+ if (bypass) {
154
+ this.sessionUnsandboxed.add(pattern);
155
+ }
156
+ } else {
157
+ this.sessionDeny.add(pattern);
158
+ this.sessionAllow.delete(pattern);
159
+ this.sessionUnsandboxed.delete(pattern);
160
+ }
161
+ }
162
+ /**
163
+ * Add a permission to the deny list
164
+ */
165
+ async addDeniedPermission(tool, command) {
166
+ const s = await this.load();
167
+ const pattern = `${tool}:${command}`;
168
+ if (!s.permissions.deny.includes(pattern)) {
169
+ s.permissions.deny.push(pattern);
170
+ await this.save({ permissions: s.permissions });
171
+ }
172
+ }
173
+ async save(newSettings) {
174
+ const current = await this.load();
175
+ const merged = { ...current, ...newSettings };
176
+ if (newSettings.autoAccept) {
177
+ merged.autoAccept = { ...current.autoAccept, ...newSettings.autoAccept };
178
+ }
179
+ if (newSettings.permissions) {
180
+ merged.permissions = {
181
+ ...current.permissions,
182
+ ...newSettings.permissions
183
+ };
184
+ }
185
+ if (newSettings.security) {
186
+ merged.security = { ...current.security, ...newSettings.security };
187
+ }
188
+ if (newSettings.ui) {
189
+ merged.ui = { ...current.ui, ...newSettings.ui };
190
+ }
191
+ const validated = SettingsSchema.parse(merged);
192
+ const dir = path.dirname(this.settingsPath);
193
+ await fs.mkdir(dir, { recursive: true });
194
+ await fs.writeFile(this.settingsPath, JSON.stringify(validated, null, 2));
195
+ this.cache = validated;
196
+ }
197
+ async get(key) {
198
+ const s = await this.load();
199
+ return s[key];
200
+ }
201
+ async set(key, value) {
202
+ await this.save({ [key]: value });
203
+ }
204
+ /**
205
+ * Check if a tool:command pattern is authorized for THIS SESSION only
206
+ */
207
+ async isSessionAuthorized(tool, command) {
208
+ const pattern = `${tool}:${command}`;
209
+ return this.sessionAllow.has(pattern);
210
+ }
211
+ /**
212
+ * Check if a tool:command pattern is allowed (session or persistent)
213
+ */
214
+ async isAllowed(tool, command) {
215
+ const pattern = `${tool}:${command}`;
216
+ if (this.sessionAllow.has(pattern)) {
217
+ return true;
218
+ }
219
+ const s = await this.load();
220
+ for (const deny of s.permissions.deny) {
221
+ if (this.matchPattern(pattern, deny)) {
222
+ return false;
223
+ }
224
+ }
225
+ for (const allow of s.permissions.allow) {
226
+ if (this.matchPattern(pattern, allow)) {
227
+ return true;
228
+ }
229
+ }
230
+ return false;
231
+ }
232
+ /**
233
+ * Check if a tool:command pattern is allowed to bypass sandbox
234
+ */
235
+ async isUnsandboxed(tool, command) {
236
+ const pattern = `${tool}:${command}`;
237
+ if (this.sessionUnsandboxed.has(pattern)) {
238
+ return true;
239
+ }
240
+ const s = await this.load();
241
+ for (const allow of s.permissions.allowUnsandboxed) {
242
+ if (this.matchPattern(pattern, allow)) {
243
+ return true;
244
+ }
245
+ }
246
+ return false;
247
+ }
248
+ /**
249
+ * Check if a tool:command pattern is explicitly denied
250
+ */
251
+ async isDenied(tool, command) {
252
+ const pattern = `${tool}:${command}`;
253
+ if (this.sessionDeny.has(pattern)) {
254
+ return true;
255
+ }
256
+ const s = await this.load();
257
+ for (const deny of s.permissions.deny) {
258
+ if (this.matchPattern(pattern, deny)) {
259
+ return true;
260
+ }
261
+ }
262
+ return false;
263
+ }
264
+ /**
265
+ * Simple glob-like pattern matching
266
+ * Supports * as wildcard
267
+ */
268
+ matchPattern(value, pattern) {
269
+ const regex = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
270
+ return new RegExp(`^${regex}$`).test(value);
271
+ }
272
+ clearCache() {
273
+ this.cache = null;
274
+ }
275
+ getPath() {
276
+ return this.settingsPath;
277
+ }
278
+ };
279
+ var settings = new SettingsManager();
280
+
281
+ export {
282
+ SettingsSchema,
283
+ settings
284
+ };
@@ -0,0 +1,133 @@
1
+ import {
2
+ history,
3
+ session,
4
+ tasks
5
+ } from "./chunk-P5PQSFZT.js";
6
+ import {
7
+ context
8
+ } from "./chunk-DPNIQWKZ.js";
9
+ import {
10
+ bus
11
+ } from "./chunk-WQM6FFSD.js";
12
+
13
+ // src/commands/resume.ts
14
+ import path from "path";
15
+ var resumeCommand = async (args) => {
16
+ if (args[0] === "--delete" || args[0] === "-d") {
17
+ const sessionId = args[1];
18
+ if (!sessionId) {
19
+ bus.emitAgent({
20
+ type: "error",
21
+ message: "Usage: /resume --delete <session_id>"
22
+ });
23
+ return;
24
+ }
25
+ const deleted = await session.delete(sessionId);
26
+ if (deleted) {
27
+ bus.emitAgent({
28
+ type: "done",
29
+ summary: `Session ${sessionId} deleted.`
30
+ });
31
+ } else {
32
+ bus.emitAgent({
33
+ type: "error",
34
+ message: `Session ${sessionId} not found.`
35
+ });
36
+ }
37
+ return;
38
+ }
39
+ if (args[0] === "--last" || args[0] === "-l") {
40
+ const sessions = await session.list();
41
+ if (sessions.length === 0) {
42
+ bus.emitAgent({
43
+ type: "error",
44
+ message: "No saved sessions found."
45
+ });
46
+ return;
47
+ }
48
+ args[0] = sessions[0].id;
49
+ }
50
+ if (!args[0]) {
51
+ const sessions = await session.list();
52
+ if (sessions.length === 0) {
53
+ bus.emitAgent({
54
+ type: "thought",
55
+ content: "No saved sessions found.\n\nSessions are created when you run /exit."
56
+ });
57
+ bus.emitAgent({
58
+ type: "done",
59
+ summary: "No sessions available."
60
+ });
61
+ return;
62
+ }
63
+ const content2 = [
64
+ "Saved Session Registry",
65
+ ...sessions.slice(0, 10).map((s) => {
66
+ const date = new Date(s.savedAt);
67
+ const dateStr = date.toLocaleDateString();
68
+ const timeStr = date.toLocaleTimeString([], {
69
+ hour: "2-digit",
70
+ minute: "2-digit"
71
+ });
72
+ const workspaceName = path.basename(s.workspace);
73
+ return [
74
+ ` \u23BF [${s.id}]`,
75
+ ` \u23BF Date ${dateStr} ${timeStr}`,
76
+ ` \u23BF Workspace ${workspaceName}`,
77
+ s.task ? ` \u23BF Task ${s.task}` : null,
78
+ ` \u23BF Activity ${s.filesModified} files handled`,
79
+ ""
80
+ ].filter(Boolean).join("\n");
81
+ }),
82
+ sessions.length > 10 ? ` ... and ${sessions.length - 10} more sessions
83
+ ` : "",
84
+ " [Usage]",
85
+ " \u23BF /resume <id> Restore session",
86
+ " \u23BF /resume --last Restore latest",
87
+ ""
88
+ ].join("\n");
89
+ bus.emitAgent({
90
+ type: "thought",
91
+ content: content2
92
+ });
93
+ bus.emitAgent({
94
+ type: "done",
95
+ summary: `${sessions.length} session(s) available.`
96
+ });
97
+ return;
98
+ }
99
+ const sessionIdArg = args[0];
100
+ const result = await session.restore(sessionIdArg);
101
+ if (!result.success) {
102
+ bus.emitAgent({
103
+ type: "error",
104
+ message: result.error || "Failed to restore session"
105
+ });
106
+ return;
107
+ }
108
+ const currentTask = tasks.get();
109
+ const currentContext = context.get();
110
+ const content = [
111
+ "Session Restored Successfully",
112
+ ` \u23BF ID ${sessionIdArg}`,
113
+ ` \u23BF Root ${path.basename(process.cwd())}`,
114
+ "",
115
+ " [Restored State]",
116
+ ` \u23BF Context ${currentContext.files_read.length} files in set`,
117
+ ` \u23BF History ${(await history.load()).length} events rehydrated`,
118
+ ` \u23BF Task ${currentTask?.title || "None"}`,
119
+ ""
120
+ ].join("\n");
121
+ bus.emitAgent({
122
+ type: "thought",
123
+ content
124
+ });
125
+ bus.emitAgent({
126
+ type: "done",
127
+ summary: `Session ${sessionIdArg} restored.`
128
+ });
129
+ };
130
+
131
+ export {
132
+ resumeCommand
133
+ };
@@ -0,0 +1,130 @@
1
+ import {
2
+ history,
3
+ session,
4
+ tasks
5
+ } from "./chunk-JNEIL7UN.js";
6
+ import {
7
+ context
8
+ } from "./chunk-MSDU36RT.js";
9
+ import {
10
+ bus
11
+ } from "./chunk-WQM6FFSD.js";
12
+
13
+ // src/commands/resume.ts
14
+ import path from "path";
15
+ var resumeCommand = async (args) => {
16
+ if (args[0] === "--delete" || args[0] === "-d") {
17
+ const sessionId = args[1];
18
+ if (!sessionId) {
19
+ bus.emitAgent({
20
+ type: "error",
21
+ message: "Usage: /resume --delete <session_id>"
22
+ });
23
+ return;
24
+ }
25
+ const deleted = await session.delete(sessionId);
26
+ if (deleted) {
27
+ bus.emitAgent({
28
+ type: "done",
29
+ summary: `Session ${sessionId} deleted.`
30
+ });
31
+ } else {
32
+ bus.emitAgent({
33
+ type: "error",
34
+ message: `Session ${sessionId} not found.`
35
+ });
36
+ }
37
+ return;
38
+ }
39
+ if (args[0] === "--last" || args[0] === "-l") {
40
+ const sessions = await session.list();
41
+ if (sessions.length === 0) {
42
+ bus.emitAgent({
43
+ type: "error",
44
+ message: "No saved sessions found."
45
+ });
46
+ return;
47
+ }
48
+ args[0] = sessions[0].id;
49
+ }
50
+ if (!args[0]) {
51
+ const sessions = await session.list();
52
+ if (sessions.length === 0) {
53
+ bus.emitAgent({
54
+ type: "thought",
55
+ content: "No saved sessions found.\n\nSessions are created when you run /exit."
56
+ });
57
+ bus.emitAgent({
58
+ type: "done",
59
+ summary: "No sessions available."
60
+ });
61
+ return;
62
+ }
63
+ const content2 = [
64
+ "Saved Session Registry",
65
+ ...sessions.slice(0, 10).map((s) => {
66
+ const date = new Date(s.savedAt);
67
+ const dateStr = date.toLocaleDateString();
68
+ const timeStr = date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
69
+ const workspaceName = path.basename(s.workspace);
70
+ return [
71
+ ` \u23BF [${s.id}]`,
72
+ ` \u23BF Date ${dateStr} ${timeStr}`,
73
+ ` \u23BF Workspace ${workspaceName}`,
74
+ s.task ? ` \u23BF Task ${s.task}` : null,
75
+ ` \u23BF Activity ${s.filesModified} files handled`,
76
+ ""
77
+ ].filter(Boolean).join("\n");
78
+ }),
79
+ sessions.length > 10 ? ` ... and ${sessions.length - 10} more sessions
80
+ ` : "",
81
+ " [Usage]",
82
+ " \u23BF /resume <id> Restore session",
83
+ " \u23BF /resume --last Restore latest",
84
+ ""
85
+ ].join("\n");
86
+ bus.emitAgent({
87
+ type: "thought",
88
+ content: content2
89
+ });
90
+ bus.emitAgent({
91
+ type: "done",
92
+ summary: `${sessions.length} session(s) available.`
93
+ });
94
+ return;
95
+ }
96
+ const sessionIdArg = args[0];
97
+ const result = await session.restore(sessionIdArg);
98
+ if (!result.success) {
99
+ bus.emitAgent({
100
+ type: "error",
101
+ message: result.error || "Failed to restore session"
102
+ });
103
+ return;
104
+ }
105
+ const currentTask = tasks.get();
106
+ const currentContext = context.get();
107
+ const content = [
108
+ "Session Restored Successfully",
109
+ ` \u23BF ID ${sessionIdArg}`,
110
+ ` \u23BF Root ${path.basename(process.cwd())}`,
111
+ "",
112
+ " [Restored State]",
113
+ ` \u23BF Context ${currentContext.files_read.length} files in set`,
114
+ ` \u23BF History ${(await history.load()).length} events rehydrated`,
115
+ ` \u23BF Task ${currentTask?.title || "None"}`,
116
+ ""
117
+ ].join("\n");
118
+ bus.emitAgent({
119
+ type: "thought",
120
+ content
121
+ });
122
+ bus.emitAgent({
123
+ type: "done",
124
+ summary: `Session ${sessionIdArg} restored.`
125
+ });
126
+ };
127
+
128
+ export {
129
+ resumeCommand
130
+ };