@gajae-code/agent-core 0.10.0 → 0.10.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.
@@ -298,6 +298,7 @@ export declare class Agent {
298
298
  get streamMaxRetries(): number | undefined;
299
299
  set streamMaxRetries(value: number | undefined);
300
300
  get state(): AgentState;
301
+ get contextRevision(): number;
301
302
  get appendOnlyContext(): AppendOnlyContextManager | undefined;
302
303
  setAppendOnlyContext(manager?: AppendOnlyContextManager): void;
303
304
  subscribe(fn: (e: AgentEvent) => void): () => void;
@@ -321,6 +322,11 @@ export declare class Agent {
321
322
  replaceMessages(ms: AgentMessage[]): void;
322
323
  appendMessage(m: AgentMessage): void;
323
324
  popMessage(): AgentMessage | undefined;
325
+ /**
326
+ * For callers that mutate committed messages or the system prompt in place
327
+ * outside Agent-owned mutators.
328
+ */
329
+ touchContext(): void;
324
330
  /**
325
331
  * Queue a steering message to interrupt the agent mid-run.
326
332
  * Delivered after current tool execution, skips remaining tools.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@gajae-code/agent-core",
4
- "version": "0.10.0",
4
+ "version": "0.10.1",
5
5
  "description": "General-purpose agent with transport abstraction, state management, and attachment support",
6
6
  "homepage": "https://gajae-code.com",
7
7
  "author": "Yeachan-Heo and Gajae Code Contributors",
@@ -32,9 +32,9 @@
32
32
  "fmt": "biome format --write ."
33
33
  },
34
34
  "dependencies": {
35
- "@gajae-code/ai": "0.10.0",
36
- "@gajae-code/natives": "0.10.0",
37
- "@gajae-code/utils": "0.10.0",
35
+ "@gajae-code/ai": "0.10.1",
36
+ "@gajae-code/natives": "0.10.1",
37
+ "@gajae-code/utils": "0.10.1",
38
38
  "@opentelemetry/api": "^1.9.0"
39
39
  },
40
40
  "devDependencies": {
package/src/agent.ts CHANGED
@@ -296,6 +296,7 @@ export class Agent {
296
296
  pendingToolCalls: new Set<string>(),
297
297
  error: undefined,
298
298
  };
299
+ #contextRevision = 0;
299
300
 
300
301
  #listeners = new Set<(e: AgentEvent) => void>();
301
302
  #abortController?: AbortController;
@@ -640,6 +641,10 @@ export class Agent {
640
641
  return this.#state;
641
642
  }
642
643
 
644
+ get contextRevision(): number {
645
+ return this.#contextRevision;
646
+ }
647
+
643
648
  get appendOnlyContext(): AppendOnlyContextManager | undefined {
644
649
  return this.#appendOnlyContext;
645
650
  }
@@ -822,10 +827,12 @@ export class Agent {
822
827
  // State mutators
823
828
  setSystemPrompt(v: string[]) {
824
829
  this.#state.systemPrompt = v;
830
+ this.#contextRevision++;
825
831
  }
826
832
 
827
833
  setModel(m: Model) {
828
834
  this.#state.model = m;
835
+ this.#contextRevision++;
829
836
  }
830
837
 
831
838
  setThinkingLevel(l: Effort | undefined) {
@@ -858,10 +865,12 @@ export class Agent {
858
865
 
859
866
  setTools(t: AgentTool<any>[]) {
860
867
  this.#state.tools = t;
868
+ this.#contextRevision++;
861
869
  }
862
870
 
863
871
  replaceMessages(ms: AgentMessage[]) {
864
872
  this.#state.messages = ms.slice();
873
+ this.#contextRevision++;
865
874
  }
866
875
 
867
876
  appendMessage(m: AgentMessage) {
@@ -869,12 +878,14 @@ export class Agent {
869
878
  // N is O(N+M), not O(M*N). Consumers read state.messages fresh; run() snapshots
870
879
  // via slice() at the API boundary, so no caller relies on per-append array identity.
871
880
  this.#state.messages.push(m);
881
+ this.#contextRevision++;
872
882
  }
873
883
 
874
884
  popMessage(): AgentMessage | undefined {
875
885
  const messages = this.#state.messages.slice(0, -1);
876
886
  const removed = this.#state.messages.at(-1);
877
887
  this.#state.messages = messages;
888
+ this.#contextRevision++;
878
889
 
879
890
  if (removed && this.#state.streamMessage === removed) {
880
891
  this.#state.streamMessage = null;
@@ -883,6 +894,14 @@ export class Agent {
883
894
  return removed;
884
895
  }
885
896
 
897
+ /**
898
+ * For callers that mutate committed messages or the system prompt in place
899
+ * outside Agent-owned mutators.
900
+ */
901
+ touchContext(): void {
902
+ this.#contextRevision++;
903
+ }
904
+
886
905
  /**
887
906
  * Queue a steering message to interrupt the agent mid-run.
888
907
  * Delivered after current tool execution, skips remaining tools.
@@ -1056,6 +1075,7 @@ export class Agent {
1056
1075
 
1057
1076
  clearMessages() {
1058
1077
  this.#state.messages = [];
1078
+ this.#contextRevision++;
1059
1079
  }
1060
1080
 
1061
1081
  abort() {
@@ -1094,6 +1114,7 @@ export class Agent {
1094
1114
 
1095
1115
  reset() {
1096
1116
  this.#state.messages = [];
1117
+ this.#contextRevision++;
1097
1118
  this.#state.isStreaming = false;
1098
1119
  this.#state.streamMessage = null;
1099
1120
  this.#state.pendingToolCalls = new Set<string>();