@segmentstream/ontology 0.138.0 → 0.139.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,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.139.0
4
+
5
+ The inbox takes `attribution`: `inbox: { roles: [client], attribution: "none" }` sends a member's
6
+ own reply to a person in the inbox, from their session in the app, as written, without the
7
+ separator or their name, and archives that text alone. The reply stays the member's own message,
8
+ and its `requestedBy` still names them, with an empty `attribution`. The default, `"name"`, signs
9
+ the reply with `chat.attribution` as before, and writes nothing new into the manifest. Posts to
10
+ group chats, and posts by OAuth clients, services and the agent's sessions, stay signed whatever
11
+ the inbox says. `check` reports `invalid-inbox` for any other value.
12
+
13
+ An approved Slack reply goes in the thread it answers: `agent_review.approve` posts it with the
14
+ review's `threadId` as Slack's `thread_ts`, in a channel or in the person's direct message, and
15
+ records it `sent` only when Slack confirms that thread. Chat posts are unchanged.
16
+
3
17
  ## 0.138.0
4
18
 
5
19
  `agent_chat.send` sends WhatsApp templates with a header and buttons: `header.parameters` for a text
package/dist/analyze.d.ts CHANGED
@@ -237,6 +237,8 @@ export interface Analysis {
237
237
  readonly takeover: {
238
238
  readonly channels: ReadonlyArray<string>;
239
239
  };
240
+ /** Whether a member's own reply to the person carries their name. */
241
+ readonly attribution: "name" | "none";
240
242
  };
241
243
  readonly entities: ReadonlyArray<ResolvedEntity>;
242
244
  /** The workspace-owned `member` role and declared roles, then the implicit reporter when enabled. */
package/dist/analyze.js CHANGED
@@ -355,8 +355,9 @@ export function analyze(config, options = {}) {
355
355
  }
356
356
  /**
357
357
  * `inbox`: the wire names of the roles whose private chats join the inbox, each a declared role or
358
- * `member`, and the channels whose chats staff may take over: those `takeover.channels` lists, or
359
- * every channel `chat` declares; `undefined` when absent or malformed.
358
+ * `member`, the channels whose chats staff may take over: those `takeover.channels` lists, or
359
+ * every channel `chat` declares, and whether a member's own reply carries their name: `name`
360
+ * unless `attribution` is `none`; `undefined` when absent or malformed.
360
361
  */
361
362
  function inboxOptions(value, declaredRoles,
362
363
  /** Whether the ontology declares `guest`, whose visitors' chats the inbox may take. */
@@ -367,13 +368,19 @@ chatChannels, report) {
367
368
  return undefined;
368
369
  }
369
370
  if (!isPlainObject(value) ||
370
- Object.keys(value).some((key) => key !== "roles" && key !== "takeover") ||
371
+ Object.keys(value).some((key) => key !== "roles" && key !== "takeover" && key !== "attribution") ||
371
372
  !Array.isArray(value.roles) ||
372
373
  value.roles.length === 0) {
373
- report("invalid-inbox", "inbox", "inbox takes { roles: [...], takeover?: { channels?: [...] } }, at least one role.");
374
+ report("invalid-inbox", "inbox", 'inbox takes { roles: [...], takeover?: { channels?: [...] }, attribution?: "name" | ' +
375
+ '"none" }, at least one role.');
374
376
  return undefined;
375
377
  }
376
378
  const takeover = takeoverOptions(value.takeover, chatChannels, report);
379
+ const attribution = value.attribution === undefined ? "name" : value.attribution;
380
+ if (attribution !== "name" && attribution !== "none") {
381
+ report("invalid-inbox", "inbox.attribution", 'inbox.attribution takes "name", the default, which signs a member\'s reply with their ' +
382
+ 'name, or "none".');
383
+ }
377
384
  const declared = new Set(declaredRoles.map((candidate) => candidate.name));
378
385
  if (guests) {
379
386
  declared.add(GUEST_ROLE);
@@ -394,7 +401,9 @@ chatChannels, report) {
394
401
  roles.push(name);
395
402
  }
396
403
  });
397
- return valid && takeover !== undefined ? { roles, takeover } : undefined;
404
+ return valid && takeover !== undefined && (attribution === "name" || attribution === "none")
405
+ ? { roles, takeover, attribution }
406
+ : undefined;
398
407
  }
399
408
  /**
400
409
  * `inbox.takeover`: the channels whose private chats staff may take over from the agent, each a
package/dist/chat.d.ts CHANGED
@@ -18,6 +18,12 @@ export interface InboxOptions<R = unknown> {
18
18
  readonly takeover?: {
19
19
  readonly channels?: ReadonlyArray<string>;
20
20
  };
21
+ /**
22
+ * Whether a member's own reply to the person, from their session in the app, carries their name
23
+ * as `chat.attribution` lays it out: `"name"`, the default, or `"none"`, sent and archived as
24
+ * written and still the member's message. Every other post stays signed.
25
+ */
26
+ readonly attribution?: "name" | "none";
21
27
  }
22
28
  import { Context, Effect, Schema } from "effect";
23
29
  import type { ActionError } from "./errors.js";
@@ -92,7 +92,9 @@ import { type ResolvedGuest, type ResolvedSignInOptions, type SignInPolicy } fro
92
92
  * Within version 15, the top-level `inbox`, written only when declared, holds the wire names of the
93
93
  * `roles` whose people's private chats the agent registers as `agent_chat` records of kind
94
94
  * `private`, and in `takeover.channels` the channels whose chats staff may take over from the
95
- * agent. Older readers ignore it, register none and let none be taken over.
95
+ * agent. Older readers ignore it, register none and let none be taken over. `inbox` may carry
96
+ * `attribution: "none"`, written only when declared: a member's own reply in the inbox is sent and
97
+ * archived without their name. Older readers ignore it and sign the reply.
96
98
  * Within version 15, a webhook trigger's `signature` may have scheme `hmac` and carry the provider's
97
99
  * format, written only when declared. Older readers present the scheme and ignore the format; an
98
100
  * older publication check refuses the scheme. A signature may carry `generated: true` instead of
@@ -1306,16 +1308,18 @@ export declare const OntologyManifestWire: Schema.encodeKeys<Schema.Struct<{
1306
1308
  }>>;
1307
1309
  }>>;
1308
1310
  /**
1309
- * Whose private chats join the inbox, within version 15: the wire names of their roles, and the
1310
- * channels whose chats staff may take over from the agent. Written only when declared; absent
1311
- * registers no private chat, absent `takeover` lets no chat be taken over, and older readers
1312
- * ignore both.
1311
+ * Whose private chats join the inbox, within version 15: the wire names of their roles, the
1312
+ * channels whose chats staff may take over from the agent, and `attribution: "none"` when a
1313
+ * member's own reply there goes without their name. Written only when declared; absent
1314
+ * registers no private chat, absent `takeover` lets no chat be taken over, absent `attribution`
1315
+ * signs replies, and older readers ignore all three.
1313
1316
  */
1314
1317
  readonly inbox: Schema.optionalKey<Schema.Struct<{
1315
1318
  readonly roles: Schema.$Array<Schema.String>;
1316
1319
  readonly takeover: Schema.optionalKey<Schema.Struct<{
1317
1320
  readonly channels: Schema.$Array<Schema.String>;
1318
1321
  }>>;
1322
+ readonly attribution: Schema.optionalKey<Schema.Literals<readonly ["name", "none"]>>;
1319
1323
  }>>;
1320
1324
  /**
1321
1325
  * The metrics of the model, since version 8. Written only when there are some; absent reads as
@@ -1796,6 +1800,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1796
1800
  } | undefined;
1797
1801
  readonly inbox?: {
1798
1802
  readonly roles: readonly string[];
1803
+ readonly attribution?: "name" | "none" | undefined;
1799
1804
  readonly takeover?: {
1800
1805
  readonly channels: readonly string[];
1801
1806
  } | undefined;
@@ -2149,6 +2154,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2149
2154
  } | undefined;
2150
2155
  readonly inbox?: {
2151
2156
  readonly roles: readonly string[];
2157
+ readonly attribution?: "name" | "none" | undefined;
2152
2158
  readonly takeover?: {
2153
2159
  readonly channels: readonly string[];
2154
2160
  } | undefined;
@@ -2465,6 +2471,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2465
2471
  } | undefined;
2466
2472
  readonly inbox?: {
2467
2473
  readonly roles: readonly string[];
2474
+ readonly attribution?: "name" | "none" | undefined;
2468
2475
  readonly takeover?: {
2469
2476
  readonly channels: readonly string[];
2470
2477
  } | undefined;
@@ -2855,6 +2862,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2855
2862
  } | undefined;
2856
2863
  readonly inbox?: {
2857
2864
  readonly roles: readonly string[];
2865
+ readonly attribution?: "name" | "none" | undefined;
2858
2866
  readonly takeover?: {
2859
2867
  readonly channels: readonly string[];
2860
2868
  } | undefined;
@@ -3207,16 +3215,18 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3207
3215
  }>>;
3208
3216
  }>>;
3209
3217
  /**
3210
- * Whose private chats join the inbox, within version 15: the wire names of their roles, and the
3211
- * channels whose chats staff may take over from the agent. Written only when declared; absent
3212
- * registers no private chat, absent `takeover` lets no chat be taken over, and older readers
3213
- * ignore both.
3218
+ * Whose private chats join the inbox, within version 15: the wire names of their roles, the
3219
+ * channels whose chats staff may take over from the agent, and `attribution: "none"` when a
3220
+ * member's own reply there goes without their name. Written only when declared; absent
3221
+ * registers no private chat, absent `takeover` lets no chat be taken over, absent `attribution`
3222
+ * signs replies, and older readers ignore all three.
3214
3223
  */
3215
3224
  readonly inbox: Schema.optionalKey<Schema.Struct<{
3216
3225
  readonly roles: Schema.$Array<Schema.String>;
3217
3226
  readonly takeover: Schema.optionalKey<Schema.Struct<{
3218
3227
  readonly channels: Schema.$Array<Schema.String>;
3219
3228
  }>>;
3229
+ readonly attribution: Schema.optionalKey<Schema.Literals<readonly ["name", "none"]>>;
3220
3230
  }>>;
3221
3231
  /**
3222
3232
  * The metrics of the model, since version 8. Written only when there are some; absent reads as
@@ -3683,16 +3693,18 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3683
3693
  }>>;
3684
3694
  }>>;
3685
3695
  /**
3686
- * Whose private chats join the inbox, within version 15: the wire names of their roles, and the
3687
- * channels whose chats staff may take over from the agent. Written only when declared; absent
3688
- * registers no private chat, absent `takeover` lets no chat be taken over, and older readers
3689
- * ignore both.
3696
+ * Whose private chats join the inbox, within version 15: the wire names of their roles, the
3697
+ * channels whose chats staff may take over from the agent, and `attribution: "none"` when a
3698
+ * member's own reply there goes without their name. Written only when declared; absent
3699
+ * registers no private chat, absent `takeover` lets no chat be taken over, absent `attribution`
3700
+ * signs replies, and older readers ignore all three.
3690
3701
  */
3691
3702
  readonly inbox: Schema.optionalKey<Schema.Struct<{
3692
3703
  readonly roles: Schema.$Array<Schema.String>;
3693
3704
  readonly takeover: Schema.optionalKey<Schema.Struct<{
3694
3705
  readonly channels: Schema.$Array<Schema.String>;
3695
3706
  }>>;
3707
+ readonly attribution: Schema.optionalKey<Schema.Literals<readonly ["name", "none"]>>;
3696
3708
  }>>;
3697
3709
  /**
3698
3710
  * The metrics of the model, since version 8. Written only when there are some; absent reads as
@@ -4165,6 +4177,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
4165
4177
  } | undefined;
4166
4178
  readonly inbox?: {
4167
4179
  readonly roles: readonly string[];
4180
+ readonly attribution?: "name" | "none" | undefined;
4168
4181
  readonly takeover?: {
4169
4182
  readonly channels: readonly string[];
4170
4183
  } | undefined;
@@ -4518,6 +4531,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
4518
4531
  } | undefined;
4519
4532
  readonly inbox?: {
4520
4533
  readonly roles: readonly string[];
4534
+ readonly attribution?: "name" | "none" | undefined;
4521
4535
  readonly takeover?: {
4522
4536
  readonly channels: readonly string[];
4523
4537
  } | undefined;
@@ -4877,6 +4891,7 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
4877
4891
  } | undefined;
4878
4892
  readonly inbox?: {
4879
4893
  readonly roles: readonly string[];
4894
+ readonly attribution?: "name" | "none" | undefined;
4880
4895
  readonly takeover?: {
4881
4896
  readonly channels: readonly string[];
4882
4897
  } | undefined;
@@ -5230,6 +5245,7 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
5230
5245
  } | undefined;
5231
5246
  readonly inbox?: {
5232
5247
  readonly roles: readonly string[];
5248
+ readonly attribution?: "name" | "none" | undefined;
5233
5249
  readonly takeover?: {
5234
5250
  readonly channels: readonly string[];
5235
5251
  } | undefined;
@@ -5286,6 +5302,8 @@ export declare function signUpRolesOf(manifest: Pick<OntologyManifest, "signIn">
5286
5302
  export declare function inboxRolesOf(manifest: Pick<OntologyManifest, "inbox">): ReadonlySet<string>;
5287
5303
  /** The channels whose private chats staff may take over from the agent; empty without any. */
5288
5304
  export declare function takeoverChannelsOf(manifest: Pick<OntologyManifest, "inbox">): ReadonlySet<string>;
5305
+ /** Whether a member's own reply in the inbox carries their name: `name` unless declared `none`. */
5306
+ export declare function inboxAttributionOf(manifest: Pick<OntologyManifest, "inbox">): "name" | "none";
5289
5307
  /**
5290
5308
  * The account providers people write from on the channels staff take chats over on: a platform
5291
5309
  * channel's kind, whose accounts every channel of the kind shares, and `channel:<name>` for a
@@ -5349,6 +5367,7 @@ export declare function buildManifest(input: {
5349
5367
  readonly takeover: {
5350
5368
  readonly channels: ReadonlyArray<string>;
5351
5369
  };
5370
+ readonly attribution?: "name" | "none";
5352
5371
  };
5353
5372
  readonly entities: ReadonlyArray<ResolvedEntity>;
5354
5373
  readonly roles: ReadonlyArray<Role>;
package/dist/manifest.js CHANGED
@@ -93,7 +93,9 @@ import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, isGuestBotCheckScheme, isGue
93
93
  * Within version 15, the top-level `inbox`, written only when declared, holds the wire names of the
94
94
  * `roles` whose people's private chats the agent registers as `agent_chat` records of kind
95
95
  * `private`, and in `takeover.channels` the channels whose chats staff may take over from the
96
- * agent. Older readers ignore it, register none and let none be taken over.
96
+ * agent. Older readers ignore it, register none and let none be taken over. `inbox` may carry
97
+ * `attribution: "none"`, written only when declared: a member's own reply in the inbox is sent and
98
+ * archived without their name. Older readers ignore it and sign the reply.
97
99
  * Within version 15, a webhook trigger's `signature` may have scheme `hmac` and carry the provider's
98
100
  * format, written only when declared. Older readers present the scheme and ignore the format; an
99
101
  * older publication check refuses the scheme. A signature may carry `generated: true` instead of
@@ -610,14 +612,16 @@ const OntologyManifestModel = Schema.Struct({
610
612
  })),
611
613
  })),
612
614
  /**
613
- * Whose private chats join the inbox, within version 15: the wire names of their roles, and the
614
- * channels whose chats staff may take over from the agent. Written only when declared; absent
615
- * registers no private chat, absent `takeover` lets no chat be taken over, and older readers
616
- * ignore both.
615
+ * Whose private chats join the inbox, within version 15: the wire names of their roles, the
616
+ * channels whose chats staff may take over from the agent, and `attribution: "none"` when a
617
+ * member's own reply there goes without their name. Written only when declared; absent
618
+ * registers no private chat, absent `takeover` lets no chat be taken over, absent `attribution`
619
+ * signs replies, and older readers ignore all three.
617
620
  */
618
621
  inbox: Schema.optionalKey(Schema.Struct({
619
622
  roles: Schema.Array(Schema.String),
620
623
  takeover: Schema.optionalKey(Schema.Struct({ channels: Schema.Array(Schema.String) })),
624
+ attribution: Schema.optionalKey(Schema.Literals(["name", "none"])),
621
625
  })),
622
626
  /**
623
627
  * The metrics of the model, since version 8. Written only when there are some; absent reads as
@@ -721,6 +725,10 @@ export function inboxRolesOf(manifest) {
721
725
  export function takeoverChannelsOf(manifest) {
722
726
  return new Set(manifest.inbox?.takeover?.channels ?? []);
723
727
  }
728
+ /** Whether a member's own reply in the inbox carries their name: `name` unless declared `none`. */
729
+ export function inboxAttributionOf(manifest) {
730
+ return manifest.inbox?.attribution === "none" ? "none" : "name";
731
+ }
724
732
  /**
725
733
  * The account providers people write from on the channels staff take chats over on: a platform
726
734
  * channel's kind, whose accounts every channel of the kind shares, and `channel:<name>` for a
@@ -1098,6 +1106,7 @@ export function buildManifest(input) {
1098
1106
  inbox: {
1099
1107
  roles: [...input.inbox.roles],
1100
1108
  takeover: { channels: [...input.inbox.takeover.channels] },
1109
+ ...(input.inbox.attribution === "none" ? { attribution: "none" } : {}),
1101
1110
  },
1102
1111
  }),
1103
1112
  ...(connections.length > 0
@@ -595,6 +595,7 @@ export declare const MigrationPlan: Schema.Struct<{
595
595
  } | undefined;
596
596
  readonly inbox?: {
597
597
  readonly roles: readonly string[];
598
+ readonly attribution?: "name" | "none" | undefined;
598
599
  readonly takeover?: {
599
600
  readonly channels: readonly string[];
600
601
  } | undefined;
@@ -948,6 +949,7 @@ export declare const MigrationPlan: Schema.Struct<{
948
949
  } | undefined;
949
950
  readonly inbox?: {
950
951
  readonly roles: readonly string[];
952
+ readonly attribution?: "name" | "none" | undefined;
951
953
  readonly takeover?: {
952
954
  readonly channels: readonly string[];
953
955
  } | undefined;
@@ -1264,6 +1266,7 @@ export declare const MigrationPlan: Schema.Struct<{
1264
1266
  } | undefined;
1265
1267
  readonly inbox?: {
1266
1268
  readonly roles: readonly string[];
1269
+ readonly attribution?: "name" | "none" | undefined;
1267
1270
  readonly takeover?: {
1268
1271
  readonly channels: readonly string[];
1269
1272
  } | undefined;
@@ -1654,6 +1657,7 @@ export declare const MigrationPlan: Schema.Struct<{
1654
1657
  } | undefined;
1655
1658
  readonly inbox?: {
1656
1659
  readonly roles: readonly string[];
1660
+ readonly attribution?: "name" | "none" | undefined;
1657
1661
  readonly takeover?: {
1658
1662
  readonly channels: readonly string[];
1659
1663
  } | undefined;
@@ -1944,6 +1948,7 @@ export declare const MigrationPlan: Schema.Struct<{
1944
1948
  readonly takeover: Schema.optionalKey<Schema.Struct<{
1945
1949
  readonly channels: Schema.$Array<Schema.String>;
1946
1950
  }>>;
1951
+ readonly attribution: Schema.optionalKey<Schema.Literals<readonly ["name", "none"]>>;
1947
1952
  }>>;
1948
1953
  readonly metrics: Schema.optionalKey<Schema.$Array<Schema.Struct<{
1949
1954
  readonly name: Schema.String;
@@ -2293,6 +2298,7 @@ export declare const MigrationPlan: Schema.Struct<{
2293
2298
  readonly takeover: Schema.optionalKey<Schema.Struct<{
2294
2299
  readonly channels: Schema.$Array<Schema.String>;
2295
2300
  }>>;
2301
+ readonly attribution: Schema.optionalKey<Schema.Literals<readonly ["name", "none"]>>;
2296
2302
  }>>;
2297
2303
  readonly metrics: Schema.optionalKey<Schema.$Array<Schema.Struct<{
2298
2304
  readonly name: Schema.String;
@@ -2718,6 +2724,7 @@ export declare const MigrationPlan: Schema.Struct<{
2718
2724
  } | undefined;
2719
2725
  readonly inbox?: {
2720
2726
  readonly roles: readonly string[];
2727
+ readonly attribution?: "name" | "none" | undefined;
2721
2728
  readonly takeover?: {
2722
2729
  readonly channels: readonly string[];
2723
2730
  } | undefined;
@@ -3071,6 +3078,7 @@ export declare const MigrationPlan: Schema.Struct<{
3071
3078
  } | undefined;
3072
3079
  readonly inbox?: {
3073
3080
  readonly roles: readonly string[];
3081
+ readonly attribution?: "name" | "none" | undefined;
3074
3082
  readonly takeover?: {
3075
3083
  readonly channels: readonly string[];
3076
3084
  } | undefined;
@@ -22,5 +22,6 @@ export interface ChatRequester {
22
22
  readonly via: "oauth" | "hq" | "service";
23
23
  readonly clientId: string | null;
24
24
  readonly clientName: string | null;
25
+ /** Empty only for a member's own reply in the inbox, unsigned where the inbox says `none`. */
25
26
  readonly attribution: string;
26
27
  }
@@ -1,5 +1,5 @@
1
1
  import { validateTelegramPreviews } from "../../telegram.js";
2
- import { takeoverChannelsOf } from "../../manifest.js";
2
+ import { inboxAttributionOf, takeoverChannelsOf } from "../../manifest.js";
3
3
  import { randomUUID } from "node:crypto";
4
4
  import { Cause, Effect } from "effect";
5
5
  import { chatOperationId, chatPreviewDigest, } from "../../chat.js";
@@ -51,6 +51,7 @@ chats) {
51
51
  const attribution = ontology.config.chat?.attribution;
52
52
  const separator = attribution?.separator ?? "\n\n";
53
53
  const takeoverChannels = takeoverChannelsOf(ontology.manifest);
54
+ const unsignedReplies = inboxAttributionOf(ontology.manifest) === "none";
54
55
  const providers = listedChatProviders(ontology.manifest.chat);
55
56
  const destination = ontology.manifest.chat?.telegram?.connection;
56
57
  const destinationPreviews = previews.settings?.connection === destination ? previews : { ownOrigins: previews.ownOrigins };
@@ -87,7 +88,8 @@ chats) {
87
88
  }
88
89
  const inbox = yield* inboxChat(input.chat, permission);
89
90
  // A member answers a person in the inbox from their own session in the app, signed with
90
- // their name as the workspace's attribution lays it out.
91
+ // their name as the workspace's attribution lays it out, or unsigned where the inbox's
92
+ // `attribution` is `none`: only this reply, never a post to a group or by another caller.
91
93
  const requester = (inbox !== undefined || asAgent) &&
92
94
  context.caller.kind === "member" &&
93
95
  context.caller.subjectId === context.principal.id &&
@@ -99,7 +101,9 @@ chats) {
99
101
  via: "hq",
100
102
  clientId: null,
101
103
  clientName: null,
102
- attribution: (attribution?.template ?? "{name}").replace(/\{(name|client)\}/g, (_, key) => (key === "name" ? String(user.name) : "")),
104
+ attribution: inbox !== undefined && !asAgent && unsignedReplies
105
+ ? ""
106
+ : (attribution?.template ?? "{name}").replace(/\{(name|client)\}/g, (_, key) => (key === "name" ? String(user.name) : "")),
103
107
  }
104
108
  : yield* deliveryRequester(context.caller, context.principal, String(user.name), attribution);
105
109
  if (context.caller.kind === "runtime" &&
@@ -152,7 +156,8 @@ chats) {
152
156
  message: "Chat posting requires a configured connection for the chat's provider.",
153
157
  });
154
158
  }
155
- // The agent's own message carries no attribution, as a reply a member approved does not.
159
+ // The agent's own message carries no attribution, as a reply a member approved does not,
160
+ // and neither does a member's unsigned reply in the inbox; without one, no separator.
156
161
  const signature = asAgent ? "" : requester.attribution;
157
162
  const invalid = () => new ActionRejected({
158
163
  message: "The exact attributed message or reply target is invalid or too long. Nothing was truncated.",
@@ -243,7 +248,7 @@ chats) {
243
248
  }
244
249
  const text = input.text ?? "";
245
250
  const { finalText, plainText } = yield* Effect.try({
246
- try: () => provider.render(text, signature, asAgent ? "" : separator),
251
+ try: () => provider.render(text, signature, signature === "" ? "" : separator),
247
252
  catch: (cause) => new ActionRejected({ message: "The Markdown could not be rendered.", cause }),
248
253
  });
249
254
  if (!text.trim() ||
@@ -534,8 +539,11 @@ chats) {
534
539
  sessionId: context.envelope?.session_id ?? null,
535
540
  turnId: null,
536
541
  // The claim binds text immutably. Keep the source here and the actual wire payload
537
- // in argsSummary, which can record the plain retry without changing that binding.
538
- text: asAgent ? preview.text : `${preview.text}${separator}${requester.attribution}`,
542
+ // in argsSummary, which can record the plain retry without changing that binding. A
543
+ // message without attribution is kept as written.
544
+ text: preview.attribution === ""
545
+ ? preview.text
546
+ : `${preview.text}${separator}${preview.attribution}`,
539
547
  decision: null,
540
548
  reason: null,
541
549
  toolCallId: null,
@@ -571,7 +579,7 @@ chats) {
571
579
  destination: target,
572
580
  connection,
573
581
  text: preview.text,
574
- separator,
582
+ separator: preview.attribution === "" ? "" : separator,
575
583
  attribution: preview.attribution,
576
584
  finalText: preview.finalText,
577
585
  previews: destinationPreviews,
@@ -39,7 +39,10 @@ export interface ChatSend {
39
39
  readonly finalText: string;
40
40
  readonly plainText: string;
41
41
  readonly replyTo: string | null;
42
- /** The forum topic of a Telegram group to send in; others ignore it. */
42
+ /**
43
+ * The chat's thread to send in: a Telegram group's forum topic, the Slack thread of a message
44
+ * that replies to none, the person's Gmail thread, or a workspace channel's; WhatsApp ignores it.
45
+ */
43
46
  readonly threadId?: string | null;
44
47
  /** Telegram's link preview settings for its destination connection; others ignore them. */
45
48
  readonly previews?: TelegramPreviewContext;
@@ -1,9 +1,10 @@
1
1
  import { Effect } from "effect";
2
2
  import { type ChatProvider, type ChatSend, type ProviderOutcome } from "./provider.js";
3
3
  /**
4
- * One `chat.postMessage` through the connection's `web` API, never retried. Slack's own refusal
5
- * (`ok: false` with an error code) is definite; a timeout, a 5xx, an unparseable answer or a
6
- * success that does not name the message is uncertain.
4
+ * One `chat.postMessage` through the connection's `web` API, never retried, in the thread of the
5
+ * message it replies to, else in the chat's thread, such as the one a reviewed reply answers.
6
+ * Slack's own refusal (`ok: false` with an error code) is definite; a timeout, a 5xx, an
7
+ * unparseable answer or a success that does not name the message, or its thread, is uncertain.
7
8
  */
8
9
  export declare function sendSlack(input: ChatSend): Effect.Effect<ProviderOutcome>;
9
10
  /** Slack: the member's Markdown as `markdown_text`, in a channel or a member's direct message. */
@@ -13,13 +13,16 @@ const POSSIBLY_POSTED = new Set([
13
13
  "service_unavailable",
14
14
  ]);
15
15
  /**
16
- * One `chat.postMessage` through the connection's `web` API, never retried. Slack's own refusal
17
- * (`ok: false` with an error code) is definite; a timeout, a 5xx, an unparseable answer or a
18
- * success that does not name the message is uncertain.
16
+ * One `chat.postMessage` through the connection's `web` API, never retried, in the thread of the
17
+ * message it replies to, else in the chat's thread, such as the one a reviewed reply answers.
18
+ * Slack's own refusal (`ok: false` with an error code) is definite; a timeout, a 5xx, an
19
+ * unparseable answer or a success that does not name the message, or its thread, is uncertain.
19
20
  */
20
21
  export function sendSlack(input) {
21
22
  return Effect.gen(function* () {
22
23
  const payload = { markdown_text: input.finalText };
24
+ const thread = input.replyTo ??
25
+ (typeof input.threadId === "string" && SLACK_TS.test(input.threadId) ? input.threadId : null);
23
26
  const result = yield* input.transport
24
27
  .request({
25
28
  connection: input.connection,
@@ -30,7 +33,7 @@ export function sendSlack(input) {
30
33
  body: new TextEncoder().encode(JSON.stringify({
31
34
  channel: input.destination.external_id,
32
35
  ...payload,
33
- ...(input.replyTo === null ? {} : { thread_ts: input.replyTo }),
36
+ ...(thread === null ? {} : { thread_ts: thread }),
34
37
  })),
35
38
  })
36
39
  .pipe(Effect.exit);
@@ -70,7 +73,7 @@ export function sendSlack(input) {
70
73
  body.channel === "" ||
71
74
  // A member's direct message is posted to their user id and answers with its `D…` channel.
72
75
  (input.destination.kind === "group" && body.channel !== input.destination.external_id) ||
73
- (input.replyTo !== null && message.thread_ts !== input.replyTo)) {
76
+ (thread !== null && message.thread_ts !== thread)) {
74
77
  return uncertain(new Error("Slack success could not be verified."));
75
78
  }
76
79
  return { payload, status: "sent", messageId: body.ts, url: null };
@@ -552,6 +552,7 @@ export declare const Catalog: Schema.decodeTo<Schema.Struct<{
552
552
  readonly takeover: Schema.optionalKey<Schema.Struct<{
553
553
  readonly channels: Schema.$Array<Schema.String>;
554
554
  }>>;
555
+ readonly attribution: Schema.optionalKey<Schema.Literals<readonly ["name", "none"]>>;
555
556
  }>>;
556
557
  readonly metrics: Schema.optionalKey<Schema.$Array<Schema.Struct<{
557
558
  readonly name: Schema.String;
@@ -914,6 +915,7 @@ export declare const Catalog: Schema.decodeTo<Schema.Struct<{
914
915
  readonly takeover: Schema.optionalKey<Schema.Struct<{
915
916
  readonly channels: Schema.$Array<Schema.String>;
916
917
  }>>;
918
+ readonly attribution: Schema.optionalKey<Schema.Literals<readonly ["name", "none"]>>;
917
919
  }>>>;
918
920
  readonly metrics: Schema.toEncoded<Schema.optionalKey<Schema.$Array<Schema.Struct<{
919
921
  readonly name: Schema.String;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream/ontology",
3
- "version": "0.138.0",
3
+ "version": "0.139.0",
4
4
  "description": "Define a SegmentStream workspace app's ontology: entities, relationships, roles and actions, written with Effect.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SegmentStream",