@segmentstream/ontology 0.151.0 → 0.153.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/README.md +2 -2
- package/dist/agent-chat.d.ts +6 -1
- package/dist/agent-chat.js +9 -6
- package/dist/analyze.d.ts +14 -0
- package/dist/analyze.js +31 -11
- package/dist/chat.d.ts +17 -3
- package/dist/chat.js +17 -1
- package/dist/files.d.ts +7 -0
- package/dist/files.js +7 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/manifest.d.ts +243 -51
- package/dist/manifest.js +27 -5
- package/dist/migrate/model.d.ts +156 -36
- package/dist/runtime/chat-messages.d.ts +7 -2
- package/dist/runtime/chat-messages.js +41 -14
- package/dist/service/chat/delivery.js +3 -1
- package/dist/service/chat/history-import.d.ts +19 -5
- package/dist/service/chat/history-import.js +183 -8
- package/dist/service/schemas.d.ts +30 -0
- package/dist/storage/attachments.d.ts +40 -9
- package/dist/storage/attachments.js +185 -21
- package/dist/storage/sessions.js +16 -8
- package/dist/storage/tables.d.ts +2 -1
- package/dist/storage/tables.js +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.153.0
|
|
4
|
+
|
|
5
|
+
An email channel with `record: "all"` takes the mailbox's chats into the inbox. A verified sender's chat that has no member joins the inbox without members when the ontology's `inbox.channels` lists the channel, which may now name an email channel. Mail that failed DMARC never joins. Mail staff send from the mailbox is recorded in each recipient's chat, including a chat the agent has none of yet, when `recordQuery`, if any, finds it.
|
|
6
|
+
|
|
7
|
+
## 0.152.0
|
|
8
|
+
|
|
9
|
+
`agent_chat.importHistory` writes a chat's earlier history into the workspace's own database once
|
|
10
|
+
it holds the agent's messages. Each message joins the chat in its place by its time, among the
|
|
11
|
+
messages the agent recorded, so history that overlaps what the chat holds imports as it is: a
|
|
12
|
+
message the chat already holds, by its id, is a duplicate, and importing again adds nothing. The
|
|
13
|
+
rule that only messages at least 15 minutes older than the chat's oldest are added holds only while
|
|
14
|
+
the history still goes to the platform's chat archive, before the workspace's database holds a
|
|
15
|
+
message; there `skipped` counts them, and in the workspace's database it is always 0.
|
|
16
|
+
|
|
17
|
+
An imported message may carry files: `files: [{ upload: <ticket> }]`, each a completed upload begun
|
|
18
|
+
with `files_upload` for `entity: "agent_chat"`, `action: "import_history"` and `property: "files"`
|
|
19
|
+
(or `Files.stage` with `target: { entity: "agent_chat", property: "files" }` in a workflow step), up
|
|
20
|
+
to 20 MB a file, 10 a message and 50 a call. Each file becomes one of the chat's stored attachments
|
|
21
|
+
without its bytes being copied, listed in the message's `files`; a private chat's files are its
|
|
22
|
+
person's, as the files they send are. A message's `text` is now optional when it has files. The
|
|
23
|
+
upload of a message not imported, a duplicate or an expired one, is released. The platform's chat
|
|
24
|
+
archive takes no files, so an import with files is refused until the history goes to the
|
|
25
|
+
workspace's database.
|
|
26
|
+
|
|
27
|
+
A chat channel keeps its chats' files as long as their messages with
|
|
28
|
+
`chat: { whatsapp: { connection: whatsapp, files: { keep: true } } }`: a file the agent receives
|
|
29
|
+
there, and a file imported with a chat's history, then expires `chat.retentionDays` after its
|
|
30
|
+
message instead of 24 hours after it arrives. The manifest carries `files: { keep: true }` on the
|
|
31
|
+
channel only when declared. A member may still receive 50 attachments a day. A message deleted at
|
|
32
|
+
its provider now discards the stored files it held, on every channel.
|
|
33
|
+
|
|
34
|
+
A member whose `agent_chat:read`, within its scope, holds a chat's record downloads and lists that
|
|
35
|
+
chat's files with `attachments_download`, `attachments_get` and `attachments_list` (`chat`), as they
|
|
36
|
+
read its messages: staff working the inbox see the files of the chats they read.
|
|
37
|
+
|
|
38
|
+
The agent never shows a running session history imported after its bookmark in the workspace's
|
|
39
|
+
database, and a session's first turn reads the chat's newest messages in the order of their time,
|
|
40
|
+
imported history among them.
|
|
41
|
+
|
|
3
42
|
## 0.151.0
|
|
4
43
|
|
|
5
44
|
`inbox` takes `channels`: the WhatsApp and workspace channels `chat` declares whose chats with
|
package/README.md
CHANGED
|
@@ -1537,8 +1537,8 @@ deletes the old one. `provider`, `externalId`, `title` and `lastMessageAt` are
|
|
|
1537
1537
|
managed. Members set `purpose` and `whenToUse` with the generated
|
|
1538
1538
|
`agent_chat.update`, the chat's only generated action, which sets no relationship: `handledBy`
|
|
1539
1539
|
changes only through `agent_chat.takeOver` and `agent_chat.handBack`. `agent_chat.importHistory`
|
|
1540
|
-
adds a chat's messages from before the agent recorded it
|
|
1541
|
-
`agent_chat:import_history`. Chat read/update permissions remain
|
|
1540
|
+
adds a chat's messages from before the agent recorded it, each in its place by its time and once by
|
|
1541
|
+
its id, with their files as the chat's attachments, for a caller with `agent_chat:import_history`. Chat read/update permissions remain
|
|
1542
1542
|
`agent_chat:read` and `agent_chat:update`, granted explicitly; wildcard entity grants do not
|
|
1543
1543
|
cover this built-in registry.
|
|
1544
1544
|
|
package/dist/agent-chat.d.ts
CHANGED
|
@@ -54,8 +54,13 @@ export declare const AgentChat: import("./entity.js").Entity<"agent_chat", {
|
|
|
54
54
|
readonly direction: Schema.Literals<readonly ["inbound", "outbound"]>;
|
|
55
55
|
readonly by: Schema.optionalKey<Schema.Literals<readonly ["human", "agent", "bot"]>>;
|
|
56
56
|
readonly name: Schema.optionalKey<Schema.String>;
|
|
57
|
-
readonly text: Schema.String
|
|
57
|
+
readonly text: Schema.optionalKey<Schema.String>;
|
|
58
58
|
readonly replyTo: Schema.optionalKey<Schema.String>;
|
|
59
|
+
readonly files: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
60
|
+
readonly upload: Schema.Struct<{
|
|
61
|
+
readonly uploadId: Schema.String;
|
|
62
|
+
}>;
|
|
63
|
+
}>>>;
|
|
59
64
|
}>>;
|
|
60
65
|
}>, {
|
|
61
66
|
readonly imported: number;
|
package/dist/agent-chat.js
CHANGED
|
@@ -199,12 +199,15 @@ export const AgentChat = entity("agent_chat", {
|
|
|
199
199
|
}),
|
|
200
200
|
importHistory: action({
|
|
201
201
|
description: "Import a chat's messages from before the agent recorded it, such as a client's earlier " +
|
|
202
|
-
"conversation kept elsewhere:
|
|
203
|
-
"next session of the chat, the inbox and chat search read as history. Name the chat
|
|
204
|
-
"agent_chat record, or by channel and chatId as the channel keys it.
|
|
205
|
-
"
|
|
206
|
-
"
|
|
207
|
-
"
|
|
202
|
+
"conversation kept elsewhere: each joins the chat in its place by its time, which the " +
|
|
203
|
+
"agent's next session of the chat, the inbox and chat search read as history. Name the chat " +
|
|
204
|
+
"by its agent_chat record, or by channel and chatId as the channel keys it. A message the " +
|
|
205
|
+
"chat already holds, by id, is a duplicate, so importing again adds nothing, and history " +
|
|
206
|
+
"that overlaps what the chat recorded adds only what it lacks. A message's files are " +
|
|
207
|
+
"completed uploads, from files_upload with entity agent_chat, action import_history and " +
|
|
208
|
+
"property files, given as files: [{ upload: <ticket> }]. Up to 500 messages and 50 files " +
|
|
209
|
+
"a call. Nothing is sent and no turn starts. Until the chat store holds the agent's " +
|
|
210
|
+
"messages, only text older than the chat's oldest message is added.",
|
|
208
211
|
input: ChatHistoryImportInput,
|
|
209
212
|
hints: { destructive: false, irreversible: true, idempotent: true },
|
|
210
213
|
connections: [],
|
package/dist/analyze.d.ts
CHANGED
|
@@ -267,6 +267,16 @@ export interface Analysis {
|
|
|
267
267
|
export interface ChatChannelConfig {
|
|
268
268
|
readonly kind?: ChatKind;
|
|
269
269
|
readonly connection?: AnyConnectionHandle;
|
|
270
|
+
/**
|
|
271
|
+
* What the channel's chats keep of their files. With `keep: true`, a file a message of the
|
|
272
|
+
* channel holds, received by the agent or imported with `agent_chat.importHistory`, is kept as
|
|
273
|
+
* long as the chat's messages (`retentionDays`); otherwise it expires 24 hours after it arrives.
|
|
274
|
+
*/
|
|
275
|
+
readonly files?: ChatFilesConfig;
|
|
276
|
+
}
|
|
277
|
+
/** `files` of a chat channel: whether its chats keep their files with their messages. */
|
|
278
|
+
export interface ChatFilesConfig {
|
|
279
|
+
readonly keep?: boolean;
|
|
270
280
|
}
|
|
271
281
|
/**
|
|
272
282
|
* `chat` of {@link OntologyConfig}: the agent's channels by name, the post attribution, and how
|
|
@@ -275,15 +285,19 @@ export interface ChatChannelConfig {
|
|
|
275
285
|
export interface ChatConfig {
|
|
276
286
|
readonly telegram?: {
|
|
277
287
|
readonly connection: AnyConnectionHandle;
|
|
288
|
+
readonly files?: ChatFilesConfig;
|
|
278
289
|
};
|
|
279
290
|
readonly slack?: {
|
|
280
291
|
readonly connection: AnyConnectionHandle;
|
|
292
|
+
readonly files?: ChatFilesConfig;
|
|
281
293
|
};
|
|
282
294
|
readonly whatsapp?: {
|
|
283
295
|
readonly connection: AnyConnectionHandle;
|
|
296
|
+
readonly files?: ChatFilesConfig;
|
|
284
297
|
};
|
|
285
298
|
readonly email?: {
|
|
286
299
|
readonly connection: AnyConnectionHandle;
|
|
300
|
+
readonly files?: ChatFilesConfig;
|
|
287
301
|
};
|
|
288
302
|
readonly attribution?: ChatAttributionSettings;
|
|
289
303
|
/**
|
package/dist/analyze.js
CHANGED
|
@@ -47,7 +47,11 @@ const RESERVED_CHAT_NAMES = new Set(["web", "task", WORKSPACE_CHANNEL_KIND]);
|
|
|
47
47
|
/** The keys of `chat` that are settings, not channels. */
|
|
48
48
|
const CHAT_SETTINGS = new Set(["attribution", "retentionDays"]);
|
|
49
49
|
/** The kinds of channel whose agent records every message it receives, when asked to. */
|
|
50
|
-
const INBOX_CHANNEL_KINDS = new Set([
|
|
50
|
+
const INBOX_CHANNEL_KINDS = new Set([
|
|
51
|
+
"whatsapp",
|
|
52
|
+
"email",
|
|
53
|
+
WORKSPACE_CHANNEL_KIND,
|
|
54
|
+
]);
|
|
51
55
|
/** Whether `chat` declares a channel of `kind`: the one named after it, or another of the kind. */
|
|
52
56
|
function declaresChatKind(chat, kind) {
|
|
53
57
|
return (isPlainObject(chat) &&
|
|
@@ -187,7 +191,11 @@ export function analyze(config, options = {}) {
|
|
|
187
191
|
const malformed = entries.find(([name, value]) => {
|
|
188
192
|
const named = !CHAT_PROVIDER_KEYS.includes(name);
|
|
189
193
|
return (!isPlainObject(value) ||
|
|
190
|
-
Object.keys(value).some((key) => key !== "connection" && key !== "kind") ||
|
|
194
|
+
Object.keys(value).some((key) => key !== "connection" && key !== "kind" && key !== "files") ||
|
|
195
|
+
(value.files !== undefined &&
|
|
196
|
+
(!isPlainObject(value.files) ||
|
|
197
|
+
Object.keys(value.files).some((key) => key !== "keep") ||
|
|
198
|
+
(value.files.keep !== undefined && typeof value.files.keep !== "boolean"))) ||
|
|
191
199
|
// A workspace channel has no connection here: the agent sends through it, with the
|
|
192
200
|
// connection agent/segmentstream.json gives it. Every other channel sends through its own.
|
|
193
201
|
(value.kind === WORKSPACE_CHANNEL_KIND
|
|
@@ -199,9 +207,16 @@ export function analyze(config, options = {}) {
|
|
|
199
207
|
const channels = malformed === undefined && unknown === undefined
|
|
200
208
|
? entries.map(([name, value]) => {
|
|
201
209
|
const entry = value;
|
|
202
|
-
return [
|
|
210
|
+
return [
|
|
211
|
+
name,
|
|
212
|
+
entry.connection,
|
|
213
|
+
entry.kind ?? name,
|
|
214
|
+
entry.files?.keep === true,
|
|
215
|
+
];
|
|
203
216
|
})
|
|
204
217
|
: [];
|
|
218
|
+
// Written only for a channel that keeps its files: older readers keep none.
|
|
219
|
+
const keptFiles = (keep) => (keep ? { files: { keep: true } } : {});
|
|
205
220
|
const handles = channels.flatMap(([name, handle, kind]) => handle === undefined ? [] : [[name, handle, kind]]);
|
|
206
221
|
const unlisted = handles.find(([, handle]) => !(config.connections ?? []).includes(handle));
|
|
207
222
|
const shared = handles.find(([, handle], index) => handles.findIndex(([, other]) => other === handle) !== index);
|
|
@@ -213,7 +228,8 @@ export function analyze(config, options = {}) {
|
|
|
213
228
|
else if (malformed !== undefined) {
|
|
214
229
|
report("invalid-connection", "chat", `chat.${malformed}.connection must reference a declared connection handle, and a ` +
|
|
215
230
|
`channel not named after its kind needs kind: ${CHAT_KINDS.join(", ")}; a ` +
|
|
216
|
-
`${WORKSPACE_CHANNEL_KIND} channel takes none, as the agent sends through it
|
|
231
|
+
`${WORKSPACE_CHANNEL_KIND} channel takes none, as the agent sends through it. ` +
|
|
232
|
+
`files takes keep, true or false.`);
|
|
217
233
|
}
|
|
218
234
|
else if (unlisted !== undefined) {
|
|
219
235
|
report("invalid-connection", `chat.${unlisted[0]}.connection`, "The chat channel connection must be listed in connections.");
|
|
@@ -224,15 +240,19 @@ export function analyze(config, options = {}) {
|
|
|
224
240
|
else if (channels.length > 0) {
|
|
225
241
|
const named = channels.filter(([name]) => !CHAT_PROVIDER_KEYS.includes(name));
|
|
226
242
|
chat = {
|
|
227
|
-
...Object.fromEntries(
|
|
243
|
+
...Object.fromEntries(channels
|
|
228
244
|
.filter(([name]) => CHAT_PROVIDER_KEYS.includes(name))
|
|
229
|
-
.
|
|
245
|
+
.flatMap(([name, handle, , keep]) => handle === undefined ? [] : [[name, { connection: handle.key, ...keptFiles(keep) }]])),
|
|
230
246
|
...(named.length === 0
|
|
231
247
|
? {}
|
|
232
248
|
: {
|
|
233
|
-
channels: Object.fromEntries(named.map(([name, handle, kind]) => [
|
|
249
|
+
channels: Object.fromEntries(named.map(([name, handle, kind, keep]) => [
|
|
234
250
|
name,
|
|
235
|
-
{
|
|
251
|
+
{
|
|
252
|
+
kind,
|
|
253
|
+
...(handle === undefined ? {} : { connection: handle.key }),
|
|
254
|
+
...keptFiles(keep),
|
|
255
|
+
},
|
|
236
256
|
])),
|
|
237
257
|
}),
|
|
238
258
|
...(config.chat.attribution === undefined ? {} : { attribution: config.chat.attribution }),
|
|
@@ -437,7 +457,7 @@ recordingChannels, report) {
|
|
|
437
457
|
}
|
|
438
458
|
/**
|
|
439
459
|
* `inbox.channels`: the channels whose chats with people who are no users join the inbox, each a
|
|
440
|
-
* WhatsApp or workspace channel `chat` declares, as only their agent records the messages of
|
|
460
|
+
* WhatsApp, email or workspace channel `chat` declares, as only their agent records the messages of
|
|
441
461
|
* people it does not answer; none when absent.
|
|
442
462
|
*/
|
|
443
463
|
function inboxChannels(value, recordingChannels, report) {
|
|
@@ -448,8 +468,8 @@ function inboxChannels(value, recordingChannels, report) {
|
|
|
448
468
|
let valid = true;
|
|
449
469
|
value.forEach((candidate, index) => {
|
|
450
470
|
if (typeof candidate !== "string" || !recordingChannels.includes(candidate)) {
|
|
451
|
-
report("invalid-inbox", `inbox.channels[${index}]`, "Use a WhatsApp or workspace channel chat declares: only their agent records
|
|
452
|
-
'messages of people it does not answer, with record: "all".');
|
|
471
|
+
report("invalid-inbox", `inbox.channels[${index}]`, "Use a WhatsApp, email or workspace channel chat declares: only their agent records " +
|
|
472
|
+
'the messages of people it does not answer, with record: "all".');
|
|
453
473
|
valid = false;
|
|
454
474
|
}
|
|
455
475
|
else if (!channels.includes(candidate)) {
|
package/dist/chat.d.ts
CHANGED
|
@@ -149,6 +149,8 @@ export interface ChatPreview {
|
|
|
149
149
|
}
|
|
150
150
|
export declare const chatOperationId: (sessionId: string, callId: string) => string;
|
|
151
151
|
export declare const chatPreviewDigest: (preview: ChatPreview) => string;
|
|
152
|
+
/** The most files one imported message carries. */
|
|
153
|
+
export declare const CHAT_HISTORY_MESSAGE_FILES = 10;
|
|
152
154
|
/** One message of a chat from before the agent's archive recorded it, as the workspace kept it. */
|
|
153
155
|
export declare const ChatHistoryMessage: Schema.Struct<{
|
|
154
156
|
readonly id: Schema.String;
|
|
@@ -156,12 +158,19 @@ export declare const ChatHistoryMessage: Schema.Struct<{
|
|
|
156
158
|
readonly direction: Schema.Literals<readonly ["inbound", "outbound"]>;
|
|
157
159
|
readonly by: Schema.optionalKey<Schema.Literals<readonly ["human", "agent", "bot"]>>;
|
|
158
160
|
readonly name: Schema.optionalKey<Schema.String>;
|
|
159
|
-
readonly text: Schema.String
|
|
161
|
+
readonly text: Schema.optionalKey<Schema.String>;
|
|
160
162
|
readonly replyTo: Schema.optionalKey<Schema.String>;
|
|
163
|
+
readonly files: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
164
|
+
readonly upload: Schema.Struct<{
|
|
165
|
+
readonly uploadId: Schema.String;
|
|
166
|
+
}>;
|
|
167
|
+
}>>>;
|
|
161
168
|
}>;
|
|
162
169
|
export type ChatHistoryMessage = typeof ChatHistoryMessage.Type;
|
|
163
170
|
/** The most messages one import takes. */
|
|
164
171
|
export declare const CHAT_HISTORY_MESSAGES = 500;
|
|
172
|
+
/** The most files one import takes, of all its messages together. */
|
|
173
|
+
export declare const CHAT_HISTORY_FILES = 50;
|
|
165
174
|
export declare const ChatHistoryImportInput: Schema.Struct<{
|
|
166
175
|
readonly chat: Schema.optionalKey<Schema.String>;
|
|
167
176
|
readonly channel: Schema.optionalKey<Schema.String>;
|
|
@@ -175,8 +184,13 @@ export declare const ChatHistoryImportInput: Schema.Struct<{
|
|
|
175
184
|
readonly direction: Schema.Literals<readonly ["inbound", "outbound"]>;
|
|
176
185
|
readonly by: Schema.optionalKey<Schema.Literals<readonly ["human", "agent", "bot"]>>;
|
|
177
186
|
readonly name: Schema.optionalKey<Schema.String>;
|
|
178
|
-
readonly text: Schema.String
|
|
187
|
+
readonly text: Schema.optionalKey<Schema.String>;
|
|
179
188
|
readonly replyTo: Schema.optionalKey<Schema.String>;
|
|
189
|
+
readonly files: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
190
|
+
readonly upload: Schema.Struct<{
|
|
191
|
+
readonly uploadId: Schema.String;
|
|
192
|
+
}>;
|
|
193
|
+
}>>>;
|
|
180
194
|
}>>;
|
|
181
195
|
}>;
|
|
182
196
|
export type ChatHistoryImportInput = typeof ChatHistoryImportInput.Type;
|
|
@@ -222,7 +236,7 @@ declare const ChatDelivery_base: Context.ServiceClass<ChatDelivery, "@segmentstr
|
|
|
222
236
|
readonly sendReview?: (input: ReviewSendInput) => Effect.Effect<ReviewSendResult, ActionError>;
|
|
223
237
|
/** Asks the agent to redraft a reply it held for review, in a session of its own. */
|
|
224
238
|
readonly reviseReview?: (input: ReviewReviseInput) => Effect.Effect<ReviewReviseResult, ActionError>;
|
|
225
|
-
/** Adds a chat's messages from before the
|
|
239
|
+
/** Adds a chat's messages from before the agent recorded it, each in its place by its time. */
|
|
226
240
|
readonly importHistory?: (input: ChatHistoryImportInput) => Effect.Effect<ChatHistoryImportResult, ActionError>;
|
|
227
241
|
/** The channels whose private chats staff may take over, as the ontology's inbox lists them. */
|
|
228
242
|
readonly takeoverChannels?: ReadonlySet<string>;
|
package/dist/chat.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { Context, Schema } from "effect";
|
|
3
|
+
import { BLOB_UPLOAD_ANNOTATION, BlobUpload } from "./blob.js";
|
|
4
|
+
import { CHAT_FILES } from "./files.js";
|
|
3
5
|
const Identifier = Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(512));
|
|
4
6
|
export const ChatPostInput = Schema.Struct({
|
|
5
7
|
chat: Identifier,
|
|
@@ -123,6 +125,8 @@ export const chatPreviewDigest = (preview) => chatProtocolDigest([
|
|
|
123
125
|
preview.finalText,
|
|
124
126
|
preview.replyTo,
|
|
125
127
|
]);
|
|
128
|
+
/** The most files one imported message carries. */
|
|
129
|
+
export const CHAT_HISTORY_MESSAGE_FILES = 10;
|
|
126
130
|
/** One message of a chat from before the agent's archive recorded it, as the workspace kept it. */
|
|
127
131
|
export const ChatHistoryMessage = Schema.Struct({
|
|
128
132
|
id: Identifier.annotate({
|
|
@@ -140,11 +144,23 @@ export const ChatHistoryMessage = Schema.Struct({
|
|
|
140
144
|
"agent for outbound.",
|
|
141
145
|
})),
|
|
142
146
|
name: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(200))),
|
|
143
|
-
text: Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(100_000)),
|
|
147
|
+
text: Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(100_000))),
|
|
144
148
|
replyTo: Schema.optionalKey(Identifier),
|
|
149
|
+
files: Schema.optionalKey(Schema.Array(Schema.Struct({
|
|
150
|
+
upload: BlobUpload.annotate({
|
|
151
|
+
description: "A completed upload, from files_upload with entity agent_chat, action " +
|
|
152
|
+
"import_history and property files: the file the message carried, which the chat " +
|
|
153
|
+
"keeps as its attachment.",
|
|
154
|
+
[BLOB_UPLOAD_ANNOTATION]: { entity: CHAT_FILES.entity, property: CHAT_FILES.property },
|
|
155
|
+
}),
|
|
156
|
+
}))
|
|
157
|
+
.check(Schema.isMinLength(1), Schema.isMaxLength(CHAT_HISTORY_MESSAGE_FILES))
|
|
158
|
+
.annotate({ description: "The message's files. A message has text, files or both." })),
|
|
145
159
|
});
|
|
146
160
|
/** The most messages one import takes. */
|
|
147
161
|
export const CHAT_HISTORY_MESSAGES = 500;
|
|
162
|
+
/** The most files one import takes, of all its messages together. */
|
|
163
|
+
export const CHAT_HISTORY_FILES = 50;
|
|
148
164
|
export const ChatHistoryImportInput = Schema.Struct({
|
|
149
165
|
chat: Schema.optionalKey(Identifier.annotate({ description: "The agent_chat record of the chat, if it has one." })),
|
|
150
166
|
channel: Schema.optionalKey(Identifier.annotate({ description: "Without chat: the channel's name, such as whatsapp." })),
|
package/dist/files.d.ts
CHANGED
|
@@ -6,6 +6,13 @@ export interface FileTarget {
|
|
|
6
6
|
readonly entity: string;
|
|
7
7
|
readonly property: string;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* A file of a chat's message, which `agent_chat.importHistory` keeps as one of the chat's
|
|
11
|
+
* attachments: the one upload target that is no record's property.
|
|
12
|
+
*/
|
|
13
|
+
export declare const CHAT_FILES: FileTarget;
|
|
14
|
+
/** The action that takes {@link CHAT_FILES} uploads. */
|
|
15
|
+
export declare const CHAT_FILES_ACTION = "agent_chat.import_history";
|
|
9
16
|
export interface StageFile<E, R> {
|
|
10
17
|
readonly target: FileTarget;
|
|
11
18
|
/** Stable source identity within this action or workflow step's idempotency key. */
|
package/dist/files.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { Context } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* A file of a chat's message, which `agent_chat.importHistory` keeps as one of the chat's
|
|
4
|
+
* attachments: the one upload target that is no record's property.
|
|
5
|
+
*/
|
|
6
|
+
export const CHAT_FILES = { entity: "agent_chat", property: "files" };
|
|
7
|
+
/** The action that takes {@link CHAT_FILES} uploads. */
|
|
8
|
+
export const CHAT_FILES_ACTION = "agent_chat.import_history";
|
|
2
9
|
/** File I/O outside transactions, bound to the current action or workflow principal. */
|
|
3
10
|
export class Files extends Context.Service()("@segmentstream/ontology/Files") {
|
|
4
11
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export type { ConfirmContext } from "./confirmation.js";
|
|
|
14
14
|
export type { Action, ActionConfig, ActionConfigWithConnections, ActionContext, ActionIdentity, ActionEncodedInput, ActionHints, ActionInput, ActionResult, ActionWriteTarget, Actions, AnyAction, PrepareContext, PrepareError, } from "./action.js";
|
|
15
15
|
export { CONNECTION_ERROR_REASONS, CONNECTION_KEY, CONNECTION_METHODS, connection, ConnectionError, Connections, ConnectionTransport, isConnection, MAXIMUM_CONNECTION_BODY_BYTES, MAXIMUM_CONNECTION_FILE_BYTES, MAXIMUM_CONNECTION_RESPONSE_BYTES, } from "./connection.js";
|
|
16
16
|
export type { AnyConnectionHandle, Connection, ConnectionCall, ConnectionClient, ConnectionErrorReason, ConnectionHandle, ConnectionHeaders, ConnectionMethod, ConnectionOptions, ConnectionReply, ConnectionRequest, ConnectionRequestOptions, ConnectionResponse, ConnectionStreamReply, ConnectionStreamResponse, ConnectionsOf, ConnectionStub, StubRequest, StubResponse, } from "./connection.js";
|
|
17
|
-
export type { ChatChannelConfig, ChatConfig, DiscoveryOptions, EntityPermissions, JsonSchemaObject, MemberOptions, OntologyConfig, ResolvedAction, ResolvedConnection, ResolvedEntity, ResolvedIndex, ResolvedProperty, ResolvedRelationship, } from "./analyze.js";
|
|
17
|
+
export type { ChatChannelConfig, ChatConfig, ChatFilesConfig, DiscoveryOptions, EntityPermissions, JsonSchemaObject, MemberOptions, OntologyConfig, ResolvedAction, ResolvedConnection, ResolvedEntity, ResolvedIndex, ResolvedProperty, ResolvedRelationship, } from "./analyze.js";
|
|
18
18
|
export { Diagnostic, DIAGNOSTIC_CODES, formatDiagnostics, InvalidOntology } from "./diagnostics.js";
|
|
19
19
|
export type { DiagnosticCode } from "./diagnostics.js";
|
|
20
20
|
export { entity, isEntity } from "./entity.js";
|
|
@@ -24,7 +24,7 @@ export type { ActionsBuilder, AnyEntity, ActionHandle, ActionInvoker, MetricQuer
|
|
|
24
24
|
export { ActionRejected, BatchErrorDetails, Conflict, DeploymentInterrupted, DeploymentSwitching, LimitErrorDetails, NotFound, PermissionDenied, ScopeViolated, } from "./errors.js";
|
|
25
25
|
export type { ActionError } from "./errors.js";
|
|
26
26
|
export { browserAuthenticationCompatible } from "./manifest-compatibility.js";
|
|
27
|
-
export { ActionManifest, actionConnectionKeys, canonicalJson, ConnectionManifest, EntityManifest, EntityPermissionsManifest, decodeManifestDocument, encodeManifest, formatManifest, IndexManifest, isValueMatched, MANIFEST_VERSION, manifestHash, ModelMetricManifest, OntologyManifest, OntologyManifestWire, PropertyManifest, RelationshipManifest, RoleManifest, ActionTriggerManifest, ScopeManifest, CronTriggerManifest, isActionTrigger, isCronTrigger, isWebhookTrigger, OtherTriggerManifest, WebhookTriggerManifest, WorkflowManifest, WorkflowTriggerManifest, SelectOptionManifest, SignInManifest, GuestManifest, guestOf, signInPolicyOf, channelPolicyOf, signUpOriginsOf, inboxRolesOf, inboxChannelsOf, takeoverChannelsOf, signUpRolesOf, CHAT_RETENTION_DAYS, chatRetentionDaysOf, } from "./manifest.js";
|
|
27
|
+
export { ActionManifest, actionConnectionKeys, canonicalJson, ConnectionManifest, EntityManifest, EntityPermissionsManifest, decodeManifestDocument, encodeManifest, formatManifest, IndexManifest, isValueMatched, MANIFEST_VERSION, manifestHash, ModelMetricManifest, OntologyManifest, OntologyManifestWire, PropertyManifest, RelationshipManifest, RoleManifest, ActionTriggerManifest, ScopeManifest, CronTriggerManifest, isActionTrigger, isCronTrigger, isWebhookTrigger, OtherTriggerManifest, WebhookTriggerManifest, WorkflowManifest, WorkflowTriggerManifest, SelectOptionManifest, SignInManifest, GuestManifest, guestOf, signInPolicyOf, channelPolicyOf, signUpOriginsOf, inboxRolesOf, inboxChannelsOf, takeoverChannelsOf, signUpRolesOf, CHAT_RETENTION_DAYS, chatRetentionDaysOf, keepsChatFiles, } from "./manifest.js";
|
|
28
28
|
export { SYSTEM_PROPERTIES } from "./names.js";
|
|
29
29
|
export type { SystemProperty } from "./names.js";
|
|
30
30
|
export { isMe, isMeMarker, MAX_ME_HOPS, me, ME_KEY, MeMarker, mePathOf, meToWire, MeTypeId, } from "./me.js";
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ export { entity, isEntity } from "./entity.js";
|
|
|
13
13
|
export { isToolset, MCP_TOOL_NAME, TOOLSET_LOCK_VERSION, toolset, ToolsetLock, ToolsetLockTool, } from "./toolset.js";
|
|
14
14
|
export { ActionRejected, BatchErrorDetails, Conflict, DeploymentInterrupted, DeploymentSwitching, LimitErrorDetails, NotFound, PermissionDenied, ScopeViolated, } from "./errors.js";
|
|
15
15
|
export { browserAuthenticationCompatible } from "./manifest-compatibility.js";
|
|
16
|
-
export { ActionManifest, actionConnectionKeys, canonicalJson, ConnectionManifest, EntityManifest, EntityPermissionsManifest, decodeManifestDocument, encodeManifest, formatManifest, IndexManifest, isValueMatched, MANIFEST_VERSION, manifestHash, ModelMetricManifest, OntologyManifest, OntologyManifestWire, PropertyManifest, RelationshipManifest, RoleManifest, ActionTriggerManifest, ScopeManifest, CronTriggerManifest, isActionTrigger, isCronTrigger, isWebhookTrigger, OtherTriggerManifest, WebhookTriggerManifest, WorkflowManifest, WorkflowTriggerManifest, SelectOptionManifest, SignInManifest, GuestManifest, guestOf, signInPolicyOf, channelPolicyOf, signUpOriginsOf, inboxRolesOf, inboxChannelsOf, takeoverChannelsOf, signUpRolesOf, CHAT_RETENTION_DAYS, chatRetentionDaysOf, } from "./manifest.js";
|
|
16
|
+
export { ActionManifest, actionConnectionKeys, canonicalJson, ConnectionManifest, EntityManifest, EntityPermissionsManifest, decodeManifestDocument, encodeManifest, formatManifest, IndexManifest, isValueMatched, MANIFEST_VERSION, manifestHash, ModelMetricManifest, OntologyManifest, OntologyManifestWire, PropertyManifest, RelationshipManifest, RoleManifest, ActionTriggerManifest, ScopeManifest, CronTriggerManifest, isActionTrigger, isCronTrigger, isWebhookTrigger, OtherTriggerManifest, WebhookTriggerManifest, WorkflowManifest, WorkflowTriggerManifest, SelectOptionManifest, SignInManifest, GuestManifest, guestOf, signInPolicyOf, channelPolicyOf, signUpOriginsOf, inboxRolesOf, inboxChannelsOf, takeoverChannelsOf, signUpRolesOf, CHAT_RETENTION_DAYS, chatRetentionDaysOf, keepsChatFiles, } from "./manifest.js";
|
|
17
17
|
export { SYSTEM_PROPERTIES } from "./names.js";
|
|
18
18
|
export { isMe, isMeMarker, MAX_ME_HOPS, me, ME_KEY, MeMarker, mePathOf, meToWire, MeTypeId, } from "./me.js";
|
|
19
19
|
export { check, defineOntology } from "./ontology.js";
|