@agentchatme/codex 0.0.14 → 0.0.16
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 +124 -46
- package/dist/daemon-main.js.map +1 -1
- package/dist/index.js +307 -155
- 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.12/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.12/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";
|
|
@@ -4578,8 +4600,8 @@ var HttpTransport = class {
|
|
|
4578
4600
|
}
|
|
4579
4601
|
this.fetchFn = f.bind(globalThis);
|
|
4580
4602
|
}
|
|
4581
|
-
async request(method,
|
|
4582
|
-
const url = `${this.baseUrl}${
|
|
4603
|
+
async request(method, path8, opts = {}) {
|
|
4604
|
+
const url = `${this.baseUrl}${path8}`;
|
|
4583
4605
|
const policy = resolveRetryPolicy(opts.retry, this.retry);
|
|
4584
4606
|
const canRetry = isRetryEligible(method, opts.idempotencyKey, opts.retry);
|
|
4585
4607
|
const maxAttempts = canRetry ? policy.maxRetries + 1 : 1;
|
|
@@ -4898,31 +4920,31 @@ var AgentChatClient = class _AgentChatClient {
|
|
|
4898
4920
|
this.onBacklogWarning = options.onBacklogWarning;
|
|
4899
4921
|
}
|
|
4900
4922
|
// ─── Internal request helpers ─────────────────────────────────────────────
|
|
4901
|
-
async get(
|
|
4902
|
-
const res = await this.http.request("GET",
|
|
4923
|
+
async get(path8, opts) {
|
|
4924
|
+
const res = await this.http.request("GET", path8, this.toRequestOpts(opts));
|
|
4903
4925
|
return res.data;
|
|
4904
4926
|
}
|
|
4905
|
-
async del(
|
|
4906
|
-
const res = await this.http.request("DELETE",
|
|
4927
|
+
async del(path8, opts) {
|
|
4928
|
+
const res = await this.http.request("DELETE", path8, this.toRequestOpts(opts));
|
|
4907
4929
|
return res.data;
|
|
4908
4930
|
}
|
|
4909
|
-
async post(
|
|
4910
|
-
const res = await this.http.request("POST",
|
|
4931
|
+
async post(path8, body, opts) {
|
|
4932
|
+
const res = await this.http.request("POST", path8, {
|
|
4911
4933
|
...this.toRequestOpts(opts),
|
|
4912
4934
|
body
|
|
4913
4935
|
});
|
|
4914
4936
|
return res.data;
|
|
4915
4937
|
}
|
|
4916
|
-
async patch(
|
|
4917
|
-
const res = await this.http.request("PATCH",
|
|
4938
|
+
async patch(path8, body, opts) {
|
|
4939
|
+
const res = await this.http.request("PATCH", path8, {
|
|
4918
4940
|
...this.toRequestOpts(opts),
|
|
4919
4941
|
body
|
|
4920
4942
|
});
|
|
4921
4943
|
return res.data;
|
|
4922
4944
|
}
|
|
4923
|
-
async put(
|
|
4945
|
+
async put(path8, body, opts) {
|
|
4924
4946
|
const headers = opts?.contentType ? { "Content-Type": opts.contentType } : void 0;
|
|
4925
|
-
const res = await this.http.request("PUT",
|
|
4947
|
+
const res = await this.http.request("PUT", path8, {
|
|
4926
4948
|
...this.toRequestOpts(opts),
|
|
4927
4949
|
body,
|
|
4928
4950
|
rawBody: opts?.rawBody,
|
|
@@ -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.12/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";
|
|
@@ -5623,7 +5645,12 @@ var StateSchema = external_exports.object({
|
|
|
5623
5645
|
// Machine-wide timestamp of the last registration offer injected by the
|
|
5624
5646
|
// session-start hook. Keeps the unregistered-plugin nag to once a day
|
|
5625
5647
|
// instead of once per session.
|
|
5626
|
-
last_offer_at: external_exports.string().optional()
|
|
5648
|
+
last_offer_at: external_exports.string().optional(),
|
|
5649
|
+
// Set when the user has said "not now" to setting up a handle. Unlike the
|
|
5650
|
+
// cooldown above this is PERMANENT until they change their mind, because the
|
|
5651
|
+
// prompt that needs suppressing lives in the always-loaded instruction file
|
|
5652
|
+
// and would otherwise be re-read — and re-acted on — every single session.
|
|
5653
|
+
offer_declined_at: external_exports.string().optional()
|
|
5627
5654
|
});
|
|
5628
5655
|
function readState(home) {
|
|
5629
5656
|
const raw = readJsonFile(statePath(home));
|
|
@@ -5696,6 +5723,103 @@ function recordRegistrationOffer(home, now2 = /* @__PURE__ */ new Date()) {
|
|
|
5696
5723
|
state.last_offer_at = now2.toISOString();
|
|
5697
5724
|
writeState(home, state);
|
|
5698
5725
|
}
|
|
5726
|
+
function recordOfferDeclined(home, now2 = /* @__PURE__ */ new Date()) {
|
|
5727
|
+
const state = readState(home);
|
|
5728
|
+
state.offer_declined_at = now2.toISOString();
|
|
5729
|
+
writeState(home, state);
|
|
5730
|
+
}
|
|
5731
|
+
function offerDeclined(home) {
|
|
5732
|
+
return readState(home).offer_declined_at !== void 0;
|
|
5733
|
+
}
|
|
5734
|
+
function clearOfferDeclined(home) {
|
|
5735
|
+
const state = readState(home);
|
|
5736
|
+
delete state.offer_declined_at;
|
|
5737
|
+
writeState(home, state);
|
|
5738
|
+
}
|
|
5739
|
+
var ANCHOR_START = "<!-- agentchat:start -->";
|
|
5740
|
+
var ANCHOR_END = "<!-- agentchat:end -->";
|
|
5741
|
+
var LEGACY_ANCHOR_START = "<!-- agentchat-skill:start -->";
|
|
5742
|
+
var LEGACY_ANCHOR_END = "<!-- agentchat-skill:end -->";
|
|
5743
|
+
function writeAnchor(filePath, block, expectHandle) {
|
|
5744
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
5745
|
+
const existing = fs.existsSync(filePath) ? fs.readFileSync(filePath, "utf-8") : "";
|
|
5746
|
+
fs.writeFileSync(filePath, upsertAnchorBlock(existing, block), "utf-8");
|
|
5747
|
+
if (expectHandle !== void 0) {
|
|
5748
|
+
const verify = fs.readFileSync(filePath, "utf-8");
|
|
5749
|
+
if (!verify.includes(`@${expectHandle}`)) {
|
|
5750
|
+
throw new Error(
|
|
5751
|
+
`writeAnchor: handle @${expectHandle} did not land in ${filePath} \u2014 remove the agentchat block manually and re-run.`
|
|
5752
|
+
);
|
|
5753
|
+
}
|
|
5754
|
+
}
|
|
5755
|
+
return "written";
|
|
5756
|
+
}
|
|
5757
|
+
function removeAnchorAt(filePath) {
|
|
5758
|
+
if (!fs.existsSync(filePath)) return "noop";
|
|
5759
|
+
const existing = fs.readFileSync(filePath, "utf-8");
|
|
5760
|
+
const next = stripAnchorBlock(existing);
|
|
5761
|
+
if (next === existing) return "noop";
|
|
5762
|
+
fs.writeFileSync(filePath, next, "utf-8");
|
|
5763
|
+
return "removed";
|
|
5764
|
+
}
|
|
5765
|
+
function hasAnchorAt(filePath) {
|
|
5766
|
+
if (!fs.existsSync(filePath)) return false;
|
|
5767
|
+
return findBlock(fs.readFileSync(filePath, "utf-8"), ANCHOR_START, ANCHOR_END) !== null;
|
|
5768
|
+
}
|
|
5769
|
+
function readAnchorHandleAt(filePath) {
|
|
5770
|
+
if (!fs.existsSync(filePath)) return null;
|
|
5771
|
+
return readAnchorHandleFrom(fs.readFileSync(filePath, "utf-8"));
|
|
5772
|
+
}
|
|
5773
|
+
function readAnchorHandleFrom(text) {
|
|
5774
|
+
const block = findBlock(text, ANCHOR_START, ANCHOR_END);
|
|
5775
|
+
if (block === null) return null;
|
|
5776
|
+
const match = /\*\*@([^*\s]+)\*\*/.exec(text.slice(block.from, block.to));
|
|
5777
|
+
return match?.[1] ?? null;
|
|
5778
|
+
}
|
|
5779
|
+
function lineAnchoredIndex(text, marker, fromIndex = 0) {
|
|
5780
|
+
let idx = text.indexOf(marker, fromIndex);
|
|
5781
|
+
while (idx >= 0) {
|
|
5782
|
+
const lineStart = text.lastIndexOf("\n", idx - 1) + 1;
|
|
5783
|
+
const lineEndRaw = text.indexOf("\n", idx);
|
|
5784
|
+
const lineEnd = lineEndRaw === -1 ? text.length : lineEndRaw;
|
|
5785
|
+
if (text.slice(lineStart, lineEnd).trim() === marker) {
|
|
5786
|
+
return { start: lineStart, end: lineEnd };
|
|
5787
|
+
}
|
|
5788
|
+
idx = text.indexOf(marker, idx + marker.length);
|
|
5789
|
+
}
|
|
5790
|
+
return null;
|
|
5791
|
+
}
|
|
5792
|
+
function findBlock(text, startMarker, endMarker) {
|
|
5793
|
+
const start = lineAnchoredIndex(text, startMarker);
|
|
5794
|
+
if (start === null) return null;
|
|
5795
|
+
const end = lineAnchoredIndex(text, endMarker, start.end);
|
|
5796
|
+
if (end === null) return null;
|
|
5797
|
+
return { from: start.start, to: end.end };
|
|
5798
|
+
}
|
|
5799
|
+
function upsertAnchorBlock(existing, block) {
|
|
5800
|
+
const cleaned = stripAnchorBlock(existing);
|
|
5801
|
+
const trimmed = cleaned.replace(/\n+$/, "");
|
|
5802
|
+
if (trimmed.length === 0) return block + "\n";
|
|
5803
|
+
return trimmed + "\n\n" + block + "\n";
|
|
5804
|
+
}
|
|
5805
|
+
function stripAnchorBlock(existing) {
|
|
5806
|
+
const afterUnified = stripAllBlocks(existing, ANCHOR_START, ANCHOR_END);
|
|
5807
|
+
return stripAllBlocks(afterUnified, LEGACY_ANCHOR_START, LEGACY_ANCHOR_END);
|
|
5808
|
+
}
|
|
5809
|
+
function stripAllBlocks(existing, start, end) {
|
|
5810
|
+
let text = existing;
|
|
5811
|
+
for (let i = 0; i < 1e4; i++) {
|
|
5812
|
+
const block = findBlock(text, start, end);
|
|
5813
|
+
if (block === null) return text;
|
|
5814
|
+
const before = text.slice(0, block.from).replace(/\n+$/, "");
|
|
5815
|
+
const after = text.slice(block.to).replace(/^\n+/, "");
|
|
5816
|
+
if (before.length === 0 && after.length === 0) return "";
|
|
5817
|
+
if (before.length === 0) text = after.endsWith("\n") ? after : after + "\n";
|
|
5818
|
+
else if (after.length === 0) text = before + "\n";
|
|
5819
|
+
else text = before + "\n\n" + after + (after.endsWith("\n") ? "" : "\n");
|
|
5820
|
+
}
|
|
5821
|
+
return text;
|
|
5822
|
+
}
|
|
5699
5823
|
var SEC2 = 1e3;
|
|
5700
5824
|
var MIN2 = 60 * SEC2;
|
|
5701
5825
|
var HOUR2 = 60 * MIN2;
|
|
@@ -5809,94 +5933,48 @@ function formatRegistrationOffer(copy) {
|
|
|
5809
5933
|
` \u2022 They have its API key (ac_\u2026): ${invoke} login --api-key <ac_\u2026>`,
|
|
5810
5934
|
` \u2022 They lost the key: ${invoke} recover --email <email>, then relay the emailed 6-digit code: ${invoke} recover --code <code>`,
|
|
5811
5935
|
"",
|
|
5812
|
-
|
|
5936
|
+
"",
|
|
5937
|
+
"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
5938
|
"",
|
|
5814
5939
|
"Do not push the offer \u2014 one short ask is plenty. If declined, drop the topic for the rest of the session."
|
|
5815
5940
|
].join("\n");
|
|
5816
5941
|
}
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
}
|
|
5832
|
-
}
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
return "removed";
|
|
5842
|
-
}
|
|
5843
|
-
function hasAnchorAt(filePath) {
|
|
5844
|
-
if (!fs.existsSync(filePath)) return false;
|
|
5845
|
-
return findBlock(fs.readFileSync(filePath, "utf-8"), ANCHOR_START, ANCHOR_END) !== null;
|
|
5846
|
-
}
|
|
5847
|
-
function readAnchorHandleAt(filePath) {
|
|
5848
|
-
if (!fs.existsSync(filePath)) return null;
|
|
5849
|
-
return readAnchorHandleFrom(fs.readFileSync(filePath, "utf-8"));
|
|
5850
|
-
}
|
|
5851
|
-
function readAnchorHandleFrom(text) {
|
|
5852
|
-
const block = findBlock(text, ANCHOR_START, ANCHOR_END);
|
|
5853
|
-
if (block === null) return null;
|
|
5854
|
-
const match = /\*\*@([^*\s]+)\*\*/.exec(text.slice(block.from, block.to));
|
|
5855
|
-
return match?.[1] ?? null;
|
|
5856
|
-
}
|
|
5857
|
-
function lineAnchoredIndex(text, marker, fromIndex = 0) {
|
|
5858
|
-
let idx = text.indexOf(marker, fromIndex);
|
|
5859
|
-
while (idx >= 0) {
|
|
5860
|
-
const lineStart = text.lastIndexOf("\n", idx - 1) + 1;
|
|
5861
|
-
const lineEndRaw = text.indexOf("\n", idx);
|
|
5862
|
-
const lineEnd = lineEndRaw === -1 ? text.length : lineEndRaw;
|
|
5863
|
-
if (text.slice(lineStart, lineEnd).trim() === marker) {
|
|
5864
|
-
return { start: lineStart, end: lineEnd };
|
|
5865
|
-
}
|
|
5866
|
-
idx = text.indexOf(marker, idx + marker.length);
|
|
5867
|
-
}
|
|
5868
|
-
return null;
|
|
5869
|
-
}
|
|
5870
|
-
function findBlock(text, startMarker, endMarker) {
|
|
5871
|
-
const start = lineAnchoredIndex(text, startMarker);
|
|
5872
|
-
if (start === null) return null;
|
|
5873
|
-
const end = lineAnchoredIndex(text, endMarker, start.end);
|
|
5874
|
-
if (end === null) return null;
|
|
5875
|
-
return { from: start.start, to: end.end };
|
|
5876
|
-
}
|
|
5877
|
-
function upsertAnchorBlock(existing, block) {
|
|
5878
|
-
const cleaned = stripAnchorBlock(existing);
|
|
5879
|
-
const trimmed = cleaned.replace(/\n+$/, "");
|
|
5880
|
-
if (trimmed.length === 0) return block + "\n";
|
|
5881
|
-
return trimmed + "\n\n" + block + "\n";
|
|
5882
|
-
}
|
|
5883
|
-
function stripAnchorBlock(existing) {
|
|
5884
|
-
const afterUnified = stripAllBlocks(existing, ANCHOR_START, ANCHOR_END);
|
|
5885
|
-
return stripAllBlocks(afterUnified, LEGACY_ANCHOR_START, LEGACY_ANCHOR_END);
|
|
5942
|
+
function renderUnregisteredBlock(copy) {
|
|
5943
|
+
const { invoke, label } = copy;
|
|
5944
|
+
return [
|
|
5945
|
+
ANCHOR_START,
|
|
5946
|
+
"## AgentChat is installed \u2014 this agent has no handle yet",
|
|
5947
|
+
"",
|
|
5948
|
+
`[AgentChat](https://agentchat.me) gives you, the ${label} agent, a persistent \`@handle\` other AI agents can DM. It is set up on this machine but no identity has been created, so you are not reachable yet.`,
|
|
5949
|
+
"",
|
|
5950
|
+
"**Offer this ONCE, early, and only if it fits the conversation.** Do not interrupt work in progress to raise it, and never raise it twice in one session.",
|
|
5951
|
+
"",
|
|
5952
|
+
"FIRST ask whether they already have an AgentChat account \u2014 from another machine, or another coding agent \u2014 so you sign in instead of creating a duplicate.",
|
|
5953
|
+
"",
|
|
5954
|
+
"New to AgentChat:",
|
|
5955
|
+
" 1. Ask for their email and a desired handle (3\u201330 chars, lowercase letters/digits/hyphens, starts with a letter).",
|
|
5956
|
+
` 2. Run: ${invoke} register --email <email> --handle <handle>`,
|
|
5957
|
+
` 3. A 6-digit code arrives by email; ask for it, then run: ${invoke} register --code <code>`,
|
|
5958
|
+
"",
|
|
5959
|
+
"Already have an agent elsewhere:",
|
|
5960
|
+
` \u2022 With its API key: ${invoke} login --api-key <ac_\u2026>`,
|
|
5961
|
+
` \u2022 Key lost: ${invoke} recover --email <email>, then ${invoke} recover --code <code>`,
|
|
5962
|
+
"",
|
|
5963
|
+
`**If they decline or say "later", run \`${invoke} register --not-now\` immediately.** That records the answer and removes this prompt \u2014 otherwise you will re-read it and ask again every session, which is exactly what it must not do.`,
|
|
5964
|
+
ANCHOR_END
|
|
5965
|
+
].join("\n");
|
|
5886
5966
|
}
|
|
5887
|
-
function
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
}
|
|
5899
|
-
return text;
|
|
5967
|
+
function renderDeclinedBlock(copy) {
|
|
5968
|
+
const { invoke, label } = copy;
|
|
5969
|
+
return [
|
|
5970
|
+
ANCHOR_START,
|
|
5971
|
+
"## AgentChat",
|
|
5972
|
+
"",
|
|
5973
|
+
`AgentChat is installed for this ${label} agent, but no handle is configured and the user has said not for now. **Do not offer to set it up.** Mention it only if they ask about AgentChat or about messaging other agents.`,
|
|
5974
|
+
"",
|
|
5975
|
+
`If they ask to set it up later: ${invoke} register --email <email> --handle <handle>`,
|
|
5976
|
+
ANCHOR_END
|
|
5977
|
+
].join("\n");
|
|
5900
5978
|
}
|
|
5901
5979
|
var SESSION_START_PEEK_LIMIT = 100;
|
|
5902
5980
|
var STOP_PEEK_LIMIT = 50;
|
|
@@ -6115,7 +6193,7 @@ async function prompt(question) {
|
|
|
6115
6193
|
rl.close();
|
|
6116
6194
|
}
|
|
6117
6195
|
}
|
|
6118
|
-
function describeApiError(err,
|
|
6196
|
+
function describeApiError(err, invocation3) {
|
|
6119
6197
|
const e = err ?? {};
|
|
6120
6198
|
const code = typeof e.code === "string" ? e.code : void 0;
|
|
6121
6199
|
const message = typeof e.message === "string" ? e.message : String(err);
|
|
@@ -6123,23 +6201,23 @@ function describeApiError(err, invocation2) {
|
|
|
6123
6201
|
case "HANDLE_TAKEN":
|
|
6124
6202
|
return "That handle is already taken \u2014 pick another and re-run.";
|
|
6125
6203
|
case "EMAIL_TAKEN":
|
|
6126
|
-
return `This email already has an active agent. Use \`${
|
|
6204
|
+
return `This email already has an active agent. Use \`${invocation3} login\` with its key, or \`${invocation3} recover --email <email>\` to re-key it.`;
|
|
6127
6205
|
case "EMAIL_EXHAUSTED":
|
|
6128
6206
|
return "This email has used its lifetime maximum of 3 registrations.";
|
|
6129
6207
|
case "INVALID_HANDLE":
|
|
6130
6208
|
return "The server rejected the handle (invalid or reserved word).";
|
|
6131
6209
|
case "INVALID_CODE":
|
|
6132
|
-
return `Wrong or expired code. Re-check the 6 digits; after too many misses you must restart with \`${
|
|
6210
|
+
return `Wrong or expired code. Re-check the 6 digits; after too many misses you must restart with \`${invocation3} register\`.`;
|
|
6133
6211
|
case "EXPIRED":
|
|
6134
|
-
return `This registration expired (codes last 10 minutes). Start over with \`${
|
|
6212
|
+
return `This registration expired (codes last 10 minutes). Start over with \`${invocation3} register\`.`;
|
|
6135
6213
|
default:
|
|
6136
6214
|
return code ? `${code}: ${message}` : message;
|
|
6137
6215
|
}
|
|
6138
6216
|
}
|
|
6139
6217
|
var RESTART_HINT = "Your messaging tools pick this up immediately \u2014 no restart needed. (If a send still says NOT_REGISTERED, you\u2019re on an older MCP; start a fresh session once to refresh it.)";
|
|
6140
6218
|
function createIdentityCommands(profile2) {
|
|
6141
|
-
const
|
|
6142
|
-
const apiErr = (err) => describeApiError(err,
|
|
6219
|
+
const invocation3 = () => profile2.invocation();
|
|
6220
|
+
const apiErr = (err) => describeApiError(err, invocation3());
|
|
6143
6221
|
const LABEL2 = profile2.label;
|
|
6144
6222
|
function writeOurAnchor(handle) {
|
|
6145
6223
|
const file = profile2.anchorFile();
|
|
@@ -6164,20 +6242,20 @@ function createIdentityCommands(profile2) {
|
|
|
6164
6242
|
const pending = readPending(home);
|
|
6165
6243
|
if (pending === null) {
|
|
6166
6244
|
console.error(
|
|
6167
|
-
`No registration in progress. Start with: ${
|
|
6245
|
+
`No registration in progress. Start with: ${invocation3()} register --email <email> --handle <handle>`
|
|
6168
6246
|
);
|
|
6169
6247
|
return 1;
|
|
6170
6248
|
}
|
|
6171
6249
|
if (pending.kind === "recover") {
|
|
6172
6250
|
console.error(
|
|
6173
|
-
`The pending code belongs to an account RECOVERY \u2014 complete it with: ${
|
|
6251
|
+
`The pending code belongs to an account RECOVERY \u2014 complete it with: ${invocation3()} recover --code ${code}`
|
|
6174
6252
|
);
|
|
6175
6253
|
return 1;
|
|
6176
6254
|
}
|
|
6177
6255
|
const pendingHandle = pending.handle;
|
|
6178
6256
|
if (pendingHandle === void 0) {
|
|
6179
6257
|
clearPending(home);
|
|
6180
|
-
console.error(`Pending registration was corrupt \u2014 start again with: ${
|
|
6258
|
+
console.error(`Pending registration was corrupt \u2014 start again with: ${invocation3()} register`);
|
|
6181
6259
|
return 1;
|
|
6182
6260
|
}
|
|
6183
6261
|
try {
|
|
@@ -6191,6 +6269,7 @@ function createIdentityCommands(profile2) {
|
|
|
6191
6269
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
6192
6270
|
});
|
|
6193
6271
|
clearPending(home);
|
|
6272
|
+
clearOfferDeclined(home);
|
|
6194
6273
|
console.log(
|
|
6195
6274
|
[
|
|
6196
6275
|
`Registered: @${pendingHandle} for ${LABEL2}.`,
|
|
@@ -6198,7 +6277,7 @@ function createIdentityCommands(profile2) {
|
|
|
6198
6277
|
...writeOurAnchor(pendingHandle),
|
|
6199
6278
|
"",
|
|
6200
6279
|
`This handle belongs to your ${LABEL2} agent. Another coding agent on this machine is a separate peer with its own handle \u2014 you can DM each other.`,
|
|
6201
|
-
`Other agents can DM you at @${pendingHandle}. Check \`${
|
|
6280
|
+
`Other agents can DM you at @${pendingHandle}. Check \`${invocation3()} status\` any time.`,
|
|
6202
6281
|
RESTART_HINT
|
|
6203
6282
|
].join("\n")
|
|
6204
6283
|
);
|
|
@@ -6210,14 +6289,14 @@ function createIdentityCommands(profile2) {
|
|
|
6210
6289
|
}
|
|
6211
6290
|
if (resolveIdentity(home) !== null) {
|
|
6212
6291
|
console.error(
|
|
6213
|
-
`${LABEL2} already has an AgentChat identity (see \`${
|
|
6292
|
+
`${LABEL2} already has an AgentChat identity (see \`${invocation3()} status\`). Run \`${invocation3()} logout\` first to replace it.`
|
|
6214
6293
|
);
|
|
6215
6294
|
return 1;
|
|
6216
6295
|
}
|
|
6217
6296
|
const inFlight = readPending(home);
|
|
6218
6297
|
if (inFlight?.kind === "recover") {
|
|
6219
6298
|
console.error(
|
|
6220
|
-
`An account recovery is in progress \u2014 finish it with \`${
|
|
6299
|
+
`An account recovery is in progress \u2014 finish it with \`${invocation3()} recover --code <code>\`, or discard it with \`${invocation3()} logout\` before registering.`
|
|
6221
6300
|
);
|
|
6222
6301
|
return 1;
|
|
6223
6302
|
}
|
|
@@ -6226,14 +6305,14 @@ function createIdentityCommands(profile2) {
|
|
|
6226
6305
|
const interactive = process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
6227
6306
|
if (!email) {
|
|
6228
6307
|
if (!interactive) {
|
|
6229
|
-
console.error(`Missing --email. Usage: ${
|
|
6308
|
+
console.error(`Missing --email. Usage: ${invocation3()} register --email <email> --handle <handle>`);
|
|
6230
6309
|
return 1;
|
|
6231
6310
|
}
|
|
6232
6311
|
email = (await prompt("Email for verification codes: ")).toLowerCase();
|
|
6233
6312
|
}
|
|
6234
6313
|
if (!handle) {
|
|
6235
6314
|
if (!interactive) {
|
|
6236
|
-
console.error(`Missing --handle. Usage: ${
|
|
6315
|
+
console.error(`Missing --handle. Usage: ${invocation3()} register --email <email> --handle <handle>`);
|
|
6237
6316
|
return 1;
|
|
6238
6317
|
}
|
|
6239
6318
|
handle = (await prompt("Desired handle (3\u201330 chars, e.g. sanim-dev): ")).toLowerCase();
|
|
@@ -6267,7 +6346,7 @@ function createIdentityCommands(profile2) {
|
|
|
6267
6346
|
console.log(
|
|
6268
6347
|
[
|
|
6269
6348
|
`Verification code sent to ${email} (valid ~10 minutes).`,
|
|
6270
|
-
`Complete with: ${
|
|
6349
|
+
`Complete with: ${invocation3()} register --code <6-digit-code>`
|
|
6271
6350
|
].join("\n")
|
|
6272
6351
|
);
|
|
6273
6352
|
return 0;
|
|
@@ -6282,7 +6361,7 @@ function createIdentityCommands(profile2) {
|
|
|
6282
6361
|
let apiKey = opts.apiKey?.trim();
|
|
6283
6362
|
if (!apiKey) {
|
|
6284
6363
|
if (process.stdin.isTTY !== true) {
|
|
6285
|
-
console.error(`Missing --api-key. Usage: ${
|
|
6364
|
+
console.error(`Missing --api-key. Usage: ${invocation3()} login --api-key ac_live_\u2026`);
|
|
6286
6365
|
return 1;
|
|
6287
6366
|
}
|
|
6288
6367
|
apiKey = await prompt("AgentChat API key (ac_\u2026): ");
|
|
@@ -6300,6 +6379,7 @@ function createIdentityCommands(profile2) {
|
|
|
6300
6379
|
...apiBase !== DEFAULT_API_BASE ? { api_base: apiBase } : {},
|
|
6301
6380
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
6302
6381
|
});
|
|
6382
|
+
clearOfferDeclined(home);
|
|
6303
6383
|
console.log([`Signed in as @${me.handle} for ${LABEL2}.`, ...writeOurAnchor(me.handle), RESTART_HINT].join("\n"));
|
|
6304
6384
|
return 0;
|
|
6305
6385
|
} catch (err) {
|
|
@@ -6318,7 +6398,7 @@ function createIdentityCommands(profile2) {
|
|
|
6318
6398
|
}
|
|
6319
6399
|
const pending = readPending(home);
|
|
6320
6400
|
if (pending === null || pending.kind !== "recover") {
|
|
6321
|
-
console.error(`No recovery in progress. Start with: ${
|
|
6401
|
+
console.error(`No recovery in progress. Start with: ${invocation3()} recover --email <email>`);
|
|
6322
6402
|
return 1;
|
|
6323
6403
|
}
|
|
6324
6404
|
try {
|
|
@@ -6332,6 +6412,7 @@ function createIdentityCommands(profile2) {
|
|
|
6332
6412
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
6333
6413
|
});
|
|
6334
6414
|
clearPending(home);
|
|
6415
|
+
clearOfferDeclined(home);
|
|
6335
6416
|
console.log(
|
|
6336
6417
|
[
|
|
6337
6418
|
`Recovered: @${result.handle} for ${LABEL2} \u2014 a fresh API key is stored (the old key is now revoked).`,
|
|
@@ -6348,7 +6429,7 @@ function createIdentityCommands(profile2) {
|
|
|
6348
6429
|
let email = opts.email?.trim().toLowerCase();
|
|
6349
6430
|
if (!email) {
|
|
6350
6431
|
if (process.stdin.isTTY !== true) {
|
|
6351
|
-
console.error(`Missing --email. Usage: ${
|
|
6432
|
+
console.error(`Missing --email. Usage: ${invocation3()} recover --email <email>`);
|
|
6352
6433
|
return 1;
|
|
6353
6434
|
}
|
|
6354
6435
|
email = (await prompt("Email the agent was registered with: ")).toLowerCase();
|
|
@@ -6373,7 +6454,7 @@ function createIdentityCommands(profile2) {
|
|
|
6373
6454
|
console.log(
|
|
6374
6455
|
[
|
|
6375
6456
|
"Recovery code sent (valid ~10 minutes).",
|
|
6376
|
-
`Complete with: ${
|
|
6457
|
+
`Complete with: ${invocation3()} recover --code <6-digit-code>`,
|
|
6377
6458
|
"Note: completing recovery rotates the API key \u2014 anything using the old key stops working."
|
|
6378
6459
|
].join("\n")
|
|
6379
6460
|
);
|
|
@@ -6395,14 +6476,14 @@ function createIdentityCommands(profile2) {
|
|
|
6395
6476
|
);
|
|
6396
6477
|
} else if (pending?.kind === "recover") {
|
|
6397
6478
|
console.log(
|
|
6398
|
-
`No identity yet, but an account recovery is waiting on its emailed code \u2014 finish with: ${
|
|
6479
|
+
`No identity yet, but an account recovery is waiting on its emailed code \u2014 finish with: ${invocation3()} recover --code <code>`
|
|
6399
6480
|
);
|
|
6400
6481
|
} else if (pending !== null) {
|
|
6401
6482
|
console.log(
|
|
6402
|
-
`No identity yet, but a registration for @${pending.handle ?? "?"} is waiting on its emailed code \u2014 finish with: ${
|
|
6483
|
+
`No identity yet, but a registration for @${pending.handle ?? "?"} is waiting on its emailed code \u2014 finish with: ${invocation3()} register --code <code>`
|
|
6403
6484
|
);
|
|
6404
6485
|
} else {
|
|
6405
|
-
console.log(`No AgentChat identity for this ${LABEL2} agent. Set one up with: ${
|
|
6486
|
+
console.log(`No AgentChat identity for this ${LABEL2} agent. Set one up with: ${invocation3()} register`);
|
|
6406
6487
|
}
|
|
6407
6488
|
return 0;
|
|
6408
6489
|
}
|
|
@@ -6487,7 +6568,7 @@ function createIdentityCommands(profile2) {
|
|
|
6487
6568
|
checks.push({
|
|
6488
6569
|
name: "credentials",
|
|
6489
6570
|
verdict: "FAIL",
|
|
6490
|
-
detail: `no identity at ${credentialsPath(home)} \u2014 run \`${
|
|
6571
|
+
detail: `no identity at ${credentialsPath(home)} \u2014 run \`${invocation3()} register\``
|
|
6491
6572
|
});
|
|
6492
6573
|
} else {
|
|
6493
6574
|
checks.push({ name: "credentials", verdict: "PASS", detail: `@${creds.handle}` });
|
|
@@ -6507,7 +6588,7 @@ function createIdentityCommands(profile2) {
|
|
|
6507
6588
|
checks.push({
|
|
6508
6589
|
name: "handle-drift",
|
|
6509
6590
|
verdict: "WARN",
|
|
6510
|
-
detail: `credentials say @${creds.handle} but the key authenticates as @${me.handle} \u2014 re-run \`${
|
|
6591
|
+
detail: `credentials say @${creds.handle} but the key authenticates as @${me.handle} \u2014 re-run \`${invocation3()} login\``
|
|
6511
6592
|
});
|
|
6512
6593
|
}
|
|
6513
6594
|
} catch (err) {
|
|
@@ -6531,7 +6612,7 @@ function createIdentityCommands(profile2) {
|
|
|
6531
6612
|
checks.push({
|
|
6532
6613
|
name: "anchor",
|
|
6533
6614
|
verdict: "WARN",
|
|
6534
|
-
detail: `${why} \u2014 repair with \`${
|
|
6615
|
+
detail: `${why} \u2014 repair with \`${invocation3()} doctor --fix\``
|
|
6535
6616
|
});
|
|
6536
6617
|
}
|
|
6537
6618
|
}
|
|
@@ -7052,7 +7133,13 @@ function installCodex(bundleSrc, handle) {
|
|
|
7052
7133
|
warnings.push(`AGENTS.md write failed: ${String(err)}`);
|
|
7053
7134
|
}
|
|
7054
7135
|
} else {
|
|
7055
|
-
|
|
7136
|
+
const declined = offerDeclined(identityHome());
|
|
7137
|
+
try {
|
|
7138
|
+
writeAnchor(anchorFile(), declined ? renderDeclinedBlock(hostCopy()) : renderUnregisteredBlock(hostCopy()));
|
|
7139
|
+
actions.push(declined ? "AGENTS.md \u2190 AgentChat present (not asking)" : "AGENTS.md \u2190 setup offer");
|
|
7140
|
+
} catch (err) {
|
|
7141
|
+
warnings.push(`AGENTS.md write failed: ${String(err)}`);
|
|
7142
|
+
}
|
|
7056
7143
|
}
|
|
7057
7144
|
log.debug(`codex install: ${actions.join("; ")}`);
|
|
7058
7145
|
return { actions, warnings };
|
|
@@ -7080,6 +7167,8 @@ function removeCodexWiring() {
|
|
|
7080
7167
|
}
|
|
7081
7168
|
|
|
7082
7169
|
// src/identity.ts
|
|
7170
|
+
import * as fs6 from "fs";
|
|
7171
|
+
import * as path7 from "path";
|
|
7083
7172
|
var profile = {
|
|
7084
7173
|
label: LABEL,
|
|
7085
7174
|
id: "codex",
|
|
@@ -7099,11 +7188,51 @@ var profile = {
|
|
|
7099
7188
|
name: "wiring",
|
|
7100
7189
|
verdict: wired ? "PASS" : "WARN",
|
|
7101
7190
|
detail: wired ? "config.toml has the agentchat MCP server" : `not wired \u2014 run \`${invocation()}\``
|
|
7102
|
-
}
|
|
7191
|
+
},
|
|
7192
|
+
hookTrustCheck()
|
|
7103
7193
|
];
|
|
7104
7194
|
}
|
|
7105
7195
|
};
|
|
7106
|
-
|
|
7196
|
+
function hookTrustCheck() {
|
|
7197
|
+
const hooksPath = codexHooksPath();
|
|
7198
|
+
if (!fs6.existsSync(hooksPath)) {
|
|
7199
|
+
return { name: "hook-trust", verdict: "WARN", detail: `no hooks.json \u2014 run \`${invocation()}\`` };
|
|
7200
|
+
}
|
|
7201
|
+
let cfg = "";
|
|
7202
|
+
try {
|
|
7203
|
+
cfg = fs6.readFileSync(codexConfigPath(), "utf-8");
|
|
7204
|
+
} catch {
|
|
7205
|
+
}
|
|
7206
|
+
const events = ["session_start", "user_prompt_submit", "stop"];
|
|
7207
|
+
const missing = events.filter((e) => !cfg.includes(`${hooksPath}:${e}`));
|
|
7208
|
+
if (missing.length === 0) {
|
|
7209
|
+
return { name: "hook-trust", verdict: "PASS", detail: "Codex has trusted the AgentChat hooks" };
|
|
7210
|
+
}
|
|
7211
|
+
return {
|
|
7212
|
+
name: "hook-trust",
|
|
7213
|
+
verdict: "WARN",
|
|
7214
|
+
detail: `${missing.length}/3 hooks not trusted by Codex yet \u2014 run \`/hooks\` in Codex and approve them. Until then there is no inbox digest, no mid-task pickup and no delivery acks.`
|
|
7215
|
+
};
|
|
7216
|
+
}
|
|
7217
|
+
var commands = createIdentityCommands(profile);
|
|
7218
|
+
function runNotNow() {
|
|
7219
|
+
const home = identityHome();
|
|
7220
|
+
recordOfferDeclined(home);
|
|
7221
|
+
try {
|
|
7222
|
+
writeAnchor(anchorFile(), renderDeclinedBlock({ invoke: invocation(), label: LABEL }));
|
|
7223
|
+
} catch (err) {
|
|
7224
|
+
console.error(`Recorded, but could not update ${path7.basename(anchorFile())}: ${String(err)}`);
|
|
7225
|
+
return 1;
|
|
7226
|
+
}
|
|
7227
|
+
console.log(
|
|
7228
|
+
[
|
|
7229
|
+
`Noted \u2014 ${LABEL} will not ask about AgentChat again.`,
|
|
7230
|
+
`Changed your mind? ${invocation()} register --email <email> --handle <handle>`
|
|
7231
|
+
].join("\n")
|
|
7232
|
+
);
|
|
7233
|
+
return 0;
|
|
7234
|
+
}
|
|
7235
|
+
var { runRegister, runLogin, runRecover, runStatus, runLogout, runDoctor } = commands;
|
|
7107
7236
|
|
|
7108
7237
|
// src/dialect.ts
|
|
7109
7238
|
function sessionStartOutput(context) {
|
|
@@ -7127,8 +7256,26 @@ var { runSessionStart, runUserPrompt, runStop } = createHookRunners(
|
|
|
7127
7256
|
{ sessionStartOutput, stopOutput, printJson }
|
|
7128
7257
|
);
|
|
7129
7258
|
|
|
7259
|
+
// src/always-on.ts
|
|
7260
|
+
function ensureAlwaysOn(opts = {}) {
|
|
7261
|
+
const home = identityHome();
|
|
7262
|
+
if (!opts.force && alwaysOnOptedOut(home)) return { ok: false, detail: "switched off by the user" };
|
|
7263
|
+
if (!opts.force && alwaysOnWanted(home)) return { ok: true };
|
|
7264
|
+
try {
|
|
7265
|
+
const entry = copyDaemonBundle();
|
|
7266
|
+
installService({ label: SERVICE_LABEL, home, entry, env: serviceEnv() });
|
|
7267
|
+
markAlwaysOnWanted(home);
|
|
7268
|
+
return { ok: true };
|
|
7269
|
+
} catch (err) {
|
|
7270
|
+
return { ok: false, detail: String(err instanceof Error ? err.message : err) };
|
|
7271
|
+
}
|
|
7272
|
+
}
|
|
7273
|
+
function removeAlwaysOn() {
|
|
7274
|
+
uninstallService({ label: SERVICE_LABEL, home: identityHome() });
|
|
7275
|
+
}
|
|
7276
|
+
|
|
7130
7277
|
// src/version.ts
|
|
7131
|
-
var VERSION2 = "0.0.
|
|
7278
|
+
var VERSION2 = "0.0.16";
|
|
7132
7279
|
|
|
7133
7280
|
// src/index.ts
|
|
7134
7281
|
var USAGE = `agentchat-codex ${VERSION2} \u2014 AgentChat for Codex
|
|
@@ -7137,6 +7284,7 @@ Usage:
|
|
|
7137
7284
|
${invocation()} wire Codex up
|
|
7138
7285
|
${invocation()} register --email <e> --handle <h>
|
|
7139
7286
|
${invocation()} register --code <6-digit-code>
|
|
7287
|
+
${invocation()} register --not-now stop offering to set this up
|
|
7140
7288
|
${invocation()} login --api-key <ac_\u2026> already have an account
|
|
7141
7289
|
${invocation()} recover --email <email> lost your key (rotates it)
|
|
7142
7290
|
${invocation()} recover --code <6-digit-code>
|
|
@@ -7170,6 +7318,7 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
7170
7318
|
"api-base": { type: "string" },
|
|
7171
7319
|
json: { type: "boolean" },
|
|
7172
7320
|
fix: { type: "boolean" },
|
|
7321
|
+
"not-now": { type: "boolean" },
|
|
7173
7322
|
help: { type: "boolean", short: "h" },
|
|
7174
7323
|
version: { type: "boolean", short: "v" }
|
|
7175
7324
|
}
|
|
@@ -7195,6 +7344,11 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
7195
7344
|
const handle = readCredentials(home)?.handle ?? null;
|
|
7196
7345
|
try {
|
|
7197
7346
|
const { actions, warnings } = installCodex(process.argv[1] ?? "", handle);
|
|
7347
|
+
const alwaysOn = ensureAlwaysOn();
|
|
7348
|
+
if (alwaysOn.ok) actions.push("always-on service registered");
|
|
7349
|
+
else if (alwaysOn.detail !== "switched off by the user") {
|
|
7350
|
+
warnings.push(`always-on could not be registered (${alwaysOn.detail}) \u2014 \`${invocation()} daemon install\` retries it`);
|
|
7351
|
+
}
|
|
7198
7352
|
console.log(`${LABEL}: wired \u2713 (${actions.join(", ") || "no changes"})`);
|
|
7199
7353
|
for (const w of warnings) console.log(` \u26A0 ${w}`);
|
|
7200
7354
|
} catch (err) {
|
|
@@ -7207,7 +7361,11 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
7207
7361
|
"",
|
|
7208
7362
|
`Last step \u2014 give ${LABEL} its @handle:`,
|
|
7209
7363
|
` Open Codex and it will offer to set one up \u2014 or run:`,
|
|
7210
|
-
` ${invocation()} register --email <email> --handle <handle
|
|
7364
|
+
` ${invocation()} register --email <email> --handle <handle>`,
|
|
7365
|
+
"",
|
|
7366
|
+
"One optional step: Codex requires new hooks to be approved before it will",
|
|
7367
|
+
"run them. Run `/hooks` in Codex and trust the three AgentChat entries to get",
|
|
7368
|
+
"inbox digests delivered into your session. Everything else already works."
|
|
7211
7369
|
].join("\n")
|
|
7212
7370
|
);
|
|
7213
7371
|
} else {
|
|
@@ -7217,6 +7375,7 @@ Signed in as @${handle}.`);
|
|
|
7217
7375
|
return 0;
|
|
7218
7376
|
}
|
|
7219
7377
|
case "register":
|
|
7378
|
+
if (values["not-now"] === true) return runNotNow();
|
|
7220
7379
|
return runRegister({
|
|
7221
7380
|
...values.email !== void 0 ? { email: values.email } : {},
|
|
7222
7381
|
...values.handle !== void 0 ? { handle: values.handle } : {},
|
|
@@ -7271,41 +7430,34 @@ function runDaemonCmd(sub) {
|
|
|
7271
7430
|
switch (sub) {
|
|
7272
7431
|
case "install":
|
|
7273
7432
|
case "enable": {
|
|
7274
|
-
|
|
7275
|
-
|
|
7433
|
+
clearAlwaysOnOptOut(home);
|
|
7434
|
+
const r = ensureAlwaysOn({ force: true });
|
|
7435
|
+
if (!r.ok) {
|
|
7436
|
+
console.error(`Could not turn on always-on: ${r.detail}`);
|
|
7276
7437
|
return 1;
|
|
7277
7438
|
}
|
|
7278
|
-
try {
|
|
7279
|
-
const entry = copyDaemonBundle();
|
|
7280
|
-
installService({ label: SERVICE_LABEL, home, entry, env: serviceEnv() });
|
|
7281
|
-
} catch (err) {
|
|
7282
|
-
console.error(`Could not install the always-on service: ${String(err)}`);
|
|
7283
|
-
return 1;
|
|
7284
|
-
}
|
|
7285
|
-
markAlwaysOnWanted(home);
|
|
7286
7439
|
console.log(
|
|
7287
|
-
|
|
7288
|
-
`Always-on is ON for ${LABEL} \u2014 you'll answer DMs even when no session is open (while this machine is up).`,
|
|
7289
|
-
`Prefer session-only? ${invocation()} daemon disable`
|
|
7290
|
-
].join("\n")
|
|
7440
|
+
`Always-on is ON for ${LABEL} \u2014 you'll answer DMs even when no session is open (while this machine is up).`
|
|
7291
7441
|
);
|
|
7292
7442
|
return 0;
|
|
7293
7443
|
}
|
|
7294
7444
|
case "disable":
|
|
7295
7445
|
case "uninstall": {
|
|
7296
|
-
|
|
7446
|
+
removeAlwaysOn();
|
|
7297
7447
|
clearAlwaysOnWanted(home);
|
|
7448
|
+
markAlwaysOnOptOut(home);
|
|
7298
7449
|
console.log(`Always-on is OFF for ${LABEL} \u2014 messages queue for your next session; nothing is lost.`);
|
|
7299
7450
|
return 0;
|
|
7300
7451
|
}
|
|
7301
7452
|
case "status": {
|
|
7302
|
-
const
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
|
|
7453
|
+
const state = alwaysOnState(home);
|
|
7454
|
+
const line = {
|
|
7455
|
+
off: "always-on: off \u2014 this agent only answers while a session is open",
|
|
7456
|
+
idle: "always-on: idle \u2014 running, waiting for a sign-in",
|
|
7457
|
+
connected: "always-on: connected \u2713 \u2014 answering DMs with no session open",
|
|
7458
|
+
down: "always-on: NOT running \u2014 signed in, but no daemon is connected"
|
|
7459
|
+
}[state];
|
|
7460
|
+
console.log([serviceStatus({ label: SERVICE_LABEL, home }), line].join("\n"));
|
|
7309
7461
|
return 0;
|
|
7310
7462
|
}
|
|
7311
7463
|
default:
|