goals.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * goals domain contract. Method signatures are the source of truth:
  3. * unary methods take the RpcRequest<P> narrow form and the impl echoes rpcId.
  4. *
  5. * Mutations only: the read side is the 'goal' session projection (history
  6. * tail-page projections block + session/projection frames), so there is no
  7. * goal.get and no wire goal view — responses acknowledge with the new CAS
  8. * ref and never feed client state (the committed goal/change event reaches
  9. * every client through the mux stream carrying the same whole value).
  10. */
  11. import type { Branded } from '@deepseek-ai/dsh-brand'
  12. import type { SessionId } from '@deepseek-ai/dsh-session/types'
  13. import type { RpcRequest, RpcResponse } from './rpc.ts'
  14. /** Identifies one goal across its durable revisions. */
  15. export type GoalId = Branded<'GoalId'>
  16. /** Compare-and-set identity for one exact goal revision. */
  17. export interface GoalRef {
  18. readonly id: GoalId
  19. readonly revision: number
  20. }
  21. /** Goal-domain unary methods (every mutation resolves the session's agent and applies one CAS-guarded verb). */
  22. export interface GoalsApi {
  23. /** Create and arm a goal. */
  24. create(request: RpcRequest<{ sessionId: SessionId; objective: string; maxGoalRounds?: number }>):
  25. Promise<RpcResponse<{ ref: GoalRef }>>
  26. /** Edit objective and/or round cap without changing phase. */
  27. edit(request: RpcRequest<{ sessionId: SessionId; ref: GoalRef; objective?: string; maxGoalRounds?: number }>):
  28. Promise<RpcResponse<{ ref: GoalRef }>>
  29. /** Pause an active goal and disarm automatic continuation. */
  30. pause(request: RpcRequest<{ sessionId: SessionId; ref: GoalRef }>):
  31. Promise<RpcResponse<{ ref: GoalRef }>>
  32. /** Resume and arm a stopped goal. */
  33. resume(request: RpcRequest<{ sessionId: SessionId; ref: GoalRef }>):
  34. Promise<RpcResponse<{ ref: GoalRef }>>
  35. /** Mark a current non-complete goal complete and disarm it. */
  36. complete(request: RpcRequest<{ sessionId: SessionId; ref: GoalRef }>):
  37. Promise<RpcResponse<{ ref: GoalRef }>>
  38. /** Clear the current goal while retaining a durable tombstone and history. */
  39. clear(request: RpcRequest<{ sessionId: SessionId; ref: GoalRef }>):
  40. Promise<RpcResponse<{ cleared: true }>>
  41. }