Liking cljdoc? Tell your friends :D

im.ttalk.agent.tools

clj-agent-tools 门面:一行拿到绑定好工作区的编码类工具(设计:designs/tools-module.md)。

(require '[im.ttalk.agent.tools :as tools]) (def ws (tools/workspace {:root "/abs/repo"})) (tools/workspace-tools ws {:groups #{:files :edit}}) ;; ⇒ [#'read_file …] 放进 :tools

工具是 deftool 定义的 var;workspace-tools 为每个工具造一个匿名 var,根值是 (fn [args] (binding [ws/*workspace* ws] (f args))),元数据沿用 deftool 的(可按实例覆盖 :tool/sensitive 与 description)。绑定发生在工具函数体内部——与哪个引擎 / 线程执行它无关 (design-principles §3)。用 var 而不用内联工具 map,是因为 :sensitive 只对 var 生效 (tool_registry/build-func-def),审批 filter 与 :on-pause 才看得见。

组(缺省只开只读的 :files;写、删、跑进程、出网都要显式开):

  • :files read_file list_dir glob grep
  • :edit write_file edit_file apply_patch(敏感、串行)
  • :delete delete_path(敏感、串行)
  • :exec exec exec_command write_stdin(敏感、串行;必须给 {:exec {:backend ..}})
  • :web-fetch web_fetch(缺省敏感,{:web-fetch {:sensitive false}} 可关)
  • :skill skill({:skills {:dirs [..]}})
  • :notes notes_list notes_read notes_write(必须给 {:notes store};{:notes-write-sensitive? true} 让写走审批)
clj-agent-tools 门面:一行拿到绑定好工作区的编码类工具(设计:designs/tools-module.md)。

(require '[im.ttalk.agent.tools :as tools])
(def ws (tools/workspace {:root "/abs/repo"}))
(tools/workspace-tools ws {:groups #{:files :edit}})   ;; ⇒ [#'read_file …] 放进 :tools

工具是 deftool 定义的 var;`workspace-tools` 为每个工具造一个**匿名 var**,根值是
`(fn [args] (binding [ws/*workspace* ws] (f args)))`,元数据沿用 deftool 的(可按实例覆盖
`:tool/sensitive` 与 description)。绑定发生在工具函数体内部——与哪个引擎 / 线程执行它无关
(design-principles §3)。用 var 而不用内联工具 map,是因为 `:sensitive` 只对 var 生效
(tool_registry/build-func-def),审批 filter 与 :on-pause 才看得见。

组(缺省只开只读的 :files;写、删、跑进程、出网都要显式开):
- :files     read_file list_dir glob grep
- :edit      write_file edit_file apply_patch(敏感、串行)
- :delete    delete_path(敏感、串行)
- :exec      exec exec_command write_stdin(敏感、串行;必须给 {:exec {:backend ..}})
- :web-fetch web_fetch(缺省敏感,{:web-fetch {:sensitive false}} 可关)
- :skill     skill({:skills {:dirs [..]}})
- :notes     notes_list notes_read notes_write(必须给 {:notes store};{:notes-write-sensitive? true} 让写走审批)
raw docstring

all-groupsclj

source

bind-toolclj

(bind-tool v w)
(bind-tool v w overrides)

把一个 deftool var 绑到工作区:⇒ 新的匿名 var(元数据 = 原元数据 + overrides + :tools/workspace)。

把一个 deftool var 绑到工作区:⇒ 新的匿名 var(元数据 = 原元数据 + overrides + :tools/workspace)。
sourceraw docstring

close!clj

(close! w)

收尾:结束工作区里的全部 exec 会话。⇒ 结束了几个。

收尾:结束工作区里的全部 exec 会话。⇒ 结束了几个。
sourceraw docstring

groupsclj

组 ⇒ 工具 var(deftool 原件,未绑定)。

组 ⇒ 工具 var(deftool 原件,未绑定)。
sourceraw docstring

previewclj

(preview w tool-name args)

审批预览(出处 Keelson ApprovalPreview / 各工具 PreviewAsync):与执行同一个 plan 函数(无副作用)。 w:工作区(或 workspace-tools 产出的任一 var);tool-name:字符串或关键字;args:工具参数 map。 ⇒ {:title .. :diff ..}(会失败 ⇒ {:title .. :will-fail 原因});不是写类工具 ⇒ nil。

典型用法:在 approval-filter 的 approve-fn 或 simple-agent 的 :on-pause 回调里调用,把 diff 给人看。

审批预览(出处 Keelson ApprovalPreview / 各工具 PreviewAsync):与执行**同一个 plan 函数**(无副作用)。
w:工作区(或 workspace-tools 产出的任一 var);tool-name:字符串或关键字;args:工具参数 map。
⇒ {:title .. :diff ..}(会失败 ⇒ {:title .. :will-fail 原因});不是写类工具 ⇒ nil。

典型用法:在 approval-filter 的 approve-fn 或 simple-agent 的 :on-pause 回调里调用,把 diff 给人看。
sourceraw docstring

workspaceclj

(workspace opts)

建工作区(选项见 im.ttalk.agent.tools.workspace/workspace)。已经是工作区 ⇒ 原样返回。

建工作区(选项见 `im.ttalk.agent.tools.workspace/workspace`)。已经是工作区 ⇒ 原样返回。
sourceraw docstring

workspace-ofclj

(workspace-of tool-var)

从 workspace-tools 产出的 var 取回它绑定的工作区。

从 workspace-tools 产出的 var 取回它绑定的工作区。
sourceraw docstring

workspace-toolsclj

(workspace-tools w-or-opts)
(workspace-tools w-or-opts opts)

按组造工具 ⇒ 绑定好工作区的 tool var 向量,直接放进 build-chat-client / simple-agent 的 :tools。

w-or-opts:工作区(workspace 的结果)或其选项 map(:root 等)。 opts(可省,也可直接并在 w-or-opts 里):

  • :groups 组集合(缺省 #{:files};:all = 全部可用的组)
  • :only 只要这些工具名(字符串集合)
  • :exclude 不要这些工具名

校验:开了 :exec 却没给 {:exec {:backend ..}} / {:exec {:runner ..}} ⇒ 抛;开了 :notes 却没给 :notes 存储 ⇒ 抛。

按组造工具 ⇒ 绑定好工作区的 tool var 向量,直接放进 build-chat-client / simple-agent 的 :tools。

w-or-opts:工作区(`workspace` 的结果)或其选项 map(:root 等)。
opts(可省,也可直接并在 w-or-opts 里):
- :groups  组集合(缺省 #{:files};:all = 全部可用的组)
- :only    只要这些工具名(字符串集合)
- :exclude 不要这些工具名

校验:开了 :exec 却没给 {:exec {:backend ..}} / {:exec {:runner ..}} ⇒ 抛;开了 :notes 却没给 :notes 存储 ⇒ 抛。
sourceraw docstring

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