@deepseek-ai/dsh-goal 0.0.1-rc.1

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/src/types.ts ADDED
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Pure types of the goal domain: the ONE home of the `goal` projection-key
3
+ * declaration plus the durable payload vocabulary it carries, free of this
4
+ * package's host-side imports (cordis events, dsh-agent, dsh-llm, the
5
+ * service). Two namespace projections serve it — `./types` for host
6
+ * consumers, `./client` (the browser half-entry's re-export) for client
7
+ * aggregates — with zero content duplication. Host-coupled domain
8
+ * vocabulary (message sources, events, fold shapes) lives in ./domain.ts.
9
+ *
10
+ * @module @deepseek-ai/dsh-goal/types
11
+ */
12
+
13
+ import type { Branded } from '@deepseek-ai/dsh-brand'
14
+
15
+ /** Identifies one goal across its durable revisions. */
16
+ export type GoalId = Branded<'GoalId'>
17
+
18
+ /** Compare-and-set identity for one exact goal revision. */
19
+ export interface GoalRef {
20
+ /** Stable goal identity. */
21
+ readonly id: GoalId
22
+ /** Positive revision; every durable mutation increments it. */
23
+ readonly revision: number
24
+ }
25
+
26
+ /** Input whose omitted round cap is resolved by the service configuration. */
27
+ export interface CreateGoalRequest {
28
+ readonly objective: string
29
+ readonly maxGoalRounds?: number
30
+ }
31
+
32
+ /** Wire-safe acknowledgement of one created goal. */
33
+ export interface CreateGoalResult {
34
+ readonly ref: GoalRef
35
+ }
36
+
37
+ /** Fields changed by an edit; at least one must be present. */
38
+ export interface EditGoalRequest {
39
+ readonly objective?: string
40
+ readonly maxGoalRounds?: number
41
+ }
42
+
43
+ /** Durable continuation phase. Activation is process-local and separate. */
44
+ export type GoalPhase =
45
+ | 'active'
46
+ | 'paused'
47
+ | 'blocked'
48
+ | 'complete'
49
+
50
+ /** Machine-routable and human-readable explanation for a blocked goal. */
51
+ export interface GoalBlockReason {
52
+ /** Stable lower-kebab-case classification chosen by the blocking policy. */
53
+ readonly code: string
54
+ /** Non-empty explanation shown to humans and models. */
55
+ readonly message: string
56
+ }
57
+
58
+ /** Full durable state written by every non-clear goal mutation. */
59
+ export interface GoalSnapshot extends GoalRef {
60
+ /** Human-requested completion objective. */
61
+ readonly objective: string
62
+ /** Durable lifecycle phase. */
63
+ readonly phase: GoalPhase
64
+ /** Present exactly while `phase` is `blocked`. */
65
+ readonly blockedReason?: GoalBlockReason
66
+ /** Total admitted goal-round cap. */
67
+ readonly maxGoalRounds: number
68
+ }
69
+
70
+ /** Whether this live process may automatically continue an active goal. */
71
+ export type GoalActivation = 'armed' | 'disarmed'
72
+
73
+ /** Current goal projection, including values derived from the session log. */
74
+ export interface GoalView extends GoalSnapshot {
75
+ /** Highest admitted round number for this goal. */
76
+ readonly roundsStarted: number
77
+ /** Epoch milliseconds of the create mutation. */
78
+ readonly createdAt: number
79
+ /** Epoch milliseconds of the latest mutation. */
80
+ readonly updatedAt: number
81
+ /** Process-local continuation eligibility; never persisted. */
82
+ readonly activation: GoalActivation
83
+ }
84
+
85
+ /**
86
+ * The `goal` projection value: the current durable goal with its replay
87
+ * counters, exactly as the latest `goal/change` event carried them.
88
+ * Activation is process-local (never persisted) and deliberately absent —
89
+ * the projection reflects durable phase only.
90
+ */
91
+ export interface GoalProjection {
92
+ /** Current durable goal snapshot (the CAS ref for mutations rides on it). */
93
+ readonly goal: GoalSnapshot
94
+ /** Highest admitted round number for this goal. */
95
+ readonly roundsStarted: number
96
+ /** Epoch milliseconds of the create mutation. */
97
+ readonly createdAt: number
98
+ /** Epoch milliseconds of the latest mutation. */
99
+ readonly updatedAt: number
100
+ }
101
+
102
+ declare module '@deepseek-ai/dsh-session-projection/types' {
103
+ interface SessionProjectionMap {
104
+ /**
105
+ * The session's current goal (the latest `goal/change` whole value), or
106
+ * `null` before the first create and after a clear tombstone.
107
+ * Whole-value rule: every goal change carries the complete post-change
108
+ * state, so the fold is last-wins.
109
+ */
110
+ goal: GoalProjection | null
111
+ }
112
+ }