@clinebot/core 0.0.30 → 0.0.33

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.
Files changed (31) hide show
  1. package/dist/extensions/context/agentic-compaction.d.ts.map +1 -1
  2. package/dist/extensions/context/basic-compaction.d.ts.map +1 -1
  3. package/dist/extensions/context/compaction-shared.d.ts +1 -1
  4. package/dist/extensions/context/compaction-shared.d.ts.map +1 -1
  5. package/dist/extensions/context/compaction.d.ts.map +1 -1
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +213 -215
  9. package/dist/runtime/checkpoint-hooks.d.ts +10 -0
  10. package/dist/runtime/checkpoint-hooks.d.ts.map +1 -1
  11. package/dist/session/default-session-manager.d.ts.map +1 -1
  12. package/dist/session/session-agent-events.d.ts.map +1 -1
  13. package/dist/types/config.d.ts +61 -0
  14. package/dist/types/config.d.ts.map +1 -1
  15. package/dist/types/events.d.ts +4 -0
  16. package/dist/types/events.d.ts.map +1 -1
  17. package/package.json +4 -4
  18. package/src/extensions/context/agentic-compaction.ts +22 -10
  19. package/src/extensions/context/basic-compaction.ts +43 -18
  20. package/src/extensions/context/compaction-shared.ts +1 -1
  21. package/src/extensions/context/compaction.test.ts +16 -10
  22. package/src/extensions/context/compaction.ts +35 -12
  23. package/src/index.ts +2 -0
  24. package/src/providers/local-provider-service.test.ts +4 -4
  25. package/src/runtime/checkpoint-hooks.ts +26 -1
  26. package/src/session/default-session-manager.test.ts +7 -9
  27. package/src/session/default-session-manager.ts +2 -6
  28. package/src/session/persistence-service.test.ts +8 -17
  29. package/src/session/session-agent-events.ts +9 -1
  30. package/src/types/config.ts +69 -0
  31. package/src/types/events.ts +4 -0
@@ -95,6 +95,74 @@ export interface CoreCompactionConfig {
95
95
  | undefined;
96
96
  }
97
97
 
98
+ /**
99
+ * Context passed to a custom `createCheckpoint` implementation.
100
+ */
101
+ export interface CoreCheckpointContext {
102
+ /** Absolute path to the working directory of the session. */
103
+ cwd: string;
104
+ /** The session identifier. */
105
+ sessionId: string;
106
+ /** Monotonically increasing run counter for this session (starts at 1). */
107
+ runCount: number;
108
+ }
109
+
110
+ /**
111
+ * Configuration for the built-in git-based checkpoint feature.
112
+ *
113
+ * Checkpoints capture a restorable snapshot of the workspace at the start of
114
+ * each root-agent run so that changes made during a session can be rolled back.
115
+ *
116
+ * @example Disable checkpoints entirely:
117
+ * ```ts
118
+ * checkpoint: { enabled: false }
119
+ * ```
120
+ *
121
+ * @example Bring your own checkpoint implementation:
122
+ * ```ts
123
+ * checkpoint: {
124
+ * createCheckpoint: async ({ cwd, sessionId, runCount }) => {
125
+ * const ref = await mySnapshotFn(cwd);
126
+ * return { ref, createdAt: Date.now(), runCount };
127
+ * },
128
+ * }
129
+ * ```
130
+ */
131
+ export interface CoreCheckpointConfig {
132
+ /**
133
+ * Whether to create checkpoints on each root-agent run start.
134
+ * Defaults to `false` — checkpoints are **opt-in**. Set to `true` to
135
+ * enable the built-in git stash/ref checkpoint behaviour for this session.
136
+ */
137
+ enabled?: boolean;
138
+ /**
139
+ * Replace the built-in git stash/ref checkpoint logic with a custom
140
+ * implementation. Called once at the start of each root-agent run (before
141
+ * the first agent iteration).
142
+ *
143
+ * Return an object with at least `ref`, `createdAt`, and `runCount` to have
144
+ * the entry recorded in session metadata, or return `undefined` to skip
145
+ * writing a checkpoint for that run.
146
+ */
147
+ createCheckpoint?: (context: CoreCheckpointContext) =>
148
+ | Promise<
149
+ | {
150
+ ref: string;
151
+ createdAt: number;
152
+ runCount: number;
153
+ kind?: "stash" | "commit";
154
+ }
155
+ | undefined
156
+ >
157
+ | {
158
+ ref: string;
159
+ createdAt: number;
160
+ runCount: number;
161
+ kind?: "stash" | "commit";
162
+ }
163
+ | undefined;
164
+ }
165
+
98
166
  export interface CoreSessionConfig
99
167
  extends CoreModelConfig,
100
168
  CoreRuntimeFeatures,
@@ -124,6 +192,7 @@ export interface CoreSessionConfig
124
192
  extensions?: AgentConfig["extensions"];
125
193
  execution?: AgentConfig["execution"];
126
194
  compaction?: CoreCompactionConfig;
195
+ checkpoint?: CoreCheckpointConfig;
127
196
  onTeamEvent?: (event: TeamEvent) => void;
128
197
  onConsecutiveMistakeLimitReached?: (
129
198
  context: ConsecutiveMistakeLimitContext,
@@ -61,6 +61,10 @@ export type CoreSessionEvent =
61
61
  payload: {
62
62
  sessionId: string;
63
63
  event: import("@clinebot/shared").AgentEvent;
64
+ /** Identifies the named agent within the team (e.g. "educator", "assessor", "coordinator") for both lead and teammate agents */
65
+ teamAgentId?: string;
66
+ /** Whether this is the lead agent or a teammate */
67
+ teamRole?: "lead" | "teammate";
64
68
  };
65
69
  }
66
70
  | { type: "team_progress"; payload: SessionTeamProgressEvent }