-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathindex.ts
More file actions
67 lines (65 loc) · 2.45 KB
/
Copy pathindex.ts
File metadata and controls
67 lines (65 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* App-specific frontend tools. Provider defaults are added per turn by
* `app/channel-helpers.ts`.
*
* Add new tools here and include them in `appTools`. Wire the array into
* `createChannel({ tools })`.
*/
import {
blockCatalogTool,
isBlockCatalogEnabled,
} from "./block-catalog.js";
import { connectAppTool } from "./connect-app.js";
import { readThreadTool } from "./read-thread.js";
import { createShowCapabilitiesTool } from "./capabilities.js";
import { renderDiagramTool } from "./render-diagram.js";
import { renderTableTool } from "./render-table.js";
import { issueCardTool, issueListTool, pageListTool } from "./render-tools.js";
import {
showIncidentTool,
showStatusTool,
showLinksTool,
showWorkPlanTool,
showDecisionBriefTool,
showKnowledgeSummaryTool,
} from "./showcase-tools.js";
import type { ChannelTool } from "@copilotkit/channels";
import { DEFAULT_AGENT_DISPLAY_NAME } from "../env.js";
/**
* Every tool is a plain `ChannelTool`: its handler receives the generic
* `ChannelToolContext` (`{ thread, message?, user?, signal?, platform }`) the
* adapter supplies at call time. Platform power (post/stream/postFile,
* `thread.getMessages()`, `thread.lookupUser()`, …) is reached via the
* `thread` methods, so there's no per-adapter context and no cast needed —
* the array assigns straight into `createChannel({ tools })`.
*/
export function createAppTools(
agentDisplayName = DEFAULT_AGENT_DISPLAY_NAME,
env: NodeJS.ProcessEnv = process.env,
): ChannelTool[] {
return [
readThreadTool,
createShowCapabilitiesTool(agentDisplayName),
renderDiagramTool,
renderTableTool,
issueCardTool,
issueListTool,
pageListTool,
showIncidentTool,
showStatusTool,
showLinksTool,
showWorkPlanTool,
showDecisionBriefTool,
showKnowledgeSummaryTool,
// Registered unconditionally. Which apps a person can connect is the
// agent's configuration, not the runtime's — on a two-service deployment the
// toolkit lists are set on the agent alone — so the surface offers the
// button and the agent decides when asking for one makes sense.
connectAppTool,
// Off by default, and *absent* rather than refusing when off: a tool the
// agent can see but must not call leaks into its reasoning and turns into
// "I can't do that here" instead of the topic not existing.
...(isBlockCatalogEnabled(env) ? [blockCatalogTool] : []),
];
}
export const appTools = createAppTools();