import { Agent, Flow, Vector, Workflow } from "@tuoluo/ai"const brain = await Agent.boot({ tenant: "acme", locale: "zh-CN", region: "cn-hangzhou" })await brain.memory.link({ user: ctx.user, source: "eb_customer", scope: ["profile", "order"] })const sql = await nl2sql("统计本月新增客户按行业与区域的分布", schema, { dialect: "mysql" })brain.on("intent", async (e) => ctx.state.set("intent", { type: e.type, score: e.score }))await queue.push("sync.org", { deptId, depth: 3, retry: 2, backoff: "exponential", timeout: 30_000 })cache.set(`tpl:${templateId}`, compiled, { ttl: 3600, tags: ["approval", "v2"], compress: true })const kb = await Vector.index(docs, { dim: 1024, metric: "cosine", shards: 8, onProgress })if (score > 0.82) return brain.recall({ id, topK: 8, rerank: true, filters: { dept } })await flow.dispatch({ id: flowId, payload, traceId, timeout: 30_000, onError: retry(3) })ctx.state.set("approval.step", 2, { persist: true, notify: ["owner", "finance"], expireAt })brain.emit("insight", metrics.aggregate({ window: "7d", groupBy: "dept", orderBy: "amount" }))for (const item of list) await sync(item, { batch: 200, concurrency: 8, onFail: "skip" })return { ok: true, traceId, elapsed: performance.now() - startedAt, version: PKG.version }const brain = await Agent.boot({ tenant: "acme", locale: "zh-CN", region: "cn-hangzhou" })await brain.memory.link({ user: ctx.user, source: "eb_customer", scope: ["profile", "order"] })const sql = await nl2sql("统计本月新增客户按行业与区域的分布", schema, { dialect: "mysql" })brain.on("intent", async (e) => ctx.state.set("intent", { type: e.type, score: e.score }))await queue.push("sync.org", { deptId, depth: 3, retry: 2, backoff: "exponential", timeout: 30_000 })cache.set(`tpl:${templateId}`, compiled, { ttl: 3600, tags: ["approval", "v2"], compress: true })const kb = await Vector.index(docs, { dim: 1024, metric: "cosine", shards: 8, onProgress })if (score > 0.82) return brain.recall({ id, topK: 8, rerank: true, filters: { dept } })await flow.dispatch({ id: flowId, payload, traceId, timeout: 30_000, onError: retry(3) })ctx.state.set("approval.step", 2, { persist: true, notify: ["owner", "finance"], expireAt })brain.emit("insight", metrics.aggregate({ window: "7d", groupBy: "dept", orderBy: "amount" }))for (const item of list) await sync(item, { batch: 200, concurrency: 8, onFail: "skip" })return { ok: true, traceId, elapsed: performance.now() - startedAt, version: PKG.version }import { Agent, Flow, Vector, Workflow } from "@tuoluo/ai"await brain.memory.link({ user: ctx.user, source: "eb_customer", scope: ["profile", "order"] })const sql = await nl2sql("统计本月新增客户按行业与区域的分布", schema, { dialect: "mysql" })brain.on("intent", async (e) => ctx.state.set("intent", { type: e.type, score: e.score }))await queue.push("sync.org", { deptId, depth: 3, retry: 2, backoff: "exponential", timeout: 30_000 })cache.set(`tpl:${templateId}`, compiled, { ttl: 3600, tags: ["approval", "v2"], compress: true })const kb = await Vector.index(docs, { dim: 1024, metric: "cosine", shards: 8, onProgress })if (score > 0.82) return brain.recall({ id, topK: 8, rerank: true, filters: { dept } })await flow.dispatch({ id: flowId, payload, traceId, timeout: 30_000, onError: retry(3) })ctx.state.set("approval.step", 2, { persist: true, notify: ["owner", "finance"], expireAt })brain.emit("insight", metrics.aggregate({ window: "7d", groupBy: "dept", orderBy: "amount" }))for (const item of list) await sync(item, { batch: 200, concurrency: 8, onFail: "skip" })return { ok: true, traceId, elapsed: performance.now() - startedAt, version: PKG.version }import { Agent, Flow, Vector, Workflow } from "@tuoluo/ai"const brain = await Agent.boot({ tenant: "acme", locale: "zh-CN", region: "cn-hangzhou" })import { Agent, Flow, Vector, Workflow } from "@tuoluo/ai"const brain = await Agent.boot({ tenant: "acme", locale: "zh-CN", region: "cn-hangzhou" })await brain.memory.link({ user: ctx.user, source: "eb_customer", scope: ["profile", "order"] })const sql = await nl2sql("统计本月新增客户按行业与区域的分布", schema, { dialect: "mysql" })brain.on("intent", async (e) => ctx.state.set("intent", { type: e.type, score: e.score }))await queue.push("sync.org", { deptId, depth: 3, retry: 2, backoff: "exponential", timeout: 30_000 })cache.set(`tpl:${templateId}`, compiled, { ttl: 3600, tags: ["approval", "v2"], compress: true })const kb = await Vector.index(docs, { dim: 1024, metric: "cosine", shards: 8, onProgress })if (score > 0.82) return brain.recall({ id, topK: 8, rerank: true, filters: { dept } })await flow.dispatch({ id: flowId, payload, traceId, timeout: 30_000, onError: retry(3) })ctx.state.set("approval.step", 2, { persist: true, notify: ["owner", "finance"], expireAt })brain.emit("insight", metrics.aggregate({ window: "7d", groupBy: "dept", orderBy: "amount" }))for (const item of list) await sync(item, { batch: 200, concurrency: 8, onFail: "skip" })return { ok: true, traceId, elapsed: performance.now() - startedAt, version: PKG.version }const brain = await Agent.boot({ tenant: "acme", locale: "zh-CN", region: "cn-hangzhou" })await brain.memory.link({ user: ctx.user, source: "eb_customer", scope: ["profile", "order"] })const sql = await nl2sql("统计本月新增客户按行业与区域的分布", schema, { dialect: "mysql" })brain.on("intent", async (e) => ctx.state.set("intent", { type: e.type, score: e.score }))await queue.push("sync.org", { deptId, depth: 3, retry: 2, backoff: "exponential", timeout: 30_000 })cache.set(`tpl:${templateId}`, compiled, { ttl: 3600, tags: ["approval", "v2"], compress: true })const kb = await Vector.index(docs, { dim: 1024, metric: "cosine", shards: 8, onProgress })if (score > 0.82) return brain.recall({ id, topK: 8, rerank: true, filters: { dept } })await flow.dispatch({ id: flowId, payload, traceId, timeout: 30_000, onError: retry(3) })ctx.state.set("approval.step", 2, { persist: true, notify: ["owner", "finance"], expireAt })brain.emit("insight", metrics.aggregate({ window: "7d", groupBy: "dept", orderBy: "amount" }))for (const item of list) await sync(item, { batch: 200, concurrency: 8, onFail: "skip" })return { ok: true, traceId, elapsed: performance.now() - startedAt, version: PKG.version }import { Agent, Flow, Vector, Workflow } from "@tuoluo/ai"await brain.memory.link({ user: ctx.user, source: "eb_customer", scope: ["profile", "order"] })const sql = await nl2sql("统计本月新增客户按行业与区域的分布", schema, { dialect: "mysql" })brain.on("intent", async (e) => ctx.state.set("intent", { type: e.type, score: e.score }))await queue.push("sync.org", { deptId, depth: 3, retry: 2, backoff: "exponential", timeout: 30_000 })cache.set(`tpl:${templateId}`, compiled, { ttl: 3600, tags: ["approval", "v2"], compress: true })const kb = await Vector.index(docs, { dim: 1024, metric: "cosine", shards: 8, onProgress })if (score > 0.82) return brain.recall({ id, topK: 8, rerank: true, filters: { dept } })await flow.dispatch({ id: flowId, payload, traceId, timeout: 30_000, onError: retry(3) })ctx.state.set("approval.step", 2, { persist: true, notify: ["owner", "finance"], expireAt })brain.emit("insight", metrics.aggregate({ window: "7d", groupBy: "dept", orderBy: "amount" }))for (const item of list) await sync(item, { batch: 200, concurrency: 8, onFail: "skip" })return { ok: true, traceId, elapsed: performance.now() - startedAt, version: PKG.version }import { Agent, Flow, Vector, Workflow } from "@tuoluo/ai"const brain = await Agent.boot({ tenant: "acme", locale: "zh-CN", region: "cn-hangzhou" })