@poolzin/pool-bot 2026.3.25 → 2026.3.26
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/dist/agents/model-fallback.js +5 -4
- package/dist/agents/tools/common.js +16 -201
- package/dist/auto-reply/auto-reply/reply/agent-runner-execution.js +502 -0
- package/dist/auto-reply/auto-reply/reply/agent-runner-helpers.js +65 -0
- package/dist/auto-reply/auto-reply/reply/agent-runner-memory.js +160 -0
- package/dist/auto-reply/auto-reply/reply/agent-runner-payloads.js +85 -0
- package/dist/auto-reply/auto-reply/reply/agent-runner-utils.js +101 -0
- package/dist/auto-reply/auto-reply/reply/bash-command.js +338 -0
- package/dist/auto-reply/auto-reply/reply/block-streaming.js +91 -0
- package/dist/auto-reply/auto-reply/reply/commands-approve.js +88 -0
- package/dist/auto-reply/auto-reply/reply/commands-bash.js +26 -0
- package/dist/auto-reply/auto-reply/reply/commands-compact.js +107 -0
- package/dist/auto-reply/auto-reply/reply/commands-config.js +241 -0
- package/dist/auto-reply/auto-reply/reply/commands-context-report.js +295 -0
- package/dist/auto-reply/auto-reply/reply/commands-context.js +30 -0
- package/dist/auto-reply/auto-reply/reply/commands-core.js +151 -0
- package/dist/auto-reply/auto-reply/reply/commands-export-session.js +163 -0
- package/dist/auto-reply/auto-reply/reply/commands-info.js +184 -0
- package/dist/auto-reply/auto-reply/reply/commands-models.js +299 -0
- package/dist/auto-reply/auto-reply/reply/commands-plugin.js +35 -0
- package/dist/auto-reply/auto-reply/reply/commands-ptt.js +171 -0
- package/dist/auto-reply/auto-reply/reply/commands-setunset-standard.js +13 -0
- package/dist/auto-reply/auto-reply/reply/commands-setunset.js +73 -0
- package/dist/auto-reply/auto-reply/reply/commands-slash-parse.js +31 -0
- package/dist/auto-reply/auto-reply/reply/commands-status.js +178 -0
- package/dist/auto-reply/auto-reply/reply/commands-subagents.js +73 -0
- package/dist/auto-reply/auto-reply/reply/commands-system-prompt.js +117 -0
- package/dist/auto-reply/auto-reply/reply/commands-tts.js +231 -0
- package/dist/auto-reply/auto-reply/reply/directive-handling.impl.js +380 -0
- package/dist/auto-reply/auto-reply/reply/followup-runner.js +227 -0
- package/dist/auto-reply/auto-reply/reply/get-reply-directives-apply.js +201 -0
- package/dist/auto-reply/auto-reply/reply/get-reply-directives-utils.js +54 -0
- package/dist/auto-reply/auto-reply/reply/get-reply-directives.js +332 -0
- package/dist/auto-reply/auto-reply/reply/get-reply-inline-actions.js +258 -0
- package/dist/auto-reply/auto-reply/reply/get-reply-run.js +297 -0
- package/dist/auto-reply/auto-reply/reply/groups.js +102 -0
- package/dist/auto-reply/auto-reply/reply/mentions.js +129 -0
- package/dist/auto-reply/auto-reply/reply/reply-delivery.js +92 -0
- package/dist/auto-reply/auto-reply/reply/reply-directives.js +30 -0
- package/dist/auto-reply/auto-reply/reply/reply-dispatcher.js +152 -0
- package/dist/auto-reply/auto-reply/reply/reply-elevated.js +166 -0
- package/dist/auto-reply/auto-reply/reply/reply-inline.js +28 -0
- package/dist/auto-reply/auto-reply/reply/reply-payloads.js +114 -0
- package/dist/auto-reply/auto-reply/reply/reply-reference.js +36 -0
- package/dist/auto-reply/auto-reply/reply/reply-tags.js +13 -0
- package/dist/auto-reply/auto-reply/reply/reply-threading.js +41 -0
- package/dist/auto-reply/auto-reply/reply/session-updates.js +233 -0
- package/dist/auto-reply/auto-reply/reply/stage-sandbox-media.js +146 -0
- package/dist/build-info.json +3 -3
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/canvas-host/a2ui/a2ui.bundle.js +2 -17772
- package/dist/canvas-host/a2ui/index.html +1 -307
- package/dist/channels/channels/directory-config.js +185 -0
- package/dist/channels/channels/discord/handle-action.guild-admin.js +332 -0
- package/dist/channels/channels/discord/handle-action.js +165 -0
- package/dist/channels/channels/discord.js +413 -0
- package/dist/channels/channels/dock.js +436 -0
- package/dist/channels/channels/index.js +51 -0
- package/dist/channels/channels/plugins/outbound/discord.js +101 -0
- package/dist/channels/channels/whatsapp.js +17 -0
- package/dist/channels/plugins/types.js +1 -1
- package/dist/channels/run-state-machine.js +7 -0
- package/dist/commands/models/auth.js +47 -1
- package/dist/commands-subagents/action-agents.js +44 -0
- package/dist/commands-subagents/action-focus.js +64 -0
- package/dist/commands-subagents/action-help.js +4 -0
- package/dist/commands-subagents/action-info.js +45 -0
- package/dist/commands-subagents/action-kill.js +60 -0
- package/dist/commands-subagents/action-list.js +44 -0
- package/dist/commands-subagents/action-log.js +29 -0
- package/dist/commands-subagents/action-send.js +119 -0
- package/dist/commands-subagents/action-spawn.js +52 -0
- package/dist/commands-subagents/action-unfocus.js +30 -0
- package/dist/commands-subagents/shared.js +303 -0
- package/dist/config/config.js +1 -8
- package/dist/config/types.secrets.js +61 -0
- package/dist/control-ui/assets/{index-D7shnQwQ.js → index-umCsvrWy.js} +884 -741
- package/dist/control-ui/assets/index-umCsvrWy.js.map +1 -0
- package/dist/control-ui/assets/pt-BR-DedEVAvY.js +2 -0
- package/dist/control-ui/assets/pt-BR-DedEVAvY.js.map +1 -0
- package/dist/control-ui/assets/zh-CN-CDzeklK-.js +2 -0
- package/dist/control-ui/assets/zh-CN-CDzeklK-.js.map +1 -0
- package/dist/control-ui/assets/zh-TW-BJCRYNWH.js +2 -0
- package/dist/control-ui/assets/zh-TW-BJCRYNWH.js.map +1 -0
- package/dist/control-ui/index.html +1 -1
- package/dist/gateway/method-scopes.js +9 -1
- package/dist/gateway/node-pending-work.js +142 -0
- package/dist/gateway/protocol/index.js +5 -1
- package/dist/gateway/protocol/schema/nodes.js +18 -0
- package/dist/gateway/server-methods/nodes-pending.js +96 -0
- package/dist/gateway/server-methods-list.js +4 -0
- package/dist/gateway/server-methods.js +2 -0
- package/dist/imessage/channel.js +253 -0
- package/dist/imessage/monitor/echo-cache.js +70 -0
- package/dist/imessage/monitor/loop-rate-limiter.js +51 -0
- package/dist/imessage/monitor/reflection-guard.js +50 -0
- package/dist/imessage/monitor/sanitize-outbound.js +25 -0
- package/dist/imessage/monitor/self-chat-cache.js +75 -0
- package/dist/imessage/runtime.js +3 -0
- package/dist/infra/exec-approval-reply.js +7 -0
- package/dist/infra/tmp-openclaw-dir.js +84 -0
- package/dist/pairing/pairing-challenge.js +15 -0
- package/dist/plugin-sdk/account-id.d.ts +1 -0
- package/dist/plugin-sdk/agent-media-payload.d.ts +12 -0
- package/dist/plugin-sdk/allow-from.d.ts +27 -0
- package/dist/plugin-sdk/command-auth.d.ts +25 -0
- package/dist/plugin-sdk/command-auth.js +3 -1
- package/dist/plugin-sdk/config-paths.d.ts +6 -0
- package/dist/plugin-sdk/file-lock.d.ts +16 -0
- package/dist/plugin-sdk/index.d.ts +428 -0
- package/dist/plugin-sdk/index.js +237 -103
- package/dist/plugin-sdk/json-store.d.ts +5 -0
- package/dist/plugin-sdk/keyed-async-queue.d.ts +12 -0
- package/dist/plugin-sdk/onboarding.d.ts +11 -0
- package/dist/plugin-sdk/provider-auth-result.d.ts +14 -0
- package/dist/plugin-sdk/slack-message-actions.d.ts +11 -0
- package/dist/plugin-sdk/status-helpers.d.ts +25 -0
- package/dist/plugin-sdk/temp-path.d.ts +12 -0
- package/dist/plugin-sdk/text-chunking.d.ts +1 -0
- package/dist/plugin-sdk/tool-send.d.ts +4 -0
- package/dist/plugin-sdk/webhook-path.d.ts +6 -0
- package/dist/plugin-sdk/webhook-targets.d.ts +23 -0
- package/dist/plugin-sdk/windows-spawn.d.ts +39 -0
- package/dist/plugin-sdk-internal/accounts.js +6 -0
- package/dist/plugin-sdk-internal/discord.js +23 -0
- package/dist/plugin-sdk-internal/imessage.js +13 -0
- package/dist/plugin-sdk-internal/setup.js +9 -0
- package/dist/plugin-sdk-internal/signal.js +13 -0
- package/dist/plugin-sdk-internal/slack.js +22 -0
- package/dist/plugin-sdk-internal/telegram.js +32 -0
- package/dist/plugin-sdk-internal/whatsapp.js +29 -0
- package/dist/routing/session-key.js +4 -185
- package/dist/shared/pid-alive.js +2 -61
- package/dist/shared/process-scoped-map.js +5 -7
- package/dist/signal/channel.js +264 -0
- package/dist/signal/monitor/access-policy.js +60 -0
- package/dist/signal/runtime.js +3 -0
- package/dist/slack/account-inspect.js +135 -0
- package/dist/slack/blocks-input.js +7 -38
- package/dist/slack/channel.js +394 -0
- package/dist/slack/interactive-replies.js +28 -0
- package/dist/slack/monitor/channel-type.js +31 -0
- package/dist/slack/monitor/dm-auth.js +49 -0
- package/dist/slack/monitor/events/interactions.modal.js +137 -0
- package/dist/slack/monitor/events/message-subtype-handlers.js +68 -0
- package/dist/slack/monitor/events/system-event-context.js +29 -0
- package/dist/slack/monitor/events/system-event-test-harness.js +41 -0
- package/dist/slack/monitor/external-arg-menu-store.js +46 -0
- package/dist/slack/monitor/message-handler/prepare-content.js +69 -0
- package/dist/slack/monitor/message-handler/prepare-thread-context.js +91 -0
- package/dist/slack/monitor/message-handler/prepare.test-helpers.js +55 -0
- package/dist/slack/monitor/reconnect-policy.js +78 -0
- package/dist/slack/monitor/slash-commands.runtime.js +1 -0
- package/dist/slack/monitor/slash-dispatch.runtime.js +9 -0
- package/dist/slack/monitor/slash-skill-commands.runtime.js +1 -0
- package/dist/slack/resolve-allowlist-common.js +36 -0
- package/dist/slack/runtime.js +3 -0
- package/dist/slack/sent-thread-cache.js +61 -0
- package/dist/slack/truncate.js +10 -0
- package/dist/telegram/account-inspect.js +175 -0
- package/dist/telegram/allow-from.js +10 -0
- package/dist/telegram/api-fetch.js +18 -0
- package/dist/telegram/approval-buttons.js +30 -0
- package/dist/telegram/audit-membership-runtime.js +61 -0
- package/dist/telegram/bot/delivery.replies.js +508 -0
- package/dist/telegram/bot/delivery.resolve-media.js +227 -0
- package/dist/telegram/bot/delivery.send.js +132 -0
- package/dist/telegram/bot/reply-threading.js +46 -0
- package/dist/telegram/bot-message-context.body.js +186 -0
- package/dist/telegram/bot-message-context.session.js +207 -0
- package/dist/telegram/bot-message-context.types.js +1 -0
- package/dist/telegram/bot-native-commands.test-helpers.js +117 -0
- package/dist/telegram/bot.media.e2e-harness.js +81 -0
- package/dist/telegram/bot.media.test-utils.js +81 -0
- package/dist/telegram/channel-actions.js +225 -0
- package/dist/telegram/channel.js +515 -0
- package/dist/telegram/conversation-route.js +107 -0
- package/dist/telegram/delivery.js +2 -0
- package/dist/telegram/delivery.replies.js +508 -0
- package/dist/telegram/dm-access.js +86 -0
- package/dist/telegram/draft-stream.test-helpers.js +62 -0
- package/dist/telegram/exec-approvals-handler.js +281 -0
- package/dist/telegram/exec-approvals.js +62 -0
- package/dist/telegram/forum-service-message.js +22 -0
- package/dist/telegram/group-config-helpers.js +10 -0
- package/dist/telegram/lane-delivery-state.js +19 -0
- package/dist/telegram/lane-delivery-text-deliverer.js +357 -0
- package/dist/telegram/lane-delivery.js +2 -0
- package/dist/telegram/normalize.js +37 -0
- package/dist/telegram/onboarding.js +192 -0
- package/dist/telegram/outbound-adapter.js +100 -0
- package/dist/telegram/polling-session.js +275 -0
- package/dist/telegram/runtime.js +3 -0
- package/dist/telegram/sendchataction-401-backoff.js +71 -0
- package/dist/telegram/sequential-key.js +46 -0
- package/dist/telegram/status-issues.js +105 -0
- package/dist/telegram/target-writeback.js +165 -0
- package/dist/telegram/thread-bindings.js +560 -0
- package/dist/utils.js +10 -276
- package/dist/wizard/prompts.js +5 -5
- package/extensions/feishu/src/policy.ts +1 -1
- package/extensions/firecrawl/index.test.ts +82 -0
- package/extensions/firecrawl/index.ts +20 -0
- package/extensions/firecrawl/openclaw.plugin.json +8 -0
- package/extensions/firecrawl/package.json +12 -0
- package/extensions/firecrawl/src/config.ts +159 -0
- package/extensions/firecrawl/src/firecrawl-client.ts +446 -0
- package/extensions/firecrawl/src/firecrawl-scrape-tool.ts +89 -0
- package/extensions/firecrawl/src/firecrawl-search-provider.ts +63 -0
- package/extensions/firecrawl/src/firecrawl-search-tool.ts +76 -0
- package/package.json +1 -1
- package/dist/.buildstamp +0 -1
- package/dist/acp/bindings-store.js +0 -209
- package/dist/acp/control-plane/runtime-cache.js +0 -54
- package/dist/acp/control-plane/runtime-options.js +0 -215
- package/dist/acp/control-plane/session-actor-queue.js +0 -36
- package/dist/acp/index.js +0 -2
- package/dist/acp/runtime/errors.js +0 -47
- package/dist/acp/runtime/registry.js +0 -86
- package/dist/acp/secret-file.js +0 -22
- package/dist/agents/auth-profiles.resolve-auth-profile-order.fixtures.js +0 -23
- package/dist/agents/bash-process-registry.test-helpers.js +0 -29
- package/dist/agents/bash-tools.exec-approval-request.js +0 -20
- package/dist/agents/bash-tools.exec-host-gateway.js +0 -240
- package/dist/agents/bash-tools.exec-host-node.js +0 -235
- package/dist/agents/checkpoint-manager.js +0 -290
- package/dist/agents/claude-cli-runner.js +0 -3
- package/dist/agents/error-classifier.js +0 -251
- package/dist/agents/live-model-filter.js +0 -84
- package/dist/agents/nvidia-models.js +0 -228
- package/dist/agents/pi-embedded-runner/run.overflow-compaction.fixture.js +0 -34
- package/dist/agents/pi-embedded-runner/run.overflow-compaction.mocks.shared.js +0 -156
- package/dist/agents/pi-embedded-subscribe.handlers.tools.media.test-helpers.js +0 -30
- package/dist/agents/provider/config-loader.js +0 -76
- package/dist/agents/provider/index.js +0 -15
- package/dist/agents/provider/models-dev.js +0 -129
- package/dist/agents/provider/session-binding.js +0 -376
- package/dist/agents/queued-file-writer.js +0 -22
- package/dist/agents/skills/bundled-context.js +0 -23
- package/dist/agents/skills/security.js +0 -211
- package/dist/agents/skills/tools-dir.js +0 -9
- package/dist/agents/skills-install-download.js +0 -290
- package/dist/agents/skills-install-output.js +0 -30
- package/dist/agents/skills-install.download-test-utils.js +0 -36
- package/dist/agents/skills.test-helpers.js +0 -13
- package/dist/agents/subagent-announce-reliability.js +0 -160
- package/dist/agents/subagent-registry.mocks.shared.js +0 -12
- package/dist/agents/test-helpers/assistant-message-fixtures.js +0 -29
- package/dist/agents/test-helpers/fast-coding-tools.js +0 -1
- package/dist/agents/test-helpers/fast-core-tools.js +0 -8
- package/dist/agents/test-helpers/fast-tool-stubs.js +0 -18
- package/dist/agents/test-helpers/host-sandbox-fs-bridge.js +0 -74
- package/dist/agents/test-helpers/pi-tools-sandbox-context.js +0 -27
- package/dist/agents/tool-display-common.js +0 -915
- package/dist/agents/tool-policy-shared.js +0 -108
- package/dist/agents/tool-policy.conformance.js +0 -14
- package/dist/agents/tool-result-truncation.js +0 -299
- package/dist/agents/tools/cron-tool.test-helpers.js +0 -12
- package/dist/agents/tools/discord-actions-moderation-shared.js +0 -27
- package/dist/agents/tools/discord-actions-presence.js +0 -78
- package/dist/control-ui/assets/index-D7shnQwQ.js.map +0 -1
- package/dist/discord/discord-improvements.js +0 -167
- package/dist/discord/index.js +0 -2
- package/dist/hooks/bundled/boot-md/HOOK.md +0 -19
- package/dist/hooks/bundled/command-logger/HOOK.md +0 -122
- package/dist/hooks/bundled/session-memory/HOOK.md +0 -86
- package/dist/hooks/bundled/soul-evil/HOOK.md +0 -71
- package/dist/whatsapp/normalize.js +0 -66
- package/dist/whatsapp/resolve-outbound-target.js +0 -42
- /package/dist/{acp/runtime/types.js → auto-reply/auto-reply/reply/commands-types.js} +0 -0
- /package/dist/{agents/pi-embedded-payloads.js → slack/account-surface-fields.js} +0 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { extractAssistantText, resolveInternalSessionKey, resolveMainSessionAlias, sanitizeTextContent, stripToolMessages, } from "../../../agents/tools/sessions-helpers.js";
|
|
2
|
+
import { parseDiscordTarget } from "../../../discord/targets.js";
|
|
3
|
+
import { callGateway } from "../../../gateway/call.js";
|
|
4
|
+
import { formatTimeAgo } from "../../../infra/format-time/format-relative.js";
|
|
5
|
+
import { parseAgentSessionKey } from "../../../routing/session-key.js";
|
|
6
|
+
import { extractTextFromChatContent } from "../../../shared/chat-content.js";
|
|
7
|
+
import { formatDurationCompact, formatTokenUsageDisplay, truncateLine, } from "../../../shared/subagents-format.js";
|
|
8
|
+
import { formatRunLabel, formatRunStatus, resolveSubagentTargetFromRuns, } from "../subagents-utils.js";
|
|
9
|
+
export { extractAssistantText, stripToolMessages };
|
|
10
|
+
export const COMMAND = "/subagents";
|
|
11
|
+
export const COMMAND_KILL = "/kill";
|
|
12
|
+
export const COMMAND_STEER = "/steer";
|
|
13
|
+
export const COMMAND_TELL = "/tell";
|
|
14
|
+
export const COMMAND_FOCUS = "/focus";
|
|
15
|
+
export const COMMAND_UNFOCUS = "/unfocus";
|
|
16
|
+
export const COMMAND_AGENTS = "/agents";
|
|
17
|
+
export const ACTIONS = new Set([
|
|
18
|
+
"list",
|
|
19
|
+
"kill",
|
|
20
|
+
"log",
|
|
21
|
+
"send",
|
|
22
|
+
"steer",
|
|
23
|
+
"info",
|
|
24
|
+
"spawn",
|
|
25
|
+
"focus",
|
|
26
|
+
"unfocus",
|
|
27
|
+
"agents",
|
|
28
|
+
"help",
|
|
29
|
+
]);
|
|
30
|
+
export const RECENT_WINDOW_MINUTES = 30;
|
|
31
|
+
const SUBAGENT_TASK_PREVIEW_MAX = 110;
|
|
32
|
+
export const STEER_ABORT_SETTLE_TIMEOUT_MS = 5_000;
|
|
33
|
+
const SESSION_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
34
|
+
function compactLine(value) {
|
|
35
|
+
return value.replace(/\s+/g, " ").trim();
|
|
36
|
+
}
|
|
37
|
+
function formatTaskPreview(value) {
|
|
38
|
+
return truncateLine(compactLine(value), SUBAGENT_TASK_PREVIEW_MAX);
|
|
39
|
+
}
|
|
40
|
+
function resolveModelDisplay(entry, fallbackModel) {
|
|
41
|
+
const model = typeof entry?.model === "string" ? entry.model.trim() : "";
|
|
42
|
+
const provider = typeof entry?.modelProvider === "string" ? entry.modelProvider.trim() : "";
|
|
43
|
+
let combined = model.includes("/") ? model : model && provider ? `${provider}/${model}` : model;
|
|
44
|
+
if (!combined) {
|
|
45
|
+
const overrideModel = typeof entry?.modelOverride === "string" ? entry.modelOverride.trim() : "";
|
|
46
|
+
const overrideProvider = typeof entry?.providerOverride === "string" ? entry.providerOverride.trim() : "";
|
|
47
|
+
combined = overrideModel.includes("/")
|
|
48
|
+
? overrideModel
|
|
49
|
+
: overrideModel && overrideProvider
|
|
50
|
+
? `${overrideProvider}/${overrideModel}`
|
|
51
|
+
: overrideModel;
|
|
52
|
+
}
|
|
53
|
+
if (!combined) {
|
|
54
|
+
combined = fallbackModel?.trim() || "";
|
|
55
|
+
}
|
|
56
|
+
if (!combined) {
|
|
57
|
+
return "model n/a";
|
|
58
|
+
}
|
|
59
|
+
const slash = combined.lastIndexOf("/");
|
|
60
|
+
if (slash >= 0 && slash < combined.length - 1) {
|
|
61
|
+
return combined.slice(slash + 1);
|
|
62
|
+
}
|
|
63
|
+
return combined;
|
|
64
|
+
}
|
|
65
|
+
export function resolveDisplayStatus(entry) {
|
|
66
|
+
const status = formatRunStatus(entry);
|
|
67
|
+
return status === "error" ? "failed" : status;
|
|
68
|
+
}
|
|
69
|
+
export function formatSubagentListLine(params) {
|
|
70
|
+
const usageText = formatTokenUsageDisplay(params.sessionEntry);
|
|
71
|
+
const label = truncateLine(formatRunLabel(params.entry, { maxLength: 48 }), 48);
|
|
72
|
+
const task = formatTaskPreview(params.entry.task);
|
|
73
|
+
const runtime = formatDurationCompact(params.runtimeMs);
|
|
74
|
+
const status = resolveDisplayStatus(params.entry);
|
|
75
|
+
return `${params.index}. ${label} (${resolveModelDisplay(params.sessionEntry, params.entry.model)}, ${runtime}${usageText ? `, ${usageText}` : ""}) ${status}${task.toLowerCase() !== label.toLowerCase() ? ` - ${task}` : ""}`;
|
|
76
|
+
}
|
|
77
|
+
function formatTimestamp(valueMs) {
|
|
78
|
+
if (!valueMs || !Number.isFinite(valueMs) || valueMs <= 0) {
|
|
79
|
+
return "n/a";
|
|
80
|
+
}
|
|
81
|
+
return new Date(valueMs).toISOString();
|
|
82
|
+
}
|
|
83
|
+
export function formatTimestampWithAge(valueMs) {
|
|
84
|
+
if (!valueMs || !Number.isFinite(valueMs) || valueMs <= 0) {
|
|
85
|
+
return "n/a";
|
|
86
|
+
}
|
|
87
|
+
return `${formatTimestamp(valueMs)} (${formatTimeAgo(Date.now() - valueMs, { fallback: "n/a" })})`;
|
|
88
|
+
}
|
|
89
|
+
export function stopWithText(text) {
|
|
90
|
+
return { shouldContinue: false, reply: { text } };
|
|
91
|
+
}
|
|
92
|
+
export function stopWithUnknownTargetError(error) {
|
|
93
|
+
return stopWithText(`⚠️ ${error ?? "Unknown subagent."}`);
|
|
94
|
+
}
|
|
95
|
+
export function resolveSubagentTarget(runs, token) {
|
|
96
|
+
return resolveSubagentTargetFromRuns({
|
|
97
|
+
runs,
|
|
98
|
+
token,
|
|
99
|
+
recentWindowMinutes: RECENT_WINDOW_MINUTES,
|
|
100
|
+
label: (entry) => formatRunLabel(entry),
|
|
101
|
+
errors: {
|
|
102
|
+
missingTarget: "Missing subagent id.",
|
|
103
|
+
invalidIndex: (value) => `Invalid subagent index: ${value}`,
|
|
104
|
+
unknownSession: (value) => `Unknown subagent session: ${value}`,
|
|
105
|
+
ambiguousLabel: (value) => `Ambiguous subagent label: ${value}`,
|
|
106
|
+
ambiguousLabelPrefix: (value) => `Ambiguous subagent label prefix: ${value}`,
|
|
107
|
+
ambiguousRunIdPrefix: (value) => `Ambiguous run id prefix: ${value}`,
|
|
108
|
+
unknownTarget: (value) => `Unknown subagent id: ${value}`,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
export function resolveSubagentEntryForToken(runs, token) {
|
|
113
|
+
const resolved = resolveSubagentTarget(runs, token);
|
|
114
|
+
if (!resolved.entry) {
|
|
115
|
+
return { reply: stopWithUnknownTargetError(resolved.error) };
|
|
116
|
+
}
|
|
117
|
+
return { entry: resolved.entry };
|
|
118
|
+
}
|
|
119
|
+
export function resolveRequesterSessionKey(params, opts) {
|
|
120
|
+
const commandTarget = params.ctx.CommandTargetSessionKey?.trim();
|
|
121
|
+
const commandSession = params.sessionKey?.trim();
|
|
122
|
+
const raw = opts?.preferCommandTarget
|
|
123
|
+
? commandTarget || commandSession
|
|
124
|
+
: commandSession || commandTarget;
|
|
125
|
+
if (!raw) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
const { mainKey, alias } = resolveMainSessionAlias(params.cfg);
|
|
129
|
+
return resolveInternalSessionKey({ key: raw, alias, mainKey });
|
|
130
|
+
}
|
|
131
|
+
export function resolveHandledPrefix(normalized) {
|
|
132
|
+
return normalized.startsWith(COMMAND)
|
|
133
|
+
? COMMAND
|
|
134
|
+
: normalized.startsWith(COMMAND_KILL)
|
|
135
|
+
? COMMAND_KILL
|
|
136
|
+
: normalized.startsWith(COMMAND_STEER)
|
|
137
|
+
? COMMAND_STEER
|
|
138
|
+
: normalized.startsWith(COMMAND_TELL)
|
|
139
|
+
? COMMAND_TELL
|
|
140
|
+
: normalized.startsWith(COMMAND_FOCUS)
|
|
141
|
+
? COMMAND_FOCUS
|
|
142
|
+
: normalized.startsWith(COMMAND_UNFOCUS)
|
|
143
|
+
? COMMAND_UNFOCUS
|
|
144
|
+
: normalized.startsWith(COMMAND_AGENTS)
|
|
145
|
+
? COMMAND_AGENTS
|
|
146
|
+
: null;
|
|
147
|
+
}
|
|
148
|
+
export function resolveSubagentsAction(params) {
|
|
149
|
+
if (params.handledPrefix === COMMAND) {
|
|
150
|
+
const [actionRaw] = params.restTokens;
|
|
151
|
+
const action = (actionRaw?.toLowerCase() || "list");
|
|
152
|
+
if (!ACTIONS.has(action)) {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
params.restTokens.splice(0, 1);
|
|
156
|
+
return action;
|
|
157
|
+
}
|
|
158
|
+
if (params.handledPrefix === COMMAND_KILL) {
|
|
159
|
+
return "kill";
|
|
160
|
+
}
|
|
161
|
+
if (params.handledPrefix === COMMAND_FOCUS) {
|
|
162
|
+
return "focus";
|
|
163
|
+
}
|
|
164
|
+
if (params.handledPrefix === COMMAND_UNFOCUS) {
|
|
165
|
+
return "unfocus";
|
|
166
|
+
}
|
|
167
|
+
if (params.handledPrefix === COMMAND_AGENTS) {
|
|
168
|
+
return "agents";
|
|
169
|
+
}
|
|
170
|
+
return "steer";
|
|
171
|
+
}
|
|
172
|
+
export function isDiscordSurface(params) {
|
|
173
|
+
const channel = params.ctx.OriginatingChannel ??
|
|
174
|
+
params.command.channel ??
|
|
175
|
+
params.ctx.Surface ??
|
|
176
|
+
params.ctx.Provider;
|
|
177
|
+
return (String(channel ?? "")
|
|
178
|
+
.trim()
|
|
179
|
+
.toLowerCase() === "discord");
|
|
180
|
+
}
|
|
181
|
+
export function resolveDiscordAccountId(params) {
|
|
182
|
+
const accountId = typeof params.ctx.AccountId === "string" ? params.ctx.AccountId.trim() : "";
|
|
183
|
+
return accountId || "default";
|
|
184
|
+
}
|
|
185
|
+
export function resolveDiscordChannelIdForFocus(params) {
|
|
186
|
+
const toCandidates = [
|
|
187
|
+
typeof params.ctx.OriginatingTo === "string" ? params.ctx.OriginatingTo.trim() : "",
|
|
188
|
+
typeof params.command.to === "string" ? params.command.to.trim() : "",
|
|
189
|
+
typeof params.ctx.To === "string" ? params.ctx.To.trim() : "",
|
|
190
|
+
].filter(Boolean);
|
|
191
|
+
for (const candidate of toCandidates) {
|
|
192
|
+
try {
|
|
193
|
+
const target = parseDiscordTarget(candidate, { defaultKind: "channel" });
|
|
194
|
+
if (target?.kind === "channel" && target.id) {
|
|
195
|
+
return target.id;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
// Ignore parse failures and try the next candidate.
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return undefined;
|
|
203
|
+
}
|
|
204
|
+
export async function resolveFocusTargetSession(params) {
|
|
205
|
+
const subagentMatch = resolveSubagentTarget(params.runs, params.token);
|
|
206
|
+
if (subagentMatch.entry) {
|
|
207
|
+
const key = subagentMatch.entry.childSessionKey;
|
|
208
|
+
const parsed = parseAgentSessionKey(key);
|
|
209
|
+
return {
|
|
210
|
+
targetKind: "subagent",
|
|
211
|
+
targetSessionKey: key,
|
|
212
|
+
agentId: parsed?.agentId ?? "main",
|
|
213
|
+
label: formatRunLabel(subagentMatch.entry),
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
const token = params.token.trim();
|
|
217
|
+
if (!token) {
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
const attempts = [];
|
|
221
|
+
attempts.push({ key: token });
|
|
222
|
+
if (SESSION_ID_RE.test(token)) {
|
|
223
|
+
attempts.push({ sessionId: token });
|
|
224
|
+
}
|
|
225
|
+
attempts.push({ label: token });
|
|
226
|
+
for (const attempt of attempts) {
|
|
227
|
+
try {
|
|
228
|
+
const resolved = await callGateway({
|
|
229
|
+
method: "sessions.resolve",
|
|
230
|
+
params: attempt,
|
|
231
|
+
});
|
|
232
|
+
const key = typeof resolved?.key === "string" ? resolved.key.trim() : "";
|
|
233
|
+
if (!key) {
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
const parsed = parseAgentSessionKey(key);
|
|
237
|
+
return {
|
|
238
|
+
targetKind: key.includes(":subagent:") ? "subagent" : "acp",
|
|
239
|
+
targetSessionKey: key,
|
|
240
|
+
agentId: parsed?.agentId ?? "main",
|
|
241
|
+
label: token,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
catch {
|
|
245
|
+
// Try the next resolution strategy.
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
export function buildSubagentsHelp() {
|
|
251
|
+
return [
|
|
252
|
+
"Subagents",
|
|
253
|
+
"Usage:",
|
|
254
|
+
"- /subagents list",
|
|
255
|
+
"- /subagents kill <id|#|all>",
|
|
256
|
+
"- /subagents log <id|#> [limit] [tools]",
|
|
257
|
+
"- /subagents info <id|#>",
|
|
258
|
+
"- /subagents send <id|#> <message>",
|
|
259
|
+
"- /subagents steer <id|#> <message>",
|
|
260
|
+
"- /subagents spawn <agentId> <task> [--model <model>] [--thinking <level>]",
|
|
261
|
+
"- /focus <subagent-label|session-key|session-id|session-label>",
|
|
262
|
+
"- /unfocus",
|
|
263
|
+
"- /agents",
|
|
264
|
+
"- /session ttl <duration|off>",
|
|
265
|
+
"- /kill <id|#|all>",
|
|
266
|
+
"- /steer <id|#> <message>",
|
|
267
|
+
"- /tell <id|#> <message>",
|
|
268
|
+
"",
|
|
269
|
+
"Ids: use the list index (#), runId/session prefix, label, or full session key.",
|
|
270
|
+
].join("\n");
|
|
271
|
+
}
|
|
272
|
+
export function extractMessageText(message) {
|
|
273
|
+
const role = typeof message.role === "string" ? message.role : "";
|
|
274
|
+
const shouldSanitize = role === "assistant";
|
|
275
|
+
const text = extractTextFromChatContent(message.content, {
|
|
276
|
+
sanitizeText: shouldSanitize ? sanitizeTextContent : undefined,
|
|
277
|
+
});
|
|
278
|
+
return text ? { role, text } : null;
|
|
279
|
+
}
|
|
280
|
+
export function formatLogLines(messages) {
|
|
281
|
+
const lines = [];
|
|
282
|
+
for (const msg of messages) {
|
|
283
|
+
const extracted = extractMessageText(msg);
|
|
284
|
+
if (!extracted) {
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
const label = extracted.role === "assistant" ? "Assistant" : "User";
|
|
288
|
+
lines.push(`${label}: ${extracted.text}`);
|
|
289
|
+
}
|
|
290
|
+
return lines;
|
|
291
|
+
}
|
|
292
|
+
export function loadSubagentSessionEntry(params, childKey, loaders, storeCache) {
|
|
293
|
+
const parsed = parseAgentSessionKey(childKey);
|
|
294
|
+
const storePath = loaders.resolveStorePath(params.cfg.session?.store, {
|
|
295
|
+
agentId: parsed?.agentId,
|
|
296
|
+
});
|
|
297
|
+
let store = storeCache?.get(storePath);
|
|
298
|
+
if (!store) {
|
|
299
|
+
store = loaders.loadSessionStore(storePath);
|
|
300
|
+
storeCache?.set(storePath, store);
|
|
301
|
+
}
|
|
302
|
+
return { storePath, store, entry: store[childKey] };
|
|
303
|
+
}
|
package/dist/config/config.js
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { migrateLegacyConfig } from "./legacy-migrate.js";
|
|
3
|
-
export * from "./paths.js";
|
|
4
|
-
export * from "./runtime-overrides.js";
|
|
5
|
-
export * from "./secrets-integration.js";
|
|
6
|
-
export * from "./types.js";
|
|
7
|
-
export { validateConfigObject, validateConfigObjectWithPlugins } from "./validation.js";
|
|
8
|
-
export { PoolBotSchema } from "./zod-schema.js";
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Secret input type helpers
|
|
3
|
+
*
|
|
4
|
+
* Utilities for working with secret inputs that may be:
|
|
5
|
+
* - Direct string values
|
|
6
|
+
* - Secret references (env:, file:, etc.)
|
|
7
|
+
* - undefined/null
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Normalizes a secret input value to a string if it's a direct value.
|
|
11
|
+
* Returns null if the value is undefined, null, or a secret reference.
|
|
12
|
+
*/
|
|
13
|
+
export function normalizeSecretInputString(value) {
|
|
14
|
+
if (value === undefined || value === null) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
if (typeof value !== "string") {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
// Check if it's a secret reference pattern
|
|
21
|
+
if (isSecretReference(value)) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Checks if a value is a secret reference (env:, file:, etc.)
|
|
28
|
+
*/
|
|
29
|
+
function isSecretReference(value) {
|
|
30
|
+
const secretPrefixes = ["env:", "file:", "op:", "1password:", "keychain:", "aws:"];
|
|
31
|
+
return secretPrefixes.some((prefix) => value.startsWith(prefix));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Checks if a secret input is "configured" - meaning it has some value
|
|
35
|
+
* (either direct or as a secret reference), as opposed to being undefined/null.
|
|
36
|
+
*
|
|
37
|
+
* Optionally accepts a defaults config to check for default values.
|
|
38
|
+
*/
|
|
39
|
+
export function hasConfiguredSecretInput(value, _defaults) {
|
|
40
|
+
// Direct value check
|
|
41
|
+
if (value !== undefined && value !== null) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Resolves a secret input that may be a reference or direct value.
|
|
48
|
+
* Returns undefined if the value is not configured.
|
|
49
|
+
*/
|
|
50
|
+
export function resolveSecretInput(value, _defaults) {
|
|
51
|
+
const normalized = normalizeSecretInputString(value);
|
|
52
|
+
if (normalized !== null) {
|
|
53
|
+
return normalized;
|
|
54
|
+
}
|
|
55
|
+
// Handle secret references - would need secrets runtime to resolve
|
|
56
|
+
if (typeof value === "string" && isSecretReference(value)) {
|
|
57
|
+
// Return the reference as-is; actual resolution happens at runtime
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|