@segmentstream/ontology 0.98.0 → 0.99.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.
Files changed (46) hide show
  1. package/README.md +8 -5
  2. package/dist/agent-review.d.ts +4 -4
  3. package/dist/agent-review.js +10 -10
  4. package/dist/app-feedback.js +1 -1
  5. package/dist/groups.d.ts +11 -4
  6. package/dist/groups.js +54 -11
  7. package/dist/permissions.d.ts +1 -1
  8. package/dist/permissions.js +1 -1
  9. package/dist/runtime-source.js +3 -3
  10. package/dist/service/agent/{conversation-routes.d.ts → archive-routes.d.ts} +7 -4
  11. package/dist/service/agent/{conversation-routes.js → archive-routes.js} +8 -5
  12. package/dist/service/agent/attachments.d.ts +2 -2
  13. package/dist/service/agent/attachments.js +2 -2
  14. package/dist/service/agent/authentication.d.ts +1 -1
  15. package/dist/service/agent/authentication.js +7 -5
  16. package/dist/service/agent/{conversations.d.ts → chat-archive.d.ts} +11 -11
  17. package/dist/service/agent/{conversations.js → chat-archive.js} +12 -12
  18. package/dist/service/agent/protocol.js +2 -2
  19. package/dist/service/chat/archive.d.ts +2 -2
  20. package/dist/service/chat/archive.js +1 -1
  21. package/dist/service/chat/attribution.d.ts +1 -1
  22. package/dist/service/chat/delivery.d.ts +2 -2
  23. package/dist/service/chat/delivery.js +2 -2
  24. package/dist/service/chat/idempotency.d.ts +3 -3
  25. package/dist/service/chat/reads.d.ts +3 -3
  26. package/dist/service/chat/reads.js +10 -10
  27. package/dist/service/chat/resolve.d.ts +6 -6
  28. package/dist/service/chat/resolve.js +7 -7
  29. package/dist/service/chat/review-delivery.d.ts +1 -1
  30. package/dist/service/chat/review-delivery.js +4 -4
  31. package/dist/service/chat/routes.d.ts +2 -2
  32. package/dist/service/chat/routes.js +7 -7
  33. package/dist/service/errors.js +3 -3
  34. package/dist/service/mcp/server.d.ts +3 -3
  35. package/dist/service/mcp/server.js +20 -16
  36. package/dist/service/mcp/tools.d.ts +2 -2
  37. package/dist/service/mcp/tools.js +12 -14
  38. package/dist/service/member-file-routes.js +26 -2
  39. package/dist/service/member-files.d.ts +7 -7
  40. package/dist/service/member-files.js +2 -2
  41. package/dist/service/service.js +9 -9
  42. package/dist/storage/attachments.d.ts +3 -3
  43. package/dist/storage/attachments.js +16 -15
  44. package/dist/storage/tables.d.ts +4 -0
  45. package/dist/storage/tables.js +4 -0
  46. package/package.json +1 -1
@@ -5,7 +5,7 @@ import type { Operations } from "./operations.js";
5
5
  import type { ApiPlan } from "./plan.js";
6
6
  import type { OntologyBackend } from "./runtime-contract.js";
7
7
  export declare const AttachmentFilters: Schema.Struct<{
8
- readonly conversation: Schema.optionalKey<Schema.String>;
8
+ readonly chat: Schema.optionalKey<Schema.String>;
9
9
  readonly sender_id: Schema.optionalKey<Schema.String>;
10
10
  readonly from: Schema.optionalKey<Schema.String>;
11
11
  readonly to: Schema.optionalKey<Schema.String>;
@@ -14,7 +14,7 @@ export declare const AttachmentFilters: Schema.Struct<{
14
14
  }>;
15
15
  export declare const MEMBER_FILE_SCHEMAS: {
16
16
  "attachments-list": Schema.Struct<{
17
- readonly conversation: Schema.optionalKey<Schema.String>;
17
+ readonly chat: Schema.optionalKey<Schema.String>;
18
18
  readonly sender_id: Schema.optionalKey<Schema.String>;
19
19
  readonly from: Schema.optionalKey<Schema.String>;
20
20
  readonly to: Schema.optionalKey<Schema.String>;
@@ -84,7 +84,7 @@ export declare function attachmentForWire(attachment: import("../storage/attachm
84
84
  created_at: string;
85
85
  expires_at: string;
86
86
  promotion: unknown;
87
- conversation: string | undefined;
87
+ chat: string | undefined;
88
88
  sender_id: string | undefined;
89
89
  };
90
90
  /** The member REST and MCP surfaces run the same runtime operations and action pipeline. */
@@ -174,7 +174,7 @@ export declare function memberFileOperations(backend: OntologyBackend["Service"]
174
174
  created_at: string;
175
175
  expires_at: string;
176
176
  promotion: unknown;
177
- conversation: string | undefined;
177
+ chat: string | undefined;
178
178
  sender_id: string | undefined;
179
179
  }[];
180
180
  nextCursor: string | null;
@@ -192,7 +192,7 @@ export declare function memberFileOperations(backend: OntologyBackend["Service"]
192
192
  created_at: string;
193
193
  expires_at: string;
194
194
  promotion: unknown;
195
- conversation: string | undefined;
195
+ chat: string | undefined;
196
196
  sender_id: string | undefined;
197
197
  };
198
198
  deduplicated: boolean;
@@ -212,7 +212,7 @@ export declare function memberFileOperations(backend: OntologyBackend["Service"]
212
212
  created_at: string;
213
213
  expires_at: string;
214
214
  promotion: unknown;
215
- conversation: string | undefined;
215
+ chat: string | undefined;
216
216
  sender_id: string | undefined;
217
217
  };
218
218
  upload?: undefined;
@@ -230,7 +230,7 @@ export declare function memberFileOperations(backend: OntologyBackend["Service"]
230
230
  created_at: string;
231
231
  expires_at: string;
232
232
  promotion: unknown;
233
- conversation: string | undefined;
233
+ chat: string | undefined;
234
234
  sender_id: string | undefined;
235
235
  };
236
236
  download: {
@@ -10,7 +10,7 @@ import { InvalidRequestBody, RequestId } from "./errors.js";
10
10
  const Id = Schema.String.check(Schema.isUUID());
11
11
  const DateTime = Schema.String.check(Schema.isPattern(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/));
12
12
  export const AttachmentFilters = Schema.Struct({
13
- conversation: Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200))),
13
+ chat: Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200))),
14
14
  sender_id: Schema.optionalKey(Id),
15
15
  from: Schema.optionalKey(DateTime),
16
16
  to: Schema.optionalKey(DateTime),
@@ -88,7 +88,7 @@ export function attachmentForWire(attachment) {
88
88
  created_at: attachment.createdAt,
89
89
  expires_at: attachment.expiresAt,
90
90
  promotion: attachment.promotion,
91
- conversation: attachment.conversation,
91
+ chat: attachment.chat,
92
92
  sender_id: attachment.senderId,
93
93
  };
94
94
  }
@@ -15,8 +15,8 @@ import { neonSignInLinks, segmentstreamSignInLinks } from "../runtime/sign-in-li
15
15
  import { memberFileRoutes } from "./member-file-routes.js";
16
16
  import { attachmentsLayer } from "./agent/attachments.js";
17
17
  import { filesLayer } from "./agent/files.js";
18
- import { platformConversations } from "./agent/conversations.js";
19
- import { conversationRoutes } from "./agent/conversation-routes.js";
18
+ import { platformChatArchive } from "./agent/chat-archive.js";
19
+ import { archiveRoutes } from "./agent/archive-routes.js";
20
20
  import { makeChatDelivery } from "./chat/delivery.js";
21
21
  import { platformDeliveryArchive } from "./chat/archive.js";
22
22
  import { chatRoutes } from "./chat/routes.js";
@@ -338,7 +338,7 @@ export function createOntologyService(ontology, config) {
338
338
  : localConnections(config.localConnections)));
339
339
  const replicate = deployedReplication(config);
340
340
  const chatDelivery = makeChatDelivery(ontology, connections, config.chatArchive ?? platformDeliveryArchive(config), { settings: config.channels?.telegram, ownOrigins: config.appOrigins });
341
- const conversations = config.runtimeIdentity === undefined ? undefined : platformConversations(config);
341
+ const chatHistory = config.runtimeIdentity === undefined ? undefined : platformChatArchive(config);
342
342
  const metricQueries = makeMetricQueries({
343
343
  ontology,
344
344
  transport: platformMetricQueries({ ...config, manifestHash: ontology.manifest.hash }),
@@ -359,7 +359,7 @@ export function createOntologyService(ontology, config) {
359
359
  replicate,
360
360
  metricQueries,
361
361
  chatDelivery,
362
- conversations,
362
+ chatHistory,
363
363
  ...(navigation === undefined ? {} : { navigation }),
364
364
  appOrigins: config.appOrigins,
365
365
  streamMaxDurationMs: config.mcpStreamMaxDurationMs,
@@ -397,7 +397,7 @@ export function createOntologyService(ontology, config) {
397
397
  connections,
398
398
  replicate,
399
399
  chatDelivery,
400
- conversations,
400
+ chatHistory,
401
401
  verifyToken,
402
402
  verifyRuntime,
403
403
  exchangeSession,
@@ -409,10 +409,10 @@ export function createOntologyService(ontology, config) {
409
409
  chatDelivery,
410
410
  verifyToken,
411
411
  exchangeSession,
412
- }), preview ? Layer.empty : filesLayer({ plan: built.plan, verifyRuntime }), conversations === undefined
412
+ }), preview ? Layer.empty : filesLayer({ plan: built.plan, verifyRuntime }), chatHistory === undefined
413
413
  ? Layer.empty
414
- : conversationRoutes({
415
- transport: conversations,
414
+ : archiveRoutes({
415
+ transport: chatHistory,
416
416
  verifyToken,
417
417
  verifyRuntime,
418
418
  exchangeSession,
@@ -479,7 +479,7 @@ export function createOntologyService(ontology, config) {
479
479
  requireDeploymentCapability(deployment);
480
480
  if (preview) {
481
481
  const path = new URL(request.url).pathname;
482
- const blocked = /^\/api\/ontology\/(?:agent|agents|chat|conversations|attachments|channels)(?:\/|$)/.test(path)
482
+ const blocked = /^\/api\/ontology\/(?:agent|agents|chat|attachments|channels)(?:\/|$)/.test(path)
483
483
  ? "agents"
484
484
  : undefined;
485
485
  if (blocked) {
@@ -25,7 +25,7 @@ export { ATTACHMENT_SOURCES };
25
25
  export interface AttachmentCaller {
26
26
  readonly principal: Principal;
27
27
  /** The chat the attachment arrived in, such as `telegram:12345`. */
28
- readonly conversation: string;
28
+ readonly chat: string;
29
29
  /**
30
30
  * The agent session the request comes from. Private attachments stay bound to the first session
31
31
  * that reads them. Group attachments are shared across authorized sessions in the same chat.
@@ -64,11 +64,11 @@ export interface AttachmentView {
64
64
  readonly createdAt: string;
65
65
  readonly expiresAt: string;
66
66
  readonly promotion: unknown;
67
- readonly conversation?: string;
67
+ readonly chat?: string;
68
68
  readonly senderId?: string;
69
69
  }
70
70
  export interface AttachmentSearch {
71
- readonly conversation?: string;
71
+ readonly chat?: string;
72
72
  readonly senderId?: string;
73
73
  readonly from?: string;
74
74
  readonly to?: string;
@@ -25,7 +25,8 @@ export const ATTACHMENT_TTL_HOURS = 24;
25
25
  export const MAX_LIVE_ATTACHMENTS = 50;
26
26
  export { ATTACHMENT_SOURCES };
27
27
  const SHA256 = /^[0-9a-f]{64}$/;
28
- const SELECT = `SELECT a.id::text, a.blob_id::text, b.key, a.owner_id::text, a.conversation,
28
+ // @legacy ontology.attachment-conversation-column: the SQL here names the chat column `conversation`.
29
+ const SELECT = `SELECT a.id::text, a.blob_id::text, b.key, a.owner_id::text, a.conversation AS chat,
29
30
  a.session_id, a.filename, a.content_type, a.size::text, a.sha256, a.state, a.provider_upload_id,
30
31
  a.promotion,
31
32
  to_char(a.created_at AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"') AS created_at,
@@ -97,7 +98,7 @@ function view(row) {
97
98
  createdAt: row.created_at,
98
99
  expiresAt: row.expires_at,
99
100
  promotion: row.promotion ?? null,
100
- conversation: row.conversation,
101
+ chat: row.chat,
101
102
  senderId: row.owner_id,
102
103
  };
103
104
  }
@@ -121,9 +122,9 @@ export function attachmentRuntime(ontology, sql, provider) {
121
122
  return "administrator";
122
123
  }
123
124
  }
124
- const separator = caller.conversation.indexOf(":");
125
+ const separator = caller.chat.indexOf(":");
125
126
  const [chat] = yield* sql.unsafe(`SELECT id::text FROM "agent_chat"
126
- WHERE provider = $1 AND external_id = $2 FOR SHARE`, [caller.conversation.slice(0, separator), caller.conversation.slice(separator + 1)]);
127
+ WHERE provider = $1 AND external_id = $2 FOR SHARE`, [caller.chat.slice(0, separator), caller.chat.slice(separator + 1)]);
127
128
  if (chat === undefined) {
128
129
  return "private";
129
130
  }
@@ -157,7 +158,7 @@ export function attachmentRuntime(ontology, sql, provider) {
157
158
  AND a.branch_id = $4 FOR UPDATE OF a, b`, [
158
159
  id,
159
160
  caller.principal.id,
160
- caller.conversation,
161
+ caller.chat,
161
162
  binding.branchId,
162
163
  (access === "group" || access === "administrator") && scope === "session",
163
164
  ]);
@@ -210,7 +211,7 @@ export function attachmentRuntime(ontology, sql, provider) {
210
211
  yield* authorizeBlobOperation(ontology, sql, caller.principal.id, [], caller.principal.execution);
211
212
  yield* sql.unsafe(`SELECT pg_advisory_xact_lock(818724)`);
212
213
  const [existing] = yield* sql.unsafe(`SELECT id::text FROM "${ATTACHMENTS_TABLE}"
213
- WHERE owner_id = $1::uuid AND conversation = $2 AND source_ref = $3`, [caller.principal.id, caller.conversation, input.sourceRef]);
214
+ WHERE owner_id = $1::uuid AND conversation = $2 AND source_ref = $3`, [caller.principal.id, caller.chat, input.sourceRef]);
214
215
  if (existing) {
215
216
  const row = yield* load(existing.id, caller, "source");
216
217
  if (row.sha256 !== input.sha256 || Number(row.size) !== input.size) {
@@ -259,7 +260,7 @@ export function attachmentRuntime(ontology, sql, provider) {
259
260
  blobId,
260
261
  binding.branchId,
261
262
  caller.principal.id,
262
- caller.conversation,
263
+ caller.chat,
263
264
  caller.sessionId ?? null,
264
265
  input.source,
265
266
  input.sourceRef,
@@ -346,7 +347,7 @@ export function attachmentRuntime(ontology, sql, provider) {
346
347
  AND ($5 OR a.session_id IS NULL OR a.session_id = $4)
347
348
  ORDER BY a.created_at DESC LIMIT ${MAX_LIVE_ATTACHMENTS}`, [
348
349
  caller.principal.id,
349
- caller.conversation,
350
+ caller.chat,
350
351
  binding.branchId,
351
352
  caller.sessionId ?? null,
352
353
  access === "group",
@@ -453,7 +454,7 @@ export function attachmentRuntime(ontology, sql, provider) {
453
454
  binding.branchId,
454
455
  row.id,
455
456
  qualified,
456
- caller.conversation,
457
+ caller.chat,
457
458
  caller.principal.id,
458
459
  ["group", "administrator"].includes(yield* accessScope(caller)),
459
460
  caller.sessionId ?? null,
@@ -562,13 +563,13 @@ export function attachmentRuntime(ontology, sql, provider) {
562
563
  if (!/^[0-9a-f-]{36}$/i.test(id)) {
563
564
  return yield* missing(id);
564
565
  }
565
- const [row] = yield* sql.unsafe(`SELECT conversation FROM "${ATTACHMENTS_TABLE}" WHERE id = $1::uuid AND branch_id = $2`, [id, binding.branchId]);
566
+ const [row] = yield* sql.unsafe(`SELECT conversation AS chat FROM "${ATTACHMENTS_TABLE}" WHERE id = $1::uuid AND branch_id = $2`, [id, binding.branchId]);
566
567
  if (!row) {
567
568
  return yield* missing(id);
568
569
  }
569
570
  const caller = {
570
571
  principal,
571
- conversation: row.conversation,
572
+ chat: row.chat,
572
573
  access: "member",
573
574
  };
574
575
  yield* load(id, caller);
@@ -597,10 +598,10 @@ export function attachmentRuntime(ontology, sql, provider) {
597
598
  const admin = yield* authorizeBlobOperation(ontology, sql, principal.id, [
598
599
  "agent_chat:update",
599
600
  ]).pipe(Effect.as(true), Effect.catchTag("PermissionDenied", () => Effect.succeed(false)));
600
- if (filters.conversation !== undefined) {
601
+ if (filters.chat !== undefined) {
601
602
  const scope = yield* accessScope({
602
603
  principal,
603
- conversation: filters.conversation,
604
+ chat: filters.chat,
604
605
  access: "member",
605
606
  });
606
607
  if (scope === "denied") {
@@ -608,7 +609,7 @@ export function attachmentRuntime(ontology, sql, provider) {
608
609
  }
609
610
  if (scope === "private") {
610
611
  const [sent] = yield* sql.unsafe(`SELECT 1 FROM "${ATTACHMENTS_TABLE}" WHERE branch_id = $1 AND conversation = $2
611
- AND owner_id = $3::uuid LIMIT 1`, [binding.branchId, filters.conversation, principal.id]);
612
+ AND owner_id = $3::uuid LIMIT 1`, [binding.branchId, filters.chat, principal.id]);
612
613
  if (sent === undefined) {
613
614
  return yield* missing("chat");
614
615
  }
@@ -633,7 +634,7 @@ export function attachmentRuntime(ontology, sql, provider) {
633
634
  binding.branchId,
634
635
  admin,
635
636
  principal.id,
636
- filters.conversation ?? null,
637
+ filters.chat ?? null,
637
638
  filters.senderId ?? null,
638
639
  filters.from ?? null,
639
640
  filters.to ?? null,
@@ -14,6 +14,10 @@ export declare const ATTACHMENT_SOURCE_CHECK = "_agent_attachments_source_check"
14
14
  * a `_blobs` revision in the same storage as uploads; the row binds them to their owner, the chat
15
15
  * and, for private chats, the first agent session that reads them. Group access follows the chat
16
16
  * registry's current members. Attachments expire 24 hours after receipt unless promoted.
17
+ *
18
+ * @legacy ontology.attachment-conversation-column
19
+ * The column `conversation` holds the chat, `provider:external_id`: SDKs sharing this database
20
+ * still read and write it under that name.
17
21
  */
18
22
  export declare const ATTACHMENT_TABLES_DDL: ReadonlyArray<string>;
19
23
  /** The pending and started workflow starts of action triggers, beside the blob action results. */
@@ -68,6 +68,10 @@ const SOURCE_CHECK = `CHECK ("source" IN (${ATTACHMENT_SOURCES.map((source) => `
68
68
  * a `_blobs` revision in the same storage as uploads; the row binds them to their owner, the chat
69
69
  * and, for private chats, the first agent session that reads them. Group access follows the chat
70
70
  * registry's current members. Attachments expire 24 hours after receipt unless promoted.
71
+ *
72
+ * @legacy ontology.attachment-conversation-column
73
+ * The column `conversation` holds the chat, `provider:external_id`: SDKs sharing this database
74
+ * still read and write it under that name.
71
75
  */
72
76
  export const ATTACHMENT_TABLES_DDL = [
73
77
  `CREATE TABLE IF NOT EXISTS "${ATTACHMENTS_TABLE}" (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream/ontology",
3
- "version": "0.98.0",
3
+ "version": "0.99.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",