@segmentstream/ontology 0.164.0 → 0.165.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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.165.0
4
+
5
+ Staff choose a draft's files and post files of their own. `agent_draft.approve` takes `files`, the
6
+ `{ entity, id, property, revisionId }` of the draft's files to send, leaving the others out;
7
+ naming a file the draft does not hold is refused with `file_not_held`, and the draft keeps the
8
+ files it sent. `agent_chat.post_message` takes `files`, one to ten `{ entity, id, property? }`,
9
+ read as the caller and sent with the text in one delivery, refused before the key is reserved
10
+ when the caller may not read one or the channel cannot send it. In `@segmentstream/app/agent`, a
11
+ draft of `useInboxChat` lists its `files`, `approve` takes the files to send as its fourth
12
+ argument, and `send` takes the record files to post with the text.
13
+
3
14
  ## 0.164.0
4
15
 
5
16
  Approving a draft with files now sends them on Telegram, Slack and WhatsApp too, with the shared
@@ -39,6 +39,11 @@ export declare const AgentChat: import("./entity.js").Entity<"agent_chat", {
39
39
  readonly chat: Schema.String;
40
40
  readonly text: Schema.String;
41
41
  readonly replyTo: Schema.optionalKey<Schema.String>;
42
+ readonly files: Schema.optionalKey<Schema.$Array<Schema.Struct<{
43
+ readonly entity: Schema.String;
44
+ readonly id: Schema.String;
45
+ readonly property: Schema.optionalKey<Schema.String>;
46
+ }>>>;
42
47
  readonly idempotencyKey: Schema.String;
43
48
  }>, import("./chat.js").ChatPreview>;
44
49
  readonly importHistory: import("./action.js").Action<Schema.Struct<{
@@ -109,6 +114,11 @@ export declare const AgentChat: import("./entity.js").Entity<"agent_chat", {
109
114
  readonly chat: Schema.String;
110
115
  readonly text: Schema.String;
111
116
  readonly replyTo: Schema.optionalKey<Schema.String>;
117
+ readonly files: Schema.optionalKey<Schema.$Array<Schema.Struct<{
118
+ readonly entity: Schema.String;
119
+ readonly id: Schema.String;
120
+ readonly property: Schema.optionalKey<Schema.String>;
121
+ }>>>;
112
122
  readonly idempotencyKey: Schema.String;
113
123
  }>, {
114
124
  readonly status: "sent" | "uncertain";
@@ -98,7 +98,7 @@ export declare const AgentDraft: import("./entity.js").Entity<"agent_draft", {
98
98
  readonly draft: import("./property.js").Property<string, false, false>;
99
99
  readonly files: Schema.optionalKey<import("./property.js").Property<Schema.Json, false, false>>;
100
100
  readonly text: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
101
- readonly status: import("./property.js").Property<"pending" | "sent" | "uncertain" | "failed" | "rejected" | "superseded" | "dismissed", false, false>;
101
+ readonly status: import("./property.js").Property<"pending" | "sent" | "failed" | "uncertain" | "rejected" | "superseded" | "dismissed", false, false>;
102
102
  readonly mode: import("./property.js").Property<"always" | "whenUnsure", false, false>;
103
103
  readonly confidence: Schema.optionalKey<import("./property.js").Property<number, false, false>>;
104
104
  readonly messageId: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
@@ -119,13 +119,19 @@ export declare const AgentDraft: import("./entity.js").Entity<"agent_draft", {
119
119
  readonly text: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
120
120
  readonly to: Schema.optionalKey<Schema.$Array<Schema.String>>;
121
121
  readonly cc: Schema.optionalKey<Schema.$Array<Schema.String>>;
122
+ readonly files: Schema.optionalKey<Schema.$Array<Schema.Struct<{
123
+ readonly entity: Schema.String;
124
+ readonly id: Schema.String;
125
+ readonly property: Schema.String;
126
+ readonly revisionId: Schema.String;
127
+ }>>>;
122
128
  readonly unlessNewer: Schema.optionalKey<Schema.Boolean>;
123
129
  }>, {
124
130
  to?: readonly string[] | undefined;
125
131
  cc?: readonly string[] | undefined;
126
132
  draft: string;
127
133
  review: string;
128
- status: "sent" | "uncertain" | "failed";
134
+ status: "sent" | "failed" | "uncertain";
129
135
  message_id: string | null;
130
136
  duplicate: boolean;
131
137
  }>;
@@ -182,7 +188,7 @@ export declare const AgentDraft: import("./entity.js").Entity<"agent_draft", {
182
188
  readonly draft: string;
183
189
  readonly files: Schema.Json;
184
190
  readonly text: string | null;
185
- readonly status: "pending" | "sent" | "uncertain" | "failed" | "rejected" | "superseded" | "dismissed";
191
+ readonly status: "pending" | "sent" | "failed" | "uncertain" | "rejected" | "superseded" | "dismissed";
186
192
  readonly mode: "always" | "whenUnsure";
187
193
  readonly confidence: number | null;
188
194
  readonly messageId: string | null;
@@ -218,7 +224,7 @@ export declare const AgentReview: import("./entity.js").Entity<"agent_draft", {
218
224
  readonly draft: import("./property.js").Property<string, false, false>;
219
225
  readonly files: Schema.optionalKey<import("./property.js").Property<Schema.Json, false, false>>;
220
226
  readonly text: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
221
- readonly status: import("./property.js").Property<"pending" | "sent" | "uncertain" | "failed" | "rejected" | "superseded" | "dismissed", false, false>;
227
+ readonly status: import("./property.js").Property<"pending" | "sent" | "failed" | "uncertain" | "rejected" | "superseded" | "dismissed", false, false>;
222
228
  readonly mode: import("./property.js").Property<"always" | "whenUnsure", false, false>;
223
229
  readonly confidence: Schema.optionalKey<import("./property.js").Property<number, false, false>>;
224
230
  readonly messageId: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
@@ -239,13 +245,19 @@ export declare const AgentReview: import("./entity.js").Entity<"agent_draft", {
239
245
  readonly text: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
240
246
  readonly to: Schema.optionalKey<Schema.$Array<Schema.String>>;
241
247
  readonly cc: Schema.optionalKey<Schema.$Array<Schema.String>>;
248
+ readonly files: Schema.optionalKey<Schema.$Array<Schema.Struct<{
249
+ readonly entity: Schema.String;
250
+ readonly id: Schema.String;
251
+ readonly property: Schema.String;
252
+ readonly revisionId: Schema.String;
253
+ }>>>;
242
254
  readonly unlessNewer: Schema.optionalKey<Schema.Boolean>;
243
255
  }>, {
244
256
  to?: readonly string[] | undefined;
245
257
  cc?: readonly string[] | undefined;
246
258
  draft: string;
247
259
  review: string;
248
- status: "sent" | "uncertain" | "failed";
260
+ status: "sent" | "failed" | "uncertain";
249
261
  message_id: string | null;
250
262
  duplicate: boolean;
251
263
  }>;
@@ -302,7 +314,7 @@ export declare const AgentReview: import("./entity.js").Entity<"agent_draft", {
302
314
  readonly draft: string;
303
315
  readonly files: Schema.Json;
304
316
  readonly text: string | null;
305
- readonly status: "pending" | "sent" | "uncertain" | "failed" | "rejected" | "superseded" | "dismissed";
317
+ readonly status: "pending" | "sent" | "failed" | "uncertain" | "rejected" | "superseded" | "dismissed";
306
318
  readonly mode: "always" | "whenUnsure";
307
319
  readonly confidence: number | null;
308
320
  readonly messageId: string | null;
@@ -393,6 +393,18 @@ export const AgentDraft = entity("agent_draft", {
393
393
  description: "A reply to mail: the addresses it copies, in place of the draft's cc; [] copies " +
394
394
  "no one, and omitting it keeps them.",
395
395
  })),
396
+ files: Schema.optionalKey(Schema.Array(Schema.Struct({
397
+ entity: Schema.String,
398
+ id: Schema.String,
399
+ property: Schema.String,
400
+ revisionId: Schema.String,
401
+ }))
402
+ .check(Schema.isMaxLength(AGENT_DRAFT_FILES_LIMIT))
403
+ .annotate({
404
+ description: "The draft's files to send, each { entity, id, property, revisionId } as the draft " +
405
+ "lists it, in place of all of them: an approval may leave files out, never add one. " +
406
+ "Omit it to send every file; [] sends none.",
407
+ })),
396
408
  unlessNewer: Schema.optionalKey(Schema.Boolean.annotate({
397
409
  description: "true refuses the approval, with refusal newer_message and nothing sent, when the " +
398
410
  "person wrote in the chat after the turn that wrote the reply, or basis_unknown when " +
@@ -415,6 +427,7 @@ export const AgentDraft = entity("agent_draft", {
415
427
  ...(input.to === undefined ? {} : { to: input.to }),
416
428
  ...(input.cc === undefined ? {} : { cc: input.cc }),
417
429
  ...(input.unlessNewer === true ? { unlessNewer: true } : {}),
430
+ ...(input.files === undefined ? {} : { files: input.files }),
418
431
  });
419
432
  }),
420
433
  handler: ({ input, prepared, principal }) => Effect.gen(function* () {
@@ -443,6 +456,22 @@ export const AgentDraft = entity("agent_draft", {
443
456
  to: draftAddresses(recipients.to),
444
457
  cc: recipients.cc.length === 0 ? null : draftAddresses(recipients.cc),
445
458
  }),
459
+ // The draft keeps the files sent, as it keeps the text approved.
460
+ ...(prepared.files === undefined
461
+ ? {}
462
+ : {
463
+ files: prepared.files.length === 0
464
+ ? null
465
+ : prepared.files.map(({ entity, id, property, revisionId, filename, contentType, size }) => ({
466
+ entity,
467
+ id,
468
+ property,
469
+ revisionId,
470
+ filename,
471
+ contentType,
472
+ size,
473
+ })),
474
+ }),
446
475
  });
447
476
  return {
448
477
  draft: review.id,
package/dist/chat.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { AgentDraftFile } from "./agent-draft.js";
1
2
  /** Workspace-authored exact-post attribution; neutral defaults are name and a blank line. */
2
3
  export interface ChatAttributionSettings {
3
4
  readonly template?: string;
@@ -39,6 +40,11 @@ export declare const ChatPostInput: Schema.Struct<{
39
40
  readonly chat: Schema.String;
40
41
  readonly text: Schema.String;
41
42
  readonly replyTo: Schema.optionalKey<Schema.String>;
43
+ readonly files: Schema.optionalKey<Schema.$Array<Schema.Struct<{
44
+ readonly entity: Schema.String;
45
+ readonly id: Schema.String;
46
+ readonly property: Schema.optionalKey<Schema.String>;
47
+ }>>>;
42
48
  readonly idempotencyKey: Schema.String;
43
49
  }>;
44
50
  export type ChatPostInput = typeof ChatPostInput.Type;
@@ -215,6 +221,16 @@ export interface ReviewSendInput {
215
221
  * after the turn that wrote the reply, or when that cannot be told.
216
222
  */
217
223
  readonly unlessNewer?: boolean;
224
+ /**
225
+ * The draft's files to send, each by its record and revision, in place of all it holds: it can
226
+ * only leave files out, never add one. `[]` sends none of them.
227
+ */
228
+ readonly files?: ReadonlyArray<{
229
+ readonly entity: string;
230
+ readonly id: string;
231
+ readonly property: string;
232
+ readonly revisionId: string;
233
+ }>;
218
234
  }
219
235
  /** Whether the person wrote after a draft's turn; `null` when it cannot be told. */
220
236
  export interface DraftNewer {
@@ -228,6 +244,8 @@ export interface ReviewSendResult {
228
244
  readonly text: string;
229
245
  readonly messageId: string | null;
230
246
  readonly duplicate: boolean;
247
+ /** The files sent with the text, or attempted; absent for a reply of text alone. */
248
+ readonly files?: ReadonlyArray<AgentDraftFile>;
231
249
  /** The reply's message in the workspace chat store, by its id; absent before the store held it. */
232
250
  readonly message?: string | null;
233
251
  /** A reply to mail: whom it was sent to, or attempted; absent on another channel. */
package/dist/chat.js CHANGED
@@ -9,6 +9,16 @@ export const ChatPostInput = Schema.Struct({
9
9
  description: "Markdown source; the platform adds sender attribution after channel rendering.",
10
10
  }),
11
11
  replyTo: Schema.optionalKey(Identifier),
12
+ files: Schema.optionalKey(Schema.Array(Schema.Struct({
13
+ entity: Identifier,
14
+ id: Identifier,
15
+ property: Schema.optionalKey(Identifier),
16
+ }))
17
+ .check(Schema.isMinLength(1), Schema.isMaxLength(10))
18
+ .annotate({
19
+ description: "Stored files the post carries after its text, each a record and its file property, " +
20
+ "which the caller may read: content by default. Each is sent at the revision read now.",
21
+ })),
12
22
  idempotencyKey: Identifier,
13
23
  });
14
24
  /** The file of a template's image, video or document header, where it is stored or served. */