@capybara-hq/kernel 0.1.0-rc.114 → 0.1.0-rc.116
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/bootstrap.json +9 -9
- package/dist/admin/admin.schemas.d.ts +1 -0
- package/dist/agents/agents.controller.d.ts +13 -1
- package/dist/agents/agents.controller.js +24 -2
- package/dist/catalog/catalog.service.d.ts +11 -1
- package/dist/catalog/catalog.service.js +36 -2
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/platform-components.js +13 -0
- package/dist/catalog/plugin-connectors.d.ts +35 -0
- package/dist/catalog/plugin-connectors.js +81 -0
- package/dist/channels/supervisor.d.ts +5 -1
- package/dist/channels/supervisor.js +17 -1
- package/dist/conversations/conversations.controller.d.ts +46 -14
- package/dist/conversations/conversations.controller.js +82 -47
- package/dist/conversations/conversations.service.d.ts +93 -59
- package/dist/conversations/conversations.service.js +255 -72
- package/dist/conversations/events.d.ts +39 -0
- package/dist/conversations/events.js +52 -2
- package/dist/conversations/inline-tokens.d.ts +87 -0
- package/dist/conversations/inline-tokens.js +154 -0
- package/dist/conversations/permission-profiles.controller.d.ts +14 -7
- package/dist/conversations/permission-profiles.controller.js +1 -5
- package/dist/conversations/prompt-suggestions.js +2 -4
- package/dist/conversations/queue.d.ts +0 -2
- package/dist/conversations/queue.service.js +9 -13
- package/dist/db/kernel-schema.d.ts +5 -0
- package/dist/errors.d.ts +12 -0
- package/dist/errors.js +12 -0
- package/dist/evals/snapshot.js +4 -2
- package/dist/files/library-files.service.d.ts +13 -0
- package/dist/files/library-files.service.js +33 -6
- package/dist/identity/settings.d.ts +5 -0
- package/dist/identity/settings.js +4 -0
- package/dist/models/purposes.js +5 -0
- package/dist/net/safe-fetch.js +1 -1
- package/dist/orgs/settings.service.d.ts +2 -0
- package/dist/platform/exclusions.js +6 -1
- package/dist/platform/ops/org-settings.ops.js +1 -1
- package/dist/runtime/compaction-model.d.ts +57 -0
- package/dist/runtime/compaction-model.js +87 -0
- package/dist/runtime/compaction.service.d.ts +23 -8
- package/dist/runtime/compaction.service.js +15 -10
- package/dist/runtime/context/build.d.ts +7 -2
- package/dist/runtime/context/build.js +17 -6
- package/dist/runtime/context/compaction.d.ts +22 -5
- package/dist/runtime/context/compaction.js +35 -15
- package/dist/runtime/context/idle-compaction-rules.d.ts +17 -2
- package/dist/runtime/context/idle-compaction-rules.js +20 -5
- package/dist/runtime/idle-arm.d.ts +12 -2
- package/dist/runtime/idle-arm.js +66 -18
- package/dist/runtime/idle-compaction-jobs.d.ts +24 -3
- package/dist/runtime/idle-compaction.d.ts +11 -3
- package/dist/runtime/idle-compaction.js +61 -30
- package/dist/runtime/model-call.d.ts +52 -16
- package/dist/runtime/model-call.js +71 -24
- package/dist/runtime/run-finish.d.ts +12 -3
- package/dist/runtime/run-finish.js +14 -7
- package/dist/runtime/run-queue.d.ts +5 -2
- package/dist/runtime/run-queue.js +7 -4
- package/dist/runtime/run-steps.d.ts +4 -1
- package/dist/runtime/run-steps.js +9 -2
- package/dist/runtime/run-worker.js +4 -2
- package/dist/runtime/runtime.module.js +3 -0
- package/dist/sandbox/review/classifier.js +5 -1
- package/dist/tools/connector-content.controller.d.ts +6 -2
- package/dist/tools/connector-content.controller.js +13 -3
- package/dist/tools/connector-content.d.ts +55 -15
- package/dist/tools/connector-content.js +112 -54
- package/dist/tools/connectors.service.d.ts +3 -2
- package/dist/tools/connectors.service.js +6 -20
- package/dist/tools/mentionable-connectors.d.ts +88 -0
- package/dist/tools/mentionable-connectors.js +218 -0
- package/dist/tools/pipeline.js +43 -6
- package/dist/tools/specs.d.ts +13 -4
- package/dist/tools/specs.js +22 -8
- package/dist/tools/tools.module.js +7 -0
- package/package.json +3 -3
- package/src/migrations/0200_runs_idle_mode.sql +4 -0
- package/src/migrations/0201_tool_specs_text.sql +8 -0
|
@@ -24,6 +24,7 @@ import { CompactBody, DOWNLOAD_AS, EventsQuery, FilesQuery, IdParams, ListQuery,
|
|
|
24
24
|
import { ConversationsService, MAX_PROJECT_FILES, } from "./conversations.service.js";
|
|
25
25
|
import { ConversationDeviceStatus } from "./device-status.js";
|
|
26
26
|
import { ConversationFiles, FILE_CONTENT_MAX_BYTES } from "./files.js";
|
|
27
|
+
import { countMarkers, MAX_CONNECTOR_MENTIONS, MAX_TOKENS, tokenEntityKey, } from "./inline-tokens.js";
|
|
27
28
|
import { ConversationOutputs, OUTPUT_PAGE_MAX_CHARS } from "./outputs-read.js";
|
|
28
29
|
import { ConversationQueue } from "./queue.service.js";
|
|
29
30
|
const GroupsQuery = z.object({
|
|
@@ -57,40 +58,39 @@ const DownloadQuery = z.object({
|
|
|
57
58
|
inline: z.enum(["0", "1"]).optional(),
|
|
58
59
|
as: DOWNLOAD_AS.optional(),
|
|
59
60
|
});
|
|
61
|
+
/** One inline token of a message (composer inline tokens spec §3.1); its place is a U+FFFC in `text`. */
|
|
62
|
+
export const MessageTokenSchema = z.discriminatedUnion("type", [
|
|
63
|
+
z.object({ type: z.literal("connector"), connectorId: z.uuid() }).strict(),
|
|
64
|
+
z
|
|
65
|
+
.object({
|
|
66
|
+
type: z.literal("resource"),
|
|
67
|
+
connectorId: z.uuid(),
|
|
68
|
+
uri: z.string().min(1).max(2000),
|
|
69
|
+
})
|
|
70
|
+
.strict(),
|
|
71
|
+
z.object({ type: z.literal("file"), id: z.uuid() }).strict(),
|
|
72
|
+
z.object({ type: z.literal("projectFile"), path: z.string().min(1).max(4096) }).strict(),
|
|
73
|
+
z.object({ type: z.literal("conversation"), id: z.string().min(1).max(100) }).strict(),
|
|
74
|
+
]);
|
|
60
75
|
const MessageFields = z.object({
|
|
61
|
-
/** 用户输入的文本;只有带 `files` 且不带 `attachments` 时可以为空(只发图片 / 文件)。 */
|
|
62
|
-
text: z.string().max(100_000),
|
|
63
|
-
clientMessageId: z.string().min(1).max(200).optional(),
|
|
64
|
-
/** `@` 资源引用:内核以发送者的凭据读取并作为附加文本块写入(见 ConversationsService.postUserMessage)。 */
|
|
65
|
-
attachments: z
|
|
66
|
-
.array(z.object({ connectorId: z.uuid(), uri: z.string().min(1).max(2000) }).strict())
|
|
67
|
-
.max(MAX_ATTACHMENTS)
|
|
68
|
-
.optional(),
|
|
69
76
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
77
|
+
* The person's text; each U+FFFC marks one token's place, in order. Empty only with a skill, or
|
|
78
|
+
* with `files` and no tokens (an upload-only message).
|
|
72
79
|
*/
|
|
73
|
-
|
|
80
|
+
text: z.string().max(100_000),
|
|
81
|
+
clientMessageId: z.string().min(1).max(200).optional(),
|
|
74
82
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* the create body.
|
|
83
|
+
* Inline tokens (composer inline tokens spec §3.1), in text order: connectors, connector
|
|
84
|
+
* resources, library files, project files and the sender's conversations. A repeated entity is
|
|
85
|
+
* resolved and counted once. A project file token needs the conversation's device project (a
|
|
86
|
+
* new conversation: `project` in the create body).
|
|
80
87
|
*/
|
|
81
|
-
|
|
82
|
-
.array(z.object({ path: z.string().min(1).max(4096) }).strict())
|
|
83
|
-
.max(MAX_PROJECT_FILES)
|
|
84
|
-
.optional(),
|
|
88
|
+
tokens: z.array(MessageTokenSchema).max(MAX_TOKENS).optional(),
|
|
85
89
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* so `payload.conversationRefs` may be shorter than this list.
|
|
90
|
+
* Uploaded file ids (finalized, see the files routes); the per-message cap is
|
|
91
|
+
* `attachments.maxPerMessage` (file tokens count toward it), 100 is only the hard ceiling here.
|
|
89
92
|
*/
|
|
90
|
-
|
|
91
|
-
.array(z.object({ id: z.string().min(1).max(100) }).strict())
|
|
92
|
-
.max(MAX_CONVERSATION_REFS)
|
|
93
|
-
.optional(),
|
|
93
|
+
files: z.array(z.uuid()).max(100).optional(),
|
|
94
94
|
/** Switch the conversation's model from the next run (UI refresh B); the agent's own = back. */
|
|
95
95
|
model: ModelRef.strict().optional(),
|
|
96
96
|
/** Switch the effort: one of the (selected) model's declared `effort` values. */
|
|
@@ -119,23 +119,63 @@ const MessageFields = z.object({
|
|
|
119
119
|
/** The sender's UI language (run context spec §3.4). */
|
|
120
120
|
locale: z.enum(["zh", "en"]).optional(),
|
|
121
121
|
});
|
|
122
|
-
// The body of `@` resource i is `content[i + 1]`, then the project files' and the referenced
|
|
123
|
-
// conversations' blocks follow, so `content[0]` must be the user's text: with `@` resources,
|
|
124
|
-
// project files or conversation references the text must not be empty. A skill invocation's
|
|
125
|
-
// `content[0]` is the rendered skill, so its text (the arguments) may be empty.
|
|
126
122
|
const textRule = [
|
|
127
|
-
(b) => b.text.length > 0 ||
|
|
128
|
-
b.skill !== undefined ||
|
|
129
|
-
((b.files?.length ?? 0) > 0 &&
|
|
130
|
-
!b.attachments?.length &&
|
|
131
|
-
!b.projectFiles?.length &&
|
|
132
|
-
!b.conversationRefs?.length),
|
|
123
|
+
(b) => b.text.length > 0 || b.skill !== undefined || ((b.files?.length ?? 0) > 0 && !b.tokens?.length),
|
|
133
124
|
{
|
|
134
|
-
message: "Text is required unless the message invokes a skill or carries files
|
|
125
|
+
message: "Text is required unless the message invokes a skill or carries files and no tokens",
|
|
135
126
|
path: ["text"],
|
|
136
127
|
},
|
|
137
128
|
];
|
|
138
|
-
|
|
129
|
+
/** The per-kind token caps (a repeated entity counts once); file tokens are capped with `files`. */
|
|
130
|
+
const TOKEN_KIND_MAX = {
|
|
131
|
+
connector: MAX_CONNECTOR_MENTIONS,
|
|
132
|
+
resource: MAX_ATTACHMENTS,
|
|
133
|
+
projectFile: MAX_PROJECT_FILES,
|
|
134
|
+
conversation: MAX_CONVERSATION_REFS,
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* The token rules: one U+FFFC per token, the per-kind caps. A project file path that leaves the
|
|
138
|
+
* project is counted by its raw text here and refused with `device.path_outside_project` when the
|
|
139
|
+
* message resolves it, before anything is written.
|
|
140
|
+
*/
|
|
141
|
+
function tokenRules(b, ctx) {
|
|
142
|
+
const tokens = b.tokens ?? [];
|
|
143
|
+
if (countMarkers(b.text) !== tokens.length) {
|
|
144
|
+
ctx.addIssue({
|
|
145
|
+
code: "custom",
|
|
146
|
+
message: "Each token needs one U+FFFC marker in text, in order",
|
|
147
|
+
path: ["text"],
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
if (b.tokens === undefined)
|
|
151
|
+
return;
|
|
152
|
+
const seen = new Map();
|
|
153
|
+
for (const t of tokens) {
|
|
154
|
+
let key;
|
|
155
|
+
try {
|
|
156
|
+
key = tokenEntityKey(t);
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
key = `${t.type}:raw:${t.type === "projectFile" ? t.path : ""}`;
|
|
160
|
+
}
|
|
161
|
+
const keys = seen.get(t.type) ?? new Set();
|
|
162
|
+
keys.add(key);
|
|
163
|
+
seen.set(t.type, keys);
|
|
164
|
+
}
|
|
165
|
+
for (const [kind, keys] of seen) {
|
|
166
|
+
const max = TOKEN_KIND_MAX[kind];
|
|
167
|
+
if (max !== undefined && keys.size > max) {
|
|
168
|
+
ctx.addIssue({
|
|
169
|
+
code: "custom",
|
|
170
|
+
message: `At most ${max} different ${kind} tokens per message`,
|
|
171
|
+
path: ["tokens"],
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
const MessageBody = MessageFields.strict()
|
|
177
|
+
.refine(...textRule)
|
|
178
|
+
.superRefine(tokenRules);
|
|
139
179
|
/**
|
|
140
180
|
* `POST /conversations`: `message` creates the conversation with its first message (create on
|
|
141
181
|
* first send; `clientMessageId` is required and makes a retry return the same conversation).
|
|
@@ -159,6 +199,7 @@ export const CreateBody = z
|
|
|
159
199
|
.extend({ clientMessageId: z.string().min(1).max(200) })
|
|
160
200
|
.strict()
|
|
161
201
|
.refine(...textRule)
|
|
202
|
+
.superRefine(tokenRules)
|
|
162
203
|
.optional(),
|
|
163
204
|
})
|
|
164
205
|
.strict();
|
|
@@ -237,10 +278,8 @@ let ConversationsController = class ConversationsController {
|
|
|
237
278
|
const out = await this.conversations.createWithMessage(org.orgId, p.account.id, body.agentId, {
|
|
238
279
|
text: m.text,
|
|
239
280
|
clientMessageId: m.clientMessageId,
|
|
240
|
-
...(m.
|
|
281
|
+
...(m.tokens !== undefined && { tokens: m.tokens }),
|
|
241
282
|
...(m.files !== undefined && { files: m.files }),
|
|
242
|
-
...(m.projectFiles !== undefined && { projectFiles: m.projectFiles }),
|
|
243
|
-
...(m.conversationRefs !== undefined && { conversationRefs: m.conversationRefs }),
|
|
244
283
|
...(m.model !== undefined && { model: m.model }),
|
|
245
284
|
...(m.effort !== undefined && { effort: m.effort }),
|
|
246
285
|
...(m.skill !== undefined && { skill: m.skill }),
|
|
@@ -452,12 +491,8 @@ let ConversationsController = class ConversationsController {
|
|
|
452
491
|
event: await this.conversations.postUserMessage(org.orgId, id, p.account.id, {
|
|
453
492
|
text: body.text,
|
|
454
493
|
...(body.clientMessageId !== undefined && { clientMessageId: body.clientMessageId }),
|
|
455
|
-
...(body.
|
|
494
|
+
...(body.tokens !== undefined && { tokens: body.tokens }),
|
|
456
495
|
...(body.files !== undefined && { files: body.files }),
|
|
457
|
-
...(body.projectFiles !== undefined && { projectFiles: body.projectFiles }),
|
|
458
|
-
...(body.conversationRefs !== undefined && {
|
|
459
|
-
conversationRefs: body.conversationRefs,
|
|
460
|
-
}),
|
|
461
496
|
...(body.model !== undefined && { model: body.model }),
|
|
462
497
|
...(body.effort !== undefined && { effort: body.effort }),
|
|
463
498
|
...(body.retryOf !== undefined && { retryOf: body.retryOf }),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ConversationSource, TriggerSubject } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { AgentLookup } from "../agents/agent-lookup.js";
|
|
3
|
-
import type { ModelRef } from "../agents/definition.js";
|
|
3
|
+
import type { AgentDefinition, ModelRef } from "../agents/definition.js";
|
|
4
4
|
import type { AgentAvatarView } from "../agents/profile.js";
|
|
5
5
|
import type { AutomationEventMarker, ScheduleMarker } from "../automations/types.js";
|
|
6
6
|
import type { ConversationSubject, TitleSource } from "../db/kernel-schema.js";
|
|
@@ -19,11 +19,13 @@ import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js
|
|
|
19
19
|
import { type RenderedInvocation, SkillInvoker } from "../skills/invoke.js";
|
|
20
20
|
import { type ApprovalRecord, ApprovalsService } from "../tools/approvals.service.js";
|
|
21
21
|
import { ConnectorContent } from "../tools/connector-content.js";
|
|
22
|
+
import { MentionableConnectorsService } from "../tools/mentionable-connectors.js";
|
|
22
23
|
import { type QuestionRecord, QuestionsService } from "../tools/questions.service.js";
|
|
23
24
|
import { ConversationAccess } from "./access.js";
|
|
24
25
|
import { type AgentTreeNode } from "./agent-tree.js";
|
|
25
26
|
import { EventLog } from "./event-log.js";
|
|
26
27
|
import { type ConversationEvent, type LogContentBlock } from "./events.js";
|
|
28
|
+
import { type InlineEntry, type MessageToken } from "./inline-tokens.js";
|
|
27
29
|
import { type ImSenderContext } from "./message-context.js";
|
|
28
30
|
import type { PermissionSelection } from "./permission-profiles.schemas.js";
|
|
29
31
|
import { PermissionProfilesService } from "./permission-profiles.service.js";
|
|
@@ -212,21 +214,31 @@ export interface RunControl {
|
|
|
212
214
|
includeSelf?: boolean;
|
|
213
215
|
}): Promise<number>;
|
|
214
216
|
}
|
|
215
|
-
/** 消息附件引用(连接器 + 资源 URI)。 */
|
|
216
|
-
export interface AttachmentRef {
|
|
217
|
-
connectorId: string;
|
|
218
|
-
uri: string;
|
|
219
|
-
}
|
|
220
217
|
/**
|
|
221
218
|
* Resolved `@` resources and referenced project files: the blocks after the user text (the
|
|
222
|
-
* resources' bodies, then one text block per project file) and their metadata.
|
|
219
|
+
* resources' bodies, then one text block per project file) and their metadata. A message with
|
|
220
|
+
* `tokens` (composer inline tokens spec §3) also gets its rendered text, where its placeholders
|
|
221
|
+
* stand, its connector mentions and its file tokens.
|
|
223
222
|
*/
|
|
224
223
|
export interface ResolvedExtra {
|
|
225
224
|
blocks: {
|
|
226
225
|
type: "text";
|
|
227
226
|
text: string;
|
|
228
227
|
}[];
|
|
229
|
-
/**
|
|
228
|
+
/**
|
|
229
|
+
* The text with each token marker replaced by its placeholder (a skill invocation's trimmed
|
|
230
|
+
* arguments); absent: the message has no tokens and its text is used as typed.
|
|
231
|
+
*/
|
|
232
|
+
text?: string;
|
|
233
|
+
/** Where each placeholder stands in {@link text} (`payload.inline`, display only). */
|
|
234
|
+
inline?: InlineEntry[];
|
|
235
|
+
/** The connectors the message names (`payload.connectorMentions`), in block order. */
|
|
236
|
+
connectorMentions?: ConnectorMention[];
|
|
237
|
+
/** The library files the message's file tokens name, in text order, before the uploads. */
|
|
238
|
+
fileTokenIds?: string[];
|
|
239
|
+
/** The label of each file (file tokens and uploads), numbered across them (spec §3.2). */
|
|
240
|
+
fileLabels?: Map<string, string>;
|
|
241
|
+
/** The resources' metadata in the user_message (payload fields `appId` / `appName`, C27). */
|
|
230
242
|
attachments: {
|
|
231
243
|
appId: string;
|
|
232
244
|
appName: string;
|
|
@@ -245,6 +257,26 @@ export interface ResolvedExtra {
|
|
|
245
257
|
*/
|
|
246
258
|
conversationRefs?: ConversationRefMeta[];
|
|
247
259
|
}
|
|
260
|
+
/** One connector a message names, as `payload.connectorMentions` records it (spec §3.5). */
|
|
261
|
+
export interface ConnectorMention {
|
|
262
|
+
connectorId: string;
|
|
263
|
+
slug: string;
|
|
264
|
+
name: string;
|
|
265
|
+
/** The agent's offered tools of it at send time. */
|
|
266
|
+
toolCount: number;
|
|
267
|
+
/**
|
|
268
|
+
* Its offered tool keys when it offers at most 20 (else empty), loaded from this message on when
|
|
269
|
+
* a step runs with tool search (inert without it).
|
|
270
|
+
*/
|
|
271
|
+
loadedTools: string[];
|
|
272
|
+
}
|
|
273
|
+
/** Where the agent's tools are resolved for a message that names connectors or resources. */
|
|
274
|
+
export interface MessageAgentContext {
|
|
275
|
+
agent: AgentDefinition;
|
|
276
|
+
source: ConversationSource;
|
|
277
|
+
/** The conversation the step's sandbox tools follow; absent for a conversation being created. */
|
|
278
|
+
sandboxConversationId?: string | undefined;
|
|
279
|
+
}
|
|
248
280
|
/** One referenced conversation as `payload.conversationRefs` names it. */
|
|
249
281
|
export interface ConversationRefMeta {
|
|
250
282
|
id: string;
|
|
@@ -273,6 +305,12 @@ export interface ProjectFilesTarget {
|
|
|
273
305
|
* the `user_message`, so replay rebuilds it from the log as it is.
|
|
274
306
|
*/
|
|
275
307
|
export declare const projectFileText: (path: string, root: string) => string;
|
|
308
|
+
/**
|
|
309
|
+
* The files' blocks with a `[file: <label>]` text block before each media block (composer inline
|
|
310
|
+
* tokens spec §3.3), so the model reads which file each one is (an image is sent bare). A file
|
|
311
|
+
* with no given label is labelled by its name, numbered after the given labels.
|
|
312
|
+
*/
|
|
313
|
+
export declare function withFileLines(blocks: readonly LogContentBlock[], labels?: ReadonlyMap<string, string>): LogContentBlock[];
|
|
276
314
|
export { userMessageIdemKey } from "./idem-keys.js";
|
|
277
315
|
/** The longest conversation title (characters, after trimming). */
|
|
278
316
|
export declare const CONVERSATION_TITLE_MAX_CHARS = 120;
|
|
@@ -285,22 +323,12 @@ export declare const EVENTS_TURN_EXTEND = 2000;
|
|
|
285
323
|
export interface UserMessageInput {
|
|
286
324
|
text: string;
|
|
287
325
|
clientMessageId?: string;
|
|
288
|
-
attachments?: AttachmentRef[];
|
|
289
|
-
files?: string[];
|
|
290
326
|
/**
|
|
291
|
-
*
|
|
292
|
-
*
|
|
327
|
+
* Inline tokens (composer inline tokens spec §3.1), one U+FFFC in `text` each, in order:
|
|
328
|
+
* connectors, connector resources, library files, project files and conversations.
|
|
293
329
|
*/
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}[];
|
|
297
|
-
/**
|
|
298
|
-
* The sender's own conversations referenced by id (@ conversations spec §1): each is read at
|
|
299
|
-
* send time into one text block ({@link conversationRefText}).
|
|
300
|
-
*/
|
|
301
|
-
conversationRefs?: {
|
|
302
|
-
id: string;
|
|
303
|
-
}[];
|
|
330
|
+
tokens?: MessageToken[];
|
|
331
|
+
files?: string[];
|
|
304
332
|
/** Switch the conversation's model from the next run (the agent's own model = back to it). */
|
|
305
333
|
model?: ModelRef;
|
|
306
334
|
/** Switch the effort (one of the model's declared `effort` values). */
|
|
@@ -394,15 +422,17 @@ export declare class ConversationsService {
|
|
|
394
422
|
private readonly ceilings;
|
|
395
423
|
/** Owes the snapshot deletions of the shares a deletion revokes (file sharing spec §9). */
|
|
396
424
|
private readonly outbox;
|
|
425
|
+
/** The agent's tools for a message naming connectors or resources (inline tokens §3.4). */
|
|
426
|
+
private readonly mentions;
|
|
397
427
|
constructor(permissions: Pick<PermissionProfilesService, "initialize" | "lockInitial">, db: KernelDb, eventLog: EventLog, agents: Pick<AgentLookup, "get">, access: Pick<ConversationAccess, "isAccessible">,
|
|
398
428
|
/** Starts and stops the conversation's runs. */
|
|
399
429
|
runs: RunControl,
|
|
400
430
|
/** Resolves a switched-to model and its declared parameters (UI refresh B). */
|
|
401
431
|
providers: Pick<ProviderRegistry, "resolve">,
|
|
402
432
|
/** Reads `@` resources with the sender's credentials. */
|
|
403
|
-
content: Pick<ConnectorContent, "
|
|
433
|
+
content: Pick<ConnectorContent, "readResources">,
|
|
404
434
|
/** Attaches the sender's library files to the conversation in the message's transaction. */
|
|
405
|
-
libraryFiles: Pick<LibraryFilesService, "attachForMessage">,
|
|
435
|
+
libraryFiles: Pick<LibraryFilesService, "attachForMessage" | "labelsFor" | "checkMessageFileCount">,
|
|
406
436
|
/** Renders a person's skill invocation (phase D). */
|
|
407
437
|
invoker: Pick<SkillInvoker, "prepare">,
|
|
408
438
|
/** Stops a deleted conversation's background tasks. */
|
|
@@ -418,7 +448,9 @@ export declare class ConversationsService {
|
|
|
418
448
|
/** ... and its pending network asks (network ask-to-allow spec §6.7). */
|
|
419
449
|
approvals: Pick<ApprovalsService, "skipNetworkIn">, events: Pick<KernelEvents, "emit">, txHost: TransactionHost, ceilings: PermissionCeilingWrites,
|
|
420
450
|
/** Owes the snapshot deletions of the shares a deletion revokes (file sharing spec §9). */
|
|
421
|
-
outbox: Pick<OutboxService, "add"
|
|
451
|
+
outbox: Pick<OutboxService, "add">,
|
|
452
|
+
/** The agent's tools for a message naming connectors or resources (inline tokens §3.4). */
|
|
453
|
+
mentions: Pick<MentionableConnectorsService, "resolveForMessage">);
|
|
422
454
|
/**
|
|
423
455
|
* Creates an empty conversation bound to its device (`pick`, see
|
|
424
456
|
* {@link ConversationDevices.forNew}); an agent the account cannot use →
|
|
@@ -613,26 +645,17 @@ export declare class ConversationsService {
|
|
|
613
645
|
* ends. A failed `ensureRun` is logged, not thrown: the message's transaction owes the ensure-run
|
|
614
646
|
* backstop, which starts the run once the queue is reachable (transactional outbox spec §6).
|
|
615
647
|
*
|
|
616
|
-
* `
|
|
617
|
-
*
|
|
618
|
-
*
|
|
619
|
-
* `
|
|
620
|
-
* `clientMessageId` returns the written event without
|
|
648
|
+
* `tokens` (composer inline tokens spec §3): resolved as the sender before the write
|
|
649
|
+
* ({@link resolveExtra}): each marker becomes its placeholder in `content[0]`, the referenced
|
|
650
|
+
* blocks (resources, project files, conversations, connector mentions) follow it, and
|
|
651
|
+
* `payload.inline` / `connectorMentions` record them. Any refusal writes nothing; a repeated send
|
|
652
|
+
* with the same `clientMessageId` returns the written event without resolving again.
|
|
621
653
|
*
|
|
622
654
|
* `files` (uploaded attachment ids): checked and bound to this conversation in the transaction
|
|
623
655
|
* that writes the event (see {@link BindFiles}) and appended last as image / document reference
|
|
624
|
-
* blocks
|
|
625
|
-
* only references, never bytes. With empty `text` (files only: the HTTP layer ensures
|
|
626
|
-
* and no
|
|
627
|
-
*
|
|
628
|
-
* `projectFiles` (composer menus §5): checked in the conversation's stored project before the
|
|
629
|
-
* write ({@link resolveExtra}); one block each after the `@` resources' bodies, before the
|
|
630
|
-
* uploaded files' blocks, and `payload.projectFiles`. Any refusal writes nothing; a repeated
|
|
631
|
-
* send with the same `clientMessageId` returns the written event without checking again.
|
|
632
|
-
*
|
|
633
|
-
* `conversationRefs` (@ conversations spec §1): read as the sender in the same step, one block
|
|
634
|
-
* each after the project files' blocks, and `payload.conversationRefs`; refused and retried
|
|
635
|
-
* like the project files.
|
|
656
|
+
* blocks, each after its `[file: <name>]` line; any unavailable file writes nothing. The log
|
|
657
|
+
* holds only references, never bytes. With empty `text` (files only: the HTTP layer ensures
|
|
658
|
+
* `files` and no tokens then) no text block of the person's is written.
|
|
636
659
|
*/
|
|
637
660
|
postUserMessage(orgId: string, conversationId: string, accountId: string, input: UserMessageInput,
|
|
638
661
|
/** The request's signal: the project file check on the device stops when the client hangs up. */
|
|
@@ -703,19 +726,27 @@ export declare class ConversationsService {
|
|
|
703
726
|
* `skill`. The queue stores the result and sends it unchanged later.
|
|
704
727
|
*/
|
|
705
728
|
prepareQueuedSkill(orgId: string, conv: ConversationView, accountId: string, input: Pick<UserMessageInput, "skill" | "text">): Promise<RenderedInvocation | undefined>;
|
|
706
|
-
/**
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
*
|
|
712
|
-
*
|
|
713
|
-
*
|
|
714
|
-
*
|
|
715
|
-
*
|
|
716
|
-
*
|
|
717
|
-
|
|
718
|
-
|
|
729
|
+
/** Resolves what a message's tokens reference before it is written ({@link resolveTokens}). */
|
|
730
|
+
resolveExtra(orgId: string, accountId: string, input: Pick<UserMessageInput, "text" | "tokens" | "files" | "skill">, target?: ProjectFilesTarget,
|
|
731
|
+
/** Where the agent's tools are resolved; required when the tokens name connectors or resources. */
|
|
732
|
+
agentContext?: MessageAgentContext): Promise<ResolvedExtra>;
|
|
733
|
+
/**
|
|
734
|
+
* {@link resolveExtra} for a message with tokens (composer inline tokens spec §3), as the sender,
|
|
735
|
+
* outside any transaction; any refusal writes nothing. Each entity is resolved once however
|
|
736
|
+
* often its token repeats: project file paths are normalized first (a path leaving the project →
|
|
737
|
+
* `device.path_outside_project` before anything is read), then the connectors named and the
|
|
738
|
+
* resources' connectors against the agent's tools in one resolution
|
|
739
|
+
* ({@link MentionableConnectorsService.resolveForMessage}: `conversation.connector_unavailable`),
|
|
740
|
+
* the project files and the referenced conversations as without tokens, the resources last
|
|
741
|
+
* ({@link ConnectorContent.readResources}; one whose `read_resource` the agent is not offered →
|
|
742
|
+
* `connector.resources_disabled`), and the files' names. Labels are numbered per kind in text
|
|
743
|
+
* order (file tokens before uploads); each marker becomes its placeholder in the text (the trimmed
|
|
744
|
+
* arguments of a skill invocation, where `inline` then points). Blocks, in order: resources,
|
|
745
|
+
* project files, conversations, connector mentions; the files' blocks follow in the write.
|
|
746
|
+
*/
|
|
747
|
+
private resolveTokens;
|
|
748
|
+
/** The conversation's source (where it comes from: web, IM, an automation). */
|
|
749
|
+
private sourceOf;
|
|
719
750
|
/**
|
|
720
751
|
* {@link resolveExtra}'s referenced conversations (@ conversations spec §1), read as the sender
|
|
721
752
|
* outside any transaction, once each in the body's order. Each must be the sender's own chat in
|
|
@@ -735,12 +766,15 @@ export declare class ConversationsService {
|
|
|
735
766
|
* none → no blocks. The files join the conversation's files, so open pages read the list again
|
|
736
767
|
* after the commit (`changed: files`, a hint).
|
|
737
768
|
*/
|
|
738
|
-
bindIn(orgId: string, conversationId: string, accountId: string, files: readonly string[]
|
|
769
|
+
bindIn(orgId: string, conversationId: string, accountId: string, files: readonly string[],
|
|
770
|
+
/** Each file's label (composer inline tokens spec §3.2); a file not in it: its name. */
|
|
771
|
+
labels?: ReadonlyMap<string, string>): Promise<LogContentBlock[]>;
|
|
739
772
|
private userMessage;
|
|
740
773
|
/**
|
|
741
|
-
*
|
|
742
|
-
*
|
|
743
|
-
*
|
|
774
|
+
* Aborts the conversation's current run (queued / running / waiting): returns its runId; none →
|
|
775
|
+
* `run.not_active`. A run waiting for a person has no worker: its wait is cancelled and its end
|
|
776
|
+
* written here. Any other is broadcast through Redis, reaching whichever replica runs it; an
|
|
777
|
+
* orphaned run (no worker executing it) gets its end written directly.
|
|
744
778
|
*
|
|
745
779
|
* A root conversation's stop stops everything below it too (agent map spec §6, changed in
|
|
746
780
|
* acceptance 2026-11-13: after a person stops, the conversation stays stopped). In order:
|