@agentdocumentformat/cli 0.7.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/LICENSE +21 -0
- package/README.md +45 -0
- package/dist/adf.mjs +162 -0
- package/dist/chunks/APEv2Parser-2CNNHMXV.mjs +22 -0
- package/dist/chunks/AiffParser-7BR4RL6G.mjs +162 -0
- package/dist/chunks/App-L5L37JI5.mjs +16747 -0
- package/dist/chunks/AsfParser-VVRSLFOM.mjs +538 -0
- package/dist/chunks/DsdiffParser-CMD4AX7A.mjs +156 -0
- package/dist/chunks/DsfParser-UOGZDS2M.mjs +94 -0
- package/dist/chunks/FlacParser-HB3T3CD4.mjs +23 -0
- package/dist/chunks/MP4Parser-66HBRUSX.mjs +973 -0
- package/dist/chunks/MatroskaParser-J3HUIMEW.mjs +579 -0
- package/dist/chunks/MpegParser-YW6LIUEW.mjs +442 -0
- package/dist/chunks/MusepackParser-PAUSXP7D.mjs +252 -0
- package/dist/chunks/OggParser-NUBV3GWC.mjs +359 -0
- package/dist/chunks/WavPackParser-WQAGT7TC.mjs +171 -0
- package/dist/chunks/WaveParser-EWLQVDX4.mjs +238 -0
- package/dist/chunks/adf-schema-JRU2BTOG.mjs +62 -0
- package/dist/chunks/build-QF5W473T.mjs +60 -0
- package/dist/chunks/chatgpt-subscription-BQGWYZXE.mjs +23 -0
- package/dist/chunks/chunk-2DIECGFL.mjs +6 -0
- package/dist/chunks/chunk-2NAP2ZF7.mjs +60 -0
- package/dist/chunks/chunk-3AT7IIP7.mjs +25696 -0
- package/dist/chunks/chunk-3GNIDM53.mjs +35 -0
- package/dist/chunks/chunk-3M4ZPOA3.mjs +1477 -0
- package/dist/chunks/chunk-4MQPTCXY.mjs +510 -0
- package/dist/chunks/chunk-5PO5PKRV.mjs +366 -0
- package/dist/chunks/chunk-5QU5VY7N.mjs +52 -0
- package/dist/chunks/chunk-5W7KES6P.mjs +436 -0
- package/dist/chunks/chunk-62NE4LG4.mjs +61 -0
- package/dist/chunks/chunk-64OKE4X3.mjs +45 -0
- package/dist/chunks/chunk-6GJ4QHRI.mjs +1278 -0
- package/dist/chunks/chunk-6VQEXLE2.mjs +144 -0
- package/dist/chunks/chunk-6XUV6EK6.mjs +41 -0
- package/dist/chunks/chunk-776TSXEP.mjs +43 -0
- package/dist/chunks/chunk-7CV2SA3H.mjs +285 -0
- package/dist/chunks/chunk-7MTRVW2U.mjs +3103 -0
- package/dist/chunks/chunk-7N2R2VCG.mjs +1434 -0
- package/dist/chunks/chunk-7T2YMTWL.mjs +374 -0
- package/dist/chunks/chunk-7XYNI52E.mjs +149 -0
- package/dist/chunks/chunk-APHX6HSV.mjs +7731 -0
- package/dist/chunks/chunk-APRU6PHC.mjs +40 -0
- package/dist/chunks/chunk-AUYKRQPJ.mjs +499 -0
- package/dist/chunks/chunk-DXWDD5XJ.mjs +136 -0
- package/dist/chunks/chunk-EWL5FG4I.mjs +39 -0
- package/dist/chunks/chunk-EYX2YLJW.mjs +117 -0
- package/dist/chunks/chunk-F5ELW46V.mjs +27 -0
- package/dist/chunks/chunk-G426FACA.mjs +49 -0
- package/dist/chunks/chunk-GEKSJHIV.mjs +2472 -0
- package/dist/chunks/chunk-HBUENVQL.mjs +570 -0
- package/dist/chunks/chunk-HPVFJYXR.mjs +112 -0
- package/dist/chunks/chunk-HWLWPXQ7.mjs +721 -0
- package/dist/chunks/chunk-I2HJYHFT.mjs +665 -0
- package/dist/chunks/chunk-I3UYSITV.mjs +68 -0
- package/dist/chunks/chunk-IC4JDZCI.mjs +3864 -0
- package/dist/chunks/chunk-IHDDCZBS.mjs +112 -0
- package/dist/chunks/chunk-IIGMZHQQ.mjs +10416 -0
- package/dist/chunks/chunk-KWFOS5WC.mjs +41 -0
- package/dist/chunks/chunk-LAZIXV2F.mjs +5290 -0
- package/dist/chunks/chunk-LFMB4PAA.mjs +10814 -0
- package/dist/chunks/chunk-M2RX3S2T.mjs +49 -0
- package/dist/chunks/chunk-M3WPIJYM.mjs +65 -0
- package/dist/chunks/chunk-NBTUWMGP.mjs +263 -0
- package/dist/chunks/chunk-NGK6PVSF.mjs +2676 -0
- package/dist/chunks/chunk-NZ7JTHEO.mjs +85 -0
- package/dist/chunks/chunk-OQN33RGQ.mjs +52 -0
- package/dist/chunks/chunk-RIX34QHC.mjs +2935 -0
- package/dist/chunks/chunk-SGUTYISF.mjs +16 -0
- package/dist/chunks/chunk-SLJ5L7PY.mjs +1473 -0
- package/dist/chunks/chunk-SLUKGXKH.mjs +68 -0
- package/dist/chunks/chunk-TMT32MXT.mjs +419 -0
- package/dist/chunks/chunk-UYY5M2PB.mjs +151 -0
- package/dist/chunks/chunk-VAUOM3IN.mjs +298 -0
- package/dist/chunks/chunk-VMHTYDH4.mjs +172 -0
- package/dist/chunks/chunk-VZS54AA5.mjs +200 -0
- package/dist/chunks/chunk-WFQUVXML.mjs +295 -0
- package/dist/chunks/chunk-X34PDRUH.mjs +809 -0
- package/dist/chunks/chunk-XNPZBLYL.mjs +33 -0
- package/dist/chunks/chunk-XX7OSWTO.mjs +157 -0
- package/dist/chunks/chunk-XYTWGHFS.mjs +600 -0
- package/dist/chunks/chunk-XYV3VCIX.mjs +336 -0
- package/dist/chunks/chunk-Y5ZLKFLE.mjs +1469 -0
- package/dist/chunks/chunk-ZJKXHM4Q.mjs +230 -0
- package/dist/chunks/cli-TCMBNZF6.mjs +1030 -0
- package/dist/chunks/commands-DTEKM4ZL.mjs +20 -0
- package/dist/chunks/daemon-ZC3FZ2P4.mjs +112449 -0
- package/dist/chunks/daemon-control-WDX7PMTC.mjs +300 -0
- package/dist/chunks/daemon-token-WRSULP7G.mjs +23 -0
- package/dist/chunks/devtools-H7CI2ZVG.mjs +85 -0
- package/dist/chunks/discord-IWDQJA7A.mjs +70588 -0
- package/dist/chunks/dist-C57KYFS2.mjs +4952 -0
- package/dist/chunks/dist-I3XBAGDL.mjs +11 -0
- package/dist/chunks/email-V4Q4VJON.mjs +58679 -0
- package/dist/chunks/environment-NX277MQG.mjs +15 -0
- package/dist/chunks/grok-subscription-4PYX7TBF.mjs +19 -0
- package/dist/chunks/layout-EPJQNFAI.mjs +22 -0
- package/dist/chunks/lib-N7FCZWKH.mjs +4038 -0
- package/dist/chunks/open-OTQDGDH5.mjs +36 -0
- package/dist/chunks/parser-JVY2PWSM.mjs +19 -0
- package/dist/chunks/pipeline-executor-BHBSJX2K.mjs +19 -0
- package/dist/chunks/react-IUIDQ5LX.mjs +11 -0
- package/dist/chunks/screen-54BUTYCW.mjs +27 -0
- package/dist/chunks/slack-3L5QTDZX.mjs +8113 -0
- package/dist/chunks/store-WR7TZJZS.mjs +32 -0
- package/dist/chunks/telegram-5ISVFBV3.mjs +14918 -0
- package/dist/chunks/terminal-O5WO7C5U.mjs +48 -0
- package/dist/chunks/theme-NORU4J74.mjs +20 -0
- package/dist/chunks/themes-F2FKU7CP.mjs +23 -0
- package/dist/chunks/token-6G3HCMNX.mjs +54 -0
- package/dist/chunks/token-util-UXYSDQIW.mjs +12 -0
- package/dist/chunks/tui-ODVYUIMT.mjs +197 -0
- package/dist/chunks/welcome-XHXFV7SH.mjs +32 -0
- package/dist/chunks/whatsapp-XSAMNGPJ.mjs +85412 -0
- package/dist/chunks/xterm-headless-YF53XWXE.mjs +3353 -0
- package/package.json +53 -0
- package/resources/wasm/coreutils.LICENSE +18 -0
- package/resources/wasm/coreutils.wasm +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { createRequire as __adfCreateRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __adfFileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __adfDirname } from 'node:path';
|
|
4
|
+
const require = __adfCreateRequire(import.meta.url);
|
|
5
|
+
const __filename = __adfFileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = __adfDirname(__filename);
|
|
7
|
+
import {
|
|
8
|
+
createTheme
|
|
9
|
+
} from "./chunk-EYX2YLJW.mjs";
|
|
10
|
+
|
|
11
|
+
// src/main/tui/commands/builtin/themes.ts
|
|
12
|
+
var ADF_DARK = { ...createTheme({ mono: !1, env: {} }).color }, ADF_LIGHT = {
|
|
13
|
+
text: "#2B2925",
|
|
14
|
+
muted: "#6B6456",
|
|
15
|
+
dim: "#A39C8E",
|
|
16
|
+
accent: "#A8641A",
|
|
17
|
+
live: "#1F7A70",
|
|
18
|
+
loop: "#6A4BB0",
|
|
19
|
+
user: "#A8641A",
|
|
20
|
+
assistant: "#2B2925",
|
|
21
|
+
thinking: "#8A8476",
|
|
22
|
+
tool: "#2F6DA8",
|
|
23
|
+
success: "#3F7F3A",
|
|
24
|
+
warn: "#9A6A00",
|
|
25
|
+
error: "#B83232",
|
|
26
|
+
info: "#2F6DA8",
|
|
27
|
+
border: "#C9C2B2",
|
|
28
|
+
borderFocus: "#A8641A",
|
|
29
|
+
selectionFg: "#FFFDF7",
|
|
30
|
+
selectionBg: "#A8641A",
|
|
31
|
+
surface: "#EFEADF",
|
|
32
|
+
overlay: "#F7F3EA"
|
|
33
|
+
}, ADF_CONTRAST = {
|
|
34
|
+
...ADF_DARK,
|
|
35
|
+
text: "#F2EEE4",
|
|
36
|
+
muted: "#C4BDAE",
|
|
37
|
+
dim: "#8C8577",
|
|
38
|
+
border: "#7A7466",
|
|
39
|
+
thinking: "#A8A294"
|
|
40
|
+
}, THEMES = [
|
|
41
|
+
{ name: "adf", label: "ADF dark", description: "Ink & parchment on a dark terminal (default)", colors: ADF_DARK },
|
|
42
|
+
{ name: "adf-light", label: "ADF light", description: "Ink on paper, for light terminal backgrounds", colors: ADF_LIGHT },
|
|
43
|
+
{ name: "adf-contrast", label: "ADF high contrast", description: "Brighter text and borders on dark backgrounds", colors: ADF_CONTRAST },
|
|
44
|
+
{ name: "adf-mono", label: "Mono", description: "No color (like NO_COLOR): bold and inverse carry emphasis", colors: void 0 }
|
|
45
|
+
], ALIASES = { dark: "adf", default: "adf", light: "adf-light", contrast: "adf-contrast", mono: "adf-mono", "no-color": "adf-mono" };
|
|
46
|
+
function findTheme(name) {
|
|
47
|
+
let wanted = name.trim().toLowerCase();
|
|
48
|
+
return THEMES.find((t) => t.name === (ALIASES[wanted] ?? wanted));
|
|
49
|
+
}
|
|
50
|
+
function nextThemeName(current) {
|
|
51
|
+
let at = THEMES.findIndex((t) => t.name === current);
|
|
52
|
+
return THEMES[(at + 1) % THEMES.length].name;
|
|
53
|
+
}
|
|
54
|
+
var MONO_COLORS = Object.fromEntries(Object.keys(ADF_DARK).map((k) => [k, void 0]));
|
|
55
|
+
function applyTheme(theme, choice) {
|
|
56
|
+
theme.name = choice.name, theme.mono = choice.colors === void 0, theme.color = { ...choice.colors ?? MONO_COLORS };
|
|
57
|
+
}
|
|
58
|
+
function themeNames() {
|
|
59
|
+
return THEMES.map((t) => t.name);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export {
|
|
63
|
+
THEMES,
|
|
64
|
+
findTheme,
|
|
65
|
+
nextThemeName,
|
|
66
|
+
applyTheme,
|
|
67
|
+
themeNames
|
|
68
|
+
};
|
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
import { createRequire as __adfCreateRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __adfFileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __adfDirname } from 'node:path';
|
|
4
|
+
const require = __adfCreateRequire(import.meta.url);
|
|
5
|
+
const __filename = __adfFileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = __adfDirname(__filename);
|
|
7
|
+
import {
|
|
8
|
+
classifyRedirectTarget,
|
|
9
|
+
parseBracedExpansion,
|
|
10
|
+
unsupportedDevTargetMessage
|
|
11
|
+
} from "./chunk-5W7KES6P.mjs";
|
|
12
|
+
import {
|
|
13
|
+
resolveWithDefault
|
|
14
|
+
} from "./chunk-HPVFJYXR.mjs";
|
|
15
|
+
import {
|
|
16
|
+
EXIT,
|
|
17
|
+
enforceToolGate,
|
|
18
|
+
err,
|
|
19
|
+
evaluateCommand,
|
|
20
|
+
evaluateToolNames,
|
|
21
|
+
getCommand,
|
|
22
|
+
notifyToolCallObservers,
|
|
23
|
+
shellReadFile
|
|
24
|
+
} from "./chunk-7MTRVW2U.mjs";
|
|
25
|
+
|
|
26
|
+
// src/main/tools/shell/executor/pipeline-executor.ts
|
|
27
|
+
function vfsPath(p) {
|
|
28
|
+
return p === "." || p === "./" || p === "/" ? "" : p.replace(/^\.\//, "").replace(/^\//, "");
|
|
29
|
+
}
|
|
30
|
+
var MAX_SHELL_DEPTH = 50;
|
|
31
|
+
async function guardCommand(cmd, ctx) {
|
|
32
|
+
let gate = ctx.gate;
|
|
33
|
+
if (!gate) return { blocked: null, observed: [] };
|
|
34
|
+
let evalr = evaluateCommand(cmd, ctx.config), blocked = await enforceToolGate(evalr, gate, ctx.config, gate.command ?? cmd.name);
|
|
35
|
+
return { blocked, observed: blocked ? [] : evalr.intercepted };
|
|
36
|
+
}
|
|
37
|
+
async function executeNode(node, stdin, ctx) {
|
|
38
|
+
if (ctx.signal?.aborted)
|
|
39
|
+
return err("shell: aborted", 130);
|
|
40
|
+
if (node.kind === "pipeline")
|
|
41
|
+
return executePipeline(node, stdin, ctx);
|
|
42
|
+
let sequence = [];
|
|
43
|
+
{
|
|
44
|
+
let op = null, cur = node;
|
|
45
|
+
for (; cur.kind === "chain"; )
|
|
46
|
+
sequence.push({ op, pipeline: cur.left }), op = cur.operator, cur = cur.right;
|
|
47
|
+
sequence.push({ op, pipeline: cur });
|
|
48
|
+
}
|
|
49
|
+
let combine = (left, right) => {
|
|
50
|
+
let media = [...left.media ?? [], ...right.media ?? []], endTurn = left.end_turn || right.end_turn, targetState = right.target_state ?? left.target_state;
|
|
51
|
+
return {
|
|
52
|
+
exit_code: right.exit_code,
|
|
53
|
+
stdout: left.stdout && right.stdout ? left.stdout + `
|
|
54
|
+
` + right.stdout : left.stdout || right.stdout,
|
|
55
|
+
stderr: left.stderr && right.stderr ? left.stderr + `
|
|
56
|
+
` + right.stderr : left.stderr || right.stderr,
|
|
57
|
+
...media.length > 0 ? { media } : {},
|
|
58
|
+
...endTurn ? { end_turn: !0 } : {},
|
|
59
|
+
...targetState ? { target_state: targetState } : {}
|
|
60
|
+
};
|
|
61
|
+
}, acc = null, lastExit = 0, nextStdin = stdin;
|
|
62
|
+
for (let { op, pipeline } of sequence) {
|
|
63
|
+
if (ctx.signal?.aborted)
|
|
64
|
+
return err("shell: aborted", 130);
|
|
65
|
+
if (op === "&&" && lastExit !== 0 || op === "||" && lastExit === 0) continue;
|
|
66
|
+
let result = await executePipeline(pipeline, nextStdin, ctx);
|
|
67
|
+
nextStdin = "", lastExit = result.exit_code, acc = acc ? combine(acc, result) : result;
|
|
68
|
+
}
|
|
69
|
+
return acc ?? { exit_code: 0, stdout: "", stderr: "" };
|
|
70
|
+
}
|
|
71
|
+
async function executePipeline(pipeline, initialStdin, ctx) {
|
|
72
|
+
if (pipeline.stages.length === 0)
|
|
73
|
+
return { exit_code: 0, stdout: "", stderr: "" };
|
|
74
|
+
let currentStdin = initialStdin, lastResult = { exit_code: 0, stdout: "", stderr: "" }, media = [], endTurn = !1, targetState, finish = (result) => ({
|
|
75
|
+
...result,
|
|
76
|
+
...media.length > 0 ? { media } : {},
|
|
77
|
+
...endTurn ? { end_turn: !0 } : {},
|
|
78
|
+
...targetState ? { target_state: targetState } : {}
|
|
79
|
+
});
|
|
80
|
+
for (let cmd of pipeline.stages) {
|
|
81
|
+
if (ctx.signal?.aborted)
|
|
82
|
+
return err("shell: aborted", 130);
|
|
83
|
+
if (lastResult = await executeCommand(cmd, currentStdin, ctx), ctx.env.setLastExitCode(lastResult.exit_code), lastResult.media && media.push(...lastResult.media), lastResult.end_turn && (endTurn = !0, targetState = lastResult.target_state ?? targetState), PIPELINE_FATAL_CODES.has(lastResult.exit_code) && lastResult.stderr !== "")
|
|
84
|
+
return finish(lastResult);
|
|
85
|
+
currentStdin = lastResult.stdout;
|
|
86
|
+
}
|
|
87
|
+
return finish(lastResult);
|
|
88
|
+
}
|
|
89
|
+
var PIPELINE_FATAL_CODES = /* @__PURE__ */ new Set([124, 126, 127, 130]), RESERVED_CONTROL_WORDS = /* @__PURE__ */ new Set([
|
|
90
|
+
"for",
|
|
91
|
+
"while",
|
|
92
|
+
"until",
|
|
93
|
+
"if",
|
|
94
|
+
"then",
|
|
95
|
+
"else",
|
|
96
|
+
"elif",
|
|
97
|
+
"fi",
|
|
98
|
+
"do",
|
|
99
|
+
"done",
|
|
100
|
+
"case",
|
|
101
|
+
"esac",
|
|
102
|
+
"select",
|
|
103
|
+
"function"
|
|
104
|
+
]);
|
|
105
|
+
async function executeCommand(cmd, stdin, ctx) {
|
|
106
|
+
let name = cmd.name, liveConfig = ctx.getConfig ?? ctx.gate?.getConfig;
|
|
107
|
+
if (liveConfig && (ctx = { ...ctx, config: liveConfig() }), RESERVED_CONTROL_WORDS.has(name))
|
|
108
|
+
return err(`${name}: control flow is not supported in adf_shell \u2014 use xargs, or a .js script for loops`, 2);
|
|
109
|
+
let firstArg = cmd.args[0];
|
|
110
|
+
if (firstArg?.type === "literal" && (firstArg.value === "-h" || firstArg.value === "--help")) {
|
|
111
|
+
let helpHandler = getCommand(name);
|
|
112
|
+
if (helpHandler)
|
|
113
|
+
return { exit_code: 0, stdout: helpHandler.helpText, stderr: "" };
|
|
114
|
+
}
|
|
115
|
+
let { blocked, observed } = await guardCommand(cmd, ctx);
|
|
116
|
+
if (blocked) return applyGateFailureRedirects(blocked, cmd, ctx);
|
|
117
|
+
let observe = (result2) => (observed.length > 0 && ctx.gate && notifyToolCallObservers(observed, ctx.gate, ctx.config, ctx.gate.command ?? cmd.name), result2);
|
|
118
|
+
if (cmd.assignments?.length) {
|
|
119
|
+
let vars = {};
|
|
120
|
+
for (let a of cmd.assignments) {
|
|
121
|
+
let parts = await Promise.all(a.value.map((p) => resolveArg(p, ctx)));
|
|
122
|
+
vars[a.name] = parts.join("");
|
|
123
|
+
}
|
|
124
|
+
if (!name) {
|
|
125
|
+
for (let [k, v] of Object.entries(vars)) ctx.env.export(k, v);
|
|
126
|
+
return { exit_code: 0, stdout: "", stderr: "" };
|
|
127
|
+
}
|
|
128
|
+
ctx = { ...ctx, env: ctx.env.withOverlay(vars) };
|
|
129
|
+
}
|
|
130
|
+
let redirects = [];
|
|
131
|
+
for (let r of cmd.redirects) {
|
|
132
|
+
if (r.type === "dup" || r.type === "discard") {
|
|
133
|
+
redirects.push(r);
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
let target = r.target;
|
|
137
|
+
if (target === void 0 && r.targetNode && (target = await resolveArg(r.targetNode, ctx)), target === void 0) continue;
|
|
138
|
+
let special = classifyRedirectTarget(target);
|
|
139
|
+
if (special === "null") {
|
|
140
|
+
redirects.push({ type: "discard", fd: r.type === "in" ? 0 : r.fd ?? 1 });
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (special)
|
|
144
|
+
return err(`${name}: ${unsupportedDevTargetMessage(special)}`, 2);
|
|
145
|
+
redirects.push({ ...r, target });
|
|
146
|
+
}
|
|
147
|
+
for (let r of redirects) {
|
|
148
|
+
if (r.type === "in" && r.target !== void 0) {
|
|
149
|
+
let [redirectContent, redirectErr] = await shellReadFile(ctx.toolRegistry, ctx.workspace, vfsPath(r.target));
|
|
150
|
+
if (redirectErr)
|
|
151
|
+
return err(`${name}: ${redirectErr}`);
|
|
152
|
+
stdin = redirectContent;
|
|
153
|
+
}
|
|
154
|
+
r.type === "discard" && r.fd === 0 && (stdin = "");
|
|
155
|
+
}
|
|
156
|
+
cmd.heredoc && (stdin = cmd.heredoc.quoted ? cmd.heredoc.content : expandHeredocVars(cmd.heredoc.content, ctx.env));
|
|
157
|
+
let resolvedArgs = await resolveArgs(cmd.args, ctx);
|
|
158
|
+
if (resolvedArgs.length > 0 && (resolvedArgs[0] === "-h" || resolvedArgs[0] === "--help")) {
|
|
159
|
+
let handler2 = getCommand(name);
|
|
160
|
+
if (handler2)
|
|
161
|
+
return { exit_code: 0, stdout: handler2.helpText, stderr: "" };
|
|
162
|
+
}
|
|
163
|
+
if (name === "echo") {
|
|
164
|
+
let args = resolvedArgs, interpretEscapes = !1, noTrailingNewline = !1;
|
|
165
|
+
for (; args.length > 0 && (args[0] === "-e" || args[0] === "-n" || args[0] === "-en" || args[0] === "-ne"); )
|
|
166
|
+
args[0].includes("e") && (interpretEscapes = !0), args[0].includes("n") && (noTrailingNewline = !0), args = args.slice(1);
|
|
167
|
+
let output = args.join(" ");
|
|
168
|
+
return interpretEscapes && (output = output.replace(/\\n/g, `
|
|
169
|
+
`).replace(/\\t/g, " ").replace(/\\r/g, "\r").replace(/\\\\/g, "\\")), noTrailingNewline || (output += `
|
|
170
|
+
`), observe(await applyRedirects({ exit_code: 0, stdout: output, stderr: "" }, redirects, ctx));
|
|
171
|
+
}
|
|
172
|
+
if (name.startsWith("./") || name.startsWith("/")) {
|
|
173
|
+
let handler2 = getCommand("./");
|
|
174
|
+
if (handler2) {
|
|
175
|
+
let cmdCtx2 = buildCommandContext([name, ...resolvedArgs], stdin, ctx, handler2.valueFlags), result2 = await handler2.execute(cmdCtx2);
|
|
176
|
+
return observe(await applyRedirects(result2, redirects, ctx));
|
|
177
|
+
}
|
|
178
|
+
return err(`${name}: command not found`, EXIT.NOT_FOUND);
|
|
179
|
+
}
|
|
180
|
+
let handler = getCommand(name);
|
|
181
|
+
if (!handler)
|
|
182
|
+
return err(`${name}: command not found`, EXIT.NOT_FOUND);
|
|
183
|
+
let cmdCtx = buildCommandContext(resolvedArgs, stdin, ctx, handler.valueFlags), result = await handler.execute(cmdCtx);
|
|
184
|
+
return observe(await applyRedirects(result, redirects, ctx));
|
|
185
|
+
}
|
|
186
|
+
async function resolveArgs(args, ctx) {
|
|
187
|
+
let result = [];
|
|
188
|
+
for (let arg of args) {
|
|
189
|
+
if (arg.type === "literal" && hasGlobChars(arg.value)) {
|
|
190
|
+
result.push(...expandGlob(arg.value, ctx));
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
result.push(await resolveArg(arg, ctx));
|
|
194
|
+
}
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
async function resolveArg(arg, ctx) {
|
|
198
|
+
switch (arg.type) {
|
|
199
|
+
case "literal":
|
|
200
|
+
return arg.value;
|
|
201
|
+
case "variable":
|
|
202
|
+
return resolveWithDefault(ctx.env, arg.name, arg.op, arg.word);
|
|
203
|
+
case "substitution":
|
|
204
|
+
return (await executePipeline(arg.pipeline, "", ctx)).stdout.replace(/\n$/, "");
|
|
205
|
+
case "quoted":
|
|
206
|
+
return (await Promise.all(arg.parts.map((p) => resolveArg(p, ctx)))).join("");
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function expandHeredocVars(content, env) {
|
|
210
|
+
return content.replace(
|
|
211
|
+
/\\\$|\$\{([^}]*)\}|\$([A-Za-z_][A-Za-z0-9_]*)|\$\?/g,
|
|
212
|
+
(m, braced, name) => {
|
|
213
|
+
if (m === "\\$") return "$";
|
|
214
|
+
if (m === "$?") return env.resolve("?");
|
|
215
|
+
if (braced !== void 0) {
|
|
216
|
+
let exp = parseBracedExpansion(braced);
|
|
217
|
+
return resolveWithDefault(env, exp.name, exp.op, exp.word);
|
|
218
|
+
}
|
|
219
|
+
return env.resolve(name);
|
|
220
|
+
}
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
function hasGlobChars(s) {
|
|
224
|
+
return /[*?]/.test(s) || /\[.+\]/.test(s);
|
|
225
|
+
}
|
|
226
|
+
function globToRegExp(pattern) {
|
|
227
|
+
let re = "^";
|
|
228
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
229
|
+
let c = pattern[i];
|
|
230
|
+
if (c === "*")
|
|
231
|
+
re += "[^/]*";
|
|
232
|
+
else if (c === "?")
|
|
233
|
+
re += "[^/]";
|
|
234
|
+
else if (c === "[") {
|
|
235
|
+
let j = i + 1;
|
|
236
|
+
for ((pattern[j] === "!" || pattern[j] === "^") && j++, pattern[j] === "]" && j++; j < pattern.length && pattern[j] !== "]"; ) j++;
|
|
237
|
+
if (j >= pattern.length) {
|
|
238
|
+
re += "\\[";
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
let cls = pattern.slice(i + 1, j);
|
|
242
|
+
cls.startsWith("!") && (cls = "^" + cls.slice(1)), re += "[" + cls.replace(/\\/g, "\\\\") + "]", i = j;
|
|
243
|
+
} else
|
|
244
|
+
re += c.replace(/[.+^${}()|\\]/g, "\\$&");
|
|
245
|
+
}
|
|
246
|
+
return new RegExp(re + "$");
|
|
247
|
+
}
|
|
248
|
+
function expandGlob(pattern, ctx) {
|
|
249
|
+
if (typeof ctx.workspace.listFiles != "function") return [pattern];
|
|
250
|
+
let paths;
|
|
251
|
+
try {
|
|
252
|
+
paths = ctx.workspace.listFiles().map((f) => f.path);
|
|
253
|
+
} catch {
|
|
254
|
+
return [pattern];
|
|
255
|
+
}
|
|
256
|
+
let candidates = /* @__PURE__ */ new Set();
|
|
257
|
+
for (let p of paths) {
|
|
258
|
+
candidates.add(p);
|
|
259
|
+
let idx = p.indexOf("/");
|
|
260
|
+
for (; idx !== -1; )
|
|
261
|
+
candidates.add(p.slice(0, idx)), idx = p.indexOf("/", idx + 1);
|
|
262
|
+
}
|
|
263
|
+
let regex = globToRegExp(vfsPath(pattern)), matches = [...candidates].filter((c) => regex.test(c)).sort().map((m) => m.startsWith("-") ? "./" + m : m);
|
|
264
|
+
return matches.length > 0 ? matches : [pattern];
|
|
265
|
+
}
|
|
266
|
+
function buildCommandContext(resolvedArgs, stdin, ctx, valueFlags) {
|
|
267
|
+
let args = [], flags = {}, i = 0;
|
|
268
|
+
for (; i < resolvedArgs.length; ) {
|
|
269
|
+
let a = resolvedArgs[i];
|
|
270
|
+
if (a === "--") {
|
|
271
|
+
for (let j = i + 1; j < resolvedArgs.length; j++)
|
|
272
|
+
args.push(resolvedArgs[j]);
|
|
273
|
+
break;
|
|
274
|
+
} else if (a.startsWith("--")) {
|
|
275
|
+
let key = a.slice(2), eqIdx = key.indexOf("=");
|
|
276
|
+
if (eqIdx !== -1) {
|
|
277
|
+
let eqVal = key.slice(eqIdx + 1);
|
|
278
|
+
key = key.slice(0, eqIdx), eqVal ? (flags[key] = eqVal, i++) : i + 1 < resolvedArgs.length && !resolvedArgs[i + 1].startsWith("-") ? (flags[key] = resolvedArgs[i + 1], i += 2) : (flags[key] = !0, i++);
|
|
279
|
+
} else if (i + 1 < resolvedArgs.length && !resolvedArgs[i + 1].startsWith("-")) {
|
|
280
|
+
let val = resolvedArgs[i + 1], existing = flags[key];
|
|
281
|
+
existing !== void 0 ? Array.isArray(existing) ? existing.push(val) : typeof existing == "string" && (flags[key] = [existing, val]) : flags[key] = val, i += 2;
|
|
282
|
+
} else
|
|
283
|
+
flags[key] = !0, i++;
|
|
284
|
+
} else if (a.startsWith("-") && a.length >= 2 && a[1] !== "-")
|
|
285
|
+
if (a.length === 2) {
|
|
286
|
+
let key = a.slice(1);
|
|
287
|
+
if (valueFlags?.has(key) && i + 1 < resolvedArgs.length && !resolvedArgs[i + 1].startsWith("-")) {
|
|
288
|
+
let val = resolvedArgs[i + 1], existing = flags[key];
|
|
289
|
+
existing !== void 0 ? Array.isArray(existing) ? existing.push(val) : typeof existing == "string" && (flags[key] = [existing, val]) : flags[key] = val, i += 2;
|
|
290
|
+
} else
|
|
291
|
+
flags[key] = !0, i++;
|
|
292
|
+
} else if (valueFlags?.has(a[1]))
|
|
293
|
+
flags[a[1]] = a.slice(2), i++;
|
|
294
|
+
else {
|
|
295
|
+
for (let c = 1; c < a.length; c++)
|
|
296
|
+
flags[a[c]] = !0;
|
|
297
|
+
i++;
|
|
298
|
+
}
|
|
299
|
+
else
|
|
300
|
+
args.push(a), i++;
|
|
301
|
+
}
|
|
302
|
+
return {
|
|
303
|
+
stdin,
|
|
304
|
+
args,
|
|
305
|
+
flags,
|
|
306
|
+
rawArgs: resolvedArgs,
|
|
307
|
+
workspace: ctx.workspace,
|
|
308
|
+
toolRegistry: ctx.toolRegistry,
|
|
309
|
+
config: ctx.config,
|
|
310
|
+
env: ctx.env,
|
|
311
|
+
gate: ctx.gate,
|
|
312
|
+
authorized: ctx.gate?.authorized,
|
|
313
|
+
signal: ctx.signal,
|
|
314
|
+
depth: ctx.depth
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
function staticResolveTarget(node, env) {
|
|
318
|
+
switch (node.type) {
|
|
319
|
+
case "literal":
|
|
320
|
+
return node.value;
|
|
321
|
+
case "variable":
|
|
322
|
+
return resolveWithDefault(env, node.name, node.op, node.word);
|
|
323
|
+
case "quoted": {
|
|
324
|
+
let out = "";
|
|
325
|
+
for (let p of node.parts) {
|
|
326
|
+
let s = staticResolveTarget(p, env);
|
|
327
|
+
if (s === null) return null;
|
|
328
|
+
out += s;
|
|
329
|
+
}
|
|
330
|
+
return out;
|
|
331
|
+
}
|
|
332
|
+
case "substitution":
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
async function applyGateFailureRedirects(blocked, cmd, ctx) {
|
|
337
|
+
if (cmd.redirects.length === 0) return blocked;
|
|
338
|
+
let notes = [], redirects = [];
|
|
339
|
+
for (let r of cmd.redirects) {
|
|
340
|
+
if (r.type === "in") continue;
|
|
341
|
+
if (r.type === "dup" || r.type === "discard") {
|
|
342
|
+
redirects.push(r);
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
let target = r.target;
|
|
346
|
+
if (target === void 0 && r.targetNode) {
|
|
347
|
+
let resolved = staticResolveTarget(r.targetNode, ctx.env);
|
|
348
|
+
if (resolved === null) {
|
|
349
|
+
notes.push("adf_shell: note: redirect target with command substitution was not resolved for the refused command; error kept on stderr");
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
target = resolved;
|
|
353
|
+
}
|
|
354
|
+
if (target === void 0) continue;
|
|
355
|
+
let special = classifyRedirectTarget(target);
|
|
356
|
+
if (special === "null") {
|
|
357
|
+
redirects.push({ type: "discard", fd: r.fd ?? 1 });
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
if (special) {
|
|
361
|
+
notes.push(`adf_shell: note: ${unsupportedDevTargetMessage(special)}; error kept on stderr`);
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
redirects.push({ ...r, target });
|
|
365
|
+
}
|
|
366
|
+
let isFileRedirect = (r) => (r.type === "out" || r.type === "append") && r.target !== void 0, observeWrite = [];
|
|
367
|
+
if (redirects.some(isFileRedirect) && !ctx.gate?.authorized) {
|
|
368
|
+
let ev = Array.isArray(ctx.config.tools) ? evaluateToolNames(["fs_write"], ctx.config) : { disabled: [], approvalRequired: [], intercepted: [], resolvedTools: [] };
|
|
369
|
+
if (ev.disabled.length > 0 || ev.approvalRequired.length > 0) {
|
|
370
|
+
for (let i = redirects.length - 1; i >= 0; i--)
|
|
371
|
+
isFileRedirect(redirects[i]) && redirects.splice(i, 1);
|
|
372
|
+
notes.push("adf_shell: note: file redirect not honored (fs_write is not permitted); error kept on stderr");
|
|
373
|
+
} else
|
|
374
|
+
observeWrite = ev.intercepted;
|
|
375
|
+
}
|
|
376
|
+
let res = await applyRedirects(blocked, redirects, ctx);
|
|
377
|
+
if (observeWrite.length > 0 && ctx.gate && notifyToolCallObservers(observeWrite, ctx.gate, ctx.config, ctx.gate.command ?? cmd.name), notes.length === 0) return res;
|
|
378
|
+
let noteText = notes.join(`
|
|
379
|
+
`);
|
|
380
|
+
return { ...res, stderr: res.stderr ? `${res.stderr}
|
|
381
|
+
${noteText}` : noteText };
|
|
382
|
+
}
|
|
383
|
+
async function applyRedirects(result, redirects, ctx) {
|
|
384
|
+
let res = result;
|
|
385
|
+
for (let r of redirects)
|
|
386
|
+
if (r.type === "dup") {
|
|
387
|
+
if (r.fd === 2 && r.targetFd === 1) {
|
|
388
|
+
let sep = res.stdout && !res.stdout.endsWith(`
|
|
389
|
+
`) && res.stderr ? `
|
|
390
|
+
` : "";
|
|
391
|
+
res = { ...res, stdout: res.stdout + sep + res.stderr, stderr: "" };
|
|
392
|
+
} else if (r.fd === 1 && r.targetFd === 2) {
|
|
393
|
+
let sep = res.stderr && !res.stderr.endsWith(`
|
|
394
|
+
`) && res.stdout ? `
|
|
395
|
+
` : "";
|
|
396
|
+
res = { ...res, stderr: res.stderr + sep + res.stdout, stdout: "" };
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
for (let r of redirects) {
|
|
400
|
+
if (r.type === "discard") {
|
|
401
|
+
r.fd === 2 ? res = { ...res, stderr: "" } : r.fd !== 0 && (res = { ...res, stdout: "" });
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
404
|
+
if ((r.type === "out" || r.type === "append") && r.target !== void 0) {
|
|
405
|
+
let content = r.fd === 2 ? res.stderr : res.stdout;
|
|
406
|
+
await ctx.toolRegistry.executeTool("fs_write", {
|
|
407
|
+
mode: r.type === "append" ? "append" : "write",
|
|
408
|
+
path: vfsPath(r.target),
|
|
409
|
+
content
|
|
410
|
+
}, ctx.workspace), res = r.fd === 2 ? { ...res, stderr: "" } : { ...res, stdout: "" };
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return res;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
export {
|
|
417
|
+
MAX_SHELL_DEPTH,
|
|
418
|
+
executeNode
|
|
419
|
+
};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { createRequire as __adfCreateRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __adfFileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __adfDirname } from 'node:path';
|
|
4
|
+
const require = __adfCreateRequire(import.meta.url);
|
|
5
|
+
const __filename = __adfFileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = __adfDirname(__filename);
|
|
7
|
+
import {
|
|
8
|
+
__export
|
|
9
|
+
} from "./chunk-M2RX3S2T.mjs";
|
|
10
|
+
|
|
11
|
+
// src/shared/constants/adapter-registry.ts
|
|
12
|
+
var adapter_registry_exports = {};
|
|
13
|
+
__export(adapter_registry_exports, {
|
|
14
|
+
ADAPTER_REGISTRY: () => ADAPTER_REGISTRY,
|
|
15
|
+
findAdapterRegistryEntry: () => findAdapterRegistryEntry,
|
|
16
|
+
findAdapterRegistryEntryByPackage: () => findAdapterRegistryEntryByPackage,
|
|
17
|
+
getEnabledAgentAdapterConfig: () => getEnabledAgentAdapterConfig,
|
|
18
|
+
withBuiltInAdapterRegistrations: () => withBuiltInAdapterRegistrations
|
|
19
|
+
});
|
|
20
|
+
var MESSAGING_GUIDE_URL = "https://github.com/christianbalevski/adf/blob/main/docs/guides/messaging.md", ADAPTER_REGISTRY = [
|
|
21
|
+
{
|
|
22
|
+
type: "telegram",
|
|
23
|
+
displayName: "Telegram",
|
|
24
|
+
builtIn: !0,
|
|
25
|
+
description: "Receive and send Telegram messages via a bot token",
|
|
26
|
+
tagline: "A bot in your DMs and groups. One token from BotFather.",
|
|
27
|
+
iconKey: "telegram",
|
|
28
|
+
requiredEnvKeys: ["TELEGRAM_BOT_TOKEN"],
|
|
29
|
+
credentials: [
|
|
30
|
+
{ key: "TELEGRAM_BOT_TOKEN", label: "Bot token", required: !0, placeholder: "123456789:AA\u2026", hint: "From @BotFather after /newbot." }
|
|
31
|
+
],
|
|
32
|
+
setupSteps: [
|
|
33
|
+
{ text: 'Open @BotFather in Telegram and send /newbot. Pick a name and a username ending in "bot".', url: "https://t.me/BotFather" },
|
|
34
|
+
{ text: "Copy the token BotFather replies with and paste it below." },
|
|
35
|
+
{ text: "Message your bot once so it can see you. For groups, add the bot and mention it." }
|
|
36
|
+
],
|
|
37
|
+
docsUrl: `${MESSAGING_GUIDE_URL}#telegram-adapter`,
|
|
38
|
+
verified: !0
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: "email",
|
|
42
|
+
displayName: "Email",
|
|
43
|
+
builtIn: !0,
|
|
44
|
+
description: "Send and receive email via IMAP/SMTP",
|
|
45
|
+
tagline: "Any mailbox with IMAP and SMTP. Gmail, iCloud, Outlook, Fastmail, self-hosted.",
|
|
46
|
+
iconKey: "email",
|
|
47
|
+
requiredEnvKeys: ["EMAIL_USERNAME", "EMAIL_PASSWORD"],
|
|
48
|
+
credentials: [
|
|
49
|
+
{ key: "EMAIL_USERNAME", label: "Email address", required: !0, placeholder: "agent@example.com", hint: "Servers are detected from the domain. Custom hosts go in the agent config." },
|
|
50
|
+
{ key: "EMAIL_PASSWORD", label: "App password", required: !0, placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022", hint: "An app-specific password, not the account password." }
|
|
51
|
+
],
|
|
52
|
+
setupSteps: [
|
|
53
|
+
{ text: "Turn on two-factor authentication for the mailbox. Most providers require it for app passwords." },
|
|
54
|
+
{ text: "Create an app-specific password in the provider's security settings (Gmail: myaccount.google.com/apppasswords).", url: "https://myaccount.google.com/apppasswords" },
|
|
55
|
+
{ text: "Enter the full address and that app password below. IMAP and SMTP hosts are detected from the domain." }
|
|
56
|
+
],
|
|
57
|
+
docsUrl: `${MESSAGING_GUIDE_URL}#email-adapter`,
|
|
58
|
+
verified: !0
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
type: "discord",
|
|
62
|
+
displayName: "Discord",
|
|
63
|
+
builtIn: !0,
|
|
64
|
+
description: "Receive and send Discord messages via a bot token (DMs, guilds, /<botname> slash command)",
|
|
65
|
+
tagline: "A bot in servers and DMs, with an optional slash command.",
|
|
66
|
+
iconKey: "discord",
|
|
67
|
+
requiredEnvKeys: ["DISCORD_BOT_TOKEN"],
|
|
68
|
+
optionalEnvKeys: ["DISCORD_APPLICATION_ID"],
|
|
69
|
+
credentials: [
|
|
70
|
+
{ key: "DISCORD_BOT_TOKEN", label: "Bot token", required: !0, placeholder: "MTA\u2026", hint: "Bot page \u2192 Reset Token. Discord shows it once." },
|
|
71
|
+
{ key: "DISCORD_APPLICATION_ID", label: "Application ID", required: !1, placeholder: "1234567890", hint: "Optional. Registers a /<botname> slash command." }
|
|
72
|
+
],
|
|
73
|
+
setupSteps: [
|
|
74
|
+
{ text: "Create an application in the Discord Developer Portal.", url: "https://discord.com/developers/applications" },
|
|
75
|
+
{ text: "On the Bot page click Reset Token and copy it. Under Privileged Gateway Intents turn on Message Content Intent and save." },
|
|
76
|
+
{ text: 'Invite the bot with the "bot" and "applications.commands" scopes and permission to view channels, read history, send messages, and attach files.' }
|
|
77
|
+
],
|
|
78
|
+
docsUrl: `${MESSAGING_GUIDE_URL}#discord-adapter`,
|
|
79
|
+
verified: !0
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
type: "slack",
|
|
83
|
+
displayName: "Slack",
|
|
84
|
+
builtIn: !0,
|
|
85
|
+
description: "Receive and send Slack messages via Socket Mode (app token + bot token, no public endpoint)",
|
|
86
|
+
tagline: "Socket Mode: no public URL. Two tokens from api.slack.com.",
|
|
87
|
+
iconKey: "slack",
|
|
88
|
+
requiredEnvKeys: ["SLACK_APP_TOKEN", "SLACK_BOT_TOKEN"],
|
|
89
|
+
credentials: [
|
|
90
|
+
{ key: "SLACK_APP_TOKEN", label: "App-level token", required: !0, placeholder: "xapp-\u2026", hint: "Socket Mode page. Needs the connections:write scope." },
|
|
91
|
+
{ key: "SLACK_BOT_TOKEN", label: "Bot user OAuth token", required: !0, placeholder: "xoxb-\u2026", hint: "Install App page, after installing to the workspace." }
|
|
92
|
+
],
|
|
93
|
+
setupSteps: [
|
|
94
|
+
{ text: "Create a Slack app from scratch and pick the workspace.", url: "https://api.slack.com/apps" },
|
|
95
|
+
{ text: "Socket Mode page: enable it and copy the xapp- token." },
|
|
96
|
+
{ text: "Event Subscriptions: enable events and subscribe the bot to message.channels, message.groups, message.im, message.mpim. Without these the socket connects but stays silent." },
|
|
97
|
+
{ text: "OAuth & Permissions: add chat:write, im:write, users:read, channels:read, groups:read, im:read, mpim:read, files:read, files:write. App Home: enable the Messages tab." },
|
|
98
|
+
{ text: "Install (or reinstall) the app and copy the xoxb- bot token. Invite the bot to each channel it should read." }
|
|
99
|
+
],
|
|
100
|
+
docsUrl: `${MESSAGING_GUIDE_URL}#slack-adapter`,
|
|
101
|
+
verified: !0
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
type: "whatsapp",
|
|
105
|
+
displayName: "WhatsApp",
|
|
106
|
+
builtIn: !0,
|
|
107
|
+
description: "Personal WhatsApp account via multi-device pairing \u2014 scan a QR code, no tokens. Unofficial protocol; use a non-critical account.",
|
|
108
|
+
tagline: "Pair a personal account by QR. Unofficial protocol, use a spare number.",
|
|
109
|
+
iconKey: "whatsapp",
|
|
110
|
+
requiredEnvKeys: [],
|
|
111
|
+
credentials: [],
|
|
112
|
+
setupSteps: [
|
|
113
|
+
{ text: "Connect an agent below. No credentials are needed." },
|
|
114
|
+
{ text: "Start the agent. The adapter writes a pairing QR to imported/whatsapp/pairing-qr.png in the agent's files and notes it in the channel log." },
|
|
115
|
+
{ text: "On the phone open WhatsApp \u2192 Linked Devices \u2192 Link a device and scan it. The QR refreshes every minute until paired." }
|
|
116
|
+
],
|
|
117
|
+
docsUrl: `${MESSAGING_GUIDE_URL}#whatsapp-adapter`,
|
|
118
|
+
verified: !0
|
|
119
|
+
}
|
|
120
|
+
], BUILT_IN_ADAPTER_REGISTRATIONS = ADAPTER_REGISTRY.filter((entry) => entry.builtIn).map((entry) => ({
|
|
121
|
+
id: entry.type,
|
|
122
|
+
type: entry.type,
|
|
123
|
+
managed: !1
|
|
124
|
+
}));
|
|
125
|
+
function withBuiltInAdapterRegistrations(registrations) {
|
|
126
|
+
let builtInsByType = new Map(BUILT_IN_ADAPTER_REGISTRATIONS.map((entry) => [entry.type, entry])), seenTypes = /* @__PURE__ */ new Set(), merged = [];
|
|
127
|
+
for (let registration of registrations ?? []) {
|
|
128
|
+
let builtIn = builtInsByType.get(registration.type);
|
|
129
|
+
merged.push(builtIn ? { ...builtIn, ...registration } : { ...registration }), seenTypes.add(registration.type);
|
|
130
|
+
}
|
|
131
|
+
for (let builtIn of BUILT_IN_ADAPTER_REGISTRATIONS)
|
|
132
|
+
seenTypes.has(builtIn.type) || merged.push({ ...builtIn });
|
|
133
|
+
return merged;
|
|
134
|
+
}
|
|
135
|
+
function findAdapterRegistryEntry(type) {
|
|
136
|
+
return ADAPTER_REGISTRY.find((e) => e.type === type);
|
|
137
|
+
}
|
|
138
|
+
function findAdapterRegistryEntryByPackage(npmPackage) {
|
|
139
|
+
return ADAPTER_REGISTRY.find((e) => e.npmPackage === npmPackage);
|
|
140
|
+
}
|
|
141
|
+
function getEnabledAgentAdapterConfig(adapters, type) {
|
|
142
|
+
let config = adapters?.[type];
|
|
143
|
+
return config?.enabled === !0 ? config : null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export {
|
|
147
|
+
withBuiltInAdapterRegistrations,
|
|
148
|
+
findAdapterRegistryEntry,
|
|
149
|
+
getEnabledAgentAdapterConfig,
|
|
150
|
+
adapter_registry_exports
|
|
151
|
+
};
|