@sentry/junior 0.311.0 → 0.312.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/dist/{adapter-context-G2M0y6rP.js → adapter-context-BRjEWRy1.js} +2 -2
- package/dist/{adapter-B1wujchl.js → adapter-iIq7ihf7.js} +1 -1
- package/dist/{admin-DCiBhUT1.js → admin-DhInw5K9.js} +1 -1
- package/dist/{agent-runner-BVHPUIc8.js → agent-runner-C9iDurwX.js} +3423 -3477
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +6 -6
- package/dist/api.d.ts +2 -2
- package/dist/api.js +289 -306
- package/dist/{app-Cw5Vy6H6.d.ts → app-DRFrC8Mw.d.ts} +2 -9
- package/dist/app.d.ts +1 -1
- package/dist/app.js +338 -604
- package/dist/{background-compaction-queue-CJDnWVOJ.js → background-compaction-queue-DrKi7w3d.js} +10 -85
- package/dist/callback-mFlTUWWx.js +75 -0
- package/dist/{catalog-runtime-DMY3VV-D.js → catalog-runtime-D7xapBAX.js} +1 -1
- package/dist/channel-access-CJGfNTdn.js +221 -0
- package/dist/child-message-DcsritGf.js +179 -0
- package/dist/cli/chat.js +18 -19
- package/dist/cli/check.js +3 -3
- package/dist/cli/init.js +0 -1
- package/dist/cli/main.js +3 -7
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/run.d.ts +1 -2
- package/dist/cli/run.js +1 -2
- package/dist/cli/snapshot-create.js +5 -5
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +3 -3
- package/dist/{config-BrXDQefC.js → config-kXB2Y5tl.js} +59 -27
- package/dist/{continue-in-slack-DNXSC9So.js → continue-in-slack-O6pV5004.js} +7 -8
- package/dist/{conversation-feed-DkinDu5o.js → conversation-feed-uNOv_x68.js} +74 -20
- package/dist/{conversation-privacy-DxttrKb9.js → conversation-privacy-L4ja1_W6.js} +1 -1
- package/dist/{conversation-turn-DWw7Xhdr.js → conversation-turn-CeLbHqdw.js} +31 -27
- package/dist/{credential-sync-Bk8wGb8Y.js → credential-sync-I8VBGk05.js} +16 -15
- package/dist/{projection-Cns7XwWa.js → credentialed-Cb6E2phL.js} +16308 -20732
- package/dist/{db-7ETESH44.d.ts → db-BbC5stfa.d.ts} +11 -6
- package/dist/{db-DTxzH7u5.js → db-LAyyX8tk.js} +174 -91
- package/dist/{executor-DqTiYj9S.js → executor-SCub-fAq.js} +117 -97
- package/dist/{html-B9Sl4Axb.js → html-BCZ3Xtb_.js} +6 -6
- package/dist/ingest-BDf3D50j.js +3836 -0
- package/dist/{install-Sg4ePfLl.js → install-DCFJFkC0.js} +2 -2
- package/dist/instrumentation.js +3 -3
- package/dist/{lineage-BHAMpNKr.js → lineage-B_m-4TJw.js} +2 -2
- package/dist/{stop-CYsfc0Ed.js → list-CN2QA2R9.js} +663 -442
- package/dist/{logging-FjclQsXu.js → logging-dQ9ZRGQ8.js} +1 -1
- package/dist/{schedule-BLJ476XQ.js → media-CYm1QD8T.js} +1055 -11
- package/dist/{message-CJ7_RL50.js → message-DSXGj1hM.js} +19 -26
- package/dist/{model-input-CMLh4Cwq.js → model-input--TrP9hYV.js} +3 -3
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +4 -3
- package/dist/{oauth-callback-server-RVcbiDjL.js → oauth-callback-server-DHCZC6B4.js} +2 -2
- package/dist/{oauth-relay-Bu9kkaQu.js → oauth-relay-pPMGnDZt.js} +1 -1
- package/dist/{registry-BPwuOP2O.js → registry-CZOzddwu.js} +1 -1
- package/dist/{resolve-BK29bBry.js → resolve-cKOQ14Dh.js} +3 -3
- package/dist/result-DcvEOe1r.js +574 -0
- package/dist/result-event-type-BdIJuZxg.js +48 -0
- package/dist/{runner-BcAE-cJm.js → runner-DBfUW44l.js} +14 -16
- package/dist/{sandbox-egress-signals-C-q0go5b.js → sandbox-egress-signals-BVF_xAm1.js} +1 -1
- package/dist/{schema-DYcJeV7d.d.ts → schema-BEHKxr4I.d.ts} +166 -242
- package/dist/{schema-BLgSZXcL.js → schema-Bk9Nm2E8.js} +106 -121
- package/dist/{service-account-iJoCtkHR.js → service-account-CVYsFjty.js} +3 -3
- package/dist/{service-account-gN0zqf0S.js → service-account-Ts4ulcrV.js} +5 -5
- package/dist/{skills-BoZ80epJ.js → skills-VTnhAJWm.js} +2 -2
- package/dist/{slack-conversation-unfurl-CogYrITA.js → slack-conversation-unfurl-fuLnF1jE.js} +9 -9
- package/dist/{spawn-Dk92r7mX.js → spawn-vxAarlX5.js} +6 -5
- package/dist/start-conversation-CEn2KH1A.js +941 -0
- package/dist/{state-DH3Cmgp3.js → state-C1P3_Ywk.js} +4 -4
- package/dist/statuses-_cRJHXK7.js +150 -0
- package/dist/store-DFZaN-Ix.js +492 -0
- package/dist/task-queue-Cx4Lmjyk.js +90 -0
- package/dist/task-runner-CbTwFA6k.js +1432 -0
- package/dist/{thread-context-BW2BsQbH.js → thread-context-BkAZDTX2.js} +7 -7
- package/dist/thread-state-DhPndWi1.js +5625 -0
- package/dist/{validation-DrJd0nnq.js → validation-nIzMtAVJ.js} +1 -1
- package/dist/{task-queue-C_zldF5J.js → vercel-queue-hW90XzbG.js} +93 -172
- package/dist/{version-CNKZ8owc.js → version-Brbtz4Qf.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{warmup-BWdHew2H.js → warmup-BDA5myRK.js} +6463 -12290
- package/dist/web-message-id-C6P83ans.js +10 -0
- package/dist/{worker-t9qpu_Zx.js → worker-D63RcaVD.js} +20 -7
- package/migrations/0143_todos.sql +14 -0
- package/migrations/0144_inbox_items.sql +32 -0
- package/migrations/0145_todo_changed_by_agent.sql +1 -0
- package/migrations/0146_inbox_item_subject_title_parts.sql +1 -0
- package/migrations/0147_inbox_snooze_wake_reason.sql +1 -0
- package/migrations/0148_authorization_request_index.sql +1 -0
- package/migrations/0149_conversation_metadata.sql +10 -0
- package/migrations/0150_conversation_metadata_fill.sql +39 -0
- package/migrations/0151_conversation_search_index.sql +1 -0
- package/migrations/0152_inbox_item_legacy_automation_keys.sql +21 -0
- package/migrations/0153_artifact_expiry.sql +1 -0
- package/migrations/0154_artifact_permanent_sha_index.sql +1 -0
- package/migrations/0155_artifact_drop_public_sha_index.sql +3 -0
- package/migrations/0156_conversation_kind_lead.sql +6 -0
- package/migrations/0157_conversation_lead_actor_index.sql +1 -0
- package/migrations/meta/0143_snapshot.json +6434 -0
- package/migrations/meta/0144_snapshot.json +6434 -0
- package/migrations/meta/0145_snapshot.json +6440 -0
- package/migrations/meta/0146_snapshot.json +6446 -0
- package/migrations/meta/0147_snapshot.json +6452 -0
- package/migrations/meta/0148_snapshot.json +6474 -0
- package/migrations/meta/0149_snapshot.json +6490 -0
- package/migrations/meta/0150_snapshot.json +6490 -0
- package/migrations/meta/0151_snapshot.json +6505 -0
- package/migrations/meta/0152_snapshot.json +6505 -0
- package/migrations/meta/0153_snapshot.json +6511 -0
- package/migrations/meta/0154_snapshot.json +6533 -0
- package/migrations/meta/0155_snapshot.json +6511 -0
- package/migrations/meta/0156_snapshot.json +6511 -0
- package/migrations/meta/0157_snapshot.json +6527 -0
- package/migrations/meta/_journal.json +106 -1
- package/package.json +6 -6
- package/skills/design-automation-skill/SKILL.md +108 -0
- package/dist/briefs-BDjnug6Y.js +0 -395
- package/dist/conversation-ca__NDQW.js +0 -1063
- package/dist/prompt-CDqcsDYC.js +0 -910
- package/dist/store-DmmMIrQi.js +0 -335
- package/dist/task-runner-C7oCJQIx.js +0 -294
- package/dist/turn-session-routing-Xh_2nSQe.js +0 -261
- package/dist/web-message-id-Ch5dPq-a.js +0 -306
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./schema-
|
|
1
|
+
import "./schema-BEHKxr4I.js";
|
|
2
2
|
import * as z from "zod";
|
|
3
3
|
import "@earendil-works/pi-ai";
|
|
4
4
|
import { Destination, Source, locationSchema } from "@sentry/junior-plugin-api";
|
|
@@ -53,11 +53,14 @@ type Usage = z.output<typeof usageSchema>;
|
|
|
53
53
|
type AgentTurnUsage = Usage;
|
|
54
54
|
type ConversationSource = "api" | "internal" | "local" | "plugin" | "event" | "scheduler" | "slack" | "web";
|
|
55
55
|
/**
|
|
56
|
-
* Where a Conversation sits in its tree. A root
|
|
57
|
-
* parent. A Thread is a child that people can message. A Task
|
|
58
|
-
* only its parent messages. A Conversation never changes
|
|
56
|
+
* Where a Conversation sits in its tree. A root, an Automation run, and a
|
|
57
|
+
* Lead have no parent. A Thread is a child that people can message. A Task
|
|
58
|
+
* is a child that only its parent messages. A Conversation never changes
|
|
59
|
+
* kind.
|
|
59
60
|
*/
|
|
60
|
-
type ConversationKind = "root" | "automation" | "thread" | "task";
|
|
61
|
+
type ConversationKind = "root" | "automation" | "lead" | "thread" | "task";
|
|
62
|
+
/** The kind of a Conversation that has no parent. */
|
|
63
|
+
type TopLevelConversationKind = Exclude<ConversationKind, ChildConversationKind>;
|
|
61
64
|
/** The kind of a Conversation that has a parent. */
|
|
62
65
|
type ChildConversationKind = "thread" | "task";
|
|
63
66
|
type ConversationStatus = "paused" | "failed" | "idle" | "pending" | "running";
|
|
@@ -119,6 +122,8 @@ interface Conversation {
|
|
|
119
122
|
*/
|
|
120
123
|
sessionSource?: SessionSource;
|
|
121
124
|
title?: string | undefined;
|
|
125
|
+
/** Conversation metadata. Only the metadata task writes it. */
|
|
126
|
+
summary?: string;
|
|
122
127
|
updatedAtMs: number;
|
|
123
128
|
/**
|
|
124
129
|
* When retention purged this conversation's content. Set means messages and
|
|
@@ -227,7 +232,7 @@ interface ConversationStore {
|
|
|
227
232
|
* Kind of a new Conversation. Default `root`. An existing Conversation
|
|
228
233
|
* keeps its kind.
|
|
229
234
|
*/
|
|
230
|
-
kind?:
|
|
235
|
+
kind?: TopLevelConversationKind;
|
|
231
236
|
/**
|
|
232
237
|
* Current visibility from its owner, such as a Slack event channel type. It
|
|
233
238
|
* replaces the visibility of the shared Destination row. Omit it for saved
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
|
|
2
|
-
import {
|
|
2
|
+
import { N as cacheKeyPrefix, P as createCache, r as getChatConfig } from "./config-kXB2Y5tl.js";
|
|
3
3
|
import { a as isSlackUserId, d as parseSlackChannelReferenceId, f as parseSlackTeamId, s as parseActorUserId } from "./actor-BsBdxDXQ.js";
|
|
4
|
-
import { A as juniorConversationMetrics, B as juniorAttachments, C as juniorConversationParticipants, H as juniorConversations, K as juniorUsers, M as juniorConversationEvents,
|
|
4
|
+
import { A as juniorConversationMetrics, B as juniorAttachments, C as juniorConversationParticipants, H as juniorConversations, K as juniorUsers, M as juniorConversationEvents, P as juniorConversationAnnotations, S as juniorConversationReadPositions, T as juniorConversationBriefs, U as juniorIdentities, V as juniorMessageAttachments, _ as juniorAutomationRuns, f as juniorInboxItemAssignees, g as juniorAutomations, h as juniorInboxItems, j as isUserInstruction, k as CONVERSATION_METRICS, p as juniorInboxItemConversations, q as juniorDestinations, t as createJuniorSqlExecutor, w as juniorConversationBindings } from "./executor-SCub-fAq.js";
|
|
5
5
|
import { c as newConversationEventSchema, h as usageSchema, l as encodeHistoryPayload, o as decodeStoredConversationEvent, r as conversationEventDataSchema, s as historyReplacementSchema } from "./history-CYstOMKX.js";
|
|
6
|
-
import { t as canExposeConversationPayload } from "./conversation-privacy-
|
|
6
|
+
import { t as canExposeConversationPayload } from "./conversation-privacy-L4ja1_W6.js";
|
|
7
7
|
import { t as mapBounded } from "./fan-out-Cod-yEHG.js";
|
|
8
|
-
import { J as normalizeIdentityEmail, K as GOOGLE_IDENTITY_PROVIDER, h as logWarn } from "./logging-
|
|
9
|
-
import { i as getStateAdapter } from "./adapter-
|
|
8
|
+
import { J as normalizeIdentityEmail, K as GOOGLE_IDENTITY_PROVIDER, h as logWarn } from "./logging-dQ9ZRGQ8.js";
|
|
9
|
+
import { i as getStateAdapter } from "./adapter-iIq7ihf7.js";
|
|
10
10
|
import * as z from "zod";
|
|
11
11
|
import { createHash, randomUUID } from "node:crypto";
|
|
12
12
|
import { PluginToolInputError, destinationSchema, identitySchema, locationSchema, sourceSchema, userSchema } from "@sentry/junior-plugin-api";
|
|
@@ -398,7 +398,20 @@ function canAccessConversation(args) {
|
|
|
398
398
|
if (requester.destinationId !== void 0 && requester.destinationId === target.destinationId) return true;
|
|
399
399
|
return target.visibility === "public";
|
|
400
400
|
}
|
|
401
|
-
|
|
401
|
+
/**
|
|
402
|
+
* Whether work in `requesterConversationId` may read `conversationId`, by
|
|
403
|
+
* `canAccessConversation`. A missing target is not readable. A requester that
|
|
404
|
+
* is not stored yet reaches only public targets.
|
|
405
|
+
*/
|
|
406
|
+
async function canReadConversation(db, requesterConversationId, conversationId) {
|
|
407
|
+
const access = await readConversationAccessFromSql(db, [requesterConversationId, conversationId]);
|
|
408
|
+
const target = access.get(conversationId);
|
|
409
|
+
return target !== void 0 && canAccessConversation({
|
|
410
|
+
requester: access.get(requesterConversationId) ?? { visibility: null },
|
|
411
|
+
target
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
// src/chat/tool-support/tool-input-error.ts
|
|
402
415
|
/** Thrown when a tool fails due to invalid model/user input, not a system error. */
|
|
403
416
|
var ToolInputError = class extends Error {
|
|
404
417
|
constructor(message, options) {
|
|
@@ -1057,7 +1070,7 @@ async function readIdentityByIdFromSql(db, identityId) {
|
|
|
1057
1070
|
async function readIdentityById(identityId) {
|
|
1058
1071
|
return await readIdentityByIdFromSql(getDb(), identityId);
|
|
1059
1072
|
}
|
|
1060
|
-
// src/chat/
|
|
1073
|
+
// src/chat/inbox-items/assignees.ts
|
|
1061
1074
|
/** Text that the agent writes to assign Everyone. */
|
|
1062
1075
|
const EVERYONE_ASSIGNEE = "everyone";
|
|
1063
1076
|
/**
|
|
@@ -1076,9 +1089,9 @@ async function resolveAssignee(db, value, tenant, findMentionedUserId) {
|
|
|
1076
1089
|
}
|
|
1077
1090
|
throw new ToolInputError(`Unknown assignee ${JSON.stringify(text)}. Use ${EVERYONE_ASSIGNEE}, an email, or a mention such as <@U123>.`);
|
|
1078
1091
|
}
|
|
1079
|
-
/** Resolve the assignees of
|
|
1092
|
+
/** Resolve the assignees of an Inbox item. One is required. */
|
|
1080
1093
|
async function resolveAssignees(db, values, tenant, findMentionedUserId) {
|
|
1081
|
-
if (values.length === 0) throw new ToolInputError("
|
|
1094
|
+
if (values.length === 0) throw new ToolInputError("An inbox item needs at least one assignee.");
|
|
1082
1095
|
const resolved = await mapBounded(values, (value) => resolveAssignee(db, value, tenant, findMentionedUserId));
|
|
1083
1096
|
return {
|
|
1084
1097
|
everyone: resolved.some((assignee) => "everyone" in assignee),
|
|
@@ -1105,7 +1118,7 @@ async function automationCreatorUserId(db, automationId) {
|
|
|
1105
1118
|
const [row] = await db.select({ userId: juniorIdentities.userId }).from(juniorAutomations).innerJoin(juniorIdentities, eq(juniorIdentities.id, juniorAutomations.creatorIdentityId)).where(eq(juniorAutomations.id, automationId)).limit(1);
|
|
1106
1119
|
return row?.userId ?? void 0;
|
|
1107
1120
|
}
|
|
1108
|
-
// src/chat/
|
|
1121
|
+
// src/chat/inbox-items/access.ts
|
|
1109
1122
|
/** Return whether two tenants are the same. Two missing tenants match. */
|
|
1110
1123
|
function isSameTenant(a, b) {
|
|
1111
1124
|
return a?.provider === b?.provider && a?.providerTenantId === b?.providerTenantId;
|
|
@@ -1114,7 +1127,7 @@ function isSameTenant(a, b) {
|
|
|
1114
1127
|
* The reader for one person: items assigned to them, and public items in the
|
|
1115
1128
|
* provider tenants of their identities.
|
|
1116
1129
|
*/
|
|
1117
|
-
function
|
|
1130
|
+
function inboxItemReaderForUser(user) {
|
|
1118
1131
|
return {
|
|
1119
1132
|
tenants: user.identities.flatMap((identity) => identity.providerTenantId ? [{
|
|
1120
1133
|
provider: identity.provider,
|
|
@@ -1124,88 +1137,88 @@ function reviewItemReaderForUser(user) {
|
|
|
1124
1137
|
};
|
|
1125
1138
|
}
|
|
1126
1139
|
/**
|
|
1127
|
-
* SQL: a Conversation owns the
|
|
1140
|
+
* SQL: a Conversation owns the Inbox item. The Conversation status and
|
|
1128
1141
|
* feeds read the items that each Conversation owns.
|
|
1129
1142
|
*/
|
|
1130
|
-
function
|
|
1131
|
-
return and(eq(
|
|
1143
|
+
function inboxItemOwnedByConversation(conversationId) {
|
|
1144
|
+
return and(eq(juniorInboxItems.ownerKind, "conversation"), eq(juniorInboxItems.ownerId, conversationId));
|
|
1132
1145
|
}
|
|
1133
|
-
/** SQL: the
|
|
1134
|
-
function
|
|
1135
|
-
return sql`exists (select 1 from ${
|
|
1146
|
+
/** SQL: the Inbox item has this assigned User. */
|
|
1147
|
+
function inboxItemAssignedTo(userId) {
|
|
1148
|
+
return sql`exists (select 1 from ${juniorInboxItemAssignees} where ${juniorInboxItemAssignees.itemId} = ${juniorInboxItems.id} and ${juniorInboxItemAssignees.userId} = ${userId})`;
|
|
1136
1149
|
}
|
|
1137
1150
|
/**
|
|
1138
|
-
* SQL: the
|
|
1151
|
+
* SQL: the Inbox item needs this User. Only an open `action` item that is
|
|
1139
1152
|
* assigned to the User needs them. A notice, an item for Everyone, and an
|
|
1140
1153
|
* item without assignees need no one. An assigned User can always see the
|
|
1141
1154
|
* item, so this rule needs no visibility check. The nav count and the
|
|
1142
1155
|
* "Waiting on you" marker use this rule.
|
|
1143
1156
|
*/
|
|
1144
|
-
function
|
|
1145
|
-
return and(eq(
|
|
1157
|
+
function inboxItemNeedsUser(userId) {
|
|
1158
|
+
return and(eq(juniorInboxItems.status, "open"), eq(juniorInboxItems.kind, "action"), inboxItemAssignedTo(userId));
|
|
1146
1159
|
}
|
|
1147
1160
|
/**
|
|
1148
|
-
* SQL: the
|
|
1149
|
-
* assigned User. It is `
|
|
1161
|
+
* SQL: the Inbox item needs some person: an open `action` item with an
|
|
1162
|
+
* assigned User. It is `inboxItemNeedsUser` for any User.
|
|
1150
1163
|
*/
|
|
1151
|
-
function
|
|
1152
|
-
return and(eq(
|
|
1164
|
+
function inboxItemNeedsSomeone() {
|
|
1165
|
+
return and(eq(juniorInboxItems.status, "open"), eq(juniorInboxItems.kind, "action"), sql`exists (select 1 from ${juniorInboxItemAssignees} where ${juniorInboxItemAssignees.itemId} = ${juniorInboxItems.id})`);
|
|
1153
1166
|
}
|
|
1154
1167
|
/**
|
|
1155
|
-
* SQL: the
|
|
1168
|
+
* SQL: the Inbox item waits for a person's input: an open `action` item,
|
|
1156
1169
|
* whoever it is assigned to. An item with no assignees still waits for
|
|
1157
1170
|
* anyone who can answer it. The Conversation that added it shows
|
|
1158
|
-
* `needs_input`. `
|
|
1171
|
+
* `needs_input`. `junior_inbox_items_open_action_added_by_idx` has this
|
|
1159
1172
|
* predicate.
|
|
1160
1173
|
*/
|
|
1161
|
-
function
|
|
1162
|
-
return and(eq(
|
|
1174
|
+
function inboxItemNeedsInput() {
|
|
1175
|
+
return and(eq(juniorInboxItems.status, "open"), eq(juniorInboxItems.kind, "action"));
|
|
1163
1176
|
}
|
|
1164
1177
|
/**
|
|
1165
|
-
* SQL: the
|
|
1178
|
+
* SQL: the Inbox item is not assigned only to other people. It is assigned
|
|
1166
1179
|
* to this User, to Everyone, or to no one. This is the assignee rule of
|
|
1167
|
-
* `
|
|
1180
|
+
* `canActOnInboxItem`; keep the two the same.
|
|
1168
1181
|
*/
|
|
1169
|
-
function
|
|
1170
|
-
return or(eq(
|
|
1182
|
+
function inboxItemForUser(userId) {
|
|
1183
|
+
return or(eq(juniorInboxItems.assignedToEveryone, true), sql`not exists (select 1 from ${juniorInboxItemAssignees} where ${juniorInboxItemAssignees.itemId} = ${juniorInboxItems.id})`, inboxItemAssignedTo(userId));
|
|
1171
1184
|
}
|
|
1172
|
-
/** SQL: the
|
|
1173
|
-
function
|
|
1174
|
-
return sql`exists (select 1 from ${
|
|
1185
|
+
/** SQL: the Inbox item links this Conversation. */
|
|
1186
|
+
function inboxItemLinkedTo(conversationId) {
|
|
1187
|
+
return sql`exists (select 1 from ${juniorInboxItemConversations} where ${juniorInboxItemConversations.itemId} = ${juniorInboxItems.id} and ${juniorInboxItemConversations.conversationId} = ${conversationId})`;
|
|
1175
1188
|
}
|
|
1176
1189
|
function publicIn(tenants) {
|
|
1177
|
-
return tenants.map((tenant) => and(eq(
|
|
1190
|
+
return tenants.map((tenant) => and(eq(juniorInboxItems.visibility, "public"), eq(juniorInboxItems.provider, tenant.provider), eq(juniorInboxItems.providerTenantId, tenant.providerTenantId)));
|
|
1178
1191
|
}
|
|
1179
1192
|
/**
|
|
1180
|
-
* SQL form of `
|
|
1181
|
-
*
|
|
1193
|
+
* SQL form of `canReadInboxItem`, for search. Keep the two the same; the
|
|
1194
|
+
* Inbox item access test checks that they agree.
|
|
1182
1195
|
*/
|
|
1183
|
-
function
|
|
1184
|
-
return or(...publicIn(reader.tenants ?? []), ...reader.userId ? [
|
|
1196
|
+
function inboxItemVisibleTo(reader) {
|
|
1197
|
+
return or(...publicIn(reader.tenants ?? []), ...reader.userId ? [inboxItemAssignedTo(reader.userId)] : [], ...reader.conversationId ? [inboxItemLinkedTo(reader.conversationId)] : [], ...reader.automationId ? [eq(juniorInboxItems.automationId, reader.automationId)] : []) ?? sql`false`;
|
|
1185
1198
|
}
|
|
1186
|
-
/** Return whether a reader can see one
|
|
1187
|
-
function
|
|
1199
|
+
/** Return whether a reader can see one Inbox item. */
|
|
1200
|
+
function canReadInboxItem(item, reader) {
|
|
1188
1201
|
return item.visibility === "public" && item.tenant !== void 0 && (reader.tenants ?? []).some((tenant) => isSameTenant(tenant, item.tenant)) || reader.userId !== void 0 && item.assignees.some((assignee) => assignee.userId === reader.userId) || reader.conversationId !== void 0 && item.conversationIds.includes(reader.conversationId) || reader.automationId !== void 0 && item.automationId === reader.automationId;
|
|
1189
1202
|
}
|
|
1190
1203
|
/**
|
|
1191
|
-
* Return whether a person can read one
|
|
1204
|
+
* Return whether a person can read one Inbox item: by the reader rule, or
|
|
1192
1205
|
* because they take part in a Conversation that the item links. The second
|
|
1193
1206
|
* part is the person rule of `policies/conversation-access.md`; it lets the
|
|
1194
1207
|
* Conversation view show its items. Viewing a public Conversation is not
|
|
1195
1208
|
* enough: a private item stays private when its Conversation becomes public.
|
|
1196
1209
|
*/
|
|
1197
|
-
async function
|
|
1198
|
-
if (
|
|
1210
|
+
async function canUserReadInboxItem(item, user) {
|
|
1211
|
+
if (canReadInboxItem(item, inboxItemReaderForUser(user))) return true;
|
|
1199
1212
|
const access = await readConversationAccessFromSql(getDb(), item.conversationIds, user);
|
|
1200
1213
|
return item.conversationIds.some((id) => access.get(id)?.isParticipant === true);
|
|
1201
1214
|
}
|
|
1202
1215
|
/**
|
|
1203
1216
|
* The reader for one person who looks at one Conversation: the person's
|
|
1204
1217
|
* reader, plus the items linked to the Conversation when they take part in
|
|
1205
|
-
* it. It is the list form of `
|
|
1218
|
+
* it. It is the list form of `canUserReadInboxItem`.
|
|
1206
1219
|
*/
|
|
1207
|
-
async function
|
|
1208
|
-
const reader =
|
|
1220
|
+
async function inboxItemReaderForUserInConversation(user, conversationId) {
|
|
1221
|
+
const reader = inboxItemReaderForUser(user);
|
|
1209
1222
|
return (await readConversationAccessFromSql(getDb(), [conversationId], user)).get(conversationId)?.isParticipant ? {
|
|
1210
1223
|
...reader,
|
|
1211
1224
|
conversationId
|
|
@@ -1216,7 +1229,7 @@ async function reviewItemReaderForUserInConversation(user, conversationId) {
|
|
|
1216
1229
|
* Automation, not as its Actor: an assignment lets a person see the item on
|
|
1217
1230
|
* the Inbox, not let an agent read it into another Conversation.
|
|
1218
1231
|
*/
|
|
1219
|
-
async function
|
|
1232
|
+
async function readInboxItemAgentScope(context) {
|
|
1220
1233
|
const actor = await context.resolveActorIdentity?.();
|
|
1221
1234
|
const user = actor?.user;
|
|
1222
1235
|
const automationId = context.source.kind === "scheduled_automation" || context.source.kind === "event_automation" ? context.source.automationId : void 0;
|
|
@@ -1238,24 +1251,24 @@ async function readReviewItemAgentScope(context) {
|
|
|
1238
1251
|
* Dedupe keys with this prefix belong to plugins. Only the plugin that added
|
|
1239
1252
|
* the item, or a person, can change it. An agent cannot use the prefix.
|
|
1240
1253
|
*/
|
|
1241
|
-
const
|
|
1254
|
+
const PLUGIN_INBOX_ITEM_KEY_PREFIX = "plugin:";
|
|
1242
1255
|
/**
|
|
1243
1256
|
* Dedupe keys with this prefix belong to Automation alerts, which core adds
|
|
1244
1257
|
* and closes. An agent cannot use the prefix.
|
|
1245
1258
|
*/
|
|
1246
|
-
const
|
|
1259
|
+
const AUTOMATION_INBOX_ITEM_KEY_PREFIX = "automation:";
|
|
1247
1260
|
/** Return the plugin that owns a dedupe key, or undefined for an agent's key. */
|
|
1248
|
-
function
|
|
1261
|
+
function inboxItemPlugin(dedupeKey) {
|
|
1249
1262
|
if (!dedupeKey.startsWith("plugin:")) return void 0;
|
|
1250
1263
|
return dedupeKey.slice(7).split(":", 1)[0] || void 0;
|
|
1251
1264
|
}
|
|
1252
1265
|
/** Return whether the item is an Automation alert. Core takes its answer. */
|
|
1253
1266
|
function isAutomationAlertItem(item) {
|
|
1254
|
-
return item.dedupeKey.startsWith(
|
|
1267
|
+
return item.dedupeKey.startsWith(AUTOMATION_INBOX_ITEM_KEY_PREFIX);
|
|
1255
1268
|
}
|
|
1256
1269
|
/** Return whether a plugin added the item. Its answer goes to the plugin. */
|
|
1257
|
-
function
|
|
1258
|
-
return
|
|
1270
|
+
function isPluginInboxItem(item) {
|
|
1271
|
+
return inboxItemPlugin(item.dedupeKey) !== void 0;
|
|
1259
1272
|
}
|
|
1260
1273
|
/**
|
|
1261
1274
|
* Whether an agent can change an item. Only an agent in the tenant of the
|
|
@@ -1265,7 +1278,7 @@ function isPluginReviewItem(item) {
|
|
|
1265
1278
|
* agent never changes an item that a plugin added, or an item that another
|
|
1266
1279
|
* owner kind, such as an Automation, owns.
|
|
1267
1280
|
*/
|
|
1268
|
-
function
|
|
1281
|
+
function canAgentChangeInboxItem(item, scope) {
|
|
1269
1282
|
if (item.dedupeKey.startsWith("plugin:")) return false;
|
|
1270
1283
|
if (item.owner.kind !== "conversation") return false;
|
|
1271
1284
|
if (!isSameTenant(item.tenant, scope.tenant)) return false;
|
|
@@ -1278,7 +1291,7 @@ function canAgentChangeReviewItem(item, scope) {
|
|
|
1278
1291
|
* that the item already has) always pass. A private item gets no other
|
|
1279
1292
|
* links. A public item can get other links only to public Conversations.
|
|
1280
1293
|
*/
|
|
1281
|
-
async function
|
|
1294
|
+
async function requireInboxItemLinks(args) {
|
|
1282
1295
|
const access = await readConversationAccessFromSql(getDb(), args.conversationIds, args.scope.user);
|
|
1283
1296
|
for (const conversationId of args.conversationIds) {
|
|
1284
1297
|
const conversation = access.get(conversationId);
|
|
@@ -1296,7 +1309,7 @@ async function requireReviewItemLinks(args) {
|
|
|
1296
1309
|
* Automation run often has no Actor and no people yet, and its creator wrote
|
|
1297
1310
|
* the work. A public item can go to anyone.
|
|
1298
1311
|
*/
|
|
1299
|
-
async function
|
|
1312
|
+
async function requireInboxItemAssignees(args) {
|
|
1300
1313
|
if (args.visibility === "public") return;
|
|
1301
1314
|
if (args.assignees.everyone) throw new ToolInputError("A private item cannot be assigned to Everyone. Assign Users instead.");
|
|
1302
1315
|
const creatorId = args.automationId ? await automationCreatorUserId(getDb(), args.automationId) : void 0;
|
|
@@ -1305,20 +1318,20 @@ async function requireReviewItemAssignees(args) {
|
|
|
1305
1318
|
if (others.some((id) => !inConversation.has(id))) throw new ToolInputError("A private item can be assigned only to people in its Conversation.");
|
|
1306
1319
|
}
|
|
1307
1320
|
/**
|
|
1308
|
-
* Return whether a User can act on an open
|
|
1321
|
+
* Return whether a User can act on an open Inbox item: an assigned User,
|
|
1309
1322
|
* anyone for an item assigned to Everyone, and anyone for an item with no
|
|
1310
1323
|
* assignees. The caller checks that the User can see the item.
|
|
1311
|
-
* `
|
|
1324
|
+
* `inboxItemForUser` is the SQL form of the assignee rule.
|
|
1312
1325
|
*/
|
|
1313
|
-
function
|
|
1326
|
+
function canActOnInboxItem(item, userId) {
|
|
1314
1327
|
if (item.status !== "open") return false;
|
|
1315
1328
|
if (item.assignedToEveryone) return true;
|
|
1316
1329
|
if (item.assignees.length === 0) return true;
|
|
1317
1330
|
return item.assignees.some((assignee) => assignee.userId === userId);
|
|
1318
1331
|
}
|
|
1319
1332
|
/**
|
|
1320
|
-
* Return whether
|
|
1321
|
-
* assigned to them. `
|
|
1333
|
+
* Return whether an Inbox item needs a User: an open `action` item that is
|
|
1334
|
+
* assigned to them. `inboxItemNeedsUser` is the SQL form; keep the two the
|
|
1322
1335
|
* same.
|
|
1323
1336
|
*/
|
|
1324
1337
|
function itemNeedsUser(item, userId) {
|
|
@@ -1375,16 +1388,18 @@ function awaitsAuthorizationFrom(conversationId, userId) {
|
|
|
1375
1388
|
/** SQL: the newest wait event is a live request that `requester` matches. */
|
|
1376
1389
|
function authorizationWait(conversationId, requester) {
|
|
1377
1390
|
const events = juniorConversationEvents;
|
|
1378
|
-
|
|
1391
|
+
const start = authorizationWaitStart();
|
|
1392
|
+
const recentRequest = sql`(select true from ${events} where ${events.conversationId} = ${conversationId} and ${events.type} = 'authorization_requested' and ${events.createdAt} > ${start}::timestamptz limit 1)`;
|
|
1393
|
+
return sql`(coalesce(${recentRequest}, false) and coalesce((
|
|
1379
1394
|
select ${events.type} = 'authorization_requested'
|
|
1380
|
-
and ${events.createdAt} > ${
|
|
1395
|
+
and ${events.createdAt} > ${start}::timestamptz
|
|
1381
1396
|
and ${requester}
|
|
1382
1397
|
from ${events}
|
|
1383
1398
|
where ${events.conversationId} = ${conversationId}
|
|
1384
1399
|
and ${events.type} in (${sql.join(AUTHORIZATION_WAIT_EVENT_TYPES.map((type) => sql`${type}`), sql`, `)})
|
|
1385
1400
|
order by ${events.seq} desc
|
|
1386
1401
|
limit 1
|
|
1387
|
-
), false)`;
|
|
1402
|
+
), false))`;
|
|
1388
1403
|
}
|
|
1389
1404
|
/**
|
|
1390
1405
|
* SQL: the root or a child Conversation of `rootConversationId` waits on a
|
|
@@ -1440,6 +1455,7 @@ async function ensureConversationRow(executor, conversationId, atMs, options = {
|
|
|
1440
1455
|
const CONVERSATION_KINDS = /* @__PURE__ */ new Set([
|
|
1441
1456
|
"root",
|
|
1442
1457
|
"automation",
|
|
1458
|
+
"lead",
|
|
1443
1459
|
"thread",
|
|
1444
1460
|
"task"
|
|
1445
1461
|
]);
|
|
@@ -1499,7 +1515,9 @@ function conversationStarterUserIdSql(conversation) {
|
|
|
1499
1515
|
* `working`, not waiting. One of these applies:
|
|
1500
1516
|
*
|
|
1501
1517
|
* - The latest Turn failed.
|
|
1502
|
-
* - The latest Brief outcome is `partial` or `blocked
|
|
1518
|
+
* - The latest Brief outcome is `partial` or `blocked`, and that Brief
|
|
1519
|
+
* covers the latest assistant Message. Turns no longer store Briefs, so a
|
|
1520
|
+
* legacy Brief stops deciding once the Conversation moves on.
|
|
1503
1521
|
* - The latest assistant Message is an answer that the starter has not
|
|
1504
1522
|
* read. It is an answer when the latest Brief is `answered` or does not
|
|
1505
1523
|
* cover it. A `done` Brief that covers it needs no read. The starter read
|
|
@@ -1509,22 +1527,28 @@ function conversationStarterUserIdSql(conversation) {
|
|
|
1509
1527
|
*/
|
|
1510
1528
|
function conversationWaitsOnStarterSql(conversation) {
|
|
1511
1529
|
const id = conversation.conversationId;
|
|
1512
|
-
const
|
|
1513
|
-
const
|
|
1514
|
-
const
|
|
1515
|
-
const
|
|
1516
|
-
const
|
|
1517
|
-
const
|
|
1518
|
-
const
|
|
1530
|
+
const starter = sql.identifier("status_starter");
|
|
1531
|
+
const brief = sql.identifier("status_brief");
|
|
1532
|
+
const reply = sql.identifier("status_reply");
|
|
1533
|
+
const starterUserId = sql`${starter}.user_id`;
|
|
1534
|
+
const briefStatus = sql`${brief}.status`;
|
|
1535
|
+
const briefThroughSeq = sql`${brief}.through_seq`;
|
|
1536
|
+
const replySeq = sql`${reply}.seq`;
|
|
1537
|
+
const replyInSlack = sql`${reply}.in_slack`;
|
|
1538
|
+
const latestBrief = sql`(select ${juniorConversationBriefs.content}->'outcome'->>'status' as status, ${juniorConversationBriefs.throughSeq} as through_seq from ${juniorConversationBriefs} where ${eq(juniorConversationBriefs.conversationId, id)} order by ${desc(juniorConversationBriefs.version)} limit 1)`;
|
|
1539
|
+
const latestReply = sql`(select ${juniorConversationEvents.seq} as seq, coalesce(${juniorConversationEvents.payload}->'meta'->>'source' = 'slack', ${juniorConversationEvents.createdAt} < ${DELIVERY_PAUSE_START}) as in_slack from ${juniorConversationEvents} where ${and(eq(juniorConversationEvents.conversationId, id), eq(juniorConversationEvents.type, "message"), sql`${juniorConversationEvents.payload}->>'role' = 'assistant'`)} order by ${desc(juniorConversationEvents.seq)} limit 1)`;
|
|
1519
1540
|
const readByStarter = or(and(sql`${conversation.parentConversationId} is null`, sql`${conversation.location} is not null`, sql`coalesce(${replyInSlack}, false)`), sql`exists (select 1 from ${juniorConversationEvents} join ${juniorIdentities} as ${replyReader} on ${eq(replyReader.id, juniorConversationEvents.actorIdentityId)} where ${and(eq(juniorConversationEvents.conversationId, id), eq(juniorConversationEvents.type, "message"), gt(juniorConversationEvents.seq, replySeq), eq(replyReader.userId, starterUserId))})`, sql`exists (select 1 from ${juniorConversationReadPositions} where ${and(eq(juniorConversationReadPositions.conversationId, id), eq(juniorConversationReadPositions.userId, starterUserId), gte(juniorConversationReadPositions.lastReadSeq, replySeq))})`);
|
|
1520
1541
|
const unreadAnswer = sql`${replySeq} is not null and ${starterUserId} is not null and (coalesce(${briefStatus}, 'answered') = 'answered' or ${briefThroughSeq} < ${replySeq}) and not (${readByStarter})`;
|
|
1542
|
+
const waitsOnFacts = sql`(select (${briefStatus} in ('partial', 'blocked') and (${replySeq} is null or ${briefThroughSeq} >= ${replySeq})) or (${unreadAnswer})
|
|
1543
|
+
from (select ${conversationStarterUserIdSql(conversation)} as user_id offset 0) as ${starter}
|
|
1544
|
+
left join lateral ${latestBrief} as ${brief} on true
|
|
1545
|
+
left join lateral ${latestReply} as ${reply} on true)`;
|
|
1521
1546
|
return sql`(${conversation.stoppedAt} is null
|
|
1522
1547
|
and ${conversationKindSql(conversation)} <> 'task'
|
|
1523
1548
|
and not ${conversationIsActiveSql(conversation)}
|
|
1524
1549
|
and (
|
|
1525
1550
|
${conversationTurnFailedSql(conversation)}
|
|
1526
|
-
or ${
|
|
1527
|
-
or (${unreadAnswer})
|
|
1551
|
+
or ${waitsOnFacts}
|
|
1528
1552
|
))`;
|
|
1529
1553
|
}
|
|
1530
1554
|
/**
|
|
@@ -1532,7 +1556,7 @@ function conversationWaitsOnStarterSql(conversation) {
|
|
|
1532
1556
|
* This is the only place that derives it; readers, counts, and feed tokens
|
|
1533
1557
|
* select it. When more than one applies: `needs_input` > `working` > `done`.
|
|
1534
1558
|
*
|
|
1535
|
-
* - `needs_input`: an open action
|
|
1559
|
+
* - `needs_input`: an open action Inbox item that this Conversation added
|
|
1536
1560
|
* waits on its assignees or Everyone, a Turn waits on a person to sign in
|
|
1537
1561
|
* (`awaitsAuthorization`), or the work waits on its starter
|
|
1538
1562
|
* (`conversationWaitsOnStarterSql`).
|
|
@@ -1541,7 +1565,7 @@ function conversationWaitsOnStarterSql(conversation) {
|
|
|
1541
1565
|
* or an idle Conversation.
|
|
1542
1566
|
*/
|
|
1543
1567
|
function conversationStatusSql(conversation) {
|
|
1544
|
-
const needsInput = sql`exists (select 1 from ${
|
|
1568
|
+
const needsInput = sql`exists (select 1 from ${juniorInboxItems} where ${and(inboxItemOwnedByConversation(conversation.conversationId), inboxItemNeedsInput())})`;
|
|
1545
1569
|
return sql`case
|
|
1546
1570
|
when ${needsInput} or ${awaitsAuthorization(conversation.conversationId)} or ${conversationWaitsOnStarterSql(conversation)} then 'needs_input'
|
|
1547
1571
|
when ${conversationIsActiveSql(conversation)} then 'working'
|
|
@@ -2044,6 +2068,7 @@ const ROOT = {
|
|
|
2044
2068
|
gated: false,
|
|
2045
2069
|
failureNotice: "none",
|
|
2046
2070
|
sessionTasks: true,
|
|
2071
|
+
relatedConversations: true,
|
|
2047
2072
|
tools: {
|
|
2048
2073
|
agents: "children",
|
|
2049
2074
|
inbox: true,
|
|
@@ -2054,11 +2079,16 @@ const ROOT = {
|
|
|
2054
2079
|
noReply: true
|
|
2055
2080
|
}
|
|
2056
2081
|
};
|
|
2082
|
+
const ROOT_RUNTIME_TURN = {
|
|
2083
|
+
...ROOT,
|
|
2084
|
+
relatedConversations: false
|
|
2085
|
+
};
|
|
2057
2086
|
const PERSON_IN_THREAD = {
|
|
2058
2087
|
...ROOT,
|
|
2059
2088
|
promptMode: "thread",
|
|
2060
2089
|
sender: "person",
|
|
2061
2090
|
sessionTasks: false,
|
|
2091
|
+
relatedConversations: false,
|
|
2062
2092
|
tools: {
|
|
2063
2093
|
...ROOT.tools,
|
|
2064
2094
|
agents: "none"
|
|
@@ -2072,6 +2102,7 @@ const CHILD_AGENT_TURN = {
|
|
|
2072
2102
|
gated: true,
|
|
2073
2103
|
failureNotice: "none",
|
|
2074
2104
|
sessionTasks: false,
|
|
2105
|
+
relatedConversations: false,
|
|
2075
2106
|
tools: {
|
|
2076
2107
|
agents: "children_and_parent",
|
|
2077
2108
|
inbox: false,
|
|
@@ -2107,6 +2138,7 @@ const AUTOMATION_RUN = {
|
|
|
2107
2138
|
gated: true,
|
|
2108
2139
|
failureNotice: "none",
|
|
2109
2140
|
sessionTasks: true,
|
|
2141
|
+
relatedConversations: false,
|
|
2110
2142
|
tools: {
|
|
2111
2143
|
...ROOT.tools,
|
|
2112
2144
|
reply: "automation",
|
|
@@ -2116,15 +2148,47 @@ const AUTOMATION_RUN = {
|
|
|
2116
2148
|
const PERSON_IN_AUTOMATION = {
|
|
2117
2149
|
...ROOT,
|
|
2118
2150
|
promptMode: "automation",
|
|
2119
|
-
sender: "person"
|
|
2151
|
+
sender: "person",
|
|
2152
|
+
relatedConversations: false
|
|
2153
|
+
};
|
|
2154
|
+
const LEAD_TOOLS = [
|
|
2155
|
+
"startConversation",
|
|
2156
|
+
"messageAgent",
|
|
2157
|
+
"searchConversations",
|
|
2158
|
+
"searchConversationEvents",
|
|
2159
|
+
"readConversationEvent",
|
|
2160
|
+
"searchInboxItems",
|
|
2161
|
+
"searchEventTypes",
|
|
2162
|
+
"watchEvents",
|
|
2163
|
+
"watchTimer",
|
|
2164
|
+
"listWatches",
|
|
2165
|
+
"stopWatchingResources",
|
|
2166
|
+
"systemTime",
|
|
2167
|
+
"updateUserCustomization",
|
|
2168
|
+
"noReply"
|
|
2169
|
+
];
|
|
2170
|
+
const LEAD = {
|
|
2171
|
+
...ROOT,
|
|
2172
|
+
promptMode: "lead",
|
|
2173
|
+
sessionTasks: false,
|
|
2174
|
+
tools: {
|
|
2175
|
+
...ROOT.tools,
|
|
2176
|
+
agents: "lead",
|
|
2177
|
+
subscriptions: false,
|
|
2178
|
+
only: LEAD_TOOLS
|
|
2179
|
+
}
|
|
2120
2180
|
};
|
|
2121
2181
|
/** Return the behavior of one Turn. */
|
|
2122
2182
|
function turnBehavior(args) {
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2183
|
+
switch (args.kind) {
|
|
2184
|
+
case "root": return args.personInput ? ROOT : ROOT_RUNTIME_TURN;
|
|
2185
|
+
case "automation": return args.personInput ? PERSON_IN_AUTOMATION : AUTOMATION_RUN;
|
|
2186
|
+
case "thread": return args.personInput ? PERSON_IN_THREAD : AGENT_IN_THREAD;
|
|
2187
|
+
case "task":
|
|
2188
|
+
if (!args.personInput) return AGENT_IN_TASK;
|
|
2189
|
+
throw new Error("A task Conversation cannot have a person's input");
|
|
2190
|
+
case "lead": return LEAD;
|
|
2191
|
+
}
|
|
2128
2192
|
}
|
|
2129
2193
|
/**
|
|
2130
2194
|
* Return the tools that every Turn of one Prompt mode lists. A Turn of a mode
|
|
@@ -2132,14 +2196,31 @@ function turnBehavior(args) {
|
|
|
2132
2196
|
* cannot use are disabled.
|
|
2133
2197
|
*/
|
|
2134
2198
|
function promptModeTurnTools(mode) {
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2199
|
+
switch (mode) {
|
|
2200
|
+
case "automation": return AUTOMATION_RUN.tools;
|
|
2201
|
+
case "child_agent": return AGENT_IN_TASK.tools;
|
|
2202
|
+
case "thread": return THREAD_TOOLS;
|
|
2203
|
+
case "conversation": return ROOT.tools;
|
|
2204
|
+
case "lead": return LEAD.tools;
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
/**
|
|
2208
|
+
* Return whether Turns update the Conversation metadata of this kind. Only
|
|
2209
|
+
* its parent reads a Task, so a Task has no summary.
|
|
2210
|
+
*/
|
|
2211
|
+
function hasConversationMetadata(kind) {
|
|
2212
|
+
return kind !== "task";
|
|
2139
2213
|
}
|
|
2140
2214
|
/** Return whether a Conversation of this kind has no parent. */
|
|
2141
2215
|
function isTopLevelKind(kind) {
|
|
2142
|
-
return kind === "root" || kind === "automation";
|
|
2216
|
+
return kind === "root" || kind === "automation" || kind === "lead";
|
|
2217
|
+
}
|
|
2218
|
+
/**
|
|
2219
|
+
* Return whether a Watch on this Conversation would repeat what already
|
|
2220
|
+
* reaches the watcher: a child agent's results and messages go to its parent.
|
|
2221
|
+
*/
|
|
2222
|
+
function watchRepeatsChildResults(target, watcherConversationId) {
|
|
2223
|
+
return target.parentConversationId === watcherConversationId;
|
|
2143
2224
|
}
|
|
2144
2225
|
/** Return whether a person sent input from this Source. */
|
|
2145
2226
|
function isPersonInput(source) {
|
|
@@ -2320,6 +2401,7 @@ function conversationFromRow(readRow) {
|
|
|
2320
2401
|
...source ? { source } : void 0,
|
|
2321
2402
|
...sessionSource ? { sessionSource } : void 0,
|
|
2322
2403
|
...row.title ? { title: row.title } : void 0,
|
|
2404
|
+
...row.summary ? { summary: row.summary } : void 0,
|
|
2323
2405
|
...msFromDate(row.transcriptPurgedAt) !== void 0 ? { transcriptPurgedAtMs: msFromDate(row.transcriptPurgedAt) } : void 0,
|
|
2324
2406
|
...msFromDate(row.stoppedAt) !== void 0 ? { stoppedAtMs: msFromDate(row.stoppedAt) } : void 0,
|
|
2325
2407
|
...msFromDate(row.deliveryPausedAt) !== void 0 ? { deliveryPausedAtMs: msFromDate(row.deliveryPausedAt) } : void 0,
|
|
@@ -3249,7 +3331,8 @@ var SqlConversationEventStore = class {
|
|
|
3249
3331
|
await db.with(conversationDetailTouch(db, [conversationId])).insert(juniorConversationEvents).values(insertFromEvent(conversationId, cursor.nextSeq, historyVersion, parsed));
|
|
3250
3332
|
return {
|
|
3251
3333
|
status: "replaced",
|
|
3252
|
-
historyVersion
|
|
3334
|
+
historyVersion,
|
|
3335
|
+
seq: cursor.nextSeq
|
|
3253
3336
|
};
|
|
3254
3337
|
});
|
|
3255
3338
|
}
|
|
@@ -3523,4 +3606,4 @@ async function closeDb() {
|
|
|
3523
3606
|
current = void 0;
|
|
3524
3607
|
await previous?.db.close();
|
|
3525
3608
|
}
|
|
3526
|
-
export {
|
|
3609
|
+
export { conversationWaitsOnUserSql as $, resolveActorIdentityId as $t, isTopLevelKind as A, agentTurnTotalTokens as An, activeParticipantUserIds as At, claimProviderConversation as B, requireSlackDestination as Bn, readIdentityByIdFromSql as Bt, createSqlStore as C, conversationIsNotUnsubscribedRoot as Cn, isOnlyAssignee as Ct, hasConversationMetadata as D, viewerMarksFromParticipant as Dn, requireInboxItemAssignees as Dt, dispatchInstructionsInvokeSkills as E, rootVisibleToViewer as En, readInboxItemAgentScope as Et, turnBehavior as F, conversationDetailTouch as Fn, findUserByEmailFromSql as Ft, microUsdToUsd as G, hasUserPhoto as Gt, parseSessionSource as H, resolveViewerUser as Ht, watchRepeatsChildResults as I, nextDetailVersion as In, listAdminUsersFromSql as It, conversationRangeColumns as J, readAvatarFetch as Jt, usdToMicroUsd as K, identityAvatarUrl as Kt, locationFromRow as L, touchConversationDetail as Ln, readActorIdentity as Lt, postsRunNotices as M, hasAgentTurnUsage as Mn, resolveAssignee as Mt, promptModeTurnTools as N, resolveRootConversationId as Nn, resolveAssignees as Nt, isPersonInput as O, addAgentTurnUsage as On, requireInboxItemLinks as Ot, sourceLabel as P, rootConversationIsArchived as Pn, findUserByEmail as Pt, conversationTurnFailedSql as Q, SYSTEM_IDENTITY_ID as Qt, setFirstConversationLocation as R, createSlackDestination as Rn, readActorIdentityFromSql as Rt, userMessageQueries as S, conversationIsMemberRoot as Sn, isAutomationAlertItem as St, deliversFinalText as T, readMemberParticipants as Tn, itemNeedsUser as Tt, conversationCostOf as U, setUserAdminFromSql as Ut, getConversationIdByProviderConversation as V, sameDestination as Vn, readViewerAvatarUrl as Vt, microUsdSql as W, updateViewerDisplayName as Wt, conversationIsActiveSql as X, userAvatarUrlsFromIdentities as Xt, conversationUsageCostExpr as Y, readUserAvatarUrls as Yt, conversationStatusSql as Z, userAvatarUrlsFromJoinedPhotos as Zt, readConversationTrees as _, conversationAccessFromRows as _n, inboxItemOwnedByConversation as _t, getConversationStore as a, findUserByVerifiedEmails as an, AUTOMATION_INBOX_ITEM_KEY_PREFIX as at, loadConversationSlackTenantIds as b, readConversationAccessRows as bn, inboxItemReaderForUserInConversation as bt, hasAnnotationKey as c, recordGoogleSignIn as cn, canAgentChangeInboxItem as ct, eventFromRow as d, readCachedUserByEmail as dn, inboxItemAssignedTo as dt, saveActorAvatar as en, executionIsActive as et, copyMessageLinks as f, ToolInputError as fn, inboxItemForUser as ft, conversationDescendants as g, canReadConversation as gn, inboxItemNeedsUser as gt, conversationAncestors as h, canAddConversationMessages as hn, inboxItemNeedsSomeone as ht, getConversationMessageSearchStore as i, findSlackUserByPrimaryEmail as in, treeAwaitsAuthorization as it, personSourcePlatform as j, agentTurnUsageSchema as jn, automationCreatorUserId as jt, isPersonSource as k, agentTurnCostUsd as kn, EVERYONE_ASSIGNEE as kt, treeHasAnnotationKey as l, saveUserTimezone as ln, canReadInboxItem as lt, withConversationEventLock as m, canAccessConversation as mn, inboxItemNeedsInput as mt, db_exports as n, deleteProviderIdentityForUser as nn, conversationKindSql as nt, getDb as o, linkedSlackUser as on, PLUGIN_INBOX_ITEM_KEY_PREFIX as ot, deleteMessageLinks as p, isToolInputError as pn, inboxItemLinkedTo as pt, conversationAggregateColumns as q, parseAvatarUrl as qt, getConversationEventStore as r, findLinkedSlackUser as rn, awaitsAuthorizationFrom as rt, getSqlExecutor as s, readUserTimezone as sn, canActOnInboxItem as st, closeDb as t, deleteProviderIdentityForSlackUser as tn, conversationKindFromRow as tt, createSqlConversationEventStore as u, upsertLinkedIdentity as un, canUserReadInboxItem as ut, setArchivedAt as v, createConversationAccessReader as vn, inboxItemPlugin as vt, withConversationMutationLock as w, conversationPinnedForUser as wn, isPluginInboxItem as wt, lastMessageAtSql as x, readableSlackTeamId as xn, inboxItemVisibleTo as xt, conversationSlackTenantId as y, readConversationAccessFromSql as yn, inboxItemReaderForUser as yt, startLocationThread as z, parseDestination as zn, readIdentityById as zt };
|