-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy path16d-credentials-gh-cli.ts
More file actions
59 lines (53 loc) · 2.04 KB
/
Copy path16d-credentials-gh-cli.ts
File metadata and controls
59 lines (53 loc) · 2.04 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
/**
* Credentials -- GitHub CLI (gh) with automatic credential injection.
*
* Demonstrates:
* - cliConfig with allowedCommands: ["gh"] gives the agent a run_command tool
* - credentials: ["GH_TOKEN"] auto-injects the token into the tool env
* - The agent calls `gh` commands directly -- no subprocess boilerplate needed
*
* Setup (one-time, via CLI):
* conductor config save
* conductor secret put GH_TOKEN <your-gh-token>
*
* Requirements:
* - Conductor server running at CONDUCTOR_SERVER_URL
* - CONDUCTOR_AGENT_LLM_MODEL set (or defaults to openai/gpt-4o-mini)
* - `gh` CLI installed (https://cli.github.com)
* - GH_TOKEN stored via `conductor secret put`
*/
import { Agent, AgentRuntime } from '@io-orkes/conductor-javascript/agents';
import { llmModel } from './settings';
export const agent = new Agent({
name: 'github_cli_agent',
model: llmModel,
cliConfig: { enabled: true, allowedCommands: ['gh'] },
credentials: ['GH_TOKEN'],
instructions:
'You are a GitHub assistant that uses the `gh` CLI tool. ' +
'GH_TOKEN is already set in the environment -- gh will use it automatically. ' +
'Use --json for structured output when listing repos, issues, or PRs. ' +
'Always confirm with the user before creating issues or PRs.',
});
// -- Run ----------------------------------------------------------------------
async function main() {
const runtime = new AgentRuntime();
try {
const result = await runtime.run(
agent,
"List the 5 most recently updated repos for the 'agentspan' and list the URL for the repo",
);
result.printResult();
// Production pattern:
// 1. Deploy once during CI/CD (optional -- serve() below also deploys):
// await runtime.deploy(agent);
// CLI alternative:
// conductor deploy --package examples/agents --agents github_cli_agent
//
// 2. In a separate long-lived worker process (deploys + registers workers + starts polling):
// await runtime.serve(agent);
} finally {
await runtime.shutdown();
}
}
main().catch(console.error);