@gobing-ai/ts-ai-runner 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +165 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,3 +1,167 @@
|
|
|
1
1
|
# @gobing-ai/ts-ai-runner
|
|
2
2
|
|
|
3
|
-
Coding-agent command shims, detection, doctor checks, and prompt execution for
|
|
3
|
+
Coding-agent command shims, installation detection, doctor checks, slash-command translation, and prompt execution for downstream CLIs.
|
|
4
|
+
|
|
5
|
+
## What It Provides
|
|
6
|
+
|
|
7
|
+
`ts-ai-runner` normalizes the command-line surface of common coding agents so application code can work with stable TypeScript APIs instead of hard-coded executable arguments.
|
|
8
|
+
|
|
9
|
+
| Export | Purpose |
|
|
10
|
+
|--------|---------|
|
|
11
|
+
| `AiRunner` | Runs help, version, auth, and prompt commands through a pluggable process executor |
|
|
12
|
+
| `AgentDetector` | Probes supported agent CLIs and parses version output |
|
|
13
|
+
| `DoctorRunner` | Combines installation and authentication checks into a usability report |
|
|
14
|
+
| `getAgentShim()` | Returns the pure command builder for one supported agent |
|
|
15
|
+
| `translateSlashCommand()` | Converts Claude-style `/plugin:command` inputs to each agent's dialect |
|
|
16
|
+
|
|
17
|
+
Supported agent identifiers are `claude`, `codex`, `gemini`, `pi`, `opencode`, `antigravity`, and `openclaw`.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
bun add @gobing-ai/ts-ai-runner
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The package depends on `@gobing-ai/ts-runtime` for process execution. The target agent CLIs are not bundled; install them separately in the host environment.
|
|
26
|
+
|
|
27
|
+
## Detect Installed Agents
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { AgentDetector } from '@gobing-ai/ts-ai-runner';
|
|
31
|
+
|
|
32
|
+
const detector = new AgentDetector({ timeout: 5_000 });
|
|
33
|
+
const agents = await detector.detectAll();
|
|
34
|
+
|
|
35
|
+
for (const agent of agents) {
|
|
36
|
+
console.log(agent.name, agent.installed, agent.version, agent.error);
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Probe a single agent when you already know the target:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
const codex = await detector.detectOne('codex');
|
|
44
|
+
if (!codex.installed) {
|
|
45
|
+
throw new Error(codex.error ?? 'codex is not installed');
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Unknown agent names are reported as unavailable rather than throwing.
|
|
50
|
+
|
|
51
|
+
## Run Agent Commands
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import { AiRunner } from '@gobing-ai/ts-ai-runner';
|
|
55
|
+
|
|
56
|
+
const runner = new AiRunner({
|
|
57
|
+
defaultCwd: '/workspace/project',
|
|
58
|
+
defaultTimeout: 60_000,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const result = await runner.runPromptCommand('codex', {
|
|
62
|
+
input: 'Review packages/runtime/src/fs.ts',
|
|
63
|
+
model: 'gpt-5',
|
|
64
|
+
mode: 'text',
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
if (result.exitCode !== 0) {
|
|
68
|
+
throw new Error(result.stderr);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
console.log(result.stdout);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`AiRunner` captures `stdout`, `stderr`, `exitCode`, optional termination `signal`, and `durationMs`. It does not throw on non-zero agent exits; callers decide how to handle failures.
|
|
75
|
+
|
|
76
|
+
## Inject a Process Executor
|
|
77
|
+
|
|
78
|
+
For tests, dry runs, or sandboxed launchers, inject a `ProcessExecutor` from `@gobing-ai/ts-runtime`:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import type { ProcessExecutor } from '@gobing-ai/ts-runtime';
|
|
82
|
+
import { AiRunner } from '@gobing-ai/ts-ai-runner';
|
|
83
|
+
|
|
84
|
+
const processExecutor: ProcessExecutor = {
|
|
85
|
+
async run(options) {
|
|
86
|
+
return {
|
|
87
|
+
exitCode: 0,
|
|
88
|
+
stdout: `${options.command} ${options.args.join(' ')}`,
|
|
89
|
+
stderr: '',
|
|
90
|
+
durationMs: 1,
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const runner = new AiRunner({ processExecutor });
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Doctor Checks
|
|
99
|
+
|
|
100
|
+
`DoctorRunner` verifies both installation and authentication state. Auth checks use each agent's native command when available, and known credential files or environment variables when the CLI has no auth-status command.
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import { DoctorRunner } from '@gobing-ai/ts-ai-runner';
|
|
104
|
+
|
|
105
|
+
const doctor = new DoctorRunner();
|
|
106
|
+
const report = await doctor.runAll();
|
|
107
|
+
|
|
108
|
+
const usable = report.filter((agent) => agent.usable);
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Each result includes:
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
interface DoctorResult {
|
|
115
|
+
agent: string;
|
|
116
|
+
installed: boolean;
|
|
117
|
+
version: string | null;
|
|
118
|
+
authenticated: boolean;
|
|
119
|
+
usable: boolean;
|
|
120
|
+
tier: 1 | 2;
|
|
121
|
+
channels: string[];
|
|
122
|
+
error: string | null;
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Tier `1` agents support direct prompt-style CLI execution. Tier `2` agents are gateway or TUI constrained and may require adapter logic in the downstream app.
|
|
127
|
+
|
|
128
|
+
## Slash Command Translation
|
|
129
|
+
|
|
130
|
+
Claude-style plugin commands use `/plugin:command args`. Other agents expose different command syntaxes. Use `translateSlashCommand()` before sending user-entered slash commands to a target agent:
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
import { translateSlashCommand } from '@gobing-ai/ts-ai-runner';
|
|
134
|
+
|
|
135
|
+
translateSlashCommand('claude', '/rd3:dev-fixall bun run check');
|
|
136
|
+
// /rd3:dev-fixall bun run check
|
|
137
|
+
|
|
138
|
+
translateSlashCommand('codex', '/rd3:dev-fixall bun run check');
|
|
139
|
+
// $rd3-dev-fixall bun run check
|
|
140
|
+
|
|
141
|
+
translateSlashCommand('pi', '/rd3:dev-fixall bun run check');
|
|
142
|
+
// /skill:rd3-dev-fixall bun run check
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Non-slash input is returned unchanged.
|
|
146
|
+
|
|
147
|
+
## Command Shims
|
|
148
|
+
|
|
149
|
+
If you need to inspect command construction without launching a process, use the pure shim API:
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
import { getAgentShim } from '@gobing-ai/ts-ai-runner';
|
|
153
|
+
|
|
154
|
+
const shim = getAgentShim('codex');
|
|
155
|
+
const command = shim.getPromptCommand({ input: 'Summarize this repository' });
|
|
156
|
+
|
|
157
|
+
console.log(command.command, command.args);
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
This is the right layer for UI previews, audit logging, and custom launchers.
|
|
161
|
+
|
|
162
|
+
## Boundary Notes
|
|
163
|
+
|
|
164
|
+
- This package is a command adapter, not an agent orchestration framework.
|
|
165
|
+
- It does not install agent CLIs or manage credentials.
|
|
166
|
+
- It does not parse agent responses beyond process result capture.
|
|
167
|
+
- It keeps subprocess launching behind `ProcessExecutor`, so tests can stay deterministic.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gobing-ai/ts-ai-runner",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "@gobing-ai/ts-ai-runner — Coding-agent shims, detection, doctor checks, and prompt execution.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"release": "echo 'Manual publish is disabled. Releases go through GitHub Actions via Trusted Publishing — push a tag: git tag @gobing-ai/ts-ai-runner-v<version> && git push --tags' && exit 1"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@gobing-ai/ts-runtime": "^0.2.
|
|
50
|
+
"@gobing-ai/ts-runtime": "^0.2.8"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/bun": "1.3.14"
|