@ap3x/cli 0.1.0
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/LICENSE +21 -0
- package/README.md +34 -0
- package/dist/agent-session.d.ts +163 -0
- package/dist/agent-session.d.ts.map +1 -0
- package/dist/auth/anthropic-login.d.ts +98 -0
- package/dist/auth/anthropic-login.d.ts.map +1 -0
- package/dist/auth/codex-login.d.ts +80 -0
- package/dist/auth/codex-login.d.ts.map +1 -0
- package/dist/auth/copilot-login.d.ts +36 -0
- package/dist/auth/copilot-login.d.ts.map +1 -0
- package/dist/auth/login-dispatch.d.ts +76 -0
- package/dist/auth/login-dispatch.d.ts.map +1 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +15 -0
- package/dist/branding.d.ts +89 -0
- package/dist/branding.d.ts.map +1 -0
- package/dist/chunk-3WSVGI7R.js +10522 -0
- package/dist/cli.d.ts +135 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cron/agent-executor.d.ts +45 -0
- package/dist/cron/agent-executor.d.ts.map +1 -0
- package/dist/cron/cron-cli.d.ts +27 -0
- package/dist/cron/cron-cli.d.ts.map +1 -0
- package/dist/cron/schedule-file.d.ts +7 -0
- package/dist/cron/schedule-file.d.ts.map +1 -0
- package/dist/glob.d.ts +12 -0
- package/dist/glob.d.ts.map +1 -0
- package/dist/hooks/hooks-cli.d.ts +11 -0
- package/dist/hooks/hooks-cli.d.ts.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +462 -0
- package/dist/modes/index.d.ts +5 -0
- package/dist/modes/index.d.ts.map +1 -0
- package/dist/modes/interactive.d.ts +44 -0
- package/dist/modes/interactive.d.ts.map +1 -0
- package/dist/modes/print.d.ts +24 -0
- package/dist/modes/print.d.ts.map +1 -0
- package/dist/modes/render.d.ts +29 -0
- package/dist/modes/render.d.ts.map +1 -0
- package/dist/modes/rpc.d.ts +149 -0
- package/dist/modes/rpc.d.ts.map +1 -0
- package/dist/sdk.d.ts +95 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/settings.d.ts +109 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/skills.d.ts +27 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/slash-commands.d.ts +79 -0
- package/dist/slash-commands.d.ts.map +1 -0
- package/dist/system-prompt.d.ts +21 -0
- package/dist/system-prompt.d.ts.map +1 -0
- package/dist/tools/a2a.d.ts +11 -0
- package/dist/tools/a2a.d.ts.map +1 -0
- package/dist/tools/bash.d.ts +4 -0
- package/dist/tools/bash.d.ts.map +1 -0
- package/dist/tools/context.d.ts +42 -0
- package/dist/tools/context.d.ts.map +1 -0
- package/dist/tools/edit.d.ts +16 -0
- package/dist/tools/edit.d.ts.map +1 -0
- package/dist/tools/find.d.ts +9 -0
- package/dist/tools/find.d.ts.map +1 -0
- package/dist/tools/grep.d.ts +9 -0
- package/dist/tools/grep.d.ts.map +1 -0
- package/dist/tools/index.d.ts +35 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/ls.d.ts +5 -0
- package/dist/tools/ls.d.ts.map +1 -0
- package/dist/tools/read.d.ts +9 -0
- package/dist/tools/read.d.ts.map +1 -0
- package/dist/tools/swarm.d.ts +42 -0
- package/dist/tools/swarm.d.ts.map +1 -0
- package/dist/tools/walk.d.ts +48 -0
- package/dist/tools/walk.d.ts.map +1 -0
- package/dist/tools/write.d.ts +9 -0
- package/dist/tools/write.d.ts.map +1 -0
- package/dist/trace/trace-cli.d.ts +9 -0
- package/dist/trace/trace-cli.d.ts.map +1 -0
- package/dist/utils/clipboard.d.ts +23 -0
- package/dist/utils/clipboard.d.ts.map +1 -0
- package/dist/utils/git.d.ts +13 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/highlight.d.ts +23 -0
- package/dist/utils/highlight.d.ts.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/resume.d.ts +9 -0
- package/dist/utils/resume.d.ts.map +1 -0
- package/dist/utils/version-check.d.ts +34 -0
- package/dist/utils/version-check.d.ts.map +1 -0
- package/package.json +45 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ALL_TOOL_NAMES,
|
|
3
|
+
APP_NAME,
|
|
4
|
+
AgentSession,
|
|
5
|
+
AgentSessionRuntime,
|
|
6
|
+
ArgError,
|
|
7
|
+
BUILTIN_SLASH_COMMANDS,
|
|
8
|
+
CONFIG_DIR_NAME,
|
|
9
|
+
CRON_DIR_NAME,
|
|
10
|
+
CronAgentExecutor,
|
|
11
|
+
CronPayloadSchema,
|
|
12
|
+
DEFAULT_ANTHROPIC_CALLBACK_PORTS,
|
|
13
|
+
DEFAULT_CALLBACK_PORTS,
|
|
14
|
+
DEFAULT_SETTINGS,
|
|
15
|
+
DISPLAY_NAME,
|
|
16
|
+
ENV_CONFIG_DIR,
|
|
17
|
+
ENV_PREFIX,
|
|
18
|
+
HOOKS_FILE_NAME,
|
|
19
|
+
InteractiveMode,
|
|
20
|
+
LOGS_DIR_NAME,
|
|
21
|
+
READ_ONLY_TOOL_NAMES,
|
|
22
|
+
RPC_COMMANDS,
|
|
23
|
+
RpcClient,
|
|
24
|
+
RpcCommandSchema,
|
|
25
|
+
SESSIONS_DIR_NAME,
|
|
26
|
+
SETTINGS_FILE_NAME,
|
|
27
|
+
SKILLS_DIR_NAME,
|
|
28
|
+
SettingsManager,
|
|
29
|
+
TRACES_DIR_NAME,
|
|
30
|
+
VERSION,
|
|
31
|
+
argsToSettings,
|
|
32
|
+
assistantText,
|
|
33
|
+
buildCodingAgentSystemPrompt,
|
|
34
|
+
composeSystemPromptWithSkills,
|
|
35
|
+
createA2aTools,
|
|
36
|
+
createAgentSession,
|
|
37
|
+
createAgentSessionFromServices,
|
|
38
|
+
createAgentSessionRuntime,
|
|
39
|
+
createAgentSessionRuntimeFromServices,
|
|
40
|
+
createAgentSessionServices,
|
|
41
|
+
createAllTools,
|
|
42
|
+
createAutoSwarmTool,
|
|
43
|
+
createBashTool,
|
|
44
|
+
createBuildAgentTool,
|
|
45
|
+
createCallAgentTool,
|
|
46
|
+
createCodingTools,
|
|
47
|
+
createEditTool,
|
|
48
|
+
createFindTool,
|
|
49
|
+
createGrepTool,
|
|
50
|
+
createLsTool,
|
|
51
|
+
createReadOnlyTools,
|
|
52
|
+
createReadTool,
|
|
53
|
+
createRunSwarmTool,
|
|
54
|
+
createSwarmTools,
|
|
55
|
+
createToolContext,
|
|
56
|
+
createWriteTool,
|
|
57
|
+
defaultOpenBrowser,
|
|
58
|
+
dispatchSlashCommand,
|
|
59
|
+
findSlashCommand,
|
|
60
|
+
frameResponse,
|
|
61
|
+
globToRegExp,
|
|
62
|
+
isSlashCommand,
|
|
63
|
+
loadSkillsFromDir,
|
|
64
|
+
loginAnthropic,
|
|
65
|
+
loginGitHubCopilot,
|
|
66
|
+
loginWithChatGPT,
|
|
67
|
+
logoutAnthropic,
|
|
68
|
+
logoutCodex,
|
|
69
|
+
main,
|
|
70
|
+
mergeSettings,
|
|
71
|
+
minimatch,
|
|
72
|
+
nodeRpcInput,
|
|
73
|
+
nodeRpcOutput,
|
|
74
|
+
parseArgs,
|
|
75
|
+
parseAuthorizationInput,
|
|
76
|
+
parsePartialSettings,
|
|
77
|
+
parseRpcLine,
|
|
78
|
+
printCronHelp,
|
|
79
|
+
printHelp,
|
|
80
|
+
printHooksHelp,
|
|
81
|
+
printTraceHelp,
|
|
82
|
+
printVersion,
|
|
83
|
+
refreshAnthropic,
|
|
84
|
+
renderAgentEvent,
|
|
85
|
+
renderUsage,
|
|
86
|
+
resolveConfigDir,
|
|
87
|
+
resolveCronDir,
|
|
88
|
+
resolveEnvContext,
|
|
89
|
+
resolveHooksPath,
|
|
90
|
+
resolveLogsDir,
|
|
91
|
+
resolveRuntime,
|
|
92
|
+
resolveSessionsDir,
|
|
93
|
+
resolveSettingsPath,
|
|
94
|
+
resolveSkillsDir,
|
|
95
|
+
resolveTracesDir,
|
|
96
|
+
runCronCli,
|
|
97
|
+
runHooksCli,
|
|
98
|
+
runPrintMode,
|
|
99
|
+
runRpcMode,
|
|
100
|
+
runTraceCli,
|
|
101
|
+
selectTools,
|
|
102
|
+
settingsFromEnv,
|
|
103
|
+
startRealAnthropicLoopbackServer,
|
|
104
|
+
startRealLoopbackServer,
|
|
105
|
+
toPrintJson,
|
|
106
|
+
welcomeBanner,
|
|
107
|
+
withFileMutationQueue
|
|
108
|
+
} from "./chunk-3WSVGI7R.js";
|
|
109
|
+
|
|
110
|
+
// src/utils/resume.ts
|
|
111
|
+
function formatResumeCommand(sessionId) {
|
|
112
|
+
return `${APP_NAME} --resume ${sessionId}`;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// src/utils/git.ts
|
|
116
|
+
import { execFile } from "child_process";
|
|
117
|
+
var defaultGitRunner = (args, cwd) => new Promise((resolve) => {
|
|
118
|
+
execFile("git", args, { cwd, windowsHide: true }, (error, stdout) => {
|
|
119
|
+
if (error) {
|
|
120
|
+
resolve(void 0);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
resolve(stdout.toString().trim());
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
async function repoRoot(cwd = process.cwd(), run = defaultGitRunner) {
|
|
127
|
+
const out = await run(["rev-parse", "--show-toplevel"], cwd);
|
|
128
|
+
return out && out.length > 0 ? out : void 0;
|
|
129
|
+
}
|
|
130
|
+
async function currentBranch(cwd = process.cwd(), run = defaultGitRunner) {
|
|
131
|
+
const out = await run(["rev-parse", "--abbrev-ref", "HEAD"], cwd);
|
|
132
|
+
if (!out || out.length === 0 || out === "HEAD") return void 0;
|
|
133
|
+
return out;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// src/utils/clipboard.ts
|
|
137
|
+
import { spawn } from "child_process";
|
|
138
|
+
import { platform } from "os";
|
|
139
|
+
var defaultRunner = (command, args, text) => new Promise((resolve) => {
|
|
140
|
+
try {
|
|
141
|
+
const child = spawn(command, args, {
|
|
142
|
+
stdio: ["pipe", "ignore", "ignore"],
|
|
143
|
+
windowsHide: true
|
|
144
|
+
});
|
|
145
|
+
child.on("error", () => resolve(false));
|
|
146
|
+
child.on("close", (code) => resolve(code === 0));
|
|
147
|
+
child.stdin.on("error", () => resolve(false));
|
|
148
|
+
child.stdin.end(text);
|
|
149
|
+
} catch {
|
|
150
|
+
resolve(false);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
function clipboardCommand(os) {
|
|
154
|
+
switch (os) {
|
|
155
|
+
case "darwin":
|
|
156
|
+
return { command: "pbcopy", args: [] };
|
|
157
|
+
case "win32":
|
|
158
|
+
return { command: "clip", args: [] };
|
|
159
|
+
default:
|
|
160
|
+
return { command: "xclip", args: ["-selection", "clipboard"] };
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
async function copyToClipboard(text, options = {}) {
|
|
164
|
+
const os = options.os ?? platform();
|
|
165
|
+
const runner = options.runner ?? defaultRunner;
|
|
166
|
+
const resolved = clipboardCommand(os);
|
|
167
|
+
if (!resolved) return false;
|
|
168
|
+
return runner(resolved.command, resolved.args, text);
|
|
169
|
+
}
|
|
170
|
+
var noopClipboard = {
|
|
171
|
+
copy: async () => false
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// src/utils/version-check.ts
|
|
175
|
+
function compareVersions(a, b) {
|
|
176
|
+
const pa = a.split(".").map((n) => Number.parseInt(n, 10) || 0);
|
|
177
|
+
const pb = b.split(".").map((n) => Number.parseInt(n, 10) || 0);
|
|
178
|
+
const len = Math.max(pa.length, pb.length);
|
|
179
|
+
for (let i = 0; i < len; i++) {
|
|
180
|
+
const x = pa[i] ?? 0;
|
|
181
|
+
const y = pb[i] ?? 0;
|
|
182
|
+
if (x !== y) return x < y ? -1 : 1;
|
|
183
|
+
}
|
|
184
|
+
return 0;
|
|
185
|
+
}
|
|
186
|
+
async function checkForUpdate(options = {}) {
|
|
187
|
+
const current = options.current ?? VERSION;
|
|
188
|
+
if (!options.source || !options.fetcher) {
|
|
189
|
+
return { current, updateAvailable: false, skipped: "no version source configured" };
|
|
190
|
+
}
|
|
191
|
+
try {
|
|
192
|
+
const latest = (await options.fetcher(options.source, options.signal)).trim();
|
|
193
|
+
return {
|
|
194
|
+
current,
|
|
195
|
+
latest,
|
|
196
|
+
updateAvailable: compareVersions(current, latest) < 0
|
|
197
|
+
};
|
|
198
|
+
} catch (error) {
|
|
199
|
+
return {
|
|
200
|
+
current,
|
|
201
|
+
updateAvailable: false,
|
|
202
|
+
skipped: error instanceof Error ? error.message : String(error)
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// src/utils/highlight.ts
|
|
208
|
+
var ANSI = {
|
|
209
|
+
keyword: "\x1B[35m",
|
|
210
|
+
string: "\x1B[32m",
|
|
211
|
+
comment: "\x1B[90m",
|
|
212
|
+
number: "\x1B[33m",
|
|
213
|
+
reset: "\x1B[0m"
|
|
214
|
+
};
|
|
215
|
+
var NO_HIGHLIGHT = {
|
|
216
|
+
keyword: "",
|
|
217
|
+
string: "",
|
|
218
|
+
comment: "",
|
|
219
|
+
number: "",
|
|
220
|
+
reset: ""
|
|
221
|
+
};
|
|
222
|
+
var KEYWORDS = /* @__PURE__ */ new Set([
|
|
223
|
+
"const",
|
|
224
|
+
"let",
|
|
225
|
+
"var",
|
|
226
|
+
"function",
|
|
227
|
+
"return",
|
|
228
|
+
"if",
|
|
229
|
+
"else",
|
|
230
|
+
"for",
|
|
231
|
+
"while",
|
|
232
|
+
"import",
|
|
233
|
+
"export",
|
|
234
|
+
"from",
|
|
235
|
+
"class",
|
|
236
|
+
"extends",
|
|
237
|
+
"new",
|
|
238
|
+
"async",
|
|
239
|
+
"await",
|
|
240
|
+
"try",
|
|
241
|
+
"catch",
|
|
242
|
+
"finally",
|
|
243
|
+
"throw",
|
|
244
|
+
"type",
|
|
245
|
+
"interface",
|
|
246
|
+
"enum",
|
|
247
|
+
"def",
|
|
248
|
+
"fn",
|
|
249
|
+
"pub",
|
|
250
|
+
"use",
|
|
251
|
+
"match",
|
|
252
|
+
"struct",
|
|
253
|
+
"impl",
|
|
254
|
+
"true",
|
|
255
|
+
"false",
|
|
256
|
+
"null",
|
|
257
|
+
"undefined",
|
|
258
|
+
"void",
|
|
259
|
+
"this",
|
|
260
|
+
"super",
|
|
261
|
+
"yield",
|
|
262
|
+
"break",
|
|
263
|
+
"continue"
|
|
264
|
+
]);
|
|
265
|
+
function highlight(code, theme = ANSI) {
|
|
266
|
+
if (theme === NO_HIGHLIGHT) return code;
|
|
267
|
+
return code.split("\n").map((line) => highlightLine(line, theme)).join("\n");
|
|
268
|
+
}
|
|
269
|
+
function highlightLine(line, theme) {
|
|
270
|
+
const commentMatch = line.match(/(\/\/|#).*$/);
|
|
271
|
+
let head = line;
|
|
272
|
+
let comment = "";
|
|
273
|
+
if (commentMatch && commentMatch.index !== void 0) {
|
|
274
|
+
head = line.slice(0, commentMatch.index);
|
|
275
|
+
comment = `${theme.comment}${commentMatch[0]}${theme.reset}`;
|
|
276
|
+
}
|
|
277
|
+
const colored = head.replace(/"[^"\n]*"|'[^'\n]*'/g, (m) => `${theme.string}${m}${theme.reset}`).replace(/\b\d+(?:\.\d+)?\b/g, (m) => `${theme.number}${m}${theme.reset}`).replace(
|
|
278
|
+
/\b[A-Za-z_]\w*\b/g,
|
|
279
|
+
(m) => KEYWORDS.has(m) ? `${theme.keyword}${m}${theme.reset}` : m
|
|
280
|
+
);
|
|
281
|
+
return colored + comment;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// src/index.ts
|
|
285
|
+
import {
|
|
286
|
+
MODELS,
|
|
287
|
+
getModel,
|
|
288
|
+
getModels,
|
|
289
|
+
getProviders,
|
|
290
|
+
getSupportedThinkingLevels,
|
|
291
|
+
clampThinkingLevel,
|
|
292
|
+
modelsAreEqual,
|
|
293
|
+
calculateCost,
|
|
294
|
+
getEnvApiKey,
|
|
295
|
+
findEnvKeys
|
|
296
|
+
} from "@ap3x/ai";
|
|
297
|
+
import {
|
|
298
|
+
Session,
|
|
299
|
+
createSessionId,
|
|
300
|
+
buildSessionContext,
|
|
301
|
+
InMemorySessionStorage,
|
|
302
|
+
JsonlSessionStorage
|
|
303
|
+
} from "@ap3x/agent-core";
|
|
304
|
+
import {
|
|
305
|
+
compact,
|
|
306
|
+
shouldCompact,
|
|
307
|
+
estimateContextTokens,
|
|
308
|
+
DEFAULT_COMPACTION_SETTINGS
|
|
309
|
+
} from "@ap3x/agent-core";
|
|
310
|
+
import {
|
|
311
|
+
Ap3xRuntimeBackend,
|
|
312
|
+
createRuntimeBackend,
|
|
313
|
+
Agent,
|
|
314
|
+
defineTool
|
|
315
|
+
} from "@ap3x/agent-core";
|
|
316
|
+
import { matchBlocklist, isBlockedCommand } from "@ap3x/agent-core";
|
|
317
|
+
var PACKAGE = "@ap3x/cli";
|
|
318
|
+
var VERSION2 = "0.1.0";
|
|
319
|
+
export {
|
|
320
|
+
ALL_TOOL_NAMES,
|
|
321
|
+
APP_NAME,
|
|
322
|
+
Agent,
|
|
323
|
+
AgentSession,
|
|
324
|
+
AgentSessionRuntime,
|
|
325
|
+
Ap3xRuntimeBackend,
|
|
326
|
+
ArgError,
|
|
327
|
+
BUILTIN_SLASH_COMMANDS,
|
|
328
|
+
CONFIG_DIR_NAME,
|
|
329
|
+
CRON_DIR_NAME,
|
|
330
|
+
CronAgentExecutor,
|
|
331
|
+
CronPayloadSchema,
|
|
332
|
+
DEFAULT_ANTHROPIC_CALLBACK_PORTS,
|
|
333
|
+
DEFAULT_CALLBACK_PORTS,
|
|
334
|
+
DEFAULT_COMPACTION_SETTINGS,
|
|
335
|
+
DEFAULT_SETTINGS,
|
|
336
|
+
DISPLAY_NAME,
|
|
337
|
+
ENV_CONFIG_DIR,
|
|
338
|
+
ENV_PREFIX,
|
|
339
|
+
HOOKS_FILE_NAME,
|
|
340
|
+
InMemorySessionStorage,
|
|
341
|
+
InteractiveMode,
|
|
342
|
+
JsonlSessionStorage,
|
|
343
|
+
LOGS_DIR_NAME,
|
|
344
|
+
MODELS,
|
|
345
|
+
NO_HIGHLIGHT,
|
|
346
|
+
PACKAGE,
|
|
347
|
+
READ_ONLY_TOOL_NAMES,
|
|
348
|
+
RPC_COMMANDS,
|
|
349
|
+
RpcClient,
|
|
350
|
+
RpcCommandSchema,
|
|
351
|
+
SESSIONS_DIR_NAME,
|
|
352
|
+
SETTINGS_FILE_NAME,
|
|
353
|
+
SKILLS_DIR_NAME,
|
|
354
|
+
Session,
|
|
355
|
+
SettingsManager,
|
|
356
|
+
TRACES_DIR_NAME,
|
|
357
|
+
VERSION2 as VERSION,
|
|
358
|
+
argsToSettings,
|
|
359
|
+
assistantText,
|
|
360
|
+
buildCodingAgentSystemPrompt,
|
|
361
|
+
buildSessionContext,
|
|
362
|
+
calculateCost,
|
|
363
|
+
checkForUpdate,
|
|
364
|
+
clampThinkingLevel,
|
|
365
|
+
compact,
|
|
366
|
+
composeSystemPromptWithSkills,
|
|
367
|
+
copyToClipboard,
|
|
368
|
+
createA2aTools,
|
|
369
|
+
createAgentSession,
|
|
370
|
+
createAgentSessionFromServices,
|
|
371
|
+
createAgentSessionRuntime,
|
|
372
|
+
createAgentSessionRuntimeFromServices,
|
|
373
|
+
createAgentSessionServices,
|
|
374
|
+
createAllTools,
|
|
375
|
+
createAutoSwarmTool,
|
|
376
|
+
createBashTool,
|
|
377
|
+
createBuildAgentTool,
|
|
378
|
+
createCallAgentTool,
|
|
379
|
+
createCodingTools,
|
|
380
|
+
createEditTool,
|
|
381
|
+
createFindTool,
|
|
382
|
+
createGrepTool,
|
|
383
|
+
createLsTool,
|
|
384
|
+
createReadOnlyTools,
|
|
385
|
+
createReadTool,
|
|
386
|
+
createRunSwarmTool,
|
|
387
|
+
createRuntimeBackend,
|
|
388
|
+
createAgentSession as createSession,
|
|
389
|
+
createSessionId,
|
|
390
|
+
createSwarmTools,
|
|
391
|
+
createToolContext,
|
|
392
|
+
createWriteTool,
|
|
393
|
+
currentBranch,
|
|
394
|
+
defaultGitRunner,
|
|
395
|
+
defaultOpenBrowser,
|
|
396
|
+
defineTool,
|
|
397
|
+
dispatchSlashCommand,
|
|
398
|
+
estimateContextTokens,
|
|
399
|
+
findEnvKeys,
|
|
400
|
+
findSlashCommand,
|
|
401
|
+
formatResumeCommand,
|
|
402
|
+
frameResponse,
|
|
403
|
+
getEnvApiKey,
|
|
404
|
+
getModel,
|
|
405
|
+
getModels,
|
|
406
|
+
getProviders,
|
|
407
|
+
getSupportedThinkingLevels,
|
|
408
|
+
globToRegExp,
|
|
409
|
+
highlight,
|
|
410
|
+
isBlockedCommand,
|
|
411
|
+
isSlashCommand,
|
|
412
|
+
loadSkillsFromDir,
|
|
413
|
+
loginAnthropic,
|
|
414
|
+
loginGitHubCopilot,
|
|
415
|
+
loginWithChatGPT,
|
|
416
|
+
logoutAnthropic,
|
|
417
|
+
logoutCodex,
|
|
418
|
+
main,
|
|
419
|
+
matchBlocklist,
|
|
420
|
+
mergeSettings,
|
|
421
|
+
minimatch,
|
|
422
|
+
modelsAreEqual,
|
|
423
|
+
nodeRpcInput,
|
|
424
|
+
nodeRpcOutput,
|
|
425
|
+
noopClipboard,
|
|
426
|
+
parseArgs,
|
|
427
|
+
parseAuthorizationInput,
|
|
428
|
+
parsePartialSettings,
|
|
429
|
+
parseRpcLine,
|
|
430
|
+
printCronHelp,
|
|
431
|
+
printHelp,
|
|
432
|
+
printHooksHelp,
|
|
433
|
+
printTraceHelp,
|
|
434
|
+
printVersion,
|
|
435
|
+
refreshAnthropic,
|
|
436
|
+
renderAgentEvent,
|
|
437
|
+
renderUsage,
|
|
438
|
+
repoRoot,
|
|
439
|
+
resolveConfigDir,
|
|
440
|
+
resolveCronDir,
|
|
441
|
+
resolveEnvContext,
|
|
442
|
+
resolveHooksPath,
|
|
443
|
+
resolveLogsDir,
|
|
444
|
+
resolveRuntime,
|
|
445
|
+
resolveSessionsDir,
|
|
446
|
+
resolveSettingsPath,
|
|
447
|
+
resolveSkillsDir,
|
|
448
|
+
resolveTracesDir,
|
|
449
|
+
runCronCli,
|
|
450
|
+
runHooksCli,
|
|
451
|
+
runPrintMode,
|
|
452
|
+
runRpcMode,
|
|
453
|
+
runTraceCli,
|
|
454
|
+
selectTools,
|
|
455
|
+
settingsFromEnv,
|
|
456
|
+
shouldCompact,
|
|
457
|
+
startRealAnthropicLoopbackServer,
|
|
458
|
+
startRealLoopbackServer,
|
|
459
|
+
toPrintJson,
|
|
460
|
+
welcomeBanner,
|
|
461
|
+
withFileMutationQueue
|
|
462
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { InteractiveMode, welcomeBanner, type InteractiveModeOptions, type InteractiveInput, type InteractiveRenderer, } from "./interactive";
|
|
2
|
+
export { runPrintMode, type PrintModeOptions } from "./print";
|
|
3
|
+
export { runRpcMode, RpcClient, RpcCommandSchema, RPC_COMMANDS, parseRpcLine, frameResponse, nodeRpcInput, nodeRpcOutput, type RpcCommand, type RpcResponse, type RpcError, type RpcSessionState, type RpcInput, type RpcOutput, type RpcModeOptions, } from "./rpc";
|
|
4
|
+
export { renderAgentEvent, renderUsage, assistantText, toPrintJson, type PrintJsonResult, } from "./render";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/modes/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EACf,aAAa,EACb,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,GACzB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EACL,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,aAAa,EACb,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,cAAc,GACpB,MAAM,OAAO,CAAC;AACf,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,WAAW,EACX,KAAK,eAAe,GACrB,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { AgentSessionRuntime } from "../sdk";
|
|
2
|
+
import type { Settings, SettingsManager } from "../settings";
|
|
3
|
+
/**
|
|
4
|
+
* The interactive REPL. To keep it testable and free of a heavy TUI app loop
|
|
5
|
+
* (per the design note, a focused loop over injectable IO is preferred), it
|
|
6
|
+
* reads prompts from an injected {@link InteractiveInput}, renders streamed
|
|
7
|
+
* agent events through an injected {@link InteractiveRenderer}, dispatches slash
|
|
8
|
+
* commands vs. send-to-agent, and loops until input ends or `/quit`.
|
|
9
|
+
*/
|
|
10
|
+
/** Async source of user input lines. Returning `null` ends the session (EOF). */
|
|
11
|
+
export interface InteractiveInput {
|
|
12
|
+
/** Resolve the next line, or `null` at end-of-input. `prompt` is the visible cue. */
|
|
13
|
+
readLine(prompt: string): Promise<string | null>;
|
|
14
|
+
/** Optional cleanup (restore terminal mode, etc.). */
|
|
15
|
+
close?(): void;
|
|
16
|
+
}
|
|
17
|
+
/** Sink for rendered output. Separated from input so both mock cleanly. */
|
|
18
|
+
export interface InteractiveRenderer {
|
|
19
|
+
/** Print a finished line (a reply, a status, an error). */
|
|
20
|
+
line(text: string): void;
|
|
21
|
+
/** Optional: stream a partial chunk (defaults to {@link line} when absent). */
|
|
22
|
+
chunk?(text: string): void;
|
|
23
|
+
}
|
|
24
|
+
/** Options for {@link InteractiveMode}. */
|
|
25
|
+
export interface InteractiveModeOptions {
|
|
26
|
+
runtime: AgentSessionRuntime;
|
|
27
|
+
settings: SettingsManager;
|
|
28
|
+
resolved: Settings;
|
|
29
|
+
input: InteractiveInput;
|
|
30
|
+
renderer: InteractiveRenderer;
|
|
31
|
+
/** The prompt cue shown before each line. Default: "ap3x> ". */
|
|
32
|
+
promptCue?: string;
|
|
33
|
+
/** Print the welcome banner before the loop. Default: true. */
|
|
34
|
+
banner?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** The welcome banner (AP3X-branded). */
|
|
37
|
+
export declare function welcomeBanner(): string;
|
|
38
|
+
/**
|
|
39
|
+
* Run the interactive loop. Returns a process exit code (0 on a clean exit).
|
|
40
|
+
* Each iteration: read a line → if it's a slash command, dispatch it (and break
|
|
41
|
+
* on `/quit`); otherwise send it to the agent and render the streamed events.
|
|
42
|
+
*/
|
|
43
|
+
export declare function InteractiveMode(options: InteractiveModeOptions): Promise<number>;
|
|
44
|
+
//# sourceMappingURL=interactive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactive.d.ts","sourceRoot":"","sources":["../../src/modes/interactive.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAI7D;;;;;;GAMG;AAEH,iFAAiF;AACjF,MAAM,WAAW,gBAAgB;IAC/B,qFAAqF;IACrF,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACjD,sDAAsD;IACtD,KAAK,CAAC,IAAI,IAAI,CAAC;CAChB;AAED,2EAA2E;AAC3E,MAAM,WAAW,mBAAmB;IAClC,2DAA2D;IAC3D,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,+EAA+E;IAC/E,KAAK,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,2CAA2C;AAC3C,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,mBAAmB,CAAC;IAC7B,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,gBAAgB,CAAC;IACxB,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,yCAAyC;AACzC,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,CAoFtF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { CliIO, PrintFormat } from "../cli";
|
|
2
|
+
import type { AgentSessionRuntime } from "../sdk";
|
|
3
|
+
/** Options for {@link runPrintMode}. */
|
|
4
|
+
export interface PrintModeOptions {
|
|
5
|
+
/** The runtime to drive (already wired with model/tools/backend). */
|
|
6
|
+
runtime: AgentSessionRuntime;
|
|
7
|
+
/** The single prompt to run. */
|
|
8
|
+
prompt: string;
|
|
9
|
+
/** Output shape: plain text (default) or JSON. */
|
|
10
|
+
format?: PrintFormat;
|
|
11
|
+
/** Output sink (injectable for tests). */
|
|
12
|
+
io: CliIO;
|
|
13
|
+
/** Whether to append a usage summary in text mode. Default: false. */
|
|
14
|
+
showUsage?: boolean;
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Single-shot mode: run one task through the runtime and emit the final result.
|
|
19
|
+
* In `text` mode it writes the final assistant text (optionally followed by a
|
|
20
|
+
* usage line); in `json` mode it writes one stable JSON object. Returns a
|
|
21
|
+
* process exit code: 0 on success, 1 when the run errored, 2 on an exception.
|
|
22
|
+
*/
|
|
23
|
+
export declare function runPrintMode(options: PrintModeOptions): Promise<number>;
|
|
24
|
+
//# sourceMappingURL=print.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print.d.ts","sourceRoot":"","sources":["../../src/modes/print.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAGlD,wCAAwC;AACxC,MAAM,WAAW,gBAAgB;IAC/B,qEAAqE;IACrE,OAAO,EAAE,mBAAmB,CAAC;IAC7B,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,0CAA0C;IAC1C,EAAE,EAAE,KAAK,CAAC;IACV,sEAAsE;IACtE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CA4B7E"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { AgentEvent, AgentRunResult } from "@ap3x/agent-core";
|
|
2
|
+
import type { AssistantMessage, Usage } from "@ap3x/ai";
|
|
3
|
+
/**
|
|
4
|
+
* Pure projection of agent events into terminal-renderable strings. Keeping this
|
|
5
|
+
* separate from the IO loop means the interactive / print modes share one
|
|
6
|
+
* rendering contract, and it can be unit-tested without a terminal.
|
|
7
|
+
*/
|
|
8
|
+
/** Concatenate the text blocks of an assistant message into a single string. */
|
|
9
|
+
export declare function assistantText(message: AssistantMessage): string;
|
|
10
|
+
/**
|
|
11
|
+
* Map a single {@link AgentEvent} to a renderable line, or `undefined` when the
|
|
12
|
+
* event has no user-visible projection (lifecycle bookkeeping). Final assistant
|
|
13
|
+
* text arrives via `turn_end`/`message_end`; tool activity is surfaced as terse
|
|
14
|
+
* status lines.
|
|
15
|
+
*/
|
|
16
|
+
export declare function renderAgentEvent(event: AgentEvent): string | undefined;
|
|
17
|
+
/** A one-line usage summary suitable for status output. */
|
|
18
|
+
export declare function renderUsage(usage: Usage): string;
|
|
19
|
+
/** The JSON-mode projection of a completed run (stable shape for embedders). */
|
|
20
|
+
export interface PrintJsonResult {
|
|
21
|
+
ok: boolean;
|
|
22
|
+
finalText: string;
|
|
23
|
+
stopReason: string;
|
|
24
|
+
usage: Usage;
|
|
25
|
+
errorMessage?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Build the stable JSON payload for `--json` print mode. */
|
|
28
|
+
export declare function toPrintJson(result: AgentRunResult): PrintJsonResult;
|
|
29
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/modes/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAe,KAAK,EAAE,MAAM,UAAU,CAAC;AAErE;;;;GAIG;AAEH,gFAAgF;AAChF,wBAAgB,aAAa,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAK/D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAatE;AAeD,2DAA2D;AAC3D,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAEhD;AAED,gFAAgF;AAChF,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,OAAO,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,6DAA6D;AAC7D,wBAAgB,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,eAAe,CAQnE"}
|