@segmentstream/agent 0.102.0 → 0.103.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/CHANGELOG.md +16 -0
- package/README.md +8 -20
- package/dist/_chunks/{build-metadata-BtB38zQ0.mjs → build-metadata-BkLo_nGS.mjs} +1 -1
- package/dist/_chunks/{chat-archive-DmCXcI8G.mjs → chat-archive-CMyCVvpe.mjs} +1 -1
- package/dist/_chunks/{principal-DL9NdRRP.mjs → principal-DIQHp6AG.mjs} +32 -11
- package/dist/_chunks/{silent-xJcJ8SNJ.mjs → silent-CWcAjHwt.mjs} +1 -1
- package/dist/extension/config.d.ts +0 -13
- package/dist/extension/config.mjs +0 -56
- package/dist/extension/connections/ontology.mjs +1 -1
- package/dist/extension/extension.d.ts +0 -2
- package/dist/extension/hooks/authorization.mjs +1 -1
- package/dist/extension/instructions/persona.mjs +1 -1
- package/dist/extension/lib/actor.mjs +1 -1
- package/dist/extension/lib/attachment-tools.mjs +1 -1
- package/dist/extension/lib/attachments-dispatch.mjs +2 -2
- package/dist/extension/lib/attachments-send.mjs +1 -1
- package/dist/extension/lib/attachments.mjs +1 -1
- package/dist/extension/lib/build-metadata.mjs +1 -1
- package/dist/extension/lib/channel-guest.d.ts +15 -0
- package/dist/extension/lib/channel-guest.mjs +54 -0
- package/dist/extension/lib/chat-address.mjs +1 -1
- package/dist/extension/lib/chat-context.mjs +1 -1
- package/dist/extension/lib/chat-persona.mjs +1 -1
- package/dist/extension/lib/chat-recorder.mjs +2 -2
- package/dist/extension/lib/confirmations.mjs +1 -1
- package/dist/extension/lib/email/attachments-send.mjs +1 -1
- package/dist/extension/lib/email/channel.mjs +2 -2
- package/dist/extension/lib/guest-usage.mjs +1 -1
- package/dist/extension/lib/identities.d.ts +22 -0
- package/dist/extension/lib/identities.mjs +25 -0
- package/dist/extension/lib/inbound-media/files.mjs +1 -1
- package/dist/extension/lib/inbound-media/index.mjs +1 -1
- package/dist/extension/lib/ontology-connection.mjs +1 -1
- package/dist/extension/lib/ontology-file-call.mjs +1 -1
- package/dist/extension/lib/ontology-recall.mjs +1 -1
- package/dist/extension/lib/ontology-tools.mjs +1 -1
- package/dist/extension/lib/review/files.mjs +1 -1
- package/dist/extension/lib/review/hold.mjs +1 -1
- package/dist/extension/lib/review/reply.mjs +2 -2
- package/dist/extension/lib/role-skill.mjs +1 -1
- package/dist/extension/lib/runtime-envelope.mjs +1 -1
- package/dist/extension/lib/sent-files.mjs +1 -1
- package/dist/extension/lib/slack/adapter.d.ts +2 -0
- package/dist/extension/lib/slack/adapter.mjs +86 -18
- package/dist/extension/lib/slack/attachments-send.mjs +1 -1
- package/dist/extension/lib/slack/callbacks.mjs +1 -1
- package/dist/extension/lib/slack/confirmation-card.mjs +1 -1
- package/dist/extension/lib/stored-files.mjs +1 -1
- package/dist/extension/lib/telegram/adapter.mjs +19 -12
- package/dist/extension/lib/telegram/attachment-description.mjs +1 -1
- package/dist/extension/lib/telegram/attachments-send.mjs +1 -1
- package/dist/extension/lib/telegram/callbacks.mjs +1 -1
- package/dist/extension/lib/telegram/chat-archive.mjs +1 -1
- package/dist/extension/lib/telegram/confirmations.d.ts +2 -0
- package/dist/extension/lib/telegram/confirmations.mjs +49 -13
- package/dist/extension/lib/telegram/customer-text.mjs +1 -1
- package/dist/extension/lib/telegram/files.mjs +1 -1
- package/dist/extension/lib/telegram/health.mjs +1 -1
- package/dist/extension/lib/telegram/held-approvals.mjs +1 -1
- package/dist/extension/lib/telegram/inbound-request.d.ts +2 -0
- package/dist/extension/lib/telegram/inbound-request.mjs +1 -1
- package/dist/extension/lib/telegram/inbound.mjs +30 -15
- package/dist/extension/lib/telegram/lifecycle.mjs +2 -2
- package/dist/extension/lib/telegram/principal.mjs +1 -1
- package/dist/extension/lib/telegram/routing-context.mjs +1 -1
- package/dist/extension/lib/telegram/session-recovery.mjs +1 -1
- package/dist/extension/lib/telegram/sessions.d.ts +2 -0
- package/dist/extension/lib/telegram/sessions.mjs +9 -1
- package/dist/extension/lib/telegram/silent.mjs +1 -1
- package/dist/extension/lib/telegram/store-capture.mjs +1 -1
- package/dist/extension/lib/telegram/structured.mjs +1 -1
- package/dist/extension/lib/telegram/turn-errors.mjs +2 -2
- package/dist/extension/lib/triage.mjs +1 -1
- package/dist/extension/lib/web/auth.d.ts +1 -0
- package/dist/extension/lib/web/auth.mjs +1 -1
- package/dist/extension/lib/web/channel.mjs +1 -1
- package/dist/extension/lib/whatsapp/adapter.mjs +26 -2
- package/dist/extension/lib/whatsapp/attachments-send.mjs +1 -1
- package/dist/extension/lib/whatsapp/callbacks.mjs +1 -1
- package/dist/extension/lib/whatsapp/files.mjs +1 -1
- package/dist/extension/lib/workspace-action.mjs +1 -1
- package/dist/extension/lib/workspace-channel/attachments-send.mjs +1 -1
- package/dist/extension/lib/workspace-channel/channel.mjs +2 -2
- package/dist/extension/lib/workspace-source.mjs +1 -1
- package/dist/extension/model.mjs +1 -1
- package/dist/extension/tools/attachments_discard.mjs +1 -1
- package/dist/extension/tools/attachments_list.mjs +1 -1
- package/dist/extension/tools/attachments_promote.mjs +1 -1
- package/dist/extension/tools/attachments_read.mjs +1 -1
- package/dist/extension/tools/attachments_send.mjs +2 -2
- package/dist/extension/tools/attachments_stage.mjs +1 -1
- package/dist/extension/tools/attachments_table.mjs +1 -1
- package/dist/extension/tools/handoff.mjs +1 -1
- package/dist/extension/tools/questions_ask.mjs +1 -1
- package/dist/extension/tools/workspace_source.mjs +1 -1
- package/package.json +2 -2
- package/dist/extension/lib/public-group-knowledge.d.ts +0 -16
- package/dist/extension/lib/public-group-knowledge.mjs +0 -44
- package/dist/extension/lib/public-group.d.ts +0 -28
- package/dist/extension/lib/public-group.mjs +0 -116
|
@@ -6,10 +6,10 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { n as workflowToolResult } from "../../_chunks/workflow-serializable-gzv5MZ5P.mjs";
|
|
8
8
|
import segmentstream from "../extension.mjs";
|
|
9
|
-
import {
|
|
9
|
+
import { G as memberTool, It as chatAddressOf } from "../../_chunks/principal-DIQHp6AG.mjs";
|
|
10
10
|
import { sendStoredFiles } from "../lib/attachments-dispatch.mjs";
|
|
11
11
|
import { sendAttachmentsInput } from "../lib/telegram/attachments-send.mjs";
|
|
12
|
-
import { d as attachToReply } from "../../_chunks/silent-
|
|
12
|
+
import { d as attachToReply } from "../../_chunks/silent-CWcAjHwt.mjs";
|
|
13
13
|
import { repliesReviewed } from "../lib/review/hold.mjs";
|
|
14
14
|
import { defineTool } from "eve/tools";
|
|
15
15
|
const tool = defineTool({
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import segmentstream from "../extension.mjs";
|
|
8
|
-
import { H as actorOf } from "../../_chunks/principal-
|
|
8
|
+
import { H as actorOf } from "../../_chunks/principal-DIQHp6AG.mjs";
|
|
9
9
|
import { SANDBOX_TOOL, holdsAgentTool, requireAgentTool } from "../lib/agent-tools.mjs";
|
|
10
10
|
import { attachmentOwner, optionalString, stringArgument, toolAttachments } from "../lib/attachment-tools.mjs";
|
|
11
11
|
import { sessionSandbox } from "../lib/sandbox-session.mjs";
|
|
@@ -8,7 +8,7 @@ import { n as workflowToolResult } from "../../_chunks/workflow-serializable-gzv
|
|
|
8
8
|
import { ID_INPUT, attachmentForModel, attachmentOwner, boundedResultPage, headerArgument, optionalString, pageInteger, stringArgument, toolAttachments } from "../lib/attachment-tools.mjs";
|
|
9
9
|
import { readSheets, typedTable } from "../lib/attachment-tables.mjs";
|
|
10
10
|
import { queryTable } from "../lib/attachment-query.mjs";
|
|
11
|
-
import { G as memberTool } from "../../_chunks/principal-
|
|
11
|
+
import { G as memberTool } from "../../_chunks/principal-DIQHp6AG.mjs";
|
|
12
12
|
import { defineTool } from "eve/tools";
|
|
13
13
|
const FILTER_OPERATIONS = [
|
|
14
14
|
"eq",
|
|
@@ -7,7 +7,7 @@ __eveCreateRequire(import.meta.url);
|
|
|
7
7
|
import segmentstream from "../extension.mjs";
|
|
8
8
|
import { agentTaskIdOf } from "../lib/agent-task.mjs";
|
|
9
9
|
import { stringArgument } from "../lib/attachment-tools.mjs";
|
|
10
|
-
import {
|
|
10
|
+
import { It as chatAddressOf, Lt as chatChannel, i as memberIdOf } from "../../_chunks/principal-DIQHp6AG.mjs";
|
|
11
11
|
import { appOrigin } from "../lib/environment.mjs";
|
|
12
12
|
import { agentIdentities } from "../lib/identities.mjs";
|
|
13
13
|
import { runtimeToken } from "../lib/runtime-token.mjs";
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { n as workflowToolResult } from "../../_chunks/workflow-serializable-gzv5MZ5P.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { It as chatAddressOf, K as notForGuests, i as memberIdOf } from "../../_chunks/principal-DIQHp6AG.mjs";
|
|
9
9
|
import { agentTaskIdOf, agentTaskSessions } from "../lib/agent-task.mjs";
|
|
10
10
|
import { stringArgument } from "../lib/attachment-tools.mjs";
|
|
11
11
|
import { pendingQuestions, questionKey } from "../lib/questions.mjs";
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import segmentstream from "../extension.mjs";
|
|
8
|
-
import { H as actorOf } from "../../_chunks/principal-
|
|
8
|
+
import { H as actorOf } from "../../_chunks/principal-DIQHp6AG.mjs";
|
|
9
9
|
import { SANDBOX_TOOL, holdsAgentTool, requireAgentTool } from "../lib/agent-tools.mjs";
|
|
10
10
|
import { appOrigin } from "../lib/environment.mjs";
|
|
11
11
|
import { runtimeToken } from "../lib/runtime-token.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segmentstream/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.103.0",
|
|
4
4
|
"description": "The SegmentStream workspace agent: the ontology as tools, acting as the member who writes, and the browser, Telegram, WhatsApp and Slack through the workspace's connections.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "SegmentStream",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"@chat-adapter/state-memory": "4.42.0",
|
|
89
89
|
"@chat-adapter/telegram": "4.41.0",
|
|
90
90
|
"@chat-adapter/whatsapp": "4.42.0",
|
|
91
|
-
"@segmentstream/ontology": "0.
|
|
91
|
+
"@segmentstream/ontology": "0.182.0",
|
|
92
92
|
"@vercel/oidc": "^3.8.4",
|
|
93
93
|
"ai": "^7.0.172",
|
|
94
94
|
"chat": "4.42.0",
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { type ChannelConnectionRequestOptions } from "./workspace-channel/connection.js";
|
|
2
|
-
export interface PublicGroupKnowledgeContext {
|
|
3
|
-
readonly question: string;
|
|
4
|
-
readonly signal: AbortSignal;
|
|
5
|
-
/** GET against the one workspace connection bound to this source. Never a model tool. */
|
|
6
|
-
readonly get: (path: string, options?: Pick<ChannelConnectionRequestOptions, "api" | "headers" | "query">) => Promise<string>;
|
|
7
|
-
/** A private, tool-free model call, metered against the same guest budget. */
|
|
8
|
-
readonly reason: (instructions: string, input: string) => Promise<string>;
|
|
9
|
-
}
|
|
10
|
-
/** Trusted workspace code returns only information it permits the group to see. */
|
|
11
|
-
export interface PublicGroupKnowledge {
|
|
12
|
-
readonly connection: string;
|
|
13
|
-
readonly unavailable: Readonly<Record<string, string>>;
|
|
14
|
-
readonly lookup?: (context: PublicGroupKnowledgeContext) => Promise<readonly string[]>;
|
|
15
|
-
}
|
|
16
|
-
export declare function publicGroupEvidence(source: PublicGroupKnowledge, question: string, reason: PublicGroupKnowledgeContext["reason"], signal: AbortSignal): Promise<readonly string[]>;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath as __eveFileURLToPath } from "node:url";
|
|
2
|
-
import { dirname as __eveDirname } from "node:path";
|
|
3
|
-
import { createRequire as __eveCreateRequire } from "node:module";
|
|
4
|
-
const __filename = __eveFileURLToPath(import.meta.url);
|
|
5
|
-
__eveDirname(__filename);
|
|
6
|
-
__eveCreateRequire(import.meta.url);
|
|
7
|
-
import { connectionProxy } from "./connection-proxy.mjs";
|
|
8
|
-
import { proxyEnvironment } from "./environment.mjs";
|
|
9
|
-
import { runtimeToken } from "./runtime-token.mjs";
|
|
10
|
-
import { connectionCall } from "./workspace-channel/connection.mjs";
|
|
11
|
-
async function publicGroupEvidence(source, question, reason, signal) {
|
|
12
|
-
if (!source.lookup) return [];
|
|
13
|
-
let reads = 0;
|
|
14
|
-
let calls = 0;
|
|
15
|
-
try {
|
|
16
|
-
return (await source.lookup({
|
|
17
|
-
question,
|
|
18
|
-
signal,
|
|
19
|
-
reason: (instructions, input) => {
|
|
20
|
-
signal.throwIfAborted();
|
|
21
|
-
if (++calls > 3 || input.length > 6e4 || instructions.length > 8e3) throw new Error("Public research model limit exceeded.");
|
|
22
|
-
return reason(instructions, input);
|
|
23
|
-
},
|
|
24
|
-
get: async (path, options) => {
|
|
25
|
-
signal.throwIfAborted();
|
|
26
|
-
if (++reads > 10) throw new Error("Public research read limit exceeded.");
|
|
27
|
-
const result = await connectionProxy({
|
|
28
|
-
environment: proxyEnvironment(),
|
|
29
|
-
connection: source.connection,
|
|
30
|
-
token: runtimeToken
|
|
31
|
-
}).request(connectionCall({
|
|
32
|
-
...options,
|
|
33
|
-
method: "GET",
|
|
34
|
-
path
|
|
35
|
-
}), signal);
|
|
36
|
-
if (result.status < 200 || result.status >= 300) throw new Error(`Knowledge source returned HTTP ${result.status}.`);
|
|
37
|
-
return new TextDecoder().decode(result.body);
|
|
38
|
-
}
|
|
39
|
-
})).filter((fact) => typeof fact === "string" && fact.length <= 1e3).slice(0, 8);
|
|
40
|
-
} catch {
|
|
41
|
-
return [];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
export { publicGroupEvidence };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { AdmissionSettings } from "../config.js";
|
|
2
|
-
export interface PublicGroupResponseContext {
|
|
3
|
-
readonly question: string;
|
|
4
|
-
readonly locale?: string;
|
|
5
|
-
/** Privately verified facts, fetched at most once. */
|
|
6
|
-
readonly evidence: () => Promise<readonly string[]>;
|
|
7
|
-
readonly reason: (instructions: string, prompt: string) => Promise<string>;
|
|
8
|
-
/** The workspace-authored ontology action. Never offered to a model. */
|
|
9
|
-
readonly act: (input: Readonly<Record<string, unknown>>) => Promise<unknown>;
|
|
10
|
-
}
|
|
11
|
-
/** Everyone in an opened group sees the reply, including when an employee asks. */
|
|
12
|
-
export declare function isPublicGroup(admission: AdmissionSettings, channel: string, chat: string, sender: string): Promise<boolean>;
|
|
13
|
-
/** An unlinked sender can only submit this message to the workspace's public instructions.
|
|
14
|
-
* No member principal, history, tools, workspace files or channel tokens enter the model call. */
|
|
15
|
-
export declare function answerPublicGroup(input: {
|
|
16
|
-
admission: AdmissionSettings;
|
|
17
|
-
channel: string;
|
|
18
|
-
chat: string;
|
|
19
|
-
sender: string;
|
|
20
|
-
message: string;
|
|
21
|
-
text: string;
|
|
22
|
-
locale?: string;
|
|
23
|
-
post: (text: string) => Promise<unknown>;
|
|
24
|
-
claim?: () => Promise<boolean>;
|
|
25
|
-
finish?: (delivered: boolean) => Promise<void>;
|
|
26
|
-
}): Promise<boolean>;
|
|
27
|
-
/** An authenticated provider join only offers the inviter's own, row-scoped authority. */
|
|
28
|
-
export declare function publicGroupInvite(admission: AdmissionSettings, provider: "slack" | "telegram", channel: string, chat: string, inviter: string): Promise<void>;
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath as __eveFileURLToPath } from "node:url";
|
|
2
|
-
import { dirname as __eveDirname } from "node:path";
|
|
3
|
-
import { createRequire as __eveCreateRequire } from "node:module";
|
|
4
|
-
const __filename = __eveFileURLToPath(import.meta.url);
|
|
5
|
-
__eveDirname(__filename);
|
|
6
|
-
__eveCreateRequire(import.meta.url);
|
|
7
|
-
import { localizedText } from "./admission.mjs";
|
|
8
|
-
import { chatRuntimeRequest } from "./chat-persona.mjs";
|
|
9
|
-
import { ontologyGuestUsage } from "./guest-usage.mjs";
|
|
10
|
-
import { publicGroupEvidence } from "./public-group-knowledge.mjs";
|
|
11
|
-
import { gatewayCostOf } from "./web-search.mjs";
|
|
12
|
-
import { gateway, generateText } from "ai";
|
|
13
|
-
async function isPublicGroup(admission, channel, chat, sender) {
|
|
14
|
-
if (!admission.publicGroups) return false;
|
|
15
|
-
const result = await chatRuntimeRequest("public-turn", {
|
|
16
|
-
channel,
|
|
17
|
-
chat,
|
|
18
|
-
sender,
|
|
19
|
-
check: true
|
|
20
|
-
});
|
|
21
|
-
if (result?.status !== "public" && result?.status !== "closed") throw new Error("Invalid group access.");
|
|
22
|
-
return result.status === "public";
|
|
23
|
-
}
|
|
24
|
-
async function answerPublicGroup(input) {
|
|
25
|
-
const settings = input.admission.publicGroups;
|
|
26
|
-
if (!settings || !input.text.trim()) return false;
|
|
27
|
-
if (input.claim && !await input.claim()) return true;
|
|
28
|
-
let delivered = false;
|
|
29
|
-
try {
|
|
30
|
-
const turn = await chatRuntimeRequest("public-turn", {
|
|
31
|
-
channel: input.channel,
|
|
32
|
-
chat: input.chat,
|
|
33
|
-
sender: input.sender,
|
|
34
|
-
limits: input.admission.limits
|
|
35
|
-
});
|
|
36
|
-
if (turn?.status === "closed") return false;
|
|
37
|
-
if (turn?.status === "limited") {
|
|
38
|
-
const text = localizedText(input.admission.replies.limited, input.locale);
|
|
39
|
-
if (text) await input.post(text);
|
|
40
|
-
delivered = true;
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
if (turn?.status !== "admitted" || typeof turn.guestId !== "string") throw new Error("Invalid public group admission.");
|
|
44
|
-
const guestId = turn.guestId;
|
|
45
|
-
const question = input.text.slice(0, 8e3);
|
|
46
|
-
const researchDeadline = AbortSignal.timeout(3e4);
|
|
47
|
-
const messageKey = JSON.stringify([
|
|
48
|
-
input.channel,
|
|
49
|
-
input.chat,
|
|
50
|
-
input.message
|
|
51
|
-
]);
|
|
52
|
-
let stage = 0;
|
|
53
|
-
const generate = async (system, prompt, privateCall = false, signal = AbortSignal.timeout(3e4)) => {
|
|
54
|
-
const usageKey = privateCall ? `research:${++stage}:${messageKey}` : messageKey;
|
|
55
|
-
const reply = await generateText({
|
|
56
|
-
model: gateway(settings.model),
|
|
57
|
-
system,
|
|
58
|
-
prompt,
|
|
59
|
-
maxRetries: 0,
|
|
60
|
-
maxOutputTokens: privateCall ? 1e3 : 600,
|
|
61
|
-
abortSignal: signal
|
|
62
|
-
});
|
|
63
|
-
const costUsd = gatewayCostOf(reply.providerMetadata);
|
|
64
|
-
if (costUsd > 0) await ontologyGuestUsage()({
|
|
65
|
-
guestId,
|
|
66
|
-
costUsd,
|
|
67
|
-
key: usageKey.slice(0, 256)
|
|
68
|
-
});
|
|
69
|
-
return reply.text.trim();
|
|
70
|
-
};
|
|
71
|
-
let research;
|
|
72
|
-
const evidenceForTurn = () => research ??= settings.knowledge ? publicGroupEvidence(settings.knowledge, question, (system, prompt) => generate(system, prompt, true, researchDeadline), researchDeadline) : Promise.resolve([]);
|
|
73
|
-
let calls = 0;
|
|
74
|
-
let actions = 0;
|
|
75
|
-
const response = await settings.respond?.({
|
|
76
|
-
question,
|
|
77
|
-
locale: input.locale,
|
|
78
|
-
evidence: evidenceForTurn,
|
|
79
|
-
reason: (system, prompt) => {
|
|
80
|
-
if (++calls > 2 || system.length > 8e3 || prompt.length > 2e4) throw new Error("Public response limit exceeded.");
|
|
81
|
-
return generate(system, prompt, true);
|
|
82
|
-
},
|
|
83
|
-
act: async (data) => {
|
|
84
|
-
if (++actions > 4 || JSON.stringify(data).length > 12e3) throw new Error("Public action limit exceeded.");
|
|
85
|
-
const reply = await chatRuntimeRequest("public-action", {
|
|
86
|
-
channel: input.channel,
|
|
87
|
-
chat: input.chat,
|
|
88
|
-
sender: input.sender,
|
|
89
|
-
input: data
|
|
90
|
-
}, AbortSignal.timeout(25e3));
|
|
91
|
-
if (!reply || !Object.hasOwn(reply, "result")) throw new Error("Public action failed.");
|
|
92
|
-
return reply.result;
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
const evidence = response === void 0 && settings.knowledge ? await evidenceForTurn() : void 0;
|
|
96
|
-
const prompt = evidence === void 0 ? question : JSON.stringify({
|
|
97
|
-
question,
|
|
98
|
-
evidence
|
|
99
|
-
});
|
|
100
|
-
const text = response ?? (settings.knowledge && !evidence?.length ? localizedText(settings.knowledge.unavailable, input.locale) : await generate(settings.instructions, prompt));
|
|
101
|
-
if (!text) throw new Error("The public group answer was empty.");
|
|
102
|
-
await input.post(text.slice(0, 3500));
|
|
103
|
-
delivered = true;
|
|
104
|
-
return true;
|
|
105
|
-
} finally {
|
|
106
|
-
await input.finish?.(delivered);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
async function publicGroupInvite(admission, provider, channel, chat, inviter) {
|
|
110
|
-
if (admission.publicGroups?.trustedJoinChannels?.includes(channel)) await chatRuntimeRequest("public-invite", {
|
|
111
|
-
key: `${channel}:${chat}`,
|
|
112
|
-
provider,
|
|
113
|
-
inviter
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
export { answerPublicGroup, isPublicGroup, publicGroupInvite };
|