@anteros/core 0.0.42 → 0.0.44

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 (55) hide show
  1. package/database/replication.ts +614 -26
  2. package/lib/agent.ts +279 -39
  3. package/lib/agentMemory.ts +103 -0
  4. package/lib/agents.ts +25 -2
  5. package/lib/define.ts +1 -1
  6. package/lib/mcpClient.ts +128 -0
  7. package/lib/providers.ts +169 -66
  8. package/lib/skills.ts +481 -0
  9. package/package.json +1 -1
  10. package/server/agents.ts +27 -6
  11. package/server/api.ts +74 -1
  12. package/tests/agent-mcp.test.ts +116 -0
  13. package/tests/agent-memory.test.ts +6 -6
  14. package/tests/agent-provider.test.ts +288 -0
  15. package/tests/agent-runtime.test.ts +369 -0
  16. package/tests/agent-skills.test.ts +177 -0
  17. package/tests/agent-summarize.test.ts +124 -0
  18. package/tests/agent-working-memory.test.ts +5 -3
  19. package/tests/agent.test.ts +18 -16
  20. package/tests/agents-api.test.ts +1 -1
  21. package/tests/api-private-fields.test.ts +196 -0
  22. package/tests/file-collection-replication.test.ts +2 -0
  23. package/tests/fixtures/agent-tenant/agents/support.agent.ts +1 -1
  24. package/tests/fixtures/agent-tenant/agents/weather.agent.ts +1 -1
  25. package/tests/fixtures/agents-api/agents/assistant.agent.ts +1 -1
  26. package/tests/fixtures/agents-api/agents/plain.agent.ts +1 -1
  27. package/tests/fixtures/agents-api/agents/private.agent.ts +1 -1
  28. package/tests/fixtures/repl-only/app.ts +3 -0
  29. package/tests/fixtures/replication-meta/agents/chat.agent.ts +1 -1
  30. package/tests/fixtures/skills-tenant/agents/docs.agent.ts +23 -0
  31. package/tests/fixtures/skills-tenant/agents/incomplete.agent.ts +14 -0
  32. package/tests/fixtures/skills-tenant/broken/bad-name.md +6 -0
  33. package/tests/fixtures/skills-tenant/broken/dup-a.md +6 -0
  34. package/tests/fixtures/skills-tenant/broken/dup-b.md +6 -0
  35. package/tests/fixtures/skills-tenant/broken/empty-body.md +4 -0
  36. package/tests/fixtures/skills-tenant/broken/long-compat.md +7 -0
  37. package/tests/fixtures/skills-tenant/broken/long-description.md +6 -0
  38. package/tests/fixtures/skills-tenant/broken/mismatch/SKILL.md +6 -0
  39. package/tests/fixtures/skills-tenant/broken/no-description.md +5 -0
  40. package/tests/fixtures/skills-tenant/broken/no-name.md +5 -0
  41. package/tests/fixtures/skills-tenant/broken/plain.md +4 -0
  42. package/tests/fixtures/skills-tenant/broken/unknown-key.md +9 -0
  43. package/tests/fixtures/skills-tenant/docs/pdf-forms.md +18 -0
  44. package/tests/fixtures/skills-tenant/guide/ml.md +9 -0
  45. package/tests/fixtures/skills-tenant/guides/pdf/SKILL.md +9 -0
  46. package/tests/fixtures/skills-tenant/runbooks/incident.md +9 -0
  47. package/tests/fixtures/skills-tenant/runbooks/notes.txt +2 -0
  48. package/tests/replication-change-stream.test.ts +240 -0
  49. package/tests/replication-control.test.ts +2 -0
  50. package/tests/replication-initial-sync.test.ts +2 -0
  51. package/tests/replication-meta.test.ts +3 -0
  52. package/tests/replication.test.ts +2 -0
  53. package/tests/vars-replication.test.ts +2 -0
  54. package/types/agent.d.ts +237 -7
  55. package/types/replication.d.ts +41 -4
@@ -5,6 +5,21 @@ export type ReplicationSchedule =
5
5
  | { cron: string }
6
6
  | { interval: string | number };
7
7
 
8
+ /**
9
+ * How replication detects changes (default: `'changeStream'`).
10
+ *
11
+ * - `'changeStream'` — tails the MongoDB oplog through change streams: real-time,
12
+ * exact position (a **resume token**, no `key` to scan), and **native deletes**
13
+ * (including the ones no hook can see: a TTL expiry on `_audit_` / `_workflows_`).
14
+ * Requires a replica set or a sharded cluster; on a standalone source the engine
15
+ * logs it once and falls back to `'scan'`. `schedule` is then ignored (the stream
16
+ * is continuous), `key`/`batchSize` only size the initial backfill, and `lookback`
17
+ * is unnecessary (a resume token has no clock skew).
18
+ * - `'scan'` — the historical engine: a periodic scan of the source on the `key`
19
+ * date field, with `lookback` and applicative delete tombstones.
20
+ */
21
+ export type ReplicationMode = "changeStream" | "scan";
22
+
8
23
  /**
9
24
  * Initial synchronization mode — how replication starts when no `_replication_`
10
25
  * state exists yet.
@@ -46,16 +61,29 @@ export type ReplicationMetaName = 'audit' | 'workflows' | 'locks' | 'replication
46
61
  export type ReplicationConfig = {
47
62
  /** Enable/disable replication for this scope (default: true when `destinations` is non-empty). */
48
63
  enabled?: boolean;
49
- /** Scheduling — `{ cron }` or `{ interval }` (default: every 5 minutes). */
64
+ /**
65
+ * Change-detection mode (default: `'changeStream'`, auto-fallback to `'scan'`
66
+ * when the source is a standalone `mongod`). See {@link ReplicationMode}.
67
+ */
68
+ mode?: ReplicationMode;
69
+ /**
70
+ * Scheduling — `{ cron }` or `{ interval }` (default: every 5 minutes).
71
+ * **Ignored in `changeStream` mode**: the change stream is continuous.
72
+ */
50
73
  schedule?: ReplicationSchedule;
51
- /** Date key used for incremental replication (default: `'updatedAt'`). */
74
+ /**
75
+ * Date key used to read the source (default: `'updatedAt'`). In `'scan'` mode it
76
+ * is the change-detection key (it must be updated on every write); in
77
+ * `'changeStream'` mode it only drives the initial backfill / catch-up run.
78
+ */
52
79
  key?: string;
53
80
  /**
54
81
  * Rewind the cursor by this many milliseconds on each run, so documents
55
82
  * written slightly out of order (clock skew) are not missed (default: 0).
83
+ * Ignored in `changeStream` mode — a resume token has no clock skew.
56
84
  */
57
85
  lookback?: number;
58
- /** Documents transferred per batch (default: 1000). */
86
+ /** Documents transferred per batch — scan batch, and backfill batch (default: 1000). */
59
87
  batchSize?: number;
60
88
  /** Run a first replication right after boot (default: true). */
61
89
  runOnBoot?: boolean;
@@ -93,7 +121,7 @@ export type CollectionReplicationConfig = {
93
121
  initialSync?: ReplicationInitialSync;
94
122
  };
95
123
 
96
- export type ReplicationStatus = "idle" | "running" | "success" | "error";
124
+ export type ReplicationStatus = "idle" | "running" | "success" | "watching" | "error";
97
125
 
98
126
  /** Cursor of the last replicated document — `value` is the date key, `id` the tie-breaker. */
99
127
  export type ReplicationCursor = {
@@ -118,7 +146,16 @@ export type ReplicationState = {
118
146
  destination: string;
119
147
  collection: string;
120
148
  key: string;
149
+ /** Change-detection mode this state was written by (absent = legacy `'scan'`). */
150
+ mode?: ReplicationMode;
151
+ /** Scan position — `mode: 'scan'` only. */
121
152
  cursor: ReplicationCursor;
153
+ /**
154
+ * Change-stream position (`mode: 'changeStream'` only) — the oplog resume token
155
+ * of the last applied event. This is the whole cursor in that mode: no date key,
156
+ * no tie-breaker, and it survives inserts/updates/deletes alike.
157
+ */
158
+ resumeToken?: any;
122
159
  status: ReplicationStatus;
123
160
  lastRunAt: Date | null;
124
161
  lastError: string | null;