axexec 1.6.0 → 1.6.1
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/dist/agents/claude-code/types.d.ts +2 -2
- package/dist/agents/gemini/types.d.ts +4 -4
- package/dist/build-execution-metadata.d.ts +1 -2
- package/dist/build-execution-metadata.js +1 -1
- package/dist/credentials/get-credential-environment.d.ts +1 -1
- package/dist/credentials/get-credential-environment.js +1 -1
- package/dist/credentials/install-credentials.d.ts +1 -2
- package/dist/credentials/install-credentials.js +3 -1
- package/dist/credentials/write-agent-credentials.d.ts +4 -2
- package/dist/credentials/write-agent-credentials.js +1 -6
- package/dist/execute-agent.d.ts +1 -2
- package/dist/index.d.ts +1 -1
- package/dist/parse-credentials.d.ts +1 -2
- package/dist/parse-credentials.js +14 -6
- package/dist/types/run-result.d.ts +1 -2
- package/package.json +1 -1
- package/dist/credentials/credentials.d.ts +0 -39
- package/dist/credentials/credentials.js +0 -73
|
@@ -77,8 +77,8 @@ type ClaudeUserEvent = z.infer<typeof ClaudeUserEvent>;
|
|
|
77
77
|
declare const ClaudeResultEvent: z.ZodObject<{
|
|
78
78
|
type: z.ZodLiteral<"result">;
|
|
79
79
|
subtype: z.ZodEnum<{
|
|
80
|
-
error: "error";
|
|
81
80
|
success: "success";
|
|
81
|
+
error: "error";
|
|
82
82
|
cancelled: "cancelled";
|
|
83
83
|
}>;
|
|
84
84
|
timestamp: z.ZodOptional<z.ZodString>;
|
|
@@ -153,8 +153,8 @@ declare const ClaudeEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
153
153
|
}, z.core.$strip>, z.ZodObject<{
|
|
154
154
|
type: z.ZodLiteral<"result">;
|
|
155
155
|
subtype: z.ZodEnum<{
|
|
156
|
-
error: "error";
|
|
157
156
|
success: "success";
|
|
157
|
+
error: "error";
|
|
158
158
|
cancelled: "cancelled";
|
|
159
159
|
}>;
|
|
160
160
|
timestamp: z.ZodOptional<z.ZodString>;
|
|
@@ -41,8 +41,8 @@ declare const GeminiToolResultEvent: z.ZodObject<{
|
|
|
41
41
|
type: z.ZodLiteral<"tool_result">;
|
|
42
42
|
tool_id: z.ZodString;
|
|
43
43
|
status: z.ZodEnum<{
|
|
44
|
-
error: "error";
|
|
45
44
|
success: "success";
|
|
45
|
+
error: "error";
|
|
46
46
|
}>;
|
|
47
47
|
output: z.ZodOptional<z.ZodString>;
|
|
48
48
|
error: z.ZodOptional<z.ZodObject<{
|
|
@@ -67,8 +67,8 @@ type GeminiErrorEvent = z.infer<typeof GeminiErrorEvent>;
|
|
|
67
67
|
declare const GeminiResultEvent: z.ZodObject<{
|
|
68
68
|
type: z.ZodLiteral<"result">;
|
|
69
69
|
status: z.ZodEnum<{
|
|
70
|
-
error: "error";
|
|
71
70
|
success: "success";
|
|
71
|
+
error: "error";
|
|
72
72
|
}>;
|
|
73
73
|
error: z.ZodOptional<z.ZodObject<{
|
|
74
74
|
type: z.ZodString;
|
|
@@ -109,8 +109,8 @@ declare const GeminiEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
109
109
|
type: z.ZodLiteral<"tool_result">;
|
|
110
110
|
tool_id: z.ZodString;
|
|
111
111
|
status: z.ZodEnum<{
|
|
112
|
-
error: "error";
|
|
113
112
|
success: "success";
|
|
113
|
+
error: "error";
|
|
114
114
|
}>;
|
|
115
115
|
output: z.ZodOptional<z.ZodString>;
|
|
116
116
|
error: z.ZodOptional<z.ZodObject<{
|
|
@@ -129,8 +129,8 @@ declare const GeminiEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
129
129
|
}, z.core.$strip>, z.ZodObject<{
|
|
130
130
|
type: z.ZodLiteral<"result">;
|
|
131
131
|
status: z.ZodEnum<{
|
|
132
|
-
error: "error";
|
|
133
132
|
success: "success";
|
|
133
|
+
error: "error";
|
|
134
134
|
}>;
|
|
135
135
|
error: z.ZodOptional<z.ZodObject<{
|
|
136
136
|
type: z.ZodString;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { AgentCli } from "axshared";
|
|
1
|
+
import type { AgentCli, Credentials } from "axshared";
|
|
2
2
|
import type { RunAgentOptions, ExecutionMetadata } from "./types/run-result.js";
|
|
3
|
-
import type { Credentials } from "./credentials/credentials.js";
|
|
4
3
|
import type { installCredentials } from "./credentials/install-credentials.js";
|
|
5
4
|
type CredentialInstallResult = Awaited<ReturnType<typeof installCredentials>>;
|
|
6
5
|
/**
|
|
@@ -19,7 +19,7 @@ function buildExecutionMetadata(agentId, options, credentialResult, credentials,
|
|
|
19
19
|
if (credentials) {
|
|
20
20
|
execution.credentials = {
|
|
21
21
|
type: credentials.type,
|
|
22
|
-
provider: credentials.provider,
|
|
22
|
+
provider: credentials.agent === "opencode" ? credentials.provider : undefined,
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
return execution;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Each agent has its own env var requirements. This module extracts
|
|
5
5
|
* the appropriate values from Credentials and returns them as env vars.
|
|
6
6
|
*/
|
|
7
|
-
import type { Credentials } from "
|
|
7
|
+
import type { Credentials } from "axshared";
|
|
8
8
|
/**
|
|
9
9
|
* Gets additional environment variables for credential-based auth.
|
|
10
10
|
*
|
|
@@ -51,7 +51,7 @@ function getCredentialEnvironment(credentials) {
|
|
|
51
51
|
}
|
|
52
52
|
case "opencode": {
|
|
53
53
|
// OpenCode supports multiple providers, env var depends on provider
|
|
54
|
-
const provider = credentials.provider
|
|
54
|
+
const provider = credentials.provider;
|
|
55
55
|
if (credentials.type === "api-key" && apiKey) {
|
|
56
56
|
switch (provider) {
|
|
57
57
|
case "anthropic": {
|
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
* directory. This ensures complete isolation - agents never discover or use
|
|
7
7
|
* locally installed credentials.
|
|
8
8
|
*/
|
|
9
|
-
import { type AgentCli } from "axshared";
|
|
10
|
-
import type { Credentials } from "./credentials.js";
|
|
9
|
+
import { type AgentCli, type Credentials } from "axshared";
|
|
11
10
|
import type { InstallResult } from "./types.js";
|
|
12
11
|
type WarningWriter = (message: string) => void;
|
|
13
12
|
/**
|
|
@@ -57,7 +57,9 @@ function installAgentCredentials(agentId, configDirectory, dataDirectory, creden
|
|
|
57
57
|
break;
|
|
58
58
|
}
|
|
59
59
|
case "opencode": {
|
|
60
|
-
|
|
60
|
+
if (credentials.agent === "opencode") {
|
|
61
|
+
installOpenCodeCredentials(dataDirectory, credentials, warn);
|
|
62
|
+
}
|
|
61
63
|
break;
|
|
62
64
|
}
|
|
63
65
|
case "copilot": {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* write credentials in the agent-specific format, extracting what
|
|
6
6
|
* they need from the canonical Credentials type.
|
|
7
7
|
*/
|
|
8
|
-
import type { Credentials } from "
|
|
8
|
+
import type { Credentials } from "axshared";
|
|
9
9
|
type WarningWriter = (message: string) => void;
|
|
10
10
|
/**
|
|
11
11
|
* Installs Claude credentials to a config directory.
|
|
@@ -54,5 +54,7 @@ declare function installGeminiCredentials(configDirectory: string, credentials:
|
|
|
54
54
|
* - oauth-credentials: Written as { [provider]: { type: "oauth", ...data } }
|
|
55
55
|
* - api-key: Written as { [provider]: { type: "api", key: "..." } }
|
|
56
56
|
*/
|
|
57
|
-
declare function installOpenCodeCredentials(dataDirectory: string, credentials: Credentials,
|
|
57
|
+
declare function installOpenCodeCredentials(dataDirectory: string, credentials: Extract<Credentials, {
|
|
58
|
+
agent: "opencode";
|
|
59
|
+
}>, warn?: WarningWriter): void;
|
|
58
60
|
export { installClaudeCredentials, installCodexCredentials, installGeminiCredentials, installOpenCodeCredentials, };
|
|
@@ -8,11 +8,6 @@
|
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import { resolveStringField } from "./resolve-string-field.js";
|
|
10
10
|
import { saveJsonFile } from "./save-json-file.js";
|
|
11
|
-
function normalizeOpenCodeProvider(provider) {
|
|
12
|
-
if (!provider)
|
|
13
|
-
return "anthropic";
|
|
14
|
-
return provider === "gemini" ? "google" : provider;
|
|
15
|
-
}
|
|
16
11
|
function defaultWarningWriter(message) {
|
|
17
12
|
const formatted = message.endsWith("\n") ? message : `${message}\n`;
|
|
18
13
|
process.stderr.write(formatted);
|
|
@@ -107,7 +102,7 @@ function installGeminiCredentials(configDirectory, credentials) {
|
|
|
107
102
|
*/
|
|
108
103
|
function installOpenCodeCredentials(dataDirectory, credentials, warn = defaultWarningWriter) {
|
|
109
104
|
const authPath = path.join(dataDirectory, "auth.json");
|
|
110
|
-
const provider =
|
|
105
|
+
const provider = credentials.provider;
|
|
111
106
|
switch (credentials.type) {
|
|
112
107
|
case "oauth-credentials": {
|
|
113
108
|
saveJsonFile(authPath, {
|
package/dist/execute-agent.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { AgentAdapter } from "./types/adapter.js";
|
|
2
|
-
import type { AgentCli } from "axshared";
|
|
2
|
+
import type { AgentCli, Credentials } from "axshared";
|
|
3
3
|
import type { RunAgentOptions, RunResult } from "./types/run-result.js";
|
|
4
|
-
import type { Credentials } from "./credentials/credentials.js";
|
|
5
4
|
import type { installCredentials } from "./credentials/install-credentials.js";
|
|
6
5
|
import type { DiagnosticWriter } from "./resolve-run-diagnostics.js";
|
|
7
6
|
type CredentialInstallResult = Awaited<ReturnType<typeof installCredentials>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -13,4 +13,4 @@ export { runAgent } from "./run-agent.js";
|
|
|
13
13
|
export { cleanupCredentials } from "./credentials/install-credentials.js";
|
|
14
14
|
export type { ExecutionCredentials, ExecutionDirectories, ExecutionMetadata, RunAgentDiagnostics, RunAgentOptions, RunResult, } from "./types/run-result.js";
|
|
15
15
|
export type { AxexecEvent } from "./types/events.js";
|
|
16
|
-
export type { Credentials } from "
|
|
16
|
+
export type { Credentials } from "axshared";
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
* Used by axexec CLI to read credentials from environment when
|
|
5
5
|
* not provided via the programmatic API.
|
|
6
6
|
*/
|
|
7
|
-
import type
|
|
8
|
-
import { type Credentials } from "./credentials/credentials.js";
|
|
7
|
+
import { type AgentCli, type Credentials } from "axshared";
|
|
9
8
|
type ParseCredentialsResult = {
|
|
10
9
|
ok: true;
|
|
11
10
|
credentials: Credentials | undefined;
|
|
@@ -4,8 +4,16 @@
|
|
|
4
4
|
* Used by axexec CLI to read credentials from environment when
|
|
5
5
|
* not provided via the programmatic API.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { parseCredentialsResult, } from "axshared";
|
|
8
8
|
import { getEnvironmentTrimmed } from "./credentials/get-environment-trimmed.js";
|
|
9
|
+
function formatZodError(error) {
|
|
10
|
+
return error.issues
|
|
11
|
+
.map((issue) => {
|
|
12
|
+
const path = issue.path.length > 0 ? issue.path.map(String).join(".") : "root";
|
|
13
|
+
return `${path}: ${issue.message}`;
|
|
14
|
+
})
|
|
15
|
+
.join("; ");
|
|
16
|
+
}
|
|
9
17
|
/**
|
|
10
18
|
* Parses credentials from environment variables.
|
|
11
19
|
*
|
|
@@ -22,23 +30,23 @@ function parseCredentialsFromEnvironment(agentId) {
|
|
|
22
30
|
if (credEnvironmentValue) {
|
|
23
31
|
try {
|
|
24
32
|
const parsed = JSON.parse(credEnvironmentValue);
|
|
25
|
-
const parseResult =
|
|
33
|
+
const parseResult = parseCredentialsResult(parsed);
|
|
26
34
|
if (parseResult.ok) {
|
|
27
|
-
if (parseResult.
|
|
35
|
+
if (parseResult.value.agent !== agentId) {
|
|
28
36
|
return {
|
|
29
37
|
ok: false,
|
|
30
38
|
exitCode: 2,
|
|
31
39
|
message: `Error: ${credEnvironmentVariable} agent mismatch. ` +
|
|
32
|
-
`Expected ${agentId}, got ${parseResult.
|
|
40
|
+
`Expected ${agentId}, got ${parseResult.value.agent}.`,
|
|
33
41
|
};
|
|
34
42
|
}
|
|
35
|
-
return { ok: true, credentials: parseResult.
|
|
43
|
+
return { ok: true, credentials: parseResult.value };
|
|
36
44
|
}
|
|
37
45
|
return {
|
|
38
46
|
ok: false,
|
|
39
47
|
exitCode: 2,
|
|
40
48
|
message: `Error: Invalid credentials format in ${credEnvironmentVariable}: ` +
|
|
41
|
-
parseResult.error,
|
|
49
|
+
formatZodError(parseResult.error),
|
|
42
50
|
};
|
|
43
51
|
}
|
|
44
52
|
catch (error) {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Types for run-agent results and options.
|
|
3
3
|
*/
|
|
4
|
-
import type { AgentCli } from "axshared";
|
|
4
|
+
import type { AgentCli, Credentials } from "axshared";
|
|
5
5
|
import type { AxexecEvent } from "./events.js";
|
|
6
6
|
import type { OutputFormat } from "../resolve-output-mode.js";
|
|
7
|
-
import type { Credentials } from "../credentials/credentials.js";
|
|
8
7
|
interface RunAgentDiagnostics {
|
|
9
8
|
error: (message: string) => void;
|
|
10
9
|
warn: (message: string) => void;
|
package/package.json
CHANGED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Credential schema and parser.
|
|
3
|
-
*
|
|
4
|
-
* Temporary local copy of the axshared credentials schema.
|
|
5
|
-
* Remove once axshared exports an equivalent parser with matching validation.
|
|
6
|
-
*/
|
|
7
|
-
import { z } from "zod";
|
|
8
|
-
/** Zod schema for Credentials */
|
|
9
|
-
declare const Credentials: z.ZodObject<{
|
|
10
|
-
agent: z.ZodEnum<{
|
|
11
|
-
claude: "claude";
|
|
12
|
-
codex: "codex";
|
|
13
|
-
gemini: "gemini";
|
|
14
|
-
opencode: "opencode";
|
|
15
|
-
copilot: "copilot";
|
|
16
|
-
}>;
|
|
17
|
-
type: z.ZodEnum<{
|
|
18
|
-
"oauth-credentials": "oauth-credentials";
|
|
19
|
-
"oauth-token": "oauth-token";
|
|
20
|
-
"api-key": "api-key";
|
|
21
|
-
}>;
|
|
22
|
-
provider: z.ZodOptional<z.ZodString>;
|
|
23
|
-
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
24
|
-
}, z.core.$strip>;
|
|
25
|
-
type Credentials = z.infer<typeof Credentials>;
|
|
26
|
-
type ParseCredentialsResult = {
|
|
27
|
-
ok: true;
|
|
28
|
-
credentials: Credentials;
|
|
29
|
-
} | {
|
|
30
|
-
ok: false;
|
|
31
|
-
error: string;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Parse and validate credentials from unknown input.
|
|
35
|
-
*
|
|
36
|
-
* @returns Validated Credentials or error details
|
|
37
|
-
*/
|
|
38
|
-
declare function parseCredentials(input: unknown): ParseCredentialsResult;
|
|
39
|
-
export { Credentials, parseCredentials };
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Credential schema and parser.
|
|
3
|
-
*
|
|
4
|
-
* Temporary local copy of the axshared credentials schema.
|
|
5
|
-
* Remove once axshared exports an equivalent parser with matching validation.
|
|
6
|
-
*/
|
|
7
|
-
import { z } from "zod";
|
|
8
|
-
import { AGENT_CLIS } from "axshared";
|
|
9
|
-
import { resolveStringField } from "./resolve-string-field.js";
|
|
10
|
-
/** Credential storage types */
|
|
11
|
-
const CREDENTIAL_TYPES = [
|
|
12
|
-
"oauth-credentials",
|
|
13
|
-
"oauth-token",
|
|
14
|
-
"api-key",
|
|
15
|
-
];
|
|
16
|
-
/** Zod schema for credential type validation and parsing */
|
|
17
|
-
const CredentialType = z.enum(CREDENTIAL_TYPES);
|
|
18
|
-
/** Zod schema for Credentials */
|
|
19
|
-
const Credentials = z
|
|
20
|
-
.object({
|
|
21
|
-
/** Agent this credential belongs to */
|
|
22
|
-
agent: z.enum(AGENT_CLIS),
|
|
23
|
-
/** Credential storage type */
|
|
24
|
-
type: CredentialType,
|
|
25
|
-
/** Provider identifier for multi-provider agents like OpenCode */
|
|
26
|
-
provider: z.string().trim().min(1).optional(),
|
|
27
|
-
/** The actual credential data (format depends on type and agent) */
|
|
28
|
-
data: z.record(z.string(), z.unknown()),
|
|
29
|
-
})
|
|
30
|
-
.superRefine((value, context) => {
|
|
31
|
-
if (value.type === "api-key") {
|
|
32
|
-
const apiKey = resolveStringField(value.data, "apiKey", "key");
|
|
33
|
-
if (!apiKey) {
|
|
34
|
-
context.addIssue({
|
|
35
|
-
code: "custom",
|
|
36
|
-
path: ["data"],
|
|
37
|
-
message: 'api-key credentials require "apiKey" or "key"',
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
if (value.type === "oauth-token") {
|
|
42
|
-
const oauthToken = resolveStringField(value.data, "oauthToken", "token");
|
|
43
|
-
if (!oauthToken) {
|
|
44
|
-
context.addIssue({
|
|
45
|
-
code: "custom",
|
|
46
|
-
path: ["data"],
|
|
47
|
-
message: 'oauth-token credentials require "oauthToken" or "token"',
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
// oauth-credentials payloads are provider-specific and intentionally
|
|
52
|
-
// not validated beyond basic schema checks here.
|
|
53
|
-
});
|
|
54
|
-
function formatParseError(error) {
|
|
55
|
-
return error.issues
|
|
56
|
-
.map((issue) => {
|
|
57
|
-
const path = issue.path.length > 0 ? issue.path.map(String).join(".") : "root";
|
|
58
|
-
return `${path}: ${issue.message}`;
|
|
59
|
-
})
|
|
60
|
-
.join("; ");
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Parse and validate credentials from unknown input.
|
|
64
|
-
*
|
|
65
|
-
* @returns Validated Credentials or error details
|
|
66
|
-
*/
|
|
67
|
-
function parseCredentials(input) {
|
|
68
|
-
const result = Credentials.safeParse(input);
|
|
69
|
-
if (result.success)
|
|
70
|
-
return { ok: true, credentials: result.data };
|
|
71
|
-
return { ok: false, error: formatParseError(result.error) };
|
|
72
|
-
}
|
|
73
|
-
export { Credentials, parseCredentials };
|