@vellumai/cli 0.12.4-dev.202609232017.d454a3d → 0.12.4-dev.202609232047.847daa9
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/node_modules/@vellumai/local-mode/node_modules/@vellumai/service-contracts/src/__tests__/guardian-requests.test.ts +26 -0
- package/node_modules/@vellumai/local-mode/node_modules/@vellumai/service-contracts/src/guardian-requests.ts +77 -3
- package/node_modules/@vellumai/service-contracts/src/__tests__/guardian-requests.test.ts +26 -0
- package/node_modules/@vellumai/service-contracts/src/guardian-requests.ts +77 -3
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
GUARDIAN_DECISION_ACTION_IDS,
|
|
5
|
+
isDenyingGuardianAction,
|
|
6
|
+
isParkGuardianAction,
|
|
7
|
+
} from "../guardian-requests.js";
|
|
8
|
+
|
|
9
|
+
describe("guardian decision actions", () => {
|
|
10
|
+
test("reject, leave_unverified and block deny; every other action approves", () => {
|
|
11
|
+
const denying = GUARDIAN_DECISION_ACTION_IDS.filter(
|
|
12
|
+
isDenyingGuardianAction,
|
|
13
|
+
);
|
|
14
|
+
expect(denying).toEqual(["reject", "leave_unverified", "block"]);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("only leave_unverified parks the sender", () => {
|
|
18
|
+
const parking = GUARDIAN_DECISION_ACTION_IDS.filter(isParkGuardianAction);
|
|
19
|
+
expect(parking).toEqual(["leave_unverified"]);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("an absent or unknown action neither denies nor parks", () => {
|
|
23
|
+
expect(isDenyingGuardianAction(undefined)).toBe(false);
|
|
24
|
+
expect(isParkGuardianAction("approve_always")).toBe(false);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Canonical vocabulary for
|
|
3
|
-
* the
|
|
4
|
-
*
|
|
2
|
+
* Canonical vocabulary for guardian requests, shared by the gateway that owns
|
|
3
|
+
* the request rows, the daemon that decides and projects them, and the web
|
|
4
|
+
* that renders the projection: a request's lifecycle status, the actions a
|
|
5
|
+
* guardian can decide it with, and the weight a card gives each action.
|
|
5
6
|
*/
|
|
6
7
|
import { z } from "zod";
|
|
7
8
|
|
|
@@ -16,3 +17,76 @@ export const GuardianRequestStatusSchema = z.enum(
|
|
|
16
17
|
GUARDIAN_REQUEST_STATUS_VALUES,
|
|
17
18
|
);
|
|
18
19
|
export type GuardianRequestStatus = z.infer<typeof GuardianRequestStatusSchema>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The actions a guardian can decide a request with.
|
|
23
|
+
*
|
|
24
|
+
* `approve_once` / `reject` are the generic decision pair used by every
|
|
25
|
+
* request kind. `trust` / `verify_code` / `leave_unverified` / `block` are the
|
|
26
|
+
* introduction-card actions, valid only for `access_request` requests.
|
|
27
|
+
*/
|
|
28
|
+
export const GUARDIAN_DECISION_ACTION_IDS = [
|
|
29
|
+
"approve_once",
|
|
30
|
+
"reject",
|
|
31
|
+
"trust",
|
|
32
|
+
"verify_code",
|
|
33
|
+
"leave_unverified",
|
|
34
|
+
"block",
|
|
35
|
+
] as const;
|
|
36
|
+
export const GuardianDecisionActionIdSchema = z.enum(
|
|
37
|
+
GUARDIAN_DECISION_ACTION_IDS,
|
|
38
|
+
);
|
|
39
|
+
export type GuardianDecisionActionId = z.infer<
|
|
40
|
+
typeof GuardianDecisionActionIdSchema
|
|
41
|
+
>;
|
|
42
|
+
|
|
43
|
+
/** Actions that resolve a request to `denied`; every other one approves. */
|
|
44
|
+
export const GUARDIAN_DENYING_ACTION_VALUES = [
|
|
45
|
+
"reject",
|
|
46
|
+
"leave_unverified",
|
|
47
|
+
"block",
|
|
48
|
+
] as const satisfies readonly GuardianDecisionActionId[];
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The denying actions that park the sender at `unverified`: a neutral hold,
|
|
52
|
+
* not a rejection. A parked contact is still admitted under the permissive
|
|
53
|
+
* admission floors (`any_contact`, `strangers`) and can be trusted or verified
|
|
54
|
+
* later; contrast `block` (revoked, a hard keep-out) and `reject` (an explicit
|
|
55
|
+
* decline). All three resolve the request to `denied`, so a resolved card
|
|
56
|
+
* consults this to read a park neutrally rather than as a denial.
|
|
57
|
+
*/
|
|
58
|
+
export const GUARDIAN_PARK_ACTION_VALUES = [
|
|
59
|
+
"leave_unverified",
|
|
60
|
+
] as const satisfies readonly GuardianDecisionActionId[];
|
|
61
|
+
|
|
62
|
+
const DENYING_ACTIONS: ReadonlySet<string> = new Set(
|
|
63
|
+
GUARDIAN_DENYING_ACTION_VALUES,
|
|
64
|
+
);
|
|
65
|
+
const PARK_ACTIONS: ReadonlySet<string> = new Set(GUARDIAN_PARK_ACTION_VALUES);
|
|
66
|
+
|
|
67
|
+
/** True when `action` resolves a request to `denied`. */
|
|
68
|
+
export function isDenyingGuardianAction(action: string | undefined): boolean {
|
|
69
|
+
return action !== undefined && DENYING_ACTIONS.has(action);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** True when `action` parks the sender at `unverified`. */
|
|
73
|
+
export function isParkGuardianAction(action: string | undefined): boolean {
|
|
74
|
+
return action !== undefined && PARK_ACTIONS.has(action);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Surface-agnostic weight of a card action. Each renderer translates it to
|
|
79
|
+
* its own token (Slack primary/danger, a web button variant); absent means the
|
|
80
|
+
* renderer's default.
|
|
81
|
+
*/
|
|
82
|
+
export const GUARDIAN_ACTION_EMPHASIS_VALUES = [
|
|
83
|
+
"primary",
|
|
84
|
+
"secondary",
|
|
85
|
+
"destructive",
|
|
86
|
+
] as const;
|
|
87
|
+
export const GuardianActionEmphasisSchema = z.enum(
|
|
88
|
+
GUARDIAN_ACTION_EMPHASIS_VALUES,
|
|
89
|
+
);
|
|
90
|
+
export type GuardianActionEmphasis = z.infer<
|
|
91
|
+
typeof GuardianActionEmphasisSchema
|
|
92
|
+
>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
GUARDIAN_DECISION_ACTION_IDS,
|
|
5
|
+
isDenyingGuardianAction,
|
|
6
|
+
isParkGuardianAction,
|
|
7
|
+
} from "../guardian-requests.js";
|
|
8
|
+
|
|
9
|
+
describe("guardian decision actions", () => {
|
|
10
|
+
test("reject, leave_unverified and block deny; every other action approves", () => {
|
|
11
|
+
const denying = GUARDIAN_DECISION_ACTION_IDS.filter(
|
|
12
|
+
isDenyingGuardianAction,
|
|
13
|
+
);
|
|
14
|
+
expect(denying).toEqual(["reject", "leave_unverified", "block"]);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("only leave_unverified parks the sender", () => {
|
|
18
|
+
const parking = GUARDIAN_DECISION_ACTION_IDS.filter(isParkGuardianAction);
|
|
19
|
+
expect(parking).toEqual(["leave_unverified"]);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("an absent or unknown action neither denies nor parks", () => {
|
|
23
|
+
expect(isDenyingGuardianAction(undefined)).toBe(false);
|
|
24
|
+
expect(isParkGuardianAction("approve_always")).toBe(false);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Canonical vocabulary for
|
|
3
|
-
* the
|
|
4
|
-
*
|
|
2
|
+
* Canonical vocabulary for guardian requests, shared by the gateway that owns
|
|
3
|
+
* the request rows, the daemon that decides and projects them, and the web
|
|
4
|
+
* that renders the projection: a request's lifecycle status, the actions a
|
|
5
|
+
* guardian can decide it with, and the weight a card gives each action.
|
|
5
6
|
*/
|
|
6
7
|
import { z } from "zod";
|
|
7
8
|
|
|
@@ -16,3 +17,76 @@ export const GuardianRequestStatusSchema = z.enum(
|
|
|
16
17
|
GUARDIAN_REQUEST_STATUS_VALUES,
|
|
17
18
|
);
|
|
18
19
|
export type GuardianRequestStatus = z.infer<typeof GuardianRequestStatusSchema>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The actions a guardian can decide a request with.
|
|
23
|
+
*
|
|
24
|
+
* `approve_once` / `reject` are the generic decision pair used by every
|
|
25
|
+
* request kind. `trust` / `verify_code` / `leave_unverified` / `block` are the
|
|
26
|
+
* introduction-card actions, valid only for `access_request` requests.
|
|
27
|
+
*/
|
|
28
|
+
export const GUARDIAN_DECISION_ACTION_IDS = [
|
|
29
|
+
"approve_once",
|
|
30
|
+
"reject",
|
|
31
|
+
"trust",
|
|
32
|
+
"verify_code",
|
|
33
|
+
"leave_unverified",
|
|
34
|
+
"block",
|
|
35
|
+
] as const;
|
|
36
|
+
export const GuardianDecisionActionIdSchema = z.enum(
|
|
37
|
+
GUARDIAN_DECISION_ACTION_IDS,
|
|
38
|
+
);
|
|
39
|
+
export type GuardianDecisionActionId = z.infer<
|
|
40
|
+
typeof GuardianDecisionActionIdSchema
|
|
41
|
+
>;
|
|
42
|
+
|
|
43
|
+
/** Actions that resolve a request to `denied`; every other one approves. */
|
|
44
|
+
export const GUARDIAN_DENYING_ACTION_VALUES = [
|
|
45
|
+
"reject",
|
|
46
|
+
"leave_unverified",
|
|
47
|
+
"block",
|
|
48
|
+
] as const satisfies readonly GuardianDecisionActionId[];
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The denying actions that park the sender at `unverified`: a neutral hold,
|
|
52
|
+
* not a rejection. A parked contact is still admitted under the permissive
|
|
53
|
+
* admission floors (`any_contact`, `strangers`) and can be trusted or verified
|
|
54
|
+
* later; contrast `block` (revoked, a hard keep-out) and `reject` (an explicit
|
|
55
|
+
* decline). All three resolve the request to `denied`, so a resolved card
|
|
56
|
+
* consults this to read a park neutrally rather than as a denial.
|
|
57
|
+
*/
|
|
58
|
+
export const GUARDIAN_PARK_ACTION_VALUES = [
|
|
59
|
+
"leave_unverified",
|
|
60
|
+
] as const satisfies readonly GuardianDecisionActionId[];
|
|
61
|
+
|
|
62
|
+
const DENYING_ACTIONS: ReadonlySet<string> = new Set(
|
|
63
|
+
GUARDIAN_DENYING_ACTION_VALUES,
|
|
64
|
+
);
|
|
65
|
+
const PARK_ACTIONS: ReadonlySet<string> = new Set(GUARDIAN_PARK_ACTION_VALUES);
|
|
66
|
+
|
|
67
|
+
/** True when `action` resolves a request to `denied`. */
|
|
68
|
+
export function isDenyingGuardianAction(action: string | undefined): boolean {
|
|
69
|
+
return action !== undefined && DENYING_ACTIONS.has(action);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** True when `action` parks the sender at `unverified`. */
|
|
73
|
+
export function isParkGuardianAction(action: string | undefined): boolean {
|
|
74
|
+
return action !== undefined && PARK_ACTIONS.has(action);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Surface-agnostic weight of a card action. Each renderer translates it to
|
|
79
|
+
* its own token (Slack primary/danger, a web button variant); absent means the
|
|
80
|
+
* renderer's default.
|
|
81
|
+
*/
|
|
82
|
+
export const GUARDIAN_ACTION_EMPHASIS_VALUES = [
|
|
83
|
+
"primary",
|
|
84
|
+
"secondary",
|
|
85
|
+
"destructive",
|
|
86
|
+
] as const;
|
|
87
|
+
export const GuardianActionEmphasisSchema = z.enum(
|
|
88
|
+
GUARDIAN_ACTION_EMPHASIS_VALUES,
|
|
89
|
+
);
|
|
90
|
+
export type GuardianActionEmphasis = z.infer<
|
|
91
|
+
typeof GuardianActionEmphasisSchema
|
|
92
|
+
>;
|