pantheon-cli 0.3.0 → 0.3.2
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/pantheon.mjs +79 -9
- package/package.json +1 -1
package/dist/pantheon.mjs
CHANGED
|
@@ -45901,6 +45901,7 @@ function readMeta(home, slug) {
|
|
|
45901
45901
|
if (key === "members") inMembers = true;
|
|
45902
45902
|
if (key === "topic") meta.topic = value.trim();
|
|
45903
45903
|
if (key === "own" && value.trim()) meta.own = value.trim();
|
|
45904
|
+
if (key === "kind" && value.trim() === "dm") meta.kind = "dm";
|
|
45904
45905
|
if (key === "created_at") meta.createdAt = value.trim();
|
|
45905
45906
|
if (key === "updated_at") meta.updatedAt = value.trim();
|
|
45906
45907
|
}
|
|
@@ -45915,6 +45916,7 @@ function writeMeta2(home, meta) {
|
|
|
45915
45916
|
"members:",
|
|
45916
45917
|
...meta.members.map((member2) => ` - ${member2}`),
|
|
45917
45918
|
...meta.own ? [`own: ${meta.own}`] : [],
|
|
45919
|
+
...meta.kind ? [`kind: ${meta.kind}`] : [],
|
|
45918
45920
|
`created_at: ${meta.createdAt}`,
|
|
45919
45921
|
`updated_at: ${meta.updatedAt}`,
|
|
45920
45922
|
""
|
|
@@ -46019,6 +46021,7 @@ function listChannels(home) {
|
|
|
46019
46021
|
topic: meta.topic,
|
|
46020
46022
|
members: meta.members,
|
|
46021
46023
|
...meta.own ? { own: meta.own } : {},
|
|
46024
|
+
...meta.kind ? { kind: meta.kind } : {},
|
|
46022
46025
|
messages: count,
|
|
46023
46026
|
updatedAt: meta.updatedAt || (existsSync6(log2) ? statSync3(log2).mtime.toISOString() : meta.createdAt)
|
|
46024
46027
|
}
|
|
@@ -46126,6 +46129,47 @@ function ensureChannelSpace(home, name) {
|
|
|
46126
46129
|
touch(home, meta);
|
|
46127
46130
|
return { channel: meta.slug, space: slug, created };
|
|
46128
46131
|
}
|
|
46132
|
+
var MAX_EMOJI = 16;
|
|
46133
|
+
function editMessage(home, name, id, edit) {
|
|
46134
|
+
const meta = requireChannel(home, name);
|
|
46135
|
+
const path = join6(channelDir(home, meta.slug), "messages.jsonl");
|
|
46136
|
+
const parsed = (existsSync6(path) ? readFileSync6(path, "utf8").split("\n") : []).filter((line) => line.trim()).map((line) => {
|
|
46137
|
+
try {
|
|
46138
|
+
return JSON.parse(line);
|
|
46139
|
+
} catch {
|
|
46140
|
+
return line;
|
|
46141
|
+
}
|
|
46142
|
+
});
|
|
46143
|
+
const all = parsed.filter((item) => typeof item !== "string");
|
|
46144
|
+
const target = all.find((message) => message.id === id);
|
|
46145
|
+
if (!target) throw new Error(`No message ${oneLine(id, 64)} in #${meta.slug}.`);
|
|
46146
|
+
const next = edit(target, all);
|
|
46147
|
+
const lines = parsed.flatMap((item) => {
|
|
46148
|
+
if (typeof item === "string") return [item];
|
|
46149
|
+
if (item.id !== id) return [JSON.stringify(item)];
|
|
46150
|
+
return next ? [JSON.stringify(next)] : [];
|
|
46151
|
+
});
|
|
46152
|
+
writeFileSync5(path, lines.length ? `${lines.join("\n")}
|
|
46153
|
+
` : "");
|
|
46154
|
+
touch(home, meta);
|
|
46155
|
+
return { channel: meta.slug, message: next ? { ...next, text: sanitizeText(next.text) } : null };
|
|
46156
|
+
}
|
|
46157
|
+
function reactToChannelMessage(home, name, id, input) {
|
|
46158
|
+
const emoji2 = (input.emoji || "").trim();
|
|
46159
|
+
if (!emoji2 || emoji2.length > MAX_EMOJI || /[\s<>]/.test(emoji2)) throw new Error("React with one emoji, like \u{1F44D}.");
|
|
46160
|
+
const who = !input.by || input.by === "you" ? "you" : resolveAgentRef(home, input.by).space;
|
|
46161
|
+
return editMessage(home, name, id, (message) => {
|
|
46162
|
+
const reactions = { ...message.reactions ?? {} };
|
|
46163
|
+
const people = new Set(reactions[emoji2] ?? []);
|
|
46164
|
+
if (input.remove) people.delete(who);
|
|
46165
|
+
else people.add(who);
|
|
46166
|
+
if (people.size) reactions[emoji2] = [...people];
|
|
46167
|
+
else delete reactions[emoji2];
|
|
46168
|
+
const next = { ...message, reactions };
|
|
46169
|
+
if (!Object.keys(reactions).length) delete next.reactions;
|
|
46170
|
+
return next;
|
|
46171
|
+
});
|
|
46172
|
+
}
|
|
46129
46173
|
function noteChannelHandoff(home, name, input) {
|
|
46130
46174
|
const meta = requireChannel(home, name);
|
|
46131
46175
|
const message = appendMessage(home, meta.slug, {
|
|
@@ -46138,11 +46182,15 @@ function noteChannelHandoff(home, name, input) {
|
|
|
46138
46182
|
touch(home, meta);
|
|
46139
46183
|
return message;
|
|
46140
46184
|
}
|
|
46185
|
+
function isDecision(text2) {
|
|
46186
|
+
return /^\s*(?:\*\*)?(?:decision|decided)(?:\*\*)?\s*[:\-–—]/i.test(text2) || /^\s*we(?:'ve| have)? decided\b/i.test(text2);
|
|
46187
|
+
}
|
|
46141
46188
|
function postChannelMessage(home, name, input) {
|
|
46142
46189
|
const meta = requireChannel(home, name);
|
|
46143
46190
|
const text2 = (input.text || "").trim();
|
|
46144
46191
|
if (!text2) throw new Error("Nothing to post. Pass the message text.");
|
|
46145
46192
|
const thread = threadFor(home, meta.slug, input);
|
|
46193
|
+
const remember = Boolean(input.remember) || isDecision(text2);
|
|
46146
46194
|
let agent;
|
|
46147
46195
|
if (input.by === "agent") {
|
|
46148
46196
|
if (!input.agent) throw new Error("Posting as an agent needs that agent's @name.");
|
|
@@ -46161,9 +46209,9 @@ function postChannelMessage(home, name, input) {
|
|
|
46161
46209
|
...evidence.length ? { evidence } : {},
|
|
46162
46210
|
...input.replyTo ? { replyTo: oneLine(input.replyTo, 64) } : {},
|
|
46163
46211
|
...thread ? { thread } : {},
|
|
46164
|
-
...
|
|
46212
|
+
...remember ? { remembered: true } : {}
|
|
46165
46213
|
});
|
|
46166
|
-
if (
|
|
46214
|
+
if (remember) {
|
|
46167
46215
|
appendFileSync2(join6(channelDir(home, meta.slug), "memory.md"), `- ${oneLine(text2, 1e3)}
|
|
46168
46216
|
`);
|
|
46169
46217
|
}
|
|
@@ -46195,12 +46243,20 @@ function mentionedAgents(home, text2) {
|
|
|
46195
46243
|
function channelOpenQuestions(home, slug, messages = readMessages(home, slug)) {
|
|
46196
46244
|
const answered = /* @__PURE__ */ new Map();
|
|
46197
46245
|
for (const message of messages) {
|
|
46246
|
+
for (const who of Object.values(message.reactions ?? {}).flat()) {
|
|
46247
|
+
if (who === "you") continue;
|
|
46248
|
+
const set2 = answered.get(message.id) ?? /* @__PURE__ */ new Set();
|
|
46249
|
+
set2.add(who);
|
|
46250
|
+
answered.set(message.id, set2);
|
|
46251
|
+
}
|
|
46198
46252
|
if (message.kind !== "answer" || !message.replyTo || !message.agent) continue;
|
|
46199
46253
|
const set = answered.get(message.replyTo) ?? /* @__PURE__ */ new Set();
|
|
46200
46254
|
set.add(message.agent);
|
|
46201
46255
|
answered.set(message.replyTo, set);
|
|
46202
46256
|
}
|
|
46203
46257
|
const byId = new Map(messages.map((message) => [message.id, message]));
|
|
46258
|
+
const meta = readMeta(home, slug);
|
|
46259
|
+
const direct = meta?.kind === "dm" ? meta.members : null;
|
|
46204
46260
|
const talking = /* @__PURE__ */ new Map();
|
|
46205
46261
|
const noteTakers = /* @__PURE__ */ new Map();
|
|
46206
46262
|
const isNoteTaker = (space) => {
|
|
@@ -46226,9 +46282,9 @@ function channelOpenQuestions(home, slug, messages = readMessages(home, slug)) {
|
|
|
46226
46282
|
if (!list.includes(message.agent)) list.push(message.agent);
|
|
46227
46283
|
return [];
|
|
46228
46284
|
}
|
|
46229
|
-
if (message.kind !== "post" || message.by !== "human") return [];
|
|
46285
|
+
if (message.kind !== "post" || message.by !== "human" || message.deleted) return [];
|
|
46230
46286
|
const mentioned2 = mentionedAgents(home, message.text);
|
|
46231
|
-
const asked = mentioned2.length
|
|
46287
|
+
const asked = mentioned2.length ? mentioned2 : direct ? direct : thread ? (talking.get(thread) ?? []).filter((agent) => !isNoteTaker(agent)) : [];
|
|
46232
46288
|
const waiting = asked.filter((agent) => !answered.get(message.id)?.has(agent));
|
|
46233
46289
|
return waiting.length ? [
|
|
46234
46290
|
{
|
|
@@ -48268,7 +48324,7 @@ function captureNeedsTranscript(error2) {
|
|
|
48268
48324
|
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
48269
48325
|
return message.includes("No local conversation history was found") || message.includes("does not expose this conversation record");
|
|
48270
48326
|
}
|
|
48271
|
-
function handoffQualityReceipt(written, sync2) {
|
|
48327
|
+
function handoffQualityReceipt(written, sync2, agent) {
|
|
48272
48328
|
const providerSkipped = sync2.skipped ?? [];
|
|
48273
48329
|
const suppliedCoverageUnknown = !written.capturedFrom;
|
|
48274
48330
|
const incomplete = written.truncated || written.skippedTotal > 0 || providerSkipped.length > 0 || sync2.ok === false;
|
|
@@ -48323,6 +48379,7 @@ function handoffQualityReceipt(written, sync2) {
|
|
|
48323
48379
|
explanation: incomplete ? "A percentage is not shown because Pantheon cannot honestly quantify unknown or omitted context." : suppliedCoverageUnknown ? "The destination confirmed persistence, but the calling agent supplied the visible turns, so Pantheon cannot independently measure transcript coverage." : "All discovered conversation data and artifacts were captured and the destination confirmed persistence."
|
|
48324
48380
|
},
|
|
48325
48381
|
destination,
|
|
48382
|
+
handedOffTo: agent ? `${agent.name} (${agent.handle})${agent.channel ? `, the history of ${agent.channel}` : ""}` : null,
|
|
48326
48383
|
conversationSafe: written.turns > 0,
|
|
48327
48384
|
readyForResume: written.turns > 0 && sync2.ok !== false,
|
|
48328
48385
|
capturedFrom: written.capturedFrom,
|
|
@@ -48330,6 +48387,14 @@ function handoffQualityReceipt(written, sync2) {
|
|
|
48330
48387
|
actions: incomplete ? ["retry", "view_issue"] : []
|
|
48331
48388
|
};
|
|
48332
48389
|
}
|
|
48390
|
+
function receivingAgent(home, slug, channel) {
|
|
48391
|
+
try {
|
|
48392
|
+
const name = listSpaces(home).find((space) => space.slug === slug)?.agent?.name || slug;
|
|
48393
|
+
return { name, handle: `@${slug}`, ...channel ? { channel: `#${channel}` } : {} };
|
|
48394
|
+
} catch {
|
|
48395
|
+
return void 0;
|
|
48396
|
+
}
|
|
48397
|
+
}
|
|
48333
48398
|
function fail(error2) {
|
|
48334
48399
|
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
48335
48400
|
return {
|
|
@@ -48733,7 +48798,7 @@ ${GUIDE}` }]
|
|
|
48733
48798
|
registerTool(
|
|
48734
48799
|
server,
|
|
48735
48800
|
"pantheon_handoff",
|
|
48736
|
-
"Archive this chat into a Pantheon space. Trigger: /pantheon-handoff <space>; a new name creates the space. /pantheon-handoff #channel adds the chat to that channel's own history instead, so resuming the channel anywhere includes it. First call: omit transcript, transcriptFile, and transcriptFallback so Pantheon can try verified automatic capture for this client. If the result is transcript_required, tell the human in one line that you are including the conversation visible to you, then retry with the same space and attachments, transcriptFallback:true, and every visible user and assistant message copied verbatim in order (truncated:true if earlier turns are gone). If it is capture_first_required, retry once without transcript fields. Use append:true when re-sending the same chat. Attach every existing generated or uploaded file \u2014 { name, path } locally, { name, url } remotely, base64 only as a fallback \u2014 and never create a file just for the handoff. When turns were added, process the skill review and say which drafts you saved. Then report the handoffQuality receipt: lead with HANDOFF RESULTS; show complete or incomplete, turns and Tool calls captured, artifacts, decisions and unresolved issues, integrity, destination, and readiness for resume. If incomplete, list every issue and whether the conversation itself is safe; never invent an integrity percentage.",
|
|
48801
|
+
"Archive this chat into a Pantheon space. Trigger: /pantheon-handoff <space>; a new name creates the space. /pantheon-handoff #channel adds the chat to that channel's own history instead, so resuming the channel anywhere includes it. First call: omit transcript, transcriptFile, and transcriptFallback so Pantheon can try verified automatic capture for this client. If the result is transcript_required, tell the human in one line that you are including the conversation visible to you, then retry with the same space and attachments, transcriptFallback:true, and every visible user and assistant message copied verbatim in order (truncated:true if earlier turns are gone). If it is capture_first_required, retry once without transcript fields. Use append:true when re-sending the same chat. Attach every existing generated or uploaded file \u2014 { name, path } locally, { name, url } remotely, base64 only as a fallback \u2014 and never create a file just for the handoff. When turns were added, process the skill review and say which drafts you saved. Then report the handoffQuality receipt: lead with HANDOFF RESULTS; show complete or incomplete, the agent it was handed off to (handedOffTo), turns and Tool calls captured, artifacts, decisions and unresolved issues, integrity, destination, and readiness for resume. If incomplete, list every issue and whether the conversation itself is safe; never invent an integrity percentage.",
|
|
48737
48802
|
{
|
|
48738
48803
|
space: external_exports.string(),
|
|
48739
48804
|
source: external_exports.string().optional(),
|
|
@@ -48872,7 +48937,7 @@ ${GUIDE}` }]
|
|
|
48872
48937
|
...channelTarget ? { channel: channelTarget, note: `Added to #${channelTarget}'s own history. Resume #${channelTarget} anywhere to continue with it.` } : {},
|
|
48873
48938
|
sync: sync2,
|
|
48874
48939
|
storageSkipped: sync2.skipped ?? [],
|
|
48875
|
-
handoffQuality: handoffQualityReceipt(written, sync2),
|
|
48940
|
+
handoffQuality: handoffQualityReceipt(written, sync2, receivingAgent(home, written.slug, channelTarget)),
|
|
48876
48941
|
skillReview: review,
|
|
48877
48942
|
skillReviewAction: !shouldReview ? null : {
|
|
48878
48943
|
requiresAgentJudgment: true,
|
|
@@ -49207,9 +49272,9 @@ ${GUIDE}` }]
|
|
|
49207
49272
|
registerTool(
|
|
49208
49273
|
server,
|
|
49209
49274
|
"pantheon_channel",
|
|
49210
|
-
"Channels group handoff agents. action list: every channel. read: a channel's members, memory and latest messages. create: a new #name, optionally with agents and a topic. add: merge agents into a channel, so questions there search all of them; nothing is copied, and remove undoes it. remove: take one agent out. post: add a message, only when the human asks to post or record something; remember:true also saves it to the channel memory every resume loads; as_agent with evidence and reply_to posts an agent's answer to an open question (it lands in the question's thread when there is one); thread posts as a reply under that message. read and resume list openQuestions: posts that @mention an agent, or reply in a thread an agent is part of, that it has not answered yet. Messages carry thread when they are thread replies. Messages are visible in the Pantheon app.",
|
|
49275
|
+
"Channels group handoff agents. action list: every channel. read: a channel's members, memory and latest messages. create: a new #name, optionally with agents and a topic. add: merge agents into a channel, so questions there search all of them; nothing is copied, and remove undoes it. remove: take one agent out. post: add a message, only when the human asks to post or record something; remember:true also saves it to the channel memory every resume loads; as_agent with evidence and reply_to posts an agent's answer to an open question (it lands in the question's thread when there is one); thread posts as a reply under that message. read and resume list openQuestions: posts that @mention an agent, or reply in a thread an agent is part of, that it has not answered yet. Messages carry thread when they are thread replies. A channel of kind dm (named dm-<agent>) is the human's direct line to one agent: every post there asks that agent. react: put one emoji (text) on the message reply_to, as_agent for the agent; when a post only needs an acknowledgement (thanks, ok, done), react instead of posting, which also answers it. Messages are visible in the Pantheon app.",
|
|
49211
49276
|
{
|
|
49212
|
-
action: external_exports.enum(["list", "read", "create", "add", "remove", "post"]),
|
|
49277
|
+
action: external_exports.enum(["list", "read", "create", "add", "remove", "post", "react"]),
|
|
49213
49278
|
channel: external_exports.string().trim().max(65).optional().describe("#name. Required for every action except list."),
|
|
49214
49279
|
agents: external_exports.array(external_exports.string().trim().min(1).max(130)).max(20).optional().describe("@agents to create the channel with, add, or (one) remove."),
|
|
49215
49280
|
topic: external_exports.string().max(300).optional().describe("One line on what the channel is for (create only)."),
|
|
@@ -49243,6 +49308,11 @@ ${GUIDE}` }]
|
|
|
49243
49308
|
if (!agents?.length) throw new Error("Name the agent to remove, like @preorders.");
|
|
49244
49309
|
return removeChannelMember(home, channel, agents[0], { via });
|
|
49245
49310
|
}
|
|
49311
|
+
if (action === "react") {
|
|
49312
|
+
if (!reply_to) throw new Error("Name the message to react to with reply_to.");
|
|
49313
|
+
if (!text2) throw new Error("Pass the emoji as text, like \u{1F44D}.");
|
|
49314
|
+
return reactToChannelMessage(home, channel, reply_to, { emoji: text2, ...as_agent ? { by: as_agent } : {} });
|
|
49315
|
+
}
|
|
49246
49316
|
if (!text2) throw new Error("Nothing to post. Pass text.");
|
|
49247
49317
|
return postChannelMessage(home, channel, {
|
|
49248
49318
|
text: text2,
|
package/package.json
CHANGED