@integrity-labs/agt-cli 0.27.119 → 0.27.121
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/bin/agt.js +3 -3
- package/dist/{chunk-SUSXP7ZY.js → chunk-PMBWORBQ.js} +1 -1
- package/dist/lib/manager-worker.js +93 -6
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/mcp/slack-channel.js +167 -1
- package/package.json +1 -1
- /package/dist/{chunk-SUSXP7ZY.js.map → chunk-PMBWORBQ.js.map} +0 -0
|
@@ -15266,6 +15266,165 @@ function buildSafeInboundPath2(codeName, fileId, mimetype) {
|
|
|
15266
15266
|
return buildSafeInboundPath(resolveSlackInboundDir(codeName), fileId, mimetype);
|
|
15267
15267
|
}
|
|
15268
15268
|
|
|
15269
|
+
// src/slack-rich-text.ts
|
|
15270
|
+
var MAX_DEPTH = 12;
|
|
15271
|
+
function isRecord(v) {
|
|
15272
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
15273
|
+
}
|
|
15274
|
+
function asString(v) {
|
|
15275
|
+
return typeof v === "string" ? v : "";
|
|
15276
|
+
}
|
|
15277
|
+
function asArray(v) {
|
|
15278
|
+
return Array.isArray(v) ? v : [];
|
|
15279
|
+
}
|
|
15280
|
+
function isTableElement(el) {
|
|
15281
|
+
return isRecord(el) && asString(el.type).includes("table");
|
|
15282
|
+
}
|
|
15283
|
+
function renderEmoji(el) {
|
|
15284
|
+
const unicode = asString(el.unicode);
|
|
15285
|
+
if (unicode) {
|
|
15286
|
+
try {
|
|
15287
|
+
const cps = unicode.split("-").map((h) => parseInt(h, 16));
|
|
15288
|
+
if (cps.every((n) => Number.isFinite(n) && n >= 0 && n <= 1114111)) {
|
|
15289
|
+
return String.fromCodePoint(...cps);
|
|
15290
|
+
}
|
|
15291
|
+
} catch {
|
|
15292
|
+
}
|
|
15293
|
+
}
|
|
15294
|
+
const name = asString(el.name);
|
|
15295
|
+
return name ? `:${name}:` : "";
|
|
15296
|
+
}
|
|
15297
|
+
function renderLeaf(el) {
|
|
15298
|
+
if (!isRecord(el)) return "";
|
|
15299
|
+
switch (asString(el.type)) {
|
|
15300
|
+
case "text":
|
|
15301
|
+
return asString(el.text);
|
|
15302
|
+
case "link": {
|
|
15303
|
+
const label = asString(el.text);
|
|
15304
|
+
const url = asString(el.url);
|
|
15305
|
+
if (label && url && label !== url) return `${label} (${url})`;
|
|
15306
|
+
return label || url;
|
|
15307
|
+
}
|
|
15308
|
+
case "emoji":
|
|
15309
|
+
return renderEmoji(el);
|
|
15310
|
+
case "user":
|
|
15311
|
+
return `<@${asString(el.user_id)}>`;
|
|
15312
|
+
case "usergroup":
|
|
15313
|
+
return `<!subteam^${asString(el.usergroup_id)}>`;
|
|
15314
|
+
case "channel":
|
|
15315
|
+
return `<#${asString(el.channel_id)}>`;
|
|
15316
|
+
case "broadcast":
|
|
15317
|
+
return `@${asString(el.range) || "channel"}`;
|
|
15318
|
+
case "date":
|
|
15319
|
+
return asString(el.fallback) || asString(el.timestamp);
|
|
15320
|
+
default:
|
|
15321
|
+
if (Array.isArray(el.elements)) return renderInline(el.elements);
|
|
15322
|
+
return asString(el.text);
|
|
15323
|
+
}
|
|
15324
|
+
}
|
|
15325
|
+
function renderInline(elements) {
|
|
15326
|
+
return elements.map(renderLeaf).join("");
|
|
15327
|
+
}
|
|
15328
|
+
function deepText(node, depth) {
|
|
15329
|
+
if (depth > MAX_DEPTH) return "";
|
|
15330
|
+
if (typeof node === "string") return node;
|
|
15331
|
+
if (Array.isArray(node)) return node.map((n) => deepText(n, depth + 1)).join("");
|
|
15332
|
+
if (!isRecord(node)) return "";
|
|
15333
|
+
const type = asString(node.type);
|
|
15334
|
+
if (type && type !== "rich_text" && !type.startsWith("rich_text_") && !type.includes("table")) {
|
|
15335
|
+
return renderLeaf(node);
|
|
15336
|
+
}
|
|
15337
|
+
if (Array.isArray(node.elements)) return node.elements.map((n) => deepText(n, depth + 1)).join("");
|
|
15338
|
+
if (Array.isArray(node.rows)) return node.rows.map((n) => deepText(n, depth + 1)).join(" ");
|
|
15339
|
+
return asString(node.text);
|
|
15340
|
+
}
|
|
15341
|
+
function renderCell(cell) {
|
|
15342
|
+
if (!isRecord(cell)) return deepText(cell, 0).replace(/\s*\n\s*/g, " ").trim();
|
|
15343
|
+
const inner = Array.isArray(cell.elements) ? renderSection(cell, 0) : deepText(cell, 0);
|
|
15344
|
+
return inner.replace(/\s*\n\s*/g, " ").trim();
|
|
15345
|
+
}
|
|
15346
|
+
function renderTable(el) {
|
|
15347
|
+
const rawRows = asArray(el.elements).length ? asArray(el.elements) : asArray(el.rows);
|
|
15348
|
+
const rows = [];
|
|
15349
|
+
for (const row of rawRows) {
|
|
15350
|
+
if (!isRecord(row) && !Array.isArray(row)) continue;
|
|
15351
|
+
const rawCells = Array.isArray(row) ? row : asArray(row.elements).length ? asArray(row.elements) : asArray(row.cells);
|
|
15352
|
+
if (rawCells.length === 0) continue;
|
|
15353
|
+
rows.push(rawCells.map(renderCell));
|
|
15354
|
+
}
|
|
15355
|
+
if (rows.length === 0) {
|
|
15356
|
+
const fallback = deepText(el, 0).replace(/[ \t]+\n/g, "\n").trim();
|
|
15357
|
+
return fallback;
|
|
15358
|
+
}
|
|
15359
|
+
const colCount = rows.reduce((max, r) => Math.max(max, r.length), 0);
|
|
15360
|
+
const pad = (r) => {
|
|
15361
|
+
const cells = r.slice();
|
|
15362
|
+
while (cells.length < colCount) cells.push("");
|
|
15363
|
+
return cells.map((c) => c.replace(/\|/g, "\\|"));
|
|
15364
|
+
};
|
|
15365
|
+
const lines = [];
|
|
15366
|
+
const header = rows[0] ?? [];
|
|
15367
|
+
const body = rows.slice(1);
|
|
15368
|
+
lines.push(`| ${pad(header).join(" | ")} |`);
|
|
15369
|
+
lines.push(`| ${Array.from({ length: colCount }, () => "---").join(" | ")} |`);
|
|
15370
|
+
for (const r of body) lines.push(`| ${pad(r).join(" | ")} |`);
|
|
15371
|
+
return lines.join("\n");
|
|
15372
|
+
}
|
|
15373
|
+
function renderSection(section, depth) {
|
|
15374
|
+
if (depth > MAX_DEPTH || !isRecord(section)) return "";
|
|
15375
|
+
const type = asString(section.type);
|
|
15376
|
+
if (isTableElement(section)) return renderTable(section);
|
|
15377
|
+
switch (type) {
|
|
15378
|
+
case "rich_text_section":
|
|
15379
|
+
return renderInline(asArray(section.elements));
|
|
15380
|
+
case "rich_text_preformatted": {
|
|
15381
|
+
const code = renderInline(asArray(section.elements));
|
|
15382
|
+
return code ? `\`\`\`
|
|
15383
|
+
${code}
|
|
15384
|
+
\`\`\`` : "";
|
|
15385
|
+
}
|
|
15386
|
+
case "rich_text_quote": {
|
|
15387
|
+
const quoted = renderInline(asArray(section.elements));
|
|
15388
|
+
return quoted ? quoted.split("\n").map((l) => `> ${l}`).join("\n") : "";
|
|
15389
|
+
}
|
|
15390
|
+
case "rich_text_list": {
|
|
15391
|
+
const ordered = asString(section.style) === "ordered";
|
|
15392
|
+
const items = asArray(section.elements).map((item, i) => {
|
|
15393
|
+
const body = renderSection(item, depth + 1) || renderInline(asArray(item?.elements));
|
|
15394
|
+
const marker = ordered ? `${i + 1}.` : "-";
|
|
15395
|
+
return `${marker} ${body}`.trimEnd();
|
|
15396
|
+
});
|
|
15397
|
+
return items.join("\n");
|
|
15398
|
+
}
|
|
15399
|
+
default:
|
|
15400
|
+
if (Array.isArray(section.elements)) return renderInline(asArray(section.elements));
|
|
15401
|
+
return deepText(section, depth + 1);
|
|
15402
|
+
}
|
|
15403
|
+
}
|
|
15404
|
+
function renderSlackBlocks(blocks) {
|
|
15405
|
+
let hadTable = false;
|
|
15406
|
+
const out = [];
|
|
15407
|
+
try {
|
|
15408
|
+
for (const block of asArray(blocks)) {
|
|
15409
|
+
if (!isRecord(block) || asString(block.type) !== "rich_text") continue;
|
|
15410
|
+
for (const section of asArray(block.elements)) {
|
|
15411
|
+
if (isTableElement(section)) hadTable = true;
|
|
15412
|
+
const rendered = renderSection(section, 0);
|
|
15413
|
+
if (rendered.trim().length > 0) out.push(rendered);
|
|
15414
|
+
}
|
|
15415
|
+
}
|
|
15416
|
+
} catch {
|
|
15417
|
+
}
|
|
15418
|
+
const text = out.join("\n\n").replace(/[ \t]+$/gm, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
15419
|
+
return { text, hadTable };
|
|
15420
|
+
}
|
|
15421
|
+
function mergeInboundText(text, blocks) {
|
|
15422
|
+
const { text: rendered, hadTable } = renderSlackBlocks(blocks);
|
|
15423
|
+
if (!hadTable) return { content: text, recoveredTable: false };
|
|
15424
|
+
const content = rendered.length > 0 ? rendered : text;
|
|
15425
|
+
return { content, recoveredTable: rendered.length > 0 && content !== text };
|
|
15426
|
+
}
|
|
15427
|
+
|
|
15269
15428
|
// src/slack-response-mode.ts
|
|
15270
15429
|
var MODES = [
|
|
15271
15430
|
"mention_only",
|
|
@@ -18788,10 +18947,17 @@ async function connectSocketMode() {
|
|
|
18788
18947
|
);
|
|
18789
18948
|
}
|
|
18790
18949
|
}
|
|
18950
|
+
const { content: inboundContent, recoveredTable } = mergeInboundText(text, evt.blocks);
|
|
18951
|
+
if (recoveredTable) {
|
|
18952
|
+
process.stderr.write(
|
|
18953
|
+
`slack-channel(${AGENT_CODE_NAME}): recovered rich_text table from blocks (channel=${redactSlackId(channel)} ts=${redactSlackId(ts)})
|
|
18954
|
+
`
|
|
18955
|
+
);
|
|
18956
|
+
}
|
|
18791
18957
|
await mcp.notification({
|
|
18792
18958
|
method: "notifications/claude/channel",
|
|
18793
18959
|
params: {
|
|
18794
|
-
content:
|
|
18960
|
+
content: inboundContent,
|
|
18795
18961
|
meta: {
|
|
18796
18962
|
user,
|
|
18797
18963
|
user_name: userName,
|
package/package.json
CHANGED
|
File without changes
|