@anteros/core 0.0.41 → 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/audit.ts +9 -59
- package/database/collection.ts +3 -1
- package/database/deleteLog.ts +67 -3
- package/database/file.ts +4 -3
- package/database/mongodbadapter.ts +103 -42
- package/database/replication.ts +724 -58
- package/database/ttl.ts +68 -0
- package/database/workflow.ts +466 -240
- package/index.ts +6 -0
- package/lib/agent.ts +1567 -0
- package/lib/agentMemory.ts +689 -0
- package/lib/agents.ts +180 -0
- package/lib/ai.ts +0 -0
- package/lib/api.ts +246 -0
- package/lib/attachment.ts +351 -0
- package/lib/auditResult.ts +13 -0
- package/lib/define.ts +43 -1
- package/lib/endpoints.ts +80 -0
- package/lib/files.ts +2 -1
- package/lib/jsonSchema.ts +183 -0
- package/lib/lifecycle.ts +7 -1
- package/lib/load.ts +17 -0
- package/lib/mcp.ts +3 -2
- package/lib/mcpClient.ts +128 -0
- package/lib/messages.ts +299 -0
- package/lib/providers.ts +970 -0
- package/lib/routes.ts +14 -1
- package/lib/scriptWorker.ts +4 -1
- package/lib/scripts.ts +6 -1
- package/lib/skills.ts +481 -0
- package/lib/sockets.ts +3 -1
- package/lib/workflow.ts +209 -37
- package/lib/zip.ts +109 -0
- package/package.json +1 -1
- package/server/access.ts +96 -0
- package/server/agents.ts +472 -0
- package/server/api.ts +80 -65
- package/server/boot.ts +11 -0
- package/server/hono.ts +8 -3
- package/server/mcp.ts +17 -63
- package/server/routes.ts +19 -24
- package/tests/agent-mcp.test.ts +116 -0
- package/tests/agent-memory.test.ts +617 -0
- 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 +404 -0
- package/tests/agent.test.ts +1241 -0
- package/tests/agents-api.test.ts +593 -0
- package/tests/api-private-fields.test.ts +196 -0
- package/tests/api.test.ts +51 -0
- package/tests/attachment.test.ts +241 -0
- package/tests/audit-operations.test.ts +1 -1
- package/tests/audit-redact.test.ts +29 -3
- package/tests/audit-run-action.test.ts +1 -1
- package/tests/endpoints.test.ts +80 -0
- package/tests/file-collection-replication.test.ts +2 -0
- package/tests/fixtures/agent-tenant/agents/support.agent.ts +9 -0
- package/tests/fixtures/agent-tenant/agents/weather.agent.ts +21 -0
- package/tests/fixtures/agents-api/agents/assistant.agent.ts +46 -0
- package/tests/fixtures/agents-api/agents/plain.agent.ts +23 -0
- package/tests/fixtures/agents-api/agents/private.agent.ts +15 -0
- package/tests/fixtures/agents-api/collections/notes.model.ts +26 -0
- package/tests/fixtures/agents-api/routes/probe.route.ts +21 -0
- package/tests/fixtures/agents-api/services/probe.service.ts +19 -0
- package/tests/fixtures/attachment/data.csv +2 -0
- package/tests/fixtures/fake-provider.ts +128 -0
- package/tests/fixtures/repl-only/app.ts +3 -0
- package/tests/fixtures/replication-meta/agents/chat.agent.ts +16 -0
- package/tests/fixtures/replication-meta/collections/counters.model.ts +13 -0
- package/tests/fixtures/replication-meta/collections/orders.model.ts +9 -0
- package/tests/fixtures/replication-meta/workflows/run.workflow.ts +8 -0
- 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/fixtures/vars-tenant/vars/private.var.ts +4 -1
- package/tests/fixtures/workflow-engine/workflows/failing.workflow.ts +34 -0
- package/tests/fixtures/workflow-engine/workflows/flaky.workflow.ts +23 -0
- package/tests/fixtures/workflow-engine/workflows/hang.workflow.ts +17 -0
- package/tests/fixtures/workflow-engine/workflows/simple.workflow.ts +19 -0
- package/tests/fixtures/workflow-engine/workflows/slow.workflow.ts +23 -0
- package/tests/fixtures/workflow-engine/workflows/versioned.workflow.ts +19 -0
- package/tests/fixtures/workflow-tenant/workflows/broken.workflow.ts +3 -0
- package/tests/fixtures/workflow-tenant/workflows/disabled.workflow.ts +8 -0
- package/tests/fixtures/workflow-tenant/workflows/invoice.workflow.ts +21 -0
- package/tests/fixtures/workflow-tenant/workflows/no-id.workflow.ts +7 -0
- package/tests/fixtures/workflow-tenant/workflows/order-duplicate.workflow.ts +13 -0
- package/tests/fixtures/workflow-tenant/workflows/order.workflow.ts +17 -0
- package/tests/hono.test.ts +6 -3
- package/tests/locks.test.ts +120 -0
- package/tests/mcp.test.ts +11 -11
- package/tests/messages.test.ts +258 -0
- package/tests/replication-change-stream.test.ts +240 -0
- package/tests/replication-control.test.ts +4 -2
- package/tests/replication-initial-sync.test.ts +2 -0
- package/tests/replication-meta.test.ts +246 -0
- package/tests/replication.test.ts +2 -0
- package/tests/upload.test.ts +44 -12
- package/tests/vars-api.test.ts +1 -1
- package/tests/vars-replication.test.ts +5 -2
- package/tests/workflow-engine.test.ts +340 -0
- package/tests/workflow-retention.test.ts +103 -0
- package/tests/workflow.test.ts +186 -0
- package/types/agent.d.ts +1067 -0
- package/types/config.d.ts +16 -0
- package/types/file.d.ts +7 -7
- package/types/hook.d.ts +6 -0
- package/types/lifecycle.d.ts +6 -0
- package/types/mcp.d.ts +11 -1
- package/types/replication.d.ts +70 -4
- package/types/route.d.ts +7 -1
- package/types/scripts.d.ts +6 -0
- package/types/service.d.ts +7 -1
- package/types/tenant.d.ts +13 -0
- package/types/vars.d.ts +2 -2
- package/types/websocket.d.ts +6 -0
- package/types/workflow.d.ts +50 -3
package/database/ttl.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Db } from "mongodb";
|
|
2
|
+
import { parseDuration } from "../utils/func";
|
|
3
|
+
|
|
4
|
+
export type RetentionResult = 'applied' | 'dropped' | 'unchanged' | 'skipped'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Declarative TTL retention for a collection:
|
|
8
|
+
*
|
|
9
|
+
* - a duration string (`'90d'`, `'24h'`) → ensure the TTL index with that expiry
|
|
10
|
+
* - `false` → explicitly disabled: drop the TTL index
|
|
11
|
+
* - omitted → untouched
|
|
12
|
+
*
|
|
13
|
+
* MongoDB cannot change `expireAfterSeconds` in place through `createIndex`:
|
|
14
|
+
* `collMod` does it instantly, dropping/recreating is the fallback. Never fatal —
|
|
15
|
+
* a failure is logged and `'skipped'` is returned.
|
|
16
|
+
*/
|
|
17
|
+
async function syncTtlRetention(
|
|
18
|
+
db: Db,
|
|
19
|
+
opts: { collection: string; index: string; field: string; retention?: string | false; label?: string },
|
|
20
|
+
): Promise<RetentionResult> {
|
|
21
|
+
const { collection, index, field, retention } = opts;
|
|
22
|
+
const label = opts.label ?? collection;
|
|
23
|
+
|
|
24
|
+
if (retention === undefined) return 'skipped';
|
|
25
|
+
|
|
26
|
+
const col: any = db.collection(collection);
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
const existing = (await col.listIndexes().toArray())
|
|
30
|
+
.find((entry: any) => entry.name === index);
|
|
31
|
+
|
|
32
|
+
if (retention === false) {
|
|
33
|
+
if (!existing) return 'unchanged';
|
|
34
|
+
await col.dropIndex(index);
|
|
35
|
+
console.log(`🧹 ${label} retention disabled — ${index} dropped`);
|
|
36
|
+
return 'dropped';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const parsed = parseDuration(retention);
|
|
40
|
+
if (parsed === null) {
|
|
41
|
+
console.error(`Invalid ${label} retention '${retention}' — expected a duration like '90d' or '24h'`);
|
|
42
|
+
return 'skipped';
|
|
43
|
+
}
|
|
44
|
+
const expireAfterSeconds = Math.round(parsed / 1000);
|
|
45
|
+
|
|
46
|
+
if (!existing) {
|
|
47
|
+
await col.createIndex({ [field]: 1 }, { name: index, expireAfterSeconds, background: true });
|
|
48
|
+
console.log(`🧹 ${label} retention enabled — entries expire after ${retention}`);
|
|
49
|
+
return 'applied';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (existing.expireAfterSeconds === expireAfterSeconds) return 'unchanged';
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
await db.command({ collMod: collection, index: { name: index, expireAfterSeconds } });
|
|
56
|
+
} catch {
|
|
57
|
+
await col.dropIndex(index);
|
|
58
|
+
await col.createIndex({ [field]: 1 }, { name: index, expireAfterSeconds, background: true });
|
|
59
|
+
}
|
|
60
|
+
console.log(`🧹 ${label} retention updated — entries expire after ${retention}`);
|
|
61
|
+
return 'applied';
|
|
62
|
+
} catch (err: any) {
|
|
63
|
+
console.error(`${label} retention failed (${retention})`, err?.message);
|
|
64
|
+
return 'skipped';
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { syncTtlRetention }
|