@gratiaos/presence-kernel 1.1.2 → 1.1.3
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/README.md +9 -0
- package/dist/index.d.ts +29 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +72 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +84 -1
package/README.md
CHANGED
|
@@ -17,6 +17,15 @@ Provides a tiny reactive core (`PresenceKernel`) and four shared signals:
|
|
|
17
17
|
| `pulse$` | Monotonic integer tick (heartbeats) |
|
|
18
18
|
| `kernelAuthority` | String constant identifying who currently conducts the shared kernel |
|
|
19
19
|
|
|
20
|
+
## 🛰️ Garden Stack naming (infra-facing)
|
|
21
|
+
|
|
22
|
+
- **Pattern Engine** → the underlying model stack (training / inference / retrieval). Use this when you talk infra, capabilities, or updates.
|
|
23
|
+
- **Presence Node** → any surfaced endpoint where humans contact the Engine (web UI, CLI, scripts, voice, agents).
|
|
24
|
+
- **Mode** → behavioral / conversational contract for a Presence Node (e.g. `Codex-mode`, `Monday-mode`). Styles, not identities.
|
|
25
|
+
- **Garden Stack** → Pattern Engine + Presence Nodes + Modes working together.
|
|
26
|
+
|
|
27
|
+
Any mention of “AI” should map to the correct layer above so kernel docs stay precise.
|
|
28
|
+
|
|
20
29
|
## Install
|
|
21
30
|
|
|
22
31
|
```bash
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type Phase = 'companion' | 'presence' | 'archive' | (string & {});
|
|
2
2
|
export type Mood = 'soft' | 'presence' | 'focused' | 'celebratory' | (string & {});
|
|
3
|
+
export type KernelAuthority = 'local-primary' | 'remote-primary' | 'distributed' | (string & {});
|
|
3
4
|
export type PresenceSnapshot = Readonly<{
|
|
4
5
|
t: number;
|
|
5
6
|
phase: Phase;
|
|
@@ -41,8 +42,22 @@ export interface PresenceAdapter {
|
|
|
41
42
|
}
|
|
42
43
|
export type KernelPlugin = (kernel: PresenceKernel) => void;
|
|
43
44
|
import { type Signal } from '@gratiaos/signal';
|
|
44
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Identifies who is currently "conducting" the shared presence kernel.
|
|
47
|
+
*
|
|
48
|
+
* - 'local-primary' (default): This process is the source-of-truth for presence state.
|
|
49
|
+
* Everything else listens or mirrors from here.
|
|
50
|
+
*
|
|
51
|
+
* Future modes (not yet implemented) may include:
|
|
52
|
+
* - 'remote-primary' — presence conducted elsewhere (e.g., another browser/device)
|
|
53
|
+
* - 'distributed' — multiple equal peers co-conduct the field
|
|
54
|
+
*
|
|
55
|
+
* Surfaces can read this to understand how to interpret presence and pulse flow.
|
|
56
|
+
*/
|
|
45
57
|
export declare const kernelAuthority: "local-primary";
|
|
58
|
+
export declare const authority$: Signal<KernelAuthority>;
|
|
59
|
+
export declare const setAuthority: (next: KernelAuthority) => void;
|
|
60
|
+
export declare const getAuthority: () => KernelAuthority;
|
|
46
61
|
export declare const phase$: Signal<Phase>;
|
|
47
62
|
export declare const mood$: Signal<Mood>;
|
|
48
63
|
export declare const peers$: Signal<string[]>;
|
|
@@ -76,6 +91,19 @@ export declare class PresenceKernel {
|
|
|
76
91
|
private tick;
|
|
77
92
|
private publish;
|
|
78
93
|
}
|
|
94
|
+
export interface ValueSealOptions {
|
|
95
|
+
whisper?: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* runValueSealRitual()
|
|
99
|
+
* ---------------------
|
|
100
|
+
* Helper for the Value Bridge "Seal" action.
|
|
101
|
+
*
|
|
102
|
+
* 1. Temporarily shifts the shared mood to 'soft' for the length of the exhale.
|
|
103
|
+
* 2. Emits a `value:sealed` CustomEvent so other surfaces can respond without direct wiring.
|
|
104
|
+
* 3. Applies a gentle glow to the body that falls back once the exhale completes.
|
|
105
|
+
*/
|
|
106
|
+
export declare function runValueSealRitual(options?: ValueSealOptions): void;
|
|
79
107
|
export { Heartbeat } from './Heartbeat';
|
|
80
108
|
export { ConstellationHUD } from './ConstellationHUD';
|
|
81
109
|
export { usePhaseSound } from './usePhaseSound';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AACzE,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,aAAa,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AACzE,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,aAAa,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AACnF,MAAM,MAAM,eAAe,GAAG,eAAe,GAAG,gBAAgB,GAAG,aAAa,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAEjG,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC,CAAC;AAEH,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,gBAAgB,CAAA;CAAE,GACxC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,KAAK,CA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AAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAI9D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import { createSignal } from '@gratiaos/signal';
|
|
2
2
|
// Signals are now sourced from @gratiaos/signal (shared micro observable).
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Identifies who is currently "conducting" the shared presence kernel.
|
|
5
|
+
*
|
|
6
|
+
* - 'local-primary' (default): This process is the source-of-truth for presence state.
|
|
7
|
+
* Everything else listens or mirrors from here.
|
|
8
|
+
*
|
|
9
|
+
* Future modes (not yet implemented) may include:
|
|
10
|
+
* - 'remote-primary' — presence conducted elsewhere (e.g., another browser/device)
|
|
11
|
+
* - 'distributed' — multiple equal peers co-conduct the field
|
|
12
|
+
*
|
|
13
|
+
* Surfaces can read this to understand how to interpret presence and pulse flow.
|
|
14
|
+
*/
|
|
4
15
|
export const kernelAuthority = 'local-primary';
|
|
16
|
+
export const authority$ = createSignal(kernelAuthority);
|
|
17
|
+
export const setAuthority = (next) => authority$.set(next);
|
|
18
|
+
export const getAuthority = () => authority$.value;
|
|
5
19
|
export const phase$ = createSignal('presence');
|
|
6
20
|
export const mood$ = createSignal('soft'); // phase can be vivid while mood stays gentle by default
|
|
7
21
|
export const peers$ = createSignal([]);
|
|
@@ -132,6 +146,63 @@ export class PresenceKernel {
|
|
|
132
146
|
(_a = adapter.emit) === null || _a === void 0 ? void 0 : _a.call(adapter, event);
|
|
133
147
|
}
|
|
134
148
|
}
|
|
149
|
+
const AUTHORITY_EXHALE_MS = {
|
|
150
|
+
'local-primary': 1200,
|
|
151
|
+
'remote-primary': 900,
|
|
152
|
+
distributed: 800,
|
|
153
|
+
};
|
|
154
|
+
const AUTHORITY_GLOWS = {
|
|
155
|
+
'local-primary': 'var(--tone-glow)',
|
|
156
|
+
'remote-primary': '0 0 18px color-mix(in oklab, var(--tone-accent) 26%, transparent)',
|
|
157
|
+
distributed: '0 0 16px color-mix(in oklab, var(--tone-accent) 22%, transparent)',
|
|
158
|
+
};
|
|
159
|
+
let valueSealTimer = null;
|
|
160
|
+
/**
|
|
161
|
+
* runValueSealRitual()
|
|
162
|
+
* ---------------------
|
|
163
|
+
* Helper for the Value Bridge "Seal" action.
|
|
164
|
+
*
|
|
165
|
+
* 1. Temporarily shifts the shared mood to 'soft' for the length of the exhale.
|
|
166
|
+
* 2. Emits a `value:sealed` CustomEvent so other surfaces can respond without direct wiring.
|
|
167
|
+
* 3. Applies a gentle glow to the body that falls back once the exhale completes.
|
|
168
|
+
*/
|
|
169
|
+
export function runValueSealRitual(options) {
|
|
170
|
+
var _a, _b;
|
|
171
|
+
const authority = authority$.value;
|
|
172
|
+
const previousMood = mood$.value;
|
|
173
|
+
const exhaleMs = (_a = AUTHORITY_EXHALE_MS[authority]) !== null && _a !== void 0 ? _a : 900;
|
|
174
|
+
const glow = (_b = AUTHORITY_GLOWS[authority]) !== null && _b !== void 0 ? _b : 'var(--tone-glow)';
|
|
175
|
+
setMood('soft');
|
|
176
|
+
if (typeof window !== 'undefined') {
|
|
177
|
+
const detail = {
|
|
178
|
+
t: Date.now(),
|
|
179
|
+
authority,
|
|
180
|
+
whisper: options === null || options === void 0 ? void 0 : options.whisper,
|
|
181
|
+
};
|
|
182
|
+
window.dispatchEvent(new CustomEvent('value:sealed', { detail }));
|
|
183
|
+
}
|
|
184
|
+
if (valueSealTimer) {
|
|
185
|
+
clearTimeout(valueSealTimer);
|
|
186
|
+
valueSealTimer = null;
|
|
187
|
+
}
|
|
188
|
+
let originalShadow = null;
|
|
189
|
+
if (typeof document !== 'undefined') {
|
|
190
|
+
originalShadow = document.body.style.boxShadow;
|
|
191
|
+
document.body.style.boxShadow = glow;
|
|
192
|
+
}
|
|
193
|
+
valueSealTimer = setTimeout(() => {
|
|
194
|
+
if (typeof document !== 'undefined') {
|
|
195
|
+
if (originalShadow !== null) {
|
|
196
|
+
document.body.style.boxShadow = originalShadow;
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
document.body.style.removeProperty('box-shadow');
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
setMood(previousMood);
|
|
203
|
+
valueSealTimer = null;
|
|
204
|
+
}, exhaleMs);
|
|
205
|
+
}
|
|
135
206
|
export { Heartbeat } from './Heartbeat';
|
|
136
207
|
export { ConstellationHUD } from './ConstellationHUD';
|
|
137
208
|
export { usePhaseSound } from './usePhaseSound';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAgCA,OAAO,EAAE,YAAY,EAAoC,MAAM,kBAAkB,CAAC;AAClF,2EAA2E;AAE3E;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,eAAwB,CAAC;AACxD,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAkB,eAAe,CAAC,CAAC;AACzE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAqB,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC5E,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;AAEnD,MAAM,CAAC,MAAM,MAAM,GAAG,YAAY,CAAQ,UAAU,CAAC,CAAC;AACtD,MAAM,CAAC,MAAM,KAAK,GAAG,YAAY,CAAO,MAAM,CA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AAC;IACxB,CAAC;IAED,IAAI,cAAc,GAAkB,IAAI,CAAC;IACzC,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;QACpC,cAAc,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;QAC/C,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;IACvC,CAAC;IAED,cAAc,GAAG,UAAU,CAAC,GAAG,EAAE;QAC/B,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;YACpC,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;gBAC5B,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,cAAc,CAAC;YACjD,CAAC;iBAAM,CAAC;gBACN,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;QACD,OAAO,CAAC,YAAY,CAAC,CAAC;QACtB,cAAc,GAAG,IAAI,CAAC;IACxB,CAAC,EAAE,QAAQ,CAAC,CAAC;AACf,CAAC;AAED,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,2EAA2E;AAC3E,gFAAgF;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type Phase = 'companion' | 'presence' | 'archive' | (string & {});
|
|
2
2
|
export type Mood = 'soft' | 'presence' | 'focused' | 'celebratory' | (string & {});
|
|
3
|
+
export type KernelAuthority = 'local-primary' | 'remote-primary' | 'distributed' | (string & {});
|
|
3
4
|
|
|
4
5
|
export type PresenceSnapshot = Readonly<{
|
|
5
6
|
t: number;
|
|
@@ -32,8 +33,22 @@ export type KernelPlugin = (kernel: PresenceKernel) => void;
|
|
|
32
33
|
import { createSignal, type Signal, type SignalListener } from '@gratiaos/signal';
|
|
33
34
|
// Signals are now sourced from @gratiaos/signal (shared micro observable).
|
|
34
35
|
|
|
35
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Identifies who is currently "conducting" the shared presence kernel.
|
|
38
|
+
*
|
|
39
|
+
* - 'local-primary' (default): This process is the source-of-truth for presence state.
|
|
40
|
+
* Everything else listens or mirrors from here.
|
|
41
|
+
*
|
|
42
|
+
* Future modes (not yet implemented) may include:
|
|
43
|
+
* - 'remote-primary' — presence conducted elsewhere (e.g., another browser/device)
|
|
44
|
+
* - 'distributed' — multiple equal peers co-conduct the field
|
|
45
|
+
*
|
|
46
|
+
* Surfaces can read this to understand how to interpret presence and pulse flow.
|
|
47
|
+
*/
|
|
36
48
|
export const kernelAuthority = 'local-primary' as const;
|
|
49
|
+
export const authority$ = createSignal<KernelAuthority>(kernelAuthority);
|
|
50
|
+
export const setAuthority = (next: KernelAuthority) => authority$.set(next);
|
|
51
|
+
export const getAuthority = () => authority$.value;
|
|
37
52
|
|
|
38
53
|
export const phase$ = createSignal<Phase>('presence');
|
|
39
54
|
export const mood$ = createSignal<Mood>('soft'); // phase can be vivid while mood stays gentle by default
|
|
@@ -168,6 +183,74 @@ export class PresenceKernel {
|
|
|
168
183
|
}
|
|
169
184
|
}
|
|
170
185
|
|
|
186
|
+
const AUTHORITY_EXHALE_MS: Record<string, number> = {
|
|
187
|
+
'local-primary': 1200,
|
|
188
|
+
'remote-primary': 900,
|
|
189
|
+
distributed: 800,
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const AUTHORITY_GLOWS: Record<string, string> = {
|
|
193
|
+
'local-primary': 'var(--tone-glow)',
|
|
194
|
+
'remote-primary': '0 0 18px color-mix(in oklab, var(--tone-accent) 26%, transparent)',
|
|
195
|
+
distributed: '0 0 16px color-mix(in oklab, var(--tone-accent) 22%, transparent)',
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
let valueSealTimer: ReturnType<typeof setTimeout> | null = null;
|
|
199
|
+
|
|
200
|
+
export interface ValueSealOptions {
|
|
201
|
+
whisper?: string;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* runValueSealRitual()
|
|
206
|
+
* ---------------------
|
|
207
|
+
* Helper for the Value Bridge "Seal" action.
|
|
208
|
+
*
|
|
209
|
+
* 1. Temporarily shifts the shared mood to 'soft' for the length of the exhale.
|
|
210
|
+
* 2. Emits a `value:sealed` CustomEvent so other surfaces can respond without direct wiring.
|
|
211
|
+
* 3. Applies a gentle glow to the body that falls back once the exhale completes.
|
|
212
|
+
*/
|
|
213
|
+
export function runValueSealRitual(options?: ValueSealOptions) {
|
|
214
|
+
const authority = authority$.value;
|
|
215
|
+
const previousMood = mood$.value;
|
|
216
|
+
const exhaleMs = AUTHORITY_EXHALE_MS[authority] ?? 900;
|
|
217
|
+
const glow = AUTHORITY_GLOWS[authority] ?? 'var(--tone-glow)';
|
|
218
|
+
|
|
219
|
+
setMood('soft');
|
|
220
|
+
|
|
221
|
+
if (typeof window !== 'undefined') {
|
|
222
|
+
const detail = {
|
|
223
|
+
t: Date.now(),
|
|
224
|
+
authority,
|
|
225
|
+
whisper: options?.whisper,
|
|
226
|
+
};
|
|
227
|
+
window.dispatchEvent(new CustomEvent('value:sealed', { detail }));
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (valueSealTimer) {
|
|
231
|
+
clearTimeout(valueSealTimer);
|
|
232
|
+
valueSealTimer = null;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
let originalShadow: string | null = null;
|
|
236
|
+
if (typeof document !== 'undefined') {
|
|
237
|
+
originalShadow = document.body.style.boxShadow;
|
|
238
|
+
document.body.style.boxShadow = glow;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
valueSealTimer = setTimeout(() => {
|
|
242
|
+
if (typeof document !== 'undefined') {
|
|
243
|
+
if (originalShadow !== null) {
|
|
244
|
+
document.body.style.boxShadow = originalShadow;
|
|
245
|
+
} else {
|
|
246
|
+
document.body.style.removeProperty('box-shadow');
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
setMood(previousMood);
|
|
250
|
+
valueSealTimer = null;
|
|
251
|
+
}, exhaleMs);
|
|
252
|
+
}
|
|
253
|
+
|
|
171
254
|
export { Heartbeat } from './Heartbeat';
|
|
172
255
|
export { ConstellationHUD } from './ConstellationHUD';
|
|
173
256
|
|