@lovelybunch/core 1.0.66 → 1.0.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './change-proposal.js';
2
2
  export * from './storage.js';
3
3
  export * from './markdown-storage.js';
4
+ export * from './logging/index.js';
4
5
  export type * from '@lovelybunch/types';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,mBAAmB,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,mBAAmB,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './change-proposal.js';
2
2
  export * from './storage.js';
3
3
  export * from './markdown-storage.js';
4
+ export * from './logging/index.js';
4
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Coconut activity logging module
3
+ * @module logging
4
+ *
5
+ * This module provides a unified activity logging system for Coconut that tracks
6
+ * all operations (proposals, sessions, jobs, git actions, etc.) in a file-first,
7
+ * append-only JSONL format.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { getLogger, EventKinds } from "@lovelybunch/core/logging";
12
+ *
13
+ * const logger = getLogger();
14
+ *
15
+ * // Log a proposal creation
16
+ * logger.log({
17
+ * kind: EventKinds.CREATE,
18
+ * actor: "human:user@example.com",
19
+ * subject: "proposal:cp-123",
20
+ * tags: ["proposal"],
21
+ * payload: { intent: "Add feature X" }
22
+ * });
23
+ * ```
24
+ */
25
+ export { getLogger, resetLogger, hasLogger } from "./logger";
26
+ export type { LogEventBase, LogEvent, Logger, LoggerOptions, LogLevel, } from "./types";
27
+ export { EventKinds, ProposalKinds, AgentKinds, CodeKinds, KnowledgeKinds, JobKinds, ResourceKinds, AuthKinds, isValidEventKind, EventKindRegistry, } from "./kinds";
28
+ export { defaultRedactor, createRedactor, noRedactor, } from "./redact";
29
+ export { JsonlWriter } from "./jsonl-writer";
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logging/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG7D,YAAY,EACV,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,aAAa,EACb,QAAQ,GACT,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,UAAU,EACV,aAAa,EACb,UAAU,EACV,SAAS,EACT,cAAc,EACd,QAAQ,EACR,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,eAAe,EACf,cAAc,EACd,UAAU,GACX,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Coconut activity logging module
3
+ * @module logging
4
+ *
5
+ * This module provides a unified activity logging system for Coconut that tracks
6
+ * all operations (proposals, sessions, jobs, git actions, etc.) in a file-first,
7
+ * append-only JSONL format.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { getLogger, EventKinds } from "@lovelybunch/core/logging";
12
+ *
13
+ * const logger = getLogger();
14
+ *
15
+ * // Log a proposal creation
16
+ * logger.log({
17
+ * kind: EventKinds.CREATE,
18
+ * actor: "human:user@example.com",
19
+ * subject: "proposal:cp-123",
20
+ * tags: ["proposal"],
21
+ * payload: { intent: "Add feature X" }
22
+ * });
23
+ * ```
24
+ */
25
+ // Main logger interface
26
+ export { getLogger, resetLogger, hasLogger } from "./logger";
27
+ // Event kinds taxonomy
28
+ export { EventKinds, ProposalKinds, AgentKinds, CodeKinds, KnowledgeKinds, JobKinds, ResourceKinds, AuthKinds, isValidEventKind, EventKindRegistry, } from "./kinds";
29
+ // Redaction utilities
30
+ export { defaultRedactor, createRedactor, noRedactor, } from "./redact";
31
+ // Internal writer (exported for testing and advanced use cases)
32
+ export { JsonlWriter } from "./jsonl-writer";
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/logging/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,wBAAwB;AACxB,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAW7D,uBAAuB;AACvB,OAAO,EACL,UAAU,EACV,aAAa,EACb,UAAU,EACV,SAAS,EACT,cAAc,EACd,QAAQ,EACR,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,SAAS,CAAC;AAEjB,sBAAsB;AACtB,OAAO,EACL,eAAe,EACf,cAAc,EACd,UAAU,GACX,MAAM,UAAU,CAAC;AAElB,gEAAgE;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * JSONL writer with rotation support for Coconut activity logging
3
+ * @module logging/jsonl-writer
4
+ */
5
+ import type { LogEvent, LogEventBase } from "./types";
6
+ /**
7
+ * Internal writer that manages append-only JSONL files with size-based rotation
8
+ *
9
+ * Features:
10
+ * - Single append-only file: events-current.jsonl
11
+ * - Size-based rotation (default: 128MB)
12
+ * - Monotonic sequence counter persisted in .seq file
13
+ * - Non-blocking queue-based writes
14
+ * - Automatic directory creation
15
+ */
16
+ export declare class JsonlWriter {
17
+ private readonly dir;
18
+ private readonly coconut;
19
+ private readonly rotateBytes;
20
+ private seq;
21
+ private queue;
22
+ private writing;
23
+ private out;
24
+ private currentPath;
25
+ private bytes;
26
+ private closed;
27
+ /**
28
+ * Create a new JSONL writer
29
+ *
30
+ * @param dir - Directory to store log files
31
+ * @param coconut - Coconut instance identifier
32
+ * @param rotateBytes - File size threshold for rotation (default: 128MB)
33
+ */
34
+ constructor(dir: string, coconut: string, rotateBytes?: number);
35
+ /**
36
+ * Enqueue an event for writing (non-blocking)
37
+ */
38
+ enqueue(event: LogEvent): void;
39
+ /**
40
+ * Flush pending events to disk
41
+ */
42
+ flush(): Promise<void>;
43
+ /**
44
+ * Get the last assigned sequence number
45
+ */
46
+ getSeq(): number;
47
+ /**
48
+ * Close the writer and cleanup resources
49
+ */
50
+ close(): Promise<void>;
51
+ /**
52
+ * Create the next event with auto-filled fields and enqueue it
53
+ */
54
+ nextEvent(event: LogEventBase): number;
55
+ /**
56
+ * Drain the queue by writing all pending events
57
+ */
58
+ private drain;
59
+ /**
60
+ * Read the sequence counter from disk
61
+ */
62
+ private readSeq;
63
+ /**
64
+ * Persist the current sequence counter to disk
65
+ */
66
+ private writeSeq;
67
+ /**
68
+ * Open a new current file for writing
69
+ */
70
+ private rotateNewFile;
71
+ /**
72
+ * Rotate the current file to a timestamped archive
73
+ */
74
+ private rotate;
75
+ }
76
+ //# sourceMappingURL=jsonl-writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonl-writer.d.ts","sourceRoot":"","sources":["../../src/logging/jsonl-writer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEtD;;;;;;;;;GASG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,GAAG,CAAK;IAChB,OAAO,CAAC,KAAK,CAAkB;IAC/B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,GAAG,CAAkB;IAC7B,OAAO,CAAC,WAAW,CAAU;IAC7B,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,MAAM,CAAS;IAEvB;;;;;;OAMG;gBACS,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,SAAoB;IAezE;;OAEG;IACH,OAAO,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAW9B;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAU5B;;OAEG;IACH,MAAM,IAAI,MAAM;IAIhB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAqB5B;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM;IAiBtC;;OAEG;YACW,KAAK;IA+CnB;;OAEG;IACH,OAAO,CAAC,OAAO;IAUf;;OAEG;IACH,OAAO,CAAC,QAAQ;IAUhB;;OAEG;IACH,OAAO,CAAC,aAAa;IA0CrB;;OAEG;YACW,MAAM;CAqBrB"}
@@ -0,0 +1,252 @@
1
+ /**
2
+ * JSONL writer with rotation support for Coconut activity logging
3
+ * @module logging/jsonl-writer
4
+ */
5
+ import fs from "node:fs";
6
+ import path from "node:path";
7
+ /**
8
+ * Internal writer that manages append-only JSONL files with size-based rotation
9
+ *
10
+ * Features:
11
+ * - Single append-only file: events-current.jsonl
12
+ * - Size-based rotation (default: 128MB)
13
+ * - Monotonic sequence counter persisted in .seq file
14
+ * - Non-blocking queue-based writes
15
+ * - Automatic directory creation
16
+ */
17
+ export class JsonlWriter {
18
+ dir;
19
+ coconut;
20
+ rotateBytes;
21
+ seq = 0;
22
+ queue = [];
23
+ writing = false;
24
+ out;
25
+ currentPath;
26
+ bytes = 0;
27
+ closed = false;
28
+ /**
29
+ * Create a new JSONL writer
30
+ *
31
+ * @param dir - Directory to store log files
32
+ * @param coconut - Coconut instance identifier
33
+ * @param rotateBytes - File size threshold for rotation (default: 128MB)
34
+ */
35
+ constructor(dir, coconut, rotateBytes = 128 * 1024 * 1024) {
36
+ this.dir = dir;
37
+ this.coconut = coconut;
38
+ this.rotateBytes = rotateBytes;
39
+ // Ensure the directory exists
40
+ fs.mkdirSync(this.dir, { recursive: true });
41
+ // Load the last sequence number
42
+ this.seq = this.readSeq();
43
+ // Open the current file
44
+ this.rotateNewFile();
45
+ }
46
+ /**
47
+ * Enqueue an event for writing (non-blocking)
48
+ */
49
+ enqueue(event) {
50
+ if (this.closed) {
51
+ throw new Error("JsonlWriter is closed");
52
+ }
53
+ this.queue.push(event);
54
+ if (!this.writing) {
55
+ // Don't await - this is fire-and-forget
56
+ void this.drain();
57
+ }
58
+ }
59
+ /**
60
+ * Flush pending events to disk
61
+ */
62
+ async flush() {
63
+ if (this.closed) {
64
+ return;
65
+ }
66
+ // Wait for any pending writes to complete
67
+ while (this.writing) {
68
+ await new Promise((resolve) => setTimeout(resolve, 10));
69
+ }
70
+ }
71
+ /**
72
+ * Get the last assigned sequence number
73
+ */
74
+ getSeq() {
75
+ return this.seq;
76
+ }
77
+ /**
78
+ * Close the writer and cleanup resources
79
+ */
80
+ async close() {
81
+ if (this.closed) {
82
+ return;
83
+ }
84
+ this.closed = true;
85
+ // Wait for any pending writes
86
+ while (this.writing || this.queue.length > 0) {
87
+ await new Promise((resolve) => setTimeout(resolve, 10));
88
+ }
89
+ // Close the output stream
90
+ return new Promise((resolve) => {
91
+ if (this.out) {
92
+ this.out.end(() => resolve());
93
+ }
94
+ else {
95
+ resolve();
96
+ }
97
+ });
98
+ }
99
+ /**
100
+ * Create the next event with auto-filled fields and enqueue it
101
+ */
102
+ nextEvent(event) {
103
+ const seq = ++this.seq;
104
+ const ts = event.ts || new Date().toISOString();
105
+ const fullEvent = {
106
+ ...event,
107
+ v: 1,
108
+ seq,
109
+ ts,
110
+ coconut: this.coconut,
111
+ };
112
+ this.enqueue(fullEvent);
113
+ this.writeSeq();
114
+ return seq;
115
+ }
116
+ /**
117
+ * Drain the queue by writing all pending events
118
+ */
119
+ async drain() {
120
+ this.writing = true;
121
+ try {
122
+ while (this.queue.length > 0) {
123
+ const event = this.queue.shift();
124
+ const line = JSON.stringify(event) + "\n";
125
+ const lineBytes = Buffer.byteLength(line, "utf8");
126
+ try {
127
+ // Write the line
128
+ this.out.write(line);
129
+ // Force sync to disk for real-time SSE streaming
130
+ // Get the file descriptor and sync it
131
+ const fd = this.out.fd;
132
+ if (fd !== undefined && fd !== null) {
133
+ try {
134
+ fs.fsyncSync(fd);
135
+ }
136
+ catch (syncError) {
137
+ // fsync might fail on some systems, continue anyway
138
+ }
139
+ }
140
+ this.bytes += lineBytes;
141
+ // Rotate if we've exceeded the threshold
142
+ if (this.bytes > this.rotateBytes) {
143
+ await this.rotate();
144
+ }
145
+ }
146
+ catch (error) {
147
+ // Log to console but don't crash - logging should never break the app
148
+ console.error('[JsonlWriter] Failed to write event:', error);
149
+ // Try to recreate the file stream if it was closed/deleted
150
+ try {
151
+ this.rotateNewFile();
152
+ }
153
+ catch (recreateError) {
154
+ console.error('[JsonlWriter] Failed to recreate log file:', recreateError);
155
+ }
156
+ }
157
+ }
158
+ }
159
+ finally {
160
+ this.writing = false;
161
+ }
162
+ }
163
+ /**
164
+ * Read the sequence counter from disk
165
+ */
166
+ readSeq() {
167
+ const seqPath = path.join(this.dir, ".seq");
168
+ if (fs.existsSync(seqPath)) {
169
+ const content = fs.readFileSync(seqPath, "utf8").trim();
170
+ const seq = Number(content);
171
+ return isNaN(seq) ? 0 : seq;
172
+ }
173
+ return 0;
174
+ }
175
+ /**
176
+ * Persist the current sequence counter to disk
177
+ */
178
+ writeSeq() {
179
+ try {
180
+ const seqPath = path.join(this.dir, ".seq");
181
+ fs.writeFileSync(seqPath, String(this.seq), "utf8");
182
+ }
183
+ catch (error) {
184
+ // Fail silently - sequence counter is not critical
185
+ console.error('[JsonlWriter] Failed to write sequence counter:', error);
186
+ }
187
+ }
188
+ /**
189
+ * Open a new current file for writing
190
+ */
191
+ rotateNewFile() {
192
+ try {
193
+ this.currentPath = path.join(this.dir, "events-current.jsonl");
194
+ // Ensure directory exists (in case it was deleted)
195
+ if (!fs.existsSync(this.dir)) {
196
+ fs.mkdirSync(this.dir, { recursive: true });
197
+ }
198
+ // Close existing stream if open
199
+ if (this.out) {
200
+ try {
201
+ this.out.end();
202
+ }
203
+ catch {
204
+ // Ignore errors closing old stream
205
+ }
206
+ }
207
+ // Create or append to the file
208
+ // Use highWaterMark: 0 to disable buffering for real-time SSE streaming
209
+ this.out = fs.createWriteStream(this.currentPath, {
210
+ flags: "a",
211
+ highWaterMark: 0 // Disable buffering for immediate disk writes
212
+ });
213
+ // Handle stream errors gracefully
214
+ this.out.on('error', (error) => {
215
+ console.error('[JsonlWriter] Stream error:', error);
216
+ });
217
+ // Calculate current file size
218
+ if (fs.existsSync(this.currentPath)) {
219
+ this.bytes = fs.statSync(this.currentPath).size;
220
+ }
221
+ else {
222
+ this.bytes = 0;
223
+ }
224
+ }
225
+ catch (error) {
226
+ console.error('[JsonlWriter] Failed to open log file:', error);
227
+ throw error; // Only throw on initialization, not during recovery
228
+ }
229
+ }
230
+ /**
231
+ * Rotate the current file to a timestamped archive
232
+ */
233
+ async rotate() {
234
+ // Close the current file
235
+ await new Promise((resolve) => {
236
+ this.out.end(() => resolve());
237
+ });
238
+ // Generate timestamp for the rotated file
239
+ const now = new Date();
240
+ const timestamp = now
241
+ .toISOString()
242
+ .replace(/[:.]/g, "")
243
+ .replace("T", "-")
244
+ .replace("Z", "");
245
+ // Rename current file to timestamped archive
246
+ const rotatedPath = path.join(this.dir, `events-${timestamp}.jsonl`);
247
+ fs.renameSync(this.currentPath, rotatedPath);
248
+ // Open a new current file
249
+ this.rotateNewFile();
250
+ }
251
+ }
252
+ //# sourceMappingURL=jsonl-writer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonl-writer.js","sourceRoot":"","sources":["../../src/logging/jsonl-writer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B;;;;;;;;;GASG;AACH,MAAM,OAAO,WAAW;IACL,GAAG,CAAS;IACZ,OAAO,CAAS;IAChB,WAAW,CAAS;IAC7B,GAAG,GAAG,CAAC,CAAC;IACR,KAAK,GAAe,EAAE,CAAC;IACvB,OAAO,GAAG,KAAK,CAAC;IAChB,GAAG,CAAkB;IACrB,WAAW,CAAU;IACrB,KAAK,GAAG,CAAC,CAAC;IACV,MAAM,GAAG,KAAK,CAAC;IAEvB;;;;;;OAMG;IACH,YAAY,GAAW,EAAE,OAAe,EAAE,WAAW,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI;QACvE,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAE/B,8BAA8B;QAC9B,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAE5C,gCAAgC;QAChC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,OAAO,EAA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}
@@ -0,0 +1,224 @@
1
+ /**
2
+ * Event kind taxonomy for Coconut activity logging
3
+ * @module logging/kinds
4
+ *
5
+ * Event kinds follow a hierarchical naming convention:
6
+ * {entity}.{action}.{qualifier}
7
+ *
8
+ * Examples:
9
+ * - proposal.create
10
+ * - agent.session.start
11
+ * - code.commit
12
+ */
13
+ /**
14
+ * Proposal-related events
15
+ */
16
+ export declare const ProposalKinds: {
17
+ readonly CREATE: "proposal.create";
18
+ readonly UPDATE: "proposal.update";
19
+ readonly RUN_START: "proposal.run.start";
20
+ readonly RUN_END: "proposal.run.end";
21
+ readonly STATUS_CHANGE: "proposal.status.change";
22
+ };
23
+ /**
24
+ * Agent and session events
25
+ */
26
+ export declare const AgentKinds: {
27
+ readonly SESSION_START: "agent.session.start";
28
+ readonly SESSION_STDOUT: "agent.session.stdout";
29
+ readonly SESSION_END: "agent.session.end";
30
+ readonly SESSION_ERROR: "agent.session.error";
31
+ };
32
+ /**
33
+ * Code and git-related events
34
+ */
35
+ export declare const CodeKinds: {
36
+ readonly EDIT: "code.edit";
37
+ readonly COMMIT: "code.commit";
38
+ readonly BRANCH_CREATE: "code.branch.create";
39
+ readonly WORKTREE_ADD: "code.worktree.add";
40
+ };
41
+ /**
42
+ * Knowledge base events
43
+ */
44
+ export declare const KnowledgeKinds: {
45
+ readonly CREATE: "knowledge.create";
46
+ readonly UPDATE: "knowledge.update";
47
+ readonly DELETE: "knowledge.delete";
48
+ };
49
+ /**
50
+ * Job scheduling and execution events
51
+ */
52
+ export declare const JobKinds: {
53
+ readonly SCHEDULE: "job.schedule";
54
+ readonly RUN_START: "job.run.start";
55
+ readonly RUN_END: "job.run.end";
56
+ readonly RUN_ERROR: "job.run.error";
57
+ };
58
+ /**
59
+ * Resource management events
60
+ */
61
+ export declare const ResourceKinds: {
62
+ readonly UPLOAD: "resource.upload";
63
+ readonly DELETE: "resource.delete";
64
+ };
65
+ /**
66
+ * Authentication events (when auth is enabled)
67
+ */
68
+ export declare const AuthKinds: {
69
+ readonly LOGIN: "auth.login";
70
+ readonly LOGOUT: "auth.logout";
71
+ readonly API_KEY_USE: "auth.api.key.use";
72
+ readonly API_KEY_CREATE: "auth.api.key.create";
73
+ readonly API_KEY_DELETE: "auth.api.key.delete";
74
+ };
75
+ /**
76
+ * All event kinds in a single object
77
+ */
78
+ export declare const EventKinds: {
79
+ readonly LOGIN: "auth.login";
80
+ readonly LOGOUT: "auth.logout";
81
+ readonly API_KEY_USE: "auth.api.key.use";
82
+ readonly API_KEY_CREATE: "auth.api.key.create";
83
+ readonly API_KEY_DELETE: "auth.api.key.delete";
84
+ readonly UPLOAD: "resource.upload";
85
+ readonly DELETE: "resource.delete";
86
+ readonly SCHEDULE: "job.schedule";
87
+ readonly RUN_START: "job.run.start";
88
+ readonly RUN_END: "job.run.end";
89
+ readonly RUN_ERROR: "job.run.error";
90
+ readonly CREATE: "knowledge.create";
91
+ readonly UPDATE: "knowledge.update";
92
+ readonly EDIT: "code.edit";
93
+ readonly COMMIT: "code.commit";
94
+ readonly BRANCH_CREATE: "code.branch.create";
95
+ readonly WORKTREE_ADD: "code.worktree.add";
96
+ readonly SESSION_START: "agent.session.start";
97
+ readonly SESSION_STDOUT: "agent.session.stdout";
98
+ readonly SESSION_END: "agent.session.end";
99
+ readonly SESSION_ERROR: "agent.session.error";
100
+ readonly STATUS_CHANGE: "proposal.status.change";
101
+ };
102
+ /**
103
+ * Type representing all valid event kind strings
104
+ */
105
+ export type EventKind = typeof EventKinds[keyof typeof EventKinds];
106
+ /**
107
+ * Helper to validate if a string is a known event kind
108
+ */
109
+ export declare function isValidEventKind(kind: string): kind is EventKind;
110
+ /**
111
+ * Registry of event kinds with metadata
112
+ * Useful for documentation and validation
113
+ */
114
+ export declare const EventKindRegistry: {
115
+ readonly "proposal.create": {
116
+ readonly description: "A new change proposal was created";
117
+ readonly tags: readonly ["proposal"];
118
+ };
119
+ readonly "proposal.update": {
120
+ readonly description: "A change proposal was updated";
121
+ readonly tags: readonly ["proposal"];
122
+ };
123
+ readonly "proposal.run.start": {
124
+ readonly description: "Implementation of a proposal started";
125
+ readonly tags: readonly ["proposal", "execution"];
126
+ };
127
+ readonly "proposal.run.end": {
128
+ readonly description: "Implementation of a proposal completed";
129
+ readonly tags: readonly ["proposal", "execution"];
130
+ };
131
+ readonly "proposal.status.change": {
132
+ readonly description: "Proposal status changed";
133
+ readonly tags: readonly ["proposal"];
134
+ };
135
+ readonly "agent.session.start": {
136
+ readonly description: "Agent session started";
137
+ readonly tags: readonly ["agent", "session"];
138
+ };
139
+ readonly "agent.session.stdout": {
140
+ readonly description: "Agent session output";
141
+ readonly tags: readonly ["agent", "session"];
142
+ };
143
+ readonly "agent.session.end": {
144
+ readonly description: "Agent session ended";
145
+ readonly tags: readonly ["agent", "session"];
146
+ };
147
+ readonly "agent.session.error": {
148
+ readonly description: "Agent session encountered an error";
149
+ readonly tags: readonly ["agent", "session", "error"];
150
+ };
151
+ readonly "code.edit": {
152
+ readonly description: "Code was edited";
153
+ readonly tags: readonly ["code"];
154
+ };
155
+ readonly "code.commit": {
156
+ readonly description: "Git commit was created";
157
+ readonly tags: readonly ["code", "git"];
158
+ };
159
+ readonly "code.branch.create": {
160
+ readonly description: "Git branch was created";
161
+ readonly tags: readonly ["code", "git"];
162
+ };
163
+ readonly "code.worktree.add": {
164
+ readonly description: "Git worktree was added";
165
+ readonly tags: readonly ["code", "git"];
166
+ };
167
+ readonly "knowledge.create": {
168
+ readonly description: "Knowledge base entry created";
169
+ readonly tags: readonly ["knowledge"];
170
+ };
171
+ readonly "knowledge.update": {
172
+ readonly description: "Knowledge base entry updated";
173
+ readonly tags: readonly ["knowledge"];
174
+ };
175
+ readonly "knowledge.delete": {
176
+ readonly description: "Knowledge base entry deleted";
177
+ readonly tags: readonly ["knowledge"];
178
+ };
179
+ readonly "job.schedule": {
180
+ readonly description: "Job was scheduled";
181
+ readonly tags: readonly ["job"];
182
+ };
183
+ readonly "job.run.start": {
184
+ readonly description: "Job run started";
185
+ readonly tags: readonly ["job", "execution"];
186
+ };
187
+ readonly "job.run.end": {
188
+ readonly description: "Job run completed";
189
+ readonly tags: readonly ["job", "execution"];
190
+ };
191
+ readonly "job.run.error": {
192
+ readonly description: "Job run failed with error";
193
+ readonly tags: readonly ["job", "execution", "error"];
194
+ };
195
+ readonly "resource.upload": {
196
+ readonly description: "Resource was uploaded";
197
+ readonly tags: readonly ["resource"];
198
+ };
199
+ readonly "resource.delete": {
200
+ readonly description: "Resource was deleted";
201
+ readonly tags: readonly ["resource"];
202
+ };
203
+ readonly "auth.login": {
204
+ readonly description: "User logged in";
205
+ readonly tags: readonly ["auth"];
206
+ };
207
+ readonly "auth.logout": {
208
+ readonly description: "User logged out";
209
+ readonly tags: readonly ["auth"];
210
+ };
211
+ readonly "auth.api.key.use": {
212
+ readonly description: "API key was used for authentication";
213
+ readonly tags: readonly ["auth", "api"];
214
+ };
215
+ readonly "auth.api.key.create": {
216
+ readonly description: "API key was created";
217
+ readonly tags: readonly ["auth", "api"];
218
+ };
219
+ readonly "auth.api.key.delete": {
220
+ readonly description: "API key was deleted";
221
+ readonly tags: readonly ["auth", "api"];
222
+ };
223
+ };
224
+ //# sourceMappingURL=kinds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kinds.d.ts","sourceRoot":"","sources":["../../src/logging/kinds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;CAMhB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;CAKb,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;CAKZ,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,cAAc;;;;CAIjB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;;CAKX,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,aAAa;;;CAGhB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;CAMZ,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;CAQb,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,UAAU,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAEnE;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,SAAS,CAEhE;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6GpB,CAAC"}