@segmentstream/ontology 0.181.0 → 0.182.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 +4 -0
- package/dist/agent-chat.d.ts +2 -2
- package/dist/agent-chat.js +2 -1
- package/dist/agent-draft.d.ts +8 -8
- package/dist/analyze.d.ts +1 -8
- package/dist/analyze.js +108 -52
- package/dist/index.d.ts +1 -1
- package/dist/manifest.d.ts +110 -68
- package/dist/manifest.js +24 -2
- package/dist/migrate/model.d.ts +78 -50
- package/dist/runtime/agent-web.js +47 -26
- package/dist/runtime/agents.js +25 -0
- package/dist/runtime/guests.d.ts +4 -1
- package/dist/runtime/guests.js +24 -5
- package/dist/service/agent/server.d.ts +0 -2
- package/dist/service/agent/server.js +42 -47
- package/dist/service/authentication.js +14 -3
- package/dist/service/chat/envelope.d.ts +8 -8
- package/dist/service/chat/local-reads.d.ts +5 -5
- package/dist/service/discovery-search.d.ts +1 -1
- package/dist/service/operations.js +2 -1
- package/dist/service/runtime-contract.d.ts +3 -1
- package/dist/service/runtime-identity.d.ts +1 -0
- package/dist/service/runtime-identity.js +2 -0
- package/dist/service/schemas.d.ts +4 -0
- package/dist/service/service.js +0 -10
- package/dist/service/toolsets.d.ts +1 -1
- package/dist/service/toolsets.js +38 -4
- package/dist/sign-in.d.ts +14 -7
- package/dist/sign-in.js +4 -3
- package/dist/toolset.d.ts +17 -1
- package/package.json +1 -1
- package/dist/service/agent/public-group-action.d.ts +0 -23
- package/dist/service/agent/public-group-action.js +0 -53
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.182.0
|
|
4
|
+
|
|
5
|
+
Guest turns on admitted messaging channels use workspace roles, regular agent personas, and ontology tools. Workspaces select guest roles by channel and can handle authorized provider tools in workspace code. This replaces isolated group responses and their dedicated action and connection bindings.
|
|
6
|
+
|
|
3
7
|
## 0.181.0
|
|
4
8
|
|
|
5
9
|
The ontology service applies reply review. `POST /api/ontology/agent/replies` takes a reply the
|
package/dist/agent-chat.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare function agentChatKey(provider: string, externalId: string): stri
|
|
|
8
8
|
/** Existing chat registry and membership storage; delivery lives in the ontology service. */
|
|
9
9
|
export declare const AgentChat: import("./entity.js").Entity<"agent_chat", {
|
|
10
10
|
readonly provider: import("./property.js").Property<string, false, false>;
|
|
11
|
-
readonly kind: import("./property.js").Property<"
|
|
11
|
+
readonly kind: import("./property.js").Property<"group" | "private", true, false>;
|
|
12
12
|
readonly externalId: import("./property.js").Property<string, false, false>;
|
|
13
13
|
readonly key: Schema.optionalKey<import("./property.js").Property<string, false, true>>;
|
|
14
14
|
readonly title: import("./property.js").Property<string, false, false>;
|
|
@@ -162,7 +162,7 @@ export declare const AgentChat: import("./entity.js").Entity<"agent_chat", {
|
|
|
162
162
|
readonly createdBy: string | null;
|
|
163
163
|
readonly updatedBy: string | null;
|
|
164
164
|
readonly provider: string;
|
|
165
|
-
readonly kind: "
|
|
165
|
+
readonly kind: "group" | "private";
|
|
166
166
|
readonly externalId: string;
|
|
167
167
|
readonly key: string | null;
|
|
168
168
|
readonly title: string;
|
package/dist/agent-chat.js
CHANGED
|
@@ -91,7 +91,8 @@ export const AgentChat = entity("agent_chat", {
|
|
|
91
91
|
managed: true,
|
|
92
92
|
maxLength: 12,
|
|
93
93
|
label: "Group access",
|
|
94
|
-
description: "
|
|
94
|
+
description: "Allow unlinked senders to chat with the guest roles configured for this channel. " +
|
|
95
|
+
"The default requires a linked account.",
|
|
95
96
|
}),
|
|
96
97
|
personaNoticeAt: p.timestamp({
|
|
97
98
|
optional: true,
|
package/dist/agent-draft.d.ts
CHANGED
|
@@ -91,7 +91,7 @@ export declare const AgentDraft: import("./entity.js").Entity<"agent_draft", {
|
|
|
91
91
|
readonly to: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
|
|
92
92
|
readonly cc: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
|
|
93
93
|
readonly participants: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
|
|
94
|
-
readonly chatKind: import("./property.js").Property<"
|
|
94
|
+
readonly chatKind: import("./property.js").Property<"group" | "private", false, false>;
|
|
95
95
|
readonly threadId: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
|
|
96
96
|
readonly replyTo: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
|
|
97
97
|
readonly sessionId: import("./property.js").Property<string, false, false>;
|
|
@@ -101,7 +101,7 @@ export declare const AgentDraft: import("./entity.js").Entity<"agent_draft", {
|
|
|
101
101
|
readonly draft: import("./property.js").Property<string, false, false>;
|
|
102
102
|
readonly files: Schema.optionalKey<import("./property.js").Property<Schema.Json, false, false>>;
|
|
103
103
|
readonly text: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
|
|
104
|
-
readonly status: import("./property.js").Property<"pending" | "sent" | "failed" | "uncertain" | "rejected" | "
|
|
104
|
+
readonly status: import("./property.js").Property<"pending" | "sent" | "failed" | "uncertain" | "rejected" | "dismissed" | "superseded", false, false>;
|
|
105
105
|
readonly mode: import("./property.js").Property<"requested" | "always" | "whenUnsure", false, false>;
|
|
106
106
|
readonly confidence: Schema.optionalKey<import("./property.js").Property<number, false, false>>;
|
|
107
107
|
readonly messageId: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
|
|
@@ -181,7 +181,7 @@ export declare const AgentDraft: import("./entity.js").Entity<"agent_draft", {
|
|
|
181
181
|
readonly to: string | null;
|
|
182
182
|
readonly cc: string | null;
|
|
183
183
|
readonly participants: string | null;
|
|
184
|
-
readonly chatKind: "
|
|
184
|
+
readonly chatKind: "group" | "private";
|
|
185
185
|
readonly threadId: string | null;
|
|
186
186
|
readonly replyTo: string | null;
|
|
187
187
|
readonly sessionId: string;
|
|
@@ -191,7 +191,7 @@ export declare const AgentDraft: import("./entity.js").Entity<"agent_draft", {
|
|
|
191
191
|
readonly draft: string;
|
|
192
192
|
readonly files: Schema.Json;
|
|
193
193
|
readonly text: string | null;
|
|
194
|
-
readonly status: "pending" | "sent" | "failed" | "uncertain" | "rejected" | "
|
|
194
|
+
readonly status: "pending" | "sent" | "failed" | "uncertain" | "rejected" | "dismissed" | "superseded";
|
|
195
195
|
readonly mode: "requested" | "always" | "whenUnsure";
|
|
196
196
|
readonly confidence: number | null;
|
|
197
197
|
readonly messageId: string | null;
|
|
@@ -217,7 +217,7 @@ export declare const AgentReview: import("./entity.js").Entity<"agent_draft", {
|
|
|
217
217
|
readonly to: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
|
|
218
218
|
readonly cc: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
|
|
219
219
|
readonly participants: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
|
|
220
|
-
readonly chatKind: import("./property.js").Property<"
|
|
220
|
+
readonly chatKind: import("./property.js").Property<"group" | "private", false, false>;
|
|
221
221
|
readonly threadId: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
|
|
222
222
|
readonly replyTo: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
|
|
223
223
|
readonly sessionId: import("./property.js").Property<string, false, false>;
|
|
@@ -227,7 +227,7 @@ export declare const AgentReview: import("./entity.js").Entity<"agent_draft", {
|
|
|
227
227
|
readonly draft: import("./property.js").Property<string, false, false>;
|
|
228
228
|
readonly files: Schema.optionalKey<import("./property.js").Property<Schema.Json, false, false>>;
|
|
229
229
|
readonly text: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
|
|
230
|
-
readonly status: import("./property.js").Property<"pending" | "sent" | "failed" | "uncertain" | "rejected" | "
|
|
230
|
+
readonly status: import("./property.js").Property<"pending" | "sent" | "failed" | "uncertain" | "rejected" | "dismissed" | "superseded", false, false>;
|
|
231
231
|
readonly mode: import("./property.js").Property<"requested" | "always" | "whenUnsure", false, false>;
|
|
232
232
|
readonly confidence: Schema.optionalKey<import("./property.js").Property<number, false, false>>;
|
|
233
233
|
readonly messageId: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
|
|
@@ -307,7 +307,7 @@ export declare const AgentReview: import("./entity.js").Entity<"agent_draft", {
|
|
|
307
307
|
readonly to: string | null;
|
|
308
308
|
readonly cc: string | null;
|
|
309
309
|
readonly participants: string | null;
|
|
310
|
-
readonly chatKind: "
|
|
310
|
+
readonly chatKind: "group" | "private";
|
|
311
311
|
readonly threadId: string | null;
|
|
312
312
|
readonly replyTo: string | null;
|
|
313
313
|
readonly sessionId: string;
|
|
@@ -317,7 +317,7 @@ export declare const AgentReview: import("./entity.js").Entity<"agent_draft", {
|
|
|
317
317
|
readonly draft: string;
|
|
318
318
|
readonly files: Schema.Json;
|
|
319
319
|
readonly text: string | null;
|
|
320
|
-
readonly status: "pending" | "sent" | "failed" | "uncertain" | "rejected" | "
|
|
320
|
+
readonly status: "pending" | "sent" | "failed" | "uncertain" | "rejected" | "dismissed" | "superseded";
|
|
321
321
|
readonly mode: "requested" | "always" | "whenUnsure";
|
|
322
322
|
readonly confidence: number | null;
|
|
323
323
|
readonly messageId: string | null;
|
package/dist/analyze.d.ts
CHANGED
|
@@ -30,13 +30,6 @@ export interface OntologyConfig<Entities extends ReadonlyArray<AnyEntity> = Read
|
|
|
30
30
|
* Builders default to declared roles explicitly granting user:grantRoles or user:*.
|
|
31
31
|
*/
|
|
32
32
|
readonly feedback?: boolean | FeedbackOptions;
|
|
33
|
-
/** One workspace-authored action that the agent may invoke for a sender in an opened group.
|
|
34
|
-
* The named role must grant the action. This does not assign that role to a user. */
|
|
35
|
-
readonly publicGroupAction?: {
|
|
36
|
-
readonly entity: string;
|
|
37
|
-
readonly action: string;
|
|
38
|
-
readonly role: string;
|
|
39
|
-
};
|
|
40
33
|
/** Opt-in after-commit service execution; only this declared role supplies permissions. */
|
|
41
34
|
readonly hooks?: {
|
|
42
35
|
readonly role: string;
|
|
@@ -71,7 +64,7 @@ export interface OntologyConfig<Entities extends ReadonlyArray<AnyEntity> = Read
|
|
|
71
64
|
* `origins` names, on `web`. A guest is a session, not a user, and holds the built-in role
|
|
72
65
|
* `guest` with `permissions` alone. Absent, nobody chats without signing in or signing up.
|
|
73
66
|
*/
|
|
74
|
-
readonly guest?: GuestOptions<RolePermission>;
|
|
67
|
+
readonly guest?: GuestOptions<RolePermission, Role | string>;
|
|
75
68
|
/** Who may become a member by signing in. Only invited people by default. */
|
|
76
69
|
readonly signIn?: SignInOptions;
|
|
77
70
|
/**
|
package/dist/analyze.js
CHANGED
|
@@ -100,7 +100,7 @@ export function analyze(config, options = {}) {
|
|
|
100
100
|
}
|
|
101
101
|
const emails = emailOptions(config.emails, report, (name, path) => camelCaseName(name, path, "agreementReview", "Email", report));
|
|
102
102
|
const signInDeclared = signInOptions(config, report);
|
|
103
|
-
const guest = guestOptions(config, report);
|
|
103
|
+
const guest = guestOptions(config, declaredRoles, report);
|
|
104
104
|
const invitationEmail = signInEmailOption(config, emails, report, "invitationEmail");
|
|
105
105
|
const linkEmail = signInEmailOption(config, emails, report, "linkEmail");
|
|
106
106
|
const codeEmail = signInEmailOption(config, emails, report, "codeEmail");
|
|
@@ -323,22 +323,6 @@ export function analyze(config, options = {}) {
|
|
|
323
323
|
chat = { ...chat, retentionDays };
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
|
-
if (config.publicGroupAction !== undefined) {
|
|
327
|
-
const binding = config.publicGroupAction;
|
|
328
|
-
const validKeys = isPlainObject(binding) &&
|
|
329
|
-
[binding.entity, binding.action, binding.role].every((key) => typeof key === "string" && key.length > 0);
|
|
330
|
-
const target = validKeys
|
|
331
|
-
? resolved
|
|
332
|
-
.find((item) => item.name === nameToWire(binding.entity))
|
|
333
|
-
?.actions.find((item) => item.name === nameToWire(binding.action))
|
|
334
|
-
: undefined;
|
|
335
|
-
const role = validKeys
|
|
336
|
-
? roles.find((item) => item.name === nameToWire(binding.role) && !isImplicitRole(item))
|
|
337
|
-
: undefined;
|
|
338
|
-
if (!target || target.action.confirm || !role?.permissions.includes(target.permission)) {
|
|
339
|
-
report("invalid-permission", "publicGroupAction", "Name an authored action without a member confirmation and a role explicitly granting that action.");
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
326
|
checkEntityIdentities(resolved, report);
|
|
343
327
|
checkMemberNames(resolved, report);
|
|
344
328
|
const toolsets = resolveToolsets(original.toolsets, resolved, connections, report);
|
|
@@ -378,6 +362,17 @@ export function analyze(config, options = {}) {
|
|
|
378
362
|
checkAgentToolGrants(roles.filter((candidate) => !BUILT_IN_GUESTS.has(candidate)), report);
|
|
379
363
|
if (guest !== undefined) {
|
|
380
364
|
checkGuestPermissions({ entities: resolved, guest: guest.role, report });
|
|
365
|
+
for (const name of new Set(Object.values(guest.resolved.byChannel ?? {}).flat())) {
|
|
366
|
+
const role = roles.find((candidate) => candidate.name === name);
|
|
367
|
+
if (role) {
|
|
368
|
+
checkGuestPermissions({
|
|
369
|
+
entities: resolved,
|
|
370
|
+
guest: role,
|
|
371
|
+
report,
|
|
372
|
+
path: `guest.byChannel (${name})`,
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
}
|
|
381
376
|
}
|
|
382
377
|
if (feedback.enabled) {
|
|
383
378
|
checkFeedbackResponders(roles, report);
|
|
@@ -1401,10 +1396,11 @@ function resolveToolsets(declared, entities, connections, report) {
|
|
|
1401
1396
|
fail("invalid-toolset", at, `the lock has no tool ${tool}.`);
|
|
1402
1397
|
}
|
|
1403
1398
|
else if (!isPlainObject(options) ||
|
|
1404
|
-
Object.keys(options).some((key) => key !== "description") ||
|
|
1399
|
+
Object.keys(options).some((key) => key !== "description" && key !== "handle") ||
|
|
1400
|
+
(options.handle !== undefined && typeof options.handle !== "function") ||
|
|
1405
1401
|
(options.description !== undefined &&
|
|
1406
1402
|
(typeof options.description !== "string" || options.description.trim() === ""))) {
|
|
1407
|
-
fail("invalid-toolset", at, "a
|
|
1403
|
+
fail("invalid-toolset", at, "Supply a non-empty description or a tool handler.");
|
|
1408
1404
|
}
|
|
1409
1405
|
}
|
|
1410
1406
|
}
|
|
@@ -1422,6 +1418,7 @@ function resolveToolsets(declared, entities, connections, report) {
|
|
|
1422
1418
|
tools: locked.tools.map((tool) => ({
|
|
1423
1419
|
name: tool.name,
|
|
1424
1420
|
mcpName: mcpToolName(name, tool.name),
|
|
1421
|
+
...(overrides[tool.name]?.handle && { handle: overrides[tool.name].handle }),
|
|
1425
1422
|
permission: `${name}:${tool.name}`,
|
|
1426
1423
|
access: tool.access,
|
|
1427
1424
|
fixed: tool.fixed,
|
|
@@ -1714,38 +1711,13 @@ function signInEmailOption(config, emails, report, key) {
|
|
|
1714
1711
|
* `onSignUp` action. Every role must be a declared one other than `member`. A channel opened both
|
|
1715
1712
|
* here and by the earlier `signIn.channels` or `signIn.policy: "open"` is refused.
|
|
1716
1713
|
*/
|
|
1717
|
-
function
|
|
1718
|
-
const options = config.signUp;
|
|
1719
|
-
const hook = config.onSignUp;
|
|
1720
|
-
const result = {};
|
|
1721
|
-
if (hook !== undefined &&
|
|
1722
|
-
(typeof hook !== "string" || !parsePermission(hook) || hook.includes("*"))) {
|
|
1723
|
-
report("invalid-sign-in", "onSignUp", "Use an action name: <entity>:<action>.");
|
|
1724
|
-
}
|
|
1725
|
-
else if (typeof hook === "string") {
|
|
1726
|
-
if (options === undefined) {
|
|
1727
|
-
report("invalid-sign-in", "onSignUp", "onSignUp runs after sign-up; declare signUp.");
|
|
1728
|
-
}
|
|
1729
|
-
result.onSignUp = hook;
|
|
1730
|
-
}
|
|
1731
|
-
if (options === undefined) {
|
|
1732
|
-
return result;
|
|
1733
|
-
}
|
|
1734
|
-
if (!isPlainObject(options)) {
|
|
1735
|
-
report("invalid-sign-in", "signUp", 'signUp takes { channels: ["telegram", "whatsapp", "email", "web"], roles: [...] }.');
|
|
1736
|
-
return result;
|
|
1737
|
-
}
|
|
1738
|
-
for (const key of Object.keys(options)) {
|
|
1739
|
-
if (!["channels", "roles", "byChannel", "origins"].includes(key)) {
|
|
1740
|
-
report("invalid-sign-in", `signUp.${key}`, `Unknown signUp key: ${key}.`);
|
|
1741
|
-
}
|
|
1742
|
-
}
|
|
1714
|
+
function admissionRoleNames(declaredRoles, report) {
|
|
1743
1715
|
const declared = new Set(declaredRoles
|
|
1744
1716
|
.filter((candidate) => !isImplicitRole(candidate))
|
|
1745
1717
|
.map((candidate) => candidate.name));
|
|
1746
1718
|
// @legacy ontology.implicit-member
|
|
1747
1719
|
const implicit = implicitMemberOf(declaredRoles) !== undefined;
|
|
1748
|
-
|
|
1720
|
+
return (value, path) => {
|
|
1749
1721
|
if (!Array.isArray(value)) {
|
|
1750
1722
|
report("invalid-sign-in", path, "Use a list of declared roles; [] grants none.");
|
|
1751
1723
|
return undefined;
|
|
@@ -1758,7 +1730,7 @@ function signUpOptions(config, signIn, declaredRoles, report) {
|
|
|
1758
1730
|
? nameToWire(candidate)
|
|
1759
1731
|
: undefined;
|
|
1760
1732
|
if (implicit && name === MEMBER_ROLE) {
|
|
1761
|
-
report("invalid-sign-in", `${path}[${index}]`, "member is the baseline of invited people;
|
|
1733
|
+
report("invalid-sign-in", `${path}[${index}]`, "member is the baseline of invited people; admission grants declared roles only.");
|
|
1762
1734
|
}
|
|
1763
1735
|
else if (name === undefined || !declared.has(name)) {
|
|
1764
1736
|
report("invalid-sign-in", `${path}[${index}]`, "Use a role the ontology declares.");
|
|
@@ -1769,6 +1741,34 @@ function signUpOptions(config, signIn, declaredRoles, report) {
|
|
|
1769
1741
|
});
|
|
1770
1742
|
return names;
|
|
1771
1743
|
};
|
|
1744
|
+
}
|
|
1745
|
+
function signUpOptions(config, signIn, declaredRoles, report) {
|
|
1746
|
+
const options = config.signUp;
|
|
1747
|
+
const hook = config.onSignUp;
|
|
1748
|
+
const result = {};
|
|
1749
|
+
if (hook !== undefined &&
|
|
1750
|
+
(typeof hook !== "string" || !parsePermission(hook) || hook.includes("*"))) {
|
|
1751
|
+
report("invalid-sign-in", "onSignUp", "Use an action name: <entity>:<action>.");
|
|
1752
|
+
}
|
|
1753
|
+
else if (typeof hook === "string") {
|
|
1754
|
+
if (options === undefined) {
|
|
1755
|
+
report("invalid-sign-in", "onSignUp", "onSignUp runs after sign-up; declare signUp.");
|
|
1756
|
+
}
|
|
1757
|
+
result.onSignUp = hook;
|
|
1758
|
+
}
|
|
1759
|
+
if (options === undefined) {
|
|
1760
|
+
return result;
|
|
1761
|
+
}
|
|
1762
|
+
if (!isPlainObject(options)) {
|
|
1763
|
+
report("invalid-sign-in", "signUp", 'signUp takes { channels: ["telegram", "whatsapp", "email", "web"], roles: [...] }.');
|
|
1764
|
+
return result;
|
|
1765
|
+
}
|
|
1766
|
+
for (const key of Object.keys(options)) {
|
|
1767
|
+
if (!["channels", "roles", "byChannel", "origins"].includes(key)) {
|
|
1768
|
+
report("invalid-sign-in", `signUp.${key}`, `Unknown signUp key: ${key}.`);
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
const roleNames = admissionRoleNames(declaredRoles, report);
|
|
1772
1772
|
const channels = [];
|
|
1773
1773
|
if (!Array.isArray(options.channels) || options.channels.length === 0) {
|
|
1774
1774
|
report("invalid-sign-in", "signUp.channels", `List the channels strangers may sign up through: ${SIGN_UP_CHANNELS.join(", ")}.`);
|
|
@@ -1884,6 +1884,8 @@ const WEBSITE_ORIGIN_HINT = "Use an origin alone, such as https://www.example.co
|
|
|
1884
1884
|
const BUILT_IN_GUESTS = new WeakSet();
|
|
1885
1885
|
/** The guest keys `defineOntology({ guest })` takes. */
|
|
1886
1886
|
const GUEST_KEYS = [
|
|
1887
|
+
"openOnInvite",
|
|
1888
|
+
"byChannel",
|
|
1887
1889
|
"channels",
|
|
1888
1890
|
"origins",
|
|
1889
1891
|
"permissions",
|
|
@@ -1895,7 +1897,7 @@ const GUEST_KEYS = [
|
|
|
1895
1897
|
* definition declares `guest`. Every problem is reported; the role is made from the permissions
|
|
1896
1898
|
* as they are, for the permission checks to report on.
|
|
1897
1899
|
*/
|
|
1898
|
-
function guestOptions(config, report) {
|
|
1900
|
+
function guestOptions(config, declaredRoles, report) {
|
|
1899
1901
|
const options = config.guest;
|
|
1900
1902
|
if (options === undefined) {
|
|
1901
1903
|
return undefined;
|
|
@@ -1917,7 +1919,12 @@ function guestOptions(config, report) {
|
|
|
1917
1919
|
else {
|
|
1918
1920
|
options.channels.forEach((channel, index) => {
|
|
1919
1921
|
const path = `guest.channels[${index}]`;
|
|
1920
|
-
|
|
1922
|
+
const namedKind = typeof channel === "string" && channel.startsWith("channel:")
|
|
1923
|
+
? chatChannelKind(config.chat, channel.slice(8))
|
|
1924
|
+
: undefined;
|
|
1925
|
+
if (!isGuestChannel(channel) ||
|
|
1926
|
+
(channel.startsWith("channel:") &&
|
|
1927
|
+
!["telegram", "slack", "whatsapp"].includes(namedKind ?? ""))) {
|
|
1921
1928
|
report("invalid-sign-in", path, `Guests talk to the agent only on ${GUEST_CHANNELS.join(", ")}, not ${String(channel)}.`);
|
|
1922
1929
|
}
|
|
1923
1930
|
else if (channels.includes(channel)) {
|
|
@@ -1928,11 +1935,58 @@ function guestOptions(config, report) {
|
|
|
1928
1935
|
}
|
|
1929
1936
|
});
|
|
1930
1937
|
}
|
|
1938
|
+
const openOnInvite = [];
|
|
1939
|
+
if (options.openOnInvite !== undefined) {
|
|
1940
|
+
if (!Array.isArray(options.openOnInvite)) {
|
|
1941
|
+
report("invalid-sign-in", "guest.openOnInvite", "List configured group connections.");
|
|
1942
|
+
}
|
|
1943
|
+
else {
|
|
1944
|
+
for (const channel of options.openOnInvite) {
|
|
1945
|
+
const kind = typeof channel === "string"
|
|
1946
|
+
? chatChannelKind(config.chat, channel)
|
|
1947
|
+
: undefined;
|
|
1948
|
+
if ((kind !== "slack" && kind !== "telegram") ||
|
|
1949
|
+
!config.chat?.[channel] ||
|
|
1950
|
+
!(channels.includes(kind) || channels.includes(`channel:${channel}`))) {
|
|
1951
|
+
report("invalid-sign-in", "guest.openOnInvite", "Only configured guest group connections may open on an invitation.");
|
|
1952
|
+
}
|
|
1953
|
+
else {
|
|
1954
|
+
openOnInvite.push(channel);
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
const byChannel = {};
|
|
1960
|
+
if (options.byChannel !== undefined) {
|
|
1961
|
+
if (!isPlainObject(options.byChannel)) {
|
|
1962
|
+
report("invalid-sign-in", "guest.byChannel", "Map a listed channel to its guest roles.");
|
|
1963
|
+
}
|
|
1964
|
+
else {
|
|
1965
|
+
const roleNames = admissionRoleNames(declaredRoles, report);
|
|
1966
|
+
for (const [channel, value] of Object.entries(options.byChannel)) {
|
|
1967
|
+
const path = `guest.byChannel.${channel}`;
|
|
1968
|
+
if (!isGuestChannel(channel) || !channels.includes(channel)) {
|
|
1969
|
+
report("invalid-sign-in", path, "Name a channel listed in guest.channels.");
|
|
1970
|
+
}
|
|
1971
|
+
else {
|
|
1972
|
+
const names = roleNames(value, path);
|
|
1973
|
+
if (names?.includes(MEMBER_ROLE) || names?.includes(GUEST_ROLE)) {
|
|
1974
|
+
report("invalid-sign-in", path, "Guest channel overrides take declared workspace roles.");
|
|
1975
|
+
}
|
|
1976
|
+
byChannel[channel] = names;
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1931
1981
|
const origins = [];
|
|
1932
|
-
if (
|
|
1982
|
+
if (channels.includes("web") &&
|
|
1983
|
+
(!Array.isArray(options.origins) || options.origins.length === 0)) {
|
|
1933
1984
|
report("invalid-sign-in", "guest.origins", "List the websites whose visitors are guests, such as https://www.example.com.");
|
|
1934
1985
|
}
|
|
1935
|
-
else {
|
|
1986
|
+
else if (!channels.includes("web") && options.origins !== undefined) {
|
|
1987
|
+
report("invalid-sign-in", "guest.origins", "Origins apply only to the web channel.");
|
|
1988
|
+
}
|
|
1989
|
+
else if (Array.isArray(options.origins)) {
|
|
1936
1990
|
options.origins.forEach((candidate, index) => {
|
|
1937
1991
|
const origin = websiteOrigin(candidate);
|
|
1938
1992
|
const path = `guest.origins[${index}]`;
|
|
@@ -1964,6 +2018,8 @@ function guestOptions(config, report) {
|
|
|
1964
2018
|
return {
|
|
1965
2019
|
resolved: {
|
|
1966
2020
|
channels,
|
|
2021
|
+
...(Object.keys(byChannel).length ? { byChannel } : {}),
|
|
2022
|
+
...(openOnInvite.length ? { openOnInvite } : {}),
|
|
1967
2023
|
origins,
|
|
1968
2024
|
...(botCheck === undefined ? {} : { botCheck }),
|
|
1969
2025
|
...(options.confirmations === true ? { confirmations: true } : {}),
|
|
@@ -2053,7 +2109,7 @@ function usesMe(value) {
|
|
|
2053
2109
|
function checkGuestPermissions(input) {
|
|
2054
2110
|
const { entities, guest, report } = input;
|
|
2055
2111
|
const permissions = guest.permissions;
|
|
2056
|
-
const path = "guest.permissions";
|
|
2112
|
+
const path = input.path ?? "guest.permissions";
|
|
2057
2113
|
if (!Array.isArray(permissions)) {
|
|
2058
2114
|
return;
|
|
2059
2115
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export { Diagnostic, DIAGNOSTIC_CODES, formatDiagnostics, InvalidOntology } from
|
|
|
19
19
|
export type { DiagnosticCode } from "./diagnostics.js";
|
|
20
20
|
export { entity, isEntity } from "./entity.js";
|
|
21
21
|
export { isToolset, MCP_TOOL_NAME, TOOLSET_LOCK_VERSION, toolset, ToolsetLock, ToolsetLockTool, } from "./toolset.js";
|
|
22
|
-
export type { FixedValue, ResolvedTool, ResolvedToolset, Toolset, ToolsetDefinition, ToolsetToolOptions, } from "./toolset.js";
|
|
22
|
+
export type { FixedValue, ResolvedTool, ResolvedToolset, Toolset, ToolsetDefinition, ToolsetToolOptions, ToolInvocation, ToolHandler, } from "./toolset.js";
|
|
23
23
|
export type { ActionsBuilder, AnyEntity, ActionHandle, ActionInvoker, MetricQueryGroupKey, AnyStoredEntity, BatchCreateValues, BatchKey, BatchUpdateRecord, BatchUpdateValues, BatchUpsertValues, CreateValues, DraftEntity, Entity, EntityDefinition, EntityRecord, EntityWrites, FreshMetricQueryInput, FreshMetricQueryRow, IndexDefinition, IndexField, InvocableActions, NoActions, Properties, RecordRef, Relationships, SystemFields, UpdateValues, } from "./entity.js";
|
|
24
24
|
export { ActionRejected, BatchErrorDetails, Conflict, DeploymentInterrupted, DeploymentSwitching, LimitErrorDetails, NotFound, PermissionDenied, ScopeViolated, } from "./errors.js";
|
|
25
25
|
export type { ActionError } from "./errors.js";
|