@agentproto/driver-agent-cli 2.9.0 → 2.10.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/dist/{chunk-AN5G6ENG.mjs → chunk-K5PKRW2Q.mjs} +78 -40
- package/dist/chunk-K5PKRW2Q.mjs.map +1 -0
- package/dist/index.d.ts +26 -3
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/manifest/index.d.ts +2 -2
- package/dist/manifest/index.mjs +2 -2
- package/dist/{schema-DQHzxzLh.d.ts → schema-M-CpE8Yf.d.ts} +22 -0
- package/package.json +1 -1
- package/dist/chunk-AN5G6ENG.mjs.map +0 -1
|
@@ -400,6 +400,7 @@ var agentCliFrontmatterSchema = z.object({
|
|
|
400
400
|
share: z.array(z.string().regex(/^[^/]+$/)).optional(),
|
|
401
401
|
seed: z.record(z.string().regex(/^[^/]+$/).refine((n) => n !== "." && n !== "..", { message: "seed names a file of the home" }), z.string()).optional()
|
|
402
402
|
}).strict().optional(),
|
|
403
|
+
credentialDataHome: z.object({ env: z.string().regex(/^[A-Z][A-Z0-9_]*$/) }).strict().optional(),
|
|
403
404
|
runner: z.union([z.string(), z.record(z.string(), z.unknown())]).optional(),
|
|
404
405
|
protocol: z.enum(["acp", "mcp", "proprietary", "print"]),
|
|
405
406
|
acp: z.string().optional(),
|
|
@@ -1808,6 +1809,49 @@ function interpolateEnv(env, value) {
|
|
|
1808
1809
|
}
|
|
1809
1810
|
return out;
|
|
1810
1811
|
}
|
|
1812
|
+
function realStateHome(stateHome, env) {
|
|
1813
|
+
const fromEnv = env[stateHome.env];
|
|
1814
|
+
if (fromEnv && isAbsolute(fromEnv)) return fromEnv;
|
|
1815
|
+
return resolve(homedir(), stateHome.defaultDir);
|
|
1816
|
+
}
|
|
1817
|
+
function prepareIsolatedStateHome(stateHome, opts) {
|
|
1818
|
+
const real = realStateHome(stateHome, opts.env);
|
|
1819
|
+
let dir;
|
|
1820
|
+
if (opts.configDir) {
|
|
1821
|
+
dir = opts.configDir;
|
|
1822
|
+
mkdirSync(dir, { recursive: true });
|
|
1823
|
+
} else {
|
|
1824
|
+
dir = mkdtempSync(join(tmpdir(), `agentproto-${stateHome.env.toLowerCase()}-`));
|
|
1825
|
+
}
|
|
1826
|
+
const writePaths = [dir];
|
|
1827
|
+
for (const name of stateHome.share ?? []) {
|
|
1828
|
+
const target = join(real, name);
|
|
1829
|
+
const link = join(dir, name);
|
|
1830
|
+
try {
|
|
1831
|
+
lstatSync(link);
|
|
1832
|
+
unlinkSync(link);
|
|
1833
|
+
} catch {
|
|
1834
|
+
}
|
|
1835
|
+
if (!existsSync(target)) continue;
|
|
1836
|
+
symlinkSync(target, link);
|
|
1837
|
+
writePaths.push(realpathSync(target));
|
|
1838
|
+
}
|
|
1839
|
+
for (const [name, content] of Object.entries(stateHome.seed ?? {})) {
|
|
1840
|
+
const file = join(dir, name);
|
|
1841
|
+
try {
|
|
1842
|
+
unlinkSync(file);
|
|
1843
|
+
} catch {
|
|
1844
|
+
}
|
|
1845
|
+
writeFileSync(file, content);
|
|
1846
|
+
}
|
|
1847
|
+
return { dir, writePaths };
|
|
1848
|
+
}
|
|
1849
|
+
var CREDENTIAL_DATA_SUBDIR = "auth-data";
|
|
1850
|
+
function isolatedCredentialDataHome(configDir) {
|
|
1851
|
+
const dir = configDir ? join(configDir, CREDENTIAL_DATA_SUBDIR) : mkdtempSync(join(tmpdir(), "agentproto-data-"));
|
|
1852
|
+
mkdirSync(dir, { recursive: true });
|
|
1853
|
+
return dir;
|
|
1854
|
+
}
|
|
1811
1855
|
function agentCliSupportsHostContextIsolation(adapterId) {
|
|
1812
1856
|
return adapterId === "claude-code";
|
|
1813
1857
|
}
|
|
@@ -2022,43 +2066,6 @@ async function* promptTurn(arm, turnId, message, stderrTurnError) {
|
|
|
2022
2066
|
});
|
|
2023
2067
|
}
|
|
2024
2068
|
}
|
|
2025
|
-
function realStateHome(stateHome, env) {
|
|
2026
|
-
const fromEnv = env[stateHome.env];
|
|
2027
|
-
if (fromEnv && isAbsolute(fromEnv)) return fromEnv;
|
|
2028
|
-
return resolve(homedir(), stateHome.defaultDir);
|
|
2029
|
-
}
|
|
2030
|
-
function prepareIsolatedStateHome(stateHome, opts) {
|
|
2031
|
-
const real = realStateHome(stateHome, opts.env);
|
|
2032
|
-
let dir;
|
|
2033
|
-
if (opts.configDir) {
|
|
2034
|
-
dir = opts.configDir;
|
|
2035
|
-
mkdirSync(dir, { recursive: true });
|
|
2036
|
-
} else {
|
|
2037
|
-
dir = mkdtempSync(join(tmpdir(), `agentproto-${stateHome.env.toLowerCase()}-`));
|
|
2038
|
-
}
|
|
2039
|
-
const writePaths = [dir];
|
|
2040
|
-
for (const name of stateHome.share ?? []) {
|
|
2041
|
-
const target = join(real, name);
|
|
2042
|
-
const link = join(dir, name);
|
|
2043
|
-
try {
|
|
2044
|
-
lstatSync(link);
|
|
2045
|
-
unlinkSync(link);
|
|
2046
|
-
} catch {
|
|
2047
|
-
}
|
|
2048
|
-
if (!existsSync(target)) continue;
|
|
2049
|
-
symlinkSync(target, link);
|
|
2050
|
-
writePaths.push(realpathSync(target));
|
|
2051
|
-
}
|
|
2052
|
-
for (const [name, content] of Object.entries(stateHome.seed ?? {})) {
|
|
2053
|
-
const file = join(dir, name);
|
|
2054
|
-
try {
|
|
2055
|
-
unlinkSync(file);
|
|
2056
|
-
} catch {
|
|
2057
|
-
}
|
|
2058
|
-
writeFileSync(file, content);
|
|
2059
|
-
}
|
|
2060
|
-
return { dir, writePaths };
|
|
2061
|
-
}
|
|
2062
2069
|
function npxCacheKey(packages) {
|
|
2063
2070
|
return createHash("sha512").update([...packages].sort((a, b) => a.localeCompare(b, "en")).join("\n")).digest("hex").slice(0, 16);
|
|
2064
2071
|
}
|
|
@@ -2164,6 +2171,26 @@ function ensureExecDirOnPath(env, execPath = process.execPath) {
|
|
|
2164
2171
|
if (parts.includes(execDir)) return;
|
|
2165
2172
|
env.PATH = [...parts, execDir].join(delimiter);
|
|
2166
2173
|
}
|
|
2174
|
+
function isPlainObject(v) {
|
|
2175
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
2176
|
+
}
|
|
2177
|
+
function deepMergeJson(base, over) {
|
|
2178
|
+
const out = { ...base };
|
|
2179
|
+
for (const [k, v] of Object.entries(over)) {
|
|
2180
|
+
const prev = out[k];
|
|
2181
|
+
out[k] = isPlainObject(prev) && isPlainObject(v) ? deepMergeJson(prev, v) : v;
|
|
2182
|
+
}
|
|
2183
|
+
return out;
|
|
2184
|
+
}
|
|
2185
|
+
function mergeJsonEnvValue(base, over) {
|
|
2186
|
+
try {
|
|
2187
|
+
const a = JSON.parse(base);
|
|
2188
|
+
const b = JSON.parse(over);
|
|
2189
|
+
if (isPlainObject(a) && isPlainObject(b)) return JSON.stringify(deepMergeJson(a, b));
|
|
2190
|
+
} catch {
|
|
2191
|
+
}
|
|
2192
|
+
return over;
|
|
2193
|
+
}
|
|
2167
2194
|
function createAgentCliRuntime(definition) {
|
|
2168
2195
|
return {
|
|
2169
2196
|
definition,
|
|
@@ -2181,6 +2208,7 @@ function createAgentCliRuntime(definition) {
|
|
|
2181
2208
|
};
|
|
2182
2209
|
for (const k of composed.envUnset) delete env[k];
|
|
2183
2210
|
const authSpec = opts?.auth;
|
|
2211
|
+
let credentialDataDir;
|
|
2184
2212
|
const hasGatewayAuthToken = "ANTHROPIC_AUTH_TOKEN" in composed.env;
|
|
2185
2213
|
const hasGatewayBaseUrl = "ANTHROPIC_BASE_URL" in composed.env;
|
|
2186
2214
|
const resolverCoupledGateway = authSpec?.baseUrl !== void 0;
|
|
@@ -2200,6 +2228,15 @@ function createAgentCliRuntime(definition) {
|
|
|
2200
2228
|
throw new RuntimeConfigError("missing_auth_credential", "opts.auth.credential", message);
|
|
2201
2229
|
}
|
|
2202
2230
|
env[authSpec.setEnv] = authSpec.credential;
|
|
2231
|
+
if (authSpec.extraEnv) {
|
|
2232
|
+
for (const [key, value] of Object.entries(authSpec.extraEnv)) {
|
|
2233
|
+
env[key] = key in composed.env ? mergeJsonEnvValue(composed.env[key], value) : value;
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
if (definition.credentialDataHome && authSpec.isolateDataHome !== false) {
|
|
2237
|
+
credentialDataDir = isolatedCredentialDataHome(opts?.configDir);
|
|
2238
|
+
env[definition.credentialDataHome.env] = credentialDataDir;
|
|
2239
|
+
}
|
|
2203
2240
|
}
|
|
2204
2241
|
}
|
|
2205
2242
|
Object.assign(env, opts?.env ?? {});
|
|
@@ -2266,6 +2303,7 @@ function createAgentCliRuntime(definition) {
|
|
|
2266
2303
|
env.CLAUDE_CONFIG_DIR = claudeConfigDir;
|
|
2267
2304
|
}
|
|
2268
2305
|
const extraWritePaths = claudeConfigDir ? [claudeConfigDir] : [];
|
|
2306
|
+
if (credentialDataDir) extraWritePaths.push(credentialDataDir);
|
|
2269
2307
|
if (definition.stateHome && definition.protocol !== "proprietary" && await willConfineAgentCliSpawn({ mode: opts?.commandSandbox, cwd, zones: opts?.fsZones })) {
|
|
2270
2308
|
const isolated = prepareIsolatedStateHome(definition.stateHome, {
|
|
2271
2309
|
...opts?.configDir ? { configDir: opts.configDir } : {},
|
|
@@ -2548,6 +2586,6 @@ function derivedModelRefusalError(definition, requested, reason) {
|
|
|
2548
2586
|
);
|
|
2549
2587
|
}
|
|
2550
2588
|
|
|
2551
|
-
export { LEGACY_GATEWAY_MODE_IDS, LEGACY_POSTURE_MODE_IDS, RuntimeConfigError, agentCliFrontmatterSchema, agentCliSupportsHostContextIsolation, applyModelCommand, autoAllowPermissionHandler, composeSpawn, createAcpProtocolArm, createAgentCliRuntime, createArmSessionControls, createJcodeMapperState, createMastraMapperState, createPrintSession, createProprietaryProtocolArm, defineAgentCli, hostContextExcludes, inferLegacyModeKind, isLegacyExtractedModeId, isModelSwitchAcknowledgement, mapJcodeEvent, mapMastraEvent, parseModelSwitchCommand, planModePermissionHandler, promptTurn, resolveContinuationStrategy, runtimeConfigSchema, toFileBasedMcpServers };
|
|
2552
|
-
//# sourceMappingURL=chunk-
|
|
2553
|
-
//# sourceMappingURL=chunk-
|
|
2589
|
+
export { CREDENTIAL_DATA_SUBDIR, LEGACY_GATEWAY_MODE_IDS, LEGACY_POSTURE_MODE_IDS, RuntimeConfigError, agentCliFrontmatterSchema, agentCliSupportsHostContextIsolation, applyModelCommand, autoAllowPermissionHandler, composeSpawn, createAcpProtocolArm, createAgentCliRuntime, createArmSessionControls, createJcodeMapperState, createMastraMapperState, createPrintSession, createProprietaryProtocolArm, defineAgentCli, hostContextExcludes, inferLegacyModeKind, isLegacyExtractedModeId, isModelSwitchAcknowledgement, mapJcodeEvent, mapMastraEvent, parseModelSwitchCommand, planModePermissionHandler, promptTurn, resolveContinuationStrategy, runtimeConfigSchema, toFileBasedMcpServers };
|
|
2590
|
+
//# sourceMappingURL=chunk-K5PKRW2Q.mjs.map
|
|
2591
|
+
//# sourceMappingURL=chunk-K5PKRW2Q.mjs.map
|