Add link understanding tool support (#1637)

* Add

* Fix

---------

Co-authored-by: Richard <dasilva333@DESKTOP-74E3GJO.localdomain>
This commit is contained in:
Richard Pinedo
2026-01-24 19:15:54 -05:00
committed by GitHub
parent 2f58d59f22
commit 426168a338
13 changed files with 323 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import type { ClawdbotConfig } from "../config/config.js";
import type { MsgContext } from "../auto-reply/templating.js";
import { finalizeInboundContext } from "../auto-reply/reply/inbound-context.js";
import { formatLinkUnderstandingBody } from "./format.js";
import { runLinkUnderstanding } from "./runner.js";
export type ApplyLinkUnderstandingResult = {
outputs: string[];
urls: string[];
};
export async function applyLinkUnderstanding(params: {
ctx: MsgContext;
cfg: ClawdbotConfig;
}): Promise<ApplyLinkUnderstandingResult> {
const result = await runLinkUnderstanding({
cfg: params.cfg,
ctx: params.ctx,
});
if (result.outputs.length === 0) {
return result;
}
params.ctx.LinkUnderstanding = [...(params.ctx.LinkUnderstanding ?? []), ...result.outputs];
params.ctx.Body = formatLinkUnderstandingBody({
body: params.ctx.Body,
outputs: result.outputs,
});
finalizeInboundContext(params.ctx, {
forceBodyForAgent: true,
forceBodyForCommands: true,
});
return result;
}