synomem 0.1.0

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 (130) hide show
  1. package/AGENTS.md +42 -0
  2. package/ARCHITECTURE.md +126 -0
  3. package/CHANGELOG.md +35 -0
  4. package/CODE_OF_CONDUCT.md +29 -0
  5. package/CONTRIBUTING.md +48 -0
  6. package/LICENSE +21 -0
  7. package/README.md +247 -0
  8. package/SECURITY.md +117 -0
  9. package/dist/backend.d.ts +9 -0
  10. package/dist/backend.d.ts.map +1 -0
  11. package/dist/backend.js +60 -0
  12. package/dist/backend.js.map +1 -0
  13. package/dist/cli.d.ts +34 -0
  14. package/dist/cli.d.ts.map +1 -0
  15. package/dist/cli.js +1040 -0
  16. package/dist/cli.js.map +1 -0
  17. package/dist/client.d.ts +168 -0
  18. package/dist/client.d.ts.map +1 -0
  19. package/dist/client.js +1031 -0
  20. package/dist/client.js.map +1 -0
  21. package/dist/config.d.ts +33 -0
  22. package/dist/config.d.ts.map +1 -0
  23. package/dist/config.js +153 -0
  24. package/dist/config.js.map +1 -0
  25. package/dist/credentials.d.ts +36 -0
  26. package/dist/credentials.d.ts.map +1 -0
  27. package/dist/credentials.js +127 -0
  28. package/dist/credentials.js.map +1 -0
  29. package/dist/errors.d.ts +9 -0
  30. package/dist/errors.d.ts.map +1 -0
  31. package/dist/errors.js +60 -0
  32. package/dist/errors.js.map +1 -0
  33. package/dist/fs-utils.d.ts +7 -0
  34. package/dist/fs-utils.d.ts.map +1 -0
  35. package/dist/fs-utils.js +68 -0
  36. package/dist/fs-utils.js.map +1 -0
  37. package/dist/import.d.ts +655 -0
  38. package/dist/import.d.ts.map +1 -0
  39. package/dist/import.js +226 -0
  40. package/dist/import.js.map +1 -0
  41. package/dist/index.d.ts +20 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +11 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/mcp/index.d.ts +14 -0
  46. package/dist/mcp/index.d.ts.map +1 -0
  47. package/dist/mcp/index.js +698 -0
  48. package/dist/mcp/index.js.map +1 -0
  49. package/dist/mcp-server.d.ts +3 -0
  50. package/dist/mcp-server.d.ts.map +1 -0
  51. package/dist/mcp-server.js +45 -0
  52. package/dist/mcp-server.js.map +1 -0
  53. package/dist/oauth.d.ts +27 -0
  54. package/dist/oauth.d.ts.map +1 -0
  55. package/dist/oauth.js +201 -0
  56. package/dist/oauth.js.map +1 -0
  57. package/dist/ports/projections.d.ts +6 -0
  58. package/dist/ports/projections.d.ts.map +1 -0
  59. package/dist/ports/projections.js +2 -0
  60. package/dist/ports/projections.js.map +1 -0
  61. package/dist/ports/repository.d.ts +31 -0
  62. package/dist/ports/repository.d.ts.map +1 -0
  63. package/dist/ports/repository.js +2 -0
  64. package/dist/ports/repository.js.map +1 -0
  65. package/dist/projections.d.ts +24 -0
  66. package/dist/projections.d.ts.map +1 -0
  67. package/dist/projections.js +531 -0
  68. package/dist/projections.js.map +1 -0
  69. package/dist/remote.d.ts +120 -0
  70. package/dist/remote.d.ts.map +1 -0
  71. package/dist/remote.js +286 -0
  72. package/dist/remote.js.map +1 -0
  73. package/dist/schemas.d.ts +901 -0
  74. package/dist/schemas.d.ts.map +1 -0
  75. package/dist/schemas.js +424 -0
  76. package/dist/schemas.js.map +1 -0
  77. package/dist/service.d.ts +126 -0
  78. package/dist/service.d.ts.map +1 -0
  79. package/dist/service.js +2 -0
  80. package/dist/service.js.map +1 -0
  81. package/dist/skill-install.d.ts +34 -0
  82. package/dist/skill-install.d.ts.map +1 -0
  83. package/dist/skill-install.js +256 -0
  84. package/dist/skill-install.js.map +1 -0
  85. package/dist/storage.d.ts +94 -0
  86. package/dist/storage.d.ts.map +1 -0
  87. package/dist/storage.js +1229 -0
  88. package/dist/storage.js.map +1 -0
  89. package/dist/types.d.ts +442 -0
  90. package/dist/types.d.ts.map +1 -0
  91. package/dist/types.js +2 -0
  92. package/dist/types.js.map +1 -0
  93. package/dist/version.d.ts +3 -0
  94. package/dist/version.d.ts.map +1 -0
  95. package/dist/version.js +14 -0
  96. package/dist/version.js.map +1 -0
  97. package/docs/cli.md +180 -0
  98. package/docs/examples.md +70 -0
  99. package/docs/mcp.md +96 -0
  100. package/docs/recovery.md +45 -0
  101. package/docs/releasing.md +61 -0
  102. package/docs/skill.md +93 -0
  103. package/docs/storage-format.md +83 -0
  104. package/openapi/synomem-v1.yaml +674 -0
  105. package/package.json +100 -0
  106. package/skills/synomem/SKILL.md +71 -0
  107. package/skills/synomem/agents/openai.yaml +8 -0
  108. package/skills/synomem/references/examples.md +28 -0
  109. package/src/backend.ts +91 -0
  110. package/src/cli.ts +1623 -0
  111. package/src/client.ts +1261 -0
  112. package/src/config.ts +170 -0
  113. package/src/credentials.ts +194 -0
  114. package/src/errors.ts +64 -0
  115. package/src/fs-utils.ts +85 -0
  116. package/src/import.ts +284 -0
  117. package/src/index.ts +61 -0
  118. package/src/mcp/index.ts +973 -0
  119. package/src/mcp-server.ts +46 -0
  120. package/src/oauth.ts +252 -0
  121. package/src/ports/projections.ts +6 -0
  122. package/src/ports/repository.ts +67 -0
  123. package/src/projections.ts +624 -0
  124. package/src/remote.ts +516 -0
  125. package/src/schemas.ts +457 -0
  126. package/src/service.ts +140 -0
  127. package/src/skill-install.ts +332 -0
  128. package/src/storage.ts +1603 -0
  129. package/src/types.ts +458 -0
  130. package/src/version.ts +16 -0
package/src/types.ts ADDED
@@ -0,0 +1,458 @@
1
+ export type JsonPrimitive = string | number | boolean | null;
2
+ export type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue };
3
+
4
+ export type ActorKind = 'human' | 'agent' | 'system';
5
+ export type Visibility = 'private' | 'workspace' | 'public';
6
+ export type RecordKind = 'kudos' | 'memo' | 'note' | 'todo';
7
+
8
+ export interface ActorIdentity {
9
+ kind: ActorKind;
10
+ id: string;
11
+ displayName?: string;
12
+ }
13
+
14
+ export interface EventSource {
15
+ runtime?: string;
16
+ model?: string;
17
+ sessionId?: string;
18
+ repository?: string;
19
+ commit?: string;
20
+ workingDirectory?: string;
21
+ }
22
+
23
+ export type EvidenceKind = 'tool-call' | 'commit' | 'file' | 'url' | 'task' | 'note';
24
+ export interface EvidenceReference {
25
+ kind: EvidenceKind;
26
+ label?: string;
27
+ value: string;
28
+ }
29
+
30
+ export interface AgentProfile {
31
+ id: string;
32
+ displayName: string;
33
+ aliases?: string[];
34
+ description?: string;
35
+ createdAt: string;
36
+ metadata?: Record<string, JsonValue>;
37
+ }
38
+
39
+ export interface BaseEvent {
40
+ schemaVersion: 1;
41
+ id: string;
42
+ type: string;
43
+ workspaceId: string;
44
+ aggregateId: string;
45
+ aggregateVersion: number;
46
+ createdAt: string;
47
+ actor: ActorIdentity;
48
+ idempotencyKey?: string;
49
+ source?: EventSource;
50
+ metadata?: Record<string, JsonValue>;
51
+ }
52
+
53
+ export interface KudosGivenEvent extends BaseEvent {
54
+ type: 'kudos.given';
55
+ recipientAgentId: string;
56
+ recipientDisplayName: string;
57
+ title: string;
58
+ reason: string;
59
+ evidence?: EvidenceReference[];
60
+ tags?: string[];
61
+ visibility: Visibility;
62
+ }
63
+ export interface KudosAcknowledgedEvent extends BaseEvent {
64
+ type: 'kudos.acknowledged';
65
+ kudosId: string;
66
+ recipientAgentId: string;
67
+ note?: string;
68
+ }
69
+ export interface KudosRevokedEvent extends BaseEvent {
70
+ type: 'kudos.revoked';
71
+ kudosId: string;
72
+ reason: string;
73
+ mode: 'actor-requested' | 'administrative';
74
+ }
75
+
76
+ export interface MemoSentEvent extends BaseEvent {
77
+ type: 'memo.sent';
78
+ recipientAgentId: string;
79
+ recipientDisplayName: string;
80
+ subject: string;
81
+ body: string;
82
+ tags?: string[];
83
+ visibility: Visibility;
84
+ }
85
+ export interface MemoReadEvent extends BaseEvent {
86
+ type: 'memo.read';
87
+ memoId: string;
88
+ recipientAgentId: string;
89
+ }
90
+ export interface MemoArchivedEvent extends BaseEvent {
91
+ type: 'memo.archived';
92
+ memoId: string;
93
+ recipientAgentId: string;
94
+ }
95
+
96
+ export interface NoteCreatedEvent extends BaseEvent {
97
+ type: 'note.created';
98
+ ownerAgentId: string;
99
+ ownerDisplayName: string;
100
+ title: string;
101
+ body: string;
102
+ tags?: string[];
103
+ visibility: 'private';
104
+ }
105
+ export interface NoteRevisedEvent extends BaseEvent {
106
+ type: 'note.revised';
107
+ noteId: string;
108
+ title: string;
109
+ body: string;
110
+ tags?: string[];
111
+ visibility: 'private';
112
+ }
113
+ export interface NoteArchivedEvent extends BaseEvent {
114
+ type: 'note.archived';
115
+ noteId: string;
116
+ }
117
+
118
+ export type TodoPriority = 1 | 2 | 3 | 4;
119
+ export type TodoDue =
120
+ { kind: 'date'; date: string } | { kind: 'datetime'; datetime: string; timeZone: string };
121
+ export interface TodoCreatedEvent extends BaseEvent {
122
+ type: 'todo.created';
123
+ assigneeAgentId: string;
124
+ assigneeDisplayName: string;
125
+ title: string;
126
+ description?: string;
127
+ priority: TodoPriority;
128
+ due?: TodoDue;
129
+ tags?: string[];
130
+ visibility: Visibility;
131
+ requiresAcceptance: boolean;
132
+ }
133
+ export interface TodoUpdatedEvent extends BaseEvent {
134
+ type: 'todo.updated';
135
+ todoId: string;
136
+ title: string;
137
+ description?: string;
138
+ priority: TodoPriority;
139
+ due?: TodoDue;
140
+ tags?: string[];
141
+ visibility: Visibility;
142
+ }
143
+ export interface TodoCompletedEvent extends BaseEvent {
144
+ type: 'todo.completed';
145
+ todoId: string;
146
+ note?: string;
147
+ }
148
+ export interface TodoReopenedEvent extends BaseEvent {
149
+ type: 'todo.reopened';
150
+ todoId: string;
151
+ }
152
+ export interface TodoAcceptedEvent extends BaseEvent {
153
+ type: 'todo.accepted';
154
+ todoId: string;
155
+ }
156
+ export interface TodoRejectedEvent extends BaseEvent {
157
+ type: 'todo.rejected';
158
+ todoId: string;
159
+ reason?: string;
160
+ }
161
+ export interface TodoCanceledEvent extends BaseEvent {
162
+ type: 'todo.canceled';
163
+ todoId: string;
164
+ reason?: string;
165
+ }
166
+
167
+ export interface AgentCreatedEvent extends BaseEvent {
168
+ type: 'agent.created';
169
+ agent: AgentProfile;
170
+ }
171
+ export interface AgentUpdatedEvent extends BaseEvent {
172
+ type: 'agent.updated';
173
+ agentId: string;
174
+ changes: Partial<Omit<AgentProfile, 'id' | 'createdAt'>>;
175
+ }
176
+
177
+ export type SynomemEvent =
178
+ | KudosGivenEvent
179
+ | KudosAcknowledgedEvent
180
+ | KudosRevokedEvent
181
+ | MemoSentEvent
182
+ | MemoReadEvent
183
+ | MemoArchivedEvent
184
+ | NoteCreatedEvent
185
+ | NoteRevisedEvent
186
+ | NoteArchivedEvent
187
+ | TodoCreatedEvent
188
+ | TodoUpdatedEvent
189
+ | TodoCompletedEvent
190
+ | TodoReopenedEvent
191
+ | TodoAcceptedEvent
192
+ | TodoRejectedEvent
193
+ | TodoCanceledEvent
194
+ | AgentCreatedEvent
195
+ | AgentUpdatedEvent;
196
+
197
+ export type AcknowledgmentStatus = 'acknowledged' | 'unacknowledged';
198
+ export type RevocationStatus = 'revoked' | 'active';
199
+ export interface KudosRecord {
200
+ event: KudosGivenEvent;
201
+ acknowledgment?: KudosAcknowledgedEvent;
202
+ revocation?: KudosRevokedEvent;
203
+ status: AcknowledgmentStatus;
204
+ revocationStatus: RevocationStatus;
205
+ }
206
+ export interface MemoRecord {
207
+ event: MemoSentEvent;
208
+ read?: MemoReadEvent;
209
+ archived?: MemoArchivedEvent;
210
+ status: 'unread' | 'read' | 'archived';
211
+ }
212
+ export interface NoteRecord {
213
+ event: NoteCreatedEvent;
214
+ revision?: NoteRevisedEvent;
215
+ archived?: NoteArchivedEvent;
216
+ current: { title: string; body: string; tags: string[]; visibility: Visibility; version: number };
217
+ status: 'active' | 'archived';
218
+ }
219
+ export interface TodoRecord {
220
+ event: TodoCreatedEvent;
221
+ update?: TodoUpdatedEvent;
222
+ terminal?: TodoCompletedEvent | TodoRejectedEvent | TodoCanceledEvent;
223
+ reopened?: TodoReopenedEvent;
224
+ current: {
225
+ title: string;
226
+ description?: string;
227
+ priority: TodoPriority;
228
+ due?: TodoDue;
229
+ tags: string[];
230
+ visibility: Visibility;
231
+ version: number;
232
+ };
233
+ status: 'assigned' | 'open' | 'completed' | 'rejected' | 'canceled';
234
+ }
235
+ export type ItemRecord = KudosRecord | MemoRecord | NoteRecord | TodoRecord;
236
+
237
+ export interface ItemSummary {
238
+ id: string;
239
+ kind: RecordKind;
240
+ createdAt: string;
241
+ updatedAt: string;
242
+ actor: ActorIdentity;
243
+ title: string;
244
+ tags: string[];
245
+ visibility: Visibility;
246
+ status: string;
247
+ recipientAgentId?: string;
248
+ ownerAgentId?: string;
249
+ assigneeAgentId?: string;
250
+ }
251
+ export interface KudosSummary extends ItemSummary {
252
+ kind: 'kudos';
253
+ recipientAgentId: string;
254
+ recipientDisplayName: string;
255
+ status: AcknowledgmentStatus;
256
+ revocationStatus: RevocationStatus;
257
+ }
258
+
259
+ export interface PaginationInput {
260
+ limit?: number;
261
+ cursor?: string;
262
+ /** @deprecated */ offset?: number;
263
+ }
264
+ export interface ItemListInput extends PaginationInput {
265
+ kinds?: RecordKind[];
266
+ participantAgentId?: string;
267
+ actorId?: string;
268
+ actorKind?: ActorKind;
269
+ tag?: string;
270
+ status?: string;
271
+ visibility?: Visibility;
272
+ from?: string;
273
+ to?: string;
274
+ /** Limit results to actionable inbox states; intended for the participant's own inbox. */
275
+ pending?: boolean;
276
+ }
277
+ export interface KudosListInput extends PaginationInput {
278
+ recipientAgentId?: string;
279
+ actorId?: string;
280
+ actorKind?: ActorKind;
281
+ tag?: string;
282
+ status?: AcknowledgmentStatus;
283
+ visibility?: Visibility;
284
+ revoked?: boolean;
285
+ from?: string;
286
+ to?: string;
287
+ }
288
+ export interface Page<T> {
289
+ items: T[];
290
+ total: number;
291
+ limit: number;
292
+ offset: number;
293
+ nextCursor?: string;
294
+ hasMore: boolean;
295
+ watermark: string;
296
+ contextLimited: boolean;
297
+ }
298
+ export interface ItemChange {
299
+ cursor: string;
300
+ sequence: number;
301
+ eventId: string;
302
+ type: SynomemEvent['type'];
303
+ createdAt: string;
304
+ actor: ActorIdentity;
305
+ itemId?: string;
306
+ kind?: RecordKind;
307
+ summary?: ItemSummary;
308
+ /** Present for kudos changes. */ kudosId?: string;
309
+ /** Present for direct-recipient changes. */ recipientAgentId?: string;
310
+ }
311
+ export interface KudosChange extends ItemChange {
312
+ kudosId?: string;
313
+ recipientAgentId?: string;
314
+ summary?: KudosSummary;
315
+ }
316
+ export interface ChangesInput {
317
+ after?: string;
318
+ limit?: number;
319
+ kinds?: RecordKind[];
320
+ }
321
+ export type KudosChangesInput = ChangesInput;
322
+ export interface ChangePage {
323
+ items: ItemChange[];
324
+ limit: number;
325
+ nextCursor?: string;
326
+ hasMore: boolean;
327
+ watermark: string;
328
+ contextLimited: boolean;
329
+ }
330
+
331
+ interface MutationInput {
332
+ idempotencyKey?: string;
333
+ source?: EventSource;
334
+ metadata?: Record<string, JsonValue>;
335
+ }
336
+ export interface GiveKudosInput extends MutationInput {
337
+ recipientAgentId: string;
338
+ title: string;
339
+ reason: string;
340
+ evidence?: EvidenceReference[];
341
+ tags?: string[];
342
+ visibility?: Visibility;
343
+ }
344
+ export interface SendMemoInput extends MutationInput {
345
+ recipientAgentId: string;
346
+ subject: string;
347
+ body: string;
348
+ tags?: string[];
349
+ visibility?: Visibility;
350
+ }
351
+ export interface CreateNoteInput extends MutationInput {
352
+ ownerAgentId?: string;
353
+ title: string;
354
+ body: string;
355
+ tags?: string[];
356
+ }
357
+ export interface ReviseNoteInput extends MutationInput {
358
+ noteId: string;
359
+ expectedVersion: number;
360
+ title?: string;
361
+ body?: string;
362
+ tags?: string[];
363
+ }
364
+ export interface CreateTodoInput extends MutationInput {
365
+ assigneeAgentId?: string;
366
+ title: string;
367
+ description?: string;
368
+ priority?: TodoPriority;
369
+ due?: TodoDue;
370
+ tags?: string[];
371
+ visibility?: Visibility;
372
+ }
373
+ export interface UpdateTodoInput extends MutationInput {
374
+ todoId: string;
375
+ expectedVersion: number;
376
+ title?: string;
377
+ description?: string;
378
+ priority?: TodoPriority;
379
+ due?: TodoDue | null;
380
+ tags?: string[];
381
+ visibility?: Visibility;
382
+ }
383
+ export interface MutationResult<T> {
384
+ record: T;
385
+ created: boolean;
386
+ deduplicated: boolean;
387
+ }
388
+ export type GiveKudosResult = MutationResult<KudosRecord>;
389
+ export type SendMemoResult = MutationResult<MemoRecord>;
390
+ export type CreateNoteResult = MutationResult<NoteRecord>;
391
+ export type CreateTodoResult = MutationResult<TodoRecord>;
392
+
393
+ export interface CreateAgentInput {
394
+ id: string;
395
+ displayName: string;
396
+ aliases?: string[];
397
+ description?: string;
398
+ metadata?: Record<string, JsonValue>;
399
+ }
400
+ export interface UpdateAgentInput {
401
+ displayName?: string;
402
+ aliases?: string[];
403
+ description?: string;
404
+ metadata?: Record<string, JsonValue>;
405
+ }
406
+ export interface KudosStats {
407
+ total: number;
408
+ active: number;
409
+ acknowledged: number;
410
+ revoked: number;
411
+ byAgent: Record<string, number>;
412
+ byActor: Record<string, number>;
413
+ byTag: Record<string, number>;
414
+ }
415
+ export interface Diagnostic {
416
+ level: 'ok' | 'warning' | 'error';
417
+ code: string;
418
+ message: string;
419
+ path?: string;
420
+ }
421
+ export interface DoctorResult {
422
+ healthy: boolean;
423
+ diagnostics: Diagnostic[];
424
+ }
425
+
426
+ export type SynomemBackendConfig =
427
+ { kind: 'local' } | { kind: 'remote'; baseUrl: string; workspaceId: string };
428
+
429
+ export interface SynomemConfig {
430
+ schemaVersion: 3;
431
+ backend: SynomemBackendConfig;
432
+ workspaceId: string;
433
+ defaultVisibility: Visibility;
434
+ allowSelfAwards: boolean;
435
+ allowCrossAgentTodos: boolean;
436
+ allowAgentCreationViaMcp: boolean;
437
+ allowRebuildViaMcp: boolean;
438
+ includePrivateInStats: boolean;
439
+ projection: {
440
+ writeWinsMarkdown: boolean;
441
+ writeMemoryMarkdown: boolean;
442
+ writeTodosMarkdown: boolean;
443
+ writeInboxEntries: boolean;
444
+ };
445
+ }
446
+ export type SynomemConfigOverrides = Omit<Partial<SynomemConfig>, 'projection' | 'backend'> & {
447
+ projection?: Partial<SynomemConfig['projection']>;
448
+ backend?: SynomemBackendConfig;
449
+ };
450
+ export interface SynomemClientOptions {
451
+ home?: string;
452
+ actor?: ActorIdentity;
453
+ clock?: () => Date;
454
+ idGenerator?: () => string;
455
+ readOnly?: boolean;
456
+ config?: SynomemConfigOverrides;
457
+ signal?: AbortSignal;
458
+ }
package/src/version.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { readFileSync } from 'node:fs';
2
+
3
+ let cachedVersion: string | undefined;
4
+
5
+ /** Read the installed package metadata lazily so every runtime surface reports one version. */
6
+ export function packageVersion(): string {
7
+ if (cachedVersion) return cachedVersion;
8
+ const metadata = JSON.parse(
9
+ readFileSync(new URL('../package.json', import.meta.url), 'utf8'),
10
+ ) as { version?: unknown };
11
+ if (typeof metadata.version !== 'string' || !metadata.version) {
12
+ throw new Error('synomem package.json has no valid version.');
13
+ }
14
+ cachedVersion = metadata.version;
15
+ return cachedVersion;
16
+ }