@segmentstream/ontology 0.206.0 → 0.208.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,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.208.0
4
+
5
+ The agent's limit on sign-ups is named for what it counts, and a workspace may raise its
6
+ workspace-wide limits. In `agent/segmentstream.json`, `limits.signUpsPerHour` caps the people who
7
+ sign up in an hour by writing to the agent, in every channel together, and `replies.signUpsLimited`
8
+ is what they are told past it. `limits.newUsersPerHour` and `replies.registrationsLimited`, their
9
+ earlier names, still work until 2027-03-02, and the deploy warns to rename them.
10
+
11
+ The limits shown in the docs are the defaults. A limit on one person, `perSender` and
12
+ `guest.turnsPerDay`, guards against floods and reply loops and can still only be lowered. A limit
13
+ on the whole workspace grows with the business and may now be raised: `signUpsPerHour` up to 1000,
14
+ `workspaceTurnsPerDay` up to 100000 and `guest.workspaceTurnsPerDay` up to 100000. The ontology
15
+ takes a raised limit from an agent SDK with this change; upgrade both together, since an earlier
16
+ ontology keeps the earlier ceilings.
17
+
18
+ ## 0.207.0
19
+
20
+ Ontology actions can read the verified original Telegram message time in `context.runtime.source.sent_at`, including when delivery was delayed or the sender edited the message. The agent sends the field only to ontologies that advertise support.
21
+
3
22
  ## 0.206.0
4
23
 
5
24
  A Telegram Mini App can opt into pairing the original sender with an invited workspace email account, with the same signed browser challenge as Cloud sign-in.
package/README.md CHANGED
@@ -1443,7 +1443,10 @@ It returns 200 with `status`:
1443
1443
 
1444
1444
  `limits` has the v2 agent shape:
1445
1445
  `{ perSender: { turnsPerMinute: 6, turnsPerDay: 80 }, newUsersPerHour: 30, workspaceTurnsPerDay: 3000 }`.
1446
- These values are platform defaults **and ceilings**; trusted overrides can only lower them. Scopes are
1446
+ These values are the platform defaults; `newUsersPerHour` is the agent's `signUpsPerHour`, under the
1447
+ name the protocol keeps. Trusted overrides may lower each of them, and raise the workspace-wide ones,
1448
+ `newUsersPerHour` and `workspaceTurnsPerDay`, up to `PLATFORM_CHANNEL_LIMITS` (1000 and 100000); the
1449
+ per-sender limits cannot be raised. Scopes are
1447
1450
  `turnsPerMinute`, `turnsPerDay`, `newUsersPerHour`, `workspaceTurnsPerDay`. The latest submitted effective
1448
1451
  limits persist in `_channel_limits`; omitted limits reuse them, or defaults before the first submission.
1449
1452
  Only trusted agent configuration may submit limits; browser assertions must never supply them.
@@ -1,9 +1,16 @@
1
1
  import { Effect } from "effect";
2
2
  import type { SqlClient } from "effect/unstable/sql";
3
3
  import type { AgentLimits, AgentLimitScope, AgentResolution, ResolveIdentityInput } from "../service/runtime-contract.js";
4
- /** Defaults shared by bot resolution and other trusted channel admission boundaries. */
4
+ /**
5
+ * The limits that apply where the agent sets none, shared by bot resolution and other trusted
6
+ * channel admission boundaries. `newUsersPerHour` is the agent's `signUpsPerHour`, under the name
7
+ * the protocol keeps.
8
+ */
5
9
  export declare const DEFAULT_AGENT_LIMITS: AgentLimits;
6
- /** Platform ceilings. Workspace policy can only lower these values. */
10
+ /**
11
+ * Platform ceilings. A limit on one person can only be lowered: its ceiling is its default. A
12
+ * limit on the whole workspace may be raised up to its ceiling.
13
+ */
7
14
  export declare const PLATFORM_CHANNEL_LIMITS: AgentLimits;
8
15
  /**
9
16
  * Ceilings of the guests' daily model cost, in US dollars. Unlike the turn limits they have no
@@ -20,6 +27,7 @@ export declare const GUEST_USD_CEILINGS: Readonly<{
20
27
  export declare const GUEST_USD_UNIT = 0.0001;
21
28
  /** The most one usage report may add, in US dollars; a turn costing more is counted at this. */
22
29
  export declare const MAX_GUEST_USAGE_REPORT_USD = 100;
30
+ /** The agent's limits within the platform's ceilings; the default for each it leaves out. */
23
31
  export declare function clampChannelLimits(input: ResolveIdentityInput["limits"]): AgentLimits;
24
32
  /**
25
33
  * Only trusted runtimes submit limits; channel-app callers omit them and reuse the latest policy.
@@ -1,15 +1,30 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { Effect, Schema } from "effect";
3
3
  import { AGENT_COUNTERS_TABLE, CHANNEL_LIMITS_TABLE } from "../migrate/storage.js";
4
- /** Defaults shared by bot resolution and other trusted channel admission boundaries. */
4
+ /**
5
+ * The limits that apply where the agent sets none, shared by bot resolution and other trusted
6
+ * channel admission boundaries. `newUsersPerHour` is the agent's `signUpsPerHour`, under the name
7
+ * the protocol keeps.
8
+ */
5
9
  export const DEFAULT_AGENT_LIMITS = Object.freeze({
6
10
  perSender: Object.freeze({ turnsPerMinute: 6, turnsPerDay: 80 }),
7
11
  newUsersPerHour: 30,
8
12
  workspaceTurnsPerDay: 3000,
9
13
  guest: Object.freeze({ turnsPerDay: 20, workspaceTurnsPerDay: 1000 }),
10
14
  });
11
- /** Platform ceilings. Workspace policy can only lower these values. */
12
- export const PLATFORM_CHANNEL_LIMITS = DEFAULT_AGENT_LIMITS;
15
+ /**
16
+ * Platform ceilings. A limit on one person can only be lowered: its ceiling is its default. A
17
+ * limit on the whole workspace may be raised up to its ceiling.
18
+ */
19
+ export const PLATFORM_CHANNEL_LIMITS = Object.freeze({
20
+ perSender: DEFAULT_AGENT_LIMITS.perSender,
21
+ newUsersPerHour: 1000,
22
+ workspaceTurnsPerDay: 100_000,
23
+ guest: Object.freeze({
24
+ turnsPerDay: DEFAULT_AGENT_LIMITS.guest.turnsPerDay,
25
+ workspaceTurnsPerDay: 100_000,
26
+ }),
27
+ });
13
28
  /**
14
29
  * Ceilings of the guests' daily model cost, in US dollars. Unlike the turn limits they have no
15
30
  * default: a cap the agent does not set does not apply.
@@ -41,20 +56,21 @@ function clampUsd(value, ceiling) {
41
56
  ? Math.min(value, ceiling)
42
57
  : undefined;
43
58
  }
59
+ /** The agent's limits within the platform's ceilings; the default for each it leaves out. */
44
60
  export function clampChannelLimits(input) {
45
- const clamp = (value, ceiling) => Number.isSafeInteger(value) && value > 0 ? Math.min(value, ceiling) : ceiling;
61
+ const clamp = (value, fallback, ceiling) => Number.isSafeInteger(value) && value > 0 ? Math.min(value, ceiling) : fallback;
46
62
  const usdPerDay = clampUsd(input?.guest?.usdPerDay, GUEST_USD_CEILINGS.usdPerDay);
47
63
  const workspaceUsdPerDay = clampUsd(input?.guest?.workspaceUsdPerDay, GUEST_USD_CEILINGS.workspaceUsdPerDay);
48
64
  return {
49
65
  perSender: {
50
- turnsPerMinute: clamp(input?.perSender?.turnsPerMinute, PLATFORM_CHANNEL_LIMITS.perSender.turnsPerMinute),
51
- turnsPerDay: clamp(input?.perSender?.turnsPerDay, PLATFORM_CHANNEL_LIMITS.perSender.turnsPerDay),
66
+ turnsPerMinute: clamp(input?.perSender?.turnsPerMinute, DEFAULT_AGENT_LIMITS.perSender.turnsPerMinute, PLATFORM_CHANNEL_LIMITS.perSender.turnsPerMinute),
67
+ turnsPerDay: clamp(input?.perSender?.turnsPerDay, DEFAULT_AGENT_LIMITS.perSender.turnsPerDay, PLATFORM_CHANNEL_LIMITS.perSender.turnsPerDay),
52
68
  },
53
- newUsersPerHour: clamp(input?.newUsersPerHour, PLATFORM_CHANNEL_LIMITS.newUsersPerHour),
54
- workspaceTurnsPerDay: clamp(input?.workspaceTurnsPerDay, PLATFORM_CHANNEL_LIMITS.workspaceTurnsPerDay),
69
+ newUsersPerHour: clamp(input?.newUsersPerHour, DEFAULT_AGENT_LIMITS.newUsersPerHour, PLATFORM_CHANNEL_LIMITS.newUsersPerHour),
70
+ workspaceTurnsPerDay: clamp(input?.workspaceTurnsPerDay, DEFAULT_AGENT_LIMITS.workspaceTurnsPerDay, PLATFORM_CHANNEL_LIMITS.workspaceTurnsPerDay),
55
71
  guest: {
56
- turnsPerDay: clamp(input?.guest?.turnsPerDay, PLATFORM_CHANNEL_LIMITS.guest.turnsPerDay),
57
- workspaceTurnsPerDay: clamp(input?.guest?.workspaceTurnsPerDay, PLATFORM_CHANNEL_LIMITS.guest.workspaceTurnsPerDay),
72
+ turnsPerDay: clamp(input?.guest?.turnsPerDay, DEFAULT_AGENT_LIMITS.guest.turnsPerDay, PLATFORM_CHANNEL_LIMITS.guest.turnsPerDay),
73
+ workspaceTurnsPerDay: clamp(input?.guest?.workspaceTurnsPerDay, DEFAULT_AGENT_LIMITS.guest.workspaceTurnsPerDay, PLATFORM_CHANNEL_LIMITS.guest.workspaceTurnsPerDay),
58
74
  ...(usdPerDay === undefined ? {} : { usdPerDay }),
59
75
  ...(workspaceUsdPerDay === undefined ? {} : { workspaceUsdPerDay }),
60
76
  },
@@ -12,6 +12,8 @@ export declare const RuntimeSource: Schema.Union<readonly [Schema.Struct<{
12
12
  readonly chat_id: Schema.String;
13
13
  readonly thread_id: Schema.String;
14
14
  readonly message_id: Schema.optionalKey<Schema.String>;
15
+ /** Original send time from the provider. Edits retain the original time. */
16
+ readonly sent_at: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
15
17
  readonly reply_to_message_id: Schema.optionalKey<Schema.String>;
16
18
  readonly callback_query_id: Schema.optionalKey<Schema.String>;
17
19
  readonly sender: Schema.optionalKey<Schema.String>;
@@ -1,4 +1,5 @@
1
1
  import { Schema } from "effect";
2
+ import { p } from "./property.js";
2
3
  import { ChatChannelName } from "./chat-channel.js";
3
4
  const Id = Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(512));
4
5
  /**
@@ -24,6 +25,8 @@ const TelegramRuntimeSource = Schema.Struct({
24
25
  chat_id: Id,
25
26
  thread_id: Schema.String.check(Schema.isMaxLength(512)),
26
27
  message_id: Schema.optionalKey(Id),
28
+ /** Original send time from the provider. Edits retain the original time. */
29
+ sent_at: Schema.optionalKey(p.timestamp()),
27
30
  reply_to_message_id: Schema.optionalKey(Id),
28
31
  callback_query_id: Schema.optionalKey(Id),
29
32
  sender: Schema.optionalKey(Id),
@@ -29,7 +29,8 @@ export declare const PairingRequest: Schema.Struct<{
29
29
  readonly display: Schema.optionalKey<Schema.NullOr<Schema.String>>;
30
30
  }>;
31
31
  /**
32
- * The agent's limits, as it sends them with a turn: each can only lower the platform's ceiling.
32
+ * The agent's limits, as it sends them with a turn, each within the platform's ceiling
33
+ * (`PLATFORM_CHANNEL_LIMITS`). `newUsersPerHour` is the agent's `signUpsPerHour`.
33
34
  * `guest` limits guests' turns, apart from those of people who signed up, and, when the agent sets
34
35
  * them, the model cost of each guest's turns and of every guest's together each day.
35
36
  */
@@ -56,7 +56,8 @@ function usdCap(ceiling) {
56
56
  return Schema.Number.check(Schema.isFinite(), Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(ceiling));
57
57
  }
58
58
  /**
59
- * The agent's limits, as it sends them with a turn: each can only lower the platform's ceiling.
59
+ * The agent's limits, as it sends them with a turn, each within the platform's ceiling
60
+ * (`PLATFORM_CHANNEL_LIMITS`). `newUsersPerHour` is the agent's `signUpsPerHour`.
60
61
  * `guest` limits guests' turns, apart from those of people who signed up, and, when the agent sets
61
62
  * them, the model cost of each guest's turns and of every guest's together each day.
62
63
  */
@@ -13,6 +13,7 @@ declare const RuntimeEnvelope: Schema.Struct<{
13
13
  readonly chat_id: Schema.String;
14
14
  readonly thread_id: Schema.String;
15
15
  readonly message_id: Schema.optionalKey<Schema.String>;
16
+ readonly sent_at: Schema.optionalKey<import("../../property.js").Property<string, false, false>>;
16
17
  readonly reply_to_message_id: Schema.optionalKey<Schema.String>;
17
18
  readonly callback_query_id: Schema.optionalKey<Schema.String>;
18
19
  readonly sender: Schema.optionalKey<Schema.String>;
@@ -61,6 +62,7 @@ declare const CurrentChatCall_base: Context.ServiceClass<CurrentChatCall, "@segm
61
62
  } | undefined;
62
63
  readonly channel?: string | undefined;
63
64
  readonly message_id?: string | undefined;
65
+ readonly sent_at?: string | undefined;
64
66
  readonly reply_to_message_id?: string | undefined;
65
67
  readonly callback_query_id?: string | undefined;
66
68
  readonly sender?: string | undefined;
@@ -115,6 +117,7 @@ export declare function consumeChatEnvelope(args: Readonly<Record<string, unknow
115
117
  } | undefined;
116
118
  readonly channel?: string | undefined;
117
119
  readonly message_id?: string | undefined;
120
+ readonly sent_at?: string | undefined;
118
121
  readonly reply_to_message_id?: string | undefined;
119
122
  readonly callback_query_id?: string | undefined;
120
123
  readonly sender?: string | undefined;
@@ -694,7 +694,12 @@ function dispatch(server, message, request) {
694
694
  // The agent runtime learns that tool calls accept its chat source, and from which
695
695
  // channels, without listing the catalog. The `me` tool keeps its `_meta` marker for
696
696
  // older agents.
697
- experimental: { [RUNTIME_SOURCE_META]: { providers: [...RUNTIME_SOURCE_PROVIDERS] } },
697
+ experimental: {
698
+ [RUNTIME_SOURCE_META]: {
699
+ providers: [...RUNTIME_SOURCE_PROVIDERS],
700
+ fields: ["telegram.sent_at"],
701
+ },
702
+ },
698
703
  },
699
704
  serverInfo: {
700
705
  name: "segmentstream-ontology",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream/ontology",
3
- "version": "0.206.0",
3
+ "version": "0.208.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",