@aws/agentcore 0.3.0-preview.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 +175 -0
- package/README.md +147 -0
- package/dist/assets/README.md +79 -0
- package/dist/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap +2862 -0
- package/dist/assets/__tests__/assets.snapshot.test.ts +139 -0
- package/dist/assets/agents/AGENTS.md +102 -0
- package/dist/assets/cdk/.prettierrc +8 -0
- package/dist/assets/cdk/README.md +14 -0
- package/dist/assets/cdk/bin/cdk.ts +50 -0
- package/dist/assets/cdk/cdk.json +88 -0
- package/dist/assets/cdk/gitignore.template +9 -0
- package/dist/assets/cdk/jest.config.js +9 -0
- package/dist/assets/cdk/lib/cdk-stack.ts +38 -0
- package/dist/assets/cdk/npmignore.template +6 -0
- package/dist/assets/cdk/package.json +30 -0
- package/dist/assets/cdk/test/cdk.test.ts +16 -0
- package/dist/assets/cdk/tsconfig.json +28 -0
- package/dist/assets/mcp/python/README.md +27 -0
- package/dist/assets/mcp/python/pyproject.toml +22 -0
- package/dist/assets/mcp/python/server.py +117 -0
- package/dist/assets/mcp/python-lambda/README.md +22 -0
- package/dist/assets/mcp/python-lambda/handler.py +144 -0
- package/dist/assets/mcp/python-lambda/pyproject.toml +15 -0
- package/dist/assets/python/autogen/base/README.md +41 -0
- package/dist/assets/python/autogen/base/gitignore.template +40 -0
- package/dist/assets/python/autogen/base/main.py +52 -0
- package/dist/assets/python/autogen/base/mcp_client/client.py +18 -0
- package/dist/assets/python/autogen/base/model/load.py +136 -0
- package/dist/assets/python/autogen/base/pyproject.toml +35 -0
- package/dist/assets/python/crewai/base/README.md +41 -0
- package/dist/assets/python/crewai/base/gitignore.template +40 -0
- package/dist/assets/python/crewai/base/main.py +55 -0
- package/dist/assets/python/crewai/base/model/load.py +133 -0
- package/dist/assets/python/crewai/base/pyproject.toml +32 -0
- package/dist/assets/python/googleadk/base/README.md +39 -0
- package/dist/assets/python/googleadk/base/gitignore.template +40 -0
- package/dist/assets/python/googleadk/base/main.py +84 -0
- package/dist/assets/python/googleadk/base/mcp_client/client.py +15 -0
- package/dist/assets/python/googleadk/base/model/load.py +41 -0
- package/dist/assets/python/googleadk/base/pyproject.toml +21 -0
- package/dist/assets/python/langchain_langgraph/base/README.md +41 -0
- package/dist/assets/python/langchain_langgraph/base/gitignore.template +40 -0
- package/dist/assets/python/langchain_langgraph/base/main.py +51 -0
- package/dist/assets/python/langchain_langgraph/base/mcp_client/client.py +19 -0
- package/dist/assets/python/langchain_langgraph/base/model/load.py +123 -0
- package/dist/assets/python/langchain_langgraph/base/pyproject.toml +37 -0
- package/dist/assets/python/openaiagents/base/README.md +39 -0
- package/dist/assets/python/openaiagents/base/gitignore.template +40 -0
- package/dist/assets/python/openaiagents/base/main.py +56 -0
- package/dist/assets/python/openaiagents/base/mcp_client/client.py +14 -0
- package/dist/assets/python/openaiagents/base/model/load.py +37 -0
- package/dist/assets/python/openaiagents/base/pyproject.toml +20 -0
- package/dist/assets/python/strands/base/README.md +41 -0
- package/dist/assets/python/strands/base/gitignore.template +41 -0
- package/dist/assets/python/strands/base/main.py +76 -0
- package/dist/assets/python/strands/base/mcp_client/client.py +12 -0
- package/dist/assets/python/strands/base/model/load.py +123 -0
- package/dist/assets/python/strands/base/pyproject.toml +23 -0
- package/dist/assets/python/strands/capabilities/memory/session.py +39 -0
- package/dist/assets/typescript/.gitkeep +0 -0
- package/dist/cli/index.mjs +985 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/constants.d.ts +25 -0
- package/dist/lib/constants.d.ts.map +1 -0
- package/dist/lib/constants.js +49 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/errors/config.d.ts +49 -0
- package/dist/lib/errors/config.d.ts.map +1 -0
- package/dist/lib/errors/config.js +167 -0
- package/dist/lib/errors/config.js.map +1 -0
- package/dist/lib/errors/index.d.ts +2 -0
- package/dist/lib/errors/index.d.ts.map +1 -0
- package/dist/lib/errors/index.js +18 -0
- package/dist/lib/errors/index.js.map +1 -0
- package/dist/lib/index.d.ts +7 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +39 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/packaging/errors.d.ts +16 -0
- package/dist/lib/packaging/errors.d.ts.map +1 -0
- package/dist/lib/packaging/errors.js +36 -0
- package/dist/lib/packaging/errors.js.map +1 -0
- package/dist/lib/packaging/helpers.d.ts +54 -0
- package/dist/lib/packaging/helpers.d.ts.map +1 -0
- package/dist/lib/packaging/helpers.js +461 -0
- package/dist/lib/packaging/helpers.js.map +1 -0
- package/dist/lib/packaging/index.d.ts +36 -0
- package/dist/lib/packaging/index.d.ts.map +1 -0
- package/dist/lib/packaging/index.js +89 -0
- package/dist/lib/packaging/index.js.map +1 -0
- package/dist/lib/packaging/node.d.ts +17 -0
- package/dist/lib/packaging/node.d.ts.map +1 -0
- package/dist/lib/packaging/node.js +108 -0
- package/dist/lib/packaging/node.js.map +1 -0
- package/dist/lib/packaging/python.d.ts +17 -0
- package/dist/lib/packaging/python.d.ts.map +1 -0
- package/dist/lib/packaging/python.js +162 -0
- package/dist/lib/packaging/python.js.map +1 -0
- package/dist/lib/packaging/types/index.d.ts +2 -0
- package/dist/lib/packaging/types/index.d.ts.map +1 -0
- package/dist/lib/packaging/types/index.js +3 -0
- package/dist/lib/packaging/types/index.js.map +1 -0
- package/dist/lib/packaging/types/packaging.d.ts +57 -0
- package/dist/lib/packaging/types/packaging.d.ts.map +1 -0
- package/dist/lib/packaging/types/packaging.js +3 -0
- package/dist/lib/packaging/types/packaging.js.map +1 -0
- package/dist/lib/packaging/uv.d.ts +7 -0
- package/dist/lib/packaging/uv.d.ts.map +1 -0
- package/dist/lib/packaging/uv.js +40 -0
- package/dist/lib/packaging/uv.js.map +1 -0
- package/dist/lib/schemas/io/config-io.d.ts +106 -0
- package/dist/lib/schemas/io/config-io.d.ts.map +1 -0
- package/dist/lib/schemas/io/config-io.js +293 -0
- package/dist/lib/schemas/io/config-io.js.map +1 -0
- package/dist/lib/schemas/io/index.d.ts +3 -0
- package/dist/lib/schemas/io/index.d.ts.map +1 -0
- package/dist/lib/schemas/io/index.js +17 -0
- package/dist/lib/schemas/io/index.js.map +1 -0
- package/dist/lib/schemas/io/path-resolver.d.ts +112 -0
- package/dist/lib/schemas/io/path-resolver.d.ts.map +1 -0
- package/dist/lib/schemas/io/path-resolver.js +195 -0
- package/dist/lib/schemas/io/path-resolver.js.map +1 -0
- package/dist/lib/utils/aws-account.d.ts +7 -0
- package/dist/lib/utils/aws-account.d.ts.map +1 -0
- package/dist/lib/utils/aws-account.js +24 -0
- package/dist/lib/utils/aws-account.js.map +1 -0
- package/dist/lib/utils/credentials.d.ts +86 -0
- package/dist/lib/utils/credentials.d.ts.map +1 -0
- package/dist/lib/utils/credentials.js +153 -0
- package/dist/lib/utils/credentials.js.map +1 -0
- package/dist/lib/utils/env.d.ts +22 -0
- package/dist/lib/utils/env.d.ts.map +1 -0
- package/dist/lib/utils/env.js +65 -0
- package/dist/lib/utils/env.js.map +1 -0
- package/dist/lib/utils/index.d.ts +7 -0
- package/dist/lib/utils/index.d.ts.map +1 -0
- package/dist/lib/utils/index.js +23 -0
- package/dist/lib/utils/index.js.map +1 -0
- package/dist/lib/utils/platform.d.ts +63 -0
- package/dist/lib/utils/platform.d.ts.map +1 -0
- package/dist/lib/utils/platform.js +88 -0
- package/dist/lib/utils/platform.js.map +1 -0
- package/dist/lib/utils/subprocess.d.ts +29 -0
- package/dist/lib/utils/subprocess.d.ts.map +1 -0
- package/dist/lib/utils/subprocess.js +94 -0
- package/dist/lib/utils/subprocess.js.map +1 -0
- package/dist/lib/utils/zod.d.ts +14 -0
- package/dist/lib/utils/zod.d.ts.map +1 -0
- package/dist/lib/utils/zod.js +32 -0
- package/dist/lib/utils/zod.js.map +1 -0
- package/dist/schema/constants.d.ts +82 -0
- package/dist/schema/constants.d.ts.map +1 -0
- package/dist/schema/constants.js +117 -0
- package/dist/schema/constants.js.map +1 -0
- package/dist/schema/index.d.ts +4 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +21 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/schemas/agent-env.d.ts +75 -0
- package/dist/schema/schemas/agent-env.d.ts.map +1 -0
- package/dist/schema/schemas/agent-env.js +84 -0
- package/dist/schema/schemas/agent-env.js.map +1 -0
- package/dist/schema/schemas/agentcore-project.d.ts +88 -0
- package/dist/schema/schemas/agentcore-project.d.ts.map +1 -0
- package/dist/schema/schemas/agentcore-project.js +83 -0
- package/dist/schema/schemas/agentcore-project.js.map +1 -0
- package/dist/schema/schemas/aws-targets.d.ts +50 -0
- package/dist/schema/schemas/aws-targets.d.ts.map +1 -0
- package/dist/schema/schemas/aws-targets.js +49 -0
- package/dist/schema/schemas/aws-targets.js.map +1 -0
- package/dist/schema/schemas/deployed-state.d.ts +260 -0
- package/dist/schema/schemas/deployed-state.d.ts.map +1 -0
- package/dist/schema/schemas/deployed-state.js +100 -0
- package/dist/schema/schemas/deployed-state.js.map +1 -0
- package/dist/schema/schemas/index.d.ts +8 -0
- package/dist/schema/schemas/index.d.ts.map +1 -0
- package/dist/schema/schemas/index.js +25 -0
- package/dist/schema/schemas/index.js.map +1 -0
- package/dist/schema/schemas/mcp-defs.d.ts +52 -0
- package/dist/schema/schemas/mcp-defs.d.ts.map +1 -0
- package/dist/schema/schemas/mcp-defs.js +50 -0
- package/dist/schema/schemas/mcp-defs.js.map +1 -0
- package/dist/schema/schemas/mcp.d.ts +659 -0
- package/dist/schema/schemas/mcp.d.ts.map +1 -0
- package/dist/schema/schemas/mcp.js +283 -0
- package/dist/schema/schemas/mcp.js.map +1 -0
- package/dist/schema/schemas/primitives/index.d.ts +3 -0
- package/dist/schema/schemas/primitives/index.d.ts.map +1 -0
- package/dist/schema/schemas/primitives/index.js +9 -0
- package/dist/schema/schemas/primitives/index.js.map +1 -0
- package/dist/schema/schemas/primitives/memory.d.ts +42 -0
- package/dist/schema/schemas/primitives/memory.d.ts.map +1 -0
- package/dist/schema/schemas/primitives/memory.js +50 -0
- package/dist/schema/schemas/primitives/memory.js.map +1 -0
- package/dist/schema/schemas/zod-util.d.ts +10 -0
- package/dist/schema/schemas/zod-util.d.ts.map +1 -0
- package/dist/schema/schemas/zod-util.js +23 -0
- package/dist/schema/schemas/zod-util.js.map +1 -0
- package/dist/schema/types/index.d.ts +2 -0
- package/dist/schema/types/index.d.ts.map +1 -0
- package/dist/schema/types/index.js +18 -0
- package/dist/schema/types/index.js.map +1 -0
- package/dist/schema/types/path.d.ts +27 -0
- package/dist/schema/types/path.d.ts.map +1 -0
- package/dist/schema/types/path.js +13 -0
- package/dist/schema/types/path.js.map +1 -0
- package/package.json +111 -0
- package/scripts/bump-version.ts +442 -0
- package/scripts/check-old-cli.mjs +26 -0
- package/scripts/copy-assets.mjs +50 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectAwsAccount = detectAwsAccount;
|
|
4
|
+
const client_sts_1 = require("@aws-sdk/client-sts");
|
|
5
|
+
const credential_providers_1 = require("@aws-sdk/credential-providers");
|
|
6
|
+
/**
|
|
7
|
+
* Detect AWS account ID from current credentials using STS GetCallerIdentity.
|
|
8
|
+
* This call always succeeds if credentials are valid (cannot be denied by IAM).
|
|
9
|
+
* Returns null if credentials are not available or invalid.
|
|
10
|
+
*/
|
|
11
|
+
async function detectAwsAccount() {
|
|
12
|
+
try {
|
|
13
|
+
const client = new client_sts_1.STSClient({
|
|
14
|
+
credentials: (0, credential_providers_1.fromNodeProviderChain)(),
|
|
15
|
+
region: process.env.AWS_REGION ?? process.env.AWS_DEFAULT_REGION ?? 'us-east-1',
|
|
16
|
+
});
|
|
17
|
+
const response = await client.send(new client_sts_1.GetCallerIdentityCommand({}));
|
|
18
|
+
return response.Account ?? null;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=aws-account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aws-account.js","sourceRoot":"","sources":["../../../src/lib/utils/aws-account.ts"],"names":[],"mappings":";;AAQA,4CAWC;AAnBD,oDAA0E;AAC1E,wEAAsE;AAEtE;;;;GAIG;AACI,KAAK,UAAU,gBAAgB;IACpC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,sBAAS,CAAC;YAC3B,WAAW,EAAE,IAAA,4CAAqB,GAAE;YACpC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,WAAW;SAChF,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,qCAAwB,CAAC,EAAE,CAAC,CAAC,CAAC;QACrE,OAAO,QAAQ,CAAC,OAAO,IAAI,IAAI,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Secure credential management utilities.
|
|
3
|
+
* Prevents accidental exposure of sensitive data in logs, JSON serialization, and stack traces.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* A secure wrapper for credential data that prevents accidental exposure.
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* - Prevents JSON serialization of actual credential values
|
|
10
|
+
* - Returns redacted string in toString() for safe logging
|
|
11
|
+
* - Prevents iteration over credential keys in for...in loops
|
|
12
|
+
* - Immutable after creation
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const creds = new SecureCredentials({ OPENAI_API_KEY: 'sk-...' });
|
|
17
|
+
*
|
|
18
|
+
* // Safe to log - won't expose values
|
|
19
|
+
* console.log(creds); // "[SecureCredentials: 1 credential(s)]"
|
|
20
|
+
* console.log(JSON.stringify(creds)); // '{"_redacted":"[CREDENTIALS REDACTED]","count":1}'
|
|
21
|
+
*
|
|
22
|
+
* // Access values explicitly when needed
|
|
23
|
+
* const apiKey = creds.get('OPENAI_API_KEY');
|
|
24
|
+
*
|
|
25
|
+
* // Check if credential exists
|
|
26
|
+
* if (creds.has('OPENAI_API_KEY')) { ... }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare class SecureCredentials {
|
|
30
|
+
private readonly credentials;
|
|
31
|
+
constructor(credentials?: Record<string, string>);
|
|
32
|
+
/**
|
|
33
|
+
* Get a credential value by key.
|
|
34
|
+
* Returns undefined if the key doesn't exist.
|
|
35
|
+
*/
|
|
36
|
+
get(key: string): string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Check if a credential exists.
|
|
39
|
+
*/
|
|
40
|
+
has(key: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Get the number of stored credentials.
|
|
43
|
+
*/
|
|
44
|
+
get size(): number;
|
|
45
|
+
/**
|
|
46
|
+
* Check if any credentials are stored.
|
|
47
|
+
*/
|
|
48
|
+
isEmpty(): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Get all credential keys (not values).
|
|
51
|
+
* Safe to log as it only returns key names.
|
|
52
|
+
*/
|
|
53
|
+
keys(): string[];
|
|
54
|
+
/**
|
|
55
|
+
* Merge with another SecureCredentials instance or plain object.
|
|
56
|
+
* Returns a new SecureCredentials instance (immutable).
|
|
57
|
+
* The provided credentials take precedence over existing ones.
|
|
58
|
+
*/
|
|
59
|
+
merge(other: SecureCredentials | Record<string, string>): SecureCredentials;
|
|
60
|
+
/**
|
|
61
|
+
* Convert to plain object for internal use only.
|
|
62
|
+
* WARNING: This exposes credential values. Use only when passing to APIs that require plain objects.
|
|
63
|
+
*/
|
|
64
|
+
toPlainObject(): Record<string, string>;
|
|
65
|
+
/**
|
|
66
|
+
* Prevent JSON serialization from exposing credential values.
|
|
67
|
+
*/
|
|
68
|
+
toJSON(): {
|
|
69
|
+
_redacted: string;
|
|
70
|
+
count: number;
|
|
71
|
+
keys: string[];
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Safe string representation for logging.
|
|
75
|
+
*/
|
|
76
|
+
toString(): string;
|
|
77
|
+
/**
|
|
78
|
+
* Static factory to create from environment variables.
|
|
79
|
+
*/
|
|
80
|
+
static fromEnvVars(envVars: Record<string, string>): SecureCredentials;
|
|
81
|
+
/**
|
|
82
|
+
* Static factory to create an empty SecureCredentials instance.
|
|
83
|
+
*/
|
|
84
|
+
static empty(): SecureCredentials;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/credentials.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAsB;gBAEtC,WAAW,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;IAMpD;;;OAGG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIpC;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,OAAO,IAAI,OAAO;IAIlB;;;OAGG;IACH,IAAI,IAAI,MAAM,EAAE;IAIhB;;;;OAIG;IACH,KAAK,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,iBAAiB;IA8B3E;;;OAGG;IACH,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAWvC;;OAEG;IACH,MAAM,IAAI;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE;IAQ9D;;OAEG;IACH,QAAQ,IAAI,MAAM;IAWlB;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,iBAAiB;IAItE;;OAEG;IACH,MAAM,CAAC,KAAK,IAAI,iBAAiB;CAGlC"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Secure credential management utilities.
|
|
4
|
+
* Prevents accidental exposure of sensitive data in logs, JSON serialization, and stack traces.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.SecureCredentials = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* A secure wrapper for credential data that prevents accidental exposure.
|
|
10
|
+
*
|
|
11
|
+
* Features:
|
|
12
|
+
* - Prevents JSON serialization of actual credential values
|
|
13
|
+
* - Returns redacted string in toString() for safe logging
|
|
14
|
+
* - Prevents iteration over credential keys in for...in loops
|
|
15
|
+
* - Immutable after creation
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const creds = new SecureCredentials({ OPENAI_API_KEY: 'sk-...' });
|
|
20
|
+
*
|
|
21
|
+
* // Safe to log - won't expose values
|
|
22
|
+
* console.log(creds); // "[SecureCredentials: 1 credential(s)]"
|
|
23
|
+
* console.log(JSON.stringify(creds)); // '{"_redacted":"[CREDENTIALS REDACTED]","count":1}'
|
|
24
|
+
*
|
|
25
|
+
* // Access values explicitly when needed
|
|
26
|
+
* const apiKey = creds.get('OPENAI_API_KEY');
|
|
27
|
+
*
|
|
28
|
+
* // Check if credential exists
|
|
29
|
+
* if (creds.has('OPENAI_API_KEY')) { ... }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
class SecureCredentials {
|
|
33
|
+
credentials;
|
|
34
|
+
constructor(credentials = {}) {
|
|
35
|
+
this.credentials = new Map(Object.entries(credentials));
|
|
36
|
+
// Freeze to prevent modification
|
|
37
|
+
Object.freeze(this);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get a credential value by key.
|
|
41
|
+
* Returns undefined if the key doesn't exist.
|
|
42
|
+
*/
|
|
43
|
+
get(key) {
|
|
44
|
+
return this.credentials.get(key);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Check if a credential exists.
|
|
48
|
+
*/
|
|
49
|
+
has(key) {
|
|
50
|
+
return this.credentials.has(key);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get the number of stored credentials.
|
|
54
|
+
*/
|
|
55
|
+
get size() {
|
|
56
|
+
return this.credentials.size;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Check if any credentials are stored.
|
|
60
|
+
*/
|
|
61
|
+
isEmpty() {
|
|
62
|
+
return this.credentials.size === 0;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Get all credential keys (not values).
|
|
66
|
+
* Safe to log as it only returns key names.
|
|
67
|
+
*/
|
|
68
|
+
keys() {
|
|
69
|
+
return Array.from(this.credentials.keys());
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Merge with another SecureCredentials instance or plain object.
|
|
73
|
+
* Returns a new SecureCredentials instance (immutable).
|
|
74
|
+
* The provided credentials take precedence over existing ones.
|
|
75
|
+
*/
|
|
76
|
+
merge(other) {
|
|
77
|
+
const merged = {};
|
|
78
|
+
// Copy existing credentials
|
|
79
|
+
for (const key of this.credentials.keys()) {
|
|
80
|
+
const value = this.credentials.get(key);
|
|
81
|
+
if (value !== undefined) {
|
|
82
|
+
merged[key] = value;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Overlay new credentials
|
|
86
|
+
if (other instanceof SecureCredentials) {
|
|
87
|
+
for (const key of other.keys()) {
|
|
88
|
+
const value = other.get(key);
|
|
89
|
+
if (value !== undefined) {
|
|
90
|
+
merged[key] = value;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
for (const [key, value] of Object.entries(other)) {
|
|
96
|
+
if (value !== undefined) {
|
|
97
|
+
merged[key] = value;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return new SecureCredentials(merged);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Convert to plain object for internal use only.
|
|
105
|
+
* WARNING: This exposes credential values. Use only when passing to APIs that require plain objects.
|
|
106
|
+
*/
|
|
107
|
+
toPlainObject() {
|
|
108
|
+
const result = {};
|
|
109
|
+
for (const key of this.credentials.keys()) {
|
|
110
|
+
const value = this.credentials.get(key);
|
|
111
|
+
if (value !== undefined) {
|
|
112
|
+
result[key] = value;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Prevent JSON serialization from exposing credential values.
|
|
119
|
+
*/
|
|
120
|
+
toJSON() {
|
|
121
|
+
return {
|
|
122
|
+
_redacted: '[CREDENTIALS REDACTED]',
|
|
123
|
+
count: this.credentials.size,
|
|
124
|
+
keys: this.keys(),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Safe string representation for logging.
|
|
129
|
+
*/
|
|
130
|
+
toString() {
|
|
131
|
+
return `[SecureCredentials: ${this.credentials.size} credential(s)]`;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Custom inspect for Node.js console.log.
|
|
135
|
+
*/
|
|
136
|
+
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
137
|
+
return this.toString();
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Static factory to create from environment variables.
|
|
141
|
+
*/
|
|
142
|
+
static fromEnvVars(envVars) {
|
|
143
|
+
return new SecureCredentials(envVars);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Static factory to create an empty SecureCredentials instance.
|
|
147
|
+
*/
|
|
148
|
+
static empty() {
|
|
149
|
+
return new SecureCredentials();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
exports.SecureCredentials = SecureCredentials;
|
|
153
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../../src/lib/utils/credentials.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAa,iBAAiB;IACX,WAAW,CAAsB;IAElD,YAAY,cAAsC,EAAE;QAClD,IAAI,CAAC,WAAW,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;QACxD,iCAAiC;QACjC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,CAAC;IACrC,CAAC;IAED;;;OAGG;IACH,IAAI;QACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,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,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACtB,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO;YACL,SAAS,EAAE,wBAAwB;YACnC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;YAC5B,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;SAClB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,uBAAuB,IAAI,CAAC,WAAW,CAAC,IAAI,iBAAiB,CAAC;IACvE,CAAC;IAED;;OAEG;IACH,CAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QACxC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,OAA+B;QAChD,OAAO,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAK;QACV,OAAO,IAAI,iBAAiB,EAAE,CAAC;IACjC,CAAC;CACF;AAtID,8CAsIC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the path to agentcore/.env.local.
|
|
3
|
+
* @param configRoot - Optional config root, defaults to finding it automatically
|
|
4
|
+
*/
|
|
5
|
+
export declare function getEnvPath(configRoot?: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Read agentcore/.env.local.
|
|
8
|
+
*/
|
|
9
|
+
export declare function readEnvFile(configRoot?: string): Promise<Record<string, string>>;
|
|
10
|
+
/**
|
|
11
|
+
* Get a single value from agentcore/.env.local.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getEnvVar(key: string, configRoot?: string): Promise<string | undefined>;
|
|
14
|
+
/**
|
|
15
|
+
* Write to agentcore/.env.local. Merges with existing values by default.
|
|
16
|
+
*/
|
|
17
|
+
export declare function writeEnvFile(updates: Record<string, string>, configRoot?: string, merge?: boolean): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Set a single value in agentcore/.env.local.
|
|
20
|
+
*/
|
|
21
|
+
export declare function setEnvVar(key: string, value: string, configRoot?: string): Promise<void>;
|
|
22
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/env.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,wBAAgB,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAItD;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAItF;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAE7F;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,KAAK,UAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBpH;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE9F"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEnvPath = getEnvPath;
|
|
4
|
+
exports.readEnvFile = readEnvFile;
|
|
5
|
+
exports.getEnvVar = getEnvVar;
|
|
6
|
+
exports.writeEnvFile = writeEnvFile;
|
|
7
|
+
exports.setEnvVar = setEnvVar;
|
|
8
|
+
const constants_1 = require("../constants");
|
|
9
|
+
const path_resolver_1 = require("../schemas/io/path-resolver");
|
|
10
|
+
const dotenv_1 = require("dotenv");
|
|
11
|
+
const fs_1 = require("fs");
|
|
12
|
+
const promises_1 = require("fs/promises");
|
|
13
|
+
const path_1 = require("path");
|
|
14
|
+
/**
|
|
15
|
+
* Get the path to agentcore/.env.local.
|
|
16
|
+
* @param configRoot - Optional config root, defaults to finding it automatically
|
|
17
|
+
*/
|
|
18
|
+
function getEnvPath(configRoot) {
|
|
19
|
+
const root = configRoot ?? (0, path_resolver_1.findConfigRoot)();
|
|
20
|
+
if (!root)
|
|
21
|
+
throw new Error('Could not find agentcore directory');
|
|
22
|
+
return (0, path_1.join)(root, constants_1.ENV_FILE);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Read agentcore/.env.local.
|
|
26
|
+
*/
|
|
27
|
+
async function readEnvFile(configRoot) {
|
|
28
|
+
const path = getEnvPath(configRoot);
|
|
29
|
+
if (!(0, fs_1.existsSync)(path))
|
|
30
|
+
return {};
|
|
31
|
+
return (0, dotenv_1.parse)(await (0, promises_1.readFile)(path, 'utf-8'));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get a single value from agentcore/.env.local.
|
|
35
|
+
*/
|
|
36
|
+
async function getEnvVar(key, configRoot) {
|
|
37
|
+
return (await readEnvFile(configRoot))[key];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Write to agentcore/.env.local. Merges with existing values by default.
|
|
41
|
+
*/
|
|
42
|
+
async function writeEnvFile(updates, configRoot, merge = true) {
|
|
43
|
+
const path = getEnvPath(configRoot);
|
|
44
|
+
const current = merge ? await readEnvFile(configRoot) : {};
|
|
45
|
+
const env = { ...current, ...updates };
|
|
46
|
+
const content = Object.entries(env)
|
|
47
|
+
.map(([k, v]) => {
|
|
48
|
+
if (v === undefined || v === null)
|
|
49
|
+
return '';
|
|
50
|
+
if (!/^[a-z_][a-z0-9_]*$/i.test(k))
|
|
51
|
+
throw new Error(`Invalid env key: ${k}`);
|
|
52
|
+
const val = String(v).replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n').replace(/\r/g, '\\r');
|
|
53
|
+
return `${k}="${val}"`;
|
|
54
|
+
})
|
|
55
|
+
.filter(Boolean)
|
|
56
|
+
.join('\n') + '\n';
|
|
57
|
+
await (0, promises_1.writeFile)(path, content);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Set a single value in agentcore/.env.local.
|
|
61
|
+
*/
|
|
62
|
+
async function setEnvVar(key, value, configRoot) {
|
|
63
|
+
await writeEnvFile({ [key]: value }, configRoot);
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../../src/lib/utils/env.ts"],"names":[],"mappings":";;AAWA,gCAIC;AAKD,kCAIC;AAKD,8BAEC;AAKD,oCAmBC;AAKD,8BAEC;AA9DD,4CAAwC;AACxC,+DAA6D;AAC7D,mCAA+B;AAC/B,2BAAgC;AAChC,0CAAkD;AAClD,+BAA4B;AAE5B;;;GAGG;AACH,SAAgB,UAAU,CAAC,UAAmB;IAC5C,MAAM,IAAI,GAAG,UAAU,IAAI,IAAA,8BAAc,GAAE,CAAC;IAC5C,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACjE,OAAO,IAAA,WAAI,EAAC,IAAI,EAAE,oBAAQ,CAAC,CAAC;AAC9B,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,WAAW,CAAC,UAAmB;IACnD,MAAM,IAAI,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;IACpC,IAAI,CAAC,IAAA,eAAU,EAAC,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IACjC,OAAO,IAAA,cAAK,EAAC,MAAM,IAAA,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vB,MAAM,IAAA,oBAAS,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACjC,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,SAAS,CAAC,GAAW,EAAE,KAAa,EAAE,UAAmB;IAC7E,MAAM,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,UAAU,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { detectAwsAccount } from './aws-account';
|
|
2
|
+
export { SecureCredentials } from './credentials';
|
|
3
|
+
export { getEnvPath, readEnvFile, writeEnvFile, getEnvVar, setEnvVar } from './env';
|
|
4
|
+
export { isWindows } from './platform';
|
|
5
|
+
export { runSubprocess, checkSubprocess, runSubprocessCapture, type SubprocessOptions, type SubprocessResult, } from './subprocess';
|
|
6
|
+
export { validateAgentSchema, validateProjectSchema } from './zod';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EACL,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateProjectSchema = exports.validateAgentSchema = exports.runSubprocessCapture = exports.checkSubprocess = exports.runSubprocess = exports.isWindows = exports.setEnvVar = exports.getEnvVar = exports.writeEnvFile = exports.readEnvFile = exports.getEnvPath = exports.SecureCredentials = exports.detectAwsAccount = void 0;
|
|
4
|
+
var aws_account_1 = require("./aws-account");
|
|
5
|
+
Object.defineProperty(exports, "detectAwsAccount", { enumerable: true, get: function () { return aws_account_1.detectAwsAccount; } });
|
|
6
|
+
var credentials_1 = require("./credentials");
|
|
7
|
+
Object.defineProperty(exports, "SecureCredentials", { enumerable: true, get: function () { return credentials_1.SecureCredentials; } });
|
|
8
|
+
var env_1 = require("./env");
|
|
9
|
+
Object.defineProperty(exports, "getEnvPath", { enumerable: true, get: function () { return env_1.getEnvPath; } });
|
|
10
|
+
Object.defineProperty(exports, "readEnvFile", { enumerable: true, get: function () { return env_1.readEnvFile; } });
|
|
11
|
+
Object.defineProperty(exports, "writeEnvFile", { enumerable: true, get: function () { return env_1.writeEnvFile; } });
|
|
12
|
+
Object.defineProperty(exports, "getEnvVar", { enumerable: true, get: function () { return env_1.getEnvVar; } });
|
|
13
|
+
Object.defineProperty(exports, "setEnvVar", { enumerable: true, get: function () { return env_1.setEnvVar; } });
|
|
14
|
+
var platform_1 = require("./platform");
|
|
15
|
+
Object.defineProperty(exports, "isWindows", { enumerable: true, get: function () { return platform_1.isWindows; } });
|
|
16
|
+
var subprocess_1 = require("./subprocess");
|
|
17
|
+
Object.defineProperty(exports, "runSubprocess", { enumerable: true, get: function () { return subprocess_1.runSubprocess; } });
|
|
18
|
+
Object.defineProperty(exports, "checkSubprocess", { enumerable: true, get: function () { return subprocess_1.checkSubprocess; } });
|
|
19
|
+
Object.defineProperty(exports, "runSubprocessCapture", { enumerable: true, get: function () { return subprocess_1.runSubprocessCapture; } });
|
|
20
|
+
var zod_1 = require("./zod");
|
|
21
|
+
Object.defineProperty(exports, "validateAgentSchema", { enumerable: true, get: function () { return zod_1.validateAgentSchema; } });
|
|
22
|
+
Object.defineProperty(exports, "validateProjectSchema", { enumerable: true, get: function () { return zod_1.validateProjectSchema; } });
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/utils/index.ts"],"names":[],"mappings":";;;AAAA,6CAAiD;AAAxC,+GAAA,gBAAgB,OAAA;AACzB,6CAAkD;AAAzC,gHAAA,iBAAiB,OAAA;AAC1B,6BAAoF;AAA3E,iGAAA,UAAU,OAAA;AAAE,kGAAA,WAAW,OAAA;AAAE,mGAAA,YAAY,OAAA;AAAE,gGAAA,SAAS,OAAA;AAAE,gGAAA,SAAS,OAAA;AACpE,uCAAuC;AAA9B,qGAAA,SAAS,OAAA;AAClB,2CAMsB;AALpB,2GAAA,aAAa,OAAA;AACb,6GAAA,eAAe,OAAA;AACf,kHAAA,oBAAoB,OAAA;AAItB,6BAAmE;AAA1D,0GAAA,mBAAmB,OAAA;AAAE,4GAAA,qBAAqB,OAAA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform detection utilities and cross-platform path helpers.
|
|
3
|
+
*
|
|
4
|
+
* This module provides utilities to handle platform-specific differences
|
|
5
|
+
* between Windows and Unix-like systems (Linux, macOS).
|
|
6
|
+
*
|
|
7
|
+
* Key differences handled:
|
|
8
|
+
* - Python venv structure: bin/ (Unix) vs Scripts/ (Windows)
|
|
9
|
+
* - Executable extensions: none (Unix) vs .exe, .cmd, .bat (Windows)
|
|
10
|
+
* - Shell commands: sh/bash (Unix) vs cmd/powershell (Windows)
|
|
11
|
+
*/
|
|
12
|
+
export declare const isWindows: boolean;
|
|
13
|
+
export declare const isMacOS: boolean;
|
|
14
|
+
export declare const isLinux: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Get the path to an executable in a Python virtual environment.
|
|
17
|
+
*
|
|
18
|
+
* Python virtual environments have different structures on different platforms:
|
|
19
|
+
* - Unix (Linux/macOS): .venv/bin/python, .venv/bin/uvicorn
|
|
20
|
+
* - Windows: .venv\Scripts\python.exe, .venv\Scripts\uvicorn.exe
|
|
21
|
+
*
|
|
22
|
+
* @param venvPath - Path to the virtual environment directory (e.g., '.venv')
|
|
23
|
+
* @param executable - Name of the executable without extension (e.g., 'python', 'uvicorn')
|
|
24
|
+
* @returns Full path to the executable with correct directory and extension
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* // On Unix: /path/to/project/.venv/bin/uvicorn
|
|
29
|
+
* // On Windows: C:\path\to\project\.venv\Scripts\uvicorn.exe
|
|
30
|
+
* const uvicornPath = getVenvExecutable('.venv', 'uvicorn');
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function getVenvExecutable(venvPath: string, executable: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Get the appropriate shell command for the current platform.
|
|
36
|
+
*
|
|
37
|
+
* @returns The default shell command ('cmd' on Windows, 'sh' on Unix)
|
|
38
|
+
*/
|
|
39
|
+
export declare function getShellCommand(): string;
|
|
40
|
+
/**
|
|
41
|
+
* Get the appropriate shell arguments for executing a command.
|
|
42
|
+
*
|
|
43
|
+
* @param command - The command to execute
|
|
44
|
+
* @returns Array of arguments to pass to the shell
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* // On Unix: ['-c', 'echo hello']
|
|
49
|
+
* // On Windows: ['/c', 'echo hello']
|
|
50
|
+
* const args = getShellArgs('echo hello');
|
|
51
|
+
* spawn(getShellCommand(), args);
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function getShellArgs(command: string): string[];
|
|
55
|
+
/**
|
|
56
|
+
* Normalize a command for cross-platform execution.
|
|
57
|
+
* Adds .exe extension on Windows if needed.
|
|
58
|
+
*
|
|
59
|
+
* @param command - The command name
|
|
60
|
+
* @returns The command with appropriate extension
|
|
61
|
+
*/
|
|
62
|
+
export declare function normalizeCommand(command: string): string;
|
|
63
|
+
//# sourceMappingURL=platform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/platform.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,SAAS,SAA+B,CAAC;AACtD,eAAO,MAAM,OAAO,SAAgC,CAAC;AACrD,eAAO,MAAM,OAAO,SAA+B,CAAC;AAEpD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAI9E;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAEtD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CASxD"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isLinux = exports.isMacOS = exports.isWindows = void 0;
|
|
4
|
+
exports.getVenvExecutable = getVenvExecutable;
|
|
5
|
+
exports.getShellCommand = getShellCommand;
|
|
6
|
+
exports.getShellArgs = getShellArgs;
|
|
7
|
+
exports.normalizeCommand = normalizeCommand;
|
|
8
|
+
const node_path_1 = require("node:path");
|
|
9
|
+
/**
|
|
10
|
+
* Platform detection utilities and cross-platform path helpers.
|
|
11
|
+
*
|
|
12
|
+
* This module provides utilities to handle platform-specific differences
|
|
13
|
+
* between Windows and Unix-like systems (Linux, macOS).
|
|
14
|
+
*
|
|
15
|
+
* Key differences handled:
|
|
16
|
+
* - Python venv structure: bin/ (Unix) vs Scripts/ (Windows)
|
|
17
|
+
* - Executable extensions: none (Unix) vs .exe, .cmd, .bat (Windows)
|
|
18
|
+
* - Shell commands: sh/bash (Unix) vs cmd/powershell (Windows)
|
|
19
|
+
*/
|
|
20
|
+
exports.isWindows = process.platform === 'win32';
|
|
21
|
+
exports.isMacOS = process.platform === 'darwin';
|
|
22
|
+
exports.isLinux = process.platform === 'linux';
|
|
23
|
+
/**
|
|
24
|
+
* Get the path to an executable in a Python virtual environment.
|
|
25
|
+
*
|
|
26
|
+
* Python virtual environments have different structures on different platforms:
|
|
27
|
+
* - Unix (Linux/macOS): .venv/bin/python, .venv/bin/uvicorn
|
|
28
|
+
* - Windows: .venv\Scripts\python.exe, .venv\Scripts\uvicorn.exe
|
|
29
|
+
*
|
|
30
|
+
* @param venvPath - Path to the virtual environment directory (e.g., '.venv')
|
|
31
|
+
* @param executable - Name of the executable without extension (e.g., 'python', 'uvicorn')
|
|
32
|
+
* @returns Full path to the executable with correct directory and extension
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* // On Unix: /path/to/project/.venv/bin/uvicorn
|
|
37
|
+
* // On Windows: C:\path\to\project\.venv\Scripts\uvicorn.exe
|
|
38
|
+
* const uvicornPath = getVenvExecutable('.venv', 'uvicorn');
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
function getVenvExecutable(venvPath, executable) {
|
|
42
|
+
const binDir = exports.isWindows ? 'Scripts' : 'bin';
|
|
43
|
+
const ext = exports.isWindows ? '.exe' : '';
|
|
44
|
+
return (0, node_path_1.join)(venvPath, binDir, executable + ext);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get the appropriate shell command for the current platform.
|
|
48
|
+
*
|
|
49
|
+
* @returns The default shell command ('cmd' on Windows, 'sh' on Unix)
|
|
50
|
+
*/
|
|
51
|
+
function getShellCommand() {
|
|
52
|
+
return exports.isWindows ? 'cmd' : (process.env.SHELL ?? '/bin/sh');
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get the appropriate shell arguments for executing a command.
|
|
56
|
+
*
|
|
57
|
+
* @param command - The command to execute
|
|
58
|
+
* @returns Array of arguments to pass to the shell
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* // On Unix: ['-c', 'echo hello']
|
|
63
|
+
* // On Windows: ['/c', 'echo hello']
|
|
64
|
+
* const args = getShellArgs('echo hello');
|
|
65
|
+
* spawn(getShellCommand(), args);
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
function getShellArgs(command) {
|
|
69
|
+
return exports.isWindows ? ['/c', command] : ['-c', command];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Normalize a command for cross-platform execution.
|
|
73
|
+
* Adds .exe extension on Windows if needed.
|
|
74
|
+
*
|
|
75
|
+
* @param command - The command name
|
|
76
|
+
* @returns The command with appropriate extension
|
|
77
|
+
*/
|
|
78
|
+
function normalizeCommand(command) {
|
|
79
|
+
if (exports.isWindows && !command.endsWith('.exe') && !command.endsWith('.cmd') && !command.endsWith('.bat')) {
|
|
80
|
+
// Check if it's a known command that needs .exe
|
|
81
|
+
const exeCommands = ['python', 'node', 'npm', 'git', 'uvicorn', 'pip'];
|
|
82
|
+
if (exeCommands.some(cmd => command.endsWith(cmd))) {
|
|
83
|
+
return command + '.exe';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return command;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../../../src/lib/utils/platform.ts"],"names":[],"mappings":";;;AAoCA,8CAIC;AAOD,0CAEC;AAgBD,oCAEC;AASD,4CASC;AArFD,yCAAiC;AAEjC;;;;;;;;;;GAUG;AAEU,QAAA,SAAS,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC;AACzC,QAAA,OAAO,GAAG,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC;AACxC,QAAA,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D,OAAO,OAAO,GAAG,MAAM,CAAC;QAC1B,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { StdioOptions } from 'child_process';
|
|
2
|
+
/**
|
|
3
|
+
* Subprocess utilities for AgentCore.
|
|
4
|
+
*
|
|
5
|
+
* IMPORTANT: Async functions (runSubprocess, checkSubprocess, runSubprocessCapture)
|
|
6
|
+
* are safe for TUI contexts and are exported from lib.
|
|
7
|
+
*
|
|
8
|
+
* Sync functions (runSubprocessCaptureSync, checkSubprocessSync) block the event loop
|
|
9
|
+
* and are ONLY safe in CDK bundling contexts (which run in a subprocess). They are
|
|
10
|
+
* intentionally NOT exported from the public API to prevent accidental UI freezes.
|
|
11
|
+
*/
|
|
12
|
+
export interface SubprocessOptions {
|
|
13
|
+
cwd?: string;
|
|
14
|
+
env?: NodeJS.ProcessEnv;
|
|
15
|
+
stdio?: StdioOptions;
|
|
16
|
+
shell?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function runSubprocess(command: string, args: string[], options?: SubprocessOptions): Promise<void>;
|
|
19
|
+
export declare function checkSubprocess(command: string, args: string[], options?: SubprocessOptions): Promise<boolean>;
|
|
20
|
+
export interface SubprocessResult {
|
|
21
|
+
stdout: string;
|
|
22
|
+
stderr: string;
|
|
23
|
+
code: number | null;
|
|
24
|
+
signal: NodeJS.Signals | null;
|
|
25
|
+
}
|
|
26
|
+
export declare function runSubprocessCapture(command: string, args: string[], options?: SubprocessOptions): Promise<SubprocessResult>;
|
|
27
|
+
export declare function runSubprocessCaptureSync(command: string, args: string[], options?: SubprocessOptions): SubprocessResult;
|
|
28
|
+
export declare function checkSubprocessSync(command: string, args: string[], options?: SubprocessOptions): boolean;
|
|
29
|
+
//# sourceMappingURL=subprocess.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subprocess.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/subproc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