@vellumai/assistant 0.12.6-dev.202609300824.02624a5 → 0.12.6-dev.202609301115.aafbefc
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/ARCHITECTURE.md +3 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/channels.test.ts +2 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/channels.ts +8 -4
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/channels.test.ts +2 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/channels.ts +8 -4
- package/node_modules/@vellumai/gateway-client/src/admission-policy-contract.ts +5 -2
- package/node_modules/@vellumai/service-contracts/src/__tests__/channels.test.ts +2 -0
- package/node_modules/@vellumai/service-contracts/src/channels.ts +8 -4
- package/openapi.yaml +11 -0
- package/package.json +1 -1
- package/src/__tests__/channel-policy.test.ts +7 -0
- package/src/channels/config.ts +8 -0
- package/src/config/feature-flag-registry.json +8 -0
- package/src/contacts/types.ts +1 -0
- package/src/notifications/README.md +1 -1
- package/src/notifications/signal.ts +4 -0
- package/src/runtime/auth/__tests__/guard-tests.test.ts +51 -1
- package/src/runtime/auth/__tests__/scopes.test.ts +2 -0
- package/src/runtime/auth/scopes.ts +15 -0
- package/src/runtime/auth/types.ts +1 -0
package/ARCHITECTURE.md
CHANGED
|
@@ -83,6 +83,7 @@ All HTTP API requests use a single `Authorization: Bearer <jwt>` header for auth
|
|
|
83
83
|
| Profile | Scopes | Used by |
|
|
84
84
|
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
|
|
85
85
|
| `actor_client_v1` | `chat.{read,write}`, `approval.{read,write}`, `settings.{read,write}`, `attachments.{read,write}`, `calls.{read,write}`, `feature_flags.{read,write}` | Desktop, CLI clients |
|
|
86
|
+
| `contact_client_v1` | `chat.write`, `approval.write`, `attachments.write` | Non-guardian contact clients |
|
|
86
87
|
| `gateway_ingress_v1` | `ingress.write`, `internal.write` | Gateway channel inbound + webhook forwarding |
|
|
87
88
|
| `gateway_service_v1` | `chat.{read,write}`, `settings.{read,write}`, `attachments.{read,write}`, `internal.write` | Gateway service-to-daemon calls |
|
|
88
89
|
| `local_v1` | `local.all` | Local (loopback) conversation sessions |
|
|
@@ -98,6 +99,8 @@ All HTTP API requests use a single `Authorization: Bearer <jwt>` header for auth
|
|
|
98
99
|
|
|
99
100
|
3. **Local identity** — Local connections use deterministic identity resolution without tokens.
|
|
100
101
|
|
|
102
|
+
**Token role:** Each access and refresh token records the principal it belongs to, `guardian` or `contact`. The role picks the scope profile at mint time, and rotation carries it forward.
|
|
103
|
+
|
|
101
104
|
**Route policy enforcement:** Every protected endpoint declares required scopes and allowed principal types in `src/runtime/auth/route-policy.ts`. The `enforcePolicy()` function checks the AuthContext against these requirements and returns 403 when access is denied. A guard test ensures every dispatched endpoint has a corresponding policy entry.
|
|
102
105
|
|
|
103
106
|
**Credential storage:** Only hashed tokens are persisted. Access token hashes go in `credential_records`; refresh token hashes in `refresh_token_records`. Raw tokens are returned once and never stored server-side.
|
|
@@ -24,6 +24,7 @@ describe("isChannelId", () => {
|
|
|
24
24
|
// so these must remain canonical for that assertion to mean anything.
|
|
25
25
|
expect(isChannelId("platform")).toBe(true);
|
|
26
26
|
expect(isChannelId("vellum")).toBe(true);
|
|
27
|
+
expect(isChannelId("vellum-shared")).toBe(true);
|
|
27
28
|
});
|
|
28
29
|
|
|
29
30
|
test("includes discord", () => {
|
|
@@ -58,6 +59,7 @@ describe("botProviderForChannel and channelForBotProvider", () => {
|
|
|
58
59
|
test("answer nothing for a channel without a bot, a person's grant, or an unknown key", () => {
|
|
59
60
|
expect(botProviderForChannel("phone")).toBeUndefined();
|
|
60
61
|
expect(botProviderForChannel("vellum")).toBeUndefined();
|
|
62
|
+
expect(botProviderForChannel("vellum-shared")).toBeUndefined();
|
|
61
63
|
expect(botProviderForChannel("not-a-channel")).toBeUndefined();
|
|
62
64
|
// `slack` is the person's integration standing beside the bot's key.
|
|
63
65
|
expect(channelForBotProvider("slack")).toBeUndefined();
|
package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/channels.ts
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
*
|
|
5
5
|
* A "channel" is an external messaging surface an actor can reach the
|
|
6
6
|
* assistant through (Slack, Telegram, WhatsApp, phone, …) plus a couple of
|
|
7
|
-
* internal ids (`vellum` for native app conversations, `
|
|
8
|
-
*
|
|
7
|
+
* internal ids (`vellum` for native app conversations, `vellum-shared` for
|
|
8
|
+
* conversations a guardian shares with a contact, `platform` for the internal
|
|
9
|
+
* control plane). This is the single source of truth for that set:
|
|
9
10
|
*
|
|
10
11
|
* One id, `plugin`, does not name a surface: it names *every* surface a plugin
|
|
11
12
|
* brings. A plugin channel's real identity is the plugin, which is workspace
|
|
@@ -41,6 +42,9 @@ export const CHANNEL_IDS = [
|
|
|
41
42
|
"a2a",
|
|
42
43
|
"discord",
|
|
43
44
|
"plugin",
|
|
45
|
+
// Internal id for conversations a guardian shares with a contact. It has no
|
|
46
|
+
// transport: the contact's own client holds the connection.
|
|
47
|
+
"vellum-shared",
|
|
44
48
|
] as const;
|
|
45
49
|
|
|
46
50
|
export type ChannelId = (typeof CHANNEL_IDS)[number];
|
|
@@ -78,8 +82,8 @@ export function isChannelId(value: unknown): value is ChannelId {
|
|
|
78
82
|
* here would be a second copy of a different fact.
|
|
79
83
|
*
|
|
80
84
|
* Channels absent from this map reach the assistant without a bot credential
|
|
81
|
-
* of their own: `phone` through the voice provider, `vellum
|
|
82
|
-
* internally.
|
|
85
|
+
* of their own: `phone` through the voice provider, `vellum`, `vellum-shared`
|
|
86
|
+
* and `platform` internally.
|
|
83
87
|
*/
|
|
84
88
|
export const CHANNEL_BOT_PROVIDER = {
|
|
85
89
|
slack: "slack_channel",
|
|
@@ -24,6 +24,7 @@ describe("isChannelId", () => {
|
|
|
24
24
|
// so these must remain canonical for that assertion to mean anything.
|
|
25
25
|
expect(isChannelId("platform")).toBe(true);
|
|
26
26
|
expect(isChannelId("vellum")).toBe(true);
|
|
27
|
+
expect(isChannelId("vellum-shared")).toBe(true);
|
|
27
28
|
});
|
|
28
29
|
|
|
29
30
|
test("includes discord", () => {
|
|
@@ -58,6 +59,7 @@ describe("botProviderForChannel and channelForBotProvider", () => {
|
|
|
58
59
|
test("answer nothing for a channel without a bot, a person's grant, or an unknown key", () => {
|
|
59
60
|
expect(botProviderForChannel("phone")).toBeUndefined();
|
|
60
61
|
expect(botProviderForChannel("vellum")).toBeUndefined();
|
|
62
|
+
expect(botProviderForChannel("vellum-shared")).toBeUndefined();
|
|
61
63
|
expect(botProviderForChannel("not-a-channel")).toBeUndefined();
|
|
62
64
|
// `slack` is the person's integration standing beside the bot's key.
|
|
63
65
|
expect(channelForBotProvider("slack")).toBeUndefined();
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
*
|
|
5
5
|
* A "channel" is an external messaging surface an actor can reach the
|
|
6
6
|
* assistant through (Slack, Telegram, WhatsApp, phone, …) plus a couple of
|
|
7
|
-
* internal ids (`vellum` for native app conversations, `
|
|
8
|
-
*
|
|
7
|
+
* internal ids (`vellum` for native app conversations, `vellum-shared` for
|
|
8
|
+
* conversations a guardian shares with a contact, `platform` for the internal
|
|
9
|
+
* control plane). This is the single source of truth for that set:
|
|
9
10
|
*
|
|
10
11
|
* One id, `plugin`, does not name a surface: it names *every* surface a plugin
|
|
11
12
|
* brings. A plugin channel's real identity is the plugin, which is workspace
|
|
@@ -41,6 +42,9 @@ export const CHANNEL_IDS = [
|
|
|
41
42
|
"a2a",
|
|
42
43
|
"discord",
|
|
43
44
|
"plugin",
|
|
45
|
+
// Internal id for conversations a guardian shares with a contact. It has no
|
|
46
|
+
// transport: the contact's own client holds the connection.
|
|
47
|
+
"vellum-shared",
|
|
44
48
|
] as const;
|
|
45
49
|
|
|
46
50
|
export type ChannelId = (typeof CHANNEL_IDS)[number];
|
|
@@ -78,8 +82,8 @@ export function isChannelId(value: unknown): value is ChannelId {
|
|
|
78
82
|
* here would be a second copy of a different fact.
|
|
79
83
|
*
|
|
80
84
|
* Channels absent from this map reach the assistant without a bot credential
|
|
81
|
-
* of their own: `phone` through the voice provider, `vellum
|
|
82
|
-
* internally.
|
|
85
|
+
* of their own: `phone` through the voice provider, `vellum`, `vellum-shared`
|
|
86
|
+
* and `platform` internally.
|
|
83
87
|
*/
|
|
84
88
|
export const CHANNEL_BOT_PROVIDER = {
|
|
85
89
|
slack: "slack_channel",
|
|
@@ -56,8 +56,8 @@ export const ADMISSION_FLOOR: Record<AdmissionPolicy, number> = {
|
|
|
56
56
|
*
|
|
57
57
|
* `phone` is NOT exempt — voice ingress enforces the admission floor.
|
|
58
58
|
*
|
|
59
|
-
* `vellum` / `whatsapp` are NOT exempt
|
|
60
|
-
* runtime
|
|
59
|
+
* `vellum` / `vellum-shared` / `whatsapp` are NOT exempt: their floors are
|
|
60
|
+
* still enforced at runtime, but they are hidden from the configurable UI; see
|
|
61
61
|
* {@link ADMISSION_POLICY_HIDDEN_CHANNELS}.
|
|
62
62
|
*/
|
|
63
63
|
export const ADMISSION_POLICY_EXEMPT_CHANNELS: ReadonlySet<string> = new Set([
|
|
@@ -81,9 +81,12 @@ export function isAdmissionPolicyExemptChannel(channelType: string): boolean {
|
|
|
81
81
|
* `vellum` is the local desktop/web client surface; the guardian is always
|
|
82
82
|
* max-rank there, so the seed default admits them regardless of the floor.
|
|
83
83
|
*
|
|
84
|
+
* `vellum-shared` carries conversations a guardian shares with a contact. Its
|
|
85
|
+
* seed default is `guardian_only`, which admits no contact.
|
|
84
86
|
*/
|
|
85
87
|
export const ADMISSION_POLICY_HIDDEN_CHANNELS: ReadonlySet<string> = new Set([
|
|
86
88
|
"vellum",
|
|
89
|
+
"vellum-shared",
|
|
87
90
|
"whatsapp",
|
|
88
91
|
]);
|
|
89
92
|
|
|
@@ -24,6 +24,7 @@ describe("isChannelId", () => {
|
|
|
24
24
|
// so these must remain canonical for that assertion to mean anything.
|
|
25
25
|
expect(isChannelId("platform")).toBe(true);
|
|
26
26
|
expect(isChannelId("vellum")).toBe(true);
|
|
27
|
+
expect(isChannelId("vellum-shared")).toBe(true);
|
|
27
28
|
});
|
|
28
29
|
|
|
29
30
|
test("includes discord", () => {
|
|
@@ -58,6 +59,7 @@ describe("botProviderForChannel and channelForBotProvider", () => {
|
|
|
58
59
|
test("answer nothing for a channel without a bot, a person's grant, or an unknown key", () => {
|
|
59
60
|
expect(botProviderForChannel("phone")).toBeUndefined();
|
|
60
61
|
expect(botProviderForChannel("vellum")).toBeUndefined();
|
|
62
|
+
expect(botProviderForChannel("vellum-shared")).toBeUndefined();
|
|
61
63
|
expect(botProviderForChannel("not-a-channel")).toBeUndefined();
|
|
62
64
|
// `slack` is the person's integration standing beside the bot's key.
|
|
63
65
|
expect(channelForBotProvider("slack")).toBeUndefined();
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
*
|
|
5
5
|
* A "channel" is an external messaging surface an actor can reach the
|
|
6
6
|
* assistant through (Slack, Telegram, WhatsApp, phone, …) plus a couple of
|
|
7
|
-
* internal ids (`vellum` for native app conversations, `
|
|
8
|
-
*
|
|
7
|
+
* internal ids (`vellum` for native app conversations, `vellum-shared` for
|
|
8
|
+
* conversations a guardian shares with a contact, `platform` for the internal
|
|
9
|
+
* control plane). This is the single source of truth for that set:
|
|
9
10
|
*
|
|
10
11
|
* One id, `plugin`, does not name a surface: it names *every* surface a plugin
|
|
11
12
|
* brings. A plugin channel's real identity is the plugin, which is workspace
|
|
@@ -41,6 +42,9 @@ export const CHANNEL_IDS = [
|
|
|
41
42
|
"a2a",
|
|
42
43
|
"discord",
|
|
43
44
|
"plugin",
|
|
45
|
+
// Internal id for conversations a guardian shares with a contact. It has no
|
|
46
|
+
// transport: the contact's own client holds the connection.
|
|
47
|
+
"vellum-shared",
|
|
44
48
|
] as const;
|
|
45
49
|
|
|
46
50
|
export type ChannelId = (typeof CHANNEL_IDS)[number];
|
|
@@ -78,8 +82,8 @@ export function isChannelId(value: unknown): value is ChannelId {
|
|
|
78
82
|
* here would be a second copy of a different fact.
|
|
79
83
|
*
|
|
80
84
|
* Channels absent from this map reach the assistant without a bot credential
|
|
81
|
-
* of their own: `phone` through the voice provider, `vellum
|
|
82
|
-
* internally.
|
|
85
|
+
* of their own: `phone` through the voice provider, `vellum`, `vellum-shared`
|
|
86
|
+
* and `platform` internally.
|
|
83
87
|
*/
|
|
84
88
|
export const CHANNEL_BOT_PROVIDER = {
|
|
85
89
|
slack: "slack_channel",
|
package/openapi.yaml
CHANGED
|
@@ -4849,6 +4849,7 @@ paths:
|
|
|
4849
4849
|
- a2a
|
|
4850
4850
|
- discord
|
|
4851
4851
|
- plugin
|
|
4852
|
+
- vellum-shared
|
|
4852
4853
|
assistantId:
|
|
4853
4854
|
type: string
|
|
4854
4855
|
hasPendingChallenge:
|
|
@@ -5279,6 +5280,7 @@ paths:
|
|
|
5279
5280
|
- a2a
|
|
5280
5281
|
- discord
|
|
5281
5282
|
- plugin
|
|
5283
|
+
- vellum-shared
|
|
5282
5284
|
ready:
|
|
5283
5285
|
type: boolean
|
|
5284
5286
|
setupStatus:
|
|
@@ -5403,6 +5405,7 @@ paths:
|
|
|
5403
5405
|
- a2a
|
|
5404
5406
|
- discord
|
|
5405
5407
|
- plugin
|
|
5408
|
+
- vellum-shared
|
|
5406
5409
|
includeRemote:
|
|
5407
5410
|
description: Include remote checks (default true)
|
|
5408
5411
|
type: boolean
|
|
@@ -5434,6 +5437,7 @@ paths:
|
|
|
5434
5437
|
- a2a
|
|
5435
5438
|
- discord
|
|
5436
5439
|
- plugin
|
|
5440
|
+
- vellum-shared
|
|
5437
5441
|
ready:
|
|
5438
5442
|
type: boolean
|
|
5439
5443
|
setupStatus:
|
|
@@ -5567,6 +5571,7 @@ paths:
|
|
|
5567
5571
|
- a2a
|
|
5568
5572
|
- discord
|
|
5569
5573
|
- plugin
|
|
5574
|
+
- vellum-shared
|
|
5570
5575
|
description: Channel to send on
|
|
5571
5576
|
target:
|
|
5572
5577
|
type: object
|
|
@@ -5617,6 +5622,7 @@ paths:
|
|
|
5617
5622
|
- a2a
|
|
5618
5623
|
- discord
|
|
5619
5624
|
- plugin
|
|
5625
|
+
- vellum-shared
|
|
5620
5626
|
chatId:
|
|
5621
5627
|
type: string
|
|
5622
5628
|
threadId:
|
|
@@ -8203,6 +8209,7 @@ paths:
|
|
|
8203
8209
|
- a2a
|
|
8204
8210
|
- discord
|
|
8205
8211
|
- plugin
|
|
8212
|
+
- vellum-shared
|
|
8206
8213
|
description:
|
|
8207
8214
|
Filter by origin channel. When provided, only conversations with this exact origin_channel value are
|
|
8208
8215
|
returned. Omit to include all channels.
|
|
@@ -8367,6 +8374,7 @@ paths:
|
|
|
8367
8374
|
- a2a
|
|
8368
8375
|
- discord
|
|
8369
8376
|
- plugin
|
|
8377
|
+
- vellum-shared
|
|
8370
8378
|
- type: "null"
|
|
8371
8379
|
assistantAttention:
|
|
8372
8380
|
type: object
|
|
@@ -8737,6 +8745,7 @@ paths:
|
|
|
8737
8745
|
- a2a
|
|
8738
8746
|
- discord
|
|
8739
8747
|
- plugin
|
|
8748
|
+
- vellum-shared
|
|
8740
8749
|
- type: "null"
|
|
8741
8750
|
assistantAttention:
|
|
8742
8751
|
type: object
|
|
@@ -9951,6 +9960,7 @@ paths:
|
|
|
9951
9960
|
- a2a
|
|
9952
9961
|
- discord
|
|
9953
9962
|
- plugin
|
|
9963
|
+
- vellum-shared
|
|
9954
9964
|
- type: "null"
|
|
9955
9965
|
assistantAttention:
|
|
9956
9966
|
type: object
|
|
@@ -25359,6 +25369,7 @@ paths:
|
|
|
25359
25369
|
- a2a
|
|
25360
25370
|
- discord
|
|
25361
25371
|
- plugin
|
|
25372
|
+
- vellum-shared
|
|
25362
25373
|
- scheduler
|
|
25363
25374
|
- watcher
|
|
25364
25375
|
sourceContextId:
|
package/package.json
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
isNotificationDeliverable,
|
|
17
17
|
} from "../channels/config.js";
|
|
18
18
|
import { CHANNEL_IDS, type ChannelId } from "../channels/types.js";
|
|
19
|
+
import { getTransportForChannel } from "../messaging/providers/index.js";
|
|
19
20
|
|
|
20
21
|
describe("channel policy registry", () => {
|
|
21
22
|
// ── Exhaustiveness ────────────────────────────────────────────────────
|
|
@@ -133,6 +134,12 @@ describe("channel policy registry", () => {
|
|
|
133
134
|
expect(getConversationStrategy("phone")).toBe("not_deliverable");
|
|
134
135
|
});
|
|
135
136
|
|
|
137
|
+
test("vellum-shared has no transport and receives no notifications", () => {
|
|
138
|
+
expect(isNotificationDeliverable("vellum-shared")).toBe(false);
|
|
139
|
+
expect(getConversationStrategy("vellum-shared")).toBe("not_deliverable");
|
|
140
|
+
expect(getTransportForChannel("vellum-shared")).toBeUndefined();
|
|
141
|
+
});
|
|
142
|
+
|
|
136
143
|
test("deliverable channels include vellum and telegram", () => {
|
|
137
144
|
const deliverable = getDeliverableChannels();
|
|
138
145
|
expect(deliverable).toContain("vellum");
|
package/src/channels/config.ts
CHANGED
|
@@ -99,6 +99,14 @@ const CHANNEL_POLICIES = {
|
|
|
99
99
|
conversationStrategy: "continue_existing_conversation",
|
|
100
100
|
},
|
|
101
101
|
},
|
|
102
|
+
"vellum-shared": {
|
|
103
|
+
notification: {
|
|
104
|
+
// A shared conversation has no transport: the contact's own client
|
|
105
|
+
// reads replies over its connection, so there is nowhere to push to.
|
|
106
|
+
deliveryEnabled: false,
|
|
107
|
+
conversationStrategy: "not_deliverable",
|
|
108
|
+
},
|
|
109
|
+
},
|
|
102
110
|
} as const satisfies Record<ChannelId, ChannelNotificationPolicy>;
|
|
103
111
|
|
|
104
112
|
export type ChannelPolicies = typeof CHANNEL_POLICIES;
|
|
@@ -575,6 +575,14 @@
|
|
|
575
575
|
"label": "Sidebar Done",
|
|
576
576
|
"description": "Turns archiving a chat into marking it done: the sidebar row carries a Done check instead of the overflow menu, an All chats page lists the full history, and done chats stay findable in search by default. Off keeps today's Archive wording, the overflow menu, and search that hides archived rows unless the query asks for them.",
|
|
577
577
|
"defaultEnabled": false
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
"id": "vellum-trusted-contacts",
|
|
581
|
+
"scope": "both",
|
|
582
|
+
"key": "vellum-trusted-contacts",
|
|
583
|
+
"label": "Vellum Trusted Contacts",
|
|
584
|
+
"description": "Lets a guardian give another person access to talk to their assistant in the Vellum UI as a trusted contact. Gates contact-role token minting in the gateway, trusted-contact trust resolution for `vellum` channel principals, and the assistant's trusted-contact route allowlist. Off: none of those surfaces admit a contact, and the assistant stays reachable only by its guardian.",
|
|
585
|
+
"defaultEnabled": false
|
|
578
586
|
}
|
|
579
587
|
]
|
|
580
588
|
}
|
package/src/contacts/types.ts
CHANGED
|
@@ -216,7 +216,7 @@ Each policy defines:
|
|
|
216
216
|
| `start_new_conversation` | Pairs the delivery with a new or reused conversation, or appends to the producing one (see Conversation Pairing below). | `vellum` |
|
|
217
217
|
| `continue_existing_conversation` | Resolves the destination chat's home conversation, creating one on first delivery. The delivered post is written there only once the channel acknowledges it. | `telegram`, `slack`, `discord`, and the non-deliverable `whatsapp`, `email`, `a2a`, `plugin` |
|
|
218
218
|
| `push_only` | Pairs nothing. The push deep-links through the vellum delivery's conversation. | `platform` |
|
|
219
|
-
| `not_deliverable` | Channel cannot receive notifications. Pairing returns null IDs. | `phone`
|
|
219
|
+
| `not_deliverable` | Channel cannot receive notifications. Pairing returns null IDs. | `phone`, `vellum-shared` |
|
|
220
220
|
|
|
221
221
|
### Helper Functions
|
|
222
222
|
|
|
@@ -27,6 +27,10 @@ export const NOTIFICATION_SOURCE_CHANNELS = [
|
|
|
27
27
|
{ id: "a2a", description: "Agent-to-agent protocol channel" },
|
|
28
28
|
{ id: "discord", description: "Discord channel" },
|
|
29
29
|
{ id: "plugin", description: "Channel brought by an installed plugin" },
|
|
30
|
+
{
|
|
31
|
+
id: "vellum-shared",
|
|
32
|
+
description: "Conversation a guardian shared with a contact",
|
|
33
|
+
},
|
|
30
34
|
{ id: "scheduler", description: "Scheduled task runner (reminders, cron)" },
|
|
31
35
|
{ id: "watcher", description: "File/event watcher subsystem" },
|
|
32
36
|
] as const;
|
|
@@ -8,13 +8,15 @@
|
|
|
8
8
|
* 2. No X-Actor-Token references in production code.
|
|
9
9
|
* 3. No legacy gateway-origin proof in production code.
|
|
10
10
|
* 4. Scope profile contract — every profile resolves to the expected scopes.
|
|
11
|
+
* 5. Contact profile agreement: the gateway mints what this runtime honors.
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
14
|
import { execSync } from "node:child_process";
|
|
15
|
+
import { readFileSync } from "node:fs";
|
|
14
16
|
import { resolve } from "node:path";
|
|
15
17
|
import { describe, expect, test } from "bun:test";
|
|
16
18
|
|
|
17
|
-
import { resolveScopeProfile } from "../scopes.js";
|
|
19
|
+
import { isNarrowScopeProfile, resolveScopeProfile } from "../scopes.js";
|
|
18
20
|
import type { Scope, ScopeProfile } from "../types.js";
|
|
19
21
|
|
|
20
22
|
// ---------------------------------------------------------------------------
|
|
@@ -253,6 +255,7 @@ describe("scope profile contract", () => {
|
|
|
253
255
|
"feature_flags.read",
|
|
254
256
|
"feature_flags.write",
|
|
255
257
|
],
|
|
258
|
+
contact_client_v1: ["chat.write", "approval.write", "attachments.write"],
|
|
256
259
|
gateway_ingress_v1: ["ingress.write", "internal.write"],
|
|
257
260
|
gateway_service_v1: [
|
|
258
261
|
"chat.read",
|
|
@@ -290,3 +293,50 @@ describe("scope profile contract", () => {
|
|
|
290
293
|
}
|
|
291
294
|
});
|
|
292
295
|
});
|
|
296
|
+
|
|
297
|
+
// ---------------------------------------------------------------------------
|
|
298
|
+
// 5. Contact profile agreement with the gateway
|
|
299
|
+
//
|
|
300
|
+
// The gateway mints `contact_client_v1` and this runtime decides what it may
|
|
301
|
+
// reach. The two registries are separate tables, so a contact token carries
|
|
302
|
+
// whichever scopes the narrower one grants: a scope missing here 403s a route
|
|
303
|
+
// the gateway believes it opened.
|
|
304
|
+
// ---------------------------------------------------------------------------
|
|
305
|
+
|
|
306
|
+
describe("contact_client_v1 agrees with the gateway registry", () => {
|
|
307
|
+
const GATEWAY_SCOPES_PATH = resolve(
|
|
308
|
+
PROJECT_ROOT,
|
|
309
|
+
"gateway/src/auth/scopes.ts",
|
|
310
|
+
);
|
|
311
|
+
|
|
312
|
+
function gatewaySource(): string {
|
|
313
|
+
return readFileSync(GATEWAY_SCOPES_PATH, "utf8");
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
test("grants the same scopes on both sides", () => {
|
|
317
|
+
const block = /contact_client_v1: new Set<Scope>\(\[([^\]]*)\]\)/.exec(
|
|
318
|
+
gatewaySource(),
|
|
319
|
+
);
|
|
320
|
+
expect(
|
|
321
|
+
block,
|
|
322
|
+
`contact_client_v1 not found in ${GATEWAY_SCOPES_PATH}`,
|
|
323
|
+
).not.toBeNull();
|
|
324
|
+
|
|
325
|
+
const gatewayScopes = [...block![1].matchAll(/"([^"]+)"/g)]
|
|
326
|
+
.map((m) => m[1])
|
|
327
|
+
.sort();
|
|
328
|
+
const runtimeScopes: string[] = [
|
|
329
|
+
...resolveScopeProfile("contact_client_v1"),
|
|
330
|
+
].sort();
|
|
331
|
+
|
|
332
|
+
expect(gatewayScopes.length).toBeGreaterThan(0);
|
|
333
|
+
expect(runtimeScopes).toEqual(gatewayScopes);
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
test("is narrow on both sides", () => {
|
|
337
|
+
const broad = /contact_client_v1: (true|false)/.exec(gatewaySource());
|
|
338
|
+
expect(broad).not.toBeNull();
|
|
339
|
+
expect(broad![1]).toBe("false");
|
|
340
|
+
expect(isNarrowScopeProfile("contact_client_v1")).toBe(true);
|
|
341
|
+
});
|
|
342
|
+
});
|
|
@@ -11,6 +11,7 @@ import type { AuthContext, Scope, ScopeProfile } from "../types.js";
|
|
|
11
11
|
/** Every profile name; the Record keeps this list exhaustive. */
|
|
12
12
|
const KNOWN_PROFILES = Object.keys({
|
|
13
13
|
actor_client_v1: true,
|
|
14
|
+
contact_client_v1: true,
|
|
14
15
|
gateway_ingress_v1: true,
|
|
15
16
|
gateway_service_v1: true,
|
|
16
17
|
local_v1: true,
|
|
@@ -129,6 +130,7 @@ describe("isNarrowScopeProfile", () => {
|
|
|
129
130
|
// flipped onto a single-route grant would open every unscoped route to it.
|
|
130
131
|
const narrow: Record<ScopeProfile, boolean> = {
|
|
131
132
|
actor_client_v1: false,
|
|
133
|
+
contact_client_v1: true,
|
|
132
134
|
gateway_ingress_v1: false,
|
|
133
135
|
gateway_service_v1: false,
|
|
134
136
|
local_v1: false,
|
|
@@ -27,6 +27,18 @@ const PROFILE_SCOPES: Record<ScopeProfile, ReadonlySet<Scope>> = {
|
|
|
27
27
|
"feature_flags.read",
|
|
28
28
|
"feature_flags.write",
|
|
29
29
|
]),
|
|
30
|
+
// A non-guardian principal. Excludes the settings, feature-flag and call
|
|
31
|
+
// scopes `actor_client_v1` carries: those reach the control plane, which
|
|
32
|
+
// only the guardian may write.
|
|
33
|
+
// Carries no read scope. The routes behind `chat.read`, `approval.read` and
|
|
34
|
+
// `attachments.read` take a caller-supplied conversation or attachment id
|
|
35
|
+
// and never check who is asking, so they return the guardian's data to any
|
|
36
|
+
// holder. Each read is added back once its routes filter by caller.
|
|
37
|
+
contact_client_v1: new Set<Scope>([
|
|
38
|
+
"chat.write",
|
|
39
|
+
"approval.write",
|
|
40
|
+
"attachments.write",
|
|
41
|
+
]),
|
|
30
42
|
gateway_ingress_v1: new Set<Scope>(["ingress.write", "internal.write"]),
|
|
31
43
|
gateway_service_v1: new Set<Scope>([
|
|
32
44
|
"chat.read",
|
|
@@ -91,6 +103,9 @@ export function hasAllScopes(ctx: AuthContext, ...scopes: Scope[]): boolean {
|
|
|
91
103
|
*/
|
|
92
104
|
const BROAD_SCOPE_PROFILES: Record<ScopeProfile, boolean> = {
|
|
93
105
|
actor_client_v1: true,
|
|
106
|
+
// Narrow: a route naming no scope is a route no one has judged a contact
|
|
107
|
+
// against, so it refuses them rather than admitting any valid token.
|
|
108
|
+
contact_client_v1: false,
|
|
94
109
|
gateway_ingress_v1: true,
|
|
95
110
|
gateway_service_v1: true,
|
|
96
111
|
local_v1: true,
|