@poolzin/pool-bot 2026.3.4 → 2026.3.7
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/CHANGELOG.md +10 -0
- package/assets/pool-bot-icon-dark.png +0 -0
- package/assets/pool-bot-logo-1.png +0 -0
- package/assets/pool-bot-mascot.png +0 -0
- package/dist/agents/pi-embedded-runner/tool-result-truncation.js +62 -7
- package/dist/agents/pi-tools.js +32 -2
- package/dist/agents/poolbot-tools.js +12 -0
- package/dist/agents/session-write-lock.js +93 -8
- package/dist/agents/tools/pdf-native-providers.js +102 -0
- package/dist/agents/tools/pdf-tool.helpers.js +86 -0
- package/dist/agents/tools/pdf-tool.js +508 -0
- package/dist/auto-reply/reply/get-reply.js +6 -0
- package/dist/auto-reply/reply/message-preprocess-hooks.js +17 -0
- package/dist/build-info.json +3 -3
- package/dist/cli/banner.js +20 -1
- package/dist/cli/security-cli.js +211 -2
- package/dist/cli/tagline.js +7 -0
- package/dist/config/types.cli.js +1 -0
- package/dist/config/types.security.js +33 -0
- package/dist/config/zod-schema.js +15 -0
- package/dist/config/zod-schema.providers-core.js +1 -0
- package/dist/config/zod-schema.security.js +113 -0
- package/dist/cron/normalize.js +3 -0
- package/dist/cron/service/jobs.js +48 -0
- package/dist/discord/monitor/message-handler.preflight.js +11 -2
- package/dist/gateway/http-common.js +6 -1
- package/dist/gateway/protocol/schema/cron.js +3 -0
- package/dist/gateway/server-channels.js +99 -14
- package/dist/gateway/server-cron.js +89 -0
- package/dist/gateway/server-health-probes.js +55 -0
- package/dist/gateway/server-http.js +5 -0
- package/dist/hooks/bundled/session-memory/handler.js +8 -2
- package/dist/hooks/fire-and-forget.js +6 -0
- package/dist/hooks/internal-hooks.js +64 -19
- package/dist/hooks/message-hook-mappers.js +179 -0
- package/dist/infra/abort-signal.js +12 -0
- package/dist/infra/boundary-file-read.js +118 -0
- package/dist/infra/boundary-path.js +594 -0
- package/dist/infra/file-identity.js +12 -0
- package/dist/infra/fs-safe.js +377 -12
- package/dist/infra/hardlink-guards.js +30 -0
- package/dist/infra/json-utf8-bytes.js +8 -0
- package/dist/infra/net/fetch-guard.js +63 -13
- package/dist/infra/net/proxy-env.js +17 -0
- package/dist/infra/net/ssrf.js +74 -272
- package/dist/infra/path-alias-guards.js +21 -0
- package/dist/infra/path-guards.js +13 -1
- package/dist/infra/ports-probe.js +19 -0
- package/dist/infra/prototype-keys.js +4 -0
- package/dist/infra/restart-stale-pids.js +254 -0
- package/dist/infra/safe-open-sync.js +71 -0
- package/dist/infra/secure-random.js +7 -0
- package/dist/media/ffmpeg-limits.js +4 -0
- package/dist/media/input-files.js +6 -2
- package/dist/media/temp-files.js +12 -0
- package/dist/memory/embedding-chunk-limits.js +5 -2
- package/dist/memory/embeddings-ollama.js +91 -138
- package/dist/memory/embeddings-remote-fetch.js +11 -10
- package/dist/memory/embeddings.js +25 -9
- package/dist/memory/manager-embedding-ops.js +1 -1
- package/dist/memory/post-json.js +23 -0
- package/dist/memory/qmd-manager.js +272 -77
- package/dist/memory/remote-http.js +33 -0
- package/dist/plugin-sdk/windows-spawn.js +214 -0
- package/dist/security/capability-guards.js +89 -0
- package/dist/security/capability-manager.js +76 -0
- package/dist/security/capability.js +147 -0
- package/dist/security/index.js +7 -0
- package/dist/security/middleware.js +105 -0
- package/dist/shared/net/ip-test-fixtures.js +1 -0
- package/dist/shared/net/ip.js +303 -0
- package/dist/shared/net/ipv4.js +8 -11
- package/dist/shared/pid-alive.js +59 -2
- package/dist/slack/monitor/context.js +1 -0
- package/dist/slack/monitor/message-handler/dispatch.js +14 -1
- package/dist/slack/monitor/provider.js +2 -0
- package/dist/test-helpers/ssrf.js +13 -0
- package/dist/tui/tui.js +9 -4
- package/dist/utils/fetch-timeout.js +12 -1
- package/docs/adr/003-feature-gap-analysis.md +112 -0
- package/package.json +10 -4
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
export function deriveInboundMessageHookContext(ctx, overrides) {
|
|
2
|
+
const content = overrides?.content ??
|
|
3
|
+
(typeof ctx.BodyForCommands === "string"
|
|
4
|
+
? ctx.BodyForCommands
|
|
5
|
+
: typeof ctx.RawBody === "string"
|
|
6
|
+
? ctx.RawBody
|
|
7
|
+
: typeof ctx.Body === "string"
|
|
8
|
+
? ctx.Body
|
|
9
|
+
: "");
|
|
10
|
+
const channelId = (ctx.OriginatingChannel ?? ctx.Surface ?? ctx.Provider ?? "").toLowerCase();
|
|
11
|
+
const conversationId = ctx.OriginatingTo ?? ctx.To ?? ctx.From ?? undefined;
|
|
12
|
+
const isGroup = Boolean(ctx.GroupSubject || ctx.GroupChannel);
|
|
13
|
+
return {
|
|
14
|
+
from: ctx.From ?? "",
|
|
15
|
+
to: ctx.To,
|
|
16
|
+
content,
|
|
17
|
+
body: ctx.Body,
|
|
18
|
+
bodyForAgent: ctx.BodyForAgent,
|
|
19
|
+
transcript: ctx.Transcript,
|
|
20
|
+
timestamp: typeof ctx.Timestamp === "number" && Number.isFinite(ctx.Timestamp)
|
|
21
|
+
? ctx.Timestamp
|
|
22
|
+
: undefined,
|
|
23
|
+
channelId,
|
|
24
|
+
accountId: ctx.AccountId,
|
|
25
|
+
conversationId,
|
|
26
|
+
messageId: overrides?.messageId ??
|
|
27
|
+
ctx.MessageSidFull ??
|
|
28
|
+
ctx.MessageSid ??
|
|
29
|
+
ctx.MessageSidFirst ??
|
|
30
|
+
ctx.MessageSidLast,
|
|
31
|
+
senderId: ctx.SenderId,
|
|
32
|
+
senderName: ctx.SenderName,
|
|
33
|
+
senderUsername: ctx.SenderUsername,
|
|
34
|
+
senderE164: ctx.SenderE164,
|
|
35
|
+
provider: ctx.Provider,
|
|
36
|
+
surface: ctx.Surface,
|
|
37
|
+
threadId: ctx.MessageThreadId,
|
|
38
|
+
mediaPath: ctx.MediaPath,
|
|
39
|
+
mediaType: ctx.MediaType,
|
|
40
|
+
originatingChannel: ctx.OriginatingChannel,
|
|
41
|
+
originatingTo: ctx.OriginatingTo,
|
|
42
|
+
guildId: ctx.GroupSpace,
|
|
43
|
+
channelName: ctx.GroupChannel,
|
|
44
|
+
isGroup,
|
|
45
|
+
groupId: isGroup ? conversationId : undefined,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function buildCanonicalSentMessageHookContext(params) {
|
|
49
|
+
return {
|
|
50
|
+
to: params.to,
|
|
51
|
+
content: params.content,
|
|
52
|
+
success: params.success,
|
|
53
|
+
error: params.error,
|
|
54
|
+
channelId: params.channelId,
|
|
55
|
+
accountId: params.accountId,
|
|
56
|
+
conversationId: params.conversationId ?? params.to,
|
|
57
|
+
messageId: params.messageId,
|
|
58
|
+
isGroup: params.isGroup,
|
|
59
|
+
groupId: params.groupId,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export function toPluginMessageContext(canonical) {
|
|
63
|
+
return {
|
|
64
|
+
channelId: canonical.channelId,
|
|
65
|
+
accountId: canonical.accountId,
|
|
66
|
+
conversationId: canonical.conversationId,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export function toPluginMessageReceivedEvent(canonical) {
|
|
70
|
+
return {
|
|
71
|
+
from: canonical.from,
|
|
72
|
+
content: canonical.content,
|
|
73
|
+
timestamp: canonical.timestamp,
|
|
74
|
+
metadata: {
|
|
75
|
+
to: canonical.to,
|
|
76
|
+
provider: canonical.provider,
|
|
77
|
+
surface: canonical.surface,
|
|
78
|
+
threadId: canonical.threadId,
|
|
79
|
+
originatingChannel: canonical.originatingChannel,
|
|
80
|
+
originatingTo: canonical.originatingTo,
|
|
81
|
+
messageId: canonical.messageId,
|
|
82
|
+
senderId: canonical.senderId,
|
|
83
|
+
senderName: canonical.senderName,
|
|
84
|
+
senderUsername: canonical.senderUsername,
|
|
85
|
+
senderE164: canonical.senderE164,
|
|
86
|
+
guildId: canonical.guildId,
|
|
87
|
+
channelName: canonical.channelName,
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export function toPluginMessageSentEvent(canonical) {
|
|
92
|
+
return {
|
|
93
|
+
to: canonical.to,
|
|
94
|
+
content: canonical.content,
|
|
95
|
+
success: canonical.success,
|
|
96
|
+
...(canonical.error ? { error: canonical.error } : {}),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
export function toInternalMessageReceivedContext(canonical) {
|
|
100
|
+
return {
|
|
101
|
+
from: canonical.from,
|
|
102
|
+
content: canonical.content,
|
|
103
|
+
timestamp: canonical.timestamp,
|
|
104
|
+
channelId: canonical.channelId,
|
|
105
|
+
accountId: canonical.accountId,
|
|
106
|
+
conversationId: canonical.conversationId,
|
|
107
|
+
messageId: canonical.messageId,
|
|
108
|
+
metadata: {
|
|
109
|
+
to: canonical.to,
|
|
110
|
+
provider: canonical.provider,
|
|
111
|
+
surface: canonical.surface,
|
|
112
|
+
threadId: canonical.threadId,
|
|
113
|
+
senderId: canonical.senderId,
|
|
114
|
+
senderName: canonical.senderName,
|
|
115
|
+
senderUsername: canonical.senderUsername,
|
|
116
|
+
senderE164: canonical.senderE164,
|
|
117
|
+
guildId: canonical.guildId,
|
|
118
|
+
channelName: canonical.channelName,
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
export function toInternalMessageTranscribedContext(canonical, cfg) {
|
|
123
|
+
return {
|
|
124
|
+
from: canonical.from,
|
|
125
|
+
to: canonical.to,
|
|
126
|
+
body: canonical.body,
|
|
127
|
+
bodyForAgent: canonical.bodyForAgent,
|
|
128
|
+
transcript: canonical.transcript ?? "",
|
|
129
|
+
timestamp: canonical.timestamp,
|
|
130
|
+
channelId: canonical.channelId,
|
|
131
|
+
conversationId: canonical.conversationId,
|
|
132
|
+
messageId: canonical.messageId,
|
|
133
|
+
senderId: canonical.senderId,
|
|
134
|
+
senderName: canonical.senderName,
|
|
135
|
+
senderUsername: canonical.senderUsername,
|
|
136
|
+
provider: canonical.provider,
|
|
137
|
+
surface: canonical.surface,
|
|
138
|
+
mediaPath: canonical.mediaPath,
|
|
139
|
+
mediaType: canonical.mediaType,
|
|
140
|
+
cfg,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
export function toInternalMessagePreprocessedContext(canonical, cfg) {
|
|
144
|
+
return {
|
|
145
|
+
from: canonical.from,
|
|
146
|
+
to: canonical.to,
|
|
147
|
+
body: canonical.body,
|
|
148
|
+
bodyForAgent: canonical.bodyForAgent,
|
|
149
|
+
transcript: canonical.transcript,
|
|
150
|
+
timestamp: canonical.timestamp,
|
|
151
|
+
channelId: canonical.channelId,
|
|
152
|
+
conversationId: canonical.conversationId,
|
|
153
|
+
messageId: canonical.messageId,
|
|
154
|
+
senderId: canonical.senderId,
|
|
155
|
+
senderName: canonical.senderName,
|
|
156
|
+
senderUsername: canonical.senderUsername,
|
|
157
|
+
provider: canonical.provider,
|
|
158
|
+
surface: canonical.surface,
|
|
159
|
+
mediaPath: canonical.mediaPath,
|
|
160
|
+
mediaType: canonical.mediaType,
|
|
161
|
+
isGroup: canonical.isGroup,
|
|
162
|
+
groupId: canonical.groupId,
|
|
163
|
+
cfg,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
export function toInternalMessageSentContext(canonical) {
|
|
167
|
+
return {
|
|
168
|
+
to: canonical.to,
|
|
169
|
+
content: canonical.content,
|
|
170
|
+
success: canonical.success,
|
|
171
|
+
...(canonical.error ? { error: canonical.error } : {}),
|
|
172
|
+
channelId: canonical.channelId,
|
|
173
|
+
accountId: canonical.accountId,
|
|
174
|
+
conversationId: canonical.conversationId,
|
|
175
|
+
messageId: canonical.messageId,
|
|
176
|
+
...(canonical.isGroup != null ? { isGroup: canonical.isGroup } : {}),
|
|
177
|
+
...(canonical.groupId ? { groupId: canonical.groupId } : {}),
|
|
178
|
+
};
|
|
179
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export async function waitForAbortSignal(signal) {
|
|
2
|
+
if (!signal || signal.aborted) {
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
5
|
+
await new Promise((resolve) => {
|
|
6
|
+
const onAbort = () => {
|
|
7
|
+
signal.removeEventListener("abort", onAbort);
|
|
8
|
+
resolve();
|
|
9
|
+
};
|
|
10
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { resolveBoundaryPath, resolveBoundaryPathSync, } from "./boundary-path.js";
|
|
4
|
+
import { openVerifiedFileSync, } from "./safe-open-sync.js";
|
|
5
|
+
export function canUseBoundaryFileOpen(ioFs) {
|
|
6
|
+
return (typeof ioFs.openSync === "function" &&
|
|
7
|
+
typeof ioFs.closeSync === "function" &&
|
|
8
|
+
typeof ioFs.fstatSync === "function" &&
|
|
9
|
+
typeof ioFs.lstatSync === "function" &&
|
|
10
|
+
typeof ioFs.realpathSync === "function" &&
|
|
11
|
+
typeof ioFs.readFileSync === "function" &&
|
|
12
|
+
typeof ioFs.constants === "object" &&
|
|
13
|
+
ioFs.constants !== null);
|
|
14
|
+
}
|
|
15
|
+
export function openBoundaryFileSync(params) {
|
|
16
|
+
const ioFs = params.ioFs ?? fs;
|
|
17
|
+
const resolved = resolveBoundaryFilePathGeneric({
|
|
18
|
+
absolutePath: params.absolutePath,
|
|
19
|
+
resolve: (absolutePath) => resolveBoundaryPathSync({
|
|
20
|
+
absolutePath,
|
|
21
|
+
rootPath: params.rootPath,
|
|
22
|
+
rootCanonicalPath: params.rootRealPath,
|
|
23
|
+
boundaryLabel: params.boundaryLabel,
|
|
24
|
+
skipLexicalRootCheck: params.skipLexicalRootCheck,
|
|
25
|
+
}),
|
|
26
|
+
});
|
|
27
|
+
if (resolved instanceof Promise) {
|
|
28
|
+
return toBoundaryValidationError(new Error("Unexpected async boundary resolution"));
|
|
29
|
+
}
|
|
30
|
+
return finalizeBoundaryFileOpen({
|
|
31
|
+
resolved,
|
|
32
|
+
maxBytes: params.maxBytes,
|
|
33
|
+
rejectHardlinks: params.rejectHardlinks,
|
|
34
|
+
allowedType: params.allowedType,
|
|
35
|
+
ioFs,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function openBoundaryFileResolved(params) {
|
|
39
|
+
const opened = openVerifiedFileSync({
|
|
40
|
+
filePath: params.absolutePath,
|
|
41
|
+
resolvedPath: params.resolvedPath,
|
|
42
|
+
rejectHardlinks: params.rejectHardlinks ?? true,
|
|
43
|
+
maxBytes: params.maxBytes,
|
|
44
|
+
allowedType: params.allowedType,
|
|
45
|
+
ioFs: params.ioFs,
|
|
46
|
+
});
|
|
47
|
+
if (!opened.ok) {
|
|
48
|
+
return opened;
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
ok: true,
|
|
52
|
+
path: opened.path,
|
|
53
|
+
fd: opened.fd,
|
|
54
|
+
stat: opened.stat,
|
|
55
|
+
rootRealPath: params.rootRealPath,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function finalizeBoundaryFileOpen(params) {
|
|
59
|
+
if ("ok" in params.resolved) {
|
|
60
|
+
return params.resolved;
|
|
61
|
+
}
|
|
62
|
+
return openBoundaryFileResolved({
|
|
63
|
+
absolutePath: params.resolved.absolutePath,
|
|
64
|
+
resolvedPath: params.resolved.resolvedPath,
|
|
65
|
+
rootRealPath: params.resolved.rootRealPath,
|
|
66
|
+
maxBytes: params.maxBytes,
|
|
67
|
+
rejectHardlinks: params.rejectHardlinks,
|
|
68
|
+
allowedType: params.allowedType,
|
|
69
|
+
ioFs: params.ioFs,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
export async function openBoundaryFile(params) {
|
|
73
|
+
const ioFs = params.ioFs ?? fs;
|
|
74
|
+
const maybeResolved = resolveBoundaryFilePathGeneric({
|
|
75
|
+
absolutePath: params.absolutePath,
|
|
76
|
+
resolve: (absolutePath) => resolveBoundaryPath({
|
|
77
|
+
absolutePath,
|
|
78
|
+
rootPath: params.rootPath,
|
|
79
|
+
rootCanonicalPath: params.rootRealPath,
|
|
80
|
+
boundaryLabel: params.boundaryLabel,
|
|
81
|
+
policy: params.aliasPolicy,
|
|
82
|
+
skipLexicalRootCheck: params.skipLexicalRootCheck,
|
|
83
|
+
}),
|
|
84
|
+
});
|
|
85
|
+
const resolved = maybeResolved instanceof Promise ? await maybeResolved : maybeResolved;
|
|
86
|
+
return finalizeBoundaryFileOpen({
|
|
87
|
+
resolved,
|
|
88
|
+
maxBytes: params.maxBytes,
|
|
89
|
+
rejectHardlinks: params.rejectHardlinks,
|
|
90
|
+
allowedType: params.allowedType,
|
|
91
|
+
ioFs,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function toBoundaryValidationError(error) {
|
|
95
|
+
return { ok: false, reason: "validation", error };
|
|
96
|
+
}
|
|
97
|
+
function mapResolvedBoundaryPath(absolutePath, resolved) {
|
|
98
|
+
return {
|
|
99
|
+
absolutePath,
|
|
100
|
+
resolvedPath: resolved.canonicalPath,
|
|
101
|
+
rootRealPath: resolved.rootCanonicalPath,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function resolveBoundaryFilePathGeneric(params) {
|
|
105
|
+
const absolutePath = path.resolve(params.absolutePath);
|
|
106
|
+
try {
|
|
107
|
+
const resolved = params.resolve(absolutePath);
|
|
108
|
+
if (resolved instanceof Promise) {
|
|
109
|
+
return resolved
|
|
110
|
+
.then((value) => mapResolvedBoundaryPath(absolutePath, value))
|
|
111
|
+
.catch((error) => toBoundaryValidationError(error));
|
|
112
|
+
}
|
|
113
|
+
return mapResolvedBoundaryPath(absolutePath, resolved);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
return toBoundaryValidationError(error);
|
|
117
|
+
}
|
|
118
|
+
}
|