Liking cljdoc? Tell your friends :D

im.ttalk.agent.agui.registry

多 agent 注册表:agent id → runtime(designs/agui-borrow.md §4,对照 Keelson AguiRegistry.cs)。

为什么要有:AG-UI 前端按 id 找 agent(/info 的 agents 是字典、请求路径是 /agent/:id/run),而一个服务挂多台 agent(便宜模型的「客服」+ 带敏感工具的 「运维」)是常规用法。没有这张表时路由只能写死一台,路径里的 id 被忽略—— 请求 ops 跑的是 default,静默串台。

纯数据 + 函数,零 web 依赖(design-principles §2):找不到 agent 回 404 是 路由的事,这里只回 nil。

(def reg (registry [{:id "default" :runtime rt1 :description "通用助手"}
                    {:id "ops" :runtime rt2 :suggest? true}]))
(find-agent reg "ops")   ;; => 条目 map
(stop! reg "ops" "t1")   ;; => true / false

条目是开放 map:除下面这几个键,路由层自己的东西(服务端工具名、 /suggest 要的 agent 配置、入站插件…)照样放在条目里,本 ns 不解释。

  • :id 必填,非空字符串,全表唯一
  • :runtime 内置驱动时必填,agui.runtime/runtime 的返回值(多台可共享一个)。 自带 run 驱动的 agent 不必塞占位 runtime::external? true 即可(run / stop / connect 由 clj-agent-server 的路由选项或宿主自己的处理器接管)。
  • :external? true = 这台没有 runtime,只有名录与元数据;缺省 false
  • :description 进 /info
  • :suggest? 这台支持无状态 /suggest(/info.suggestions = 任一台支持)
  • :stop 可选 (fn [{:keys [runtime thread-id agent]}] bool)——这台自己 决定怎么停(例如拒绝停某些线程)。缺省 runtime/stop!,原因 :stop
多 agent 注册表:agent id → runtime(designs/agui-borrow.md §4,对照 Keelson
`AguiRegistry.cs`)。

为什么要有:AG-UI 前端按 id 找 agent(`/info` 的 `agents` 是字典、请求路径是
`/agent/:id/run`),而一个服务挂多台 agent(便宜模型的「客服」+ 带敏感工具的
「运维」)是常规用法。没有这张表时路由只能写死一台,路径里的 id 被忽略——
请求 `ops` 跑的是 `default`,**静默串台**。

**纯数据 + 函数,零 web 依赖**(design-principles §2):找不到 agent 回 404 是
路由的事,这里只回 nil。

```clojure
(def reg (registry [{:id "default" :runtime rt1 :description "通用助手"}
                    {:id "ops" :runtime rt2 :suggest? true}]))
(find-agent reg "ops")   ;; => 条目 map
(stop! reg "ops" "t1")   ;; => true / false
```

条目是**开放 map**:除下面这几个键,路由层自己的东西(服务端工具名、
`/suggest` 要的 agent 配置、入站插件…)照样放在条目里,本 ns 不解释。

- `:id`          **必填**,非空字符串,全表唯一
- `:runtime`     内置驱动时**必填**,`agui.runtime/runtime` 的返回值(多台可共享一个)。
                 自带 run 驱动的 agent 不必塞占位 runtime:`:external? true` 即可(run / stop / connect 由
                 clj-agent-server 的路由选项或宿主自己的处理器接管)。
- `:external?`   true = 这台没有 runtime,只有名录与元数据;缺省 false
- `:description` 进 `/info`
- `:suggest?`    这台支持无状态 `/suggest`(`/info.suggestions` = 任一台支持)
- `:stop`        可选 `(fn [{:keys [runtime thread-id agent]}] bool)`——这台自己
                 决定怎么停(例如拒绝停某些线程)。缺省 `runtime/stop!`,原因 `:stop`
raw docstring

agent-idsclj

(agent-ids reg)

按加入顺序(/info 名录的顺序因此稳定)。

按加入顺序(`/info` 名录的顺序因此稳定)。
sourceraw docstring

agentsclj

(agents reg)

全部条目,按加入顺序。

全部条目,按加入顺序。
sourceraw docstring

default-agentclj

(default-agent reg)

第一台(单 agent 部署里就是唯一那台)。

第一台(单 agent 部署里就是唯一那台)。
sourceraw docstring

find-agentclj

(find-agent reg id)

按 id 取条目;没有返回 nil(路由据此回 404 agent_not_found)。

按 id 取条目;没有返回 nil(路由据此回 404 `agent_not_found`)。
sourceraw docstring

infoclj

(info reg)
(info reg opts)

/info 的响应体:codec/run-info + 每台的 description + suggestions = 任一台支持(Keelson AguiRegistry.Info 同口径)。

opts 其余键原样交给 codec/run-info(插件能力位、线程面…)。

`/info` 的响应体:`codec/run-info` + 每台的 description +
`suggestions` = **任一台**支持(Keelson `AguiRegistry.Info` 同口径)。

`opts` 其余键原样交给 `codec/run-info`(插件能力位、线程面…)。
sourceraw docstring

registryclj

(registry entries)

由条目序列建注册表。装配期抛(不是运行期兜):空表、条目缺 :id / :runtime、id 重名——两台同名的表现是「/info 列出来一台、跑的是另一台」。

返回值不可变;要增删 agent 就重建一份(没有热插拔的真实场景)。

由条目序列建注册表。**装配期抛**(不是运行期兜):空表、条目缺 `:id` /
`:runtime`、id 重名——两台同名的表现是「`/info` 列出来一台、跑的是另一台」。

返回值不可变;要增删 agent 就重建一份(没有热插拔的真实场景)。
sourceraw docstring

registry?clj

(registry? x)
source

runtimesclj

(runtimes reg)

去重后的 runtime(多台共享一个时只出现一次)。

去重后的 runtime(多台共享一个时只出现一次)。
sourceraw docstring

shutdown!clj

(shutdown! reg)

每个不同的 runtime 关一次。

每个**不同**的 runtime 关一次。
sourceraw docstring

stop!clj

(stop! reg agent-id thread-id)

让 agent-id 那台停 thread-id 上在跑的 run。返回 true 只表示取消已登记 (同 runtime/stop!)。没这台 agent / 没在跑 → false。

条目给了 :stop 就听它的;没给就是 runtime/stop!,原因 :stop(用户按停)。

让 `agent-id` 那台停 `thread-id` 上在跑的 run。返回 true 只表示**取消已登记**
(同 `runtime/stop!`)。没这台 agent / 没在跑 → false。

条目给了 `:stop` 就听它的;没给就是 `runtime/stop!`,原因 `:stop`(用户按停)。
sourceraw docstring

supports-suggest?clj

(supports-suggest? entry)
source

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close