MCPcopy
hub / github.com/anomalyco/opencode / agentHost

Function agentHost

packages/core/test/plugin/host.ts:55–77  ·  view source on GitHub ↗
(agent: AgentV2.Interface)

Source from the content-addressed store, hash-verified

53}
54
55export function agentHost(agent: AgentV2.Interface): PluginContext["agent"] {
56 return {
57 reload: agent.reload,
58 transform: (callback) =>
59 agent.transform((draft) =>
60 callback({
61 list: () => draft.list().map(agentInfo),
62 get: (id) => {
63 const value = draft.get(AgentV2.ID.make(id))
64 return value && agentInfo(value)
65 },
66 default: (id) => draft.default(id === undefined ? undefined : AgentV2.ID.make(id)),
67 update: (id, update) =>
68 draft.update(AgentV2.ID.make(id), (value) => {
69 const current = agentInfo(value)
70 update(current)
71 Object.assign(value, current, { id: AgentV2.ID.make(current.id) })
72 }),
73 remove: (id) => draft.remove(AgentV2.ID.make(id)),
74 }),
75 ),
76 }
77}
78
79export function catalogHost(catalog: Catalog.Interface): PluginContext["catalog"] {
80 return {

Callers 2

agent.test.tsFile · 0.90
agent.test.tsFile · 0.90

Calls 10

agentInfoFunction · 0.85
defaultMethod · 0.80
listMethod · 0.65
getMethod · 0.65
updateMethod · 0.65
removeMethod · 0.65
callbackFunction · 0.50
updateFunction · 0.50
transformMethod · 0.45
makeMethod · 0.45

Tested by

no test coverage detected