Files
alamin-br 724ca69647 fix(agent): small Agent Builder fixes from the launch review (#6871)
* fix(agent): small Agent Builder fixes from the launch review

Imported actions ask first, SECRET_KEY_FALLBACKS is read, signed links keep their query,
Gemini retries transient errors, approval cards stop saying 'by you', and agent-builder turns identities on.

* test(assistant): turn identities off by having no flags

The agent-builder flag now turns identities on as well.

* fix(agent): address review of the launch quick fixes

Key fallbacks are JSON arrays, Gemini retries once per Kuma call, and an
imported action must carry the service its type runs.
2026-11-26 15:21:58 +01:00

77 lines
2.1 KiB
Vue

<template>
<!-- eslint-disable-next-line vue/no-v-html -->
<div class="chat-markdown" @click="followLink" v-html="html"></div>
</template>
<script>
import { computed } from 'vue'
import { useRouter } from 'vue-router'
import MarkdownIt from 'markdown-it'
function parseUrl(href) {
try {
return new URL(href)
} catch {
return null
}
}
// The query parameters that sign S3, GCS, CloudFront and Azure links.
const SIGNED = /^(x-amz-signature|x-goog-signature|signature|sig)$/i
// A rendered image would load any URL, which can carry conversation data away.
const markdown = new MarkdownIt({ html: false, linkify: true }).disable('image')
markdown.renderer.rules.link_open = (tokens, index, options, env, renderer) => {
const token = tokens[index]
const href = token.attrGet('href')
if (env.agentLinks && /^https?:\/\//i.test(href)) {
const url = parseUrl(href)
if (url) {
token.attrSet('rel', 'noopener noreferrer')
// Rewriting a signed link's query would break its signature.
if (![...url.searchParams.keys()].some((key) => SIGNED.test(key))) {
url.searchParams.set('utm_source', 'baserow.io')
token.attrSet('href', url.href)
}
}
}
return renderer.renderToken(tokens, index, options)
}
</script>
<script setup>
const props = defineProps({
content: { type: String, default: '' },
agentLinks: Boolean,
})
const router = useRouter()
const html = computed(() =>
markdown.render(props.content, { agentLinks: props.agentLinks })
)
/** App links open in the router, other web links in a new tab. */
function followLink(event) {
const link = event.target.closest('a')
const modified =
event.button !== 0 ||
event.metaKey ||
event.ctrlKey ||
event.shiftKey ||
event.altKey
if (!link || modified) return
const url = parseUrl(link.href)
if (!url || !['http:', 'https:'].includes(url.protocol)) return
event.preventDefault()
const path = url.pathname + url.search + url.hash
if (
url.origin === window.location.origin &&
router.resolve(path).matched.length
) {
router.push(path)
} else {
window.open(url.href, '_blank', 'noopener,noreferrer')
}
}
</script>