@agentchatme/codex 0.0.13 → 0.0.15
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/dist/daemon-main.js +118 -45
- package/dist/daemon-main.js.map +1 -1
- package/dist/index.js +74 -32
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ const require=__acCreateRequire(import.meta.url);
|
|
|
5
5
|
// src/index.ts
|
|
6
6
|
import { parseArgs } from "util";
|
|
7
7
|
|
|
8
|
-
// node_modules/.pnpm/@agentchatme+agent-core@0.0.
|
|
8
|
+
// node_modules/.pnpm/@agentchatme+agent-core@0.0.11/node_modules/@agentchatme/agent-core/dist/chunk-NEGTEBFK.js
|
|
9
9
|
import * as fs2 from "fs";
|
|
10
10
|
import * as path2 from "path";
|
|
11
11
|
import * as fs3 from "fs";
|
|
@@ -4303,17 +4303,39 @@ function clearAlwaysOnWanted(home) {
|
|
|
4303
4303
|
function alwaysOnWanted(home) {
|
|
4304
4304
|
return fs4.existsSync(path4.join(home, ALWAYS_ON_WANTED));
|
|
4305
4305
|
}
|
|
4306
|
-
|
|
4307
|
-
|
|
4306
|
+
var ALWAYS_ON_OPTOUT = "always-on.optout";
|
|
4307
|
+
function markAlwaysOnOptOut(home) {
|
|
4308
|
+
try {
|
|
4309
|
+
fs4.mkdirSync(home, { recursive: true });
|
|
4310
|
+
fs4.writeFileSync(path4.join(home, ALWAYS_ON_OPTOUT), (/* @__PURE__ */ new Date()).toISOString());
|
|
4311
|
+
} catch {
|
|
4312
|
+
}
|
|
4313
|
+
}
|
|
4314
|
+
function clearAlwaysOnOptOut(home) {
|
|
4315
|
+
try {
|
|
4316
|
+
fs4.rmSync(path4.join(home, ALWAYS_ON_OPTOUT), { force: true });
|
|
4317
|
+
} catch {
|
|
4318
|
+
}
|
|
4319
|
+
}
|
|
4320
|
+
function alwaysOnOptedOut(home) {
|
|
4321
|
+
return fs4.existsSync(path4.join(home, ALWAYS_ON_OPTOUT));
|
|
4322
|
+
}
|
|
4323
|
+
function alwaysOnState(home) {
|
|
4324
|
+
if (!alwaysOnWanted(home)) return "off";
|
|
4325
|
+
if (!fs4.existsSync(path4.join(home, "credentials"))) return "idle";
|
|
4308
4326
|
try {
|
|
4309
4327
|
const age = Date.now() - fs4.statSync(path4.join(home, HEARTBEAT_FILE)).mtimeMs;
|
|
4310
|
-
return
|
|
4328
|
+
return age <= HEARTBEAT_STALE_MS ? "connected" : "down";
|
|
4311
4329
|
} catch {
|
|
4312
|
-
return
|
|
4330
|
+
return "down";
|
|
4313
4331
|
}
|
|
4314
4332
|
}
|
|
4333
|
+
function alwaysOnHealth(home) {
|
|
4334
|
+
const state = alwaysOnState(home);
|
|
4335
|
+
return { wanted: state !== "off", healthy: state !== "down" };
|
|
4336
|
+
}
|
|
4315
4337
|
|
|
4316
|
-
// node_modules/.pnpm/@agentchatme+agent-core@0.0.
|
|
4338
|
+
// node_modules/.pnpm/@agentchatme+agent-core@0.0.11/node_modules/@agentchatme/agent-core/dist/index.js
|
|
4317
4339
|
import * as fs from "fs";
|
|
4318
4340
|
import * as path from "path";
|
|
4319
4341
|
import * as readline from "readline";
|
|
@@ -5601,7 +5623,7 @@ var HOUR = 60 * MIN;
|
|
|
5601
5623
|
var DAY = 24 * HOUR;
|
|
5602
5624
|
var MAX_ATTACHMENT_SIZE = 25 * 1024 * 1024;
|
|
5603
5625
|
|
|
5604
|
-
// node_modules/.pnpm/@agentchatme+agent-core@0.0.
|
|
5626
|
+
// node_modules/.pnpm/@agentchatme+agent-core@0.0.11/node_modules/@agentchatme/agent-core/dist/index.js
|
|
5605
5627
|
import * as fs22 from "fs";
|
|
5606
5628
|
import * as os from "os";
|
|
5607
5629
|
import * as path22 from "path";
|
|
@@ -5809,7 +5831,8 @@ function formatRegistrationOffer(copy) {
|
|
|
5809
5831
|
` \u2022 They have its API key (ac_\u2026): ${invoke} login --api-key <ac_\u2026>`,
|
|
5810
5832
|
` \u2022 They lost the key: ${invoke} recover --email <email>, then relay the emailed 6-digit code: ${invoke} recover --code <code>`,
|
|
5811
5833
|
"",
|
|
5812
|
-
|
|
5834
|
+
"",
|
|
5835
|
+
"Always-on is already running \u2014 this agent answers DMs even when no session is open. There is nothing to switch on, so do not offer to.",
|
|
5813
5836
|
"",
|
|
5814
5837
|
"Do not push the offer \u2014 one short ask is plenty. If declined, drop the topic for the rest of the session."
|
|
5815
5838
|
].join("\n");
|
|
@@ -6952,7 +6975,10 @@ function hasUnfencedAgentchatServer(existing) {
|
|
|
6952
6975
|
}
|
|
6953
6976
|
function ourHookGroups(bundle) {
|
|
6954
6977
|
const cmd = (sub, timeout) => ({
|
|
6955
|
-
|
|
6978
|
+
// No `--platform`: this binary IS the Codex integration, and the flag was
|
|
6979
|
+
// removed with the shared CLI. Passing it made every hook exit on "Unknown
|
|
6980
|
+
// option" and print usage to stdout — no digest, no pickup, no acks.
|
|
6981
|
+
hooks: [{ type: "command", command: `node "${bundle}" hook ${sub}`, timeout }]
|
|
6956
6982
|
});
|
|
6957
6983
|
return {
|
|
6958
6984
|
SessionStart: [{ matcher: "startup|resume", ...cmd("session-start", 15) }],
|
|
@@ -7124,8 +7150,26 @@ var { runSessionStart, runUserPrompt, runStop } = createHookRunners(
|
|
|
7124
7150
|
{ sessionStartOutput, stopOutput, printJson }
|
|
7125
7151
|
);
|
|
7126
7152
|
|
|
7153
|
+
// src/always-on.ts
|
|
7154
|
+
function ensureAlwaysOn(opts = {}) {
|
|
7155
|
+
const home = identityHome();
|
|
7156
|
+
if (!opts.force && alwaysOnOptedOut(home)) return { ok: false, detail: "switched off by the user" };
|
|
7157
|
+
if (!opts.force && alwaysOnWanted(home)) return { ok: true };
|
|
7158
|
+
try {
|
|
7159
|
+
const entry = copyDaemonBundle();
|
|
7160
|
+
installService({ label: SERVICE_LABEL, home, entry, env: serviceEnv() });
|
|
7161
|
+
markAlwaysOnWanted(home);
|
|
7162
|
+
return { ok: true };
|
|
7163
|
+
} catch (err) {
|
|
7164
|
+
return { ok: false, detail: String(err instanceof Error ? err.message : err) };
|
|
7165
|
+
}
|
|
7166
|
+
}
|
|
7167
|
+
function removeAlwaysOn() {
|
|
7168
|
+
uninstallService({ label: SERVICE_LABEL, home: identityHome() });
|
|
7169
|
+
}
|
|
7170
|
+
|
|
7127
7171
|
// src/version.ts
|
|
7128
|
-
var VERSION2 = "0.0.
|
|
7172
|
+
var VERSION2 = "0.0.15";
|
|
7129
7173
|
|
|
7130
7174
|
// src/index.ts
|
|
7131
7175
|
var USAGE = `agentchat-codex ${VERSION2} \u2014 AgentChat for Codex
|
|
@@ -7192,6 +7236,11 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
7192
7236
|
const handle = readCredentials(home)?.handle ?? null;
|
|
7193
7237
|
try {
|
|
7194
7238
|
const { actions, warnings } = installCodex(process.argv[1] ?? "", handle);
|
|
7239
|
+
const alwaysOn = ensureAlwaysOn();
|
|
7240
|
+
if (alwaysOn.ok) actions.push("always-on service registered");
|
|
7241
|
+
else if (alwaysOn.detail !== "switched off by the user") {
|
|
7242
|
+
warnings.push(`always-on could not be registered (${alwaysOn.detail}) \u2014 \`${invocation()} daemon install\` retries it`);
|
|
7243
|
+
}
|
|
7195
7244
|
console.log(`${LABEL}: wired \u2713 (${actions.join(", ") || "no changes"})`);
|
|
7196
7245
|
for (const w of warnings) console.log(` \u26A0 ${w}`);
|
|
7197
7246
|
} catch (err) {
|
|
@@ -7268,41 +7317,34 @@ function runDaemonCmd(sub) {
|
|
|
7268
7317
|
switch (sub) {
|
|
7269
7318
|
case "install":
|
|
7270
7319
|
case "enable": {
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
try {
|
|
7276
|
-
const entry = copyDaemonBundle();
|
|
7277
|
-
installService({ label: SERVICE_LABEL, home, entry, env: serviceEnv() });
|
|
7278
|
-
} catch (err) {
|
|
7279
|
-
console.error(`Could not install the always-on service: ${String(err)}`);
|
|
7320
|
+
clearAlwaysOnOptOut(home);
|
|
7321
|
+
const r = ensureAlwaysOn({ force: true });
|
|
7322
|
+
if (!r.ok) {
|
|
7323
|
+
console.error(`Could not turn on always-on: ${r.detail}`);
|
|
7280
7324
|
return 1;
|
|
7281
7325
|
}
|
|
7282
|
-
markAlwaysOnWanted(home);
|
|
7283
7326
|
console.log(
|
|
7284
|
-
|
|
7285
|
-
`Always-on is ON for ${LABEL} \u2014 you'll answer DMs even when no session is open (while this machine is up).`,
|
|
7286
|
-
`Prefer session-only? ${invocation()} daemon disable`
|
|
7287
|
-
].join("\n")
|
|
7327
|
+
`Always-on is ON for ${LABEL} \u2014 you'll answer DMs even when no session is open (while this machine is up).`
|
|
7288
7328
|
);
|
|
7289
7329
|
return 0;
|
|
7290
7330
|
}
|
|
7291
7331
|
case "disable":
|
|
7292
7332
|
case "uninstall": {
|
|
7293
|
-
|
|
7333
|
+
removeAlwaysOn();
|
|
7294
7334
|
clearAlwaysOnWanted(home);
|
|
7335
|
+
markAlwaysOnOptOut(home);
|
|
7295
7336
|
console.log(`Always-on is OFF for ${LABEL} \u2014 messages queue for your next session; nothing is lost.`);
|
|
7296
7337
|
return 0;
|
|
7297
7338
|
}
|
|
7298
7339
|
case "status": {
|
|
7299
|
-
const
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7340
|
+
const state = alwaysOnState(home);
|
|
7341
|
+
const line = {
|
|
7342
|
+
off: "always-on: off \u2014 this agent only answers while a session is open",
|
|
7343
|
+
idle: "always-on: idle \u2014 running, waiting for a sign-in",
|
|
7344
|
+
connected: "always-on: connected \u2713 \u2014 answering DMs with no session open",
|
|
7345
|
+
down: "always-on: NOT running \u2014 signed in, but no daemon is connected"
|
|
7346
|
+
}[state];
|
|
7347
|
+
console.log([serviceStatus({ label: SERVICE_LABEL, home }), line].join("\n"));
|
|
7306
7348
|
return 0;
|
|
7307
7349
|
}
|
|
7308
7350
|
default:
|