@deepseek-ai/dsh-goal 0.1.2-alpha.3 → 0.1.2-alpha.5

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/lib/index.js CHANGED
@@ -2,6 +2,7 @@ import { randomUUID } from "node:crypto";
2
2
  import z from "@deepseek-ai/schemastery";
3
3
  import { z as z$1 } from "zod";
4
4
  import { agentEvents } from "@deepseek-ai/dsh-agent";
5
+ import { SessionSeq } from "@deepseek-ai/dsh-session";
5
6
  import { Remote, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
6
7
  import { HarnessError } from "@deepseek-ai/dsh-llm";
7
8
  //#region lib/types/runtime.js
@@ -584,7 +585,7 @@ let GoalService = (() => {
584
585
  ctx.on("session/event", (session, event) => {
585
586
  if (event.type !== "goal/change") return;
586
587
  const runtime = this.runtimeState(session);
587
- runtime.activation = runtime.pendingActivation?.seq === event.seq ? runtime.pendingActivation.activation : "disarmed";
588
+ runtime.activation = runtime.pendingActivation !== void 0 && SessionSeq(runtime.pendingActivation.offset) === event.seq ? runtime.pendingActivation.activation : "disarmed";
588
589
  });
589
590
  }
590
591
  /**
@@ -824,13 +825,13 @@ let GoalService = (() => {
824
825
  commit(agent, runtime, change, activation) {
825
826
  const ref = goalChangeRef(change);
826
827
  runtime.pendingActivation = {
827
- seq: agent.session.seq,
828
+ offset: agent.session.seq,
828
829
  activation
829
830
  };
830
831
  try {
831
832
  const event = agent.session.append("goal/change", change);
832
833
  /* v8 ignore next -- Session.append returns the event committed at the pre-append seq. */
833
- if (runtime.pendingActivation.seq === event.seq) runtime.activation = activation;
834
+ if (SessionSeq(runtime.pendingActivation.offset) === event.seq) runtime.activation = activation;
834
835
  } finally {
835
836
  runtime.pendingActivation = void 0;
836
837
  }
package/lib/invariant.js CHANGED
@@ -294,7 +294,7 @@ const install = Object.assign((ctx, fail) => {
294
294
  const staged = /* @__PURE__ */ new WeakMap();
295
295
  const seed = (session) => {
296
296
  const state = emptyGoalFoldState();
297
- for (const event of session.events) applyChecked(state, event, fail);
297
+ for (const event of session.snapshotEvents()) applyChecked(state, event, fail);
298
298
  states.set(session, state);
299
299
  return state;
300
300
  };
@@ -150,7 +150,7 @@ export const TYPERT = {
150
150
  typeSymbol: '@deepseek-ai/dsh-goal/client#GoalRef',
151
151
  schema: _deepseek_ai_dsh_goal_goals_clear_result$schema,
152
152
  },
153
- sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":426,"column":3},
153
+ sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":431,"column":3},
154
154
  },
155
155
  {
156
156
  id: '@deepseek-ai/dsh-goal#goals/complete',
@@ -190,7 +190,7 @@ export const TYPERT = {
190
190
  typeSymbol: '@deepseek-ai/dsh-goal/client#GoalView',
191
191
  schema: _deepseek_ai_dsh_goal_goals_complete_result$schema,
192
192
  },
193
- sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":384,"column":3},
193
+ sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":389,"column":3},
194
194
  },
195
195
  {
196
196
  id: '@deepseek-ai/dsh-goal#goals/create',
@@ -231,7 +231,7 @@ export const TYPERT = {
231
231
  typeSymbol: '@deepseek-ai/dsh-goal/client#CreateGoalResult',
232
232
  schema: _deepseek_ai_dsh_goal_goals_create_result$schema,
233
233
  },
234
- sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":618,"column":3},
234
+ sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":623,"column":3},
235
235
  },
236
236
  {
237
237
  id: '@deepseek-ai/dsh-goal#goals/edit',
@@ -281,7 +281,7 @@ export const TYPERT = {
281
281
  typeSymbol: '@deepseek-ai/dsh-goal/client#GoalView',
282
282
  schema: _deepseek_ai_dsh_goal_goals_edit_result$schema,
283
283
  },
284
- sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":322,"column":3},
284
+ sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":327,"column":3},
285
285
  },
286
286
  {
287
287
  id: '@deepseek-ai/dsh-goal#goals/pause',
@@ -321,7 +321,7 @@ export const TYPERT = {
321
321
  typeSymbol: '@deepseek-ai/dsh-goal/client#GoalView',
322
322
  schema: _deepseek_ai_dsh_goal_goals_pause_result$schema,
323
323
  },
324
- sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":345,"column":3},
324
+ sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":350,"column":3},
325
325
  },
326
326
  {
327
327
  id: '@deepseek-ai/dsh-goal#goals/resume',
@@ -361,7 +361,7 @@ export const TYPERT = {
361
361
  typeSymbol: '@deepseek-ai/dsh-goal/client#GoalView',
362
362
  schema: _deepseek_ai_dsh_goal_goals_resume_result$schema,
363
363
  },
364
- sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":357,"column":3},
364
+ sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":362,"column":3},
365
365
  },
366
366
  ],
367
367
  model: {
@@ -454,6 +454,10 @@ export const TYPERT = {
454
454
  "name": "AgentCancelCause",
455
455
  "declaration": "export type AgentCancelCause = { readonly kind: 'user'; } | { readonly kind: 'parent'; } | { readonly kind: 'hook'; readonly reason: string; } | { readonly kind: 'disposed'; };"
456
456
  },
457
+ {
458
+ "name": "AgentMessageSource",
459
+ "declaration": "export interface AgentMessageSource {\n readonly kind: 'agent-message';\n readonly form: 'relay';\n readonly senderSessionId: SessionId;\n}"
460
+ },
457
461
  {
458
462
  "name": "AgentOptions",
459
463
  "declaration": "export interface AgentOptions {\n provider?: string;\n model?: string;\n reasoningEffort?: ReasoningEffortId;\n maxTokens?: number;\n subagentDepth?: number;\n}"
@@ -490,6 +494,10 @@ export const TYPERT = {
490
494
  "name": "Branded",
491
495
  "declaration": "export type Branded<B extends string> = string & { readonly [BRAND]: B; };"
492
496
  },
497
+ {
498
+ "name": "BrandedNumber",
499
+ "declaration": "export type BrandedNumber<B extends string> = number & { readonly [BRAND]: B; };"
500
+ },
493
501
  {
494
502
  "name": "CancelOptions",
495
503
  "declaration": "export interface CancelOptions {\n keepInbox?: boolean | undefined;\n}"
@@ -534,10 +542,6 @@ export const TYPERT = {
534
542
  "name": "ContinuableSubagentDescriptorData",
535
543
  "declaration": "export interface ContinuableSubagentDescriptorData extends SubagentDescriptorBase {\n readonly mode: 'continuable';\n readonly label: string;\n readonly agentProvider?: string;\n readonly agentModel?: string;\n readonly agentReasoningEffort?: ReasoningEffortId;\n readonly persona?: string;\n readonly toolFilter?: ToolRestriction;\n}"
536
544
  },
537
- {
538
- "name": "CoordinatorMessageSource",
539
- "declaration": "export interface CoordinatorMessageSource {\n readonly kind: 'coordinator';\n readonly form: 'relay';\n readonly senderSessionId: SessionId;\n}"
540
- },
541
545
  {
542
546
  "name": "CreateGoalRequest",
543
547
  "declaration": "export interface CreateGoalRequest {\n readonly objective: string;\n readonly maxGoalRounds?: number;\n}"
@@ -660,7 +664,7 @@ export const TYPERT = {
660
664
  },
661
665
  {
662
666
  "name": "MessageSourceMap",
663
- "declaration": "export interface MessageSourceMap {\n user: { kind: 'user'; };\n plugin: { kind: 'plugin'; plugin: string; } & ContextFormed;\n model: ModelMessageSource;\n tool: ToolMessageSource;\n 'user-rpc': { kind: 'user'; rpcId: SessionRequestId; clientTimeZone?: string; };\n coordinator: CoordinatorMessageSource;\n 'subagent-report': SubagentReportMessageSource;\n 'subagent-settled': SubagentSettledMessageSource;\n 'skill-invocation': SkillInvocationSource;\n 'team-message': TeamMessageSource;\n goal: GoalMessageSource;\n 'session-reference': SessionReferenceSource;\n}"
667
+ "declaration": "export interface MessageSourceMap {\n user: { kind: 'user'; };\n plugin: { kind: 'plugin'; plugin: string; } & ContextFormed;\n model: ModelMessageSource;\n tool: ToolMessageSource;\n 'user-rpc': { kind: 'user'; rpcId: SessionRequestId; clientTimeZone?: string; };\n 'agent-message': AgentMessageSource;\n 'subagent-settled': SubagentSettledMessageSource;\n 'skill-invocation': SkillInvocationSource;\n 'team-message': TeamMessageSource;\n goal: GoalMessageSource;\n 'session-reference': SessionReferenceSource;\n}"
664
668
  },
665
669
  {
666
670
  "name": "ModelMessageSource",
@@ -674,6 +678,10 @@ export const TYPERT = {
674
678
  "name": "OneShotSubagentDescriptorData",
675
679
  "declaration": "export interface OneShotSubagentDescriptorData extends SubagentDescriptorBase {\n readonly mode: 'one-shot';\n readonly label?: string;\n}"
676
680
  },
681
+ {
682
+ "name": "OptionalSessionSeq",
683
+ "declaration": "export type OptionalSessionSeq = SessionSeq | null;"
684
+ },
677
685
  {
678
686
  "name": "ProviderRequestId",
679
687
  "declaration": "export type ProviderRequestId = Branded<'ProviderRequestId'>;"
@@ -712,15 +720,15 @@ export const TYPERT = {
712
720
  },
713
721
  {
714
722
  "name": "Session",
715
- "declaration": "export class Session {\n get surface(): SessionSurface;\n readonly header: SessionHeader;\n get id(): SessionId;\n readonly firstLiveSeq: number;\n get events(): readonly SessionEvent[];\n get seq(): number;\n append<T extends SessionEventType>(type: T, data: SessionEventMap[T], ...opts: T extends SurfaceEventType ? [opts: SurfaceIntent] : []): SessionEvent<T>;\n requestHeader(): EpochHeader | undefined;\n requestContext(): RequestContext | undefined;\n deriveMessages(): Message[];\n deriveEventMessage(event: SessionEvent): Message | null;\n}"
723
+ "declaration": "export class Session {\n get surface(): SessionSurface;\n readonly header: SessionHeader;\n readonly inheritedEventCount: SessionLogOffset;\n get id(): SessionId;\n readonly firstLiveSeq: SessionLogOffset;\n eventAt(seq: SessionSeq): SessionEvent | undefined;\n snapshotEvents(fromSeq: SessionLogOffset = SessionLogOffset(0), toSeqExclusive: SessionLogOffset = this.seq): readonly SessionEvent[];\n ownEvents(): readonly SessionEvent[];\n isOwnSeq(seq: SessionSeq): boolean;\n get seq(): SessionLogOffset;\n append<T extends SessionEventType>(type: T, data: SessionEventMap[T], ...opts: T extends SurfaceEventType ? [opts: SurfaceIntent] : []): SessionEvent<T>;\n requestHeader(): EpochHeader | undefined;\n requestContext(): RequestContext | undefined;\n deriveMessages(): Message[];\n deriveEventMessage(event: SessionEvent): Message | null;\n}"
716
724
  },
717
725
  {
718
726
  "name": "SessionEvent",
719
- "declaration": "export type SessionEvent<T extends SessionEventType = SessionEventType> = { [K in SessionEventType]: { type: K; seq: number; time: number; data: SessionEventMap[K]; ignorable?: true; } & (K extends SurfaceEventType ? { sourceEventSeqs?: number[]; surfaceOp?: SurfaceOp; } : object) }[T];"
727
+ "declaration": "export type SessionEvent<T extends SessionEventType = SessionEventType> = { [K in SessionEventType]: { type: K; seq: SessionSeq; time: number; data: SessionEventMap[K]; ignorable?: true; } & (K extends SurfaceEventType ? { sourceEventSeqs?: SessionSeq[]; surfaceOp?: SurfaceOp; } : object) }[T];"
720
728
  },
721
729
  {
722
730
  "name": "SessionEventMap",
723
- "declaration": "export interface SessionEventMap {\n 'turn/start': { turn: number; };\n 'turn/end': { turn: number; reason: TurnEndReason; };\n 'step/start': { turn: number; step: number; };\n 'step/end': { turn: number; step: number; };\n 'user/message': UserMessage;\n 'assistant/chunk': { turn: number; step: number; chunk: StreamChunk; };\n 'assistant/message': { turn: number; step: number; message: AssistantMessage; usage?: TokenUsage; interrupted?: true; };\n 'tool/call': { turn: number; step: number; callId: ToolCallId; name: string; arguments: string; };\n 'tool/result': { turn: number; step: number; message: ToolResultMessage; error?: { name: string; code: string; }; meta?: JsonValue; };\n 'request/header': { header: EpochHeader; reason: RequestHeaderReason; startsSeries?: true; };\n 'request/context': RequestContext;\n 'session/end-seed': Record<string, never>;\n 'agent/inbox/spliced': { target: InboxTarget; start: number; removedCount?: number; inserted: UserMessage[]; outcome?: 'canceled'; };\n 'approval/asked': { id: ApprovalRequestId; toolName: string; callId?: ToolCallId; reason?: string; };\n 'approval/decided': { id: ApprovalRequestId; outcome: ApprovalOutcome; };\n 'approval/policy': { policy: ApprovalPolicy; source?: 'delegation'; };\n 'tool/code-dispatch-start': PtcDispatchStartEventData;\n 'tool/code-dispatch': PtcDispatchEventData;\n 'agent-preset/selected': { agentPreset: string; };\n 'session/title': SessionTitleEventData;\n 'todo/write': { todos: TodoItem[]; };\n 'model/selection': ModelSelection;\n 'subagent/descriptor': SubagentDescriptorData;\n 'sandbox/mode': { mode: SandboxMode; source?: 'delegation'; };\n 'command/run': { commandId: CommandId; name: string; args?: string; source: CommandSource; };\n 'command/done': { commandId: CommandId; kind: 'success' | 'error'; text?: string; sourceEventSeq?: number; };\n 'team/member': { version: 1; teamId: TeamId; member: TeamMemberSnapshot; };\n 'team/task': { version: 1; teamId: TeamId; task: TeamTaskSnapshot; };\n 'team/message/queued': { version: 1; teamId: TeamId; message: TeamMessageSnapshot; };\n 'team/message/delivered': { version: 1; teamId: TeamId; messageId: TeamMessageId; targetId: SessionId; };\n 'goal/change': GoalChangeMeta;\n 'compaction/start': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; };\n 'compaction/summary': { compactionId: CompactionId; sourceCommandId?: CommandId; summary: ContentBlock[]; shadowedRange: { start: number; end: number; }; shadowedSeqs: number[]; shadowedTokenCount: number; provider: string; model: string; maxTokens?: number; usage?: TokenUsage; } & ({ rawOutput: ContentBlock[]; llmStreamCall: true; } | { rawOutput?: ContentBlock[]; llmStreamCall?: never; });\n 'compaction/end': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; error?: string; };\n 'compaction/prune': { shadowedRange: { start: number; end: number; }; shadowedSeqs: number[]; shadowedTokenCount: number; };\n}"
731
+ "declaration": "export interface SessionEventMap {\n 'turn/start': { turn: number; };\n 'turn/end': { turn: number; reason: TurnEndReason; };\n 'step/start': { turn: number; step: number; };\n 'step/end': { turn: number; step: number; };\n 'user/message': UserMessage;\n 'assistant/chunk': { turn: number; step: number; chunk: StreamChunk; };\n 'assistant/message': { turn: number; step: number; message: AssistantMessage; usage?: TokenUsage; interrupted?: true; };\n 'tool/call': { turn: number; step: number; callId: ToolCallId; name: string; arguments: string; };\n 'tool/result': { turn: number; step: number; message: ToolResultMessage; error?: { name: string; code: string; }; meta?: JsonValue; };\n 'request/header': { header: EpochHeader; reason: RequestHeaderReason; startsSeries?: true; };\n 'request/context': RequestContext;\n 'session/end-seed': Record<string, never>;\n 'agent/inbox/spliced': { target: InboxTarget; start: number; removedCount?: number; inserted: UserMessage[]; outcome?: 'canceled'; };\n 'approval/asked': { id: ApprovalRequestId; toolName: string; callId?: ToolCallId; reason?: string; };\n 'approval/decided': { id: ApprovalRequestId; outcome: ApprovalOutcome; };\n 'approval/policy': { policy: ApprovalPolicy; source?: 'delegation'; };\n 'tool/code-dispatch-start': PtcDispatchStartEventData;\n 'tool/code-dispatch': PtcDispatchEventData;\n 'agent-preset/selected': { agentPreset: string; };\n 'session/title': SessionTitleEventData;\n 'todo/write': { todos: TodoItem[]; };\n 'model/selection': ModelSelection;\n 'subagent/descriptor': SubagentDescriptorData;\n 'sandbox/mode': { mode: SandboxMode; source?: 'delegation'; };\n 'command/run': { commandId: CommandId; name: string; args?: string; source: CommandSource; };\n 'command/done': { commandId: CommandId; kind: 'success' | 'error'; text?: string; sourceEventSeq?: import('@deepseek-ai/dsh-session/types').SessionSeq; };\n 'team/member': { version: 1; teamId: TeamId; member: TeamMemberSnapshot; };\n 'team/task': { version: 1; teamId: TeamId; task: TeamTaskSnapshot; };\n 'team/message/queued': { version: 1; teamId: TeamId; message: TeamMessageSnapshot; };\n 'team/message/delivered': { version: 1; teamId: TeamId; messageId: TeamMessageId; targetId: SessionId; };\n 'goal/change': GoalChangeMeta;\n 'compaction/start': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; };\n 'compaction/summary': { compactionId: CompactionId; sourceCommandId?: CommandId; summary: ContentBlock[]; shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; provider: string; model: string; maxTokens?: number; usage?: TokenUsage; } & ({ rawOutput: ContentBlock[]; llmStreamCall: true; } | { rawOutput?: ContentBlock[]; llmStreamCall?: never; });\n 'compaction/end': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; error?: string; };\n 'compaction/prune': { shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; };\n}"
724
732
  },
725
733
  {
726
734
  "name": "SessionEventType",
@@ -728,27 +736,35 @@ export const TYPERT = {
728
736
  },
729
737
  {
730
738
  "name": "SessionHeader",
731
- "declaration": "export interface SessionHeader {\n readonly version: number;\n readonly id: SessionId;\n readonly createdAt: number;\n readonly cwd?: string;\n readonly parentSession?: SessionId;\n readonly seedLength?: number;\n readonly origin?: 'subagent';\n readonly delegationDepth?: number;\n readonly agentPreset?: string;\n}"
739
+ "declaration": "export interface SessionHeader {\n readonly version: number;\n readonly id: SessionId;\n readonly createdAt: number;\n readonly cwd?: string;\n readonly parentSession?: SessionId;\n readonly isSeeded: boolean;\n readonly origin?: 'subagent';\n readonly delegationDepth?: number;\n readonly agentPreset?: string;\n}"
732
740
  },
733
741
  {
734
742
  "name": "SessionId",
735
743
  "declaration": "export type SessionId = Branded<'SessionId'>;"
736
744
  },
745
+ {
746
+ "name": "SessionLogOffset",
747
+ "declaration": "export type SessionLogOffset = BrandedNumber<'SessionLogOffset'>;"
748
+ },
737
749
  {
738
750
  "name": "SessionReferenceSource",
739
- "declaration": "export interface SessionReferenceSource {\n kind: 'session-reference';\n form: 'recall';\n version: 1;\n references: { sessionId: string; label: string; capturedThroughSeq: number | null; compacted: boolean; originalMessages: number; retainedMessages: number; omittedMessages: number; omittedBytes: number; truncated: boolean; inputIndex: number; }[];\n}"
751
+ "declaration": "export interface SessionReferenceSource {\n kind: 'session-reference';\n form: 'recall';\n version: 1;\n references: { sessionId: string; label: string; capturedThroughSeq: OptionalSessionSeq; compacted: boolean; originalMessages: number; retainedMessages: number; omittedMessages: number; omittedBytes: number; truncated: boolean; inputIndex: number; }[];\n}"
740
752
  },
741
753
  {
742
754
  "name": "SessionRequestId",
743
755
  "declaration": "export type SessionRequestId = Branded<'session-request-id'>;"
744
756
  },
757
+ {
758
+ "name": "SessionSeq",
759
+ "declaration": "export type SessionSeq = BrandedNumber<'SessionSeq'>;"
760
+ },
745
761
  {
746
762
  "name": "SessionSurface",
747
- "declaration": "export interface SessionSurface {\n readonly nodes: readonly number[];\n readonly replaceGeneration: number;\n}"
763
+ "declaration": "export interface SessionSurface {\n readonly nodes: readonly SessionSeq[];\n readonly replaceGeneration: number;\n}"
748
764
  },
749
765
  {
750
766
  "name": "SessionTitleEventData",
751
- "declaration": "export interface SessionTitleEventData {\n readonly title: string;\n readonly messageSeqs: number[];\n readonly source: SessionTitleSource;\n}"
767
+ "declaration": "export interface SessionTitleEventData {\n readonly title: string;\n readonly messageSeqs: SessionSeq[];\n readonly source: SessionTitleSource;\n}"
752
768
  },
753
769
  {
754
770
  "name": "SessionTitleModelProvenance",
@@ -778,10 +794,6 @@ export const TYPERT = {
778
794
  "name": "SubagentDescriptorData",
779
795
  "declaration": "export type SubagentDescriptorData = OneShotSubagentDescriptorData | ContinuableSubagentDescriptorData;"
780
796
  },
781
- {
782
- "name": "SubagentReportMessageSource",
783
- "declaration": "export interface SubagentReportMessageSource {\n readonly kind: 'subagent-report';\n readonly form: 'relay';\n readonly senderSessionId: SessionId;\n}"
784
- },
785
797
  {
786
798
  "name": "SubagentSettledMessageSource",
787
799
  "declaration": "export interface SubagentSettledMessageSource {\n readonly kind: 'subagent-settled';\n readonly form: 'notice';\n readonly summary: string;\n readonly senderSessionId: SessionId;\n}"
@@ -792,11 +804,11 @@ export const TYPERT = {
792
804
  },
793
805
  {
794
806
  "name": "SurfaceIntent",
795
- "declaration": "export interface SurfaceIntent {\n surfaceOp: SurfaceOp;\n sourceEventSeqs?: number[];\n}"
807
+ "declaration": "export interface SurfaceIntent {\n surfaceOp: SurfaceOp;\n sourceEventSeqs?: SessionSeq[];\n}"
796
808
  },
797
809
  {
798
810
  "name": "SurfaceOp",
799
- "declaration": "export type SurfaceOp = 'append' | { op: 'replace'; start: number; end: number; };"
811
+ "declaration": "export type SurfaceOp = 'append' | { op: 'replace'; start: SessionSeq; end: SessionSeq; };"
800
812
  },
801
813
  {
802
814
  "name": "TeamId",
@@ -147,7 +147,7 @@ export const TYPERT_REMOTE = {
147
147
  typeSymbol: '@deepseek-ai/dsh-goal/client#GoalRef',
148
148
  schema: _deepseek_ai_dsh_goal_goals_clear_result$schema,
149
149
  },
150
- sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":426,"column":3},
150
+ sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":431,"column":3},
151
151
  },
152
152
  {
153
153
  id: '@deepseek-ai/dsh-goal#goals/complete',
@@ -187,7 +187,7 @@ export const TYPERT_REMOTE = {
187
187
  typeSymbol: '@deepseek-ai/dsh-goal/client#GoalView',
188
188
  schema: _deepseek_ai_dsh_goal_goals_complete_result$schema,
189
189
  },
190
- sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":384,"column":3},
190
+ sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":389,"column":3},
191
191
  },
192
192
  {
193
193
  id: '@deepseek-ai/dsh-goal#goals/create',
@@ -228,7 +228,7 @@ export const TYPERT_REMOTE = {
228
228
  typeSymbol: '@deepseek-ai/dsh-goal/client#CreateGoalResult',
229
229
  schema: _deepseek_ai_dsh_goal_goals_create_result$schema,
230
230
  },
231
- sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":618,"column":3},
231
+ sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":623,"column":3},
232
232
  },
233
233
  {
234
234
  id: '@deepseek-ai/dsh-goal#goals/edit',
@@ -278,7 +278,7 @@ export const TYPERT_REMOTE = {
278
278
  typeSymbol: '@deepseek-ai/dsh-goal/client#GoalView',
279
279
  schema: _deepseek_ai_dsh_goal_goals_edit_result$schema,
280
280
  },
281
- sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":322,"column":3},
281
+ sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":327,"column":3},
282
282
  },
283
283
  {
284
284
  id: '@deepseek-ai/dsh-goal#goals/pause',
@@ -318,7 +318,7 @@ export const TYPERT_REMOTE = {
318
318
  typeSymbol: '@deepseek-ai/dsh-goal/client#GoalView',
319
319
  schema: _deepseek_ai_dsh_goal_goals_pause_result$schema,
320
320
  },
321
- sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":345,"column":3},
321
+ sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":350,"column":3},
322
322
  },
323
323
  {
324
324
  id: '@deepseek-ai/dsh-goal#goals/resume',
@@ -358,7 +358,7 @@ export const TYPERT_REMOTE = {
358
358
  typeSymbol: '@deepseek-ai/dsh-goal/client#GoalView',
359
359
  schema: _deepseek_ai_dsh_goal_goals_resume_result$schema,
360
360
  },
361
- sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":357,"column":3},
361
+ sourceLocation: {"file":"packages/goal/goal/src/index.ts","line":362,"column":3},
362
362
  },
363
363
  ],
364
364
  }
@@ -41,6 +41,7 @@ import { randomUUID } from 'node:crypto';
41
41
  import z from '@deepseek-ai/schemastery';
42
42
  import { z as zod } from 'zod';
43
43
  import { agentEvents } from '@deepseek-ai/dsh-agent';
44
+ import { SessionSeq } from '@deepseek-ai/dsh-session';
44
45
  import { TypertRemoteService, Remote } from '@deepseek-ai/dsh-typert-protocol';
45
46
  import { applyGoalEvent, goalChangeRef, } from "./fold.js";
46
47
  import { GOAL_CHANGE_VERSION, GoalError, GoalId, } from "./runtime.js";
@@ -227,7 +228,8 @@ let GoalService = (() => {
227
228
  if (event.type !== 'goal/change')
228
229
  return;
229
230
  const runtime = this.runtimeState(session);
230
- runtime.activation = runtime.pendingActivation?.seq === event.seq
231
+ runtime.activation = runtime.pendingActivation !== undefined
232
+ && SessionSeq(runtime.pendingActivation.offset) === event.seq
231
233
  ? runtime.pendingActivation.activation
232
234
  : 'disarmed';
233
235
  });
@@ -475,11 +477,11 @@ let GoalService = (() => {
475
477
  /** Commit one mutation into the goal log and live event stream. */
476
478
  commit(agent, runtime, change, activation) {
477
479
  const ref = goalChangeRef(change);
478
- runtime.pendingActivation = { seq: agent.session.seq, activation };
480
+ runtime.pendingActivation = { offset: agent.session.seq, activation };
479
481
  try {
480
482
  const event = agent.session.append('goal/change', change);
481
483
  /* v8 ignore next -- Session.append returns the event committed at the pre-append seq. */
482
- if (runtime.pendingActivation.seq === event.seq)
484
+ if (SessionSeq(runtime.pendingActivation.offset) === event.seq)
483
485
  runtime.activation = activation;
484
486
  }
485
487
  finally {
@@ -33,7 +33,7 @@ const install = Object.assign((ctx, fail) => {
33
33
  const staged = new WeakMap();
34
34
  const seed = (session) => {
35
35
  const state = emptyGoalFoldState();
36
- for (const event of session.events)
36
+ for (const event of session.snapshotEvents())
37
37
  applyChecked(state, event, fail);
38
38
  states.set(session, state);
39
39
  return state;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-goal",
3
3
  "description": "Event-sourced same-session goal state and lifecycle service for the DeepSeek Harness",
4
- "version": "0.1.2-alpha.3",
4
+ "version": "0.1.2-alpha.5",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -53,14 +53,14 @@
53
53
  ],
54
54
  "license": "MIT",
55
55
  "peerDependencies": {
56
- "@deepseek-ai/dsh-agent": "^0.1.2-alpha.3",
57
- "@deepseek-ai/dsh-brand": "^0.1.2-alpha.3",
58
- "@deepseek-ai/dsh-invariants": "^0.1.2-alpha.3",
59
- "@deepseek-ai/dsh-session-projection": "^0.1.2-alpha.3",
60
- "@deepseek-ai/dsh-scope": "^0.1.2-alpha.3",
61
- "@deepseek-ai/dsh-session": "^0.1.2-alpha.3",
62
- "@deepseek-ai/dsh-llm": "^0.1.2-alpha.3",
63
- "@deepseek-ai/dsh-typert-protocol": "^0.1.2-alpha.3",
56
+ "@deepseek-ai/dsh-agent": "^0.1.2-alpha.5",
57
+ "@deepseek-ai/dsh-session-projection": "^0.1.2-alpha.5",
58
+ "@deepseek-ai/dsh-invariants": "^0.1.2-alpha.5",
59
+ "@deepseek-ai/dsh-brand": "^0.1.2-alpha.5",
60
+ "@deepseek-ai/dsh-llm": "^0.1.2-alpha.5",
61
+ "@deepseek-ai/dsh-scope": "^0.1.2-alpha.5",
62
+ "@deepseek-ai/dsh-session": "^0.1.2-alpha.5",
63
+ "@deepseek-ai/dsh-typert-protocol": "^0.1.2-alpha.5",
64
64
  "@deepseek-ai/cordis": "^4.0.2"
65
65
  },
66
66
  "dependencies": {
@@ -68,19 +68,19 @@
68
68
  "@deepseek-ai/schemastery": "^3.18.2"
69
69
  },
70
70
  "devDependencies": {
71
- "@deepseek-ai/dsh-agent": "^0.1.2-alpha.3",
72
- "@deepseek-ai/dsh-bash-local": "^0.1.2-alpha.3",
73
- "@deepseek-ai/dsh-session-projection": "^0.1.2-alpha.3",
74
- "@deepseek-ai/dsh-brand": "^0.1.2-alpha.3",
75
- "@deepseek-ai/dsh-invariants": "^0.1.2-alpha.3",
76
- "@deepseek-ai/dsh-session": "^0.1.2-alpha.3",
77
- "@deepseek-ai/dsh-session-checkpoint-policy": "^0.1.2-alpha.3",
78
- "@deepseek-ai/dsh-session-persistence-jsonl": "^0.1.2-alpha.3",
79
- "@deepseek-ai/dsh-subprocess-local": "^0.1.2-alpha.3",
80
- "@deepseek-ai/dsh-typert-protocol": "^0.1.2-alpha.3",
81
- "@deepseek-ai/cordis": "^4.0.2",
82
- "@deepseek-ai/dsh-llm": "^0.1.2-alpha.3",
83
- "@deepseek-ai/dsh-scope": "^0.1.2-alpha.3",
84
- "@deepseek-ai/dsh-loader-smoke": "^0.1.2-alpha.3"
71
+ "@deepseek-ai/dsh-agent": "^0.1.2-alpha.5",
72
+ "@deepseek-ai/dsh-bash-local": "^0.1.2-alpha.5",
73
+ "@deepseek-ai/dsh-session-projection": "^0.1.2-alpha.5",
74
+ "@deepseek-ai/dsh-brand": "^0.1.2-alpha.5",
75
+ "@deepseek-ai/dsh-invariants": "^0.1.2-alpha.5",
76
+ "@deepseek-ai/dsh-loader-smoke": "^0.1.2-alpha.5",
77
+ "@deepseek-ai/dsh-llm": "^0.1.2-alpha.5",
78
+ "@deepseek-ai/dsh-scope": "^0.1.2-alpha.5",
79
+ "@deepseek-ai/dsh-session": "^0.1.2-alpha.5",
80
+ "@deepseek-ai/dsh-session-checkpoint-policy": "^0.1.2-alpha.5",
81
+ "@deepseek-ai/dsh-session-persistence-jsonl": "^0.1.2-alpha.5",
82
+ "@deepseek-ai/dsh-subprocess-local": "^0.1.2-alpha.5",
83
+ "@deepseek-ai/dsh-typert-protocol": "^0.1.2-alpha.5",
84
+ "@deepseek-ai/cordis": "^4.0.2"
85
85
  }
86
86
  }