@gkorepanov/ccodex 0.5.0-rc.8 → 0.5.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 (88) hide show
  1. package/README.md +159 -157
  2. package/config/compatibility.json +1 -1
  3. package/dist/claude/delegation.d.ts +10 -0
  4. package/dist/claude/delegation.js +41 -0
  5. package/dist/claude/delegation.js.map +1 -0
  6. package/dist/claude/native/catalog.d.ts +5 -0
  7. package/dist/claude/native/catalog.js +26 -17
  8. package/dist/claude/native/catalog.js.map +1 -1
  9. package/dist/claude/native/history.js +4 -3
  10. package/dist/claude/native/history.js.map +1 -1
  11. package/dist/claude/native/pages.d.ts +2 -0
  12. package/dist/claude/native/pages.js +6 -1
  13. package/dist/claude/native/pages.js.map +1 -1
  14. package/dist/claude/native/projector.js +33 -12
  15. package/dist/claude/native/projector.js.map +1 -1
  16. package/dist/claude/native/records.js +19 -0
  17. package/dist/claude/native/records.js.map +1 -1
  18. package/dist/claude/native/search.d.ts +7 -0
  19. package/dist/claude/native/search.js +79 -0
  20. package/dist/claude/native/search.js.map +1 -0
  21. package/dist/claude/native/summary.d.ts +6 -1
  22. package/dist/claude/native/summary.js +24 -6
  23. package/dist/claude/native/summary.js.map +1 -1
  24. package/dist/claude/peers.d.ts +2 -0
  25. package/dist/claude/peers.js +13 -4
  26. package/dist/claude/peers.js.map +1 -1
  27. package/dist/claude/processes.d.ts +2 -0
  28. package/dist/claude/processes.js +15 -0
  29. package/dist/claude/processes.js.map +1 -1
  30. package/dist/claude/sdk.d.ts +6 -5
  31. package/dist/claude/sdk.js +15 -8
  32. package/dist/claude/sdk.js.map +1 -1
  33. package/dist/claude/session.d.ts +25 -5
  34. package/dist/claude/session.js +134 -29
  35. package/dist/claude/session.js.map +1 -1
  36. package/dist/claude/threads.d.ts +43 -3
  37. package/dist/claude/threads.js +255 -60
  38. package/dist/claude/threads.js.map +1 -1
  39. package/dist/claude/toolMapper.d.ts +7 -0
  40. package/dist/claude/toolMapper.js +14 -1
  41. package/dist/claude/toolMapper.js.map +1 -1
  42. package/dist/config.d.ts +2 -0
  43. package/dist/config.js +2 -1
  44. package/dist/config.js.map +1 -1
  45. package/dist/daemon/daemon.d.ts +3 -0
  46. package/dist/daemon/daemon.js +6 -3
  47. package/dist/daemon/daemon.js.map +1 -1
  48. package/dist/daemon/supervisor.d.ts +3 -0
  49. package/dist/daemon/supervisor.js +2 -0
  50. package/dist/daemon/supervisor.js.map +1 -1
  51. package/dist/desktop/stdioFrontend.js +1 -1
  52. package/dist/desktop/stdioFrontend.js.map +1 -1
  53. package/dist/gateway/catalog.js +35 -20
  54. package/dist/gateway/catalog.js.map +1 -1
  55. package/dist/gateway/connection.d.ts +2 -0
  56. package/dist/gateway/connection.js +14 -2
  57. package/dist/gateway/connection.js.map +1 -1
  58. package/dist/gateway/lineage.d.ts +9 -1
  59. package/dist/gateway/lineage.js +134 -37
  60. package/dist/gateway/lineage.js.map +1 -1
  61. package/dist/gateway/server.d.ts +2 -1
  62. package/dist/gateway/server.js +24 -12
  63. package/dist/gateway/server.js.map +1 -1
  64. package/dist/gateway/status.d.ts +15 -5
  65. package/dist/gateway/status.js +142 -47
  66. package/dist/gateway/status.js.map +1 -1
  67. package/dist/gateway/stock.js +17 -2
  68. package/dist/gateway/stock.js.map +1 -1
  69. package/dist/instructions.d.ts +4 -0
  70. package/dist/instructions.js +13 -0
  71. package/dist/instructions.js.map +1 -0
  72. package/dist/management/commands.js +19 -2
  73. package/dist/management/commands.js.map +1 -1
  74. package/dist/meta.d.ts +39 -11
  75. package/dist/meta.js +59 -28
  76. package/dist/meta.js.map +1 -1
  77. package/dist/protocol/codex.d.ts +1 -3
  78. package/dist/protocol/codex.js +1 -4
  79. package/dist/protocol/codex.js.map +1 -1
  80. package/dist/protocol/turnPagination.d.ts +27 -2
  81. package/dist/protocol/turnPagination.js +46 -18
  82. package/dist/protocol/turnPagination.js.map +1 -1
  83. package/examples/config.toml +6 -2
  84. package/instructions/ccodex_extra_claude_instructions.md +20 -0
  85. package/instructions/ccodex_extra_common_instructions.md +23 -0
  86. package/legal/THIRD_PARTY_NOTICES.md +9 -9
  87. package/package.json +6 -5
  88. package/scripts/migrate-0.4-to-0.5.mjs +29 -18
@@ -6,6 +6,11 @@ import { type JsonObject, type Thread, type Turn } from "../protocol/codex.js";
6
6
  import { NativeSessionCatalog, type SessionSummary } from "./native/catalog.js";
7
7
  import { type TranscriptProjection } from "./native/projector.js";
8
8
  import { ClaudeSession, type SessionSettings } from "./session.js";
9
+ interface RateLimitWindow {
10
+ usedPercent: number;
11
+ windowDurationMins: number | null;
12
+ resetsAt: number | null;
13
+ }
9
14
  /** The Claude side of the gateway: catalog of native sessions, live sessions, side chats, models, skills. */
10
15
  export declare class ClaudeThreads {
11
16
  readonly config: Config;
@@ -16,15 +21,26 @@ export declare class ClaudeThreads {
16
21
  private readonly sides;
17
22
  /** `agent-<id>` sub-agent thread → the native session whose transcript directory holds it. */
18
23
  private readonly subagentRoots;
24
+ /** Threads rolled back but not continued yet: their kept history ends at this record. A restart meanwhile shows
25
+ * the rolled-back messages again. */
26
+ private readonly leaves;
19
27
  /** Sub-agents spawned live, shown until Claude has written their transcript. */
20
28
  private readonly spawnedSubagents;
21
29
  /** Context window of each Claude model, as its sessions report it. */
22
- readonly contextWindows: Map<string, number>;
30
+ private readonly contextWindows;
23
31
  /** Running sub-agents: their thread follows the transcript Claude writes (what was shown: item id → item). */
24
32
  private readonly liveSubagents;
25
33
  private models_?;
26
34
  private defaultModel;
27
35
  private readonly rateLimitWindows;
36
+ private usage?;
37
+ /** Why Claude's plan limits could not be read, when they could not. */
38
+ usageError?: string;
39
+ /** Weekly windows of single models (e.g. Fable), from Claude's `/usage` data. */
40
+ modelLimits: {
41
+ name: string;
42
+ window: RateLimitWindow;
43
+ }[];
28
44
  private stopWatching?;
29
45
  onTurnCompleted?: (threadId: string, turnId: string) => void;
30
46
  constructor(config: Config, gateway: Gateway, logger: Logger);
@@ -32,7 +48,7 @@ export declare class ClaudeThreads {
32
48
  /** CPU seconds each command of a loaded session used, and since when unchanged. */
33
49
  private cpuSeen;
34
50
  private sweeper?;
35
- /** What CCodex last did to each chat's process and commands, and why (shown by /ccstate). */
51
+ /** What CCodex last did to each chat's process and commands, and why (shown by /cc). */
36
52
  private readonly actions;
37
53
  private act;
38
54
  /**
@@ -53,9 +69,14 @@ export declare class ClaudeThreads {
53
69
  private status;
54
70
  /** Claude's own title of a session stays unseen while CCodex names it (it would show until CCodex's replaces it). */
55
71
  private headerOf;
72
+ /** A chat's model from its transcript; in plan mode meta.json's (Claude plans a Haiku chat on Sonnet, see Meta.setPlan). */
73
+ private recordedModel;
74
+ /** A chat's effort from its transcript (Claude records `ultra` as the max it runs at, told to delegate); in plan mode meta.json's. */
75
+ private recordedEffort;
56
76
  /** Transcripts name the resolved model (`claude-haiku-4-5-…`); the picker (and a live session) its value (`haiku`). */
57
77
  private pickerModel;
58
78
  /** Every native session as a list row (sub-agents excluded; they are listed through their parent). */
79
+ search(term: string): Promise<Map<string, string>>;
59
80
  threads(): Thread[];
60
81
  private decorate;
61
82
  private freshThread;
@@ -93,6 +114,8 @@ export declare class ClaudeThreads {
93
114
  /** The newest turns (at least `count` unless history is shorter). */
94
115
  private newestTurns;
95
116
  turnsPage(threadId: string, params: JsonObject): Promise<JsonObject>;
117
+ /** Stock's `thread/searchOccurrences`: history is read back only to the first message holding the term (ripgrep finds it). */
118
+ searchOccurrences(threadId: string, params: JsonObject): Promise<JsonObject>;
96
119
  itemsPage(threadId: string, params: JsonObject): Promise<JsonObject>;
97
120
  settings(threadId: string): SessionSettings;
98
121
  /** Common fields of thread/start|resume|fork responses and thread/settings/updated. */
@@ -103,12 +126,17 @@ export declare class ClaudeThreads {
103
126
  /** The session continued from the rollback leaf: its new records end the history from now on. */
104
127
  resumedAtLeaf(threadId: string): void;
105
128
  turnCompleted(session: ClaudeSession, turnId: string): void;
106
- /** Claude's native `/goal` as a Codex ThreadGoal (Claude tracks no budget or time). */
129
+ /**
130
+ * Claude's native `/goal` as a Codex ThreadGoal (Claude tracks no budget or time); a paused one is kept in meta.json.
131
+ * The goal last sent to Claude is the chat's: Claude records a `/goal` a moment after taking it.
132
+ */
107
133
  goal(threadId: string): JsonObject | null;
108
134
  subagentMessage(_session: ClaudeSession, _message: JsonObject): void;
109
135
  onRateLimit(info: JsonObject | undefined): void;
110
136
  private rateLimitSnapshot;
137
+ /** Claude's plan limits: read from Claude's `/usage` data at most once a minute, and as turns report them. */
111
138
  rateLimits(): Promise<JsonObject>;
139
+ private readUsage;
112
140
  rateLimitWindowsText(): string[];
113
141
  models(): Promise<JsonObject[]>;
114
142
  private get modelsPath();
@@ -116,9 +144,14 @@ export declare class ClaudeThreads {
116
144
  /** Asks Claude for its models and keeps them for the next start. */
117
145
  private probeModels;
118
146
  private useModels;
147
+ /** The effort Claude runs at: the chat's, else its model's default as the picker shows it (Claude's own may differ). */
148
+ effort(settings: SessionSettings): string | null;
149
+ /** The context window Claude works with for a model (picker value or resolved id; none: the default model). */
150
+ contextWindow(model: string | null | undefined): number;
119
151
  modelLabel(model: string | null): string;
120
152
  private readonly pendingNames;
121
153
  private readonly pickerValues;
154
+ private readonly defaultEfforts;
122
155
  private readonly skillCache;
123
156
  skills(cwds: readonly string[]): Promise<Map<string, JsonObject[]>>;
124
157
  private sideThread;
@@ -137,6 +170,12 @@ export declare class ClaudeThreads {
137
170
  create(settings: SessionSettings): ClaudeSession;
138
171
  private resume;
139
172
  rename(threadId: string, name: string): Promise<JsonObject>;
173
+ /** The goal of a Claude backend the chat switches away from, out of Claude (a running goal turn stops). */
174
+ takeGoal(threadId: string): Promise<JsonObject | null>;
175
+ /** A goal the chat brings to this Claude backend as it switches (or keeps as a switch fails). */
176
+ giveGoal(threadId: string, goal: JsonObject): Promise<void>;
177
+ /** A Claude backend the chat switched away from: nothing of it runs on (background tasks, process). */
178
+ retire(threadId: string): Promise<void>;
140
179
  /** Removes a session with its transcript (also what a failed switch to Claude leaves behind). */
141
180
  discard(threadId: string): Promise<void>;
142
181
  private delete;
@@ -155,3 +194,4 @@ export declare class ClaudeThreads {
155
194
  exists(threadId: string): boolean;
156
195
  liveSession(threadId: string): ClaudeSession | undefined;
157
196
  }
197
+ export {};