@kumbatio/energy-system 0.5.3 → 0.6.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/README.md CHANGED
@@ -32,6 +32,10 @@ This library gives applications a structured way to adapt to energy state instea
32
32
  - Task complexity guidance
33
33
  - Interaction forgiveness (undo windows, destructive-action confirmation)
34
34
  - Energy-aware deferral ordering
35
+ - Autonomy (how much automation may do unattended)
36
+ - **Inbound demand admission**: an energy-resolved policy for arrivals that ask
37
+ something of the user — reach them now, acknowledge and queue, or queue
38
+ silently (`demandAdmissionStrategy`, `resolveDemandOutcome`)
35
39
  - **Presence annotation**: declare which energy levels a component/view belongs
36
40
  to (`defineEnergyPresence`, `presenceAtOrAbove`, `<EnergyGate>`, `data-energy-min`)
37
41
  - **Focus sessions**: time-boxed suppression windows with auto-expiry and break nudges
@@ -254,6 +258,93 @@ const { defaultPresetId, orderedPresetIds } = engine.resolve(deferralStrategy)
254
258
  const resurfaceAt = resolveDeferral(presets, defaultPresetId) // epoch ms
255
259
  ```
256
260
 
261
+ ## Inbound demand and autonomy
262
+
263
+ **Inbound demand** is anything arriving from outside that asks for the user's
264
+ attention or action: an email, a document comment, a review request, a task
265
+ assignment, a collaboration invite.
266
+
267
+ Every triage system in general use is organised around properties of the
268
+ _message_ — who sent it, how urgent it claims to be, what category it fits.
269
+ None is organised around the state of the _recipient_, which is the thing that
270
+ actually decides whether an arrival is a small task or a crushing weight. This
271
+ is that variable, applied to the queue.
272
+
273
+ `demandAdmissionStrategy` resolves the policy; `resolveDemandOutcome` applies
274
+ it. Both are pure. The library performs no effects here — acknowledging an
275
+ originator means sending mail, posting a comment, or updating a status chip
276
+ depending on the app, and those are irreversible in ways an in-process runtime
277
+ cannot make transactional. The orchestration, with its ordering, retries, and
278
+ deduplication, belongs to the app.
279
+
280
+ ```ts
281
+ import {
282
+ autonomyStrategy,
283
+ deferralStrategy,
284
+ demandAdmissionStrategy,
285
+ resolveDemandOutcome,
286
+ } from '@kumbatio/energy-system'
287
+
288
+ const outcome = resolveDemandOutcome(
289
+ engine.resolve(demandAdmissionStrategy),
290
+ engine.resolve(autonomyStrategy),
291
+ {
292
+ originatorTier: 'unknown', // 'exempt' | 'known' | 'unknown', assigned by your app
293
+ bearsObligation: true, // does this ask something of the user?
294
+ confidence: 0.9, // how sure are you? a deterministic rule reports 1
295
+ },
296
+ )
297
+
298
+ switch (outcome.admission) {
299
+ case 'live':
300
+ return inbox.deliver(message)
301
+ case 'acknowledge':
302
+ // One act, never two. An acknowledgment without a capture is a promise
303
+ // nobody kept; a capture without an acknowledgment leaves the originator in
304
+ // silence. Capture first — it is the reversible half.
305
+ await tasks.capture(message, engine.resolve(deferralStrategy).defaultPresetId)
306
+ return replies.acknowledge(message, outcome.acknowledgment)
307
+ case 'silent':
308
+ return tasks.capture(message, engine.resolve(deferralStrategy).defaultPresetId)
309
+ }
310
+ ```
311
+
312
+ Two rules are worth stating outright, because each blocks a specific failure:
313
+
314
+ 1. **The exempt tier is never handled by machine.** At every level, an exempt
315
+ originator is admitted live. This is also what defuses the gaming risk: an
316
+ originator who learns an acknowledgment means "deprioritised" and escalates
317
+ elsewhere only succeeds if their escalation is one the user cannot ignore —
318
+ which is what makes them exempt.
319
+ 2. **Acknowledgments report state, never intent.** "Received and queued,
320
+ current response horizon early next week" is a fact. "I'll get back to you
321
+ soon" is a promise the user's Tuesday self has to keep. The horizon comes
322
+ from `deferralStrategy`, so the queue and the acknowledgment cannot disagree.
323
+
324
+ Disclosure is the app's job in the app's own medium — an `Auto-Submitted:
325
+ auto-replied` header, an "auto-queued" badge, a system-attributed status. An
326
+ automated action toward a third party must be identifiable as automated.
327
+
328
+ ### Autonomy
329
+
330
+ `autonomyStrategy` is the mirror of `interactionForgivenessStrategy`:
331
+ forgiveness protects against the _user's_ mistakes at low energy, autonomy
332
+ against the _agent's_. It is useful to any consumer with agentic surfaces, with
333
+ or without demand admission.
334
+
335
+ ```ts
336
+ const { confidenceThreshold, allowGeneratedContent, maxUnattendedSteps } =
337
+ engine.resolve(autonomyStrategy)
338
+ ```
339
+
340
+ What narrows as energy falls is _discretion_, not action. At rest the
341
+ confidence threshold is `1`, which admits only certainty — rule-based actions,
342
+ never a judgment call — and `maxUnattendedSteps` is `1`. Automation may still
343
+ take a single, certain, template-only step, which is exactly the shape of an
344
+ out-of-office reply. It may not chain steps or improvise wording. The system
345
+ acts for the user precisely when they are least able to supervise it, so the
346
+ worst day is the wrong day for it to get creative.
347
+
257
348
  ## Quick start (DOM)
258
349
 
259
350
  ```ts
@@ -308,7 +399,8 @@ animating presence changes should do the same.
308
399
  - `mapToNearestDiscreteLevel(value, levels, fallback)`
309
400
  - `mapToNearestEnergyLevel(value)`
310
401
  - Strategies: `uiVisibilityStrategy`, `notificationStrategy`,
311
- `taskComplexityStrategy`, `interactionForgivenessStrategy`, `deferralStrategy`
402
+ `taskComplexityStrategy`, `interactionForgivenessStrategy`, `deferralStrategy`,
403
+ `autonomyStrategy`, `demandAdmissionStrategy`
312
404
  - Presence: `defineEnergyPresence(spec)`, `presenceAtOrAbove(min, below?)`,
313
405
  `presenceAtOrBelow(max, above?)`, `resolveEnergyPresence(map, level)`,
314
406
  `isPresenceVisible(presence)`, `isEnergyPresence(value)`,
@@ -320,6 +412,8 @@ animating presence changes should do the same.
320
412
  `isNotificationPriority(value)`
321
413
  - Deferral: `createDeferralPresets(options?)`, `resolveDeferral(presets, id, now?)`,
322
414
  `DEFERRAL_PRESET_IDS`
415
+ - Demand admission: `resolveDemandOutcome(config, autonomy, demand)`,
416
+ `isOriginatorTier(value)`
323
417
  - Types: `EnergyLevel`, `EnergyState`, `EnergyPresence`, `EnergyPresenceMap`,
324
418
  `AdaptationStrategy`, `FocusSession`, `NotificationDelivery`, etc.
325
419
 
@@ -439,6 +533,14 @@ pnpm run pack:dry-run
439
533
  This package is framework-agnostic at its core. Platform-specific persistence
440
534
  adapters (e.g., SQLite-backed desktop stores) should live in consuming apps.
441
535
 
536
+ ## Who uses this
537
+
538
+ - **[Anasa](https://anasa.md)** — Kumbatio's local-first writing and thinking workspace, in public alpha. Runs its entire adaptive shell on the engine: custom settings-backed persistence, energy-gated AI surfaces, notification filtering, and task-complexity guidance.
539
+ - **[Meltemi](https://meltemi.app)** — an email client in private beta from [entro314 labs](https://github.com/entro314-labs) (the studio behind Kumbatio), built outside the Kumbatio product line. Uses the notification gate (defer, never drop), focus sessions, deferral ordering, and interaction forgiveness — integrated without the React adapter.
540
+ - **[kumbat.io](https://kumbat.io)** — the site itself runs on this model; change the energy level there and watch the interface adapt.
541
+
542
+ The integration patterns these apps proved out are documented in the [Production Patterns guide](https://docs.kumbat.io/docs/energy-system/guides/production-patterns). If you ship something with `energy-system`, tell us: [hello@kumbat.io](mailto:hello@kumbat.io).
543
+
442
544
  ## Kumbatio
443
545
 
444
546
  `energy-system` is the infrastructure layer of [Kumbatio](https://kumbat.io) — an ecosystem of open-source, neuroinclusive software built from lived experience with ADHD and depression. The position behind it, in one line: **energy ≠ time**, and software should adapt to real cognitive capacity instead of assuming a default brain.
package/api-surface.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.5.3",
2
+ "version": "0.6.0",
3
3
  "entryPoints": [
4
4
  {
5
5
  "specifier": "@kumbatio/energy-system",
@@ -10,8 +10,10 @@
10
10
  "ENERGY_SOURCE_VALUES",
11
11
  "UNPRODUCED_ORIGIN",
12
12
  "UNPRODUCED_TIMESTAMP",
13
+ "autonomyStrategy",
13
14
  "createDeferralPresets",
14
15
  "createEnergyEngine",
16
+ "createEnergyOrigin",
15
17
  "createEnergyState",
16
18
  "createExternalLevelCompatibility",
17
19
  "createFocusSessionController",
@@ -21,6 +23,7 @@
21
23
  "cycleEnergyLevel",
22
24
  "deferralStrategy",
23
25
  "defineEnergyPresence",
26
+ "demandAdmissionStrategy",
24
27
  "getEnergyLevel",
25
28
  "getEnergyLevels",
26
29
  "getEnergyMetrics",
@@ -30,6 +33,7 @@
30
33
  "isEnergySource",
31
34
  "isHigherEnergy",
32
35
  "isNotificationPriority",
36
+ "isOriginatorTier",
33
37
  "isPresenceVisible",
34
38
  "isSessionExpired",
35
39
  "isUnproducedState",
@@ -39,6 +43,7 @@
39
43
  "presenceAtOrAbove",
40
44
  "presenceAtOrBelow",
41
45
  "resolveDeferral",
46
+ "resolveDemandOutcome",
42
47
  "resolveEnergyPresence",
43
48
  "resolveNotificationOutcome",
44
49
  "sessionRemainingMs",
@@ -46,12 +51,20 @@
46
51
  "uiVisibilityStrategy"
47
52
  ],
48
53
  "types": [
54
+ "AcknowledgmentDetail",
49
55
  "AdaptationStrategy",
56
+ "AutonomyConfig",
50
57
  "CognitiveProfile",
51
58
  "DecisionCapacity",
52
59
  "DeferralConfig",
53
60
  "DeferralPreset",
54
61
  "DeferralPresetOptions",
62
+ "DemandAcknowledgment",
63
+ "DemandAdmission",
64
+ "DemandAdmissionConfig",
65
+ "DemandInput",
66
+ "DemandOutcome",
67
+ "DemandOutcomeReason",
55
68
  "EnergyChangeListener",
56
69
  "EnergyClock",
57
70
  "EnergyEngine",
@@ -85,6 +98,7 @@
85
98
  "NotificationGate",
86
99
  "NotificationGateOptions",
87
100
  "NotificationPriority",
101
+ "OriginatorTier",
88
102
  "PublishOutcome",
89
103
  "StartFocusSessionOptions",
90
104
  "TaskComplexity",
@@ -160,6 +174,25 @@
160
174
  "defaultPresetId",
161
175
  "orderedPresetIds"
162
176
  ],
177
+ "DemandAcknowledgment": [
178
+ "allowGeneratedContent",
179
+ "detail"
180
+ ],
181
+ "DemandOutcome": [
182
+ "acknowledgment",
183
+ "admission",
184
+ "reason"
185
+ ],
186
+ "DemandInput": [
187
+ "bearsObligation",
188
+ "confidence",
189
+ "originatorTier"
190
+ ],
191
+ "DemandAdmissionConfig": [
192
+ "acknowledge",
193
+ "acknowledgmentDetail",
194
+ "originatorThreshold"
195
+ ],
163
196
  "EnergyEngineOptions": [
164
197
  "autoStart",
165
198
  "clock",
@@ -291,6 +324,11 @@
291
324
  "confirmDestructive",
292
325
  "undoWindowMs"
293
326
  ],
327
+ "AutonomyConfig": [
328
+ "allowGeneratedContent",
329
+ "confidenceThreshold",
330
+ "maxUnattendedSteps"
331
+ ],
294
332
  "EnergyState": [
295
333
  "level",
296
334
  "origin",
@@ -0,0 +1,88 @@
1
+ import type { AutonomyConfig } from './strategies.js';
2
+ import type { AdaptationStrategy } from './types.js';
3
+ /**
4
+ * Standing of the originator relative to the user.
5
+ *
6
+ * - `exempt`: the inner circle. Never sees an energy acknowledgment.
7
+ * - `known`: an established correspondent.
8
+ * - `unknown`: no established relationship.
9
+ *
10
+ * Tier assignment is the app's job — a Screener approval, a contacts list, an
11
+ * org chart. The policy only consumes the tier.
12
+ */
13
+ export type OriginatorTier = 'exempt' | 'known' | 'unknown';
14
+ /** Validate that an unknown value is a valid OriginatorTier */
15
+ export declare function isOriginatorTier(value: unknown): value is OriginatorTier;
16
+ /**
17
+ * What happens to a piece of inbound demand.
18
+ *
19
+ * - `live`: reaches the user now, untouched by this policy.
20
+ * - `acknowledge`: the originator is acknowledged and the obligation is
21
+ * captured for later. The two are one act — an acknowledgment without a
22
+ * capture is a promise nobody kept, a capture without an acknowledgment
23
+ * leaves the originator in silence.
24
+ * - `silent`: captured for later with no acknowledgment.
25
+ */
26
+ export type DemandAdmission = 'live' | 'acknowledge' | 'silent';
27
+ /** How much an acknowledgment may say */
28
+ export type AcknowledgmentDetail = 'full' | 'brief' | 'minimal';
29
+ /** Why the policy reached its decision — for audit trails and explanatory UI */
30
+ export type DemandOutcomeReason = 'exempt-originator' | 'tier-admitted' | 'no-obligation' | 'acknowledgment-disabled' | 'below-confidence' | 'acknowledged';
31
+ /**
32
+ * What the acknowledgment is permitted to be. The two axes are independent:
33
+ * how much it may say comes from the level's admission config, whether the
34
+ * wording may be composed at all comes from autonomy.
35
+ */
36
+ export interface DemandAcknowledgment {
37
+ readonly detail: AcknowledgmentDetail;
38
+ /** Whether the wording may be composed, or must come from a fixed template. */
39
+ readonly allowGeneratedContent: boolean;
40
+ }
41
+ /** The policy decision for one piece of demand */
42
+ export interface DemandOutcome {
43
+ readonly admission: DemandAdmission;
44
+ /** The acknowledgment to send. Null unless `admission` is `acknowledge`. */
45
+ readonly acknowledgment: DemandAcknowledgment | null;
46
+ readonly reason: DemandOutcomeReason;
47
+ }
48
+ /** The properties of one piece of demand that the policy reads */
49
+ export interface DemandInput {
50
+ readonly originatorTier: OriginatorTier;
51
+ /**
52
+ * Whether this demand asks something of the user. Informational mail — a
53
+ * receipt, a newsletter, a build notification — is not this policy's
54
+ * business and passes through untouched.
55
+ */
56
+ readonly bearsObligation: boolean;
57
+ /**
58
+ * Confidence (0–1) that the two classifications above are right. A
59
+ * deterministic rule reports `1`; an LLM classifier reports what it reports.
60
+ * Below the level's autonomy threshold, the demand is captured silently
61
+ * rather than risking a wrong automated action on the user's worst day.
62
+ * Defaults to `1`, so a caller with no classifier gets rule-based behavior.
63
+ */
64
+ readonly confidence?: number;
65
+ }
66
+ export interface DemandAdmissionConfig {
67
+ /**
68
+ * Lowest originator tier admitted live. Mirrors the notification gate's
69
+ * `priorityThreshold`: `all` admits everyone, `none` admits no one.
70
+ */
71
+ readonly originatorThreshold: 'all' | 'known' | 'exempt' | 'none';
72
+ /** Whether demand held back from the user is acknowledged to its originator. */
73
+ readonly acknowledge: boolean;
74
+ /** Ceiling on acknowledgment detail at this level. */
75
+ readonly acknowledgmentDetail: AcknowledgmentDetail;
76
+ }
77
+ export declare const demandAdmissionStrategy: AdaptationStrategy<DemandAdmissionConfig>;
78
+ /**
79
+ * The pure gating decision, extracted so apps can unit-test their demand
80
+ * policy without wiring any effects — the counterpart of
81
+ * `resolveNotificationOutcome`.
82
+ *
83
+ * Both configs are required because the two questions are genuinely separate:
84
+ * `admission` says what the app's policy wants done, `autonomy` says how much
85
+ * of it may happen without the user watching.
86
+ */
87
+ export declare function resolveDemandOutcome(config: DemandAdmissionConfig, autonomy: AutonomyConfig, demand: DemandInput): DemandOutcome;
88
+ //# sourceMappingURL=demand.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EAAE,MAAM,CAAA;CAC7B;AAED,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,QAAQ,CAAC,mBAAmB,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;IACjE,gFAAgF;IAChF,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAA;IAC7B,sDAAsD;IACtD,QAAQ,CAAC,oBAAoB,EAAE,oBAAoB,CAAA;CACpD;AAkCD,eAAO,MAAM,uBAAuB,EAAE,kBAAkB,CAAC,qBAAqB,CAmB7E,CAAA;AAkBD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,qBAAqB,EAC7B,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,WAAW,GAClB,aAAa,CAoEf"}
package/dist/demand.js ADDED
@@ -0,0 +1,166 @@
1
+ import { getEnergyLevel } from './levels.js';
2
+ /**
3
+ * Inbound demand — anything arriving from outside that asks for the user's
4
+ * attention or action: an email, a document comment, a review request, a task
5
+ * assignment, a collaboration invite.
6
+ *
7
+ * Email is the only queue in modern life with no backpressure: infinite
8
+ * senders write to a finite human with zero feedback about that human's
9
+ * capacity. Every other triage system is organised around properties of the
10
+ * *message* (sender, urgency, type); this one is organised around the state of
11
+ * the *recipient*.
12
+ *
13
+ * This module is the policy half only, and it is pure. It decides whether a
14
+ * piece of demand reaches the user now, is acknowledged to its originator and
15
+ * captured for later, or is captured silently. It never performs any of those
16
+ * effects: acknowledging an originator means sending mail, posting a comment,
17
+ * or updating a status chip depending on the app, and those effects are
18
+ * irreversible in ways an in-process runtime cannot make transactional. The
19
+ * consuming app owns the orchestration; it owns the ordering, the retries, and
20
+ * the deduplication that go with irreversible outbound effects.
21
+ *
22
+ * Pair the outcome with `deferralStrategy` for the resurface horizon: the
23
+ * acknowledgment states when the user will actually get to the item, and the
24
+ * energy-ordered deferral default is that answer.
25
+ */
26
+ function freezeObject(value) {
27
+ return Object.freeze(value);
28
+ }
29
+ const ORIGINATOR_TIERS = new Set(['exempt', 'known', 'unknown']);
30
+ /** Validate that an unknown value is a valid OriginatorTier */
31
+ export function isOriginatorTier(value) {
32
+ return typeof value === 'string' && ORIGINATOR_TIERS.has(value);
33
+ }
34
+ const ADMISSION_CONFIGS = freezeObject({
35
+ // Full capacity: no policy at all. Everything reaches the user.
36
+ 100: freezeObject({
37
+ originatorThreshold: 'all',
38
+ acknowledge: false,
39
+ acknowledgmentDetail: 'full',
40
+ }),
41
+ 75: freezeObject({
42
+ originatorThreshold: 'known',
43
+ acknowledge: true,
44
+ acknowledgmentDetail: 'full',
45
+ }),
46
+ 50: freezeObject({
47
+ originatorThreshold: 'exempt',
48
+ acknowledge: true,
49
+ acknowledgmentDetail: 'full',
50
+ }),
51
+ 25: freezeObject({
52
+ originatorThreshold: 'exempt',
53
+ acknowledge: true,
54
+ acknowledgmentDetail: 'brief',
55
+ }),
56
+ // Rest: the acknowledgment survives, stripped to a fixed template. The
57
+ // originator's social debt still clears — that is the whole point of the
58
+ // loop — but nothing is composed on the user's behalf.
59
+ 0: freezeObject({
60
+ originatorThreshold: 'exempt',
61
+ acknowledge: true,
62
+ acknowledgmentDetail: 'minimal',
63
+ }),
64
+ });
65
+ export const demandAdmissionStrategy = {
66
+ name: 'demand-admission',
67
+ describe(level) {
68
+ const def = getEnergyLevel(level);
69
+ const config = ADMISSION_CONFIGS[def.value];
70
+ const admitted = config.originatorThreshold === 'all'
71
+ ? 'all originators reach the inbox'
72
+ : config.originatorThreshold === 'none'
73
+ ? 'no originator reaches the inbox'
74
+ : `only ${config.originatorThreshold} originators reach the inbox`;
75
+ if (!config.acknowledge)
76
+ return `${def.label}: ${admitted}`;
77
+ return `${def.label}: ${admitted}, the rest get a ${config.acknowledgmentDetail} acknowledgment and are queued`;
78
+ },
79
+ resolve(level) {
80
+ return ADMISSION_CONFIGS[getEnergyLevel(level).value];
81
+ },
82
+ };
83
+ function isTierAdmitted(threshold, tier) {
84
+ switch (threshold) {
85
+ case 'all':
86
+ return true;
87
+ case 'known':
88
+ return tier !== 'unknown';
89
+ case 'exempt':
90
+ return tier === 'exempt';
91
+ case 'none':
92
+ return false;
93
+ }
94
+ }
95
+ /**
96
+ * The pure gating decision, extracted so apps can unit-test their demand
97
+ * policy without wiring any effects — the counterpart of
98
+ * `resolveNotificationOutcome`.
99
+ *
100
+ * Both configs are required because the two questions are genuinely separate:
101
+ * `admission` says what the app's policy wants done, `autonomy` says how much
102
+ * of it may happen without the user watching.
103
+ */
104
+ export function resolveDemandOutcome(config, autonomy, demand) {
105
+ if (!isOriginatorTier(demand.originatorTier)) {
106
+ throw new Error(`Invalid originator tier: ${String(demand.originatorTier)}`);
107
+ }
108
+ const confidence = demand.confidence ?? 1;
109
+ if (!Number.isFinite(confidence) || confidence < 0 || confidence > 1) {
110
+ throw new Error(`Invalid demand confidence: ${String(demand.confidence)} (expected 0-1)`);
111
+ }
112
+ // The inner circle is never handled by machine. This is also what defuses the
113
+ // gaming risk: an originator who learns that an acknowledgment means
114
+ // "deprioritised" and escalates through another channel only succeeds if
115
+ // their escalation is one the user cannot ignore — which makes them exempt.
116
+ if (demand.originatorTier === 'exempt') {
117
+ return freezeObject({
118
+ admission: 'live',
119
+ acknowledgment: null,
120
+ reason: 'exempt-originator',
121
+ });
122
+ }
123
+ if (isTierAdmitted(config.originatorThreshold, demand.originatorTier)) {
124
+ return freezeObject({
125
+ admission: 'live',
126
+ acknowledgment: null,
127
+ reason: 'tier-admitted',
128
+ });
129
+ }
130
+ // Informational mail asks nothing, so there is nothing to acknowledge or
131
+ // capture. Whether it should *interrupt* is the notification gate's question.
132
+ if (!demand.bearsObligation) {
133
+ return freezeObject({
134
+ admission: 'live',
135
+ acknowledgment: null,
136
+ reason: 'no-obligation',
137
+ });
138
+ }
139
+ if (!config.acknowledge) {
140
+ return freezeObject({
141
+ admission: 'silent',
142
+ acknowledgment: null,
143
+ reason: 'acknowledgment-disabled',
144
+ });
145
+ }
146
+ // Rule 4, the reason this policy needs the autonomy config: an uncertain
147
+ // classification queues silently rather than sending a stranger a wrong
148
+ // acknowledgment on the user's behalf. Silence is recoverable; a sent message
149
+ // is not.
150
+ if (confidence < autonomy.confidenceThreshold) {
151
+ return freezeObject({
152
+ admission: 'silent',
153
+ acknowledgment: null,
154
+ reason: 'below-confidence',
155
+ });
156
+ }
157
+ return freezeObject({
158
+ admission: 'acknowledge',
159
+ acknowledgment: freezeObject({
160
+ detail: config.acknowledgmentDetail,
161
+ allowGeneratedContent: autonomy.allowGeneratedContent,
162
+ }),
163
+ reason: 'acknowledged',
164
+ });
165
+ }
166
+ //# sourceMappingURL=demand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"demand.js","sourceRoot":"","sources":["../src/demand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAI5C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,SAAS,YAAY,CAAmB,KAAQ;IAC9C,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC7B,CAAC;AAcD,MAAM,gBAAgB,GAAgC,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAA;AAE7F,+DAA+D;AAC/D,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,gBAAgB,CAAC,GAAG,CAAC,KAAuB,CAAC,CAAA;AACnF,CAAC;AA4ED,MAAM,iBAAiB,GAAG,YAAY,CAAC;IACrC,gEAAgE;IAChE,GAAG,EAAE,YAAY,CAAC;QAChB,mBAAmB,EAAE,KAAK;QAC1B,WAAW,EAAE,KAAK;QAClB,oBAAoB,EAAE,MAAM;KAC7B,CAAC;IACF,EAAE,EAAE,YAAY,CAAC;QACf,mBAAmB,EAAE,OAAO;QAC5B,WAAW,EAAE,IAAI;QACjB,oBAAoB,EAAE,MAAM;KAC7B,CAAC;IACF,EAAE,EAAE,YAAY,CAAC;QAC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EAA8E;IAC9E,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;QAC5B,OAAO,YAAY,CAAC;YAClB,SAAS,EAAE,MAAM;YACjB,cAAc,EAAE,IAAI;YACpB,MAAM,EAAE,eAAe;SACxB,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QACxB,OAAO,YAAY,CAAC;YAClB,SAAS,EAAE,QAAQ;YACnB,cAAc,EAAE,IAAI;YACpB,MAAM,EAAE,yBAAyB;SAClC,CAAC,CAAA;IACJ,CAAC;IAED,yEAAyE;IACzE,wEAAwE;IACxE,8EAA8E;IAC9E,UAAU;IACV,IAAI,UAAU,GAAG,QAAQ,CAAC,mBAAmB,EAAE,CAAC;QAC9C,OAAO,YAAY,CAAC;YAClB,SAAS,EAAE,QAAQ;YACnB,cAAc,EAAE,IAAI;YACpB,MAAM,EAAE,kBAAkB;SAC3B,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,YAAY,CAAC;QAClB,SAAS,EAAE,aAAa;QACxB,cAAc,EAAE,YAAY,CAAC;YAC3B,MAAM,EAAE,MAAM,CAAC,oBAAoB;YACnC,qBAAqB,EAAE,QAAQ,CAAC,qBAAqB;SACtD,CAAC;QACF,MAAM,EAAE,cAAc;KACvB,CAAC,CAAA;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,19 +1,21 @@
1
1
  export type { AdaptationStrategy, CognitiveProfile, DecisionCapacity, EnergyClock, EnergyChangeListener, EnergyLevel, EnergyLevelDefinition, EnergyMetrics, EnergyPersistence, EnergyPresence, EnergyPresenceMap, EnergySource, EnergyState, FocusDuration, InterruptionTolerance, TaskComplexity, } from './types.js';
2
2
  export { ENERGY_LEVEL_VALUES, ENERGY_PRESENCE_VALUES, ENERGY_SOURCE_VALUES } from './types.js';
3
- export { UNPRODUCED_ORIGIN, UNPRODUCED_TIMESTAMP, createEnergyState, cycleEnergyLevel, getEnergyLevel, getEnergyLevels, isEnergyLevel, isEnergySource, isHigherEnergy, isUnproducedState, } from './levels.js';
3
+ export { UNPRODUCED_ORIGIN, UNPRODUCED_TIMESTAMP, createEnergyOrigin, createEnergyState, cycleEnergyLevel, getEnergyLevel, getEnergyLevels, isEnergyLevel, isEnergySource, isHigherEnergy, isUnproducedState, } from './levels.js';
4
4
  export type { ExternalLevelCompatibility, ExternalLevelCompatibilityOptions } from './compat.js';
5
5
  export { createExternalLevelCompatibility, cycleDiscreteLevel, mapToNearestDiscreteLevel, mapToNearestEnergyLevel, } from './compat.js';
6
6
  export { getEnergyMetrics } from './metrics.js';
7
7
  export type { EnergyEngine, EnergyEngineOptions } from './engine.js';
8
8
  export { createEnergyEngine } from './engine.js';
9
- export type { InteractionForgivenessConfig, NotificationConfig, TaskComplexityConfig, UIVisibilityConfig, } from './strategies.js';
10
- export { interactionForgivenessStrategy, notificationStrategy, taskComplexityStrategy, uiVisibilityStrategy, } from './strategies.js';
9
+ export type { AutonomyConfig, InteractionForgivenessConfig, NotificationConfig, TaskComplexityConfig, UIVisibilityConfig, } from './strategies.js';
10
+ export { autonomyStrategy, interactionForgivenessStrategy, notificationStrategy, taskComplexityStrategy, uiVisibilityStrategy, } from './strategies.js';
11
11
  export type { EnergyPresenceSpec } from './presence.js';
12
12
  export { createPresenceStrategy, defineEnergyPresence, isEnergyPresence, isPresenceVisible, presenceAtOrAbove, presenceAtOrBelow, resolveEnergyPresence, } from './presence.js';
13
13
  export type { FocusSession, FocusSessionController, FocusSessionControllerOptions, FocusSessionEvent, FocusSessionListener, FocusSuppressible, StartFocusSessionOptions, } from './session.js';
14
14
  export { createFocusSessionController, isSessionExpired, sessionRemainingMs } from './session.js';
15
15
  export type { DeferralConfig, DeferralPreset, DeferralPresetOptions } from './defer.js';
16
16
  export { DEFERRAL_PRESET_IDS, createDeferralPresets, deferralStrategy, resolveDeferral, } from './defer.js';
17
+ export type { AcknowledgmentDetail, DemandAcknowledgment, DemandAdmission, DemandAdmissionConfig, DemandInput, DemandOutcome, DemandOutcomeReason, OriginatorTier, } from './demand.js';
18
+ export { demandAdmissionStrategy, isOriginatorTier, resolveDemandOutcome } from './demand.js';
17
19
  export type { EnergyNotification, GateScheduler, NotificationChannels, NotificationDelivery, NotificationDeliveryReason, NotificationGate, NotificationGateOptions, NotificationPriority, PublishOutcome, } from './gate.js';
18
20
  export { createNotificationGate, isNotificationPriority, resolveNotificationOutcome, } from './gate.js';
19
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,oBAAoB,EACpB,WAAW,EACX,qBAAqB,EACrB,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,aAAa,EACb,qBAAqB,EACrB,cAAc,GACf,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAG9F,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,aAAa,EACb,cAAc,EACd,cAAc,EACd,iBAAiB,GAClB,MAAM,aAAa,CAAA;AAEpB,YAAY,EAAE,0BAA0B,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAA;AAChG,OAAO,EACL,gCAAgC,EAChC,kBAAkB,EAClB,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,aAAa,CAAA;AAGpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAG/C,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAGhD,YAAY,EACV,4BAA4B,EAC5B,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,8BAA8B,EAC9B,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,iBAAiB,CAAA;AAGxB,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,eAAe,CAAA;AAGtB,YAAY,EACV,YAAY,EACZ,sBAAsB,EACtB,6BAA6B,EAC7B,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAGjG,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AACvF,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,GAChB,MAAM,YAAY,CAAA;AAGnB,YAAY,EACV,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,EAC1B,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,cAAc,GACf,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,oBAAoB,EACpB,WAAW,EACX,qBAAqB,EACrB,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,aAAa,EACb,qBAAqB,EACrB,cAAc,GACf,MAA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AAE,cAAc,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AACvF,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,GAChB,MAAM,YAAY,CAAA;AAGnB,YAAY,EACV,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,qBAAqB,EACrB,WAAW,EACX,aAAa,EACb,mBAAmB,EACnB,cAAc,GACf,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAG7F,YAAY,EACV,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,EAC1B,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,cAAc,GACf,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,WAAW,CAAA"}
package/dist/index.js CHANGED
@@ -1,13 +1,14 @@
1
1
  export { ENERGY_LEVEL_VALUES, ENERGY_PRESENCE_VALUES, ENERGY_SOURCE_VALUES } from './types.js';
2
2
  // Level definitions and pure functions
3
- export { UNPRODUCED_ORIGIN, UNPRODUCED_TIMESTAMP, createEnergyState, cycleEnergyLevel, getEnergyLevel, getEnergyLevels, isEnergyLevel, isEnergySource, isHigherEnergy, isUnproducedState, } from './levels.js';
3
+ export { UNPRODUCED_ORIGIN, UNPRODUCED_TIMESTAMP, createEnergyOrigin, createEnergyState, cycleEnergyLevel, getEnergyLevel, getEnergyLevels, isEnergyLevel, isEnergySource, isHigherEnergy, isUnproducedState, } from './levels.js';
4
4
  export { createExternalLevelCompatibility, cycleDiscreteLevel, mapToNearestDiscreteLevel, mapToNearestEnergyLevel, } from './compat.js';
5
5
  // Derived metrics
6
6
  export { getEnergyMetrics } from './metrics.js';
7
7
  export { createEnergyEngine } from './engine.js';
8
- export { interactionForgivenessStrategy, notificationStrategy, taskComplexityStrategy, uiVisibilityStrategy, } from './strategies.js';
8
+ export { autonomyStrategy, interactionForgivenessStrategy, notificationStrategy, taskComplexityStrategy, uiVisibilityStrategy, } from './strategies.js';
9
9
  export { createPresenceStrategy, defineEnergyPresence, isEnergyPresence, isPresenceVisible, presenceAtOrAbove, presenceAtOrBelow, resolveEnergyPresence, } from './presence.js';
10
10
  export { createFocusSessionController, isSessionExpired, sessionRemainingMs } from './session.js';
11
11
  export { DEFERRAL_PRESET_IDS, createDeferralPresets, deferralStrategy, resolveDeferral, } from './defer.js';
12
+ export { demandAdmissionStrategy, isOriginatorTier, resolveDemandOutcome } from './demand.js';
12
13
  export { createNotificationGate, isNotificationPriority, resolveNotificationOutcome, } from './gate.js';
13
14
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAE9F,uCAAuC;AACvC,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,aAAa,EACb,cAAc,EACd,cAAc,EACd,iBAAiB,GAClB,MAAM,aAAa,CAAA;AAGpB,OAAO,EACL,gCAAgC,EAChC,kBAAkB,EAClB,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,aAAa,CAAA;AAEpB,kBAAkB;AAClB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAI/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAShD,OAAO,EACL,8BAA8B,EAC9B,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,iBAAiB,CAAA;AAIxB,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,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EAChB,eAAe,GAChB,MAAM,YAAY,CAAA;AAanB,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAc7F,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,WAAW,CAAA"}
@@ -48,4 +48,30 @@ export interface InteractionForgivenessConfig {
48
48
  readonly autosaveIntervalMs: number;
49
49
  }
50
50
  export declare const interactionForgivenessStrategy: AdaptationStrategy<InteractionForgivenessConfig>;
51
+ /**
52
+ * How much latitude automation has to act for the user without asking.
53
+ *
54
+ * The mirror of `interactionForgivenessStrategy`: forgiveness protects against
55
+ * the *user's* mistakes at low energy, autonomy against the *agent's*. The
56
+ * system acts on the user's behalf precisely when they are least able to
57
+ * supervise it, so the worst day is the wrong day for it to improvise.
58
+ *
59
+ * What narrows as energy falls is *discretion*, not action. At rest the
60
+ * automation may still take a single, certain, template-only step — an
61
+ * out-of-office reply is exactly that shape — but it may not chain steps,
62
+ * compose novel wording, or act on a judgment call.
63
+ */
64
+ export interface AutonomyConfig {
65
+ /**
66
+ * Minimum confidence (0–1) an automated decision needs before acting
67
+ * unattended. `1` admits only certainty, which in practice means rule-based
68
+ * actions and never a judgment call.
69
+ */
70
+ readonly confidenceThreshold: number;
71
+ /** Whether automation may compose novel wording, or only fill fixed templates. */
72
+ readonly allowGeneratedContent: boolean;
73
+ /** How many automated steps may chain before control returns to the user. */
74
+ readonly maxUnattendedSteps: number;
75
+ }
76
+ export declare const autonomyStrategy: AdaptationStrategy<AutonomyConfig>;
51
77
  //# sourceMappingURL=strategies.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"strategies.d.ts","sourceRoot":"","sources":["../src/strategies.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAe,cAAc,EAAE,MAAM,YAAY,CAAA;AAQjF,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;I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AAM,oBAAoB,EAAE,kBAAkB,CAAC,kBAAkB,CAgBvE,CAAA;AAID,MAAM,WAAW,oBAAoB;IACnC,yCAAyC;IACzC,QAAQ,CAAC,aAAa,EAAE,cAAc,CAAA;IACtC,4CAA4C;IAC5C,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAA;IAC/B,uDAAuD;IACvD,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAA;CACtC;AAgCD,eAAO,MAAM,sBAAsB,EAAE,kBAAkB,CAAC,oBAAoB,CAY3E,CAAA;AAID;;;;;GAKG;AACH,MAAM,WAAW,4BAA4B;IAC3C,kEAAkE;IAClE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,yEAAyE;IACzE,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAA;IACpC,sDAAsD;IACtD,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAA;CACpC;AA8BD,eAAO,MAAM,8BAA8B,EAAE,kBAAkB,CAAC,4BAA4B,CAa3F,CAAA;AAID;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAA;IACpC,kFAAkF;IAClF,QAAQ,CAAC,qBAAqB,EAAE,OAAO,CAAA;IACvC,6EAA6E;IAC7E,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAA;CACpC;AAiCD,eAAO,MAAM,gBAAgB,EAAE,kBAAkB,CAAC,cAAc,CAW/D,CAAA"}
@@ -218,4 +218,46 @@ export const interactionForgivenessStrategy = {
218
218
  return FORGIVENESS_CONFIGS[getEnergyLevel(level).value];
219
219
  },
220
220
  };
221
+ const AUTONOMY_CONFIGS = freezeObject({
222
+ 100: freezeObject({
223
+ confidenceThreshold: 0.6,
224
+ allowGeneratedContent: true,
225
+ maxUnattendedSteps: 8,
226
+ }),
227
+ 75: freezeObject({
228
+ confidenceThreshold: 0.7,
229
+ allowGeneratedContent: true,
230
+ maxUnattendedSteps: 5,
231
+ }),
232
+ 50: freezeObject({
233
+ confidenceThreshold: 0.8,
234
+ allowGeneratedContent: true,
235
+ maxUnattendedSteps: 3,
236
+ }),
237
+ 25: freezeObject({
238
+ confidenceThreshold: 0.9,
239
+ allowGeneratedContent: false,
240
+ maxUnattendedSteps: 1,
241
+ }),
242
+ // Rest: one certain, templated step at most. Not zero — an automated action
243
+ // the user has standing consent for (an out-of-office reply is the classic)
244
+ // is safest at rest precisely because it stops improvising.
245
+ 0: freezeObject({
246
+ confidenceThreshold: 1,
247
+ allowGeneratedContent: false,
248
+ maxUnattendedSteps: 1,
249
+ }),
250
+ });
251
+ export const autonomyStrategy = {
252
+ name: 'autonomy',
253
+ describe(level) {
254
+ const def = getEnergyLevel(level);
255
+ const config = AUTONOMY_CONFIGS[def.value];
256
+ const content = config.allowGeneratedContent ? 'generated content allowed' : 'templates only';
257
+ return `${def.label}: acts unattended at ${Math.round(config.confidenceThreshold * 100)}% confidence, ${content}, up to ${config.maxUnattendedSteps} chained step${config.maxUnattendedSteps === 1 ? '' : 's'}`;
258
+ },
259
+ resolve(level) {
260
+ return AUTONOMY_CONFIGS[getEnergyLevel(level).value];
261
+ },
262
+ };
221
263
  //# sourceMappingURL=strategies.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"strategies.js","sourceRoot":"","sources":["../src/strategies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAG5C,SAAS,YAAY,CAAmB,KAAQ;IAC9C,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC7B,CAAC;AAgBD,MAAM,UAAU,GAAG,YAAY,CAAC;IAC9B,GAAG,EAAE,YAAY,CAAC;QAChB,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,IAAI;QACZ,SAAS,EAAE,IAAI;QACf,OAAO,EAAE,IAAI;QACb,aAAa,EAAE,CAAC;QAChB,kBAAkB,EAAE,CAAC;QACrB,eAAe,EAAE,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C5E,4DAA4D;IAC5D,CAAC,EAAE,YAAY,CAAC;QACd,mBAAmB,EAAE,CAAC;QACtB,qBAAqB,EAAE,KAAK;QAC5B,kBAAkB,EAAE,CAAC;KACtB,CAAC;CACH,CAAmE,CAAA;AAEpE,MAAM,CAAC,MAAM,gBAAgB,GAAuC;IAClE,IAAI,EAAE,UAAU;IAChB,QAAQ,CAAC,KAAK;QACZ,MAAM,GAAG,GAAG,cAAc,CAAC,KAAK,CAAC,CAAA;QACjC,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAC1C,MAAM,OAAO,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,gBAAgB,CAAA;QAC7F,OAAO,GAAG,GAAG,CAAC,KAAK,wBAAwB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,mBAAmB,GAAG,GAAG,CAAC,iBAAiB,OAAO,WAAW,MAAM,CAAC,kBAAkB,gBAAgB,MAAM,CAAC,kBAAkB,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAA;IACjN,CAAC;IACD,OAAO,CAAC,KAAK;QACX,OAAO,gBAAgB,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAA;IACtD,CAAC;CACF,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kumbatio/energy-system",
3
- "version": "0.5.3",
3
+ "version": "0.6.0",
4
4
  "private": false,
5
5
  "description": "Framework-agnostic TypeScript library for energy-aware application behavior.",
6
6
  "license": "MIT",
@@ -43,14 +43,14 @@
43
43
  "devDependencies": {
44
44
  "@happy-dom/global-registrator": "^20.11.1",
45
45
  "@types/node": "^26.1.2",
46
- "@types/react": "^19.2.17",
47
- "@types/react-dom": "^19.2.3",
48
- "oxfmt": "0.61.0",
49
- "oxlint": "1.76.0",
46
+ "@types/react": "^19.2.18",
47
+ "@types/react-dom": "^19.2.4",
48
+ "oxfmt": "0.62.0",
49
+ "oxlint": "1.77.0",
50
50
  "oxlint-tsgolint": "^7.0.2001",
51
51
  "react": "^19.2.8",
52
52
  "react-dom": "^19.2.8",
53
- "tsx": "^4.23.1",
53
+ "tsx": "^4.23.7",
54
54
  "typescript": "^7.0.2"
55
55
  },
56
56
  "peerDependencies": {
@@ -66,7 +66,7 @@
66
66
  }
67
67
  },
68
68
  "engines": {
69
- "node": ">=24"
69
+ "node": ">=24.19.0"
70
70
  },
71
71
  "scripts": {
72
72
  "build": "tsc -p tsconfig.build.json && pnpm run api:surface",