@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.
- package/database/replication.ts +614 -26
- package/lib/agent.ts +279 -39
- package/lib/agentMemory.ts +103 -0
- package/lib/agents.ts +25 -2
- package/lib/define.ts +1 -1
- package/lib/mcpClient.ts +128 -0
- package/lib/providers.ts +169 -66
- package/lib/skills.ts +481 -0
- package/package.json +1 -1
- package/server/agents.ts +27 -6
- package/server/api.ts +74 -1
- package/tests/agent-mcp.test.ts +116 -0
- package/tests/agent-memory.test.ts +6 -6
- package/tests/agent-provider.test.ts +288 -0
- package/tests/agent-runtime.test.ts +369 -0
- package/tests/agent-skills.test.ts +177 -0
- package/tests/agent-summarize.test.ts +124 -0
- package/tests/agent-working-memory.test.ts +5 -3
- package/tests/agent.test.ts +18 -16
- package/tests/agents-api.test.ts +1 -1
- package/tests/api-private-fields.test.ts +196 -0
- package/tests/file-collection-replication.test.ts +2 -0
- package/tests/fixtures/agent-tenant/agents/support.agent.ts +1 -1
- package/tests/fixtures/agent-tenant/agents/weather.agent.ts +1 -1
- package/tests/fixtures/agents-api/agents/assistant.agent.ts +1 -1
- package/tests/fixtures/agents-api/agents/plain.agent.ts +1 -1
- package/tests/fixtures/agents-api/agents/private.agent.ts +1 -1
- package/tests/fixtures/repl-only/app.ts +3 -0
- package/tests/fixtures/replication-meta/agents/chat.agent.ts +1 -1
- package/tests/fixtures/skills-tenant/agents/docs.agent.ts +23 -0
- package/tests/fixtures/skills-tenant/agents/incomplete.agent.ts +14 -0
- package/tests/fixtures/skills-tenant/broken/bad-name.md +6 -0
- package/tests/fixtures/skills-tenant/broken/dup-a.md +6 -0
- package/tests/fixtures/skills-tenant/broken/dup-b.md +6 -0
- package/tests/fixtures/skills-tenant/broken/empty-body.md +4 -0
- package/tests/fixtures/skills-tenant/broken/long-compat.md +7 -0
- package/tests/fixtures/skills-tenant/broken/long-description.md +6 -0
- package/tests/fixtures/skills-tenant/broken/mismatch/SKILL.md +6 -0
- package/tests/fixtures/skills-tenant/broken/no-description.md +5 -0
- package/tests/fixtures/skills-tenant/broken/no-name.md +5 -0
- package/tests/fixtures/skills-tenant/broken/plain.md +4 -0
- package/tests/fixtures/skills-tenant/broken/unknown-key.md +9 -0
- package/tests/fixtures/skills-tenant/docs/pdf-forms.md +18 -0
- package/tests/fixtures/skills-tenant/guide/ml.md +9 -0
- package/tests/fixtures/skills-tenant/guides/pdf/SKILL.md +9 -0
- package/tests/fixtures/skills-tenant/runbooks/incident.md +9 -0
- package/tests/fixtures/skills-tenant/runbooks/notes.txt +2 -0
- package/tests/replication-change-stream.test.ts +240 -0
- package/tests/replication-control.test.ts +2 -0
- package/tests/replication-initial-sync.test.ts +2 -0
- package/tests/replication-meta.test.ts +3 -0
- package/tests/replication.test.ts +2 -0
- package/tests/vars-replication.test.ts +2 -0
- package/types/agent.d.ts +237 -7
- package/types/replication.d.ts +41 -4
package/types/replication.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
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
|
-
/**
|
|
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;
|