axexec 1.0.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 +196 -0
- package/bin/axexec +17 -0
- package/dist/agents/claude-code/adapter.d.ts +6 -0
- package/dist/agents/claude-code/adapter.js +71 -0
- package/dist/agents/claude-code/parse-event.d.ts +16 -0
- package/dist/agents/claude-code/parse-event.js +185 -0
- package/dist/agents/claude-code/types.d.ts +180 -0
- package/dist/agents/claude-code/types.js +112 -0
- package/dist/agents/codex/adapter.d.ts +6 -0
- package/dist/agents/codex/adapter.js +62 -0
- package/dist/agents/codex/item-parsers.d.ts +17 -0
- package/dist/agents/codex/item-parsers.js +126 -0
- package/dist/agents/codex/parse-event.d.ts +38 -0
- package/dist/agents/codex/parse-event.js +141 -0
- package/dist/agents/codex/types.d.ts +407 -0
- package/dist/agents/codex/types.js +188 -0
- package/dist/agents/copilot/adapter.d.ts +11 -0
- package/dist/agents/copilot/adapter.js +81 -0
- package/dist/agents/copilot/parse-event.d.ts +20 -0
- package/dist/agents/copilot/parse-event.js +137 -0
- package/dist/agents/copilot/stream-session.d.ts +10 -0
- package/dist/agents/copilot/stream-session.js +120 -0
- package/dist/agents/copilot/tail-file.d.ts +11 -0
- package/dist/agents/copilot/tail-file.js +52 -0
- package/dist/agents/copilot/transform-event.d.ts +19 -0
- package/dist/agents/copilot/transform-event.js +100 -0
- package/dist/agents/copilot/types.d.ts +320 -0
- package/dist/agents/copilot/types.js +220 -0
- package/dist/agents/copilot/watch-session.d.ts +26 -0
- package/dist/agents/copilot/watch-session.js +186 -0
- package/dist/agents/gemini/adapter.d.ts +6 -0
- package/dist/agents/gemini/adapter.js +78 -0
- package/dist/agents/gemini/parse-event.d.ts +18 -0
- package/dist/agents/gemini/parse-event.js +144 -0
- package/dist/agents/gemini/types.d.ts +162 -0
- package/dist/agents/gemini/types.js +103 -0
- package/dist/agents/opencode/adapter.d.ts +16 -0
- package/dist/agents/opencode/adapter.js +142 -0
- package/dist/agents/opencode/cleanup-session.d.ts +17 -0
- package/dist/agents/opencode/cleanup-session.js +41 -0
- package/dist/agents/opencode/create-session-start-event.d.ts +18 -0
- package/dist/agents/opencode/create-session-start-event.js +24 -0
- package/dist/agents/opencode/detect-empty-session.d.ts +25 -0
- package/dist/agents/opencode/detect-empty-session.js +42 -0
- package/dist/agents/opencode/map-error-to-event.d.ts +10 -0
- package/dist/agents/opencode/map-error-to-event.js +55 -0
- package/dist/agents/opencode/parse-message-part.d.ts +24 -0
- package/dist/agents/opencode/parse-message-part.js +112 -0
- package/dist/agents/opencode/parse-sse-event.d.ts +23 -0
- package/dist/agents/opencode/parse-sse-event.js +125 -0
- package/dist/agents/opencode/process-sse-events.d.ts +24 -0
- package/dist/agents/opencode/process-sse-events.js +66 -0
- package/dist/agents/opencode/server-types.d.ts +509 -0
- package/dist/agents/opencode/server-types.js +293 -0
- package/dist/agents/opencode/session-api.d.ts +56 -0
- package/dist/agents/opencode/session-api.js +151 -0
- package/dist/agents/opencode/spawn-server.d.ts +29 -0
- package/dist/agents/opencode/spawn-server.js +95 -0
- package/dist/agents/opencode/sse-client.d.ts +33 -0
- package/dist/agents/opencode/sse-client.js +145 -0
- package/dist/agents/registry.d.ts +15 -0
- package/dist/agents/registry.js +24 -0
- package/dist/cli.d.ts +15 -0
- package/dist/cli.js +119 -0
- package/dist/credentials/get-credential-environment.d.ts +13 -0
- package/dist/credentials/get-credential-environment.js +46 -0
- package/dist/credentials/install-credentials.d.ts +27 -0
- package/dist/credentials/install-credentials.js +102 -0
- package/dist/credentials/save-json-file.d.ts +11 -0
- package/dist/credentials/save-json-file.js +21 -0
- package/dist/credentials/types.d.ts +24 -0
- package/dist/credentials/types.js +4 -0
- package/dist/credentials/write-agent-credentials.d.ts +36 -0
- package/dist/credentials/write-agent-credentials.js +91 -0
- package/dist/determine-session-success.d.ts +15 -0
- package/dist/determine-session-success.js +25 -0
- package/dist/format-event-tsv.d.ts +23 -0
- package/dist/format-event-tsv.js +136 -0
- package/dist/parse-credentials.d.ts +13 -0
- package/dist/parse-credentials.js +63 -0
- package/dist/parse-iso-timestamp.d.ts +21 -0
- package/dist/parse-iso-timestamp.js +37 -0
- package/dist/resolve-binary.d.ts +29 -0
- package/dist/resolve-binary.js +46 -0
- package/dist/resolve-output-mode.d.ts +39 -0
- package/dist/resolve-output-mode.js +39 -0
- package/dist/run-agent.d.ts +32 -0
- package/dist/run-agent.js +146 -0
- package/dist/stream-agent.d.ts +20 -0
- package/dist/stream-agent.js +207 -0
- package/dist/types/adapter.d.ts +101 -0
- package/dist/types/adapter.js +14 -0
- package/dist/types/events.d.ts +82 -0
- package/dist/types/events.js +13 -0
- package/dist/types/options.d.ts +41 -0
- package/dist/types/options.js +4 -0
- package/dist/validate-agent.d.ts +20 -0
- package/dist/validate-agent.js +50 -0
- package/dist/write-event.d.ts +23 -0
- package/dist/write-event.js +43 -0
- package/package.json +79 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent validation utilities.
|
|
3
|
+
*/
|
|
4
|
+
import { AGENT_CLIS, isValidAgentCli } from "axshared";
|
|
5
|
+
import { getAdapter, listAdapters } from "./agents/registry.js";
|
|
6
|
+
/**
|
|
7
|
+
* Validate that an agent ID is valid and the adapter is available.
|
|
8
|
+
*/
|
|
9
|
+
function validateAgent(agentId) {
|
|
10
|
+
if (!agentId) {
|
|
11
|
+
return {
|
|
12
|
+
ok: false,
|
|
13
|
+
exitCode: 2,
|
|
14
|
+
message: [
|
|
15
|
+
"Error: --agent is required",
|
|
16
|
+
"Usage: axexec --agent <id> <prompt>",
|
|
17
|
+
"Try 'axexec --help' for more information.",
|
|
18
|
+
].join("\n"),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
if (!isValidAgentCli(agentId)) {
|
|
22
|
+
return {
|
|
23
|
+
ok: false,
|
|
24
|
+
exitCode: 2,
|
|
25
|
+
message: [
|
|
26
|
+
`Error: Unknown agent '${agentId}'`,
|
|
27
|
+
`Supported agents: ${AGENT_CLIS.join(", ")}`,
|
|
28
|
+
].join("\n"),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const adapter = getAdapter(agentId);
|
|
32
|
+
if (!adapter) {
|
|
33
|
+
const available = listAdapters();
|
|
34
|
+
const availableMessage = available.length > 0
|
|
35
|
+
? `Available agents: ${available.map((a) => a.id).join(", ")}`
|
|
36
|
+
: "";
|
|
37
|
+
return {
|
|
38
|
+
ok: false,
|
|
39
|
+
exitCode: 1,
|
|
40
|
+
message: [
|
|
41
|
+
`Error: Agent '${agentId}' is not yet implemented`,
|
|
42
|
+
availableMessage,
|
|
43
|
+
]
|
|
44
|
+
.filter(Boolean)
|
|
45
|
+
.join("\n"),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return { ok: true, agentId, adapter };
|
|
49
|
+
}
|
|
50
|
+
export { validateAgent };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified event writer for CLI output.
|
|
3
|
+
*
|
|
4
|
+
* Creates a writer function that formats and outputs events
|
|
5
|
+
* based on the resolved output mode. Uses line-buffered output
|
|
6
|
+
* for real-time streaming.
|
|
7
|
+
*/
|
|
8
|
+
import type { OutputMode } from "./resolve-output-mode.js";
|
|
9
|
+
import type { AxexecEvent } from "./types/events.js";
|
|
10
|
+
/**
|
|
11
|
+
* Creates an event writer function for the specified output mode.
|
|
12
|
+
*
|
|
13
|
+
* @param mode - The output mode (jsonl, tsv, or tsv-truncated)
|
|
14
|
+
* @returns A function that writes a single event to stdout
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const writeEvent = createEventWriter("jsonl");
|
|
18
|
+
* for await (const event of streamAgent(adapter, options)) {
|
|
19
|
+
* writeEvent(event);
|
|
20
|
+
* }
|
|
21
|
+
*/
|
|
22
|
+
declare function createEventWriter(mode: OutputMode): (event: AxexecEvent) => void;
|
|
23
|
+
export { createEventWriter };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified event writer for CLI output.
|
|
3
|
+
*
|
|
4
|
+
* Creates a writer function that formats and outputs events
|
|
5
|
+
* based on the resolved output mode. Uses line-buffered output
|
|
6
|
+
* for real-time streaming.
|
|
7
|
+
*/
|
|
8
|
+
import { formatEventTsv } from "./format-event-tsv.js";
|
|
9
|
+
/**
|
|
10
|
+
* Creates an event writer function for the specified output mode.
|
|
11
|
+
*
|
|
12
|
+
* @param mode - The output mode (jsonl, tsv, or tsv-truncated)
|
|
13
|
+
* @returns A function that writes a single event to stdout
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const writeEvent = createEventWriter("jsonl");
|
|
17
|
+
* for await (const event of streamAgent(adapter, options)) {
|
|
18
|
+
* writeEvent(event);
|
|
19
|
+
* }
|
|
20
|
+
*/
|
|
21
|
+
function createEventWriter(mode) {
|
|
22
|
+
switch (mode) {
|
|
23
|
+
case "jsonl": {
|
|
24
|
+
return (event) => {
|
|
25
|
+
const line = JSON.stringify(event);
|
|
26
|
+
process.stdout.write(line + "\n");
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
case "tsv": {
|
|
30
|
+
return (event) => {
|
|
31
|
+
const line = formatEventTsv(event, { truncate: false });
|
|
32
|
+
process.stdout.write(line + "\n");
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
case "tsv-truncated": {
|
|
36
|
+
return (event) => {
|
|
37
|
+
const line = formatEventTsv(event, { truncate: true });
|
|
38
|
+
process.stdout.write(line + "\n");
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export { createEventWriter };
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "axexec",
|
|
3
|
+
"author": "Łukasz Jerciński",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"description": "Unified CLI runner for AI coding agents with normalized event streaming",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/Jercik/axexec.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/Jercik/axexec#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/Jercik/axexec/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"bin": {
|
|
17
|
+
"axexec": "bin/axexec"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"bin/",
|
|
21
|
+
"dist/",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"prepare": "git config core.hooksPath .githooks",
|
|
27
|
+
"prepublishOnly": "pnpm run rebuild",
|
|
28
|
+
"build": "tsc -p tsconfig.app.json",
|
|
29
|
+
"clean": "rm -rf dist *.tsbuildinfo",
|
|
30
|
+
"format": "prettier --write .",
|
|
31
|
+
"format:check": "prettier --check .",
|
|
32
|
+
"fta": "fta-check",
|
|
33
|
+
"knip": "knip",
|
|
34
|
+
"lint": "eslint",
|
|
35
|
+
"rebuild": "pnpm run clean && pnpm run build",
|
|
36
|
+
"start": "pnpm -s run rebuild && node bin/axexec",
|
|
37
|
+
"test": "vitest run",
|
|
38
|
+
"test:coverage": "vitest run --coverage",
|
|
39
|
+
"test:watch": "vitest",
|
|
40
|
+
"typecheck": "tsc -b --noEmit"
|
|
41
|
+
},
|
|
42
|
+
"keywords": [
|
|
43
|
+
"ai",
|
|
44
|
+
"agent",
|
|
45
|
+
"cli",
|
|
46
|
+
"runner",
|
|
47
|
+
"claude-code",
|
|
48
|
+
"codex",
|
|
49
|
+
"gemini",
|
|
50
|
+
"llm",
|
|
51
|
+
"automation",
|
|
52
|
+
"coding-assistant"
|
|
53
|
+
],
|
|
54
|
+
"packageManager": "pnpm@10.27.0",
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=22.14.0"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"@commander-js/extra-typings": "^14.0.0",
|
|
60
|
+
"axconfig": "^3.6.0",
|
|
61
|
+
"axshared": "^1.9.0",
|
|
62
|
+
"commander": "^14.0.2",
|
|
63
|
+
"zod": "^4.3.5"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@total-typescript/ts-reset": "^0.6.1",
|
|
67
|
+
"@types/node": "^25.0.7",
|
|
68
|
+
"@vitest/coverage-v8": "^4.0.17",
|
|
69
|
+
"eslint": "^9.39.2",
|
|
70
|
+
"eslint-config-axkit": "^1.0.0",
|
|
71
|
+
"fta-check": "^1.5.1",
|
|
72
|
+
"fta-cli": "^3.0.0",
|
|
73
|
+
"knip": "^5.80.2",
|
|
74
|
+
"prettier": "3.7.4",
|
|
75
|
+
"semantic-release": "^25.0.2",
|
|
76
|
+
"typescript": "^5.9.3",
|
|
77
|
+
"vitest": "^4.0.17"
|
|
78
|
+
}
|
|
79
|
+
}
|