@animalabs/agent-framework 0.15.0 → 0.17.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.
- package/README.md +22 -1
- package/dist/src/agent.d.ts +32 -0
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +55 -0
- package/dist/src/agent.js.map +1 -1
- package/dist/src/api/server.d.ts +9 -0
- package/dist/src/api/server.d.ts.map +1 -1
- package/dist/src/api/server.js +156 -0
- package/dist/src/api/server.js.map +1 -1
- package/dist/src/api/types.d.ts +15 -0
- package/dist/src/api/types.d.ts.map +1 -1
- package/dist/src/framework.d.ts +423 -3
- package/dist/src/framework.d.ts.map +1 -1
- package/dist/src/framework.js +1857 -75
- package/dist/src/framework.js.map +1 -1
- package/dist/src/gate/event-gate.d.ts +16 -0
- package/dist/src/gate/event-gate.d.ts.map +1 -1
- package/dist/src/gate/event-gate.js +41 -3
- package/dist/src/gate/event-gate.js.map +1 -1
- package/dist/src/index.d.ts +4 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcpl/channel-registry.d.ts +172 -0
- package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
- package/dist/src/mcpl/channel-registry.js +444 -2
- package/dist/src/mcpl/channel-registry.js.map +1 -1
- package/dist/src/mcpl/server-connection.d.ts +9 -0
- package/dist/src/mcpl/server-connection.d.ts.map +1 -1
- package/dist/src/mcpl/server-connection.js +71 -13
- package/dist/src/mcpl/server-connection.js.map +1 -1
- package/dist/src/modules/history/index.d.ts +89 -13
- package/dist/src/modules/history/index.d.ts.map +1 -1
- package/dist/src/modules/history/index.js +655 -24
- package/dist/src/modules/history/index.js.map +1 -1
- package/dist/src/operator-log.d.ts +78 -0
- package/dist/src/operator-log.d.ts.map +1 -0
- package/dist/src/operator-log.js +102 -0
- package/dist/src/operator-log.js.map +1 -0
- package/dist/src/recovery/discord-awareness-outbox.d.ts +10 -0
- package/dist/src/recovery/discord-awareness-outbox.d.ts.map +1 -1
- package/dist/src/recovery/discord-awareness-outbox.js +20 -0
- package/dist/src/recovery/discord-awareness-outbox.js.map +1 -1
- package/dist/src/types/framework.d.ts +56 -0
- package/dist/src/types/framework.d.ts.map +1 -1
- package/dist/src/types/trace.d.ts +36 -0
- package/dist/src/types/trace.d.ts.map +1 -1
- package/dist/test/agent-runtime-settings.test.js +199 -1
- package/dist/test/agent-runtime-settings.test.js.map +1 -1
- package/dist/test/api-admin-gate.test.d.ts +2 -0
- package/dist/test/api-admin-gate.test.d.ts.map +1 -0
- package/dist/test/api-admin-gate.test.js +116 -0
- package/dist/test/api-admin-gate.test.js.map +1 -0
- package/dist/test/channel-label-history.test.d.ts +2 -0
- package/dist/test/channel-label-history.test.d.ts.map +1 -0
- package/dist/test/channel-label-history.test.js +424 -0
- package/dist/test/channel-label-history.test.js.map +1 -0
- package/dist/test/discord-awareness-outbox.test.js +16 -0
- package/dist/test/discord-awareness-outbox.test.js.map +1 -1
- package/dist/test/event-gate.test.js +44 -0
- package/dist/test/event-gate.test.js.map +1 -1
- package/dist/test/helpers/quiesce-crash-child.d.ts +2 -0
- package/dist/test/helpers/quiesce-crash-child.d.ts.map +1 -0
- package/dist/test/helpers/quiesce-crash-child.js +156 -0
- package/dist/test/helpers/quiesce-crash-child.js.map +1 -0
- package/dist/test/history-module-overview.test.d.ts +2 -0
- package/dist/test/history-module-overview.test.d.ts.map +1 -0
- package/dist/test/history-module-overview.test.js +711 -0
- package/dist/test/history-module-overview.test.js.map +1 -0
- package/dist/test/history-module.test.js +146 -0
- package/dist/test/history-module.test.js.map +1 -1
- package/dist/test/host-quiesce.test.d.ts +2 -0
- package/dist/test/host-quiesce.test.d.ts.map +1 -0
- package/dist/test/host-quiesce.test.js +863 -0
- package/dist/test/host-quiesce.test.js.map +1 -0
- package/dist/test/liveness-watchdog.test.js +18 -2
- package/dist/test/liveness-watchdog.test.js.map +1 -1
- package/dist/test/operator-surgery.test.d.ts +2 -0
- package/dist/test/operator-surgery.test.d.ts.map +1 -0
- package/dist/test/operator-surgery.test.js +398 -0
- package/dist/test/operator-surgery.test.js.map +1 -0
- package/dist/test/provider-acceleration-cooldown.test.js +145 -0
- package/dist/test/provider-acceleration-cooldown.test.js.map +1 -1
- package/dist/test/puppet-tool-call.test.js +5 -0
- package/dist/test/puppet-tool-call.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/agent.ts +69 -0
- package/src/api/server.ts +159 -2
- package/src/api/types.ts +15 -0
- package/src/framework.ts +2155 -96
- package/src/gate/event-gate.ts +47 -4
- package/src/index.ts +5 -1
- package/src/mcpl/channel-registry.ts +495 -2
- package/src/mcpl/server-connection.ts +73 -13
- package/src/modules/history/index.ts +689 -25
- package/src/operator-log.ts +132 -0
- package/src/recovery/discord-awareness-outbox.ts +19 -0
- package/src/types/framework.ts +63 -0
- package/src/types/trace.ts +42 -0
|
@@ -9,13 +9,25 @@
|
|
|
9
9
|
* this module can answer "what happened in #foo last Tuesday" against a
|
|
10
10
|
* multi-million-message store without walking the whole log.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
* - `stats`
|
|
14
|
-
*
|
|
15
|
-
* - `extract`
|
|
16
|
-
* - `search`
|
|
17
|
-
*
|
|
18
|
-
*
|
|
12
|
+
* Four tools:
|
|
13
|
+
* - `stats` — per-channel message counts (all-time) + token totals
|
|
14
|
+
* (range-scoped), for orienting before pulling raw content.
|
|
15
|
+
* - `extract` — paginated raw messages for a time range and/or channel.
|
|
16
|
+
* - `search` — substring/regex match over a narrowed candidate window,
|
|
17
|
+
* with an explicit truncation signal when the caller's
|
|
18
|
+
* filter was too broad for `maxScan`.
|
|
19
|
+
* - `overview` — a compression-summary table of contents (zero new LLM
|
|
20
|
+
* calls) for a time range, gap-filled with raw message
|
|
21
|
+
* counts wherever nothing has been summarized yet. See
|
|
22
|
+
* `handleOverview` for the fold-reduction and gap-fill
|
|
23
|
+
* algorithm.
|
|
24
|
+
*
|
|
25
|
+
* All four accept `channelId` as either a channel label (e.g. `#general`)
|
|
26
|
+
* or a raw internal channel id — `resolveChannel()` resolves a label via
|
|
27
|
+
* the bound `ChannelRegistry`'s durable label history before it reaches any
|
|
28
|
+
* context-manager call. A host that hasn't wired up MCPL (no registry
|
|
29
|
+
* bound) sees unchanged behavior: `channelId` is treated as already the raw
|
|
30
|
+
* internal id.
|
|
19
31
|
*
|
|
20
32
|
* Kept deliberately read-only, same posture as HealthModule: no side
|
|
21
33
|
* effects, no message mutation. `onProcess` is a no-op.
|
|
@@ -30,18 +42,81 @@ import type { ContextManager } from '@animalabs/context-manager';
|
|
|
30
42
|
import type { Module, ModuleContext } from '../../types/module.js';
|
|
31
43
|
import type { ToolDefinition, ToolCall, ToolResult, ProcessEvent } from '../../types/events.js';
|
|
32
44
|
import type { EventResponse, ProcessState } from '../../types/module.js';
|
|
45
|
+
import type { ChannelRegistry } from '../../mcpl/channel-registry.js';
|
|
33
46
|
export declare class HistoryModule implements Module {
|
|
34
47
|
readonly name = "history";
|
|
35
48
|
private ctx;
|
|
36
49
|
private cm;
|
|
50
|
+
private channelRegistry;
|
|
51
|
+
/**
|
|
52
|
+
* Wire the context-manager instance, and optionally the host's
|
|
53
|
+
* ChannelRegistry. Host calls this after ContextManager.open() so the
|
|
54
|
+
* module can issue the native index-backed queries — ModuleContext itself
|
|
55
|
+
* exposes no store/context-manager reference, only the narrower message
|
|
56
|
+
* CRUD surface (addMessage/getMessage/queryMessages), which can't do
|
|
57
|
+
* range or channel queries.
|
|
58
|
+
*
|
|
59
|
+
* `channelRegistry` is optional: a host without MCPL wired up has no
|
|
60
|
+
* registry to pass, and `resolveChannel()` falls back to treating
|
|
61
|
+
* `channelId` as already the raw internal id — today's behavior,
|
|
62
|
+
* unchanged.
|
|
63
|
+
*/
|
|
64
|
+
bind(contextManager: ContextManager, channelRegistry?: ChannelRegistry): void;
|
|
65
|
+
/**
|
|
66
|
+
* Resolve an agent-supplied channel spec — a label like `#general` or an
|
|
67
|
+
* already-raw internal channelId — to the internal id used by
|
|
68
|
+
* context-manager's channel-indexed queries, via the bound
|
|
69
|
+
* ChannelRegistry's durable label history (`resolveProseTargetDurable`,
|
|
70
|
+
* which survives the bot disconnecting from or restarting on a channel —
|
|
71
|
+
* exactly the case that matters for browsing OLD history).
|
|
72
|
+
*
|
|
73
|
+
* Falls through the input unchanged when no registry is bound (host
|
|
74
|
+
* without MCPL — today's behavior). On a registry MISS, the response
|
|
75
|
+
* depends on whether the spec actually looks like a label: `#general`,
|
|
76
|
+
* `@name`, or a `<@id>`/`<@!id>` mention (the syntaxes `resolveProseTarget`
|
|
77
|
+
* itself treats as unambiguously label-shaped — see its own leading
|
|
78
|
+
* `#`/`@` and mention-regex handling) is very likely a typo or a
|
|
79
|
+
* never-registered target, not a raw internal id, so a miss there throws
|
|
80
|
+
* a clean tool error (with any `candidates` suggestions folded in)
|
|
81
|
+
* instead of quietly treating it as an empty/nonexistent channel. A
|
|
82
|
+
* mention in particular can never legitimately BE a raw internal
|
|
83
|
+
* channelId, so the escape-hatch rationale below doesn't even apply to
|
|
84
|
+
* it. Anything else is
|
|
85
|
+
* passed through as an escape hatch — an agent can legitimately already
|
|
86
|
+
* hold a raw channelId (e.g. echoed back by a prior
|
|
87
|
+
* `stats`/`extract`/`search`/`overview` call), and erroring on that would
|
|
88
|
+
* break working addressing to "fix" a spec that was never a label at all.
|
|
89
|
+
*
|
|
90
|
+
* The thrown message is deliberately NOT `resolved.error` verbatim:
|
|
91
|
+
* `resolveProseTargetDurable`'s underlying live resolver
|
|
92
|
+
* (`resolveProseTarget`) writes its error text for a SEND context (e.g.
|
|
93
|
+
* a DM miss says '...use the send_dm tool') — sensible advice when
|
|
94
|
+
* you're trying to deliver a message, nonsense advice from a read-only
|
|
95
|
+
* history tool. This module always uses its own read-only-appropriate
|
|
96
|
+
* wording instead, regardless of which branch of the live resolver
|
|
97
|
+
* produced the miss.
|
|
98
|
+
*/
|
|
99
|
+
private resolveChannel;
|
|
100
|
+
/**
|
|
101
|
+
* Earliest message timestamp anywhere in the store, constrained to
|
|
102
|
+
* `toMs` when given (never look past the caller's own upper bound while
|
|
103
|
+
* anchoring). Used by `handleOverview` to anchor its gap-walk cursor when
|
|
104
|
+
* `from` is omitted — see the cursor-anchoring comment there for why
|
|
105
|
+
* falling back to "now" instead is wrong. Cheap: a single native
|
|
106
|
+
* time-indexed query for one message (oldest-first is
|
|
107
|
+
* `queryMessagesByTime`'s default order). Returns undefined for a
|
|
108
|
+
* genuinely empty store (or empty up to `toMs`).
|
|
109
|
+
*/
|
|
110
|
+
private earliestMessageMs;
|
|
37
111
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
112
|
+
* Every raw message sharing exactly `ms` (a single-point, both-ends-
|
|
113
|
+
* inclusive time query). Used by `handleOverview`'s boundary-tie
|
|
114
|
+
* disambiguation to see past `getChannelTokenStats`'s aggregate-only,
|
|
115
|
+
* sequence-blind view of a millisecond — see the correction pass there
|
|
116
|
+
* for why. Cheap: at most a handful of messages share one millisecond in
|
|
117
|
+
* practice.
|
|
43
118
|
*/
|
|
44
|
-
|
|
119
|
+
private boundaryMessagesAt;
|
|
45
120
|
start(ctx: ModuleContext): Promise<void>;
|
|
46
121
|
stop(): Promise<void>;
|
|
47
122
|
getTools(): ToolDefinition[];
|
|
@@ -65,5 +140,6 @@ export declare class HistoryModule implements Module {
|
|
|
65
140
|
* must never be indistinguishable from a clean "no matches" result.
|
|
66
141
|
*/
|
|
67
142
|
private searchWithRegexWorker;
|
|
143
|
+
private handleOverview;
|
|
68
144
|
}
|
|
69
145
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/history/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":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