@gajae-code/coding-agent 0.11.11 → 0.12.0

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 (182) hide show
  1. package/CHANGELOG.md +49 -3
  2. package/dist/types/cli/read-cli.d.ts +1 -0
  3. package/dist/types/commands/deep-interview.d.ts +9 -0
  4. package/dist/types/commands/harness.d.ts +22 -0
  5. package/dist/types/commands/read.d.ts +6 -0
  6. package/dist/types/config/model-registry.d.ts +4 -0
  7. package/dist/types/config/provider-auth-health.d.ts +14 -0
  8. package/dist/types/config/provider-ranking.d.ts +59 -0
  9. package/dist/types/config/settings-schema.d.ts +29 -1
  10. package/dist/types/config/settings.d.ts +2 -0
  11. package/dist/types/extensibility/extensions/types.d.ts +22 -2
  12. package/dist/types/extensibility/shared-events.d.ts +6 -0
  13. package/dist/types/gjc-runtime/deep-interview-ambiguity.d.ts +5 -12
  14. package/dist/types/gjc-runtime/deep-interview-recorder.d.ts +17 -32
  15. package/dist/types/gjc-runtime/deep-interview-stage.d.ts +37 -0
  16. package/dist/types/gjc-runtime/deep-interview-state.d.ts +4 -135
  17. package/dist/types/gjc-runtime/gc-runtime.d.ts +1 -1
  18. package/dist/types/gjc-runtime/memory-guard-owner-claims.d.ts +47 -0
  19. package/dist/types/gjc-runtime/ralplan-runtime.d.ts +52 -1
  20. package/dist/types/gjc-runtime/state-writer.d.ts +5 -46
  21. package/dist/types/gjc-runtime/team-launch.d.ts +1 -1
  22. package/dist/types/gjc-runtime/team-runtime.d.ts +2 -1
  23. package/dist/types/gjc-runtime/team-store.d.ts +12 -0
  24. package/dist/types/gjc-runtime/team-worker-memory-guard.d.ts +92 -0
  25. package/dist/types/gjc-runtime/tmux-owner-isolation.d.ts +7 -0
  26. package/dist/types/gjc-runtime/ultragoal-receipt-freshness.d.ts +8 -0
  27. package/dist/types/gjc-runtime/workflow-manifest.d.ts +3 -5
  28. package/dist/types/internal-urls/local-root-gc.d.ts +2 -0
  29. package/dist/types/main.d.ts +1 -1
  30. package/dist/types/memories/index.d.ts +2 -0
  31. package/dist/types/modes/acp/acp-agent.d.ts +8 -0
  32. package/dist/types/modes/components/assistant-message.d.ts +3 -1
  33. package/dist/types/modes/components/irc-sidebar.d.ts +41 -0
  34. package/dist/types/modes/components/read-tool-group.d.ts +4 -4
  35. package/dist/types/modes/components/session-observer-overlay.d.ts +4 -0
  36. package/dist/types/modes/components/settings-selector.d.ts +2 -0
  37. package/dist/types/modes/components/tool-execution.d.ts +8 -0
  38. package/dist/types/modes/controllers/event-controller.d.ts +3 -0
  39. package/dist/types/modes/interactive-mode.d.ts +2 -0
  40. package/dist/types/modes/irc-observation-ledger.d.ts +17 -1
  41. package/dist/types/modes/types.d.ts +2 -0
  42. package/dist/types/modes/utils/ui-helpers.d.ts +16 -0
  43. package/dist/types/runtime-mcp/smithery-auth.d.ts +5 -0
  44. package/dist/types/sdk/broker/lifecycle.d.ts +5 -0
  45. package/dist/types/sdk/bus/control-drain-lease.d.ts +52 -0
  46. package/dist/types/sdk/bus/index.d.ts +15 -1
  47. package/dist/types/sdk/bus/kind-aware-reconciliation.d.ts +37 -0
  48. package/dist/types/sdk/bus/prompt-reconciliation.d.ts +2 -1
  49. package/dist/types/sdk/bus/reconciliation-store.d.ts +65 -0
  50. package/dist/types/sdk/host/control/operations.d.ts +1 -1
  51. package/dist/types/sdk/host/host.d.ts +2 -0
  52. package/dist/types/sdk/host/query/handlers.d.ts +5 -0
  53. package/dist/types/session/agent-session.d.ts +44 -10
  54. package/dist/types/session/memory-guard-checkpoint-participant.d.ts +69 -0
  55. package/dist/types/session/session-manager.d.ts +25 -13
  56. package/dist/types/session/streaming-output.d.ts +60 -5
  57. package/dist/types/skill-state/active-state.d.ts +0 -4
  58. package/dist/types/skill-state/workflow-hud.d.ts +3 -0
  59. package/dist/types/tools/browser/launch.d.ts +7 -0
  60. package/dist/types/tools/fetch.d.ts +17 -1
  61. package/dist/types/tools/output-meta.d.ts +21 -1
  62. package/dist/types/tools/read-internals.d.ts +12 -0
  63. package/dist/types/tools/read.d.ts +45 -1
  64. package/dist/types/tools/resource-gc.d.ts +4 -0
  65. package/dist/types/tools/tool-result.d.ts +7 -1
  66. package/package.json +9 -13
  67. package/scripts/benchmark-sticky-viewport-pr1.ts +239 -0
  68. package/scripts/capture-sticky-viewport-showcase.ts +292 -0
  69. package/scripts/generate-sdk-operation-inventory.ts +2 -0
  70. package/scripts/verify-gjc-sdk-canonicalization.ts +122 -18
  71. package/scripts/verify-sticky-viewport-showcase.ts +611 -0
  72. package/src/capability/index.ts +8 -0
  73. package/src/cli/read-cli.ts +2 -1
  74. package/src/cli.ts +1 -0
  75. package/src/commands/deep-interview.ts +29 -9
  76. package/src/commands/harness.ts +35 -12
  77. package/src/commands/read.ts +11 -2
  78. package/src/commands/team.ts +1 -1
  79. package/src/config/model-registry.ts +21 -2
  80. package/src/config/provider-auth-health.ts +42 -0
  81. package/src/config/provider-ranking.ts +119 -0
  82. package/src/config/settings-schema.ts +23 -1
  83. package/src/config/settings.ts +246 -108
  84. package/src/defaults/gjc/skills/deep-interview/SKILL.md +229 -82
  85. package/src/defaults/gjc/skills/ralplan/SKILL.md +58 -25
  86. package/src/defaults/gjc/skills/team/SKILL.md +1 -1
  87. package/src/defaults/gjc/skills/ultragoal/SKILL.md +25 -15
  88. package/src/eval/py/executor.ts +7 -2
  89. package/src/extensibility/extensions/types.ts +28 -4
  90. package/src/extensibility/shared-events.ts +5 -0
  91. package/src/gjc-runtime/deep-interview-ambiguity.ts +47 -82
  92. package/src/gjc-runtime/deep-interview-recorder.ts +227 -310
  93. package/src/gjc-runtime/deep-interview-runtime.ts +109 -270
  94. package/src/gjc-runtime/deep-interview-stage.ts +1016 -0
  95. package/src/gjc-runtime/deep-interview-state.ts +12 -943
  96. package/src/gjc-runtime/gc-render.ts +1 -0
  97. package/src/gjc-runtime/gc-runtime.ts +11 -1
  98. package/src/gjc-runtime/memory-guard-owner-claims.ts +389 -0
  99. package/src/gjc-runtime/ralplan-runtime.ts +742 -85
  100. package/src/gjc-runtime/state-runtime.ts +2 -1
  101. package/src/gjc-runtime/state-writer.ts +70 -222
  102. package/src/gjc-runtime/team-launch.ts +34 -5
  103. package/src/gjc-runtime/team-runtime.ts +970 -33
  104. package/src/gjc-runtime/team-store.ts +32 -0
  105. package/src/gjc-runtime/team-worker-memory-guard.ts +363 -0
  106. package/src/gjc-runtime/team-workers.ts +1 -0
  107. package/src/gjc-runtime/tmux-owner-isolation.ts +18 -0
  108. package/src/gjc-runtime/ultragoal-receipt-freshness.ts +20 -0
  109. package/src/gjc-runtime/ultragoal-runtime.ts +13 -7
  110. package/src/gjc-runtime/workflow-manifest.generated.json +97 -350
  111. package/src/gjc-runtime/workflow-manifest.ts +34 -179
  112. package/src/hooks/native-skill-hook.ts +17 -4
  113. package/src/hooks/skill-state.ts +1 -23
  114. package/src/internal-urls/docs-index.generated.ts +8 -9
  115. package/src/internal-urls/local-root-gc.ts +127 -0
  116. package/src/main.ts +9 -5
  117. package/src/memories/index.ts +10 -0
  118. package/src/modes/DESIGN.md +47 -0
  119. package/src/modes/acp/acp-agent.ts +43 -7
  120. package/src/modes/acp/acp-event-mapper.ts +14 -7
  121. package/src/modes/acp/acp-mode.ts +39 -3
  122. package/src/modes/components/assistant-message.ts +123 -22
  123. package/src/modes/components/irc-sidebar.ts +176 -62
  124. package/src/modes/components/model-selector.ts +61 -4
  125. package/src/modes/components/oauth-selector.ts +42 -12
  126. package/src/modes/components/read-tool-group.ts +82 -14
  127. package/src/modes/components/session-observer-overlay.ts +187 -32
  128. package/src/modes/components/settings-selector.ts +60 -18
  129. package/src/modes/components/tool-execution.ts +138 -27
  130. package/src/modes/controllers/event-controller.ts +109 -27
  131. package/src/modes/controllers/extension-ui-controller.ts +19 -2
  132. package/src/modes/controllers/input-controller.ts +18 -3
  133. package/src/modes/controllers/selector-controller.ts +83 -37
  134. package/src/modes/interactive-mode.ts +62 -3
  135. package/src/modes/irc-observation-ledger.ts +71 -15
  136. package/src/modes/runtime-init.ts +19 -2
  137. package/src/modes/types.ts +2 -0
  138. package/src/modes/utils/ui-helpers.ts +94 -1
  139. package/src/prompts/agents/architect.md +9 -1
  140. package/src/prompts/agents/critic.md +9 -0
  141. package/src/prompts/system/system-prompt.md +0 -1
  142. package/src/prompts/tools/read.md +4 -2
  143. package/src/runtime-mcp/smithery-auth.ts +17 -2
  144. package/src/runtime-mcp/smithery-connect.ts +11 -1
  145. package/src/sdk/broker/lifecycle.ts +25 -6
  146. package/src/sdk/bus/control-drain-lease.ts +104 -0
  147. package/src/sdk/bus/index.ts +341 -38
  148. package/src/sdk/bus/kind-aware-reconciliation.ts +242 -0
  149. package/src/sdk/bus/prompt-reconciliation.ts +2 -1
  150. package/src/sdk/bus/reconciliation-store.ts +224 -0
  151. package/src/sdk/host/control/dispatch.ts +5 -1
  152. package/src/sdk/host/control/operations.ts +1 -1
  153. package/src/sdk/host/host.ts +23 -1
  154. package/src/sdk/host/query/handlers.ts +55 -0
  155. package/src/sdk/mcp/server.ts +46 -18
  156. package/src/sdk/protocol/operation-inventory.generated.json +29 -0
  157. package/src/sdk/protocol/operation-registry.ts +7 -2
  158. package/src/sdk/session.ts +13 -1
  159. package/src/session/agent-session.ts +466 -50
  160. package/src/session/memory-guard-checkpoint-participant.ts +131 -0
  161. package/src/session/session-manager.ts +764 -17
  162. package/src/session/streaming-output.ts +262 -43
  163. package/src/setup/provider-onboarding.ts +19 -4
  164. package/src/skill-state/active-state.ts +0 -10
  165. package/src/skill-state/workflow-hud.ts +25 -2
  166. package/src/skill-state/workflow-mutation-guard.ts +65 -7
  167. package/src/tools/ask.ts +89 -69
  168. package/src/tools/browser/launch.ts +41 -6
  169. package/src/tools/fetch.ts +114 -23
  170. package/src/tools/output-meta.ts +176 -9
  171. package/src/tools/path-utils.ts +5 -1
  172. package/src/tools/read-internals.ts +44 -0
  173. package/src/tools/read.ts +1542 -310
  174. package/src/tools/resource-gc.ts +182 -18
  175. package/src/tools/tool-result.ts +14 -1
  176. package/src/web/search/providers/codex.ts +1 -1
  177. package/dist/types/gjc-runtime/deep-interview-draft.d.ts +0 -8
  178. package/dist/types/gjc-runtime/deep-interview-payload.d.ts +0 -41
  179. package/dist/types/gjc-runtime/deep-interview-repair.d.ts +0 -17
  180. package/src/gjc-runtime/deep-interview-draft.ts +0 -843
  181. package/src/gjc-runtime/deep-interview-payload.ts +0 -262
  182. package/src/gjc-runtime/deep-interview-repair.ts +0 -1674
@@ -0,0 +1,69 @@
1
+ import type { RecoveryFsRoot } from "@gajae-code/natives";
2
+ import type { RecoveryHydrationContext, ResumeSessionIdentity, SessionDestinationInput, SessionManager, SessionManagerCheckpointRevisionStrings, StrictSessionOpenFailure } from "./session-manager";
3
+ export interface MemoryGuardTranscriptDescriptorV1 {
4
+ bytes: string;
5
+ relative_path: string;
6
+ sha256: string;
7
+ }
8
+ export interface MemoryGuardCheckpointBlobAuthorityV1 {
9
+ kind: "checkpoint_blob_tree_v1";
10
+ manifest_relative_path: string;
11
+ manifest_sha256: string;
12
+ root_relative_path: string;
13
+ }
14
+ export interface MemoryGuardCheckpointBlobManifestEntryV1 {
15
+ bytes: string;
16
+ relative_path: string;
17
+ sha256: string;
18
+ }
19
+ export interface MemoryGuardCheckpointBlobManifestV1 {
20
+ entries: MemoryGuardCheckpointBlobManifestEntryV1[];
21
+ schema_version: 1;
22
+ }
23
+ export interface MemoryGuardSessionManagerCheckpointV1 {
24
+ blob_authority: MemoryGuardCheckpointBlobAuthorityV1;
25
+ revisions: SessionManagerCheckpointRevisionStrings;
26
+ schema_version: 1;
27
+ session_id: string;
28
+ session_name: string | null;
29
+ transcript: MemoryGuardTranscriptDescriptorV1;
30
+ }
31
+ export interface MemoryGuardParticipantDescriptorV1 {
32
+ ordinal: number;
33
+ checkpoint: MemoryGuardCheckpointBlobAuthorityV1;
34
+ revisions: SessionManagerCheckpointRevisionStrings;
35
+ session_id: string;
36
+ session_name: string | null;
37
+ transcript: MemoryGuardTranscriptDescriptorV1;
38
+ }
39
+ export interface MemoryGuardParticipantIngressLease {
40
+ readonly token: symbol;
41
+ release(): void;
42
+ }
43
+ export interface MemoryGuardCreateCheckpointInput {
44
+ ingressLease: MemoryGuardParticipantIngressLease;
45
+ checkpointRoot: string;
46
+ }
47
+ export type MemoryGuardRestoreBlockedReason = StrictSessionOpenFailure["reason"] | "checkpoint-mismatch" | "participant-mismatch" | "transcript-mismatch" | "blob-manifest-mismatch" | "blob-missing" | "blob-hash-mismatch" | "blob-authority-mismatch" | "destination-unavailable";
48
+ export interface MemoryGuardRestoreInput {
49
+ incidentAuthority: RecoveryFsRoot;
50
+ participant: MemoryGuardParticipantDescriptorV1;
51
+ checkpoint: MemoryGuardSessionManagerCheckpointV1;
52
+ destination: SessionDestinationInput;
53
+ }
54
+ export type MemoryGuardRestoreResult = {
55
+ kind: "staged";
56
+ manager: SessionManager;
57
+ hydrationContext: RecoveryHydrationContext;
58
+ transcriptIdentity: ResumeSessionIdentity;
59
+ cleanup: () => Promise<void>;
60
+ } | {
61
+ kind: "blocked";
62
+ reason: MemoryGuardRestoreBlockedReason;
63
+ };
64
+ export declare function memoryGuardCanonicalJson(value: unknown): string;
65
+ export declare function memoryGuardSha256Hex(value: Uint8Array | string): string;
66
+ export declare function isMemoryGuardDecimalString(value: unknown): value is string;
67
+ export declare function isMemoryGuardSha256Hex(value: unknown): value is string;
68
+ export declare function isMemoryGuardRelativePath(value: unknown): value is string;
69
+ export declare function hasOnlyKeys(value: Record<string, unknown>, allowed: readonly string[]): boolean;
@@ -8,6 +8,7 @@ import { ArtifactManager } from "./artifacts";
8
8
  import { type BlobPutResult, BlobStore } from "./blob-store";
9
9
  import { type ManagedMigrationPolicy } from "./internal/managed-session-scope";
10
10
  import { type ManagedDirectoryRoot, ManagedSessionDescendantStore } from "./internal/managed-session-storage";
11
+ import { type MemoryGuardCreateCheckpointInput, type MemoryGuardParticipantIngressLease, type MemoryGuardRestoreInput, type MemoryGuardRestoreResult, type MemoryGuardSessionManagerCheckpointV1 } from "./memory-guard-checkpoint-participant";
11
12
  import { type BashExecutionMessage, type CustomMessage, type FileMentionMessage, type HookMessage, type PythonExecutionMessage } from "./messages";
12
13
  import { type SessionManagerReadAccess, sessionManagerReadCapability } from "./session-manager-internal";
13
14
  import type { ManagedSessionSecurityContext, SessionStorage, SessionStorageStat, VerifiedSessionDeleteResult, VerifiedSessionDeleteTarget } from "./session-storage";
@@ -259,6 +260,21 @@ export type DefaultModelSelectionStage = {
259
260
  readonly tempPath: string | undefined;
260
261
  readonly persistsToExistingFile: boolean;
261
262
  };
263
+ export interface SessionManagerRevisionSnapshot {
264
+ entry: number;
265
+ leaf: number;
266
+ headerExport: number;
267
+ label: number;
268
+ replayMetadata: number;
269
+ }
270
+ export interface SessionManagerCheckpointRevisionStrings {
271
+ entry: string;
272
+ leaf: string;
273
+ headerExport: string;
274
+ label: string;
275
+ replayMetadata: string;
276
+ }
277
+ export declare function toSessionManagerCheckpointRevisionStrings(snapshot: SessionManagerRevisionSnapshot): SessionManagerCheckpointRevisionStrings;
262
278
  export type DefaultModelSelectionPromotion = {
263
279
  readonly kind: "promoted";
264
280
  } | {
@@ -541,6 +557,10 @@ export declare function residentBlobSentinelForTests(kind: ResidentBlobKind, ref
541
557
  export declare function materializeResidentEntriesForPersistenceForTests<T>(entries: T[], textStore: BlobStore, imageStore?: BlobStore): T[];
542
558
  /** Get recent sessions for display in welcome screen */
543
559
  export declare function getRecentSessions(sessionDir: string, limit?: number, storage?: SessionStorage): Promise<RecentSessionInfo[]>;
560
+ export declare function getRecentSessionDisplay(sessions: readonly SessionInfo[], limit?: number): Array<{
561
+ name: string;
562
+ timeAgo: string;
563
+ }>;
544
564
  /**
545
565
  * Manages conversation sessions as append-only trees stored in JSONL files.
546
566
  *
@@ -589,13 +609,7 @@ export declare class SessionManager {
589
609
  * revision contract). Tests assert the invalidation mapping through this;
590
610
  * future export/label-view caches key off their respective domains.
591
611
  */
592
- revisionSnapshot(): {
593
- entry: number;
594
- leaf: number;
595
- headerExport: number;
596
- label: number;
597
- replayMetadata: number;
598
- };
612
+ revisionSnapshot(): SessionManagerRevisionSnapshot;
599
613
  /** Puts a binary blob into the blob store and returns the blob reference */
600
614
  putBlob(data: Buffer): Promise<BlobPutResult>;
601
615
  captureState(): SessionManagerStateSnapshot;
@@ -691,6 +705,8 @@ export declare class SessionManager {
691
705
  listForResumePickerReadOnly(): Promise<SessionInfo[]>;
692
706
  getSessionId(): string;
693
707
  getSessionFile(): string | undefined;
708
+ acquireMemoryGuardParticipantIngressLease(): MemoryGuardParticipantIngressLease;
709
+ createMemoryGuardCheckpoint(input: MemoryGuardCreateCheckpointInput): Promise<MemoryGuardSessionManagerCheckpointV1>;
694
710
  /**
695
711
  * Returns the session artifacts directory path (session file path without .jsonl).
696
712
  * Returns null when the session is not persisted to a file.
@@ -747,11 +763,6 @@ export declare class SessionManager {
747
763
  /** The source that set the session name: "user" (manual /rename or RPC) or "auto" (generated title). */
748
764
  get titleSource(): "auto" | "user" | undefined;
749
765
  getSessionName(): string | undefined;
750
- /**
751
- * Set the session display name.
752
- * @param source - "user" for explicit renames (/rename command, RPC); "auto" for generated titles.
753
- * Auto-generated titles are silently ignored when the user has already set a name.
754
- */
755
766
  setSessionName(name: string, source?: "auto" | "user"): Promise<boolean>;
756
767
  _persist(entry: SessionEntry): void;
757
768
  /** Append a configured fallback chain as child of current leaf, then advance leaf. Returns entry id. */
@@ -971,7 +982,7 @@ export declare class SessionManager {
971
982
  * legacy sibling directories.
972
983
  */
973
984
  static listForResumePickerReadOnly(cwd: string, sessionDir?: string, storage?: SessionStorage): Promise<SessionInfo[]>;
974
- /** Tombstone and exact-delete a default-managed candidate. */
985
+ /** Delete an authorized managed or project-local picker candidate. */
975
986
  static deleteManagedCandidate(sessionPath: string): Promise<void>;
976
987
  /** Capture exact source content for a strict fork without granting write ownership. */
977
988
  static captureTranscriptStrict(filePath: string, storage?: SessionStorage): StrictSessionCaptureResult;
@@ -981,6 +992,7 @@ export declare class SessionManager {
981
992
  * persistence; destination history always comes from the captured bytes.
982
993
  */
983
994
  static forkFromCaptured(snapshot: CapturedSessionTranscriptSnapshot, cwd: string, destinationInput?: SessionDestinationInput, _migrationPolicy?: SessionDirectoryMigrationPolicy): Promise<StrictSessionForkResult>;
995
+ static restoreMemoryGuardCheckpoint(input: MemoryGuardRestoreInput): Promise<MemoryGuardRestoreResult>;
984
996
  /** Inspect a selected session without acquiring write-capable ownership. */
985
997
  static inspectSessionTailReadOnly(filePath: string, storage?: SessionStorage): Promise<ResumeTailInspection>;
986
998
  /**
@@ -83,7 +83,10 @@ export interface TruncationResult {
83
83
  elidedLines?: number;
84
84
  lastLinePartial?: boolean;
85
85
  firstLineExceedsLimit?: boolean;
86
+ lastLineExceedsLimit?: boolean;
86
87
  }
88
+ /** Direction vocabulary used by callers that select which end of content to retain. */
89
+ export type TruncationDirection = "head" | "last" | "both";
87
90
  export interface TruncationOptions {
88
91
  /** Maximum number of lines (default: 3000) */
89
92
  maxLines?: number;
@@ -99,6 +102,8 @@ export interface TruncationOptions {
99
102
  * window receives `maxLines - maxHeadLines`. Default `floor(maxLines/2)`.
100
103
  */
101
104
  maxHeadLines?: number;
105
+ /** Direction to dispatch through truncateContent (head, last, or both). */
106
+ direction?: TruncationDirection;
102
107
  }
103
108
  /** Result from byte-level truncation helpers. */
104
109
  export interface ByteTruncationResult {
@@ -155,14 +160,64 @@ export declare function truncateTail(content: string, options?: TruncationOption
155
160
  */
156
161
  export declare function formatMiddleElisionMarker(elidedLines: number, elidedBytes: number): string;
157
162
  /**
158
- * Truncate content keeping a head window and a tail window, eliding the middle.
163
+ * A retained source segment returned by {@link truncateMiddleWindows}.
164
+ * Line coordinates are 1-indexed and inclusive.
165
+ */
166
+ export type ReadSegment = {
167
+ kind: "lines";
168
+ content: string;
169
+ lines: number;
170
+ bytes: number;
171
+ origin: {
172
+ startLine: number;
173
+ endLine: number;
174
+ };
175
+ lastLinePartial: false;
176
+ } | {
177
+ kind: "partial-line";
178
+ content: string;
179
+ lines: 1;
180
+ bytes: number;
181
+ origin: {
182
+ startLine: number;
183
+ endLine: number;
184
+ };
185
+ sourceLineBytes: number;
186
+ lastLinePartial: true;
187
+ };
188
+ /** The actual windows retained by middle truncation. */
189
+ export interface ReadWindow {
190
+ kind: "full" | "head-only" | "tail-only" | "middle";
191
+ head?: ReadSegment;
192
+ tail?: ReadSegment;
193
+ overlap: "disjoint" | "adjacent" | "overlapping";
194
+ elidedLines: number;
195
+ elidedBytes: number;
196
+ totalLines: number;
197
+ totalBytes: number;
198
+ /** @deprecated Non-enumerable compatibility reason for older consumers. */
199
+ truncatedBy?: "lines" | "bytes" | "middle";
200
+ }
201
+ /**
202
+ * Truncate content while exposing the exact retained head/tail windows.
159
203
  *
160
- * The combined output is `<head>\n<marker>\n<tail>` when truncation is needed.
161
- * `maxHeadBytes` defaults to `floor(maxBytes / 2)`; the tail receives the
162
- * remainder. Falls back to `truncateTail` / `truncateHead` if either side's
163
- * budget is empty or the content already fits.
204
+ * The budget split and fallback ordering intentionally mirror truncateMiddle.
205
+ * The overlap classification is performed before resolving an overlap to a
206
+ * full window, so callers can distinguish disjoint, adjacent and overlapping
207
+ * candidate windows even when no marker is needed.
208
+ */
209
+ export declare function truncateMiddleWindows(content: string, options?: TruncationOptions): ReadWindow;
210
+ /**
211
+ * Truncate content keeping a head window and a tail window, eliding the middle.
212
+ * The composed return shape remains field-for-field compatible with the
213
+ * historical implementation; callers that need coordinates use
214
+ * truncateMiddleWindows directly.
164
215
  */
165
216
  export declare function truncateMiddle(content: string, options?: TruncationOptions): TruncationResult;
217
+ /**
218
+ * Dispatch truncation using the caller-facing direction vocabulary.
219
+ */
220
+ export declare function truncateContent(content: string, options?: TruncationOptions): TruncationResult;
166
221
  export declare class TailBuffer {
167
222
  #private;
168
223
  readonly maxBytes: number;
@@ -45,8 +45,6 @@ export interface SkillActiveEntry {
45
45
  handoff_at?: string;
46
46
  active_subskills?: ActiveSubskillEntry[];
47
47
  source_state_revision?: number;
48
- /** Durable ordering token from the source workflow mode-state, not this cache file's revision. */
49
- committed_mode_state_revision?: number;
50
48
  }
51
49
  export interface SkillActiveState {
52
50
  version?: number;
@@ -87,8 +85,6 @@ export interface SyncSkillActiveStateOptions {
87
85
  handoff_at?: string;
88
86
  active_subskills?: ActiveSubskillEntry[];
89
87
  sourceRevision?: number;
90
- /** Durable ordering token from the source workflow mode-state, not this cache file's revision. */
91
- committedModeRevision?: number;
92
88
  }
93
89
  export declare function normalizeWorkflowHudSummary(raw: unknown): WorkflowHudSummary | undefined;
94
90
  export declare function isCanonicalGjcWorkflowSkill(skill: string): skill is CanonicalGjcWorkflowSkill;
@@ -20,6 +20,9 @@ interface RalplanHudState extends WorkflowGateHudState {
20
20
  iteration?: number;
21
21
  iterationFromIndex?: number;
22
22
  stages?: string;
23
+ architectPasses?: number;
24
+ criticPasses?: number;
25
+ reviewPassBudget?: number;
23
26
  verdict?: string;
24
27
  latestSummary?: string;
25
28
  pendingApproval?: boolean;
@@ -13,6 +13,13 @@ export declare const DEFAULT_VIEWPORT: {
13
13
  export declare const BROWSER_PROTOCOL_TIMEOUT_MS = 60000;
14
14
  export declare function loadPuppeteer(): Promise<typeof Puppeteer>;
15
15
  export declare function loadPuppeteerInWorker(safeDir: string): Promise<typeof Puppeteer>;
16
+ /** Test seam: the browser launch overrides as resolved from trusted env. */
17
+ export declare function resolveBrowserEnvOverridesForTest(): {
18
+ executablePath: string | undefined;
19
+ proxy: string | undefined;
20
+ proxyBypassLoopback: boolean;
21
+ ignoreCertErrors: boolean;
22
+ };
16
23
  export interface LaunchHeadlessOptions {
17
24
  headless: boolean;
18
25
  viewport?: {
@@ -4,6 +4,7 @@ import type { Settings } from "../config/settings";
4
4
  import type { RenderResultOptions } from "../extensibility/custom-tools/types";
5
5
  import { type Theme } from "../modes/theme/theme";
6
6
  import type { ToolSession } from "../sdk";
7
+ import { type TruncationDirection } from "../session/streaming-output";
7
8
  import type { RenderResult } from "../web/scrapers/types";
8
9
  import { type OutputMeta } from "./output-meta";
9
10
  export declare function isReadableUrlPath(value: string): boolean;
@@ -50,7 +51,12 @@ interface ReadUrlCacheEntry {
50
51
  artifactId?: string;
51
52
  details: ReadUrlToolDetails;
52
53
  image?: FetchImagePayload;
54
+ /** Complete URL output, including its preamble and body. */
53
55
  output: string;
56
+ /** UTF-16 code-unit offset of the preamble in `output`. */
57
+ preambleChars: number;
58
+ /** Offset of the preamble after `wrapUntrustedContent(output)` is persisted. */
59
+ wrappedPreambleChars?: number;
54
60
  }
55
61
  export declare function loadReadUrlCacheEntry(session: ToolSession, params: {
56
62
  path: string;
@@ -59,11 +65,21 @@ export declare function loadReadUrlCacheEntry(session: ToolSession, params: {
59
65
  ensureArtifact?: boolean;
60
66
  preferCached?: boolean;
61
67
  }): Promise<ReadUrlCacheEntry>;
68
+ export declare const WRAP_PREFIX_CHARS: number;
69
+ export declare function escapeUntrustedContent(content: string): string;
62
70
  export declare function wrapUntrustedContent(content: string): string;
71
+ /**
72
+ * Remove only the outer URL-output wrapper before line pagination. The content
73
+ * remains escaped exactly as persisted; it is deliberately never unescaped.
74
+ */
75
+ export declare function prepareReadUrlSelectorInput(output: string, preambleChars: number, wrappedPreambleChars?: number): {
76
+ text: string;
77
+ preambleChars: number;
78
+ };
63
79
  export declare function executeReadUrl(session: ToolSession, params: {
64
80
  path: string;
65
81
  raw?: boolean;
66
- }, signal?: AbortSignal): Promise<AgentToolResult<ReadUrlToolDetails>>;
82
+ }, signal?: AbortSignal, direction?: TruncationDirection): Promise<AgentToolResult<ReadUrlToolDetails>>;
67
83
  /** Render URL read call (URL preview) */
68
84
  export declare function renderReadUrlCall(args: {
69
85
  path?: string;
@@ -7,12 +7,15 @@
7
7
  import type { AgentTool } from "@gajae-code/agent-core";
8
8
  import { type Settings } from "../config/settings";
9
9
  import type { Theme } from "../modes/theme/theme";
10
- import { type OutputSummary, type TruncationResult } from "../session/streaming-output";
10
+ import { type OutputSummary, type ReadWindow, type TruncationResult } from "../session/streaming-output";
11
11
  /**
12
12
  * Truncation metadata for the output notice.
13
13
  */
14
14
  export interface TruncationMeta {
15
15
  direction: "head" | "tail" | "middle";
16
+ /** Coordinate basis for shown/head/tail ranges. Omitted means file coordinates; "window" is the selected-range coordinate system. */
17
+ rangeBase?: "file" | "window";
18
+ noticeOwner?: "body";
16
19
  truncatedBy: "lines" | "bytes" | "middle";
17
20
  totalLines: number;
18
21
  totalBytes: number;
@@ -33,6 +36,12 @@ export interface TruncationMeta {
33
36
  start: number;
34
37
  end: number;
35
38
  };
39
+ /** Partial source-line preview retained by a directional window. */
40
+ partialLine?: {
41
+ line: number;
42
+ bytes: number;
43
+ sourceBytes: number;
44
+ };
36
45
  /** Bytes elided from the middle. */
37
46
  elidedBytes?: number;
38
47
  /** Lines elided from the middle. */
@@ -96,11 +105,14 @@ export interface TruncationOptions {
96
105
  startLine?: number;
97
106
  totalFileLines?: number;
98
107
  artifactId?: string;
108
+ maxBytes?: number;
109
+ noticeOwner?: "body";
99
110
  }
100
111
  export interface TruncationSummaryOptions {
101
112
  direction: "head" | "tail" | "middle";
102
113
  startLine?: number;
103
114
  totalFileLines?: number;
115
+ noticeOwner?: "body";
104
116
  }
105
117
  export interface TruncationTextOptions {
106
118
  direction: "head" | "tail" | "middle";
@@ -108,6 +120,7 @@ export interface TruncationTextOptions {
108
120
  totalBytes?: number;
109
121
  maxBytes?: number;
110
122
  artifactId?: string;
123
+ noticeOwner?: "body";
111
124
  }
112
125
  /**
113
126
  * Fluent builder for OutputMeta.
@@ -125,6 +138,13 @@ export declare class OutputMetaBuilder {
125
138
  #private;
126
139
  /** Add truncation info from TruncationResult. No-op if not truncated. */
127
140
  truncation(result: TruncationResult, options: TruncationOptions): this;
141
+ /** Add metadata from the actual head/tail windows retained by middle truncation. */
142
+ truncationWindows(windows: ReadWindow, options?: {
143
+ artifactId?: string;
144
+ noticeOwner?: "body";
145
+ maxBytes?: number;
146
+ rangeBase?: "file" | "window";
147
+ }): this;
128
148
  /** Add truncation info from OutputSummary. No-op if not truncated. */
129
149
  truncationFromSummary(summary: OutputSummary, options: TruncationSummaryOptions): this;
130
150
  /** Add truncation info from truncated output text. No-op if truncation not detected. */
@@ -0,0 +1,12 @@
1
+ import type { Settings } from "../config/settings";
2
+ import type { TruncationDirection } from "../session/streaming-output";
3
+ /**
4
+ * Read execution routes that have distinct truncation-default contracts.
5
+ * Routes that share the same default are grouped only when their truncation
6
+ * policy is identical; selection and rendering remain owned by read.ts.
7
+ */
8
+ export type ReadRoute = "local-bare-stream" | "local-bare-acp" | "archive-member-bare" | "local-range" | "local-multi-range" | "local-raw" | "local-summary" | "url-reader" | "url-cache-page" | "dir-local" | "dir-archive" | "sqlite-list" | "sqlite-rows" | "converted";
9
+ /** Resolve the configured default for a route; explicit parameters bypass it. */
10
+ export declare function pathDefault(route: ReadRoute, settings: Settings): TruncationDirection;
11
+ /** Resolve the effective caller-facing direction with explicit precedence. */
12
+ export declare function resolveEffectiveDirection(explicitParam: TruncationDirection | undefined, route: ReadRoute, settings: Settings): TruncationDirection;
@@ -4,10 +4,49 @@ import * as z from "zod/v4";
4
4
  import type { RenderResultOptions } from "../extensibility/custom-tools/types";
5
5
  import { type Theme } from "../modes/theme/theme";
6
6
  import type { ToolSession } from "../sdk";
7
- import { type TruncationResult } from "../session/streaming-output";
7
+ import type { ReadWindow, TruncationResult } from "../session/streaming-output";
8
8
  import { type OutputMeta } from "./output-meta";
9
+ export declare function streamLinesFromFile(filePath: string, startLine: number, maxLinesToCollect: number, maxBytes: number, selectedLineLimit: number | null, signal?: AbortSignal, collect?: "head" | "tail" | "both", collectEndExclusive?: number | null): Promise<{
10
+ lines: string[];
11
+ totalFileLines: number;
12
+ collectedBytes: number;
13
+ stoppedByByteLimit: boolean;
14
+ firstLinePreview?: {
15
+ text: string;
16
+ bytes: number;
17
+ };
18
+ firstLineByteLength?: number;
19
+ selectedBytesTotal: number;
20
+ windowBytesTotal: number;
21
+ windowLinesTotal: number;
22
+ windowStartIndex: number;
23
+ tailPartial?: {
24
+ text: string;
25
+ bytes: number;
26
+ sourceIndex: number;
27
+ sourceLineBytes: number;
28
+ };
29
+ maxBytes: number;
30
+ headLines?: string[];
31
+ headBytes?: number;
32
+ headStartIndex?: number;
33
+ degenerateTailBudget: boolean;
34
+ degenerateHeadBudget: boolean;
35
+ headStoppedByBytes: boolean;
36
+ headStoppedByLines: boolean;
37
+ ringBudgetLines: number;
38
+ ringEvictedForBytes: boolean;
39
+ ringEvictedForLines: boolean;
40
+ tailDroppedForBytes: boolean;
41
+ }>;
42
+ export declare function streamResultWindow(result: Awaited<ReturnType<typeof streamLinesFromFile>>, collect: "tail" | "both", startLine: number, collectEndExclusive: number | null): ReadWindow;
9
43
  declare const readSchema: z.ZodObject<{
10
44
  path: z.ZodString;
45
+ truncation: z.ZodOptional<z.ZodEnum<{
46
+ both: "both";
47
+ head: "head";
48
+ last: "last";
49
+ }>>;
11
50
  }, z.core.$strict>;
12
51
  export type ReadToolInput = z.infer<typeof readSchema>;
13
52
  /** Project paths and output sizes without exposing read content or remote URLs. */
@@ -60,6 +99,11 @@ export declare class ReadTool implements AgentTool<typeof readSchema, ReadToolDe
60
99
  readonly description: string;
61
100
  readonly parameters: z.ZodObject<{
62
101
  path: z.ZodString;
102
+ truncation: z.ZodOptional<z.ZodEnum<{
103
+ both: "both";
104
+ head: "head";
105
+ last: "last";
106
+ }>>;
63
107
  }, z.core.$strict>;
64
108
  readonly nonAbortable = true;
65
109
  readonly strict = true;
@@ -1,5 +1,6 @@
1
1
  import type { WindowsJobMemoryProbeResult } from "@gajae-code/natives";
2
2
  import type { Settings } from "../config/settings";
3
+ import type { MemoryGuardWorkerSample } from "../runtime/memory-guard-contract";
3
4
  import { type TabGcSnapshot } from "./browser/tab-supervisor";
4
5
  export interface BrowserGcPolicy {
5
6
  enabled: boolean;
@@ -35,10 +36,13 @@ export interface ResourceGcDeps {
35
36
  removed: number;
36
37
  }>;
37
38
  screenshotArmed: () => boolean;
39
+ listTeamWorkers?: (cwd: string, sessionId: string) => Promise<MemoryGuardWorkerSample[]>;
40
+ applyTeamWorkerGuard?: (cwd: string, sessionId: string, workerId: string, excessBytes: number, incidentId: string) => Promise<void>;
38
41
  }
39
42
  export interface ResourceGcRegistration {
40
43
  sessionId: string;
41
44
  settings: Settings;
45
+ cwd?: string | (() => string);
42
46
  }
43
47
  /**
44
48
  * Register a session with the resource GC. Starts the single shared timer on the first
@@ -1,6 +1,6 @@
1
1
  import type { AgentToolResult } from "@gajae-code/agent-core";
2
2
  import type { ImageContent, TextContent } from "@gajae-code/ai";
3
- import type { OutputSummary, TruncationResult } from "../session/streaming-output";
3
+ import type { OutputSummary, ReadWindow, TruncationResult } from "../session/streaming-output";
4
4
  import type { OutputMeta, TruncationOptions, TruncationSummaryOptions, TruncationTextOptions } from "./output-meta";
5
5
  type ToolContent = Array<TextContent | ImageContent>;
6
6
  type DetailsWithMeta = {
@@ -12,6 +12,12 @@ export declare class ToolResultBuilder<TDetails extends DetailsWithMeta> {
12
12
  text(text: string): this;
13
13
  content(content: ToolContent): this;
14
14
  truncation(result: TruncationResult, options: TruncationOptions): this;
15
+ truncationWindows(windows: ReadWindow, options?: {
16
+ artifactId?: string;
17
+ noticeOwner?: "body";
18
+ maxBytes?: number;
19
+ rangeBase?: "file" | "window";
20
+ }): this;
15
21
  truncationFromSummary(summary: OutputSummary, options: TruncationSummaryOptions): this;
16
22
  truncationFromText(text: string, options: TruncationTextOptions): this;
17
23
  limits(limits: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@gajae-code/coding-agent",
4
- "version": "0.11.11",
4
+ "version": "0.12.0",
5
5
  "description": "Gajae Code CLI with read, bash, edit, write tools and session management",
6
6
  "homepage": "https://gajae-code.com",
7
7
  "author": "Yeachan-Heo and Gajae Code Contributors",
@@ -50,16 +50,16 @@
50
50
  "check:sdk-closure": "bun ../../scripts/telegram-daemon-generation-guard.ts --validate-current-tree && bun test ../../scripts/telegram-daemon-generation-guard.test.ts && bun scripts/generate-sdk-operation-inventory.ts --check && bun scripts/generate-sdk-adapter-parity-manifest.ts --check && bun scripts/run-test-manifest.ts test/manifests/sdk-adapter-parity-v1.json && bun scripts/generate-telegram-baseline-manifest.ts --check && bun scripts/run-test-manifest.ts test/manifests/telegram-baseline-v1.json && bun test test/sdk-downgrade-rollback.test.ts test/sdk-downgrade-unknown-version.test.ts && bun scripts/verify-gjc-sdk-canonicalization.ts --self-test && bun scripts/verify-gjc-sdk-canonicalization.ts && bun scripts/verify-gjc-sdk-rename.ts"
51
51
  },
52
52
  "dependencies": {
53
- "@agentclientprotocol/sdk": "1.2.1",
53
+ "@agentclientprotocol/sdk": "1.3.0",
54
54
  "@babel/parser": "^7.29.3",
55
55
  "@mozilla/readability": "^0.6.0",
56
- "@gajae-code/stats": "0.11.11",
57
- "@gajae-code/agent-core": "0.11.11",
58
- "@gajae-code/ai": "0.11.11",
59
- "@gajae-code/bridge-client": "0.11.11",
60
- "@gajae-code/natives": "0.11.11",
61
- "@gajae-code/tui": "0.11.11",
62
- "@gajae-code/utils": "0.11.11",
56
+ "@gajae-code/stats": "0.12.0",
57
+ "@gajae-code/agent-core": "0.12.0",
58
+ "@gajae-code/ai": "0.12.0",
59
+ "@gajae-code/bridge-client": "0.12.0",
60
+ "@gajae-code/natives": "0.12.0",
61
+ "@gajae-code/tui": "0.12.0",
62
+ "@gajae-code/utils": "0.12.0",
63
63
  "@puppeteer/browsers": "^2.13.0",
64
64
  "@types/turndown": "5.0.6",
65
65
  "@xterm/headless": "^6.0.0",
@@ -343,10 +343,6 @@
343
343
  "types": "./dist/types/extensibility/custom-commands/bundled/ci-green/index.d.ts",
344
344
  "import": "./src/extensibility/custom-commands/bundled/ci-green/index.ts"
345
345
  },
346
- "./extensibility/custom-commands/bundled/review": {
347
- "types": "./dist/types/extensibility/custom-commands/bundled/review/index.d.ts",
348
- "import": "./src/extensibility/custom-commands/bundled/review/index.ts"
349
- },
350
346
  "./extensibility/custom-tools": {
351
347
  "types": "./dist/types/extensibility/custom-tools/index.d.ts",
352
348
  "import": "./src/extensibility/custom-tools/index.ts"