@dhrxv29/autocodex 0.1.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.
- package/LICENSE +21 -0
- package/README.md +119 -0
- package/dist/app.d.ts +47 -0
- package/dist/app.js +174 -0
- package/dist/app.js.map +1 -0
- package/dist/cli.d.ts +22 -0
- package/dist/cli.js +308 -0
- package/dist/cli.js.map +1 -0
- package/dist/clock.d.ts +14 -0
- package/dist/clock.js +21 -0
- package/dist/clock.js.map +1 -0
- package/dist/defaults.d.ts +10 -0
- package/dist/defaults.js +11 -0
- package/dist/defaults.js.map +1 -0
- package/dist/facing.d.ts +31 -0
- package/dist/facing.js +115 -0
- package/dist/facing.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/launchd.d.ts +57 -0
- package/dist/launchd.js +333 -0
- package/dist/launchd.js.map +1 -0
- package/dist/machine.d.ts +21 -0
- package/dist/machine.js +277 -0
- package/dist/machine.js.map +1 -0
- package/dist/paths.d.ts +20 -0
- package/dist/paths.js +58 -0
- package/dist/paths.js.map +1 -0
- package/dist/provider.d.ts +20 -0
- package/dist/provider.js +2 -0
- package/dist/provider.js.map +1 -0
- package/dist/providers/app-server.d.ts +102 -0
- package/dist/providers/app-server.js +474 -0
- package/dist/providers/app-server.js.map +1 -0
- package/dist/providers/codex.d.ts +44 -0
- package/dist/providers/codex.js +260 -0
- package/dist/providers/codex.js.map +1 -0
- package/dist/scheduler.d.ts +25 -0
- package/dist/scheduler.js +59 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/schema.d.ts +5 -0
- package/dist/schema.js +41 -0
- package/dist/schema.js.map +1 -0
- package/dist/store.d.ts +15 -0
- package/dist/store.js +146 -0
- package/dist/store.js.map +1 -0
- package/dist/tracker.d.ts +33 -0
- package/dist/tracker.js +98 -0
- package/dist/tracker.js.map +1 -0
- package/dist/tui.d.ts +25 -0
- package/dist/tui.js +89 -0
- package/dist/tui.js.map +1 -0
- package/dist/types.d.ts +84 -0
- package/dist/types.js +48 -0
- package/dist/types.js.map +1 -0
- package/dist/view.d.ts +68 -0
- package/dist/view.js +139 -0
- package/dist/view.js.map +1 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dhruv Rao
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# autocodex
|
|
2
|
+
|
|
3
|
+
Paste a Codex thread id. That's the whole setup.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npx autocodex
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
1. Run that (Node 22+).
|
|
10
|
+
2. Paste the id. In Codex type `/status` and copy the bit that looks like `thr_…`.
|
|
11
|
+
3. Done. On a Mac you can close the window — it keeps watching.
|
|
12
|
+
|
|
13
|
+
When Codex hits a usage limit, autocodex waits for the real reset time, then continues **that same chat**. It never starts a new one.
|
|
14
|
+
|
|
15
|
+
## 2-minute check
|
|
16
|
+
|
|
17
|
+
No Codex account needed. This only checks that the tracker opens.
|
|
18
|
+
|
|
19
|
+
1. `node -v` — needs v22 or newer.
|
|
20
|
+
2. `npx autocodex`
|
|
21
|
+
3. You should see **Paste a Codex thread id** and a box that says type `/status` / copy `thr_…`.
|
|
22
|
+
4. Type `thr_demo` and press Enter.
|
|
23
|
+
5. You should see **tracking** and **Auto-resume ON**.
|
|
24
|
+
6. Press `q` to quit.
|
|
25
|
+
|
|
26
|
+
If step 2 says to open a terminal, do that — this is a terminal app, not a web page.
|
|
27
|
+
|
|
28
|
+
To actually continue a real Codex chat after a limit, Codex must already be installed and signed in on this Mac (`codex login`). Autocodex never asks for an API key.
|
|
29
|
+
|
|
30
|
+
## What works today
|
|
31
|
+
|
|
32
|
+
### Implemented and verified (tests, fake clock, no Codex binary)
|
|
33
|
+
|
|
34
|
+
- First-run screen: paste an id, with a hard-to-miss `/status` tip
|
|
35
|
+
- Track that same chat (`watch`)
|
|
36
|
+
- Wait until the official reset time
|
|
37
|
+
- Resume the **same** id and send **one** continue prompt (never twice for the same reset)
|
|
38
|
+
- Refuse `--last` / a different chat
|
|
39
|
+
- If Codex is still using the chat: stay on that id, show “close that Codex window”, retry
|
|
40
|
+
- Background helper on a Mac (tests fake `launchctl`; never print its raw errors)
|
|
41
|
+
- Every failure shows **one** plain-English next step
|
|
42
|
+
|
|
43
|
+
### Needs a live Codex install (not run in CI)
|
|
44
|
+
|
|
45
|
+
- Talking to real `codex app-server`
|
|
46
|
+
- A real usage-limit wait and a real continue after reset
|
|
47
|
+
- The Mac helper surviving sleep and reboot on your machine
|
|
48
|
+
|
|
49
|
+
### Not published yet
|
|
50
|
+
|
|
51
|
+
`npx autocodex` works **after** this package is on npm. Until then, from a clone: `npm install && npm run build && node dist/cli.js`.
|
|
52
|
+
|
|
53
|
+
CI does **not** ship a mock continue to your real Codex. Tests use a fake Codex and a fake clock.
|
|
54
|
+
|
|
55
|
+
## Why
|
|
56
|
+
|
|
57
|
+
Codex does not continue by itself after a usage-limit reset. Autocodex waits for the official time, then resumes the same session. It does not bypass limits, scrape the screen, or start a new chat.
|
|
58
|
+
|
|
59
|
+
## From source / power users
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npm install
|
|
63
|
+
npm test
|
|
64
|
+
npm run typecheck
|
|
65
|
+
npm run build
|
|
66
|
+
node dist/cli.js # same tracker as npx autocodex
|
|
67
|
+
node dist/cli.js status # text status
|
|
68
|
+
node dist/cli.js watch thr_… # track without the UI
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
| What | Path |
|
|
72
|
+
| --- | --- |
|
|
73
|
+
| Mac helper | `~/Library/LaunchAgents/com.autocodex.agent.plist` |
|
|
74
|
+
| Saved state | `~/.autocodex/state.sqlite` |
|
|
75
|
+
| Helper logs | `~/.autocodex/daemon.stdout.log` and `daemon.stderr.log` |
|
|
76
|
+
|
|
77
|
+
Linux: leave the tracker window open (no background helper).
|
|
78
|
+
|
|
79
|
+
If Codex itself is still open on that chat, close it. Autocodex will retry the **same** id. It will not start a different chat.
|
|
80
|
+
|
|
81
|
+
A continue may auto-accept Codex’s “allow this?” prompts so it can finish unattended. Change those settings in Codex, not here.
|
|
82
|
+
|
|
83
|
+
## Advanced CLI
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
autocodex enable # on + start Mac helper
|
|
87
|
+
autocodex disable # off + stop helper
|
|
88
|
+
autocodex daemon # used by the helper
|
|
89
|
+
autocodex status
|
|
90
|
+
autocodex sessions
|
|
91
|
+
autocodex watch <sessionId>
|
|
92
|
+
autocodex step
|
|
93
|
+
autocodex cancel [sessionId]
|
|
94
|
+
autocodex logs [--limit 50]
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
`--data-dir` defaults to `~/.autocodex`. `--poll-seconds` (default 30) is only how often it wakes; the reset time in the database is what matters.
|
|
98
|
+
|
|
99
|
+
## Publish to npm (maintainers)
|
|
100
|
+
|
|
101
|
+
The name `autocodex` is free on npm. From this repo, logged in to npm as the owner:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
npm publish --access public
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
That builds `dist/` first, then uploads `dist/`, `README.md`, and `LICENSE`.
|
|
108
|
+
|
|
109
|
+
If npm asks for a one-time password, type the 2FA code. There is no publish without that login.
|
|
110
|
+
|
|
111
|
+
## License
|
|
112
|
+
|
|
113
|
+
MIT.
|
|
114
|
+
|
|
115
|
+
## Hard rules
|
|
116
|
+
|
|
117
|
+
- Official Codex only. No screen scraping.
|
|
118
|
+
- Same chat id only. Missing id is an error. Never `--last`, never a new chat.
|
|
119
|
+
- One continue per reset. Never spend extra quota to skip a limit.
|
package/dist/app.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Clock } from "./clock.js";
|
|
2
|
+
import { type MachineState } from "./machine.js";
|
|
3
|
+
import type { AgentProvider } from "./provider.js";
|
|
4
|
+
import type { SqliteStore } from "./store.js";
|
|
5
|
+
import { type AppStatus, type LogEvent, type SessionRecord } from "./types.js";
|
|
6
|
+
export interface AutoCodexOptions {
|
|
7
|
+
store: SqliteStore;
|
|
8
|
+
clock: Clock;
|
|
9
|
+
provider: AgentProvider;
|
|
10
|
+
}
|
|
11
|
+
export interface StepResult {
|
|
12
|
+
resumed: string[];
|
|
13
|
+
continued: string[];
|
|
14
|
+
failed: string[];
|
|
15
|
+
retrying: string[];
|
|
16
|
+
}
|
|
17
|
+
export declare class AutoCodex {
|
|
18
|
+
private readonly store;
|
|
19
|
+
private readonly clock;
|
|
20
|
+
private readonly provider;
|
|
21
|
+
constructor(options: AutoCodexOptions);
|
|
22
|
+
enable(): void;
|
|
23
|
+
disable(): void;
|
|
24
|
+
watch(sessionId: string, cwd?: string): void;
|
|
25
|
+
cancel(sessionId?: string): void;
|
|
26
|
+
status(): AppStatus;
|
|
27
|
+
sessions(): SessionRecord[];
|
|
28
|
+
logs(limit?: number, sessionId?: string): LogEvent[];
|
|
29
|
+
ingest(rawEvent: unknown, hintSessionId?: string): boolean;
|
|
30
|
+
tick(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Drive available sessions: resume the same id, then send the continuation
|
|
33
|
+
* prompt once. Safe to call after process restart.
|
|
34
|
+
*/
|
|
35
|
+
nowUnix(): number;
|
|
36
|
+
step(): Promise<StepResult>;
|
|
37
|
+
/**
|
|
38
|
+
* For watched threads, read `account/rateLimits/read` and ingest an official
|
|
39
|
+
* snapshot. Recording providers omit `readAccountRateLimits`.
|
|
40
|
+
*/
|
|
41
|
+
private syncUsageLimitsFromProvider;
|
|
42
|
+
close(): Promise<void>;
|
|
43
|
+
private failSession;
|
|
44
|
+
private loadState;
|
|
45
|
+
private dispatch;
|
|
46
|
+
}
|
|
47
|
+
export declare function createStateSnapshot(store: SqliteStore): MachineState;
|
package/dist/app.js
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { applyEvent, sessionsNeedingContinue, sessionsNeedingResume, } from "./machine.js";
|
|
3
|
+
import { AutocodexError, isRetriableResumeError, } from "./types.js";
|
|
4
|
+
export class AutoCodex {
|
|
5
|
+
store;
|
|
6
|
+
clock;
|
|
7
|
+
provider;
|
|
8
|
+
constructor(options) {
|
|
9
|
+
if (options.provider.name !== "codex") {
|
|
10
|
+
throw new AutocodexError("MVP only supports the Codex provider");
|
|
11
|
+
}
|
|
12
|
+
this.store = options.store;
|
|
13
|
+
this.clock = options.clock;
|
|
14
|
+
this.provider = options.provider;
|
|
15
|
+
}
|
|
16
|
+
enable() {
|
|
17
|
+
this.dispatch({ type: "enable" });
|
|
18
|
+
}
|
|
19
|
+
disable() {
|
|
20
|
+
this.dispatch({ type: "disable" });
|
|
21
|
+
}
|
|
22
|
+
watch(sessionId, cwd) {
|
|
23
|
+
this.dispatch({ type: "watch", sessionId, cwd });
|
|
24
|
+
}
|
|
25
|
+
cancel(sessionId) {
|
|
26
|
+
this.dispatch({ type: "cancel", sessionId });
|
|
27
|
+
}
|
|
28
|
+
status() {
|
|
29
|
+
return {
|
|
30
|
+
enabled: this.store.getDaemon().enabled,
|
|
31
|
+
sessions: this.store.listSessions(),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
sessions() {
|
|
35
|
+
return this.store.listSessions();
|
|
36
|
+
}
|
|
37
|
+
logs(limit = 50, sessionId) {
|
|
38
|
+
return this.store.listEvents(limit, sessionId);
|
|
39
|
+
}
|
|
40
|
+
ingest(rawEvent, hintSessionId) {
|
|
41
|
+
const detected = this.provider.detectUsageLimit(rawEvent, hintSessionId);
|
|
42
|
+
if (!detected) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
this.dispatch({
|
|
46
|
+
type: "limitHit",
|
|
47
|
+
sessionId: detected.sessionId,
|
|
48
|
+
resetAtUnix: detected.resetAtUnix,
|
|
49
|
+
limitKind: detected.kind,
|
|
50
|
+
});
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
tick() {
|
|
54
|
+
this.dispatch({ type: "tick" });
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Drive available sessions: resume the same id, then send the continuation
|
|
58
|
+
* prompt once. Safe to call after process restart.
|
|
59
|
+
*/
|
|
60
|
+
nowUnix() {
|
|
61
|
+
return this.clock.nowUnix();
|
|
62
|
+
}
|
|
63
|
+
async step() {
|
|
64
|
+
const result = { resumed: [], continued: [], failed: [], retrying: [] };
|
|
65
|
+
if (this.store.getDaemon().enabled) {
|
|
66
|
+
await this.syncUsageLimitsFromProvider();
|
|
67
|
+
}
|
|
68
|
+
this.tick();
|
|
69
|
+
if (!this.store.getDaemon().enabled) {
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
for (const session of sessionsNeedingResume(this.loadState())) {
|
|
73
|
+
const attemptId = session.resumeAttemptId ?? randomUUID();
|
|
74
|
+
try {
|
|
75
|
+
this.dispatch({
|
|
76
|
+
type: "resumeStarted",
|
|
77
|
+
sessionId: session.sessionId,
|
|
78
|
+
resumeAttemptId: attemptId,
|
|
79
|
+
});
|
|
80
|
+
const resumed = await this.provider.resumeSession(session.sessionId);
|
|
81
|
+
this.dispatch({
|
|
82
|
+
type: "resumeSucceeded",
|
|
83
|
+
sessionId: session.sessionId,
|
|
84
|
+
resumedSessionId: resumed.sessionId,
|
|
85
|
+
});
|
|
86
|
+
const afterResume = this.store.getSession(session.sessionId);
|
|
87
|
+
if (afterResume?.phase === "failed") {
|
|
88
|
+
result.failed.push(session.sessionId);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
result.resumed.push(session.sessionId);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
if (isRetriableResumeError(error)) {
|
|
95
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
96
|
+
this.dispatch({ type: "resumeRetry", sessionId: session.sessionId, error: message });
|
|
97
|
+
result.retrying.push(session.sessionId);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
this.failSession(session.sessionId, error);
|
|
101
|
+
result.failed.push(session.sessionId);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
for (const session of sessionsNeedingContinue(this.loadState())) {
|
|
106
|
+
if (session.continuationSent) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
await this.provider.sendContinuation(session.sessionId, session.continuationPrompt);
|
|
111
|
+
this.dispatch({ type: "continueSucceeded", sessionId: session.sessionId });
|
|
112
|
+
result.continued.push(session.sessionId);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
this.failSession(session.sessionId, error);
|
|
116
|
+
result.failed.push(session.sessionId);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* For watched threads, read `account/rateLimits/read` and ingest an official
|
|
123
|
+
* snapshot. Recording providers omit `readAccountRateLimits`.
|
|
124
|
+
*/
|
|
125
|
+
async syncUsageLimitsFromProvider() {
|
|
126
|
+
if (!this.provider.readAccountRateLimits) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const watched = this.store
|
|
130
|
+
.listSessions()
|
|
131
|
+
.filter((session) => session.phase === "watching" || session.phase === "waiting");
|
|
132
|
+
if (watched.length === 0) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const snapshot = await this.provider.readAccountRateLimits();
|
|
136
|
+
for (const session of watched) {
|
|
137
|
+
this.ingest(snapshot, session.sessionId);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
async close() {
|
|
141
|
+
await this.provider.close?.();
|
|
142
|
+
}
|
|
143
|
+
failSession(sessionId, error) {
|
|
144
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
145
|
+
this.dispatch({ type: "fail", sessionId, error: message });
|
|
146
|
+
}
|
|
147
|
+
loadState() {
|
|
148
|
+
return {
|
|
149
|
+
daemon: this.store.getDaemon(),
|
|
150
|
+
sessions: new Map(this.store.listSessions().map((session) => [session.sessionId, session])),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
dispatch(event) {
|
|
154
|
+
const now = this.clock.nowUnix();
|
|
155
|
+
const applied = applyEvent(this.loadState(), event, now);
|
|
156
|
+
this.store.setDaemon(applied.state.daemon.enabled, applied.state.daemon.updatedAtUnix);
|
|
157
|
+
this.store.replaceSessions([...applied.state.sessions.values()]);
|
|
158
|
+
for (const log of applied.logs) {
|
|
159
|
+
this.store.appendEvent({
|
|
160
|
+
sessionId: log.sessionId,
|
|
161
|
+
atUnix: now,
|
|
162
|
+
kind: log.kind,
|
|
163
|
+
message: log.message,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
export function createStateSnapshot(store) {
|
|
169
|
+
return {
|
|
170
|
+
daemon: store.getDaemon(),
|
|
171
|
+
sessions: new Map(store.listSessions().map((session) => [session.sessionId, session])),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=app.js.map
|
package/dist/app.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EACL,UAAU,EACV,uBAAuB,EACvB,qBAAqB,GAEtB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,cAAc,EACd,sBAAsB,GAKvB,MAAM,YAAY,CAAC;AAepB,MAAM,OAAO,SAAS;IACH,KAAK,CAAc;IACnB,KAAK,CAAQ;IACb,QAAQ,CAAgB;IAEzC,YAAY,OAAyB;QACnC,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YACtC,MAAM,IAAI,cAAc,CAAC,sCAAsC,CAAC,CAAC;QACnE,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IACnC,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IACpC,CAAC;IAED,OAAO;QACL,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,SAAiB,EAAE,GAAY;QAC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;KACvF,CAAC;AACJ,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { AutoCodex } from "./app.js";
|
|
3
|
+
import { type LaunchdHost } from "./launchd.js";
|
|
4
|
+
import { runDaemon } from "./scheduler.js";
|
|
5
|
+
import { runTui, type TuiIo } from "./tui.js";
|
|
6
|
+
export interface CliIo extends TuiIo {
|
|
7
|
+
prompt?: (question: string) => Promise<string>;
|
|
8
|
+
}
|
|
9
|
+
export declare function runCli(argv: string[], options?: {
|
|
10
|
+
dataDir?: string;
|
|
11
|
+
io?: CliIo;
|
|
12
|
+
app?: AutoCodex;
|
|
13
|
+
launchd?: LaunchdHost;
|
|
14
|
+
runDaemonLoop?: typeof runDaemon;
|
|
15
|
+
runTui?: typeof runTui;
|
|
16
|
+
stdinIsTty?: boolean;
|
|
17
|
+
}): Promise<number>;
|
|
18
|
+
/**
|
|
19
|
+
* True when this file is the process entry, including `npx autocodex`
|
|
20
|
+
* (npm bin is a symlink named `autocodex`, not `cli.js`).
|
|
21
|
+
*/
|
|
22
|
+
export declare function isCliEntry(argv1: string | undefined, modulePath: string): boolean;
|