@crossworks/client-types 0.300.50 → 0.300.52

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crossworks/client-types",
3
- "version": "0.300.50",
3
+ "version": "0.300.52",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The profile booleans and their defaults, in one table (A10 #11;
3
+ * docs/configuration.md, "Flags and env"). A preference the owner never set
4
+ * is absent from the stored jsonb, so every reader has to supply the
5
+ * default; 29 sites did, each with its own `!== false` or `=== true`. Read
6
+ * one with {@link profileFlag}; the brain's preferences loader, its routes
7
+ * and the feature registry (@mantle/config FEATURES) all do.
8
+ *
9
+ * Browser-safe and dependency-free: the client reads the same table.
10
+ */
11
+ import type { ProfilePreferences } from './dto/rows';
12
+
13
+ export type ProfileFlagSpec = { default: boolean; doc: string };
14
+
15
+ export const PROFILE_FLAGS = {
16
+ shareNeat: { default: true, doc: 'the public /s share reader paints the saved Neat gradient' },
17
+ streamThoughts: { default: true, doc: 'stream the thought trail live while a turn runs' },
18
+ persistThoughts: { default: true, doc: 'keep the thought trail on the finished message' },
19
+ toolsmithRequireApproval: {
20
+ default: false,
21
+ doc: 'a tool an agent authors is confirm-gated until the operator clears it',
22
+ },
23
+ heartbeatEgressGate: {
24
+ default: false,
25
+ doc: "a heartbeat's egress tool calls park for approval",
26
+ },
27
+ remoteMcpEnabled: {
28
+ default: false,
29
+ doc: 'the remote MCP connector and its OAuth endpoints answer',
30
+ },
31
+ teamPrivateReads: {
32
+ default: false,
33
+ doc: "the team responder may read the owner's email and journal",
34
+ },
35
+ } as const satisfies { [K in keyof ProfilePreferences]?: ProfileFlagSpec };
36
+
37
+ export type ProfileFlag = keyof typeof PROFILE_FLAGS;
38
+
39
+ /** The stored value of one profile boolean, with its default: a default-on
40
+ * flag is on unless stored `false`, a default-off flag on only when stored
41
+ * `true` (jsonb can hold anything; nothing else counts). */
42
+ export function profileFlag(
43
+ prefs: { readonly [K in ProfileFlag]?: unknown } | null | undefined,
44
+ name: ProfileFlag,
45
+ ): boolean {
46
+ const v = prefs?.[name];
47
+ return PROFILE_FLAGS[name].default ? v !== false : v === true;
48
+ }
@@ -22,9 +22,15 @@ function flagOn(raw: string | undefined): boolean {
22
22
  }
23
23
 
24
24
  /** Server-side master gate: the SSE/cancel routes exist and the POST turn route
25
- * goes non-blocking. Off only when `MANTLE_TURN_STREAMING` is explicitly falsy. */
25
+ * goes non-blocking. Off only when `MANTLE_TURN_STREAMING` is explicitly falsy.
26
+ * Honours the legacy name `NEXT_PUBLIC_MANTLE_TURN_STREAMING` when the new
27
+ * one is unset, exactly as `env()` does (@mantle/config ENV_ALIASES): until
28
+ * A10 #11 this reader ignored it while the replay buffer honoured it, so a
29
+ * box setting only the legacy name to 0 served the stream routes with no
30
+ * buffer behind them. The brain reads `feature('turnStreaming')`; this stays
31
+ * for the published contract. */
26
32
  export function isTurnStreamingEnabled(): boolean {
27
- return flagOn(process.env.MANTLE_TURN_STREAMING);
33
+ return flagOn(process.env.MANTLE_TURN_STREAMING ?? process.env.NEXT_PUBLIC_MANTLE_TURN_STREAMING);
28
34
  }
29
35
 
30
36
  /** Client-side twin, compiled into the browser bundle. Defaults on (an unset