@segmentstream/ontology 0.207.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,20 @@
|
|
|
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
|
+
|
|
3
18
|
## 0.207.0
|
|
4
19
|
|
|
5
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.
|
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
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
12
|
-
|
|
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) :
|
|
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
|
},
|
|
@@ -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
|
|
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
|
|
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
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segmentstream/ontology",
|
|
3
|
-
"version": "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",
|