@capybara-hq/kernel 0.1.0-rc.105 → 0.1.0-rc.106
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/agents.schemas.d.ts +9 -9
- package/dist/{schedules/schedules.controller.d.ts → automations/automations.controller.d.ts} +37 -32
- package/dist/{schedules/schedules.controller.js → automations/automations.controller.js} +68 -57
- package/dist/automations/automations.module.d.ts +16 -0
- package/dist/{schedules/schedules.module.js → automations/automations.module.js} +18 -15
- package/dist/{schedules/schedules.schemas.d.ts → automations/automations.schemas.d.ts} +151 -50
- package/dist/automations/automations.schemas.js +253 -0
- package/dist/{schedules/scheduled-tasks.service.d.ts → automations/automations.service.d.ts} +99 -52
- package/dist/{schedules/scheduled-tasks.service.js → automations/automations.service.js} +303 -134
- package/dist/{schedules → automations}/calendar.d.ts +8 -8
- package/dist/{schedules → automations}/calendar.js +2 -2
- package/dist/automations/effective-settings.d.ts +28 -0
- package/dist/automations/effective-settings.js +25 -0
- package/dist/automations/errors.d.ts +19 -0
- package/dist/automations/errors.js +19 -0
- package/dist/automations/events/coalesce.d.ts +28 -0
- package/dist/automations/events/coalesce.js +131 -0
- package/dist/automations/events/deadline.d.ts +10 -0
- package/dist/automations/events/deadline.js +24 -0
- package/dist/automations/events/dispatcher.d.ts +74 -0
- package/dist/automations/events/dispatcher.js +353 -0
- package/dist/automations/events/events.module.d.ts +7 -0
- package/dist/automations/events/events.module.js +26 -0
- package/dist/automations/events/guards.d.ts +32 -0
- package/dist/automations/events/guards.js +87 -0
- package/dist/automations/events/sweep.job.d.ts +49 -0
- package/dist/automations/events/sweep.job.js +202 -0
- package/dist/automations/events/token.d.ts +5 -0
- package/dist/automations/events/token.js +5 -0
- package/dist/automations/events/trigger-events.service.d.ts +47 -0
- package/dist/automations/events/trigger-events.service.js +254 -0
- package/dist/{schedules → automations}/fire.d.ts +57 -17
- package/dist/{schedules → automations}/fire.js +311 -79
- package/dist/{schedules → automations}/grant-rules.d.ts +1 -1
- package/dist/{schedules → automations}/grant-rules.js +5 -5
- package/dist/automations/job-ids.d.ts +113 -0
- package/dist/automations/job-ids.js +117 -0
- package/dist/{schedules → automations}/pause.d.ts +3 -3
- package/dist/{schedules → automations}/pause.js +3 -3
- package/dist/{schedules → automations}/run-tracker.d.ts +21 -10
- package/dist/{schedules → automations}/run-tracker.js +68 -56
- package/dist/{schedules → automations}/scan.job.d.ts +12 -8
- package/dist/{schedules → automations}/scan.job.js +39 -23
- package/dist/{schedules → automations}/schedule-math.d.ts +19 -12
- package/dist/{schedules → automations}/schedule-math.js +17 -7
- package/dist/{schedules → automations}/store.d.ts +57 -27
- package/dist/{schedules → automations}/store.js +102 -52
- package/dist/automations/store.module.d.ts +6 -0
- package/dist/{schedules → automations}/store.module.js +9 -9
- package/dist/automations/types.d.ts +178 -0
- package/dist/{schedules → automations}/unattended.d.ts +22 -11
- package/dist/{schedules → automations}/unattended.js +53 -30
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/channels/channels.module.js +3 -3
- package/dist/channels/outbound.d.ts +5 -5
- package/dist/channels/outbound.js +17 -17
- package/dist/channels/threads.d.ts +1 -1
- package/dist/channels/threads.js +1 -1
- package/dist/config/schema.d.ts +5 -1
- package/dist/config/schema.js +44 -6
- package/dist/conversations/approval-profile.d.ts +2 -2
- package/dist/conversations/approval-profile.js +3 -3
- package/dist/conversations/conversations.controller.d.ts +7 -1
- package/dist/conversations/conversations.controller.js +26 -10
- package/dist/conversations/conversations.service.d.ts +101 -25
- package/dist/conversations/conversations.service.js +132 -32
- package/dist/conversations/events.d.ts +46 -0
- package/dist/conversations/events.js +54 -3
- package/dist/conversations/message-context.d.ts +2 -2
- package/dist/conversations/message-context.js +1 -1
- package/dist/conversations/permission-profile-store.d.ts +2 -1
- package/dist/conversations/permission-profiles.controller.d.ts +3 -0
- package/dist/conversations/permission-profiles.service.js +1 -1
- package/dist/conversations/prompt-suggestion-request.d.ts +1 -1
- package/dist/conversations/prompt-suggestion-request.js +2 -1
- package/dist/conversations/queue.d.ts +7 -4
- package/dist/conversations/queue.js +6 -2
- package/dist/conversations/queue.service.d.ts +5 -5
- package/dist/conversations/queue.service.js +20 -14
- package/dist/ctx/create-ctx.d.ts +20 -1
- package/dist/ctx/create-ctx.js +59 -2
- package/dist/db/kernel-schema.d.ts +104 -25
- package/dist/devices/device-project-files.service.d.ts +88 -0
- package/dist/devices/device-project-files.service.js +249 -0
- package/dist/devices/device-projects.service.d.ts +40 -0
- package/dist/devices/device-projects.service.js +16 -13
- package/dist/devices/devices.controller.d.ts +9 -3
- package/dist/devices/devices.controller.js +27 -5
- package/dist/devices/devices.module.js +9 -1
- package/dist/devices/devices.schemas.js +6 -1
- package/dist/devices/dto.d.ts +15 -0
- package/dist/devices/dto.js +11 -0
- package/dist/devices/project-paths.d.ts +29 -0
- package/dist/devices/project-paths.js +66 -0
- package/dist/devices/project-rules.d.ts +5 -1
- package/dist/devices/project-rules.js +5 -1
- package/dist/errors.d.ts +34 -13
- package/dist/errors.js +34 -13
- package/dist/evals/reconstruct.d.ts +10 -1
- package/dist/evals/reconstruct.js +7 -0
- package/dist/extensions/host.d.ts +6 -1
- package/dist/extensions/host.js +10 -0
- package/dist/extensions/permission-set.d.ts +17 -1
- package/dist/extensions/permission-set.js +13 -1
- package/dist/extensions/permission-view.d.ts +1 -1
- package/dist/extensions/permission-view.js +4 -1
- package/dist/git/gateway.js +2 -2
- package/dist/http/api.module.js +5 -5
- package/dist/http/request-signal.d.ts +8 -0
- package/dist/http/request-signal.js +14 -0
- package/dist/inbox/inbox.module.js +2 -2
- package/dist/inbox/inbox.service.d.ts +8 -8
- package/dist/inbox/inbox.service.js +7 -7
- package/dist/infra/config/kernel-config.service.js +10 -5
- package/dist/infra/outbox/registry.d.ts +29 -2
- package/dist/infra/outbox/registry.js +30 -7
- package/dist/kernel.module.js +3 -0
- package/dist/orgs/roles.d.ts +1 -1
- package/dist/orgs/roles.js +3 -3
- package/dist/orgs/settings.controller.d.ts +1 -1
- package/dist/orgs/settings.service.d.ts +27 -11
- package/dist/orgs/settings.service.js +42 -24
- package/dist/platform/operation.js +2 -2
- package/dist/platform/ops/{schedules.ops.d.ts → automations.ops.d.ts} +4 -4
- package/dist/platform/ops/automations.ops.js +560 -0
- package/dist/platform/ops/devices.ops.d.ts +3 -1
- package/dist/platform/ops/devices.ops.js +77 -3
- package/dist/platform/ops/inbox.ops.js +4 -4
- package/dist/platform/ops/orgs.ops.js +1 -1
- package/dist/platform/ops/platform.ops.js +4 -4
- package/dist/platform/platform-ops.module.d.ts +2 -2
- package/dist/platform/platform-ops.module.js +5 -5
- package/dist/platform/route-schemas.js +3 -3
- package/dist/push/jobs.d.ts +3 -3
- package/dist/push/jobs.js +2 -2
- package/dist/push/preferences.service.js +1 -1
- package/dist/push/push-owed.d.ts +3 -3
- package/dist/push/push-owed.js +6 -6
- package/dist/push/push.schemas.d.ts +4 -4
- package/dist/push/push.schemas.js +3 -3
- package/dist/push/recipients.d.ts +4 -4
- package/dist/push/recipients.js +23 -23
- package/dist/push/texts.d.ts +3 -3
- package/dist/push/texts.js +2 -2
- package/dist/push/triggers.d.ts +1 -1
- package/dist/roles/worker.module.js +3 -3
- package/dist/runtime/context/build.d.ts +6 -0
- package/dist/runtime/context/build.js +14 -3
- package/dist/runtime/context/compaction.js +15 -5
- package/dist/runtime/context/run-context.d.ts +38 -0
- package/dist/runtime/context/run-context.js +54 -0
- package/dist/runtime/maintenance.d.ts +8 -4
- package/dist/runtime/maintenance.js +37 -16
- package/dist/runtime/run-finish.d.ts +4 -4
- package/dist/runtime/run-finish.js +3 -3
- package/dist/runtime/run-queue.js +12 -7
- package/dist/runtime/run-worker.js +7 -1
- package/dist/runtime/runtime.module.js +3 -3
- package/dist/runtime/subagents/dispatch.js +11 -3
- package/dist/sandbox/browse-roots.d.ts +8 -0
- package/dist/sandbox/browse-roots.js +22 -0
- package/dist/sandbox/network-grants.d.ts +4 -4
- package/dist/sandbox/network-grants.js +7 -7
- package/dist/sandbox/operation-authority.d.ts +10 -3
- package/dist/sandbox/operation-authority.js +20 -10
- package/dist/sandbox/operation-intents.d.ts +3 -1
- package/dist/sandbox/operation-intents.js +11 -4
- package/dist/sandbox/permission-call-grants.js +2 -2
- package/dist/sandbox/permission-facts.js +1 -1
- package/dist/sandbox/review/classifier.d.ts +2 -2
- package/dist/sandbox/review/classifier.js +22 -11
- package/dist/sandbox/review/permission-candidate.d.ts +1 -1
- package/dist/sandbox/review/permission-candidate.js +1 -1
- package/dist/sandbox/sandbox.service.d.ts +15 -5
- package/dist/sandbox/sandbox.service.js +14 -8
- package/dist/storage/purge.d.ts +1 -1
- package/dist/storage/purge.js +2 -2
- package/dist/tools/approvals.service.d.ts +6 -6
- package/dist/tools/approvals.service.js +19 -19
- package/dist/tools/builtin-names.d.ts +12 -12
- package/dist/tools/builtin-names.js +29 -29
- package/dist/tools/builtins/{schedules.d.ts → automations.d.ts} +35 -33
- package/dist/tools/builtins/{schedules.js → automations.js} +236 -105
- package/dist/tools/builtins/builtin-tools.d.ts +8 -8
- package/dist/tools/builtins/builtin-tools.js +16 -16
- package/dist/tools/call-scope.d.ts +1 -1
- package/dist/tools/git-asks.js +1 -1
- package/dist/tools/git-push-policy.d.ts +3 -3
- package/dist/tools/git-push-policy.js +6 -6
- package/dist/tools/network-asks.d.ts +3 -3
- package/dist/tools/network-asks.js +3 -3
- package/dist/tools/pipeline.d.ts +4 -4
- package/dist/tools/pipeline.js +2 -2
- package/dist/tools/policy.d.ts +3 -3
- package/dist/tools/policy.js +3 -3
- package/dist/tools/tools.module.js +9 -9
- package/package.json +3 -3
- package/src/migrations/0188_automations_rename.sql +309 -0
- package/src/migrations/0189_event_automations.sql +136 -0
- package/dist/platform/ops/schedules.ops.js +0 -509
- package/dist/schedules/effective-settings.d.ts +0 -22
- package/dist/schedules/effective-settings.js +0 -18
- package/dist/schedules/errors.d.ts +0 -8
- package/dist/schedules/errors.js +0 -8
- package/dist/schedules/job-ids.d.ts +0 -81
- package/dist/schedules/job-ids.js +0 -95
- package/dist/schedules/schedules.module.d.ts +0 -16
- package/dist/schedules/schedules.schemas.js +0 -213
- package/dist/schedules/store.module.d.ts +0 -6
- package/dist/schedules/types.d.ts +0 -110
- /package/dist/{schedules → automations}/types.js +0 -0
|
@@ -15,7 +15,10 @@ import { avatarView } from "../agents/avatar-view.js";
|
|
|
15
15
|
import { unbindConversation } from "../channels/threads.js";
|
|
16
16
|
import { oweConversationDeletedNotice } from "../device-access/conversation-notices.js";
|
|
17
17
|
import { ConversationDevices, } from "../devices/conversation-devices.js";
|
|
18
|
+
import { DeviceProjectFilesService } from "../devices/device-project-files.service.js";
|
|
18
19
|
import { DeviceProjectsService } from "../devices/device-projects.service.js";
|
|
20
|
+
import { projectFilePath } from "../devices/project-paths.js";
|
|
21
|
+
import { clipped } from "../devices/project-rules.js";
|
|
19
22
|
import { ApiError } from "../errors.js";
|
|
20
23
|
import { loadPeople } from "../identity/account-avatar.js";
|
|
21
24
|
import { afterCommit } from "../infra/database/after-commit.js";
|
|
@@ -97,6 +100,14 @@ function toConversationAgent(r) {
|
|
|
97
100
|
}
|
|
98
101
|
const notFound = () => new ApiError("conversation.not_found", "Conversation not found");
|
|
99
102
|
export const NO_REPLY_SKIPS = { questions: [], network: [], seqs: new Map() };
|
|
103
|
+
export { MAX_PROJECT_FILES } from "../devices/device-project-files.service.js";
|
|
104
|
+
/**
|
|
105
|
+
* The model-visible text of one referenced project file (composer menus §5): English, logged in
|
|
106
|
+
* the `user_message`, so replay rebuilds it from the log as it is.
|
|
107
|
+
*/
|
|
108
|
+
export const projectFileText = (path, root) => `Referenced project file: ${path} (in the project root ${root}; read it with Read when needed).`;
|
|
109
|
+
/** A message's project file that cannot be referenced (422, `details: [{ path }]` or `reason`). */
|
|
110
|
+
const projectFileUnavailable = (message, details) => new ApiError("conversation.project_file_unavailable", message, details);
|
|
100
111
|
export { userMessageIdemKey } from "./idem-keys.js";
|
|
101
112
|
const COLUMNS = [
|
|
102
113
|
"id",
|
|
@@ -113,7 +124,8 @@ const COLUMNS = [
|
|
|
113
124
|
"subagent_type",
|
|
114
125
|
"archived_at",
|
|
115
126
|
"device_id",
|
|
116
|
-
"
|
|
127
|
+
"automation_id",
|
|
128
|
+
"subject",
|
|
117
129
|
"project_name",
|
|
118
130
|
"project_path",
|
|
119
131
|
];
|
|
@@ -133,7 +145,15 @@ function toView(r) {
|
|
|
133
145
|
subagentType: r.subagent_type,
|
|
134
146
|
archivedAt: r.archived_at,
|
|
135
147
|
deviceId: r.device_id,
|
|
136
|
-
|
|
148
|
+
automationId: r.automation_id,
|
|
149
|
+
subject: r.subject === null
|
|
150
|
+
? null
|
|
151
|
+
: {
|
|
152
|
+
source: r.subject.source,
|
|
153
|
+
kind: r.subject.kind,
|
|
154
|
+
id: r.subject.id,
|
|
155
|
+
title: r.subject.title,
|
|
156
|
+
},
|
|
137
157
|
project: r.project_name !== null && r.project_path !== null
|
|
138
158
|
? { name: r.project_name, path: r.project_path }
|
|
139
159
|
: null,
|
|
@@ -148,6 +168,12 @@ export const CONVERSATION_TITLE_MAX_CHARS = 120;
|
|
|
148
168
|
* paging spec §2); a longer run starts mid-run.
|
|
149
169
|
*/
|
|
150
170
|
export const EVENTS_TURN_EXTEND = 2000;
|
|
171
|
+
/** `conversations.subject` as stored: the four fields, never the subject's link. */
|
|
172
|
+
function storedSubject(s) {
|
|
173
|
+
return s === undefined
|
|
174
|
+
? null
|
|
175
|
+
: JSON.stringify({ source: s.source, kind: s.kind, id: s.id, title: s.title });
|
|
176
|
+
}
|
|
151
177
|
/** The sums of the `usage` events matching `where` (over `conversation_events e`), one row. */
|
|
152
178
|
const usageSums = (where) => sql `
|
|
153
179
|
SELECT
|
|
@@ -182,6 +208,7 @@ let ConversationsService = class ConversationsService {
|
|
|
182
208
|
deletion;
|
|
183
209
|
devices;
|
|
184
210
|
projects;
|
|
211
|
+
projectFiles;
|
|
185
212
|
questions;
|
|
186
213
|
approvals;
|
|
187
214
|
events;
|
|
@@ -205,6 +232,8 @@ let ConversationsService = class ConversationsService {
|
|
|
205
232
|
devices,
|
|
206
233
|
/** The project of that device a new conversation is bound to (project root design §4.3). */
|
|
207
234
|
projects,
|
|
235
|
+
/** Checks a message's referenced project files on the device (composer menus §5). */
|
|
236
|
+
projectFiles,
|
|
208
237
|
/** A starter's message skips the run's pending questions (reply-while-question spec §8.1). */
|
|
209
238
|
questions,
|
|
210
239
|
/** ... and its pending network asks (network ask-to-allow spec §6.7). */
|
|
@@ -224,6 +253,7 @@ let ConversationsService = class ConversationsService {
|
|
|
224
253
|
this.deletion = deletion;
|
|
225
254
|
this.devices = devices;
|
|
226
255
|
this.projects = projects;
|
|
256
|
+
this.projectFiles = projectFiles;
|
|
227
257
|
this.questions = questions;
|
|
228
258
|
this.approvals = approvals;
|
|
229
259
|
this.events = events;
|
|
@@ -254,6 +284,7 @@ let ConversationsService = class ConversationsService {
|
|
|
254
284
|
project_name: project?.name ?? null,
|
|
255
285
|
project_path: project?.path ?? null,
|
|
256
286
|
source: opts.source,
|
|
287
|
+
subject: storedSubject(opts.subject),
|
|
257
288
|
})
|
|
258
289
|
.returning(COLUMNS)
|
|
259
290
|
.executeTakeFirstOrThrow();
|
|
@@ -267,8 +298,8 @@ let ConversationsService = class ConversationsService {
|
|
|
267
298
|
* `agent.not_found` and nothing is written. Queues a run afterwards, like `postUserMessage`.
|
|
268
299
|
* `events` are every event the create wrote, in seq order from seq 1 (a `model_switched` before
|
|
269
300
|
* the message when the send switched), so a client can seed the new conversation's log whole.
|
|
270
|
-
* `internal`: the conversation's source and, for kernel callers only,
|
|
271
|
-
* which also sets `conversations.
|
|
301
|
+
* `internal`: the conversation's source and, for kernel callers only, an automation's marker,
|
|
302
|
+
* which also sets `conversations.automation_id`, and its zone override. `pick.project` binds
|
|
272
303
|
* the conversation to one of its device's projects inside the write ({@link bindingFor}); a
|
|
273
304
|
* retry answers with the conversation the first send created, its binding unchanged.
|
|
274
305
|
*/
|
|
@@ -284,7 +315,15 @@ let ConversationsService = class ConversationsService {
|
|
|
284
315
|
return prior;
|
|
285
316
|
const deviceId = await this.devices.forNew(orgId, accountId, pick);
|
|
286
317
|
const next = await this.planSwitch(orgId, agent.definition, NO_SELECTION, input);
|
|
287
|
-
|
|
318
|
+
// the project its files are checked in, read before the write (the binding inside it decides)
|
|
319
|
+
const project = (input.projectFiles?.length ?? 0) > 0
|
|
320
|
+
? await this.bindingFor(orgId, accountId, deviceId, pick.project)
|
|
321
|
+
: undefined;
|
|
322
|
+
const extra = await this.resolveExtra(orgId, accountId, input, {
|
|
323
|
+
deviceId,
|
|
324
|
+
project,
|
|
325
|
+
signal: internal.signal,
|
|
326
|
+
});
|
|
288
327
|
const invoked = await this.prepareSkill(orgId, accountId, agentId, { conversationId: undefined, deviceId }, agent.definition, input);
|
|
289
328
|
const id = randomUUID();
|
|
290
329
|
let all;
|
|
@@ -324,6 +363,10 @@ let ConversationsService = class ConversationsService {
|
|
|
324
363
|
if (internal.initialPermission)
|
|
325
364
|
await this.permissions.lockInitial(orgId, id, conv.deviceId);
|
|
326
365
|
const project = await this.bindingFor(orgId, accountId, conv.deviceId, conv.project);
|
|
366
|
+
// the project changed since its files were checked: the blocks would name another root
|
|
367
|
+
if (extra.projectRoot !== undefined && extra.projectRoot !== project?.path) {
|
|
368
|
+
throw new ApiError("conflict", "The project changed while the message was sent; retry");
|
|
369
|
+
}
|
|
327
370
|
const row = await this.db
|
|
328
371
|
.insertInto("conversations")
|
|
329
372
|
.values({
|
|
@@ -336,8 +379,9 @@ let ConversationsService = class ConversationsService {
|
|
|
336
379
|
project_path: project?.path ?? null,
|
|
337
380
|
create_request_id: input.clientMessageId,
|
|
338
381
|
create_request_hash: internal.createRequestHash ?? null,
|
|
339
|
-
|
|
382
|
+
automation_id: internal.schedule?.taskId ?? internal.automationEvent?.automationId ?? null,
|
|
340
383
|
source: internal.source,
|
|
384
|
+
subject: storedSubject(internal.subject),
|
|
341
385
|
})
|
|
342
386
|
.onConflict((oc) => oc
|
|
343
387
|
.columns(["org_id", "account_id", "create_request_id"])
|
|
@@ -721,7 +765,7 @@ let ConversationsService = class ConversationsService {
|
|
|
721
765
|
SELECT page.agent_id, page.latest_at, v.definition ->> 'name' AS agent_name,
|
|
722
766
|
a.profile_avatar, a.profile_updated_at, cs.id, cs.org_id, cs.account_id, cs.title, cs.title_source, cs.selection, cs.last_seq,
|
|
723
767
|
cs.created_at, cs.updated_at, cs.parent_conversation_id, cs.subagent_type,
|
|
724
|
-
cs.archived_at, cs.device_id, cs.
|
|
768
|
+
cs.archived_at, cs.device_id, cs.automation_id, cs.subject, cs.project_name, cs.project_path,
|
|
725
769
|
cs.activity
|
|
726
770
|
FROM page
|
|
727
771
|
JOIN capybara.agents a ON a.id = page.agent_id
|
|
@@ -729,7 +773,7 @@ let ConversationsService = class ConversationsService {
|
|
|
729
773
|
CROSS JOIN LATERAL (
|
|
730
774
|
SELECT c.id, c.org_id, c.account_id, c.title, c.title_source, c.selection, c.last_seq,
|
|
731
775
|
c.created_at, c.updated_at, c.parent_conversation_id, c.subagent_type,
|
|
732
|
-
c.archived_at, c.device_id, c.
|
|
776
|
+
c.archived_at, c.device_id, c.automation_id, c.subject, c.project_name, c.project_path,
|
|
733
777
|
${activitySql("c")} AS activity
|
|
734
778
|
FROM capybara.conversations c
|
|
735
779
|
WHERE c.org_id = ${orgId} AND c.account_id = ${accountId} AND c.kind = 'chat'
|
|
@@ -930,20 +974,32 @@ let ConversationsService = class ConversationsService {
|
|
|
930
974
|
return this.eventLog.readTurnPageBefore(conversationId, beforeSeq, limit, EVENTS_TURN_EXTEND);
|
|
931
975
|
}
|
|
932
976
|
/**
|
|
933
|
-
*
|
|
934
|
-
*
|
|
935
|
-
*
|
|
977
|
+
* Appends a user message; a repeated send with the same `clientMessageId` returns the same
|
|
978
|
+
* event. After the write it calls `ensureRun`: with no run in progress it enqueues one; during
|
|
979
|
+
* a run the current run takes the message in between steps, or `ensureRun` runs again when it
|
|
980
|
+
* ends. A failed `ensureRun` is logged, not thrown: the message's transaction owes the ensure-run
|
|
936
981
|
* backstop, which starts the run once the queue is reachable (transactional outbox spec §6).
|
|
937
982
|
*
|
|
938
|
-
* `attachments
|
|
939
|
-
*
|
|
940
|
-
*
|
|
983
|
+
* `attachments` (`@` resource references): the kernel reads each resource with the sender's
|
|
984
|
+
* credentials (redacted, length-capped) and writes it as an extra text block after the user's
|
|
985
|
+
* text in the same user_message, with its metadata in `payload.attachments` (attachment i is
|
|
986
|
+
* `content[i + 1]`). A failed read writes nothing. A repeated send with the same
|
|
987
|
+
* `clientMessageId` returns the written event without reading again.
|
|
941
988
|
*
|
|
942
|
-
* `files
|
|
943
|
-
* document
|
|
944
|
-
*
|
|
989
|
+
* `files` (uploaded attachment ids): checked and bound to this conversation in the transaction
|
|
990
|
+
* that writes the event (see {@link BindFiles}) and appended last as image / document reference
|
|
991
|
+
* blocks (after the `@` resource blocks); any unavailable file writes nothing. The log holds
|
|
992
|
+
* only references, never bytes. With empty `text` (files only: the HTTP layer ensures `files`
|
|
993
|
+
* and no `@` resources then) no text block is written.
|
|
994
|
+
*
|
|
995
|
+
* `projectFiles` (composer menus §5): checked in the conversation's stored project before the
|
|
996
|
+
* write ({@link resolveExtra}); one block each after the `@` resources' bodies, before the
|
|
997
|
+
* uploaded files' blocks, and `payload.projectFiles`. Any refusal writes nothing; a repeated
|
|
998
|
+
* send with the same `clientMessageId` returns the written event without checking again.
|
|
945
999
|
*/
|
|
946
|
-
async postUserMessage(orgId, conversationId, accountId, input
|
|
1000
|
+
async postUserMessage(orgId, conversationId, accountId, input,
|
|
1001
|
+
/** The request's signal: the project file check on the device stops when the client hangs up. */
|
|
1002
|
+
signal) {
|
|
947
1003
|
const conv = await this.writable(orgId, conversationId, accountId);
|
|
948
1004
|
// A retry returns the written event before resolving today's model or resources.
|
|
949
1005
|
if (input.clientMessageId !== undefined) {
|
|
@@ -957,7 +1013,7 @@ let ConversationsService = class ConversationsService {
|
|
|
957
1013
|
const agent = needsAgent
|
|
958
1014
|
? (await this.agents.get(orgId, conv.agentId, accountId)).definition
|
|
959
1015
|
: undefined;
|
|
960
|
-
const extra = await this.resolveExtra(orgId, accountId, input);
|
|
1016
|
+
const extra = await this.resolveExtra(orgId, accountId, input, { ...conv, signal });
|
|
961
1017
|
const invoked = agent === undefined
|
|
962
1018
|
? undefined
|
|
963
1019
|
: await this.prepareSkill(orgId, accountId, conv.agentId, { conversationId, deviceId: conv.deviceId }, agent, input);
|
|
@@ -1146,7 +1202,7 @@ let ConversationsService = class ConversationsService {
|
|
|
1146
1202
|
im: input.im,
|
|
1147
1203
|
timeZoneOverride: internal.timeZoneOverride,
|
|
1148
1204
|
});
|
|
1149
|
-
events.push(this.userMessage(accountId, input, extra, blocks, invoked, context, internal
|
|
1205
|
+
events.push(this.userMessage(accountId, input, extra, blocks, invoked, context, internal));
|
|
1150
1206
|
const { events: written, fresh } = await this.eventLog.appendInReport(conversationId, events);
|
|
1151
1207
|
const message = written.at(-1);
|
|
1152
1208
|
// the run this message starts is owed with it: the direct ensureRun after the commit may never
|
|
@@ -1202,14 +1258,53 @@ let ConversationsService = class ConversationsService {
|
|
|
1202
1258
|
return this.prepareSkill(orgId, accountId, conv.agentId, { conversationId: conv.id, deviceId: conv.deviceId }, agent.definition, input);
|
|
1203
1259
|
}
|
|
1204
1260
|
/**
|
|
1205
|
-
* Reads the `@` resources with the sender's credentials
|
|
1206
|
-
* with the queue, which reads
|
|
1261
|
+
* Reads the `@` resources with the sender's credentials and checks the referenced project files
|
|
1262
|
+
* (nothing when there are none). Shared with the queue, which reads the resources when a
|
|
1263
|
+
* message is queued (decision 15; a queued message carries no project files).
|
|
1264
|
+
*
|
|
1265
|
+
* Project files (composer menus §5) are checked in `target`'s project on its device as the
|
|
1266
|
+
* sender (the conversation's owner, through `DeviceProjectFilesService.statAll`, outside any
|
|
1267
|
+
* transaction): no bound project → `conversation.project_file_unavailable` with `reason:
|
|
1268
|
+
* "no_project"`; a path leaving the project → `device.path_outside_project`; one that is not a
|
|
1269
|
+
* file there → `conversation.project_file_unavailable` with its path; the device codes pass on.
|
|
1270
|
+
* Each becomes a {@link projectFileText} block after the resources' bodies.
|
|
1207
1271
|
*/
|
|
1208
|
-
async resolveExtra(orgId, accountId, input) {
|
|
1272
|
+
async resolveExtra(orgId, accountId, input, target) {
|
|
1209
1273
|
const refs = input.attachments ?? [];
|
|
1274
|
+
const files = await this.checkProjectFiles(orgId, accountId, input.projectFiles ?? [], target);
|
|
1275
|
+
const resolved = refs.length === 0
|
|
1276
|
+
? { blocks: [], attachments: [] }
|
|
1277
|
+
: await this.content.resolveAttachments(orgId, accountId, refs);
|
|
1278
|
+
if (files === undefined)
|
|
1279
|
+
return resolved;
|
|
1280
|
+
return {
|
|
1281
|
+
blocks: [
|
|
1282
|
+
...resolved.blocks,
|
|
1283
|
+
...files.paths.map((path) => ({
|
|
1284
|
+
type: "text",
|
|
1285
|
+
text: projectFileText(path, files.root),
|
|
1286
|
+
})),
|
|
1287
|
+
],
|
|
1288
|
+
attachments: resolved.attachments,
|
|
1289
|
+
projectFiles: files.paths.map((path) => ({ path })),
|
|
1290
|
+
projectRoot: files.root,
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
/** {@link resolveExtra}'s project file check: the normalized paths and the root, or none. */
|
|
1294
|
+
async checkProjectFiles(orgId, accountId, refs, target) {
|
|
1210
1295
|
if (refs.length === 0)
|
|
1211
|
-
return
|
|
1212
|
-
|
|
1296
|
+
return undefined;
|
|
1297
|
+
const project = target?.project;
|
|
1298
|
+
if (!project || target?.deviceId == null) {
|
|
1299
|
+
throw projectFileUnavailable("This conversation has no device project, so it cannot reference project files; start it in a project", [{ reason: "no_project" }]);
|
|
1300
|
+
}
|
|
1301
|
+
// normalized first (a path leaving the project is refused before the device is asked), once each
|
|
1302
|
+
const paths = [...new Set(refs.map((r) => projectFilePath(r.path)))];
|
|
1303
|
+
const { missing } = await this.projectFiles.statAll({ orgId, accountId, deviceId: target.deviceId }, project.path, paths, target.signal);
|
|
1304
|
+
if (missing.length > 0) {
|
|
1305
|
+
throw projectFileUnavailable(`${clipped(missing[0])} is not a file in the project ${project.name}; pick it again`, missing.map((path) => ({ path: clipped(path) })));
|
|
1306
|
+
}
|
|
1307
|
+
return { paths, root: project.path };
|
|
1213
1308
|
}
|
|
1214
1309
|
/**
|
|
1215
1310
|
* Binds uploaded files inside the message's (or queue item's) transaction; none → no blocks.
|
|
@@ -1223,7 +1318,8 @@ let ConversationsService = class ConversationsService {
|
|
|
1223
1318
|
afterCommit(() => this.eventLog.publishChanged(conversationId, "files"));
|
|
1224
1319
|
return blocks;
|
|
1225
1320
|
}
|
|
1226
|
-
userMessage(accountId, input, extra, fileBlocks, invoked, context,
|
|
1321
|
+
userMessage(accountId, input, extra, fileBlocks, invoked, context, markers = {}) {
|
|
1322
|
+
const { schedule, automationEvent } = markers;
|
|
1227
1323
|
// a skill invocation's rendered text replaces the typed arguments as content[0]
|
|
1228
1324
|
const text = invoked?.text ?? input.text;
|
|
1229
1325
|
return {
|
|
@@ -1239,12 +1335,15 @@ let ConversationsService = class ConversationsService {
|
|
|
1239
1335
|
...fileBlocks,
|
|
1240
1336
|
],
|
|
1241
1337
|
...(extra.attachments.length > 0 && { attachments: extra.attachments }),
|
|
1338
|
+
...(extra.projectFiles !== undefined &&
|
|
1339
|
+
extra.projectFiles.length > 0 && { projectFiles: extra.projectFiles }),
|
|
1242
1340
|
authorAccountId: accountId,
|
|
1243
1341
|
...context,
|
|
1244
1342
|
...(input.clientMessageId !== undefined && { clientMessageId: input.clientMessageId }),
|
|
1245
1343
|
...(input.retryOf !== undefined && { retryOf: input.retryOf }),
|
|
1246
1344
|
...(invoked !== undefined && { skill: invoked.skill }),
|
|
1247
1345
|
...(schedule !== undefined && { schedule }),
|
|
1346
|
+
...(automationEvent !== undefined && { automationEvent }),
|
|
1248
1347
|
},
|
|
1249
1348
|
};
|
|
1250
1349
|
}
|
|
@@ -1424,11 +1523,12 @@ ConversationsService = __decorate([
|
|
|
1424
1523
|
__param(10, Inject(RunDeletion)),
|
|
1425
1524
|
__param(11, Inject(ConversationDevices)),
|
|
1426
1525
|
__param(12, Inject(DeviceProjectsService)),
|
|
1427
|
-
__param(13, Inject(
|
|
1428
|
-
__param(14, Inject(
|
|
1429
|
-
__param(15, Inject(
|
|
1430
|
-
__param(16, Inject(
|
|
1431
|
-
__param(17, Inject(
|
|
1432
|
-
__param(18, Inject(
|
|
1526
|
+
__param(13, Inject(DeviceProjectFilesService)),
|
|
1527
|
+
__param(14, Inject(QuestionsService)),
|
|
1528
|
+
__param(15, Inject(ApprovalsService)),
|
|
1529
|
+
__param(16, Inject(KernelEvents)),
|
|
1530
|
+
__param(17, Inject(TransactionHost)),
|
|
1531
|
+
__param(18, Inject(PermissionCeilingWrites)),
|
|
1532
|
+
__param(19, Inject(OutboxService))
|
|
1433
1533
|
], ConversationsService);
|
|
1434
1534
|
export { ConversationsService };
|
|
@@ -622,6 +622,29 @@ export declare const ScheduleMarkerSchema: z.ZodObject<{
|
|
|
622
622
|
taskName: z.ZodString;
|
|
623
623
|
localTime: z.ZodString;
|
|
624
624
|
}, z.core.$strip>;
|
|
625
|
+
/**
|
|
626
|
+
* `user_message.automationEvent` (collaboration spec §4.6): the `AutomationEventMarker` shape, the
|
|
627
|
+
* events an event automation's message reports (at least one; coalesced events in order; at most
|
|
628
|
+
* the first 5 and the latest 15, `omittedEvents` counting the ones between, absent when none).
|
|
629
|
+
*/
|
|
630
|
+
export declare const AutomationEventMarkerSchema: z.ZodObject<{
|
|
631
|
+
automationId: z.ZodString;
|
|
632
|
+
automationRunId: z.ZodString;
|
|
633
|
+
automationName: z.ZodString;
|
|
634
|
+
source: z.ZodString;
|
|
635
|
+
events: z.ZodArray<z.ZodObject<{
|
|
636
|
+
id: z.ZodString;
|
|
637
|
+
type: z.ZodString;
|
|
638
|
+
subject: z.ZodObject<{
|
|
639
|
+
kind: z.ZodString;
|
|
640
|
+
id: z.ZodString;
|
|
641
|
+
title: z.ZodString;
|
|
642
|
+
url: z.ZodOptional<z.ZodString>;
|
|
643
|
+
}, z.core.$strip>;
|
|
644
|
+
summary: z.ZodString;
|
|
645
|
+
}, z.core.$strip>>;
|
|
646
|
+
omittedEvents: z.ZodOptional<z.ZodNumber>;
|
|
647
|
+
}, z.core.$strip>;
|
|
625
648
|
/** `run_context` (run context spec §3.1): every field optional, a later event holds changes only. */
|
|
626
649
|
export declare const RunContextSchema: z.ZodObject<{
|
|
627
650
|
agent: z.ZodOptional<z.ZodObject<{
|
|
@@ -935,6 +958,9 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
935
958
|
uri: z.ZodString;
|
|
936
959
|
name: z.ZodString;
|
|
937
960
|
}, z.core.$strip>>>;
|
|
961
|
+
projectFiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
962
|
+
path: z.ZodString;
|
|
963
|
+
}, z.core.$strip>>>;
|
|
938
964
|
authorAccountId: z.ZodString;
|
|
939
965
|
sender: z.ZodOptional<z.ZodObject<{
|
|
940
966
|
name: z.ZodString;
|
|
@@ -978,6 +1004,24 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
978
1004
|
taskName: z.ZodString;
|
|
979
1005
|
localTime: z.ZodString;
|
|
980
1006
|
}, z.core.$strip>>;
|
|
1007
|
+
automationEvent: z.ZodOptional<z.ZodObject<{
|
|
1008
|
+
automationId: z.ZodString;
|
|
1009
|
+
automationRunId: z.ZodString;
|
|
1010
|
+
automationName: z.ZodString;
|
|
1011
|
+
source: z.ZodString;
|
|
1012
|
+
events: z.ZodArray<z.ZodObject<{
|
|
1013
|
+
id: z.ZodString;
|
|
1014
|
+
type: z.ZodString;
|
|
1015
|
+
subject: z.ZodObject<{
|
|
1016
|
+
kind: z.ZodString;
|
|
1017
|
+
id: z.ZodString;
|
|
1018
|
+
title: z.ZodString;
|
|
1019
|
+
url: z.ZodOptional<z.ZodString>;
|
|
1020
|
+
}, z.core.$strip>;
|
|
1021
|
+
summary: z.ZodString;
|
|
1022
|
+
}, z.core.$strip>>;
|
|
1023
|
+
omittedEvents: z.ZodOptional<z.ZodNumber>;
|
|
1024
|
+
}, z.core.$strip>>;
|
|
981
1025
|
dispatch: z.ZodOptional<z.ZodObject<{
|
|
982
1026
|
parentConversationId: z.ZodString;
|
|
983
1027
|
parentRunId: z.ZodString;
|
|
@@ -1040,6 +1084,7 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
1040
1084
|
}, z.core.$strip>;
|
|
1041
1085
|
triggerAccountId: z.ZodString;
|
|
1042
1086
|
trigger: z.ZodOptional<z.ZodEnum<{
|
|
1087
|
+
automation_event: "automation_event";
|
|
1043
1088
|
background_task: "background_task";
|
|
1044
1089
|
compact: "compact";
|
|
1045
1090
|
message: "message";
|
|
@@ -1069,6 +1114,7 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
1069
1114
|
}, z.core.$strict>>;
|
|
1070
1115
|
reminderSeqs: z.ZodArray<z.ZodNumber>;
|
|
1071
1116
|
runOutcomeSeqs: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
1117
|
+
automationEventSeqs: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
1072
1118
|
maxOutputTokens: z.ZodNumber;
|
|
1073
1119
|
params: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
1074
1120
|
droppedParams: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -709,6 +709,31 @@ export const ScheduleMarkerSchema = z.object({
|
|
|
709
709
|
taskName: z.string(),
|
|
710
710
|
localTime: z.string(),
|
|
711
711
|
});
|
|
712
|
+
/**
|
|
713
|
+
* `user_message.automationEvent` (collaboration spec §4.6): the `AutomationEventMarker` shape, the
|
|
714
|
+
* events an event automation's message reports (at least one; coalesced events in order; at most
|
|
715
|
+
* the first 5 and the latest 15, `omittedEvents` counting the ones between, absent when none).
|
|
716
|
+
*/
|
|
717
|
+
export const AutomationEventMarkerSchema = z.object({
|
|
718
|
+
automationId: z.string(),
|
|
719
|
+
automationRunId: z.string(),
|
|
720
|
+
automationName: z.string(),
|
|
721
|
+
source: z.string(),
|
|
722
|
+
events: z
|
|
723
|
+
.array(z.object({
|
|
724
|
+
id: z.string(),
|
|
725
|
+
type: z.string(),
|
|
726
|
+
subject: z.object({
|
|
727
|
+
kind: z.string(),
|
|
728
|
+
id: z.string(),
|
|
729
|
+
title: z.string(),
|
|
730
|
+
url: z.string().optional(),
|
|
731
|
+
}),
|
|
732
|
+
summary: z.string(),
|
|
733
|
+
}))
|
|
734
|
+
.min(1),
|
|
735
|
+
omittedEvents: z.number().int().positive().optional(),
|
|
736
|
+
});
|
|
712
737
|
/** `run_context` (run context spec §3.1): every field optional, a later event holds changes only. */
|
|
713
738
|
export const RunContextSchema = z.object({
|
|
714
739
|
/** The agent itself: its name and its versioned description collapsed to one line. */
|
|
@@ -831,6 +856,13 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
|
831
856
|
attachments: z
|
|
832
857
|
.array(z.object({ appId: z.string(), appName: z.string(), uri: z.string(), name: z.string() }))
|
|
833
858
|
.optional(),
|
|
859
|
+
/**
|
|
860
|
+
* The referenced project files (composer menus §5), paths relative to the conversation's
|
|
861
|
+
* project root: the text block of file i is `content[1 + attachments.length + i]`, before
|
|
862
|
+
* the uploaded files' blocks. Normalized and deduplicated, so possibly shorter than the
|
|
863
|
+
* body's list. Absent: none.
|
|
864
|
+
*/
|
|
865
|
+
projectFiles: z.array(z.object({ path: z.string() })).optional(),
|
|
834
866
|
authorAccountId: z.string(),
|
|
835
867
|
/**
|
|
836
868
|
* Who wrote the message, at send time (run context spec §3.2): display name and org role
|
|
@@ -889,9 +921,17 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
|
889
921
|
* Not model-visible as such: request building renders only `taskName` and `localTime`, fixed
|
|
890
922
|
* here at write time, as the header `[Scheduled task "<name>", run for <local time>]`
|
|
891
923
|
* (`scheduleHeader`). The run this message triggers is unattended
|
|
892
|
-
* (`runs.
|
|
924
|
+
* (`runs.automation_run_id`).
|
|
893
925
|
*/
|
|
894
926
|
schedule: ScheduleMarkerSchema.optional(),
|
|
927
|
+
/**
|
|
928
|
+
* An event automation's message (collaboration spec §4.6): which automation and run posted
|
|
929
|
+
* it and the events it reports. Request building renders it, from these fields fixed at
|
|
930
|
+
* write time, as a block before the automation's prompt (`automationEventBlock`); the ids
|
|
931
|
+
* are not model-visible. The run this message triggers is unattended
|
|
932
|
+
* (`runs.automation_run_id`) and records its last event (`runs.trigger_event_id`).
|
|
933
|
+
*/
|
|
934
|
+
automationEvent: AutomationEventMarkerSchema.optional(),
|
|
895
935
|
/**
|
|
896
936
|
* Set on a sub-agent's task message (phase C, spec §6.3): which parent call dispatched it.
|
|
897
937
|
* Not model-visible; the web renders the message as the task block.
|
|
@@ -946,9 +986,12 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
|
946
986
|
* (spec 2026-11-05-background-bash-design §3), `subagent` = a sub-agent's delivery woke it
|
|
947
987
|
* (agent map spec §5.3), `schedule` = a scheduled task's message (scheduled tasks spec §6),
|
|
948
988
|
* `compact` = a manual compaction run (context compaction spec §4.7): no message, no model
|
|
949
|
-
* step, only the summary and its usage
|
|
989
|
+
* step, only the summary and its usage, `automation_event` = an event automation's message
|
|
990
|
+
* (collaboration spec §4.6).
|
|
950
991
|
*/
|
|
951
|
-
trigger: z
|
|
992
|
+
trigger: z
|
|
993
|
+
.enum(["message", "background_task", "subagent", "schedule", "compact", "automation_event"])
|
|
994
|
+
.optional(),
|
|
952
995
|
/**
|
|
953
996
|
* A wake run's boundary: the seq of the finish or delivery that woke it (full-run replay
|
|
954
997
|
* seeds from it).
|
|
@@ -976,6 +1019,12 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
|
976
1019
|
* renders another set (a request sent before the note existed).
|
|
977
1020
|
*/
|
|
978
1021
|
runOutcomeSeqs: z.array(seqNo).optional(),
|
|
1022
|
+
/**
|
|
1023
|
+
* The `user_message` events whose event automation block (`automationEventBlock`) the
|
|
1024
|
+
* request rendered, in seq order; absent when it rendered none. Reconstruction reports
|
|
1025
|
+
* `automation_event_block` when the rebuild renders another set.
|
|
1026
|
+
*/
|
|
1027
|
+
automationEventSeqs: z.array(seqNo).optional(),
|
|
979
1028
|
/**
|
|
980
1029
|
* The request's output cap: `min(model cap, maxOutputTokens knob ??
|
|
981
1030
|
* runtime.maxOutputTokens)`, clamped by the hard fit guard.
|
|
@@ -1852,6 +1901,8 @@ const _toolResult = true;
|
|
|
1852
1901
|
void _toolResult;
|
|
1853
1902
|
const _schedule = true;
|
|
1854
1903
|
void _schedule;
|
|
1904
|
+
const _automationEvent = true;
|
|
1905
|
+
void _automationEvent;
|
|
1855
1906
|
void _blocks;
|
|
1856
1907
|
void _logIsBlock;
|
|
1857
1908
|
void _stop;
|
|
@@ -59,7 +59,7 @@ export type MessageContext = Pick<EventPayload<"user_message">, "sender" | "time
|
|
|
59
59
|
* - `sender`: the account's display name and org role at send time; the org's anonymous guest
|
|
60
60
|
* account (`org_anonymous_accounts`) is `{ name: <senderName, else "Anonymous guest">, role:
|
|
61
61
|
* "guest", anonymous: true }`. Names are sanitised; an empty one leaves `sender` out.
|
|
62
|
-
* - `timeZone`: the override (`timeZoneOverride`, when valid:
|
|
62
|
+
* - `timeZone`: the override (`timeZoneOverride`, when valid: an automation's zone, scheduled
|
|
63
63
|
* tasks spec §6), else what the IM platform gave for the sender (`im`, when valid), else the
|
|
64
64
|
* account's setting, else the browser's (when valid), else the org default, else UTC. The
|
|
65
65
|
* anonymous guest account has no setting of its own, so it gets the IM value or the org default.
|
|
@@ -77,6 +77,6 @@ export declare function readMessageContext(t: KernelSchemaDb, input: {
|
|
|
77
77
|
browser?: BrowserContext | undefined;
|
|
78
78
|
/** An IM message: what the platform gave for the sender (maintainer decision 2026-11-08). */
|
|
79
79
|
im?: ImSenderContext | undefined;
|
|
80
|
-
/** A zone that beats every other source (
|
|
80
|
+
/** A zone that beats every other source (an automation's zone); internal callers only. */
|
|
81
81
|
timeZoneOverride?: string | undefined;
|
|
82
82
|
}): Promise<MessageContext>;
|
|
@@ -84,7 +84,7 @@ export async function recipientLocale(t, input) {
|
|
|
84
84
|
* - `sender`: the account's display name and org role at send time; the org's anonymous guest
|
|
85
85
|
* account (`org_anonymous_accounts`) is `{ name: <senderName, else "Anonymous guest">, role:
|
|
86
86
|
* "guest", anonymous: true }`. Names are sanitised; an empty one leaves `sender` out.
|
|
87
|
-
* - `timeZone`: the override (`timeZoneOverride`, when valid:
|
|
87
|
+
* - `timeZone`: the override (`timeZoneOverride`, when valid: an automation's zone, scheduled
|
|
88
88
|
* tasks spec §6), else what the IM platform gave for the sender (`im`, when valid), else the
|
|
89
89
|
* account's setting, else the browser's (when valid), else the org default, else UTC. The
|
|
90
90
|
* anonymous guest account has no setting of its own, so it gets the IM value or the org default.
|
|
@@ -12,6 +12,7 @@ export declare class PermissionProfileStore {
|
|
|
12
12
|
account_id: string;
|
|
13
13
|
agent_id: string;
|
|
14
14
|
archived_at: Date | null;
|
|
15
|
+
automation_id: string | null;
|
|
15
16
|
consumed_seq: string;
|
|
16
17
|
create_request_hash: string | null;
|
|
17
18
|
create_request_id: string | null;
|
|
@@ -31,11 +32,11 @@ export declare class PermissionProfileStore {
|
|
|
31
32
|
project_path: string | null;
|
|
32
33
|
queue_pause_reason: string | null;
|
|
33
34
|
queue_paused: boolean;
|
|
34
|
-
scheduled_task_id: string | null;
|
|
35
35
|
selection: unknown;
|
|
36
36
|
source: "channel_dm" | "channel_group" | "subagent" | "web";
|
|
37
37
|
subagent_depth: number;
|
|
38
38
|
subagent_type: string | null;
|
|
39
|
+
subject: import("../db/kernel-schema.js").ConversationSubject | null;
|
|
39
40
|
title: string | null;
|
|
40
41
|
title_attempts: number;
|
|
41
42
|
title_source: import("../db/kernel-schema.js").TitleSource | null;
|
|
@@ -16,6 +16,9 @@ export declare const FirstMessageBody: z.ZodObject<{
|
|
|
16
16
|
uri: z.ZodString;
|
|
17
17
|
}, z.core.$strict>>>;
|
|
18
18
|
files: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
|
|
19
|
+
projectFiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
20
|
+
path: z.ZodString;
|
|
21
|
+
}, z.core.$strict>>>;
|
|
19
22
|
model: z.ZodOptional<z.ZodObject<{
|
|
20
23
|
provider: z.ZodString;
|
|
21
24
|
model: z.ZodString;
|
|
@@ -123,7 +123,7 @@ let PermissionProfilesService = class PermissionProfilesService {
|
|
|
123
123
|
}
|
|
124
124
|
async setLocked(orgId, id, accountId, body, binding) {
|
|
125
125
|
let row = await this.store.own(orgId, id, accountId);
|
|
126
|
-
if (row.parent_conversation_id || row.kind !== "chat" || row.
|
|
126
|
+
if (row.parent_conversation_id || row.kind !== "chat" || row.automation_id)
|
|
127
127
|
throw new ApiError("forbidden", "Only interactive root conversations have editable permissions");
|
|
128
128
|
const subject = {
|
|
129
129
|
orgId,
|
|
@@ -78,7 +78,7 @@ export interface SuggestionEligibilityInput {
|
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
80
|
* Whether a finished run may get a suggestion by its outcome, conversation and trigger (spec §2):
|
|
81
|
-
* `completed` or `max_steps`, a `chat` conversation from `web`, not
|
|
81
|
+
* `completed` or `max_steps`, a `chat` conversation from `web`, not an automation's or compact run.
|
|
82
82
|
* The final reply, freshness and the switches are checked elsewhere.
|
|
83
83
|
*/
|
|
84
84
|
export declare function suggestionEligible(i: SuggestionEligibilityInput): boolean;
|
|
@@ -147,7 +147,7 @@ export function buildSuggestionRequest(input) {
|
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
149
|
* Whether a finished run may get a suggestion by its outcome, conversation and trigger (spec §2):
|
|
150
|
-
* `completed` or `max_steps`, a `chat` conversation from `web`, not
|
|
150
|
+
* `completed` or `max_steps`, a `chat` conversation from `web`, not an automation's or compact run.
|
|
151
151
|
* The final reply, freshness and the switches are checked elsewhere.
|
|
152
152
|
*/
|
|
153
153
|
export function suggestionEligible(i) {
|
|
@@ -155,6 +155,7 @@ export function suggestionEligible(i) {
|
|
|
155
155
|
i.kind === "chat" &&
|
|
156
156
|
i.source === "web" &&
|
|
157
157
|
i.trigger !== "schedule" &&
|
|
158
|
+
i.trigger !== "automation_event" &&
|
|
158
159
|
i.trigger !== "compact");
|
|
159
160
|
}
|
|
160
161
|
// C0 and C1 controls (newlines are split on first; a tab becomes a space)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ModelRef } from "../agents/definition.js";
|
|
2
|
+
import type { ScheduleMarker } from "../automations/types.js";
|
|
2
3
|
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
3
4
|
import { ApiError } from "../errors.js";
|
|
4
|
-
import type { ScheduleMarker } from "../schedules/types.js";
|
|
5
5
|
import { type InvocationRecord, type RenderedInvocation } from "../skills/invoke.js";
|
|
6
6
|
import type { AttachmentRef } from "./conversations.service.js";
|
|
7
7
|
import { type AppendEvent, type EventLog } from "./event-log.js";
|
|
@@ -30,7 +30,7 @@ export interface QueuedSkill {
|
|
|
30
30
|
record: InvocationRecord;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* An automation's queued message (scheduled tasks spec §6), stored in
|
|
34
34
|
* `conversation_queue.schedule`: the marker the `user_message` carries and the task's zone, which
|
|
35
35
|
* becomes the message's `timeZone` (the top-priority override of `readMessageContext`).
|
|
36
36
|
*/
|
|
@@ -104,9 +104,11 @@ export interface QueueRow {
|
|
|
104
104
|
effort: string | null;
|
|
105
105
|
skill: unknown;
|
|
106
106
|
schedule: unknown;
|
|
107
|
+
/** An event automation's marker (collaboration spec §4.6); null for any other message. */
|
|
108
|
+
automation_event: unknown;
|
|
107
109
|
created_at: Date;
|
|
108
110
|
}
|
|
109
|
-
export declare const COLUMNS: readonly ["id", "conversation_id", "account_id", "position", "text", "content", "attachments", "files", "client_message_id", "model", "effort", "skill", "schedule", "created_at"];
|
|
111
|
+
export declare const COLUMNS: readonly ["id", "conversation_id", "account_id", "position", "text", "content", "attachments", "files", "client_message_id", "model", "effort", "skill", "schedule", "automation_event", "created_at"];
|
|
110
112
|
/**
|
|
111
113
|
* Queued text as the event log will store it: NUL becomes U+FFFD (PG rejects NUL in text and
|
|
112
114
|
* jsonb), the mapping `payloadJson` applies to a direct send (final review m1).
|
|
@@ -127,7 +129,8 @@ export declare function storedSkill(invokedAs: string, invoked: RenderedInvocati
|
|
|
127
129
|
};
|
|
128
130
|
/**
|
|
129
131
|
* The `user_message` a queued item becomes, as `postUserMessage` would have written it; a scheduled
|
|
130
|
-
* task's item carries its marker (without the stored zone, which is in `context`)
|
|
132
|
+
* task's item carries its marker (without the stored zone, which is in `context`), an event
|
|
133
|
+
* automation's item its event marker.
|
|
131
134
|
*/
|
|
132
135
|
export declare function queuedUserMessage(r: QueueRow, context?: MessageContext): AppendEvent;
|
|
133
136
|
/**
|